UI: Match Windows taskbar state to tray icon
This adds both a status icon, and changes the color of the taskbar button itself.
This commit is contained in:
parent
c59ce6981b
commit
d442fda3fc
@ -57,6 +57,9 @@ set(CMAKE_INCLUDE_CURRENT_DIR TRUE)
|
||||
set(CMAKE_AUTOMOC TRUE)
|
||||
|
||||
find_package(Qt5Svg ${FIND_MODE})
|
||||
if(WIN32)
|
||||
find_package(Qt5WinExtras ${FIND_MODE})
|
||||
endif()
|
||||
find_package(Qt5Xml ${FIND_MODE})
|
||||
|
||||
find_package(FFmpeg REQUIRED COMPONENTS avcodec avutil avformat)
|
||||
@ -385,6 +388,8 @@ if(WIN32)
|
||||
set_target_properties(obs
|
||||
PROPERTIES
|
||||
OUTPUT_NAME "obs${_output_suffix}")
|
||||
target_link_libraries(obs
|
||||
Qt5::WinExtras)
|
||||
endif()
|
||||
|
||||
target_link_libraries(obs
|
||||
|
BIN
UI/forms/images/active.png
Normal file
BIN
UI/forms/images/active.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.3 KiB |
BIN
UI/forms/images/paused.png
Normal file
BIN
UI/forms/images/paused.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.9 KiB |
@ -12,6 +12,8 @@
|
||||
<file>images/obs.png</file>
|
||||
<file>images/obs_paused.png</file>
|
||||
<file>images/tray_active.png</file>
|
||||
<file>images/paused.png</file>
|
||||
<file>images/active.png</file>
|
||||
<file>images/expand.svg</file>
|
||||
<file>images/unlocked.svg</file>
|
||||
<file>images/locked.svg</file>
|
||||
|
@ -1780,6 +1780,11 @@ void OBSBasic::OBSInit()
|
||||
SystemTray(true);
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
taskBtn->setWindow(windowHandle());
|
||||
taskProg->setRange(0, 1);
|
||||
#endif
|
||||
|
||||
bool has_last_version = config_has_user_value(App()->GlobalConfig(),
|
||||
"General", "LastVersion");
|
||||
bool first_run =
|
||||
@ -5292,6 +5297,13 @@ inline void OBSBasic::OnActivate()
|
||||
App()->IncrementSleepInhibition();
|
||||
UpdateProcessPriority();
|
||||
|
||||
#ifdef _WIN32
|
||||
taskProg->show();
|
||||
taskProg->resume();
|
||||
taskProg->setValue(1);
|
||||
taskBtn->setOverlayIcon(QIcon::fromTheme(
|
||||
"obs-active", QIcon(":/res/images/active.png")));
|
||||
#endif
|
||||
if (trayIcon)
|
||||
trayIcon->setIcon(QIcon::fromTheme(
|
||||
"obs-tray-active",
|
||||
@ -5313,12 +5325,34 @@ inline void OBSBasic::OnDeactivate()
|
||||
if (trayIcon)
|
||||
trayIcon->setIcon(QIcon::fromTheme(
|
||||
"obs-tray", QIcon(":/res/images/obs.png")));
|
||||
} else if (trayIcon) {
|
||||
if (os_atomic_load_bool(&recording_paused))
|
||||
trayIcon->setIcon(QIcon(":/res/images/obs_paused.png"));
|
||||
else
|
||||
trayIcon->setIcon(
|
||||
QIcon(":/res/images/tray_active.png"));
|
||||
#ifdef _WIN32
|
||||
taskProg->hide();
|
||||
taskBtn->clearOverlayIcon();
|
||||
#endif
|
||||
} else {
|
||||
if (os_atomic_load_bool(&recording_paused)) {
|
||||
#ifdef _WIN32
|
||||
taskProg->show();
|
||||
taskProg->pause();
|
||||
taskBtn->setOverlayIcon(QIcon::fromTheme(
|
||||
"obs-paused",
|
||||
QIcon(":/res/images/paused.png")));
|
||||
#endif
|
||||
if (trayIcon)
|
||||
trayIcon->setIcon(
|
||||
QIcon(":/res/images/obs_paused.png"));
|
||||
} else {
|
||||
#ifdef _WIN32
|
||||
taskProg->show();
|
||||
taskProg->resume();
|
||||
taskBtn->setOverlayIcon(QIcon::fromTheme(
|
||||
"obs-active",
|
||||
QIcon(":/res/images/active.png")));
|
||||
#endif
|
||||
if (trayIcon)
|
||||
trayIcon->setIcon(
|
||||
QIcon(":/res/images/tray_active.png"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -7698,6 +7732,11 @@ void OBSBasic::PauseRecording()
|
||||
|
||||
ui->statusbar->RecordingPaused();
|
||||
|
||||
#ifdef _WIN32
|
||||
taskProg->pause();
|
||||
taskBtn->setOverlayIcon(QIcon::fromTheme(
|
||||
"obs-paused", QIcon(":/res/images/paused.png")));
|
||||
#endif
|
||||
if (trayIcon)
|
||||
trayIcon->setIcon(QIcon(":/res/images/obs_paused.png"));
|
||||
|
||||
@ -7727,6 +7766,11 @@ void OBSBasic::UnpauseRecording()
|
||||
|
||||
ui->statusbar->RecordingUnpaused();
|
||||
|
||||
#ifdef _WIN32
|
||||
taskProg->resume();
|
||||
taskBtn->setOverlayIcon(QIcon::fromTheme(
|
||||
"obs-active", QIcon(":/res/images/active.png")));
|
||||
#endif
|
||||
if (trayIcon)
|
||||
trayIcon->setIcon(
|
||||
QIcon(":/res/images/tray_active.png"));
|
||||
|
@ -21,6 +21,10 @@
|
||||
#include <QAction>
|
||||
#include <QWidgetAction>
|
||||
#include <QSystemTrayIcon>
|
||||
#ifdef _WIN32
|
||||
#include <QWinTaskbarButton>
|
||||
#include <QWinTaskbarProgress>
|
||||
#endif
|
||||
#include <QStyledItemDelegate>
|
||||
#include <obs.hpp>
|
||||
#include <vector>
|
||||
@ -272,6 +276,11 @@ private:
|
||||
QPointer<QMenu> perSceneTransitionMenu;
|
||||
QPointer<QObject> shortcutFilter;
|
||||
|
||||
#ifdef _WIN32
|
||||
QWinTaskbarButton *taskBtn = new QWinTaskbarButton(this);
|
||||
QWinTaskbarProgress *taskProg = taskBtn->progress();
|
||||
#endif
|
||||
|
||||
QPointer<QWidget> programWidget;
|
||||
QPointer<QVBoxLayout> programLayout;
|
||||
QPointer<QLabel> programLabel;
|
||||
|
@ -158,6 +158,7 @@ file(GLOB QT_DEBUG_BIN_FILES
|
||||
"${Qt5Core_DIR}/../../../bin/Qt5Guid.dll"
|
||||
"${Qt5Core_DIR}/../../../bin/Qt5Widgetsd.dll"
|
||||
"${Qt5Core_DIR}/../../../bin/Qt5Svgd.dll"
|
||||
"${Qt5Core_DIR}/../../../bin/Qt5WinExtrasd.dll"
|
||||
"${Qt5Core_DIR}/../../../bin/Qt5Xmld.dll"
|
||||
"${Qt5Core_DIR}/../../../bin/libGLESv2d.dll"
|
||||
"${Qt5Core_DIR}/../../../bin/libEGLd.dll")
|
||||
@ -176,6 +177,7 @@ file(GLOB QT_BIN_FILES
|
||||
"${Qt5Core_DIR}/../../../bin/Qt5Gui.dll"
|
||||
"${Qt5Core_DIR}/../../../bin/Qt5Widgets.dll"
|
||||
"${Qt5Core_DIR}/../../../bin/Qt5Svg.dll"
|
||||
"${Qt5Core_DIR}/../../../bin/Qt5WinExtras.dll"
|
||||
"${Qt5Core_DIR}/../../../bin/Qt5Xml.dll"
|
||||
"${Qt5Core_DIR}/../../../bin/libGLESv2.dll"
|
||||
"${Qt5Core_DIR}/../../../bin/libEGL.dll")
|
||||
|
Loading…
x
Reference in New Issue
Block a user