From 4450843aa076ce3b5d5eaf5f0390bba43d9f1046 Mon Sep 17 00:00:00 2001 From: jp9000 Date: Tue, 5 Mar 2019 14:37:01 -0800 Subject: [PATCH] UI: Warn when closing dock widgets for first time Users don't realize that dockable windows can be closed (hidden) and can be shown again via the View menu. This adds an explicit warning when the user first closes a dockable window for their first time. In future versions, this should be changed to a dialog box with a "Do not show again" checkbox. --- UI/CMakeLists.txt | 2 ++ UI/auth-mixer.cpp | 5 +++-- UI/auth-twitch.cpp | 5 +++-- UI/data/locale/en-US.ini | 4 ++++ UI/forms/OBSBasic.ui | 22 ++++++++++++++-------- UI/window-basic-main.cpp | 2 +- UI/window-dock.cpp | 27 +++++++++++++++++++++++++++ UI/window-dock.hpp | 12 ++++++++++++ 8 files changed, 66 insertions(+), 13 deletions(-) create mode 100644 UI/window-dock.cpp create mode 100644 UI/window-dock.hpp diff --git a/UI/CMakeLists.txt b/UI/CMakeLists.txt index 3c2542e70..0f64fb3b5 100644 --- a/UI/CMakeLists.txt +++ b/UI/CMakeLists.txt @@ -178,6 +178,7 @@ set(obs_SOURCES ${obs_libffutil_SOURCES} ../deps/json11/json11.cpp obs-app.cpp + window-dock.cpp api-interface.cpp window-basic-main.cpp window-basic-stats.cpp @@ -234,6 +235,7 @@ set(obs_HEADERS ../deps/json11/json11.hpp obs-app.hpp platform.hpp + window-dock.hpp window-main.hpp window-basic-main.hpp window-basic-stats.hpp diff --git a/UI/auth-mixer.cpp b/UI/auth-mixer.cpp index d835cfc16..dc2cb5b8e 100644 --- a/UI/auth-mixer.cpp +++ b/UI/auth-mixer.cpp @@ -9,6 +9,7 @@ #include "window-basic-main.hpp" #include "remote-text.hpp" +#include "window-dock.hpp" #include @@ -204,9 +205,9 @@ bool MixerAuth::LoadInternal() return OAuthStreamKey::LoadInternal(); } -class MixerChat : public QDockWidget { +class MixerChat : public OBSDock { public: - inline MixerChat() : QDockWidget() {} + inline MixerChat() : OBSDock() {} QScopedPointer widget; }; diff --git a/UI/auth-twitch.cpp b/UI/auth-twitch.cpp index 33d87222c..19c6584e2 100644 --- a/UI/auth-twitch.cpp +++ b/UI/auth-twitch.cpp @@ -9,6 +9,7 @@ #include "window-basic-main.hpp" #include "remote-text.hpp" +#include "window-dock.hpp" #include @@ -165,9 +166,9 @@ bool TwitchAuth::LoadInternal() return OAuthStreamKey::LoadInternal(); } -class TwitchWidget : public QDockWidget { +class TwitchWidget : public OBSDock { public: - inline TwitchWidget() : QDockWidget() {} + inline TwitchWidget() : OBSDock() {} QScopedPointer widget; diff --git a/UI/data/locale/en-US.ini b/UI/data/locale/en-US.ini index 44f101aac..d68020a6c 100644 --- a/UI/data/locale/en-US.ini +++ b/UI/data/locale/en-US.ini @@ -91,6 +91,10 @@ AlreadyRunning.Title="OBS is already running" AlreadyRunning.Text="OBS is already running! Unless you meant to do this, please shut down any existing instances of OBS before trying to run a new instance. If you have OBS set to minimize to the system tray, please check to see if it's still running there." AlreadyRunning.LaunchAnyway="Launch Anyway" +# warning when closing docks. it's frustrating that we actually need this. +DockCloseWarning.Title="Closing Dockable Window" +DockCloseWarning.Text="You just closed a dockable window. If you'd like to show it again, use the View → Docks menu on the menu bar." + # Auth Auth.Authing.Title="Authenticating..." Auth.Authing.Text="Authenticating with %1, please wait..." diff --git a/UI/forms/OBSBasic.ui b/UI/forms/OBSBasic.ui index 530b05669..b07d5c5b4 100644 --- a/UI/forms/OBSBasic.ui +++ b/UI/forms/OBSBasic.ui @@ -113,7 +113,7 @@ 0 0 1079 - 25 + 21 @@ -336,7 +336,7 @@ - + QDockWidget::AllDockWidgetFeatures @@ -468,7 +468,7 @@ - + QDockWidget::AllDockWidgetFeatures @@ -601,7 +601,7 @@ - + QDockWidget::AllDockWidgetFeatures @@ -651,7 +651,7 @@ 0 0 - 82 + 80 16 @@ -705,7 +705,7 @@ 0 0 16 - 26 + 28 @@ -738,7 +738,7 @@ - + QDockWidget::AllDockWidgetFeatures @@ -985,7 +985,7 @@ - + QDockWidget::AllDockWidgetFeatures @@ -1712,6 +1712,12 @@ QListView
source-tree.hpp
+ + OBSDock + QDockWidget +
window-dock.hpp
+ 1 +
diff --git a/UI/window-basic-main.cpp b/UI/window-basic-main.cpp index 2d577a948..8d454b112 100644 --- a/UI/window-basic-main.cpp +++ b/UI/window-basic-main.cpp @@ -216,7 +216,7 @@ OBSBasic::OBSBasic(QWidget *parent) startingDockLayout = saveState(); - statsDock = new QDockWidget(); + statsDock = new OBSDock(); statsDock->setObjectName(QStringLiteral("statsDock")); statsDock->setFeatures(QDockWidget::AllDockWidgetFeatures); statsDock->setWindowTitle(QTStr("Basic.Stats")); diff --git a/UI/window-dock.cpp b/UI/window-dock.cpp new file mode 100644 index 000000000..365c221f3 --- /dev/null +++ b/UI/window-dock.cpp @@ -0,0 +1,27 @@ +#include "window-dock.hpp" +#include "obs-app.hpp" + +#include + +void OBSDock::closeEvent(QCloseEvent *event) +{ + auto msgBox = [] () + { + QMessageBox::information(App()->GetMainWindow(), + QTStr("DockCloseWarning.Title"), + QTStr("DockCloseWarning.Text")); + }; + + bool warned = config_get_bool(App()->GlobalConfig(), "General", + "WarnedAboutClosingDocks"); + if (!warned) { + 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); +} diff --git a/UI/window-dock.hpp b/UI/window-dock.hpp new file mode 100644 index 000000000..ccb1cf0ae --- /dev/null +++ b/UI/window-dock.hpp @@ -0,0 +1,12 @@ +#pragma once + +#include + +class OBSDock : public QDockWidget { + Q_OBJECT + +public: + inline OBSDock(QWidget *parent = nullptr) : QDockWidget(parent) {} + + virtual void closeEvent(QCloseEvent *event); +};