Skip to content
This repository has been archived by the owner on Mar 3, 2022. It is now read-only.

Commit

Permalink
Resize config dialog when page changes
Browse files Browse the repository at this point in the history
  • Loading branch information
CDrummond authored and craig.p.drummond committed Oct 8, 2014
1 parent 55e6669 commit ecc13bd
Show file tree
Hide file tree
Showing 12 changed files with 53 additions and 10 deletions.
4 changes: 4 additions & 0 deletions gui/filesettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ FileSettings::FileSettings(QWidget *p)
: QWidget(p)
{
setupUi(this);

#ifdef Q_OS_MAC
expandingSpacer->changeSize(0, 0, QSizePolicy::Fixed, QSizePolicy::Fixed);
#endif
}

void FileSettings::load()
Expand Down
4 changes: 2 additions & 2 deletions gui/filesettings.ui
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
</widget>
</item>
<item>
<spacer name="verticalSpacer_2">
<spacer name="expandingSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
Expand All @@ -69,7 +69,7 @@
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>8</height>
<height>0</height>
</size>
</property>
</spacer>
Expand Down
4 changes: 4 additions & 0 deletions gui/playbacksettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ PlaybackSettings::PlaybackSettings(QWidget *p)
#endif
outputsView->setVisible(outputsView->count()>1);
outputsViewLabel->setVisible(outputsView->count()>1);

#ifdef Q_OS_MAC
expandingSpacer->changeSize(0, 0, QSizePolicy::Fixed, QSizePolicy::Fixed);
#endif
}

void PlaybackSettings::load()
Expand Down
4 changes: 2 additions & 2 deletions gui/playbacksettings.ui
Original file line number Diff line number Diff line change
Expand Up @@ -207,14 +207,14 @@
</widget>
</item>
<item>
<spacer name="paddingSpacer">
<spacer name="expandingSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>2</height>
<height>0</height>
</size>
</property>
</spacer>
Expand Down
4 changes: 4 additions & 0 deletions gui/serversettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ ServerSettings::ServerSettings(QWidget *p)
REMOVE(streamUrl)
REMOVE(streamUrlNoteLabel)
#endif

#ifdef Q_OS_MAC
expandingSpacer->changeSize(0, 0, QSizePolicy::Fixed, QSizePolicy::Fixed);
#endif
}

void ServerSettings::load()
Expand Down
4 changes: 2 additions & 2 deletions gui/serversettings.ui
Original file line number Diff line number Diff line change
Expand Up @@ -270,14 +270,14 @@
</widget>
</item>
<item row="4" column="2">
<spacer name="verticalSpacer_6">
<spacer name="expandingSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>363</height>
<height>0</height>
</size>
</property>
</spacer>
Expand Down
4 changes: 4 additions & 0 deletions http/httpserversettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ HttpServerSettings::HttpServerSettings(QWidget *p)
{
setupUi(this);
initInterfaces(httpInterface);

#ifdef Q_OS_MAC
expandingSpacer->changeSize(0, 0, QSizePolicy::Fixed, QSizePolicy::Fixed);
#endif
}

void HttpServerSettings::load()
Expand Down
4 changes: 2 additions & 2 deletions http/httpserversettings.ui
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<spacer name="expandingSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>13</height>
<height>0</height>
</size>
</property>
</spacer>
Expand Down
4 changes: 4 additions & 0 deletions scrobbling/scrobblingsettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ ScrobblingSettings::ScrobblingSettings(QWidget *parent)
"then you will need to have this already started and running. "
"Cantata can only 'Love' tracks via this, and cannot enable/disable scrobbling.", firstMpdClient));
}

#ifdef Q_OS_MAC
expandingSpacer->changeSize(0, 0, QSizePolicy::Fixed, QSizePolicy::Fixed);
#endif
}

void ScrobblingSettings::load()
Expand Down
4 changes: 2 additions & 2 deletions scrobbling/scrobblingsettings.ui
Original file line number Diff line number Diff line change
Expand Up @@ -143,14 +143,14 @@
<widget class="NoteLabel" name="noteLabel"/>
</item>
<item row="9" column="0">
<spacer name="verticalSpacer">
<spacer name="expandingSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>6</height>
<height>0</height>
</size>
</property>
</spacer>
Expand Down
16 changes: 16 additions & 0 deletions support/configdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
#include <QTextEdit>
#include <QAbstractItemView>
#include <QTimer>
#include <QPropertyAnimation>
#include "icon.h"
#include "osxstyle.h"
#else
Expand Down Expand Up @@ -113,6 +114,7 @@ ConfigDialog::ConfigDialog(QWidget *parent, const QString &name, const QSize &de
#ifdef __APPLE__
: QMainWindow(parent)
, shown(false)
, resizeAnim(0)
#else
: Dialog(parent, name, defSize)
#endif
Expand Down Expand Up @@ -202,6 +204,20 @@ bool ConfigDialog::setCurrentPage(const QString &id)
setCaption(it.value().item->text());
it.value().item->setChecked(true);
}
int newH=it.value().widget->sizeHint().height()+toolBar->height()+buttonBox->height()+layout()->spacing()+(2*layout()->margin());
if (isVisible()) {
if (newH!=height()) {
if (!resizeAnim) {
resizeAnim=new QPropertyAnimation(this, "h");
resizeAnim->setDuration(250);
}
resizeAnim->setStartValue(height());
resizeAnim->setEndValue(newH);
resizeAnim->start();
}
} else {
setFixedHeight(newH);
}
#else
pageWidget->setCurrentPage(pages[id]);
#endif
Expand Down
7 changes: 7 additions & 0 deletions support/configdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class QToolButton;
class QButtonGroup;
class QStackedWidget;
class QDialogButtonBox;
class QPropertyAnimation;
#else
class PageWidget;
class PageWidgetItem;
Expand All @@ -50,6 +51,9 @@ class ConfigDialog : public
#endif
{
Q_OBJECT
#ifdef __APPLE__
Q_PROPERTY(int h READ getH WRITE setH)
#endif

public:
ConfigDialog(QWidget *parent, const QString &name=QString(), const QSize &defSize=QSize());
Expand All @@ -63,6 +67,8 @@ class ConfigDialog : public
void setCaption(const QString &c) { setWindowTitle(c); }
void accept();
void reject();
int getH() const { return height(); }
void setH(int h) { setFixedHeight(h); }
#endif

virtual void save()=0;
Expand Down Expand Up @@ -98,6 +104,7 @@ private Q_SLOTS:
QDialogButtonBox *buttonBox;
QMap<QString, Page> pages;
bool shown;
QPropertyAnimation *resizeAnim;
#else
PageWidget *pageWidget;
QMap<QString, PageWidgetItem *> pages;
Expand Down

0 comments on commit ecc13bd

Please sign in to comment.