2024-08-08 21:41:52 +02:00
|
|
|
#include "moc_window-dock.cpp"
|
2019-03-05 23:37:01 +01:00
|
|
|
#include "obs-app.hpp"
|
2024-03-03 02:08:10 +01:00
|
|
|
#include "window-basic-main.hpp"
|
2019-03-05 23:37:01 +01:00
|
|
|
|
|
|
|
#include <QMessageBox>
|
2019-03-06 00:16:16 +01:00
|
|
|
#include <QCheckBox>
|
2019-03-05 23:37:01 +01:00
|
|
|
|
|
|
|
void OBSDock::closeEvent(QCloseEvent *event)
|
|
|
|
{
|
|
|
|
auto msgBox = []() {
|
2019-03-06 00:16:16 +01: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()) {
|
2024-09-03 16:28:36 +02:00
|
|
|
config_set_bool(App()->GetUserConfig(), "General",
|
2019-03-06 00:16:16 +01:00
|
|
|
"WarnedAboutClosingDocks", true);
|
2024-09-03 16:28:36 +02:00
|
|
|
config_save_safe(App()->GetUserConfig(), "tmp",
|
|
|
|
nullptr);
|
2019-03-06 00:16:16 +01:00
|
|
|
}
|
2019-03-05 23:37:01 +01:00
|
|
|
};
|
|
|
|
|
2024-09-03 16:28:36 +02:00
|
|
|
bool warned = config_get_bool(App()->GetUserConfig(), "General",
|
2019-03-05 23:37:01 +01:00
|
|
|
"WarnedAboutClosingDocks");
|
2024-03-03 02:08:10 +01:00
|
|
|
if (!OBSBasic::Get()->Closing() && !warned) {
|
2019-03-05 23:37:01 +01:00
|
|
|
QMetaObject::invokeMethod(App(), "Exec", Qt::QueuedConnection,
|
|
|
|
Q_ARG(VoidFunc, msgBox));
|
|
|
|
}
|
|
|
|
|
|
|
|
QDockWidget::closeEvent(event);
|
2024-04-11 16:28:40 +02:00
|
|
|
|
|
|
|
if (widget() && event->isAccepted()) {
|
|
|
|
QEvent widgetEvent(QEvent::Type(QEvent::User + QEvent::Close));
|
|
|
|
qApp->sendEvent(widget(), &widgetEvent);
|
|
|
|
}
|
2019-03-05 23:37:01 +01:00
|
|
|
}
|
2023-08-11 22:47:29 +02:00
|
|
|
|
|
|
|
void OBSDock::showEvent(QShowEvent *event)
|
|
|
|
{
|
|
|
|
QDockWidget::showEvent(event);
|
|
|
|
}
|