summaryrefslogtreecommitdiffabout
path: root/microkde
authorzautrix <zautrix>2004-07-05 08:15:56 (UTC)
committer zautrix <zautrix>2004-07-05 08:15:56 (UTC)
commit9f0d4ee43ce6f8c61abbd546376ef4f262261a1e (patch) (unidiff)
tree4484ee12251cc858c3130271e5a798f4302be888 /microkde
parent25671b4735f2604e13f4d6801b96f016ac8b9834 (diff)
downloadkdepimpi-9f0d4ee43ce6f8c61abbd546376ef4f262261a1e.zip
kdepimpi-9f0d4ee43ce6f8c61abbd546376ef4f262261a1e.tar.gz
kdepimpi-9f0d4ee43ce6f8c61abbd546376ef4f262261a1e.tar.bz2
Found and fixed problem of fastload of KAPI
Diffstat (limited to 'microkde') (more/less context) (ignore whitespace changes)
-rw-r--r--microkde/kdeui/kmainwindow.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/microkde/kdeui/kmainwindow.cpp b/microkde/kdeui/kmainwindow.cpp
index 3a2a4d0..bd5a2cc 100644
--- a/microkde/kdeui/kmainwindow.cpp
+++ b/microkde/kdeui/kmainwindow.cpp
@@ -1,569 +1,569 @@
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 Stephan Kulow (coolo@kde.org) 4 (C) 1997 Stephan Kulow (coolo@kde.org)
5 (C) 1997-2000 Sven Radej (radej@kde.org) 5 (C) 1997-2000 Sven Radej (radej@kde.org)
6 (C) 1997-2000 Matthias Ettrich (ettrich@kde.org) 6 (C) 1997-2000 Matthias Ettrich (ettrich@kde.org)
7 (C) 1999 Chris Schlaeger (cs@kde.org) 7 (C) 1999 Chris Schlaeger (cs@kde.org)
8 (C) 2002 Joseph Wenninger (jowenn@kde.org) 8 (C) 2002 Joseph Wenninger (jowenn@kde.org)
9 9
10 This library is free software; you can redistribute it and/or 10 This library is free software; you can redistribute it and/or
11 modify it under the terms of the GNU Library General Public 11 modify it under the terms of the GNU Library General Public
12 License version 2 as published by the Free Software Foundation. 12 License version 2 as published by the Free Software Foundation.
13 13
14 This library is distributed in the hope that it will be useful, 14 This library is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 Library General Public License for more details. 17 Library General Public License for more details.
18 18
19 You should have received a copy of the GNU Library General Public License 19 You should have received a copy of the GNU Library General Public License
20 along with this library; see the file COPYING.LIB. If not, write to 20 along with this library; see the file COPYING.LIB. If not, write to
21 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 21 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 Boston, MA 02111-1307, USA. 22 Boston, MA 02111-1307, USA.
23 */ 23 */
24#include <qobjectlist.h> 24#include <qobjectlist.h>
25#include <qstringlist.h> 25#include <qstringlist.h>
26#include <qtimer.h> 26#include <qtimer.h>
27#include <qmenubar.h> 27#include <qmenubar.h>
28#include <qstatusbar.h> 28#include <qstatusbar.h>
29#include <qapplication.h> 29#include <qapplication.h>
30 30
31 31
32#include "kdebug.h" 32#include "kdebug.h"
33#include "kmainwindow.h" 33#include "kmainwindow.h"
34#include "kglobalsettings.h" 34#include "kglobalsettings.h"
35#include "kactioncollection.h" 35#include "kactioncollection.h"
36 36
37class KMainWindowPrivate { 37class KMainWindowPrivate {
38public: 38public:
39//US bool showHelpMenu:1; 39//US bool showHelpMenu:1;
40 40
41 bool autoSaveSettings:1; 41 bool autoSaveSettings:1;
42 bool settingsDirty:1; 42 bool settingsDirty:1;
43 bool autoSaveWindowSize:1; 43 bool autoSaveWindowSize:1;
44 bool care_about_geometry:1; 44 bool care_about_geometry:1;
45 QString autoSaveGroup; 45 QString autoSaveGroup;
46//US KAccel * kaccel; 46//US KAccel * kaccel;
47//US KMainWindowInterface *m_interface; 47//US KMainWindowInterface *m_interface;
48 KDEPrivate::ToolBarHandler *toolBarHandler; 48 KDEPrivate::ToolBarHandler *toolBarHandler;
49 QTimer* settingsTimer; 49 QTimer* settingsTimer;
50 KToggleAction *showStatusBarAction; 50 KToggleAction *showStatusBarAction;
51 QRect defaultWindowSize; 51 QRect defaultWindowSize;
52}; 52};
53 53
54static bool no_query_exit = false; 54static bool no_query_exit = false;
55 55
56KMainWindow::KMainWindow( QWidget* parent, const char *name, WFlags f ) 56KMainWindow::KMainWindow( QWidget* parent, const char *name, WFlags f )
57 : QMainWindow( parent, name, f )/*US, KXMLGUIBuilder( this ), helpMenu2( 0 ), factory_( 0 )*/ 57 : QMainWindow( parent, name ) /*LR, f ) with the default widget flag we cannot have fastload */ /*US, KXMLGUIBuilder( this ), helpMenu2( 0 ), factory_( 0 )*/
58{ 58{
59 mQToolBar = 0; 59 mQToolBar = 0;
60 initKMainWindow(name); 60 initKMainWindow(name);
61} 61}
62 62
63void KMainWindow::parseGeometry(bool parsewidth) 63void KMainWindow::parseGeometry(bool parsewidth)
64{ 64{
65//US the following code is not getting used in the embedded version !! So disable it for now 65//US the following code is not getting used in the embedded version !! So disable it for now
66/*US 66/*US
67 67
68 assert ( !kapp->geometryArgument().isNull() ); 68 assert ( !kapp->geometryArgument().isNull() );
69 assert ( d->care_about_geometry ); 69 assert ( d->care_about_geometry );
70 70
71#ifndef Q_WS_QWS 71#ifndef Q_WS_QWS
72 // FIXME: (E) Implement something similar for Qt Embedded (or decide we don't need it) 72 // FIXME: (E) Implement something similar for Qt Embedded (or decide we don't need it)
73 int x, y; 73 int x, y;
74 int w, h; 74 int w, h;
75 int m = XParseGeometry( kapp->geometryArgument().latin1(), &x, &y, (unsigned int*)&w, (unsigned int*)&h); 75 int m = XParseGeometry( kapp->geometryArgument().latin1(), &x, &y, (unsigned int*)&w, (unsigned int*)&h);
76 if (parsewidth) { 76 if (parsewidth) {
77 QSize minSize = minimumSize(); 77 QSize minSize = minimumSize();
78 QSize maxSize = maximumSize(); 78 QSize maxSize = maximumSize();
79 if ( (m & WidthValue) == 0 ) 79 if ( (m & WidthValue) == 0 )
80 w = width(); 80 w = width();
81 if ( (m & HeightValue) == 0 ) 81 if ( (m & HeightValue) == 0 )
82 h = height(); 82 h = height();
83 w = QMIN(w,maxSize.width()); 83 w = QMIN(w,maxSize.width());
84 h = QMIN(h,maxSize.height()); 84 h = QMIN(h,maxSize.height());
85 w = QMAX(w,minSize.width()); 85 w = QMAX(w,minSize.width());
86 h = QMAX(h,minSize.height()); 86 h = QMAX(h,minSize.height());
87 resize(w, h); 87 resize(w, h);
88 } else { 88 } else {
89 if ( parsewidth && (m & XValue) == 0 ) 89 if ( parsewidth && (m & XValue) == 0 )
90 x = geometry().x(); 90 x = geometry().x();
91 if ( parsewidth && (m & YValue) == 0 ) 91 if ( parsewidth && (m & YValue) == 0 )
92 y = geometry().y(); 92 y = geometry().y();
93 if ( (m & XNegative) ) 93 if ( (m & XNegative) )
94 x = KApplication::desktop()->width() + x - w; 94 x = KApplication::desktop()->width() + x - w;
95 if ( (m & YNegative) ) 95 if ( (m & YNegative) )
96 y = KApplication::desktop()->height() + y - h; 96 y = KApplication::desktop()->height() + y - h;
97 move(x, y); 97 move(x, y);
98 } 98 }
99#endif 99#endif
100*/ 100*/
101} 101}
102 102
103KMainWindow::~KMainWindow() 103KMainWindow::~KMainWindow()
104{ 104{
105 delete d->settingsTimer; 105 delete d->settingsTimer;
106 QMenuBar* mb = internalMenuBar(); 106 QMenuBar* mb = internalMenuBar();
107 delete mb; 107 delete mb;
108//US delete d->m_interface; 108//US delete d->m_interface;
109 109
110 delete d; 110 delete d;
111//US memberList->remove( this ); 111//US memberList->remove( this );
112} 112}
113 113
114void KMainWindow::initKMainWindow(const char *name) 114void KMainWindow::initKMainWindow(const char *name)
115{ 115{
116 setDockMenuEnabled( FALSE ); 116 setDockMenuEnabled( FALSE );
117//US mHelpMenu = 0; 117//US mHelpMenu = 0;
118 118
119//US kapp->setTopWidget( this ); 119//US kapp->setTopWidget( this );
120 actionCollection()->setWidget( this ); 120 actionCollection()->setWidget( this );
121//US connect(kapp, SIGNAL(shutDown()), this, SLOT(shuttingDown())); 121//US connect(kapp, SIGNAL(shutDown()), this, SLOT(shuttingDown()));
122//US if( !memberList ) 122//US if( !memberList )
123//US memberList = new QPtrList<KMainWindow>; 123//US memberList = new QPtrList<KMainWindow>;
124/*US 124/*US
125 125
126 if ( !ksm ) 126 if ( !ksm )
127 ksm = ksmd.setObject(new KMWSessionManaged()); 127 ksm = ksmd.setObject(new KMWSessionManaged());
128 // set a unique object name. Required by session management. 128 // set a unique object name. Required by session management.
129 QCString objname; 129 QCString objname;
130 QCString s; 130 QCString s;
131 int unusedNumber; 131 int unusedNumber;
132 if ( !name ) 132 if ( !name )
133 { // no name given 133 { // no name given
134 objname = kapp->instanceName() + "-mainwindow#"; 134 objname = kapp->instanceName() + "-mainwindow#";
135 s = objname + '1'; // start adding number immediately 135 s = objname + '1'; // start adding number immediately
136 unusedNumber = 1; 136 unusedNumber = 1;
137 } 137 }
138 else if( name[ strlen( name ) - 1 ] == '#' ) 138 else if( name[ strlen( name ) - 1 ] == '#' )
139 { // trailing # - always add a number 139 { // trailing # - always add a number
140 objname = name; 140 objname = name;
141 s = objname + '1'; // start adding number immediately 141 s = objname + '1'; // start adding number immediately
142 unusedNumber = 1; 142 unusedNumber = 1;
143 } 143 }
144 else 144 else
145 { 145 {
146 objname = name; 146 objname = name;
147 s = objname; 147 s = objname;
148 unusedNumber = 0; // add numbers only when needed 148 unusedNumber = 0; // add numbers only when needed
149 } 149 }
150 for(;;) { 150 for(;;) {
151 QWidgetList* list = kapp->topLevelWidgets(); 151 QWidgetList* list = kapp->topLevelWidgets();
152 QWidgetListIt it( *list ); 152 QWidgetListIt it( *list );
153 bool found = false; 153 bool found = false;
154 for( QWidget* w = it.current(); 154 for( QWidget* w = it.current();
155 w != NULL; 155 w != NULL;
156 ++it, w = it.current()) 156 ++it, w = it.current())
157 if( w != this && w->name() == s ) 157 if( w != this && w->name() == s )
158 { 158 {
159 found = true; 159 found = true;
160 break; 160 break;
161 } 161 }
162 delete list; 162 delete list;
163 if( !found ) 163 if( !found )
164 break; 164 break;
165 s.setNum( ++unusedNumber ); 165 s.setNum( ++unusedNumber );
166 s = objname + s; 166 s = objname + s;
167 } 167 }
168 setName( s ); 168 setName( s );
169 memberList->append( this ); 169 memberList->append( this );
170*/ 170*/
171 171
172 d = new KMainWindowPrivate; 172 d = new KMainWindowPrivate;
173//US d->showHelpMenu = true; 173//US d->showHelpMenu = true;
174 d->settingsDirty = false; 174 d->settingsDirty = false;
175 d->autoSaveSettings = false; 175 d->autoSaveSettings = false;
176 d->autoSaveWindowSize = true; // for compatibility 176 d->autoSaveWindowSize = true; // for compatibility
177//US d->kaccel = actionCollection()->kaccel(); 177//US d->kaccel = actionCollection()->kaccel();
178 d->toolBarHandler = 0; 178 d->toolBarHandler = 0;
179 d->settingsTimer = 0; 179 d->settingsTimer = 0;
180 d->showStatusBarAction = NULL; 180 d->showStatusBarAction = NULL;
181/*US 181/*US
182 if ((d->care_about_geometry == beeing_first)) { 182 if ((d->care_about_geometry == beeing_first)) {
183 beeing_first = false; 183 beeing_first = false;
184 if ( kapp->geometryArgument().isNull() ) // if there is no geometry, it doesn't mater 184 if ( kapp->geometryArgument().isNull() ) // if there is no geometry, it doesn't mater
185 d->care_about_geometry = false; 185 d->care_about_geometry = false;
186 else 186 else
187 parseGeometry(false); 187 parseGeometry(false);
188 } 188 }
189*/ 189*/
190 d->care_about_geometry = false; 190 d->care_about_geometry = false;
191 191
192//US setCaption( kapp->caption() ); 192//US setCaption( kapp->caption() );
193 // attach dcop interface 193 // attach dcop interface
194//US d->m_interface = new KMainWindowInterface(this); 194//US d->m_interface = new KMainWindowInterface(this);
195 195
196//US if (!kapp->authorize("movable_toolbars")) 196//US if (!kapp->authorize("movable_toolbars"))
197//US setDockWindowsMovable(false); 197//US setDockWindowsMovable(false);
198} 198}
199 199
200KAction *KMainWindow::toolBarMenuAction() 200KAction *KMainWindow::toolBarMenuAction()
201{ 201{
202 if ( !d->toolBarHandler ) 202 if ( !d->toolBarHandler )
203 return 0; 203 return 0;
204 204
205 return d->toolBarHandler->toolBarMenuAction(); 205 return d->toolBarHandler->toolBarMenuAction();
206} 206}
207 207
208bool KMainWindow::canBeRestored( int number ) 208bool KMainWindow::canBeRestored( int number )
209{ 209{
210/*US we do not have and want to save sessioninformation. Use info from the default 210/*US we do not have and want to save sessioninformation. Use info from the default
211application config. 211application config.
212*/ 212*/
213//US if ( !kapp->isRestored() ) 213//US if ( !kapp->isRestored() )
214//US return FALSE; 214//US return FALSE;
215//US KConfig *config = kapp->sessionConfig(); 215//US KConfig *config = kapp->sessionConfig();
216 KConfig *config = KGlobal::config(); 216 KConfig *config = KGlobal::config();
217 if ( !config ) 217 if ( !config )
218 return FALSE; 218 return FALSE;
219 config->setGroup( QString::fromLatin1("Number") ); 219 config->setGroup( QString::fromLatin1("Number") );
220 int n = config->readNumEntry( QString::fromLatin1("NumberOfWindows") , 1 ); 220 int n = config->readNumEntry( QString::fromLatin1("NumberOfWindows") , 1 );
221 return number >= 1 && number <= n; 221 return number >= 1 && number <= n;
222 222
223} 223}
224 224
225const QString KMainWindow::classNameOfToplevel( int number ) 225const QString KMainWindow::classNameOfToplevel( int number )
226{ 226{
227/*US we do not have and want to save sessioninformation. Use info from the default 227/*US we do not have and want to save sessioninformation. Use info from the default
228application config. 228application config.
229*/ 229*/
230//US if ( !kapp->isRestored() ) 230//US if ( !kapp->isRestored() )
231//US return QString::null; 231//US return QString::null;
232//US KConfig *config = kapp->sessionConfig(); 232//US KConfig *config = kapp->sessionConfig();
233 KConfig *config = KGlobal::config(); 233 KConfig *config = KGlobal::config();
234 if ( !config ) 234 if ( !config )
235 return QString::null; 235 return QString::null;
236 QString s; 236 QString s;
237 s.setNum( number ); 237 s.setNum( number );
238 s.prepend( QString::fromLatin1("WindowProperties") ); 238 s.prepend( QString::fromLatin1("WindowProperties") );
239 config->setGroup( s ); 239 config->setGroup( s );
240 if ( !config->hasKey( QString::fromLatin1("ClassName") ) ) 240 if ( !config->hasKey( QString::fromLatin1("ClassName") ) )
241 return QString::null; 241 return QString::null;
242 else 242 else
243 return config->readEntry( QString::fromLatin1("ClassName") ); 243 return config->readEntry( QString::fromLatin1("ClassName") );
244} 244}
245 245
246bool KMainWindow::restore( int number, bool show ) 246bool KMainWindow::restore( int number, bool show )
247{ 247{
248/*US we do not have and want to save sessioninformation. Use info from the default 248/*US we do not have and want to save sessioninformation. Use info from the default
249application config. 249application config.
250*/ 250*/
251 if ( !canBeRestored( number ) ) 251 if ( !canBeRestored( number ) )
252 return FALSE; 252 return FALSE;
253//US KConfig *config = kapp->sessionConfig(); 253//US KConfig *config = kapp->sessionConfig();
254 KConfig *config = KGlobal::config(); 254 KConfig *config = KGlobal::config();
255 255
256 if ( readPropertiesInternal( config, number ) ){ 256 if ( readPropertiesInternal( config, number ) ){
257 if ( show ) 257 if ( show )
258 KMainWindow::show(); 258 KMainWindow::show();
259 return FALSE; 259 return FALSE;
260 } 260 }
261 return FALSE; 261 return FALSE;
262 262
263} 263}
264 264
265void KMainWindow::setCaption( const QString &caption ) 265void KMainWindow::setCaption( const QString &caption )
266{ 266{
267//US setPlainCaption( kapp->makeStdCaption(caption) ); 267//US setPlainCaption( kapp->makeStdCaption(caption) );
268 setPlainCaption( caption ); 268 setPlainCaption( caption );
269} 269}
270 270
271void KMainWindow::setCaption( const QString &caption, bool modified ) 271void KMainWindow::setCaption( const QString &caption, bool modified )
272{ 272{
273//US setPlainCaption( kapp->makeStdCaption(caption, true, modified) ); 273//US setPlainCaption( kapp->makeStdCaption(caption, true, modified) );
274 setPlainCaption( caption + "modified:" ); 274 setPlainCaption( caption + "modified:" );
275} 275}
276 276
277void KMainWindow::setPlainCaption( const QString &caption ) 277void KMainWindow::setPlainCaption( const QString &caption )
278{ 278{
279 QMainWindow::setCaption( caption ); 279 QMainWindow::setCaption( caption );
280#ifndef Q_WS_QWS 280#ifndef Q_WS_QWS
281//US the following is disabled for the embedded version 281//US the following is disabled for the embedded version
282//US NETWinInfo info( qt_xdisplay(), winId(), qt_xrootwin(), 0 ); 282//US NETWinInfo info( qt_xdisplay(), winId(), qt_xrootwin(), 0 );
283//US info.setName( caption.utf8().data() ); 283//US info.setName( caption.utf8().data() );
284#endif 284#endif
285} 285}
286 286
287void KMainWindow::slotStateChanged(const QString &newstate) 287void KMainWindow::slotStateChanged(const QString &newstate)
288{ 288{
289 stateChanged(newstate, KXMLGUIClient::StateNoReverse); 289 stateChanged(newstate, KXMLGUIClient::StateNoReverse);
290} 290}
291 291
292/* 292/*
293 * Get rid of this for KDE 4.0 293 * Get rid of this for KDE 4.0
294 */ 294 */
295void KMainWindow::slotStateChanged(const QString &newstate, 295void KMainWindow::slotStateChanged(const QString &newstate,
296 KXMLGUIClient::ReverseStateChange reverse) 296 KXMLGUIClient::ReverseStateChange reverse)
297{ 297{
298 stateChanged(newstate, reverse); 298 stateChanged(newstate, reverse);
299} 299}
300 300
301void KMainWindow::closeEvent ( QCloseEvent *e ) 301void KMainWindow::closeEvent ( QCloseEvent *e )
302{ 302{
303 // Save settings if auto-save is enabled, and settings have changed 303 // Save settings if auto-save is enabled, and settings have changed
304 if (d->settingsDirty && d->autoSaveSettings) 304 if (d->settingsDirty && d->autoSaveSettings)
305 saveAutoSaveSettings(); 305 saveAutoSaveSettings();
306 306
307 if (queryClose()) { 307 if (queryClose()) {
308 e->accept(); 308 e->accept();
309 309
310 int not_withdrawn = 0; 310 int not_withdrawn = 0;
311/*US 311/*US
312 QPtrListIterator<KMainWindow> it(*KMainWindow::memberList); 312 QPtrListIterator<KMainWindow> it(*KMainWindow::memberList);
313 for (it.toFirst(); it.current(); ++it){ 313 for (it.toFirst(); it.current(); ++it){
314 if ( !it.current()->isHidden() && it.current()->isTopLevel() && it.current() != this ) 314 if ( !it.current()->isHidden() && it.current()->isTopLevel() && it.current() != this )
315 not_withdrawn++; 315 not_withdrawn++;
316 } 316 }
317*/ 317*/
318 if ( !no_query_exit && not_withdrawn <= 0 ) { // last window close accepted? 318 if ( !no_query_exit && not_withdrawn <= 0 ) { // last window close accepted?
319/*US 319/*US
320 if ( queryExit() && !kapp->sessionSaving()) { // Yes, Quit app? 320 if ( queryExit() && !kapp->sessionSaving()) { // Yes, Quit app?
321 // don't call queryExit() twice 321 // don't call queryExit() twice
322 disconnect(kapp, SIGNAL(shutDown()), this, SLOT(shuttingDown())); 322 disconnect(kapp, SIGNAL(shutDown()), this, SLOT(shuttingDown()));
323 kapp->deref(); // ...and quit aplication. 323 kapp->deref(); // ...and quit aplication.
324 } else { 324 } else {
325 // cancel closing, it's stupid to end up with no windows at all.... 325 // cancel closing, it's stupid to end up with no windows at all....
326 e->ignore(); 326 e->ignore();
327 } 327 }
328*/ 328*/
329//US we have no sessionmanagement. Simply close app. 329//US we have no sessionmanagement. Simply close app.
330 if ( queryExit() ) { // Yes, Quit app? 330 if ( queryExit() ) { // Yes, Quit app?
331 qDebug("KMainWindow::closeEvent: Exit application ???"); 331 qDebug("KMainWindow::closeEvent: Exit application ???");
332 // don't call queryExit() twice 332 // don't call queryExit() twice
333//US disconnect(kapp, SIGNAL(shutDown()), this, SLOT(shuttingDown())); 333//US disconnect(kapp, SIGNAL(shutDown()), this, SLOT(shuttingDown()));
334 } 334 }
335 335
336 } 336 }
337 } 337 }
338} 338}
339 339
340bool KMainWindow::queryExit() 340bool KMainWindow::queryExit()
341{ 341{
342 return TRUE; 342 return TRUE;
343} 343}
344 344
345bool KMainWindow::queryClose() 345bool KMainWindow::queryClose()
346{ 346{
347 return TRUE; 347 return TRUE;
348} 348}
349 349
350void KMainWindow::saveGlobalProperties( KConfig* ) 350void KMainWindow::saveGlobalProperties( KConfig* )
351{ 351{
352} 352}
353 353
354void KMainWindow::readGlobalProperties( KConfig* ) 354void KMainWindow::readGlobalProperties( KConfig* )
355{ 355{
356} 356}
357 357
358void KMainWindow::savePropertiesInternal( KConfig *config, int number ) 358void KMainWindow::savePropertiesInternal( KConfig *config, int number )
359{ 359{
360 bool oldASWS = d->autoSaveWindowSize; 360 bool oldASWS = d->autoSaveWindowSize;
361 d->autoSaveWindowSize = true; // make saveMainWindowSettings save the window size 361 d->autoSaveWindowSize = true; // make saveMainWindowSettings save the window size
362 362
363 QString s; 363 QString s;
364 s.setNum(number); 364 s.setNum(number);
365 s.prepend(QString::fromLatin1("WindowProperties")); 365 s.prepend(QString::fromLatin1("WindowProperties"));
366 config->setGroup(s); 366 config->setGroup(s);
367 367
368 // store objectName, className, Width and Height for later restoring 368 // store objectName, className, Width and Height for later restoring
369 // (Only useful for session management) 369 // (Only useful for session management)
370 config->writeEntry(QString::fromLatin1("ObjectName"), name()); 370 config->writeEntry(QString::fromLatin1("ObjectName"), name());
371 config->writeEntry(QString::fromLatin1("ClassName"), className()); 371 config->writeEntry(QString::fromLatin1("ClassName"), className());
372 372
373 saveMainWindowSettings(config); // Menubar, statusbar and Toolbar settings. 373 saveMainWindowSettings(config); // Menubar, statusbar and Toolbar settings.
374 374
375 s.setNum(number); 375 s.setNum(number);
376 config->setGroup(s); 376 config->setGroup(s);
377 saveProperties(config); 377 saveProperties(config);
378 378
379 d->autoSaveWindowSize = oldASWS; 379 d->autoSaveWindowSize = oldASWS;
380} 380}
381 381
382void KMainWindow::setStandardToolBarMenuEnabled( bool enable ) 382void KMainWindow::setStandardToolBarMenuEnabled( bool enable )
383{ 383{
384 if ( enable ) 384 if ( enable )
385 { 385 {
386 if ( d->toolBarHandler ) 386 if ( d->toolBarHandler )
387 return; 387 return;
388 388
389 d->toolBarHandler = new KDEPrivate::ToolBarHandler( this ); 389 d->toolBarHandler = new KDEPrivate::ToolBarHandler( this );
390 390
391/*US if ( factory() ) 391/*US if ( factory() )
392 factory()->addClient( d->toolBarHandler ); 392 factory()->addClient( d->toolBarHandler );
393*/ 393*/
394 } 394 }
395 else 395 else
396 { 396 {
397 if ( !d->toolBarHandler ) 397 if ( !d->toolBarHandler )
398 return; 398 return;
399/*US 399/*US
400 if ( factory() ) 400 if ( factory() )
401 factory()->removeClient( d->toolBarHandler ); 401 factory()->removeClient( d->toolBarHandler );
402*/ 402*/
403 delete d->toolBarHandler; 403 delete d->toolBarHandler;
404 d->toolBarHandler = 0; 404 d->toolBarHandler = 0;
405 } 405 }
406 406
407} 407}
408 408
409bool KMainWindow::isStandardToolBarMenuEnabled() const 409bool KMainWindow::isStandardToolBarMenuEnabled() const
410{ 410{
411 return ( d->toolBarHandler != 0 ); 411 return ( d->toolBarHandler != 0 );
412} 412}
413 413
414void KMainWindow::createStandardStatusBarAction(){ 414void KMainWindow::createStandardStatusBarAction(){
415 if(!d->showStatusBarAction){ 415 if(!d->showStatusBarAction){
416 d->showStatusBarAction = KStdAction::showStatusbar(this, SLOT(setSettingsDirty()), actionCollection()); 416 d->showStatusBarAction = KStdAction::showStatusbar(this, SLOT(setSettingsDirty()), actionCollection());
417 connect(d->showStatusBarAction, SIGNAL(toggled(bool)), statusBar(), SLOT(setShown(bool))); 417 connect(d->showStatusBarAction, SIGNAL(toggled(bool)), statusBar(), SLOT(setShown(bool)));
418 if(internalStatusBar()) 418 if(internalStatusBar())
419 d->showStatusBarAction->setChecked(!internalStatusBar()->isHidden()); 419 d->showStatusBarAction->setChecked(!internalStatusBar()->isHidden());
420 } 420 }
421} 421}
422 422
423QToolBar *KMainWindow::tBar( ) 423QToolBar *KMainWindow::tBar( )
424{ 424{
425 if ( ! mQToolBar ) 425 if ( ! mQToolBar )
426 mQToolBar = new QToolBar( this ); 426 mQToolBar = new QToolBar( this );
427 return mQToolBar; 427 return mQToolBar;
428} 428}
429 429
430KToolBar *KMainWindow::toolBar( const char * name ) 430KToolBar *KMainWindow::toolBar( const char * name )
431{ 431{
432 432
433 if (!name) 433 if (!name)
434 name = "mainToolBar"; 434 name = "mainToolBar";
435 KToolBar *tb = (KToolBar*)child( name, "KToolBar" ); 435 KToolBar *tb = (KToolBar*)child( name, "KToolBar" );
436 if ( tb ) 436 if ( tb )
437 return tb; 437 return tb;
438 bool honor_mode = (name == "mainToolBar"); 438 bool honor_mode = (name == "mainToolBar");
439 439
440/*US 440/*US
441 if ( builderClient() ) 441 if ( builderClient() )
442 return new KToolBar(this, name, honor_mode); // XMLGUI constructor 442 return new KToolBar(this, name, honor_mode); // XMLGUI constructor
443 else 443 else
444*/ 444*/
445 return new KToolBar(this, Top, false, name, honor_mode ); // non-XMLGUI 445 return new KToolBar(this, Top, false, name, honor_mode ); // non-XMLGUI
446} 446}
447 447
448QPtrListIterator<KToolBar> KMainWindow::toolBarIterator() 448QPtrListIterator<KToolBar> KMainWindow::toolBarIterator()
449{ 449{
450 toolbarList.clear(); 450 toolbarList.clear();
451 QPtrList<QToolBar> lst; 451 QPtrList<QToolBar> lst;
452 for ( int i = (int)QMainWindow::Unmanaged; i <= (int)Minimized; ++i ) { 452 for ( int i = (int)QMainWindow::Unmanaged; i <= (int)Minimized; ++i ) {
453 lst = toolBars( (ToolBarDock)i ); 453 lst = toolBars( (ToolBarDock)i );
454 for ( QToolBar *tb = lst.first(); tb; tb = lst.next() ) { 454 for ( QToolBar *tb = lst.first(); tb; tb = lst.next() ) {
455 if ( !tb->inherits( "KToolBar" ) ) 455 if ( !tb->inherits( "KToolBar" ) )
456 continue; 456 continue;
457 toolbarList.append( (KToolBar*)tb ); 457 toolbarList.append( (KToolBar*)tb );
458 } 458 }
459 } 459 }
460 return QPtrListIterator<KToolBar>( toolbarList ); 460 return QPtrListIterator<KToolBar>( toolbarList );
461} 461}
462 462
463void KMainWindow::setAutoSaveSettings( const QString & groupName, bool saveWindowSize ) 463void KMainWindow::setAutoSaveSettings( const QString & groupName, bool saveWindowSize )
464{ 464{
465 d->autoSaveSettings = true; 465 d->autoSaveSettings = true;
466 d->autoSaveGroup = groupName; 466 d->autoSaveGroup = groupName;
467 d->autoSaveWindowSize = saveWindowSize; 467 d->autoSaveWindowSize = saveWindowSize;
468 // Get notified when the user moves a toolbar around 468 // Get notified when the user moves a toolbar around
469//US connect( this, SIGNAL( dockWindowPositionChanged( QDockWindow * ) ), 469//US connect( this, SIGNAL( dockWindowPositionChanged( QDockWindow * ) ),
470//US this, SLOT( setSettingsDirty() ) ); 470//US this, SLOT( setSettingsDirty() ) );
471 connect( this, SIGNAL( toolBarPositionChanged(QToolBar *) ), 471 connect( this, SIGNAL( toolBarPositionChanged(QToolBar *) ),
472 this, SLOT( setSettingsDirty() ) ); 472 this, SLOT( setSettingsDirty() ) );
473 473
474 474
475 // Get default values 475 // Get default values
476//US int scnum = QApplication::desktop()->screenNumber(parentWidget()); 476//US int scnum = QApplication::desktop()->screenNumber(parentWidget());
477//US QRect desk = QApplication::desktop()->screenGeometry(scnum); 477//US QRect desk = QApplication::desktop()->screenGeometry(scnum);
478 QRect desk = KGlobalSettings::desktopGeometry(0); 478 QRect desk = KGlobalSettings::desktopGeometry(0);
479 479
480 d->defaultWindowSize = QRect(desk.width(), width(), desk.height(), height()); 480 d->defaultWindowSize = QRect(desk.width(), width(), desk.height(), height());
481 // Now read the previously saved settings 481 // Now read the previously saved settings
482 applyMainWindowSettings( KGlobal::config(), groupName ); 482 applyMainWindowSettings( KGlobal::config(), groupName );
483} 483}
484 484
485 485
486void KMainWindow::resetAutoSaveSettings() 486void KMainWindow::resetAutoSaveSettings()
487{ 487{
488 d->autoSaveSettings = false; 488 d->autoSaveSettings = false;
489 if ( d->settingsTimer ) 489 if ( d->settingsTimer )
490 d->settingsTimer->stop(); 490 d->settingsTimer->stop();
491} 491}
492 492
493bool KMainWindow::autoSaveSettings() const 493bool KMainWindow::autoSaveSettings() const
494{ 494{
495 return d->autoSaveSettings; 495 return d->autoSaveSettings;
496} 496}
497 497
498QString KMainWindow::autoSaveGroup() const 498QString KMainWindow::autoSaveGroup() const
499{ 499{
500 return d->autoSaveGroup; 500 return d->autoSaveGroup;
501} 501}
502 502
503void KMainWindow::saveAutoSaveSettings() 503void KMainWindow::saveAutoSaveSettings()
504{ 504{
505 ASSERT( d->autoSaveSettings ); 505 ASSERT( d->autoSaveSettings );
506 //kdDebug(200) << "KMainWindow::saveAutoSaveSettings -> saving settings" << endl; 506 //kdDebug(200) << "KMainWindow::saveAutoSaveSettings -> saving settings" << endl;
507 saveMainWindowSettings( KGlobal::config(), d->autoSaveGroup ); 507 saveMainWindowSettings( KGlobal::config(), d->autoSaveGroup );
508 KGlobal::config()->sync(); 508 KGlobal::config()->sync();
509 d->settingsDirty = false; 509 d->settingsDirty = false;
510 if ( d->settingsTimer ) 510 if ( d->settingsTimer )
511 d->settingsTimer->stop(); 511 d->settingsTimer->stop();
512} 512}
513 513
514void KMainWindow::createGUI( const QString &xmlfile, bool _conserveMemory ) 514void KMainWindow::createGUI( const QString &xmlfile, bool _conserveMemory )
515{ 515{
516 // disabling the updates prevents unnecessary redraws 516 // disabling the updates prevents unnecessary redraws
517 setUpdatesEnabled( false ); 517 setUpdatesEnabled( false );
518 518
519 // just in case we are rebuilding, let's remove our old client 519 // just in case we are rebuilding, let's remove our old client
520//US guiFactory()->removeClient( this ); 520//US guiFactory()->removeClient( this );
521 521
522 // make sure to have an empty GUI 522 // make sure to have an empty GUI
523 QMenuBar* mb = internalMenuBar(); 523 QMenuBar* mb = internalMenuBar();
524 if ( mb ) 524 if ( mb )
525 mb->clear(); 525 mb->clear();
526 526
527 (void)toolBarIterator(); // make sure toolbarList is most-up-to-date 527 (void)toolBarIterator(); // make sure toolbarList is most-up-to-date
528 toolbarList.setAutoDelete( true ); 528 toolbarList.setAutoDelete( true );
529 toolbarList.clear(); 529 toolbarList.clear();
530 toolbarList.setAutoDelete( false ); 530 toolbarList.setAutoDelete( false );
531/*US 531/*US
532 // don't build a help menu unless the user ask for it 532 // don't build a help menu unless the user ask for it
533 if (d->showHelpMenu) { 533 if (d->showHelpMenu) {
534 // we always want a help menu 534 // we always want a help menu
535 if (helpMenu2 == 0) 535 if (helpMenu2 == 0)
536 helpMenu2 = new KHelpMenu(this, instance()->aboutData(), true, 536 helpMenu2 = new KHelpMenu(this, instance()->aboutData(), true,
537 actionCollection()); 537 actionCollection());
538 } 538 }
539 539
540 // we always want to load in our global standards file 540 // we always want to load in our global standards file
541 setXMLFile( locate( "config", "ui/ui_standards.rc", instance() ) ); 541 setXMLFile( locate( "config", "ui/ui_standards.rc", instance() ) );
542 542
543 // now, merge in our local xml file. if this is null, then that 543 // now, merge in our local xml file. if this is null, then that
544 // means that we will be only using the global file 544 // means that we will be only using the global file
545 if ( !xmlfile.isNull() ) { 545 if ( !xmlfile.isNull() ) {
546 setXMLFile( xmlfile, true ); 546 setXMLFile( xmlfile, true );
547 } else { 547 } else {
548 QString auto_file(instance()->instanceName() + "ui.rc"); 548 QString auto_file(instance()->instanceName() + "ui.rc");
549 setXMLFile( auto_file, true ); 549 setXMLFile( auto_file, true );
550 } 550 }
551 551
552 // make sure we don't have any state saved already 552 // make sure we don't have any state saved already
553 setXMLGUIBuildDocument( QDomDocument() ); 553 setXMLGUIBuildDocument( QDomDocument() );
554 554
555 // do the actual GUI building 555 // do the actual GUI building
556 guiFactory()->addClient( this ); 556 guiFactory()->addClient( this );
557 557
558 // try and get back *some* of our memory 558 // try and get back *some* of our memory
559 if ( _conserveMemory ) 559 if ( _conserveMemory )
560 { 560 {
561 // before freeing the memory allocated by the DOM document we also 561 // before freeing the memory allocated by the DOM document we also
562 // free all memory allocated internally in the KXMLGUIFactory for 562 // free all memory allocated internally in the KXMLGUIFactory for
563 // the menubar and the toolbars . This however implies that we 563 // the menubar and the toolbars . This however implies that we
564 // have to take care of deleting those widgets ourselves. For 564 // have to take care of deleting those widgets ourselves. For
565 // destruction this is no problem, but when rebuilding we have 565 // destruction this is no problem, but when rebuilding we have
566 // to take care of that (and we want to rebuild the GUI when 566 // to take care of that (and we want to rebuild the GUI when
567 // using stuff like the toolbar editor ). 567 // using stuff like the toolbar editor ).
568 // In addition we have to take care of not removing containers 568 // In addition we have to take care of not removing containers
569 // like popupmenus, defined in the XML document. 569 // like popupmenus, defined in the XML document.