From 62a6fcce4442c7277af7ca8bc0ffa21daef18f87 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Sun, 23 Aug 2015 14:01:02 +0300 Subject: [PATCH] Sync measurements. --HG-- branch : feature --- src/app/valentina/mainwindow.cpp | 45 +++++++++++++----- src/app/valentina/mainwindow.h | 4 ++ src/app/valentina/mainwindow.ui | 22 +++++++-- src/libs/vmisc/share/resources/icon.qrc | 1 + .../share/resources/icon/32x32/syncM.png | Bin 0 -> 837 bytes 5 files changed, 55 insertions(+), 17 deletions(-) create mode 100644 src/libs/vmisc/share/resources/icon/32x32/syncM.png diff --git a/src/app/valentina/mainwindow.cpp b/src/app/valentina/mainwindow.cpp index 32c321f0b..2010b142e 100644 --- a/src/app/valentina/mainwindow.cpp +++ b/src/app/valentina/mainwindow.cpp @@ -80,7 +80,8 @@ Q_LOGGING_CATEGORY(vMainWindow, "v.mainwindow") MainWindow::MainWindow(QWidget *parent) :MainWindowsNoGUI(parent), ui(new Ui::MainWindow), watcher(new QFileSystemWatcher(this)), currentTool(Tool::Arrow), lastUsedTool(Tool::Arrow), sceneDraw(nullptr), sceneDetails(nullptr), - mouseCoordinate(nullptr), helpLabel(nullptr), isInitialized(false), dialogTable(nullptr), dialogTool(nullptr), + mouseCoordinate(nullptr), helpLabel(nullptr), isInitialized(false), mChanges(false), dialogTable(nullptr), + dialogTool(nullptr), dialogHistory(nullptr), comboBoxDraws(nullptr), mode(Draw::Calculation), currentDrawIndex(0), currentToolBoxIndex(0), drawMode(true), recentFileActs(), separatorAct(nullptr), @@ -305,6 +306,19 @@ bool MainWindow::LoadMeasurements(const QString &path) return true; } +//--------------------------------------------------------------------------------------------------------------------- +void MainWindow::ToggleMSync(bool toggle) +{ + if (mChanges) + { + ui->actionSyncMeasurements->setEnabled(toggle); + } + else + { + ui->actionSyncMeasurements->setEnabled(false); + } +} + //--------------------------------------------------------------------------------------------------------------------- /** * @brief OptionDraw help change name of pattern piece. @@ -1062,7 +1076,7 @@ void MainWindow::ShowMeasurements() //--------------------------------------------------------------------------------------------------------------------- void MainWindow::MeasurementsChanged(const QString &path) { - bool mChanges = false; + mChanges = false; QFileInfo checkFile(path); if (checkFile.exists()) { @@ -1084,24 +1098,27 @@ void MainWindow::MeasurementsChanged(const QString &path) } } + ToggleMSync(true); +} + +//--------------------------------------------------------------------------------------------------------------------- +void MainWindow::SyncMeasurements() +{ if (mChanges) { - QMessageBox::StandardButton reply = QMessageBox::question(this, tr("Update measurements"), - tr("Measurement file was changed. Do you want to update?"), - QMessageBox::Yes|QMessageBox::No); - if (reply == QMessageBox::Yes) + if(LoadMeasurements(doc->MPath())) { - if(LoadMeasurements(path)) + if (not watcher->files().contains(doc->MPath())) { - if (not watcher->files().contains(path)) - { - watcher->addPath(path); - } - helpLabel->setText(tr("Measurements updated")); - doc->LiteParseTree(Document::LiteParse); + watcher->addPath(doc->MPath()); } + helpLabel->setText(tr("Measurements updated")); + doc->LiteParseTree(Document::LiteParse); + mChanges = false; } } + + ToggleMSync(false); } //--------------------------------------------------------------------------------------------------------------------- @@ -2888,6 +2905,8 @@ void MainWindow::CreateActions() recentFileActs[i]->setVisible(false); connect(recentFileActs[i], &QAction::triggered, this, &MainWindow::OpenRecentFile); } + + connect(ui->actionSyncMeasurements, &QAction::triggered, this, &MainWindow::SyncMeasurements); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/valentina/mainwindow.h b/src/app/valentina/mainwindow.h index 617652ce8..971f35ea0 100644 --- a/src/app/valentina/mainwindow.h +++ b/src/app/valentina/mainwindow.h @@ -167,6 +167,7 @@ private slots: void CreateMeasurements(); void ShowMeasurements(); void MeasurementsChanged(const QString &path); + void SyncMeasurements(); private: Q_DISABLE_COPY(MainWindow) /** @brief ui keeps information about user interface */ @@ -194,6 +195,7 @@ private: /** @brief isInitialized true after first show window. */ bool isInitialized; + bool mChanges; DialogIncrements *dialogTable; DialogTool *dialogTool; @@ -294,6 +296,8 @@ private: void InitScenes(); bool LoadMeasurements(const QString &path); + + void ToggleMSync(bool toggle); }; #endif // MAINWINDOW_H diff --git a/src/app/valentina/mainwindow.ui b/src/app/valentina/mainwindow.ui index 683994f8a..26788adb6 100644 --- a/src/app/valentina/mainwindow.ui +++ b/src/app/valentina/mainwindow.ui @@ -372,7 +372,7 @@ 0 0 - 117 + 130 58 @@ -458,7 +458,7 @@ 0 0 - 117 + 130 156 @@ -622,7 +622,7 @@ 0 0 - 117 + 130 196 @@ -864,7 +864,7 @@ 0 0 - 117 + 130 58 @@ -1089,6 +1089,7 @@ + @@ -1139,6 +1140,7 @@ + @@ -1893,6 +1895,18 @@ Show measurements + + + false + + + + :/icon/32x32/syncM.png:/icon/32x32/syncM.png + + + Sync measurements + + diff --git a/src/libs/vmisc/share/resources/icon.qrc b/src/libs/vmisc/share/resources/icon.qrc index b9c6b0aaa..5720f89cf 100644 --- a/src/libs/vmisc/share/resources/icon.qrc +++ b/src/libs/vmisc/share/resources/icon.qrc @@ -50,5 +50,6 @@ icon/24x24/left_to_right_arrow.png icon/24x24/right_to_left_arrow.png icon/32x32/clockwise.png + icon/32x32/syncM.png diff --git a/src/libs/vmisc/share/resources/icon/32x32/syncM.png b/src/libs/vmisc/share/resources/icon/32x32/syncM.png new file mode 100644 index 0000000000000000000000000000000000000000..71417f6a79d6935a449f51f0a5f347481fcd414b GIT binary patch literal 837 zcmV-L1G@Z)P)JIf7A~Zc34#m)(JU7g6bU(tqCY5xkQPG((H}MaP|(6$ zR1`tfCK!SW3m3J>MYKqfh!Bwo5fN!|uR6>(*S>rGdROb8yby}Dgp0C}&u(Gl_#FZBV zafE*c)_6lxM6qyP3p1&#Yyv(213-@!=2O7e5#T1#hmHabT9|QnPACS>1<1#MRxQk+ zW19eaNQii4rHskvPy^_A%{)rHMODBsQ0|zgffg;yKtOCFl$CWvJLDeYG_Y0+GcsrJ zV_=_04xrPL188A}0OgrWfo|8}3+V9P$AL>}$sOD#I(rvwK>^CjQlQD3{B$XWMhi0y z^n2zyW#x)I0l+GvEpqWLEBPWmazJfJKviI|zkOK{@-fe~lyY1YxB|uk<26O#2>F=j zas_-R%62Zc6hS~s!1gsyKpe6D|K1*#<4lPEtUaE2$W6z73_SDRD}mEl1rYTR{t-NJ zUwi?5z#q?cCaIDwhPa|?&pZv>PZSVu%~fwvDX=wxB&V!Aq^#WJ*&BgZFKd?g`_b-vY<9Fn!)wIZ??z z!9wP|5kI#RPH0nr2o<%&rc_zETnqEtv+W?N@oCz$NuW~;^D;D8P+P97TnStQx>68B zlw0;{VLm2JC^Qx42=|9cm?G*C8x|vnls6+~WfyP-s16Lz0E0xi