예제 #1
0
void MarginWidget::setNewBleeds(MarginStruct& b)
{
	disconnect(BleedLeft, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds()));
	disconnect(BleedRight, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds()));
	disconnect(BleedTop, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds()));
	disconnect(BleedBottom, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds()));
	BleedTop->setValue(b.top() * m_unitRatio);
	BleedBottom->setValue(b.bottom() * m_unitRatio);
	BleedLeft->setValue(b.left() * m_unitRatio);
	BleedRight->setValue(b.right() * m_unitRatio);
	connect(BleedLeft, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds()));
	connect(BleedRight, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds()));
	connect(BleedTop, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds()));
	connect(BleedBottom, SIGNAL(valueChanged(double)), this, SLOT(changeBleeds()));
}
MarginStruct PresetLayout::getMargins(int index, double pageWidth, double pageHeight, double leftMargin)
{
	MarginStruct ret;

	updateMargins = true;

	switch (index)
	{
		case PresetLayout::magazine:
			ret.set(leftMargin, leftMargin, leftMargin, leftMargin);
			break;
		case PresetLayout::gutenberg:
			{
				double ratio = pageHeight / pageWidth;
				ret.setLeft(leftMargin);
				ret.setTop(leftMargin * ratio);
				ret.setRight(leftMargin * 2.0);
				ret.setBottom(ret.right() * ratio);
			}
			break;
		case PresetLayout::fibonacci:
			ret.setLeft(leftMargin);
			ret.setTop(leftMargin / 2.0 * 3.0);
			ret.setRight(leftMargin / 2.0 * 5.0);
			ret.setBottom(leftMargin / 2.0 * 8.0);
			break;
		case PresetLayout::goldencut:
			ret.setLeft(leftMargin);
			ret.setTop(leftMargin / 2.0 * 3.4);
			ret.setRight(leftMargin / 2.0 * 4.8);
			ret.setBottom(leftMargin / 2.0 * 6.8);
			break;
		case PresetLayout::nineparts:
			ret.setLeft(pageWidth / 9.0);
			ret.setTop(pageHeight / 9.0);
			ret.setRight(pageWidth / 9.0 * 2.0);
			ret.setBottom(pageHeight / 9.0 * 2.0);
			break;
		default:
			updateMargins = false;
			ret.set(-1.0, -1.0, -1.0, -1.0);
	}
	return ret;
}
예제 #3
0
void MarginWidget::setPreset()
{
	disconnect(topR, SIGNAL(valueChanged(double)), this, SLOT(setTop()));
	disconnect(bottomR, SIGNAL(valueChanged(double)), this, SLOT(setBottom()));
	disconnect(leftR, SIGNAL(valueChanged(double)), this, SLOT(setLeft()));
	disconnect(rightR, SIGNAL(valueChanged(double)), this, SLOT(setRight()));
	if (savedPresetItem==PresetLayout::none)
		savedMargins=marginData;
	int item = presetCombo->currentIndex();

	MarginStruct marg = presetCombo->getMargins(item, pageWidth, pageHeight, leftR->value() / m_unitRatio);
	presetCombo->setEnabled(facingPages);

	bool restoringValues=false;
	if (item==PresetLayout::none && savedPresetItem!=PresetLayout::none)
	{
		marg=savedMargins;
		restoringValues=true;
	}
	if (restoringValues || (presetCombo->needUpdate() && facingPages))
	{
		marginData.set(qMax(0.0, marg.top()), qMax(0.0, marg.left()), qMax(0.0, marg.bottom()), qMax(0.0, marg.right()));
		updateMarginSpinValues();
		
		bottomR->setMaximum(qMax(0.0, pageHeight * m_unitRatio - topR->value()));
		topR->setMaximum(qMax(0.0, pageHeight * m_unitRatio - bottomR->value()));
		rightR->setMaximum(qMax(0.0, pageWidth * m_unitRatio - leftR->value()));
		leftR->setMaximum(qMax(0.0, pageWidth * m_unitRatio - rightR->value()));
		rightR->setEnabled(restoringValues);
		topR->setEnabled(restoringValues);
		bottomR->setEnabled(restoringValues);
	}
	else
	{
		rightR->setEnabled(true);
		topR->setEnabled(true);
		bottomR->setEnabled(true);
	}
	if (pageType == 1)
		rightR->setEnabled(false);
	leftR->setEnabled(item != PresetLayout::nineparts);
	if (item!=PresetLayout::none)
		linkMargins->setChecked(false);
	linkMargins->setEnabled(item==PresetLayout::none || !presetCombo->isEnabled());
	connect(topR, SIGNAL(valueChanged(double)), this, SLOT(setTop()));
	connect(bottomR, SIGNAL(valueChanged(double)), this, SLOT(setBottom()));
	connect(leftR, SIGNAL(valueChanged(double)), this, SLOT(setLeft()));
	connect(rightR, SIGNAL(valueChanged(double)), this, SLOT(setRight()));
	savedPresetItem=item;
}
예제 #4
0
void NewMarginWidget::setPreset()
{
	if ((m_flags & ShowPreset) == 0)
		return;
	leftMarginSpinBox->blockSignals(true);
	rightMarginSpinBox->blockSignals(true);
	topMarginSpinBox->blockSignals(true);
	bottomMarginSpinBox->blockSignals(true);
	if (savedPresetItem==PresetLayout::none)
		savedMarginData=marginData;
	int item = presetLayoutComboBox->currentIndex();

	MarginStruct marg = presetLayoutComboBox->getMargins(item, pageWidth, pageHeight, leftMarginSpinBox->value() / m_unitRatio);
	facingPages ? presetLayoutComboBox->setEnabled(true) : presetLayoutComboBox->setEnabled(false);
	bool restoringValues=false;
	if (item==PresetLayout::none && savedPresetItem!=PresetLayout::none)
	{
		marg=savedMarginData;
		restoringValues=true;
	}
	if (restoringValues || (presetLayoutComboBox->needUpdate() && facingPages))
	{
		marginData.set(qMax(0.0, marg.top()), qMax(0.0, marg.left()), qMax(0.0, marg.bottom()), qMax(0.0, marg.right()));
		updateMarginSpinValues();

		bottomMarginSpinBox->setMaximum(qMax(0.0, pageHeight * m_unitRatio - topMarginSpinBox->value()));
		topMarginSpinBox->setMaximum(qMax(0.0, pageHeight * m_unitRatio - bottomMarginSpinBox->value()));
		rightMarginSpinBox->setMaximum(qMax(0.0, pageWidth * m_unitRatio - leftMarginSpinBox->value()));
		leftMarginSpinBox->setMaximum(qMax(0.0, pageWidth * m_unitRatio - rightMarginSpinBox->value()));
		rightMarginSpinBox->setEnabled(restoringValues);
		topMarginSpinBox->setEnabled(restoringValues);
		bottomMarginSpinBox->setEnabled(restoringValues);
	}
	else
	{
		rightMarginSpinBox->setEnabled(true);
		topMarginSpinBox->setEnabled(true);
		bottomMarginSpinBox->setEnabled(true);
	}
	if (pageType == 1)
		rightMarginSpinBox->setEnabled(false);
	leftMarginSpinBox->setEnabled(item != PresetLayout::nineparts);
	if (item!=PresetLayout::none)
		marginLinkButton->setChecked(false);
	marginLinkButton->setEnabled(item==PresetLayout::none || !presetLayoutComboBox->isEnabled());
	leftMarginSpinBox->blockSignals(false);
	rightMarginSpinBox->blockSignals(false);
	topMarginSpinBox->blockSignals(false);
	bottomMarginSpinBox->blockSignals(false);
	savedPresetItem=item;
}