yolobs-studio/UI/window-dock.cpp

37 lines
952 B
C++
Raw Normal View History

2019-07-27 12:47:10 +00:00
#include "window-dock.hpp"
#include "obs-app.hpp"
#include <QMessageBox>
#include <QCheckBox>
void OBSDock::closeEvent(QCloseEvent *event)
{
2019-09-22 21:19:10 +00:00
auto msgBox = []() {
2019-07-27 12:47:10 +00:00
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",
2019-09-22 21:19:10 +00:00
"WarnedAboutClosingDocks");
2019-07-27 12:47:10 +00:00
if (!warned) {
2019-09-22 21:19:10 +00:00
QMetaObject::invokeMethod(App(), "Exec", Qt::QueuedConnection,
Q_ARG(VoidFunc, msgBox));
2019-07-27 12:47:10 +00:00
}
QDockWidget::closeEvent(event);
}