UI: Add (Do not show again) checkbox to dock closing warning

Closes obsproject/obs-studio#1717
This commit is contained in:
Clayton Groeneveld
2019-03-05 17:16:16 -06:00
committed by jp9000
parent 4c7860056e
commit b40d000648
2 changed files with 18 additions and 6 deletions

View File

@@ -85,6 +85,7 @@ StudioMode.Program="Program"
ShowInMultiview="Show in Multiview"
VerticalLayout="Vertical Layout"
Group="Group"
DoNotShowAgain="Do not show again"
# warning if program already open
AlreadyRunning.Title="OBS is already running"

View File

@@ -2,14 +2,28 @@
#include "obs-app.hpp"
#include <QMessageBox>
#include <QCheckBox>
void OBSDock::closeEvent(QCloseEvent *event)
{
auto msgBox = [] ()
{
QMessageBox::information(App()->GetMainWindow(),
QTStr("DockCloseWarning.Title"),
QTStr("DockCloseWarning.Text"));
QMessageBox msgbox(App()->GetMainWindow());
msgbox.setWindowTitle(QTStr("DockCloseWarning.Title"));
msgbox.setText(QTStr("DockCloseWarning.Text"));
msgbox.setIcon(QMessageBox::Icon::Information);
msgbox.addButton(QMessageBox::Ok);
QCheckBox *cb = new QCheckBox(QTStr("DoNotShowAgain"));
msgbox.setCheckBox(cb);
msgbox.exec();
if (cb->isChecked()) {
config_set_bool(App()->GlobalConfig(), "General",
"WarnedAboutClosingDocks", true);
config_save_safe(App()->GlobalConfig(), "tmp", nullptr);
}
};
bool warned = config_get_bool(App()->GlobalConfig(), "General",
@@ -18,9 +32,6 @@ void OBSDock::closeEvent(QCloseEvent *event)
QMetaObject::invokeMethod(App(), "Exec",
Qt::QueuedConnection,
Q_ARG(VoidFunc, msgBox));
config_set_bool(App()->GlobalConfig(), "General",
"WarnedAboutClosingDocks", true);
config_save_safe(App()->GlobalConfig(), "tmp", nullptr);
}
QDockWidget::closeEvent(event);