diff --git a/src/app/dialogs/app/dialogundo.cpp b/src/app/dialogs/app/dialogundo.cpp index f9e931f0f..7032c1a60 100644 --- a/src/app/dialogs/app/dialogundo.cpp +++ b/src/app/dialogs/app/dialogundo.cpp @@ -39,7 +39,15 @@ DialogUndo::DialogUndo(QWidget *parent) { ui->setupUi(this); - connect(ui->pushButtonUndo, &QPushButton::clicked, this, &DialogUndo::Undo); + bool opening = qApp->getOpeningPattern(); + if (opening) + { + ui->pushButtonUndo->setDisabled(opening); + } + else + { + connect(ui->pushButtonUndo, &QPushButton::clicked, this, &DialogUndo::Undo); + } connect(ui->pushButtonFix, &QPushButton::clicked, this, &DialogUndo::Fix); connect(ui->pushButtonCancel, &QPushButton::clicked, this, &DialogUndo::Cancel); } diff --git a/src/app/mainwindow.cpp b/src/app/mainwindow.cpp index 4db0f6cec..25a9b5b18 100644 --- a/src/app/mainwindow.cpp +++ b/src/app/mainwindow.cpp @@ -2194,6 +2194,7 @@ MainWindow::~MainWindow() */ void MainWindow::LoadPattern(const QString &fileName) { + qApp->setOpeningPattern();//Begin opening file try { VDomDocument::ValidateXML("://schema/pattern.xsd", fileName); @@ -2257,6 +2258,8 @@ void MainWindow::LoadPattern(const QString &fileName) PatternWasModified(patternModified); } helpLabel->setText(tr("File loaded")); + + qApp->setOpeningPattern();// End opening file } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/widgets/vapplication.cpp b/src/app/widgets/vapplication.cpp index 81d3b8bbe..44b21f9a1 100644 --- a/src/app/widgets/vapplication.cpp +++ b/src/app/widgets/vapplication.cpp @@ -59,7 +59,7 @@ VApplication::VApplication(int &argc, char **argv) guiTexts(QMap()), descriptions(QMap()), variables(QMap()), functions(QMap()), postfixOperators(QMap()), undoStack(nullptr), sceneView(nullptr), autoSaveTimer(nullptr), - mainWindow(nullptr) + mainWindow(nullptr), openingPattern(false) { undoStack = new QUndoStack(this); @@ -1967,3 +1967,16 @@ void VApplication::setMainWindow(QWidget *value) mainWindow = value; } +//--------------------------------------------------------------------------------------------------------------------- +bool VApplication::getOpeningPattern() const +{ + return openingPattern; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VApplication::setOpeningPattern() +{ + openingPattern = !openingPattern; +} + + diff --git a/src/app/widgets/vapplication.h b/src/app/widgets/vapplication.h index 37fa7eac4..59318429a 100644 --- a/src/app/widgets/vapplication.h +++ b/src/app/widgets/vapplication.h @@ -78,6 +78,8 @@ public: void setAutoSaveTimer(QTimer *value); QWidget *getMainWindow() const; void setMainWindow(QWidget *value); + bool getOpeningPattern() const; + void setOpeningPattern(); private: Q_DISABLE_COPY(VApplication) Unit _patternUnit; @@ -98,6 +100,11 @@ private: * modality doesn't work. */ QWidget *mainWindow; + /** + * @brief openingPattern true when we opening pattern. If something will be wrong in formula this help understand if + * we can allow user use Undo option. + */ + bool openingPattern; void InitLineWidth(); void InitMeasurements(); void InitVariables();