Fix bugs. ref #657.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2017-10-11 11:34:22 +03:00
parent 8cbf143592
commit 38815727bb
4 changed files with 364 additions and 299 deletions

View File

@ -157,7 +157,6 @@ DialogSaveLayout::DialogSaveLayout(int count, Draw mode, const QString &fileName
connect(ui->toolButtonPortrait, &QToolButton::toggled, this, &DialogSaveLayout::WriteSettings); connect(ui->toolButtonPortrait, &QToolButton::toggled, this, &DialogSaveLayout::WriteSettings);
connect(ui->toolButtonLandscape, &QToolButton::toggled, this, &DialogSaveLayout::WriteSettings); connect(ui->toolButtonLandscape, &QToolButton::toggled, this, &DialogSaveLayout::WriteSettings);
ShowExample();//Show example for current format. ShowExample();//Show example for current format.
} }
@ -754,6 +753,11 @@ void DialogSaveLayout::ReadSettings()
ui->doubleSpinBoxRightField->setValue(margins.right()); ui->doubleSpinBoxRightField->setValue(margins.right());
ui->doubleSpinBoxBottomField->setValue(margins.bottom()); ui->doubleSpinBoxBottomField->setValue(margins.bottom());
ui->doubleSpinBoxLeftField->setSuffix(UnitsToStr(unit, true));
ui->doubleSpinBoxTopField->setSuffix(UnitsToStr(unit, true));
ui->doubleSpinBoxRightField->setSuffix(UnitsToStr(unit, true));
ui->doubleSpinBoxBottomField->setSuffix(UnitsToStr(unit, true));
// read Template // read Template
const QSizeF size = QSizeF(settings->GetTiledPDFPaperWidth(Unit::Mm), settings->GetTiledPDFPaperHeight(Unit::Mm)); const QSizeF size = QSizeF(settings->GetTiledPDFPaperWidth(Unit::Mm), settings->GetTiledPDFPaperHeight(Unit::Mm));

View File

@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>601</width> <width>719</width>
<height>325</height> <height>314</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -17,9 +17,7 @@
<iconset resource="../../../libs/vmisc/share/resources/icon.qrc"> <iconset resource="../../../libs/vmisc/share/resources/icon.qrc">
<normaloff>:/icon/64x64/icon64x64.png</normaloff>:/icon/64x64/icon64x64.png</iconset> <normaloff>:/icon/64x64/icon64x64.png</normaloff>:/icon/64x64/icon64x64.png</iconset>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QFormLayout" name="formLayout_3">
<item>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0"> <item row="0" column="0">
<widget class="QLabel" name="label"> <widget class="QLabel" name="label">
<property name="text"> <property name="text">
@ -101,10 +99,7 @@
</widget> </widget>
</item> </item>
<item row="4" column="1"> <item row="4" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_3"> <layout class="QHBoxLayout" name="horizontalLayout_5">
<property name="bottomMargin">
<number>10</number>
</property>
<item> <item>
<widget class="QGroupBox" name="groupBoxMargins"> <widget class="QGroupBox" name="groupBoxMargins">
<property name="enabled"> <property name="enabled">
@ -116,18 +111,44 @@
<property name="checkable"> <property name="checkable">
<bool>false</bool> <bool>false</bool>
</property> </property>
<layout class="QHBoxLayout" name="horizontalLayout_6"> <layout class="QHBoxLayout" name="horizontalLayout_3">
<item> <item>
<layout class="QFormLayout" name="formLayout_2"> <layout class="QFormLayout" name="formLayout_2">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::ExpandingFieldsGrow</enum>
</property>
<item row="0" column="0">
<widget class="QLabel" name="labelLeftField">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Left:</string>
</property>
</widget>
</item>
<item row="1" column="0"> <item row="1" column="0">
<widget class="QLabel" name="labelRightField"> <widget class="QLabel" name="labelRightField">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text"> <property name="text">
<string>Right:</string> <string>Right:</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="1"> <item row="1" column="1">
<widget class="QDoubleSpinBox" name="doubleSpinBoxRightField"/> <widget class="QDoubleSpinBox" name="doubleSpinBoxRightField">
<property name="suffix">
<string>cm</string>
</property>
</widget>
</item> </item>
<item row="0" column="1"> <item row="0" column="1">
<widget class="QDoubleSpinBox" name="doubleSpinBoxLeftField"> <widget class="QDoubleSpinBox" name="doubleSpinBoxLeftField">
@ -137,38 +158,73 @@
<height>0</height> <height>0</height>
</size> </size>
</property> </property>
</widget> <property name="prefix">
</item> <string/>
<item row="0" column="0"> </property>
<widget class="QLabel" name="labelLeftField"> <property name="suffix">
<property name="text"> <string>cm</string>
<string>Left:</string>
</property> </property>
</widget> </widget>
</item> </item>
</layout> </layout>
</item> </item>
<item> <item>
<layout class="QFormLayout" name="formLayout_3"> <spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QFormLayout" name="formLayout">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::ExpandingFieldsGrow</enum>
</property>
<item row="0" column="0"> <item row="0" column="0">
<widget class="QLabel" name="labelTopField"> <widget class="QLabel" name="labelTopField">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text"> <property name="text">
<string>Top:</string> <string>Top:</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="1"> <item row="0" column="1">
<widget class="QDoubleSpinBox" name="doubleSpinBoxTopField"/> <widget class="QDoubleSpinBox" name="doubleSpinBoxTopField">
<property name="suffix">
<string>cm</string>
</property>
</widget>
</item> </item>
<item row="1" column="0"> <item row="1" column="0">
<widget class="QLabel" name="labelBottomField"> <widget class="QLabel" name="labelBottomField">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text"> <property name="text">
<string>Bottom:</string> <string>Bottom:</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="1"> <item row="1" column="1">
<widget class="QDoubleSpinBox" name="doubleSpinBoxBottomField"/> <widget class="QDoubleSpinBox" name="doubleSpinBoxBottomField">
<property name="suffix">
<string>cm</string>
</property>
</widget>
</item> </item>
</layout> </layout>
</item> </item>
@ -307,9 +363,7 @@
</item> </item>
</layout> </layout>
</item> </item>
</layout> <item row="6" column="0" colspan="2">
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox"> <widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>

