changed to 80 max column

This commit is contained in:
fourtf
2018-08-06 21:17:03 +02:00
parent defa7e41fa
commit f71ff08e68
203 changed files with 3792 additions and 2405 deletions
+13 -8
View File
@@ -102,17 +102,20 @@ Fonts::FontData Fonts::createFontData(Type type, float scale)
{ChatSmall, {0.6f, false, QFont::Normal}},
{ChatMediumSmall, {0.8f, false, QFont::Normal}},
{ChatMedium, {1, false, QFont::Normal}},
{ChatMediumBold, {1, false, QFont::Weight(getApp()->settings->boldScale.getValue())}},
{ChatMediumBold,
{1, false,
QFont::Weight(getApp()->settings->boldScale.getValue())}},
{ChatMediumItalic, {1, true, QFont::Normal}},
{ChatLarge, {1.2f, false, QFont::Normal}},
{ChatVeryLarge, {1.4f, false, QFont::Normal}},
};
sizeScale[ChatMediumBold] = {1, false,
QFont::Weight(getApp()->settings->boldScale.getValue())};
sizeScale[ChatMediumBold] = {
1, false, QFont::Weight(getApp()->settings->boldScale.getValue())};
auto data = sizeScale[type];
return FontData(QFont(QString::fromStdString(this->chatFontFamily.getValue()),
int(this->chatFontSize.getValue() * data.scale * scale), data.weight,
data.italic));
return FontData(
QFont(QString::fromStdString(this->chatFontFamily.getValue()),
int(this->chatFontSize.getValue() * data.scale * scale),
data.weight, data.italic));
}
// normal Ui font (use pt size)
@@ -125,8 +128,10 @@ Fonts::FontData Fonts::createFontData(Type type, float scale)
static std::unordered_map<Type, UiFontData> defaultSize{
{Tiny, {8, "Monospace", false, QFont::Normal}},
{UiMedium, {int(9 * multiplier), DEFAULT_FONT_FAMILY, false, QFont::Normal}},
{UiTabs, {int(9 * multiplier), DEFAULT_FONT_FAMILY, false, QFont::Normal}},
{UiMedium,
{int(9 * multiplier), DEFAULT_FONT_FAMILY, false, QFont::Normal}},
{UiTabs,
{int(9 * multiplier), DEFAULT_FONT_FAMILY, false, QFont::Normal}},
};
UiFontData &data = defaultSize[type];
+2 -2
View File
@@ -26,8 +26,8 @@ void Logging::addMessage(const QString &channelName, MessagePtr message)
if (it == this->loggingChannels_.end()) {
auto channel = new LoggingChannel(channelName);
channel->addMessage(message);
this->loggingChannels_.emplace(channelName,
std::unique_ptr<LoggingChannel>(std::move(channel)));
this->loggingChannels_.emplace(
channelName, std::unique_ptr<LoggingChannel>(std::move(channel)));
} else {
it->second->addMessage(message);
}
+28 -18
View File
@@ -32,7 +32,8 @@ namespace ipc = boost::interprocess;
namespace chatterino {
void registerNmManifest(Paths &paths, const QString &manifestFilename,
const QString &registryKeyName, const QJsonDocument &document);
const QString &registryKeyName,
const QJsonDocument &document);
void registerNmHost(Paths &paths)
{
@@ -53,14 +54,15 @@ void registerNmHost(Paths &paths)
QJsonDocument document;
auto obj = getBaseDocument();
QJsonArray allowed_origins_arr = {"chrome-extension://" EXTENSION_ID "/"};
QJsonArray allowed_origins_arr = {"chrome-extension://" EXTENSION_ID
"/"};
obj.insert("allowed_origins", allowed_origins_arr);
document.setObject(obj);
registerNmManifest(
paths, "/native-messaging-manifest-chrome.json",
"HKCU\\Software\\Google\\Chrome\\NativeMessagingHosts\\com.chatterino.chatterino",
document);
registerNmManifest(paths, "/native-messaging-manifest-chrome.json",
"HKCU\\Software\\Google\\Chrome\\NativeMessagingHost"
"s\\com.chatterino.chatterino",
document);
}
// firefox
@@ -72,14 +74,16 @@ void registerNmHost(Paths &paths)
obj.insert("allowed_extensions", allowed_extensions);
document.setObject(obj);
registerNmManifest(
paths, "/native-messaging-manifest-firefox.json",
"HKCU\\Software\\Mozilla\\NativeMessagingHosts\\com.chatterino.chatterino", document);
registerNmManifest(paths, "/native-messaging-manifest-firefox.json",
"HKCU\\Software\\Mozilla\\NativeMessagingHosts\\com."
"chatterino.chatterino",
document);
}
}
void registerNmManifest(Paths &paths, const QString &manifestFilename,
const QString &registryKeyName, const QJsonDocument &document)
const QString &registryKeyName,
const QJsonDocument &document)
{
(void)registryKeyName;
@@ -99,7 +103,8 @@ void registerNmManifest(Paths &paths, const QString &manifestFilename,
std::string &getNmQueueName(Paths &paths)
{
static std::string name = "chatterino_gui" + paths.applicationFilePathHash.toStdString();
static std::string name =
"chatterino_gui" + paths.applicationFilePathHash.toStdString();
return name;
}
@@ -137,18 +142,20 @@ void NativeMessagingServer::ReceiverThread::run()
{
ipc::message_queue::remove("chatterino_gui");
ipc::message_queue messageQueue(ipc::open_or_create, "chatterino_gui", 100, MESSAGE_SIZE);
ipc::message_queue messageQueue(ipc::open_or_create, "chatterino_gui", 100,
MESSAGE_SIZE);
while (true) {
try {
std::unique_ptr<char> buf(static_cast<char *>(malloc(MESSAGE_SIZE)));
std::unique_ptr<char> buf(
static_cast<char *>(malloc(MESSAGE_SIZE)));
ipc::message_queue::size_type retSize;
unsigned int priority;
messageQueue.receive(buf.get(), MESSAGE_SIZE, retSize, priority);
QJsonDocument document =
QJsonDocument::fromJson(QByteArray::fromRawData(buf.get(), retSize));
QJsonDocument document = QJsonDocument::fromJson(
QByteArray::fromRawData(buf.get(), retSize));
this->handleMessage(document.object());
} catch (ipc::interprocess_exception &ex) {
@@ -157,7 +164,8 @@ void NativeMessagingServer::ReceiverThread::run()
}
}
void NativeMessagingServer::ReceiverThread::handleMessage(const QJsonObject &root)
void NativeMessagingServer::ReceiverThread::handleMessage(
const QJsonObject &root)
{
auto app = getApp();
@@ -199,9 +207,11 @@ void NativeMessagingServer::ReceiverThread::handleMessage(const QJsonObject &roo
if (attach) {
#ifdef USEWINSDK
// if (args.height != -1) {
auto *window = AttachedWindow::get(::GetForegroundWindow(), args);
auto *window =
AttachedWindow::get(::GetForegroundWindow(), args);
if (!name.isEmpty()) {
window->setChannel(app->twitch.server->getOrAddChannel(name));
window->setChannel(
app->twitch.server->getOrAddChannel(name));
}
// }
// window->show();
+19 -12
View File
@@ -36,8 +36,9 @@ bool Paths::isPortable()
void Paths::initAppFilePathHash()
{
this->applicationFilePathHash =
QCryptographicHash::hash(QCoreApplication::applicationFilePath().toUtf8(),
QCryptographicHash::Sha224)
QCryptographicHash::hash(
QCoreApplication::applicationFilePath().toUtf8(),
QCryptographicHash::Sha224)
.toBase64()
.mid(0, 32)
.replace("+", "-")
@@ -46,15 +47,16 @@ void Paths::initAppFilePathHash()
void Paths::initCheckPortable()
{
this->portable_ =
QFileInfo::exists(combinePath(QCoreApplication::applicationDirPath(), "portable"));
this->portable_ = QFileInfo::exists(
combinePath(QCoreApplication::applicationDirPath(), "portable"));
}
void Paths::initAppDataDirectory()
{
assert(this->portable_.is_initialized());
// Root path = %APPDATA%/Chatterino or the folder that the executable resides in
// Root path = %APPDATA%/Chatterino or the folder that the executable
// resides in
this->rootAppDataDirectory = [&]() -> QString {
// portable
@@ -63,13 +65,15 @@ void Paths::initAppDataDirectory()
}
// permanent installation
QString path = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
QString path =
QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
if (path.isEmpty()) {
throw std::runtime_error("Error finding writable location for settings");
throw std::runtime_error(
"Error finding writable location for settings");
}
// create directory Chatterino2 instead of chatterino on windows because the ladder one is takes by
// chatterino 1 already
// create directory Chatterino2 instead of chatterino on windows because the
// ladder one is takes by chatterino 1 already
#ifdef Q_OS_WIN
path.replace("chatterino", "Chatterino");
@@ -84,12 +88,15 @@ void Paths::initSubDirectories()
// required the app data directory to be set first
assert(!this->rootAppDataDirectory.isEmpty());
// create settings subdirectories and validate that they are created properly
// create settings subdirectories and validate that they are created
// properly
auto makePath = [&](const std::string &name) -> QString {
auto path = combinePath(this->rootAppDataDirectory, QString::fromStdString(name));
auto path = combinePath(this->rootAppDataDirectory,
QString::fromStdString(name));
if (!QDir().mkpath(path)) {
throw std::runtime_error("Error creating appdata path %appdata%/chatterino/" + name);
throw std::runtime_error(
"Error creating appdata path %appdata%/chatterino/" + name);
}
return path;
+2 -2
View File
@@ -12,8 +12,8 @@ public:
Paths();
// Root directory for the configuration files. %APPDATA%/chatterino or ExecutablePath for
// portable mode
// Root directory for the configuration files. %APPDATA%/chatterino or
// ExecutablePath for portable mode
QString rootAppDataDirectory;
// Directory for settings files. Same as <appDataDirectory>/Settings
+2 -1
View File
@@ -12,7 +12,8 @@ std::vector<std::weak_ptr<pajlada::Settings::ISettingData>> _settings;
Settings *Settings::instance = nullptr;
void _actuallyRegisterSetting(std::weak_ptr<pajlada::Settings::ISettingData> setting)
void _actuallyRegisterSetting(
std::weak_ptr<pajlada::Settings::ISettingData> setting)
{
_settings.push_back(setting);
}
+50 -28
View File
@@ -12,7 +12,8 @@
namespace chatterino {
void _actuallyRegisterSetting(std::weak_ptr<pajlada::Settings::ISettingData> setting);
void _actuallyRegisterSetting(
std::weak_ptr<pajlada::Settings::ISettingData> setting);
class Settings
{
@@ -25,48 +26,62 @@ public:
/// Appearance
BoolSetting showTimestamps = {"/appearance/messages/showTimestamps", true};
QStringSetting timestampFormat = {"/appearance/messages/timestampFormat", "h:mm"};
QStringSetting timestampFormat = {"/appearance/messages/timestampFormat",
"h:mm"};
BoolSetting showBadges = {"/appearance/messages/showBadges", true};
BoolSetting showLastMessageIndicator = {"/appearance/messages/showLastMessageIndicator", false};
IntSetting lastMessagePattern = {"/appearance/messages/lastMessagePattern", Qt::VerPattern};
BoolSetting showLastMessageIndicator = {
"/appearance/messages/showLastMessageIndicator", false};
IntSetting lastMessagePattern = {"/appearance/messages/lastMessagePattern",
Qt::VerPattern};
BoolSetting showEmptyInput = {"/appearance/showEmptyInputBox", true};
BoolSetting showMessageLength = {"/appearance/messages/showMessageLength", false};
BoolSetting separateMessages = {"/appearance/messages/separateMessages", false};
// BoolSetting collapseLongMessages = {"/appearance/messages/collapseLongMessages", false};
IntSetting collpseMessagesMinLines = {"/appearance/messages/collapseMessagesMinLines", 0};
BoolSetting alternateMessageBackground = {"/appearance/messages/alternateMessageBackground",
false};
BoolSetting showMessageLength = {"/appearance/messages/showMessageLength",
false};
BoolSetting separateMessages = {"/appearance/messages/separateMessages",
false};
// BoolSetting collapseLongMessages =
// {"/appearance/messages/collapseLongMessages", false};
IntSetting collpseMessagesMinLines = {
"/appearance/messages/collapseMessagesMinLines", 0};
BoolSetting alternateMessageBackground = {
"/appearance/messages/alternateMessageBackground", false};
IntSetting uiScale = {"/appearance/uiScale", 0};
IntSetting boldScale = {"/appearance/boldScale", 57};
BoolSetting windowTopMost = {"/appearance/windowAlwaysOnTop", false};
BoolSetting showTabCloseButton = {"/appearance/showTabCloseButton", true};
BoolSetting hidePreferencesButton = {"/appearance/hidePreferencesButton", false};
BoolSetting hidePreferencesButton = {"/appearance/hidePreferencesButton",
false};
BoolSetting hideUserButton = {"/appearance/hideUserButton", false};
BoolSetting enableSmoothScrolling = {"/appearance/smoothScrolling", true};
BoolSetting enableSmoothScrollingNewMessages = {"/appearance/smoothScrollingNewMessages",
false};
BoolSetting enableUsernameBold = {"/appearence/messages/boldUsernames", false};
BoolSetting enableSmoothScrollingNewMessages = {
"/appearance/smoothScrollingNewMessages", false};
BoolSetting enableUsernameBold = {"/appearence/messages/boldUsernames",
false};
// BoolSetting customizable splitheader
BoolSetting showViewerCount = {"/appearance/splitheader/showViewerCount", false};
BoolSetting showViewerCount = {"/appearance/splitheader/showViewerCount",
false};
BoolSetting showTitle = {"/appearance/splitheader/showTitle", false};
BoolSetting showGame = {"/appearance/splitheader/showGame", false};
BoolSetting showUptime = {"/appearance/splitheader/showUptime", false};
// BoolSetting useCustomWindowFrame = {"/appearance/useCustomWindowFrame", false};
// BoolSetting useCustomWindowFrame = {"/appearance/useCustomWindowFrame",
// false};
/// Behaviour
BoolSetting allowDuplicateMessages = {"/behaviour/allowDuplicateMessages", true};
BoolSetting allowDuplicateMessages = {"/behaviour/allowDuplicateMessages",
true};
BoolSetting mentionUsersWithAt = {"/behaviour/mentionUsersWithAt", false};
BoolSetting showJoins = {"/behaviour/showJoins", false};
BoolSetting showParts = {"/behaviour/showParts", false};
FloatSetting mouseScrollMultiplier = {"/behaviour/mouseScrollMultiplier", 1.0};
// BoolSetting twitchSeperateWriteConnection = {"/behaviour/twitchSeperateWriteConnection",
// false};
FloatSetting mouseScrollMultiplier = {"/behaviour/mouseScrollMultiplier",
1.0};
// BoolSetting twitchSeperateWriteConnection =
// {"/behaviour/twitchSeperateWriteConnection", false};
// Auto-completion
BoolSetting onlyFetchChattersForSmallerStreamers = {
"/behaviour/autocompletion/onlyFetchChattersForSmallerStreamers", true};
IntSetting smallStreamerLimit = {"/behaviour/autocompletion/smallStreamerLimit", 1000};
IntSetting smallStreamerLimit = {
"/behaviour/autocompletion/smallStreamerLimit", 1000};
BoolSetting pauseChatHover = {"/behaviour/pauseChatHover", false};
@@ -74,7 +89,8 @@ public:
BoolSetting allowCommandsAtEnd = {"/commands/allowCommandsAtEnd", false};
/// Emotes
BoolSetting scaleEmotesByLineHeight = {"/emotes/scaleEmotesByLineHeight", false};
BoolSetting scaleEmotesByLineHeight = {"/emotes/scaleEmotesByLineHeight",
false};
BoolSetting enableTwitchEmotes = {"/emotes/enableTwitchEmotes", true};
BoolSetting enableBttvEmotes = {"/emotes/enableBTTVEmotes", true};
BoolSetting enableFfzEmotes = {"/emotes/enableFFZEmotes", true};
@@ -95,16 +111,19 @@ public:
BoolSetting enableLowercaseLink = {"/links/linkLowercase", true};
/// Ingored Users
BoolSetting enableTwitchIgnoredUsers = {"/ignore/enableTwitchIgnoredUsers", true};
BoolSetting enableTwitchIgnoredUsers = {"/ignore/enableTwitchIgnoredUsers",
true};
/// Moderation
QStringSetting timeoutAction = {"/moderation/timeoutAction", "Disable"};
/// Highlighting
// BoolSetting enableHighlights = {"/highlighting/enabled", true};
BoolSetting enableHighlightsSelf = {"/highlighting/nameIsHighlightKeyword", true};
BoolSetting enableHighlightsSelf = {"/highlighting/nameIsHighlightKeyword",
true};
BoolSetting enableHighlightSound = {"/highlighting/enableSound", true};
BoolSetting enableHighlightTaskbar = {"/highlighting/enableTaskbarFlashing", true};
BoolSetting enableHighlightTaskbar = {"/highlighting/enableTaskbarFlashing",
true};
BoolSetting customHighlightSound = {"/highlighting/useCustomSound", false};
/// Logging
@@ -115,15 +134,18 @@ public:
QStringSetting pathHighlightSound = {"/highlighting/highlightSoundPath",
"qrc:/sounds/ping2.wav"};
BoolSetting highlightAlwaysPlaySound = {"/highlighting/alwaysPlaySound", false};
BoolSetting highlightAlwaysPlaySound = {"/highlighting/alwaysPlaySound",
false};
BoolSetting inlineWhispers = {"/whispers/enableInlineWhispers", true};
/// External tools
// Streamlink
BoolSetting streamlinkUseCustomPath = {"/external/streamlink/useCustomPath", false};
BoolSetting streamlinkUseCustomPath = {"/external/streamlink/useCustomPath",
false};
QStringSetting streamlinkPath = {"/external/streamlink/customPath", ""};
QStringSetting preferredQuality = {"/external/streamlink/quality", "Choose"};
QStringSetting preferredQuality = {"/external/streamlink/quality",
"Choose"};
QStringSetting streamlinkOpts = {"/external/streamlink/options", ""};
/// Misc
+66 -45
View File
@@ -39,7 +39,8 @@ Theme::Theme()
void Theme::update()
{
this->actuallyUpdate(this->themeHue, detail::getMultiplierByTheme(this->themeName.getValue()));
this->actuallyUpdate(this->themeHue, detail::getMultiplierByTheme(
this->themeName.getValue()));
}
// hue: theme color (0 - 1)
@@ -88,32 +89,40 @@ void Theme::actuallyUpdate(double hue, double multiplier)
/// TABS
if (lightWin) {
this->tabs.regular = {QColor("#444"),
{QColor("#fff"), QColor("#eee"), QColor("#fff")},
{QColor("#fff"), QColor("#fff"), QColor("#fff")}};
this->tabs.newMessage = {QColor("#222"),
{QColor("#fff"), QColor("#eee"), QColor("#fff")},
{QColor("#bbb"), QColor("#bbb"), QColor("#bbb")}};
this->tabs.highlighted = {fg,
{QColor("#fff"), QColor("#eee"), QColor("#fff")},
{highlighted, highlighted, highlighted}};
this->tabs.selected = {QColor("#000"),
{QColor("#b4d7ff"), QColor("#b4d7ff"), QColor("#b4d7ff")},
{QColor("#00aeef"), QColor("#00aeef"), QColor("#00aeef")}};
this->tabs.regular = {
QColor("#444"),
{QColor("#fff"), QColor("#eee"), QColor("#fff")},
{QColor("#fff"), QColor("#fff"), QColor("#fff")}};
this->tabs.newMessage = {
QColor("#222"),
{QColor("#fff"), QColor("#eee"), QColor("#fff")},
{QColor("#bbb"), QColor("#bbb"), QColor("#bbb")}};
this->tabs.highlighted = {
fg,
{QColor("#fff"), QColor("#eee"), QColor("#fff")},
{highlighted, highlighted, highlighted}};
this->tabs.selected = {
QColor("#000"),
{QColor("#b4d7ff"), QColor("#b4d7ff"), QColor("#b4d7ff")},
{QColor("#00aeef"), QColor("#00aeef"), QColor("#00aeef")}};
} else {
this->tabs.regular = {QColor("#aaa"),
{QColor("#252525"), QColor("#252525"), QColor("#252525")},
{QColor("#444"), QColor("#444"), QColor("#444")}};
this->tabs.newMessage = {fg,
{QColor("#252525"), QColor("#252525"), QColor("#252525")},
{QColor("#888"), QColor("#888"), QColor("#888")}};
this->tabs.highlighted = {fg,
{QColor("#252525"), QColor("#252525"), QColor("#252525")},
{highlighted, highlighted, highlighted}};
this->tabs.regular = {
QColor("#aaa"),
{QColor("#252525"), QColor("#252525"), QColor("#252525")},
{QColor("#444"), QColor("#444"), QColor("#444")}};
this->tabs.newMessage = {
fg,
{QColor("#252525"), QColor("#252525"), QColor("#252525")},
{QColor("#888"), QColor("#888"), QColor("#888")}};
this->tabs.highlighted = {
fg,
{QColor("#252525"), QColor("#252525"), QColor("#252525")},
{highlighted, highlighted, highlighted}};
this->tabs.selected = {QColor("#fff"),
{QColor("#555555"), QColor("#555555"), QColor("#555555")},
{QColor("#00aeef"), QColor("#00aeef"), QColor("#00aeef")}};
this->tabs.selected = {
QColor("#fff"),
{QColor("#555555"), QColor("#555555"), QColor("#555555")},
{QColor("#00aeef"), QColor("#00aeef"), QColor("#00aeef")}};
}
this->splits.input.focusedLine = highlighted;
@@ -126,16 +135,19 @@ void Theme::actuallyUpdate(double hue, double multiplier)
// fg,
// {QBrush(blendColors(themeColor, "#ccc", 0.9), Qt::FDiagPattern),
// QBrush(blendColors(themeColor, "#ccc", 0.9), Qt::FDiagPattern),
// QBrush(blendColors(themeColorNoSat, "#ccc", 0.9), Qt::FDiagPattern)}};
// QBrush(blendColors(themeColorNoSat, "#ccc", 0.9),
// Qt::FDiagPattern)}};
// this->tabs.newMessage = {
// fg,
// {QBrush(blendColors(themeColor, "#666", 0.7), Qt::FDiagPattern),
// QBrush(blendColors(themeColor, "#666", 0.5), Qt::FDiagPattern),
// {QBrush(blendColors(themeColor, "#666", 0.7),
// Qt::FDiagPattern),
// QBrush(blendColors(themeColor, "#666", 0.5),
// Qt::FDiagPattern),
// QBrush(blendColors(themeColorNoSat, "#666", 0.7),
// Qt::FDiagPattern)}};
// this->tabs.highlighted = {fg, {QColor("#777"), QColor("#777"),
// QColor("#666")}};
// this->tabs.highlighted = {fg, {QColor("#777"),
// QColor("#777"), QColor("#666")}};
this->tabs.bottomLine = this->tabs.selected.backgrounds.regular.color();
}
@@ -143,7 +155,8 @@ void Theme::actuallyUpdate(double hue, double multiplier)
// Split
bool flat = isLight_;
this->splits.messageSeperator = isLight_ ? QColor(127, 127, 127) : QColor(60, 60, 60);
this->splits.messageSeperator =
isLight_ ? QColor(127, 127, 127) : QColor(60, 60, 60);
this->splits.background = getColor(0, sat, 1);
this->splits.dropPreview = QColor(0, 148, 255, 0x30);
this->splits.dropPreviewBorder = QColor(0, 148, 255, 0xff);
@@ -165,20 +178,23 @@ void Theme::actuallyUpdate(double hue, double multiplier)
this->splits.header.background = getColor(0, sat, flat ? 1 : 0.9);
this->splits.header.border = getColor(0, sat, flat ? 1 : 0.85);
this->splits.header.text = this->messages.textColors.regular;
this->splits.header.focusedText = isLight_ ? QColor("#198CFF") : QColor("#84C1FF");
this->splits.header.focusedText =
isLight_ ? QColor("#198CFF") : QColor("#84C1FF");
this->splits.input.background = getColor(0, sat, flat ? 0.95 : 0.95);
this->splits.input.border = getColor(0, sat, flat ? 1 : 1);
this->splits.input.text = this->messages.textColors.regular;
this->splits.input.styleSheet =
"background:" + this->splits.input.background.name() + ";" +
"border:" + this->tabs.selected.backgrounds.regular.color().name() + ";" +
"color:" + this->messages.textColors.regular.name() + ";" + //
"border:" + this->tabs.selected.backgrounds.regular.color().name() +
";" + "color:" + this->messages.textColors.regular.name() + ";" + //
"selection-background-color:" +
(isLight_ ? "#68B1FF" : this->tabs.selected.backgrounds.regular.color().name());
(isLight_ ? "#68B1FF"
: this->tabs.selected.backgrounds.regular.color().name());
// Message
this->messages.textColors.link = isLight_ ? QColor(66, 134, 244) : QColor(66, 134, 244);
this->messages.textColors.link =
isLight_ ? QColor(66, 134, 244) : QColor(66, 134, 244);
this->messages.textColors.system = QColor(140, 127, 127);
this->messages.backgrounds.regular = splits.background;
@@ -212,12 +228,14 @@ void Theme::actuallyUpdate(double hue, double multiplier)
this->tooltip.text = QColor(255, 255, 255);
// Selection
this->messages.selection = isLightTheme() ? QColor(0, 0, 0, 64) : QColor(255, 255, 255, 64);
this->messages.selection =
isLightTheme() ? QColor(0, 0, 0, 64) : QColor(255, 255, 255, 64);
this->updated.invoke();
}
QColor Theme::blendColors(const QColor &color1, const QColor &color2, qreal ratio)
QColor Theme::blendColors(const QColor &color1, const QColor &color2,
qreal ratio)
{
int r = int(color1.red() * (1 - ratio) + color2.red() * ratio);
int g = int(color1.green() * (1 - ratio) + color2.green() * ratio);
@@ -233,21 +251,24 @@ void Theme::normalizeColor(QColor &color)
color.setHslF(color.hueF(), color.saturationF(), 0.5);
}
if (color.lightnessF() > 0.4 && color.hueF() > 0.1 && color.hueF() < 0.33333) {
color.setHslF(
color.hueF(), color.saturationF(),
color.lightnessF() - sin((color.hueF() - 0.1) / (0.3333 - 0.1) * 3.14159) *
color.saturationF() * 0.4);
if (color.lightnessF() > 0.4 && color.hueF() > 0.1 &&
color.hueF() < 0.33333) {
color.setHslF(color.hueF(), color.saturationF(),
color.lightnessF() - sin((color.hueF() - 0.1) /
(0.3333 - 0.1) * 3.14159) *
color.saturationF() * 0.4);
}
} else {
if (color.lightnessF() < 0.5) {
color.setHslF(color.hueF(), color.saturationF(), 0.5);
}
if (color.lightnessF() < 0.6 && color.hueF() > 0.54444 && color.hueF() < 0.83333) {
if (color.lightnessF() < 0.6 && color.hueF() > 0.54444 &&
color.hueF() < 0.83333) {
color.setHslF(
color.hueF(), color.saturationF(),
color.lightnessF() + sin((color.hueF() - 0.54444) / (0.8333 - 0.54444) * 3.14159) *
color.lightnessF() + sin((color.hueF() - 0.54444) /
(0.8333 - 0.54444) * 3.14159) *
color.saturationF() * 0.4);
}
}
+2 -2
View File
@@ -135,8 +135,8 @@ public:
private:
void actuallyUpdate(double hue, double multiplier);
QColor blendColors(const QColor &color1, const QColor &color2, qreal ratio);
void fillLookupTableValues(double (&array)[360], double from, double to, double fromValue,
double toValue);
void fillLookupTableValues(double (&array)[360], double from, double to,
double fromValue, double toValue);
double middleLookupTable_[360] = {};
double minLookupTable_[360] = {};
+20 -14
View File
@@ -44,10 +44,11 @@ void Updates::installUpdates()
}
#ifdef Q_OS_WIN
QMessageBox *box = new QMessageBox(QMessageBox::Information, "Chatterino Update",
"Chatterino is downloading the update "
"in the background and will run the "
"updater once it is finished.");
QMessageBox *box =
new QMessageBox(QMessageBox::Information, "Chatterino Update",
"Chatterino is downloading the update "
"in the background and will run the "
"updater once it is finished.");
box->setAttribute(Qt::WA_DeleteOnClose);
box->show();
@@ -57,8 +58,9 @@ void Updates::installUpdates()
this->setStatus_(DownloadFailed);
postToThread([] {
QMessageBox *box = new QMessageBox(QMessageBox::Information, "Chatterino Update",
"Failed while trying to download the update.");
QMessageBox *box =
new QMessageBox(QMessageBox::Information, "Chatterino Update",
"Failed while trying to download the update.");
box->setAttribute(Qt::WA_DeleteOnClose);
box->show();
box->raise();
@@ -80,7 +82,8 @@ void Updates::installUpdates()
}
QProcess::startDetached(
combinePath(QCoreApplication::applicationDirPath(), "updater.1/ChatterinoUpdater.exe"),
combinePath(QCoreApplication::applicationDirPath(),
"updater.1/ChatterinoUpdater.exe"),
{filename, "restart"});
QApplication::exit(0);
@@ -94,7 +97,9 @@ void Updates::installUpdates()
void Updates::checkForUpdates()
{
#ifdef Q_OS_WIN
QString url = "https://notitia.chatterino.com/version/chatterino/" CHATTERINO_OS "/stable";
QString url =
"https://notitia.chatterino.com/version/chatterino/" CHATTERINO_OS
"/stable";
NetworkRequest req(url);
req.setTimeout(30000);
@@ -110,7 +115,8 @@ void Updates::checkForUpdates()
postToThread([] {
QMessageBox *box = new QMessageBox(
QMessageBox::Information, "Chatterino Update",
"Error while searching for updates.\n\nEither the service is down "
"Error while searching for updates.\n\nEither the service "
"is down "
"temporarily or everything is broken.");
box->setAttribute(Qt::WA_DeleteOnClose);
box->show();
@@ -125,11 +131,11 @@ void Updates::checkForUpdates()
if (this->currentVersion_ != this->onlineVersion_) {
this->setStatus_(UpdateAvailable);
postToThread([this] {
QMessageBox *box =
new QMessageBox(QMessageBox::Information, "Chatterino Update",
"An update for chatterino is available.\n\nDo you "
"want to download and install it?",
QMessageBox::Yes | QMessageBox::No);
QMessageBox *box = new QMessageBox(
QMessageBox::Information, "Chatterino Update",
"An update for chatterino is available.\n\nDo you "
"want to download and install it?",
QMessageBox::Yes | QMessageBox::No);
box->setAttribute(Qt::WA_DeleteOnClose);
box->show();
box->raise();
+31 -17
View File
@@ -93,14 +93,17 @@ void WindowManager::updateWordTypeMask()
}
// emotes
flags |= settings->enableTwitchEmotes ? MEF::TwitchEmoteImage : MEF::TwitchEmoteText;
flags |= settings->enableTwitchEmotes ? MEF::TwitchEmoteImage
: MEF::TwitchEmoteText;
flags |= settings->enableFfzEmotes ? MEF::FfzEmoteImage : MEF::FfzEmoteText;
flags |= settings->enableBttvEmotes ? MEF::BttvEmoteImage : MEF::BttvEmoteText;
flags |=
settings->enableBttvEmotes ? MEF::BttvEmoteImage : MEF::BttvEmoteText;
flags |= settings->enableEmojis ? MEF::EmojiImage : MEF::EmojiText;
// bits
flags |= MEF::BitsAmount;
flags |= settings->enableGifAnimations ? MEF::BitsAnimated : MEF::BitsStatic;
flags |=
settings->enableGifAnimations ? MEF::BitsAnimated : MEF::BitsStatic;
// badges
flags |= settings->showBadges ? MEF::Badges : MEF::None;
@@ -111,8 +114,10 @@ void WindowManager::updateWordTypeMask()
// misc
flags |= MEF::AlwaysShow;
flags |= MEF::Collapsed;
flags |= settings->enableUsernameBold ? MEF::BoldUsername : MEF::NonBoldUsername;
flags |= settings->enableLowercaseLink ? MEF::LowercaseLink : MEF::OriginalLink;
flags |=
settings->enableUsernameBold ? MEF::BoldUsername : MEF::NonBoldUsername;
flags |=
settings->enableLowercaseLink ? MEF::LowercaseLink : MEF::OriginalLink;
// update flags
MessageElement::Flags newFlags = static_cast<MessageElement::Flags>(flags);
@@ -180,7 +185,8 @@ Window &WindowManager::createWindow(Window::Type type)
window->setAttribute(Qt::WA_DeleteOnClose);
QObject::connect(window, &QWidget::destroyed, [this, window] {
for (auto it = this->windows_.begin(); it != this->windows_.end(); it++) {
for (auto it = this->windows_.begin(); it != this->windows_.end();
it++) {
if (*it == window) {
this->windows_.erase(it);
break;
@@ -232,7 +238,8 @@ void WindowManager::initialize(Settings &settings, Paths &paths)
// get type
QString type_val = window_obj.value("type").toString();
Window::Type type = type_val == "main" ? Window::Type::Main : Window::Type::Popup;
Window::Type type =
type_val == "main" ? Window::Type::Main : Window::Type::Popup;
if (type == Window::Type::Main && mainWindow_ != nullptr) {
type = Window::Type::Popup;
@@ -304,14 +311,18 @@ void WindowManager::initialize(Settings &settings, Paths &paths)
mainWindow_->getNotebook().addPage(true);
}
settings.timestampFormat.connect([this](auto, auto) { this->layoutChannelViews(); });
settings.timestampFormat.connect(
[this](auto, auto) { this->layoutChannelViews(); });
settings.emoteScale.connect([this](auto, auto) { this->forceLayoutChannelViews(); });
settings.emoteScale.connect(
[this](auto, auto) { this->forceLayoutChannelViews(); });
settings.timestampFormat.connect([this](auto, auto) { this->forceLayoutChannelViews(); });
settings.timestampFormat.connect(
[this](auto, auto) { this->forceLayoutChannelViews(); });
settings.alternateMessageBackground.connect(
[this](auto, auto) { this->forceLayoutChannelViews(); });
settings.separateMessages.connect([this](auto, auto) { this->forceLayoutChannelViews(); });
settings.separateMessages.connect(
[this](auto, auto) { this->forceLayoutChannelViews(); });
settings.collpseMessagesMinLines.connect(
[this](auto, auto) { this->forceLayoutChannelViews(); });
@@ -352,10 +363,11 @@ void WindowManager::save()
// window tabs
QJsonArray tabs_arr;
for (int tab_i = 0; tab_i < window->getNotebook().getPageCount(); tab_i++) {
for (int tab_i = 0; tab_i < window->getNotebook().getPageCount();
tab_i++) {
QJsonObject tab_obj;
SplitContainer *tab =
dynamic_cast<SplitContainer *>(window->getNotebook().getPageAt(tab_i));
SplitContainer *tab = dynamic_cast<SplitContainer *>(
window->getNotebook().getPageAt(tab_i));
assert(tab != nullptr);
// custom tab title
@@ -415,8 +427,9 @@ void WindowManager::encodeNodeRecusively(SplitNode *node, QJsonObject &obj)
} break;
case SplitNode::HorizontalContainer:
case SplitNode::VerticalContainer: {
obj.insert("type", node->getType() == SplitNode::HorizontalContainer ? "horizontal"
: "vertical");
obj.insert("type", node->getType() == SplitNode::HorizontalContainer
? "horizontal"
: "vertical");
QJsonArray items_arr;
for (const std::unique_ptr<SplitNode> &n : node->getChildren()) {
@@ -458,7 +471,8 @@ IndirectChannel WindowManager::decodeChannel(const QJsonObject &obj)
QString type = obj.value("type").toString();
if (type == "twitch") {
return app->twitch.server->getOrAddChannel(obj.value("name").toString());
return app->twitch.server->getOrAddChannel(
obj.value("name").toString());
} else if (type == "mentions") {
return app->twitch.server->mentionsChannel;
} else if (type == "watching") {
+4 -2
View File
@@ -21,7 +21,8 @@ LoggingChannel::LoggingChannel(const QString &_channelName)
} else if (channelName.startsWith("/mentions")) {
this->subDirectory = "Mentions";
} else {
this->subDirectory = QStringLiteral("Channels") + QDir::separator() + channelName;
this->subDirectory =
QStringLiteral("Channels") + QDir::separator() + channelName;
}
// FOURTF: change this when adding more providers
@@ -60,7 +61,8 @@ void LoggingChannel::openLogFile()
QString baseFileName = this->channelName + "-" + this->dateString + ".log";
QString directory = this->baseDirectory + QDir::separator() + this->subDirectory;
QString directory =
this->baseDirectory + QDir::separator() + this->subDirectory;
if (!QDir().mkpath(directory)) {
Log("Unable to create logging path");
+4 -2
View File
@@ -24,8 +24,10 @@ public:
private:
void openLogFile();
QString generateOpeningString(const QDateTime &now = QDateTime::currentDateTime()) const;
QString generateClosingString(const QDateTime &now = QDateTime::currentDateTime()) const;
QString generateOpeningString(
const QDateTime &now = QDateTime::currentDateTime()) const;
QString generateClosingString(
const QDateTime &now = QDateTime::currentDateTime()) const;
void appendLine(const QString &line);