|
|
@@ -55,6 +55,33 @@
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
+class SettingsEventFilter : public QObject {
|
|
|
+ QScopedPointer<OBSEventFilter> shortcutFilter;
|
|
|
+
|
|
|
+public:
|
|
|
+ inline SettingsEventFilter()
|
|
|
+ : shortcutFilter((OBSEventFilter *)CreateShortcutFilter())
|
|
|
+ {
|
|
|
+ }
|
|
|
+
|
|
|
+protected:
|
|
|
+ bool eventFilter(QObject *obj, QEvent *event) override
|
|
|
+ {
|
|
|
+ int key;
|
|
|
+
|
|
|
+ switch (event->type()) {
|
|
|
+ case QEvent::KeyPress:
|
|
|
+ case QEvent::KeyRelease:
|
|
|
+ key = static_cast<QKeyEvent *>(event)->key();
|
|
|
+ if (key == Qt::Key_Escape) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return shortcutFilter->filter(obj, event);
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
// Used for QVariant in codec comboboxes
|
|
|
namespace {
|
|
|
static bool StringEquals(QString left, QString right)
|
|
|
@@ -656,7 +683,7 @@ OBSBasicSettings::OBSBasicSettings(QWidget *parent)
|
|
|
// Initialize libff library
|
|
|
ff_init();
|
|
|
|
|
|
- installEventFilter(CreateShortcutFilter());
|
|
|
+ installEventFilter(new SettingsEventFilter());
|
|
|
|
|
|
LoadEncoderTypes();
|
|
|
LoadColorRanges();
|
|
|
@@ -3611,14 +3638,14 @@ bool OBSBasicSettings::QueryChanges()
|
|
|
|
|
|
void OBSBasicSettings::closeEvent(QCloseEvent *event)
|
|
|
{
|
|
|
- if (Changed() && !QueryChanges())
|
|
|
+ if (!AskIfCanCloseSettings())
|
|
|
event->ignore();
|
|
|
+}
|
|
|
|
|
|
- if (forceAuthReload) {
|
|
|
- main->auth->Save();
|
|
|
- main->auth->Load();
|
|
|
- forceAuthReload = false;
|
|
|
- }
|
|
|
+void OBSBasicSettings::reject()
|
|
|
+{
|
|
|
+ if (AskIfCanCloseSettings())
|
|
|
+ close();
|
|
|
}
|
|
|
|
|
|
void OBSBasicSettings::on_theme_activated(int idx)
|
|
|
@@ -3872,6 +3899,22 @@ void OBSBasicSettings::RecalcOutputResPixels(const char *resText)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+bool OBSBasicSettings::AskIfCanCloseSettings()
|
|
|
+{
|
|
|
+ bool canCloseSettings = false;
|
|
|
+
|
|
|
+ if (!Changed() || QueryChanges())
|
|
|
+ canCloseSettings = true;
|
|
|
+
|
|
|
+ if (forceAuthReload) {
|
|
|
+ main->auth->Save();
|
|
|
+ main->auth->Load();
|
|
|
+ forceAuthReload = false;
|
|
|
+ }
|
|
|
+
|
|
|
+ return canCloseSettings;
|
|
|
+}
|
|
|
+
|
|
|
void OBSBasicSettings::on_filenameFormatting_textEdited(const QString &text)
|
|
|
{
|
|
|
#ifdef __APPLE__
|