Sfoglia il codice sorgente

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.
jp9000 6 anni fa
parent
commit
4450843aa0

+ 2 - 0
UI/CMakeLists.txt

@@ -178,6 +178,7 @@ set(obs_SOURCES
 	${obs_libffutil_SOURCES}
 	${obs_libffutil_SOURCES}
 	../deps/json11/json11.cpp
 	../deps/json11/json11.cpp
 	obs-app.cpp
 	obs-app.cpp
+	window-dock.cpp
 	api-interface.cpp
 	api-interface.cpp
 	window-basic-main.cpp
 	window-basic-main.cpp
 	window-basic-stats.cpp
 	window-basic-stats.cpp
@@ -234,6 +235,7 @@ set(obs_HEADERS
 	../deps/json11/json11.hpp
 	../deps/json11/json11.hpp
 	obs-app.hpp
 	obs-app.hpp
 	platform.hpp
 	platform.hpp
+	window-dock.hpp
 	window-main.hpp
 	window-main.hpp
 	window-basic-main.hpp
 	window-basic-main.hpp
 	window-basic-stats.hpp
 	window-basic-stats.hpp

+ 3 - 2
UI/auth-mixer.cpp

@@ -9,6 +9,7 @@
 
 
 #include "window-basic-main.hpp"
 #include "window-basic-main.hpp"
 #include "remote-text.hpp"
 #include "remote-text.hpp"
+#include "window-dock.hpp"
 
 
 #include <json11.hpp>
 #include <json11.hpp>
 
 
@@ -204,9 +205,9 @@ bool MixerAuth::LoadInternal()
 	return OAuthStreamKey::LoadInternal();
 	return OAuthStreamKey::LoadInternal();
 }
 }
 
 
-class MixerChat : public QDockWidget {
+class MixerChat : public OBSDock {
 public:
 public:
-	inline MixerChat() : QDockWidget() {}
+	inline MixerChat() : OBSDock() {}
 
 
 	QScopedPointer<QCefWidget> widget;
 	QScopedPointer<QCefWidget> widget;
 };
 };

+ 3 - 2
UI/auth-twitch.cpp

@@ -9,6 +9,7 @@
 
 
 #include "window-basic-main.hpp"
 #include "window-basic-main.hpp"
 #include "remote-text.hpp"
 #include "remote-text.hpp"
+#include "window-dock.hpp"
 
 
 #include <json11.hpp>
 #include <json11.hpp>
 
 
@@ -165,9 +166,9 @@ bool TwitchAuth::LoadInternal()
 	return OAuthStreamKey::LoadInternal();
 	return OAuthStreamKey::LoadInternal();
 }
 }
 
 
