author | drw <drw> | 2002-07-16 01:08:45 (UTC) |
---|---|---|
committer | drw <drw> | 2002-07-16 01:08:45 (UTC) |
commit | b1849c87eade2706908caddeda5924866c040441 (patch) (unidiff) | |
tree | f36cbfb15eaa2eeea9f20438a5655188ee6165ab /noncore/settings/sysinfo/otabwidget.cpp | |
parent | 72eb74051ed8f1b7696041e241ab99df3af5b08d (diff) | |
download | opie-b1849c87eade2706908caddeda5924866c040441.zip opie-b1849c87eade2706908caddeda5924866c040441.tar.gz opie-b1849c87eade2706908caddeda5924866c040441.tar.bz2 |
New tab widget
Diffstat (limited to 'noncore/settings/sysinfo/otabwidget.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/settings/sysinfo/otabwidget.cpp | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/noncore/settings/sysinfo/otabwidget.cpp b/noncore/settings/sysinfo/otabwidget.cpp new file mode 100644 index 0000000..5d5b3e6 --- a/dev/null +++ b/noncore/settings/sysinfo/otabwidget.cpp | |||
@@ -0,0 +1,71 @@ | |||
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/resource.h> | ||
23 | |||
24 | #include <qlist.h> | ||
25 | #include <qtabbar.h> | ||
26 | |||
27 | |||
28 | OTabWidget::OTabWidget( QWidget *parent, const char *name ) | ||
29 | : QTabWidget( parent, name ) | ||
30 | { | ||
31 | connect( this, SIGNAL( currentChanged( QWidget * ) ), | ||
32 | this, SLOT( tabChangedSlot( QWidget * ) ) ); | ||
33 | } | ||
34 | |||
35 | OTabWidget::~OTabWidget() | ||
36 | { | ||
37 | } | ||
38 | |||
39 | void OTabWidget::addTab( QWidget *child, const QString &icon, const QString &label ) | ||
40 | { | ||
41 | Tabs.append( TabInfo( child, icon, label ) ); | ||
42 | QTabWidget::addTab( child, loadSmooth( icon ), QString::null ); | ||
43 | } | ||
44 | |||
45 | void OTabWidget::tabChangedSlot( QWidget *child ) | ||
46 | { | ||
47 | TabInfoList::Iterator it; | ||
48 | |||
49 | if ( CurrentTab != 0x0 ) | ||
50 | { | ||
51 | changeTab( (*CurrentTab).control(), loadSmooth( (*CurrentTab).icon() ), QString::null ); | ||
52 | } | ||
53 | |||
54 | for ( it = Tabs.begin(); it != Tabs.end(); ++it ) | ||
55 | { | ||
56 | if ( (*it).control() == child ) | ||
57 | { | ||
58 | CurrentTab = it; | ||
59 | changeTab( (*CurrentTab).control(), loadSmooth( (*CurrentTab).icon() ), (*CurrentTab).label() ); | ||
60 | } | ||
61 | } | ||
62 | } | ||
63 | |||
64 | QPixmap OTabWidget::loadSmooth( const QString &name ) | ||
65 | { | ||
66 | QImage image = Resource::loadImage( name ); | ||
67 | QPixmap pixmap; | ||
68 | pixmap.convertFromImage( image.smoothScale( 16, 16 ) ); | ||
69 | return pixmap; | ||
70 | } | ||
71 | |||