switched up the settings pages

This commit is contained in:
fourtf 2018-04-25 20:35:32 +02:00
parent 98be8aaeff
commit b176dc5295
15 changed files with 163 additions and 50 deletions

View file

@ -183,7 +183,8 @@ SOURCES += \
src/singletons/updatemanager.cpp \ src/singletons/updatemanager.cpp \
src/widgets/lastruncrashdialog.cpp \ src/widgets/lastruncrashdialog.cpp \
src/widgets/attachedwindow.cpp \ src/widgets/attachedwindow.cpp \
src/util/tupletablemodel.cpp src/util/tupletablemodel.cpp \
src/widgets/settingspages/externaltoolspage.cpp
HEADERS += \ HEADERS += \
src/precompiled_header.hpp \ src/precompiled_header.hpp \
@ -309,7 +310,9 @@ HEADERS += \
src/singletons/updatemanager.hpp \ src/singletons/updatemanager.hpp \
src/widgets/lastruncrashdialog.hpp \ src/widgets/lastruncrashdialog.hpp \
src/widgets/attachedwindow.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/resources.qrc resources/resources.qrc

@ -1 +1 @@
Subproject commit 94edfacf14728faf3aa1d9c058e89395c97aae14 Subproject commit ad31b38866d80a17ced902476ed06da69edce3a0

View file

@ -1,6 +1,7 @@
#pragma once #pragma once
#include <QHBoxLayout> #include <QHBoxLayout>
#include <QScrollArea>
#include <QTabWidget> #include <QTabWidget>
#include <QWidget> #include <QWidget>
@ -52,6 +53,15 @@ public:
return LayoutCreator<T2>(t); return LayoutCreator<T2>(t);
} }
template <typename Q = T,
typename std::enable_if<std::is_base_of<QScrollArea, Q>::value, int>::type = 0>
LayoutCreator<QWidget> emplaceScrollAreaWidget()
{
QWidget *widget = new QWidget;
this->item->setWidget(widget);
return LayoutCreator<QWidget>(widget);
}
template <typename T2, typename Q = T, template <typename T2, typename Q = T,
typename std::enable_if<std::is_base_of<QWidget, Q>::value, int>::type = 0, typename std::enable_if<std::is_base_of<QWidget, Q>::value, int>::type = 0,
typename std::enable_if<std::is_base_of<QLayout, T2>::value, int>::type = 0> typename std::enable_if<std::is_base_of<QLayout, T2>::value, int>::type = 0>

View file

@ -0,0 +1,20 @@
#pragma once
#include <QScrollArea>
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

View file

@ -80,11 +80,12 @@ void NotebookTab2::updateSize()
float scale = getScale(); float scale = getScale();
int width; int width;
QFontMetrics metrics(this->font());
if (singletons::SettingManager::getInstance().hideTabX) { if (singletons::SettingManager::getInstance().hideTabX) {
width = (int)((fontMetrics().width(this->title) + 16 /*+ 16*/) * scale); width = (int)((metrics.width(this->title) + 16 /*+ 16*/) * scale);
} else { } 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)); this->resize(std::min((int)(150 * scale), width), (int)(24 * scale));

View file

@ -7,6 +7,7 @@
#include "widgets/settingspages/behaviourpage.hpp" #include "widgets/settingspages/behaviourpage.hpp"
#include "widgets/settingspages/commandpage.hpp" #include "widgets/settingspages/commandpage.hpp"
#include "widgets/settingspages/emotespage.hpp" #include "widgets/settingspages/emotespage.hpp"
#include "widgets/settingspages/externaltoolspage.hpp"
#include "widgets/settingspages/highlightingpage.hpp" #include "widgets/settingspages/highlightingpage.hpp"
#include "widgets/settingspages/ignoremessagespage.hpp" #include "widgets/settingspages/ignoremessagespage.hpp"
#include "widgets/settingspages/ignoreuserspage.hpp" #include "widgets/settingspages/ignoreuserspage.hpp"
@ -75,10 +76,16 @@ void SettingsDialog::addTabs()
this->ui.tabContainer->setSpacing(0); this->ui.tabContainer->setSpacing(0);
this->addTab(new settingspages::AccountsPage); this->addTab(new settingspages::AccountsPage);
this->ui.tabContainer->addStretch(1);
this->addTab(new settingspages::AppearancePage); this->addTab(new settingspages::AppearancePage);
this->addTab(new settingspages::BehaviourPage); this->addTab(new settingspages::BehaviourPage);
this->ui.tabContainer->addStretch(1);
this->addTab(new settingspages::CommandPage); this->addTab(new settingspages::CommandPage);
this->addTab(new settingspages::EmotesPage); // this->addTab(new settingspages::EmotesPage);
this->addTab(new settingspages::HighlightingPage); this->addTab(new settingspages::HighlightingPage);
this->ui.tabContainer->addStretch(1); this->ui.tabContainer->addStretch(1);
@ -88,7 +95,8 @@ void SettingsDialog::addTabs()
this->addTab(new settingspages::KeyboardSettingsPage); this->addTab(new settingspages::KeyboardSettingsPage);
this->addTab(new settingspages::LogsPage); this->addTab(new settingspages::LogsPage);
this->addTab(new settingspages::ModerationPage); 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->ui.tabContainer->addStretch(1);
this->addTab(new settingspages::AboutPage, Qt::AlignBottom); this->addTab(new settingspages::AboutPage, Qt::AlignBottom);

