From b570b719de11512ab2acc2c1fd8a8a9ae8391763 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Thu, 18 May 2023 23:19:08 -0700 Subject: [PATCH] shared_widget: Force min width of 100 for restore button Dark theme mandates a 100px minimum width for QAbstractButton, even though this is not desired here. --- src/yuzu/configuration/shared_widget.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/yuzu/configuration/shared_widget.cpp b/src/yuzu/configuration/shared_widget.cpp index 71f4eadbe..d5b2bd60e 100644 --- a/src/yuzu/configuration/shared_widget.cpp +++ b/src/yuzu/configuration/shared_widget.cpp @@ -18,6 +18,7 @@ #include #include #include +#include #include #include "common/common_types.h" #include "common/settings.h" @@ -27,11 +28,20 @@ namespace ConfigurationShared { +static int restore_button_count = 0; + QPushButton* Widget::CreateRestoreGlobalButton(bool using_global, QWidget* parent) { + restore_button_count++; + QStyle* style = parent->style(); QIcon* icon = new QIcon(style->standardIcon(QStyle::SP_LineEditClearButton)); QPushButton* restore_button = new QPushButton(*icon, QStringLiteral(""), parent); - restore_button->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred); + restore_button->setObjectName(QStringLiteral("RestoreButton%1").arg(restore_button_count)); + restore_button->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); + + // Workaround for dark theme causing min-width to be much larger than 0 + restore_button->setStyleSheet( + QStringLiteral("QAbstractButton#%1 { min-width: 0px }").arg(restore_button->objectName())); QSizePolicy sp_retain = restore_button->sizePolicy(); sp_retain.setRetainSizeWhenHidden(true); @@ -113,8 +123,9 @@ void Widget::CreateCombobox(const QString& label, std::function& load_fu QLayout* layout = new QHBoxLayout(this); - QLabel* qt_label = new QLabel(label, this); + QLabel* qt_label = CreateLabel(label); combobox = new QComboBox(this); + combobox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); layout->addWidget(qt_label); layout->addWidget(combobox);