summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar lat9nq2023-05-18 23:19:08 -0700
committerGravatar lat9nq2023-07-21 10:56:07 -0400
commitb570b719de11512ab2acc2c1fd8a8a9ae8391763 (patch)
treedd654531817a2138bf20c6154951200606f606dc /src
parentconfiguration: Workaround for Windows Qt bug (diff)
downloadyuzu-b570b719de11512ab2acc2c1fd8a8a9ae8391763.tar.gz
yuzu-b570b719de11512ab2acc2c1fd8a8a9ae8391763.tar.xz
yuzu-b570b719de11512ab2acc2c1fd8a8a9ae8391763.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/yuzu/configuration/shared_widget.cpp15
1 files 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 @@
18#include <qboxlayout.h> 18#include <qboxlayout.h>
19#include <qnamespace.h> 19#include <qnamespace.h>
20#include <qpushbutton.h> 20#include <qpushbutton.h>
21#include <qsizepolicy.h>
21#include <qvalidator.h> 22#include <qvalidator.h>
22#include "common/common_types.h" 23#include "common/common_types.h"
23#include "common/settings.h" 24#include "common/settings.h"
@@ -27,11 +28,20 @@
27 28
28namespace ConfigurationShared { 29namespace ConfigurationShared {
29 30
31static int restore_button_count = 0;
32
30QPushButton* Widget::CreateRestoreGlobalButton(bool using_global, QWidget* parent) { 33QPushButton* Widget::CreateRestoreGlobalButton(bool using_global, QWidget* parent) {
34 restore_button_count++;
35
31 QStyle* style = parent->style(); 36 QStyle* style = parent->style();
32 QIcon* icon = new QIcon(style->standardIcon(QStyle::SP_LineEditClearButton)); 37 QIcon* icon = new QIcon(style->standardIcon(QStyle::SP_LineEditClearButton));
33 QPushButton* restore_button = new QPushButton(*icon, QStringLiteral(""), parent); 38 QPushButton* restore_button = new QPushButton(*icon, QStringLiteral(""), parent);
34 restore_button->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred); 39 restore_button->setObjectName(QStringLiteral("RestoreButton%1").arg(restore_button_count));
40 restore_button->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
41
42 // Workaround for dark theme causing min-width to be much larger than 0
43 restore_button->setStyleSheet(
44 QStringLiteral("QAbstractButton#%1 { min-width: 0px }").arg(restore_button->objectName()));
35 45
36 QSizePolicy sp_retain = restore_button->sizePolicy(); 46 QSizePolicy sp_retain = restore_button->sizePolicy();
37 sp_retain.setRetainSizeWhenHidden(true); 47 sp_retain.setRetainSizeWhenHidden(true);
@@ -113,8 +123,9 @@ void Widget::CreateCombobox(const QString& label, std::function<void()>& load_fu
113 123
114 QLayout* layout = new QHBoxLayout(this); 124 QLayout* layout = new QHBoxLayout(this);
115 125
116 QLabel* qt_label = new QLabel(label, this); 126 QLabel* qt_label = CreateLabel(label);
117 combobox = new QComboBox(this); 127 combobox = new QComboBox(this);
128 combobox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
118 129
119 layout->addWidget(qt_label); 130 layout->addWidget(qt_label);
120 layout->addWidget(combobox); 131 layout->addWidget(combobox);