DolphinQt: Custom style for QGroupBox in Fusion.
Fusion is the fallback style that Qt provides in systems that do not offer a OS-specific style. Basically, anything that is not Windows, macOS, or KDE (NOTE: Since #13919, users on these systems can opt in to Fusion too). Its default style for `QGroupBox` is not very conventional, and has been customized to align with more popular designs. | Before | After | | --- | --- | |  |  |
This commit is contained in:
@@ -159,7 +159,6 @@ void Settings::ApplyStyle()
|
|||||||
{
|
{
|
||||||
const StyleType style_type = GetStyleType();
|
const StyleType style_type = GetStyleType();
|
||||||
|
|
||||||
{
|
|
||||||
const bool use_fusion{style_type == StyleType::FusionLight ||
|
const bool use_fusion{style_type == StyleType::FusionLight ||
|
||||||
style_type == StyleType::FusionDarkGray ||
|
style_type == StyleType::FusionDarkGray ||
|
||||||
style_type == StyleType::FusionDark};
|
style_type == StyleType::FusionDark};
|
||||||
@@ -167,7 +166,6 @@ void Settings::ApplyStyle()
|
|||||||
const QString style_name{use_fusion ? QStringLiteral("fusion") : s_initial_style_name};
|
const QString style_name{use_fusion ? QStringLiteral("fusion") : s_initial_style_name};
|
||||||
if (QApplication::style()->name() != style_name)
|
if (QApplication::style()->name() != style_name)
|
||||||
QApplication::setStyle(style_name);
|
QApplication::setStyle(style_name);
|
||||||
}
|
|
||||||
|
|
||||||
const QString stylesheet_name = GetUserStyleName();
|
const QString stylesheet_name = GetUserStyleName();
|
||||||
QString stylesheet_contents;
|
QString stylesheet_contents;
|
||||||
@@ -386,6 +384,26 @@ void Settings::ApplyStyle()
|
|||||||
stylesheet_contents.append(QStringLiteral("%1").arg(tooltip_stylesheet));
|
stylesheet_contents.append(QStringLiteral("%1").arg(tooltip_stylesheet));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// For Fusion, define group box style if not already defined.
|
||||||
|
if (style_name.compare(QStringLiteral("fusion"), Qt::CaseInsensitive) == 0 &&
|
||||||
|
!stylesheet_contents.contains(QStringLiteral("QGroupBox")))
|
||||||
|
{
|
||||||
|
stylesheet_contents.append(QStringLiteral("QGroupBox {"
|
||||||
|
" margin-top: 0.6em;"
|
||||||
|
" padding-top: 0.5em;"
|
||||||
|
" padding-bottom: 0;"
|
||||||
|
" padding-left: 1px;"
|
||||||
|
" padding-right: 1px;"
|
||||||
|
"} "
|
||||||
|
"QGroupBox::title {"
|
||||||
|
" subcontrol-origin: margin;"
|
||||||
|
" subcontrol-position: top left;"
|
||||||
|
" left: 0.7em;"
|
||||||
|
" padding-top: 1px;"
|
||||||
|
" min-width: 0;"
|
||||||
|
"}"));
|
||||||
|
}
|
||||||
|
|
||||||
qApp->setStyleSheet(stylesheet_contents);
|
qApp->setStyleSheet(stylesheet_contents);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user