Gui: Respect both content size and minimum width for buttons
This is a hacky fix for https://github.com/FreeCAD/FreeCAD/issues/23607 Basically after widget is shown or polished we enforce it's minimum size to at least cover the minimum size hint - something that QSS ignores if min-width is specified.
This commit is contained in:
committed by
Chris Hennes
parent
16032ae34c
commit
aefd2592a8
@@ -39,6 +39,7 @@
|
||||
#include <QTextStream>
|
||||
#include <QTimer>
|
||||
#include <QWindow>
|
||||
#include <QStyleFactory>
|
||||
|
||||
#include <QLoggingCategory>
|
||||
#include <fmt/format.h>
|
||||
@@ -141,6 +142,7 @@
|
||||
#include "Inventor/SoFCPlacementIndicatorKit.h"
|
||||
#include "QtWidgets.h"
|
||||
|
||||
#include <FreeCADStyle.h>
|
||||
#include <OverlayManager.h>
|
||||
#include <ParamHandler.h>
|
||||
#include <Base/ServiceProvider.h>
|
||||
@@ -2768,6 +2770,38 @@ QString Application::replaceVariablesInQss(const QString& qssText)
|
||||
return QString::fromStdString(d->styleParameterManager->replacePlaceholders(qssText.toStdString()));
|
||||
}
|
||||
|
||||
void Application::setStyle(const QString& name)
|
||||
{
|
||||
const auto createStyleFromName = [](const QString& name) -> QStyle* {
|
||||
if (name == "FreeCAD") {
|
||||
return new FreeCADStyle();
|
||||
}
|
||||
|
||||
if (name.compare("System", Qt::CaseInsensitive) == 0) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return QStyleFactory::create(name);
|
||||
};
|
||||
|
||||
const auto requiresEventFilter = [](QStyle* style) {
|
||||
// for now only FreeCAD style requires additional event processing
|
||||
return qobject_cast<FreeCADStyle*>(style) != nullptr;
|
||||
};
|
||||
|
||||
if (auto* current = qApp->style(); current != nullptr && requiresEventFilter(current)) {
|
||||
qApp->removeEventFilter(current);
|
||||
}
|
||||
|
||||
if (auto* style = createStyleFromName(name)) {
|
||||
qApp->setStyle(style);
|
||||
|
||||
if (requiresEventFilter(style)) {
|
||||
qApp->installEventFilter(style);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Application::checkForDeprecatedSettings()
|
||||
{
|
||||
// From 0.21, `FCBak` will be the intended default backup format
|
||||
|
||||
Reference in New Issue
Block a user