Diffstat (limited to 'core/launcher/launchertab.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/launcher/launchertab.cpp | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/core/launcher/launchertab.cpp b/core/launcher/launchertab.cpp index 710f259..72ebf59 100644 --- a/core/launcher/launchertab.cpp +++ b/core/launcher/launchertab.cpp | |||
@@ -88,77 +88,77 @@ void LauncherTabBar::layoutTabs() | |||
88 | QListIterator< LauncherTab > it( items ); | 88 | QListIterator< LauncherTab > it( items ); |
89 | int required = 0; | 89 | int required = 0; |
90 | int eventabwidth = (width()-1)/count(); | 90 | int eventabwidth = (width()-1)/count(); |
91 | enum Mode { HideBackText, Pack, Even } mode=Even; | 91 | enum Mode { HideBackText, Pack, Even } mode=Even; |
92 | for (it.toFirst(); it.current(); ++it ) { | 92 | for (it.toFirst(); it.current(); ++it ) { |
93 | t = it.current(); | 93 | t = it.current(); |
94 | if ( !t ) | 94 | if ( !t ) |
95 | continue; | 95 | continue; |
96 | int iw = fm.width( t->text() ) + hframe - overlap; | 96 | int iw = fm.width( t->text() ) + hframe - overlap; |
97 | if ( t != current ) { | 97 | if ( t != current ) { |
98 | available -= hiddenTabWidth + hframe - overlap; | 98 | available -= hiddenTabWidth + hframe - overlap; |
99 | if ( t->iconSet() != 0 ) | 99 | if ( t->iconSet() != 0 ) |
100 | available -= t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); | 100 | available -= t->iconSet()->pixmap().width(); |
101 | } | 101 | } |
102 | if ( t->iconSet() != 0 ) | 102 | if ( t->iconSet() != 0 ) |
103 | iw += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); | 103 | iw += t->iconSet()->pixmap().width(); |
104 | required += iw; | 104 | required += iw; |
105 | // As space gets tight, packed looks better than even. "10" must be at least 0. | 105 | // As space gets tight, packed looks better than even. "10" must be at least 0. |
106 | if ( iw >= eventabwidth-10 ) | 106 | if ( iw >= eventabwidth-10 ) |
107 | mode = Pack; | 107 | mode = Pack; |
108 | } | 108 | } |
109 | if ( mode == Pack && required > width()-1 ) | 109 | if ( mode == Pack && required > width()-1 ) |
110 | mode = HideBackText; | 110 | mode = HideBackText; |
111 | for ( it.toFirst(); it.current(); ++it ) { | 111 | for ( it.toFirst(); it.current(); ++it ) { |
112 | t = it.current(); | 112 | t = it.current(); |
113 | if ( !t ) | 113 | if ( !t ) |
114 | continue; | 114 | continue; |
115 | if ( mode != HideBackText ) { | 115 | if ( mode != HideBackText ) { |
116 | int w = fm.width( t->text() ); | 116 | int w = fm.width( t->text() ); |
117 | int ih = 0; | 117 | int ih = 0; |
118 | if ( t->iconSet() != 0 ) { | 118 | if ( t->iconSet() != 0 ) { |
119 | w += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); | 119 | w += t->iconSet()->pixmap().width(); |
120 | ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height(); | 120 | ih = t->iconSet()->pixmap().height(); |
121 | } | 121 | } |
122 | int h = QMAX( fm.height(), ih ); | 122 | int h = QMAX( fm.height(), ih ); |
123 | h = QMAX( h, QApplication::globalStrut().height() ); | 123 | h = QMAX( h, QApplication::globalStrut().height() ); |
124 | 124 | ||
125 | h += vframe; | 125 | h += vframe; |
126 | w += hframe; | 126 | w += hframe; |
127 | 127 | ||
128 | QRect totr(x, 0, | 128 | QRect totr(x, 0, |
129 | mode == Even ? eventabwidth : w * (width()-1)/required, h); | 129 | mode == Even ? eventabwidth : w * (width()-1)/required, h); |
130 | t->setRect(totr); | 130 | t->setRect(totr); |
131 | x += totr.width() - overlap; | 131 | x += totr.width() - overlap; |
132 | r = r.unite(totr); | 132 | r = r.unite(totr); |
133 | } else if ( t != current ) { | 133 | } else if ( t != current ) { |
134 | int w = hiddenTabWidth; | 134 | int w = hiddenTabWidth; |
135 | int ih = 0; | 135 | int ih = 0; |
136 | if ( t->iconSet() != 0 ) { | 136 | if ( t->iconSet() != 0 ) { |
137 | w += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); | 137 | w += t->iconSet()->pixmap().width(); |
138 | ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height(); | 138 | ih = t->iconSet()->pixmap().height(); |
139 | } | 139 | } |
140 | int h = QMAX( fm.height(), ih ); | 140 | int h = QMAX( fm.height(), ih ); |
141 | h = QMAX( h, QApplication::globalStrut().height() ); | 141 | h = QMAX( h, QApplication::globalStrut().height() ); |
142 | 142 | ||
143 | h += vframe; | 143 | h += vframe; |
144 | w += hframe; | 144 | w += hframe; |
145 | 145 | ||
146 | t->setRect( QRect(x, 0, w, h) ); | 146 | t->setRect( QRect(x, 0, w, h) ); |
147 | x += t->rect().width() - overlap; | 147 | x += t->rect().width() - overlap; |
148 | r = r.unite( t->rect() ); | 148 | r = r.unite( t->rect() ); |
149 | } else { | 149 | } else { |
150 | int ih = 0; | 150 | int ih = 0; |
151 | if ( t->iconSet() != 0 ) { | 151 | if ( t->iconSet() != 0 ) { |
152 | ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height(); | 152 | ih = t->iconSet()->pixmap().height(); |
153 | } | 153 | } |
154 | int h = QMAX( fm.height(), ih ); | 154 | int h = QMAX( fm.height(), ih ); |
155 | h = QMAX( h, QApplication::globalStrut().height() ); | 155 | h = QMAX( h, QApplication::globalStrut().height() ); |
156 | 156 | ||
157 | h += vframe; | 157 | h += vframe; |
158 | 158 | ||
159 | t->setRect( QRect(x, 0, available, h) ); | 159 | t->setRect( QRect(x, 0, available, h) ); |
160 | x += t->rect().width() - overlap; | 160 | x += t->rect().width() - overlap; |
161 | r = r.unite( t->rect() ); | 161 | r = r.unite( t->rect() ); |
162 | } | 162 | } |
163 | } | 163 | } |
164 | 164 | ||
@@ -211,26 +211,26 @@ void LauncherTabBar::paint( QPainter * p, QTab * t, bool selected ) const | |||
211 | p->setFont( f ); | 211 | p->setFont( f ); |
212 | 212 | ||
213 | if ( ct->fgColor.isValid() ) { | 213 | if ( ct->fgColor.isValid() ) { |
214 | pal.setColor( QPalette::Active, QColorGroup::Foreground, ct->fgColor ); | 214 | pal.setColor( QPalette::Active, QColorGroup::Foreground, ct->fgColor ); |
215 | pal.setColor( QPalette::Inactive, QColorGroup::Foreground, ct->fgColor ); | 215 | pal.setColor( QPalette::Inactive, QColorGroup::Foreground, ct->fgColor ); |
216 | that->setUpdatesEnabled( FALSE ); | 216 | that->setUpdatesEnabled( FALSE ); |
217 | that->setPalette( pal ); | 217 | that->setPalette( pal ); |
218 | setPal = TRUE; | 218 | setPal = TRUE; |
219 | } | 219 | } |
220 | int iw = 0; | 220 | int iw = 0; |
221 | int ih = 0; | 221 | int ih = 0; |
222 | if ( t->iconSet() != 0 ) { | 222 | if ( t->iconSet() != 0 ) { |
223 | iw = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width() + 2; | 223 | iw = t->iconSet()->pixmap().width() + 2; |
224 | ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height(); | 224 | ih = t->iconSet()->pixmap().height(); |
225 | } | 225 | } |
226 | int w = iw + p->fontMetrics().width( t->text() ) + 4; | 226 | int w = iw + p->fontMetrics().width( t->text() ) + 4; |
227 | int h = QMAX(p->fontMetrics().height() + 4, ih ); | 227 | int h = QMAX(p->fontMetrics().height() + 4, ih ); |
228 | paintLabel( p, QRect( r.left() + (r.width()-w)/2 - 3, | 228 | paintLabel( p, QRect( r.left() + (r.width()-w)/2 - 3, |
229 | r.top() + (r.height()-h)/2, w, h ), t, | 229 | r.top() + (r.height()-h)/2, w, h ), t, |
230 | #if QT_VERSION >= 0x030000 | 230 | #if QT_VERSION >= 0x030000 |
231 | t->identifier() == keyboardFocusTab() | 231 | t->identifier() == keyboardFocusTab() |
232 | #else | 232 | #else |
233 | t->identitifer() == keyboardFocusTab() | 233 | t->identitifer() == keyboardFocusTab() |
234 | #endif | 234 | #endif |
235 | ); | 235 | ); |
236 | if ( setPal ) { | 236 | if ( setPal ) { |
@@ -242,25 +242,29 @@ void LauncherTabBar::paint( QPainter * p, QTab * t, bool selected ) const | |||
242 | void LauncherTabBar::paintLabel( QPainter* p, const QRect&, | 242 | void LauncherTabBar::paintLabel( QPainter* p, const QRect&, |
243 | QTab* t, bool has_focus ) const | 243 | QTab* t, bool has_focus ) const |
244 | { | 244 | { |
245 | QRect r = t->rect(); | 245 | QRect r = t->rect(); |
246 | // if ( t->id != currentTab() ) | 246 | // if ( t->id != currentTab() ) |
247 | //r.moveBy( 1, 1 ); | 247 | //r.moveBy( 1, 1 ); |
248 | // | 248 | // |
249 | if ( t->iconSet() ) { | 249 | if ( t->iconSet() ) { |
250 | // the tab has an iconset, draw it in the right mode | 250 | // the tab has an iconset, draw it in the right mode |
251 | QIconSet::Mode mode = (t->isEnabled() && isEnabled()) ? QIconSet::Normal : QIconSet::Disabled; | 251 | QIconSet::Mode mode = (t->isEnabled() && isEnabled()) ? QIconSet::Normal : QIconSet::Disabled; |
252 | if ( mode == QIconSet::Normal && has_focus ) | 252 | if ( mode == QIconSet::Normal && has_focus ) |
253 | mode = QIconSet::Active; | 253 | mode = QIconSet::Active; |
254 | QPixmap pixmap = t->iconSet()->pixmap( QIconSet::Small, mode ); | 254 | QPixmap pixmap; |
255 | if ( mode == QIconSet::Disabled ) | ||
256 | pixmap = t->iconSet()->pixmap( QIconSet::Automatic, mode ); | ||
257 | else | ||
258 | pixmap = t->iconSet()->pixmap(); | ||
255 | int pixw = pixmap.width(); | 259 | int pixw = pixmap.width(); |
256 | int pixh = pixmap.height(); | 260 | int pixh = pixmap.height(); |
257 | p->drawPixmap( r.left() + 6, r.center().y() - pixh / 2 + 1, pixmap ); | 261 | p->drawPixmap( r.left() + 6, r.center().y() - pixh / 2 + 1, pixmap ); |
258 | r.setLeft( r.left() + pixw + 5 ); | 262 | r.setLeft( r.left() + pixw + 5 ); |
259 | } | 263 | } |
260 | 264 | ||
261 | QRect tr = r; | 265 | QRect tr = r; |
262 | 266 | ||
263 | if ( r.width() < 20 ) | 267 | if ( r.width() < 20 ) |
264 | return; | 268 | return; |
265 | 269 | ||
266 | if ( t->isEnabled() && isEnabled() ) { | 270 | if ( t->isEnabled() && isEnabled() ) { |