Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Evergreen:11.1:kernel-2.6.32
kdepim4
r879230.diff
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File r879230.diff of Package kdepim4
Subject: kalarm: UI fixes From: wstephenson@suse.de Bug: Patch-upstream: 879230 --- kalarm/dialogscroll.h (revision 879229) +++ kalarm/dialogscroll.h (revision 879230) @@ -45,6 +45,7 @@ class DialogScroll : public QScrollArea static void setSized() { mSized = true; } static bool sized() { return mSized; } private: + static QSize maxMinimumSizeHint(); static QList<DialogScroll<T>*> mTabs; static int mMinHeight; static int mHeightReduction; @@ -82,28 +83,30 @@ DialogScroll<T>::~DialogScroll() mTabs.removeAll(this); } +/****************************************************************************** +* Return the minimum size for the tab, adjusted if necessary to a height that +* fits the screen. +* In order to make the QStackedWidget containing the tabs take the correct +* size, the value returned is actually the minimum size of the largest tab. +* Otherwise, only the currently visible tab would be taken into account with +* the result that the dialog would initially be displayed too small. +*/ template <class T> QSize DialogScroll<T>::minimumSizeHint() const { - if (!widget()) - return QSize(); - QSize s = widget()->minimumSizeHint(); + QSize s = maxMinimumSizeHint(); if (mMinHeight > 0 && mMinHeight < s.height()) return QSize(s.width() + style()->pixelMetric(QStyle::PM_ScrollBarExtent), mMinHeight); return s; } /****************************************************************************** -* Return the minimum size for the dialog. -* If the minimum size would be too high to fit the desktop, the tab contents -* are made scrollable. +* Return the maximum minimum size for any instance. */ template <class T> -QSize DialogScroll<T>::initMinimumHeight(T* dlg) +QSize DialogScroll<T>::maxMinimumSizeHint() { - if (mSized) - return QSize(); - int maxHeight = 0; + QSize sz; for (int i = 0, end = mTabs.count(); i < end; ++i) { if (!mTabs[i]->widget()) @@ -111,9 +114,25 @@ QSize DialogScroll<T>::initMinimumHeight QSize s = mTabs[i]->widget()->minimumSizeHint(); if (!s.isValid()) return QSize(); - if (s.height() > maxHeight) - maxHeight = s.height(); + sz = sz.expandedTo(s); } + return sz; +} + +/****************************************************************************** +* Return the minimum size for the dialog. +* If the minimum size would be too high to fit the desktop, the tab contents +* are made scrollable. +*/ +template <class T> +QSize DialogScroll<T>::initMinimumHeight(T* dlg) +{ + if (mSized) + return QSize(); + QSize s = maxMinimumSizeHint(); + if (s.isEmpty()) + return QSize(); + int maxHeight = s.height(); int decoration = dlg->frameGeometry().height() - dlg->geometry().height(); if (!decoration) { @@ -125,12 +144,13 @@ QSize DialogScroll<T>::initMinimumHeight // There is no stored size, or the deferral group is visible. // Allow the tab contents to be scrolled vertically if that is necessary // to avoid the dialog exceeding the screen height. - QSize s = dlg->KDialog::minimumSizeHint(); + s = dlg->KDialog::minimumSizeHint(); int y = s.height() + decoration - desk; if (y > 0) { mHeightReduction = y; mMinHeight = maxHeight - y; + kDebug() << "Scrolling: min height=" << mMinHeight << ", reduction=" << mHeightReduction; if (mMinHeight > 0) { for (int i = 0, end = mTabs.count(); i < end; ++i) --- kalarm/prefdlg.h (revision 879229) +++ kalarm/prefdlg.h (revision 879230) @@ -58,7 +58,8 @@ class KAlarmPrefDlg : public KPageDialog KPageWidgetItem* mFontColourPageItem; protected: - virtual void resizeEvent(QResizeEvent*); + virtual void resizeEvent(QResizeEvent*); + virtual void showEvent(QShowEvent*); protected slots: virtual void slotOk(); @@ -72,6 +73,7 @@ class KAlarmPrefDlg : public KPageDialog void restore(bool defaults); static KAlarmPrefDlg* mInstance; + bool mShown; // dialog has already been shown bool mValid; }; --- kalarm/prefdlg.cpp (revision 879229) +++ kalarm/prefdlg.cpp (revision 879230) @@ -138,7 +138,8 @@ void KAlarmPrefDlg::display() } KAlarmPrefDlg::KAlarmPrefDlg() - : KPageDialog() + : KPageDialog(), + mShown(false) { setAttribute(Qt::WA_DeleteOnClose); setObjectName("PrefDlg"); // used by LikeBack @@ -303,6 +304,21 @@ QSize KAlarmPrefDlg::minimumSizeHint() c } /****************************************************************************** +* Called when the dialog is displayed. +* The first time through, sets the tabs to be scrollable if the dialog is too +* high to fit the screen. +*/ +void KAlarmPrefDlg::showEvent(QShowEvent* e) +{ + KPageDialog::showEvent(e); + if (!mShown) + { + DialogScroll<KAlarmPrefDlg>::initMinimumHeight(this); + mShown = true; + } +} + +/****************************************************************************** * Called when the dialog's size has changed. * Records the new size in the config file. */ Index: kalarm/dialogscroll.h =================================================================== Index: kalarm/prefdlg.h =================================================================== Index: kalarm/prefdlg.cpp ===================================================================
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor