--- kdepim-3.4.0/kontact/src/iconsidepane.cpp~ 20 Feb 2005 19:21:29 -0000 1.40 +++ kdepim-3.4.0/kontact/src/iconsidepane.cpp 28 Mar 2005 23:37:08 -0000 @@ -124,12 +124,24 @@ int EntryItem::width( const QListBox *listbox ) const { int w; - if ( text().isEmpty() ) + if ( text().isEmpty() && !navigator()->showText() ) + // dont show text or text empty: only icon's width w = mPixmap.width(); else if (navigator()->viewMode() > SmallIcons) - w = QMAX( (int)navigator()->viewMode(), listbox->fontMetrics().width( text() ) ); + { + // icon above text, take max of text's and icon's widths + // we actually dont wnat the text's width when we dont show it + if (navigator()->showText()) + w = QMAX( (int)navigator()->viewMode(), listbox->fontMetrics().width( text() ) ); + else + w = (int)navigator()->viewMode(); + } else - w = (int)navigator()->viewMode() + 4 + listbox->fontMetrics().width( text() ); + { + // text next to icon: sum their widhts + w = (int)navigator()->viewMode(); + if (navigator()->showText()) w += listbox->fontMetrics().width( text() ) + 4; + } return w + ( KDialog::marginHint() * 2 ); } @@ -137,14 +149,28 @@ int EntryItem::height( const QListBox *listbox ) const { int h; - if ( text().isEmpty() ) + if ( text().isEmpty() && !navigator()->showText() ) + // text is empty or we dont show text - only height of pixmap (+4 margin) h = mPixmap.height() + 4; else if (navigator()->viewMode() > SmallIcons) - h = (int)navigator()->viewMode() + listbox->fontMetrics().lineSpacing() + 4; + { + // text not null but icon is over the text - we have icons > small icons + // returns height of icon + distance ebtween baselines + 4 margin + // we dont want the distance when we dont show text + h = (int)navigator()->viewMode() + 4; + if (navigator()->showText()) h+=listbox->fontMetrics().lineSpacing(); + } else - h = QMAX( (int)navigator()->viewMode(), - listbox->fontMetrics().lineSpacing() ) + - KDialog::spacingHint() * 2; + { + // icon next to text, height is (max of icon height and + // baseline distance) + + if (navigator()->showText()) + h = QMAX( (int)navigator()->viewMode(), + listbox->fontMetrics().lineSpacing() ) + + KDialog::spacingHint() * 2; + else + h = (int)navigator()->viewMode() + KDialog::spacingHint() * 2; + } return h; } @@ -192,7 +218,7 @@ p->setPen( box->colorGroup().highlightedText() ); } - if ( !text().isEmpty() ) { + if ( !text().isEmpty() /*&& navigator()->showText()*/ ) { QFontMetrics fm = p->fontMetrics(); int x = 0; @@ -209,8 +235,8 @@ y += mPixmap.height()/2 - fm.height()/2 + fm.ascent(); } - if ( isCurrent() || isSelected() || mHasHover ) { - p->setPen( box->colorGroup().highlight().dark(115) ); + if ( navigator()->showText() && ( isCurrent() || isSelected() || mHasHover ) ) { + p->setPen( box->colorGroup().highlight().dark(115) ); p->drawText( x + ( QApplication::reverseLayout() ? -1 : 1), y + 1, text() ); p->setPen( box->colorGroup().highlightedText() ); @@ -218,6 +244,7 @@ else p->setPen( box->colorGroup().text() ); + if ( navigator()->showText() ) p->drawText( x, y, text() ); } @@ -241,6 +268,7 @@ mMouseOn = 0; mHighlightItem = 0; mViewMode = sizeIntToEnum( Prefs::self()->sidePaneIconSize() ); + mHaveText=Prefs::self()->sidePaneShowText(); setSelectionMode( KListBox::Single ); viewport()->setBackgroundMode( PaletteBackground ); setFrameStyle( QFrame::NoFrame ); @@ -433,18 +461,53 @@ { KPopupMenu menu; menu.insertTitle( i18n( "Icon Size" ) ); - menu.insertItem( i18n( "Large" ), (int)LargeIcons ); - menu.insertItem( i18n( "Normal" ), (int)NormalIcons ); - menu.insertItem( i18n( "Small" ), (int)SmallIcons ); - menu.insertItem( i18n( "Text Only" ), (int)TextOnly ); + int i=1; + menu.insertItem( i18n( "Large" ), (int)LargeIcons, i++ ); + menu.insertItem( i18n( "Normal" ), (int)NormalIcons,i++ ); + menu.insertItem( i18n( "Small" ), (int)SmallIcons,i++ ); + menu.insertItem( i18n( "Text Only" ), (int)TextOnly,i ); menu.setItemChecked( (int)mViewMode, true ); + + // needed to check if we show any icons at all, we cant disable + // both icons and text right? + mViewMode = sizeIntToEnum( Prefs::self()->sidePaneIconSize() ); + // needed to know whether to ask user for showing or hiding the text + mHaveText=Prefs::self()->sidePaneShowText(); + + if (mViewMode != TextOnly) + { + menu.insertSeparator(i+1); + // the current seting is no-text + kdDebug(5600)<< "IconShowText=" << IconShowText - 1 << "\n"; + if (mHaveText != IconShowText) + menu.insertItem( i18n( "Show Text" ), IconShowText,i+2); + else + menu.insertItem( i18n( "Hide Text" ), IconShowText-1,i+2); + } + int choice = menu.exec( pos ); if ( choice == -1 ) return; +// choice is not from an icon size menu part and it is either +// IconShowText=showtext or the IconShowText-1 = dont show text + + kdDebug(5600) << "Index: " << menu.indexOf(choice) << "\n"; + kdDebug(5600) << "Choice: " << choice << "\n"; - mViewMode = sizeIntToEnum( choice ); - Prefs::self()->setSidePaneIconSize( choice ); + if ( menu.indexOf(choice) == i+2 ) + { + if (choice==IconShowText || choice==IconShowText-1) + { + mHaveText=choice; + Prefs::self()->setSidePaneShowText(choice) ; + } + } + else + { + mViewMode = sizeIntToEnum( choice ); + Prefs::self()->setSidePaneIconSize( choice ); + } int maxWidth = 0; QListBoxItem* it = 0; --- kdepim-3.4.0/kontact/src/iconsidepane.h~ 20 Feb 2005 15:33:47 -0000 1.16 +++ kdepim-3.4.0/kontact/src/iconsidepane.h 28 Mar 2005 23:37:11 -0000 @@ -22,7 +22,7 @@ #define KONTACT_ICONSIDEPANEBASE_H #include "sidepanebase.h" - +#include "prefs.h" #include class QSignalMapper; @@ -37,6 +37,8 @@ class Navigator; enum IconViewMode { LargeIcons = 48, NormalIcons = 32, SmallIcons = 22, TextOnly = 0 }; +// always set greater by 2 then max (IconViewMode) and sync kontact.kcfg with it +const int IconShowText = 50; /** A @see QListBoxPixmap Square Box with an optional icon and a text @@ -96,6 +98,7 @@ void highlightItem( EntryItem* item ); IconViewMode viewMode() { return mViewMode; } + bool showText() { return mHaveText==IconShowText && mViewMode != TextOnly || mViewMode == TextOnly ; } IconViewMode sizeIntToEnum(int size) const; const QPtrList & actions() { return mActions; } signals: @@ -123,6 +126,7 @@ private: SidePaneBase *mSidePane; IconViewMode mViewMode; + int mHaveText; QListBoxItem* mMouseOn; --- kdepim-3.4.0/kontact/src/kontact.kcfg~ 24 Feb 2005 21:14:52 -0000 1.10 +++ kdepim-3.4.0/kontact/src/kontact.kcfg 28 Mar 2005 23:37:13 -0000 @@ -20,7 +20,10 @@ 1 - + + + 50 + 32