Gui: Add SplitButton widget

This adds SplitButton widget that has one primary action and possibly
more secondary ones accessible via menu.
This commit is contained in:
Kacper Donat
2025-11-26 23:35:36 +01:00
parent 4e74031e06
commit c500408a6d
7 changed files with 191 additions and 7 deletions

View File

@@ -2603,6 +2603,18 @@ void Application::setStyleSheet(const QString& qssFile, bool tiledBackground)
mw->setProperty("fc_currentStyleSheet", qssFile);
mw->setProperty("fc_tiledBackground", tiledBackground);
QString defaultStyleSheet = [this]() {
QFile f("qss:defaults.qss");
if (!f.open(QFile::ReadOnly)) {
return QString();
}
QTextStream in(&f);
return replaceVariablesInQss(in.readAll());
}();
if (!qssFile.isEmpty()) {
// Search for stylesheet in user-defined search paths.
// For qss they are set-up in runApplication() with the prefix "qss"
@@ -2622,7 +2634,7 @@ void Application::setStyleSheet(const QString& qssFile, bool tiledBackground)
QString styleSheetContent = replaceVariablesInQss(str.readAll());
qApp->setStyleSheet(styleSheetContent);
qApp->setStyleSheet(defaultStyleSheet + QStringLiteral("\n") + styleSheetContent);
ActionStyleEvent e(ActionStyleEvent::Clear);
qApp->sendEvent(mw, &e);
@@ -2650,13 +2662,13 @@ void Application::setStyleSheet(const QString& qssFile, bool tiledBackground)
}
else {
if (tiledBackground) {
qApp->setStyleSheet(QString());
qApp->setStyleSheet(defaultStyleSheet);
ActionStyleEvent e(ActionStyleEvent::Restore);
qApp->sendEvent(getMainWindow(), &e);
mdi->setBackground(QPixmap(QLatin1String("images:background.png")));
}
else {
qApp->setStyleSheet(QString());
qApp->setStyleSheet(defaultStyleSheet);
ActionStyleEvent e(ActionStyleEvent::Restore);
qApp->sendEvent(getMainWindow(), &e);
mdi->setBackground(QBrush(QColor(160, 160, 160)));