feat: Add tab style option (Normal & Combat) (#5858)
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
- 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: 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 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)
|
||||
|
||||
@@ -92,6 +92,11 @@ enum StreamerModeSetting {
|
||||
DetectStreamingSoftware = 2,
|
||||
};
|
||||
|
||||
enum class TabStyle : std::uint8_t {
|
||||
Normal,
|
||||
Compact,
|
||||
};
|
||||
|
||||
/// 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.
|
||||
class Settings
|
||||
@@ -182,6 +187,10 @@ public:
|
||||
FloatSetting boldScale = {"/appearance/boldScale", 63};
|
||||
BoolSetting showTabCloseButton = {"/appearance/showTabCloseButton", true};
|
||||
BoolSetting showTabLive = {"/appearance/showTabLiveButton", true};
|
||||
EnumStringSetting<TabStyle> tabStyle = {
|
||||
"/appearance/tabStyle",
|
||||
TabStyle::Normal,
|
||||
};
|
||||
BoolSetting hidePreferencesButton = {"/appearance/hidePreferencesButton",
|
||||
false};
|
||||
BoolSetting hideUserButton = {"/appearance/hideUserButton", false};
|
||||
|
||||
@@ -54,6 +54,30 @@ namespace {
|
||||
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
|
||||
|
||||
NotebookTab::NotebookTab(Notebook *notebook)
|
||||
@@ -67,8 +91,15 @@ NotebookTab::NotebookTab(Notebook *notebook)
|
||||
this->positionChangedAnimation_.setEasingCurve(
|
||||
QEasingCurve(QEasingCurve::InCubic));
|
||||
|
||||
getSettings()->showTabCloseButton.connectSimple(
|
||||
boost::bind(&NotebookTab::hideTabXChanged, this),
|
||||
getSettings()->showTabCloseButton.connect(
|
||||
[this] {
|
||||
this->tabSizeChanged();
|
||||
},
|
||||
this->managedConnections_);
|
||||
getSettings()->tabStyle.connect(
|
||||
[this] {
|
||||
this->tabSizeChanged();
|
||||
},
|
||||
this->managedConnections_);
|
||||
getSettings()->showTabLive.connect(
|
||||
[this](auto, auto) {
|
||||
@@ -204,13 +235,16 @@ int NotebookTab::normalTabWidthForHeight(int height) const
|
||||
QFontMetrics metrics =
|
||||
getApp()->getFonts()->getFontMetrics(FontStyle::UiTabs, scale);
|
||||
|
||||
float compactDivider = getCompactDivider(getSettings()->tabStyle);
|
||||
if (this->hasXButton())
|
||||
{
|
||||
width = (metrics.horizontalAdvance(this->getTitle()) + int(32 * scale));
|
||||
width = (metrics.horizontalAdvance(this->getTitle()) +
|
||||
int(32 / compactDivider * scale));
|
||||
}
|
||||
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)
|
||||
@@ -608,7 +642,7 @@ QRect NotebookTab::getDesiredRect() const
|
||||
return QRect(this->positionAnimationDesiredPoint_, size());
|
||||
}
|
||||
|
||||
void NotebookTab::hideTabXChanged()
|
||||
void NotebookTab::tabSizeChanged()
|
||||
{
|
||||
this->updateSize();
|
||||
this->update();
|
||||
@@ -760,12 +794,15 @@ void NotebookTab::paintEvent(QPaintEvent *)
|
||||
// set the pen color
|
||||
painter.setPen(colors.text);
|
||||
|
||||
float compactDivider = getCompactDivider(getSettings()->tabStyle);
|
||||
// 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);
|
||||
|
||||
// draw text
|
||||
int offset = int(scale * 8);
|
||||
int offset = int(scale * 4 / compactDivider);
|
||||
QRect textRect(offset, 0, this->width() - offset - offset, height);
|
||||
translateRectForLocation(textRect, this->tabLocation_,
|
||||
this->selected_ ? -1 : -2);
|
||||
@@ -1044,7 +1081,8 @@ QRect NotebookTab::getXRect() const
|
||||
? (size / 3) // slightly off 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);
|
||||
|
||||
if (this->selected_)
|
||||
|
||||
@@ -82,7 +82,7 @@ public:
|
||||
void moveAnimated(QPoint targetPos, bool animated = true);
|
||||
|
||||
QRect getDesiredRect() const;
|
||||
void hideTabXChanged();
|
||||
void tabSizeChanged();
|
||||
|
||||
void growWidth(int width);
|
||||
int normalTabWidth() const;
|
||||
|
||||
@@ -279,6 +279,8 @@ void GeneralPage::initLayout(GeneralPageView &layout)
|
||||
},
|
||||
false, "Choose which tabs are visible in the notebook");
|
||||
|
||||
SettingWidget::dropdown("Tab style", s.tabStyle)->addTo(layout);
|
||||
|
||||
SettingWidget::inverseCheckbox("Show message reply context",
|
||||
s.hideReplyContext)
|
||||
->setTooltip(
|
||||
|
||||
Reference in New Issue
Block a user