summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--api/plugin-api.cpp15
-rw-r--r--gui/options-dialog.cpp24
-rw-r--r--gui/options-dialog.hpp2
3 files changed, 29 insertions, 12 deletions
diff --git a/api/plugin-api.cpp b/api/plugin-api.cpp
index 92602b11..20c24e62 100644
--- a/api/plugin-api.cpp
+++ b/api/plugin-api.cpp
@@ -1,5 +1,7 @@
#include "plugin-api.hpp"
+using namespace plugin_api::detail;
+
// these exist so that vtable is emitted in a single compilation unit, not all of them.
Metadata::~Metadata() {}
@@ -10,9 +12,9 @@ IProtocolDialog::~IProtocolDialog() {}
ITracker::~ITracker() {}
ITrackerDialog::~ITrackerDialog() {}
-plugin_api::detail::BaseDialog::BaseDialog() {}
+BaseDialog::BaseDialog() {}
-void plugin_api::detail::BaseDialog::closeEvent(QCloseEvent*)
+void BaseDialog::closeEvent(QCloseEvent*)
{
if (isVisible())
{
@@ -29,4 +31,11 @@ IProtocolDialog::IProtocolDialog() {}
ITracker::ITracker() {}
ITrackerDialog::ITrackerDialog() {}
-void plugin_api::detail::BaseDialog::done(int) { close(); hide(); }
+void BaseDialog::done(int)
+{
+ if (isVisible())
+ {
+ hide();
+ close();
+ }
+}
diff --git a/gui/options-dialog.cpp b/gui/options-dialog.cpp
index 8e420a83..51da498a 100644
--- a/gui/options-dialog.cpp
+++ b/gui/options-dialog.cpp
@@ -145,6 +145,11 @@ OptionsDialog::OptionsDialog(std::function<void(bool)> pause_keybindings) :
}
}
+void OptionsDialog::closeEvent(QCloseEvent *)
+{
+ done(int(result()));
+}
+
void OptionsDialog::bind_key(key_opts& kopts, QLabel* label)
{
kopts.button = -1;
@@ -199,11 +204,11 @@ void OptionsDialog::bind_key(key_opts& kopts, QLabel* label)
void OptionsDialog::doOK()
{
- if (!close()) // dialog was closed already
- return;
if (isHidden()) // close() can return true twice in a row it seems
return;
hide();
+ if (!close()) // dialog was closed already
+ return;
main.b->save();
ui.game_detector->save();
@@ -213,11 +218,11 @@ void OptionsDialog::doOK()
void OptionsDialog::doCancel()
{
- if (!close()) // dialog was closed already
- return;
if (isHidden()) // close() can return true twice in a row it seems
return;
hide();
+ if (!close()) // dialog was closed already
+ return;
main.b->reload();
ui.game_detector->revert();
@@ -226,8 +231,11 @@ void OptionsDialog::doCancel()
void OptionsDialog::done(int res)
{
- if (res == QDialog::Accepted)
- doOK();
- else
- doCancel();
+ if (isVisible())
+ {
+ if (res == QDialog::Accepted)
+ doOK();
+ else
+ doCancel();
+ }
}
diff --git a/gui/options-dialog.hpp b/gui/options-dialog.hpp
index e9359b6d..dab919ed 100644
--- a/gui/options-dialog.hpp
+++ b/gui/options-dialog.hpp
@@ -18,7 +18,7 @@ private:
main_settings main;
std::function<void(bool)> pause_keybindings;
Ui::options_dialog ui;
- void closeEvent(QCloseEvent *) override { doCancel(); }
+ void closeEvent(QCloseEvent *) override;
static QString kopts_to_string(const key_opts& opts);
private slots:
void doOK();