feat: Add tab style option (Normal & Combat) (#5858)

This commit is contained in:
apa420
2025-03-11 15:16:33 +00:00
committed by GitHub
parent 108a437841
commit 59e93d41d3
5 changed files with 59 additions and 9 deletions
+1
View File
@@ -19,6 +19,7 @@
- Minor: The `/watching` channel is now supported on all platforms. (#6031, #6043) - Minor: The `/watching` channel is now supported on all platforms. (#6031, #6043)
- Minor: The font weight of chat messages can now be changed. (#6037) - Minor: The font weight of chat messages can now be changed. (#6037)
- Minor: Messages from restricted users can now be hidden when in streamer mode. This is enabled by default. (#6042, #6049) - Minor: Messages from restricted users can now be hidden when in streamer mode. This is enabled by default. (#6042, #6049)
- Minor: Added a tab style option allowing you to make your tabs more compact. (#5858)
- Bugfix: Fixed a potential way to escape the Lua Plugin sandbox. (#5846) - Bugfix: Fixed a potential way to escape the Lua Plugin sandbox. (#5846)
- Bugfix: Fixed a crash relating to Lua HTTP. (#5800) - Bugfix: Fixed a crash relating to Lua HTTP. (#5800)
- Bugfix: Fixed a crash that could occur on Linux and macOS when clicking "Install" from the update prompt. (#5818) - Bugfix: Fixed a crash that could occur on Linux and macOS when clicking "Install" from the update prompt. (#5818)
+9
View File
@@ -92,6 +92,11 @@ enum StreamerModeSetting {
DetectStreamingSoftware = 2, DetectStreamingSoftware = 2,
}; };
enum class TabStyle : std::uint8_t {
Normal,
Compact,
};
/// Settings which are availlable for reading and writing on the gui thread. /// Settings which are availlable for reading and writing on the gui thread.
// These settings are still accessed concurrently in the code but it is bad practice. // These settings are still accessed concurrently in the code but it is bad practice.
class Settings class Settings
@@ -182,6 +187,10 @@ public:
FloatSetting boldScale = {"/appearance/boldScale", 63}; FloatSetting boldScale = {"/appearance/boldScale", 63};
BoolSetting showTabCloseButton = {"/appearance/showTabCloseButton", true}; BoolSetting showTabCloseButton = {"/appearance/showTabCloseButton", true};
BoolSetting showTabLive = {"/appearance/showTabLiveButton", true}; BoolSetting showTabLive = {"/appearance/showTabLiveButton", true};
EnumStringSetting<TabStyle> tabStyle = {
"/appearance/tabStyle",
TabStyle::Normal,
};
BoolSetting hidePreferencesButton = {"/appearance/hidePreferencesButton", BoolSetting hidePreferencesButton = {"/appearance/hidePreferencesButton",
false}; false};
BoolSetting hideUserButton = {"/appearance/hideUserButton", false}; BoolSetting hideUserButton = {"/appearance/hideUserButton", false};
+46 -8
View File
@@ -54,6 +54,30 @@ namespace {
break; break;
} }
} }
float getCompactDivider(TabStyle tabStyle)
{
switch (tabStyle)
{
case TabStyle::Compact:
return 1.5;
case TabStyle::Normal:
default:
return 1.0;
}
}
float getCompactReducer(TabStyle tabStyle)
{
switch (tabStyle)
{
case TabStyle::Compact:
return 4.0;
case TabStyle::Normal:
default:
return 0.0;
}
}
} // namespace } // namespace
NotebookTab::NotebookTab(Notebook *notebook) NotebookTab::NotebookTab(Notebook *notebook)
@@ -67,8 +91,15 @@ NotebookTab::NotebookTab(Notebook *notebook)
this->positionChangedAnimation_.setEasingCurve( this->positionChangedAnimation_.setEasingCurve(
QEasingCurve(QEasingCurve::InCubic)); QEasingCurve(QEasingCurve::InCubic));
getSettings()->showTabCloseButton.connectSimple( getSettings()->showTabCloseButton.connect(
boost::bind(&NotebookTab::hideTabXChanged, this), [this] {
this->tabSizeChanged();
},
this->managedConnections_);
getSettings()->tabStyle.connect(
[this] {
this->tabSizeChanged();
},
this->managedConnections_); this->managedConnections_);
getSettings()->showTabLive.connect( getSettings()->showTabLive.connect(
[this](auto, auto) { [this](auto, auto) {
@@ -204,13 +235,16 @@ int NotebookTab::normalTabWidthForHeight(int height) const
QFontMetrics metrics = QFontMetrics metrics =
getApp()->getFonts()->getFontMetrics(FontStyle::UiTabs, scale); getApp()->getFonts()->getFontMetrics(FontStyle::UiTabs, scale);
float compactDivider = getCompactDivider(getSettings()->tabStyle);
if (this->hasXButton()) if (this->hasXButton())
{ {
width = (metrics.horizontalAdvance(this->getTitle()) + int(32 * scale)); width = (metrics.horizontalAdvance(this->getTitle()) +
int(32 / compactDivider * scale));
} }
else else
{ {
width = (metrics.horizontalAdvance(this->getTitle()) + int(16 * scale)); width = (metrics.horizontalAdvance(this->getTitle()) +
int(16 / compactDivider * scale));
} }
if (static_cast<float>(height) > 150 * scale) if (static_cast<float>(height) > 150 * scale)
@@ -608,7 +642,7 @@ QRect NotebookTab::getDesiredRect() const
return QRect(this->positionAnimationDesiredPoint_, size()); return QRect(this->positionAnimationDesiredPoint_, size());
} }
void NotebookTab::hideTabXChanged() void NotebookTab::tabSizeChanged()
{ {
this->updateSize(); this->updateSize();
this->update(); this->update();
@@ -760,12 +794,15 @@ void NotebookTab::paintEvent(QPaintEvent *)
// set the pen color // set the pen color
painter.setPen(colors.text); painter.setPen(colors.text);
float compactDivider = getCompactDivider(getSettings()->tabStyle);
// set area for text // set area for text
int rectW = (!getSettings()->showTabCloseButton ? 0 : int(16 * scale)); int rectW =
(!getSettings()->showTabCloseButton ? 0
: int(16 * scale / compactDivider));
QRect rect(0, 0, this->width() - rectW, height); QRect rect(0, 0, this->width() - rectW, height);
// draw text // draw text
int offset = int(scale * 8); int offset = int(scale * 4 / compactDivider);
QRect textRect(offset, 0, this->width() - offset - offset, height); QRect textRect(offset, 0, this->width() - offset - offset, height);
translateRectForLocation(textRect, this->tabLocation_, translateRectForLocation(textRect, this->tabLocation_,
this->selected_ ? -1 : -2); this->selected_ ? -1 : -2);
@@ -1044,7 +1081,8 @@ QRect NotebookTab::getXRect() const
? (size / 3) // slightly off true center ? (size / 3) // slightly off true center
: (size / 2); // true center : (size / 2); // true center
QRect xRect(rect.right() - static_cast<int>(20 * s), float compactReducer = getCompactReducer(getSettings()->tabStyle);
QRect xRect(rect.right() - static_cast<int>((20 - compactReducer) * s),
rect.center().y() - centerAdjustment, size, size); rect.center().y() - centerAdjustment, size, size);
if (this->selected_) if (this->selected_)
+1 -1
View File
@@ -82,7 +82,7 @@ public:
void moveAnimated(QPoint targetPos, bool animated = true); void moveAnimated(QPoint targetPos, bool animated = true);
QRect getDesiredRect() const; QRect getDesiredRect() const;
void hideTabXChanged(); void tabSizeChanged();
void growWidth(int width); void growWidth(int width);
int normalTabWidth() const; int normalTabWidth() const;
@@ -279,6 +279,8 @@ void GeneralPage::initLayout(GeneralPageView &layout)
}, },
false, "Choose which tabs are visible in the notebook"); false, "Choose which tabs are visible in the notebook");
SettingWidget::dropdown("Tab style", s.tabStyle)->addTo(layout);
SettingWidget::inverseCheckbox("Show message reply context", SettingWidget::inverseCheckbox("Show message reply context",
s.hideReplyContext) s.hideReplyContext)
->setTooltip( ->setTooltip(