From 5545eafb6ed6084347ecf3b16349feb4e4969ae4 Mon Sep 17 00:00:00 2001 From: dismine Date: Thu, 23 Oct 2014 12:13:18 +0300 Subject: [PATCH] Create new process when you open new pattern and have usaved chages in current. --HG-- branch : develop --- src/app/core/vapplication.cpp | 9 ++++++++- src/app/core/vapplication.h | 2 +- src/app/main.cpp | 9 +-------- src/app/mainwindow.cpp | 19 +++++++++++++------ src/app/mainwindow.h | 1 + 5 files changed, 24 insertions(+), 16 deletions(-) diff --git a/src/app/core/vapplication.cpp b/src/app/core/vapplication.cpp index d57724f78..4913288f6 100644 --- a/src/app/core/vapplication.cpp +++ b/src/app/core/vapplication.cpp @@ -80,7 +80,14 @@ void VApplication::NewValentina(const QString &fileName) QProcess *v = new QProcess(); QStringList arguments; arguments << fileName; - v->startDetached(QCoreApplication::applicationFilePath(), arguments); + if (fileName.isEmpty()) + { + v->startDetached(QCoreApplication::applicationFilePath()); + } + else + { + v->startDetached(QCoreApplication::applicationFilePath(), arguments); + } delete v; } diff --git a/src/app/core/vapplication.h b/src/app/core/vapplication.h index 255fb22c3..768111cd0 100644 --- a/src/app/core/vapplication.h +++ b/src/app/core/vapplication.h @@ -55,7 +55,7 @@ class VApplication : public QApplication public: VApplication(int &argc, char ** argv); virtual ~VApplication() {} - static void NewValentina(const QString &fileName); + static void NewValentina(const QString &fileName = QString()); static void CheckFactor(qreal &oldFactor, const qreal &Newfactor); virtual bool notify(QObject * receiver, QEvent * event); Unit patternUnit() const; diff --git a/src/app/main.cpp b/src/app/main.cpp index 5069c2ce9..2661719d3 100644 --- a/src/app/main.cpp +++ b/src/app/main.cpp @@ -195,14 +195,7 @@ int main(int argc, char *argv[]) for (int i=0;iisWindowModified() || curFile.isEmpty() == false) - { - QProcess *v = new QProcess(this); - v->startDetached(QCoreApplication::applicationFilePath ()); - delete v; - } + OpenNewValentina(); } //--------------------------------------------------------------------------------------------------------------------- @@ -2058,6 +2053,15 @@ void MainWindow::PropertyBrowser() connect(doc, &VPattern::FullUpdateFromFile, toolOptions, &VToolOptionsPropertyBrowser::UpdateOptions); } +//--------------------------------------------------------------------------------------------------------------------- +void MainWindow::OpenNewValentina(const QString &fileName) const +{ + if (this->isWindowModified() || curFile.isEmpty() == false) + { + VApplication::NewValentina(fileName); + } +} + //--------------------------------------------------------------------------------------------------------------------- void MainWindow::CreateActions() { @@ -2166,6 +2170,9 @@ MainWindow::~MainWindow() */ void MainWindow::LoadPattern(const QString &fileName) { + //We have unsaved changes or load more then one file per time + OpenNewValentina(fileName); + // On this stage scene empty. Fit scene size to view size VAbstractTool::NewSceneRect(sceneDraw, ui->view); VAbstractTool::NewSceneRect(sceneDetails, ui->view); diff --git a/src/app/mainwindow.h b/src/app/mainwindow.h index 57279c026..4dd5c72d3 100644 --- a/src/app/mainwindow.h +++ b/src/app/mainwindow.h @@ -252,6 +252,7 @@ private: void AddDocks(); void PropertyBrowser(); + void OpenNewValentina(const QString &fileName = QString())const; }; #endif // MAINWINDOW_H