Merged develop into feature

--HG--
branch : feature
This commit is contained in:
Bojan Kverh 2016-08-15 15:38:51 +02:00
commit a5f16ab738
8 changed files with 202 additions and 118 deletions

View File

@ -91,15 +91,22 @@ DialogSaveLayout::DialogSaveLayout(int count, const QString &fileName, QWidget *
}
connect(bOk, &QPushButton::clicked, this, &DialogSaveLayout::Save);
auto ShowExample = [this](){ui->labelExample->setText(tr("Example:") + FileName() + "1" + Formate());};
auto ShowExample = [this]()
{
ui->labelExample->setText(tr("Example:") + FileName() + QLatin1String("1") + Format());
};
connect(ui->lineEditFileName, &QLineEdit::textChanged, ShowExample);
connect(ui->comboBoxFormat, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), ShowExample);
connect(ui->pushButtonBrowse, &QPushButton::clicked, [this]()
{
const QString dir = QFileDialog::getExistingDirectory(this, tr("Select folder"), QDir::homePath(),
const QString dir = QFileDialog::getExistingDirectory(this, tr("Select folder"),
qApp->ValentinaSettings()->GetPathLayout(),
QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
ui->lineEditPath->setText(dir);
if (not dir.isEmpty())
{// If paths equal the signal will not be called, we will do this manually
dir == ui->lineEditPath->text() ? PathChanged(dir) : ui->lineEditPath->setText(dir);
}
});
connect(ui->lineEditPath, &QLineEdit::textChanged, this, &DialogSaveLayout::PathChanged);
@ -128,12 +135,12 @@ void DialogSaveLayout::SelectFormate(const int formate)
//---------------------------------------------------------------------------------------------------------------------
QString DialogSaveLayout::MakeHelpFormatList()
{
QString out = "\n";
QString out("\n");
int cntr = 0;
const QVector<std::pair<QString, QString>> availFormats = InitAvailFormats();
foreach(auto& v, availFormats)
{
out += "\t"+v.first+" = "+ QString::number(cntr++)+"\n";
out += QLatin1String("\t") + v.first+QLatin1String(" = ") + QString::number(cntr++) + QLatin1String("\n");
}
return out;
}
@ -184,7 +191,7 @@ QString DialogSaveLayout::FileName() const
}
//---------------------------------------------------------------------------------------------------------------------
QString DialogSaveLayout::Formate() const
QString DialogSaveLayout::Format() const
{
#if QT_VERSION < QT_VERSION_CHECK(5, 2, 0)
return ui->comboBoxFormat->itemData(ui->comboBoxFormat->currentIndex()).toString();
@ -198,7 +205,7 @@ void DialogSaveLayout::Save()
{
for (int i=0; i < count; ++i)
{
const QString name = Path()+"/"+FileName()+QString::number(i+1)+Formate();
const QString name = Path()+QLatin1Literal("/")+FileName()+QString::number(i+1)+Format();
if (QFile::exists(name))
{
QMessageBox::StandardButton res = QMessageBox::question(this, tr("Name conflict"),
@ -256,8 +263,7 @@ void DialogSaveLayout::showEvent(QShowEvent *event)
}
// do your init stuff here
setMaximumSize(size());
setMinimumSize(size());
setFixedHeight(size().height());
isInitialized = true;//first show windows are held
}
@ -280,7 +286,8 @@ bool DialogSaveLayout::TestPdf()
QProcess proc;
#if defined(Q_OS_WIN) || defined(Q_OS_OSX)
proc.start(qApp->applicationDirPath()+"/"+PDFTOPS); // Seek pdftops in app bundle or near valentin.exe
// Seek pdftops in app bundle or near valentin.exe
proc.start(qApp->applicationDirPath() + QLatin1String("/")+ PDFTOPS);
#else
proc.start(PDFTOPS); // Seek pdftops in standard path
#endif

View File

@ -53,7 +53,7 @@ public:
QString Path() const;
QString FileName() const;
QString Formate() const;
QString Format() const;
void SelectFormate(const int formate);
static QString MakeHelpFormatList();
void SetDestinationPath(const QString& cmdDestinationPath);

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>692</width>
<height>179</height>
<width>748</width>
<height>150</height>
</rect>
</property>
<property name="windowTitle">
@ -19,17 +19,19 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QGridLayout" name="gridLayout_2">
<property name="rightMargin">
<number>0</number>
<layout class="QFormLayout" name="formLayout">
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
<property name="labelAlignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="formAlignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>File name:</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
@ -37,6 +39,42 @@
</property>
</widget>
</item>
<item row="0" column="1">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLineEdit" name="lineEditPath">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Destination folder</string>
</property>
<property name="placeholderText">
<string>Path to destination folder</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButtonBrowse">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Select path to destination folder</string>
</property>
<property name="text">
<string>Browse...</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
@ -44,64 +82,58 @@
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="lineEditPath">
<property name="toolTip">
<string>Destination folder</string>
</property>
<property name="placeholderText">
<string>Path to destination folder.</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QPushButton" name="pushButtonBrowse">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Select path to destination folder</string>
</property>
<property name="text">
<string>Browse...</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="comboBoxFormat">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>File name:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="lineEditFileName">
<property name="toolTip">
<string>File base name</string>
</property>
<property name="placeholderText">
<string>File base name.</string>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QLabel" name="labelExample">
<property name="minimumSize">
<size>
<width>130</width>
<height>0</height>
</size>
</property>
<property name="text">
<string notr="true">TextLabel</string>
</property>
</widget>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLineEdit" name="lineEditFileName">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>File base name</string>
</property>
<property name="placeholderText">
<string>File base name</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="labelExample">
<property name="minimumSize">
<size>
<width>130</width>
<height>0</height>
</size>
</property>
<property name="text">
<string notr="true">TextLabel</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>

View File

@ -1702,6 +1702,7 @@ void MainWindow::InitToolButtons()
connect(ui->toolButtonGroup, &QToolButton::clicked, this, &MainWindow::ToolGroup);
connect(ui->toolButtonRotation, &QToolButton::clicked, this, &MainWindow::ToolRotation);
connect(ui->toolButtonMidpoint, &QToolButton::clicked, this, &MainWindow::ToolMidpoint);
connect(ui->toolButtonLayoutExportAs, &QToolButton::clicked, this, &MainWindow::ExportLayoutAs);
}
//---------------------------------------------------------------------------------------------------------------------
@ -2970,6 +2971,7 @@ void MainWindow::SetLayoutModeActions()
{
const bool enabled = not scenes.isEmpty();
ui->toolButtonLayoutExportAs->setEnabled(enabled);
ui->actionExportAs->setEnabled(enabled);
ui->actionPrintPreview->setEnabled(enabled);
ui->actionPrintPreviewTiled->setEnabled(enabled);
@ -3950,6 +3952,40 @@ void MainWindow::CreateMeasurements()
QProcess::startDetached(tape, QStringList(), workingDirectory);
}
//---------------------------------------------------------------------------------------------------------------------
void MainWindow::ExportLayoutAs()
{
if (isLayoutStale)
{
if (ContinueIfLayoutStale() == QMessageBox::No)
{
ui->toolButtonLayoutExportAs->setChecked(false);
return;
}
}
try
{
DialogSaveLayout dialog(scenes.size(), FileName(), this);
if (dialog.exec() == QDialog::Rejected)
{
ui->toolButtonLayoutExportAs->setChecked(false);
return;
}
ExportLayout(dialog);
}
catch (const VException &e)
{
ui->toolButtonLayoutExportAs->setChecked(false);
qCritical("%s\n\n%s\n\n%s", qUtf8Printable(tr("Export error.")),
qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation()));
return;
}
ui->toolButtonLayoutExportAs->setChecked(false);
}
//---------------------------------------------------------------------------------------------------------------------
void MainWindow::ToolBarStyle(QToolBar *bar)
{

View File

@ -113,6 +113,7 @@ private slots:
void ShowPaper(int index);
void Preferences();
void CreateMeasurements();
void ExportLayoutAs();
void ArrowTool();
void ToolEndLine(bool checked);

View File

@ -48,14 +48,14 @@
<string>Tools</string>
</property>
<property name="currentIndex">
<number>4</number>
<number>6</number>
</property>
<widget class="QWidget" name="page">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>117</width>
<width>100</width>
<height>358</height>
</rect>
</property>
@ -427,7 +427,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>130</width>
<width>100</width>
<height>110</height>
</rect>
</property>
@ -536,7 +536,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>130</width>
<width>100</width>
<height>248</height>
</rect>
</property>
@ -798,7 +798,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>130</width>
<width>100</width>
<height>248</height>
</rect>
</property>
@ -1063,8 +1063,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>130</width>
<height>356</height>
<width>100</width>
<height>104</height>
</rect>
</property>
<attribute name="icon">
@ -1163,7 +1163,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>130</width>
<width>100</width>
<height>104</height>
</rect>
</property>
@ -1316,6 +1316,32 @@
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QToolButton" name="toolButtonLayoutExportAs">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>Export original layout</string>
</property>
<property name="text">
<string notr="true">...</string>
</property>
<property name="icon">
<iconset resource="../../libs/vmisc/share/resources/icon.qrc">
<normaloff>:/icon/32x32/export_to_picture_document.png</normaloff>:/icon/32x32/export_to_picture_document.png</iconset>
</property>
<property name="iconSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</widget>

View File

@ -182,43 +182,21 @@ void MainWindowsNoGUI::ErrorConsoleMode(const LayoutErrors &state)
}
//---------------------------------------------------------------------------------------------------------------------
void MainWindowsNoGUI::ExportLayoutAs()
{
if (isLayoutStale)
{
if (ContinueIfLayoutStale() == QMessageBox::No)
{
return;
}
}
try
{
DialogSaveLayout dialog(scenes.size(), FileName(), this);
if (dialog.exec() == QDialog::Rejected)
{
return;
}
ExportLayout(dialog);
}
catch (const VException &e)
{
qCritical("%s\n\n%s\n\n%s", qUtf8Printable(tr("Export error.")),
qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation()));
return;
}
}
//---------------------------------------------------------------------------------------------------------------------
void MainWindowsNoGUI::ExportLayout(const DialogSaveLayout &dialog)
{
QString suf = dialog.Formate();
suf.replace(".", "");
const QString suf = dialog.Format().replace(".", "");
const QString path = dialog.Path();
QDir dir(path);
dir.setPath(path);
if (not dir.exists(path))
{
if (not dir.mkpath(path))
{
qCritical() << tr("Can't create path");
return;
}
}
qApp->ValentinaSettings()->SetPathLayout(path);
const QString mask = dialog.FileName();
@ -227,13 +205,19 @@ void MainWindowsNoGUI::ExportLayout(const DialogSaveLayout &dialog)
QGraphicsRectItem *paper = qgraphicsitem_cast<QGraphicsRectItem *>(papers.at(i));
if (paper)
{
const QString name = path + "/" + mask+QString::number(i+1) + dialog.Formate();
const QString name = path + QLatin1String("/") + mask+QString::number(i+1) + dialog.Format();
QBrush *brush = new QBrush();
brush->setColor( QColor( Qt::white ) );
scenes[i]->setBackgroundBrush( *brush );
shadows[i]->setVisible(false);
paper->setPen(QPen(QBrush(Qt::white, Qt::NoBrush), 0.1, Qt::NoPen));
const QStringList suffix = QStringList() << "svg" << "png" << "pdf" << "eps" << "ps" << "obj" << "dxf";
const QStringList suffix = QStringList() << QLatin1String("svg")
<< QLatin1String("png")
<< QLatin1String("pdf")
<< QLatin1String("eps")
<< QLatin1String("ps")
<< QLatin1String("obj")
<< QLatin1String("dxf");
switch (suffix.indexOf(suf))
{
case 0: //svg

View File

@ -53,7 +53,6 @@ public:
public slots:
void ToolLayoutSettings(bool checked);
void ExportLayoutAs();
void SaveAsTiledPDF();
void PrintPreviewOrigin();
void PrintPreviewTiled();
@ -98,6 +97,8 @@ protected:
virtual void PrepareSceneList()=0;
QIcon ScenePreview(int i) const;
bool LayoutSettings(VLayoutGenerator& lGenerator);
int ContinueIfLayoutStale();
QString FileName() const;
private slots:
void PrintPages (QPrinter *printer);
void ErrorConsoleMode(const LayoutErrors &state);
@ -135,9 +136,6 @@ private:
bool isPagesUniform() const;
bool IsPagesFit(const QSizeF &printPaper) const;
QString FileName() const;
int ContinueIfLayoutStale();
};
#endif // MAINWINDOWSNOGUI_H