2018-06-26 14:09:39 +02:00
|
|
|
#include "AppearancePage.hpp"
|
2018-01-12 23:09:05 +01:00
|
|
|
|
2018-06-26 14:09:39 +02:00
|
|
|
#include "Application.hpp"
|
|
|
|
#include "singletons/WindowManager.hpp"
|
|
|
|
#include "util/LayoutCreator.hpp"
|
|
|
|
#include "util/RemoveScrollAreaBackground.hpp"
|
2018-04-27 22:11:19 +02:00
|
|
|
|
2018-01-12 23:09:05 +01:00
|
|
|
#include <QFontDialog>
|
|
|
|
#include <QFormLayout>
|
|
|
|
#include <QGroupBox>
|
|
|
|
#include <QLabel>
|
|
|
|
#include <QPushButton>
|
2018-04-25 20:35:32 +02:00
|
|
|
#include <QScrollArea>
|
2018-04-03 02:55:32 +02:00
|
|
|
#include <QSlider>
|
2018-01-12 23:09:05 +01:00
|
|
|
#include <QVBoxLayout>
|
|
|
|
|
|
|
|
#define THEME_ITEMS "White", "Light", "Dark", "Black"
|
|
|
|
|
2018-04-25 20:35:32 +02:00
|
|
|
#define TAB_X "Show close button"
|
2018-01-12 23:09:05 +01:00
|
|
|
#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"
|
|
|
|
|
2018-04-25 20:35:32 +02:00
|
|
|
#define LAST_MSG "Mark the last message you read (dotted line)"
|
|
|
|
|
2018-01-17 18:36:12 +01:00
|
|
|
// 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
|
2018-01-12 23:09:05 +01:00
|
|
|
|
|
|
|
namespace chatterino {
|
|
|
|
|
|
|
|
AppearancePage::AppearancePage()
|
2018-04-25 20:35:32 +02:00
|
|
|
: SettingsPage("Look", ":/images/theme.svg")
|
2018-01-12 23:09:05 +01:00
|
|
|
{
|
2018-04-27 22:11:19 +02:00
|
|
|
auto app = getApp();
|
2018-06-26 17:06:17 +02:00
|
|
|
LayoutCreator<AppearancePage> layoutCreator(this);
|
2018-04-25 20:35:32 +02:00
|
|
|
|
|
|
|
auto scroll = layoutCreator.emplace<QScrollArea>();
|
|
|
|
auto widget = scroll.emplaceScrollAreaWidget();
|
2018-06-26 17:06:17 +02:00
|
|
|
removeScrollAreaBackground(scroll.getElement(), widget.getElement());
|
2018-04-25 20:35:32 +02:00
|
|
|
|
|
|
|
auto layout = widget.setLayoutType<QVBoxLayout>();
|
2018-01-12 23:09:05 +01:00
|
|
|
|
|
|
|
auto application =
|
|
|
|
layout.emplace<QGroupBox>("Application").emplace<QVBoxLayout>().withoutMargin();
|
|
|
|
{
|
|
|
|
auto form = application.emplace<QFormLayout>();
|
|
|
|
|
2018-06-04 14:39:26 +02:00
|
|
|
auto *theme = this->createComboBox({THEME_ITEMS}, app->themes->themeName);
|
2018-06-04 16:10:54 +02:00
|
|
|
QObject::connect(theme, &QComboBox::currentTextChanged,
|
|
|
|
[](const QString &) { getApp()->windows->forceLayoutChannelViews(); });
|
|
|
|
|
|
|
|
form->addRow("Theme:", theme);
|
|
|
|
// form->addRow("Theme color:", this->createThemeColorChanger());
|
2018-06-11 15:04:54 +02:00
|
|
|
form->addRow("UI Scaling:", this->createUiScaleSlider());
|
2018-06-04 16:10:54 +02:00
|
|
|
form->addRow("Font:", this->createFontChanger());
|
|
|
|
|
|
|
|
form->addRow("Tabs:", this->createCheckBox(TAB_X, app->settings->showTabCloseButton));
|
|
|
|
#ifndef USEWINSDK
|
|
|
|
form->addRow("", this->createCheckBox(TAB_PREF, app->settings->hidePreferencesButton));
|
|
|
|
form->addRow("", this->createCheckBox(TAB_USER, app->settings->hideUserButton));
|
|
|
|
#endif
|
|
|
|
|
|
|
|
form->addRow("Scrolling:",
|
|
|
|
this->createCheckBox(SCROLL_SMOOTH, app->settings->enableSmoothScrolling));
|
|
|
|
form->addRow("", this->createCheckBox(SCROLL_NEWMSG,
|
|
|
|
app->settings->enableSmoothScrollingNewMessages));
|
2018-01-12 23:09:05 +01:00
|
|
|
}
|
|
|
|
|
2018-04-25 20:35:32 +02:00
|
|
|
auto messages = layout.emplace<QGroupBox>("Messages").emplace<QVBoxLayout>();
|
2018-01-12 23:09:05 +01:00
|
|
|
{
|
2018-04-27 22:11:19 +02:00
|
|
|
messages.append(this->createCheckBox("Show timestamp", app->settings->showTimestamps));
|
2018-04-25 20:35:32 +02:00
|
|
|
auto tbox = messages.emplace<QHBoxLayout>().withoutMargin();
|
2018-01-12 23:09:05 +01:00
|
|
|
{
|
2018-01-17 18:36:12 +01:00
|
|
|
tbox.emplace<QLabel>("timestamp format (a = am/pm):");
|
2018-04-27 22:11:19 +02:00
|
|
|
tbox.append(this->createComboBox({TIMESTAMP_FORMATS}, app->settings->timestampFormat));
|
2018-01-24 15:08:22 +01:00
|
|
|
tbox->addStretch(1);
|
2018-01-12 23:09:05 +01:00
|
|
|
}
|
2018-04-21 00:40:17 +02:00
|
|
|
|
2018-04-27 22:11:19 +02:00
|
|
|
messages.append(this->createCheckBox("Show badges", app->settings->showBadges));
|
2018-05-24 11:35:50 +02:00
|
|
|
|
2018-06-04 16:34:47 +02:00
|
|
|
{
|
|
|
|
auto *combo = new QComboBox(this);
|
|
|
|
combo->addItems({"Never", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12",
|
|
|
|
"13", "14", "15"});
|
2018-07-03 15:43:54 +02:00
|
|
|
const auto currentIndex = []() -> int {
|
|
|
|
auto val = getApp()->settings->collpseMessagesMinLines.getValue();
|
|
|
|
if (val > 0) {
|
|
|
|
--val;
|
|
|
|
}
|
|
|
|
return val;
|
|
|
|
}();
|
|
|
|
combo->setCurrentIndex(currentIndex);
|
2018-06-04 16:34:47 +02:00
|
|
|
|
|
|
|
QObject::connect(combo, &QComboBox::currentTextChanged, [](const QString &str) {
|
|
|
|
getApp()->settings->collpseMessagesMinLines = str.toInt();
|
|
|
|
});
|
|
|
|
|
|
|
|
auto hbox = messages.emplace<QHBoxLayout>().withoutMargin();
|
|
|
|
hbox.emplace<QLabel>("Collapse messages longer than");
|
|
|
|
hbox.append(combo);
|
|
|
|
hbox.emplace<QLabel>("lines");
|
|
|
|
}
|
|
|
|
|
2018-06-24 18:32:00 +02:00
|
|
|
messages.append(this->createCheckBox("Separate messages", app->settings->separateMessages));
|
2018-06-04 16:10:54 +02:00
|
|
|
messages.append(this->createCheckBox("Alternate message background color",
|
|
|
|
app->settings->alternateMessageBackground));
|
2018-04-27 22:11:19 +02:00
|
|
|
messages.append(this->createCheckBox("Show message length while typing",
|
|
|
|
app->settings->showMessageLength));
|
2018-04-25 20:35:32 +02:00
|
|
|
|
2018-04-27 22:11:19 +02:00
|
|
|
messages.append(this->createCheckBox(LAST_MSG, app->settings->showLastMessageIndicator));
|
2018-07-03 13:44:59 +02:00
|
|
|
{
|
|
|
|
auto *combo = new QComboBox(this);
|
2018-07-03 15:45:25 +02:00
|
|
|
combo->addItems({"Dotted", "Solid"});
|
|
|
|
|
|
|
|
const auto currentIndex = []() -> int {
|
|
|
|
switch (getApp()->settings->lastMessagePattern.getValue()) {
|
|
|
|
case Qt::SolidLine: {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
case Qt::VerPattern: {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}();
|
|
|
|
combo->setCurrentIndex(currentIndex);
|
2018-07-03 13:44:59 +02:00
|
|
|
|
|
|
|
QObject::connect(combo,
|
|
|
|
static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
|
|
|
|
[](int index) {
|
|
|
|
Qt::BrushStyle brush;
|
|
|
|
switch (index) {
|
|
|
|
case 1:
|
|
|
|
brush = Qt::SolidPattern;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
case 0:
|
|
|
|
brush = Qt::VerPattern;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
getApp()->settings->lastMessagePattern = brush;
|
|
|
|
});
|
|
|
|
|
|
|
|
auto hbox = messages.emplace<QHBoxLayout>().withoutMargin();
|
|
|
|
hbox.emplace<QLabel>("Last message indicator pattern");
|
|
|
|
hbox.append(combo);
|
|
|
|
}
|
2018-04-25 20:35:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
auto emotes = layout.emplace<QGroupBox>("Emotes").setLayoutType<QVBoxLayout>();
|
|
|
|
{
|
2018-06-05 00:14:20 +02:00
|
|
|
/*
|
2018-04-25 20:35:32 +02:00
|
|
|
emotes.append(
|
2018-04-27 22:11:19 +02:00
|
|
|
this->createCheckBox("Enable Twitch emotes", app->settings->enableTwitchEmotes));
|
|
|
|
emotes.append(this->createCheckBox("Enable BetterTTV emotes for Twitch",
|
|
|
|
app->settings->enableBttvEmotes));
|
2018-04-25 20:35:32 +02:00
|
|
|
emotes.append(this->createCheckBox("Enable FrankerFaceZ emotes for Twitch",
|
2018-04-27 22:11:19 +02:00
|
|
|
app->settings->enableFfzEmotes));
|
|
|
|
emotes.append(this->createCheckBox("Enable emojis", app->settings->enableEmojis));
|
2018-06-05 00:14:20 +02:00
|
|
|
*/
|
2018-04-27 22:11:19 +02:00
|
|
|
emotes.append(
|
|
|
|
this->createCheckBox("Enable animations", app->settings->enableGifAnimations));
|
2018-05-23 13:31:55 +02:00
|
|
|
|
|
|
|
auto scaleBox = emotes.emplace<QHBoxLayout>();
|
|
|
|
{
|
|
|
|
scaleBox.emplace<QLabel>("Emote scale:");
|
|
|
|
|
|
|
|
auto emoteScale = scaleBox.emplace<QSlider>(Qt::Horizontal);
|
|
|
|
emoteScale->setMinimum(5);
|
|
|
|
emoteScale->setMaximum(50);
|
|
|
|
|
|
|
|
auto scaleLabel = scaleBox.emplace<QLabel>("1.0");
|
|
|
|
scaleLabel->setFixedWidth(100);
|
2018-06-22 12:34:33 +02:00
|
|
|
QObject::connect(emoteScale.getElement(), &QSlider::valueChanged,
|
|
|
|
[scaleLabel](int value) mutable {
|
|
|
|
float f = (float)value / 10.f;
|
|
|
|
scaleLabel->setText(QString::number(f));
|
2018-05-23 13:31:55 +02:00
|
|
|
|
2018-06-22 12:34:33 +02:00
|
|
|
getApp()->settings->emoteScale.setValue(f);
|
|
|
|
});
|
2018-05-23 13:31:55 +02:00
|
|
|
|
|
|
|
emoteScale->setValue(std::max<int>(
|
|
|
|
5, std::min<int>(50, (int)(app->settings->emoteScale.getValue() * 10.f))));
|
|
|
|
|
|
|
|
scaleLabel->setText(QString::number(app->settings->emoteScale.getValue()));
|
|
|
|
}
|
2018-06-06 01:29:43 +02:00
|
|
|
|
|
|
|
{
|
|
|
|
auto *combo = new QComboBox(this);
|
|
|
|
combo->addItems({"EmojiOne 2", "EmojiOne 3", "Twitter", "Facebook", "Apple", "Google",
|
|
|
|
"Messenger"});
|
|
|
|
|
2018-06-06 11:42:41 +02:00
|
|
|
combo->setCurrentText(getApp()->settings->emojiSet);
|
|
|
|
|
2018-06-06 01:29:43 +02:00
|
|
|
QObject::connect(combo, &QComboBox::currentTextChanged, [](const QString &str) {
|
|
|
|
getApp()->settings->emojiSet = str; //
|
|
|
|
});
|
|
|
|
|
|
|
|
auto hbox = emotes.emplace<QHBoxLayout>().withoutMargin();
|
|
|
|
hbox.emplace<QLabel>("Emoji set");
|
|
|
|
hbox.append(combo);
|
|
|
|
}
|
2018-01-12 23:09:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
layout->addStretch(1);
|
2018-06-06 01:29:43 +02:00
|
|
|
}
|
2018-01-12 23:09:05 +01:00
|
|
|
|
|
|
|
QLayout *AppearancePage::createThemeColorChanger()
|
|
|
|
{
|
2018-04-27 22:11:19 +02:00
|
|
|
auto app = getApp();
|
2018-01-12 23:09:05 +01:00
|
|
|
QHBoxLayout *layout = new QHBoxLayout;
|
|
|
|
|
2018-04-27 22:11:19 +02:00
|
|
|
auto &themeHue = app->themes->themeHue;
|
2018-01-12 23:09:05 +01:00
|
|
|
|
|
|
|
// SLIDER
|
|
|
|
QSlider *slider = new QSlider(Qt::Horizontal);
|
|
|
|
layout->addWidget(slider);
|
2018-06-04 16:10:54 +02:00
|
|
|
slider->setValue(int(std::min(std::max(themeHue.getValue(), 0.0), 1.0) * 100));
|
2018-01-12 23:09:05 +01:00
|
|
|
|
|
|
|
// BUTTON
|
|
|
|
QPushButton *button = new QPushButton;
|
|
|
|
layout->addWidget(button);
|
|
|
|
button->setFlat(true);
|
|
|
|
button->setFixedWidth(64);
|
|
|
|
|
2018-04-27 22:11:19 +02:00
|
|
|
auto setButtonColor = [button, app](int value) mutable {
|
2018-01-23 13:34:26 +01:00
|
|
|
double newValue = value / 100.0;
|
2018-04-27 22:11:19 +02:00
|
|
|
app->themes->themeHue.setValue(newValue);
|
2018-01-12 23:09:05 +01:00
|
|
|
|
|
|
|
QPalette pal = button->palette();
|
|
|
|
QColor color;
|
|
|
|
color.setHsvF(newValue, 1.0, 1.0, 1.0);
|
|
|
|
pal.setColor(QPalette::Button, color);
|
|
|
|
button->setAutoFillBackground(true);
|
|
|
|
button->setPalette(pal);
|
|
|
|
button->update();
|
2018-02-06 00:10:30 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
// SIGNALS
|
|
|
|
QObject::connect(slider, &QSlider::valueChanged, this, setButtonColor);
|
2018-01-12 23:09:05 +01:00
|
|
|
|
2018-02-06 00:10:30 +01:00
|
|
|
setButtonColor(themeHue * 100);
|
2018-01-12 23:09:05 +01:00
|
|
|
|
|
|
|
return layout;
|
|
|
|
}
|
|
|
|
|
|
|
|
QLayout *AppearancePage::createFontChanger()
|
|
|
|
{
|
2018-04-28 15:20:18 +02:00
|
|
|
auto app = getApp();
|
2018-01-12 23:09:05 +01:00
|
|
|
|
2018-04-28 15:20:18 +02:00
|
|
|
QHBoxLayout *layout = new QHBoxLayout;
|
2018-01-12 23:09:05 +01:00
|
|
|
|
|
|
|
// LABEL
|
|
|
|
QLabel *label = new QLabel();
|
|
|
|
layout->addWidget(label);
|
|
|
|
|
2018-04-28 15:20:18 +02:00
|
|
|
auto updateFontFamilyLabel = [=](auto) {
|
2018-05-23 04:22:17 +02:00
|
|
|
label->setText(QString::fromStdString(app->fonts->chatFontFamily.getValue()) + ", " +
|
|
|
|
QString::number(app->fonts->chatFontSize) + "pt");
|
2018-01-12 23:09:05 +01:00
|
|
|
};
|
|
|
|
|
2018-05-23 04:22:17 +02:00
|
|
|
app->fonts->chatFontFamily.connectSimple(updateFontFamilyLabel, this->managedConnections);
|
|
|
|
app->fonts->chatFontSize.connectSimple(updateFontFamilyLabel, this->managedConnections);
|
2018-01-12 23:09:05 +01:00
|
|
|
|
|
|
|
// BUTTON
|
|
|
|
QPushButton *button = new QPushButton("Select");
|
|
|
|
layout->addWidget(button);
|
|
|
|
button->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Policy::Fixed);
|
|
|
|
|
2018-04-28 15:20:18 +02:00
|
|
|
QObject::connect(button, &QPushButton::clicked, [=]() {
|
2018-06-28 19:51:07 +02:00
|
|
|
QFontDialog dialog(app->fonts->getFont(Fonts::ChatMedium, 1.));
|
2018-01-12 23:09:05 +01:00
|
|
|
|
2018-06-25 11:25:39 +02:00
|
|
|
dialog.setWindowFlag(Qt::WindowStaysOnTopHint);
|
|
|
|
|
2018-04-28 15:20:18 +02:00
|
|
|
dialog.connect(&dialog, &QFontDialog::fontSelected, [=](const QFont &font) {
|
2018-05-23 04:22:17 +02:00
|
|
|
app->fonts->chatFontFamily = font.family().toStdString();
|
|
|
|
app->fonts->chatFontSize = font.pointSize();
|
2018-01-12 23:09:05 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
dialog.show();
|
|
|
|
dialog.exec();
|
|
|
|
});
|
|
|
|
|
|
|
|
return layout;
|
|
|
|
}
|
2018-04-03 02:55:32 +02:00
|
|
|
|
2018-06-11 15:04:54 +02:00
|
|
|
QLayout *AppearancePage::createUiScaleSlider()
|
|
|
|
{
|
|
|
|
auto layout = new QHBoxLayout();
|
|
|
|
auto slider = new QSlider(Qt::Horizontal);
|
|
|
|
auto label = new QLabel();
|
|
|
|
layout->addWidget(slider);
|
|
|
|
layout->addWidget(label);
|
|
|
|
|
2018-06-28 19:38:57 +02:00
|
|
|
slider->setMinimum(WindowManager::uiScaleMin);
|
|
|
|
slider->setMaximum(WindowManager::uiScaleMax);
|
2018-06-11 15:04:54 +02:00
|
|
|
slider->setValue(
|
2018-06-28 19:38:57 +02:00
|
|
|
WindowManager::clampUiScale(getApp()->settings->uiScale.getValue()));
|
2018-06-11 15:04:54 +02:00
|
|
|
|
|
|
|
label->setMinimumWidth(100);
|
|
|
|
|
|
|
|
QObject::connect(slider, &QSlider::valueChanged,
|
|
|
|
[](auto value) { getApp()->settings->uiScale.setValue(value); });
|
|
|
|
|
|
|
|
getApp()->settings->uiScale.connect(
|
|
|
|
[label](auto, auto) {
|
2018-06-28 19:38:57 +02:00
|
|
|
label->setText(QString::number(WindowManager::getUiScaleValue()));
|
2018-06-11 15:04:54 +02:00
|
|
|
},
|
|
|
|
this->connections_);
|
|
|
|
|
|
|
|
return layout;
|
|
|
|
}
|
|
|
|
|
2018-01-12 23:09:05 +01:00
|
|
|
} // namespace chatterino
|