Diffstat (limited to 'microkde/kdeui/kmainwindow.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | microkde/kdeui/kmainwindow.cpp | 97 |
1 files changed, 47 insertions, 50 deletions
diff --git a/microkde/kdeui/kmainwindow.cpp b/microkde/kdeui/kmainwindow.cpp index fa678f2..bac0db8 100644 --- a/microkde/kdeui/kmainwindow.cpp +++ b/microkde/kdeui/kmainwindow.cpp | |||
@@ -1,996 +1,993 @@ | |||
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 <qobject.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 | //Added by qt3to4: | ||
31 | #include <QCloseEvent> | ||
32 | #include <QPaintEvent> | ||
33 | #include <QResizeEvent> | ||
34 | #include <QChildEvent> | ||
35 | #include <Q3PtrList> | ||
30 | 36 | ||
31 | 37 | ||
32 | #include "kdebug.h" | 38 | #include "kdebug.h" |
33 | #include "kmainwindow.h" | 39 | #include "kmainwindow.h" |
34 | #include "kglobalsettings.h" | 40 | #include "kglobalsettings.h" |
35 | #include "kactioncollection.h" | 41 | #include "kactioncollection.h" |
36 | 42 | ||
37 | class KMainWindowPrivate { | 43 | class KMainWindowPrivate { |
38 | public: | 44 | public: |
39 | //US bool showHelpMenu:1; | 45 | //US bool showHelpMenu:1; |
40 | 46 | ||
41 | bool autoSaveSettings:1; | 47 | bool autoSaveSettings:1; |
42 | bool settingsDirty:1; | 48 | bool settingsDirty:1; |
43 | bool autoSaveWindowSize:1; | 49 | bool autoSaveWindowSize:1; |
44 | bool care_about_geometry:1; | 50 | bool care_about_geometry:1; |
45 | QString autoSaveGroup; | 51 | QString autoSaveGroup; |
46 | //US KAccel * kaccel; | 52 | //US KAccel * kaccel; |
47 | //US KMainWindowInterface *m_interface; | 53 | //US KMainWindowInterface *m_interface; |
48 | KDEPrivate::ToolBarHandler *toolBarHandler; | 54 | KDEPrivate::ToolBarHandler *toolBarHandler; |
49 | QTimer* settingsTimer; | 55 | QTimer* settingsTimer; |
50 | KToggleAction *showStatusBarAction; | 56 | KToggleAction *showStatusBarAction; |
51 | QRect defaultWindowSize; | 57 | QRect defaultWindowSize; |
52 | }; | 58 | }; |
53 | 59 | ||
54 | static bool no_query_exit = false; | 60 | static bool no_query_exit = false; |
55 | 61 | ||
56 | KMainWindow::KMainWindow( QWidget* parent, const char *name ) | 62 | KMainWindow::KMainWindow( QWidget* parent, const char *name ) |
57 | : QMainWindow( parent, name ) /*LR, f ) with the default widget flag we cannot have fastload */ /*US, KXMLGUIBuilder( this ), helpMenu2( 0 ), factory_( 0 )*/ | 63 | : Q3MainWindow( parent, name ) /*LR, f ) with the default widget flag we cannot have fastload */ /*US, KXMLGUIBuilder( this ), helpMenu2( 0 ), factory_( 0 )*/ |
58 | { | 64 | { |
59 | mQToolBar = 0; | 65 | mQToolBar = 0; |
60 | initKMainWindow(name); | 66 | initKMainWindow(name); |
61 | } | 67 | } |
62 | 68 | ||
63 | void KMainWindow::parseGeometry(bool parsewidth) | 69 | void KMainWindow::parseGeometry(bool parsewidth) |
64 | { | 70 | { |
65 | //US the following code is not getting used in the embedded version !! So disable it for now | 71 | //US the following code is not getting used in the embedded version !! So disable it for now |
66 | /*US | 72 | /*US |
67 | 73 | ||
68 | assert ( !kapp->geometryArgument().isNull() ); | 74 | assert ( !kapp->geometryArgument().isNull() ); |
69 | assert ( d->care_about_geometry ); | 75 | assert ( d->care_about_geometry ); |
70 | 76 | ||
71 | #ifndef Q_WS_QWS | 77 | #ifndef Q_WS_QWS |
72 | // FIXME: (E) Implement something similar for Qt Embedded (or decide we don't need it) | 78 | // FIXME: (E) Implement something similar for Qt Embedded (or decide we don't need it) |
73 | int x, y; | 79 | int x, y; |
74 | int w, h; | 80 | int w, h; |
75 | int m = XParseGeometry( kapp->geometryArgument().latin1(), &x, &y, (unsigned int*)&w, (unsigned int*)&h); | 81 | int m = XParseGeometry( kapp->geometryArgument().latin1(), &x, &y, (unsigned int*)&w, (unsigned int*)&h); |
76 | if (parsewidth) { | 82 | if (parsewidth) { |
77 | QSize minSize = minimumSize(); | 83 | QSize minSize = minimumSize(); |
78 | QSize maxSize = maximumSize(); | 84 | QSize maxSize = maximumSize(); |
79 | if ( (m & WidthValue) == 0 ) | 85 | if ( (m & WidthValue) == 0 ) |
80 | w = width(); | 86 | w = width(); |
81 | if ( (m & HeightValue) == 0 ) | 87 | if ( (m & HeightValue) == 0 ) |
82 | h = height(); | 88 | h = height(); |
83 | w = QMIN(w,maxSize.width()); | 89 | w = QMIN(w,maxSize.width()); |
84 | h = QMIN(h,maxSize.height()); | 90 | h = QMIN(h,maxSize.height()); |
85 | w = QMAX(w,minSize.width()); | 91 | w = QMAX(w,minSize.width()); |
86 | h = QMAX(h,minSize.height()); | 92 | h = QMAX(h,minSize.height()); |
87 | resize(w, h); | 93 | resize(w, h); |
88 | } else { | 94 | } else { |
89 | if ( parsewidth && (m & XValue) == 0 ) | 95 | if ( parsewidth && (m & XValue) == 0 ) |
90 | x = geometry().x(); | 96 | x = geometry().x(); |
91 | if ( parsewidth && (m & YValue) == 0 ) | 97 | if ( parsewidth && (m & YValue) == 0 ) |
92 | y = geometry().y(); | 98 | y = geometry().y(); |
93 | if ( (m & XNegative) ) | 99 | if ( (m & XNegative) ) |
94 | x = KApplication::desktop()->width() + x - w; | 100 | x = KApplication::desktop()->width() + x - w; |
95 | if ( (m & YNegative) ) | 101 | if ( (m & YNegative) ) |
96 | y = KApplication::desktop()->height() + y - h; | 102 | y = KApplication::desktop()->height() + y - h; |
97 | move(x, y); | 103 | move(x, y); |
98 | } | 104 | } |
99 | #endif | 105 | #endif |
100 | */ | 106 | */ |
101 | } | 107 | } |
102 | 108 | ||
103 | KMainWindow::~KMainWindow() | 109 | KMainWindow::~KMainWindow() |
104 | { | 110 | { |
105 | delete d->settingsTimer; | 111 | delete d->settingsTimer; |
106 | QMenuBar* mb = internalMenuBar(); | 112 | QMenuBar* mb = internalMenuBar(); |
107 | delete mb; | 113 | delete mb; |
108 | //US delete d->m_interface; | 114 | //US delete d->m_interface; |
109 | 115 | ||
110 | delete d; | 116 | delete d; |
111 | //US memberList->remove( this ); | 117 | //US memberList->remove( this ); |
112 | } | 118 | } |
113 | 119 | ||
114 | void KMainWindow::initKMainWindow(const char *name) | 120 | void KMainWindow::initKMainWindow(const char *name) |
115 | { | 121 | { |
116 | setDockMenuEnabled( FALSE ); | 122 | setDockMenuEnabled( FALSE ); |
117 | //US mHelpMenu = 0; | 123 | //US mHelpMenu = 0; |
118 | 124 | ||
119 | //US kapp->setTopWidget( this ); | 125 | //US kapp->setTopWidget( this ); |
120 | actionCollection()->setWidget( this ); | 126 | actionCollection()->setWidget( this ); |
121 | //US connect(kapp, SIGNAL(shutDown()), this, SLOT(shuttingDown())); | 127 | //US connect(kapp, SIGNAL(shutDown()), this, SLOT(shuttingDown())); |
122 | //US if( !memberList ) | 128 | //US if( !memberList ) |
123 | //US memberList = new QPtrList<KMainWindow>; | 129 | //US memberList = new QPtrList<KMainWindow>; |
124 | /*US | 130 | /*US |
125 | 131 | ||
126 | if ( !ksm ) | 132 | if ( !ksm ) |
127 | ksm = ksmd.setObject(new KMWSessionManaged()); | 133 | ksm = ksmd.setObject(new KMWSessionManaged()); |
128 | // set a unique object name. Required by session management. | 134 | // set a unique object name. Required by session management. |
129 | QCString objname; | 135 | QCString objname; |
130 | QCString s; | 136 | QCString s; |
131 | int unusedNumber; | 137 | int unusedNumber; |
132 | if ( !name ) | 138 | if ( !name ) |
133 | { // no name given | 139 | { // no name given |
134 | objname = kapp->instanceName() + "-mainwindow#"; | 140 | objname = kapp->instanceName() + "-mainwindow#"; |
135 | s = objname + '1'; // start adding number immediately | 141 | s = objname + '1'; // start adding number immediately |
136 | unusedNumber = 1; | 142 | unusedNumber = 1; |
137 | } | 143 | } |
138 | else if( name[ strlen( name ) - 1 ] == '#' ) | 144 | else if( name[ strlen( name ) - 1 ] == '#' ) |
139 | { // trailing # - always add a number | 145 | { // trailing # - always add a number |
140 | objname = name; | 146 | objname = name; |
141 | s = objname + '1'; // start adding number immediately | 147 | s = objname + '1'; // start adding number immediately |
142 | unusedNumber = 1; | 148 | unusedNumber = 1; |
143 | } | 149 | } |
144 | else | 150 | else |
145 | { | 151 | { |
146 | objname = name; | 152 | objname = name; |
147 | s = objname; | 153 | s = objname; |
148 | unusedNumber = 0; // add numbers only when needed | 154 | unusedNumber = 0; // add numbers only when needed |
149 | } | 155 | } |
150 | for(;;) { | 156 | for(;;) { |
151 | QWidgetList* list = kapp->topLevelWidgets(); | 157 | QWidgetList* list = kapp->topLevelWidgets(); |
152 | QWidgetListIt it( *list ); | 158 | QWidgetListIt it( *list ); |
153 | bool found = false; | 159 | bool found = false; |
154 | for( QWidget* w = it.current(); | 160 | for( QWidget* w = it.current(); |
155 | w != NULL; | 161 | w != NULL; |
156 | ++it, w = it.current()) | 162 | ++it, w = it.current()) |
157 | if( w != this && w->name() == s ) | 163 | if( w != this && w->name() == s ) |
158 | { | 164 | { |
159 | found = true; | 165 | found = true; |
160 | break; | 166 | break; |
161 | } | 167 | } |
162 | delete list; | 168 | delete list; |
163 | if( !found ) | 169 | if( !found ) |
164 | break; | 170 | break; |
165 | s.setNum( ++unusedNumber ); | 171 | s.setNum( ++unusedNumber ); |
166 | s = objname + s; | 172 | s = objname + s; |
167 | } | 173 | } |
168 | setName( s ); | 174 | setName( s ); |
169 | memberList->append( this ); | 175 | memberList->append( this ); |
170 | */ | 176 | */ |
171 | 177 | ||
172 | d = new KMainWindowPrivate; | 178 | d = new KMainWindowPrivate; |
173 | //US d->showHelpMenu = true; | 179 | //US d->showHelpMenu = true; |
174 | d->settingsDirty = false; | 180 | d->settingsDirty = false; |
175 | d->autoSaveSettings = false; | 181 | d->autoSaveSettings = false; |
176 | d->autoSaveWindowSize = true; // for compatibility | 182 | d->autoSaveWindowSize = true; // for compatibility |
177 | //US d->kaccel = actionCollection()->kaccel(); | 183 | //US d->kaccel = actionCollection()->kaccel(); |
178 | d->toolBarHandler = 0; | 184 | d->toolBarHandler = 0; |
179 | d->settingsTimer = 0; | 185 | d->settingsTimer = 0; |
180 | d->showStatusBarAction = NULL; | 186 | d->showStatusBarAction = NULL; |
181 | /*US | 187 | /*US |
182 | if ((d->care_about_geometry == beeing_first)) { | 188 | if ((d->care_about_geometry == beeing_first)) { |
183 | beeing_first = false; | 189 | beeing_first = false; |
184 | if ( kapp->geometryArgument().isNull() ) // if there is no geometry, it doesn't mater | 190 | if ( kapp->geometryArgument().isNull() ) // if there is no geometry, it doesn't mater |
185 | d->care_about_geometry = false; | 191 | d->care_about_geometry = false; |
186 | else | 192 | else |
187 | parseGeometry(false); | 193 | parseGeometry(false); |
188 | } | 194 | } |
189 | */ | 195 | */ |
190 | d->care_about_geometry = false; | 196 | d->care_about_geometry = false; |
191 | 197 | ||
192 | //US setCaption( kapp->caption() ); | 198 | //US setCaption( kapp->caption() ); |
193 | // attach dcop interface | 199 | // attach dcop interface |
194 | //US d->m_interface = new KMainWindowInterface(this); | 200 | //US d->m_interface = new KMainWindowInterface(this); |
195 | 201 | ||
196 | //US if (!kapp->authorize("movable_toolbars")) | 202 | //US if (!kapp->authorize("movable_toolbars")) |
197 | //US setDockWindowsMovable(false); | 203 | //US setDockWindowsMovable(false); |
198 | } | 204 | } |
199 | 205 | ||
200 | KAction *KMainWindow::toolBarMenuAction() | 206 | KAction *KMainWindow::toolBarMenuAction() |
201 | { | 207 | { |
202 | if ( !d->toolBarHandler ) | 208 | if ( !d->toolBarHandler ) |
203 | return 0; | 209 | return 0; |
204 | 210 | ||
205 | return d->toolBarHandler->toolBarMenuAction(); | 211 | return d->toolBarHandler->toolBarMenuAction(); |
206 | } | 212 | } |
207 | 213 | ||
208 | bool KMainWindow::canBeRestored( int number ) | 214 | bool KMainWindow::canBeRestored( int number ) |
209 | { | 215 | { |
210 | /*US we do not have and want to save sessioninformation. Use info from the default | 216 | /*US we do not have and want to save sessioninformation. Use info from the default |
211 | application config. | 217 | application config. |
212 | */ | 218 | */ |
213 | //US if ( !kapp->isRestored() ) | 219 | //US if ( !kapp->isRestored() ) |
214 | //US return FALSE; | 220 | //US return FALSE; |
215 | //US KConfig *config = kapp->sessionConfig(); | 221 | //US KConfig *config = kapp->sessionConfig(); |
216 | KConfig *config = KGlobal::config(); | 222 | KConfig *config = KGlobal::config(); |
217 | if ( !config ) | 223 | if ( !config ) |
218 | return FALSE; | 224 | return FALSE; |
219 | config->setGroup( QString::fromLatin1("Number") ); | 225 | config->setGroup( QString::fromLatin1("Number") ); |
220 | int n = config->readNumEntry( QString::fromLatin1("NumberOfWindows") , 1 ); | 226 | int n = config->readNumEntry( QString::fromLatin1("NumberOfWindows") , 1 ); |
221 | return number >= 1 && number <= n; | 227 | return number >= 1 && number <= n; |
222 | 228 | ||
223 | } | 229 | } |
224 | 230 | ||
225 | const QString KMainWindow::classNameOfToplevel( int number ) | 231 | const QString KMainWindow::classNameOfToplevel( int number ) |
226 | { | 232 | { |
227 | /*US we do not have and want to save sessioninformation. Use info from the default | 233 | /*US we do not have and want to save sessioninformation. Use info from the default |
228 | application config. | 234 | application config. |
229 | */ | 235 | */ |
230 | //US if ( !kapp->isRestored() ) | 236 | //US if ( !kapp->isRestored() ) |
231 | //US return QString::null; | 237 | //US return QString::null; |
232 | //US KConfig *config = kapp->sessionConfig(); | 238 | //US KConfig *config = kapp->sessionConfig(); |
233 | KConfig *config = KGlobal::config(); | 239 | KConfig *config = KGlobal::config(); |
234 | if ( !config ) | 240 | if ( !config ) |
235 | return QString::null; | 241 | return QString::null; |
236 | QString s; | 242 | QString s; |
237 | s.setNum( number ); | 243 | s.setNum( number ); |
238 | s.prepend( QString::fromLatin1("WindowProperties") ); | 244 | s.prepend( QString::fromLatin1("WindowProperties") ); |
239 | config->setGroup( s ); | 245 | config->setGroup( s ); |
240 | if ( !config->hasKey( QString::fromLatin1("ClassName") ) ) | 246 | if ( !config->hasKey( QString::fromLatin1("ClassName") ) ) |
241 | return QString::null; | 247 | return QString::null; |
242 | else | 248 | else |
243 | return config->readEntry( QString::fromLatin1("ClassName") ); | 249 | return config->readEntry( QString::fromLatin1("ClassName") ); |
244 | } | 250 | } |
245 | 251 | ||
246 | bool KMainWindow::restore( int number, bool show ) | 252 | bool KMainWindow::restore( int number, bool show ) |
247 | { | 253 | { |
248 | /*US we do not have and want to save sessioninformation. Use info from the default | 254 | /*US we do not have and want to save sessioninformation. Use info from the default |
249 | application config. | 255 | application config. |
250 | */ | 256 | */ |
251 | if ( !canBeRestored( number ) ) | 257 | if ( !canBeRestored( number ) ) |
252 | return FALSE; | 258 | return FALSE; |
253 | //US KConfig *config = kapp->sessionConfig(); | 259 | //US KConfig *config = kapp->sessionConfig(); |
254 | KConfig *config = KGlobal::config(); | 260 | KConfig *config = KGlobal::config(); |
255 | 261 | ||
256 | if ( readPropertiesInternal( config, number ) ){ | 262 | if ( readPropertiesInternal( config, number ) ){ |
257 | if ( show ) | 263 | if ( show ) |
258 | KMainWindow::show(); | 264 | KMainWindow::show(); |
259 | return FALSE; | 265 | return FALSE; |
260 | } | 266 | } |
261 | return FALSE; | 267 | return FALSE; |
262 | 268 | ||
263 | } | 269 | } |
264 | 270 | ||
265 | void KMainWindow::setCaption( const QString &caption ) | 271 | void KMainWindow::setCaption( const QString &caption ) |
266 | { | 272 | { |
267 | //US setPlainCaption( kapp->makeStdCaption(caption) ); | 273 | //US setPlainCaption( kapp->makeStdCaption(caption) ); |
268 | setPlainCaption( caption ); | 274 | setPlainCaption( caption ); |
269 | } | 275 | } |
270 | 276 | ||
271 | void KMainWindow::setCaption( const QString &caption, bool modified ) | 277 | void KMainWindow::setCaption( const QString &caption, bool modified ) |
272 | { | 278 | { |
273 | //US setPlainCaption( kapp->makeStdCaption(caption, true, modified) ); | 279 | //US setPlainCaption( kapp->makeStdCaption(caption, true, modified) ); |
274 | setPlainCaption( caption + "modified:" ); | 280 | setPlainCaption( caption + "modified:" ); |
275 | } | 281 | } |
276 | 282 | ||
277 | void KMainWindow::setPlainCaption( const QString &caption ) | 283 | void KMainWindow::setPlainCaption( const QString &caption ) |
278 | { | 284 | { |
279 | QMainWindow::setCaption( caption ); | 285 | Q3MainWindow::setCaption( caption ); |
280 | #ifndef Q_WS_QWS | 286 | #ifndef Q_WS_QWS |
281 | //US the following is disabled for the embedded version | 287 | //US the following is disabled for the embedded version |
282 | //US NETWinInfo info( qt_xdisplay(), winId(), qt_xrootwin(), 0 ); | 288 | //US NETWinInfo info( qt_xdisplay(), winId(), qt_xrootwin(), 0 ); |
283 | //US info.setName( caption.utf8().data() ); | 289 | //US info.setName( caption.utf8().data() ); |
284 | #endif | 290 | #endif |
285 | } | 291 | } |
286 | 292 | ||
287 | void KMainWindow::slotStateChanged(const QString &newstate) | 293 | void KMainWindow::slotStateChanged(const QString &newstate) |
288 | { | 294 | { |
289 | stateChanged(newstate, KXMLGUIClient::StateNoReverse); | 295 | stateChanged(newstate, KXMLGUIClient::StateNoReverse); |
290 | } | 296 | } |
291 | 297 | ||
292 | /* | 298 | /* |
293 | * Get rid of this for KDE 4.0 | 299 | * Get rid of this for KDE 4.0 |
294 | */ | 300 | */ |
295 | void KMainWindow::slotStateChanged(const QString &newstate, | 301 | void KMainWindow::slotStateChanged(const QString &newstate, |
296 | KXMLGUIClient::ReverseStateChange reverse) | 302 | KXMLGUIClient::ReverseStateChange reverse) |
297 | { | 303 | { |
298 | stateChanged(newstate, reverse); | 304 | stateChanged(newstate, reverse); |
299 | } | 305 | } |
300 | 306 | ||
301 | void KMainWindow::closeEvent ( QCloseEvent *e ) | 307 | void KMainWindow::closeEvent ( QCloseEvent *e ) |
302 | { | 308 | { |
303 | //qDebug("MainWindow::closeEvent "); | 309 | //qDebug("MainWindow::closeEvent "); |
304 | // Save settings if auto-save is enabled, and settings have changed | 310 | // Save settings if auto-save is enabled, and settings have changed |
305 | if (d->settingsDirty && d->autoSaveSettings) | 311 | if (d->settingsDirty && d->autoSaveSettings) |
306 | saveAutoSaveSettings(); | 312 | saveAutoSaveSettings(); |
307 | 313 | ||
308 | if (queryClose()) { | 314 | if (queryClose()) { |
309 | e->accept(); | 315 | e->accept(); |
310 | 316 | ||
311 | int not_withdrawn = 0; | 317 | int not_withdrawn = 0; |
312 | /*US | 318 | /*US |
313 | QPtrListIterator<KMainWindow> it(*KMainWindow::memberList); | 319 | QPtrListIterator<KMainWindow> it(*KMainWindow::memberList); |
314 | for (it.toFirst(); it.current(); ++it){ | 320 | for (it.toFirst(); it.current(); ++it){ |
315 | if ( !it.current()->isHidden() && it.current()->isTopLevel() && it.current() != this ) | 321 | if ( !it.current()->isHidden() && it.current()->isTopLevel() && it.current() != this ) |
316 | not_withdrawn++; | 322 | not_withdrawn++; |
317 | } | 323 | } |
318 | */ | 324 | */ |
319 | if ( !no_query_exit && not_withdrawn <= 0 ) { // last window close accepted? | 325 | if ( !no_query_exit && not_withdrawn <= 0 ) { // last window close accepted? |
320 | /*US | 326 | /*US |
321 | if ( queryExit() && !kapp->sessionSaving()) { // Yes, Quit app? | 327 | if ( queryExit() && !kapp->sessionSaving()) { // Yes, Quit app? |
322 | // don't call queryExit() twice | 328 | // don't call queryExit() twice |
323 | disconnect(kapp, SIGNAL(shutDown()), this, SLOT(shuttingDown())); | 329 | disconnect(kapp, SIGNAL(shutDown()), this, SLOT(shuttingDown())); |
324 | kapp->deref(); // ...and quit aplication. | 330 | kapp->deref(); // ...and quit aplication. |
325 | } else { | 331 | } else { |
326 | // cancel closing, it's stupid to end up with no windows at all.... | 332 | // cancel closing, it's stupid to end up with no windows at all.... |
327 | e->ignore(); | 333 | e->ignore(); |
328 | } | 334 | } |
329 | */ | 335 | */ |
330 | //US we have no sessionmanagement. Simply close app. | 336 | //US we have no sessionmanagement. Simply close app. |
331 | if ( queryExit() ) { // Yes, Quit app? | 337 | if ( queryExit() ) { // Yes, Quit app? |
332 | qDebug("KMainWindow::closeEvent: Exit application ???"); | 338 | qDebug("KMainWindow::closeEvent: Exit application ???"); |
333 | // don't call queryExit() twice | 339 | // don't call queryExit() twice |
334 | //US disconnect(kapp, SIGNAL(shutDown()), this, SLOT(shuttingDown())); | 340 | //US disconnect(kapp, SIGNAL(shutDown()), this, SLOT(shuttingDown())); |
335 | } | 341 | } |
336 | 342 | ||
337 | } | 343 | } |
338 | } | 344 | } |
339 | } | 345 | } |
340 | 346 | ||
341 | bool KMainWindow::queryExit() | 347 | bool KMainWindow::queryExit() |
342 | { | 348 | { |
343 | return TRUE; | 349 | return TRUE; |
344 | } | 350 | } |
345 | 351 | ||
346 | bool KMainWindow::queryClose() | 352 | bool KMainWindow::queryClose() |
347 | { | 353 | { |
348 | return TRUE; | 354 | return TRUE; |
349 | } | 355 | } |
350 | 356 | ||
351 | void KMainWindow::saveGlobalProperties( KConfig* ) | 357 | void KMainWindow::saveGlobalProperties( KConfig* ) |
352 | { | 358 | { |
353 | } | 359 | } |
354 | 360 | ||
355 | void KMainWindow::readGlobalProperties( KConfig* ) | 361 | void KMainWindow::readGlobalProperties( KConfig* ) |
356 | { | 362 | { |
357 | } | 363 | } |
358 | 364 | ||
359 | void KMainWindow::savePropertiesInternal( KConfig *config, int number ) | 365 | void KMainWindow::savePropertiesInternal( KConfig *config, int number ) |
360 | { | 366 | { |
361 | bool oldASWS = d->autoSaveWindowSize; | 367 | bool oldASWS = d->autoSaveWindowSize; |
362 | d->autoSaveWindowSize = true; // make saveMainWindowSettings save the window size | 368 | d->autoSaveWindowSize = true; // make saveMainWindowSettings save the window size |
363 | 369 | ||
364 | QString s; | 370 | QString s; |
365 | s.setNum(number); | 371 | s.setNum(number); |
366 | s.prepend(QString::fromLatin1("WindowProperties")); | 372 | s.prepend(QString::fromLatin1("WindowProperties")); |
367 | config->setGroup(s); | 373 | config->setGroup(s); |
368 | 374 | ||
369 | // store objectName, className, Width and Height for later restoring | 375 | // store objectName, className, Width and Height for later restoring |
370 | // (Only useful for session management) | 376 | // (Only useful for session management) |
371 | config->writeEntry(QString::fromLatin1("ObjectName"), name()); | 377 | config->writeEntry(QString::fromLatin1("ObjectName"), name()); |
372 | config->writeEntry(QString::fromLatin1("ClassName"), className()); | 378 | config->writeEntry(QString::fromLatin1("ClassName"), className()); |
373 | 379 | ||
374 | saveMainWindowSettings(config); // Menubar, statusbar and Toolbar settings. | 380 | saveMainWindowSettings(config); // Menubar, statusbar and Toolbar settings. |
375 | 381 | ||
376 | s.setNum(number); | 382 | s.setNum(number); |
377 | config->setGroup(s); | 383 | config->setGroup(s); |
378 | saveProperties(config); | 384 | saveProperties(config); |
379 | 385 | ||
380 | d->autoSaveWindowSize = oldASWS; | 386 | d->autoSaveWindowSize = oldASWS; |
381 | } | 387 | } |
382 | 388 | ||
383 | void KMainWindow::setStandardToolBarMenuEnabled( bool enable ) | 389 | void KMainWindow::setStandardToolBarMenuEnabled( bool enable ) |
384 | { | 390 | { |
385 | if ( enable ) | 391 | if ( enable ) |
386 | { | 392 | { |
387 | if ( d->toolBarHandler ) | 393 | if ( d->toolBarHandler ) |
388 | return; | 394 | return; |
389 | 395 | ||
390 | d->toolBarHandler = new KDEPrivate::ToolBarHandler( this ); | 396 | d->toolBarHandler = new KDEPrivate::ToolBarHandler( this ); |
391 | 397 | ||
392 | /*US if ( factory() ) | 398 | /*US if ( factory() ) |
393 | factory()->addClient( d->toolBarHandler ); | 399 | factory()->addClient( d->toolBarHandler ); |
394 | */ | 400 | */ |
395 | } | 401 | } |
396 | else | 402 | else |
397 | { | 403 | { |
398 | if ( !d->toolBarHandler ) | 404 | if ( !d->toolBarHandler ) |
399 | return; | 405 | return; |
400 | /*US | 406 | /*US |
401 | if ( factory() ) | 407 | if ( factory() ) |
402 | factory()->removeClient( d->toolBarHandler ); | 408 | factory()->removeClient( d->toolBarHandler ); |
403 | */ | 409 | */ |
404 | delete d->toolBarHandler; | 410 | delete d->toolBarHandler; |
405 | d->toolBarHandler = 0; | 411 | d->toolBarHandler = 0; |
406 | } | 412 | } |
407 | 413 | ||
408 | } | 414 | } |
409 | 415 | ||
410 | bool KMainWindow::isStandardToolBarMenuEnabled() const | 416 | bool KMainWindow::isStandardToolBarMenuEnabled() const |
411 | { | 417 | { |
412 | return ( d->toolBarHandler != 0 ); | 418 | return ( d->toolBarHandler != 0 ); |
413 | } | 419 | } |
414 | 420 | ||
415 | void KMainWindow::createStandardStatusBarAction(){ | 421 | void KMainWindow::createStandardStatusBarAction(){ |
416 | if(!d->showStatusBarAction){ | 422 | if(!d->showStatusBarAction){ |
417 | d->showStatusBarAction = KStdAction::showStatusbar(this, SLOT(setSettingsDirty()), actionCollection()); | 423 | d->showStatusBarAction = KStdAction::showStatusbar(this, SLOT(setSettingsDirty()), actionCollection()); |
418 | connect(d->showStatusBarAction, SIGNAL(toggled(bool)), statusBar(), SLOT(setShown(bool))); | 424 | connect(d->showStatusBarAction, SIGNAL(toggled(bool)), statusBar(), SLOT(setShown(bool))); |
419 | if(internalStatusBar()) | 425 | if(internalStatusBar()) |
420 | d->showStatusBarAction->setChecked(!internalStatusBar()->isHidden()); | 426 | d->showStatusBarAction->setChecked(!internalStatusBar()->isHidden()); |
421 | } | 427 | } |
422 | } | 428 | } |
423 | 429 | ||
424 | QToolBar *KMainWindow::tBar( ) | 430 | Q3ToolBar *KMainWindow::tBar( ) |
425 | { | 431 | { |
426 | if ( ! mQToolBar ) | 432 | if ( ! mQToolBar ) |
427 | mQToolBar = new QToolBar( this ); | 433 | mQToolBar = new Q3ToolBar( this ); |
428 | return mQToolBar; | 434 | return mQToolBar; |
429 | } | 435 | } |
430 | 436 | ||
431 | KToolBar *KMainWindow::toolBar( const char * name ) | 437 | KToolBar *KMainWindow::toolBar( const char * name ) |
432 | { | 438 | { |
433 | 439 | ||
434 | if (!name) | 440 | if (!name) |
435 | name = "mainToolBar"; | 441 | name = "mainToolBar"; |
436 | KToolBar *tb = (KToolBar*)child( name, "KToolBar" ); | 442 | KToolBar *tb = (KToolBar*)child( name, "KToolBar" ); |
437 | if ( tb ) | 443 | if ( tb ) |
438 | return tb; | 444 | return tb; |
439 | bool honor_mode = (name == "mainToolBar"); | 445 | bool honor_mode = (name == "mainToolBar"); |
440 | 446 | ||
441 | /*US | 447 | /*US |
442 | if ( builderClient() ) | 448 | if ( builderClient() ) |
443 | return new KToolBar(this, name, honor_mode); // XMLGUI constructor | 449 | return new KToolBar(this, name, honor_mode); // XMLGUI constructor |
444 | else | 450 | else |
445 | */ | 451 | */ |
446 | return new KToolBar(this, Top, false, name, honor_mode ); // non-XMLGUI | 452 | return new KToolBar(this, Qt::Top, false, name, honor_mode ); // non-XMLGUI |
447 | } | 453 | } |
448 | 454 | ||
449 | QPtrListIterator<KToolBar> KMainWindow::toolBarIterator() | 455 | Q3PtrListIterator<KToolBar> KMainWindow::toolBarIterator() |
450 | { | 456 | { |
451 | toolbarList.clear(); | 457 | toolbarList.clear(); |
452 | QPtrList<QToolBar> lst; | 458 | QList<Q3ToolBar*> lst; |
453 | for ( int i = (int)QMainWindow::Unmanaged; i <= (int)Minimized; ++i ) { | 459 | for ( int i = (int)Qt::Unmanaged; i <= (int)Qt::Minimized; ++i ) { |
454 | lst = toolBars( (ToolBarDock)i ); | 460 | lst = toolBars( (Qt::ToolBarDock)i ); |
455 | for ( QToolBar *tb = lst.first(); tb; tb = lst.next() ) { | 461 | for(QList<Q3ToolBar*>::iterator i=lst.begin();i!=lst.end();++i) { |
462 | Q3ToolBar *tb = *i; | ||
456 | if ( !tb->inherits( "KToolBar" ) ) | 463 | if ( !tb->inherits( "KToolBar" ) ) |
457 | continue; | 464 | continue; |
458 | toolbarList.append( (KToolBar*)tb ); | 465 | toolbarList.append( (KToolBar*)tb ); |
459 | } | 466 | } |
460 | } | 467 | } |
461 | return QPtrListIterator<KToolBar>( toolbarList ); | 468 | return Q3PtrListIterator<KToolBar>( toolbarList ); |
462 | } | 469 | } |
463 | 470 | ||
464 | void KMainWindow::setAutoSaveSettings( const QString & groupName, bool saveWindowSize ) | 471 | void KMainWindow::setAutoSaveSettings( const QString & groupName, bool saveWindowSize ) |
465 | { | 472 | { |
466 | d->autoSaveSettings = true; | 473 | d->autoSaveSettings = true; |
467 | d->autoSaveGroup = groupName; | 474 | d->autoSaveGroup = groupName; |
468 | d->autoSaveWindowSize = saveWindowSize; | 475 | d->autoSaveWindowSize = saveWindowSize; |
469 | // Get notified when the user moves a toolbar around | 476 | // Get notified when the user moves a toolbar around |
470 | //US connect( this, SIGNAL( dockWindowPositionChanged( QDockWindow * ) ), | 477 | //US connect( this, SIGNAL( dockWindowPositionChanged( QDockWindow * ) ), |
471 | //US this, SLOT( setSettingsDirty() ) ); | 478 | //US this, SLOT( setSettingsDirty() ) ); |
472 | connect( this, SIGNAL( toolBarPositionChanged(QToolBar *) ), | 479 | connect( this, SIGNAL( toolBarPositionChanged(Q3ToolBar *) ), |
473 | this, SLOT( setSettingsDirty() ) ); | 480 | this, SLOT( setSettingsDirty() ) ); |
474 | 481 | ||
475 | 482 | ||
476 | // Get default values | 483 | // Get default values |
477 | //US int scnum = QApplication::desktop()->screenNumber(parentWidget()); | 484 | //US int scnum = QApplication::desktop()->screenNumber(parentWidget()); |
478 | //US QRect desk = QApplication::desktop()->screenGeometry(scnum); | 485 | //US QRect desk = QApplication::desktop()->screenGeometry(scnum); |
479 | QRect desk = KGlobalSettings::desktopGeometry(0); | 486 | QRect desk = KGlobalSettings::desktopGeometry(0); |
480 | 487 | ||
481 | d->defaultWindowSize = QRect(desk.width(), width(), desk.height(), height()); | 488 | d->defaultWindowSize = QRect(desk.width(), width(), desk.height(), height()); |
482 | // Now read the previously saved settings | 489 | // Now read the previously saved settings |
483 | applyMainWindowSettings( KGlobal::config(), groupName ); | 490 | applyMainWindowSettings( KGlobal::config(), groupName ); |
484 | } | 491 | } |
485 | 492 | ||
486 | 493 | ||
487 | void KMainWindow::resetAutoSaveSettings() | 494 | void KMainWindow::resetAutoSaveSettings() |
488 | { | 495 | { |
489 | d->autoSaveSettings = false; | 496 | d->autoSaveSettings = false; |
490 | if ( d->settingsTimer ) | 497 | if ( d->settingsTimer ) |
491 | d->settingsTimer->stop(); | 498 | d->settingsTimer->stop(); |
492 | } | 499 | } |
493 | 500 | ||
494 | bool KMainWindow::autoSaveSettings() const | 501 | bool KMainWindow::autoSaveSettings() const |
495 | { | 502 | { |
496 | return d->autoSaveSettings; | 503 | return d->autoSaveSettings; |
497 | } | 504 | } |
498 | 505 | ||
499 | QString KMainWindow::autoSaveGroup() const | 506 | QString KMainWindow::autoSaveGroup() const |
500 | { | 507 | { |
501 | return d->autoSaveGroup; | 508 | return d->autoSaveGroup; |
502 | } | 509 | } |
503 | 510 | ||
504 | void KMainWindow::saveAutoSaveSettings() | 511 | void KMainWindow::saveAutoSaveSettings() |
505 | { | 512 | { |
506 | ASSERT( d->autoSaveSettings ); | 513 | Q_ASSERT( d->autoSaveSettings ); |
507 | //kdDebug(200) << "KMainWindow::saveAutoSaveSettings -> saving settings" << endl; | 514 | //kdDebug(200) << "KMainWindow::saveAutoSaveSettings -> saving settings" << endl; |
508 | saveMainWindowSettings( KGlobal::config(), d->autoSaveGroup ); | 515 | saveMainWindowSettings( KGlobal::config(), d->autoSaveGroup ); |
509 | KGlobal::config()->sync(); | 516 | KGlobal::config()->sync(); |
510 | d->settingsDirty = false; | 517 | d->settingsDirty = false; |
511 | if ( d->settingsTimer ) | 518 | if ( d->settingsTimer ) |
512 | d->settingsTimer->stop(); | 519 | d->settingsTimer->stop(); |
513 | } | 520 | } |
514 | 521 | ||
515 | void KMainWindow::createGUI( const QString &xmlfile, bool _conserveMemory ) | 522 | void KMainWindow::createGUI( const QString &xmlfile, bool _conserveMemory ) |
516 | { | 523 | { |
517 | // disabling the updates prevents unnecessary redraws | 524 | // disabling the updates prevents unnecessary redraws |
518 | setUpdatesEnabled( false ); | 525 | setUpdatesEnabled( false ); |
519 | 526 | ||
520 | // just in case we are rebuilding, let's remove our old client | 527 | // just in case we are rebuilding, let's remove our old client |
521 | //US guiFactory()->removeClient( this ); | 528 | //US guiFactory()->removeClient( this ); |
522 | 529 | ||
523 | // make sure to have an empty GUI | 530 | // make sure to have an empty GUI |
524 | QMenuBar* mb = internalMenuBar(); | 531 | QMenuBar* mb = internalMenuBar(); |
525 | if ( mb ) | 532 | if ( mb ) |
526 | mb->clear(); | 533 | mb->clear(); |
527 | 534 | ||
528 | (void)toolBarIterator(); // make sure toolbarList is most-up-to-date | 535 | (void)toolBarIterator(); // make sure toolbarList is most-up-to-date |
529 | toolbarList.setAutoDelete( true ); | 536 | toolbarList.setAutoDelete( true ); |
530 | toolbarList.clear(); | 537 | toolbarList.clear(); |
531 | toolbarList.setAutoDelete( false ); | 538 | toolbarList.setAutoDelete( false ); |
532 | /*US | 539 | /*US |
533 | // don't build a help menu unless the user ask for it | 540 | // don't build a help menu unless the user ask for it |
534 | if (d->showHelpMenu) { | 541 | if (d->showHelpMenu) { |
535 | // we always want a help menu | 542 | // we always want a help menu |
536 | if (helpMenu2 == 0) | 543 | if (helpMenu2 == 0) |
537 | helpMenu2 = new KHelpMenu(this, instance()->aboutData(), true, | 544 | helpMenu2 = new KHelpMenu(this, instance()->aboutData(), true, |
538 | actionCollection()); | 545 | actionCollection()); |
539 | } | 546 | } |
540 | 547 | ||
541 | // we always want to load in our global standards file | 548 | // we always want to load in our global standards file |
542 | setXMLFile( locate( "config", "ui/ui_standards.rc", instance() ) ); | 549 | setXMLFile( locate( "config", "ui/ui_standards.rc", instance() ) ); |
543 | 550 | ||
544 | // now, merge in our local xml file. if this is null, then that | 551 | // now, merge in our local xml file. if this is null, then that |
545 | // means that we will be only using the global file | 552 | // means that we will be only using the global file |
546 | if ( !xmlfile.isNull() ) { | 553 | if ( !xmlfile.isNull() ) { |
547 | setXMLFile( xmlfile, true ); | 554 | setXMLFile( xmlfile, true ); |
548 | } else { | 555 | } else { |
549 | QString auto_file(instance()->instanceName() + "ui.rc"); | 556 | QString auto_file(instance()->instanceName() + "ui.rc"); |
550 | setXMLFile( auto_file, true ); | 557 | setXMLFile( auto_file, true ); |
551 | } | 558 | } |
552 | 559 | ||
553 | // make sure we don't have any state saved already | 560 | // make sure we don't have any state saved already |
554 | setXMLGUIBuildDocument( QDomDocument() ); | 561 | setXMLGUIBuildDocument( QDomDocument() ); |
555 | 562 | ||
556 | // do the actual GUI building | 563 | // do the actual GUI building |
557 | guiFactory()->addClient( this ); | 564 | guiFactory()->addClient( this ); |
558 | 565 | ||
559 | // try and get back *some* of our memory | 566 | // try and get back *some* of our memory |
560 | if ( _conserveMemory ) | 567 | if ( _conserveMemory ) |
561 | { | 568 | { |
562 | // before freeing the memory allocated by the DOM document we also | 569 | // before freeing the memory allocated by the DOM document we also |
563 | // free all memory allocated internally in the KXMLGUIFactory for | 570 | // free all memory allocated internally in the KXMLGUIFactory for |
564 | // the menubar and the toolbars . This however implies that we | 571 | // the menubar and the toolbars . This however implies that we |
565 | // have to take care of deleting those widgets ourselves. For | 572 | // have to take care of deleting those widgets ourselves. For |
566 | // destruction this is no problem, but when rebuilding we have | 573 | // destruction this is no problem, but when rebuilding we have |
567 | // to take care of that (and we want to rebuild the GUI when | 574 | // to take care of that (and we want to rebuild the GUI when |
568 | // using stuff like the toolbar editor ). | 575 | // using stuff like the toolbar editor ). |
569 | // In addition we have to take care of not removing containers | 576 | // In addition we have to take care of not removing containers |
570 | // like popupmenus, defined in the XML document. | 577 | // like popupmenus, defined in the XML document. |
571 | // this code should probably go into a separate method in KMainWindow. | 578 | // this code should probably go into a separate method in KMainWindow. |
572 | // there's just one problem: I'm bad in finding names ;-) , so | 579 | // there's just one problem: I'm bad in finding names ;-) , so |
573 | // I skipped this ;-) | 580 | // I skipped this ;-) |
574 | 581 | ||
575 | QDomDocument doc = domDocument(); | 582 | QDomDocument doc = domDocument(); |
576 | 583 | ||
577 | QDomElement e = doc.documentElement().firstChild().toElement(); | 584 | QDomElement e = doc.documentElement().firstChild().toElement(); |
578 | for (; !e.isNull(); e = e.nextSibling().toElement() ) { | 585 | for (; !e.isNull(); e = e.nextSibling().toElement() ) { |
579 | if ( e.tagName().lower() == "toolbar" ) | 586 | if ( e.tagName().lower() == "toolbar" ) |
580 | factory_->resetContainer( e.attribute( "name" ) ); | 587 | factory_->resetContainer( e.attribute( "name" ) ); |
581 | else if ( e.tagName().lower() == "menubar" ) | 588 | else if ( e.tagName().lower() == "menubar" ) |
582 | factory_->resetContainer( e.tagName(), true ); | 589 | factory_->resetContainer( e.tagName(), true ); |
583 | } | 590 | } |
584 | 591 | ||
585 | conserveMemory(); | 592 | conserveMemory(); |
586 | } | 593 | } |
587 | */ | 594 | */ |
588 | setUpdatesEnabled( true ); | 595 | setUpdatesEnabled( true ); |
589 | updateGeometry(); | 596 | updateGeometry(); |
590 | } | 597 | } |
591 | 598 | ||
592 | void KMainWindow::saveMainWindowSettings(KConfig *config, const QString &configGroup) | 599 | void KMainWindow::saveMainWindowSettings(KConfig *config, const QString &configGroup) |
593 | { | 600 | { |
594 | kdDebug(200) << "KMainWindow::saveMainWindowSettings " << configGroup << endl; | 601 | kdDebug(200) << "KMainWindow::saveMainWindowSettings " << configGroup << endl; |
595 | //US QStrList entryList; | 602 | //US QStrList entryList; |
596 | QStringList entryList; | 603 | QStringList entryList; |
597 | QString oldGroup; | 604 | QString oldGroup; |
598 | 605 | ||
599 | if (!configGroup.isEmpty()) | 606 | if (!configGroup.isEmpty()) |
600 | { | 607 | { |
601 | oldGroup = config->group(); | 608 | oldGroup = config->group(); |
602 | config->setGroup(configGroup); | 609 | config->setGroup(configGroup); |
603 | } | 610 | } |
604 | 611 | ||
605 | // Called by session management - or if we want to save the window size anyway | 612 | // Called by session management - or if we want to save the window size anyway |
606 | if ( d->autoSaveWindowSize ) | 613 | if ( d->autoSaveWindowSize ) |
607 | saveWindowSize( config ); | 614 | saveWindowSize( config ); |
608 | 615 | ||
609 | QStatusBar* sb = internalStatusBar(); | 616 | QStatusBar* sb = internalStatusBar(); |
610 | if (sb) { | 617 | if (sb) { |
611 | entryList.clear(); | 618 | entryList.clear(); |
612 | if ( sb->isHidden() ) | 619 | if ( sb->isHidden() ) |
613 | entryList.append("Disabled"); | 620 | entryList.append("Disabled"); |
614 | else | 621 | else |
615 | entryList.append("Enabled"); | 622 | entryList.append("Enabled"); |
616 | 623 | ||
617 | if(sb->isHidden()) | 624 | if(sb->isHidden()) |
618 | //US config->writeEntry(QString::fromLatin1("StatusBar"), entryList, ';'); | 625 | //US config->writeEntry(QString::fromLatin1("StatusBar"), entryList, ';'); |
619 | config->writeEntry(QString::fromLatin1("StatusBar"), entryList); | 626 | config->writeEntry(QString::fromLatin1("StatusBar"), entryList); |
620 | else | 627 | else |
621 | config->deleteEntry(QString::fromLatin1("StatusBar")); | 628 | config->deleteEntry(QString::fromLatin1("StatusBar")); |
622 | } | 629 | } |
623 | 630 | ||
624 | QMenuBar* mb = internalMenuBar(); | 631 | QMenuBar* mb = internalMenuBar(); |
625 | if (mb) { | 632 | if (mb) { |
626 | entryList.clear(); | 633 | entryList.clear(); |
627 | if ( mb->isHidden() ) | 634 | if ( mb->isHidden() ) |
628 | entryList.append("Disabled"); | 635 | entryList.append("Disabled"); |
629 | else | 636 | else |
630 | entryList.append("Enabled"); | 637 | entryList.append("Enabled"); |
631 | 638 | ||
632 | // By default we don't hide. | 639 | // By default we don't hide. |
633 | if(mb->isHidden()) | 640 | if(mb->isHidden()) |
634 | //US config->writeEntry(QString::fromLatin1("MenuBar"), entryList, ';'); | 641 | //US config->writeEntry(QString::fromLatin1("MenuBar"), entryList, ';'); |
635 | config->writeEntry(QString::fromLatin1("MenuBar"), entryList); | 642 | config->writeEntry(QString::fromLatin1("MenuBar"), entryList); |
636 | else | 643 | else |
637 | config->deleteEntry(QString::fromLatin1("MenuBar")); | 644 | config->deleteEntry(QString::fromLatin1("MenuBar")); |
638 | } | 645 | } |
639 | 646 | ||
640 | int n = 1; // Toolbar counter. toolbars are counted from 1, | 647 | int n = 1; // Toolbar counter. toolbars are counted from 1, |
641 | KToolBar *toolbar = 0; | 648 | KToolBar *toolbar = 0; |
642 | QPtrListIterator<KToolBar> it( toolBarIterator() ); | 649 | Q3PtrListIterator<KToolBar> it( toolBarIterator() ); |
643 | while ( ( toolbar = it.current() ) ) { | 650 | while ( ( toolbar = it.current() ) ) { |
644 | ++it; | 651 | ++it; |
645 | QString group; | 652 | QString group; |
646 | if (!configGroup.isEmpty()) | 653 | if (!configGroup.isEmpty()) |
647 | { | 654 | { |
648 | // Give a number to the toolbar, but prefer a name if there is one, | 655 | // Give a number to the toolbar, but prefer a name if there is one, |
649 | // because there's no real guarantee on the ordering of toolbars | 656 | // because there's no real guarantee on the ordering of toolbars |
650 | group = (!::qstrcmp(toolbar->name(), "unnamed") ? QString::number(n) : QString(" ")+toolbar->name()); | 657 | group = (!::qstrcmp(toolbar->name(), "unnamed") ? QString::number(n) : QString(" ")+toolbar->name()); |
651 | group.prepend(" Toolbar"); | 658 | group.prepend(" Toolbar"); |
652 | group.prepend(configGroup); | 659 | group.prepend(configGroup); |
653 | } | 660 | } |
654 | toolbar->saveSettings(config, group); | 661 | toolbar->saveSettings(config, group); |
655 | n++; | 662 | n++; |
656 | } | 663 | } |
657 | if (!configGroup.isEmpty()) | 664 | if (!configGroup.isEmpty()) |
658 | config->setGroup(oldGroup); | 665 | config->setGroup(oldGroup); |
659 | } | 666 | } |
660 | 667 | ||
661 | bool KMainWindow::readPropertiesInternal( KConfig *config, int number ) | 668 | bool KMainWindow::readPropertiesInternal( KConfig *config, int number ) |
662 | { | 669 | { |
663 | if ( number == 1 ) | 670 | if ( number == 1 ) |
664 | readGlobalProperties( config ); | 671 | readGlobalProperties( config ); |
665 | 672 | ||
666 | // in order they are in toolbar list | 673 | // in order they are in toolbar list |
667 | QString s; | 674 | QString s; |
668 | s.setNum(number); | 675 | s.setNum(number); |
669 | s.prepend(QString::fromLatin1("WindowProperties")); | 676 | s.prepend(QString::fromLatin1("WindowProperties")); |
670 | 677 | ||
671 | config->setGroup(s); | 678 | config->setGroup(s); |
672 | 679 | ||
673 | // restore the object name (window role) | 680 | // restore the object name (window role) |
674 | if ( config->hasKey(QString::fromLatin1("ObjectName" )) ) | 681 | if ( config->hasKey(QString::fromLatin1("ObjectName" )) ) |
675 | setName( config->readEntry(QString::fromLatin1("ObjectName")).latin1()); // latin1 is right here | 682 | setName( config->readEntry(QString::fromLatin1("ObjectName")).latin1()); // latin1 is right here |
676 | 683 | ||
677 | applyMainWindowSettings(config); // Menubar, statusbar and toolbar settings. | 684 | applyMainWindowSettings(config); // Menubar, statusbar and toolbar settings. |
678 | 685 | ||
679 | s.setNum(number); | 686 | s.setNum(number); |
680 | config->setGroup(s); | 687 | config->setGroup(s); |
681 | readProperties(config); | 688 | readProperties(config); |
682 | return true; | 689 | return true; |
683 | } | 690 | } |
684 | 691 | ||
685 | void KMainWindow::applyMainWindowSettings(KConfig *config, const QString &configGroup) | 692 | void KMainWindow::applyMainWindowSettings(KConfig *config, const QString &configGroup) |
686 | { | 693 | { |
687 | kdDebug(200) << "KMainWindow::applyMainWindowSettings" << endl; | 694 | kdDebug(200) << "KMainWindow::applyMainWindowSettings" << endl; |
688 | QString entry; | 695 | QString entry; |
689 | //US QStrList entryList; | 696 | //US QStrList entryList; |
690 | QStringList entryList; | 697 | QStringList entryList; |
691 | int i = 0; // Number of entries in list | 698 | int i = 0; // Number of entries in list |
692 | 699 | ||
693 | if (!configGroup.isEmpty()) | 700 | if (!configGroup.isEmpty()) |
694 | config->setGroup(configGroup); | 701 | config->setGroup(configGroup); |
695 | 702 | ||
696 | restoreWindowSize(config); | 703 | restoreWindowSize(config); |
697 | 704 | ||
698 | QStatusBar* sb = internalStatusBar(); | 705 | QStatusBar* sb = internalStatusBar(); |
699 | if (sb) { | 706 | if (sb) { |
700 | entryList.clear(); | 707 | entryList.clear(); |
701 | //US i = config->readListEntry (QString::fromLatin1("StatusBar"), entryList, ';'); | 708 | //US i = config->readListEntry (QString::fromLatin1("StatusBar"), entryList, ';'); |
702 | entryList = config->readListEntry (QString::fromLatin1("StatusBar")); | 709 | entryList = config->readListEntry (QString::fromLatin1("StatusBar")); |
703 | entry = entryList.first(); | 710 | entry = entryList.first(); |
704 | if (entry == QString::fromLatin1("Disabled")) | 711 | if (entry == QString::fromLatin1("Disabled")) |
705 | sb->hide(); | 712 | sb->hide(); |
706 | else | 713 | else |
707 | sb->show(); | 714 | sb->show(); |
708 | if(d->showStatusBarAction) | 715 | if(d->showStatusBarAction) |
709 | d->showStatusBarAction->setChecked(!sb->isHidden()); | 716 | d->showStatusBarAction->setChecked(!sb->isHidden()); |
710 | } | 717 | } |
711 | 718 | ||
712 | QMenuBar* mb = internalMenuBar(); | 719 | QMenuBar* mb = internalMenuBar(); |
713 | if (mb) { | 720 | if (mb) { |
714 | entryList.clear(); | 721 | entryList.clear(); |
715 | //US i = config->readListEntry (QString::fromLatin1("MenuBar"), entryList, ';'); | 722 | //US i = config->readListEntry (QString::fromLatin1("MenuBar"), entryList, ';'); |
716 | entryList = config->readListEntry (QString::fromLatin1("MenuBar")); | 723 | entryList = config->readListEntry (QString::fromLatin1("MenuBar")); |
717 | entry = entryList.first(); | 724 | if(!entryList.empty()) { |
718 | if (entry==QString::fromLatin1("Disabled")) | 725 | entry = entryList.first(); |
719 | { | 726 | if (entry==QString::fromLatin1("Disabled")) |
720 | mb->hide(); | 727 | { |
721 | } else | 728 | mb->hide(); |
722 | { | 729 | } else |
723 | mb->show(); | 730 | { |
724 | } | 731 | mb->show(); |
732 | } | ||
733 | } | ||
725 | } | 734 | } |
726 | 735 | ||
727 | int n = 1; // Toolbar counter. toolbars are counted from 1, | 736 | int n = 1; // Toolbar counter. toolbars are counted from 1, |
728 | KToolBar *toolbar; | 737 | KToolBar *toolbar; |
729 | QPtrListIterator<KToolBar> it( toolBarIterator() ); // must use own iterator | 738 | Q3PtrListIterator<KToolBar> it( toolBarIterator() ); // must use own iterator |
730 | 739 | ||
731 | for ( ; it.current(); ++it) { | 740 | for ( ; it.current(); ++it) { |
732 | toolbar= it.current(); | 741 | toolbar= it.current(); |
733 | QString group; | 742 | QString group; |
734 | if (!configGroup.isEmpty()) | 743 | if (!configGroup.isEmpty()) |
735 | { | 744 | { |
736 | // Give a number to the toolbar, but prefer a name if there is one, | 745 | // Give a number to the toolbar, but prefer a name if there is one, |
737 | // because there's no real guarantee on the ordering of toolbars | 746 | // because there's no real guarantee on the ordering of toolbars |
738 | group = (!::qstrcmp(toolbar->name(), "unnamed") ? QString::number(n) : QString(" ")+toolbar->name()); | 747 | group = (!::qstrcmp(toolbar->name(), "unnamed") ? QString::number(n) : QString(" ")+toolbar->name()); |
739 | group.prepend(" Toolbar"); | 748 | group.prepend(" Toolbar"); |
740 | group.prepend(configGroup); | 749 | group.prepend(configGroup); |
741 | } | 750 | } |
742 | toolbar->applySettings(config, group); | 751 | toolbar->applySettings(config, group); |
743 | n++; | 752 | n++; |
744 | } | 753 | } |
745 | 754 | ||
746 | finalizeGUI( true ); | 755 | finalizeGUI( true ); |
747 | } | 756 | } |
748 | 757 | ||
749 | void KMainWindow::finalizeGUI( bool force ) | 758 | void KMainWindow::finalizeGUI( bool force ) |
750 | { | 759 | { |
751 | //kdDebug(200) << "KMainWindow::finalizeGUI force=" << force << endl; | 760 | //kdDebug(200) << "KMainWindow::finalizeGUI force=" << force << endl; |
752 | // The whole reason for this is that moveToolBar relies on the indexes | 761 | // The whole reason for this is that moveToolBar relies on the indexes |
753 | // of the other toolbars, so in theory it should be called only once per | 762 | // of the other toolbars, so in theory it should be called only once per |
754 | // toolbar, but in increasing order of indexes. | 763 | // toolbar, but in increasing order of indexes. |
755 | // Since we can't do that immediately, we move them, and _then_ | 764 | // Since we can't do that immediately, we move them, and _then_ |
756 | // we call positionYourself again for each of them, but this time | 765 | // we call positionYourself again for each of them, but this time |
757 | // the toolbariterator should give them in the proper order. | 766 | // the toolbariterator should give them in the proper order. |
758 | // Both the XMLGUI and applySettings call this, hence "force" for the latter. | 767 | // Both the XMLGUI and applySettings call this, hence "force" for the latter. |
759 | QPtrListIterator<KToolBar> it( toolBarIterator() ); | 768 | Q3PtrListIterator<KToolBar> it( toolBarIterator() ); |
760 | for ( ; it.current() ; ++ it ) | 769 | for ( ; it.current() ; ++ it ) |
761 | it.current()->positionYourself( force ); | 770 | it.current()->positionYourself( force ); |
762 | 771 | ||
763 | d->settingsDirty = false; | 772 | d->settingsDirty = false; |
764 | } | 773 | } |
765 | 774 | ||
766 | void KMainWindow::saveWindowSize( KConfig * config ) const | 775 | void KMainWindow::saveWindowSize( KConfig * config ) const |
767 | { | 776 | { |
768 | /*US | 777 | /*US |
769 | int scnum = QApplication::desktop()->screenNumber(parentWidget()); | 778 | int scnum = QApplication::desktop()->screenNumber(parentWidget()); |
770 | QRect desk = QApplication::desktop()->screenGeometry(scnum); | 779 | QRect desk = QApplication::desktop()->screenGeometry(scnum); |
771 | */ | 780 | */ |
772 | QRect desk = KGlobalSettings::desktopGeometry(0); | 781 | QRect desk = KGlobalSettings::desktopGeometry(0); |
773 | 782 | ||
774 | QRect size( desk.width(), width(), desk.height(), height() ); | 783 | QRect size( desk.width(), width(), desk.height(), height() ); |
775 | if(size != d->defaultWindowSize){ | 784 | if(size != d->defaultWindowSize){ |
776 | config->writeEntry(QString::fromLatin1("Width %1").arg(desk.width()), width() ); | 785 | config->writeEntry(QString::fromLatin1("Width %1").arg(desk.width()), width() ); |
777 | config->writeEntry(QString::fromLatin1("Height %1").arg(desk.height()), height() ); | 786 | config->writeEntry(QString::fromLatin1("Height %1").arg(desk.height()), height() ); |
778 | } | 787 | } |
779 | else{ | 788 | else{ |
780 | config->deleteEntry(QString::fromLatin1("Width %1").arg(desk.width())); | 789 | config->deleteEntry(QString::fromLatin1("Width %1").arg(desk.width())); |
781 | config->deleteEntry(QString::fromLatin1("Height %1").arg(desk.height())); | 790 | config->deleteEntry(QString::fromLatin1("Height %1").arg(desk.height())); |
782 | } | 791 | } |
783 | } | 792 | } |
784 | 793 | ||
785 | void KMainWindow::restoreWindowSize( KConfig * config ) | 794 | void KMainWindow::restoreWindowSize( KConfig * config ) |
786 | { | 795 | { |
787 | if (d->care_about_geometry) { | 796 | if (d->care_about_geometry) { |
788 | parseGeometry(true); | 797 | parseGeometry(true); |
789 | } else { | 798 | } else { |
790 | // restore the size | 799 | // restore the size |
791 | /*US int scnum = QApplication::desktop()->screenNumber(parentWidget()); | 800 | /*US int scnum = QApplication::desktop()->screenNumber(parentWidget()); |
792 | QRect desk = QApplication::desktop()->screenGeometry(scnum); | 801 | QRect desk = QApplication::desktop()->screenGeometry(scnum); |
793 | */ | 802 | */ |
794 | QRect desk = KGlobalSettings::desktopGeometry(0); | 803 | QRect desk = KGlobalSettings::desktopGeometry(0); |
795 | 804 | ||
796 | QSize size( config->readNumEntry( QString::fromLatin1("Width %1").arg(desk.width()), 0 ), | 805 | QSize size( config->readNumEntry( QString::fromLatin1("Width %1").arg(desk.width()), 0 ), |
797 | config->readNumEntry( QString::fromLatin1("Height %1").arg(desk.height()), 0 ) ); | 806 | config->readNumEntry( QString::fromLatin1("Height %1").arg(desk.height()), 0 ) ); |
798 | if (size.isEmpty()) { | 807 | if (size.isEmpty()) { |
799 | // try the KDE 2.0 way | 808 | // try the KDE 2.0 way |
800 | size = QSize( config->readNumEntry( QString::fromLatin1("Width"), 0 ), | 809 | size = QSize( config->readNumEntry( QString::fromLatin1("Width"), 0 ), |
801 | config->readNumEntry( QString::fromLatin1("Height"), 0 ) ); | 810 | config->readNumEntry( QString::fromLatin1("Height"), 0 ) ); |
802 | if (!size.isEmpty()) { | 811 | if (!size.isEmpty()) { |
803 | // make sure the other resolutions don't get old settings | 812 | // make sure the other resolutions don't get old settings |
804 | config->writeEntry( QString::fromLatin1("Width"), 0 ); | 813 | config->writeEntry( QString::fromLatin1("Width"), 0 ); |
805 | config->writeEntry( QString::fromLatin1("Height"), 0 ); | 814 | config->writeEntry( QString::fromLatin1("Height"), 0 ); |
806 | } | 815 | } |
807 | } | 816 | } |
808 | if ( !size.isEmpty() ) | 817 | if ( !size.isEmpty() ) |
809 | resize( size ); | 818 | resize( size ); |
810 | } | 819 | } |
811 | } | 820 | } |
812 | 821 | ||
813 | bool KMainWindow::initialGeometrySet() const | 822 | bool KMainWindow::initialGeometrySet() const |
814 | { | 823 | { |
815 | return d->care_about_geometry; | 824 | return d->care_about_geometry; |
816 | } | 825 | } |
817 | 826 | ||
818 | void KMainWindow::ignoreInitialGeometry() | 827 | void KMainWindow::ignoreInitialGeometry() |
819 | { | 828 | { |
820 | d->care_about_geometry = false; | 829 | d->care_about_geometry = false; |
821 | } | 830 | } |
822 | 831 | ||
823 | void KMainWindow::setSettingsDirty() | 832 | void KMainWindow::setSettingsDirty() |
824 | { | 833 | { |
825 | //kdDebug(200) << "KMainWindow::setSettingsDirty" << endl; | 834 | //kdDebug(200) << "KMainWindow::setSettingsDirty" << endl; |
826 | d->settingsDirty = true; | 835 | d->settingsDirty = true; |
827 | if ( d->autoSaveSettings ) | 836 | if ( d->autoSaveSettings ) |
828 | { | 837 | { |
829 | // Use a timer to save "immediately" user-wise, but not too immediately | 838 | // Use a timer to save "immediately" user-wise, but not too immediately |
830 | // (to compress calls and save only once, in case of multiple changes) | 839 | // (to compress calls and save only once, in case of multiple changes) |
831 | if ( !d->settingsTimer ) | 840 | if ( !d->settingsTimer ) |
832 | { | 841 | { |
833 | d->settingsTimer = new QTimer( this ); | 842 | d->settingsTimer = new QTimer( this ); |
834 | connect( d->settingsTimer, SIGNAL( timeout() ), SLOT( saveAutoSaveSettings() ) ); | 843 | connect( d->settingsTimer, SIGNAL( timeout() ), SLOT( saveAutoSaveSettings() ) ); |
835 | } | 844 | } |
836 | d->settingsTimer->start( 500, true ); | 845 | d->settingsTimer->start( 500, true ); |
837 | } | 846 | } |
838 | } | 847 | } |
839 | 848 | ||
840 | bool KMainWindow::settingsDirty() const | 849 | bool KMainWindow::settingsDirty() const |
841 | { | 850 | { |
842 | return d->settingsDirty; | 851 | return d->settingsDirty; |
843 | } | 852 | } |
844 | 853 | ||
845 | QString KMainWindow::settingsGroup() const | 854 | QString KMainWindow::settingsGroup() const |
846 | { | 855 | { |
847 | return d->autoSaveGroup; | 856 | return d->autoSaveGroup; |
848 | } | 857 | } |
849 | 858 | ||
850 | void KMainWindow::resizeEvent( QResizeEvent * e) | 859 | void KMainWindow::resizeEvent( QResizeEvent * e) |
851 | { | 860 | { |
852 | if ( d->autoSaveWindowSize ) | 861 | if ( d->autoSaveWindowSize ) |
853 | setSettingsDirty(); | 862 | setSettingsDirty(); |
854 | QMainWindow::resizeEvent( e ); | 863 | Q3MainWindow::resizeEvent( e ); |
855 | } | 864 | } |
856 | 865 | ||
857 | bool KMainWindow::hasMenuBar() | 866 | bool KMainWindow::hasMenuBar() |
858 | { | 867 | { |
859 | return (internalMenuBar()); | 868 | return (internalMenuBar()); |
860 | } | 869 | } |
861 | 870 | ||
862 | //US KMenuBar *KMainWindow::menuBar() | 871 | //US KMenuBar *KMainWindow::menuBar() |
863 | QMenuBar *KMainWindow::menuBar() | 872 | QMenuBar *KMainWindow::menuBar() |
864 | { | 873 | { |
865 | //US KMenuBar * mb = internalMenuBar(); | 874 | //US KMenuBar * mb = internalMenuBar(); |
866 | QMenuBar * mb = internalMenuBar(); | 875 | QMenuBar * mb = internalMenuBar(); |
867 | if ( !mb ) { | 876 | if ( !mb ) { |
868 | //US mb = new KMenuBar( this ); | 877 | //US mb = new KMenuBar( this ); |
869 | mb = new QMenuBar( this ); | 878 | mb = new QMenuBar( this ); |
870 | // trigger a re-layout and trigger a call to the private | 879 | // trigger a re-layout and trigger a call to the private |
871 | // setMenuBar method. | 880 | // setMenuBar method. |
872 | QMainWindow::menuBar(); | 881 | Q3MainWindow::menuBar(); |
873 | } | 882 | } |
874 | return mb; | 883 | return mb; |
875 | } | 884 | } |
876 | 885 | ||
877 | //US KStatusBar *KMainWindow::statusBar() | 886 | //US KStatusBar *KMainWindow::statusBar() |
878 | QStatusBar *KMainWindow::statusBar() | 887 | QStatusBar *KMainWindow::statusBar() |
879 | { | 888 | { |
880 | //US KStatusBar * sb = internalStatusBar(); | 889 | //US KStatusBar * sb = internalStatusBar(); |
881 | QStatusBar * sb = internalStatusBar(); | 890 | QStatusBar * sb = internalStatusBar(); |
882 | if ( !sb ) { | 891 | if ( !sb ) { |
883 | //US sb = new KStatusBar( this ); | 892 | //US sb = new KStatusBar( this ); |
884 | sb = new QStatusBar( this ); | 893 | sb = new QStatusBar( this ); |
885 | // trigger a re-layout and trigger a call to the private | 894 | // trigger a re-layout and trigger a call to the private |
886 | // setStatusBar method. | 895 | // setStatusBar method. |
887 | QMainWindow::statusBar(); | 896 | Q3MainWindow::statusBar(); |
888 | } | 897 | } |
889 | return sb; | 898 | return sb; |
890 | } | 899 | } |
891 | 900 | ||
892 | void KMainWindow::shuttingDown() | 901 | void KMainWindow::shuttingDown() |
893 | { | 902 | { |
894 | // Needed for Qt <= 3.0.3 at least to prevent reentrancy | 903 | // Needed for Qt <= 3.0.3 at least to prevent reentrancy |
895 | // when queryExit() shows a dialog. Check before removing! | 904 | // when queryExit() shows a dialog. Check before removing! |
896 | static bool reentrancy_protection = false; | 905 | static bool reentrancy_protection = false; |
897 | if (!reentrancy_protection) | 906 | if (!reentrancy_protection) |
898 | { | 907 | { |
899 | reentrancy_protection = true; | 908 | reentrancy_protection = true; |
900 | // call the virtual queryExit | 909 | // call the virtual queryExit |
901 | queryExit(); | 910 | queryExit(); |
902 | reentrancy_protection = false; | 911 | reentrancy_protection = false; |
903 | } | 912 | } |
904 | 913 | ||
905 | } | 914 | } |
906 | 915 | ||
907 | //US KMenuBar *KMainWindow::internalMenuBar() | 916 | //US KMenuBar *KMainWindow::internalMenuBar() |
908 | QMenuBar *KMainWindow::internalMenuBar() | 917 | QMenuBar *KMainWindow::internalMenuBar() |
909 | { | 918 | { |
910 | //US QObjectList *l = queryList( "KMenuBar", 0, false, false ); | 919 | //US QObjectList *l = queryList( "KMenuBar", 0, false, false ); |
911 | QObjectList *l = queryList( "QMenuBar", 0, false, false ); | 920 | QObjectList l = queryList( "QMenuBar", 0, false, false ); |
912 | if ( !l || !l->first() ) { | 921 | if(l.empty()) |
913 | delete l; | 922 | return 0; |
914 | return 0; | 923 | return (QMenuBar*)l.front(); |
915 | } | ||
916 | |||
917 | //US KMenuBar *m = (KMenuBar*)l->first(); | ||
918 | QMenuBar *m = (QMenuBar*)l->first(); | ||
919 | delete l; | ||
920 | return m; | ||
921 | } | 924 | } |
922 | 925 | ||
923 | //US KStatusBar *KMainWindow::internalStatusBar() | 926 | //US KStatusBar *KMainWindow::internalStatusBar() |
924 | QStatusBar *KMainWindow::internalStatusBar() | 927 | QStatusBar *KMainWindow::internalStatusBar() |
925 | { | 928 | { |
926 | //US QObjectList *l = queryList( "KStatusBar", 0, false, false ); | 929 | //US QObjectList *l = queryList( "KStatusBar", 0, false, false ); |
927 | QObjectList *l = queryList( "QStatusBar", 0, false, false ); | 930 | QObjectList l = queryList( "QStatusBar", 0, false, false ); |
928 | if ( !l || !l->first() ) { | 931 | if(l.empty()) |
929 | delete l; | 932 | return 0; |
930 | return 0; | 933 | return (QStatusBar*)l.front(); |
931 | } | ||
932 | |||
933 | //US KStatusBar *s = (KStatusBar*)l->first(); | ||
934 | QStatusBar *s = (QStatusBar*)l->first(); | ||
935 | delete l; | ||
936 | return s; | ||
937 | } | 934 | } |
938 | 935 | ||
939 | void KMainWindow::childEvent( QChildEvent* e) | 936 | void KMainWindow::childEvent( QChildEvent* e) |
940 | { | 937 | { |
941 | QMainWindow::childEvent( e ); | 938 | Q3MainWindow::childEvent( e ); |
942 | } | 939 | } |
943 | 940 | ||
944 | void KMainWindow::paintEvent( QPaintEvent * e) | 941 | void KMainWindow::paintEvent( QPaintEvent * e) |
945 | { | 942 | { |
946 | QMainWindow::paintEvent( e ); | 943 | Q3MainWindow::paintEvent( e ); |
947 | } | 944 | } |
948 | 945 | ||
949 | QSize KMainWindow::sizeForCentralWidgetSize(QSize size) | 946 | QSize KMainWindow::sizeForCentralWidgetSize(QSize size) |
950 | { | 947 | { |
951 | KToolBar *tb = (KToolBar*)child( "mainToolBar", "KToolBar" ); | 948 | KToolBar *tb = (KToolBar*)child( "mainToolBar", "KToolBar" ); |
952 | if (tb && !tb->isHidden()) { | 949 | if (tb && !tb->isHidden()) { |
953 | switch( tb->barPos() ) | 950 | switch( tb->barPos() ) |
954 | { | 951 | { |
955 | case KToolBar::Top: | 952 | case KToolBar::Top: |
956 | case KToolBar::Bottom: | 953 | case KToolBar::Bottom: |
957 | size += QSize(0, tb->sizeHint().height()); | 954 | size += QSize(0, tb->sizeHint().height()); |
958 | break; | 955 | break; |
959 | 956 | ||
960 | case KToolBar::Left: | 957 | case KToolBar::Left: |
961 | case KToolBar::Right: | 958 | case KToolBar::Right: |
962 | size += QSize(toolBar()->sizeHint().width(), 0); | 959 | size += QSize(toolBar()->sizeHint().width(), 0); |
963 | break; | 960 | break; |
964 | 961 | ||
965 | case KToolBar::Flat: | 962 | case KToolBar::Flat: |
966 | //US size += QSize(0, 3+kapp->style().pixelMetric( QStyle::PM_DockWindowHandleExtent )); | 963 | //US size += QSize(0, 3+kapp->style().pixelMetric( QStyle::PM_DockWindowHandleExtent )); |
967 | size += QSize(0, tb->sizeHint().height()); | 964 | size += QSize(0, tb->sizeHint().height()); |
968 | break; | 965 | break; |
969 | 966 | ||
970 | default: | 967 | default: |
971 | break; | 968 | break; |
972 | } | 969 | } |
973 | } | 970 | } |
974 | //US KMenuBar *mb = menuBar(); | 971 | //US KMenuBar *mb = menuBar(); |
975 | QMenuBar *mb = menuBar(); | 972 | QMenuBar *mb = menuBar(); |
976 | if (!mb->isHidden()) { | 973 | if (!mb->isHidden()) { |
977 | size += QSize(0,mb->heightForWidth(size.width())); | 974 | size += QSize(0,mb->heightForWidth(size.width())); |
978 | /*US if (style().styleHint(QStyle::SH_MainWindow_SpaceBelowMenuBar, this)) | 975 | /*US if (style().styleHint(QStyle::SH_MainWindow_SpaceBelowMenuBar, this)) |
979 | size += QSize( 0, dockWindowsMovable() ? 1 : 2); | 976 | size += QSize( 0, dockWindowsMovable() ? 1 : 2); |
980 | */ | 977 | */ |
981 | size += QSize( 0, 2); | 978 | size += QSize( 0, 2); |
982 | } | 979 | } |
983 | QStatusBar *sb = internalStatusBar(); | 980 | QStatusBar *sb = internalStatusBar(); |
984 | if( sb && !sb->isHidden() ) | 981 | if( sb && !sb->isHidden() ) |
985 | size += QSize(0, sb->sizeHint().height()); | 982 | size += QSize(0, sb->sizeHint().height()); |
986 | 983 | ||
987 | return size; | 984 | return size; |
988 | } | 985 | } |
989 | 986 | ||
990 | // why do we support old gcc versions? using KXMLGUIBuilder::finalizeGUI; | 987 | // why do we support old gcc versions? using KXMLGUIBuilder::finalizeGUI; |
991 | void KMainWindow::finalizeGUI( KXMLGUIClient *client ) | 988 | void KMainWindow::finalizeGUI( KXMLGUIClient *client ) |
992 | { /*US KXMLGUIBuilder::finalizeGUI( client );*/ } | 989 | { /*US KXMLGUIBuilder::finalizeGUI( client );*/ } |
993 | 990 | ||
994 | void KMainWindow::virtual_hook( int id, void* data ) | 991 | void KMainWindow::virtual_hook( int id, void* data ) |
995 | { /*US KXMLGUIBuilder::virtual_hook( id, data );*/ | 992 | { /*US KXMLGUIBuilder::virtual_hook( id, data );*/ |
996 | KXMLGUIClient::virtual_hook( id, data ); } | 993 | KXMLGUIClient::virtual_hook( id, data ); } |