summaryrefslogtreecommitdiff
path: root/core
Unidiff
Diffstat (limited to 'core') (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/launchertab.cpp24
-rw-r--r--core/settings/launcher/menusettings.cpp44
2 files changed, 36 insertions, 32 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
@@ -76,101 +76,101 @@ void LauncherTabBar::layoutTabs()
76 return; 76 return;
77 77
78 int available = width()-1; 78 int available = width()-1;
79 79
80 QFontMetrics fm = fontMetrics(); 80 QFontMetrics fm = fontMetrics();
81 int hiddenTabWidth = -12; 81 int hiddenTabWidth = -12;
82 LauncherTab *current = currentLauncherTab(); 82 LauncherTab *current = currentLauncherTab();
83 int hframe, vframe, overlap; 83 int hframe, vframe, overlap;
84 style().tabbarMetrics( this, hframe, vframe, overlap ); 84 style().tabbarMetrics( this, hframe, vframe, overlap );
85 int x = 0; 85 int x = 0;
86 QRect r; 86 QRect r;
87 LauncherTab *t; 87 LauncherTab *t;
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
165 t = it.toLast(); 165 t = it.toLast();
166 if (t) { 166 if (t) {
167 QRect rr = t->rect(); 167 QRect rr = t->rect();
168 rr.setRight(width()-1); 168 rr.setRight(width()-1);
169 t->setRect( rr ); 169 t->setRect( rr );
170 } 170 }
171 171
172 for (it.toFirst(); it.current(); ++it ) { 172 for (it.toFirst(); it.current(); ++it ) {
173 t = it.current(); 173 t = it.current();
174 QRect tr = t->rect(); 174 QRect tr = t->rect();
175 tr.setHeight( r.height() ); 175 tr.setHeight( r.height() );
176 t->setRect( tr ); 176 t->setRect( tr );
@@ -199,80 +199,84 @@ void LauncherTabBar::paint( QPainter * p, QTab * t, bool selected ) const
199 if ( selected ) 199 if ( selected )
200 flags |= QStyle::Style_Selected; 200 flags |= QStyle::Style_Selected;
201 style().drawControl( QStyle::CE_TabBarTab, p, this, t->rect(), 201 style().drawControl( QStyle::CE_TabBarTab, p, this, t->rect(),
202 colorGroup(), flags, QStyleOption(t) ); 202 colorGroup(), flags, QStyleOption(t) );
203#else 203#else
204 style().drawTab( p, this, t, selected ); 204 style().drawTab( p, this, t, selected );
205#endif 205#endif
206 206
207 QRect r( t->rect() ); 207 QRect r( t->rect() );
208 QFont f( font() ); 208 QFont f( font() );
209 if ( selected ) 209 if ( selected )
210 f.setBold( TRUE ); 210 f.setBold( TRUE );
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 ) {
237 that->unsetPalette(); 237 that->unsetPalette();
238 that->setUpdatesEnabled( TRUE ); 238 that->setUpdatesEnabled( TRUE );
239 } 239 }
240} 240}
241 241
242void LauncherTabBar::paintLabel( QPainter* p, const QRect&, 242void 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() ) {
267#if defined(_WS_WIN32_) 271#if defined(_WS_WIN32_)
268 if ( colorGroup().brush( QColorGroup::Button ) == colorGroup().brush( QColorGroup::Background ) ) 272 if ( colorGroup().brush( QColorGroup::Button ) == colorGroup().brush( QColorGroup::Background ) )
269 p->setPen( colorGroup().buttonText() ); 273 p->setPen( colorGroup().buttonText() );
270 else 274 else
271 p->setPen( colorGroup().foreground() ); 275 p->setPen( colorGroup().foreground() );
272#else 276#else
273 p->setPen( colorGroup().foreground() ); 277 p->setPen( colorGroup().foreground() );
274#endif 278#endif
275 p->drawText( tr, AlignCenter | AlignVCenter | ShowPrefix, t->text() ); 279 p->drawText( tr, AlignCenter | AlignVCenter | ShowPrefix, t->text() );
276 } else { 280 } else {
277 p->setPen( palette().disabled().foreground() ); 281 p->setPen( palette().disabled().foreground() );
278 p->drawText( tr, AlignCenter | AlignVCenter | ShowPrefix, t->text() ); 282 p->drawText( tr, AlignCenter | AlignVCenter | ShowPrefix, t->text() );
diff --git a/core/settings/launcher/menusettings.cpp b/core/settings/launcher/menusettings.cpp
index 55bf358..29ce841 100644
--- a/core/settings/launcher/menusettings.cpp
+++ b/core/settings/launcher/menusettings.cpp
@@ -1,47 +1,47 @@
1/* 1/*
2                This file is part of the OPIE Project 2 This file is part of the OPIE Project
3 =. Copyright (c) 2002 Trolltech AS <info@trolltech.com> 3 =. Copyright (c) 2002 Trolltech AS <info@trolltech.com>
4             .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> 4 .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org>
5           .>+-= 5 .>+-=
6 _;:,     .>    :=|. This file is free software; you can 6_;:, .> :=|. This file is free software; you can
7.> <`_,   >  .   <= redistribute it and/or modify it under 7.> <`_, > . <= redistribute it and/or modify it under
8:`=1 )Y*s>-.--   : the terms of the GNU General Public 8:`=1 )Y*s>-.-- : the terms of the GNU General Public
9.="- .-=="i,     .._ License as published by the Free Software 9.="- .-=="i, .._ License as published by the Free Software
10 - .   .-<_>     .<> Foundation; either version 2 of the License, 10- . .-<_> .<> Foundation; either version 2 of the License,
11     ._= =}       : or (at your option) any later version. 11 ._= =} : or (at your option) any later version.
12    .%`+i>       _;_. 12 .%`+i> _;_.
13    .i_,=:_.      -<s. This file is distributed in the hope that 13 .i_,=:_. -<s. This file is distributed in the hope that
14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 14 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
15    : ..    .:,     . . . without even the implied warranty of 15 : .. .:, . . . without even the implied warranty of
16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 16 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General 17 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General
18..}^=.=       =       ; Public License for more details. 18..}^=.= = ; Public License for more details.
19++=   -.     .`     .: 19++= -. .` .:
20 :     =  ...= . :.=- You should have received a copy of the GNU 20: = ...= . :.=- You should have received a copy of the GNU
21 -.   .:....=;==+<; General Public License along with this file; 21-. .:....=;==+<; General Public License along with this file;
22  -_. . .   )=.  = see the file COPYING. If not, write to the 22 -_. . . )=. = see the file COPYING. If not, write to the
23    --        :-=` Free Software Foundation, Inc., 23 -- :-=` Free Software Foundation, Inc.,
24 59 Temple Place - Suite 330, 24 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA. 25 Boston, MA 02111-1307, USA.
26 26
27*/ 27*/
28 28
29#include "menusettings.h" 29#include "menusettings.h"
30 30
31#include <qpe/config.h> 31#include <qpe/config.h>
32#include <qpe/qlibrary.h> 32#include <qpe/qlibrary.h>
33#include <qpe/qpeapplication.h> 33#include <qpe/qpeapplication.h>
34#include <qpe/menuappletinterface.h> 34#include <qpe/menuappletinterface.h>
35#include <qpe/qcopenvelope_qws.h> 35#include <qpe/qcopenvelope_qws.h>
36 36
37#include <qdir.h> 37#include <qdir.h>
38#include <qlistview.h> 38#include <qlistview.h>
39#include <qcheckbox.h> 39#include <qcheckbox.h>
40#include <qheader.h> 40#include <qheader.h>
41#include <qlayout.h> 41#include <qlayout.h>
42#include <qlabel.h> 42#include <qlabel.h>
43#include <qwhatsthis.h> 43#include <qwhatsthis.h>
44 44
45#include <stdlib.h> 45#include <stdlib.h>
46 46
47 47
@@ -84,49 +84,49 @@ void MenuSettings::init ( )
84 QString path = QPEApplication::qpeDir ( ) + "plugins/applets"; 84 QString path = QPEApplication::qpeDir ( ) + "plugins/applets";
85#ifdef Q_OS_MACX 85#ifdef Q_OS_MACX
86 QStringList list = QDir ( path, "lib*.dylib" ). entryList ( ); 86 QStringList list = QDir ( path, "lib*.dylib" ). entryList ( );
87#else 87#else
88 QStringList list = QDir ( path, "lib*.so" ). entryList ( ); 88 QStringList list = QDir ( path, "lib*.so" ). entryList ( );
89#endif /* Q_OS_MACX */ 89#endif /* Q_OS_MACX */
90 90
91 for ( QStringList::Iterator it = list. begin ( ); it != list. end ( ); ++it ) { 91 for ( QStringList::Iterator it = list. begin ( ); it != list. end ( ); ++it ) {
92 QString name; 92 QString name;
93 QPixmap icon; 93 QPixmap icon;
94 MenuAppletInterface *iface = 0; 94 MenuAppletInterface *iface = 0;
95 95
96 QLibrary *lib = new QLibrary ( path + "/" + *it ); 96 QLibrary *lib = new QLibrary ( path + "/" + *it );
97 lib-> queryInterface ( IID_MenuApplet, (QUnknownInterface**) &iface ); 97 lib-> queryInterface ( IID_MenuApplet, (QUnknownInterface**) &iface );
98 if ( iface ) { 98 if ( iface ) {
99 QString lang = getenv( "LANG" ); 99 QString lang = getenv( "LANG" );
100 QTranslator *trans = new QTranslator ( qApp ); 100 QTranslator *trans = new QTranslator ( qApp );
101 QString type = (*it). left ((*it). find (".")); 101 QString type = (*it). left ((*it). find ("."));
102 QString tfn = QPEApplication::qpeDir ( ) + "i18n/" + lang + "/" + type + ".qm"; 102 QString tfn = QPEApplication::qpeDir ( ) + "i18n/" + lang + "/" + type + ".qm";
103 if ( trans-> load ( tfn )) 103 if ( trans-> load ( tfn ))
104 qApp-> installTranslator ( trans ); 104 qApp-> installTranslator ( trans );
105 else 105 else
106 delete trans; 106 delete trans;
107 name = iface-> name ( ); 107 name = iface-> name ( );
108 icon = iface-> icon ( ). pixmap ( QIconSet::Small, QIconSet::Normal ); 108 icon = iface-> icon ( ). pixmap ();
109 iface-> release ( ); 109 iface-> release ( );
110 lib-> unload ( ); 110 lib-> unload ( );
111 111
112 QCheckListItem *item; 112 QCheckListItem *item;
113 item = new QCheckListItem ( m_list, name, QCheckListItem::CheckBox ); 113 item = new QCheckListItem ( m_list, name, QCheckListItem::CheckBox );
114 if ( !icon. isNull ( )) 114 if ( !icon. isNull ( ))
115 item-> setPixmap ( 0, icon ); 115 item-> setPixmap ( 0, icon );
116 item-> setOn ( exclude. find ( *it ) == exclude. end ( )); 116 item-> setOn ( exclude. find ( *it ) == exclude. end ( ));
117 m_applets [*it] = item; 117 m_applets [*it] = item;
118 } else { 118 } else {
119 delete lib; 119 delete lib;
120 } 120 }
121 } 121 }
122 122
123 cfg. setGroup ( "Menu" ); 123 cfg. setGroup ( "Menu" );
124 m_menutabs->setChecked( cfg.readBoolEntry( "LauncherTabs", true ) ); 124 m_menutabs->setChecked( cfg.readBoolEntry( "LauncherTabs", true ) );
125 m_menusubpopup->setChecked( cfg.readBoolEntry( "LauncherSubPopup", true ) ); 125 m_menusubpopup->setChecked( cfg.readBoolEntry( "LauncherSubPopup", true ) );
126 m_menusubpopup->setEnabled( m_menutabs->isChecked() ); 126 m_menusubpopup->setEnabled( m_menutabs->isChecked() );
127 connect( m_menutabs, SIGNAL( stateChanged(int) ), m_menusubpopup, SLOT( setEnabled(bool) ) ); 127 connect( m_menutabs, SIGNAL( stateChanged(int) ), m_menusubpopup, SLOT( setEnabled(bool) ) );
128 128
129} 129}
130 130
131void MenuSettings::appletChanged() 131void MenuSettings::appletChanged()
132{ 132{