From 32e8aa951218c0bd6118ee04bb22ef83b3b7ec2e Mon Sep 17 00:00:00 2001 From: mickeyl Date: Mon, 10 Jan 2005 23:47:36 +0000 Subject: make number of icon columns in the launcher customizable per-tab TODO: add GUI for that --- (limited to 'core/launcher') diff --git a/core/launcher/launcher.cpp b/core/launcher/launcher.cpp index 970b8cb..4f81076 100644 --- a/core/launcher/launcher.cpp +++ b/core/launcher/launcher.cpp @@ -289,6 +289,7 @@ void LauncherTabWidget::setTabViewAppearance( LauncherView *v, Config &cfg ) v->setTextColor( QColor(textCol) ); // bool customFont = cfg.readBoolEntry( "CustomFont", FALSE ); + v->setColNumber( cfg.readNumEntry( "Columns", 0 ) ); QStringList font = cfg.readListEntry( "Font", ',' ); if ( font.count() == 4 ) diff --git a/core/launcher/launcherview.cpp b/core/launcher/launcherview.cpp index dc4c57f..9d78c0d 100644 --- a/core/launcher/launcherview.cpp +++ b/core/launcher/launcherview.cpp @@ -22,6 +22,7 @@ /* OPIE */ #include +#include #include #include #include @@ -282,7 +283,7 @@ void LauncherItem::setEyePixmap(const QPixmap&aIcon) QMap* LauncherIconView::sm_EyeCache=0; LauncherIconView::LauncherIconView( QWidget* parent, const char* name ) - : QIconView(parent,name),tf(""),cf(0),bsy(0),busyTimer(0),bigIcns(TRUE),bgColor(white) + : QIconView(parent,name),tf(""),cf(0),bsy(0),busyTimer(0),bigIcns(TRUE),bgColor(white),numColumns(0) { m_EyeCallBack = 0; if (!sm_EyeCache) sm_EyeCache = new QMap(); @@ -625,22 +626,22 @@ void LauncherIconView::calculateGrid( ItemTextPos pos ) int dw = QApplication::desktop()->width(); int viewerWidth = dw-style().scrollBarExtent().width(); if ( pos == Bottom ) { - int cols = 3; - if ( viewerWidth <= 200 ) - cols = 2; - else if ( viewerWidth >= 400 ) - cols = viewerWidth/96; + if( !numColumns ) { + if ( viewerWidth <= 200 ) numColumns = 2; + else if ( viewerWidth >= 400 ) numColumns = viewerWidth/96; + else numColumns = 3; + } setSpacing( 4 ); - setGridX( (viewerWidth-(cols+1)*spacing())/cols ); + setGridX( (viewerWidth-(numColumns+1)*spacing())/numColumns ); setGridY( fontMetrics().height()*2+24 ); } else { - int cols = 2; - if ( viewerWidth < 150 ) - cols = 1; - else if ( viewerWidth >= 400 ) - cols = viewerWidth/150; + if( !numColumns ) { + if ( viewerWidth < 150 ) numColumns = 1; + else if ( viewerWidth >= 400 ) numColumns = viewerWidth/150; + else numColumns = 2; + } setSpacing( 2 ); - setGridX( (viewerWidth-(cols+1)*spacing())/cols ); + setGridX( (viewerWidth-(numColumns+1)*spacing())/numColumns ); setGridY( fontMetrics().height()+2 ); } } @@ -1003,6 +1004,17 @@ void LauncherView::setBackgroundType( BackgroundType t, const QString &val ) QTimer::singleShot( 1000, this, SLOT(flushBgCache()) ); } +void LauncherView::setColNumber( int num ) +{ + icons->setColNumber( num ); +} + +void LauncherIconView::setColNumber( int num ) +{ + numColumns = num; + calculateGrid( Bottom ); +} + void LauncherView::setTextColor( const QColor &tc ) { textCol = tc; diff --git a/core/launcher/launcherview.h b/core/launcher/launcherview.h index 05073ab..e2869eb 100644 --- a/core/launcher/launcherview.h +++ b/core/launcher/launcherview.h @@ -82,6 +82,8 @@ public: void setViewFont( const QFont & ); void clearViewFont(); + + void setColNumber( int ); void relayout(void); @@ -196,6 +198,8 @@ public: bgColor = c; } + void setColNumber( int ); + void drawBackground( QPainter *p, const QRect &r ); void setItemTextPos( ItemTextPos pos ); void hideOrShowItems(bool resort); @@ -245,6 +249,7 @@ private: #endif BusyIndicatorType busyType; QTimer m_eyeTimer; + int numColumns; }; #endif // LAUNCHERVIEW_H -- cgit v0.9.0.2