summaryrefslogtreecommitdiff
authordrw <drw>2005-03-01 00:16:32 (UTC)
committer drw <drw>2005-03-01 00:16:32 (UTC)
commit73faad9d936d5af7a331411a9572fd362907e023 (patch) (unidiff)
treeaaa2b212906baba1b5c25d772b9a181f52f05284
parent2daad674b92c1fd94b0260a15f0baa732e5db20e (diff)
downloadopie-73faad9d936d5af7a331411a9572fd362907e023.zip
opie-73faad9d936d5af7a331411a9572fd362907e023.tar.gz
opie-73faad9d936d5af7a331411a9572fd362907e023.tar.bz2
Provide initial values for tab bar style & position
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opieui/otabwidget.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/libopie2/opieui/otabwidget.cpp b/libopie2/opieui/otabwidget.cpp
index 01747e1..ae396b9 100644
--- a/libopie2/opieui/otabwidget.cpp
+++ b/libopie2/opieui/otabwidget.cpp
@@ -1,176 +1,178 @@
1/* 1/*
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 3
4 Copyright (c) 2002, 2005 Dan Williams <drw@handhelds.org> 4 Copyright (c) 2002, 2005 Dan Williams <drw@handhelds.org>
5 =. 5 =.
6 .=l. 6 .=l.
7 .>+-= 7 .>+-=
8_;:, .> :=|. This program is free software; you can 8_;:, .> :=|. This program is free software; you can
9.> <`_, > . <= redistribute it and/or modify it under 9.> <`_, > . <= redistribute it and/or modify it under
10:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 10:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
11.="- .-=="i, .._ License as published by the Free Software 11.="- .-=="i, .._ License as published by the Free Software
12- . .-<_> .<> Foundation; either version 2 of the License, 12- . .-<_> .<> Foundation; either version 2 of the License,
13 ._= =} : or (at your option) any later version. 13 ._= =} : or (at your option) any later version.
14 .%`+i> _;_. 14 .%`+i> _;_.
15 .i_,=:_. -<s. This program is distributed in the hope that 15 .i_,=:_. -<s. This program is distributed in the hope that
16 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 16 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
17 : .. .:, . . . without even the implied warranty of 17 : .. .:, . . . without even the implied warranty of
18 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 18 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
19 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 19 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
20..}^=.= = ; Library General Public License for more 20..}^=.= = ; Library General Public License for more
21++= -. .` .: details. 21++= -. .` .: details.
22: = ...= . :.=- 22: = ...= . :.=-
23-. .:....=;==+<; You should have received a copy of the GNU 23-. .:....=;==+<; You should have received a copy of the GNU
24 -_. . . )=. = Library General Public License along with 24 -_. . . )=. = Library General Public License along with
25 -- :-=` this library; see the file COPYING.LIB. 25 -- :-=` this library; see the file COPYING.LIB.
26 If not, write to the Free Software Foundation, 26 If not, write to the Free Software Foundation,
27 Inc., 59 Temple Place - Suite 330, 27 Inc., 59 Temple Place - Suite 330,
28 Boston, MA 02111-1307, USA. 28 Boston, MA 02111-1307, USA.
29 29
30*/ 30*/
31 31
32#include <opie2/otabwidget.h> 32#include <opie2/otabwidget.h>
33 33
34/* OPIE */ 34/* OPIE */
35#include <qpe/applnk.h> 35#include <qpe/applnk.h>
36#include <qpe/config.h> 36#include <qpe/config.h>
37#include <qpe/resource.h> 37#include <qpe/resource.h>
38#include <opie2/otabbar.h> 38#include <opie2/otabbar.h>
39 39
40/* QT */ 40/* QT */
41#include <qcombobox.h> 41#include <qcombobox.h>
42#include <qwidgetstack.h> 42#include <qwidgetstack.h>
43 43
44using namespace Opie::Ui; 44using namespace Opie::Ui;
45 45
46OTabWidget::OTabWidget( QWidget *parent, const char *name, TabStyle s, TabPosition p ) 46OTabWidget::OTabWidget( QWidget *parent, const char *name, TabStyle s, TabPosition p )
47 : QWidget( parent, name ) 47 : QWidget( parent, name )
48 , m_currTab( 0l ) 48 , m_currTab( 0l )
49 , m_tabBarStyle( Global )
50 , m_tabBarPosition( Top )
49 , m_usingTabs( true ) 51 , m_usingTabs( true )
50 , m_tabBar( 0l ) 52 , m_tabBar( 0l )
51 , m_tabList( 0l ) 53 , m_tabList( 0l )
52{ 54{
53 if ( s == Global ) 55 if ( s == Global )
54 { 56 {
55 // Read Opie global settings for style and position 57 // Read Opie global settings for style and position
56 Config config( "qpe" ); 58 Config config( "qpe" );
57 config.setGroup( "Appearance" ); 59 config.setGroup( "Appearance" );
58 60
59 // Style 61 // Style
60 s = ( TabStyle ) config.readNumEntry( "TabStyle", (int) IconTab ); 62 s = ( TabStyle ) config.readNumEntry( "TabStyle", (int) IconTab );
61 if ( s <= Global || s > IconList) 63 if ( s <= Global || s > IconList)
62 s = IconTab; 64 s = IconTab;
63 65
64 // Position 66 // Position
65 ( config.readEntry( "TabPosition", "Top" ) == "Bottom" ) ? p = Bottom 67 ( config.readEntry( "TabPosition", "Top" ) == "Bottom" ) ? p = Bottom
66 : p = Top; 68 : p = Top;
67 } 69 }
68 70
69 // Initialize widget stack for tab widgets 71 // Initialize widget stack for tab widgets
70 m_widgetStack = new QWidgetStack( this ); 72 m_widgetStack = new QWidgetStack( this );
71 m_widgetStack->setFrameStyle( QFrame::NoFrame ); 73 m_widgetStack->setFrameStyle( QFrame::NoFrame );
72 m_widgetStack->setLineWidth( style().defaultFrameWidth() ); 74 m_widgetStack->setLineWidth( style().defaultFrameWidth() );
73 75
74 // Set initial selector control style and position 76 // Set initial selector control style and position
75 setTabStyle( s ); 77 setTabStyle( s );
76 setTabPosition( p ); 78 setTabPosition( p );
77} 79}
78 80
79OTabWidget::~OTabWidget() 81OTabWidget::~OTabWidget()
80{ 82{
81 m_tabs.setAutoDelete( true ); 83 m_tabs.setAutoDelete( true );
82 m_tabs.clear(); 84 m_tabs.clear();
83} 85}
84 86
85void OTabWidget::addTab( QWidget *child, const QString &icon, const QString &label ) 87void OTabWidget::addTab( QWidget *child, const QString &icon, const QString &label )
86{ 88{
87 int tabid = -1; 89 int tabid = -1;
88 90
89 if ( m_usingTabs ) 91 if ( m_usingTabs )
90 { 92 {
91 // Create new tab in tab bar 93 // Create new tab in tab bar
92 QTab *tab = new QTab(); 94 QTab *tab = new QTab();
93 95
94 // Set label (and icon if necessary) 96 // Set label (and icon if necessary)
95 if ( m_tabBarStyle == IconTab ) 97 if ( m_tabBarStyle == IconTab )
96 { 98 {
97 tab->label = QString::null; 99 tab->label = QString::null;
98 tab->iconset = new QIconSet( loadSmooth( icon ) ); 100 tab->iconset = new QIconSet( loadSmooth( icon ) );
99 } 101 }
100 else 102 else
101 tab->label = label; 103 tab->label = label;
102 104
103 tabid = m_tabBar->addTab( tab ); 105 tabid = m_tabBar->addTab( tab );
104 } 106 }
105 else 107 else
106 { 108 {
107 // Insert entry (with icon if necessary) into drop down list 109 // Insert entry (with icon if necessary) into drop down list
108 if ( m_tabBarStyle == IconList ) 110 if ( m_tabBarStyle == IconList )
109 m_tabList->insertItem( loadSmooth( icon ), label, -1 ); 111 m_tabList->insertItem( loadSmooth( icon ), label, -1 );
110 else 112 else
111 m_tabList->insertItem( label ); 113 m_tabList->insertItem( label );
112 } 114 }
113 115
114 // Add widget to stack 116 // Add widget to stack
115 m_widgetStack->addWidget( child, tabid ); 117 m_widgetStack->addWidget( child, tabid );
116 m_widgetStack->raiseWidget( child ); 118 m_widgetStack->raiseWidget( child );
117 m_widgetStack->setFrameStyle( QFrame::StyledPanel | QFrame::Raised ); 119 m_widgetStack->setFrameStyle( QFrame::StyledPanel | QFrame::Raised );
118 120
119 // Keep track of tab information 121 // Keep track of tab information
120 OTabInfo *tabinfo = new OTabInfo( tabid, child, icon, label ); 122 OTabInfo *tabinfo = new OTabInfo( tabid, child, icon, label );
121 m_tabs.append( tabinfo ); 123 m_tabs.append( tabinfo );
122 124
123 // Make newly added tab the current one displayed 125 // Make newly added tab the current one displayed
124 selectTab( tabinfo ); 126 selectTab( tabinfo );
125} 127}
126 128
127void OTabWidget::removePage( QWidget *childwidget ) 129void OTabWidget::removePage( QWidget *childwidget )
128{ 130{
129 if ( childwidget ) 131 if ( childwidget )
130 { 132 {
131 // Find tab information for desired widget 133 // Find tab information for desired widget
132 OTabInfo *tab = m_tabs.first(); 134 OTabInfo *tab = m_tabs.first();
133 while ( tab && tab->control() != childwidget ) 135 while ( tab && tab->control() != childwidget )
134 tab = m_tabs.next(); 136 tab = m_tabs.next();
135 137
136 if ( tab && tab->control() == childwidget ) 138 if ( tab && tab->control() == childwidget )
137 { 139 {
138 if ( m_usingTabs ) 140 if ( m_usingTabs )
139 { 141 {
140 // Remove tab from tab bar 142 // Remove tab from tab bar
141 m_tabBar->setTabEnabled( tab->id(), false ); 143 m_tabBar->setTabEnabled( tab->id(), false );
142 m_tabBar->removeTab( m_tabBar->tab( tab->id() ) ); 144 m_tabBar->removeTab( m_tabBar->tab( tab->id() ) );
143 } 145 }
144 else 146 else
145 { 147 {
146 // Remove entry from drop down list 148 // Remove entry from drop down list
147 int i = 0; 149 int i = 0;
148 while ( i < m_tabList->count() && m_tabList->text( i ) != tab->label() ) 150 while ( i < m_tabList->count() && m_tabList->text( i ) != tab->label() )
149 i++; 151 i++;
150 if ( m_tabList->text( i ) == tab->label() ) 152 if ( m_tabList->text( i ) == tab->label() )
151 m_tabList->removeItem( i ); 153 m_tabList->removeItem( i );
152 } 154 }
153 155
154 // Remove widget from stack 156 // Remove widget from stack
155 m_widgetStack->removeWidget( childwidget ); 157 m_widgetStack->removeWidget( childwidget );
156 158
157 // Get rid of tab information 159 // Get rid of tab information
158 m_tabs.remove( tab ); 160 m_tabs.remove( tab );
159 delete tab; 161 delete tab;
160 162
161 // Reset current tab 163 // Reset current tab
162 m_currTab = m_tabs.current(); 164 m_currTab = m_tabs.current();
163 if ( !m_currTab ) 165 if ( !m_currTab )
164 m_widgetStack->setFrameStyle( QFrame::NoFrame ); 166 m_widgetStack->setFrameStyle( QFrame::NoFrame );
165 167
166 // Redraw widget 168 // Redraw widget
167 setUpLayout(); 169 setUpLayout();
168 } 170 }
169 } 171 }
170} 172}
171 173
172void OTabWidget::changeTab( QWidget *widget, const QString &iconset, const QString &label) 174void OTabWidget::changeTab( QWidget *widget, const QString &iconset, const QString &label)
173{ 175{
174 // Find tab information for desired widget 176 // Find tab information for desired widget
175 OTabInfo *currtab = m_tabs.first(); 177 OTabInfo *currtab = m_tabs.first();
176 while ( currtab && currtab->control() != widget ) 178 while ( currtab && currtab->control() != widget )