diff options
author | Francois Andriot <francois.andriot@free.fr> | 2013-05-09 19:03:47 +0200 |
---|---|---|
committer | Slávek Banko <slavek.banko@axis.cz> | 2013-05-09 19:03:47 +0200 |
commit | 8e144348bbcc8b259094e20a62b3b7b9becd6178 (patch) | |
tree | 77595faefb2624d5b877def1033ab47b9e9e57c6 /kicker | |
parent | 3e9cea48cf6f6a6c3955901475ff320d0169ffee (diff) | |
download | tdebase-8e144348bbcc8b259094e20a62b3b7b9becd6178.tar.gz tdebase-8e144348bbcc8b259094e20a62b3b7b9becd6178.zip |
Kickoff menu: Fix menu size at startup and tabbar size calculation
Diffstat (limited to 'kicker')
-rw-r--r-- | kicker/kicker/ui/k_new_mnu.cpp | 2 | ||||
-rw-r--r-- | kicker/kicker/ui/kickoff_bar.cpp | 64 | ||||
-rw-r--r-- | kicker/kicker/ui/kickoff_bar.h | 1 |
3 files changed, 53 insertions, 14 deletions
diff --git a/kicker/kicker/ui/k_new_mnu.cpp b/kicker/kicker/ui/k_new_mnu.cpp index 3ebda2d56..e2ecf40cb 100644 --- a/kicker/kicker/ui/k_new_mnu.cpp +++ b/kicker/kicker/ui/k_new_mnu.cpp @@ -3327,7 +3327,7 @@ TQSize KMenu::sizeHint() const TQSize KMenu::minimumSizeHint() const { TQSize minsize; - minsize.setWidth( minsize.width() + m_tabBar->sizeHint().width() ); + minsize.setWidth( minsize.width() + m_tabBar->minimumSizeHint().width() ); minsize.setWidth( QMAX( minsize.width(), m_search->minimumSize().width() ) ); minsize.setWidth( QMAX( minsize.width(), diff --git a/kicker/kicker/ui/kickoff_bar.cpp b/kicker/kicker/ui/kickoff_bar.cpp index 0383c0144..994300c0d 100644 --- a/kicker/kicker/ui/kickoff_bar.cpp +++ b/kicker/kicker/ui/kickoff_bar.cpp @@ -128,39 +128,77 @@ TQSize KickoffTabBar::sizeHint() const return s; } -void KickoffTabBar::layoutTabs() +TQSize KickoffTabBar::minimumSizeHint() const { - TQTabBar::layoutTabs(); + TQSize s; TQFontMetrics fm = fontMetrics(); int fh = ((KickerSettings::kickoffTabBarFormat() != KickerSettings::IconOnly) ? fm.height() : 0) + 4; int hframe = style().pixelMetric( TQStyle::PM_TabBarTabHSpace, this ); int vframe = style().pixelMetric( TQStyle::PM_TabBarTabVSpace, this ); - int overlap = style().pixelMetric( TQStyle::PM_TabBarTabOverlap, this ); - TQSize s; - for (int t = 0; t < count(); ++t) - { + for (int t = 0; t < count(); ++t) { TQTab* tab = tabAt(t); - if (tab->iconSet()) + if (tab->iconSet()) { s = s.expandedTo(tab->iconSet()->pixmap(TQIconSet::Large, TQIconSet::Normal).size()); + } } - int x = 0; + // Every tab must have identical height and width. + // We check every tab minimum height and width and we keep the + // biggest one as reference. Smaller tabs will be expanded to match + // the same size. + int mw = 0; + int mh = 0; for (int t = 0; t < count(); ++t) { TQTab* tab = tabAt(TQApplication::reverseLayout() ? count() - t - 1 : t); + + // Checks tab minimum height int h = fh; - if (tab->iconSet()) + if (tab->iconSet()) { h += 4 + s.height() + 4; - TQRect r = tab->rect(); + } + h += ((KickerSettings::kickoffTabBarFormat() != KickerSettings::IconOnly) ? fm.height() : 0) + vframe; + // Checks tab minimum width (font) int fw = fm.size( TQt::SingleLine|TQt::ShowPrefix, tab->text() ).width(); + + // Checks tab minimum width (icon) int iw = 0; - if ( tab->iconSet() != 0 ) + if ( tab->iconSet()) { iw = tab->iconSet()->pixmap( TQIconSet::Large, TQIconSet::Normal ).width(); - int w = QMAX(iw, fw + 6 + 6 ) + hframe; - h += ((KickerSettings::kickoffTabBarFormat() != KickerSettings::IconOnly) ? fm.height() : 0) + vframe; + } + + // Final width for this tab + int w = QMAX(iw, fw) + hframe; + + mw = QMAX(mw, w); + mh = QMAX(mh, h); + } + + s.setWidth(mw * count()); + s.setHeight(mh); + return (s); +} + +void KickoffTabBar::layoutTabs() +{ + TQSize s; + TQSize st = minimumSizeHint(); + + TQTabBar::layoutTabs(); + int overlap = style().pixelMetric( TQStyle::PM_TabBarTabOverlap, this ); + + int x = 0; + int h = st.height(); + + for (int t = 0; t < count(); ++t) { + TQTab* tab = tabAt(TQApplication::reverseLayout() ? count() - t - 1 : t); + + int w = QMAX(st.width() / count(), parentWidget()->width() / count()); + + TQRect r = tab->rect(); tab->setRect(TQRect(TQPoint(x, 0), style().tqsizeFromContents(TQStyle::CT_TabBarTab, this, TQSize(w, h), TQStyleOption(tab)))); x += tab->rect().width() - overlap; diff --git a/kicker/kicker/ui/kickoff_bar.h b/kicker/kicker/ui/kickoff_bar.h index 2330ffe39..941f1144f 100644 --- a/kicker/kicker/ui/kickoff_bar.h +++ b/kicker/kicker/ui/kickoff_bar.h @@ -33,6 +33,7 @@ public: void deactivateTabs(bool b); virtual TQSize sizeHint() const; + virtual TQSize minimumSizeHint() const; protected: virtual void paint(TQPainter*, TQTab*, bool) const; |