summaryrefslogtreecommitdiff
path: root/noncore/settings
Unidiff
Diffstat (limited to 'noncore/settings') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/sysinfo/otabwidget.cpp199
-rw-r--r--noncore/settings/sysinfo/otabwidget.h54
-rw-r--r--noncore/settings/sysinfo/sysinfo.cpp18
3 files changed, 239 insertions, 32 deletions
diff --git a/noncore/settings/sysinfo/otabwidget.cpp b/noncore/settings/sysinfo/otabwidget.cpp
index 5d5b3e6..5154196 100644
--- a/noncore/settings/sysinfo/otabwidget.cpp
+++ b/noncore/settings/sysinfo/otabwidget.cpp
@@ -21,13 +21,66 @@
21 21
22#include <qpe/config.h>
22#include <qpe/resource.h> 23#include <qpe/resource.h>
23 24
25#include <qcombobox.h>
24#include <qlist.h> 26#include <qlist.h>
25#include <qtabbar.h> 27#include <qtabbar.h>
28#include <qwidgetstack.h>
26 29
27 30OTabWidget::OTabWidget( QWidget *parent, const char *name = 0x0,
28OTabWidget::OTabWidget( QWidget *parent, const char *name ) 31 TabStyle s = Global, TabPosition p = Top )
29 : QTabWidget( parent, name ) 32 : QWidget( parent, name )
30{ 33{
31 connect( this, SIGNAL( currentChanged( QWidget * ) ), 34 if ( s == Global )
32 this, SLOT( tabChangedSlot( QWidget * ) ) ); 35 {
36 Config config( "qpe" );
37 config.setGroup( "Appearance" );
38 tabBarStyle = ( TabStyle ) config.readNumEntry( "TabStyle", (int) IconTab );
39 if ( tabBarStyle <= Global || tabBarStyle > IconList)
40 {
41 tabBarStyle = IconTab;
42 }
43 QString pos = config.readEntry( "TabPosition", "Top");
44 if ( pos == "Top" )
45 {
46 tabBarPosition = Top;
47 }
48 else
49 {
50 tabBarPosition = Bottom;
51 }
52 }
53 else
54 {
55 tabBarStyle = s;
56 tabBarPosition = p;
57 }
58
59 widgetStack = new QWidgetStack( this, "widgetstack" );
60 widgetStack->setFrameStyle( QFrame::StyledPanel | QFrame::Raised );
61 widgetStack->setLineWidth( style().defaultFrameWidth() );
62
63 tabBarStack = new QWidgetStack( this, "tabbarstack" );
64
65 tabBar = new QTabBar( tabBarStack, "tabbar" );
66 tabBarStack->addWidget( tabBar, 0 );
67 connect( tabBar, SIGNAL( selected( int ) ), this, SLOT( slotTabBarSelected( int ) ) );
68
69 tabList = new QComboBox( false, tabBarStack, "tablist" );
70 tabBarStack->addWidget( tabList, 1 );
71 connect( tabList, SIGNAL( activated( int ) ), this, SLOT( slotTabListSelected( int ) ) );
72
73 if ( tabBarStyle == TextTab || tabBarStyle == IconTab )
74 {
75 tabBarStack->raiseWidget( tabBar );
76 }
77 else if ( tabBarStyle == TextList || tabBarStyle == IconList )
78 {
79 tabBarStack->raiseWidget( tabList );
80 }
81
82 if ( tabBarPosition == Bottom )
83 {
84 tabBar->setShape( QTabBar::RoundedBelow );
85 }
33} 86}
@@ -40,22 +93,81 @@ void OTabWidget::addTab( QWidget *child, const QString &icon, const QString &lab
40{ 93{
41 Tabs.append( TabInfo( child, icon, label ) ); 94 QPixmap iconset = loadSmooth( icon );
42 QTabWidget::addTab( child, loadSmooth( icon ), QString::null ); 95
96 // Add to tabBar
97 QTab * tab = new QTab();
98 if ( tabBarStyle == IconTab )
99 {
100 tab->label = QString::null;
101 }
102 else
103 {
104 tab->label = label;
105 }
106 if ( tabBarStyle == IconTab || tabBarStyle == IconList)
107 {
108 tab->iconset = new QIconSet( iconset );
109 }
110 int tabid = tabBar->addTab( tab );
111 tabBar->setCurrentTab( tab );
112
113 // Add to tabList
114
115 if ( tabBarStyle == IconTab || tabBarStyle == IconList )
116 {
117 tabList->insertItem( iconset, label, -1 );
118 }
119 else
120 {
121 tabList->insertItem( label );
122 }
123 tabList->setCurrentItem( tabList->count()-1 );
124
125 // Add child to widget list
126 widgetStack->addWidget( child, tabid );
127 widgetStack->raiseWidget( child );
128
129 // Save tab information
130 tabs.append( TabInfo( tabid, child, icon, label ) );
131
132 setUpLayout( FALSE );
133}
134
135OTabWidget::TabStyle OTabWidget::tabStyle() const
136{
137 return tabBarStyle;
138}
139
140void OTabWidget::setTabStyle( TabStyle s )
141{
142 tabBarStyle = s;
43} 143}
44 144
45void OTabWidget::tabChangedSlot( QWidget *child ) 145OTabWidget::TabPosition OTabWidget::tabPosition() const
46{ 146{
47 TabInfoList::Iterator it; 147 return tabBarPosition;
148}
48 149
49 if ( CurrentTab != 0x0 ) 150void OTabWidget::setTabPosition( TabPosition p )
151{
152 tabBarPosition = p;
153}
154
155void OTabWidget::slotTabBarSelected( int id )
156{
157
158 TabInfoList::Iterator newtab = tabs.begin();
159 while ( newtab != tabs.end() && (*newtab).id() != id )
160 newtab++;
161 if ( (*newtab).id() == id )
50 { 162 {
51 changeTab( (*CurrentTab).control(), loadSmooth( (*CurrentTab).icon() ), QString::null ); 163 selectTab( newtab );
52 } 164 }
165}
53 166
54 for ( it = Tabs.begin(); it != Tabs.end(); ++it ) 167void OTabWidget::slotTabListSelected( int index )
168{
169 TabInfoList::Iterator newtab = tabs.at( index );
170 if ( newtab != tabs.end() )
55 { 171 {
56 if ( (*it).control() == child ) 172 selectTab( newtab );
57 {
58 CurrentTab = it;
59 changeTab( (*CurrentTab).control(), loadSmooth( (*CurrentTab).icon() ), (*CurrentTab).label() );
60 }
61 } 173 }
@@ -71 +183,54 @@ QPixmap OTabWidget::loadSmooth( const QString &name )
71 183
184void OTabWidget::selectTab( TabInfoList::Iterator tab )
185{
186 if ( tabBarStyle == IconTab )
187 {
188 if ( currentTab != 0x0 )
189 {
190 tabBar->tab( (*currentTab).id() )->label = QString::null;
191 }
192 tabBar->tab( (*tab).id() )->label = (*tab).label();
193 currentTab = tab;
194 }
195 tabBar->layoutTabs();
196 tabBar->update();
197
198 widgetStack->raiseWidget( (*tab).control() );
199
200 setUpLayout( FALSE );
201}
202
203void OTabWidget::setUpLayout( bool onlyCheck )
204{
205 QSize t( tabBarStack->sizeHint() );
206 if ( t.width() > width() )
207 t.setWidth( width() );
208 int lw = widgetStack->lineWidth();
209 if ( tabBarPosition == Bottom )
210 {
211 tabBarStack->setGeometry( QMAX(0, lw-2), height() - t.height() - lw, t.width(), t.height() );
212 widgetStack->setGeometry( 0, 0, width(), height()-t.height()+QMAX(0, lw-2) );
213 }
214 else
215 { // Top
216 tabBarStack->setGeometry( QMAX(0, lw-2), 0, t.width(), t.height() );
217 widgetStack->setGeometry( 0, t.height()-lw, width(), height()-t.height()+QMAX(0, lw-2));
218 }
219
220 if ( !onlyCheck )
221 update();
222 if ( autoMask() )
223 updateMask();
224}
225
226QSize OTabWidget::sizeHint() const
227{
228 QSize s( widgetStack->sizeHint() );
229 QSize t( tabBarStack->sizeHint() );
230 return QSize( QMAX( s.width(), t.width()), s.height() + t.height() );
231}
232
233void OTabWidget::resizeEvent( QResizeEvent * )
234{
235 setUpLayout( FALSE );
236}
diff --git a/noncore/settings/sysinfo/otabwidget.h b/noncore/settings/sysinfo/otabwidget.h
index 4588cb9..38f4d20 100644
--- a/noncore/settings/sysinfo/otabwidget.h
+++ b/noncore/settings/sysinfo/otabwidget.h
@@ -22,3 +22,8 @@
22 22
23#include <qtabwidget.h> 23#include <qwidget.h>
24
25class QComboBox;
26class QPixmap;
27class QTabBar;
28class QWidgetStack;
24 29
@@ -27,12 +32,14 @@ class TabInfo
27public: 32public:
28 TabInfo() : c( 0 ), i( 0 ), l( QString::null ) {} 33 TabInfo() : i( -1 ), c( 0 ), p( 0 ), l( QString::null ) {}
29 TabInfo( QWidget *control, const QString &icon, const QString &label ) 34 TabInfo( int id, QWidget *control, const QString &icon, const QString &label )
30 : c( control ), i( icon ), l( label ) {} 35 : i( id ), c( control ), p( icon ), l( label ) {}
36 int id() const { return i; }
31 QString label() const { return l; } 37 QString label() const { return l; }
32 QWidget *control() const { return c; } 38 QWidget *control() const { return c; }
33 QString icon() const { return i; } 39 QString icon() const { return p; }
34 40
35private: 41private:
42 int i;
36 QWidget *c; 43 QWidget *c;
37 QString i; 44 QString p;
38 QString l; 45 QString l;
@@ -42,3 +49,3 @@ typedef QValueList<TabInfo> TabInfoList;
42 49
43class OTabWidget : public QTabWidget 50class OTabWidget : public QWidget
44{ 51{
@@ -46,3 +53,11 @@ class OTabWidget : public QTabWidget
46public: 53public:
47 OTabWidget( QWidget *, const char * ); 54 enum TabStyle { Global, TextTab, IconTab, TextList, IconList };
55 TabStyle tabStyle() const;
56 void setTabStyle( TabStyle );
57
58 enum TabPosition { Top, Bottom };
59 TabPosition tabPosition() const;
60 void setTabPosition( TabPosition );
61
62 OTabWidget( QWidget *, const char *, TabStyle, TabPosition );
48 ~OTabWidget(); 63 ~OTabWidget();
@@ -50,11 +65,28 @@ public:
50 void addTab( QWidget *, const QString &, const QString & ); 65 void addTab( QWidget *, const QString &, const QString & );
66 QSize sizeHint() const;
67
68
69protected:
70 void resizeEvent( QResizeEvent * );
51 71
52private: 72private:
53 TabInfoList Tabs; 73 TabInfoList tabs;
54 TabInfoList::Iterator CurrentTab; 74 TabInfoList::Iterator currentTab;
75
76 TabStyle tabBarStyle;
77 TabPosition tabBarPosition;
78
79 QWidgetStack *tabBarStack;
80 QTabBar *tabBar;
81 QComboBox *tabList;
82
83 QWidgetStack *widgetStack;
55 84
56 QPixmap loadSmooth( const QString & ); 85 QPixmap loadSmooth( const QString & );
86 void selectTab( TabInfoList::Iterator );
87 void setUpLayout( bool );
57 88
58private slots: 89private slots:
59 void tabChangedSlot( QWidget * ); 90 void slotTabBarSelected( int );
91 void slotTabListSelected( int );
60}; 92};
diff --git a/noncore/settings/sysinfo/sysinfo.cpp b/noncore/settings/sysinfo/sysinfo.cpp
index 56ac488..ca08ae2 100644
--- a/noncore/settings/sysinfo/sysinfo.cpp
+++ b/noncore/settings/sysinfo/sysinfo.cpp
@@ -30,2 +30,3 @@
30 30
31#include <qpe/config.h>
31#include <qpe/resource.h> 32#include <qpe/resource.h>
@@ -39,4 +40,11 @@ SystemInfo::SystemInfo( QWidget *parent, const char *name, WFlags f )
39 setCaption( tr("System Info") ); 40 setCaption( tr("System Info") );
41
42 resize( 220, 180 );
43
44 Config config( "qpe" );
45 config.setGroup( "Appearance" );
46 bool advanced = config.readBoolEntry( "Advanced", TRUE );
47
40 QVBoxLayout *lay = new QVBoxLayout( this ); 48 QVBoxLayout *lay = new QVBoxLayout( this );
41 OTabWidget *tab = new OTabWidget( this, "tabwidget" ); 49 OTabWidget *tab = new OTabWidget( this, "tabwidget", OTabWidget::Global, OTabWidget::Bottom );
42 lay->addWidget( tab ); 50 lay->addWidget( tab );
@@ -47,7 +55,9 @@ SystemInfo::SystemInfo( QWidget *parent, const char *name, WFlags f )
47 tab->addTab( new LoadInfo( tab ), "sysinfo/cputabicon.png", tr("CPU") ); 55 tab->addTab( new LoadInfo( tab ), "sysinfo/cputabicon.png", tr("CPU") );
48 tab->addTab( new ProcessInfo( tab ), "sysinfo/processtabicon.png", tr("Process") ); 56 if ( advanced )
49 tab->addTab( new ModulesInfo( tab ), "sysinfo/moduletabicon.png", tr("Modules") ); 57 {
58 tab->addTab( new ProcessInfo( tab ), "sysinfo/processtabicon.png", tr("Process") );
59 tab->addTab( new ModulesInfo( tab ), "sysinfo/moduletabicon.png", tr("Modules") );
60 }
50 tab->addTab( new VersionInfo( tab ), "sysinfo/versiontabicon.png", tr("Version") ); 61 tab->addTab( new VersionInfo( tab ), "sysinfo/versiontabicon.png", tr("Version") );
51 62
52 resize( 220, 180 );
53} 63}