View File

@ -1100,7 +1100,7 @@ void MainWindowsNoGUI::RestorePaper(int index) const
if (paper) if (paper)
{ {
// Restore // Restore
paper->setPen(QPen(Qt::black, widthMainLine)); paper->setPen(QPen(Qt::black, 1));
QBrush brush(Qt::gray); QBrush brush(Qt::gray);
scenes.at(index)->setBackgroundBrush(brush); scenes.at(index)->setBackgroundBrush(brush);
shadows.at(index)->setVisible(true); shadows.at(index)->setVisible(true);
@ -1248,10 +1248,10 @@ void MainWindowsNoGUI::SetPrinterSettings(QPrinter *printer, const PrintType &pr
SCASSERT(printer != nullptr) SCASSERT(printer != nullptr)
printer->setCreator(QGuiApplication::applicationDisplayName()+" "+QCoreApplication::applicationVersion()); printer->setCreator(QGuiApplication::applicationDisplayName()+" "+QCoreApplication::applicationVersion());
if (not isTiled)
{
printer->setOrientation(QPrinter::Portrait); printer->setOrientation(QPrinter::Portrait);
if (not isTiled)
{
QSizeF size = QSizeF(FromPixel(paperSize.width(), Unit::Mm), FromPixel(paperSize.height(), Unit::Mm)); QSizeF size = QSizeF(FromPixel(paperSize.width(), Unit::Mm), FromPixel(paperSize.height(), Unit::Mm));
if (isAutoCrop || isUnitePages) if (isAutoCrop || isUnitePages)
{ {
@ -1273,18 +1273,6 @@ void MainWindowsNoGUI::SetPrinterSettings(QPrinter *printer, const PrintType &pr
printer->setPaperSize (pSZ); printer->setPaperSize (pSZ);
} }
} }
else
{
VSettings *settings = qApp->ValentinaSettings();
if(settings->GetTiledPDFOrientation() == PageOrientation::Landscape)
{
printer->setOrientation(QPrinter::Landscape);
}
else
{
printer->setOrientation(QPrinter::Portrait);
}
}
printer->setFullPage(ignorePrinterFields); printer->setFullPage(ignorePrinterFields);

View File

@ -84,6 +84,11 @@ QVector<QGraphicsItem *> VPoster::Borders(QGraphicsItem *parent, const PosterDat
QPen pen(Qt::NoBrush, 1, Qt::DashLine); QPen pen(Qt::NoBrush, 1, Qt::DashLine);
pen.setColor(Qt::black); pen.setColor(Qt::black);
if (img.columns == 1 && img.rows == 1)
{
return data;
}
const QRect rec = img.rect; const QRect rec = img.rect;
if (img.column != 0) if (img.column != 0)
{// Left border {// Left border
@ -180,8 +185,15 @@ int VPoster::CountRows(int height, PageOrientation orientation) const
pageLength = PageRect().height(); pageLength = PageRect().height();
} }
if (pageLength >= imgLength)
{
return 1;
}
else
{
return qCeil(imgLength/(pageLength - static_cast<int>(allowance))); return qCeil(imgLength/(pageLength - static_cast<int>(allowance)));
} }
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
int VPoster::CountColumns(int width, PageOrientation orientation) const int VPoster::CountColumns(int width, PageOrientation orientation) const
@ -198,8 +210,15 @@ int VPoster::CountColumns(int width, PageOrientation orientation) const
pageLength = PageRect().width(); pageLength = PageRect().width();
} }
if (pageLength >= imgLength)
{
return 1;
}
else
{
return qCeil(imgLength/(pageLength-static_cast<int>(allowance))); return qCeil(imgLength/(pageLength-static_cast<int>(allowance)));
} }
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
PosterData VPoster::Cut(int i, int j, const QRect &imageRect, PageOrientation orientation) const PosterData VPoster::Cut(int i, int j, const QRect &imageRect, PageOrientation orientation) const