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;
|
||||
w.setWindowState(w.windowState() ^ Qt::WindowMaximized);
|
||||
app.setWindowIcon(QIcon(":/icon/64x64/icon64x64.png"));
|
||||
app.setMainWindow(&w);
|
||||
TableWindow table;
|
||||
QObject::connect(&w, &MainWindow::ModelChosen, &table, &TableWindow::ModelChosen);
|
||||
QObject::connect(&table, &TableWindow::closed, &w, &MainWindow::tableClosed);
|
||||
|
|
|
@ -196,14 +196,14 @@ qreal VDrawTool::CheckFormula(QString &formula, VContainer *data)
|
|||
Q_UNUSED(e)
|
||||
delete cal;
|
||||
|
||||
DialogUndo *dialogUndo = new DialogUndo();
|
||||
DialogUndo *dialogUndo = new DialogUndo(qApp->getMainWindow());
|
||||
if (dialogUndo->exec() == QDialog::Accepted)
|
||||
{
|
||||
UndoButton resultUndo = dialogUndo->Result();
|
||||
delete dialogUndo;
|
||||
if (resultUndo == UndoButton::Fix)
|
||||
{
|
||||
DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data);
|
||||
DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, qApp->getMainWindow());
|
||||
dialog->setFormula(formula);
|
||||
if (dialog->exec() == QDialog::Accepted)
|
||||
{
|
||||
|
|
|
@ -118,9 +118,7 @@ protected:
|
|||
QAction *selectedAction = menu.exec(event->screenPos());
|
||||
if (selectedAction == actionOption)
|
||||
{
|
||||
QGraphicsScene *scene = tool->scene();
|
||||
QList<QGraphicsView *> list = scene->views();
|
||||
dialog = new Dialog(getData(), list.first());
|
||||
dialog = new Dialog(getData(), qApp->getMainWindow());
|
||||
dialog->setModal(true);
|
||||
|
||||
connect(qobject_cast< VMainGraphicsScene * >(tool->scene()),
|
||||
|
|
|
@ -405,9 +405,7 @@ void VToolDetail::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
|||
QAction *selectedAction = menu.exec(event->screenPos());
|
||||
if (selectedAction == actionOption)
|
||||
{
|
||||
QGraphicsScene *scene = this->scene();
|
||||
QList<QGraphicsView *> list = scene->views();
|
||||
dialog = new DialogDetail(getData(), list.first());
|
||||
dialog = new DialogDetail(getData(), qApp->getMainWindow());
|
||||
dialog->setModal(true);
|
||||
connect(qobject_cast< VMainGraphicsScene * >(this->scene()), &VMainGraphicsScene::ChoosedObject,
|
||||
dialog, &DialogTool::ChoosedObject);
|
||||
|
|
|
@ -58,7 +58,8 @@ VApplication::VApplication(int &argc, char **argv)
|
|||
_widthMainLine(DefWidth), _widthHairLine(DefWidth/3.0), measurements(QMap<QString, VTranslation>()),
|
||||
guiTexts(QMap<QString, VTranslation>()), descriptions(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);
|
||||
|
||||
|
@ -99,32 +100,32 @@ bool VApplication::notify(QObject *receiver, QEvent *event)
|
|||
}
|
||||
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();
|
||||
}
|
||||
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();
|
||||
}
|
||||
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();
|
||||
}
|
||||
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();
|
||||
}
|
||||
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();
|
||||
}
|
||||
catch (const VException &e)
|
||||
{
|
||||
e.CriticalMessageBox(tr("Something's wrong!!"));
|
||||
e.CriticalMessageBox(tr("Something's wrong!!"), mainWindow);
|
||||
return true;
|
||||
}
|
||||
catch (std::exception& e)
|
||||
|
@ -1952,3 +1953,17 @@ QString VApplication::FormulaToUser(const QString &formula)
|
|||
|
||||
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);
|
||||
QTimer *getAutoSaveTimer() const;
|
||||
void setAutoSaveTimer(QTimer *value);
|
||||
QWidget *getMainWindow() const;
|
||||
void setMainWindow(QWidget *value);
|
||||
private:
|
||||
Q_DISABLE_COPY(VApplication)
|
||||
Unit _patternUnit;
|
||||
|
@ -91,6 +93,11 @@ private:
|
|||
QUndoStack *undoStack;
|
||||
VMainGraphicsView *sceneView;
|
||||
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 InitMeasurements();
|
||||
void InitVariables();
|
||||
|
|
|
@ -636,7 +636,7 @@ bool VPattern::SaveDocument(const QString &fileName)
|
|||
}
|
||||
catch (const VExceptionWrongId &e)
|
||||
{
|
||||
e.CriticalMessageBox(tr("Error no unique id."));
|
||||
e.CriticalMessageBox(tr("Error no unique id."), qApp->getMainWindow());
|
||||
return false;
|
||||
}
|
||||
GarbageCollector();
|
||||
|
@ -665,31 +665,31 @@ void VPattern::LiteParseTree()
|
|||
}
|
||||
catch (const VExceptionObjectError &e)
|
||||
{
|
||||
e.CriticalMessageBox(tr("Error parsing file."));
|
||||
e.CriticalMessageBox(tr("Error parsing file."), qApp->getMainWindow());
|
||||
emit SetEnabledGUI(false);
|
||||
return;
|
||||
}
|
||||
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);
|
||||
return;
|
||||
}
|
||||
catch (const VExceptionEmptyParameter &e)
|
||||
{
|
||||
e.CriticalMessageBox(tr("Error empty parameter."));
|
||||
e.CriticalMessageBox(tr("Error empty parameter."), qApp->getMainWindow());
|
||||
emit SetEnabledGUI(false);
|
||||
return;
|
||||
}
|
||||
catch (const VExceptionWrongId &e)
|
||||
{
|
||||
e.CriticalMessageBox(tr("Error wrong id."));
|
||||
e.CriticalMessageBox(tr("Error wrong id."), qApp->getMainWindow());
|
||||
emit SetEnabledGUI(false);
|
||||
return;
|
||||
}
|
||||
catch (VException &e)
|
||||
{
|
||||
e.CriticalMessageBox(tr("Error parsing file."));
|
||||
e.CriticalMessageBox(tr("Error parsing file."), qApp->getMainWindow());
|
||||
emit SetEnabledGUI(false);
|
||||
return;
|
||||
}
|
||||
|
@ -698,7 +698,7 @@ void VPattern::LiteParseTree()
|
|||
#ifndef QT_NO_CURSOR
|
||||
QApplication::restoreOverrideCursor();
|
||||
#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);
|
||||
#ifndef QT_NO_CURSOR
|
||||
QApplication::setOverrideCursor(Qt::WaitCursor);
|
||||
|
|
Loading…
Reference in New Issue
Block a user