refactor: use some more SettingWidget & restyle external tools page (#6023)

This commit is contained in:
pajlada
2025-03-03 16:33:13 +01:00
committed by GitHub
parent cd8247f921
commit 34429671ba
10 changed files with 545 additions and 265 deletions
+74 -46
View File
@@ -95,7 +95,7 @@ GeneralPage::GeneralPage()
{
auto *y = new QVBoxLayout;
auto *x = new QHBoxLayout;
auto *view = new GeneralPageView;
auto *view = GeneralPageView::withNavigation(this);
this->view_ = view;
x->addWidget(view);
auto *z = new QFrame;
@@ -275,8 +275,9 @@ void GeneralPage::initLayout(GeneralPageView &layout)
"reply to a message regardless of this setting.")
->addTo(layout);
layout.addCheckbox("Show message reply button", s.showReplyButton, false,
"Show a reply button next to every chat message");
SettingWidget::checkbox("Show message reply button", s.showReplyButton)
->setTooltip("Show a reply button next to every chat message")
->addTo(layout);
auto removeTabSeq = getApp()->getHotkeys()->getDisplaySequence(
HotkeyCategory::Window, "removeTab");
@@ -309,9 +310,13 @@ void GeneralPage::initLayout(GeneralPageView &layout)
.arg(settingsSeq.toString(
QKeySequence::SequenceFormat::NativeText));
}
layout.addCheckbox("Show preferences button" + shortcut,
s.hidePreferencesButton, true);
layout.addCheckbox("Show user button", s.hideUserButton, true);
SettingWidget::inverseCheckbox("Show preferences button" + shortcut,
s.hidePreferencesButton)
->addTo(layout);
SettingWidget::inverseCheckbox("Show user button", s.hideUserButton)
->addTo(layout);
}
layout.addCheckbox("Mark tabs with live channels", s.showTabLive, false,
"Shows a red dot in the top right corner of a tab to "
@@ -464,24 +469,34 @@ void GeneralPage::initLayout(GeneralPageView &layout)
},
false);
layout.addCheckbox(
"Hide scrollbar thumb", s.hideScrollbarThumb, false,
"Hiding the scrollbar thumb (the handle you can drag) will disable "
"all mouse interaction in the scrollbar.");
SettingWidget::checkbox("Hide scrollbar thumb", s.hideScrollbarThumb)
->setTooltip("Hiding the scrollbar thumb (the handle you can drag) "
"will disable all mouse interaction in the scrollbar.")
->addKeywords({"scroll bar"})
->addTo(layout);
layout.addCheckbox("Hide scrollbar highlights", s.hideScrollbarHighlights,
false);
SettingWidget::checkbox("Hide scrollbar highlights",
s.hideScrollbarHighlights)
->addKeywords({"scroll bar"})
->addTo(layout);
layout.addTitle("Messages");
layout.addCheckbox(
"Separate with lines", s.separateMessages, false,
"Adds a line between each message to help better tell them apart.");
layout.addCheckbox("Alternate background color", s.alternateMessages, false,
"Slightly change the background behind every other "
"message to help better tell them apart.");
layout.addCheckbox("Hide deleted messages", s.hideModerated, false,
"When enabled, messages deleted by moderators will "
"be hidden.");
SettingWidget::checkbox("Separate with lines", s.separateMessages)
->setTooltip(
"Adds a line between each message to help better tell them apart.")
->addTo(layout);
SettingWidget::checkbox("Alternate background color", s.alternateMessages)
->setTooltip("Slightly change the background behind every other "
"message to help better tell them apart.")
->addTo(layout);
SettingWidget::checkbox("Hide deleted messages", s.hideModerated)
->setTooltip(
"When enabled, messages deleted by moderators will be hidden.")
->addTo(layout);
layout.addDropdown<QString>(
"Timestamp format",
{"Disable", "h:mm", "hh:mm", "h:mm a", "hh:mm a", "h:mm:ss", "hh:mm:ss",
@@ -539,9 +554,8 @@ void GeneralPage::initLayout(GeneralPageView &layout)
}
},
false);
layout.addColorButton("Line color",
QColor(getSettings()->lastMessageColor.getValue()),
getSettings()->lastMessageColor);
SettingWidget::colorButton("Line color", s.lastMessageColor)->addTo(layout);
layout.addTitle("Emotes");
layout.addCheckbox("Enable", s.enableEmoteImages);
@@ -1047,11 +1061,20 @@ void GeneralPage::initLayout(GeneralPageView &layout)
true,
"The final scale of the messages in the overlay is computed by "
"multiplying this zoom factor with the global zoom level.");
layout.addIntInput(
"Background opacity (0-255)", s.overlayBackgroundOpacity, 0, 255, 1,
"Controls the opacity of the (possibly alternating) background behind "
"messages. The color is set through the current theme. 255 corresponds "
"to a fully opaque background.");
SettingWidget::intInput("Background opacity (0-255)",
s.overlayBackgroundOpacity,
{
.min = 0,
.max = 255,
.singleStep = 1,
})
->setTooltip(
"Controls the opacity of the (possibly alternating) background "
"behind messages. The color is set through the current theme. 255 "
"corresponds to a fully opaque background.")
->addTo(layout);
layout.addCheckbox("Enable Shadow", s.enableOverlayShadow, false,
"Enables a drop shadow on the overlay. This will use "
"more processing power.");
@@ -1059,9 +1082,10 @@ void GeneralPage::initLayout(GeneralPageView &layout)
1,
"Controls the opacity of the added drop shadow. 255 "
"corresponds to a fully opaque shadow.");
layout.addColorButton("Shadow color",
QColor(getSettings()->overlayShadowColor.getValue()),
getSettings()->overlayShadowColor);
SettingWidget::colorButton("Shadow color", s.overlayShadowColor)
->addTo(layout);
layout
.addIntInput("Shadow radius", s.overlayShadowRadius, 0, 40, 1,
"Controls how far the shadow is spread (the blur "
@@ -1088,15 +1112,14 @@ void GeneralPage::initLayout(GeneralPageView &layout)
s.openLinksIncognito);
}
layout.addCustomCheckbox(
SettingWidget::customCheckbox(
"Restart on crash (requires restart)",
[] {
return getApp()->getCrashHandler()->shouldRecover();
},
getApp()->getCrashHandler()->shouldRecover(),
[](bool on) {
return getApp()->getCrashHandler()->saveShouldRecover(on);
},
"When possible, restart Chatterino if the program crashes");
getApp()->getCrashHandler()->saveShouldRecover(on);
})
->setTooltip("When possible, restart Chatterino if the program crashes")
->addTo(layout);
#if defined(Q_OS_LINUX) && !defined(NO_QTKEYCHAIN)
if (!getApp()->getPaths().isPortable())
@@ -1107,13 +1130,18 @@ void GeneralPage::initLayout(GeneralPageView &layout)
}
#endif
layout.addCheckbox(
"Show moderation messages", s.hideModerationActions, true,
"Show messages for timeouts, bans, and other moderator actions.");
layout.addCheckbox("Show deletions of single messages",
s.hideDeletionActions, true,
"Show when a single message is deleted.\ne.g. A message "
"from TreuKS was deleted: abc");
SettingWidget::inverseCheckbox("Show moderation messages",
s.hideModerationActions)
->setTooltip(
"Show messages for timeouts, bans, and other moderator actions.")
->addTo(layout);
SettingWidget::inverseCheckbox("Show deletions of single messages",
s.hideDeletionActions)
->setTooltip("Show when a single message is deleted.\ne.g. A message "
"from TreuKS was deleted: abc")
->addTo(layout);
layout.addCheckbox(
"Colorize users without color set (gray names)", s.colorizeNicknames,
false,