mirror of
https://github.com/kiwix/kiwix-desktop.git
synced 2025-08-03 20:56:49 -04:00
Fixed Tab Title Alignment
This commit is contained in:
parent
585d29d2aa
commit
df6560c1a3
@ -176,15 +176,17 @@ QTabWidget::pane {
|
|||||||
border-top: 1px solid #ccc;
|
border-top: 1px solid #ccc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* paintEvent of src/tabbar.cpp references the value of border and padding */
|
||||||
QTabBar::tab {
|
QTabBar::tab {
|
||||||
border: 1px solid #ccc;
|
border: 1px solid #ccc;
|
||||||
border-radius: 0;
|
border-radius: 0;
|
||||||
padding: 2px;
|
padding: 4px;
|
||||||
|
padding-top: 6px;
|
||||||
}
|
}
|
||||||
|
|
||||||
QTabBar::tab:selected {
|
QTabBar::tab:selected {
|
||||||
background-color: white;
|
background-color: white;
|
||||||
border-bottom: 2px solid white;
|
border-bottom: 1px solid white;
|
||||||
}
|
}
|
||||||
|
|
||||||
QTabBar::tab:first {
|
QTabBar::tab:first {
|
||||||
|
@ -425,8 +425,22 @@ void TabBar::paintEvent(QPaintEvent *e)
|
|||||||
bool textRightToLeft = tab_title.isRightToLeft();
|
bool textRightToLeft = tab_title.isRightToLeft();
|
||||||
bool appRightToLeft = QWidget::isRightToLeft();
|
bool appRightToLeft = QWidget::isRightToLeft();
|
||||||
|
|
||||||
|
// See QTabBar::tab::padding value in resources/css/style.css
|
||||||
|
const int padding = 4;
|
||||||
QRect tabTextRect = style()->subElementRect(QStyle::SE_TabBarTabText, &tabopt, this);
|
QRect tabTextRect = style()->subElementRect(QStyle::SE_TabBarTabText, &tabopt, this);
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||||
|
// See QTabBar::tab::border value in resources/css/style.css
|
||||||
|
const int border = 1;
|
||||||
|
|
||||||
|
// Add Padding to left, right. Padding is 4px. Add 5 to account for
|
||||||
|
// Extra pixel from border.
|
||||||
|
tabTextRect.setX(tabTextRect.x() + padding + border);
|
||||||
|
tabTextRect.setWidth(tabTextRect.width() - padding - border);
|
||||||
|
#else
|
||||||
|
// Qt6 correctly adds left and right padding but now incorrectly adds
|
||||||
|
// top or bottom padding.
|
||||||
|
tabTextRect.setY(tabTextRect.y() - padding);
|
||||||
|
#endif
|
||||||
QRect fontTextRect = fontMetrics().boundingRect(tab_title);
|
QRect fontTextRect = fontMetrics().boundingRect(tab_title);
|
||||||
|
|
||||||
if (fontTextRect.width() > tabTextRect.width())
|
if (fontTextRect.width() > tabTextRect.width())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user