From 1d9af2dcc003cc9af18d3fbfcb59c7a28f1b5251 Mon Sep 17 00:00:00 2001 From: Valentina Zhuravska Date: Sat, 31 Oct 2015 05:44:21 +0200 Subject: [PATCH 1/6] Resolved issue #397. Display the currently open measurement file name in the top menu of Valentina --HG-- branch : feature --- src/app/valentina/mainwindow.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/app/valentina/mainwindow.cpp b/src/app/valentina/mainwindow.cpp index 5ceb060bd..c8ec4b2e6 100644 --- a/src/app/valentina/mainwindow.cpp +++ b/src/app/valentina/mainwindow.cpp @@ -359,6 +359,14 @@ bool MainWindow::LoadMeasurements(const QString &path) } return false; } + QString shownName = strippedName(curFile); + if (curFile.isEmpty()) + { + shownName = tr("untitled.val"); + } + shownName += "[*]"; + shownName += " [" + strippedName(path) + "[*]]"; + setWindowTitle(shownName); return true; } @@ -1195,6 +1203,14 @@ void MainWindow::UnloadMeasurements() ui->actionShowM->setEnabled(false); ui->actionUnloadMeasurements->setDisabled(true); helpLabel->setText(tr("Measurements unloaded")); + + QString shownName = strippedName(curFile); + if (curFile.isEmpty()) + { + shownName = tr("untitled.val"); + } + shownName += "[*]"; + setWindowTitle(shownName); } else { @@ -2855,6 +2871,12 @@ void MainWindow::setCurrentFile(const QString &fileName) settings->SetRestoreFileList(restoreFiles); } shownName+="[*]"; + + QString path = AbsoluteMPath(fileName, doc->MPath()); + if(not path.isEmpty()) + { + shownName += " [" + strippedName(path) + "[*]]"; + } setWindowTitle(shownName); } From aba82baa987e41a2e0da51016ea326cd96d366b4 Mon Sep 17 00:00:00 2001 From: Valentina Zhuravska Date: Wed, 4 Nov 2015 07:06:44 +0200 Subject: [PATCH 2/6] Fixed issue #397. Added UpdateWindowTitle --HG-- branch : feature --- src/app/valentina/mainwindow.cpp | 77 ++++++++++++++++++++------------ src/app/valentina/mainwindow.h | 5 +++ 2 files changed, 54 insertions(+), 28 deletions(-) diff --git a/src/app/valentina/mainwindow.cpp b/src/app/valentina/mainwindow.cpp index 3a6cd2d08..6cfc3c3a7 100644 --- a/src/app/valentina/mainwindow.cpp +++ b/src/app/valentina/mainwindow.cpp @@ -360,14 +360,6 @@ bool MainWindow::LoadMeasurements(const QString &path) } return false; } - QString shownName = strippedName(curFile); - if (curFile.isEmpty()) - { - shownName = tr("untitled.val"); - } - shownName += "[*]"; - shownName += " [" + strippedName(path) + "[*]]"; - setWindowTitle(shownName); return true; } @@ -1121,6 +1113,8 @@ void MainWindow::LoadIndividual() ui->actionShowM->setEnabled(true); helpLabel->setText(tr("Measurements loaded")); doc->LiteParseTree(Document::LiteParse); + + UpdateWindowTitle(); } } } @@ -1148,6 +1142,8 @@ void MainWindow::LoadStandard() ui->actionShowM->setEnabled(true); helpLabel->setText(tr("Measurements loaded")); doc->LiteParseTree(Document::LiteParse); + + UpdateWindowTitle(); } } } @@ -1170,13 +1166,7 @@ void MainWindow::UnloadMeasurements() ui->actionUnloadMeasurements->setDisabled(true); helpLabel->setText(tr("Measurements unloaded")); - QString shownName = strippedName(curFile); - if (curFile.isEmpty()) - { - shownName = tr("untitled.val"); - } - shownName += "[*]"; - setWindowTitle(shownName); + UpdateWindowTitle(); } else { @@ -2810,12 +2800,7 @@ void MainWindow::setCurrentFile(const QString &fileName) curFile = fileName; qApp->getUndoStack()->setClean(); - QString shownName = StrippedName(curFile); - if (curFile.isEmpty()) - { - shownName = tr("untitled.val"); - } - else + if (not curFile.isEmpty()) { qCDebug(vMainWindow, "Updating recent file list."); VSettings *settings = qApp->ValentinaSettings(); @@ -2836,14 +2821,8 @@ void MainWindow::setCurrentFile(const QString &fileName) restoreFiles.prepend(fileName); settings->SetRestoreFileList(restoreFiles); } - shownName+="[*]"; - QString path = AbsoluteMPath(fileName, doc->MPath()); - if(not path.isEmpty()) - { - shownName += " [" + strippedName(path) + "[*]]"; - } - setWindowTitle(shownName); + UpdateWindowTitle(); } //--------------------------------------------------------------------------------------------------------------------- @@ -3889,3 +3868,45 @@ void MainWindow::ProcessCMD() qApp->exit(V_EX_OK);// close program after processing in console mode } } + +//--------------------------------------------------------------------------------------------------------------------- +QString MainWindow::GetPatternFileName() +{ + QString shownName = tr("untitled.val"); + if(not curFile.isEmpty()) + { + shownName = StrippedName(curFile); + } + shownName += "[*]"; + return shownName; +} + +//--------------------------------------------------------------------------------------------------------------------- +QString MainWindow::GetMeasurementFileName() +{ + if(doc->MPath().isEmpty()) + { + return ""; + } + else + { + QString shownName = " ["; + shownName += StrippedName(AbsoluteMPath(curFile, doc->MPath())); + + if(mChanges) + { + shownName += "[*]"; + } + + shownName += "]"; + return shownName; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void MainWindow::UpdateWindowTitle() +{ + QString shownName = GetPatternFileName(); + shownName += GetMeasurementFileName(); + setWindowTitle(shownName); +} diff --git a/src/app/valentina/mainwindow.h b/src/app/valentina/mainwindow.h index 0650b337c..19c05e5fa 100644 --- a/src/app/valentina/mainwindow.h +++ b/src/app/valentina/mainwindow.h @@ -310,6 +310,11 @@ private: void SetSize(const QString &text); void SetHeight(const QString & text); + + QString GetPatternFileName(); + QString GetMeasurementFileName(); + + void UpdateWindowTitle(); }; #endif // MAINWINDOW_H From 76f4753773127beee2a2bf2743f1adcca6f841a7 Mon Sep 17 00:00:00 2001 From: Valentina Zhuravska Date: Fri, 6 Nov 2015 05:31:37 +0200 Subject: [PATCH 3/6] UpdateWindowTitle in one string --HG-- branch : feature --- src/app/valentina/mainwindow.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/app/valentina/mainwindow.cpp b/src/app/valentina/mainwindow.cpp index 6cfc3c3a7..4d989d29c 100644 --- a/src/app/valentina/mainwindow.cpp +++ b/src/app/valentina/mainwindow.cpp @@ -3906,7 +3906,5 @@ QString MainWindow::GetMeasurementFileName() //--------------------------------------------------------------------------------------------------------------------- void MainWindow::UpdateWindowTitle() { - QString shownName = GetPatternFileName(); - shownName += GetMeasurementFileName(); - setWindowTitle(shownName); + setWindowTitle(qvariant_cast(GetPatternFileName()+GetMeasurementFileName())); } From fa032fced2228870cd3b73761e1db1bd8ab132ed Mon Sep 17 00:00:00 2001 From: Valentina Zhuravska Date: Fri, 6 Nov 2015 15:52:58 +0200 Subject: [PATCH 4/6] Fixed GetMeasurementFileName --HG-- branch : feature --- src/app/valentina/mainwindow.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/app/valentina/mainwindow.cpp b/src/app/valentina/mainwindow.cpp index 4d989d29c..28734ed14 100644 --- a/src/app/valentina/mainwindow.cpp +++ b/src/app/valentina/mainwindow.cpp @@ -1226,6 +1226,7 @@ void MainWindow::MeasurementsChanged(const QString &path) if (checkFile.exists()) { mChanges = true; + UpdateWindowTitle(); } else { @@ -1264,6 +1265,7 @@ void MainWindow::SyncMeasurements() VWidgetPopup::PopupMessage(this, msg); doc->LiteParseTree(Document::LiteParse); mChanges = false; + UpdateWindowTitle(); } else { @@ -3895,7 +3897,7 @@ QString MainWindow::GetMeasurementFileName() if(mChanges) { - shownName += "[*]"; + shownName += "*"; } shownName += "]"; @@ -3906,5 +3908,5 @@ QString MainWindow::GetMeasurementFileName() //--------------------------------------------------------------------------------------------------------------------- void MainWindow::UpdateWindowTitle() { - setWindowTitle(qvariant_cast(GetPatternFileName()+GetMeasurementFileName())); + setWindowTitle(GetPatternFileName()+GetMeasurementFileName()); } From 0c23f86886f07579f2e1cb3eb998f2dd751636d9 Mon Sep 17 00:00:00 2001 From: Valentina Zhuravska Date: Fri, 6 Nov 2015 16:06:32 +0200 Subject: [PATCH 5/6] UpdateWindowTitle at the end of MeasurementsChanged method --HG-- branch : feature --- src/app/valentina/mainwindow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/valentina/mainwindow.cpp b/src/app/valentina/mainwindow.cpp index 28734ed14..8c45a30b1 100644 --- a/src/app/valentina/mainwindow.cpp +++ b/src/app/valentina/mainwindow.cpp @@ -1226,7 +1226,6 @@ void MainWindow::MeasurementsChanged(const QString &path) if (checkFile.exists()) { mChanges = true; - UpdateWindowTitle(); } else { @@ -1244,6 +1243,7 @@ void MainWindow::MeasurementsChanged(const QString &path) } } + UpdateWindowTitle(); ToggleMSync(true); } From bfc6a525ed8559de224455bb85264773ee71552e Mon Sep 17 00:00:00 2001 From: Valentina Zhuravska Date: Fri, 6 Nov 2015 17:42:52 +0200 Subject: [PATCH 6/6] Fixed print on Windows --HG-- branch : develop --- src/app/valentina/mainwindowsnogui.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/app/valentina/mainwindowsnogui.cpp b/src/app/valentina/mainwindowsnogui.cpp index 98947e9ee..e7188d6f3 100644 --- a/src/app/valentina/mainwindowsnogui.cpp +++ b/src/app/valentina/mainwindowsnogui.cpp @@ -867,7 +867,11 @@ void MainWindowsNoGUI::SetPrinterSettings(QPrinter *printer) FromPixel(paper->rect().height(), Unit::Mm)), QPrinter::Millimeter ); } + #ifdef Q_OS_WIN + printer->setOutputFileName(QDir::homePath() + QDir::separator() + FileName()); + #else printer->setOutputFileName(QDir::homePath() + QDir::separator() + FileName() + QLatin1Literal(".pdf")); + #endif printer->setDocName(FileName()); IsLayoutGrayscale() ? printer->setColorMode(QPrinter::GrayScale) : printer->setColorMode(QPrinter::Color);