Save pointer to main window. Use when need create modal window.
--HG-- branch : develop
This commit is contained in:
parent
a4f6c2a10c
commit
e805d36114
|
@ -169,6 +169,7 @@ int main(int argc, char *argv[])
|
||||||
MainWindow w;
|
MainWindow w;
|
||||||
w.setWindowState(w.windowState() ^ Qt::WindowMaximized);
|
w.setWindowState(w.windowState() ^ Qt::WindowMaximized);
|
||||||
app.setWindowIcon(QIcon(":/icon/64x64/icon64x64.png"));
|
app.setWindowIcon(QIcon(":/icon/64x64/icon64x64.png"));
|
||||||
|
app.setMainWindow(&w);
|
||||||
TableWindow table;
|
TableWindow table;
|
||||||
QObject::connect(&w, &MainWindow::ModelChosen, &table, &TableWindow::ModelChosen);
|
QObject::connect(&w, &MainWindow::ModelChosen, &table, &TableWindow::ModelChosen);
|
||||||
QObject::connect(&table, &TableWindow::closed, &w, &MainWindow::tableClosed);
|
QObject::connect(&table, &TableWindow::closed, &w, &MainWindow::tableClosed);
|
||||||
|
|
|
@ -196,14 +196,14 @@ qreal VDrawTool::CheckFormula(QString &formula, VContainer *data)
|
||||||
Q_UNUSED(e)
|
Q_UNUSED(e)
|
||||||
delete cal;
|
delete cal;
|
||||||
|
|
||||||
DialogUndo *dialogUndo = new DialogUndo();
|
DialogUndo *dialogUndo = new DialogUndo(qApp->getMainWindow());
|
||||||
if (dialogUndo->exec() == QDialog::Accepted)
|
if (dialogUndo->exec() == QDialog::Accepted)
|
||||||
{
|
{
|
||||||
UndoButton resultUndo = dialogUndo->Result();
|
UndoButton resultUndo = dialogUndo->Result();
|
||||||
delete dialogUndo;
|
delete dialogUndo;
|
||||||
if (resultUndo == UndoButton::Fix)
|
if (resultUndo == UndoButton::Fix)
|
||||||
{
|
{
|
||||||
DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data);
|
DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, qApp->getMainWindow());
|
||||||
dialog->setFormula(formula);
|
dialog->setFormula(formula);
|
||||||
if (dialog->exec() == QDialog::Accepted)
|
if (dialog->exec() == QDialog::Accepted)
|
||||||
{
|
{
|
||||||
|
|
|
@ -118,9 +118,7 @@ protected:
|
||||||
QAction *selectedAction = menu.exec(event->screenPos());
|
QAction *selectedAction = menu.exec(event->screenPos());
|
||||||
if (selectedAction == actionOption)
|
if (selectedAction == actionOption)
|
||||||
{
|
{
|
||||||
QGraphicsScene *scene = tool->scene();
|
dialog = new Dialog(getData(), qApp->getMainWindow());
|
||||||
QList<QGraphicsView *> list = scene->views();
|
|
||||||
dialog = new Dialog(getData(), list.first());
|
|
||||||
dialog->setModal(true);
|
dialog->setModal(true);
|
||||||
|
|
||||||
connect(qobject_cast< VMainGraphicsScene * >(tool->scene()),
|
connect(qobject_cast< VMainGraphicsScene * >(tool->scene()),
|
||||||
|
|
|
@ -405,9 +405,7 @@ void VToolDetail::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
||||||
QAction *selectedAction = menu.exec(event->screenPos());
|
QAction *selectedAction = menu.exec(event->screenPos());
|
||||||
if (selectedAction == actionOption)
|
if (selectedAction == actionOption)
|
||||||
{
|
{
|
||||||
QGraphicsScene *scene = this->scene();
|
dialog = new DialogDetail(getData(), qApp->getMainWindow());
|
||||||
QList<QGraphicsView *> list = scene->views();
|
|
||||||
dialog = new DialogDetail(getData(), list.first());
|
|
||||||
dialog->setModal(true);
|
dialog->setModal(true);
|
||||||
connect(qobject_cast< VMainGraphicsScene * >(this->scene()), &VMainGraphicsScene::ChoosedObject,
|
connect(qobject_cast< VMainGraphicsScene * >(this->scene()), &VMainGraphicsScene::ChoosedObject,
|
||||||
dialog, &DialogTool::ChoosedObject);
|
dialog, &DialogTool::ChoosedObject);
|
||||||
|
|
|
@ -58,7 +58,8 @@ VApplication::VApplication(int &argc, char **argv)
|
||||||
_widthMainLine(DefWidth), _widthHairLine(DefWidth/3.0), measurements(QMap<QString, VTranslation>()),
|
_widthMainLine(DefWidth), _widthHairLine(DefWidth/3.0), measurements(QMap<QString, VTranslation>()),
|
||||||
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)
|
||||||
{
|
{
|
||||||
undoStack = new QUndoStack(this);
|
undoStack = new QUndoStack(this);
|
||||||
|
|
||||||
|
@ -99,32 +100,32 @@ bool VApplication::notify(QObject *receiver, QEvent *event)
|
||||||
}
|
}
|
||||||
catch (const VExceptionObjectError &e)
|
catch (const VExceptionObjectError &e)
|
||||||
{
|
{
|
||||||
e.CriticalMessageBox(tr("Error parsing file. Program will be terminated."));
|
e.CriticalMessageBox(tr("Error parsing file. Program will be terminated."), mainWindow);
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
catch (const VExceptionBadId &e)
|
catch (const VExceptionBadId &e)
|
||||||
{
|
{
|
||||||
e.CriticalMessageBox(tr("Error bad id. Program will be terminated."));
|
e.CriticalMessageBox(tr("Error bad id. Program will be terminated."), mainWindow);
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
catch (const VExceptionConversionError &e)
|
catch (const VExceptionConversionError &e)
|
||||||
{
|
{
|
||||||
e.CriticalMessageBox(tr("Error can't convert value. Program will be terminated."));
|
e.CriticalMessageBox(tr("Error can't convert value. Program will be terminated."), mainWindow);
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
catch (const VExceptionEmptyParameter &e)
|
catch (const VExceptionEmptyParameter &e)
|
||||||
{
|
{
|
||||||
e.CriticalMessageBox(tr("Error empty parameter. Program will be terminated."));
|
e.CriticalMessageBox(tr("Error empty parameter. Program will be terminated."), mainWindow);
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
catch (const VExceptionWrongId &e)
|
catch (const VExceptionWrongId &e)
|
||||||
{
|
{
|
||||||
e.CriticalMessageBox(tr("Error wrong id. Program will be terminated."));
|
e.CriticalMessageBox(tr("Error wrong id. Program will be terminated."), mainWindow);
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
catch (const VException &e)
|
catch (const VException &e)
|
||||||
{
|
{
|
||||||
e.CriticalMessageBox(tr("Something's wrong!!"));
|
e.CriticalMessageBox(tr("Something's wrong!!"), mainWindow);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
catch (std::exception& e)
|
catch (std::exception& e)
|
||||||
|
@ -1952,3 +1953,17 @@ QString VApplication::FormulaToUser(const QString &formula)
|
||||||
|
|
||||||
return newFormula;
|
return newFormula;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QWidget *VApplication::getMainWindow() const
|
||||||
|
{
|
||||||
|
return mainWindow;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VApplication::setMainWindow(QWidget *value)
|
||||||
|
{
|
||||||
|
SCASSERT(value != nullptr)
|
||||||
|
mainWindow = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -76,6 +76,8 @@ public:
|
||||||
void setSceneView(VMainGraphicsView *value);
|
void setSceneView(VMainGraphicsView *value);
|
||||||
QTimer *getAutoSaveTimer() const;
|
QTimer *getAutoSaveTimer() const;
|
||||||
void setAutoSaveTimer(QTimer *value);
|
void setAutoSaveTimer(QTimer *value);
|
||||||
|
QWidget *getMainWindow() const;
|
||||||
|
void setMainWindow(QWidget *value);
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(VApplication)
|
Q_DISABLE_COPY(VApplication)
|
||||||
Unit _patternUnit;
|
Unit _patternUnit;
|
||||||
|
@ -91,6 +93,11 @@ private:
|
||||||
QUndoStack *undoStack;
|
QUndoStack *undoStack;
|
||||||
VMainGraphicsView *sceneView;
|
VMainGraphicsView *sceneView;
|
||||||
QTimer *autoSaveTimer;
|
QTimer *autoSaveTimer;
|
||||||
|
/**
|
||||||
|
* @brief mainWindow pointer to main window. Usefull if need create modal dialog. Without pointer to main window
|
||||||
|
* modality doesn't work.
|
||||||
|
*/
|
||||||
|
QWidget *mainWindow;
|
||||||
void InitLineWidth();
|
void InitLineWidth();
|
||||||
void InitMeasurements();
|
void InitMeasurements();
|
||||||
void InitVariables();
|
void InitVariables();
|
||||||
|
|
|
@ -636,7 +636,7 @@ bool VPattern::SaveDocument(const QString &fileName)
|
||||||
}
|
}
|
||||||
catch (const VExceptionWrongId &e)
|
catch (const VExceptionWrongId &e)
|
||||||
{
|
{
|
||||||
e.CriticalMessageBox(tr("Error no unique id."));
|
e.CriticalMessageBox(tr("Error no unique id."), qApp->getMainWindow());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
GarbageCollector();
|
GarbageCollector();
|
||||||
|
@ -665,31 +665,31 @@ void VPattern::LiteParseTree()
|
||||||
}
|
}
|
||||||
catch (const VExceptionObjectError &e)
|
catch (const VExceptionObjectError &e)
|
||||||
{
|
{
|
||||||
e.CriticalMessageBox(tr("Error parsing file."));
|
e.CriticalMessageBox(tr("Error parsing file."), qApp->getMainWindow());
|
||||||
emit SetEnabledGUI(false);
|
emit SetEnabledGUI(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
catch (const VExceptionConversionError &e)
|
catch (const VExceptionConversionError &e)
|
||||||
{
|
{
|
||||||
e.CriticalMessageBox(tr("Error can't convert value."));
|
e.CriticalMessageBox(tr("Error can't convert value."), qApp->getMainWindow());
|
||||||
emit SetEnabledGUI(false);
|
emit SetEnabledGUI(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
catch (const VExceptionEmptyParameter &e)
|
catch (const VExceptionEmptyParameter &e)
|
||||||
{
|
{
|
||||||
e.CriticalMessageBox(tr("Error empty parameter."));
|
e.CriticalMessageBox(tr("Error empty parameter."), qApp->getMainWindow());
|
||||||
emit SetEnabledGUI(false);
|
emit SetEnabledGUI(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
catch (const VExceptionWrongId &e)
|
catch (const VExceptionWrongId &e)
|
||||||
{
|
{
|
||||||
e.CriticalMessageBox(tr("Error wrong id."));
|
e.CriticalMessageBox(tr("Error wrong id."), qApp->getMainWindow());
|
||||||
emit SetEnabledGUI(false);
|
emit SetEnabledGUI(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
catch (VException &e)
|
catch (VException &e)
|
||||||
{
|
{
|
||||||
e.CriticalMessageBox(tr("Error parsing file."));
|
e.CriticalMessageBox(tr("Error parsing file."), qApp->getMainWindow());
|
||||||
emit SetEnabledGUI(false);
|
emit SetEnabledGUI(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -698,7 +698,7 @@ void VPattern::LiteParseTree()
|
||||||
#ifndef QT_NO_CURSOR
|
#ifndef QT_NO_CURSOR
|
||||||
QApplication::restoreOverrideCursor();
|
QApplication::restoreOverrideCursor();
|
||||||
#endif
|
#endif
|
||||||
QMessageBox::critical(nullptr, tr("Critical error!"), tr("Error parsing file (std::bad_alloc)."),
|
QMessageBox::critical(qApp->getMainWindow(), tr("Critical error!"), tr("Error parsing file (std::bad_alloc)."),
|
||||||
QMessageBox::Ok, QMessageBox::Ok);
|
QMessageBox::Ok, QMessageBox::Ok);
|
||||||
#ifndef QT_NO_CURSOR
|
#ifndef QT_NO_CURSOR
|
||||||
QApplication::setOverrideCursor(Qt::WaitCursor);
|
QApplication::setOverrideCursor(Qt::WaitCursor);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user