Make Qt pref dialog shrinkable
This commit is contained in:
@@ -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
|
||||
-----
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -168,7 +168,7 @@ private:
|
||||
QDialogButtonBox *buttonBox;
|
||||
QMap<ButtonCode, QAbstractButton *> userButtons;
|
||||
QSize cfgSize;
|
||||
bool managedAccels;
|
||||
bool shown;
|
||||
};
|
||||
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS(Dialog::ButtonCodes)
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "pagewidget.h"
|
||||
#include "icon.h"
|
||||
#include "gtkstyle.h"
|
||||
#include "dialog.h"
|
||||
#include <QListWidget>
|
||||
#include <QStackedWidget>
|
||||
#include <QBoxLayout>
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user