Sorry, took a bit longer (I wasn't all happy about "when fix size", maybe
am still not)
The core problem is QTabWidget, which does not behave like other widgets on
a layout update (since it contains an unlayouted QStackedWidget which holds
the actual tabwidgets)
The attached patch seeks to avoid pointless judder and therefore
conditionally increases the size whenever updating widgets on a page, for
that page (imo better than aligning for all widgets, ie. when shrinking the
dialog and altering the relatively sparse smtp page, it should not update
to re-match the imap page etc.)
Errm... on the gerrit process:
how would this case be dealt (patch to a patch in review)?
Can I just push into your review (and more important: would you be pissed
if I did? ;-)
Should one open a competing patch instead?
Or is there any canonical collaboration process in gerrit?
Cheers,
Thomas
diff --git a/src/Gui/SettingsCachePage.ui b/src/Gui/SettingsCachePage.ui
index bbb921b..ce02746 100644
--- a/src/Gui/SettingsCachePage.ui
+++ b/src/Gui/SettingsCachePage.ui
@@ -9,6 +9,14 @@
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>230</width>
+ <height>176</height>
+ </rect>
+ </property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QGroupBox" name="offlineModeGroup">
diff --git a/src/Gui/SettingsDialog.cpp b/src/Gui/SettingsDialog.cpp
index 9fa5e07..2bd4391 100644
--- a/src/Gui/SettingsDialog.cpp
+++ b/src/Gui/SettingsDialog.cpp
@@ -37,8 +37,8 @@
#include <QVBoxLayout>
#include <QProcess>
#include <QPushButton>
-#include <QResizeEvent>
#include <QDebug>
+#include <QStackedWidget>
#include <QStandardItemModel>
#include <QToolTip>
#include <QMessageBox>
@@ -90,8 +90,7 @@ SettingsDialog::SettingsDialog(MainWindow *parent, Composer::SenderIdentitiesMod
addPage(new CachePage(this, *m_settings), tr("&Offline"));
addPage(new OutgoingPage(this, *m_settings), tr("&SMTP"));
#ifdef XTUPLE_CONNECT
- xtConnect = new XtConnectPage(this, *m_settings, imap);
- stack->addTab(xtConnect, tr("&xTuple"));
+ addPage(xtConnect = new XtConnectPage(this, *m_settings, imap), tr("&xTuple"));
#endif
buttons = new QDialogButtonBox(QDialogButtonBox::Save | QDialogButtonBox::Cancel, Qt::Horizontal, this);
@@ -102,6 +101,52 @@ SettingsDialog::SettingsDialog(MainWindow *parent, Composer::SenderIdentitiesMod
EMIT_LATER_NOARG(this, reloadPasswordsRequested);
}
+void SettingsDialog::adjustSizeToScrollAreas()
+{
+ QScrollArea *area = qobject_cast<QScrollArea*>(sender());
+ if (!(area && area->widget()))
+ return; // could assert just as well
+
+ // task #A: figure the "minimum" size for the tabwidget
+ QSize minSize;
+ // #A.1: search scrollareas and align their size to their content
+
+ // update size of the widget in the tabbed scrollarea
+ area->widget()->adjustSize();
+
+ // figure the size demand of this scroll area (content + margins)
+ int l,t,r,b;
+ area->getContentsMargins(&l,&r,&t,&b);
+ QSize sz(area->widget()->size() + QSize(l+r, t+b));
+
+ // TODO: clamp this to 640x480 or QDesktopWidget::availableGeometry() dependent?
+
+ // do not shrink (prevent nasty size jumps for no reason)
+ sz.setWidth(qMax(area->width(), sz.width()));
+ sz.setHeight(qMax(area->height(), sz.height()));
+
+ // expand minSize
+ minSize.setWidth(qMax(minSize.width(), sz.width()));
+ minSize.setHeight(qMax(minSize.height(), sz.height()));
+
+ // task #B: find the QStackedWidget inside the QTabWidget to determine its margins
+ Q_FOREACH(const QObject *o, stack->children()) {
+ if (const QStackedWidget *actualStack = qobject_cast<const QStackedWidget*>(o)) {
+ minSize.setWidth(minSize.width() + stack->width() - actualStack->width());
+ minSize.setHeight(minSize.height() + stack->height() - actualStack->height());
+ break;
+ }
+ }
+
+ // task #C: convince the dialog to the new size
+ // #C.1: arrest the tabwidget
+ stack->setMinimumSize(minSize);
+ // #C.2: force a relayout of the dialog (do NOT use "adjustSize", which may still shrink)
+ layout()->activate();
+ // #C.3: release the tabwidget minimum size
+ stack->setMinimumSize(QSize(0, 0));
+}
+
Plugins::PluginManager *SettingsDialog::pluginManager()
{
return mainWindow->pluginManager();
@@ -183,6 +228,8 @@ void SettingsDialog::reject()
void SettingsDialog::addPage(ConfigurationWidgetInterface *page, const QString &title)
{
stack->addTab(page->asWidget(), title);
+ connect(page->asWidget(), SIGNAL(widgetsUpdated()), SLOT(adjustSizeToScrollAreas()));
+ QMetaObject::invokeMethod(page->asWidget(), "updateWidgets", Qt::QueuedConnection);
pages << page;
}
@@ -263,7 +310,7 @@ GeneralPage::GeneralPage(SettingsDialog *parent, QSettings &s, Composer::SenderI
connect(deleteButton, SIGNAL(clicked()), SLOT(deleteButtonClicked()));
connect(passwordBox, SIGNAL(currentIndexChanged(int)), SLOT(passwordPluginChanged()));
- connect(this, SIGNAL(reloadPasswords()), m_parent, SIGNAL(reloadPasswordsRequested()));\
+ connect(this, SIGNAL(reloadPasswords()), m_parent, SIGNAL(reloadPasswordsRequested()));
updateWidgets();
}
@@ -291,6 +338,8 @@ void GeneralPage::updateWidgets()
moveDownButton->setEnabled(downEnabled);
identityTabelView->resizeColumnToContents(Composer::SenderIdentitiesModel::COLUMN_NAME);
+
+ Q_EMIT widgetsUpdated();
}
void GeneralPage::moveIdentityUp()
@@ -507,13 +556,6 @@ void ImapPage::slotSetPassword()
imapPass->setText(m_pwWatcher->password());
}
-void ImapPage::resizeEvent(QResizeEvent *event)
-{
- QScrollArea::resizeEvent(event);
- scrollAreaWidgetContents->setMinimumSize(event->size());
- scrollAreaWidgetContents->adjustSize();
-}
-
void ImapPage::changePort()
{
imapPort->setText(QString::number(encryption->currentIndex() == SSL ? Common::PORT_IMAPS : Common::PORT_IMAP));
@@ -578,6 +620,8 @@ void ImapPage::updateWidgets()
imapPass->setEnabled(!m_pwWatcher->isWaitingForPlugin());
imapPassLabel->setEnabled(!m_pwWatcher->isWaitingForPlugin());
+
+ Q_EMIT widgetsUpdated();
}
void ImapPage::save(QSettings &s)
@@ -691,21 +735,16 @@ CachePage::CachePage(QWidget *parent, QSettings &s): QScrollArea(parent), Ui_Cac
offlineNumberOfDays->setValue(s.value(SettingsNames::cacheOfflineNumberDaysKey, QVariant(30)).toInt());
updateWidgets();
+
connect(offlineNope, SIGNAL(clicked()), this, SLOT(updateWidgets()));
connect(offlineXDays, SIGNAL(clicked()), this, SLOT(updateWidgets()));
connect(offlineEverything, SIGNAL(clicked()), this, SLOT(updateWidgets()));
}
-void CachePage::resizeEvent(QResizeEvent *event)
-{
- QScrollArea::resizeEvent(event);
- scrollAreaWidgetContents->setMinimumSize(event->size());
- scrollAreaWidgetContents->adjustSize();
-}
-
void CachePage::updateWidgets()
{
offlineNumberOfDays->setEnabled(offlineXDays->isChecked());
+ Q_EMIT widgetsUpdated();
}
void CachePage::save(QSettings &s)
@@ -790,13 +829,6 @@ void OutgoingPage::slotSetPassword()
smtpPass->setText(m_pwWatcher->password());
}
-void OutgoingPage::resizeEvent(QResizeEvent *event)
-{
- QScrollArea::resizeEvent(event);
- scrollAreaWidgetContents->setMinimumSize(event->size());
- scrollAreaWidgetContents->adjustSize();
-}
-
void OutgoingPage::slotSetSubmissionMethod()
{
switch (method->currentIndex()) {
@@ -955,6 +987,8 @@ void OutgoingPage::updateWidgets()
lay->labelForField(saveFolderName)->setVisible(saveToImap->isChecked());
saveFolderName->setText(m_smtpAccountSettings->sentMailboxName());
+ Q_EMIT widgetsUpdated();
+
}
void OutgoingPage::save(QSettings &s)
diff --git a/src/Gui/SettingsDialog.h b/src/Gui/SettingsDialog.h
index a3c7754..4af7c73 100644
--- a/src/Gui/SettingsDialog.h
+++ b/src/Gui/SettingsDialog.h
@@ -107,6 +107,7 @@ private:
signals:
void saved();
void reloadPasswords();
+ void widgetsUpdated();
};
class EditIdentity : public QDialog, Ui_EditIdentity
@@ -130,6 +131,7 @@ private:
signals:
void saved();
+ void widgetsUpdated();
};
@@ -143,9 +145,6 @@ public:
virtual bool checkValidity() const;
virtual bool passwordFailures(QString &message) const;
-protected:
- virtual void resizeEvent(QResizeEvent *event);
-
private slots:
void slotSetSubmissionMethod();
void updateWidgets();
@@ -168,6 +167,7 @@ private:
signals:
void saved();
+ void widgetsUpdated();
};
class ImapPage : public QScrollArea, Ui_ImapPage, public ConfigurationWidgetInterface
@@ -183,9 +183,6 @@ public:
bool hasPassword() const;
#endif
-protected:
- virtual void resizeEvent(QResizeEvent *event);
-
private:
enum { NETWORK, PROCESS };
enum Encryption { NONE, STARTTLS, SSL };
@@ -206,6 +203,7 @@ private:
signals:
void saved();
+ void widgetsUpdated();
};
class CachePage : public QScrollArea, Ui_CachePage, public ConfigurationWidgetInterface
@@ -218,9 +216,6 @@ public:
virtual bool checkValidity() const;
virtual bool passwordFailures(QString &message) const;
-protected:
- virtual void resizeEvent(QResizeEvent *event);
-
private:
QCheckBox *startOffline;
@@ -233,6 +228,7 @@ private:
signals:
void saved();
+ void widgetsUpdated();
};
#ifdef XTUPLE_CONNECT
@@ -262,6 +258,7 @@ private:
XtConnectPage &operator=(const XtConnectPage &); // don't implement
signals:
void saved();
+ void widgetsUpdated();
};
#endif
@@ -284,6 +281,7 @@ public slots:
void accept();
void reject();
private slots:
+ void adjustSizeToScrollAreas();
void slotAccept();
private:
MainWindow *mainWindow;
diff --git a/src/Gui/SettingsGeneralPage.ui b/src/Gui/SettingsGeneralPage.ui
index 90d80ac..852bd99 100644
--- a/src/Gui/SettingsGeneralPage.ui
+++ b/src/Gui/SettingsGeneralPage.ui
@@ -2,20 +2,6 @@
<ui version="4.0">
<class>GeneralPage</class>
<widget class="QScrollArea" name="GeneralPage">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>456</width>
- <height>422</height>
- </rect>
- </property>
- <property name="minimumSize">
- <size>
- <width>420</width>
- <height>400</height>
- </size>
- </property>
<property name="windowTitle">
<string>ScrollArea</string>
</property>
@@ -30,8 +16,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>450</width>
- <height>416</height>
+ <width>389</width>
+ <height>419</height>
</rect>
</property>
<property name="layoutDirection">
@@ -210,20 +196,20 @@
<property name="specialValueText">
<string extracomment="To indicate that there's no delay">immediately</string>
</property>
- <property name="prefix">
- <string extracomment="The action will happen *after* user-provided timeout in seconds">after </string>
- </property>
<property name="suffix">
<string extracomment="A suffix "seconds" inside a QDoubleSpinBox for configuring a time delay. Please keep this short so that the window is reasonably narrow."> s</string>
</property>
+ <property name="prefix">
+ <string extracomment="The action will happen *after* user-provided timeout in seconds">after </string>
+ </property>
<property name="minimum">
- <double>0</double>
+ <number>0</number>
</property>
<property name="maximum">
- <double>60</double>
+ <number>60</number>
</property>
<property name="value">
- <double>0</double>
+ <number>0</number>
</property>
</widget>
</item>
diff --git a/src/Gui/SettingsImapPage.ui b/src/Gui/SettingsImapPage.ui
index c02f45b..e4c12a6 100644
--- a/src/Gui/SettingsImapPage.ui
+++ b/src/Gui/SettingsImapPage.ui
@@ -2,14 +2,6 @@
<ui version="4.0">
<class>ImapPage</class>
<widget class="QScrollArea" name="ImapPage">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>322</width>
- <height>360</height>
- </rect>
- </property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
@@ -21,8 +13,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>301</width>
- <height>454</height>
+ <width>237</width>
+ <height>477</height>
</rect>
</property>
<layout class="QFormLayout" name="formLayout">
@@ -329,11 +321,11 @@ p, li { white-space: pre-wrap; }
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Maximum">
<horstretch>0</horstretch>
- <verstretch>0</verstretch>
+ <verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
- <string>How often to renew the IDLE session.
+ <string>How often to renew the IDLE session.
This is useful to prevent timeouts due to broken or overly aggressive network middleboxes,
NAT gateways and other nasty annoyances.
The default value is 29 minutes.</string>
diff --git a/src/Gui/SettingsOutgoingPage.ui b/src/Gui/SettingsOutgoingPage.ui
index 9bda9f0..abc8b06 100644
--- a/src/Gui/SettingsOutgoingPage.ui
+++ b/src/Gui/SettingsOutgoingPage.ui
@@ -2,14 +2,6 @@
<ui version="4.0">
<class>OutgoingPage</class>
<widget class="QScrollArea" name="OutgoingPage">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>281</width>
- <height>319</height>
- </rect>
- </property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
@@ -21,8 +13,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>267</width>
- <height>403</height>
+ <width>220</width>
+ <height>347</height>
</rect>
</property>
<layout class="QFormLayout" name="formLayout">