Refactor AboutToQuit.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2019-07-01 12:47:06 +03:00
parent 4ab84bce38
commit c536c40628
7 changed files with 34 additions and 7 deletions

View File

@ -486,6 +486,15 @@ bool MApplication::event(QEvent *e)
return VAbstractApplication::event(e);
}
//---------------------------------------------------------------------------------------------------------------------
void MApplication::AboutToQuit()
{
// If try to use the method QApplication::exit program can't sync settings and show warning about QApplication
// instance. Solution is to call sync() before quit.
// Connect this slot with VApplication::aboutToQuit.
Settings()->sync();
}
//---------------------------------------------------------------------------------------------------------------------
void MApplication::OpenSettings()
{

View File

@ -85,6 +85,9 @@ protected:
virtual void InitTrVars() override;
virtual bool event(QEvent *e) override;
protected slots:
virtual void AboutToQuit() override;
private slots:
void NewLocalSocketConnection();

View File

@ -709,6 +709,15 @@ bool VApplication::event(QEvent *e)
return VAbstractApplication::event(e);
}
//---------------------------------------------------------------------------------------------------------------------
void VApplication::AboutToQuit()
{
// If try to use the method QApplication::exit program can't sync settings and show warning about QApplication
// instance. Solution is to call sync() before quit.
// Connect this slot with VApplication::aboutToQuit.
Settings()->sync();
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief OpenSettings get acsses to application settings.

View File

@ -82,6 +82,9 @@ protected:
virtual void InitTrVars() override;
virtual bool event(QEvent *e) override;
protected slots:
virtual void AboutToQuit() override;
private:
Q_DISABLE_COPY(VApplication)
VTranslateVars *trVars;

View File

@ -41,6 +41,7 @@ class VTestSettings;
class TestVApplication : public VAbstractApplication
{
Q_OBJECT
public:
TestVApplication(int &argc, char ** argv)
: VAbstractApplication(argc, argv),
@ -77,6 +78,11 @@ public:
{
m_trVars = trVars;
}
protected slots:
virtual void AboutToQuit() override
{}
private:
Q_DISABLE_COPY(TestVApplication)
VTranslateVars *m_trVars;

View File

@ -100,13 +100,7 @@ VAbstractApplication::VAbstractApplication(int &argc, char **argv)
setAttribute(Qt::AA_UseHighDpiPixmaps);
#endif
connect(this, &QApplication::aboutToQuit, this, [this]()
{
// If try to use the method QApplication::exit program can't sync settings and show warning about QApplication
// instance. Solution is to call sync() before quit.
// Connect this slot with VApplication::aboutToQuit.
Settings()->sync();
});
connect(this, &QApplication::aboutToQuit, this, &VAbstractApplication::AboutToQuit);
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -146,6 +146,9 @@ protected:
virtual void InitTrVars()=0;
protected slots:
virtual void AboutToQuit()=0;
private:
Q_DISABLE_COPY(VAbstractApplication)
Unit _patternUnit;