2018-07-03 17:39:20 +02:00
|
|
|
#include "LookPage.hpp"
|
2018-01-12 23:09:05 +01:00
|
|
|
|
2018-06-26 14:09:39 +02:00
|
|
|
#include "Application.hpp"
|
2018-08-11 22:23:06 +02:00
|
|
|
#include "messages/Image.hpp"
|
2018-08-07 01:35:24 +02:00
|
|
|
#include "messages/MessageBuilder.hpp"
|
2018-08-11 22:23:06 +02:00
|
|
|
#include "singletons/Resources.hpp"
|
|
|
|
#include "singletons/Theme.hpp"
|
2018-06-26 14:09:39 +02:00
|
|
|
#include "singletons/WindowManager.hpp"
|
|
|
|
#include "util/LayoutCreator.hpp"
|
|
|
|
#include "util/RemoveScrollAreaBackground.hpp"
|
2018-08-11 22:23:06 +02:00
|
|
|
#include "widgets/helper/ChannelView.hpp"
|
2018-07-03 16:55:02 +02:00
|
|
|
#include "widgets/helper/Line.hpp"
|
2018-04-27 22:11:19 +02:00
|
|
|
|
2018-10-20 13:25:24 +02:00
|
|
|
#include <QColorDialog>
|
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>
|
|
|
|
|
2018-10-25 21:52:12 +02:00
|
|
|
#define THEME_ITEMS "White", "Light", "Dark", "Black", "Custom"
|
2018-01-12 23:09:05 +01:00
|
|
|
|
2018-07-05 18:17:12 +02:00
|
|
|
#define TAB_X "Show tab close button"
|
2018-10-13 14:22:49 +02:00
|
|
|
#define TAB_PREF "Hide preferences button (ctrl+p to show)"
|
|
|
|
#define TAB_USER "Hide user button"
|
2018-01-12 23:09:05 +01:00
|
|
|
|
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
|
|
|
|
2018-07-05 18:17:12 +02:00
|
|
|
#ifdef USEWINSDK
|
2018-08-15 22:46:20 +02:00
|
|
|
# define WINDOW_TOPMOST "Window always on top"
|
2018-07-05 18:17:12 +02:00
|
|
|
#else
|
2018-08-15 22:46:20 +02:00
|
|
|
# define WINDOW_TOPMOST "Window always on top (requires restart)"
|
2018-07-05 18:17:12 +02:00
|
|
|
#endif
|
|
|
|
#define INPUT_EMPTY "Show input box when empty"
|
|
|
|
#define LAST_MSG "Mark the last message you read"
|
|
|
|
|
2018-01-12 23:09:05 +01:00
|
|
|
namespace chatterino {
|
|
|
|
|
2018-07-03 17:40:15 +02:00
|
|
|
LookPage::LookPage()
|
2018-08-09 06:22:55 +02:00
|
|
|
: SettingsPage("Look", ":/settings/theme.svg")
|
2018-07-05 18:17:12 +02:00
|
|
|
{
|
|
|
|
this->initializeUi();
|
|
|
|
}
|
|
|
|
|
|
|
|
void LookPage::initializeUi()
|
2018-01-12 23:09:05 +01:00
|
|
|
{
|
2018-07-03 17:40:15 +02:00
|
|
|
LayoutCreator<LookPage> layoutCreator(this);
|
2018-04-25 20:35:32 +02:00
|
|
|
|
2018-07-05 17:38:24 +02:00
|
|
|
auto layout = layoutCreator.emplace<QVBoxLayout>().withoutMargin();
|
2018-07-03 16:55:02 +02:00
|
|
|
|
|
|
|
// settings
|
2018-07-05 17:38:24 +02:00
|
|
|
auto tabs = layout.emplace<QTabWidget>();
|
2018-04-25 20:35:32 +02:00
|
|
|
|
2018-07-05 17:38:24 +02:00
|
|
|
this->addInterfaceTab(tabs.appendTab(new QVBoxLayout, "Interface"));
|
|
|
|
this->addMessageTab(tabs.appendTab(new QVBoxLayout, "Messages"));
|
|
|
|
this->addEmoteTab(tabs.appendTab(new QVBoxLayout, "Emotes"));
|
2018-08-06 16:42:23 +02:00
|
|
|
this->addSplitHeaderTab(tabs.appendTab(new QVBoxLayout, "Split header"));
|
2018-09-16 17:42:30 +02:00
|
|
|
this->addBadgesTab(tabs.appendTab(new QVBoxLayout, "Badges"));
|
2018-01-12 23:09:05 +01:00
|
|
|
|
2018-07-05 17:38:24 +02:00
|
|
|
layout->addStretch(1);
|
2018-07-03 16:55:02 +02:00
|
|
|
|
|
|
|
// preview
|
2018-07-05 17:38:24 +02:00
|
|
|
layout.emplace<Line>(false);
|
2018-07-03 16:55:02 +02:00
|
|
|
|
2018-07-05 17:38:24 +02:00
|
|
|
auto channelView = layout.emplace<ChannelView>();
|
2018-07-03 16:55:02 +02:00
|
|
|
auto channel = this->createPreviewChannel();
|
|
|
|
channelView->setChannel(channel);
|
2018-07-12 18:58:56 +02:00
|
|
|
channelView->setScaleIndependantHeight(74);
|
2018-07-03 16:55:02 +02:00
|
|
|
}
|
|
|
|
|
2018-07-05 17:38:24 +02:00
|
|
|
void LookPage::addInterfaceTab(LayoutCreator<QVBoxLayout> layout)
|
2018-07-03 16:55:02 +02:00
|
|
|
{
|
|
|
|
// theme
|
2018-07-05 17:38:24 +02:00
|
|
|
{
|
2018-08-06 21:17:03 +02:00
|
|
|
auto *theme =
|
|
|
|
this->createComboBox({THEME_ITEMS}, getApp()->themes->themeName);
|
2018-10-25 21:52:12 +02:00
|
|
|
QDoubleSpinBox *w = new QDoubleSpinBox;
|
|
|
|
|
2018-07-05 17:38:24 +02:00
|
|
|
QObject::connect(theme, &QComboBox::currentTextChanged,
|
2018-10-25 21:52:12 +02:00
|
|
|
[w](const QString &themeName) {
|
2018-10-29 21:46:43 +01:00
|
|
|
if (themeName == "Custom")
|
|
|
|
{
|
2018-10-25 21:52:12 +02:00
|
|
|
w->show();
|
2018-10-29 21:46:43 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-10-25 21:52:12 +02:00
|
|
|
w->hide();
|
|
|
|
}
|
2018-08-06 21:17:03 +02:00
|
|
|
getApp()->windows->forceLayoutChannelViews();
|
|
|
|
});
|
2018-07-05 17:38:24 +02:00
|
|
|
|
|
|
|
auto box = layout.emplace<QHBoxLayout>().withoutMargin();
|
|
|
|
box.emplace<QLabel>("Theme: ");
|
|
|
|
box.append(theme);
|
2018-10-25 21:52:12 +02:00
|
|
|
|
|
|
|
{
|
|
|
|
w->setButtonSymbols(QDoubleSpinBox::NoButtons);
|
2018-10-29 21:46:43 +01:00
|
|
|
if (getApp()->themes->themeName.getValue() != "Custom")
|
|
|
|
{
|
2018-10-25 21:52:12 +02:00
|
|
|
w->hide();
|
2018-10-29 21:46:43 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-10-25 21:52:12 +02:00
|
|
|
w->show();
|
|
|
|
}
|
|
|
|
w->setRange(-1.0, 1.0);
|
|
|
|
w->setSingleStep(0.05);
|
|
|
|
w->setValue(getSettings()->customThemeMultiplier.getValue());
|
|
|
|
|
|
|
|
QObject::connect(
|
|
|
|
w, QOverload<double>::of(&QDoubleSpinBox::valueChanged),
|
|
|
|
[](double value) {
|
|
|
|
getSettings()->customThemeMultiplier.setValue(float(value));
|
|
|
|
getApp()->themes->update();
|
|
|
|
getApp()->windows->forceLayoutChannelViews();
|
|
|
|
});
|
|
|
|
box.append(w);
|
|
|
|
}
|
|
|
|
|
2018-07-05 17:38:24 +02:00
|
|
|
box->addStretch(1);
|
|
|
|
}
|
2018-06-04 16:10:54 +02:00
|
|
|
|
2018-07-03 16:55:02 +02:00
|
|
|
// ui scale
|
2018-07-05 17:38:24 +02:00
|
|
|
{
|
|
|
|
auto box = layout.emplace<QHBoxLayout>().withoutMargin();
|
2018-07-05 18:17:12 +02:00
|
|
|
box.emplace<QLabel>("Window scale: ");
|
2018-07-05 17:38:24 +02:00
|
|
|
box.append(this->createUiScaleSlider());
|
|
|
|
}
|
2018-07-03 16:55:02 +02:00
|
|
|
|
2018-08-06 21:17:03 +02:00
|
|
|
layout.append(
|
|
|
|
this->createCheckBox(WINDOW_TOPMOST, getSettings()->windowTopMost));
|
2018-07-05 18:17:12 +02:00
|
|
|
|
|
|
|
// --
|
|
|
|
layout.emplace<Line>(false);
|
|
|
|
|
2018-07-03 16:55:02 +02:00
|
|
|
// tab x
|
2018-08-06 21:17:03 +02:00
|
|
|
layout.append(
|
|
|
|
this->createCheckBox(TAB_X, getSettings()->showTabCloseButton));
|
2018-07-03 16:55:02 +02:00
|
|
|
|
|
|
|
// show buttons
|
2018-06-04 16:10:54 +02:00
|
|
|
#ifndef USEWINSDK
|
2018-08-06 21:17:03 +02:00
|
|
|
layout.append(
|
|
|
|
this->createCheckBox(TAB_PREF, getSettings()->hidePreferencesButton));
|
|
|
|
layout.append(
|
|
|
|
this->createCheckBox(TAB_USER, getSettings()->hideUserButton));
|
2018-06-04 16:10:54 +02:00
|
|
|
#endif
|
|
|
|
|
2018-07-05 18:17:12 +02:00
|
|
|
// empty input
|
2018-07-05 17:38:24 +02:00
|
|
|
layout.append(
|
2018-08-06 21:17:03 +02:00
|
|
|
this->createCheckBox(INPUT_EMPTY, getSettings()->showEmptyInput));
|
|
|
|
layout.append(this->createCheckBox("Show message length while typing",
|
|
|
|
getSettings()->showMessageLength));
|
2018-07-05 17:38:24 +02:00
|
|
|
layout->addStretch(1);
|
2018-07-03 16:55:02 +02:00
|
|
|
}
|
|
|
|
|
2018-07-05 17:38:24 +02:00
|
|
|
void LookPage::addMessageTab(LayoutCreator<QVBoxLayout> layout)
|
2018-07-03 16:55:02 +02:00
|
|
|
{
|
2018-07-05 17:38:24 +02:00
|
|
|
// font
|
|
|
|
layout.append(this->createFontChanger());
|
|
|
|
|
|
|
|
// --
|
|
|
|
layout.emplace<Line>(false);
|
2018-07-03 16:55:02 +02:00
|
|
|
|
|
|
|
// timestamps
|
2018-07-05 18:17:12 +02:00
|
|
|
{
|
|
|
|
auto box = layout.emplace<QHBoxLayout>().withoutMargin();
|
2018-08-06 21:17:03 +02:00
|
|
|
box.append(this->createCheckBox("Show timestamps",
|
|
|
|
getSettings()->showTimestamps));
|
|
|
|
box.append(this->createComboBox({TIMESTAMP_FORMATS},
|
|
|
|
getSettings()->timestampFormat));
|
2018-07-05 18:17:12 +02:00
|
|
|
box->addStretch(1);
|
|
|
|
}
|
2018-01-12 23:09:05 +01:00
|
|
|
|
2018-07-05 17:38:24 +02:00
|
|
|
// --
|
|
|
|
layout.emplace<Line>(false);
|
|
|
|
|
2018-10-20 19:15:15 +02:00
|
|
|
// separate
|
|
|
|
layout.append(this->createCheckBox("Lines between messages",
|
2018-08-06 21:17:03 +02:00
|
|
|
getSettings()->separateMessages));
|
2018-07-05 17:38:24 +02:00
|
|
|
|
|
|
|
// alternate
|
2018-10-31 19:45:51 +01:00
|
|
|
layout.append(this->createCheckBox("Alternate background",
|
|
|
|
getSettings()->alternateMessages));
|
2018-07-05 17:38:24 +02:00
|
|
|
|
2018-10-29 21:46:43 +01:00
|
|
|
layout.append(
|
|
|
|
this->createCheckBox("Compact emotes", getSettings()->compactEmotes));
|
|
|
|
|
2018-10-25 21:47:52 +02:00
|
|
|
layout.append(this->createCheckBox("Grey out historic messages",
|
|
|
|
getSettings()->greyOutHistoricMessages));
|
2018-07-05 17:38:24 +02:00
|
|
|
// --
|
|
|
|
layout.emplace<Line>(false);
|
|
|
|
|
2018-10-20 19:15:15 +02:00
|
|
|
// bold-slider
|
|
|
|
{
|
|
|
|
auto box = layout.emplace<QHBoxLayout>().withoutMargin();
|
|
|
|
box.emplace<QLabel>("Username boldness: ");
|
|
|
|
box.append(this->createBoldScaleSlider());
|
|
|
|
}
|
|
|
|
|
|
|
|
// bold usernames
|
|
|
|
layout.append(this->createCheckBox("Bold mentions (@username)",
|
2018-10-31 19:45:51 +01:00
|
|
|
getSettings()->boldUsernames));
|
2018-10-20 19:15:15 +02:00
|
|
|
|
|
|
|
// --
|
|
|
|
layout.emplace<Line>(false);
|
|
|
|
|
2018-07-05 17:38:24 +02:00
|
|
|
// lowercase links
|
2018-08-06 21:17:03 +02:00
|
|
|
layout.append(this->createCheckBox("Lowercase domains",
|
2018-10-31 19:45:51 +01:00
|
|
|
getSettings()->lowercaseDomains));
|
2018-07-03 16:55:02 +02:00
|
|
|
|
|
|
|
// collapsing
|
2018-01-12 23:09:05 +01:00
|
|
|
{
|
2018-07-03 16:55:02 +02:00
|
|
|
auto *combo = new QComboBox(this);
|
2018-08-06 21:17:03 +02:00
|
|
|
combo->addItems({"Never", "2", "3", "4", "5", "6", "7", "8", "9", "10",
|
|
|
|
"11", "12", "13", "14", "15"});
|
2018-07-03 16:55:02 +02:00
|
|
|
|
2018-07-03 17:21:41 +02:00
|
|
|
const auto currentIndex = []() -> int {
|
|
|
|
auto val = getSettings()->collpseMessagesMinLines.getValue();
|
2018-10-21 13:43:02 +02:00
|
|
|
if (val > 0)
|
|
|
|
{
|
2018-07-03 17:21:41 +02:00
|
|
|
--val;
|
|
|
|
}
|
|
|
|
return val;
|
|
|
|
}();
|
|
|
|
combo->setCurrentIndex(currentIndex);
|
|
|
|
|
2018-08-06 21:17:03 +02:00
|
|
|
QObject::connect(
|
|
|
|
combo, &QComboBox::currentTextChanged, [](const QString &str) {
|
|
|
|
getSettings()->collpseMessagesMinLines = str.toInt();
|
|
|
|
});
|
2018-07-03 16:55:02 +02:00
|
|
|
|
2018-07-05 17:38:24 +02:00
|
|
|
auto hbox = layout.emplace<QHBoxLayout>().withoutMargin();
|
2018-07-03 16:55:02 +02:00
|
|
|
hbox.emplace<QLabel>("Collapse messages longer than");
|
|
|
|
hbox.append(combo);
|
|
|
|
hbox.emplace<QLabel>("lines");
|
2018-01-12 23:09:05 +01:00
|
|
|
}
|
|
|
|
|
2018-07-05 18:17:12 +02:00
|
|
|
// last read message
|
|
|
|
this->addLastReadMessageIndicatorPatternSelector(layout);
|
|
|
|
|
2018-07-05 17:38:24 +02:00
|
|
|
// --
|
|
|
|
layout->addStretch(1);
|
2018-07-03 16:55:02 +02:00
|
|
|
}
|
|
|
|
|
2018-07-05 17:38:24 +02:00
|
|
|
void LookPage::addEmoteTab(LayoutCreator<QVBoxLayout> layout)
|
2018-07-03 16:55:02 +02:00
|
|
|
{
|
2018-08-06 21:17:03 +02:00
|
|
|
layout.append(
|
2018-10-31 19:45:51 +01:00
|
|
|
this->createCheckBox("Animations", getSettings()->animateEmotes));
|
2018-08-15 23:48:16 +02:00
|
|
|
layout.append(
|
|
|
|
this->createCheckBox("Animations only when chatterino has focus",
|
2018-10-31 19:45:51 +01:00
|
|
|
getSettings()->animationsWhenFocused));
|
2018-07-03 16:55:02 +02:00
|
|
|
|
2018-07-05 17:38:24 +02:00
|
|
|
auto scaleBox = layout.emplace<QHBoxLayout>().withoutMargin();
|
2018-01-12 23:09:05 +01:00
|
|
|
{
|
2018-07-03 16:55:02 +02:00
|
|
|
scaleBox.emplace<QLabel>("Size:");
|
|
|
|
|
|
|
|
auto emoteScale = scaleBox.emplace<QSlider>(Qt::Horizontal);
|
|
|
|
emoteScale->setMinimum(5);
|
|
|
|
emoteScale->setMaximum(50);
|
|
|
|
|
|
|
|
auto scaleLabel = scaleBox.emplace<QLabel>("1.0");
|
|
|
|
scaleLabel->setFixedWidth(100);
|
|
|
|
QObject::connect(emoteScale.getElement(), &QSlider::valueChanged,
|
|
|
|
[scaleLabel](int value) mutable {
|
|
|
|
float f = float(value) / 10.f;
|
|
|
|
scaleLabel->setText(QString::number(f));
|
|
|
|
|
|
|
|
getSettings()->emoteScale.setValue(f);
|
|
|
|
});
|
|
|
|
|
2018-08-06 21:17:03 +02:00
|
|
|
emoteScale->setValue(std::max<int>(
|
|
|
|
5, std::min<int>(
|
|
|
|
50, int(getSettings()->emoteScale.getValue() * 10.f))));
|
2018-07-03 16:55:02 +02:00
|
|
|
|
2018-08-06 21:17:03 +02:00
|
|
|
scaleLabel->setText(
|
|
|
|
QString::number(getSettings()->emoteScale.getValue()));
|
2018-04-25 20:35:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
{
|
2018-07-03 16:55:02 +02:00
|
|
|
auto *combo = new QComboBox(this);
|
2018-08-06 21:17:03 +02:00
|
|
|
combo->addItems({"EmojiOne 2", "EmojiOne 3", "Twitter", "Facebook",
|
|
|
|
"Apple", "Google", "Messenger"});
|
2018-07-03 16:55:02 +02:00
|
|
|
|
|
|
|
combo->setCurrentText(getSettings()->emojiSet);
|
|
|
|
|
2018-08-06 21:17:03 +02:00
|
|
|
QObject::connect(combo, &QComboBox::currentTextChanged,
|
|
|
|
[](const QString &str) {
|
|
|
|
getSettings()->emojiSet = str; //
|
|
|
|
});
|
2018-07-03 16:55:02 +02:00
|
|
|
|
2018-07-05 17:38:24 +02:00
|
|
|
auto hbox = layout.emplace<QHBoxLayout>().withoutMargin();
|
2018-07-03 16:55:02 +02:00
|
|
|
hbox.emplace<QLabel>("Emoji set:");
|
|
|
|
hbox.append(combo);
|
|
|
|
}
|
2018-07-05 17:38:24 +02:00
|
|
|
|
|
|
|
layout->addStretch(1);
|
2018-07-03 16:55:02 +02:00
|
|
|
}
|
|
|
|
|
2018-08-06 16:42:23 +02:00
|
|
|
void LookPage::addSplitHeaderTab(LayoutCreator<QVBoxLayout> layout)
|
|
|
|
{
|
2018-09-04 21:39:54 +02:00
|
|
|
layout.append(
|
2018-10-31 19:45:51 +01:00
|
|
|
this->createCheckBox("Show uptime", getSettings()->headerUptime));
|
2018-08-06 21:17:03 +02:00
|
|
|
layout.append(this->createCheckBox("Show viewer count",
|
2018-10-31 19:45:51 +01:00
|
|
|
getSettings()->headerViewerCount));
|
|
|
|
layout.append(this->createCheckBox("Show game", getSettings()->headerGame));
|
|
|
|
layout.append(
|
|
|
|
this->createCheckBox("Show title", getSettings()->headerStreamTitle));
|
2018-08-06 16:42:23 +02:00
|
|
|
|
|
|
|
layout->addStretch(1);
|
|
|
|
}
|
|
|
|
|
2018-09-16 17:42:30 +02:00
|
|
|
void LookPage::addBadgesTab(LayoutCreator<QVBoxLayout> layout)
|
|
|
|
{
|
|
|
|
// layout.append(
|
|
|
|
// this->createCheckBox(("Show all badges"), getSettings()->showBadges));
|
|
|
|
auto fastSelection = layout.emplace<QHBoxLayout>();
|
|
|
|
{
|
|
|
|
auto addAll = fastSelection.emplace<QPushButton>("Enable all");
|
|
|
|
QObject::connect(addAll.getElement(), &QPushButton::clicked, this, [] {
|
|
|
|
getSettings()->showBadgesGlobalAuthority = true;
|
|
|
|
getSettings()->showBadgesChannelAuthority = true;
|
|
|
|
getSettings()->showBadgesSubscription = true;
|
|
|
|
getSettings()->showBadgesVanity = true;
|
|
|
|
getSettings()->showBadgesChatterino = true;
|
|
|
|
});
|
|
|
|
auto removeAll = fastSelection.emplace<QPushButton>("Disable all");
|
|
|
|
QObject::connect(removeAll.getElement(), &QPushButton::clicked, this,
|
|
|
|
[] {
|
|
|
|
getSettings()->showBadgesGlobalAuthority = false;
|
|
|
|
getSettings()->showBadgesChannelAuthority = false;
|
|
|
|
getSettings()->showBadgesSubscription = false;
|
|
|
|
getSettings()->showBadgesVanity = false;
|
|
|
|
getSettings()->showBadgesChatterino = false;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
layout.emplace<Line>(false);
|
|
|
|
layout.append(this->createCheckBox(
|
2018-10-04 18:55:02 +02:00
|
|
|
("Show authority badges (staff, admin, turbo, etc)"),
|
2018-09-16 17:42:30 +02:00
|
|
|
getSettings()->showBadgesGlobalAuthority));
|
|
|
|
layout.append(
|
|
|
|
this->createCheckBox(("Show channel badges (broadcaster, moderator)"),
|
|
|
|
getSettings()->showBadgesChannelAuthority));
|
|
|
|
layout.append(this->createCheckBox(("Show subscriber badges "),
|
|
|
|
getSettings()->showBadgesSubscription));
|
|
|
|
layout.append(
|
|
|
|
this->createCheckBox(("Show vanity badges (prime, bits, subgifter)"),
|
|
|
|
getSettings()->showBadgesVanity));
|
|
|
|
layout.append(this->createCheckBox(("Show chatterino badges"),
|
|
|
|
getSettings()->showBadgesChatterino));
|
|
|
|
layout->addStretch(1);
|
|
|
|
}
|
|
|
|
|
2018-08-06 21:17:03 +02:00
|
|
|
void LookPage::addLastReadMessageIndicatorPatternSelector(
|
|
|
|
LayoutCreator<QVBoxLayout> layout)
|
2018-07-05 18:17:12 +02:00
|
|
|
{
|
|
|
|
// combo
|
|
|
|
auto *combo = new QComboBox(this);
|
|
|
|
combo->addItems({"Dotted line", "Solid line"});
|
|
|
|
|
|
|
|
const auto currentIndex = []() -> int {
|
2018-10-21 13:43:02 +02:00
|
|
|
switch (getSettings()->lastMessagePattern.getValue())
|
|
|
|
{
|
2018-07-05 18:17:12 +02:00
|
|
|
case Qt::SolidLine:
|
|
|
|
return 1;
|
|
|
|
case Qt::VerPattern:
|
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}();
|
|
|
|
combo->setCurrentIndex(currentIndex);
|
|
|
|
|
2018-08-06 21:17:03 +02:00
|
|
|
QObject::connect(
|
|
|
|
combo,
|
|
|
|
static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
|
|
|
|
[](int index) {
|
|
|
|
getSettings()->lastMessagePattern = [&] {
|
2018-10-21 13:43:02 +02:00
|
|
|
switch (index)
|
|
|
|
{
|
2018-08-06 21:17:03 +02:00
|
|
|
case 1:
|
|
|
|
return Qt::SolidPattern;
|
|
|
|
case 0:
|
|
|
|
default:
|
|
|
|
return Qt::VerPattern;
|
|
|
|
}
|
|
|
|
}();
|
|
|
|
});
|
2018-07-05 18:17:12 +02:00
|
|
|
|
2018-10-20 13:25:24 +02:00
|
|
|
// color picker
|
|
|
|
|
|
|
|
QLabel *colorPreview = new QLabel();
|
|
|
|
|
|
|
|
auto updatePreviewColor = [colorPreview](QColor newColor) {
|
|
|
|
QPixmap pixmap(16, 16);
|
|
|
|
pixmap.fill(QColor(0, 0, 0, 255));
|
|
|
|
|
|
|
|
QPainter painter(&pixmap);
|
|
|
|
QBrush brush(newColor);
|
|
|
|
painter.fillRect(1, 1, pixmap.width() - 2, pixmap.height() - 2, brush);
|
|
|
|
colorPreview->setPixmap(pixmap);
|
|
|
|
};
|
|
|
|
|
|
|
|
auto getCurrentColor = []() {
|
|
|
|
return getSettings()->lastMessageColor != ""
|
|
|
|
? QColor(getSettings()->lastMessageColor.getValue())
|
|
|
|
: getApp()
|
|
|
|
->themes->tabs.selected.backgrounds.regular.color();
|
|
|
|
};
|
|
|
|
|
|
|
|
updatePreviewColor(getCurrentColor());
|
|
|
|
|
|
|
|
QPushButton *button = new QPushButton("Select Color");
|
|
|
|
button->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Policy::Fixed);
|
|
|
|
|
|
|
|
QObject::connect(
|
|
|
|
button, &QPushButton::clicked, [updatePreviewColor, getCurrentColor]() {
|
|
|
|
QColor newColor = QColorDialog::getColor(getCurrentColor());
|
2018-10-21 13:43:02 +02:00
|
|
|
if (newColor.isValid())
|
|
|
|
{
|
2018-10-20 13:25:24 +02:00
|
|
|
updatePreviewColor(newColor);
|
|
|
|
getSettings()->lastMessageColor = newColor.name();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
QPushButton *resetButton = new QPushButton("Reset Color");
|
|
|
|
resetButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Policy::Fixed);
|
|
|
|
|
|
|
|
QObject::connect(
|
|
|
|
resetButton, &QPushButton::clicked, [updatePreviewColor]() {
|
|
|
|
QColor defaultColor =
|
|
|
|
getApp()->themes->tabs.selected.backgrounds.regular.color();
|
|
|
|
updatePreviewColor(defaultColor);
|
|
|
|
getSettings()->lastMessageColor = "";
|
|
|
|
});
|
|
|
|
|
2018-07-05 18:17:12 +02:00
|
|
|
// layout
|
|
|
|
auto hbox = layout.emplace<QHBoxLayout>().withoutMargin();
|
2018-08-06 21:17:03 +02:00
|
|
|
hbox.append(this->createCheckBox(LAST_MSG,
|
|
|
|
getSettings()->showLastMessageIndicator));
|
2018-07-05 18:17:12 +02:00
|
|
|
hbox.append(combo);
|
2018-10-20 13:25:24 +02:00
|
|
|
hbox.append(colorPreview);
|
|
|
|
hbox.append(button);
|
|
|
|
hbox.append(resetButton);
|
2018-07-05 18:17:12 +02:00
|
|
|
hbox->addStretch(1);
|
|
|
|
}
|
|
|
|
|
2018-07-03 17:40:15 +02:00
|
|
|
ChannelPtr LookPage::createPreviewChannel()
|
2018-07-03 16:55:02 +02:00
|
|
|
{
|
2018-07-06 17:30:12 +02:00
|
|
|
auto channel = ChannelPtr(new Channel("preview", Channel::Type::Misc));
|
2018-07-03 16:55:02 +02:00
|
|
|
|
2018-08-07 01:35:24 +02:00
|
|
|
// clang-format off
|
2018-07-03 16:55:02 +02:00
|
|
|
{
|
2018-08-07 01:35:24 +02:00
|
|
|
MessageBuilder builder;
|
|
|
|
builder.emplace<TimestampElement>(QTime(8, 13, 42));
|
2018-08-10 18:56:17 +02:00
|
|
|
builder.emplace<ImageElement>(Image::fromPixmap(getApp()->resources->twitch.moderator), MessageElementFlag::BadgeChannelAuthority);
|
|
|
|
builder.emplace<ImageElement>(Image::fromPixmap(getApp()->resources->twitch.subscriber, 0.25), MessageElementFlag::BadgeSubscription);
|
2018-08-07 07:55:31 +02:00
|
|
|
builder.emplace<TextElement>("username1:", MessageElementFlag::Username, QColor("#0094FF"), FontStyle::ChatMediumBold);
|
|
|
|
builder.emplace<TextElement>("This is a preview message", MessageElementFlag::Text);
|
2018-08-10 18:56:17 +02:00
|
|
|
builder.emplace<ImageElement>(Image::fromPixmap(getApp()->resources->pajaDank, 0.25), MessageElementFlag::AlwaysShow);
|
2018-08-07 07:55:31 +02:00
|
|
|
builder.emplace<TextElement>("@fourtf", MessageElementFlag::BoldUsername, MessageColor::Text, FontStyle::ChatMediumBold);
|
|
|
|
builder.emplace<TextElement>("@fourtf", MessageElementFlag::NonBoldUsername);
|
2018-08-07 01:35:24 +02:00
|
|
|
channel->addMessage(builder.release());
|
2018-07-03 16:55:02 +02:00
|
|
|
}
|
2018-04-25 20:35:32 +02:00
|
|
|
{
|
2018-08-07 01:35:24 +02:00
|
|
|
MessageBuilder message;
|
|
|
|
message.emplace<TimestampElement>(QTime(8, 15, 21));
|
2018-08-10 18:56:17 +02:00
|
|
|
message.emplace<ImageElement>(Image::fromPixmap(getApp()->resources->twitch.broadcaster), MessageElementFlag::BadgeChannelAuthority);
|
2018-08-07 07:55:31 +02:00
|
|
|
message.emplace<TextElement>("username2:", MessageElementFlag::Username, QColor("#FF6A00"), FontStyle::ChatMediumBold);
|
|
|
|
message.emplace<TextElement>("This is another one", MessageElementFlag::Text);
|
|
|
|
// message.emplace<ImageElement>(Image::fromNonOwningPixmap(&getApp()->resources->ppHop), MessageElementFlag::BttvEmote);
|
|
|
|
message.emplace<TextElement>("www.fourtf.com", MessageElementFlag::LowercaseLink, MessageColor::Link)->setLink(Link(Link::Url, "https://www.fourtf.com"));
|
|
|
|
message.emplace<TextElement>("wWw.FoUrTf.CoM", MessageElementFlag::OriginalLink, MessageColor::Link)->setLink(Link(Link::Url, "https://www.fourtf.com"));
|
2018-08-07 01:35:24 +02:00
|
|
|
channel->addMessage(message.release());
|
2018-01-12 23:09:05 +01:00
|
|
|
}
|
2018-08-07 01:35:24 +02:00
|
|
|
// clang-format on
|
2018-01-12 23:09:05 +01:00
|
|
|
|
2018-07-03 16:55:02 +02:00
|
|
|
return channel;
|
2018-06-06 01:29:43 +02:00
|
|
|
}
|
2018-01-12 23:09:05 +01:00
|
|
|
|
2018-07-03 17:40:15 +02:00
|
|
|
QLayout *LookPage::createThemeColorChanger()
|
2018-01-12 23:09:05 +01:00
|
|
|
{
|
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-08-06 21:17:03 +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;
|
|
|
|
}
|
|
|
|
|
2018-07-03 17:40:15 +02:00
|
|
|
QLayout *LookPage::createFontChanger()
|
2018-01-12 23:09:05 +01:00
|
|
|
{
|
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-07-05 17:38:24 +02:00
|
|
|
layout->setMargin(0);
|
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-08-06 21:17:03 +02:00
|
|
|
label->setText(
|
|
|
|
"Font (" +
|
|
|
|
QString::fromStdString(app->fonts->chatFontFamily.getValue()) +
|
|
|
|
", " + QString::number(app->fonts->chatFontSize) + "pt)");
|
2018-01-12 23:09:05 +01:00
|
|
|
};
|
|
|
|
|
2018-08-06 21:17:03 +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-08-11 22:23:06 +02:00
|
|
|
QFontDialog dialog(app->fonts->getFont(FontStyle::ChatMedium, 1.));
|
2018-01-12 23:09:05 +01:00
|
|
|
|
2018-06-25 11:25:39 +02:00
|
|
|
dialog.setWindowFlag(Qt::WindowStaysOnTopHint);
|
|
|
|
|
2018-08-06 21:17:03 +02:00
|
|
|
dialog.connect(
|
|
|
|
&dialog, &QFontDialog::fontSelected, [=](const QFont &font) {
|
|
|
|
app->fonts->chatFontFamily = font.family().toStdString();
|
|
|
|
app->fonts->chatFontSize = font.pointSize();
|
|
|
|
});
|
2018-01-12 23:09:05 +01:00
|
|
|
|
|
|
|
dialog.show();
|
|
|
|
dialog.exec();
|
|
|
|
});
|
|
|
|
|
2018-07-05 17:38:24 +02:00
|
|
|
layout->addStretch(1);
|
|
|
|
|
2018-01-12 23:09:05 +01:00
|
|
|
return layout;
|
|
|
|
}
|
2018-04-03 02:55:32 +02:00
|
|
|
|
2018-07-03 17:40:15 +02:00
|
|
|
QLayout *LookPage::createUiScaleSlider()
|
2018-06-11 15:04:54 +02:00
|
|
|
{
|
|
|
|
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-08-06 21:17:03 +02:00
|
|
|
slider->setValue(
|
|
|
|
WindowManager::clampUiScale(getSettings()->uiScale.getValue()));
|
2018-06-11 15:04:54 +02:00
|
|
|
|
|
|
|
label->setMinimumWidth(100);
|
|
|
|
|
2018-08-06 21:17:03 +02:00
|
|
|
QObject::connect(slider, &QSlider::valueChanged, [](auto value) {
|
|
|
|
getSettings()->uiScale.setValue(value);
|
|
|
|
});
|
2018-06-11 15:04:54 +02:00
|
|
|
|
2018-07-03 16:55:02 +02:00
|
|
|
getSettings()->uiScale.connect(
|
2018-08-06 21:17:03 +02:00
|
|
|
[label](auto, auto) {
|
|
|
|
label->setText(QString::number(WindowManager::getUiScaleValue()));
|
|
|
|
},
|
2018-06-11 15:04:54 +02:00
|
|
|
this->connections_);
|
|
|
|
|
|
|
|
return layout;
|
|
|
|
}
|
|
|
|
|
2018-08-06 16:41:27 +02:00
|
|
|
QLayout *LookPage::createBoldScaleSlider()
|
|
|
|
{
|
|
|
|
auto layout = new QHBoxLayout();
|
|
|
|
auto slider = new QSlider(Qt::Horizontal);
|
|
|
|
auto label = new QLabel();
|
|
|
|
|
|
|
|
layout->addWidget(slider);
|
|
|
|
layout->addWidget(label);
|
|
|
|
|
|
|
|
slider->setMinimum(50);
|
|
|
|
slider->setMaximum(100);
|
|
|
|
slider->setValue(getSettings()->boldScale.getValue());
|
|
|
|
|
|
|
|
label->setMinimumWidth(100);
|
|
|
|
|
2018-08-06 21:17:03 +02:00
|
|
|
QObject::connect(slider, &QSlider::valueChanged, [](auto value) {
|
|
|
|
getSettings()->boldScale.setValue(value);
|
|
|
|
});
|
2018-08-06 16:41:27 +02:00
|
|
|
// show value
|
|
|
|
// getSettings()->boldScale.connect(
|
|
|
|
// [label](auto, auto) {
|
|
|
|
// label->setText(QString::number(getSettings()->boldScale.getValue()));
|
|
|
|
// },
|
|
|
|
// this->connections_);
|
|
|
|
|
2018-10-20 19:15:15 +02:00
|
|
|
// QPushButton *button = new QPushButton("Reset");
|
|
|
|
// layout->addWidget(button);
|
|
|
|
// button->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Policy::Fixed);
|
2018-08-06 16:41:27 +02:00
|
|
|
|
2018-10-20 19:15:15 +02:00
|
|
|
// QObject::connect(button, &QPushButton::clicked, [=]() {
|
|
|
|
// getSettings()->boldScale.setValue(57);
|
|
|
|
// slider->setValue(57);
|
|
|
|
//});
|
2018-08-06 16:41:27 +02:00
|
|
|
|
|
|
|
return layout;
|
|
|
|
}
|
|
|
|
|
2018-01-12 23:09:05 +01:00
|
|
|
} // namespace chatterino
|