-class TwitchWidget : public QDockWidget {
+class TwitchWidget : public OBSDock {
 public:
 public:
-	inline TwitchWidget() : QDockWidget() {}
+	inline TwitchWidget() : OBSDock() {}
 
 
 	QScopedPointer<QCefWidget> widget;
 	QScopedPointer<QCefWidget> widget;
 
 

+ 4 - 0
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.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"
 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
 Auth.Authing.Title="Authenticating..."
 Auth.Authing.Title="Authenticating..."
 Auth.Authing.Text="Authenticating with %1, please wait..."
 Auth.Authing.Text="Authenticating with %1, please wait..."

+ 14 - 8
UI/forms/OBSBasic.ui

@@ -113,7 +113,7 @@
      <x>0</x>
      <x>0</x>
      <y>0</y>
      <y>0</y>
      <width>1079</width>
      <width>1079</width>
-     <height>25</height>
+     <height>21</height>
     </rect>
     </rect>
    </property>
    </property>
    <widget class="QMenu" name="menu_File">
    <widget class="QMenu" name="menu_File">
@@ -336,7 +336,7 @@
    <addaction name="menuBasic_MainMenu_Help"/>
    <addaction name="menuBasic_MainMenu_Help"/>
   </widget>
   </widget>
   <widget class="OBSBasicStatusBar" name="statusbar"/>
   <widget class="OBSBasicStatusBar" name="statusbar"/>
-  <widget class="QDockWidget" name="scenesDock">
+  <widget class="OBSDock" name="scenesDock">
    <property name="features">
    <property name="features">
     <set>QDockWidget::AllDockWidgetFeatures</set>
     <set>QDockWidget::AllDockWidgetFeatures</set>
    </property>
    </property>
@@ -468,7 +468,7 @@
     </layout>
     </layout>
    </widget>
    </widget>
   </widget>
   </widget>
-  <widget class="QDockWidget" name="sourcesDock">
+  <widget class="OBSDock" name="sourcesDock">
    <property name="features">
    <property name="features">
     <set>QDockWidget::AllDockWidgetFeatures</set>
     <set>QDockWidget::AllDockWidgetFeatures</set>
    </property>
    </property>
@@ -601,7 +601,7 @@
     </layout>
     </layout>
    </widget>
    </widget>
   </widget>
   </widget>
-  <widget class="QDockWidget" name="mixerDock">
+  <widget class="OBSDock" name="mixerDock">
    <property name="features">
    <property name="features">
     <set>QDockWidget::AllDockWidgetFeatures</set>
     <set>QDockWidget::AllDockWidgetFeatures</set>
    </property>
    </property>
@@ -651,7 +651,7 @@
           <rect>
           <rect>
            <x>0</x>
            <x>0</x>
            <y>0</y>
            <y>0</y>
-           <width>82</width>
+           <width>80</width>
            <height>16</height>
            <height>16</height>
           </rect>
           </rect>
          </property>
          </property>
@@ -705,7 +705,7 @@
            <x>0</x>
            <x>0</x>
            <y>0</y>
            <y>0</y>
            <width>16</width>
            <width>16</width>
-           <height>26</height>
+           <height>28</height>
           </rect>
           </rect>
          </property>
          </property>
          <property name="sizePolicy">
          <property name="sizePolicy">
@@ -738,7 +738,7 @@
     </layout>
     </layout>
    </widget>
    </widget>
   </widget>
   </widget>
-  <widget class="QDockWidget" name="transitionsDock">
+  <widget class="OBSDock" name="transitionsDock">
    <property name="features">
    <property name="features">
     <set>QDockWidget::AllDockWidgetFeatures</set>
     <set>QDockWidget::AllDockWidgetFeatures</set>
    </property>
    </property>
@@ -985,7 +985,7 @@
     </layout>
     </layout>
    </widget>
    </widget>
   </widget>
   </widget>
-  <widget class="QDockWidget" name="controlsDock">
+  <widget class="OBSDock" name="controlsDock">
    <property name="features">
    <property name="features">
     <set>QDockWidget::AllDockWidgetFeatures</set>
     <set>QDockWidget::AllDockWidgetFeatures</set>
    </property>
    </property>
@@ -1712,6 +1712,12 @@
    <extends>QListView</extends>
    <extends>QListView</extends>
    <header>source-tree.hpp</header>
    <header>source-tree.hpp</header>
   </customwidget>
   </customwidget>
+  <customwidget>
+   <class>OBSDock</class>
+   <extends>QDockWidget</extends>
+   <header>window-dock.hpp</header>
+   <container>1</container>
+  </customwidget>
  </customwidgets>
  </customwidgets>
  <resources>
  <resources>
   <include location="obs.qrc"/>
   <include location="obs.qrc"/>

+ 1 - 1
UI/window-basic-main.cpp

@@ -216,7 +216,7 @@ OBSBasic::OBSBasic(QWidget *parent)
 
 
 	startingDockLayout = saveState();
 	startingDockLayout = saveState();
 
 
-	statsDock = new QDockWidget();
+	statsDock = new OBSDock();
 	statsDock->setObjectName(QStringLiteral("statsDock"));
 	statsDock->setObjectName(QStringLiteral("statsDock"));
 	statsDock->setFeatures(QDockWidget::AllDockWidgetFeatures);
 	statsDock->setFeatures(QDockWidget::AllDockWidgetFeatures);
 	statsDock->setWindowTitle(QTStr("Basic.Stats"));
 	statsDock->setWindowTitle(QTStr("Basic.Stats"));

+ 27 - 0
UI/window-dock.cpp

@@ -0,0 +1,27 @@
+#include "window-dock.hpp"
+#include "obs-app.hpp"
+
+#include <QMessageBox>
+
+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);
+}

+ 12 - 0
UI/window-dock.hpp

@@ -0,0 +1,12 @@
+#pragma once
+
+#include <QDockWidget>
+
+class OBSDock : public QDockWidget {
+	Q_OBJECT
+
+public:
+	inline OBSDock(QWidget *parent = nullptr) : QDockWidget(parent) {}
+
+	virtual void closeEvent(QCloseEvent *event);
+};