author | drw <drw> | 2002-08-21 11:47:05 (UTC) |
---|---|---|
committer | drw <drw> | 2002-08-21 11:47:05 (UTC) |
commit | e6ef02a9d44bc0ca5dcffad27faa781f5fbd573e (patch) (unidiff) | |
tree | 3d6b8db9dc1a23e47a4598bfca30296618e4ef80 /noncore | |
parent | 646e6491e62c73903d330881ca6781bfc2c234f1 (diff) | |
download | opie-e6ef02a9d44bc0ca5dcffad27faa781f5fbd573e.zip opie-e6ef02a9d44bc0ca5dcffad27faa781f5fbd573e.tar.gz opie-e6ef02a9d44bc0ca5dcffad27faa781f5fbd573e.tar.bz2 |
Now use libopie OTabWidget
-rw-r--r-- | noncore/settings/sysinfo/opie-sysinfo.control | 4 | ||||
-rw-r--r-- | noncore/settings/sysinfo/otabwidget.cpp | 264 | ||||
-rw-r--r-- | noncore/settings/sysinfo/otabwidget.h | 97 | ||||
-rw-r--r-- | noncore/settings/sysinfo/sysinfo.cpp | 9 | ||||
-rw-r--r-- | noncore/settings/sysinfo/sysinfo.h | 4 | ||||
-rw-r--r-- | noncore/settings/sysinfo/sysinfo.pro | 4 |
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 @@ | |||
1 | Files: bin/sysinfo apps/Applications/sysinfo.desktop pics/sysinfo | 1 | Files: bin/sysinfo apps/Applications/sysinfo.desktop pics/sysinfo |
2 | Priority: optional | 2 | Priority: optional |
3 | Section: opie/applications | 3 | Section: opie/applications |
4 | Maintainer: Warwick Allison <warwick@trolltech.com> | 4 | Maintainer: Dan Williams <wiliamsdr@acm.org> |
5 | Architecture: arm | 5 | Architecture: arm |
6 | Version: $QPE_VERSION-$SUB_VERSION | 6 | Version: $QPE_VERSION-$SUB_VERSION |
7 | Depends: opie-base ($QPE_VERSION) | 7 | Depends: opie-base ($QPE_VERSION), libopie ($QPE_VERSION) |
8 | Description: System Information dialog | 8 | Description: 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 | |||
29 | OTabWidget::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 | |||
89 | OTabWidget::~OTabWidget() | ||
90 | { | ||
91 | } | ||
92 | |||
93 | void 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 | |||
135 | void 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 | |||
148 | void 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 | |||
161 | OTabWidget::TabStyle OTabWidget::tabStyle() const | ||
162 | { | ||
163 | return tabBarStyle; | ||
164 | } | ||
165 | |||
166 | void OTabWidget::setTabStyle( TabStyle s ) | ||
167 | { | ||
168 | tabBarStyle = s; | ||
169 | } | ||
170 | |||
171 | OTabWidget::TabPosition OTabWidget::tabPosition() const | ||
172 | { | ||
173 | return tabBarPosition; | ||
174 | } | ||
175 | |||
176 | void OTabWidget::setTabPosition( TabPosition p ) | ||
177 | { | ||
178 | tabBarPosition = p; | ||
179 | } | ||
180 | |||
181 | void 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 | |||
194 | void OTabWidget::slotTabListSelected( int index ) | ||
195 | { | ||
196 | TabInfo *newtab = tabs.at( index ); | ||
197 | if ( newtab ) | ||
198 | { | ||
199 | selectTab( newtab ); | ||
200 | } | ||
201 | } | ||
202 | |||
203 | QPixmap 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 | |||
211 | void 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 | |||
230 | void 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 | |||
254 | QSize 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 | |||
261 | void 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 | |||
26 | class QComboBox; | ||
27 | class QPixmap; | ||
28 | class QTabBar; | ||
29 | class QWidgetStack; | ||
30 | |||
31 | class TabInfo | ||
32 | { | ||
33 | public: | ||
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 | |||
42 | private: | ||
43 | int i; | ||
44 | QWidget *c; | ||
45 | QString p; | ||
46 | QString l; | ||
47 | }; | ||
48 | |||
49 | typedef QList<TabInfo> TabInfoList; | ||
50 | |||
51 | class OTabWidget : public QWidget | ||
52 | { | ||
53 | Q_OBJECT | ||
54 | public: | ||
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 | |||
72 | protected: | ||
73 | void resizeEvent( QResizeEvent * ); | ||
74 | |||
75 | private: | ||
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 | |||
92 | private 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 | |||
@@ -17,6 +17,10 @@ | |||
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" |
@@ -26,7 +30,7 @@ | |||
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> |
@@ -46,7 +50,7 @@ SystemInfo::SystemInfo( QWidget *parent, const char *name, WFlags f ) | |||
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) |
@@ -60,6 +64,7 @@ SystemInfo::SystemInfo( QWidget *parent, const char *name, WFlags f ) | |||
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 | |||
@@ -17,6 +17,10 @@ | |||
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 | ||
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 | |||
@@ -10,7 +10,6 @@ HEADERS = memory.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 |
15 | SOURCES = main.cpp \ | 14 | SOURCES = main.cpp \ |
16 | memory.cpp \ | 15 | memory.cpp \ |
@@ -22,12 +21,11 @@ SOURCES = main.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 |
27 | INTERFACES = | 25 | INTERFACES = |
28 | INCLUDEPATH += $(OPIEDIR)/include | 26 | INCLUDEPATH += $(OPIEDIR)/include |
29 | DEPENDPATH += $(OPIEDIR)/include | 27 | DEPENDPATH += $(OPIEDIR)/include |
30 | LIBS += -lqpe | 28 | LIBS += -lqpe -lopie |
31 | TARGET = sysinfo | 29 | TARGET = sysinfo |
32 | 30 | ||
33 | TRANSLATIONS = ../../../i18n/de/sysinfo.ts \ | 31 | TRANSLATIONS = ../../../i18n/de/sysinfo.ts \ |