reworked the Look settings page

This commit is contained in:
fourtf 2018-07-05 17:38:24 +02:00
parent 80c8e11cec
commit 42550129e7
2 changed files with 87 additions and 73 deletions

View file

@ -17,12 +17,12 @@
#define THEME_ITEMS "White", "Light", "Dark", "Black" #define THEME_ITEMS "White", "Light", "Dark", "Black"
#define TAB_X "Show close button" #define TAB_X "Tab close button"
#define TAB_PREF "Hide preferences button (ctrl+p to show)" #define TAB_PREF "Preferences button (ctrl+p to show)"
#define TAB_USER "Hide user button" #define TAB_USER "User button"
#define SCROLL_SMOOTH "Enable smooth scrolling" #define SCROLL_SMOOTH "Smooth scrolling"
#define SCROLL_NEWMSG "Enable smooth scrolling for new messages" #define SCROLL_NEWMSG "Smooth scrolling for new messages"
// 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"
@ -35,84 +35,101 @@ LookPage::LookPage()
{ {
LayoutCreator<LookPage> layoutCreator(this); LayoutCreator<LookPage> layoutCreator(this);
auto xd = layoutCreator.emplace<QVBoxLayout>().withoutMargin(); auto layout = layoutCreator.emplace<QVBoxLayout>().withoutMargin();
// settings // settings
auto scroll = xd.emplace<QScrollArea>(); auto tabs = layout.emplace<QTabWidget>();
auto widget = scroll.emplaceScrollAreaWidget();
removeScrollAreaBackground(scroll.getElement(), widget.getElement());
auto &layout = *widget.setLayoutType<QVBoxLayout>().withoutMargin(); this->addInterfaceTab(tabs.appendTab(new QVBoxLayout, "Interface"));
this->addMessageTab(tabs.appendTab(new QVBoxLayout, "Messages"));
this->addEmoteTab(tabs.appendTab(new QVBoxLayout, "Emotes"));
this->addApplicationGroup(layout); layout->addStretch(1);
this->addMessagesGroup(layout);
this->addEmotesGroup(layout);
// preview // preview
xd.emplace<Line>(false); layout.emplace<Line>(false);
auto channelView = xd.emplace<ChannelView>(); auto channelView = layout.emplace<ChannelView>();
auto channel = this->createPreviewChannel(); auto channel = this->createPreviewChannel();
channelView->setChannel(channel); channelView->setChannel(channel);
channelView->setScaleIndependantHeight(64); channelView->setScaleIndependantHeight(64);
layout.addStretch(1);
} }
void LookPage::addApplicationGroup(QVBoxLayout &layout) void LookPage::addInterfaceTab(LayoutCreator<QVBoxLayout> layout)
{ {
auto box = LayoutCreator<QVBoxLayout>(&layout)
.emplace<QGroupBox>("Application")
.emplace<QVBoxLayout>()
.withoutMargin();
auto form = box.emplace<QFormLayout>();
// theme // theme
auto *theme = this->createComboBox({THEME_ITEMS}, getApp()->themes->themeName); {
QObject::connect(theme, &QComboBox::currentTextChanged, auto *theme = this->createComboBox({THEME_ITEMS}, getApp()->themes->themeName);
[](const QString &) { getApp()->windows->forceLayoutChannelViews(); }); QObject::connect(theme, &QComboBox::currentTextChanged,
[](const QString &) { getApp()->windows->forceLayoutChannelViews(); });
form->addRow("Theme:", theme); auto box = layout.emplace<QHBoxLayout>().withoutMargin();
box.emplace<QLabel>("Theme: ");
box.append(theme);
box->addStretch(1);
}
// ui scale // ui scale
form->addRow("UI Scaling:", this->createUiScaleSlider()); {
auto box = layout.emplace<QHBoxLayout>().withoutMargin();
// font box.emplace<QLabel>("Scale: ");
form->addRow("Font:", this->createFontChanger()); box.append(this->createUiScaleSlider());
}
// tab x // tab x
form->addRow("Tabs:", this->createCheckBox(TAB_X, getSettings()->showTabCloseButton)); layout.append(this->createCheckBox(TAB_X, getSettings()->showTabCloseButton));
// show buttons // show buttons
#ifndef USEWINSDK #ifndef USEWINSDK
form->addRow("", this->createCheckBox(TAB_PREF, getSettings()->hidePreferencesButton)); layout.append(this->createCheckBox(TAB_PREF, getSettings()->hidePreferencesButton));
form->addRow("", this->createCheckBox(TAB_USER, getSettings()->hideUserButton)); layout.append(this->createCheckBox(TAB_USER, getSettings()->hideUserButton));
#endif #endif
// scrolling // scrolling
form->addRow("Scrolling:", layout.append(this->createCheckBox(SCROLL_SMOOTH, getSettings()->enableSmoothScrolling));
this->createCheckBox(SCROLL_SMOOTH, getSettings()->enableSmoothScrolling)); layout.append(
form->addRow( this->createCheckBox(SCROLL_NEWMSG, getSettings()->enableSmoothScrollingNewMessages));
"", this->createCheckBox(SCROLL_NEWMSG, getSettings()->enableSmoothScrollingNewMessages));
layout->addStretch(1);
} }
void LookPage::addMessagesGroup(QVBoxLayout &layout) void LookPage::addMessageTab(LayoutCreator<QVBoxLayout> layout)
{ {
auto box = // font
LayoutCreator<QVBoxLayout>(&layout).emplace<QGroupBox>("Messages").emplace<QVBoxLayout>(); layout.append(this->createFontChanger());
// --
layout.emplace<Line>(false);
// timestamps // timestamps
box.append(this->createCheckBox("Show timestamps", getSettings()->showTimestamps)); layout.append(this->createCheckBox("Show timestamps", getSettings()->showTimestamps));
auto tbox = box.emplace<QHBoxLayout>().withoutMargin(); // auto tbox = layout.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}, getSettings()->timestampFormat)); // tbox.append(this->createComboBox({TIMESTAMP_FORMATS},
tbox->addStretch(1); // getSettings()->timestampFormat)); tbox->addStretch(1);
} // }
// badges // badges
box.append(this->createCheckBox("Show badges", getSettings()->showBadges)); layout.append(this->createCheckBox("Show badges", getSettings()->showBadges));
// --
layout.emplace<Line>(false);
// seperate
layout.append(this->createCheckBox("Seperate lines", getSettings()->separateMessages));
// alternate
layout.append(
this->createCheckBox("Alternate background", getSettings()->alternateMessageBackground));
// --
layout.emplace<Line>(false);
// lowercase links
layout.append(this->createCheckBox("Lowercase domains", getSettings()->lowercaseLink));
// bold usernames
layout.append(this->createCheckBox("Bold @usernames", getSettings()->usernameBold));
// collapsing // collapsing
{ {
@ -133,31 +150,18 @@ void LookPage::addMessagesGroup(QVBoxLayout &layout)
getSettings()->collpseMessagesMinLines = str.toInt(); getSettings()->collpseMessagesMinLines = str.toInt();
}); });
auto hbox = box.emplace<QHBoxLayout>().withoutMargin(); auto hbox = layout.emplace<QHBoxLayout>().withoutMargin();
hbox.emplace<QLabel>("Collapse messages longer than"); hbox.emplace<QLabel>("Collapse messages longer than");
hbox.append(combo); hbox.append(combo);
hbox.emplace<QLabel>("lines"); hbox.emplace<QLabel>("lines");
} }
// seperate // --
box.append(this->createCheckBox("Separation lines", getSettings()->separateMessages)); layout->addStretch(1);
// alternate
box.append(this->createCheckBox("Alternate background colors",
getSettings()->alternateMessageBackground));
// lowercase links
box.append(this->createCheckBox("Display domains as lowercase", getSettings()->lowercaseLink));
// bold usernames
box.append(this->createCheckBox("Make @username bold", getSettings()->usernameBold));
} }
void LookPage::addEmotesGroup(QVBoxLayout &layout) void LookPage::addEmoteTab(LayoutCreator<QVBoxLayout> layout)
{ {
auto box = LayoutCreator<QVBoxLayout>(&layout)
.emplace<QGroupBox>("Emotes")
.setLayoutType<QVBoxLayout>();
/* /*
emotes.append( emotes.append(
this->createCheckBox("Enable Twitch emotes", app->settings->enableTwitchEmotes)); this->createCheckBox("Enable Twitch emotes", app->settings->enableTwitchEmotes));
@ -167,9 +171,9 @@ void LookPage::addEmotesGroup(QVBoxLayout &layout)
app->settings->enableFfzEmotes)); app->settings->enableFfzEmotes));
emotes.append(this->createCheckBox("Enable emojis", app->settings->enableEmojis)); emotes.append(this->createCheckBox("Enable emojis", app->settings->enableEmojis));
*/ */
box.append(this->createCheckBox("Animated emotes", getSettings()->enableGifAnimations)); layout.append(this->createCheckBox("Animations", getSettings()->enableGifAnimations));
auto scaleBox = box.emplace<QHBoxLayout>().withoutMargin(); auto scaleBox = layout.emplace<QHBoxLayout>().withoutMargin();
{ {
scaleBox.emplace<QLabel>("Size:"); scaleBox.emplace<QLabel>("Size:");
@ -204,10 +208,12 @@ void LookPage::addEmotesGroup(QVBoxLayout &layout)
getSettings()->emojiSet = str; // getSettings()->emojiSet = str; //
}); });
auto hbox = box.emplace<QHBoxLayout>().withoutMargin(); auto hbox = layout.emplace<QHBoxLayout>().withoutMargin();
hbox.emplace<QLabel>("Emoji set:"); hbox.emplace<QLabel>("Emoji set:");
hbox.append(combo); hbox.append(combo);
} }
layout->addStretch(1);
} }
ChannelPtr LookPage::createPreviewChannel() ChannelPtr LookPage::createPreviewChannel()
@ -284,14 +290,15 @@ QLayout *LookPage::createFontChanger()
auto app = getApp(); auto app = getApp();
QHBoxLayout *layout = new QHBoxLayout; QHBoxLayout *layout = new QHBoxLayout;
layout->setMargin(0);
// LABEL // LABEL
QLabel *label = new QLabel(); QLabel *label = new QLabel();
layout->addWidget(label); layout->addWidget(label);
auto updateFontFamilyLabel = [=](auto) { auto updateFontFamilyLabel = [=](auto) {
label->setText(QString::fromStdString(app->fonts->chatFontFamily.getValue()) + ", " + label->setText("Font (" + QString::fromStdString(app->fonts->chatFontFamily.getValue()) +
QString::number(app->fonts->chatFontSize) + "pt"); ", " + QString::number(app->fonts->chatFontSize) + "pt)");
}; };
app->fonts->chatFontFamily.connectSimple(updateFontFamilyLabel, this->managedConnections); app->fonts->chatFontFamily.connectSimple(updateFontFamilyLabel, this->managedConnections);
@ -316,6 +323,8 @@ QLayout *LookPage::createFontChanger()
dialog.exec(); dialog.exec();
}); });
layout->addStretch(1);
return layout; return layout;
} }

View file

@ -1,6 +1,7 @@
#pragma once #pragma once
#include "common/Channel.hpp" #include "common/Channel.hpp"
#include "util/LayoutCreator.hpp"
#include "widgets/settingspages/SettingsPage.hpp" #include "widgets/settingspages/SettingsPage.hpp"
#include <QScrollArea> #include <QScrollArea>
@ -15,6 +16,10 @@ class LookPage : public SettingsPage
public: public:
LookPage(); LookPage();
void addInterfaceTab(LayoutCreator<QVBoxLayout> layout);
void addMessageTab(LayoutCreator<QVBoxLayout> layout);
void addEmoteTab(LayoutCreator<QVBoxLayout> layout);
QLayout *createThemeColorChanger(); QLayout *createThemeColorChanger();
QLayout *createFontChanger(); QLayout *createFontChanger();
QLayout *createUiScaleSlider(); QLayout *createUiScaleSlider();