0
0
mirror of https://github.com/obsproject/obs-studio.git synced 2024-09-19 20:32:15 +02:00
obs-studio/UI/window-dock.cpp
PatTheMav 2635cf3a2a UI: Split global config into app and user config
This introduces a split of the current single ConfigFile instance for
all configuration into two separate instances.

The app config instance contains system-wide settings that mainly
concern the working of the app itself, whereas the user config instance
contains settings actually exposed to the user for the configuration.
2024-09-12 16:18:46 -04:00

49 lines
1.2 KiB
C++

#include "moc_window-dock.cpp"
#include "obs-app.hpp"
#include "window-basic-main.hpp"
#include <QMessageBox>
#include <QCheckBox>
void OBSDock::closeEvent(QCloseEvent *event)
{
auto msgBox = []() {
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()->GetUserConfig(), "General",
"WarnedAboutClosingDocks", true);
config_save_safe(App()->GetUserConfig(), "tmp",
nullptr);
}
};
bool warned = config_get_bool(App()->GetUserConfig(), "General",
"WarnedAboutClosingDocks");
if (!OBSBasic::Get()->Closing() && !warned) {
QMetaObject::invokeMethod(App(), "Exec", Qt::QueuedConnection,
Q_ARG(VoidFunc, msgBox));
}
QDockWidget::closeEvent(event);
if (widget() && event->isAccepted()) {
QEvent widgetEvent(QEvent::Type(QEvent::User + QEvent::Close));
qApp->sendEvent(widget(), &widgetEvent);
}
}
void OBSDock::showEvent(QShowEvent *event)
{
QDockWidget::showEvent(event);
}