summaryrefslogtreecommitdiff
Unidiff
Diffstat (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
@@ -1,71 +1,236 @@
1/********************************************************************** 1/**********************************************************************
2** OTabWidget 2** OTabWidget
3** 3**
4** Modified tab widget control 4** Modified tab widget control
5** 5**
6** Copyright (C) 2002, Dan Williams 6** Copyright (C) 2002, Dan Williams
7** williamsdr@acm.org 7** williamsdr@acm.org
8** http://draknor.net 8** http://draknor.net
9** 9**
10** This file may be distributed and/or modified under the terms of the 10** This file may be distributed and/or modified under the terms of the
11** GNU General Public License version 2 as published by the Free Software 11** GNU General Public License version 2 as published by the Free Software
12** Foundation and appearing in the file LICENSE.GPL included in the 12** Foundation and appearing in the file LICENSE.GPL included in the
13** packaging of this file. 13** packaging of this file.
14** 14**
15** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 15** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
16** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 16** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
17** 17**
18**********************************************************************/ 18**********************************************************************/
19 19
20#include "otabwidget.h" 20#include "otabwidget.h"
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}
34 87
35OTabWidget::~OTabWidget() 88OTabWidget::~OTabWidget()
36{ 89{
37} 90}
38 91
39void OTabWidget::addTab( QWidget *child, const QString &icon, const QString &label ) 92void OTabWidget::addTab( QWidget *child, const QString &icon, const QString &label )
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 }
62} 174}
63 175
64QPixmap OTabWidget::loadSmooth( const QString &name ) 176QPixmap OTabWidget::loadSmooth( const QString &name )
65{ 177{
66 QImage image = Resource::loadImage( name ); 178 QImage image = Resource::loadImage( name );
67 QPixmap pixmap; 179 QPixmap pixmap;
68 pixmap.convertFromImage( image.smoothScale( 16, 16 ) ); 180 pixmap.convertFromImage( image.smoothScale( 16, 16 ) );
69 return pixmap; 181 return pixmap;
70} 182}
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
@@ -1,62 +1,94 @@
1/********************************************************************** 1/**********************************************************************
2** OTabWidget 2** OTabWidget
3** 3**
4** Modified tab widget control 4** Modified tab widget control
5** 5**
6** Copyright (C) 2002, Dan Williams 6** Copyright (C) 2002, Dan Williams
7** williamsdr@acm.org 7** williamsdr@acm.org
8** http://draknor.net 8** http://draknor.net
9** 9**
10** This file may be distributed and/or modified under the terms of the 10** This file may be distributed and/or modified under the terms of the
11** GNU General Public License version 2 as published by the Free Software 11** GNU General Public License version 2 as published by the Free Software
12** Foundation and appearing in the file LICENSE.GPL included in the 12** Foundation and appearing in the file LICENSE.GPL included in the
13** packaging of this file. 13** packaging of this file.
14** 14**
15** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 15** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
16** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 16** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
17** 17**
18**********************************************************************/ 18**********************************************************************/
19 19
20#ifndef OTABWIDGET_H 20#ifndef OTABWIDGET_H
21#define OTABWIDGET_H 21#define OTABWIDGET_H
22 22
23#include <qtabwidget.h> 23#include <qwidget.h>
24
25class QComboBox;
26class QPixmap;
27class QTabBar;
28class QWidgetStack;
24 29
25class TabInfo 30class TabInfo
26{ 31{
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;
39}; 46};
40 47
41typedef QValueList<TabInfo> TabInfoList; 48typedef QValueList<TabInfo> TabInfoList;
42 49
43class OTabWidget : public QTabWidget 50class OTabWidget : public QWidget
44{ 51{
45 Q_OBJECT 52 Q_OBJECT
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();
49 64
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};
61 93
62#endif 94#endif
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
@@ -1,55 +1,65 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include "memory.h" 21#include "memory.h"
22#include "load.h" 22#include "load.h"
23#include "storage.h" 23#include "storage.h"
24#include "processinfo.h" 24#include "processinfo.h"
25#include "modulesinfo.h" 25#include "modulesinfo.h"
26#include "versioninfo.h" 26#include "versioninfo.h"
27#include "sysinfo.h" 27#include "sysinfo.h"
28 28
29#include "otabwidget.h" 29#include "otabwidget.h"
30 30
31#include <qpe/config.h>
31#include <qpe/resource.h> 32#include <qpe/resource.h>
32 33
33#include <qlayout.h> 34#include <qlayout.h>
34 35
35SystemInfo::SystemInfo( QWidget *parent, const char *name, WFlags f ) 36SystemInfo::SystemInfo( QWidget *parent, const char *name, WFlags f )
36 : QWidget( parent, name, f ) 37 : QWidget( parent, name, f )
37{ 38{
38 setIcon( Resource::loadPixmap( "system_icon" ) ); 39 setIcon( Resource::loadPixmap( "system_icon" ) );
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 );
43 tab->addTab( new MemoryInfo( tab ), "sysinfo/memorytabicon.png", tr("Memory") ); 51 tab->addTab( new MemoryInfo( tab ), "sysinfo/memorytabicon.png", tr("Memory") );
44#if defined(_OS_LINUX_) || defined(Q_OS_LINUX) 52#if defined(_OS_LINUX_) || defined(Q_OS_LINUX)
45 tab->addTab( new StorageInfo( tab ), "sysinfo/storagetabicon.png", tr("Storage") ); 53 tab->addTab( new StorageInfo( tab ), "sysinfo/storagetabicon.png", tr("Storage") );
46#endif 54#endif
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}
54 64
55 65