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