GUI: preferences: fix width of combo box content view on Windows

Due to a bug in Qt[1] the content view will only be as wide as the combo
box itself on Windows while expanding to the minimum length required on
Linux and Mac OS. So force the minimum width to the maximum content
width.

[1] https://bugreports.qt.io/browse/QTBUG-3097
This commit is contained in:
Moritz Bunkus 2015-09-18 17:32:41 +02:00
parent c9aa36005a
commit 740c19c7f3
3 changed files with 10 additions and 0 deletions

View File

@ -320,6 +320,8 @@ PreferencesDialog::setupPlaylistScanningPolicy() {
ui->cbMScanPlaylistsPolicy->setCurrentIndex(selected);
ui->sbMMinPlaylistDuration->setValue(m_cfg.m_minimumPlaylistDuration);
Util::fixComboBoxViewWidth(*ui->cbMScanPlaylistsPolicy);
}
void

View File

@ -1,5 +1,6 @@
#include "common/common_pch.h"
#include <QAbstractItemView>
#include <QCheckBox>
#include <QComboBox>
#include <QIcon>
@ -152,4 +153,10 @@ preventScrollingWithoutFocus(QObject *parent) {
install(child);
}
void
fixComboBoxViewWidth(QComboBox &comboBox) {
comboBox.setSizeAdjustPolicy(QComboBox::AdjustToContents);
comboBox.view()->setMinimumWidth(comboBox.sizeHint().width());
}
}}}

View File

@ -22,6 +22,7 @@ QIcon loadIcon(QString const &name, QList<int> const &sizes);
bool setComboBoxIndexIf(QComboBox *comboBox, std::function<bool(QString const &, QVariant const &)> test);
bool setComboBoxTextByData(QComboBox *comboBox, QString const &data);
void setComboBoxTexts(QComboBox *comboBox, QStringList const &texts);
void fixComboBoxViewWidth(QComboBox &comboBox);
void enableWidgets(QList<QWidget *> const &widgets, bool enable);
QPushButton *buttonForRole(QDialogButtonBox *box, QDialogButtonBox::ButtonRole role = QDialogButtonBox::AcceptRole);