author | drw <drw> | 2005-04-14 18:30:23 (UTC) |
---|---|---|
committer | drw <drw> | 2005-04-14 18:30:23 (UTC) |
commit | 5fd266a3a5a6d9a1acb9c38e4802ff06ba38beaf (patch) (side-by-side diff) | |
tree | d4ba8a948d876db9bbff10cbd282fd16aab91feb /core | |
parent | 7a3b813cc3bfbb2f7c31f347c35405851e82aecf (diff) | |
download | opie-5fd266a3a5a6d9a1acb9c38e4802ff06ba38beaf.zip opie-5fd266a3a5a6d9a1acb9c38e4802ff06ba38beaf.tar.gz opie-5fd266a3a5a6d9a1acb9c38e4802ff06ba38beaf.tar.bz2 |
More icon sizing updates
-rw-r--r-- | core/launcher/launchertab.cpp | 24 | ||||
-rw-r--r-- | core/settings/launcher/menusettings.cpp | 44 |
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() return; int available = width()-1; QFontMetrics fm = fontMetrics(); int hiddenTabWidth = -12; LauncherTab *current = currentLauncherTab(); int hframe, vframe, overlap; style().tabbarMetrics( this, hframe, vframe, overlap ); int x = 0; QRect r; LauncherTab *t; QListIterator< LauncherTab > it( items ); int required = 0; int eventabwidth = (width()-1)/count(); enum Mode { HideBackText, Pack, Even } mode=Even; for (it.toFirst(); it.current(); ++it ) { t = it.current(); if ( !t ) continue; int iw = fm.width( t->text() ) + hframe - overlap; if ( t != current ) { available -= hiddenTabWidth + hframe - overlap; if ( t->iconSet() != 0 ) - available -= t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); + available -= t->iconSet()->pixmap().width(); } if ( t->iconSet() != 0 ) - iw += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); + iw += t->iconSet()->pixmap().width(); required += iw; // As space gets tight, packed looks better than even. "10" must be at least 0. if ( iw >= eventabwidth-10 ) mode = Pack; } if ( mode == Pack && required > width()-1 ) mode = HideBackText; for ( it.toFirst(); it.current(); ++it ) { t = it.current(); if ( !t ) continue; if ( mode != HideBackText ) { int w = fm.width( t->text() ); int ih = 0; if ( t->iconSet() != 0 ) { - w += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); - ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height(); + w += t->iconSet()->pixmap().width(); + ih = t->iconSet()->pixmap().height(); } int h = QMAX( fm.height(), ih ); h = QMAX( h, QApplication::globalStrut().height() ); h += vframe; w += hframe; QRect totr(x, 0, mode == Even ? eventabwidth : w * (width()-1)/required, h); t->setRect(totr); x += totr.width() - overlap; r = r.unite(totr); } else if ( t != current ) { int w = hiddenTabWidth; int ih = 0; if ( t->iconSet() != 0 ) { - w += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); - ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height(); + w += t->iconSet()->pixmap().width(); + ih = t->iconSet()->pixmap().height(); } int h = QMAX( fm.height(), ih ); h = QMAX( h, QApplication::globalStrut().height() ); h += vframe; w += hframe; t->setRect( QRect(x, 0, w, h) ); x += t->rect().width() - overlap; r = r.unite( t->rect() ); } else { int ih = 0; if ( t->iconSet() != 0 ) { - ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height(); + ih = t->iconSet()->pixmap().height(); } int h = QMAX( fm.height(), ih ); h = QMAX( h, QApplication::globalStrut().height() ); h += vframe; t->setRect( QRect(x, 0, available, h) ); x += t->rect().width() - overlap; r = r.unite( t->rect() ); } } t = it.toLast(); if (t) { QRect rr = t->rect(); rr.setRight(width()-1); t->setRect( rr ); } for (it.toFirst(); it.current(); ++it ) { t = it.current(); QRect tr = t->rect(); tr.setHeight( r.height() ); t->setRect( tr ); @@ -199,80 +199,84 @@ void LauncherTabBar::paint( QPainter * p, QTab * t, bool selected ) const if ( selected ) flags |= QStyle::Style_Selected; style().drawControl( QStyle::CE_TabBarTab, p, this, t->rect(), colorGroup(), flags, QStyleOption(t) ); #else style().drawTab( p, this, t, selected ); #endif QRect r( t->rect() ); QFont f( font() ); if ( selected ) f.setBold( TRUE ); p->setFont( f ); if ( ct->fgColor.isValid() ) { pal.setColor( QPalette::Active, QColorGroup::Foreground, ct->fgColor ); pal.setColor( QPalette::Inactive, QColorGroup::Foreground, ct->fgColor ); that->setUpdatesEnabled( FALSE ); that->setPalette( pal ); setPal = TRUE; } int iw = 0; int ih = 0; if ( t->iconSet() != 0 ) { - iw = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width() + 2; - ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height(); + iw = t->iconSet()->pixmap().width() + 2; + ih = t->iconSet()->pixmap().height(); } int w = iw + p->fontMetrics().width( t->text() ) + 4; int h = QMAX(p->fontMetrics().height() + 4, ih ); paintLabel( p, QRect( r.left() + (r.width()-w)/2 - 3, r.top() + (r.height()-h)/2, w, h ), t, #if QT_VERSION >= 0x030000 t->identifier() == keyboardFocusTab() #else t->identitifer() == keyboardFocusTab() #endif ); if ( setPal ) { that->unsetPalette(); that->setUpdatesEnabled( TRUE ); } } void LauncherTabBar::paintLabel( QPainter* p, const QRect&, QTab* t, bool has_focus ) const { QRect r = t->rect(); // if ( t->id != currentTab() ) //r.moveBy( 1, 1 ); // if ( t->iconSet() ) { // the tab has an iconset, draw it in the right mode QIconSet::Mode mode = (t->isEnabled() && isEnabled()) ? QIconSet::Normal : QIconSet::Disabled; if ( mode == QIconSet::Normal && has_focus ) mode = QIconSet::Active; - QPixmap pixmap = t->iconSet()->pixmap( QIconSet::Small, mode ); + QPixmap pixmap; + if ( mode == QIconSet::Disabled ) + pixmap = t->iconSet()->pixmap( QIconSet::Automatic, mode ); + else + pixmap = t->iconSet()->pixmap(); int pixw = pixmap.width(); int pixh = pixmap.height(); p->drawPixmap( r.left() + 6, r.center().y() - pixh / 2 + 1, pixmap ); r.setLeft( r.left() + pixw + 5 ); } QRect tr = r; if ( r.width() < 20 ) return; if ( t->isEnabled() && isEnabled() ) { #if defined(_WS_WIN32_) if ( colorGroup().brush( QColorGroup::Button ) == colorGroup().brush( QColorGroup::Background ) ) p->setPen( colorGroup().buttonText() ); else p->setPen( colorGroup().foreground() ); #else p->setPen( colorGroup().foreground() ); #endif p->drawText( tr, AlignCenter | AlignVCenter | ShowPrefix, t->text() ); } else { p->setPen( palette().disabled().foreground() ); 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 @@ /* - This file is part of the OPIE Project + This file is part of the OPIE Project =. Copyright (c) 2002 Trolltech AS <info@trolltech.com> - .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> - .>+-= - _;:, .> :=|. This file is free software; you can -.> <`_, > . <= redistribute it and/or modify it under -:`=1 )Y*s>-.-- : the terms of the GNU General Public -.="- .-=="i, .._ License as published by the Free Software - - . .-<_> .<> Foundation; either version 2 of the License, - ._= =} : or (at your option) any later version. - .%`+i> _;_. - .i_,=:_. -<s. This file is distributed in the hope that - + . -:. = it will be useful, but WITHOUT ANY WARRANTY; - : .. .:, . . . without even the implied warranty of - =_ + =;=|` MERCHANTABILITY or FITNESS FOR A - _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General -..}^=.= = ; Public License for more details. -++= -. .` .: - : = ...= . :.=- You should have received a copy of the GNU - -. .:....=;==+<; General Public License along with this file; - -_. . . )=. = see the file COPYING. If not, write to the - -- :-=` Free Software Foundation, Inc., + .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> + .>+-= +_;:, .> :=|. This file is free software; you can +.> <`_, > . <= redistribute it and/or modify it under +:`=1 )Y*s>-.-- : the terms of the GNU General Public +.="- .-=="i, .._ License as published by the Free Software +- . .-<_> .<> Foundation; either version 2 of the License, + ._= =} : or (at your option) any later version. + .%`+i> _;_. + .i_,=:_. -<s. This file is distributed in the hope that + + . -:. = it will be useful, but WITHOUT ANY WARRANTY; + : .. .:, . . . without even the implied warranty of + =_ + =;=|` MERCHANTABILITY or FITNESS FOR A + _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General +..}^=.= = ; Public License for more details. +++= -. .` .: +: = ...= . :.=- You should have received a copy of the GNU +-. .:....=;==+<; General Public License along with this file; + -_. . . )=. = see the file COPYING. If not, write to the + -- :-=` Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "menusettings.h" #include <qpe/config.h> #include <qpe/qlibrary.h> #include <qpe/qpeapplication.h> #include <qpe/menuappletinterface.h> #include <qpe/qcopenvelope_qws.h> #include <qdir.h> #include <qlistview.h> #include <qcheckbox.h> #include <qheader.h> #include <qlayout.h> #include <qlabel.h> #include <qwhatsthis.h> #include <stdlib.h> @@ -84,49 +84,49 @@ void MenuSettings::init ( ) QString path = QPEApplication::qpeDir ( ) + "plugins/applets"; #ifdef Q_OS_MACX QStringList list = QDir ( path, "lib*.dylib" ). entryList ( ); #else QStringList list = QDir ( path, "lib*.so" ). entryList ( ); #endif /* Q_OS_MACX */ for ( QStringList::Iterator it = list. begin ( ); it != list. end ( ); ++it ) { QString name; QPixmap icon; MenuAppletInterface *iface = 0; QLibrary *lib = new QLibrary ( path + "/" + *it ); lib-> queryInterface ( IID_MenuApplet, (QUnknownInterface**) &iface ); if ( iface ) { QString lang = getenv( "LANG" ); QTranslator *trans = new QTranslator ( qApp ); QString type = (*it). left ((*it). find (".")); QString tfn = QPEApplication::qpeDir ( ) + "i18n/" + lang + "/" + type + ".qm"; if ( trans-> load ( tfn )) qApp-> installTranslator ( trans ); else delete trans; name = iface-> name ( ); - icon = iface-> icon ( ). pixmap ( QIconSet::Small, QIconSet::Normal ); + icon = iface-> icon ( ). pixmap (); iface-> release ( ); lib-> unload ( ); QCheckListItem *item; item = new QCheckListItem ( m_list, name, QCheckListItem::CheckBox ); if ( !icon. isNull ( )) item-> setPixmap ( 0, icon ); item-> setOn ( exclude. find ( *it ) == exclude. end ( )); m_applets [*it] = item; } else { delete lib; } } cfg. setGroup ( "Menu" ); m_menutabs->setChecked( cfg.readBoolEntry( "LauncherTabs", true ) ); m_menusubpopup->setChecked( cfg.readBoolEntry( "LauncherSubPopup", true ) ); m_menusubpopup->setEnabled( m_menutabs->isChecked() ); connect( m_menutabs, SIGNAL( stateChanged(int) ), m_menusubpopup, SLOT( setEnabled(bool) ) ); } void MenuSettings::appletChanged() { |