We can't Undo if only opening pattern.

--HG--
branch : develop
This commit is contained in:
dismine 2014-07-08 14:26:13 +03:00
parent e805d36114
commit 354d722fd2
4 changed files with 33 additions and 2 deletions

View File

@ -39,7 +39,15 @@ DialogUndo::DialogUndo(QWidget *parent)
{ {
ui->setupUi(this); 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->pushButtonFix, &QPushButton::clicked, this, &DialogUndo::Fix);
connect(ui->pushButtonCancel, &QPushButton::clicked, this, &DialogUndo::Cancel); connect(ui->pushButtonCancel, &QPushButton::clicked, this, &DialogUndo::Cancel);
} }

View File

@ -2194,6 +2194,7 @@ MainWindow::~MainWindow()
*/ */
void MainWindow::LoadPattern(const QString &fileName) void MainWindow::LoadPattern(const QString &fileName)
{ {
qApp->setOpeningPattern();//Begin opening file
try try
{ {
VDomDocument::ValidateXML("://schema/pattern.xsd", fileName); VDomDocument::ValidateXML("://schema/pattern.xsd", fileName);
@ -2257,6 +2258,8 @@ void MainWindow::LoadPattern(const QString &fileName)
PatternWasModified(patternModified); PatternWasModified(patternModified);
} }
helpLabel->setText(tr("File loaded")); helpLabel->setText(tr("File loaded"));
qApp->setOpeningPattern();// End opening file
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -59,7 +59,7 @@ VApplication::VApplication(int &argc, char **argv)
guiTexts(QMap<QString, VTranslation>()), descriptions(QMap<QString, VTranslation>()), guiTexts(QMap<QString, VTranslation>()), descriptions(QMap<QString, VTranslation>()),
variables(QMap<QString, VTranslation>()), functions(QMap<QString, VTranslation>()), variables(QMap<QString, VTranslation>()), functions(QMap<QString, VTranslation>()),
postfixOperators(QMap<QString, VTranslation>()), undoStack(nullptr), sceneView(nullptr), autoSaveTimer(nullptr), postfixOperators(QMap<QString, VTranslation>()), undoStack(nullptr), sceneView(nullptr), autoSaveTimer(nullptr),
mainWindow(nullptr) mainWindow(nullptr), openingPattern(false)
{ {
undoStack = new QUndoStack(this); undoStack = new QUndoStack(this);
@ -1967,3 +1967,16 @@ void VApplication::setMainWindow(QWidget *value)
mainWindow = value; mainWindow = value;
} }
//---------------------------------------------------------------------------------------------------------------------
bool VApplication::getOpeningPattern() const
{
return openingPattern;
}
//---------------------------------------------------------------------------------------------------------------------
void VApplication::setOpeningPattern()
{
openingPattern = !openingPattern;
}

View File

@ -78,6 +78,8 @@ public:
void setAutoSaveTimer(QTimer *value); void setAutoSaveTimer(QTimer *value);
QWidget *getMainWindow() const; QWidget *getMainWindow() const;
void setMainWindow(QWidget *value); void setMainWindow(QWidget *value);
bool getOpeningPattern() const;
void setOpeningPattern();
private: private:
Q_DISABLE_COPY(VApplication) Q_DISABLE_COPY(VApplication)
Unit _patternUnit; Unit _patternUnit;
@ -98,6 +100,11 @@ private:
* modality doesn't work. * modality doesn't work.
*/ */
QWidget *mainWindow; 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 InitLineWidth();
void InitMeasurements(); void InitMeasurements();
void InitVariables(); void InitVariables();