mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
creates common texts for opening streams
Texts for opening streams were used in multiple locations. Created a file to store GUI texts like this and replaced were applicable
This commit is contained in:
parent
01082b123f
commit
f76df80575
6 changed files with 43 additions and 27 deletions
|
@ -339,6 +339,7 @@ HEADERS += \
|
||||||
src/widgets/AccountSwitchPopupWidget.hpp \
|
src/widgets/AccountSwitchPopupWidget.hpp \
|
||||||
src/widgets/AccountSwitchWidget.hpp \
|
src/widgets/AccountSwitchWidget.hpp \
|
||||||
src/widgets/AttachedWindow.hpp \
|
src/widgets/AttachedWindow.hpp \
|
||||||
|
src/widgets/CommonTexts.hpp \
|
||||||
src/widgets/dialogs/EmotePopup.hpp \
|
src/widgets/dialogs/EmotePopup.hpp \
|
||||||
src/widgets/dialogs/LastRunCrashDialog.hpp \
|
src/widgets/dialogs/LastRunCrashDialog.hpp \
|
||||||
src/widgets/dialogs/LoginDialog.hpp \
|
src/widgets/dialogs/LoginDialog.hpp \
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
#include "controllers/highlights/HighlightPhrase.hpp"
|
#include "controllers/highlights/HighlightPhrase.hpp"
|
||||||
#include "controllers/moderationactions/ModerationAction.hpp"
|
#include "controllers/moderationactions/ModerationAction.hpp"
|
||||||
|
#include "widgets/helper/CommonTexts.hpp"
|
||||||
|
|
||||||
#include <pajlada/settings/setting.hpp>
|
#include <pajlada/settings/setting.hpp>
|
||||||
#include <pajlada/settings/settinglistener.hpp>
|
#include <pajlada/settings/settinglistener.hpp>
|
||||||
|
@ -172,7 +173,8 @@ public:
|
||||||
"qrc:/sounds/ping3.wav"};
|
"qrc:/sounds/ping3.wav"};
|
||||||
|
|
||||||
BoolSetting notificationToast = {"/notifications/enableToast", false};
|
BoolSetting notificationToast = {"/notifications/enableToast", false};
|
||||||
QStringSetting openFromToast = {"/notifications/openFromToast", "in browser"};
|
QStringSetting openFromToast = {"/notifications/openFromToast",
|
||||||
|
OPEN_IN_BROWSER};
|
||||||
|
|
||||||
/// External tools
|
/// External tools
|
||||||
// Streamlink
|
// Streamlink
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#include "providers/twitch/TwitchServer.hpp"
|
#include "providers/twitch/TwitchServer.hpp"
|
||||||
#include "singletons/Paths.hpp"
|
#include "singletons/Paths.hpp"
|
||||||
#include "util/StreamLink.hpp"
|
#include "util/StreamLink.hpp"
|
||||||
|
#include "widgets/helper/CommonTexts.hpp"
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
|
|
||||||
|
@ -88,7 +89,7 @@ public:
|
||||||
{
|
{
|
||||||
QString openingMode = getSettings()->openFromToast;
|
QString openingMode = getSettings()->openFromToast;
|
||||||
QString link;
|
QString link;
|
||||||
if (openingMode == "in browser")
|
if (openingMode == OPEN_IN_BROWSER)
|
||||||
{
|
{
|
||||||
if (platform_ == Platform::Twitch)
|
if (platform_ == Platform::Twitch)
|
||||||
{
|
{
|
||||||
|
@ -96,7 +97,7 @@ public:
|
||||||
}
|
}
|
||||||
QDesktopServices::openUrl(QUrl(link));
|
QDesktopServices::openUrl(QUrl(link));
|
||||||
}
|
}
|
||||||
else if (openingMode == "player in browser")
|
else if (openingMode == OPEN_PLAYER_IN_BROWSER)
|
||||||
{
|
{
|
||||||
if (platform_ == Platform::Twitch)
|
if (platform_ == Platform::Twitch)
|
||||||
{
|
{
|
||||||
|
@ -104,12 +105,12 @@ public:
|
||||||
}
|
}
|
||||||
QDesktopServices::openUrl(QUrl(link));
|
QDesktopServices::openUrl(QUrl(link));
|
||||||
}
|
}
|
||||||
else if (openingMode == "in streamlink")
|
else if (openingMode == OPEN_IN_STREAMLINK)
|
||||||
{
|
{
|
||||||
openStreamlinkForChannel(channelName_);
|
openStreamlinkForChannel(channelName_);
|
||||||
}
|
}
|
||||||
//the fourth and last option is "don't open"
|
// the fourth and last option is "don't open"
|
||||||
//in this case obviously nothing should happen
|
// in this case obviously nothing should happen
|
||||||
}
|
}
|
||||||
|
|
||||||
void toastActivated(int actionIndex) const
|
void toastActivated(int actionIndex) const
|
||||||
|
@ -135,10 +136,12 @@ void Toasts::sendWindowsNotification(const QString &channelName, Platform p)
|
||||||
|
|
||||||
templ.setTextField(widestr, WinToastLib::WinToastTemplate::FirstLine);
|
templ.setTextField(widestr, WinToastLib::WinToastTemplate::FirstLine);
|
||||||
|
|
||||||
if (getSettings()->openFromToast != "don't open") {
|
if (getSettings()->openFromToast != DONT_OPEN)
|
||||||
QString mode = getSettings()->openFromToast ;
|
{
|
||||||
|
QString mode = getSettings()->openFromToast;
|
||||||
|
mode = mode.toLower();
|
||||||
|
|
||||||
templ.setTextField(L"Click here to open " + mode.toStdWString(),
|
templ.setTextField(L"Click here to " + mode.toStdWString(),
|
||||||
WinToastLib::WinToastTemplate::SecondLine);
|
WinToastLib::WinToastTemplate::SecondLine);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
10
src/widgets/helper/CommonTexts.hpp
Normal file
10
src/widgets/helper/CommonTexts.hpp
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
#ifndef COMMONTEXTS_HPP
|
||||||
|
#define COMMONTEXTS_HPP
|
||||||
|
|
||||||
|
#define OPEN_IN_BROWSER "Open in browser"
|
||||||
|
#define OPEN_PLAYER_IN_BROWSER "Open in player in browser"
|
||||||
|
#define OPEN_IN_STREAMLINK "Open in streamlink"
|
||||||
|
#define DONT_OPEN "Don't open"
|
||||||
|
|
||||||
|
|
||||||
|
#endif // COMMONTEXTS_HPP
|
|
@ -5,6 +5,7 @@
|
||||||
#include "controllers/notifications/NotificationModel.hpp"
|
#include "controllers/notifications/NotificationModel.hpp"
|
||||||
#include "singletons/Settings.hpp"
|
#include "singletons/Settings.hpp"
|
||||||
#include "util/LayoutCreator.hpp"
|
#include "util/LayoutCreator.hpp"
|
||||||
|
#include "widgets/helper/CommonTexts.hpp"
|
||||||
#include "widgets/helper/EditableModelView.hpp"
|
#include "widgets/helper/EditableModelView.hpp"
|
||||||
|
|
||||||
#include <QCheckBox>
|
#include <QCheckBox>
|
||||||
|
@ -17,10 +18,6 @@
|
||||||
#include <QTableView>
|
#include <QTableView>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
|
|
||||||
#define TOAST_REACTIONS \
|
|
||||||
"in browser", "player in browser", "in streamlink", "don't open"
|
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
NotificationPage::NotificationPage()
|
NotificationPage::NotificationPage()
|
||||||
|
@ -43,17 +40,20 @@ NotificationPage::NotificationPage()
|
||||||
settings.append(
|
settings.append(
|
||||||
this->createCheckBox("Enable toasts (Windows 8 or later)",
|
this->createCheckBox("Enable toasts (Windows 8 or later)",
|
||||||
getSettings()->notificationToast));
|
getSettings()->notificationToast));
|
||||||
auto openIn =
|
auto openIn = settings.emplace<QHBoxLayout>().withoutMargin();
|
||||||
settings.emplace<QHBoxLayout>().withoutMargin();
|
|
||||||
{
|
{
|
||||||
openIn.emplace<QLabel>("Open stream from Toast: ")->setSizePolicy(
|
openIn.emplace<QLabel>("Open stream from Toast: ")
|
||||||
QSizePolicy::Maximum, QSizePolicy::Preferred);
|
->setSizePolicy(QSizePolicy::Maximum,
|
||||||
openIn.append(
|
QSizePolicy::Preferred);
|
||||||
this->createComboBox({TOAST_REACTIONS},
|
openIn
|
||||||
getSettings()->openFromToast))->setSizePolicy(
|
.append(this->createComboBox(
|
||||||
QSizePolicy::Maximum, QSizePolicy::Preferred);
|
{OPEN_IN_BROWSER, OPEN_PLAYER_IN_BROWSER,
|
||||||
|
OPEN_IN_STREAMLINK, DONT_OPEN},
|
||||||
|
getSettings()->openFromToast))
|
||||||
|
->setSizePolicy(QSizePolicy::Maximum,
|
||||||
|
QSizePolicy::Preferred);
|
||||||
}
|
}
|
||||||
openIn->setContentsMargins(40,0,0,0);
|
openIn->setContentsMargins(40, 0, 0, 0);
|
||||||
openIn->setSizeConstraint(QLayout::SetMaximumSize);
|
openIn->setSizeConstraint(QLayout::SetMaximumSize);
|
||||||
#endif
|
#endif
|
||||||
auto customSound =
|
auto customSound =
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
#include "widgets/Label.hpp"
|
#include "widgets/Label.hpp"
|
||||||
#include "widgets/TooltipWidget.hpp"
|
#include "widgets/TooltipWidget.hpp"
|
||||||
#include "widgets/dialogs/SettingsDialog.hpp"
|
#include "widgets/dialogs/SettingsDialog.hpp"
|
||||||
|
#include "widgets/helper/CommonTexts.hpp"
|
||||||
#include "widgets/helper/EffectLabel.hpp"
|
#include "widgets/helper/EffectLabel.hpp"
|
||||||
#include "widgets/splits/Split.hpp"
|
#include "widgets/splits/Split.hpp"
|
||||||
#include "widgets/splits/SplitContainer.hpp"
|
#include "widgets/splits/SplitContainer.hpp"
|
||||||
|
@ -268,13 +269,12 @@ std::unique_ptr<QMenu> SplitHeader::createMainMenu()
|
||||||
});
|
});
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
menu->addAction("Open in browser", this->split_, &Split::openInBrowser);
|
menu->addAction(OPEN_IN_BROWSER, this->split_, &Split::openInBrowser);
|
||||||
#ifndef USEWEBENGINE
|
#ifndef USEWEBENGINE
|
||||||
menu->addAction("Open player in browser", this->split_,
|
menu->addAction(OPEN_PLAYER_IN_BROWSER, this->split_,
|
||||||
&Split::openBrowserPlayer);
|
&Split::openBrowserPlayer);
|
||||||
#endif
|
#endif
|
||||||
menu->addAction("Open in streamlink", this->split_,
|
menu->addAction(OPEN_IN_STREAMLINK, this->split_, &Split::openInStreamlink);
|
||||||
&Split::openInStreamlink);
|
|
||||||
menu->addSeparator();
|
menu->addSeparator();
|
||||||
|
|
||||||
// sub menu
|
// sub menu
|
||||||
|
|
Loading…
Reference in a new issue