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.
This commit is contained in:
jp9000 2019-03-05 14:37:01 -08:00
parent 106222154a
commit 4450843aa0
8 changed files with 66 additions and 13 deletions

View File

@ -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

View File

@ -9,6 +9,7 @@
#include "window-basic-main.hpp"
#include "remote-text.hpp"
#include "window-dock.hpp"
#include <json11.hpp>
@ -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<QCefWidget> widget;
};

View File

@ -9,6 +9,7 @@
#include "window-basic-main.hpp"
#include "remote-text.hpp"
#include "window-dock.hpp"
#include <json11.hpp>
@ -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<QCefWidget> widget;

View File

@ -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..."

View File

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

View File

@ -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"));

27
UI/window-dock.cpp Normal file
View File

@ -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
UI/window-dock.hpp Normal file
View File

@ -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);
};