From cf84d5045f86342a04166433f1ffb0e69129d264 Mon Sep 17 00:00:00 2001 From: JayBraker Date: Mon, 17 Jan 2022 18:07:14 +0100 Subject: [PATCH] Connected helper "closeTask" to signal "aboutToQuit" so that settings will be saved if the main application gets shutdown. Reason for implementation on this level: MyMainWindow::closeEvent was not called if browser called QCoreApplication::quit(). Should adress Issue https://github.com/RobertKrajewski/Sync-my-L2P/issues/169 --- include/mymainwindow.h | 1 + src/main.cpp | 2 ++ src/mymainwindow.cpp | 5 +++++ 3 files changed, 8 insertions(+) diff --git a/include/mymainwindow.h b/include/mymainwindow.h index 4189281..3e24591 100644 --- a/include/mymainwindow.h +++ b/include/mymainwindow.h @@ -43,6 +43,7 @@ private slots: void on_langCB_currentIndexChanged(const int &lang); void showStatusMessage(QString msg); void retranslate(); + void closeTask(); private: void init(); diff --git a/src/main.cpp b/src/main.cpp index 605f8bd..999def3 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,4 +1,5 @@ #include +#include #include "mymainwindow.h" @@ -9,5 +10,6 @@ int main(int argc, char *argv[]) MyMainWindow w; w.show(); + QObject::connect(&a, SIGNAL(aboutToQuit()), &w, SLOT(closeTask())); return a.exec(); } diff --git a/src/mymainwindow.cpp b/src/mymainwindow.cpp index b645ba4..5710947 100644 --- a/src/mymainwindow.cpp +++ b/src/mymainwindow.cpp @@ -87,6 +87,11 @@ void MyMainWindow::closeEvent(QCloseEvent * event) event->accept(); } +void MyMainWindow::closeTask() +{ + saveSettings(); +} + /// Laden der gespeicherten Einstellungen aller Tabs void MyMainWindow::loadSettings() {