View file

@ -5,20 +5,24 @@
#include <QGroupBox> #include <QGroupBox>
#include <QLabel> #include <QLabel>
#include <QPushButton> #include <QPushButton>
#include <QScrollArea>
#include <QSlider> #include <QSlider>
#include <QVBoxLayout> #include <QVBoxLayout>
#include "util/layoutcreator.hpp" #include "util/layoutcreator.hpp"
#include "util/removescrollareabackground.hpp"
#define THEME_ITEMS "White", "Light", "Dark", "Black" #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_PREF "Hide preferences button (ctrl+p to show)"
#define TAB_USER "Hide user button" #define TAB_USER "Hide user button"
#define SCROLL_SMOOTH "Enable smooth scrolling" #define SCROLL_SMOOTH "Enable smooth scrolling"
#define SCROLL_NEWMSG "Enable smooth scrolling for new messages" #define SCROLL_NEWMSG "Enable smooth scrolling for new messages"
#define LAST_MSG "Mark the last message you read (dotted line)"
// clang-format off // 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" #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 // clang-format on
@ -28,11 +32,16 @@ namespace widgets {
namespace settingspages { namespace settingspages {
AppearancePage::AppearancePage() AppearancePage::AppearancePage()
: SettingsPage("Appearance", ":/images/theme.svg") : SettingsPage("Look", ":/images/theme.svg")
{ {
singletons::SettingManager &settings = singletons::SettingManager::getInstance(); singletons::SettingManager &settings = singletons::SettingManager::getInstance();
util::LayoutCreator<AppearancePage> layoutCreator(this); util::LayoutCreator<AppearancePage> layoutCreator(this);
auto layout = layoutCreator.emplace<QVBoxLayout>().withoutMargin();
auto scroll = layoutCreator.emplace<QScrollArea>();
auto widget = scroll.emplaceScrollAreaWidget();
util::removeScrollAreaBackground(*scroll, *widget);
auto layout = widget.setLayoutType<QVBoxLayout>();
auto application = auto application =
layout.emplace<QGroupBox>("Application").emplace<QVBoxLayout>().withoutMargin(); layout.emplace<QGroupBox>("Application").emplace<QVBoxLayout>().withoutMargin();
@ -40,37 +49,50 @@ AppearancePage::AppearancePage()
auto form = application.emplace<QFormLayout>(); auto form = application.emplace<QFormLayout>();
// clang-format off // clang-format off
form->addRow("Theme:", this->createComboBox({THEME_ITEMS}, singletons::ThemeManager::getInstance().themeName)); form->addRow("Theme:", this->createComboBox({THEME_ITEMS}, singletons::ThemeManager::getInstance().themeName));
form->addRow("Theme color:", this->createThemeColorChanger()); form->addRow("Theme color:", this->createThemeColorChanger());
form->addRow("Font:", this->createFontChanger()); form->addRow("Font:", this->createFontChanger());
form->addRow("Tab bar:", this->createCheckBox(TAB_X, settings.hideTabX)); form->addRow("Tabs:", this->createCheckBox(TAB_X, settings.hideTabX));
#ifndef USEWINSDK #ifndef USEWINSDK
form->addRow("", this->createCheckBox(TAB_PREF, settings.hidePreferencesButton)); form->addRow("", this->createCheckBox(TAB_PREF, settings.hidePreferencesButton));
form->addRow("", this->createCheckBox(TAB_USER, settings.hideUserButton)); form->addRow("", this->createCheckBox(TAB_USER, settings.hideUserButton));
#endif #endif
form->addRow("Scrolling:", this->createCheckBox(SCROLL_SMOOTH, settings.enableSmoothScrolling)); form->addRow("Scrolling:", this->createCheckBox(SCROLL_SMOOTH, settings.enableSmoothScrolling));
form->addRow("", this->createCheckBox(SCROLL_NEWMSG, settings.enableSmoothScrollingNewMessages)); form->addRow("", this->createCheckBox(SCROLL_NEWMSG, settings.enableSmoothScrollingNewMessages));
// clang-format on // clang-format on
} }
auto messages = layout.emplace<QGroupBox>("Messages").emplace<QVBoxLayout>().withoutMargin(); auto messages = layout.emplace<QGroupBox>("Messages").emplace<QVBoxLayout>();
{ {
messages.append(this->createCheckBox("Show timestamp", settings.showTimestamps)); messages.append(this->createCheckBox("Show timestamp", settings.showTimestamps));
auto tbox = messages.emplace<QHBoxLayout>(); auto tbox = messages.emplace<QHBoxLayout>().withoutMargin();
{ {
tbox.emplace<QLabel>("timestamp format (a = am/pm):"); tbox.emplace<QLabel>("timestamp format (a = am/pm):");
tbox.append(this->createComboBox({TIMESTAMP_FORMATS}, settings.timestampFormat)); tbox.append(this->createComboBox({TIMESTAMP_FORMATS}, settings.timestampFormat));
tbox->addStretch(1); 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); checkbox->setEnabled(false);
messages.append(checkbox); messages.append(checkbox);
messages.append(this->createCheckBox("Seperate messages", settings.seperateMessages));
messages.append( messages.append(
this->createCheckBox("Show message length while typing", settings.showMessageLength)); this->createCheckBox("Show message length while typing", settings.showMessageLength));
messages.append(this->createCheckBox(LAST_MSG, settings.showLastMessageIndicator));
}
auto emotes = layout.emplace<QGroupBox>("Emotes").setLayoutType<QVBoxLayout>();
{
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); layout->addStretch(1);

View file

@ -2,6 +2,8 @@
#include "widgets/settingspages/settingspage.hpp" #include "widgets/settingspages/settingspage.hpp"
#include <QScrollArea>
namespace chatterino { namespace chatterino {
namespace widgets { namespace widgets {
namespace settingspages { namespace settingspages {

View file

@ -9,19 +9,16 @@
#define WINDOW_TOPMOST "Window always on top (requires restart)" #define WINDOW_TOPMOST "Window always on top (requires restart)"
#define INPUT_EMPTY "Hide input box when empty" #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 PAUSE_HOVERING "When hovering"
#define LIMIT_CHATTERS_FOR_SMALLER_STREAMERS "Only fetch chatters list for viewers under X viewers" #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 chatterino {
namespace widgets { namespace widgets {
namespace settingspages { namespace settingspages {
BehaviourPage::BehaviourPage() BehaviourPage::BehaviourPage()
: SettingsPage("Behaviour", ":/images/behave.svg") : SettingsPage("Feel", ":/images/behave.svg")
{ {
singletons::SettingManager &settings = singletons::SettingManager::getInstance(); singletons::SettingManager &settings = singletons::SettingManager::getInstance();
util::LayoutCreator<BehaviourPage> layoutCreator(this); util::LayoutCreator<BehaviourPage> layoutCreator(this);
@ -32,7 +29,6 @@ BehaviourPage::BehaviourPage()
{ {
form->addRow("Window:", this->createCheckBox(WINDOW_TOPMOST, settings.windowTopMost)); form->addRow("Window:", this->createCheckBox(WINDOW_TOPMOST, settings.windowTopMost));
form->addRow("Messages:", this->createCheckBox(INPUT_EMPTY, settings.hideEmptyInput)); 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("Pause chat:", this->createCheckBox(PAUSE_HOVERING, settings.pauseChatHover));
form->addRow("Mouse scroll speed:", this->createMouseScrollSlider()); form->addRow("Mouse scroll speed:", this->createMouseScrollSlider());
@ -54,12 +50,10 @@ BehaviourPage::BehaviourPage()
} }
{ {
auto group = layout.emplace<QGroupBox>("Streamlink"); auto group = layout.emplace<QGroupBox>("Misc");
auto groupLayout = group.setLayoutType<QFormLayout>(); auto groupLayout = group.setLayoutType<QVBoxLayout>();
groupLayout->addRow("Streamlink path:", this->createLineEdit(settings.streamlinkPath));
groupLayout->addRow("Prefered quality:", groupLayout.append(this->createCheckBox("Show whispers inline", settings.inlineWhispers));
this->createComboBox({STREAMLINK_QUALITY}, settings.preferredQuality));
groupLayout->addRow("Additional options:", this->createLineEdit(settings.streamlinkOpts));
} }
layout->addStretch(1); layout->addStretch(1);

View file

@ -19,7 +19,7 @@ namespace widgets {
namespace settingspages { namespace settingspages {
CommandPage::CommandPage() CommandPage::CommandPage()
: SettingsPage("Commands", ":/images/commands.svg") : SettingsPage("Macros", ":/images/commands.svg")
{ {
util::LayoutCreator<CommandPage> layoutCreator(this); util::LayoutCreator<CommandPage> layoutCreator(this);
auto layout = layoutCreator.emplace<QVBoxLayout>().withoutMargin(); auto layout = layoutCreator.emplace<QVBoxLayout>().withoutMargin();

View file

@ -9,19 +9,20 @@ namespace settingspages {
EmotesPage::EmotesPage() EmotesPage::EmotesPage()
: SettingsPage("Emotes", ":/images/emote.svg") : SettingsPage("Emotes", ":/images/emote.svg")
{ {
singletons::SettingManager &settings = singletons::SettingManager::getInstance(); // singletons::SettingManager &settings = singletons::SettingManager::getInstance();
util::LayoutCreator<EmotesPage> layoutCreator(this); // util::LayoutCreator<EmotesPage> layoutCreator(this);
auto layout = layoutCreator.emplace<QVBoxLayout>().withoutMargin(); // auto layout = layoutCreator.emplace<QVBoxLayout>().withoutMargin();
// clang-format off // // clang-format off
layout.append(this->createCheckBox("Enable Twitch emotes", settings.enableTwitchEmotes)); // layout.append(this->createCheckBox("Enable Twitch emotes", settings.enableTwitchEmotes));
layout.append(this->createCheckBox("Enable BetterTTV emotes", settings.enableBttvEmotes)); // layout.append(this->createCheckBox("Enable BetterTTV emotes", settings.enableBttvEmotes));
layout.append(this->createCheckBox("Enable FrankerFaceZ emotes", settings.enableFfzEmotes)); // layout.append(this->createCheckBox("Enable FrankerFaceZ emotes",
layout.append(this->createCheckBox("Enable emojis", settings.enableEmojis)); // settings.enableFfzEmotes)); layout.append(this->createCheckBox("Enable emojis",
layout.append(this->createCheckBox("Enable gif animations", settings.enableGifAnimations)); // settings.enableEmojis)); layout.append(this->createCheckBox("Enable gif animations",
// clang-format on // settings.enableGifAnimations));
// // clang-format on
layout->addStretch(1); // layout->addStretch(1);
} }
} // namespace settingspages } // namespace settingspages

View file

@ -0,0 +1,32 @@
#include "externaltoolspage.hpp"
#include "util/layoutcreator.hpp"
#include <QGroupBox>
#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<ExternalToolsPage> layoutCreator(this);
auto layout = layoutCreator.setLayoutType<QVBoxLayout>().withoutMargin();
{
auto group = layout.emplace<QGroupBox>("Streamlink");
auto groupLayout = group.setLayoutType<QFormLayout>();
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

View file

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

View file

@ -70,8 +70,12 @@ HighlightingPage::HighlightingPage()
view->setSelectionMode(QAbstractItemView::SingleSelection); view->setSelectionMode(QAbstractItemView::SingleSelection);
view->setSelectionBehavior(QAbstractItemView::SelectRows); view->setSelectionBehavior(QAbstractItemView::SelectRows);
view->horizontalHeader()->setSectionResizeMode(QHeaderView::Fixed); 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<QHBoxLayout>(); auto buttons = highlights.emplace<QHBoxLayout>();

View file

@ -26,7 +26,6 @@ SpecialChannelsPage::SpecialChannelsPage()
auto whispers = layout.emplace<QGroupBox>("Whispers").setLayoutType<QVBoxLayout>(); auto whispers = layout.emplace<QGroupBox>("Whispers").setLayoutType<QVBoxLayout>();
{ {
whispers.emplace<QLabel>("Join /whispers to view your mentions."); whispers.emplace<QLabel>("Join /whispers to view your mentions.");
whispers.append(this->createCheckBox("Show whispers inline", settings.inlineWhispers));
} }
layout->addStretch(1); layout->addStretch(1);