diff --git a/chatterino.pro b/chatterino.pro index 49afc8881..645a3bf57 100644 --- a/chatterino.pro +++ b/chatterino.pro @@ -183,7 +183,8 @@ SOURCES += \ src/singletons/updatemanager.cpp \ src/widgets/lastruncrashdialog.cpp \ src/widgets/attachedwindow.cpp \ - src/util/tupletablemodel.cpp + src/util/tupletablemodel.cpp \ + src/widgets/settingspages/externaltoolspage.cpp HEADERS += \ src/precompiled_header.hpp \ @@ -309,7 +310,9 @@ HEADERS += \ src/singletons/updatemanager.hpp \ src/widgets/lastruncrashdialog.hpp \ src/widgets/attachedwindow.hpp \ - src/util/tupletablemodel.hpp + src/util/tupletablemodel.hpp \ + src/widgets/settingspages/externaltoolspage.hpp \ + src/util/removescrollareabackground.hpp RESOURCES += \ resources/resources.qrc diff --git a/lib/settings b/lib/settings index 94edfacf1..ad31b3886 160000 --- a/lib/settings +++ b/lib/settings @@ -1 +1 @@ -Subproject commit 94edfacf14728faf3aa1d9c058e89395c97aae14 +Subproject commit ad31b38866d80a17ced902476ed06da69edce3a0 diff --git a/src/util/layoutcreator.hpp b/src/util/layoutcreator.hpp index 1573087bd..f4f669b16 100644 --- a/src/util/layoutcreator.hpp +++ b/src/util/layoutcreator.hpp @@ -1,6 +1,7 @@ #pragma once #include +#include #include #include @@ -52,6 +53,15 @@ public: return LayoutCreator(t); } + template ::value, int>::type = 0> + LayoutCreator emplaceScrollAreaWidget() + { + QWidget *widget = new QWidget; + this->item->setWidget(widget); + return LayoutCreator(widget); + } + template ::value, int>::type = 0, typename std::enable_if::value, int>::type = 0> diff --git a/src/util/removescrollareabackground.hpp b/src/util/removescrollareabackground.hpp new file mode 100644 index 000000000..48bc14637 --- /dev/null +++ b/src/util/removescrollareabackground.hpp @@ -0,0 +1,20 @@ +#pragma once + +#include + +namespace chatterino { +namespace util { + +static void removeScrollAreaBackground(QScrollArea *scrollArea, QWidget *childWidget) +{ + scrollArea->setWidgetResizable(true); + scrollArea->setFrameStyle(0); + + QPalette p; + p.setColor(QPalette::Background, QColor(0, 0, 0, 0)); + scrollArea->setPalette(p); + childWidget->setPalette(p); +} + +} // namespace util +} // namespace chatterino diff --git a/src/widgets/helper/notebooktab.cpp b/src/widgets/helper/notebooktab.cpp index ff60ce22b..e65a9f388 100644 --- a/src/widgets/helper/notebooktab.cpp +++ b/src/widgets/helper/notebooktab.cpp @@ -80,11 +80,12 @@ void NotebookTab2::updateSize() float scale = getScale(); int width; + QFontMetrics metrics(this->font()); if (singletons::SettingManager::getInstance().hideTabX) { - width = (int)((fontMetrics().width(this->title) + 16 /*+ 16*/) * scale); + width = (int)((metrics.width(this->title) + 16 /*+ 16*/) * scale); } else { - width = (int)((fontMetrics().width(this->title) + 8 + 24 /*+ 16*/) * scale); + width = (int)((metrics.width(this->title) + 8 + 24 /*+ 16*/) * scale); } this->resize(std::min((int)(150 * scale), width), (int)(24 * scale)); diff --git a/src/widgets/settingsdialog.cpp b/src/widgets/settingsdialog.cpp index abdeb24a3..491b38713 100644 --- a/src/widgets/settingsdialog.cpp +++ b/src/widgets/settingsdialog.cpp @@ -7,6 +7,7 @@ #include "widgets/settingspages/behaviourpage.hpp" #include "widgets/settingspages/commandpage.hpp" #include "widgets/settingspages/emotespage.hpp" +#include "widgets/settingspages/externaltoolspage.hpp" #include "widgets/settingspages/highlightingpage.hpp" #include "widgets/settingspages/ignoremessagespage.hpp" #include "widgets/settingspages/ignoreuserspage.hpp" @@ -75,10 +76,16 @@ void SettingsDialog::addTabs() this->ui.tabContainer->setSpacing(0); this->addTab(new settingspages::AccountsPage); + + this->ui.tabContainer->addStretch(1); + this->addTab(new settingspages::AppearancePage); this->addTab(new settingspages::BehaviourPage); + + this->ui.tabContainer->addStretch(1); + this->addTab(new settingspages::CommandPage); - this->addTab(new settingspages::EmotesPage); + // this->addTab(new settingspages::EmotesPage); this->addTab(new settingspages::HighlightingPage); this->ui.tabContainer->addStretch(1); @@ -88,7 +95,8 @@ void SettingsDialog::addTabs() this->addTab(new settingspages::KeyboardSettingsPage); this->addTab(new settingspages::LogsPage); this->addTab(new settingspages::ModerationPage); - this->addTab(new settingspages::SpecialChannelsPage); + // this->addTab(new settingspages::SpecialChannelsPage); + this->addTab(new settingspages::ExternalToolsPage); this->ui.tabContainer->addStretch(1); this->addTab(new settingspages::AboutPage, Qt::AlignBottom); diff --git a/src/widgets/settingspages/appearancepage.cpp b/src/widgets/settingspages/appearancepage.cpp index d2db2c749..e7cd3c163 100644 --- a/src/widgets/settingspages/appearancepage.cpp +++ b/src/widgets/settingspages/appearancepage.cpp @@ -5,20 +5,24 @@ #include #include #include +#include #include #include #include "util/layoutcreator.hpp" +#include "util/removescrollareabackground.hpp" #define THEME_ITEMS "White", "Light", "Dark", "Black" -#define TAB_X "Hide tab x" +#define TAB_X "Show close button" #define TAB_PREF "Hide preferences button (ctrl+p to show)" #define TAB_USER "Hide user button" #define SCROLL_SMOOTH "Enable smooth scrolling" #define SCROLL_NEWMSG "Enable smooth scrolling for new messages" +#define LAST_MSG "Mark the last message you read (dotted line)" + // clang-format off #define TIMESTAMP_FORMATS "hh:mm a", "h:mm a", "hh:mm:ss a", "h:mm:ss a", "HH:mm", "H:mm", "HH:mm:ss", "H:mm:ss" // clang-format on @@ -28,11 +32,16 @@ namespace widgets { namespace settingspages { AppearancePage::AppearancePage() - : SettingsPage("Appearance", ":/images/theme.svg") + : SettingsPage("Look", ":/images/theme.svg") { singletons::SettingManager &settings = singletons::SettingManager::getInstance(); util::LayoutCreator layoutCreator(this); - auto layout = layoutCreator.emplace().withoutMargin(); + + auto scroll = layoutCreator.emplace(); + auto widget = scroll.emplaceScrollAreaWidget(); + util::removeScrollAreaBackground(*scroll, *widget); + + auto layout = widget.setLayoutType(); auto application = layout.emplace("Application").emplace().withoutMargin(); @@ -40,37 +49,50 @@ AppearancePage::AppearancePage() auto form = application.emplace(); // clang-format off - form->addRow("Theme:", this->createComboBox({THEME_ITEMS}, singletons::ThemeManager::getInstance().themeName)); - form->addRow("Theme color:", this->createThemeColorChanger()); - form->addRow("Font:", this->createFontChanger()); + form->addRow("Theme:", this->createComboBox({THEME_ITEMS}, singletons::ThemeManager::getInstance().themeName)); + form->addRow("Theme color:", this->createThemeColorChanger()); + form->addRow("Font:", this->createFontChanger()); - form->addRow("Tab bar:", this->createCheckBox(TAB_X, settings.hideTabX)); -#ifndef USEWINSDK - form->addRow("", this->createCheckBox(TAB_PREF, settings.hidePreferencesButton)); - form->addRow("", this->createCheckBox(TAB_USER, settings.hideUserButton)); -#endif + form->addRow("Tabs:", this->createCheckBox(TAB_X, settings.hideTabX)); + #ifndef USEWINSDK + form->addRow("", this->createCheckBox(TAB_PREF, settings.hidePreferencesButton)); + form->addRow("", this->createCheckBox(TAB_USER, settings.hideUserButton)); + #endif - form->addRow("Scrolling:", this->createCheckBox(SCROLL_SMOOTH, settings.enableSmoothScrolling)); - form->addRow("", this->createCheckBox(SCROLL_NEWMSG, settings.enableSmoothScrollingNewMessages)); + form->addRow("Scrolling:", this->createCheckBox(SCROLL_SMOOTH, settings.enableSmoothScrolling)); + form->addRow("", this->createCheckBox(SCROLL_NEWMSG, settings.enableSmoothScrollingNewMessages)); // clang-format on } - auto messages = layout.emplace("Messages").emplace().withoutMargin(); + auto messages = layout.emplace("Messages").emplace(); { messages.append(this->createCheckBox("Show timestamp", settings.showTimestamps)); - auto tbox = messages.emplace(); + auto tbox = messages.emplace().withoutMargin(); { tbox.emplace("timestamp format (a = am/pm):"); tbox.append(this->createComboBox({TIMESTAMP_FORMATS}, settings.timestampFormat)); tbox->addStretch(1); } - auto checkbox = this->createCheckBox("Show badges", settings.showBadges); + messages.append(this->createCheckBox("Show badges", settings.showBadges)); + auto checkbox = this->createCheckBox("Seperate messages", settings.seperateMessages); checkbox->setEnabled(false); messages.append(checkbox); - messages.append(this->createCheckBox("Seperate messages", settings.seperateMessages)); messages.append( this->createCheckBox("Show message length while typing", settings.showMessageLength)); + + messages.append(this->createCheckBox(LAST_MSG, settings.showLastMessageIndicator)); + } + + auto emotes = layout.emplace("Emotes").setLayoutType(); + { + emotes.append(this->createCheckBox("Enable Twitch emotes", settings.enableTwitchEmotes)); + emotes.append( + this->createCheckBox("Enable BetterTTV emotes for Twitch", settings.enableBttvEmotes)); + emotes.append(this->createCheckBox("Enable FrankerFaceZ emotes for Twitch", + settings.enableFfzEmotes)); + emotes.append(this->createCheckBox("Enable emojis", settings.enableEmojis)); + emotes.append(this->createCheckBox("Enable animations", settings.enableGifAnimations)); } layout->addStretch(1); diff --git a/src/widgets/settingspages/appearancepage.hpp b/src/widgets/settingspages/appearancepage.hpp index b1ac61b27..480e9e5c8 100644 --- a/src/widgets/settingspages/appearancepage.hpp +++ b/src/widgets/settingspages/appearancepage.hpp @@ -2,6 +2,8 @@ #include "widgets/settingspages/settingspage.hpp" +#include + namespace chatterino { namespace widgets { namespace settingspages { diff --git a/src/widgets/settingspages/behaviourpage.cpp b/src/widgets/settingspages/behaviourpage.cpp index 3c89b2a0f..4b46d282c 100644 --- a/src/widgets/settingspages/behaviourpage.cpp +++ b/src/widgets/settingspages/behaviourpage.cpp @@ -9,19 +9,16 @@ #define WINDOW_TOPMOST "Window always on top (requires restart)" #define INPUT_EMPTY "Hide input box when empty" -#define LAST_MSG "Show last read message indicator (marks the spot where you left the window)" #define PAUSE_HOVERING "When hovering" #define LIMIT_CHATTERS_FOR_SMALLER_STREAMERS "Only fetch chatters list for viewers under X viewers" -#define STREAMLINK_QUALITY "Choose", "Source", "High", "Medium", "Low", "Audio only" - namespace chatterino { namespace widgets { namespace settingspages { BehaviourPage::BehaviourPage() - : SettingsPage("Behaviour", ":/images/behave.svg") + : SettingsPage("Feel", ":/images/behave.svg") { singletons::SettingManager &settings = singletons::SettingManager::getInstance(); util::LayoutCreator layoutCreator(this); @@ -32,7 +29,6 @@ BehaviourPage::BehaviourPage() { form->addRow("Window:", this->createCheckBox(WINDOW_TOPMOST, settings.windowTopMost)); form->addRow("Messages:", this->createCheckBox(INPUT_EMPTY, settings.hideEmptyInput)); - form->addRow("", this->createCheckBox(LAST_MSG, settings.showLastMessageIndicator)); form->addRow("Pause chat:", this->createCheckBox(PAUSE_HOVERING, settings.pauseChatHover)); form->addRow("Mouse scroll speed:", this->createMouseScrollSlider()); @@ -54,12 +50,10 @@ BehaviourPage::BehaviourPage() } { - auto group = layout.emplace("Streamlink"); - auto groupLayout = group.setLayoutType(); - groupLayout->addRow("Streamlink path:", this->createLineEdit(settings.streamlinkPath)); - groupLayout->addRow("Prefered quality:", - this->createComboBox({STREAMLINK_QUALITY}, settings.preferredQuality)); - groupLayout->addRow("Additional options:", this->createLineEdit(settings.streamlinkOpts)); + auto group = layout.emplace("Misc"); + auto groupLayout = group.setLayoutType(); + + groupLayout.append(this->createCheckBox("Show whispers inline", settings.inlineWhispers)); } layout->addStretch(1); diff --git a/src/widgets/settingspages/commandpage.cpp b/src/widgets/settingspages/commandpage.cpp index ff18bd4b6..5355ab848 100644 --- a/src/widgets/settingspages/commandpage.cpp +++ b/src/widgets/settingspages/commandpage.cpp @@ -19,7 +19,7 @@ namespace widgets { namespace settingspages { CommandPage::CommandPage() - : SettingsPage("Commands", ":/images/commands.svg") + : SettingsPage("Macros", ":/images/commands.svg") { util::LayoutCreator layoutCreator(this); auto layout = layoutCreator.emplace().withoutMargin(); diff --git a/src/widgets/settingspages/emotespage.cpp b/src/widgets/settingspages/emotespage.cpp index b5788815b..6578c1287 100644 --- a/src/widgets/settingspages/emotespage.cpp +++ b/src/widgets/settingspages/emotespage.cpp @@ -9,19 +9,20 @@ namespace settingspages { EmotesPage::EmotesPage() : SettingsPage("Emotes", ":/images/emote.svg") { - singletons::SettingManager &settings = singletons::SettingManager::getInstance(); - util::LayoutCreator layoutCreator(this); - auto layout = layoutCreator.emplace().withoutMargin(); + // singletons::SettingManager &settings = singletons::SettingManager::getInstance(); + // util::LayoutCreator layoutCreator(this); + // auto layout = layoutCreator.emplace().withoutMargin(); - // clang-format off - layout.append(this->createCheckBox("Enable Twitch emotes", settings.enableTwitchEmotes)); - layout.append(this->createCheckBox("Enable BetterTTV emotes", settings.enableBttvEmotes)); - layout.append(this->createCheckBox("Enable FrankerFaceZ emotes", settings.enableFfzEmotes)); - layout.append(this->createCheckBox("Enable emojis", settings.enableEmojis)); - layout.append(this->createCheckBox("Enable gif animations", settings.enableGifAnimations)); - // clang-format on + // // clang-format off + // layout.append(this->createCheckBox("Enable Twitch emotes", settings.enableTwitchEmotes)); + // layout.append(this->createCheckBox("Enable BetterTTV emotes", settings.enableBttvEmotes)); + // layout.append(this->createCheckBox("Enable FrankerFaceZ emotes", + // settings.enableFfzEmotes)); layout.append(this->createCheckBox("Enable emojis", + // settings.enableEmojis)); layout.append(this->createCheckBox("Enable gif animations", + // settings.enableGifAnimations)); + // // clang-format on - layout->addStretch(1); + // layout->addStretch(1); } } // namespace settingspages diff --git a/src/widgets/settingspages/externaltoolspage.cpp b/src/widgets/settingspages/externaltoolspage.cpp new file mode 100644 index 000000000..475f4ff13 --- /dev/null +++ b/src/widgets/settingspages/externaltoolspage.cpp @@ -0,0 +1,32 @@ +#include "externaltoolspage.hpp" + +#include "util/layoutcreator.hpp" + +#include + +#define STREAMLINK_QUALITY "Choose", "Source", "High", "Medium", "Low", "Audio only" + +namespace chatterino { +namespace widgets { +namespace settingspages { + +ExternalToolsPage::ExternalToolsPage() + : SettingsPage("External tools", "") +{ + singletons::SettingManager &settings = singletons::SettingManager::getInstance(); + util::LayoutCreator layoutCreator(this); + auto layout = layoutCreator.setLayoutType().withoutMargin(); + + { + auto group = layout.emplace("Streamlink"); + auto groupLayout = group.setLayoutType(); + groupLayout->addRow("Streamlink path:", this->createLineEdit(settings.streamlinkPath)); + groupLayout->addRow("Prefered quality:", + this->createComboBox({STREAMLINK_QUALITY}, settings.preferredQuality)); + groupLayout->addRow("Additional options:", this->createLineEdit(settings.streamlinkOpts)); + } +} + +} // namespace settingspages +} // namespace widgets +} // namespace chatterino diff --git a/src/widgets/settingspages/externaltoolspage.hpp b/src/widgets/settingspages/externaltoolspage.hpp new file mode 100644 index 000000000..ccf960626 --- /dev/null +++ b/src/widgets/settingspages/externaltoolspage.hpp @@ -0,0 +1,17 @@ +#pragma once + +#include "widgets/settingspages/settingspage.hpp" + +namespace chatterino { +namespace widgets { +namespace settingspages { + +class ExternalToolsPage : public SettingsPage +{ +public: + ExternalToolsPage(); +}; + +} // namespace settingspages +} // namespace widgets +} // namespace chatterino diff --git a/src/widgets/settingspages/highlightingpage.cpp b/src/widgets/settingspages/highlightingpage.cpp index 40842ba11..9bc366126 100644 --- a/src/widgets/settingspages/highlightingpage.cpp +++ b/src/widgets/settingspages/highlightingpage.cpp @@ -70,8 +70,12 @@ HighlightingPage::HighlightingPage() view->setSelectionMode(QAbstractItemView::SingleSelection); view->setSelectionBehavior(QAbstractItemView::SelectRows); view->horizontalHeader()->setSectionResizeMode(QHeaderView::Fixed); - view->resizeColumnsToContents(); - view->setColumnWidth(0, 250); + + // fourtf: make class extrend BaseWidget and add this to dpiChanged + QTimer::singleShot(1, [view] { + view->resizeColumnsToContents(); + view->setColumnWidth(0, 250); + }); auto buttons = highlights.emplace(); diff --git a/src/widgets/settingspages/specialchannelspage.cpp b/src/widgets/settingspages/specialchannelspage.cpp index 0c5550a1e..3a57c3cda 100644 --- a/src/widgets/settingspages/specialchannelspage.cpp +++ b/src/widgets/settingspages/specialchannelspage.cpp @@ -26,7 +26,6 @@ SpecialChannelsPage::SpecialChannelsPage() auto whispers = layout.emplace("Whispers").setLayoutType(); { whispers.emplace("Join /whispers to view your mentions."); - whispers.append(this->createCheckBox("Show whispers inline", settings.inlineWhispers)); } layout->addStretch(1);