Grab user attention if measurements was changed. Related to issue #440.
--HG-- branch : develop
This commit is contained in:
parent
e67b6b5805
commit
5ec4f51601
|
@ -1,4 +1,5 @@
|
|||
# Version 0.5.0
|
||||
- Show additional message dialog if measurements was changed. Related to issue [#440].
|
||||
- [#132] Intersect Curves.
|
||||
- Added language Chinese (China).
|
||||
- New icon for VAL file. Updated Tape logo. Updated ico for standard measurements.
|
||||
|
|
|
@ -98,7 +98,8 @@ const QString autosavePrefix = QStringLiteral(".autosave");
|
|||
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), mChanges(false), patternReadOnly(false),
|
||||
mouseCoordinate(nullptr), helpLabel(nullptr), isInitialized(false), mChanges(false), mChangesAsked(true),
|
||||
patternReadOnly(false),
|
||||
dialogTable(nullptr),
|
||||
dialogTool(nullptr),
|
||||
dialogHistory(nullptr), comboBoxDraws(nullptr), patternPieceLabel(nullptr), mode(Draw::Calculation),
|
||||
|
@ -150,6 +151,7 @@ MainWindow::MainWindow(QWidget *parent)
|
|||
ui->dockWidgetLayoutPages->setVisible(false);
|
||||
|
||||
connect(watcher, &QFileSystemWatcher::fileChanged, this, &MainWindow::MeasurementsChanged);
|
||||
connect(qApp, &QApplication::focusChanged, this, &MainWindow::OnWindowFocusChanged);
|
||||
|
||||
#if defined(Q_OS_MAC)
|
||||
// On Mac deafault icon size is 32x32.
|
||||
|
@ -1358,6 +1360,7 @@ void MainWindow::MeasurementsChanged(const QString &path)
|
|||
if (checkFile.exists())
|
||||
{
|
||||
mChanges = true;
|
||||
mChangesAsked = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1366,6 +1369,7 @@ void MainWindow::MeasurementsChanged(const QString &path)
|
|||
if (checkFile.exists())
|
||||
{
|
||||
mChanges = true;
|
||||
mChangesAsked = false;
|
||||
break;
|
||||
}
|
||||
else
|
||||
|
@ -1397,6 +1401,7 @@ void MainWindow::SyncMeasurements()
|
|||
VWidgetPopup::PopupMessage(this, msg);
|
||||
doc->LiteParseTree(Document::LiteParse);
|
||||
mChanges = false;
|
||||
mChangesAsked = true;
|
||||
UpdateWindowTitle();
|
||||
ui->actionSyncMeasurements->setEnabled(mChanges);
|
||||
}
|
||||
|
@ -1407,6 +1412,29 @@ void MainWindow::SyncMeasurements()
|
|||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void MainWindow::OnWindowFocusChanged(QWidget *old, QWidget *now)
|
||||
{
|
||||
if (old == nullptr && isAncestorOf(now) == true)
|
||||
{// focus IN
|
||||
if (mChanges && not mChangesAsked)
|
||||
{
|
||||
const auto answer = QMessageBox::question(this, tr("Measurements"),
|
||||
tr("Measurements was changed. Do you want to sync measurements now?"),
|
||||
QMessageBox::Yes|QMessageBox::No, QMessageBox::Yes);
|
||||
if (answer == QMessageBox::Yes)
|
||||
{
|
||||
SyncMeasurements();
|
||||
}
|
||||
mChangesAsked = true;
|
||||
}
|
||||
}
|
||||
|
||||
// In case we will need it
|
||||
// else if (isAncestorOf(old) == true && now == nullptr)
|
||||
// focus OUT
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
#if defined(Q_OS_MAC)
|
||||
void MainWindow::OpenAt(QAction *where)
|
||||
|
|
|
@ -172,6 +172,7 @@ private slots:
|
|||
void ShowMeasurements();
|
||||
void MeasurementsChanged(const QString &path);
|
||||
void SyncMeasurements();
|
||||
void OnWindowFocusChanged(QWidget* old, QWidget* now);
|
||||
#if defined(Q_OS_MAC)
|
||||
void OpenAt(QAction *where);
|
||||
#endif //defined(Q_OS_MAC)
|
||||
|
@ -209,6 +210,7 @@ private:
|
|||
|
||||
/** @brief mChanges true if measurement file was changed. */
|
||||
bool mChanges;
|
||||
bool mChangesAsked;
|
||||
|
||||
bool patternReadOnly;
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user