Add ability to use old style rectangular icon text boxes

git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdelibs@1177312 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
v3.5.13-sru
tpearson 15 years ago
parent 3033222c21
commit 0369eb65aa

@ -118,6 +118,12 @@ bool KGlobalSettings::singleClick()
return g.readBoolEntry("SingleClick", KDE_DEFAULT_SINGLECLICK); return g.readBoolEntry("SingleClick", KDE_DEFAULT_SINGLECLICK);
} }
bool KGlobalSettings::iconUseRoundedRect()
{
KConfigGroup g( KGlobal::config(), "KDE" );
return g.readBoolEntry("IconUseRoundedRect", KDE_DEFAULT_SINGLECLICK);
}
KGlobalSettings::TearOffHandle KGlobalSettings::insertTearOffHandle() KGlobalSettings::TearOffHandle KGlobalSettings::insertTearOffHandle()
{ {
int tearoff; int tearoff;

@ -24,6 +24,7 @@
#include "kdelibs_export.h" #include "kdelibs_export.h"
#define KDE_DEFAULT_SINGLECLICK false #define KDE_DEFAULT_SINGLECLICK false
#define KDE_DEFAULT_ICONTEXTROUNDED true
#define KDE_DEFAULT_INSERTTEAROFFHANDLES 0 #define KDE_DEFAULT_INSERTTEAROFFHANDLES 0
#define KDE_DEFAULT_AUTOSELECTDELAY -1 #define KDE_DEFAULT_AUTOSELECTDELAY -1
#define KDE_DEFAULT_CHANGECURSOR true #define KDE_DEFAULT_CHANGECURSOR true
@ -100,6 +101,12 @@ class KDECORE_EXPORT KGlobalSettings
**/ **/
static bool singleClick(); static bool singleClick();
/**
* Returns whether icon text is drawn in a rounded style
* @return true if rounded, or false if rectangular.
**/
static bool iconUseRoundedRect();
/** /**
* This enum describes the return type for insertTearOffHandle() whether to insert * This enum describes the return type for insertTearOffHandle() whether to insert
* a handle or not. Applications who independently want to use handles in their popup menus * a handle or not. Applications who independently want to use handles in their popup menus

@ -247,7 +247,7 @@ void KIconView::emitExecute( TQIconViewItem *item, const TQPoint &pos )
m_pAutoSelect->stop(); m_pAutoSelect->stop();
//Don´t emit executed if in SC mode and Shift or Ctrl are pressed //Don<EFBFBD>t emit executed if in SC mode and Shift or Ctrl are pressed
if( !( m_bUseSingle && ((keybstate & ShiftButton) || (keybstate & ControlButton)) ) ) { if( !( m_bUseSingle && ((keybstate & ShiftButton) || (keybstate & ControlButton)) ) ) {
setSelected( item, false ); setSelected( item, false );
viewport()->unsetCursor(); viewport()->unsetCursor();
@ -467,6 +467,8 @@ KIconViewItem::~KIconViewItem()
void KIconViewItem::calcRect( const TQString& text_ ) void KIconViewItem::calcRect( const TQString& text_ )
{ {
bool drawRoundedRect = KGlobalSettings::iconUseRoundedRect();
Q_ASSERT( iconView() ); Q_ASSERT( iconView() );
if ( !iconView() ) if ( !iconView() )
return; return;
@ -548,7 +550,10 @@ void KIconViewItem::calcRect( const TQString& text_ )
r = m_wordWrap->boundingRect(); r = m_wordWrap->boundingRect();
int realWidth = QMAX( QMIN( r.width() + 4, tw ), fm->width( "X" ) ); int realWidth = QMAX( QMIN( r.width() + 4, tw ), fm->width( "X" ) );
itemTextRect.setWidth( realWidth + 2); if (drawRoundedRect == true)
itemTextRect.setWidth( realWidth + 2);
else
itemTextRect.setWidth( realWidth );
itemTextRect.setHeight( r.height() ); itemTextRect.setHeight( r.height() );
int w = 0; int h = 0; int y = 0; int w = 0; int h = 0; int y = 0;
@ -699,13 +704,23 @@ void KIconViewItem::paintPixmap( TQPainter *p, const TQColorGroup &cg )
void KIconViewItem::paintText( TQPainter *p, const TQColorGroup &cg ) void KIconViewItem::paintText( TQPainter *p, const TQColorGroup &cg )
{ {
int textX = textRect( false ).x() + 4; bool drawRoundedRect = KGlobalSettings::iconUseRoundedRect();
int textX;
if (drawRoundedRect == true)
textX = textRect( false ).x() + 4;
else
textX = textRect( false ).x() + 2;
int textY = textRect( false ).y(); int textY = textRect( false ).y();
if ( isSelected() ) { if ( isSelected() ) {
if (drawRoundedRect == true) {
p->setBrush(TQBrush(cg.highlight())); p->setBrush(TQBrush(cg.highlight()));
p->setPen(TQPen(cg.highlight())); p->setPen(TQPen(cg.highlight()));
p->drawRoundRect( textRect( false ) ,1000/textRect(false).width(),1000/textRect(false).height() ); p->drawRoundRect( textRect( false ) ,1000/textRect(false).width(),1000/textRect(false).height() );
}
else {
p->fillRect( textRect( false ), cg.highlight() );
}
p->setPen( TQPen( cg.highlightedText() ) ); p->setPen( TQPen( cg.highlightedText() ) );
} else { } else {
if ( iconView()->itemTextBackground() != NoBrush ) if ( iconView()->itemTextBackground() != NoBrush )

Loading…
Cancel
Save