-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 | |||
@@ -3,6 +3,6 @@ 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 |
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 | |||
@@ -19,2 +19,6 @@ | |||
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | ** | ||
21 | ** Enhancements by: Dan Williams, <williamsdr@acm.org> | ||
22 | ** | ||
23 | **********************************************************************/ | ||
20 | 24 | ||
@@ -28,3 +32,3 @@ | |||
28 | 32 | ||
29 | #include "otabwidget.h" | 33 | #include <opie/otabwidget.h> |
30 | 34 | ||
@@ -48,3 +52,3 @@ SystemInfo::SystemInfo( QWidget *parent, const char *name, WFlags f ) | |||
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 ); |
@@ -62,2 +66,3 @@ SystemInfo::SystemInfo( QWidget *parent, const char *name, WFlags f ) | |||
62 | 66 | ||
67 | tab->setCurrentTab( tr( "Memory" ) ); | ||
63 | } | 68 | } |
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 | |||
@@ -19,2 +19,6 @@ | |||
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | ** | ||
21 | ** Enhancements by: Dan Williams, <williamsdr@acm.org> | ||
22 | ** | ||
23 | **********************************************************************/ | ||
20 | 24 | ||
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 | |||
@@ -12,3 +12,2 @@ HEADERS = memory.h \ | |||
12 | versioninfo.h \ | 12 | versioninfo.h \ |
13 | otabwidget.h \ | ||
14 | sysinfo.h | 13 | sysinfo.h |
@@ -24,3 +23,2 @@ SOURCES = main.cpp \ | |||
24 | versioninfo.cpp \ | 23 | versioninfo.cpp \ |
25 | otabwidget.cpp \ | ||
26 | sysinfo.cpp | 24 | sysinfo.cpp |
@@ -29,3 +27,3 @@ INCLUDEPATH += $(OPIEDIR)/include | |||
29 | DEPENDPATH += $(OPIEDIR)/include | 27 | DEPENDPATH += $(OPIEDIR)/include |
30 | LIBS += -lqpe | 28 | LIBS += -lqpe -lopie |
31 | TARGET = sysinfo | 29 | TARGET = sysinfo |