-rw-r--r-- | microkde/kdeui/ktoolbar.cpp | 185 |
1 files changed, 98 insertions, 87 deletions
diff --git a/microkde/kdeui/ktoolbar.cpp b/microkde/kdeui/ktoolbar.cpp index 027e5e9..02db316 100644 --- a/microkde/kdeui/ktoolbar.cpp +++ b/microkde/kdeui/ktoolbar.cpp | |||
@@ -1,651 +1,662 @@ | |||
1 | /* This file is part of the KDE libraries | 1 | /* This file is part of the KDE libraries |
2 | Copyright | 2 | Copyright |
3 | (C) 2000 Reginald Stadlbauer (reggie@kde.org) | 3 | (C) 2000 Reginald Stadlbauer (reggie@kde.org) |
4 | (C) 1997, 1998 Stephan Kulow (coolo@kde.org) | 4 | (C) 1997, 1998 Stephan Kulow (coolo@kde.org) |
5 | (C) 1997, 1998 Mark Donohoe (donohoe@kde.org) | 5 | (C) 1997, 1998 Mark Donohoe (donohoe@kde.org) |
6 | (C) 1997, 1998 Sven Radej (radej@kde.org) | 6 | (C) 1997, 1998 Sven Radej (radej@kde.org) |
7 | (C) 1997, 1998 Matthias Ettrich (ettrich@kde.org) | 7 | (C) 1997, 1998 Matthias Ettrich (ettrich@kde.org) |
8 | (C) 1999 Chris Schlaeger (cs@kde.org) | 8 | (C) 1999 Chris Schlaeger (cs@kde.org) |
9 | (C) 1999 Kurt Granroth (granroth@kde.org) | 9 | (C) 1999 Kurt Granroth (granroth@kde.org) |
10 | 10 | ||
11 | This library is free software; you can redistribute it and/or | 11 | This library is free software; you can redistribute it and/or |
12 | modify it under the terms of the GNU Library General Public | 12 | modify it under the terms of the GNU Library General Public |
13 | License version 2 as published by the Free Software Foundation. | 13 | License version 2 as published by the Free Software Foundation. |
14 | 14 | ||
15 | This library is distributed in the hope that it will be useful, | 15 | This library is distributed in the hope that it will be useful, |
16 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
18 | Library General Public License for more details. | 18 | Library General Public License for more details. |
19 | 19 | ||
20 | You should have received a copy of the GNU Library General Public License | 20 | You should have received a copy of the GNU Library General Public License |
21 | along with this library; see the file COPYING.LIB. If not, write to | 21 | along with this library; see the file COPYING.LIB. If not, write to |
22 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 22 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
23 | Boston, MA 02111-1307, USA. | 23 | Boston, MA 02111-1307, USA. |
24 | */ | 24 | */ |
25 | 25 | ||
26 | #ifdef KDE_USE_FINAL | 26 | #ifdef KDE_USE_FINAL |
27 | #undef Always | 27 | #undef Always |
28 | #include <qdockwindow.h> | 28 | #include <q3dockwindow.h> |
29 | #endif | 29 | #endif |
30 | 30 | //Added by qt3to4: | |
31 | #include <Q3ValueList> | ||
32 | #include <Q3PtrList> | ||
33 | #include <QPixmap> | ||
34 | #include <Q3Frame> | ||
35 | #include <QResizeEvent> | ||
36 | #include <QMouseEvent> | ||
37 | #include <QChildEvent> | ||
38 | #include <QEvent> | ||
39 | #include <QShowEvent> | ||
40 | #include <QDesktopWidget> | ||
41 | #include <QBoxLayout> | ||
31 | 42 | ||
32 | 43 | ||
33 | #include "ktoolbar.h" | 44 | #include "ktoolbar.h" |
34 | #include "kmainwindow.h" | 45 | #include "kmainwindow.h" |
35 | 46 | ||
36 | #include <string.h> | 47 | #include <string.h> |
37 | 48 | ||
38 | #include <qpainter.h> | 49 | #include <qpainter.h> |
39 | #include <qtooltip.h> | 50 | #include <qtooltip.h> |
40 | #include <qdrawutil.h> | 51 | #include <qdrawutil.h> |
41 | #include <qstring.h> | 52 | #include <qstring.h> |
42 | #include <qrect.h> | 53 | #include <qrect.h> |
43 | #include <qobjectlist.h> | 54 | #include <qobject.h> |
44 | #include <qtimer.h> | 55 | #include <qtimer.h> |
45 | #include <qstyle.h> | 56 | #include <qstyle.h> |
46 | #include <qapplication.h> | 57 | #include <qapplication.h> |
47 | 58 | ||
48 | //US #include <config.h> | 59 | //US #include <config.h> |
49 | 60 | ||
50 | #include "klineedit.h" | 61 | #include "klineedit.h" |
51 | #include "kseparator.h" | 62 | #include "kseparator.h" |
52 | #include <klocale.h> | 63 | #include <klocale.h> |
53 | #include <kapplication.h> | 64 | #include <kapplication.h> |
54 | #include <kaction.h> | 65 | #include <kaction.h> |
55 | #include <kstdaction.h> | 66 | #include <kstdaction.h> |
56 | #include <kglobal.h> | 67 | #include <kglobal.h> |
57 | #include <kconfig.h> | 68 | #include <kconfig.h> |
58 | #include <kiconloader.h> | 69 | #include <kiconloader.h> |
59 | #include <kcombobox.h> | 70 | #include <kcombobox.h> |
60 | //US #include <kpopupmenu.h> | 71 | //US #include <kpopupmenu.h> |
61 | //US #include <kanimwidget.h> | 72 | //US #include <kanimwidget.h> |
62 | //US #include <kipc.h> | 73 | //US #include <kipc.h> |
63 | //US #include <kwin.h> | 74 | //US #include <kwin.h> |
64 | #include <kdebug.h> | 75 | #include <kdebug.h> |
65 | #include <qlayout.h> | 76 | #include <qlayout.h> |
66 | 77 | ||
67 | #include "ktoolbarbutton.h" | 78 | #include "ktoolbarbutton.h" |
68 | 79 | ||
69 | //US | 80 | //US |
70 | #include "kconfigbase.h" | 81 | #include "kconfigbase.h" |
71 | 82 | ||
72 | #include <qpopupmenu.h> | 83 | #include <q3popupmenu.h> |
73 | #include <qmainwindow.h> | 84 | #include <q3mainwindow.h> |
74 | 85 | ||
75 | enum { | 86 | enum { |
76 | CONTEXT_TOP = 0, | 87 | CONTEXT_TOP = 0, |
77 | CONTEXT_LEFT = 1, | 88 | CONTEXT_LEFT = 1, |
78 | CONTEXT_RIGHT = 2, | 89 | CONTEXT_RIGHT = 2, |
79 | CONTEXT_BOTTOM = 3, | 90 | CONTEXT_BOTTOM = 3, |
80 | CONTEXT_FLOAT = 4, | 91 | CONTEXT_FLOAT = 4, |
81 | CONTEXT_FLAT = 5, | 92 | CONTEXT_FLAT = 5, |
82 | CONTEXT_ICONS = 6, | 93 | CONTEXT_ICONS = 6, |
83 | CONTEXT_TEXT = 7, | 94 | CONTEXT_TEXT = 7, |
84 | CONTEXT_TEXTRIGHT = 8, | 95 | CONTEXT_TEXTRIGHT = 8, |
85 | CONTEXT_TEXTUNDER = 9, | 96 | CONTEXT_TEXTUNDER = 9, |
86 | CONTEXT_ICONSIZES = 50 // starting point for the icon size list, put everything else before | 97 | CONTEXT_ICONSIZES = 50 // starting point for the icon size list, put everything else before |
87 | }; | 98 | }; |
88 | 99 | ||
89 | class KToolBarPrivate | 100 | class KToolBarPrivate |
90 | { | 101 | { |
91 | public: | 102 | public: |
92 | KToolBarPrivate() { | 103 | KToolBarPrivate() { |
93 | m_iconSize = 0; | 104 | m_iconSize = 0; |
94 | m_iconText = KToolBar::IconOnly; | 105 | m_iconText = KToolBar::IconOnly; |
95 | m_highlight = true; | 106 | m_highlight = true; |
96 | m_transparent = true; | 107 | m_transparent = true; |
97 | m_honorStyle = false; | 108 | m_honorStyle = false; |
98 | 109 | ||
99 | m_enableContext = true; | 110 | m_enableContext = true; |
100 | 111 | ||
101 | m_xmlguiClient = 0; | 112 | m_xmlguiClient = 0; |
102 | m_configurePlugged = false; | 113 | m_configurePlugged = false; |
103 | 114 | ||
104 | //US oldPos = Qt::DockUnmanaged; | 115 | //US oldPos = Qt::DockUnmanaged; |
105 | oldPos = QMainWindow::Unmanaged; | 116 | oldPos = Qt::Unmanaged; |
106 | 117 | ||
107 | modified = m_isHorizontal = positioned = FALSE; | 118 | modified = m_isHorizontal = positioned = FALSE; |
108 | 119 | ||
109 | HiddenDefault = false; | 120 | HiddenDefault = false; |
110 | IconSizeDefault = 0; | 121 | IconSizeDefault = 0; |
111 | IconTextDefault = "IconOnly"; | 122 | IconTextDefault = "IconOnly"; |
112 | IndexDefault = -1; | 123 | IndexDefault = -1; |
113 | NewLineDefault = false; | 124 | NewLineDefault = false; |
114 | OffsetDefault = -1; | 125 | OffsetDefault = -1; |
115 | PositionDefault = "Top"; | 126 | PositionDefault = "Top"; |
116 | idleButtons.setAutoDelete(true); | 127 | idleButtons.setAutoDelete(true); |
117 | } | 128 | } |
118 | 129 | ||
119 | int m_iconSize; | 130 | int m_iconSize; |
120 | KToolBar::IconText m_iconText; | 131 | KToolBar::IconText m_iconText; |
121 | bool m_highlight : 1; | 132 | bool m_highlight : 1; |
122 | bool m_transparent : 1; | 133 | bool m_transparent : 1; |
123 | bool m_honorStyle : 1; | 134 | bool m_honorStyle : 1; |
124 | bool m_isHorizontal : 1; | 135 | bool m_isHorizontal : 1; |
125 | bool m_enableContext : 1; | 136 | bool m_enableContext : 1; |
126 | bool m_configurePlugged : 1; | 137 | bool m_configurePlugged : 1; |
127 | bool modified : 1; | 138 | bool modified : 1; |
128 | bool positioned : 1; | 139 | bool positioned : 1; |
129 | 140 | ||
130 | QWidget *m_parent; | 141 | QWidget *m_parent; |
131 | 142 | ||
132 | QMainWindow::ToolBarDock oldPos; | 143 | Qt::ToolBarDock oldPos; |
133 | 144 | ||
134 | KXMLGUIClient *m_xmlguiClient; | 145 | KXMLGUIClient *m_xmlguiClient; |
135 | 146 | ||
136 | struct ToolBarInfo | 147 | struct ToolBarInfo |
137 | { | 148 | { |
138 | //US ToolBarInfo() : index( 0 ), offset( -1 ), newline( FALSE ), dock( Qt::DockTop ) {} | 149 | //US ToolBarInfo() : index( 0 ), offset( -1 ), newline( FALSE ), dock( Qt::DockTop ) {} |
139 | ToolBarInfo() : index( 0 ), offset( -1 ), newline( FALSE ), dock( QMainWindow::Top ) {} | 150 | ToolBarInfo() : index( 0 ), offset( -1 ), newline( FALSE ), dock( Qt::DockTop ) {} |
140 | //US ToolBarInfo( Qt::Dock d, int i, bool n, int o ) : index( i ), offset( o ), newline( n ), dock( d ) {} | 151 | //US ToolBarInfo( Qt::Dock d, int i, bool n, int o ) : index( i ), offset( o ), newline( n ), dock( d ) {} |
141 | ToolBarInfo( QMainWindow::ToolBarDock d, int i, bool n, int o ) : index( i ), offset( o ), newline( n ), dock( d ) {} | 152 | ToolBarInfo( Qt::ToolBarDock d, int i, bool n, int o ) : index( i ), offset( o ), newline( n ), dock( d ) {} |
142 | int index, offset; | 153 | int index, offset; |
143 | bool newline; | 154 | bool newline; |
144 | //US Qt::Dock dock; | 155 | //US Qt::Dock dock; |
145 | QMainWindow::ToolBarDock dock; | 156 | Qt::ToolBarDock dock; |
146 | }; | 157 | }; |
147 | 158 | ||
148 | ToolBarInfo toolBarInfo; | 159 | ToolBarInfo toolBarInfo; |
149 | QValueList<int> iconSizes; | 160 | Q3ValueList<int> iconSizes; |
150 | QTimer repaintTimer; | 161 | QTimer repaintTimer; |
151 | 162 | ||
152 | // Default Values. | 163 | // Default Values. |
153 | bool HiddenDefault; | 164 | bool HiddenDefault; |
154 | int IconSizeDefault; | 165 | int IconSizeDefault; |
155 | QString IconTextDefault; | 166 | QString IconTextDefault; |
156 | int IndexDefault; | 167 | int IndexDefault; |
157 | bool NewLineDefault; | 168 | bool NewLineDefault; |
158 | int OffsetDefault; | 169 | int OffsetDefault; |
159 | QString PositionDefault; | 170 | QString PositionDefault; |
160 | 171 | ||
161 | QPtrList<QWidget> idleButtons; | 172 | Q3PtrList<QWidget> idleButtons; |
162 | }; | 173 | }; |
163 | 174 | ||
164 | KToolBarSeparator::KToolBarSeparator(Orientation o , bool l, QToolBar *parent, | 175 | KToolBarSeparator::KToolBarSeparator(Qt::Orientation o , bool l, Q3ToolBar *parent, |
165 | const char* name ) | 176 | const char* name ) |
166 | :QFrame( parent, name ), line( l ) | 177 | :Q3Frame( parent, name ), line( l ) |
167 | { | 178 | { |
168 | connect( parent, SIGNAL(orientationChanged(Orientation)), | 179 | connect( parent, SIGNAL(orientationChanged(Qt::Orientation)), |
169 | this, SLOT(setOrientation(Orientation)) ); | 180 | this, SLOT(setOrientation(Qt::Orientation)) ); |
170 | setOrientation( o ); | 181 | setOrientation( o ); |
171 | setBackgroundMode( parent->backgroundMode() ); | 182 | setBackgroundMode( parent->backgroundMode() ); |
172 | setBackgroundOrigin( ParentOrigin ); | 183 | setBackgroundOrigin( ParentOrigin ); |
173 | } | 184 | } |
174 | 185 | ||
175 | void KToolBarSeparator::setOrientation( Orientation o ) | 186 | void KToolBarSeparator::setOrientation( Qt::Orientation o ) |
176 | { | 187 | { |
177 | orient = o; | 188 | orient = o; |
178 | if ( line ) { | 189 | if ( line ) { |
179 | if ( orientation() == Vertical ) | 190 | if ( orientation() == Qt::Vertical ) |
180 | setFrameStyle( HLine + Sunken ); | 191 | setFrameStyle( HLine + Sunken ); |
181 | else | 192 | else |
182 | setFrameStyle( VLine + Sunken ); | 193 | setFrameStyle( VLine + Sunken ); |
183 | } else { | 194 | } else { |
184 | setFrameStyle( NoFrame ); | 195 | setFrameStyle( NoFrame ); |
185 | } | 196 | } |
186 | } | 197 | } |
187 | 198 | ||
188 | void KToolBarSeparator::styleChange( QStyle& ) | 199 | void KToolBarSeparator::styleChange( QStyle& ) |
189 | { | 200 | { |
190 | setOrientation( orient ); | 201 | setOrientation( orient ); |
191 | } | 202 | } |
192 | 203 | ||
193 | QSize KToolBarSeparator::sizeHint() const | 204 | QSize KToolBarSeparator::sizeHint() const |
194 | { | 205 | { |
195 | return orientation() == Vertical ? QSize( 0, 6 ) : QSize( 6, 0 ); | 206 | return orientation() == Qt::Vertical ? QSize( 0, 6 ) : QSize( 6, 0 ); |
196 | } | 207 | } |
197 | 208 | ||
198 | QSizePolicy KToolBarSeparator::sizePolicy() const | 209 | QSizePolicy KToolBarSeparator::sizePolicy() const |
199 | { | 210 | { |
200 | return QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum ); | 211 | return QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum ); |
201 | } | 212 | } |
202 | 213 | ||
203 | KToolBar::KToolBar( QWidget *parent, const char *name, bool honorStyle, bool readConfig ) | 214 | KToolBar::KToolBar( QWidget *parent, const char *name, bool honorStyle, bool readConfig ) |
204 | #ifdef DESKTOP_VERSION | 215 | #ifdef DESKTOP_VERSION |
205 | : QToolBar( QString::fromLatin1( name ), | 216 | : Q3ToolBar( QString::fromLatin1( name ), |
206 | parent && parent->inherits( "QMainWindow" ) ? static_cast<QMainWindow*>(parent) : 0, | 217 | parent && parent->inherits( "Q3MainWindow" ) ? static_cast<Q3MainWindow*>(parent) : 0, |
207 | parent, FALSE, | 218 | parent, FALSE, |
208 | name ? name : "mainToolBar") | 219 | name ? name : "mainToolBar") |
209 | #else | 220 | #else |
210 | : QPEToolBar( parent && parent->inherits( "QMainWindow" ) ? static_cast<QMainWindow*>(parent) : 0, | 221 | : QPEToolBar( parent && parent->inherits( "Q3MainWindow" ) ? static_cast<Q3MainWindow*>(parent) : 0, |
211 | QString::fromLatin1( name )) | 222 | QString::fromLatin1( name )) |
212 | 223 | ||
213 | 224 | ||
214 | #endif | 225 | #endif |
215 | { | 226 | { |
216 | init( readConfig, honorStyle ); | 227 | init( readConfig, honorStyle ); |
217 | } | 228 | } |
218 | 229 | ||
219 | KToolBar::KToolBar( QMainWindow *parentWindow, QMainWindow::ToolBarDock dock, bool newLine, const char *name, bool honorStyle, bool readConfig ) | 230 | KToolBar::KToolBar( Q3MainWindow *parentWindow, Qt::ToolBarDock dock, bool newLine, const char *name, bool honorStyle, bool readConfig ) |
220 | #ifdef DESKTOP_VERSION | 231 | #ifdef DESKTOP_VERSION |
221 | : QToolBar( QString::fromLatin1( name ), | 232 | : Q3ToolBar( QString::fromLatin1( name ), |
222 | parentWindow, dock, newLine, | 233 | parentWindow, dock, newLine, |
223 | name ? name : "mainToolBar") | 234 | name ? name : "mainToolBar") |
224 | #else | 235 | #else |
225 | : QPEToolBar( parentWindow,QString::fromLatin1( name )) | 236 | : QPEToolBar( parentWindow,QString::fromLatin1( name )) |
226 | 237 | ||
227 | 238 | ||
228 | #endif | 239 | #endif |
229 | 240 | ||
230 | { | 241 | { |
231 | init( readConfig, honorStyle ); | 242 | init( readConfig, honorStyle ); |
232 | } | 243 | } |
233 | 244 | ||
234 | KToolBar::KToolBar( QMainWindow *parentWindow, QWidget *dock, bool newLine, const char *name, bool honorStyle, bool readConfig ) | 245 | KToolBar::KToolBar( Q3MainWindow *parentWindow, QWidget *dock, bool newLine, const char *name, bool honorStyle, bool readConfig ) |
235 | #ifdef DESKTOP_VERSION | 246 | #ifdef DESKTOP_VERSION |
236 | : QToolBar( QString::fromLatin1( name ), | 247 | : Q3ToolBar( QString::fromLatin1( name ), |
237 | parentWindow, dock, newLine, | 248 | parentWindow, dock, newLine, |
238 | name ? name : "mainToolBar") | 249 | name ? name : "mainToolBar") |
239 | #else | 250 | #else |
240 | : QPEToolBar( parentWindow,QString::fromLatin1( name )) | 251 | : QPEToolBar( parentWindow,QString::fromLatin1( name )) |
241 | 252 | ||
242 | 253 | ||
243 | #endif | 254 | #endif |
244 | 255 | ||
245 | { | 256 | { |
246 | init( readConfig, honorStyle ); | 257 | init( readConfig, honorStyle ); |
247 | } | 258 | } |
248 | 259 | ||
249 | KToolBar::~KToolBar() | 260 | KToolBar::~KToolBar() |
250 | { | 261 | { |
251 | inshutdownprocess = true; | 262 | inshutdownprocess = true; |
252 | emit toolbarDestroyed(); | 263 | emit toolbarDestroyed(); |
253 | delete d; | 264 | delete d; |
254 | } | 265 | } |
255 | 266 | ||
256 | void KToolBar::init( bool readConfig, bool honorStyle ) | 267 | void KToolBar::init( bool readConfig, bool honorStyle ) |
257 | { | 268 | { |
258 | sizeHintW = 240; | 269 | sizeHintW = 240; |
259 | sizeHintH = 22; | 270 | sizeHintH = 22; |
260 | inshutdownprocess = false; | 271 | inshutdownprocess = false; |
261 | d = new KToolBarPrivate; | 272 | d = new KToolBarPrivate; |
262 | setFullSize( TRUE ); | 273 | setFullSize( TRUE ); |
263 | d->m_honorStyle = honorStyle; | 274 | d->m_honorStyle = honorStyle; |
264 | context = 0; | 275 | context = 0; |
265 | layoutTimer = new QTimer( this ); | 276 | layoutTimer = new QTimer( this ); |
266 | connect( layoutTimer, SIGNAL( timeout() ), | 277 | connect( layoutTimer, SIGNAL( timeout() ), |
267 | this, SLOT( rebuildLayout() ) ); | 278 | this, SLOT( rebuildLayout() ) ); |
268 | connect( &(d->repaintTimer), SIGNAL( timeout() ), | 279 | connect( &(d->repaintTimer), SIGNAL( timeout() ), |
269 | this, SLOT( slotRepaint() ) ); | 280 | this, SLOT( slotRepaint() ) ); |
270 | /*US | 281 | /*US |
271 | if ( kapp ) { // may be null when started inside designer | 282 | if ( kapp ) { // may be null when started inside designer |
272 | connect(kapp, SIGNAL(toolbarAppearanceChanged(int)), this, SLOT(slotAppearanceChanged())); | 283 | connect(kapp, SIGNAL(toolbarAppearanceChanged(int)), this, SLOT(slotAppearanceChanged())); |
273 | // request notification of changes in icon style | 284 | // request notification of changes in icon style |
274 | kapp->addKipcEventMask(KIPC::IconChanged); | 285 | kapp->addKipcEventMask(KIPC::IconChanged); |
275 | connect(kapp, SIGNAL(iconChanged(int)), this, SLOT(slotIconChanged(int))); | 286 | connect(kapp, SIGNAL(iconChanged(int)), this, SLOT(slotIconChanged(int))); |
276 | } | 287 | } |
277 | */ | 288 | */ |
278 | // finally, read in our configurable settings | 289 | // finally, read in our configurable settings |
279 | if ( readConfig ) | 290 | if ( readConfig ) |
280 | slotReadConfig(); | 291 | slotReadConfig(); |
281 | 292 | ||
282 | if ( mainWindow() ) | 293 | if ( mainWindow() ) |
283 | connect( mainWindow(), SIGNAL( toolBarPositionChanged( QToolBar * ) ), | 294 | connect( mainWindow(), SIGNAL( toolBarPositionChanged( Q3ToolBar * ) ), |
284 | this, SLOT( toolBarPosChanged( QToolBar * ) ) ); | 295 | this, SLOT( toolBarPosChanged( Q3ToolBar * ) ) ); |
285 | 296 | ||
286 | // Hack to make sure we recalculate our size when we dock. | 297 | // Hack to make sure we recalculate our size when we dock. |
287 | //US connect( this, SIGNAL(placeChanged(QDockWindow::Place)), SLOT(rebuildLayout()) ); | 298 | //US connect( this, SIGNAL(placeChanged(QDockWindow::Place)), SLOT(rebuildLayout()) ); |
288 | } | 299 | } |
289 | 300 | ||
290 | int KToolBar::insertButton(const QString& icon, int id, bool enabled, | 301 | int KToolBar::insertButton(const QString& icon, int id, bool enabled, |
291 | const QString& text, int index/*US, KInstance *_instance*/ ) | 302 | const QString& text, int index/*US, KInstance *_instance*/ ) |
292 | { | 303 | { |
293 | KToolBarButton *button = new KToolBarButton( icon, id, this, 0, text/*US, _instance*/ ); | 304 | KToolBarButton *button = new KToolBarButton( icon, id, this, 0, text/*US, _instance*/ ); |
294 | 305 | ||
295 | insertWidgetInternal( button, index, id ); | 306 | insertWidgetInternal( button, index, id ); |
296 | button->setEnabled( enabled ); | 307 | button->setEnabled( enabled ); |
297 | doConnections( button ); | 308 | doConnections( button ); |
298 | return index; | 309 | return index; |
299 | } | 310 | } |
300 | 311 | ||
301 | 312 | ||
302 | int KToolBar::insertButton(const QString& icon, int id, const char *signal, | 313 | int KToolBar::insertButton(const QString& icon, int id, const char *signal, |
303 | const QObject *receiver, const char *slot, | 314 | const QObject *receiver, const char *slot, |
304 | bool enabled, const QString& text, int index/*US, KInstance *_instance*/ ) | 315 | bool enabled, const QString& text, int index/*US, KInstance *_instance*/ ) |
305 | { | 316 | { |
306 | KToolBarButton *button = new KToolBarButton( icon, id, this, 0, text/*US, _instance*/); | 317 | KToolBarButton *button = new KToolBarButton( icon, id, this, 0, text/*US, _instance*/); |
307 | insertWidgetInternal( button, index, id ); | 318 | insertWidgetInternal( button, index, id ); |
308 | button->setEnabled( enabled ); | 319 | button->setEnabled( enabled ); |
309 | connect( button, signal, receiver, slot ); | 320 | connect( button, signal, receiver, slot ); |
310 | doConnections( button ); | 321 | doConnections( button ); |
311 | return index; | 322 | return index; |
312 | } | 323 | } |
313 | 324 | ||
314 | 325 | ||
315 | int KToolBar::insertButton(const QPixmap& pixmap, int id, bool enabled, | 326 | int KToolBar::insertButton(const QPixmap& pixmap, int id, bool enabled, |
316 | const QString& text, int index ) | 327 | const QString& text, int index ) |
317 | { | 328 | { |
318 | KToolBarButton *button = new KToolBarButton( pixmap, id, this, 0, text); | 329 | KToolBarButton *button = new KToolBarButton( pixmap, id, this, 0, text); |
319 | insertWidgetInternal( button, index, id ); | 330 | insertWidgetInternal( button, index, id ); |
320 | button->setEnabled( enabled ); | 331 | button->setEnabled( enabled ); |
321 | doConnections( button ); | 332 | doConnections( button ); |
322 | return index; | 333 | return index; |
323 | } | 334 | } |
324 | #if 0 | 335 | #if 0 |
325 | bar->insertButton( icon, id_, SIGNAL( clicked() ), this, | 336 | bar->insertButton( icon, id_, SIGNAL( clicked() ), this, |
326 | SLOT( slotActivated() ), | 337 | SLOT( slotActivated() ), |
327 | d->isEnabled(), d->plainText(), index/*US, instance*/ ); | 338 | d->isEnabled(), d->plainText(), index/*US, instance*/ ); |
328 | #endif | 339 | #endif |
329 | 340 | ||
330 | int KToolBar::insertButton(const QPixmap& pixmap, int id, const char *signal, | 341 | int KToolBar::insertButton(const QPixmap& pixmap, int id, const char *signal, |
331 | const QObject *receiver, const char *slot, | 342 | const QObject *receiver, const char *slot, |
332 | bool enabled, const QString& text, | 343 | bool enabled, const QString& text, |
333 | int index ) | 344 | int index ) |
334 | { | 345 | { |
335 | KToolBarButton *button = new KToolBarButton( pixmap, id, this, 0, text); | 346 | KToolBarButton *button = new KToolBarButton( pixmap, id, this, 0, text); |
336 | insertWidgetInternal( button, index, id ); | 347 | insertWidgetInternal( button, index, id ); |
337 | button->setEnabled( enabled ); | 348 | button->setEnabled( enabled ); |
338 | connect( button, signal, receiver, slot ); | 349 | connect( button, signal, receiver, slot ); |
339 | doConnections( button ); | 350 | doConnections( button ); |
340 | return index; | 351 | return index; |
341 | } | 352 | } |
342 | 353 | ||
343 | 354 | ||
344 | int KToolBar::insertButton(const QString& icon, int id, QPopupMenu *popup, | 355 | int KToolBar::insertButton(const QString& icon, int id, Q3PopupMenu *popup, |
345 | bool enabled, const QString &text, int index ) | 356 | bool enabled, const QString &text, int index ) |
346 | { | 357 | { |
347 | KToolBarButton *button = new KToolBarButton( icon, id, this, 0, text ); | 358 | KToolBarButton *button = new KToolBarButton( icon, id, this, 0, text ); |
348 | insertWidgetInternal( button, index, id ); | 359 | insertWidgetInternal( button, index, id ); |
349 | button->setEnabled( enabled ); | 360 | button->setEnabled( enabled ); |
350 | button->setPopup( popup ); | 361 | button->setPopup( popup ); |
351 | doConnections( button ); | 362 | doConnections( button ); |
352 | return index; | 363 | return index; |
353 | } | 364 | } |
354 | 365 | ||
355 | 366 | ||
356 | int KToolBar::insertButton(const QPixmap& pixmap, int id, QPopupMenu *popup, | 367 | int KToolBar::insertButton(const QPixmap& pixmap, int id, Q3PopupMenu *popup, |
357 | bool enabled, const QString &text, int index ) | 368 | bool enabled, const QString &text, int index ) |
358 | { | 369 | { |
359 | KToolBarButton *button = new KToolBarButton( pixmap, id, this, 0, text ); | 370 | KToolBarButton *button = new KToolBarButton( pixmap, id, this, 0, text ); |
360 | insertWidgetInternal( button, index, id ); | 371 | insertWidgetInternal( button, index, id ); |
361 | button->setEnabled( enabled ); | 372 | button->setEnabled( enabled ); |
362 | button->setPopup( popup ); | 373 | button->setPopup( popup ); |
363 | doConnections( button ); | 374 | doConnections( button ); |
364 | return index; | 375 | return index; |
365 | } | 376 | } |
366 | 377 | ||
367 | 378 | ||
368 | int KToolBar::insertLined (const QString& text, int id, | 379 | int KToolBar::insertLined (const QString& text, int id, |
369 | const char *signal, | 380 | const char *signal, |
370 | const QObject *receiver, const char *slot, | 381 | const QObject *receiver, const char *slot, |
371 | bool enabled , | 382 | bool enabled , |
372 | const QString& toolTipText, | 383 | const QString& toolTipText, |
373 | int size, int index ) | 384 | int size, int index ) |
374 | { | 385 | { |
375 | KLineEdit *lined = new KLineEdit ( this, 0 ); | 386 | KLineEdit *lined = new KLineEdit ( this, 0 ); |
376 | if ( !toolTipText.isEmpty() ) | 387 | if ( !toolTipText.isEmpty() ) |
377 | QToolTip::add( lined, toolTipText ); | 388 | QToolTip::add( lined, toolTipText ); |
378 | if ( size > 0 ) | 389 | if ( size > 0 ) |
379 | lined->setMinimumWidth( size ); | 390 | lined->setMinimumWidth( size ); |
380 | insertWidgetInternal( lined, index, id ); | 391 | insertWidgetInternal( lined, index, id ); |
381 | connect( lined, signal, receiver, slot ); | 392 | connect( lined, signal, receiver, slot ); |
382 | lined->setText(text); | 393 | lined->setText(text); |
383 | lined->setEnabled( enabled ); | 394 | lined->setEnabled( enabled ); |
384 | return index; | 395 | return index; |
385 | } | 396 | } |
386 | 397 | ||
387 | int KToolBar::insertCombo (const QStringList &list, int id, bool writable, | 398 | int KToolBar::insertCombo (const QStringList &list, int id, bool writable, |
388 | const char *signal, const QObject *receiver, | 399 | const char *signal, const QObject *receiver, |
389 | const char *slot, bool enabled, | 400 | const char *slot, bool enabled, |
390 | const QString& tooltiptext, | 401 | const QString& tooltiptext, |
391 | int size, int index, | 402 | int size, int index, |
392 | QComboBox::Policy policy ) | 403 | QComboBox::Policy policy ) |
393 | { | 404 | { |
394 | //US KComboBox *combo = new KComboBox ( writable, this ); | 405 | //US KComboBox *combo = new KComboBox ( writable, this ); |
395 | KComboBox *combo = new KComboBox ( this ); | 406 | KComboBox *combo = new KComboBox ( this ); |
396 | combo->setEditable(writable); | 407 | combo->setEditable(writable); |
397 | 408 | ||
398 | insertWidgetInternal( combo, index, id ); | 409 | insertWidgetInternal( combo, index, id ); |
399 | combo->insertStringList (list); | 410 | combo->insertStringList (list); |
400 | combo->setInsertionPolicy(policy); | 411 | combo->setInsertionPolicy(policy); |
401 | combo->setEnabled( enabled ); | 412 | combo->setEnabled( enabled ); |
402 | if ( !tooltiptext.isEmpty() ) | 413 | if ( !tooltiptext.isEmpty() ) |
403 | QToolTip::add( combo, tooltiptext ); | 414 | QToolTip::add( combo, tooltiptext ); |
404 | if ( size > 0 ) | 415 | if ( size > 0 ) |
405 | combo->setMinimumWidth( size ); | 416 | combo->setMinimumWidth( size ); |
406 | if (!tooltiptext.isNull()) | 417 | if (!tooltiptext.isNull()) |
407 | QToolTip::add( combo, tooltiptext ); | 418 | QToolTip::add( combo, tooltiptext ); |
408 | 419 | ||
409 | if ( signal && receiver && slot ) | 420 | if ( signal && receiver && slot ) |
410 | connect ( combo, signal, receiver, slot ); | 421 | connect ( combo, signal, receiver, slot ); |
411 | return index; | 422 | return index; |
412 | } | 423 | } |
413 | 424 | ||
414 | 425 | ||
415 | int KToolBar::insertCombo (const QString& text, int id, bool writable, | 426 | int KToolBar::insertCombo (const QString& text, int id, bool writable, |
416 | const char *signal, QObject *receiver, | 427 | const char *signal, QObject *receiver, |
417 | const char *slot, bool enabled, | 428 | const char *slot, bool enabled, |
418 | const QString& tooltiptext, | 429 | const QString& tooltiptext, |
419 | int size, int index, | 430 | int size, int index, |
420 | QComboBox::Policy policy ) | 431 | QComboBox::Policy policy ) |
421 | { | 432 | { |
422 | //US KComboBox *combo = new KComboBox ( writable, this ); | 433 | //US KComboBox *combo = new KComboBox ( writable, this ); |
423 | KComboBox *combo = new KComboBox ( this ); | 434 | KComboBox *combo = new KComboBox ( this ); |
424 | combo->setEditable(writable); | 435 | combo->setEditable(writable); |
425 | 436 | ||
426 | insertWidgetInternal( combo, index, id ); | 437 | insertWidgetInternal( combo, index, id ); |
427 | combo->insertItem (text); | 438 | combo->insertItem (text); |
428 | combo->setInsertionPolicy(policy); | 439 | combo->setInsertionPolicy(policy); |
429 | combo->setEnabled( enabled ); | 440 | combo->setEnabled( enabled ); |
430 | if ( !tooltiptext.isEmpty() ) | 441 | if ( !tooltiptext.isEmpty() ) |
431 | QToolTip::add( combo, tooltiptext ); | 442 | QToolTip::add( combo, tooltiptext ); |
432 | if ( size > 0 ) | 443 | if ( size > 0 ) |
433 | combo->setMinimumWidth( size ); | 444 | combo->setMinimumWidth( size ); |
434 | if (!tooltiptext.isNull()) | 445 | if (!tooltiptext.isNull()) |
435 | QToolTip::add( combo, tooltiptext ); | 446 | QToolTip::add( combo, tooltiptext ); |
436 | connect (combo, signal, receiver, slot); | 447 | connect (combo, signal, receiver, slot); |
437 | return index; | 448 | return index; |
438 | } | 449 | } |
439 | 450 | ||
440 | int KToolBar::insertSeparator(int index, int id) | 451 | int KToolBar::insertSeparator(int index, int id) |
441 | { | 452 | { |
442 | QWidget *w = new KToolBarSeparator( orientation(), FALSE, this, "tool bar separator" ); | 453 | QWidget *w = new KToolBarSeparator( orientation(), FALSE, this, "tool bar separator" ); |
443 | insertWidgetInternal( w, index, id ); | 454 | insertWidgetInternal( w, index, id ); |
444 | return index; | 455 | return index; |
445 | } | 456 | } |
446 | 457 | ||
447 | int KToolBar::insertLineSeparator(int index, int id) | 458 | int KToolBar::insertLineSeparator(int index, int id) |
448 | { | 459 | { |
449 | QWidget *w = new KToolBarSeparator( orientation(), TRUE, this, "tool bar separator" ); | 460 | QWidget *w = new KToolBarSeparator( orientation(), TRUE, this, "tool bar separator" ); |
450 | insertWidgetInternal( w, index, id ); | 461 | insertWidgetInternal( w, index, id ); |
451 | return index; | 462 | return index; |
452 | } | 463 | } |
453 | 464 | ||
454 | 465 | ||
455 | int KToolBar::insertWidget(int id, int /*width*/, QWidget *widget, int index) | 466 | int KToolBar::insertWidget(int id, int /*width*/, QWidget *widget, int index) |
456 | { | 467 | { |
457 | // removeWidgetInternal( widget ); // in case we already have it ? | 468 | // removeWidgetInternal( widget ); // in case we already have it ? |
458 | insertWidgetInternal( widget, index, id ); | 469 | insertWidgetInternal( widget, index, id ); |
459 | return index; | 470 | return index; |
460 | } | 471 | } |
461 | /*US | 472 | /*US |
462 | int KToolBar::insertAnimatedWidget(int id, QObject *receiver, const char *slot, | 473 | int KToolBar::insertAnimatedWidget(int id, QObject *receiver, const char *slot, |
463 | const QString& icons, int index ) | 474 | const QString& icons, int index ) |
464 | { | 475 | { |
465 | KAnimWidget *anim = new KAnimWidget( icons, d->m_iconSize, this ); | 476 | KAnimWidget *anim = new KAnimWidget( icons, d->m_iconSize, this ); |
466 | insertWidgetInternal( anim, index, id ); | 477 | insertWidgetInternal( anim, index, id ); |
467 | 478 | ||
468 | if ( receiver ) | 479 | if ( receiver ) |
469 | connect( anim, SIGNAL(clicked()), receiver, slot); | 480 | connect( anim, SIGNAL(clicked()), receiver, slot); |
470 | 481 | ||
471 | return index; | 482 | return index; |
472 | } | 483 | } |
473 | 484 | ||
474 | KAnimWidget *KToolBar::animatedWidget( int id ) | 485 | KAnimWidget *KToolBar::animatedWidget( int id ) |
475 | { | 486 | { |
476 | Id2WidgetMap::Iterator it = id2widget.find( id ); | 487 | Id2WidgetMap::Iterator it = id2widget.find( id ); |
477 | if ( it == id2widget.end() ) | 488 | if ( it == id2widget.end() ) |
478 | return 0; | 489 | return 0; |
479 | if ( (*it) && (*it)->inherits( "KAnimWidget" ) ) | 490 | if ( (*it) && (*it)->inherits( "KAnimWidget" ) ) |
480 | return (KAnimWidget*)(*it); | 491 | return (KAnimWidget*)(*it); |
481 | QObjectList *l = queryList( "KAnimWidget" ); | 492 | QObjectList *l = queryList( "KAnimWidget" ); |
482 | if ( !l || !l->first() ) { | 493 | if ( !l || !l->first() ) { |
483 | delete l; | 494 | delete l; |
484 | return 0; | 495 | return 0; |
485 | } | 496 | } |
486 | 497 | ||
487 | for ( QObject *o = l->first(); o; o = l->next() ) { | 498 | for ( QObject *o = l->first(); o; o = l->next() ) { |
488 | if ( o->inherits( "KAnimWidget" ) ) | 499 | if ( o->inherits( "KAnimWidget" ) ) |
489 | { | 500 | { |
490 | delete l; | 501 | delete l; |
491 | return (KAnimWidget*)o; | 502 | return (KAnimWidget*)o; |
492 | } | 503 | } |
493 | } | 504 | } |
494 | 505 | ||
495 | delete l; | 506 | delete l; |
496 | return 0; | 507 | return 0; |
497 | } | 508 | } |
498 | */ | 509 | */ |
499 | 510 | ||
500 | void KToolBar::addConnection (int id, const char *signal, | 511 | void KToolBar::addConnection (int id, const char *signal, |
501 | const QObject *receiver, const char *slot) | 512 | const QObject *receiver, const char *slot) |
502 | { | 513 | { |
503 | Id2WidgetMap::Iterator it = id2widget.find( id ); | 514 | Id2WidgetMap::Iterator it = id2widget.find( id ); |
504 | if ( it == id2widget.end() ) | 515 | if ( it == id2widget.end() ) |
505 | return; | 516 | return; |
506 | if ( (*it) ) | 517 | if ( (*it) ) |
507 | connect( (*it), signal, receiver, slot ); | 518 | connect( (*it), signal, receiver, slot ); |
508 | } | 519 | } |
509 | 520 | ||
510 | void KToolBar::setItemEnabled( int id, bool enabled ) | 521 | void KToolBar::setItemEnabled( int id, bool enabled ) |
511 | { | 522 | { |
512 | Id2WidgetMap::Iterator it = id2widget.find( id ); | 523 | Id2WidgetMap::Iterator it = id2widget.find( id ); |
513 | if ( it == id2widget.end() ) | 524 | if ( it == id2widget.end() ) |
514 | return; | 525 | return; |
515 | if ( (*it) ) | 526 | if ( (*it) ) |
516 | (*it)->setEnabled( enabled ); | 527 | (*it)->setEnabled( enabled ); |
517 | } | 528 | } |
518 | 529 | ||
519 | 530 | ||
520 | void KToolBar::setButtonPixmap( int id, const QPixmap& _pixmap ) | 531 | void KToolBar::setButtonPixmap( int id, const QPixmap& _pixmap ) |
521 | { | 532 | { |
522 | Id2WidgetMap::Iterator it = id2widget.find( id ); | 533 | Id2WidgetMap::Iterator it = id2widget.find( id ); |
523 | if ( it == id2widget.end() ) | 534 | if ( it == id2widget.end() ) |
524 | return; | 535 | return; |
525 | //US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); | 536 | //US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); |
526 | KToolBarButton * button = (KToolBarButton *)( *it ); | 537 | KToolBarButton * button = (KToolBarButton *)( *it ); |
527 | if ( button ) | 538 | if ( button ) |
528 | button->setPixmap( _pixmap ); | 539 | button->setPixmap( _pixmap ); |
529 | } | 540 | } |
530 | 541 | ||
531 | 542 | ||
532 | void KToolBar::setButtonIcon( int id, const QString& _icon ) | 543 | void KToolBar::setButtonIcon( int id, const QString& _icon ) |
533 | { | 544 | { |
534 | Id2WidgetMap::Iterator it = id2widget.find( id ); | 545 | Id2WidgetMap::Iterator it = id2widget.find( id ); |
535 | if ( it == id2widget.end() ) | 546 | if ( it == id2widget.end() ) |
536 | return; | 547 | return; |
537 | //US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); | 548 | //US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); |
538 | KToolBarButton * button = (KToolBarButton *)( *it ); | 549 | KToolBarButton * button = (KToolBarButton *)( *it ); |
539 | if ( button ) | 550 | if ( button ) |
540 | button->setIcon( _icon ); | 551 | button->setIcon( _icon ); |
541 | } | 552 | } |
542 | 553 | ||
543 | void KToolBar::setButtonIconSet( int id, const QIconSet& iconset ) | 554 | void KToolBar::setButtonIconSet( int id, const QIcon& iconset ) |
544 | { | 555 | { |
545 | Id2WidgetMap::Iterator it = id2widget.find( id ); | 556 | Id2WidgetMap::Iterator it = id2widget.find( id ); |
546 | if ( it == id2widget.end() ) | 557 | if ( it == id2widget.end() ) |
547 | return; | 558 | return; |
548 | //US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); | 559 | //US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); |
549 | KToolBarButton * button = (KToolBarButton *)( *it ); | 560 | KToolBarButton * button = (KToolBarButton *)( *it ); |
550 | if ( button ) | 561 | if ( button ) |
551 | button->setIconSet( iconset ); | 562 | button->setIconSet( iconset ); |
552 | } | 563 | } |
553 | 564 | ||
554 | 565 | ||
555 | void KToolBar::setDelayedPopup (int id , QPopupMenu *_popup, bool toggle ) | 566 | void KToolBar::setDelayedPopup (int id , Q3PopupMenu *_popup, bool toggle ) |
556 | { | 567 | { |
557 | Id2WidgetMap::Iterator it = id2widget.find( id ); | 568 | Id2WidgetMap::Iterator it = id2widget.find( id ); |
558 | if ( it == id2widget.end() ) | 569 | if ( it == id2widget.end() ) |
559 | return; | 570 | return; |
560 | //US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); | 571 | //US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); |
561 | KToolBarButton * button = (KToolBarButton *)( *it ); | 572 | KToolBarButton * button = (KToolBarButton *)( *it ); |
562 | if ( button ) | 573 | if ( button ) |
563 | button->setDelayedPopup( _popup, toggle ); | 574 | button->setDelayedPopup( _popup, toggle ); |
564 | } | 575 | } |
565 | 576 | ||
566 | 577 | ||
567 | void KToolBar::setAutoRepeat (int id, bool flag) | 578 | void KToolBar::setAutoRepeat (int id, bool flag) |
568 | { | 579 | { |
569 | Id2WidgetMap::Iterator it = id2widget.find( id ); | 580 | Id2WidgetMap::Iterator it = id2widget.find( id ); |
570 | if ( it == id2widget.end() ) | 581 | if ( it == id2widget.end() ) |
571 | return; | 582 | return; |
572 | //US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); | 583 | //US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); |
573 | KToolBarButton * button = (KToolBarButton *)( *it ); | 584 | KToolBarButton * button = (KToolBarButton *)( *it ); |
574 | if ( button ) | 585 | if ( button ) |
575 | button->setAutoRepeat( flag ); | 586 | button->setAutoRepeat( flag ); |
576 | } | 587 | } |
577 | 588 | ||
578 | 589 | ||
579 | void KToolBar::setToggle (int id, bool flag ) | 590 | void KToolBar::setToggle (int id, bool flag ) |
580 | { | 591 | { |
581 | Id2WidgetMap::Iterator it = id2widget.find( id ); | 592 | Id2WidgetMap::Iterator it = id2widget.find( id ); |
582 | if ( it == id2widget.end() ) | 593 | if ( it == id2widget.end() ) |
583 | return; | 594 | return; |
584 | //US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); | 595 | //US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); |
585 | KToolBarButton * button = (KToolBarButton *)( *it ); | 596 | KToolBarButton * button = (KToolBarButton *)( *it ); |
586 | if ( button ) | 597 | if ( button ) |
587 | button->setToggle( flag ); | 598 | button->setToggle( flag ); |
588 | } | 599 | } |
589 | 600 | ||
590 | 601 | ||
591 | void KToolBar::toggleButton (int id) | 602 | void KToolBar::toggleButton (int id) |
592 | { | 603 | { |
593 | Id2WidgetMap::Iterator it = id2widget.find( id ); | 604 | Id2WidgetMap::Iterator it = id2widget.find( id ); |
594 | if ( it == id2widget.end() ) | 605 | if ( it == id2widget.end() ) |
595 | return; | 606 | return; |
596 | //US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); | 607 | //US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); |
597 | KToolBarButton * button = (KToolBarButton *)( *it ); | 608 | KToolBarButton * button = (KToolBarButton *)( *it ); |
598 | if ( button ) | 609 | if ( button ) |
599 | button->toggle(); | 610 | button->toggle(); |
600 | } | 611 | } |
601 | 612 | ||
602 | 613 | ||
603 | void KToolBar::setButton (int id, bool flag) | 614 | void KToolBar::setButton (int id, bool flag) |
604 | { | 615 | { |
605 | Id2WidgetMap::Iterator it = id2widget.find( id ); | 616 | Id2WidgetMap::Iterator it = id2widget.find( id ); |
606 | if ( it == id2widget.end() ) | 617 | if ( it == id2widget.end() ) |
607 | return; | 618 | return; |
608 | //US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); | 619 | //US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); |
609 | KToolBarButton * button = (KToolBarButton *)( *it ); | 620 | KToolBarButton * button = (KToolBarButton *)( *it ); |
610 | if ( button ) | 621 | if ( button ) |
611 | button->on( flag ); | 622 | button->on( flag ); |
612 | } | 623 | } |
613 | 624 | ||
614 | 625 | ||
615 | bool KToolBar::isButtonOn (int id) const | 626 | bool KToolBar::isButtonOn (int id) const |
616 | { | 627 | { |
617 | Id2WidgetMap::ConstIterator it = id2widget.find( id ); | 628 | Id2WidgetMap::ConstIterator it = id2widget.find( id ); |
618 | if ( it == id2widget.end() ) | 629 | if ( it == id2widget.end() ) |
619 | return false; | 630 | return false; |
620 | //US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); | 631 | //US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); |
621 | KToolBarButton * button = (KToolBarButton *)( *it ); | 632 | KToolBarButton * button = (KToolBarButton *)( *it ); |
622 | return button ? button->isOn() : false; | 633 | return button ? button->isOn() : false; |
623 | } | 634 | } |
624 | 635 | ||
625 | 636 | ||
626 | void KToolBar::setLinedText (int id, const QString& text) | 637 | void KToolBar::setLinedText (int id, const QString& text) |
627 | { | 638 | { |
628 | Id2WidgetMap::Iterator it = id2widget.find( id ); | 639 | Id2WidgetMap::Iterator it = id2widget.find( id ); |
629 | if ( it == id2widget.end() ) | 640 | if ( it == id2widget.end() ) |
630 | return; | 641 | return; |
631 | //US QLineEdit * lineEdit = dynamic_cast<QLineEdit *>( *it ); | 642 | //US QLineEdit * lineEdit = dynamic_cast<QLineEdit *>( *it ); |
632 | QLineEdit * lineEdit = (QLineEdit *)( *it ); | 643 | QLineEdit * lineEdit = (QLineEdit *)( *it ); |
633 | if ( lineEdit ) | 644 | if ( lineEdit ) |
634 | lineEdit->setText( text ); | 645 | lineEdit->setText( text ); |
635 | } | 646 | } |
636 | 647 | ||
637 | 648 | ||
638 | QString KToolBar::getLinedText (int id) const | 649 | QString KToolBar::getLinedText (int id) const |
639 | { | 650 | { |
640 | Id2WidgetMap::ConstIterator it = id2widget.find( id ); | 651 | Id2WidgetMap::ConstIterator it = id2widget.find( id ); |
641 | if ( it == id2widget.end() ) | 652 | if ( it == id2widget.end() ) |
642 | return QString::null; | 653 | return QString::null; |
643 | //US QLineEdit * lineEdit = dynamic_cast<QLineEdit *>( *it ); | 654 | //US QLineEdit * lineEdit = dynamic_cast<QLineEdit *>( *it ); |
644 | QLineEdit * lineEdit = (QLineEdit *)( *it ); | 655 | QLineEdit * lineEdit = (QLineEdit *)( *it ); |
645 | return lineEdit ? lineEdit->text() : QString::null; | 656 | return lineEdit ? lineEdit->text() : QString::null; |
646 | } | 657 | } |
647 | 658 | ||
648 | 659 | ||
649 | void KToolBar::insertComboItem (int id, const QString& text, int index) | 660 | void KToolBar::insertComboItem (int id, const QString& text, int index) |
650 | { | 661 | { |
651 | Id2WidgetMap::Iterator it = id2widget.find( id ); | 662 | Id2WidgetMap::Iterator it = id2widget.find( id ); |
@@ -694,1585 +705,1585 @@ void KToolBar::setCurrentComboItem (int id, int index) | |||
694 | 705 | ||
695 | 706 | ||
696 | void KToolBar::changeComboItem (int id, const QString& text, int index) | 707 | void KToolBar::changeComboItem (int id, const QString& text, int index) |
697 | { | 708 | { |
698 | Id2WidgetMap::Iterator it = id2widget.find( id ); | 709 | Id2WidgetMap::Iterator it = id2widget.find( id ); |
699 | if ( it == id2widget.end() ) | 710 | if ( it == id2widget.end() ) |
700 | return; | 711 | return; |
701 | //US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it ); | 712 | //US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it ); |
702 | QComboBox * comboBox = (QComboBox *)( *it ); | 713 | QComboBox * comboBox = (QComboBox *)( *it ); |
703 | if (comboBox) | 714 | if (comboBox) |
704 | comboBox->changeItem( text, index ); | 715 | comboBox->changeItem( text, index ); |
705 | } | 716 | } |
706 | 717 | ||
707 | 718 | ||
708 | void KToolBar::clearCombo (int id) | 719 | void KToolBar::clearCombo (int id) |
709 | { | 720 | { |
710 | Id2WidgetMap::Iterator it = id2widget.find( id ); | 721 | Id2WidgetMap::Iterator it = id2widget.find( id ); |
711 | if ( it == id2widget.end() ) | 722 | if ( it == id2widget.end() ) |
712 | return; | 723 | return; |
713 | //US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it ); | 724 | //US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it ); |
714 | QComboBox * comboBox = (QComboBox *)( *it ); | 725 | QComboBox * comboBox = (QComboBox *)( *it ); |
715 | if (comboBox) | 726 | if (comboBox) |
716 | comboBox->clear(); | 727 | comboBox->clear(); |
717 | } | 728 | } |
718 | 729 | ||
719 | 730 | ||
720 | QString KToolBar::getComboItem (int id, int index) const | 731 | QString KToolBar::getComboItem (int id, int index) const |
721 | { | 732 | { |
722 | Id2WidgetMap::ConstIterator it = id2widget.find( id ); | 733 | Id2WidgetMap::ConstIterator it = id2widget.find( id ); |
723 | if ( it == id2widget.end() ) | 734 | if ( it == id2widget.end() ) |
724 | return QString::null; | 735 | return QString::null; |
725 | //US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it ); | 736 | //US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it ); |
726 | QComboBox * comboBox = (QComboBox *)( *it ); | 737 | QComboBox * comboBox = (QComboBox *)( *it ); |
727 | return comboBox ? comboBox->text( index ) : QString::null; | 738 | return comboBox ? comboBox->text( index ) : QString::null; |
728 | } | 739 | } |
729 | 740 | ||
730 | 741 | ||
731 | KComboBox * KToolBar::getCombo(int id) | 742 | KComboBox * KToolBar::getCombo(int id) |
732 | { | 743 | { |
733 | Id2WidgetMap::Iterator it = id2widget.find( id ); | 744 | Id2WidgetMap::Iterator it = id2widget.find( id ); |
734 | if ( it == id2widget.end() ) | 745 | if ( it == id2widget.end() ) |
735 | return 0; | 746 | return 0; |
736 | //US return dynamic_cast<KComboBox *>( *it ); | 747 | //US return dynamic_cast<KComboBox *>( *it ); |
737 | return (KComboBox *)( *it ); | 748 | return (KComboBox *)( *it ); |
738 | } | 749 | } |
739 | 750 | ||
740 | 751 | ||
741 | KLineEdit * KToolBar::getLined (int id) | 752 | KLineEdit * KToolBar::getLined (int id) |
742 | { | 753 | { |
743 | Id2WidgetMap::Iterator it = id2widget.find( id ); | 754 | Id2WidgetMap::Iterator it = id2widget.find( id ); |
744 | if ( it == id2widget.end() ) | 755 | if ( it == id2widget.end() ) |
745 | return 0; | 756 | return 0; |
746 | //US return dynamic_cast<KLineEdit *>( *it ); | 757 | //US return dynamic_cast<KLineEdit *>( *it ); |
747 | return (KLineEdit *)( *it ); | 758 | return (KLineEdit *)( *it ); |
748 | } | 759 | } |
749 | 760 | ||
750 | 761 | ||
751 | KToolBarButton * KToolBar::getButton (int id) | 762 | KToolBarButton * KToolBar::getButton (int id) |
752 | { | 763 | { |
753 | Id2WidgetMap::Iterator it = id2widget.find( id ); | 764 | Id2WidgetMap::Iterator it = id2widget.find( id ); |
754 | if ( it == id2widget.end() ) | 765 | if ( it == id2widget.end() ) |
755 | return 0; | 766 | return 0; |
756 | //US return dynamic_cast<KToolBarButton *>( *it ); | 767 | //US return dynamic_cast<KToolBarButton *>( *it ); |
757 | return (KToolBarButton *)( *it ); | 768 | return (KToolBarButton *)( *it ); |
758 | } | 769 | } |
759 | 770 | ||
760 | 771 | ||
761 | void KToolBar::alignItemRight (int id, bool right ) | 772 | void KToolBar::alignItemRight (int id, bool right ) |
762 | { | 773 | { |
763 | Id2WidgetMap::Iterator it = id2widget.find( id ); | 774 | Id2WidgetMap::Iterator it = id2widget.find( id ); |
764 | if ( it == id2widget.end() ) | 775 | if ( it == id2widget.end() ) |
765 | return; | 776 | return; |
766 | if ( rightAligned && !right && (*it) == rightAligned ) | 777 | if ( rightAligned && !right && (*it) == rightAligned ) |
767 | rightAligned = 0; | 778 | rightAligned = 0; |
768 | if ( (*it) && right ) | 779 | if ( (*it) && right ) |
769 | rightAligned = (*it); | 780 | rightAligned = (*it); |
770 | } | 781 | } |
771 | 782 | ||
772 | 783 | ||
773 | QWidget *KToolBar::getWidget (int id) | 784 | QWidget *KToolBar::getWidget (int id) |
774 | { | 785 | { |
775 | Id2WidgetMap::Iterator it = id2widget.find( id ); | 786 | Id2WidgetMap::Iterator it = id2widget.find( id ); |
776 | return ( it == id2widget.end() ) ? 0 : (*it); | 787 | return ( it == id2widget.end() ) ? 0 : (*it); |
777 | } | 788 | } |
778 | 789 | ||
779 | 790 | ||
780 | void KToolBar::setItemAutoSized (int id, bool yes ) | 791 | void KToolBar::setItemAutoSized (int id, bool yes ) |
781 | { | 792 | { |
782 | QWidget *w = getWidget(id); | 793 | QWidget *w = getWidget(id); |
783 | if ( w && yes ) | 794 | if ( w && yes ) |
784 | setStretchableWidget( w ); | 795 | setStretchableWidget( w ); |
785 | } | 796 | } |
786 | 797 | ||
787 | 798 | ||
788 | void KToolBar::clear () | 799 | void KToolBar::clear () |
789 | { | 800 | { |
790 | QToolBar::clear(); | 801 | Q3ToolBar::clear(); |
791 | widget2id.clear(); | 802 | widget2id.clear(); |
792 | id2widget.clear(); | 803 | id2widget.clear(); |
793 | } | 804 | } |
794 | 805 | ||
795 | 806 | ||
796 | void KToolBar::removeItem(int id) | 807 | void KToolBar::removeItem(int id) |
797 | { | 808 | { |
798 | Id2WidgetMap::Iterator it = id2widget.find( id ); | 809 | Id2WidgetMap::Iterator it = id2widget.find( id ); |
799 | if ( it == id2widget.end() ) | 810 | if ( it == id2widget.end() ) |
800 | { | 811 | { |
801 | kdDebug(220) << "KToolBar::removeItem item " << id << " not found" << endl; | 812 | kdDebug(220) << "KToolBar::removeItem item " << id << " not found" << endl; |
802 | return; | 813 | return; |
803 | } | 814 | } |
804 | QWidget * w = (*it); | 815 | QWidget * w = (*it); |
805 | id2widget.remove( id ); | 816 | id2widget.remove( id ); |
806 | widget2id.remove( w ); | 817 | widget2id.remove( w ); |
807 | widgets.removeRef( w ); | 818 | widgets.removeRef( w ); |
808 | delete w; | 819 | delete w; |
809 | } | 820 | } |
810 | 821 | ||
811 | 822 | ||
812 | void KToolBar::removeItemDelayed(int id) | 823 | void KToolBar::removeItemDelayed(int id) |
813 | { | 824 | { |
814 | Id2WidgetMap::Iterator it = id2widget.find( id ); | 825 | Id2WidgetMap::Iterator it = id2widget.find( id ); |
815 | if ( it == id2widget.end() ) | 826 | if ( it == id2widget.end() ) |
816 | { | 827 | { |
817 | kdDebug(220) << "KToolBar::removeItem item " << id << " not found" << endl; | 828 | kdDebug(220) << "KToolBar::removeItem item " << id << " not found" << endl; |
818 | return; | 829 | return; |
819 | } | 830 | } |
820 | QWidget * w = (*it); | 831 | QWidget * w = (*it); |
821 | id2widget.remove( id ); | 832 | id2widget.remove( id ); |
822 | widget2id.remove( w ); | 833 | widget2id.remove( w ); |
823 | widgets.removeRef( w ); | 834 | widgets.removeRef( w ); |
824 | 835 | ||
825 | w->blockSignals(true); | 836 | w->blockSignals(true); |
826 | d->idleButtons.append(w); | 837 | d->idleButtons.append(w); |
827 | layoutTimer->start( 50, TRUE ); | 838 | layoutTimer->start( 50, TRUE ); |
828 | } | 839 | } |
829 | 840 | ||
830 | 841 | ||
831 | void KToolBar::hideItem (int id) | 842 | void KToolBar::hideItem (int id) |
832 | { | 843 | { |
833 | QWidget *w = getWidget(id); | 844 | QWidget *w = getWidget(id); |
834 | if ( w ) | 845 | if ( w ) |
835 | w->hide(); | 846 | w->hide(); |
836 | } | 847 | } |
837 | 848 | ||
838 | 849 | ||
839 | void KToolBar::showItem (int id) | 850 | void KToolBar::showItem (int id) |
840 | { | 851 | { |
841 | QWidget *w = getWidget(id); | 852 | QWidget *w = getWidget(id); |
842 | if ( w ) | 853 | if ( w ) |
843 | w->show(); | 854 | w->show(); |
844 | } | 855 | } |
845 | 856 | ||
846 | 857 | ||
847 | int KToolBar::itemIndex (int id) | 858 | int KToolBar::itemIndex (int id) |
848 | { | 859 | { |
849 | QWidget *w = getWidget(id); | 860 | QWidget *w = getWidget(id); |
850 | return w ? widgets.findRef(w) : -1; | 861 | return w ? widgets.findRef(w) : -1; |
851 | } | 862 | } |
852 | 863 | ||
853 | 864 | ||
854 | void KToolBar::setFullSize(bool flag ) | 865 | void KToolBar::setFullSize(bool flag ) |
855 | { | 866 | { |
856 | setHorizontalStretchable( flag ); | 867 | setHorizontalStretchable( flag ); |
857 | setVerticalStretchable( flag ); | 868 | setVerticalStretchable( flag ); |
858 | } | 869 | } |
859 | 870 | ||
860 | 871 | ||
861 | bool KToolBar::fullSize() const | 872 | bool KToolBar::fullSize() const |
862 | { | 873 | { |
863 | return isHorizontalStretchable() || isVerticalStretchable(); | 874 | return isHorizontalStretchable() || isVerticalStretchable(); |
864 | } | 875 | } |
865 | 876 | ||
866 | 877 | ||
867 | void KToolBar::enableMoving(bool flag ) | 878 | void KToolBar::enableMoving(bool flag ) |
868 | { | 879 | { |
869 | //US setMovingEnabled(flag); | 880 | //US setMovingEnabled(flag); |
870 | this->mainWindow()->setToolBarsMovable(flag); | 881 | this->mainWindow()->setToolBarsMovable(flag); |
871 | } | 882 | } |
872 | 883 | ||
873 | 884 | ||
874 | void KToolBar::setBarPos (BarPosition bpos) | 885 | void KToolBar::setBarPos (BarPosition bpos) |
875 | { | 886 | { |
876 | if ( !mainWindow() ) | 887 | if ( !mainWindow() ) |
877 | return; | 888 | return; |
878 | //US mainWindow()->moveDockWindow( this, (Dock)bpos ); | 889 | //US mainWindow()->moveDockWindow( this, (Dock)bpos ); |
879 | mainWindow()->moveToolBar( this, (QMainWindow::ToolBarDock)bpos ); | 890 | mainWindow()->moveToolBar( this, (Qt::ToolBarDock)bpos ); |
880 | } | 891 | } |
881 | 892 | ||
882 | 893 | ||
883 | const KToolBar::BarPosition KToolBar::barPos() | 894 | const KToolBar::BarPosition KToolBar::barPos() |
884 | { | 895 | { |
885 | if ( !(QMainWindow*)mainWindow() ) | 896 | if ( !(Q3MainWindow*)mainWindow() ) |
886 | return KToolBar::Top; | 897 | return KToolBar::Top; |
887 | //US Dock dock; | 898 | //US Dock dock; |
888 | QMainWindow::ToolBarDock dock; | 899 | Qt::ToolBarDock dock; |
889 | int dm1, dm2; | 900 | int dm1, dm2; |
890 | bool dm3; | 901 | bool dm3; |
891 | ((QMainWindow*)mainWindow())->getLocation( (QToolBar*)this, dock, dm1, dm3, dm2 ); | 902 | ((Q3MainWindow*)mainWindow())->getLocation( (Q3ToolBar*)this, dock, dm1, dm3, dm2 ); |
892 | //US if ( dock == DockUnmanaged ) { | 903 | //US if ( dock == DockUnmanaged ) { |
893 | if ( dock == QMainWindow::Unmanaged ) { | 904 | if ( dock == Qt::Unmanaged ) { |
894 | return (KToolBar::BarPosition)Top; | 905 | return (KToolBar::BarPosition)Top; |
895 | } | 906 | } |
896 | return (BarPosition)dock; | 907 | return (BarPosition)dock; |
897 | } | 908 | } |
898 | 909 | ||
899 | 910 | ||
900 | bool KToolBar::enable(BarStatus stat) | 911 | bool KToolBar::enable(BarStatus stat) |
901 | { | 912 | { |
902 | bool mystat = isVisible(); | 913 | bool mystat = isVisible(); |
903 | 914 | ||
904 | if ( (stat == Toggle && mystat) || stat == Hide ) | 915 | if ( (stat == Toggle && mystat) || stat == Hide ) |
905 | hide(); | 916 | hide(); |
906 | else | 917 | else |
907 | show(); | 918 | show(); |
908 | 919 | ||
909 | return isVisible() == mystat; | 920 | return isVisible() == mystat; |
910 | } | 921 | } |
911 | 922 | ||
912 | 923 | ||
913 | void KToolBar::setMaxHeight ( int h ) | 924 | void KToolBar::setMaxHeight ( int h ) |
914 | { | 925 | { |
915 | setMaximumHeight( h ); | 926 | setMaximumHeight( h ); |
916 | } | 927 | } |
917 | 928 | ||
918 | int KToolBar::maxHeight() | 929 | int KToolBar::maxHeight() |
919 | { | 930 | { |
920 | return maximumHeight(); | 931 | return maximumHeight(); |
921 | } | 932 | } |
922 | 933 | ||
923 | 934 | ||
924 | void KToolBar::setMaxWidth (int dw) | 935 | void KToolBar::setMaxWidth (int dw) |
925 | { | 936 | { |
926 | setMaximumWidth( dw ); | 937 | setMaximumWidth( dw ); |
927 | } | 938 | } |
928 | 939 | ||
929 | 940 | ||
930 | int KToolBar::maxWidth() | 941 | int KToolBar::maxWidth() |
931 | { | 942 | { |
932 | return maximumWidth(); | 943 | return maximumWidth(); |
933 | } | 944 | } |
934 | 945 | ||
935 | 946 | ||
936 | void KToolBar::setTitle (const QString& _title) | 947 | void KToolBar::setTitle (const QString& _title) |
937 | { | 948 | { |
938 | setLabel( _title ); | 949 | setLabel( _title ); |
939 | } | 950 | } |
940 | 951 | ||
941 | 952 | ||
942 | void KToolBar::enableFloating (bool ) | 953 | void KToolBar::enableFloating (bool ) |
943 | { | 954 | { |
944 | } | 955 | } |
945 | 956 | ||
946 | 957 | ||
947 | void KToolBar::setIconText(IconText it) | 958 | void KToolBar::setIconText(IconText it) |
948 | { | 959 | { |
949 | setIconText( it, true ); | 960 | setIconText( it, true ); |
950 | } | 961 | } |
951 | 962 | ||
952 | 963 | ||
953 | void KToolBar::setIconText(IconText icontext, bool update) | 964 | void KToolBar::setIconText(IconText icontext, bool update) |
954 | { | 965 | { |
955 | bool doUpdate=false; | 966 | bool doUpdate=false; |
956 | 967 | ||
957 | if (icontext != d->m_iconText) { | 968 | if (icontext != d->m_iconText) { |
958 | d->m_iconText = icontext; | 969 | d->m_iconText = icontext; |
959 | doUpdate=true; | 970 | doUpdate=true; |
960 | } | 971 | } |
961 | 972 | ||
962 | if (update == false) | 973 | if (update == false) |
963 | return; | 974 | return; |
964 | 975 | ||
965 | if (doUpdate) | 976 | if (doUpdate) |
966 | emit modechange(); // tell buttons what happened | 977 | emit modechange(); // tell buttons what happened |
967 | 978 | ||
968 | // ugly hack to force a QMainWindow::triggerLayout( TRUE ) | 979 | // ugly hack to force a QMainWindow::triggerLayout( TRUE ) |
969 | if ( mainWindow() ) { | 980 | if ( mainWindow() ) { |
970 | QMainWindow *mw = mainWindow(); | 981 | Q3MainWindow *mw = mainWindow(); |
971 | mw->setUpdatesEnabled( FALSE ); | 982 | mw->setUpdatesEnabled( FALSE ); |
972 | mw->setToolBarsMovable( !mw->toolBarsMovable() ); | 983 | mw->setToolBarsMovable( !mw->toolBarsMovable() ); |
973 | mw->setToolBarsMovable( !mw->toolBarsMovable() ); | 984 | mw->setToolBarsMovable( !mw->toolBarsMovable() ); |
974 | mw->setUpdatesEnabled( TRUE ); | 985 | mw->setUpdatesEnabled( TRUE ); |
975 | } | 986 | } |
976 | } | 987 | } |
977 | 988 | ||
978 | 989 | ||
979 | KToolBar::IconText KToolBar::iconText() const | 990 | KToolBar::IconText KToolBar::iconText() const |
980 | { | 991 | { |
981 | return d->m_iconText; | 992 | return d->m_iconText; |
982 | } | 993 | } |
983 | 994 | ||
984 | 995 | ||
985 | void KToolBar::setIconSize(int size) | 996 | void KToolBar::setIconSize(int size) |
986 | { | 997 | { |
987 | setIconSize( size, true ); | 998 | setIconSize( size, true ); |
988 | } | 999 | } |
989 | 1000 | ||
990 | void KToolBar::setIconSize(int size, bool update) | 1001 | void KToolBar::setIconSize(int size, bool update) |
991 | { | 1002 | { |
992 | bool doUpdate=false; | 1003 | bool doUpdate=false; |
993 | 1004 | ||
994 | if ( size != d->m_iconSize ) { | 1005 | if ( size != d->m_iconSize ) { |
995 | d->m_iconSize = size; | 1006 | d->m_iconSize = size; |
996 | doUpdate=true; | 1007 | doUpdate=true; |
997 | } | 1008 | } |
998 | 1009 | ||
999 | if (update == false) | 1010 | if (update == false) |
1000 | return; | 1011 | return; |
1001 | 1012 | ||
1002 | if (doUpdate) | 1013 | if (doUpdate) |
1003 | emit modechange(); // tell buttons what happened | 1014 | emit modechange(); // tell buttons what happened |
1004 | 1015 | ||
1005 | // ugly hack to force a QMainWindow::triggerLayout( TRUE ) | 1016 | // ugly hack to force a QMainWindow::triggerLayout( TRUE ) |
1006 | if ( mainWindow() ) { | 1017 | if ( mainWindow() ) { |
1007 | QMainWindow *mw = mainWindow(); | 1018 | Q3MainWindow *mw = mainWindow(); |
1008 | mw->setUpdatesEnabled( FALSE ); | 1019 | mw->setUpdatesEnabled( FALSE ); |
1009 | mw->setToolBarsMovable( !mw->toolBarsMovable() ); | 1020 | mw->setToolBarsMovable( !mw->toolBarsMovable() ); |
1010 | mw->setToolBarsMovable( !mw->toolBarsMovable() ); | 1021 | mw->setToolBarsMovable( !mw->toolBarsMovable() ); |
1011 | mw->setUpdatesEnabled( TRUE ); | 1022 | mw->setUpdatesEnabled( TRUE ); |
1012 | } | 1023 | } |
1013 | } | 1024 | } |
1014 | 1025 | ||
1015 | 1026 | ||
1016 | int KToolBar::iconSize() const | 1027 | int KToolBar::iconSize() const |
1017 | { | 1028 | { |
1018 | /*US | 1029 | /*US |
1019 | if ( !d->m_iconSize ) // default value? | 1030 | if ( !d->m_iconSize ) // default value? |
1020 | { | 1031 | { |
1021 | if (!::qstrcmp(QObject::name(), "mainToolBar")) | 1032 | if (!::qstrcmp(QObject::name(), "mainToolBar")) |
1022 | return KGlobal::iconLoader()->currentSize(KIcon::MainToolbar); | 1033 | return KGlobal::iconLoader()->currentSize(KIcon::MainToolbar); |
1023 | else | 1034 | else |
1024 | return KGlobal::iconLoader()->currentSize(KIcon::Toolbar); | 1035 | return KGlobal::iconLoader()->currentSize(KIcon::Toolbar); |
1025 | } | 1036 | } |
1026 | return d->m_iconSize; | 1037 | return d->m_iconSize; |
1027 | */ | 1038 | */ |
1028 | int ret = 18; | 1039 | int ret = 18; |
1029 | if ( QApplication::desktop()->width() > 320 ) | 1040 | if ( QApplication::desktop()->width() > 320 ) |
1030 | ret = 30; | 1041 | ret = 30; |
1031 | return ret; | 1042 | return ret; |
1032 | } | 1043 | } |
1033 | 1044 | ||
1034 | 1045 | ||
1035 | void KToolBar::setEnableContextMenu(bool enable ) | 1046 | void KToolBar::setEnableContextMenu(bool enable ) |
1036 | { | 1047 | { |
1037 | d->m_enableContext = enable; | 1048 | d->m_enableContext = enable; |
1038 | } | 1049 | } |
1039 | 1050 | ||
1040 | 1051 | ||
1041 | bool KToolBar::contextMenuEnabled() const | 1052 | bool KToolBar::contextMenuEnabled() const |
1042 | { | 1053 | { |
1043 | return d->m_enableContext; | 1054 | return d->m_enableContext; |
1044 | } | 1055 | } |
1045 | 1056 | ||
1046 | 1057 | ||
1047 | void KToolBar::setItemNoStyle(int id, bool no_style ) | 1058 | void KToolBar::setItemNoStyle(int id, bool no_style ) |
1048 | { | 1059 | { |
1049 | Id2WidgetMap::Iterator it = id2widget.find( id ); | 1060 | Id2WidgetMap::Iterator it = id2widget.find( id ); |
1050 | if ( it == id2widget.end() ) | 1061 | if ( it == id2widget.end() ) |
1051 | return; | 1062 | return; |
1052 | //US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); | 1063 | //US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); |
1053 | KToolBarButton * button = (KToolBarButton *)( *it ); | 1064 | KToolBarButton * button = (KToolBarButton *)( *it ); |
1054 | if (button) | 1065 | if (button) |
1055 | button->setNoStyle( no_style ); | 1066 | button->setNoStyle( no_style ); |
1056 | } | 1067 | } |
1057 | 1068 | ||
1058 | 1069 | ||
1059 | void KToolBar::setFlat (bool flag) | 1070 | void KToolBar::setFlat (bool flag) |
1060 | { | 1071 | { |
1061 | if ( !mainWindow() ) | 1072 | if ( !mainWindow() ) |
1062 | return; | 1073 | return; |
1063 | if ( flag ) | 1074 | if ( flag ) |
1064 | //US mainWindow()->moveDockWindow( this, DockMinimized ); | 1075 | //US mainWindow()->moveDockWindow( this, DockMinimized ); |
1065 | mainWindow()->moveToolBar( this, QMainWindow::Minimized ); | 1076 | mainWindow()->moveToolBar( this, Qt::Minimized ); |
1066 | else | 1077 | else |
1067 | //US mainWindow()->moveDockWindow( this, DockTop ); | 1078 | //US mainWindow()->moveDockWindow( this, DockTop ); |
1068 | mainWindow()->moveToolBar( this, QMainWindow::Top ); | 1079 | mainWindow()->moveToolBar( this, Qt::Top ); |
1069 | // And remember to save the new look later | 1080 | // And remember to save the new look later |
1070 | /*US | 1081 | /*US |
1071 | if ( mainWindow()->inherits( "KMainWindow" ) ) | 1082 | if ( mainWindow()->inherits( "KMainWindow" ) ) |
1072 | static_cast<KMainWindow *>(mainWindow())->setSettingsDirty(); | 1083 | static_cast<KMainWindow *>(mainWindow())->setSettingsDirty(); |
1073 | */ | 1084 | */ |
1074 | } | 1085 | } |
1075 | 1086 | ||
1076 | 1087 | ||
1077 | int KToolBar::count() const | 1088 | int KToolBar::count() const |
1078 | { | 1089 | { |
1079 | return id2widget.count(); | 1090 | return id2widget.count(); |
1080 | } | 1091 | } |
1081 | 1092 | ||
1082 | 1093 | ||
1083 | void KToolBar::saveState() | 1094 | void KToolBar::saveState() |
1084 | { | 1095 | { |
1085 | /*US | 1096 | /*US |
1086 | // first, try to save to the xml file | 1097 | // first, try to save to the xml file |
1087 | if ( d->m_xmlguiClient && !d->m_xmlguiClient->xmlFile().isEmpty() ) { | 1098 | if ( d->m_xmlguiClient && !d->m_xmlguiClient->xmlFile().isEmpty() ) { |
1088 | // go down one level to get to the right tags | 1099 | // go down one level to get to the right tags |
1089 | QDomElement elem = d->m_xmlguiClient->domDocument().documentElement().toElement(); | 1100 | QDomElement elem = d->m_xmlguiClient->domDocument().documentElement().toElement(); |
1090 | elem = elem.firstChild().toElement(); | 1101 | elem = elem.firstChild().toElement(); |
1091 | QString barname(!::qstrcmp(name(), "unnamed") ? "mainToolBar" : name()); | 1102 | QString barname(!::qstrcmp(name(), "unnamed") ? "mainToolBar" : name()); |
1092 | QDomElement current; | 1103 | QDomElement current; |
1093 | // now try to find our toolbar | 1104 | // now try to find our toolbar |
1094 | d->modified = false; | 1105 | d->modified = false; |
1095 | for( ; !elem.isNull(); elem = elem.nextSibling().toElement() ) { | 1106 | for( ; !elem.isNull(); elem = elem.nextSibling().toElement() ) { |
1096 | current = elem; | 1107 | current = elem; |
1097 | 1108 | ||
1098 | if ( current.tagName().lower() != "toolbar" ) | 1109 | if ( current.tagName().lower() != "toolbar" ) |
1099 | continue; | 1110 | continue; |
1100 | 1111 | ||
1101 | QString curname(current.attribute( "name" )); | 1112 | QString curname(current.attribute( "name" )); |
1102 | 1113 | ||
1103 | if ( curname == barname ) { | 1114 | if ( curname == barname ) { |
1104 | saveState( current ); | 1115 | saveState( current ); |
1105 | break; | 1116 | break; |
1106 | } | 1117 | } |
1107 | } | 1118 | } |
1108 | // if we didn't make changes, then just return | 1119 | // if we didn't make changes, then just return |
1109 | if ( !d->modified ) | 1120 | if ( !d->modified ) |
1110 | return; | 1121 | return; |
1111 | 1122 | ||
1112 | // now we load in the (non-merged) local file | 1123 | // now we load in the (non-merged) local file |
1113 | QString local_xml(KXMLGUIFactory::readConfigFile(d->m_xmlguiClient->xmlFile(), true, d->m_xmlguiClient->instance())); | 1124 | QString local_xml(KXMLGUIFactory::readConfigFile(d->m_xmlguiClient->xmlFile(), true, d->m_xmlguiClient->instance())); |
1114 | QDomDocument local; | 1125 | QDomDocument local; |
1115 | local.setContent(local_xml); | 1126 | local.setContent(local_xml); |
1116 | 1127 | ||
1117 | // make sure we don't append if this toolbar already exists locally | 1128 | // make sure we don't append if this toolbar already exists locally |
1118 | bool just_append = true; | 1129 | bool just_append = true; |
1119 | elem = local.documentElement().toElement(); | 1130 | elem = local.documentElement().toElement(); |
1120 | KXMLGUIFactory::removeDOMComments( elem ); | 1131 | KXMLGUIFactory::removeDOMComments( elem ); |
1121 | elem = elem.firstChild().toElement(); | 1132 | elem = elem.firstChild().toElement(); |
1122 | for( ; !elem.isNull(); elem = elem.nextSibling().toElement() ) { | 1133 | for( ; !elem.isNull(); elem = elem.nextSibling().toElement() ) { |
1123 | if ( elem.tagName().lower() != "toolbar" ) | 1134 | if ( elem.tagName().lower() != "toolbar" ) |
1124 | continue; | 1135 | continue; |
1125 | 1136 | ||
1126 | QString curname(elem.attribute( "name" )); | 1137 | QString curname(elem.attribute( "name" )); |
1127 | 1138 | ||
1128 | if ( curname == barname ) { | 1139 | if ( curname == barname ) { |
1129 | just_append = false; | 1140 | just_append = false; |
1130 | local.documentElement().replaceChild( current, elem ); | 1141 | local.documentElement().replaceChild( current, elem ); |
1131 | break; | 1142 | break; |
1132 | } | 1143 | } |
1133 | } | 1144 | } |
1134 | 1145 | ||
1135 | if (just_append) | 1146 | if (just_append) |
1136 | local.documentElement().appendChild( current ); | 1147 | local.documentElement().appendChild( current ); |
1137 | 1148 | ||
1138 | KXMLGUIFactory::saveConfigFile(local, d->m_xmlguiClient->localXMLFile(), d->m_xmlguiClient->instance() ); | 1149 | KXMLGUIFactory::saveConfigFile(local, d->m_xmlguiClient->localXMLFile(), d->m_xmlguiClient->instance() ); |
1139 | 1150 | ||
1140 | return; | 1151 | return; |
1141 | } | 1152 | } |
1142 | */ | 1153 | */ |
1143 | // if that didn't work, we save to the config file | 1154 | // if that didn't work, we save to the config file |
1144 | KConfig *config = KGlobal::config(); | 1155 | KConfig *config = KGlobal::config(); |
1145 | saveSettings(config, QString::null); | 1156 | saveSettings(config, QString::null); |
1146 | config->sync(); | 1157 | config->sync(); |
1147 | } | 1158 | } |
1148 | 1159 | ||
1149 | QString KToolBar::settingsGroup() | 1160 | QString KToolBar::settingsGroup() |
1150 | { | 1161 | { |
1151 | QString configGroup; | 1162 | QString configGroup; |
1152 | if (!::qstrcmp(name(), "unnamed") || !::qstrcmp(name(), "mainToolBar")) | 1163 | if (!::qstrcmp(name(), "unnamed") || !::qstrcmp(name(), "mainToolBar")) |
1153 | configGroup = "Toolbar style"; | 1164 | configGroup = "Toolbar style"; |
1154 | else | 1165 | else |
1155 | configGroup = QString(name()) + " Toolbar style"; | 1166 | configGroup = QString(name()) + " Toolbar style"; |
1156 | if ( this->mainWindow() ) | 1167 | if ( this->mainWindow() ) |
1157 | { | 1168 | { |
1158 | configGroup.prepend(" "); | 1169 | configGroup.prepend(" "); |
1159 | configGroup.prepend( this->mainWindow()->name() ); | 1170 | configGroup.prepend( this->mainWindow()->name() ); |
1160 | } | 1171 | } |
1161 | return configGroup; | 1172 | return configGroup; |
1162 | } | 1173 | } |
1163 | 1174 | ||
1164 | void KToolBar::saveSettings(KConfig *config, const QString &_configGroup) | 1175 | void KToolBar::saveSettings(KConfig *config, const QString &_configGroup) |
1165 | { | 1176 | { |
1166 | return; | 1177 | return; |
1167 | QString configGroup = _configGroup; | 1178 | QString configGroup = _configGroup; |
1168 | if (configGroup.isEmpty()) | 1179 | if (configGroup.isEmpty()) |
1169 | configGroup = settingsGroup(); | 1180 | configGroup = settingsGroup(); |
1170 | //kdDebug(220) << "KToolBar::saveSettings group=" << _configGroup << " -> " << configGroup << endl; | 1181 | //kdDebug(220) << "KToolBar::saveSettings group=" << _configGroup << " -> " << configGroup << endl; |
1171 | 1182 | ||
1172 | QString position, icontext; | 1183 | QString position, icontext; |
1173 | int index; | 1184 | int index; |
1174 | getAttributes( position, icontext, index ); | 1185 | getAttributes( position, icontext, index ); |
1175 | 1186 | ||
1176 | //kdDebug(220) << "KToolBar::saveSettings " << name() << " newLine=" << newLine << endl; | 1187 | //kdDebug(220) << "KToolBar::saveSettings " << name() << " newLine=" << newLine << endl; |
1177 | 1188 | ||
1178 | KConfigGroupSaver saver(config, configGroup); | 1189 | KConfigGroupSaver saver(config, configGroup); |
1179 | 1190 | ||
1180 | if ( position != d->PositionDefault ) | 1191 | if ( position != d->PositionDefault ) |
1181 | config->writeEntry("Position", position); | 1192 | config->writeEntry("Position", position); |
1182 | else | 1193 | else |
1183 | config->deleteEntry("Position"); | 1194 | config->deleteEntry("Position"); |
1184 | 1195 | ||
1185 | if ( icontext != d->IconTextDefault ) | 1196 | if ( icontext != d->IconTextDefault ) |
1186 | config->writeEntry("IconText", icontext); | 1197 | config->writeEntry("IconText", icontext); |
1187 | else | 1198 | else |
1188 | config->deleteEntry("IconText"); | 1199 | config->deleteEntry("IconText"); |
1189 | 1200 | ||
1190 | if ( iconSize() != d->IconSizeDefault ) | 1201 | if ( iconSize() != d->IconSizeDefault ) |
1191 | config->writeEntry("IconSize", iconSize()); | 1202 | config->writeEntry("IconSize", iconSize()); |
1192 | else | 1203 | else |
1193 | config->deleteEntry("IconSize"); | 1204 | config->deleteEntry("IconSize"); |
1194 | 1205 | ||
1195 | if ( isHidden() != d->HiddenDefault ) | 1206 | if ( isHidden() != d->HiddenDefault ) |
1196 | config->writeEntry("Hidden", isHidden()); | 1207 | config->writeEntry("Hidden", isHidden()); |
1197 | else | 1208 | else |
1198 | config->deleteEntry("Hidden"); | 1209 | config->deleteEntry("Hidden"); |
1199 | 1210 | ||
1200 | if ( index != d->IndexDefault ) | 1211 | if ( index != d->IndexDefault ) |
1201 | config->writeEntry( "Index", index ); | 1212 | config->writeEntry( "Index", index ); |
1202 | else | 1213 | else |
1203 | config->deleteEntry("Index"); | 1214 | config->deleteEntry("Index"); |
1204 | //US the older version of KDE (used on the Zaurus) has no Offset property | 1215 | //US the older version of KDE (used on the Zaurus) has no Offset property |
1205 | /* if ( offset() != d->OffsetDefault ) | 1216 | /* if ( offset() != d->OffsetDefault ) |
1206 | config->writeEntry( "Offset", offset() ); | 1217 | config->writeEntry( "Offset", offset() ); |
1207 | else | 1218 | else |
1208 | */ | 1219 | */ |
1209 | config->deleteEntry("Offset"); | 1220 | config->deleteEntry("Offset"); |
1210 | 1221 | ||
1211 | //US the older version of KDE (used on the Zaurus) has no NewLine property | 1222 | //US the older version of KDE (used on the Zaurus) has no NewLine property |
1212 | /* | 1223 | /* |
1213 | if ( newLine() != d->NewLineDefault ) | 1224 | if ( newLine() != d->NewLineDefault ) |
1214 | config->writeEntry( "NewLine", newLine() ); | 1225 | config->writeEntry( "NewLine", newLine() ); |
1215 | else | 1226 | else |
1216 | */ | 1227 | */ |
1217 | config->deleteEntry("NewLine"); | 1228 | config->deleteEntry("NewLine"); |
1218 | } | 1229 | } |
1219 | 1230 | ||
1220 | void KToolBar::setXMLGUIClient( KXMLGUIClient *client ) | 1231 | void KToolBar::setXMLGUIClient( KXMLGUIClient *client ) |
1221 | { | 1232 | { |
1222 | d->m_xmlguiClient = client; | 1233 | d->m_xmlguiClient = client; |
1223 | } | 1234 | } |
1224 | 1235 | ||
1225 | void KToolBar::setText( const QString & txt ) | 1236 | void KToolBar::setText( const QString & txt ) |
1226 | { | 1237 | { |
1227 | //US setLabel( txt + " ( " + kapp->caption() + " ) " ); | 1238 | //US setLabel( txt + " ( " + kapp->caption() + " ) " ); |
1228 | setLabel( txt + " ( " + KGlobal::getAppName() + " ) " ); | 1239 | setLabel( txt + " ( " + KGlobal::getAppName() + " ) " ); |
1229 | } | 1240 | } |
1230 | 1241 | ||
1231 | 1242 | ||
1232 | QString KToolBar::text() const | 1243 | QString KToolBar::text() const |
1233 | { | 1244 | { |
1234 | return label(); | 1245 | return label(); |
1235 | } | 1246 | } |
1236 | 1247 | ||
1237 | 1248 | ||
1238 | void KToolBar::doConnections( KToolBarButton *button ) | 1249 | void KToolBar::doConnections( KToolBarButton *button ) |
1239 | { | 1250 | { |
1240 | connect(button, SIGNAL(clicked(int)), this, SIGNAL( clicked( int ) ) ); | 1251 | connect(button, SIGNAL(clicked(int)), this, SIGNAL( clicked( int ) ) ); |
1241 | connect(button, SIGNAL(doubleClicked(int)), this, SIGNAL( doubleClicked( int ) ) ); | 1252 | connect(button, SIGNAL(doubleClicked(int)), this, SIGNAL( doubleClicked( int ) ) ); |
1242 | connect(button, SIGNAL(released(int)), this, SIGNAL( released( int ) ) ); | 1253 | connect(button, SIGNAL(released(int)), this, SIGNAL( released( int ) ) ); |
1243 | connect(button, SIGNAL(pressed(int)), this, SIGNAL( pressed( int ) ) ); | 1254 | connect(button, SIGNAL(pressed(int)), this, SIGNAL( pressed( int ) ) ); |
1244 | connect(button, SIGNAL(toggled(int)), this, SIGNAL( toggled( int ) ) ); | 1255 | connect(button, SIGNAL(toggled(int)), this, SIGNAL( toggled( int ) ) ); |
1245 | connect(button, SIGNAL(highlighted(int, bool)), this, SIGNAL( highlighted( int, bool ) ) ); | 1256 | connect(button, SIGNAL(highlighted(int, bool)), this, SIGNAL( highlighted( int, bool ) ) ); |
1246 | } | 1257 | } |
1247 | 1258 | ||
1248 | void KToolBar::mousePressEvent ( QMouseEvent *m ) | 1259 | void KToolBar::mousePressEvent ( QMouseEvent *m ) |
1249 | { | 1260 | { |
1250 | if ( !mainWindow() ) | 1261 | if ( !mainWindow() ) |
1251 | return; | 1262 | return; |
1252 | QMainWindow *mw = mainWindow(); | 1263 | Q3MainWindow *mw = mainWindow(); |
1253 | if ( mw->toolBarsMovable() && d->m_enableContext ) { | 1264 | if ( mw->toolBarsMovable() && d->m_enableContext ) { |
1254 | if ( m->button() == RightButton ) { | 1265 | if ( m->button() == Qt::RightButton ) { |
1255 | int i = contextMenu()->exec( m->globalPos(), 0 ); | 1266 | int i = contextMenu()->exec( m->globalPos(), 0 ); |
1256 | switch ( i ) { | 1267 | switch ( i ) { |
1257 | case -1: | 1268 | case -1: |
1258 | return; // popup cancelled | 1269 | return; // popup cancelled |
1259 | case CONTEXT_LEFT: | 1270 | case CONTEXT_LEFT: |
1260 | //US mw->moveDockWindow( this, DockLeft ); | 1271 | //US mw->moveDockWindow( this, DockLeft ); |
1261 | mw->moveToolBar( this, QMainWindow::Left ); | 1272 | mw->moveToolBar( this, Qt::Left ); |
1262 | break; | 1273 | break; |
1263 | case CONTEXT_RIGHT: | 1274 | case CONTEXT_RIGHT: |
1264 | //US mw->moveDockWindow( this, DockRight ); | 1275 | //US mw->moveDockWindow( this, DockRight ); |
1265 | mw->moveToolBar( this, QMainWindow::Right ); | 1276 | mw->moveToolBar( this, Qt::Right ); |
1266 | break; | 1277 | break; |
1267 | case CONTEXT_TOP: | 1278 | case CONTEXT_TOP: |
1268 | //US mw->moveDockWindow( this, DockTop ); | 1279 | //US mw->moveDockWindow( this, DockTop ); |
1269 | mw->moveToolBar( this, QMainWindow::Top ); | 1280 | mw->moveToolBar( this, Qt::Top ); |
1270 | break; | 1281 | break; |
1271 | case CONTEXT_BOTTOM: | 1282 | case CONTEXT_BOTTOM: |
1272 | //US mw->moveDockWindow( this, DockBottom ); | 1283 | //US mw->moveDockWindow( this, DockBottom ); |
1273 | mw->moveToolBar( this, QMainWindow::Bottom ); | 1284 | mw->moveToolBar( this, Qt::Bottom ); |
1274 | break; | 1285 | break; |
1275 | case CONTEXT_FLOAT: | 1286 | case CONTEXT_FLOAT: |
1276 | break; | 1287 | break; |
1277 | case CONTEXT_FLAT: | 1288 | case CONTEXT_FLAT: |
1278 | //US mw->moveDockWindow( this, DockMinimized ); | 1289 | //US mw->moveDockWindow( this, DockMinimized ); |
1279 | mw->moveToolBar( this, QMainWindow::Minimized ); | 1290 | mw->moveToolBar( this, Qt::Minimized ); |
1280 | break; | 1291 | break; |
1281 | case CONTEXT_ICONS: | 1292 | case CONTEXT_ICONS: |
1282 | setIconText( IconOnly ); | 1293 | setIconText( IconOnly ); |
1283 | break; | 1294 | break; |
1284 | case CONTEXT_TEXTRIGHT: | 1295 | case CONTEXT_TEXTRIGHT: |
1285 | setIconText( IconTextRight ); | 1296 | setIconText( IconTextRight ); |
1286 | break; | 1297 | break; |
1287 | case CONTEXT_TEXT: | 1298 | case CONTEXT_TEXT: |
1288 | setIconText( TextOnly ); | 1299 | setIconText( TextOnly ); |
1289 | break; | 1300 | break; |
1290 | case CONTEXT_TEXTUNDER: | 1301 | case CONTEXT_TEXTUNDER: |
1291 | setIconText( IconTextBottom ); | 1302 | setIconText( IconTextBottom ); |
1292 | break; | 1303 | break; |
1293 | default: | 1304 | default: |
1294 | if ( i >= CONTEXT_ICONSIZES ) | 1305 | if ( i >= CONTEXT_ICONSIZES ) |
1295 | setIconSize( i - CONTEXT_ICONSIZES ); | 1306 | setIconSize( i - CONTEXT_ICONSIZES ); |
1296 | else | 1307 | else |
1297 | return; // assume this was an action handled elsewhere, no need for setSettingsDirty() | 1308 | return; // assume this was an action handled elsewhere, no need for setSettingsDirty() |
1298 | } | 1309 | } |
1299 | /*US | 1310 | /*US |
1300 | if ( mw->inherits("KMainWindow") ) | 1311 | if ( mw->inherits("KMainWindow") ) |
1301 | static_cast<KMainWindow *>(mw)->setSettingsDirty(); | 1312 | static_cast<KMainWindow *>(mw)->setSettingsDirty(); |
1302 | */ | 1313 | */ |
1303 | } | 1314 | } |
1304 | } | 1315 | } |
1305 | } | 1316 | } |
1306 | 1317 | ||
1307 | 1318 | ||
1308 | void KToolBar::rebuildLayout() | 1319 | void KToolBar::rebuildLayout() |
1309 | { | 1320 | { |
1310 | 1321 | ||
1311 | for(QWidget *w=d->idleButtons.first(); w; w=d->idleButtons.next()) | 1322 | for(QWidget *w=d->idleButtons.first(); w; w=d->idleButtons.next()) |
1312 | w->blockSignals(false); | 1323 | w->blockSignals(false); |
1313 | d->idleButtons.clear(); | 1324 | d->idleButtons.clear(); |
1314 | 1325 | ||
1315 | layoutTimer->stop(); | 1326 | layoutTimer->stop(); |
1316 | QApplication::sendPostedEvents( this, QEvent::ChildInserted ); | 1327 | QApplication::sendPostedEvents( this, QEvent::ChildInserted ); |
1317 | QBoxLayout *l = boxLayout(); | 1328 | QBoxLayout *l = boxLayout(); |
1318 | l->setMargin( 1 ); | 1329 | l->setMargin( 1 ); |
1319 | // clear the old layout | 1330 | // clear the old layout |
1320 | QLayoutIterator it = l->iterator(); | 1331 | QLayoutIterator it = l->iterator(); |
1321 | 1332 | ||
1322 | while ( it.current() ) { | 1333 | while ( it.current() ) { |
1323 | it.deleteCurrent(); | 1334 | it.deleteCurrent(); |
1324 | } | 1335 | } |
1325 | for ( QWidget *w = widgets.first(); w; w = widgets.next() ) { | 1336 | for ( QWidget *w = widgets.first(); w; w = widgets.next() ) { |
1326 | if ( w == rightAligned ) { | 1337 | if ( w == rightAligned ) { |
1327 | continue; | 1338 | continue; |
1328 | } | 1339 | } |
1329 | if ( w->inherits( "KToolBarSeparator" ) && | 1340 | if ( w->inherits( "KToolBarSeparator" ) && |
1330 | !( (KToolBarSeparator*)w )->showLine() ) { | 1341 | !( (KToolBarSeparator*)w )->showLine() ) { |
1331 | l->addSpacing( 6 ); | 1342 | l->addSpacing( 6 ); |
1332 | w->hide(); | 1343 | w->hide(); |
1333 | continue; | 1344 | continue; |
1334 | } | 1345 | } |
1335 | if ( w->inherits( "QPopupMenu" ) ) | 1346 | if ( w->inherits( "Q3PopupMenu" ) ) |
1336 | continue; | 1347 | continue; |
1337 | l->addWidget( w ); | 1348 | l->addWidget( w ); |
1338 | w->show(); | 1349 | w->show(); |
1339 | } | 1350 | } |
1340 | if ( rightAligned ) { | 1351 | if ( rightAligned ) { |
1341 | l->addStretch(); | 1352 | l->addStretch(); |
1342 | l->addWidget( rightAligned ); | 1353 | l->addWidget( rightAligned ); |
1343 | rightAligned->show(); | 1354 | rightAligned->show(); |
1344 | } | 1355 | } |
1345 | 1356 | ||
1346 | if ( fullSize() ) { | 1357 | if ( fullSize() ) { |
1347 | // This code sucks. It makes the last combo in a toolbar VERY big (e.g. zoom combo in kword). | 1358 | // This code sucks. It makes the last combo in a toolbar VERY big (e.g. zoom combo in kword). |
1348 | //if ( !stretchableWidget && widgets.last() && | 1359 | //if ( !stretchableWidget && widgets.last() && |
1349 | // !widgets.last()->inherits( "QButton" ) && !widgets.last()->inherits( "KAnimWidget" ) ) | 1360 | // !widgets.last()->inherits( "QButton" ) && !widgets.last()->inherits( "KAnimWidget" ) ) |
1350 | // setStretchableWidget( widgets.last() ); | 1361 | // setStretchableWidget( widgets.last() ); |
1351 | if ( !rightAligned ) | 1362 | if ( !rightAligned ) |
1352 | l->addStretch(); | 1363 | l->addStretch(); |
1353 | if ( stretchableWidget ) | 1364 | if ( stretchableWidget ) |
1354 | l->setStretchFactor( stretchableWidget, 10 ); | 1365 | l->setStretchFactor( stretchableWidget, 10 ); |
1355 | } | 1366 | } |
1356 | l->invalidate(); | 1367 | l->invalidate(); |
1357 | QApplication::postEvent( this, new QEvent( QEvent::LayoutHint ) ); | 1368 | QApplication::postEvent( this, new QEvent( QEvent::LayoutHint ) ); |
1358 | //#endif //DESKTOP_VERSION | 1369 | //#endif //DESKTOP_VERSION |
1359 | } | 1370 | } |
1360 | 1371 | ||
1361 | void KToolBar::childEvent( QChildEvent *e ) | 1372 | void KToolBar::childEvent( QChildEvent *e ) |
1362 | { | 1373 | { |
1363 | 1374 | ||
1364 | if ( e->child()->isWidgetType() ) { | 1375 | if ( e->child()->isWidgetType() ) { |
1365 | QWidget * w = (QWidget*)e->child(); | 1376 | QWidget * w = (QWidget*)e->child(); |
1366 | if ( e->type() == QEvent::ChildInserted ) { | 1377 | if ( e->type() == QEvent::ChildInserted ) { |
1367 | if ( !e->child()->inherits( "QPopupMenu" ) && | 1378 | if ( !e->child()->inherits( "Q3PopupMenu" ) && |
1368 | ::qstrcmp( "qt_dockwidget_internal", e->child()->name() ) != 0 ) { | 1379 | ::qstrcmp( "qt_dockwidget_internal", e->child()->name() ) != 0 ) { |
1369 | 1380 | ||
1370 | // prevent items that have been explicitly inserted by insert*() from | 1381 | // prevent items that have been explicitly inserted by insert*() from |
1371 | // being inserted again | 1382 | // being inserted again |
1372 | if ( !widget2id.contains( w ) ) | 1383 | if ( !widget2id.contains( w ) ) |
1373 | { | 1384 | { |
1374 | int dummy = -1; | 1385 | int dummy = -1; |
1375 | insertWidgetInternal( w, dummy, -1 ); | 1386 | insertWidgetInternal( w, dummy, -1 ); |
1376 | } | 1387 | } |
1377 | } | 1388 | } |
1378 | } else { | 1389 | } else if( e->type() == QEvent::ChildRemoved ) { |
1379 | removeWidgetInternal( w ); | 1390 | removeWidgetInternal( w ); |
1380 | } | 1391 | } |
1381 | if ( isVisibleTo( 0 ) ) | 1392 | /* TODO:hacker: if ( isVisibleTo( 0 ) ) |
1382 | { | 1393 | { |
1383 | QBoxLayout *l = boxLayout(); | 1394 | QBoxLayout *l = boxLayout(); |
1384 | // QLayout *l = layout(); | 1395 | // QLayout *l = layout(); |
1385 | 1396 | ||
1386 | // clear the old layout so that we don't get unnecassery layout | 1397 | // clear the old layout so that we don't get unnecassery layout |
1387 | // changes till we have rebuild the thing | 1398 | // changes till we have rebuild the thing |
1388 | QLayoutIterator it = l->iterator(); | 1399 | QLayoutIterator it = l->iterator(); |
1389 | while ( it.current() ) { | 1400 | while ( it.current() ) { |
1390 | it.deleteCurrent(); | 1401 | it.deleteCurrent(); |
1391 | } | 1402 | } |
1392 | layoutTimer->start( 50, TRUE ); | 1403 | layoutTimer->start( 50, TRUE ); |
1393 | } | 1404 | } */ |
1394 | } | 1405 | } |
1395 | QToolBar::childEvent( e ); | 1406 | Q3ToolBar::childEvent( e ); |
1396 | } | 1407 | } |
1397 | 1408 | ||
1398 | void KToolBar::insertWidgetInternal( QWidget *w, int &index, int id ) | 1409 | void KToolBar::insertWidgetInternal( QWidget *w, int &index, int id ) |
1399 | { | 1410 | { |
1400 | // we can't have it in widgets, or something is really wrong | 1411 | // we can't have it in widgets, or something is really wrong |
1401 | //widgets.removeRef( w ); | 1412 | //widgets.removeRef( w ); |
1402 | 1413 | ||
1403 | connect( w, SIGNAL( destroyed() ), | 1414 | connect( w, SIGNAL( destroyed() ), |
1404 | this, SLOT( widgetDestroyed() ) ); | 1415 | this, SLOT( widgetDestroyed() ) ); |
1405 | if ( index == -1 || index > (int)widgets.count() ) { | 1416 | if ( index == -1 || index > (int)widgets.count() ) { |
1406 | widgets.append( w ); | 1417 | widgets.append( w ); |
1407 | index = (int)widgets.count(); | 1418 | index = (int)widgets.count(); |
1408 | } | 1419 | } |
1409 | else | 1420 | else |
1410 | widgets.insert( index, w ); | 1421 | widgets.insert( index, w ); |
1411 | if ( id == -1 ) | 1422 | if ( id == -1 ) |
1412 | id = id2widget.count(); | 1423 | id = id2widget.count(); |
1413 | id2widget.insert( id, w ); | 1424 | id2widget.insert( id, w ); |
1414 | widget2id.insert( w, id ); | 1425 | widget2id.insert( w, id ); |
1415 | } | 1426 | } |
1416 | void KToolBar::repaintMe() | 1427 | void KToolBar::repaintMe() |
1417 | { | 1428 | { |
1418 | setUpdatesEnabled( true ); | 1429 | setUpdatesEnabled( true ); |
1419 | QToolBar::repaint( true ); | 1430 | Q3ToolBar::repaint( true ); |
1420 | qDebug(" KToolBar::repaintMe() "); | 1431 | qDebug(" KToolBar::repaintMe() "); |
1421 | } | 1432 | } |
1422 | 1433 | ||
1423 | void KToolBar::showEvent( QShowEvent *e ) | 1434 | void KToolBar::showEvent( QShowEvent *e ) |
1424 | { | 1435 | { |
1425 | rebuildLayout(); | 1436 | rebuildLayout(); |
1426 | QToolBar::showEvent( e ); | 1437 | Q3ToolBar::showEvent( e ); |
1427 | } | 1438 | } |
1428 | 1439 | ||
1429 | void KToolBar::setStretchableWidget( QWidget *w ) | 1440 | void KToolBar::setStretchableWidget( QWidget *w ) |
1430 | { | 1441 | { |
1431 | QToolBar::setStretchableWidget( w ); | 1442 | Q3ToolBar::setStretchableWidget( w ); |
1432 | stretchableWidget = w; | 1443 | stretchableWidget = w; |
1433 | } | 1444 | } |
1434 | 1445 | ||
1435 | QSizePolicy KToolBar::sizePolicy() const | 1446 | QSizePolicy KToolBar::sizePolicy() const |
1436 | { | 1447 | { |
1437 | if ( orientation() == Horizontal ) | 1448 | if ( orientation() == Qt::Horizontal ) |
1438 | return QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ); | 1449 | return QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ); |
1439 | else | 1450 | else |
1440 | return QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Expanding ); | 1451 | return QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Expanding ); |
1441 | } | 1452 | } |
1442 | 1453 | ||
1443 | QSize KToolBar::sizeHint() const | 1454 | QSize KToolBar::sizeHint() const |
1444 | { | 1455 | { |
1445 | QSize sh = QToolBar::sizeHint(); | 1456 | QSize sh = Q3ToolBar::sizeHint(); |
1446 | //qDebug("%x KToolBar::sizeHint() %d %d ",this, QToolBar::sizeHint().width(),QToolBar::sizeHint().height() ); | 1457 | //qDebug("%x KToolBar::sizeHint() %d %d ",this, QToolBar::sizeHint().width(),QToolBar::sizeHint().height() ); |
1447 | if ( sh.height() <= 20 || sh.width() < 60 ) | 1458 | if ( sh.height() <= 20 || sh.width() < 60 ) |
1448 | return QSize( sizeHintW, sizeHintH ); | 1459 | return QSize( sizeHintW, sizeHintH ); |
1449 | KToolBar* ttt = (KToolBar*) this; | 1460 | KToolBar* ttt = (KToolBar*) this; |
1450 | ttt->sizeHintW = sh.width(); | 1461 | ttt->sizeHintW = sh.width(); |
1451 | ttt->sizeHintH = sh.height(); | 1462 | ttt->sizeHintH = sh.height(); |
1452 | return sh; | 1463 | return sh; |
1453 | //return QToolBar::sizeHint(); | 1464 | //return QToolBar::sizeHint(); |
1454 | #if 0 | 1465 | #if 0 |
1455 | QWidget::polish(); | 1466 | QWidget::polish(); |
1456 | static int iii = 0; | 1467 | static int iii = 0; |
1457 | ++iii; | 1468 | ++iii; |
1458 | qDebug("++++++++ KToolBar::sizeHint() %d ", iii ); | 1469 | qDebug("++++++++ KToolBar::sizeHint() %d ", iii ); |
1459 | int margin = static_cast<QWidget*>(ncThis)->layout()->margin(); | 1470 | int margin = static_cast<QWidget*>(ncThis)->layout()->margin(); |
1460 | switch( barPos() ) | 1471 | switch( barPos() ) |
1461 | { | 1472 | { |
1462 | case KToolBar::Top: | 1473 | case KToolBar::Top: |
1463 | case KToolBar::Bottom: | 1474 | case KToolBar::Bottom: |
1464 | for ( QWidget *w = widgets.first(); w; w =widgets.next() ) | 1475 | for ( QWidget *w = widgets.first(); w; w =widgets.next() ) |
1465 | { | 1476 | { |
1466 | if ( w->inherits( "KToolBarSeparator" ) && | 1477 | if ( w->inherits( "KToolBarSeparator" ) && |
1467 | !( static_cast<KToolBarSeparator*>(w)->showLine() ) ) | 1478 | !( static_cast<KToolBarSeparator*>(w)->showLine() ) ) |
1468 | { | 1479 | { |
1469 | minSize += QSize(6, 0); | 1480 | minSize += QSize(6, 0); |
1470 | } | 1481 | } |
1471 | else | 1482 | else |
1472 | { | 1483 | { |
1473 | QSize sh = w->sizeHint(); | 1484 | QSize sh = w->sizeHint(); |
1474 | if (!sh.isValid()) | 1485 | if (!sh.isValid()) |
1475 | sh = w->minimumSize(); | 1486 | sh = w->minimumSize(); |
1476 | minSize = minSize.expandedTo(QSize(0, sh.height())); | 1487 | minSize = minSize.expandedTo(QSize(0, sh.height())); |
1477 | minSize += QSize(sh.width()+1, 0); | 1488 | minSize += QSize(sh.width()+1, 0); |
1478 | } | 1489 | } |
1479 | } | 1490 | } |
1480 | /*US | 1491 | /*US |
1481 | minSize += QSize(QApplication::style().pixelMetric( QStyle::PM_DockWindowHandleExtent ), 0); | 1492 | minSize += QSize(QApplication::style().pixelMetric( QStyle::PM_DockWindowHandleExtent ), 0); |
1482 | */ | 1493 | */ |
1483 | minSize += QSize(margin*2, margin*2); | 1494 | minSize += QSize(margin*2, margin*2); |
1484 | break; | 1495 | break; |
1485 | 1496 | ||
1486 | case KToolBar::Left: | 1497 | case KToolBar::Left: |
1487 | case KToolBar::Right: | 1498 | case KToolBar::Right: |
1488 | for ( QWidget *w = widgets.first(); w; w = widgets.next() ) | 1499 | for ( QWidget *w = widgets.first(); w; w = widgets.next() ) |
1489 | { | 1500 | { |
1490 | if ( w->inherits( "KToolBarSeparator" ) && | 1501 | if ( w->inherits( "KToolBarSeparator" ) && |
1491 | !( static_cast<KToolBarSeparator*>(w)->showLine() ) ) | 1502 | !( static_cast<KToolBarSeparator*>(w)->showLine() ) ) |
1492 | { | 1503 | { |
1493 | minSize += QSize(0, 6); | 1504 | minSize += QSize(0, 6); |
1494 | } | 1505 | } |
1495 | else | 1506 | else |
1496 | { | 1507 | { |
1497 | QSize sh = w->sizeHint(); | 1508 | QSize sh = w->sizeHint(); |
1498 | if (!sh.isValid()) | 1509 | if (!sh.isValid()) |
1499 | sh = w->minimumSize(); | 1510 | sh = w->minimumSize(); |
1500 | minSize = minSize.expandedTo(QSize(sh.width(), 0)); | 1511 | minSize = minSize.expandedTo(QSize(sh.width(), 0)); |
1501 | minSize += QSize(0, sh.height()+1); | 1512 | minSize += QSize(0, sh.height()+1); |
1502 | } | 1513 | } |
1503 | } | 1514 | } |
1504 | /*US | 1515 | /*US |
1505 | minSize += QSize(0, QApplication::style().pixelMetric( QStyle::PM_DockWindowHandleExtent )); | 1516 | minSize += QSize(0, QApplication::style().pixelMetric( QStyle::PM_DockWindowHandleExtent )); |
1506 | */ | 1517 | */ |
1507 | minSize += QSize(margin*2, margin*2); | 1518 | minSize += QSize(margin*2, margin*2); |
1508 | break; | 1519 | break; |
1509 | 1520 | ||
1510 | default: | 1521 | default: |
1511 | minSize = QToolBar::sizeHint(); | 1522 | minSize = Q3ToolBar::sizeHint(); |
1512 | break; | 1523 | break; |
1513 | } | 1524 | } |
1514 | return minSize; | 1525 | return minSize; |
1515 | #endif | 1526 | #endif |
1516 | } | 1527 | } |
1517 | 1528 | ||
1518 | QSize KToolBar::minimumSize() const | 1529 | QSize KToolBar::minimumSize() const |
1519 | { | 1530 | { |
1520 | return minimumSizeHint(); | 1531 | return minimumSizeHint(); |
1521 | } | 1532 | } |
1522 | 1533 | ||
1523 | QSize KToolBar::minimumSizeHint() const | 1534 | QSize KToolBar::minimumSizeHint() const |
1524 | { | 1535 | { |
1525 | return sizeHint(); | 1536 | return sizeHint(); |
1526 | } | 1537 | } |
1527 | 1538 | ||
1528 | bool KToolBar::highlight() const | 1539 | bool KToolBar::highlight() const |
1529 | { | 1540 | { |
1530 | return d->m_highlight; | 1541 | return d->m_highlight; |
1531 | } | 1542 | } |
1532 | 1543 | ||
1533 | void KToolBar::hide() | 1544 | void KToolBar::hide() |
1534 | { | 1545 | { |
1535 | QToolBar::hide(); | 1546 | Q3ToolBar::hide(); |
1536 | } | 1547 | } |
1537 | 1548 | ||
1538 | void KToolBar::show() | 1549 | void KToolBar::show() |
1539 | { | 1550 | { |
1540 | QToolBar::show(); | 1551 | Q3ToolBar::show(); |
1541 | } | 1552 | } |
1542 | 1553 | ||
1543 | void KToolBar::resizeEvent( QResizeEvent *e ) | 1554 | void KToolBar::resizeEvent( QResizeEvent *e ) |
1544 | { | 1555 | { |
1545 | bool b = isUpdatesEnabled(); | 1556 | bool b = isUpdatesEnabled(); |
1546 | setUpdatesEnabled( FALSE ); | 1557 | setUpdatesEnabled( FALSE ); |
1547 | QToolBar::resizeEvent( e ); | 1558 | Q3ToolBar::resizeEvent( e ); |
1548 | if (b) | 1559 | if (b) |
1549 | d->repaintTimer.start( 100, true ); | 1560 | d->repaintTimer.start( 100, true ); |
1550 | } | 1561 | } |
1551 | 1562 | ||
1552 | void KToolBar::slotIconChanged(int group) | 1563 | void KToolBar::slotIconChanged(int group) |
1553 | { | 1564 | { |
1554 | if ((group != KIcon::Toolbar) && (group != KIcon::MainToolbar)) | 1565 | if ((group != KIcon::Toolbar) && (group != KIcon::MainToolbar)) |
1555 | return; | 1566 | return; |
1556 | if ((group == KIcon::MainToolbar) != !::qstrcmp(name(), "mainToolBar")) | 1567 | if ((group == KIcon::MainToolbar) != !::qstrcmp(name(), "mainToolBar")) |
1557 | return; | 1568 | return; |
1558 | 1569 | ||
1559 | emit modechange(); | 1570 | emit modechange(); |
1560 | if (isVisible()) | 1571 | if (isVisible()) |
1561 | updateGeometry(); | 1572 | updateGeometry(); |
1562 | } | 1573 | } |
1563 | 1574 | ||
1564 | void KToolBar::slotReadConfig() | 1575 | void KToolBar::slotReadConfig() |
1565 | { | 1576 | { |
1566 | //kdDebug(220) << "KToolBar::slotReadConfig" << endl; | 1577 | //kdDebug(220) << "KToolBar::slotReadConfig" << endl; |
1567 | // Read appearance settings (hmm, we used to do both here, | 1578 | // Read appearance settings (hmm, we used to do both here, |
1568 | // but a well behaved application will call applyMainWindowSettings | 1579 | // but a well behaved application will call applyMainWindowSettings |
1569 | // anyway, right ?) | 1580 | // anyway, right ?) |
1570 | applyAppearanceSettings(KGlobal::config(), QString::null ); | 1581 | applyAppearanceSettings(KGlobal::config(), QString::null ); |
1571 | } | 1582 | } |
1572 | 1583 | ||
1573 | void KToolBar::slotAppearanceChanged() | 1584 | void KToolBar::slotAppearanceChanged() |
1574 | { | 1585 | { |
1575 | // Read appearance settings from global file. | 1586 | // Read appearance settings from global file. |
1576 | applyAppearanceSettings(KGlobal::config(), QString::null, true /* lose local settings */ ); | 1587 | applyAppearanceSettings(KGlobal::config(), QString::null, true /* lose local settings */ ); |
1577 | // And remember to save the new look later | 1588 | // And remember to save the new look later |
1578 | /*US | 1589 | /*US |
1579 | if ( mainWindow() && mainWindow()->inherits( "KMainWindow" ) ) | 1590 | if ( mainWindow() && mainWindow()->inherits( "KMainWindow" ) ) |
1580 | static_cast<KMainWindow *>(mainWindow())->setSettingsDirty(); | 1591 | static_cast<KMainWindow *>(mainWindow())->setSettingsDirty(); |
1581 | */ | 1592 | */ |
1582 | } | 1593 | } |
1583 | 1594 | ||
1584 | //static | 1595 | //static |
1585 | bool KToolBar::highlightSetting() | 1596 | bool KToolBar::highlightSetting() |
1586 | { | 1597 | { |
1587 | QString grpToolbar(QString::fromLatin1("Toolbar style")); | 1598 | QString grpToolbar(QString::fromLatin1("Toolbar style")); |
1588 | KConfigGroupSaver saver(KGlobal::config(), grpToolbar); | 1599 | KConfigGroupSaver saver(KGlobal::config(), grpToolbar); |
1589 | return KGlobal::config()->readBoolEntry(QString::fromLatin1("Highlighting"),true); | 1600 | return KGlobal::config()->readBoolEntry(QString::fromLatin1("Highlighting"),true); |
1590 | } | 1601 | } |
1591 | 1602 | ||
1592 | //static | 1603 | //static |
1593 | bool KToolBar::transparentSetting() | 1604 | bool KToolBar::transparentSetting() |
1594 | { | 1605 | { |
1595 | QString grpToolbar(QString::fromLatin1("Toolbar style")); | 1606 | QString grpToolbar(QString::fromLatin1("Toolbar style")); |
1596 | KConfigGroupSaver saver(KGlobal::config(), grpToolbar); | 1607 | KConfigGroupSaver saver(KGlobal::config(), grpToolbar); |
1597 | return KGlobal::config()->readBoolEntry(QString::fromLatin1("TransparentMoving"),true); | 1608 | return KGlobal::config()->readBoolEntry(QString::fromLatin1("TransparentMoving"),true); |
1598 | } | 1609 | } |
1599 | 1610 | ||
1600 | //static | 1611 | //static |
1601 | KToolBar::IconText KToolBar::iconTextSetting() | 1612 | KToolBar::IconText KToolBar::iconTextSetting() |
1602 | { | 1613 | { |
1603 | QString grpToolbar(QString::fromLatin1("Toolbar style")); | 1614 | QString grpToolbar(QString::fromLatin1("Toolbar style")); |
1604 | KConfigGroupSaver saver(KGlobal::config(), grpToolbar); | 1615 | KConfigGroupSaver saver(KGlobal::config(), grpToolbar); |
1605 | QString icontext = KGlobal::config()->readEntry(QString::fromLatin1("IconText"),QString::fromLatin1("IconOnly")); | 1616 | QString icontext = KGlobal::config()->readEntry(QString::fromLatin1("IconText"),QString::fromLatin1("IconOnly")); |
1606 | if ( icontext == "IconTextRight" ) | 1617 | if ( icontext == "IconTextRight" ) |
1607 | return IconTextRight; | 1618 | return IconTextRight; |
1608 | else if ( icontext == "IconTextBottom" ) | 1619 | else if ( icontext == "IconTextBottom" ) |
1609 | return IconTextBottom; | 1620 | return IconTextBottom; |
1610 | else if ( icontext == "TextOnly" ) | 1621 | else if ( icontext == "TextOnly" ) |
1611 | return TextOnly; | 1622 | return TextOnly; |
1612 | else | 1623 | else |
1613 | return IconOnly; | 1624 | return IconOnly; |
1614 | } | 1625 | } |
1615 | 1626 | ||
1616 | void KToolBar::applyAppearanceSettings(KConfig *config, const QString &_configGroup, bool forceGlobal) | 1627 | void KToolBar::applyAppearanceSettings(KConfig *config, const QString &_configGroup, bool forceGlobal) |
1617 | { | 1628 | { |
1618 | return; | 1629 | return; |
1619 | QString configGroup = _configGroup.isEmpty() ? settingsGroup() : _configGroup; | 1630 | QString configGroup = _configGroup.isEmpty() ? settingsGroup() : _configGroup; |
1620 | //kdDebug(220) << "KToolBar::applyAppearanceSettings: configGroup=" << configGroup << endl; | 1631 | //kdDebug(220) << "KToolBar::applyAppearanceSettings: configGroup=" << configGroup << endl; |
1621 | // We have application-specific settings in the XML file, | 1632 | // We have application-specific settings in the XML file, |
1622 | // and nothing in the application's config file | 1633 | // and nothing in the application's config file |
1623 | // -> don't apply the global defaults, the XML ones are preferred | 1634 | // -> don't apply the global defaults, the XML ones are preferred |
1624 | // See applySettings for a full explanation | 1635 | // See applySettings for a full explanation |
1625 | /*US :we do not support xml files | 1636 | /*US :we do not support xml files |
1626 | if ( d->m_xmlguiClient && !d->m_xmlguiClient->xmlFile().isEmpty() && | 1637 | if ( d->m_xmlguiClient && !d->m_xmlguiClient->xmlFile().isEmpty() && |
1627 | !config->hasGroup(configGroup) ) | 1638 | !config->hasGroup(configGroup) ) |
1628 | { | 1639 | { |
1629 | //kdDebug(220) << "skipping global defaults, using XML ones instead" << endl; | 1640 | //kdDebug(220) << "skipping global defaults, using XML ones instead" << endl; |
1630 | return; | 1641 | return; |
1631 | } | 1642 | } |
1632 | */ | 1643 | */ |
1633 | if ( !config->hasGroup(configGroup) ) | 1644 | if ( !config->hasGroup(configGroup) ) |
1634 | { | 1645 | { |
1635 | //kdDebug(220) << "skipping global defaults, using XML ones instead" << endl; | 1646 | //kdDebug(220) << "skipping global defaults, using XML ones instead" << endl; |
1636 | return; | 1647 | return; |
1637 | } | 1648 | } |
1638 | 1649 | ||
1639 | 1650 | ||
1640 | KConfig *gconfig = KGlobal::config(); | 1651 | KConfig *gconfig = KGlobal::config(); |
1641 | /*US | 1652 | /*US |
1642 | static const QString &attrIconText = KGlobal::staticQString("IconText"); | 1653 | static const QString &attrIconText = KGlobal::staticQString("IconText"); |
1643 | static const QString &attrHighlight = KGlobal::staticQString("Highlighting"); | 1654 | static const QString &attrHighlight = KGlobal::staticQString("Highlighting"); |
1644 | static const QString &attrTrans = KGlobal::staticQString("TransparentMoving"); | 1655 | static const QString &attrTrans = KGlobal::staticQString("TransparentMoving"); |
1645 | static const QString &attrSize = KGlobal::staticQString("IconSize"); | 1656 | static const QString &attrSize = KGlobal::staticQString("IconSize"); |
1646 | */ | 1657 | */ |
1647 | // we actually do this in two steps. | 1658 | // we actually do this in two steps. |
1648 | // First, we read in the global styles [Toolbar style] (from the KControl module). | 1659 | // First, we read in the global styles [Toolbar style] (from the KControl module). |
1649 | // Then, if the toolbar is NOT 'mainToolBar', we will also try to read in [barname Toolbar style] | 1660 | // Then, if the toolbar is NOT 'mainToolBar', we will also try to read in [barname Toolbar style] |
1650 | bool highlight; | 1661 | bool highlight; |
1651 | int transparent; | 1662 | int transparent; |
1652 | QString icontext; | 1663 | QString icontext; |
1653 | int iconsize = 0; | 1664 | int iconsize = 0; |
1654 | 1665 | ||
1655 | // this is the first iteration | 1666 | // this is the first iteration |
1656 | QString grpToolbar(QString::fromLatin1("Toolbar style")); | 1667 | QString grpToolbar(QString::fromLatin1("Toolbar style")); |
1657 | { // start block for KConfigGroupSaver | 1668 | { // start block for KConfigGroupSaver |
1658 | KConfigGroupSaver saver(gconfig, grpToolbar); | 1669 | KConfigGroupSaver saver(gconfig, grpToolbar); |
1659 | 1670 | ||
1660 | // first, get the generic settings | 1671 | // first, get the generic settings |
1661 | //US highlight = gconfig->readBoolEntry(attrHighlight, true); | 1672 | //US highlight = gconfig->readBoolEntry(attrHighlight, true); |
1662 | highlight = gconfig->readBoolEntry("Highlighting", true); | 1673 | highlight = gconfig->readBoolEntry("Highlighting", true); |
1663 | //US transparent = gconfig->readBoolEntry(attrTrans, true); | 1674 | //US transparent = gconfig->readBoolEntry(attrTrans, true); |
1664 | transparent = gconfig->readBoolEntry("TransparentMoving", true); | 1675 | transparent = gconfig->readBoolEntry("TransparentMoving", true); |
1665 | 1676 | ||
1666 | // we read in the IconText property *only* if we intend on actually | 1677 | // we read in the IconText property *only* if we intend on actually |
1667 | // honoring it | 1678 | // honoring it |
1668 | if (d->m_honorStyle) | 1679 | if (d->m_honorStyle) |
1669 | //US d->IconTextDefault = gconfig->readEntry(attrIconText, d->IconTextDefault); | 1680 | //US d->IconTextDefault = gconfig->readEntry(attrIconText, d->IconTextDefault); |
1670 | d->IconTextDefault = gconfig->readEntry("IconText", d->IconTextDefault); | 1681 | d->IconTextDefault = gconfig->readEntry("IconText", d->IconTextDefault); |
1671 | else | 1682 | else |
1672 | d->IconTextDefault = "IconOnly"; | 1683 | d->IconTextDefault = "IconOnly"; |
1673 | 1684 | ||
1674 | // Use the default icon size for toolbar icons. | 1685 | // Use the default icon size for toolbar icons. |
1675 | //US d->IconSizeDefault = gconfig->readNumEntry(attrSize, d->IconSizeDefault); | 1686 | //US d->IconSizeDefault = gconfig->readNumEntry(attrSize, d->IconSizeDefault); |
1676 | d->IconSizeDefault = gconfig->readNumEntry("IconSize", d->IconSizeDefault); | 1687 | d->IconSizeDefault = gconfig->readNumEntry("IconSize", d->IconSizeDefault); |
1677 | 1688 | ||
1678 | if ( !forceGlobal && config->hasGroup(configGroup) ) | 1689 | if ( !forceGlobal && config->hasGroup(configGroup) ) |
1679 | { | 1690 | { |
1680 | config->setGroup(configGroup); | 1691 | config->setGroup(configGroup); |
1681 | 1692 | ||
1682 | // first, get the generic settings | 1693 | // first, get the generic settings |
1683 | //US highlight = config->readBoolEntry(attrHighlight, highlight); | 1694 | //US highlight = config->readBoolEntry(attrHighlight, highlight); |
1684 | highlight = config->readBoolEntry("Highlighting", highlight); | 1695 | highlight = config->readBoolEntry("Highlighting", highlight); |
1685 | //US transparent = config->readBoolEntry(attrTrans, transparent); | 1696 | //US transparent = config->readBoolEntry(attrTrans, transparent); |
1686 | transparent = config->readBoolEntry("TransparentMoving", transparent); | 1697 | transparent = config->readBoolEntry("TransparentMoving", transparent); |
1687 | // now we always read in the IconText property | 1698 | // now we always read in the IconText property |
1688 | //US icontext = config->readEntry(attrIconText, d->IconTextDefault); | 1699 | //US icontext = config->readEntry(attrIconText, d->IconTextDefault); |
1689 | icontext = config->readEntry("IconText", d->IconTextDefault); | 1700 | icontext = config->readEntry("IconText", d->IconTextDefault); |
1690 | 1701 | ||
1691 | // now get the size | 1702 | // now get the size |
1692 | //US iconsize = config->readNumEntry(attrSize, d->IconSizeDefault); | 1703 | //US iconsize = config->readNumEntry(attrSize, d->IconSizeDefault); |
1693 | iconsize = config->readNumEntry("IconSize", d->IconSizeDefault); | 1704 | iconsize = config->readNumEntry("IconSize", d->IconSizeDefault); |
1694 | } | 1705 | } |
1695 | else | 1706 | else |
1696 | { | 1707 | { |
1697 | iconsize = d->IconSizeDefault; | 1708 | iconsize = d->IconSizeDefault; |
1698 | icontext = d->IconTextDefault; | 1709 | icontext = d->IconTextDefault; |
1699 | } | 1710 | } |
1700 | 1711 | ||
1701 | // revert back to the old group | 1712 | // revert back to the old group |
1702 | } // end block for KConfigGroupSaver | 1713 | } // end block for KConfigGroupSaver |
1703 | 1714 | ||
1704 | bool doUpdate = false; | 1715 | bool doUpdate = false; |
1705 | 1716 | ||
1706 | IconText icon_text; | 1717 | IconText icon_text; |
1707 | if ( icontext == "IconTextRight" ) | 1718 | if ( icontext == "IconTextRight" ) |
1708 | icon_text = IconTextRight; | 1719 | icon_text = IconTextRight; |
1709 | else if ( icontext == "IconTextBottom" ) | 1720 | else if ( icontext == "IconTextBottom" ) |
1710 | icon_text = IconTextBottom; | 1721 | icon_text = IconTextBottom; |
1711 | else if ( icontext == "TextOnly" ) | 1722 | else if ( icontext == "TextOnly" ) |
1712 | icon_text = TextOnly; | 1723 | icon_text = TextOnly; |
1713 | else | 1724 | else |
1714 | icon_text = IconOnly; | 1725 | icon_text = IconOnly; |
1715 | 1726 | ||
1716 | // check if the icon/text has changed | 1727 | // check if the icon/text has changed |
1717 | if (icon_text != d->m_iconText) { | 1728 | if (icon_text != d->m_iconText) { |
1718 | //kdDebug(220) << "KToolBar::applyAppearanceSettings setIconText " << icon_text << endl; | 1729 | //kdDebug(220) << "KToolBar::applyAppearanceSettings setIconText " << icon_text << endl; |
1719 | setIconText(icon_text, false); | 1730 | setIconText(icon_text, false); |
1720 | doUpdate = true; | 1731 | doUpdate = true; |
1721 | } | 1732 | } |
1722 | 1733 | ||
1723 | // ...and check if the icon size has changed | 1734 | // ...and check if the icon size has changed |
1724 | if (iconsize != d->m_iconSize) { | 1735 | if (iconsize != d->m_iconSize) { |
1725 | setIconSize(iconsize, false); | 1736 | setIconSize(iconsize, false); |
1726 | doUpdate = true; | 1737 | doUpdate = true; |
1727 | } | 1738 | } |
1728 | 1739 | ||
1729 | QMainWindow *mw = mainWindow(); | 1740 | Q3MainWindow *mw = mainWindow(); |
1730 | 1741 | ||
1731 | // ...and if we should highlight | 1742 | // ...and if we should highlight |
1732 | if ( highlight != d->m_highlight ) { | 1743 | if ( highlight != d->m_highlight ) { |
1733 | d->m_highlight = highlight; | 1744 | d->m_highlight = highlight; |
1734 | doUpdate = true; | 1745 | doUpdate = true; |
1735 | } | 1746 | } |
1736 | 1747 | ||
1737 | // ...and if we should move transparently | 1748 | // ...and if we should move transparently |
1738 | if ( mw && transparent != (!mw->opaqueMoving()) ) { | 1749 | if ( mw && transparent != (!mw->opaqueMoving()) ) { |
1739 | mw->setOpaqueMoving( !transparent ); | 1750 | mw->setOpaqueMoving( !transparent ); |
1740 | } | 1751 | } |
1741 | 1752 | ||
1742 | if (doUpdate) | 1753 | if (doUpdate) |
1743 | emit modechange(); // tell buttons what happened | 1754 | emit modechange(); // tell buttons what happened |
1744 | if (isVisible ()) | 1755 | if (isVisible ()) |
1745 | updateGeometry(); | 1756 | updateGeometry(); |
1746 | } | 1757 | } |
1747 | 1758 | ||
1748 | void KToolBar::applySettings(KConfig *config, const QString &_configGroup) | 1759 | void KToolBar::applySettings(KConfig *config, const QString &_configGroup) |
1749 | { | 1760 | { |
1750 | //kdDebug(220) << "KToolBar::applySettings group=" << _configGroup << endl; | 1761 | //kdDebug(220) << "KToolBar::applySettings group=" << _configGroup << endl; |
1751 | 1762 | ||
1752 | QString configGroup = _configGroup.isEmpty() ? settingsGroup() : _configGroup; | 1763 | QString configGroup = _configGroup.isEmpty() ? settingsGroup() : _configGroup; |
1753 | 1764 | ||
1754 | /* | 1765 | /* |
1755 | Let's explain this a bit more in details. | 1766 | Let's explain this a bit more in details. |
1756 | The order in which we apply settings is : | 1767 | The order in which we apply settings is : |
1757 | Global config / <appnamerc> user settings if no XMLGUI is used | 1768 | Global config / <appnamerc> user settings if no XMLGUI is used |
1758 | Global config / App-XML attributes / <appnamerc> user settings if XMLGUI is used | 1769 | Global config / App-XML attributes / <appnamerc> user settings if XMLGUI is used |
1759 | 1770 | ||
1760 | So in the first case, we simply read everything from KConfig as below, | 1771 | So in the first case, we simply read everything from KConfig as below, |
1761 | but in the second case we don't do anything here if there is no app-specific config, | 1772 | but in the second case we don't do anything here if there is no app-specific config, |
1762 | and the XMLGUI uses the static methods of this class to get the global defaults. | 1773 | and the XMLGUI uses the static methods of this class to get the global defaults. |
1763 | 1774 | ||
1764 | Global config doesn't include position (index, offset, newline and hidden/shown). | 1775 | Global config doesn't include position (index, offset, newline and hidden/shown). |
1765 | */ | 1776 | */ |
1766 | 1777 | ||
1767 | // First the appearance stuff - the one which has a global config | 1778 | // First the appearance stuff - the one which has a global config |
1768 | applyAppearanceSettings( config, _configGroup ); | 1779 | applyAppearanceSettings( config, _configGroup ); |
1769 | 1780 | ||
1770 | // ...and now the position stuff | 1781 | // ...and now the position stuff |
1771 | if ( config->hasGroup(configGroup) ) | 1782 | if ( config->hasGroup(configGroup) ) |
1772 | { | 1783 | { |
1773 | KConfigGroupSaver cgs(config, configGroup); | 1784 | KConfigGroupSaver cgs(config, configGroup); |
1774 | /*US | 1785 | /*US |
1775 | static const QString &attrPosition = KGlobal::staticQString("Position"); | 1786 | static const QString &attrPosition = KGlobal::staticQString("Position"); |
1776 | static const QString &attrIndex = KGlobal::staticQString("Index"); | 1787 | static const QString &attrIndex = KGlobal::staticQString("Index"); |
1777 | static const QString &attrOffset = KGlobal::staticQString("Offset"); | 1788 | static const QString &attrOffset = KGlobal::staticQString("Offset"); |
1778 | static const QString &attrNewLine = KGlobal::staticQString("NewLine"); | 1789 | static const QString &attrNewLine = KGlobal::staticQString("NewLine"); |
1779 | static const QString &attrHidden = KGlobal::staticQString("Hidden"); | 1790 | static const QString &attrHidden = KGlobal::staticQString("Hidden"); |
1780 | 1791 | ||
1781 | QString position = config->readEntry(attrPosition, d->PositionDefault); | 1792 | QString position = config->readEntry(attrPosition, d->PositionDefault); |
1782 | int index = config->readNumEntry(attrIndex, d->IndexDefault); | 1793 | int index = config->readNumEntry(attrIndex, d->IndexDefault); |
1783 | int offset = config->readNumEntry(attrOffset, d->OffsetDefault); | 1794 | int offset = config->readNumEntry(attrOffset, d->OffsetDefault); |
1784 | bool newLine = config->readBoolEntry(attrNewLine, d->NewLineDefault); | 1795 | bool newLine = config->readBoolEntry(attrNewLine, d->NewLineDefault); |
1785 | bool hidden = config->readBoolEntry(attrHidden, d->HiddenDefault); | 1796 | bool hidden = config->readBoolEntry(attrHidden, d->HiddenDefault); |
1786 | */ | 1797 | */ |
1787 | 1798 | ||
1788 | QString position = config->readEntry("Position", d->PositionDefault); | 1799 | QString position = config->readEntry("Position", d->PositionDefault); |
1789 | int index = config->readNumEntry("Index", d->IndexDefault); | 1800 | int index = config->readNumEntry("Index", d->IndexDefault); |
1790 | int offset = config->readNumEntry("Offset", d->OffsetDefault); | 1801 | int offset = config->readNumEntry("Offset", d->OffsetDefault); |
1791 | bool newLine = config->readBoolEntry("NewLine", d->NewLineDefault); | 1802 | bool newLine = config->readBoolEntry("NewLine", d->NewLineDefault); |
1792 | bool hidden = config->readBoolEntry("Hidden", d->HiddenDefault); | 1803 | bool hidden = config->readBoolEntry("Hidden", d->HiddenDefault); |
1793 | 1804 | ||
1794 | /*US Dock pos(DockTop); | 1805 | /*US Dock pos(DockTop); |
1795 | if ( position == "Top" ) | 1806 | if ( position == "Top" ) |
1796 | pos = DockTop; | 1807 | pos = DockTop; |
1797 | else if ( position == "Bottom" ) | 1808 | else if ( position == "Bottom" ) |
1798 | pos = DockBottom; | 1809 | pos = DockBottom; |
1799 | else if ( position == "Left" ) | 1810 | else if ( position == "Left" ) |
1800 | pos = DockLeft; | 1811 | pos = DockLeft; |
1801 | else if ( position == "Right" ) | 1812 | else if ( position == "Right" ) |
1802 | pos = DockRight; | 1813 | pos = DockRight; |
1803 | else if ( position == "Floating" ) | 1814 | else if ( position == "Floating" ) |
1804 | pos = DockTornOff; | 1815 | pos = DockTornOff; |
1805 | else if ( position == "Flat" ) | 1816 | else if ( position == "Flat" ) |
1806 | pos = DockMinimized; | 1817 | pos = DockMinimized; |
1807 | */ | 1818 | */ |
1808 | QMainWindow::ToolBarDock pos(QMainWindow::Top); | 1819 | Qt::ToolBarDock pos(Qt::DockTop); |
1809 | if ( position == "Top" ) | 1820 | if ( position == "Top" ) |
1810 | pos = QMainWindow::Top; | 1821 | pos = Qt::Top; |
1811 | else if ( position == "Bottom" ) | 1822 | else if ( position == "Bottom" ) |
1812 | pos = QMainWindow::Bottom; | 1823 | pos = Qt::Bottom; |
1813 | else if ( position == "Left" ) | 1824 | else if ( position == "Left" ) |
1814 | pos = QMainWindow::Left; | 1825 | pos = Qt::Left; |
1815 | else if ( position == "Right" ) | 1826 | else if ( position == "Right" ) |
1816 | pos = QMainWindow::Right; | 1827 | pos = Qt::Right; |
1817 | else if ( position == "Floating" ) | 1828 | else if ( position == "Floating" ) |
1818 | pos = QMainWindow::TornOff; | 1829 | pos = Qt::TornOff; |
1819 | else if ( position == "Flat" ) | 1830 | else if ( position == "Flat" ) |
1820 | pos = QMainWindow::Minimized; | 1831 | pos = Qt::Minimized; |
1821 | 1832 | ||
1822 | //kdDebug(220) << "KToolBar::applySettings hidden=" << hidden << endl; | 1833 | //kdDebug(220) << "KToolBar::applySettings hidden=" << hidden << endl; |
1823 | if (hidden) | 1834 | if (hidden) |
1824 | hide(); | 1835 | hide(); |
1825 | else | 1836 | else |
1826 | show(); | 1837 | show(); |
1827 | 1838 | ||
1828 | if ( mainWindow() ) | 1839 | if ( mainWindow() ) |
1829 | { | 1840 | { |
1830 | QMainWindow *mw = mainWindow(); | 1841 | Q3MainWindow *mw = mainWindow(); |
1831 | 1842 | ||
1832 | //kdDebug(220) << "KToolBar::applySettings updating ToolbarInfo" << endl; | 1843 | //kdDebug(220) << "KToolBar::applySettings updating ToolbarInfo" << endl; |
1833 | d->toolBarInfo = KToolBarPrivate::ToolBarInfo( pos, index, newLine, offset ); | 1844 | d->toolBarInfo = KToolBarPrivate::ToolBarInfo( pos, index, newLine, offset ); |
1834 | 1845 | ||
1835 | // moveDockWindow calls QDockArea which does a reparent() on us with | 1846 | // moveDockWindow calls QDockArea which does a reparent() on us with |
1836 | // showIt = true, so we loose our visibility status | 1847 | // showIt = true, so we loose our visibility status |
1837 | bool doHide = isHidden(); | 1848 | bool doHide = isHidden(); |
1838 | 1849 | ||
1839 | //US mw->moveDockWindow( this, pos, newLine, index, offset ); | 1850 | //US mw->moveDockWindow( this, pos, newLine, index, offset ); |
1840 | mw->moveToolBar( this, pos, newLine, index, offset ); | 1851 | mw->moveToolBar( this, pos, newLine, index, offset ); |
1841 | 1852 | ||
1842 | //kdDebug(220) << "KToolBar::applySettings " << name() << " moveDockWindow with pos=" << pos << " newLine=" << newLine << " idx=" << index << " offs=" << offset << endl; | 1853 | //kdDebug(220) << "KToolBar::applySettings " << name() << " moveDockWindow with pos=" << pos << " newLine=" << newLine << " idx=" << index << " offs=" << offset << endl; |
1843 | if ( doHide ) | 1854 | if ( doHide ) |
1844 | hide(); | 1855 | hide(); |
1845 | } | 1856 | } |
1846 | if (isVisible ()) | 1857 | if (isVisible ()) |
1847 | updateGeometry(); | 1858 | updateGeometry(); |
1848 | } | 1859 | } |
1849 | } | 1860 | } |
1850 | 1861 | ||
1851 | bool KToolBar::event( QEvent *e ) | 1862 | bool KToolBar::event( QEvent *e ) |
1852 | { | 1863 | { |
1853 | if ( (e->type() == QEvent::LayoutHint) && isUpdatesEnabled() ) | 1864 | if ( (e->type() == QEvent::LayoutHint) && isUpdatesEnabled() ) |
1854 | d->repaintTimer.start( 100, true ); | 1865 | d->repaintTimer.start( 100, true ); |
1855 | 1866 | ||
1856 | if (e->type() == QEvent::ChildInserted ) | 1867 | if (e->type() == QEvent::ChildInserted ) |
1857 | { | 1868 | { |
1858 | // By pass QToolBar::event, | 1869 | // By pass QToolBar::event, |
1859 | // it will show() the inserted child and we don't want to | 1870 | // it will show() the inserted child and we don't want to |
1860 | // do that until we have rebuild the layout. | 1871 | // do that until we have rebuild the layout. |
1861 | childEvent((QChildEvent *)e); | 1872 | childEvent((QChildEvent *)e); |
1862 | return true; | 1873 | return true; |
1863 | } | 1874 | } |
1864 | 1875 | ||
1865 | return QToolBar::event( e ); | 1876 | return Q3ToolBar::event( e ); |
1866 | } | 1877 | } |
1867 | 1878 | ||
1868 | void KToolBar::slotRepaint() | 1879 | void KToolBar::slotRepaint() |
1869 | { | 1880 | { |
1870 | setUpdatesEnabled( FALSE ); | 1881 | setUpdatesEnabled( FALSE ); |
1871 | // Send a resizeEvent to update the "toolbar extension arrow" | 1882 | // Send a resizeEvent to update the "toolbar extension arrow" |
1872 | // (The button you get when your toolbar-items don't fit in | 1883 | // (The button you get when your toolbar-items don't fit in |
1873 | // the available space) | 1884 | // the available space) |
1874 | QResizeEvent ev(size(), size()); | 1885 | QResizeEvent ev(size(), size()); |
1875 | resizeEvent(&ev); | 1886 | resizeEvent(&ev); |
1876 | //#ifdef DESKTOP_VERSION | 1887 | //#ifdef DESKTOP_VERSION |
1877 | QApplication::sendPostedEvents( this, QEvent::LayoutHint ); | 1888 | QApplication::sendPostedEvents( this, QEvent::LayoutHint ); |
1878 | //#endif //DESKTOP_VERSION | 1889 | //#endif //DESKTOP_VERSION |
1879 | setUpdatesEnabled( TRUE ); | 1890 | setUpdatesEnabled( TRUE ); |
1880 | repaint( TRUE ); | 1891 | repaint( TRUE ); |
1881 | } | 1892 | } |
1882 | 1893 | ||
1883 | void KToolBar::toolBarPosChanged( QToolBar *tb ) | 1894 | void KToolBar::toolBarPosChanged( Q3ToolBar *tb ) |
1884 | { | 1895 | { |
1885 | if ( tb != this ) | 1896 | if ( tb != this ) |
1886 | return; | 1897 | return; |
1887 | //US if ( d->oldPos == DockMinimized ) | 1898 | //US if ( d->oldPos == DockMinimized ) |
1888 | if ( d->oldPos == QMainWindow::Minimized ) | 1899 | if ( d->oldPos == Qt::Minimized ) |
1889 | rebuildLayout(); | 1900 | rebuildLayout(); |
1890 | d->oldPos = (QMainWindow::ToolBarDock)barPos(); | 1901 | d->oldPos = (Qt::ToolBarDock)barPos(); |
1891 | /*US | 1902 | /*US |
1892 | if ( mainWindow() && mainWindow()->inherits( "KMainWindow" ) ) | 1903 | if ( mainWindow() && mainWindow()->inherits( "KMainWindow" ) ) |
1893 | static_cast<KMainWindow *>(mainWindow())->setSettingsDirty(); | 1904 | static_cast<KMainWindow *>(mainWindow())->setSettingsDirty(); |
1894 | */ | 1905 | */ |
1895 | } | 1906 | } |
1896 | 1907 | ||
1897 | /*US | 1908 | /*US |
1898 | void KToolBar::loadState( const QDomElement &element ) | 1909 | void KToolBar::loadState( const QDomElement &element ) |
1899 | { | 1910 | { |
1900 | //kdDebug(220) << "KToolBar::loadState " << this << endl; | 1911 | //kdDebug(220) << "KToolBar::loadState " << this << endl; |
1901 | if ( !mainWindow() ) | 1912 | if ( !mainWindow() ) |
1902 | return; | 1913 | return; |
1903 | 1914 | ||
1904 | { | 1915 | { |
1905 | QCString text = element.namedItem( "text" ).toElement().text().utf8(); | 1916 | QCString text = element.namedItem( "text" ).toElement().text().utf8(); |
1906 | if ( text.isEmpty() ) | 1917 | if ( text.isEmpty() ) |
1907 | text = element.namedItem( "Text" ).toElement().text().utf8(); | 1918 | text = element.namedItem( "Text" ).toElement().text().utf8(); |
1908 | if ( !text.isEmpty() ) | 1919 | if ( !text.isEmpty() ) |
1909 | setText( i18n( text ) ); | 1920 | setText( i18n( text ) ); |
1910 | } | 1921 | } |
1911 | 1922 | ||
1912 | { | 1923 | { |
1913 | QCString attrFullWidth = element.attribute( "fullWidth" ).lower().latin1(); | 1924 | QCString attrFullWidth = element.attribute( "fullWidth" ).lower().latin1(); |
1914 | if ( !attrFullWidth.isEmpty() ) | 1925 | if ( !attrFullWidth.isEmpty() ) |
1915 | setFullSize( attrFullWidth == "true" ); | 1926 | setFullSize( attrFullWidth == "true" ); |
1916 | } | 1927 | } |
1917 | 1928 | ||
1918 | Dock dock = DockTop; | 1929 | Dock dock = DockTop; |
1919 | { | 1930 | { |
1920 | QCString attrPosition = element.attribute( "position" ).lower().latin1(); | 1931 | QCString attrPosition = element.attribute( "position" ).lower().latin1(); |
1921 | //kdDebug(220) << "KToolBar::loadState attrPosition=" << attrPosition << endl; | 1932 | //kdDebug(220) << "KToolBar::loadState attrPosition=" << attrPosition << endl; |
1922 | if ( !attrPosition.isEmpty() ) { | 1933 | if ( !attrPosition.isEmpty() ) { |
1923 | if ( attrPosition == "top" ) | 1934 | if ( attrPosition == "top" ) |
1924 | dock = DockTop; | 1935 | dock = DockTop; |
1925 | else if ( attrPosition == "left" ) | 1936 | else if ( attrPosition == "left" ) |
1926 | dock = DockLeft; | 1937 | dock = DockLeft; |
1927 | else if ( attrPosition == "right" ) | 1938 | else if ( attrPosition == "right" ) |
1928 | dock = DockRight; | 1939 | dock = DockRight; |
1929 | else if ( attrPosition == "bottom" ) | 1940 | else if ( attrPosition == "bottom" ) |
1930 | dock = DockBottom; | 1941 | dock = DockBottom; |
1931 | else if ( attrPosition == "floating" ) | 1942 | else if ( attrPosition == "floating" ) |
1932 | dock = DockTornOff; | 1943 | dock = DockTornOff; |
1933 | else if ( attrPosition == "flat" ) | 1944 | else if ( attrPosition == "flat" ) |
1934 | dock = DockMinimized; | 1945 | dock = DockMinimized; |
1935 | } | 1946 | } |
1936 | } | 1947 | } |
1937 | 1948 | ||
1938 | { | 1949 | { |
1939 | QCString attrIconText = element.attribute( "iconText" ).lower().latin1(); | 1950 | QCString attrIconText = element.attribute( "iconText" ).lower().latin1(); |
1940 | if ( !attrIconText.isEmpty() ) { | 1951 | if ( !attrIconText.isEmpty() ) { |
1941 | //kdDebug(220) << "KToolBar::loadState attrIconText=" << attrIconText << endl; | 1952 | //kdDebug(220) << "KToolBar::loadState attrIconText=" << attrIconText << endl; |
1942 | if ( attrIconText == "icontextright" ) | 1953 | if ( attrIconText == "icontextright" ) |
1943 | setIconText( KToolBar::IconTextRight ); | 1954 | setIconText( KToolBar::IconTextRight ); |
1944 | else if ( attrIconText == "textonly" ) | 1955 | else if ( attrIconText == "textonly" ) |
1945 | setIconText( KToolBar::TextOnly ); | 1956 | setIconText( KToolBar::TextOnly ); |
1946 | else if ( attrIconText == "icontextbottom" ) | 1957 | else if ( attrIconText == "icontextbottom" ) |
1947 | setIconText( KToolBar::IconTextBottom ); | 1958 | setIconText( KToolBar::IconTextBottom ); |
1948 | else if ( attrIconText == "icononly" ) | 1959 | else if ( attrIconText == "icononly" ) |
1949 | setIconText( KToolBar::IconOnly ); | 1960 | setIconText( KToolBar::IconOnly ); |
1950 | } else | 1961 | } else |
1951 | // Use global setting | 1962 | // Use global setting |
1952 | setIconText( iconTextSetting() ); | 1963 | setIconText( iconTextSetting() ); |
1953 | } | 1964 | } |
1954 | 1965 | ||
1955 | { | 1966 | { |
1956 | QString attrIconSize = element.attribute( "iconSize" ).lower(); | 1967 | QString attrIconSize = element.attribute( "iconSize" ).lower(); |
1957 | if ( !attrIconSize.isEmpty() ) | 1968 | if ( !attrIconSize.isEmpty() ) |
1958 | d->IconSizeDefault = attrIconSize.toInt(); | 1969 | d->IconSizeDefault = attrIconSize.toInt(); |
1959 | setIconSize( d->IconSizeDefault ); | 1970 | setIconSize( d->IconSizeDefault ); |
1960 | } | 1971 | } |
1961 | 1972 | ||
1962 | { | 1973 | { |
1963 | QString attrIndex = element.attribute( "index" ).lower(); | 1974 | QString attrIndex = element.attribute( "index" ).lower(); |
1964 | if ( !attrIndex.isEmpty() ) | 1975 | if ( !attrIndex.isEmpty() ) |
1965 | d->IndexDefault = attrIndex.toInt(); | 1976 | d->IndexDefault = attrIndex.toInt(); |
1966 | } | 1977 | } |
1967 | 1978 | ||
1968 | { | 1979 | { |
1969 | QString attrOffset = element.attribute( "offset" ).lower(); | 1980 | QString attrOffset = element.attribute( "offset" ).lower(); |
1970 | if ( !attrOffset.isEmpty() ) | 1981 | if ( !attrOffset.isEmpty() ) |
1971 | d->OffsetDefault = attrOffset.toInt(); | 1982 | d->OffsetDefault = attrOffset.toInt(); |
1972 | } | 1983 | } |
1973 | 1984 | ||
1974 | { | 1985 | { |
1975 | QString attrNewLine = element.attribute( "newline" ).lower(); | 1986 | QString attrNewLine = element.attribute( "newline" ).lower(); |
1976 | if ( !attrNewLine.isEmpty() ) | 1987 | if ( !attrNewLine.isEmpty() ) |
1977 | d->NewLineDefault = attrNewLine == "true"; | 1988 | d->NewLineDefault = attrNewLine == "true"; |
1978 | } | 1989 | } |
1979 | 1990 | ||
1980 | { | 1991 | { |
1981 | QString attrHidden = element.attribute( "hidden" ).lower(); | 1992 | QString attrHidden = element.attribute( "hidden" ).lower(); |
1982 | if ( !attrHidden.isEmpty() ) | 1993 | if ( !attrHidden.isEmpty() ) |
1983 | d->HiddenDefault = attrHidden == "true"; | 1994 | d->HiddenDefault = attrHidden == "true"; |
1984 | } | 1995 | } |
1985 | 1996 | ||
1986 | d->toolBarInfo = KToolBarPrivate::ToolBarInfo( dock, d->IndexDefault, d->NewLineDefault, d->OffsetDefault ); | 1997 | d->toolBarInfo = KToolBarPrivate::ToolBarInfo( dock, d->IndexDefault, d->NewLineDefault, d->OffsetDefault ); |
1987 | mainWindow()->addDockWindow( this, dock, d->NewLineDefault ); | 1998 | mainWindow()->addDockWindow( this, dock, d->NewLineDefault ); |
1988 | //US mainWindow()->moveDockWindow( this, dock, d->NewLineDefault, d->IndexDefault, d->OffsetDefault ); | 1999 | //US mainWindow()->moveDockWindow( this, dock, d->NewLineDefault, d->IndexDefault, d->OffsetDefault ); |
1989 | mainWindow()->moveToolBar( this, dock, d->NewLineDefault, d->IndexDefault, d->OffsetDefault ); | 2000 | mainWindow()->moveToolBar( this, dock, d->NewLineDefault, d->IndexDefault, d->OffsetDefault ); |
1990 | 2001 | ||
1991 | // Apply the highlight button setting | 2002 | // Apply the highlight button setting |
1992 | d->m_highlight = highlightSetting(); | 2003 | d->m_highlight = highlightSetting(); |
1993 | 2004 | ||
1994 | // Apply transparent-toolbar-moving setting (ok, this is global to the mainwindow, | 2005 | // Apply transparent-toolbar-moving setting (ok, this is global to the mainwindow, |
1995 | // but we do it only if there are toolbars...) | 2006 | // but we do it only if there are toolbars...) |
1996 | if ( transparentSetting() != !mainWindow()->opaqueMoving() ) | 2007 | if ( transparentSetting() != !mainWindow()->opaqueMoving() ) |
1997 | mainWindow()->setOpaqueMoving( !transparentSetting() ); | 2008 | mainWindow()->setOpaqueMoving( !transparentSetting() ); |
1998 | 2009 | ||
1999 | if ( d->HiddenDefault ) | 2010 | if ( d->HiddenDefault ) |
2000 | hide(); | 2011 | hide(); |
2001 | else | 2012 | else |
2002 | show(); | 2013 | show(); |
2003 | 2014 | ||
2004 | getAttributes( d->PositionDefault, d->IconTextDefault, d->IndexDefault ); | 2015 | getAttributes( d->PositionDefault, d->IconTextDefault, d->IndexDefault ); |
2005 | } | 2016 | } |
2006 | */ | 2017 | */ |
2007 | 2018 | ||
2008 | void KToolBar::getAttributes( QString &position, QString &icontext, int &index ) | 2019 | void KToolBar::getAttributes( QString &position, QString &icontext, int &index ) |
2009 | { | 2020 | { |
2010 | // get all of the stuff to save | 2021 | // get all of the stuff to save |
2011 | switch ( barPos() ) { | 2022 | switch ( barPos() ) { |
2012 | case KToolBar::Flat: | 2023 | case KToolBar::Flat: |
2013 | position = "Flat"; | 2024 | position = "Flat"; |
2014 | break; | 2025 | break; |
2015 | case KToolBar::Bottom: | 2026 | case KToolBar::Bottom: |
2016 | position = "Bottom"; | 2027 | position = "Bottom"; |
2017 | break; | 2028 | break; |
2018 | case KToolBar::Left: | 2029 | case KToolBar::Left: |
2019 | position = "Left"; | 2030 | position = "Left"; |
2020 | break; | 2031 | break; |
2021 | case KToolBar::Right: | 2032 | case KToolBar::Right: |
2022 | position = "Right"; | 2033 | position = "Right"; |
2023 | break; | 2034 | break; |
2024 | case KToolBar::Floating: | 2035 | case KToolBar::Floating: |
2025 | position = "Floating"; | 2036 | position = "Floating"; |
2026 | break; | 2037 | break; |
2027 | case KToolBar::Top: | 2038 | case KToolBar::Top: |
2028 | default: | 2039 | default: |
2029 | position = "Top"; | 2040 | position = "Top"; |
2030 | break; | 2041 | break; |
2031 | } | 2042 | } |
2032 | 2043 | ||
2033 | if ( mainWindow() ) { | 2044 | if ( mainWindow() ) { |
2034 | QMainWindow::ToolBarDock dock; | 2045 | Qt::ToolBarDock dock; |
2035 | bool newLine; | 2046 | bool newLine; |
2036 | int offset; | 2047 | int offset; |
2037 | mainWindow()->getLocation( this, dock, index, newLine, offset ); | 2048 | mainWindow()->getLocation( this, dock, index, newLine, offset ); |
2038 | } | 2049 | } |
2039 | 2050 | ||
2040 | switch (d->m_iconText) { | 2051 | switch (d->m_iconText) { |
2041 | case KToolBar::IconTextRight: | 2052 | case KToolBar::IconTextRight: |
2042 | icontext = "IconTextRight"; | 2053 | icontext = "IconTextRight"; |
2043 | break; | 2054 | break; |
2044 | case KToolBar::IconTextBottom: | 2055 | case KToolBar::IconTextBottom: |
2045 | icontext = "IconTextBottom"; | 2056 | icontext = "IconTextBottom"; |
2046 | break; | 2057 | break; |
2047 | case KToolBar::TextOnly: | 2058 | case KToolBar::TextOnly: |
2048 | icontext = "TextOnly"; | 2059 | icontext = "TextOnly"; |
2049 | break; | 2060 | break; |
2050 | case KToolBar::IconOnly: | 2061 | case KToolBar::IconOnly: |
2051 | default: | 2062 | default: |
2052 | icontext = "IconOnly"; | 2063 | icontext = "IconOnly"; |
2053 | break; | 2064 | break; |
2054 | } | 2065 | } |
2055 | } | 2066 | } |
2056 | /*US | 2067 | /*US |
2057 | void KToolBar::saveState( QDomElement ¤t ) | 2068 | void KToolBar::saveState( QDomElement ¤t ) |
2058 | { | 2069 | { |
2059 | QString position, icontext; | 2070 | QString position, icontext; |
2060 | int index = -1; | 2071 | int index = -1; |
2061 | getAttributes( position, icontext, index ); | 2072 | getAttributes( position, icontext, index ); |
2062 | 2073 | ||
2063 | current.setAttribute( "noMerge", "1" ); | 2074 | current.setAttribute( "noMerge", "1" ); |
2064 | current.setAttribute( "position", position ); | 2075 | current.setAttribute( "position", position ); |
2065 | current.setAttribute( "iconText", icontext ); | 2076 | current.setAttribute( "iconText", icontext ); |
2066 | current.setAttribute( "index", index ); | 2077 | current.setAttribute( "index", index ); |
2067 | current.setAttribute( "offset", offset() ); | 2078 | current.setAttribute( "offset", offset() ); |
2068 | current.setAttribute( "newline", newLine() ); | 2079 | current.setAttribute( "newline", newLine() ); |
2069 | if ( isHidden() ) | 2080 | if ( isHidden() ) |
2070 | current.setAttribute( "hidden", "true" ); | 2081 | current.setAttribute( "hidden", "true" ); |
2071 | d->modified = true; | 2082 | d->modified = true; |
2072 | } | 2083 | } |
2073 | */ | 2084 | */ |
2074 | 2085 | ||
2075 | void KToolBar::positionYourself( bool force ) | 2086 | void KToolBar::positionYourself( bool force ) |
2076 | { | 2087 | { |
2077 | if (force) | 2088 | if (force) |
2078 | d->positioned = false; | 2089 | d->positioned = false; |
2079 | 2090 | ||
2080 | if ( d->positioned || !mainWindow() ) | 2091 | if ( d->positioned || !mainWindow() ) |
2081 | { | 2092 | { |
2082 | //kdDebug(220) << "KToolBar::positionYourself d->positioned=true ALREADY DONE" << endl; | 2093 | //kdDebug(220) << "KToolBar::positionYourself d->positioned=true ALREADY DONE" << endl; |
2083 | return; | 2094 | return; |
2084 | } | 2095 | } |
2085 | // we can't test for ForceHide after moveDockWindow because QDockArea | 2096 | // we can't test for ForceHide after moveDockWindow because QDockArea |
2086 | // does a reparent() with showIt == true | 2097 | // does a reparent() with showIt == true |
2087 | bool doHide = isHidden(); | 2098 | bool doHide = isHidden(); |
2088 | //kdDebug(220) << "positionYourself " << name() << " dock=" << d->toolBarInfo.dock << " newLine=" << d->toolBarInfo.newline << " offset=" << d->toolBarInfo.offset << endl; | 2099 | //kdDebug(220) << "positionYourself " << name() << " dock=" << d->toolBarInfo.dock << " newLine=" << d->toolBarInfo.newline << " offset=" << d->toolBarInfo.offset << endl; |
2089 | /*US mainWindow()->moveDockWindow( this, d->toolBarInfo.dock, | 2100 | /*US mainWindow()->moveDockWindow( this, d->toolBarInfo.dock, |
2090 | d->toolBarInfo.newline, | 2101 | d->toolBarInfo.newline, |
2091 | d->toolBarInfo.index, | 2102 | d->toolBarInfo.index, |
2092 | d->toolBarInfo.offset ); | 2103 | d->toolBarInfo.offset ); |
2093 | */ | 2104 | */ |
2094 | mainWindow()->moveToolBar( this, d->toolBarInfo.dock, d->NewLineDefault, d->IndexDefault, d->OffsetDefault ); | 2105 | mainWindow()->moveToolBar( this, d->toolBarInfo.dock, d->NewLineDefault, d->IndexDefault, d->OffsetDefault ); |
2095 | 2106 | ||
2096 | if ( doHide ) | 2107 | if ( doHide ) |
2097 | hide(); | 2108 | hide(); |
2098 | // This method can only have an effect once - unless force is set | 2109 | // This method can only have an effect once - unless force is set |
2099 | d->positioned = TRUE; | 2110 | d->positioned = TRUE; |
2100 | } | 2111 | } |
2101 | 2112 | ||
2102 | //US KPopupMenu *KToolBar::contextMenu() | 2113 | //US KPopupMenu *KToolBar::contextMenu() |
2103 | QPopupMenu *KToolBar::contextMenu() | 2114 | Q3PopupMenu *KToolBar::contextMenu() |
2104 | { | 2115 | { |
2105 | if ( context ) | 2116 | if ( context ) |
2106 | return context; | 2117 | return context; |
2107 | 2118 | ||
2108 | // Construct our context popup menu. Name it qt_dockwidget_internal so it | 2119 | // Construct our context popup menu. Name it qt_dockwidget_internal so it |
2109 | // won't be deleted by QToolBar::clear(). | 2120 | // won't be deleted by QToolBar::clear(). |
2110 | //US context = new KPopupMenu( this, "qt_dockwidget_internal" ); | 2121 | //US context = new KPopupMenu( this, "qt_dockwidget_internal" ); |
2111 | context = new QPopupMenu( this, "qt_dockwidget_internal" ); | 2122 | context = new Q3PopupMenu( this, "qt_dockwidget_internal" ); |
2112 | //US context->insertTitle(i18n("Toolbar Menu")); | 2123 | //US context->insertTitle(i18n("Toolbar Menu")); |
2113 | 2124 | ||
2114 | //US KPopupMenu *orient = new KPopupMenu( context, "orient" ); | 2125 | //US KPopupMenu *orient = new KPopupMenu( context, "orient" ); |
2115 | QPopupMenu *orient = new QPopupMenu( context, "orient" ); | 2126 | Q3PopupMenu *orient = new Q3PopupMenu( context, "orient" ); |
2116 | orient->insertItem( i18n("toolbar position string","Top"), CONTEXT_TOP ); | 2127 | orient->insertItem( i18n("toolbar position string","Top"), CONTEXT_TOP ); |
2117 | orient->insertItem( i18n("toolbar position string","Left"), CONTEXT_LEFT ); | 2128 | orient->insertItem( i18n("toolbar position string","Left"), CONTEXT_LEFT ); |
2118 | orient->insertItem( i18n("toolbar position string","Right"), CONTEXT_RIGHT ); | 2129 | orient->insertItem( i18n("toolbar position string","Right"), CONTEXT_RIGHT ); |
2119 | orient->insertItem( i18n("toolbar position string","Bottom"), CONTEXT_BOTTOM ); | 2130 | orient->insertItem( i18n("toolbar position string","Bottom"), CONTEXT_BOTTOM ); |
2120 | orient->insertSeparator(-1); | 2131 | orient->insertSeparator(-1); |
2121 | //orient->insertItem( i18n("toolbar position string","Floating"), CONTEXT_FLOAT ); | 2132 | //orient->insertItem( i18n("toolbar position string","Floating"), CONTEXT_FLOAT ); |
2122 | orient->insertItem( i18n("min toolbar", "Flat"), CONTEXT_FLAT ); | 2133 | orient->insertItem( i18n("min toolbar", "Flat"), CONTEXT_FLAT ); |
2123 | 2134 | ||
2124 | //US KPopupMenu *mode = new KPopupMenu( context, "mode" ); | 2135 | //US KPopupMenu *mode = new KPopupMenu( context, "mode" ); |
2125 | QPopupMenu *mode = new QPopupMenu( context, "mode" ); | 2136 | Q3PopupMenu *mode = new Q3PopupMenu( context, "mode" ); |
2126 | mode->insertItem( i18n("Icons Only"), CONTEXT_ICONS ); | 2137 | mode->insertItem( i18n("Icons Only"), CONTEXT_ICONS ); |
2127 | mode->insertItem( i18n("Text Only"), CONTEXT_TEXT ); | 2138 | mode->insertItem( i18n("Text Only"), CONTEXT_TEXT ); |
2128 | mode->insertItem( i18n("Text Alongside Icons"), CONTEXT_TEXTRIGHT ); | 2139 | mode->insertItem( i18n("Text Alongside Icons"), CONTEXT_TEXTRIGHT ); |
2129 | mode->insertItem( i18n("Text Under Icons"), CONTEXT_TEXTUNDER ); | 2140 | mode->insertItem( i18n("Text Under Icons"), CONTEXT_TEXTUNDER ); |
2130 | 2141 | ||
2131 | //US KPopupMenu *size = new KPopupMenu( context, "size" ); | 2142 | //US KPopupMenu *size = new KPopupMenu( context, "size" ); |
2132 | QPopupMenu *size = new QPopupMenu( context, "size" ); | 2143 | Q3PopupMenu *size = new Q3PopupMenu( context, "size" ); |
2133 | size->insertItem( i18n("Default"), CONTEXT_ICONSIZES ); | 2144 | size->insertItem( i18n("Default"), CONTEXT_ICONSIZES ); |
2134 | // Query the current theme for available sizes | 2145 | // Query the current theme for available sizes |
2135 | QValueList<int> avSizes; | 2146 | Q3ValueList<int> avSizes; |
2136 | /*US | 2147 | /*US |
2137 | KIconTheme *theme = KGlobal::instance()->iconLoader()->theme(); | 2148 | KIconTheme *theme = KGlobal::instance()->iconLoader()->theme(); |
2138 | if (!::qstrcmp(QObject::name(), "mainToolBar")) | 2149 | if (!::qstrcmp(QObject::name(), "mainToolBar")) |
2139 | avSizes = theme->querySizes( KIcon::MainToolbar); | 2150 | avSizes = theme->querySizes( KIcon::MainToolbar); |
2140 | else | 2151 | else |
2141 | avSizes = theme->querySizes( KIcon::Toolbar); | 2152 | avSizes = theme->querySizes( KIcon::Toolbar); |
2142 | */ | 2153 | */ |
2143 | avSizes << 16; | 2154 | avSizes << 16; |
2144 | avSizes << 32; | 2155 | avSizes << 32; |
2145 | 2156 | ||
2146 | d->iconSizes = avSizes; | 2157 | d->iconSizes = avSizes; |
2147 | 2158 | ||
2148 | QValueList<int>::Iterator it; | 2159 | Q3ValueList<int>::Iterator it; |
2149 | for (it=avSizes.begin(); it!=avSizes.end(); it++) { | 2160 | for (it=avSizes.begin(); it!=avSizes.end(); it++) { |
2150 | QString text; | 2161 | QString text; |
2151 | if ( *it < 19 ) | 2162 | if ( *it < 19 ) |
2152 | text = i18n("Small (%1x%2)").arg(*it).arg(*it); | 2163 | text = i18n("Small (%1x%2)").arg(*it).arg(*it); |
2153 | else if (*it < 25) | 2164 | else if (*it < 25) |
2154 | text = i18n("Medium (%1x%2)").arg(*it).arg(*it); | 2165 | text = i18n("Medium (%1x%2)").arg(*it).arg(*it); |
2155 | else | 2166 | else |
2156 | text = i18n("Large (%1x%2)").arg(*it).arg(*it); | 2167 | text = i18n("Large (%1x%2)").arg(*it).arg(*it); |
2157 | //we use the size as an id, with an offset | 2168 | //we use the size as an id, with an offset |
2158 | size->insertItem( text, CONTEXT_ICONSIZES + *it ); | 2169 | size->insertItem( text, CONTEXT_ICONSIZES + *it ); |
2159 | } | 2170 | } |
2160 | 2171 | ||
2161 | context->insertItem( i18n("Orientation"), orient ); | 2172 | context->insertItem( i18n("Orientation"), orient ); |
2162 | orient->setItemChecked(CONTEXT_TOP, true); | 2173 | orient->setItemChecked(CONTEXT_TOP, true); |
2163 | context->insertItem( i18n("Text Position"), mode ); | 2174 | context->insertItem( i18n("Text Position"), mode ); |
2164 | context->setItemChecked(CONTEXT_ICONS, true); | 2175 | context->setItemChecked(CONTEXT_ICONS, true); |
2165 | context->insertItem( i18n("Icon Size"), size ); | 2176 | context->insertItem( i18n("Icon Size"), size ); |
2166 | 2177 | ||
2167 | /*US | 2178 | /*US |
2168 | if (mainWindow()->inherits("KMainWindow")) | 2179 | if (mainWindow()->inherits("KMainWindow")) |
2169 | { | 2180 | { |
2170 | if ( (static_cast<KMainWindow*>(mainWindow())->toolBarMenuAction()) && | 2181 | if ( (static_cast<KMainWindow*>(mainWindow())->toolBarMenuAction()) && |
2171 | (static_cast<KMainWindow*>(mainWindow())->hasMenuBar()) ) | 2182 | (static_cast<KMainWindow*>(mainWindow())->hasMenuBar()) ) |
2172 | 2183 | ||
2173 | (static_cast<KMainWindow*>(mainWindow()))->toolBarMenuAction()->plug(context); | 2184 | (static_cast<KMainWindow*>(mainWindow()))->toolBarMenuAction()->plug(context); |
2174 | } | 2185 | } |
2175 | */ | 2186 | */ |
2176 | 2187 | ||
2177 | connect( context, SIGNAL( aboutToShow() ), this, SLOT( slotContextAboutToShow() ) ); | 2188 | connect( context, SIGNAL( aboutToShow() ), this, SLOT( slotContextAboutToShow() ) ); |
2178 | return context; | 2189 | return context; |
2179 | } | 2190 | } |
2180 | 2191 | ||
2181 | void KToolBar::slotContextAboutToShow() | 2192 | void KToolBar::slotContextAboutToShow() |
2182 | { | 2193 | { |
2183 | if (!d->m_configurePlugged) | 2194 | if (!d->m_configurePlugged) |
2184 | { | 2195 | { |
2185 | // try to find "configure toolbars" action | 2196 | // try to find "configure toolbars" action |
2186 | 2197 | ||
2187 | KXMLGUIClient *xmlGuiClient = d->m_xmlguiClient; | 2198 | KXMLGUIClient *xmlGuiClient = d->m_xmlguiClient; |
2188 | if ( !xmlGuiClient && mainWindow() && mainWindow()->inherits( "KMainWindow" ) ) | 2199 | if ( !xmlGuiClient && mainWindow() && mainWindow()->inherits( "KMainWindow" ) ) |
2189 | xmlGuiClient = (KXMLGUIClient *)mainWindow(); | 2200 | xmlGuiClient = (KXMLGUIClient *)mainWindow(); |
2190 | if ( xmlGuiClient ) | 2201 | if ( xmlGuiClient ) |
2191 | { | 2202 | { |
2192 | KAction *configureAction = xmlGuiClient->actionCollection()->action(KStdAction::stdName(KStdAction::ConfigureToolbars)); | 2203 | KAction *configureAction = xmlGuiClient->actionCollection()->action(KStdAction::stdName(KStdAction::ConfigureToolbars)); |
2193 | if ( configureAction ) | 2204 | if ( configureAction ) |
2194 | { | 2205 | { |
2195 | configureAction->plug(context); | 2206 | configureAction->plug(context); |
2196 | d->m_configurePlugged = true; | 2207 | d->m_configurePlugged = true; |
2197 | } | 2208 | } |
2198 | } | 2209 | } |
2199 | } | 2210 | } |
2200 | 2211 | ||
2201 | for(int i = CONTEXT_ICONS; i <= CONTEXT_TEXTUNDER; ++i) | 2212 | for(int i = CONTEXT_ICONS; i <= CONTEXT_TEXTUNDER; ++i) |
2202 | context->setItemChecked(i, false); | 2213 | context->setItemChecked(i, false); |
2203 | 2214 | ||
2204 | switch( d->m_iconText ) | 2215 | switch( d->m_iconText ) |
2205 | { | 2216 | { |
2206 | case IconOnly: | 2217 | case IconOnly: |
2207 | default: | 2218 | default: |
2208 | context->setItemChecked(CONTEXT_ICONS, true); | 2219 | context->setItemChecked(CONTEXT_ICONS, true); |
2209 | break; | 2220 | break; |
2210 | case IconTextRight: | 2221 | case IconTextRight: |
2211 | context->setItemChecked(CONTEXT_TEXTRIGHT, true); | 2222 | context->setItemChecked(CONTEXT_TEXTRIGHT, true); |
2212 | break; | 2223 | break; |
2213 | case TextOnly: | 2224 | case TextOnly: |
2214 | context->setItemChecked(CONTEXT_TEXT, true); | 2225 | context->setItemChecked(CONTEXT_TEXT, true); |
2215 | break; | 2226 | break; |
2216 | case IconTextBottom: | 2227 | case IconTextBottom: |
2217 | context->setItemChecked(CONTEXT_TEXTUNDER, true); | 2228 | context->setItemChecked(CONTEXT_TEXTUNDER, true); |
2218 | break; | 2229 | break; |
2219 | } | 2230 | } |
2220 | 2231 | ||
2221 | QValueList<int>::ConstIterator iIt = d->iconSizes.begin(); | 2232 | Q3ValueList<int>::ConstIterator iIt = d->iconSizes.begin(); |
2222 | QValueList<int>::ConstIterator iEnd = d->iconSizes.end(); | 2233 | Q3ValueList<int>::ConstIterator iEnd = d->iconSizes.end(); |
2223 | for (; iIt != iEnd; ++iIt ) | 2234 | for (; iIt != iEnd; ++iIt ) |
2224 | context->setItemChecked( CONTEXT_ICONSIZES + *iIt, false ); | 2235 | context->setItemChecked( CONTEXT_ICONSIZES + *iIt, false ); |
2225 | 2236 | ||
2226 | context->setItemChecked( CONTEXT_ICONSIZES, false ); | 2237 | context->setItemChecked( CONTEXT_ICONSIZES, false ); |
2227 | 2238 | ||
2228 | context->setItemChecked( CONTEXT_ICONSIZES + d->m_iconSize, true ); | 2239 | context->setItemChecked( CONTEXT_ICONSIZES + d->m_iconSize, true ); |
2229 | 2240 | ||
2230 | for ( int i = CONTEXT_TOP; i <= CONTEXT_FLAT; ++i ) | 2241 | for ( int i = CONTEXT_TOP; i <= CONTEXT_FLAT; ++i ) |
2231 | context->setItemChecked( i, false ); | 2242 | context->setItemChecked( i, false ); |
2232 | 2243 | ||
2233 | switch ( barPos() ) | 2244 | switch ( barPos() ) |
2234 | { | 2245 | { |
2235 | case KToolBar::Flat: | 2246 | case KToolBar::Flat: |
2236 | context->setItemChecked( CONTEXT_FLAT, true ); | 2247 | context->setItemChecked( CONTEXT_FLAT, true ); |
2237 | break; | 2248 | break; |
2238 | case KToolBar::Bottom: | 2249 | case KToolBar::Bottom: |
2239 | context->setItemChecked( CONTEXT_BOTTOM, true ); | 2250 | context->setItemChecked( CONTEXT_BOTTOM, true ); |
2240 | break; | 2251 | break; |
2241 | case KToolBar::Left: | 2252 | case KToolBar::Left: |
2242 | context->setItemChecked( CONTEXT_LEFT, true ); | 2253 | context->setItemChecked( CONTEXT_LEFT, true ); |
2243 | break; | 2254 | break; |
2244 | case KToolBar::Right: | 2255 | case KToolBar::Right: |
2245 | context->setItemChecked( CONTEXT_RIGHT, true ); | 2256 | context->setItemChecked( CONTEXT_RIGHT, true ); |
2246 | break; | 2257 | break; |
2247 | case KToolBar::Floating: | 2258 | case KToolBar::Floating: |
2248 | context->setItemChecked( CONTEXT_FLOAT, true ); | 2259 | context->setItemChecked( CONTEXT_FLOAT, true ); |
2249 | break; | 2260 | break; |
2250 | case KToolBar::Top: | 2261 | case KToolBar::Top: |
2251 | context->setItemChecked( CONTEXT_TOP, true ); | 2262 | context->setItemChecked( CONTEXT_TOP, true ); |
2252 | break; | 2263 | break; |
2253 | default: break; | 2264 | default: break; |
2254 | } | 2265 | } |
2255 | } | 2266 | } |
2256 | 2267 | ||
2257 | void KToolBar::widgetDestroyed() | 2268 | void KToolBar::widgetDestroyed() |
2258 | { | 2269 | { |
2259 | removeWidgetInternal( (QWidget*)sender() ); | 2270 | removeWidgetInternal( (QWidget*)sender() ); |
2260 | } | 2271 | } |
2261 | 2272 | ||
2262 | void KToolBar::removeWidgetInternal( QWidget * w ) | 2273 | void KToolBar::removeWidgetInternal( QWidget * w ) |
2263 | { | 2274 | { |
2264 | if ( inshutdownprocess ) | 2275 | if ( inshutdownprocess ) |
2265 | return; | 2276 | return; |
2266 | widgets.removeRef( w ); | 2277 | widgets.removeRef( w ); |
2267 | QMap< QWidget*, int >::Iterator it = widget2id.find( w ); | 2278 | QMap< QWidget*, int >::Iterator it = widget2id.find( w ); |
2268 | if ( it == widget2id.end() ) | 2279 | if ( it == widget2id.end() ) |
2269 | return; | 2280 | return; |
2270 | id2widget.remove( *it ); | 2281 | id2widget.remove( *it ); |
2271 | widget2id.remove( it ); | 2282 | widget2id.remove( it ); |
2272 | } | 2283 | } |
2273 | 2284 | ||
2274 | void KToolBar::virtual_hook( int, void* ) | 2285 | void KToolBar::virtual_hook( int, void* ) |
2275 | { /*BASE::virtual_hook( id, data );*/ } | 2286 | { /*BASE::virtual_hook( id, data );*/ } |
2276 | 2287 | ||
2277 | //US #include "ktoolbar.moc" | 2288 | //US #include "ktoolbar.moc" |
2278 | 2289 | ||