Allow to select printer in Layout Settings dialog.
--HG-- branch : develop
This commit is contained in:
parent
73bcc89107
commit
e54e1e4f11
|
@ -35,6 +35,7 @@
|
||||||
|
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
|
#include <QPrinterInfo>
|
||||||
|
|
||||||
//must be the same order as PaperSizeTemplate constants
|
//must be the same order as PaperSizeTemplate constants
|
||||||
const DialogLayoutSettings::FormatsVector DialogLayoutSettings::pageFormatNames =
|
const DialogLayoutSettings::FormatsVector DialogLayoutSettings::pageFormatNames =
|
||||||
|
@ -68,6 +69,7 @@ DialogLayoutSettings::DialogLayoutSettings(VLayoutGenerator *generator, QWidget
|
||||||
InitTemplates();
|
InitTemplates();
|
||||||
MinimumPaperSize();
|
MinimumPaperSize();
|
||||||
MinimumLayoutSize();
|
MinimumLayoutSize();
|
||||||
|
InitPrinter();
|
||||||
|
|
||||||
//in export console mode going to use defaults
|
//in export console mode going to use defaults
|
||||||
if (disableSettings == false)
|
if (disableSettings == false)
|
||||||
|
@ -79,24 +81,27 @@ DialogLayoutSettings::DialogLayoutSettings(VLayoutGenerator *generator, QWidget
|
||||||
RestoreDefaults();
|
RestoreDefaults();
|
||||||
}
|
}
|
||||||
|
|
||||||
connect(ui->comboBoxTemplates, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
|
connect(ui->comboBoxPrinter, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
|
||||||
|
this, &DialogLayoutSettings::PrinterMargins);
|
||||||
|
|
||||||
|
connect(ui->comboBoxTemplates, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
|
||||||
this, &DialogLayoutSettings::TemplateSelected);
|
this, &DialogLayoutSettings::TemplateSelected);
|
||||||
connect(ui->comboBoxPaperSizeUnit, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
|
connect(ui->comboBoxPaperSizeUnit, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
|
||||||
this, &DialogLayoutSettings::ConvertPaperSize);
|
this, &DialogLayoutSettings::ConvertPaperSize);
|
||||||
|
|
||||||
connect(ui->doubleSpinBoxPaperWidth, static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged),
|
connect(ui->doubleSpinBoxPaperWidth, static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged),
|
||||||
this, &DialogLayoutSettings::PaperSizeChanged);
|
this, &DialogLayoutSettings::PaperSizeChanged);
|
||||||
connect(ui->doubleSpinBoxPaperHeight, static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged),
|
connect(ui->doubleSpinBoxPaperHeight, static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged),
|
||||||
this, &DialogLayoutSettings::PaperSizeChanged);
|
this, &DialogLayoutSettings::PaperSizeChanged);
|
||||||
|
|
||||||
connect(ui->doubleSpinBoxPaperWidth, static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged),
|
connect(ui->doubleSpinBoxPaperWidth, static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged),
|
||||||
this, &DialogLayoutSettings::FindTemplate);
|
this, &DialogLayoutSettings::FindTemplate);
|
||||||
connect(ui->doubleSpinBoxPaperHeight, static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged),
|
connect(ui->doubleSpinBoxPaperHeight, static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged),
|
||||||
this, &DialogLayoutSettings::FindTemplate);
|
this, &DialogLayoutSettings::FindTemplate);
|
||||||
|
|
||||||
connect(ui->doubleSpinBoxPaperWidth, static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged),
|
connect(ui->doubleSpinBoxPaperWidth, static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged),
|
||||||
this, &DialogLayoutSettings::CorrectMaxFileds);
|
this, &DialogLayoutSettings::CorrectMaxFileds);
|
||||||
connect(ui->doubleSpinBoxPaperHeight, static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged),
|
connect(ui->doubleSpinBoxPaperHeight, static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged),
|
||||||
this, &DialogLayoutSettings::CorrectMaxFileds);
|
this, &DialogLayoutSettings::CorrectMaxFileds);
|
||||||
|
|
||||||
connect(ui->checkBoxIgnoreFileds, &QCheckBox::stateChanged, this, &DialogLayoutSettings::IgnoreAllFields);
|
connect(ui->checkBoxIgnoreFileds, &QCheckBox::stateChanged, this, &DialogLayoutSettings::IgnoreAllFields);
|
||||||
|
@ -333,6 +338,12 @@ void DialogLayoutSettings::SetIgnoreAllFields(bool value)
|
||||||
ui->checkBoxIgnoreFileds->setChecked(value);
|
ui->checkBoxIgnoreFileds->setChecked(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QString DialogLayoutSettings::SelectedPrinter() const
|
||||||
|
{
|
||||||
|
return ui->comboBoxPrinter->currentText();
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogLayoutSettings::TemplateSelected()
|
void DialogLayoutSettings::TemplateSelected()
|
||||||
{
|
{
|
||||||
|
@ -617,6 +628,10 @@ void DialogLayoutSettings::RestoreDefaults()
|
||||||
TemplateSelected();
|
TemplateSelected();
|
||||||
ui->comboBoxTemplates->blockSignals(false);
|
ui->comboBoxTemplates->blockSignals(false);
|
||||||
|
|
||||||
|
ui->comboBoxPrinter->blockSignals(true);
|
||||||
|
InitPrinter();
|
||||||
|
ui->comboBoxPrinter->blockSignals(false);
|
||||||
|
|
||||||
SetLayoutWidth(VSettings::GetDefLayoutWidth());
|
SetLayoutWidth(VSettings::GetDefLayoutWidth());
|
||||||
SetShift(VSettings::GetDefLayoutShift());
|
SetShift(VSettings::GetDefLayoutShift());
|
||||||
SetGroup(VSettings::GetDefLayoutGroup());
|
SetGroup(VSettings::GetDefLayoutGroup());
|
||||||
|
@ -630,6 +645,16 @@ void DialogLayoutSettings::RestoreDefaults()
|
||||||
IgnoreAllFields(ui->checkBoxIgnoreFileds->isChecked());
|
IgnoreAllFields(ui->checkBoxIgnoreFileds->isChecked());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogLayoutSettings::PrinterMargins()
|
||||||
|
{
|
||||||
|
QPrinterInfo printer = QPrinterInfo::printerInfo(ui->comboBoxPrinter->currentText());
|
||||||
|
if (not printer.isNull())
|
||||||
|
{
|
||||||
|
SetFields(VSettings::GetPrinterFields(QSharedPointer<QPrinter>(new QPrinter(printer))));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogLayoutSettings::CorrectMaxFileds()
|
void DialogLayoutSettings::CorrectMaxFileds()
|
||||||
{
|
{
|
||||||
|
@ -714,6 +739,51 @@ void DialogLayoutSettings::InitTemplates()
|
||||||
ui->comboBoxTemplates->setCurrentIndex(-1);
|
ui->comboBoxTemplates->setCurrentIndex(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogLayoutSettings::InitPrinter()
|
||||||
|
{
|
||||||
|
ui->comboBoxPrinter->clear();
|
||||||
|
QStringList printerNames;
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(5, 3, 0)
|
||||||
|
const QList<QPrinterInfo> printers = QPrinterInfo::availablePrinters();
|
||||||
|
for(int i = 0; i < printers.size(); ++i)
|
||||||
|
{
|
||||||
|
const QString name = printers.at(i).printerName();
|
||||||
|
if (not name.isEmpty())
|
||||||
|
{
|
||||||
|
printerNames.append(name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
printerNames = QPrinterInfo::availablePrinterNames();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
ui->comboBoxPrinter->addItems(printerNames);
|
||||||
|
|
||||||
|
if (ui->comboBoxPrinter->count() == 0)
|
||||||
|
{
|
||||||
|
ui->comboBoxPrinter->addItem(tr("None", "Printer"));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
QString defPrinterName;
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(5, 3, 0)
|
||||||
|
const QPrinterInfo def = QPrinterInfo::defaultPrinter();
|
||||||
|
if(not def.isNull())
|
||||||
|
{
|
||||||
|
defPrinterName = def.printerName();
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
defPrinterName = QPrinterInfo::defaultPrinterName();
|
||||||
|
#endif
|
||||||
|
const int index = ui->comboBoxPrinter->findText(defPrinterName);
|
||||||
|
if(index != -1)
|
||||||
|
{
|
||||||
|
ui->comboBoxPrinter->setCurrentIndex(index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
QString DialogLayoutSettings::MakeHelpTemplateList()
|
QString DialogLayoutSettings::MakeHelpTemplateList()
|
||||||
{
|
{
|
||||||
|
|
|
@ -111,6 +111,8 @@ public:
|
||||||
bool IsIgnoreAllFields() const;
|
bool IsIgnoreAllFields() const;
|
||||||
void SetIgnoreAllFields(bool value);
|
void SetIgnoreAllFields(bool value);
|
||||||
|
|
||||||
|
QString SelectedPrinter() const;
|
||||||
|
|
||||||
//support functions for the command line parser which uses invisible dialog to properly build layout generator
|
//support functions for the command line parser which uses invisible dialog to properly build layout generator
|
||||||
bool SelectTemplate(const PaperSizeTemplate& id);
|
bool SelectTemplate(const PaperSizeTemplate& id);
|
||||||
static QString MakeHelpTemplateList();
|
static QString MakeHelpTemplateList();
|
||||||
|
@ -131,6 +133,7 @@ private slots:
|
||||||
void PaperSizeChanged();
|
void PaperSizeChanged();
|
||||||
void Swap(bool checked);
|
void Swap(bool checked);
|
||||||
void RestoreDefaults();
|
void RestoreDefaults();
|
||||||
|
void PrinterMargins();
|
||||||
|
|
||||||
void CorrectMaxFileds();
|
void CorrectMaxFileds();
|
||||||
void IgnoreAllFields(int state);
|
void IgnoreAllFields(int state);
|
||||||
|
@ -151,6 +154,7 @@ private:
|
||||||
void InitPaperUnits();
|
void InitPaperUnits();
|
||||||
void InitLayoutUnits();
|
void InitLayoutUnits();
|
||||||
void InitTemplates();
|
void InitTemplates();
|
||||||
|
void InitPrinter();
|
||||||
QSizeF Template();
|
QSizeF Template();
|
||||||
QSizeF TemplateSize(const PaperSizeTemplate &tmpl) const;
|
QSizeF TemplateSize(const PaperSizeTemplate &tmpl) const;
|
||||||
QSizeF RoundTemplateSize(qreal width, qreal height) const;
|
QSizeF RoundTemplateSize(qreal width, qreal height) const;
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>632</width>
|
<width>600</width>
|
||||||
<height>531</height>
|
<height>531</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
|
@ -72,64 +72,6 @@
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<item row="0" column="0">
|
|
||||||
<widget class="QLabel" name="labelWidth">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Width:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="0">
|
|
||||||
<widget class="QLabel" name="labelHeight">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Height:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="1">
|
|
||||||
<widget class="QDoubleSpinBox" name="doubleSpinBoxPaperHeight">
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>94</width>
|
|
||||||
<height>0</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="decimals">
|
|
||||||
<number>2</number>
|
|
||||||
</property>
|
|
||||||
<property name="maximum">
|
|
||||||
<double>99999.000000000000000</double>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="1">
|
|
||||||
<widget class="QDoubleSpinBox" name="doubleSpinBoxPaperWidth">
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>94</width>
|
|
||||||
<height>0</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="decimals">
|
|
||||||
<number>2</number>
|
|
||||||
</property>
|
|
||||||
<property name="maximum">
|
|
||||||
<double>99999.990000000005239</double>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="0">
|
<item row="2" column="0">
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
<item>
|
<item>
|
||||||
|
@ -180,6 +122,32 @@
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="labelWidth">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Width:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QLabel" name="labelHeight">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Height:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item row="2" column="1">
|
<item row="2" column="1">
|
||||||
<widget class="QComboBox" name="comboBoxPaperSizeUnit">
|
<widget class="QComboBox" name="comboBoxPaperSizeUnit">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
|
@ -196,13 +164,65 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="QDoubleSpinBox" name="doubleSpinBoxPaperHeight">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>94</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="decimals">
|
||||||
|
<number>2</number>
|
||||||
|
</property>
|
||||||
|
<property name="maximum">
|
||||||
|
<double>99999.000000000000000</double>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QDoubleSpinBox" name="doubleSpinBoxPaperWidth">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>94</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="decimals">
|
||||||
|
<number>2</number>
|
||||||
|
</property>
|
||||||
|
<property name="maximum">
|
||||||
|
<double>99999.990000000005239</double>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_6">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_6">
|
||||||
|
<property name="text">
|
||||||
|
<string>Printer:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QComboBox" name="comboBoxPrinter"/>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QGroupBox" name="groupBoxPaperFileds">
|
<widget class="QGroupBox" name="groupBoxPaperFileds">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>Fields</string>
|
<string>Fields</string>
|
||||||
</property>
|
</property>
|
||||||
|
@ -210,72 +230,78 @@
|
||||||
<property name="fieldGrowthPolicy">
|
<property name="fieldGrowthPolicy">
|
||||||
<enum>QFormLayout::ExpandingFieldsGrow</enum>
|
<enum>QFormLayout::ExpandingFieldsGrow</enum>
|
||||||
</property>
|
</property>
|
||||||
<item row="0" column="0">
|
<item row="1" column="0">
|
||||||
<widget class="QLabel" name="labelLeftField">
|
<widget class="QLabel" name="labelLeftField">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Left:</string>
|
<string>Left:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="1">
|
<item row="1" column="1">
|
||||||
<widget class="QDoubleSpinBox" name="doubleSpinBoxLeftField">
|
<widget class="QDoubleSpinBox" name="doubleSpinBoxLeftField">
|
||||||
<property name="decimals">
|
<property name="decimals">
|
||||||
<number>5</number>
|
<number>5</number>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="0">
|
<item row="2" column="0">
|
||||||
<widget class="QLabel" name="labelRightField">
|
<widget class="QLabel" name="labelRightField">
|
||||||
<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="2" column="1">
|
||||||
<widget class="QDoubleSpinBox" name="doubleSpinBoxRightField">
|
<widget class="QDoubleSpinBox" name="doubleSpinBoxRightField">
|
||||||
<property name="decimals">
|
<property name="decimals">
|
||||||
<number>5</number>
|
<number>5</number>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0">
|
<item row="3" column="0">
|
||||||
<widget class="QLabel" name="labelTopField">
|
<widget class="QLabel" name="labelTopField">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Top:</string>
|
<string>Top:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="1">
|
<item row="3" column="1">
|
||||||
<widget class="QDoubleSpinBox" name="doubleSpinBoxTopField">
|
<widget class="QDoubleSpinBox" name="doubleSpinBoxTopField">
|
||||||
<property name="decimals">
|
<property name="decimals">
|
||||||
<number>5</number>
|
<number>5</number>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="0">
|
<item row="4" column="0">
|
||||||
<widget class="QLabel" name="labelBottomField">
|
<widget class="QLabel" name="labelBottomField">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Bottom:</string>
|
<string>Bottom:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="1">
|
<item row="4" column="1">
|
||||||
<widget class="QDoubleSpinBox" name="doubleSpinBoxBottomField">
|
<widget class="QDoubleSpinBox" name="doubleSpinBoxBottomField">
|
||||||
<property name="decimals">
|
<property name="decimals">
|
||||||
<number>5</number>
|
<number>5</number>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="4" column="0">
|
|
||||||
<widget class="QCheckBox" name="checkBoxIgnoreFileds">
|
|
||||||
<property name="text">
|
|
||||||
<string>Ignore fileds</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="checkBoxIgnoreFileds">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Ignore fileds</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
|
@ -700,7 +726,7 @@
|
||||||
</connection>
|
</connection>
|
||||||
</connections>
|
</connections>
|
||||||
<buttongroups>
|
<buttongroups>
|
||||||
<buttongroup name="buttonGroup"/>
|
|
||||||
<buttongroup name="buttonGroupPrinciple"/>
|
<buttongroup name="buttonGroupPrinciple"/>
|
||||||
|
<buttongroup name="buttonGroup"/>
|
||||||
</buttongroups>
|
</buttongroups>
|
||||||
</ui>
|
</ui>
|
||||||
|
|
|
@ -69,7 +69,8 @@ MainWindowsNoGUI::MainWindowsNoGUI(QWidget *parent)
|
||||||
paperSize(),
|
paperSize(),
|
||||||
isTiled(false),
|
isTiled(false),
|
||||||
isAutoCrop(false),
|
isAutoCrop(false),
|
||||||
isUnitePages(false)
|
isUnitePages(false),
|
||||||
|
layoutPrinterName()
|
||||||
|
|
||||||
{
|
{
|
||||||
InitTempLayoutScene();
|
InitTempLayoutScene();
|
||||||
|
@ -98,6 +99,7 @@ void MainWindowsNoGUI::ToolLayoutSettings(bool checked)
|
||||||
tButton->setChecked(false);
|
tButton->setChecked(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
layoutPrinterName = layout.SelectedPrinter();
|
||||||
LayoutSettings(lGenerator);
|
LayoutSettings(lGenerator);
|
||||||
tButton->setChecked(false);
|
tButton->setChecked(false);
|
||||||
}
|
}
|
||||||
|
@ -854,7 +856,12 @@ void MainWindowsNoGUI::PrintPreview()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QSharedPointer<QPrinter> printer = DefaultPrinter();
|
QPrinterInfo info = QPrinterInfo::printerInfo(layoutPrinterName);
|
||||||
|
if(info.isNull() || info.printerName().isEmpty())
|
||||||
|
{
|
||||||
|
info = QPrinterInfo::defaultPrinter();
|
||||||
|
}
|
||||||
|
QSharedPointer<QPrinter> printer = PreparePrinter(info);
|
||||||
if (printer.isNull())
|
if (printer.isNull())
|
||||||
{
|
{
|
||||||
qCritical("%s\n\n%s", qUtf8Printable(tr("Print error")),
|
qCritical("%s\n\n%s", qUtf8Printable(tr("Print error")),
|
||||||
|
@ -881,7 +888,12 @@ void MainWindowsNoGUI::LayoutPrint()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// display print dialog and if accepted print
|
// display print dialog and if accepted print
|
||||||
QSharedPointer<QPrinter> printer = DefaultPrinter(QPrinter::HighResolution);
|
QPrinterInfo info = QPrinterInfo::printerInfo(layoutPrinterName);
|
||||||
|
if(info.isNull() || info.printerName().isEmpty())
|
||||||
|
{
|
||||||
|
info = QPrinterInfo::defaultPrinter();
|
||||||
|
}
|
||||||
|
QSharedPointer<QPrinter> printer = PreparePrinter(info, QPrinter::HighResolution);
|
||||||
if (printer.isNull())
|
if (printer.isNull())
|
||||||
{
|
{
|
||||||
qCritical("%s\n\n%s", qUtf8Printable(tr("Print error")),
|
qCritical("%s\n\n%s", qUtf8Printable(tr("Print error")),
|
||||||
|
|
|
@ -109,6 +109,8 @@ private:
|
||||||
bool isAutoCrop;
|
bool isAutoCrop;
|
||||||
bool isUnitePages;
|
bool isUnitePages;
|
||||||
|
|
||||||
|
QString layoutPrinterName;
|
||||||
|
|
||||||
void CreateShadows();
|
void CreateShadows();
|
||||||
void CreateScenes();
|
void CreateScenes();
|
||||||
|
|
||||||
|
|
|
@ -1813,24 +1813,35 @@ QString AbsoluteMPath(const QString &patternPath, const QString &relativeMPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
QSharedPointer<QPrinter> DefaultPrinter(QPrinter::PrinterMode mode)
|
QSharedPointer<QPrinter> PreparePrinter(const QPrinterInfo &info, QPrinter::PrinterMode mode)
|
||||||
{
|
{
|
||||||
QPrinterInfo def = QPrinterInfo::defaultPrinter();
|
QPrinterInfo tmpInfo = info;
|
||||||
|
if(tmpInfo.isNull() || tmpInfo.printerName().isEmpty())
|
||||||
//if there is no default printer set the print preview won't show
|
|
||||||
if(def.isNull() || def.printerName().isEmpty())
|
|
||||||
{
|
{
|
||||||
if(QPrinterInfo::availablePrinters().isEmpty())
|
#if QT_VERSION < QT_VERSION_CHECK(5, 3, 0)
|
||||||
|
const QList<QPrinterInfo> list = QPrinterInfo::availablePrinters();
|
||||||
|
if(list.isEmpty())
|
||||||
{
|
{
|
||||||
return QSharedPointer<QPrinter>();
|
return QSharedPointer<QPrinter>();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
def = QPrinterInfo::availablePrinters().first();
|
tmpInfo = list.first();
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
const QStringList list = QPrinterInfo::availablePrinterNames();
|
||||||
|
if(list.isEmpty())
|
||||||
|
{
|
||||||
|
return QSharedPointer<QPrinter>();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
tmpInfo = QPrinterInfo::printerInfo(list.first());
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
auto printer = QSharedPointer<QPrinter>(new QPrinter(def, mode));
|
auto printer = QSharedPointer<QPrinter>(new QPrinter(tmpInfo, mode));
|
||||||
printer->setResolution(static_cast<int>(PrintDPI));
|
printer->setResolution(static_cast<int>(PrintDPI));
|
||||||
return printer;
|
return printer;
|
||||||
}
|
}
|
||||||
|
|
|
@ -620,7 +620,8 @@ QString StrippedName(const QString &fullFileName) Q_REQUIRED_RESULT;
|
||||||
QString RelativeMPath(const QString &patternPath, const QString &absoluteMPath) Q_REQUIRED_RESULT;
|
QString RelativeMPath(const QString &patternPath, const QString &absoluteMPath) Q_REQUIRED_RESULT;
|
||||||
QString AbsoluteMPath(const QString &patternPath, const QString &relativeMPath) Q_REQUIRED_RESULT;
|
QString AbsoluteMPath(const QString &patternPath, const QString &relativeMPath) Q_REQUIRED_RESULT;
|
||||||
|
|
||||||
QSharedPointer<QPrinter> DefaultPrinter(QPrinter::PrinterMode mode = QPrinter::ScreenResolution) Q_REQUIRED_RESULT;
|
QSharedPointer<QPrinter> PreparePrinter(const QPrinterInfo &info,
|
||||||
|
QPrinter::PrinterMode mode = QPrinter::ScreenResolution) Q_REQUIRED_RESULT;
|
||||||
|
|
||||||
QPixmap darkenPixmap(const QPixmap &pixmap) Q_REQUIRED_RESULT;
|
QPixmap darkenPixmap(const QPixmap &pixmap) Q_REQUIRED_RESULT;
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,7 @@
|
||||||
#include <QStringData>
|
#include <QStringData>
|
||||||
#include <QStringDataPtr>
|
#include <QStringDataPtr>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
|
#include <QPrinterInfo>
|
||||||
|
|
||||||
#include "../vmisc/def.h"
|
#include "../vmisc/def.h"
|
||||||
#include "../vmisc/vmath.h"
|
#include "../vmisc/vmath.h"
|
||||||
|
@ -375,7 +376,12 @@ QMarginsF VSettings::GetFields() const
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
QMarginsF VSettings::GetDefFields()
|
QMarginsF VSettings::GetDefFields()
|
||||||
{
|
{
|
||||||
QSharedPointer<QPrinter> printer = DefaultPrinter();
|
return GetPrinterFields(PreparePrinter(QPrinterInfo::defaultPrinter()));
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QMarginsF VSettings::GetPrinterFields(const QSharedPointer<QPrinter> &printer)
|
||||||
|
{
|
||||||
if (printer.isNull())
|
if (printer.isNull())
|
||||||
{
|
{
|
||||||
return QMarginsF();
|
return QMarginsF();
|
||||||
|
|
|
@ -39,6 +39,8 @@
|
||||||
#include "vcommonsettings.h"
|
#include "vcommonsettings.h"
|
||||||
|
|
||||||
class QMarginsF;
|
class QMarginsF;
|
||||||
|
class QPrinter;
|
||||||
|
template <class T> class QSharedPointer;
|
||||||
|
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(5, 3, 0)
|
#if QT_VERSION < QT_VERSION_CHECK(5, 3, 0)
|
||||||
# include "../vmisc/backport/qmarginsf.h"
|
# include "../vmisc/backport/qmarginsf.h"
|
||||||
|
@ -112,6 +114,7 @@ public:
|
||||||
|
|
||||||
QMarginsF GetFields() const;
|
QMarginsF GetFields() const;
|
||||||
static QMarginsF GetDefFields();
|
static QMarginsF GetDefFields();
|
||||||
|
static QMarginsF GetPrinterFields(const QSharedPointer<QPrinter> &printer);
|
||||||
void SetFields(const QMarginsF &value);
|
void SetFields(const QMarginsF &value);
|
||||||
|
|
||||||
Cases GetLayoutGroup() const;
|
Cases GetLayoutGroup() const;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user