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:
Kacper Donat
2025-12-06 22:45:53 +01:00
committed by Chris Hennes
parent 3118469338
commit 0120299a80
9 changed files with 150 additions and 15 deletions

View File

@@ -22,6 +22,7 @@
**************************************************************************/
#include <FCConfig.h>
#include <ParamHandler.h>
#ifdef FC_OS_WIN32
# include <windows.h>
@@ -37,6 +38,7 @@
#include <QThread>
#include <QTimer>
#include <QWindow>
#include <Inventor/SoDB.h>
#include <set>
@@ -52,6 +54,8 @@
#include "MainWindow.h"
#include "Language/Translator.h"
#include "Dialogs/DlgVersionMigrator.h"
#include "FreeCADStyle.h"
#include <App/Application.h>
#include <Base/Console.h>
@@ -309,19 +313,24 @@ void StartupPostProcess::setCursorFlashing()
QApplication::setCursorFlashTime(blinkTime);
}
void StartupPostProcess::setQtStyle()
{
static ParamHandlers handlers;
ParameterGrp::handle hGrp = WindowParameter::getDefaultParameter()->GetGroup("MainWindow");
auto qtStyle = hGrp->GetASCII("QtStyle");
if (qtStyle.empty()) {
qtStyle = "Fusion";
hGrp->SetASCII("QtStyle", qtStyle);
}
else if (qtStyle == "System") {
// Special value to not set a QtStyle explicitly
return;
}
QApplication::setStyle(QString::fromStdString(qtStyle));
const auto setStyleFromParameters = [hGrp]() {
const auto style = hGrp->GetASCII("QtStyle");
Application::Instance->setStyle(QString::fromStdString(style));
};
auto handler = handlers.addHandler(hGrp, "QtStyle", [setStyleFromParameters](const ParamKey*) {
setStyleFromParameters();
});
setStyleFromParameters();
}
void StartupPostProcess::checkOpenGL()