Add an indicator in the title bar if Streamer Mode is active (#4410)
This commit is contained in:
@@ -4,10 +4,12 @@
|
||||
#include "common/QLogging.hpp"
|
||||
#include "controllers/hotkeys/HotkeyCategory.hpp"
|
||||
#include "controllers/hotkeys/HotkeyController.hpp"
|
||||
#include "singletons/Resources.hpp"
|
||||
#include "singletons/Settings.hpp"
|
||||
#include "singletons/Theme.hpp"
|
||||
#include "singletons/WindowManager.hpp"
|
||||
#include "util/InitUpdateButton.hpp"
|
||||
#include "util/StreamerMode.hpp"
|
||||
#include "widgets/dialogs/SettingsDialog.hpp"
|
||||
#include "widgets/helper/ChannelView.hpp"
|
||||
#include "widgets/helper/NotebookButton.hpp"
|
||||
@@ -1155,6 +1157,45 @@ void SplitNotebook::addCustomButtons()
|
||||
auto updateBtn = this->addCustomButton();
|
||||
|
||||
initUpdateButton(*updateBtn, this->signalHolder_);
|
||||
|
||||
// streamer mode
|
||||
this->streamerModeIcon_ = this->addCustomButton();
|
||||
QObject::connect(this->streamerModeIcon_, &NotebookButton::leftClicked,
|
||||
[this] {
|
||||
getApp()->windows->showSettingsDialog(
|
||||
this, SettingsDialogPreference::StreamerMode);
|
||||
});
|
||||
this->signalHolder_.managedConnect(getApp()->streamerModeChanged, [this]() {
|
||||
this->updateStreamerModeIcon();
|
||||
});
|
||||
this->updateStreamerModeIcon();
|
||||
}
|
||||
|
||||
void SplitNotebook::updateStreamerModeIcon()
|
||||
{
|
||||
if (this->streamerModeIcon_ == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
// A duplicate of this code is in Window class
|
||||
// That copy handles the TitleBar icon in Window (main window on Windows)
|
||||
// This one is the one near splits (on linux and mac or non-main windows on Windows)
|
||||
if (getTheme()->isLightTheme())
|
||||
{
|
||||
this->streamerModeIcon_->setPixmap(
|
||||
getResources().buttons.streamerModeEnabledLight);
|
||||
}
|
||||
else
|
||||
{
|
||||
this->streamerModeIcon_->setPixmap(
|
||||
getResources().buttons.streamerModeEnabledDark);
|
||||
}
|
||||
this->streamerModeIcon_->setVisible(isInStreamerMode());
|
||||
}
|
||||
|
||||
void SplitNotebook::themeChangedEvent()
|
||||
{
|
||||
this->updateStreamerModeIcon();
|
||||
}
|
||||
|
||||
SplitContainer *SplitNotebook::addPage(bool select)
|
||||
|
||||
@@ -123,6 +123,7 @@ public:
|
||||
SplitContainer *addPage(bool select = false);
|
||||
SplitContainer *getOrAddSelectedPage();
|
||||
void select(QWidget *page, bool focusPage = true) override;
|
||||
void themeChangedEvent() override;
|
||||
|
||||
protected:
|
||||
void showEvent(QShowEvent *event) override;
|
||||
@@ -131,6 +132,11 @@ private:
|
||||
void addCustomButtons();
|
||||
|
||||
pajlada::Signals::SignalHolder signalHolder_;
|
||||
|
||||
// Main window on Windows has basically a duplicate of this in Window
|
||||
NotebookButton *streamerModeIcon_{};
|
||||
|
||||
void updateStreamerModeIcon();
|
||||
};
|
||||
|
||||
} // namespace chatterino
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "controllers/hotkeys/HotkeyController.hpp"
|
||||
#include "providers/twitch/TwitchAccount.hpp"
|
||||
#include "providers/twitch/TwitchIrcServer.hpp"
|
||||
#include "singletons/Resources.hpp"
|
||||
#include "singletons/Settings.hpp"
|
||||
#include "singletons/Theme.hpp"
|
||||
#include "singletons/Updates.hpp"
|
||||
@@ -186,6 +187,51 @@ void Window::addCustomTitlebarButtons()
|
||||
this->userLabel_->rect().bottomLeft()));
|
||||
});
|
||||
this->userLabel_->setMinimumWidth(20 * scale());
|
||||
|
||||
// streamer mode
|
||||
this->streamerModeTitlebarIcon_ =
|
||||
this->addTitleBarButton(TitleBarButtonStyle::StreamerMode, [this] {
|
||||
getApp()->windows->showSettingsDialog(
|
||||
this, SettingsDialogPreference::StreamerMode);
|
||||
});
|
||||
this->signalHolder_.managedConnect(getApp()->streamerModeChanged, [this]() {
|
||||
this->updateStreamerModeIcon();
|
||||
});
|
||||
}
|
||||
|
||||
void Window::updateStreamerModeIcon()
|
||||
{
|
||||
// A duplicate of this code is in SplitNotebook class (in Notebook.{c,h}pp)
|
||||
// That one is the one near splits (on linux and mac or non-main windows on Windows)
|
||||
// This copy handles the TitleBar icon in Window (main window on Windows)
|
||||
if (this->streamerModeTitlebarIcon_ == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
#ifdef Q_OS_WIN
|
||||
assert(this->getType() == WindowType::Main);
|
||||
if (getTheme()->isLightTheme())
|
||||
{
|
||||
this->streamerModeTitlebarIcon_->setPixmap(
|
||||
getResources().buttons.streamerModeEnabledLight);
|
||||
}
|
||||
else
|
||||
{
|
||||
this->streamerModeTitlebarIcon_->setPixmap(
|
||||
getResources().buttons.streamerModeEnabledDark);
|
||||
}
|
||||
this->streamerModeTitlebarIcon_->setVisible(isInStreamerMode());
|
||||
#else
|
||||
// clang-format off
|
||||
assert(false && "Streamer mode TitleBar icon should not exist on non-Windows OSes");
|
||||
// clang-format on
|
||||
#endif
|
||||
}
|
||||
|
||||
void Window::themeChangedEvent()
|
||||
{
|
||||
this->updateStreamerModeIcon();
|
||||
BaseWindow::themeChangedEvent();
|
||||
}
|
||||
|
||||
void Window::addDebugStuff(HotkeyController::HotkeyMap &actions)
|
||||
|
||||
@@ -31,6 +31,7 @@ public:
|
||||
protected:
|
||||
void closeEvent(QCloseEvent *event) override;
|
||||
bool event(QEvent *event) override;
|
||||
void themeChangedEvent() override;
|
||||
|
||||
private:
|
||||
void addCustomTitlebarButtons();
|
||||
@@ -51,6 +52,10 @@ private:
|
||||
pajlada::Signals::SignalHolder signalHolder_;
|
||||
std::vector<boost::signals2::scoped_connection> bSignals_;
|
||||
|
||||
// this is only used on Windows and only on the main window, for the one used otherwise, see SplitNotebook in Notebook.hpp
|
||||
TitleBarButton *streamerModeTitlebarIcon_ = nullptr;
|
||||
void updateStreamerModeIcon();
|
||||
|
||||
friend class Notebook;
|
||||
};
|
||||
|
||||
|
||||
@@ -195,6 +195,11 @@ void SettingsDialog::filterElements(const QString &text)
|
||||
}
|
||||
}
|
||||
|
||||
void SettingsDialog::setElementFilter(const QString &query)
|
||||
{
|
||||
this->ui_.search->setText(query);
|
||||
}
|
||||
|
||||
void SettingsDialog::addTabs()
|
||||
{
|
||||
this->ui_.tabContainer->setSpacing(0);
|
||||
@@ -203,7 +208,7 @@ void SettingsDialog::addTabs()
|
||||
// Constructors are wrapped in std::function to remove some strain from first time loading.
|
||||
|
||||
// clang-format off
|
||||
this->addTab([]{return new GeneralPage;}, "General", ":/settings/about.svg");
|
||||
this->addTab([]{return new GeneralPage;}, "General", ":/settings/about.svg", SettingsTabId::General);
|
||||
this->ui_.tabContainer->addSpacing(16);
|
||||
this->addTab([]{return new AccountsPage;}, "Accounts", ":/settings/accounts.svg", SettingsTabId::Accounts);
|
||||
this->addTab([]{return new NicknamesPage;}, "Nicknames", ":/settings/accounts.svg");
|
||||
@@ -316,10 +321,20 @@ void SettingsDialog::showDialog(QWidget *parent,
|
||||
}
|
||||
break;
|
||||
|
||||
case SettingsDialogPreference::StreamerMode: {
|
||||
instance->selectTab(SettingsTabId::General);
|
||||
}
|
||||
break;
|
||||
|
||||
default:;
|
||||
}
|
||||
|
||||
instance->show();
|
||||
if (preferredTab == SettingsDialogPreference::StreamerMode)
|
||||
{
|
||||
// this is needed because each time the settings are opened, the query is reset
|
||||
instance->setElementFilter("Streamer Mode");
|
||||
}
|
||||
instance->activateWindow();
|
||||
instance->raise();
|
||||
instance->setFocus();
|
||||
|
||||
@@ -27,6 +27,7 @@ class PageHeader : public QFrame
|
||||
|
||||
enum class SettingsDialogPreference {
|
||||
NoPreference,
|
||||
StreamerMode,
|
||||
Accounts,
|
||||
ModerationActions,
|
||||
};
|
||||
@@ -57,6 +58,7 @@ private:
|
||||
void selectTab(SettingsDialogTab *tab, const bool byUser = true);
|
||||
void selectTab(SettingsTabId id);
|
||||
void filterElements(const QString &query);
|
||||
void setElementFilter(const QString &query);
|
||||
|
||||
void onOkClicked();
|
||||
void onCancelClicked();
|
||||
|
||||
@@ -15,6 +15,7 @@ class SettingsDialog;
|
||||
|
||||
enum class SettingsTabId {
|
||||
None,
|
||||
General,
|
||||
Accounts,
|
||||
Moderation,
|
||||
};
|
||||
|
||||
@@ -11,7 +11,8 @@ enum class TitleBarButtonStyle {
|
||||
Unmaximize = 4,
|
||||
Close = 8,
|
||||
User = 16,
|
||||
Settings = 32
|
||||
Settings = 32,
|
||||
StreamerMode = 64,
|
||||
};
|
||||
|
||||
class TitleBarButton : public Button
|
||||
|
||||
@@ -126,6 +126,9 @@ AboutPage::AboutPage()
|
||||
"https://github.com/getsentry/crashpad",
|
||||
":/licenses/crashpad.txt");
|
||||
#endif
|
||||
addLicense(form.getElement(), "Fluent icons",
|
||||
"https://github.com/microsoft/fluentui-system-icons",
|
||||
":/licenses/fluenticons.txt");
|
||||
}
|
||||
|
||||
// Attributions
|
||||
|
||||
Reference in New Issue
Block a user