diff --git a/ChangeLog b/ChangeLog index cefdee2eb..1582dea6e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -13,6 +13,7 @@ and values 0 to 10. In the UI, ratings are show as 5 stars. 9. If we fail to download a cover, don't keep trying next time song is played. 10. Simplify toolbar cover widget, no border. +11. Allow Qt preference dialog to shrink smaller. 1.4.1 ----- diff --git a/gui/preferencesdialog.cpp b/gui/preferencesdialog.cpp index 75e2e13f6..4095fe885 100644 --- a/gui/preferencesdialog.cpp +++ b/gui/preferencesdialog.cpp @@ -69,6 +69,7 @@ PreferencesDialog::PreferencesDialog(QWidget *parent) setButtons(Ok|Apply|Cancel); pageWidget = new PageWidget(this); + setMainWidget(pageWidget); server = new ServerSettings(0); playback = new PlaybackSettings(0); files = new FileSettings(0); @@ -129,11 +130,7 @@ PreferencesDialog::PreferencesDialog(QWidget *parent) #endif pageWidget->addPage(cache, i18n("Cache"), Icons::self()->folderIcon, i18n("Cached Items")); setCaption(i18n("Configure")); - setMainWidget(pageWidget); setAttribute(Qt::WA_DeleteOnClose); - int h=sizeHint().height(); - setMinimumHeight(h); - setMinimumWidth(h*1.1); setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); } diff --git a/support/dialog.cpp b/support/dialog.cpp index 04ee5200b..9537bf42d 100644 --- a/support/dialog.cpp +++ b/support/dialog.cpp @@ -37,7 +37,7 @@ Dialog::Dialog(QWidget *parent, const QString &name, const QSize &defSize) , buttonTypes(0) , mw(0) , buttonBox(0) - , managedAccels(false) + , shown(false) #endif { if (!name.isEmpty()) { @@ -345,12 +345,19 @@ QAbstractButton *Dialog::getButton(ButtonCode button) void Dialog::showEvent(QShowEvent *e) { - if (!managedAccels) { + if (!shown) { + shown=true; AcceleratorManager::manage(this); - managedAccels=true; - } - if (defButton) { - setDefaultButton((ButtonCode)defButton); + if (defButton) { + setDefaultButton((ButtonCode)defButton); + } + if (buttonBox && mw) { + QSize mwSize=mw->minimumSize(); + if (mwSize.width()>0 && mwSize.height()>0) { + setMinimumHeight(qMax(minimumHeight(), buttonBox->height()+layout()->spacing()+mwSize.height()+(2*layout()->margin()))); + setMinimumWidth(qMax(minimumWidth(), mwSize.width()+(2*layout()->margin()))); + } + } } QDialog::showEvent(e); } diff --git a/support/dialog.h b/support/dialog.h index fe108e67f..02d528e53 100644 --- a/support/dialog.h +++ b/support/dialog.h @@ -168,7 +168,7 @@ private: QDialogButtonBox *buttonBox; QMap userButtons; QSize cfgSize; - bool managedAccels; + bool shown; }; Q_DECLARE_OPERATORS_FOR_FLAGS(Dialog::ButtonCodes) diff --git a/support/pagewidget.cpp b/support/pagewidget.cpp index 1ad488ec7..5e71c0e0a 100644 --- a/support/pagewidget.cpp +++ b/support/pagewidget.cpp @@ -24,6 +24,7 @@ #include "pagewidget.h" #include "icon.h" #include "gtkstyle.h" +#include "dialog.h" #include #include #include @@ -247,7 +248,6 @@ PageWidgetItem::PageWidgetItem(QWidget *p, const QString &header, const Icon &ic layout->addWidget(cfg); layout->setMargin(0); cfg->setParent(this); - cfg->adjustSize(); adjustSize(); } @@ -283,15 +283,12 @@ PageWidgetItem * PageWidget::addPage(QWidget *widget, const QString &name, const int rows = list->model()->rowCount(); int width = 0; - int height = 0; for (int i = 0; i < rows; ++i) { QSize rowSize=list->sizeHintForIndex(list->model()->index(i, 0)); width = qMax(width, rowSize.width()); - height += rowSize.height(); } width+=25; list->setFixedWidth(width); - list->setMinimumHeight(height); QSize stackSize = stack->size(); for (int i = 0; i < stack->count(); ++i) { @@ -300,12 +297,9 @@ PageWidgetItem * PageWidget::addPage(QWidget *widget, const QString &name, const stackSize = stackSize.expandedTo(widget->minimumSizeHint()); } } - stack->setMinimumSize(stackSize); + setMinimumHeight(qMax(minimumHeight(), stackSize.height())); + setMinimumWidth(qMax(minimumWidth(), stackSize.width()+width+layout()->spacing())); - QSize sz=size(); - sz=sz.expandedTo(stackSize); - sz=sz.expandedTo(QSize(width, height)); - setMinimumSize(sz); list->setCurrentRow(0); stack->setCurrentIndex(0); pages.insert(listItem, page);