summaryrefslogtreecommitdiff
authordrw <drw>2002-08-21 11:47:05 (UTC)
committer drw <drw>2002-08-21 11:47:05 (UTC)
commite6ef02a9d44bc0ca5dcffad27faa781f5fbd573e (patch) (unidiff)
tree3d6b8db9dc1a23e47a4598bfca30296618e4ef80
parent646e6491e62c73903d330881ca6781bfc2c234f1 (diff)
downloadopie-e6ef02a9d44bc0ca5dcffad27faa781f5fbd573e.zip
opie-e6ef02a9d44bc0ca5dcffad27faa781f5fbd573e.tar.gz
opie-e6ef02a9d44bc0ca5dcffad27faa781f5fbd573e.tar.bz2
Now use libopie OTabWidget
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/sysinfo/opie-sysinfo.control4
-rw-r--r--noncore/settings/sysinfo/otabwidget.cpp264
-rw-r--r--noncore/settings/sysinfo/otabwidget.h97
-rw-r--r--noncore/settings/sysinfo/sysinfo.cpp9
-rw-r--r--noncore/settings/sysinfo/sysinfo.h4
-rw-r--r--noncore/settings/sysinfo/sysinfo.pro4
6 files changed, 14 insertions, 368 deletions
diff --git a/noncore/settings/sysinfo/opie-sysinfo.control b/noncore/settings/sysinfo/opie-sysinfo.control
index 415854c..796f734 100644
--- a/noncore/settings/sysinfo/opie-sysinfo.control
+++ b/noncore/settings/sysinfo/opie-sysinfo.control
@@ -1,9 +1,9 @@
1Files: bin/sysinfo apps/Applications/sysinfo.desktop pics/sysinfo 1Files: bin/sysinfo apps/Applications/sysinfo.desktop pics/sysinfo
2Priority: optional 2Priority: optional
3Section: opie/applications 3Section: opie/applications
4Maintainer: Warwick Allison <warwick@trolltech.com> 4Maintainer: Dan Williams <wiliamsdr@acm.org>
5Architecture: arm 5Architecture: arm
6Version: $QPE_VERSION-$SUB_VERSION 6Version: $QPE_VERSION-$SUB_VERSION
7Depends: opie-base ($QPE_VERSION) 7Depends: opie-base ($QPE_VERSION), libopie ($QPE_VERSION)
8Description: System Information dialog 8Description: System Information dialog
9 For the Opie environment. 9 For the Opie environment.
diff --git a/noncore/settings/sysinfo/otabwidget.cpp b/noncore/settings/sysinfo/otabwidget.cpp
deleted file mode 100644
index 9fe6c4b..0000000
--- a/noncore/settings/sysinfo/otabwidget.cpp
+++ b/dev/null
@@ -1,264 +0,0 @@
1/**********************************************************************
2** OTabWidget
3**
4** Modified tab widget control
5**
6** Copyright (C) 2002, Dan Williams
7** williamsdr@acm.org
8** http://draknor.net
9**
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
12** Foundation and appearing in the file LICENSE.GPL included in the
13** packaging of this file.
14**
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.
17**
18**********************************************************************/
19
20#include "otabwidget.h"
21
22#include <qpe/config.h>
23#include <qpe/resource.h>
24
25#include <qcombobox.h>
26#include <qtabbar.h>
27#include <qwidgetstack.h>
28
29OTabWidget::OTabWidget( QWidget *parent, const char *name = 0x0,
30 TabStyle s = Global, TabPosition p = Top )
31 : QWidget( parent, name )
32{
33 if ( s == Global )
34 {
35 Config config( "qpe" );
36 config.setGroup( "Appearance" );
37 tabBarStyle = ( TabStyle ) config.readNumEntry( "TabStyle", (int) IconTab );
38 if ( tabBarStyle <= Global || tabBarStyle > IconList)
39 {
40 tabBarStyle = IconTab;
41 }
42 QString pos = config.readEntry( "TabPosition", "Top");
43 if ( pos == "Top" )
44 {
45 tabBarPosition = Top;
46 }
47 else
48 {
49 tabBarPosition = Bottom;
50 }
51 }
52 else
53 {
54 tabBarStyle = s;
55 tabBarPosition = p;
56 }
57
58 widgetStack = new QWidgetStack( this, "widgetstack" );
59 widgetStack->setFrameStyle( QFrame::StyledPanel | QFrame::Raised );
60 widgetStack->setLineWidth( style().defaultFrameWidth() );
61
62 tabBarStack = new QWidgetStack( this, "tabbarstack" );
63
64 tabBar = new QTabBar( tabBarStack, "tabbar" );
65 tabBarStack->addWidget( tabBar, 0 );
66 connect( tabBar, SIGNAL( selected( int ) ), this, SLOT( slotTabBarSelected( int ) ) );
67
68 tabList = new QComboBox( false, tabBarStack, "tablist" );
69 tabBarStack->addWidget( tabList, 1 );
70 connect( tabList, SIGNAL( activated( int ) ), this, SLOT( slotTabListSelected( int ) ) );
71
72 if ( tabBarStyle == TextTab || tabBarStyle == IconTab )
73 {
74 tabBarStack->raiseWidget( tabBar );
75 }
76 else if ( tabBarStyle == TextList || tabBarStyle == IconList )
77 {
78 tabBarStack->raiseWidget( tabList );
79 }
80
81 if ( tabBarPosition == Bottom )
82 {
83 tabBar->setShape( QTabBar::RoundedBelow );
84 }
85
86 currentTab= 0x0;
87}
88
89OTabWidget::~OTabWidget()
90{
91}
92
93void OTabWidget::addTab( QWidget *child, const QString &icon, const QString &label )
94{
95 QPixmap iconset = loadSmooth( icon );
96
97 // Add to tabBar
98 QTab * tab = new QTab();
99 if ( tabBarStyle == IconTab )
100 {
101 tab->label = QString::null;
102 }
103 else
104 {
105 tab->label = label;
106 }
107 if ( tabBarStyle == IconTab || tabBarStyle == IconList)
108 {
109 tab->iconset = new QIconSet( iconset );
110 }
111 int tabid = tabBar->addTab( tab );
112
113 // Add to tabList
114 if ( tabBarStyle == IconTab || tabBarStyle == IconList )
115 {
116 tabList->insertItem( iconset, label, -1 );
117 }
118 else
119 {
120 tabList->insertItem( label );
121 }
122
123 // Add child to widget list
124 widgetStack->addWidget( child, tabid );
125 widgetStack->raiseWidget( child );
126
127 // Save tab information
128 TabInfo *tabinfo = new TabInfo( tabid, child, icon, label );
129 tabs.append( tabinfo );
130 selectTab( tabinfo );
131
132// setUpLayout();
133}
134
135void OTabWidget::setCurrentTab( QWidget *childwidget )
136{
137 TabInfo *newtab = tabs.first();
138 while ( newtab && newtab->control() != childwidget )
139 {
140 newtab = tabs.next();
141 }
142 if ( newtab && newtab->control() == childwidget )
143 {
144 selectTab( newtab );
145 }
146}
147
148void OTabWidget::setCurrentTab( QString tabname )
149{
150 TabInfo *newtab = tabs.first();
151 while ( newtab && newtab->label() != tabname )
152 {
153 newtab = tabs.next();
154 }
155 if ( newtab && newtab->label() == tabname )
156 {
157 selectTab( newtab );
158 }
159}
160
161OTabWidget::TabStyle OTabWidget::tabStyle() const
162{
163 return tabBarStyle;
164}
165
166void OTabWidget::setTabStyle( TabStyle s )
167{
168 tabBarStyle = s;
169}
170
171OTabWidget::TabPosition OTabWidget::tabPosition() const
172{
173 return tabBarPosition;
174}
175
176void OTabWidget::setTabPosition( TabPosition p )
177{
178 tabBarPosition = p;
179}
180
181void OTabWidget::slotTabBarSelected( int id )
182{
183 TabInfo *newtab = tabs.first();
184 while ( newtab && newtab->id() != id )
185 {
186 newtab = tabs.next();
187 }
188 if ( newtab && newtab->id() == id )
189 {
190 selectTab( newtab );
191 }
192}
193
194void OTabWidget::slotTabListSelected( int index )
195{
196 TabInfo *newtab = tabs.at( index );
197 if ( newtab )
198 {
199 selectTab( newtab );
200 }
201}
202
203QPixmap OTabWidget::loadSmooth( const QString &name )
204{
205 QImage image = Resource::loadImage( name );
206 QPixmap pixmap;
207 pixmap.convertFromImage( image.smoothScale( 16, 16 ) );
208 return pixmap;
209}
210
211void OTabWidget::selectTab( TabInfo *tab )
212{
213 if ( tabBarStyle == IconTab )
214 {
215 if ( currentTab )
216 {
217 tabBar->tab( currentTab->id() )->setText( QString::null );
218 setUpLayout();
219 }
220 tabBar->tab( tab->id() )->setText( tab->label() );
221 currentTab = tab;
222 }
223 tabBar->setCurrentTab( tab->id() );
224 setUpLayout();
225 tabBar->update();
226
227 widgetStack->raiseWidget( tab->control() );
228}
229
230void OTabWidget::setUpLayout()
231{
232 tabBar->layoutTabs();
233 QSize t( tabBarStack->sizeHint() );
234 if ( t.width() > width() )
235 t.setWidth( width() );
236 int lw = widgetStack->lineWidth();
237 if ( tabBarPosition == Bottom )
238 {
239 tabBarStack->setGeometry( QMAX(0, lw-2), height() - t.height() - lw, t.width(), t.height() );
240 widgetStack->setGeometry( 0, 0, width(), height()-t.height()+QMAX(0, lw-2) );
241 }
242 else
243 { // Top
244 tabBarStack->setGeometry( QMAX(0, lw-2), 0, t.width(), t.height() );
245 widgetStack->setGeometry( 0, t.height()-lw, width(), height()-t.height()+QMAX(0, lw-2));
246 }
247
248// if ( !onlyCheck )
249// update();
250 if ( autoMask() )
251 updateMask();
252}
253
254QSize OTabWidget::sizeHint() const
255{
256 QSize s( widgetStack->sizeHint() );
257 QSize t( tabBarStack->sizeHint() );
258 return QSize( QMAX( s.width(), t.width()), s.height() + t.height() );
259}
260
261void OTabWidget::resizeEvent( QResizeEvent * )
262{
263 setUpLayout();
264}
diff --git a/noncore/settings/sysinfo/otabwidget.h b/noncore/settings/sysinfo/otabwidget.h
deleted file mode 100644
index 7450d51..0000000
--- a/noncore/settings/sysinfo/otabwidget.h
+++ b/dev/null
@@ -1,97 +0,0 @@
1/**********************************************************************
2** OTabWidget
3**
4** Modified tab widget control
5**
6** Copyright (C) 2002, Dan Williams
7** williamsdr@acm.org
8** http://draknor.net
9**
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
12** Foundation and appearing in the file LICENSE.GPL included in the
13** packaging of this file.
14**
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.
17**
18**********************************************************************/
19
20#ifndef OTABWIDGET_H
21#define OTABWIDGET_H
22
23#include <qwidget.h>
24#include <qlist.h>
25
26class QComboBox;
27class QPixmap;
28class QTabBar;
29class QWidgetStack;
30
31class TabInfo
32{
33public:
34 TabInfo() : i( -1 ), c( 0 ), p( 0 ), l( QString::null ) {}
35 TabInfo( int id, QWidget *control, const QString &icon, const QString &label )
36 : i( id ), c( control ), p( icon ), l( label ) {}
37 int id() const { return i; }
38 QString label() const { return l; }
39 QWidget *control() const { return c; }
40 QString icon() const { return p; }
41
42private:
43 int i;
44 QWidget *c;
45 QString p;
46 QString l;
47};
48
49typedef QList<TabInfo> TabInfoList;
50
51class OTabWidget : public QWidget
52{
53 Q_OBJECT
54public:
55 enum TabStyle { Global, TextTab, IconTab, TextList, IconList };
56 TabStyle tabStyle() const;
57 void setTabStyle( TabStyle );
58
59 enum TabPosition { Top, Bottom };
60 TabPosition tabPosition() const;
61 void setTabPosition( TabPosition );
62
63 OTabWidget( QWidget *, const char *, TabStyle, TabPosition );
64 ~OTabWidget();
65
66 void addTab( QWidget *, const QString &, const QString & );
67 void setCurrentTab( QWidget * );
68 void setCurrentTab( QString );
69 QSize sizeHint() const;
70
71
72protected:
73 void resizeEvent( QResizeEvent * );
74
75private:
76 TabInfoList tabs;
77 TabInfo *currentTab;
78
79 TabStyle tabBarStyle;
80 TabPosition tabBarPosition;
81
82 QWidgetStack *tabBarStack;
83 QTabBar *tabBar;
84 QComboBox *tabList;
85
86 QWidgetStack *widgetStack;
87
88 QPixmap loadSmooth( const QString & );
89 void selectTab( TabInfo * );
90 void setUpLayout();
91
92private slots:
93 void slotTabBarSelected( int );
94 void slotTabListSelected( int );
95};
96
97#endif
diff --git a/noncore/settings/sysinfo/sysinfo.cpp b/noncore/settings/sysinfo/sysinfo.cpp
index ca08ae2..a6d7f1c 100644
--- a/noncore/settings/sysinfo/sysinfo.cpp
+++ b/noncore/settings/sysinfo/sysinfo.cpp
@@ -14,22 +14,26 @@
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**
21** Enhancements by: Dan Williams, <williamsdr@acm.org>
22**
23**********************************************************************/
20 24
21#include "memory.h" 25#include "memory.h"
22#include "load.h" 26#include "load.h"
23#include "storage.h" 27#include "storage.h"
24#include "processinfo.h" 28#include "processinfo.h"
25#include "modulesinfo.h" 29#include "modulesinfo.h"
26#include "versioninfo.h" 30#include "versioninfo.h"
27#include "sysinfo.h" 31#include "sysinfo.h"
28 32
29#include "otabwidget.h" 33#include <opie/otabwidget.h>
30 34
31#include <qpe/config.h> 35#include <qpe/config.h>
32#include <qpe/resource.h> 36#include <qpe/resource.h>
33 37
34#include <qlayout.h> 38#include <qlayout.h>
35 39
@@ -43,13 +47,13 @@ SystemInfo::SystemInfo( QWidget *parent, const char *name, WFlags f )
43 47
44 Config config( "qpe" ); 48 Config config( "qpe" );
45 config.setGroup( "Appearance" ); 49 config.setGroup( "Appearance" );
46 bool advanced = config.readBoolEntry( "Advanced", TRUE ); 50 bool advanced = config.readBoolEntry( "Advanced", TRUE );
47 51
48 QVBoxLayout *lay = new QVBoxLayout( this ); 52 QVBoxLayout *lay = new QVBoxLayout( this );
49 OTabWidget *tab = new OTabWidget( this, "tabwidget", OTabWidget::Global, OTabWidget::Bottom ); 53 OTabWidget *tab = new OTabWidget( this, "tabwidget", OTabWidget::Global );
50 lay->addWidget( tab ); 54 lay->addWidget( tab );
51 tab->addTab( new MemoryInfo( tab ), "sysinfo/memorytabicon.png", tr("Memory") ); 55 tab->addTab( new MemoryInfo( tab ), "sysinfo/memorytabicon.png", tr("Memory") );
52#if defined(_OS_LINUX_) || defined(Q_OS_LINUX) 56#if defined(_OS_LINUX_) || defined(Q_OS_LINUX)
53 tab->addTab( new StorageInfo( tab ), "sysinfo/storagetabicon.png", tr("Storage") ); 57 tab->addTab( new StorageInfo( tab ), "sysinfo/storagetabicon.png", tr("Storage") );
54#endif 58#endif
55 tab->addTab( new LoadInfo( tab ), "sysinfo/cputabicon.png", tr("CPU") ); 59 tab->addTab( new LoadInfo( tab ), "sysinfo/cputabicon.png", tr("CPU") );
@@ -57,9 +61,10 @@ SystemInfo::SystemInfo( QWidget *parent, const char *name, WFlags f )
57 { 61 {
58 tab->addTab( new ProcessInfo( tab ), "sysinfo/processtabicon.png", tr("Process") ); 62 tab->addTab( new ProcessInfo( tab ), "sysinfo/processtabicon.png", tr("Process") );
59 tab->addTab( new ModulesInfo( tab ), "sysinfo/moduletabicon.png", tr("Modules") ); 63 tab->addTab( new ModulesInfo( tab ), "sysinfo/moduletabicon.png", tr("Modules") );
60 } 64 }
61 tab->addTab( new VersionInfo( tab ), "sysinfo/versiontabicon.png", tr("Version") ); 65 tab->addTab( new VersionInfo( tab ), "sysinfo/versiontabicon.png", tr("Version") );
62 66
67 tab->setCurrentTab( tr( "Memory" ) );
63} 68}
64 69
65 70
diff --git a/noncore/settings/sysinfo/sysinfo.h b/noncore/settings/sysinfo/sysinfo.h
index abbf955..91eba9d 100644
--- a/noncore/settings/sysinfo/sysinfo.h
+++ b/noncore/settings/sysinfo/sysinfo.h
@@ -14,12 +14,16 @@
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**
21** Enhancements by: Dan Williams, <williamsdr@acm.org>
22**
23**********************************************************************/
20 24
21#include <qwidget.h> 25#include <qwidget.h>
22 26
23class SystemInfo : public QWidget 27class SystemInfo : public QWidget
24{ 28{
25 Q_OBJECT 29 Q_OBJECT
diff --git a/noncore/settings/sysinfo/sysinfo.pro b/noncore/settings/sysinfo/sysinfo.pro
index a5adb26..231085d 100644
--- a/noncore/settings/sysinfo/sysinfo.pro
+++ b/noncore/settings/sysinfo/sysinfo.pro
@@ -7,30 +7,28 @@ HEADERS = memory.h \
7 storage.h \ 7 storage.h \
8 processinfo.h \ 8 processinfo.h \
9 processdetail.h \ 9 processdetail.h \
10 modulesinfo.h \ 10 modulesinfo.h \
11 modulesdetail.h \ 11 modulesdetail.h \
12 versioninfo.h \ 12 versioninfo.h \
13 otabwidget.h \
14 sysinfo.h 13 sysinfo.h
15SOURCES = main.cpp \ 14SOURCES = main.cpp \
16 memory.cpp \ 15 memory.cpp \
17 graph.cpp \ 16 graph.cpp \
18 load.cpp \ 17 load.cpp \
19 storage.cpp \ 18 storage.cpp \
20 processinfo.cpp \ 19 processinfo.cpp \
21 modulesinfo.cpp \ 20 modulesinfo.cpp \
22 processdetail.cpp \ 21 processdetail.cpp \
23 modulesdetail.cpp \ 22 modulesdetail.cpp \
24 versioninfo.cpp \ 23 versioninfo.cpp \
25 otabwidget.cpp \
26 sysinfo.cpp 24 sysinfo.cpp
27INTERFACES = 25INTERFACES =
28INCLUDEPATH += $(OPIEDIR)/include 26INCLUDEPATH += $(OPIEDIR)/include
29DEPENDPATH += $(OPIEDIR)/include 27DEPENDPATH += $(OPIEDIR)/include
30LIBS += -lqpe 28LIBS += -lqpe -lopie
31TARGET = sysinfo 29TARGET = sysinfo
32 30
33TRANSLATIONS = ../../../i18n/de/sysinfo.ts \ 31TRANSLATIONS = ../../../i18n/de/sysinfo.ts \
34 ../../../i18n/en/sysinfo.ts \ 32 ../../../i18n/en/sysinfo.ts \
35 ../../../i18n/es/sysinfo.ts \ 33 ../../../i18n/es/sysinfo.ts \
36 ../../../i18n/fr/sysinfo.ts \ 34 ../../../i18n/fr/sysinfo.ts \