author | zautrix <zautrix> | 2005-08-23 20:09:28 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-08-23 20:09:28 (UTC) |
commit | 6f5464760f5fb1e4c13027464cfe4943b85d29a0 (patch) (unidiff) | |
tree | 3c074b7e313d965516b60b9ba97fe27a7ee774a1 /microkde | |
parent | 13a736b71dec27ef7ffef06b91f34d220d89cce6 (diff) | |
download | kdepimpi-6f5464760f5fb1e4c13027464cfe4943b85d29a0.zip kdepimpi-6f5464760f5fb1e4c13027464cfe4943b85d29a0.tar.gz kdepimpi-6f5464760f5fb1e4c13027464cfe4943b85d29a0.tar.bz2 |
fixx
-rw-r--r-- | microkde/kdeui/kmainwindow.cpp | 11 | ||||
-rw-r--r-- | microkde/kdeui/kmainwindow.h | 2 |
2 files changed, 7 insertions, 6 deletions
diff --git a/microkde/kdeui/kmainwindow.cpp b/microkde/kdeui/kmainwindow.cpp index 3ae4c87..fa678f2 100644 --- a/microkde/kdeui/kmainwindow.cpp +++ b/microkde/kdeui/kmainwindow.cpp | |||
@@ -1,995 +1,996 @@ | |||
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 | ||
37 | class KMainWindowPrivate { | 37 | class KMainWindowPrivate { |
38 | public: | 38 | public: |
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 | ||
54 | static bool no_query_exit = false; | 54 | static bool no_query_exit = false; |
55 | 55 | ||
56 | KMainWindow::KMainWindow( QWidget* parent, const char *name, WFlags f ) | 56 | 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 )*/ | 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 | ||
63 | void KMainWindow::parseGeometry(bool parsewidth) | 63 | void 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 | ||
103 | KMainWindow::~KMainWindow() | 103 | KMainWindow::~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 | ||
114 | void KMainWindow::initKMainWindow(const char *name) | 114 | void 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 | ||
200 | KAction *KMainWindow::toolBarMenuAction() | 200 | KAction *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 | ||
208 | bool KMainWindow::canBeRestored( int number ) | 208 | bool 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 |
211 | application config. | 211 | application 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 | ||
225 | const QString KMainWindow::classNameOfToplevel( int number ) | 225 | const 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 |
228 | application config. | 228 | application 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 | ||
246 | bool KMainWindow::restore( int number, bool show ) | 246 | bool 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 |
249 | application config. | 249 | application 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 | ||
265 | void KMainWindow::setCaption( const QString &caption ) | 265 | void 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 | ||
271 | void KMainWindow::setCaption( const QString &caption, bool modified ) | 271 | void 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 | ||
277 | void KMainWindow::setPlainCaption( const QString &caption ) | 277 | void 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 | ||
287 | void KMainWindow::slotStateChanged(const QString &newstate) | 287 | void 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 | */ |
295 | void KMainWindow::slotStateChanged(const QString &newstate, | 295 | void 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 | ||
301 | void KMainWindow::closeEvent ( QCloseEvent *e ) | 301 | void KMainWindow::closeEvent ( QCloseEvent *e ) |
302 | { | 302 | { |
303 | //qDebug("MainWindow::closeEvent "); | 303 | //qDebug("MainWindow::closeEvent "); |
304 | // Save settings if auto-save is enabled, and settings have changed | 304 | // Save settings if auto-save is enabled, and settings have changed |
305 | if (d->settingsDirty && d->autoSaveSettings) | 305 | if (d->settingsDirty && d->autoSaveSettings) |
306 | saveAutoSaveSettings(); | 306 | saveAutoSaveSettings(); |
307 | 307 | ||
308 | if (queryClose()) { | 308 | if (queryClose()) { |
309 | e->accept(); | 309 | e->accept(); |
310 | 310 | ||
311 | int not_withdrawn = 0; | 311 | int not_withdrawn = 0; |
312 | /*US | 312 | /*US |
313 | QPtrListIterator<KMainWindow> it(*KMainWindow::memberList); | 313 | QPtrListIterator<KMainWindow> it(*KMainWindow::memberList); |
314 | for (it.toFirst(); it.current(); ++it){ | 314 | for (it.toFirst(); it.current(); ++it){ |
315 | if ( !it.current()->isHidden() && it.current()->isTopLevel() && it.current() != this ) | 315 | if ( !it.current()->isHidden() && it.current()->isTopLevel() && it.current() != this ) |
316 | not_withdrawn++; | 316 | not_withdrawn++; |
317 | } | 317 | } |
318 | */ | 318 | */ |
319 | if ( !no_query_exit && not_withdrawn <= 0 ) { // last window close accepted? | 319 | if ( !no_query_exit && not_withdrawn <= 0 ) { // last window close accepted? |
320 | /*US | 320 | /*US |
321 | if ( queryExit() && !kapp->sessionSaving()) { // Yes, Quit app? | 321 | if ( queryExit() && !kapp->sessionSaving()) { // Yes, Quit app? |
322 | // don't call queryExit() twice | 322 | // don't call queryExit() twice |
323 | disconnect(kapp, SIGNAL(shutDown()), this, SLOT(shuttingDown())); | 323 | disconnect(kapp, SIGNAL(shutDown()), this, SLOT(shuttingDown())); |
324 | kapp->deref(); // ...and quit aplication. | 324 | kapp->deref(); // ...and quit aplication. |
325 | } else { | 325 | } else { |
326 | // cancel closing, it's stupid to end up with no windows at all.... | 326 | // cancel closing, it's stupid to end up with no windows at all.... |
327 | e->ignore(); | 327 | e->ignore(); |
328 | } | 328 | } |
329 | */ | 329 | */ |
330 | //US we have no sessionmanagement. Simply close app. | 330 | //US we have no sessionmanagement. Simply close app. |
331 | if ( queryExit() ) { // Yes, Quit app? | 331 | if ( queryExit() ) { // Yes, Quit app? |
332 | qDebug("KMainWindow::closeEvent: Exit application ???"); | 332 | qDebug("KMainWindow::closeEvent: Exit application ???"); |
333 | // don't call queryExit() twice | 333 | // don't call queryExit() twice |
334 | //US disconnect(kapp, SIGNAL(shutDown()), this, SLOT(shuttingDown())); | 334 | //US disconnect(kapp, SIGNAL(shutDown()), this, SLOT(shuttingDown())); |
335 | } | 335 | } |
336 | 336 | ||
337 | } | 337 | } |
338 | } | 338 | } |
339 | } | 339 | } |
340 | 340 | ||
341 | bool KMainWindow::queryExit() | 341 | bool KMainWindow::queryExit() |
342 | { | 342 | { |
343 | return TRUE; | 343 | return TRUE; |
344 | } | 344 | } |
345 | 345 | ||
346 | bool KMainWindow::queryClose() | 346 | bool KMainWindow::queryClose() |
347 | { | 347 | { |
348 | return TRUE; | 348 | return TRUE; |
349 | } | 349 | } |
350 | 350 | ||
351 | void KMainWindow::saveGlobalProperties( KConfig* ) | 351 | void KMainWindow::saveGlobalProperties( KConfig* ) |
352 | { | 352 | { |
353 | } | 353 | } |
354 | 354 | ||
355 | void KMainWindow::readGlobalProperties( KConfig* ) | 355 | void KMainWindow::readGlobalProperties( KConfig* ) |
356 | { | 356 | { |
357 | } | 357 | } |
358 | 358 | ||
359 | void KMainWindow::savePropertiesInternal( KConfig *config, int number ) | 359 | void KMainWindow::savePropertiesInternal( KConfig *config, int number ) |
360 | { | 360 | { |
361 | bool oldASWS = d->autoSaveWindowSize; | 361 | bool oldASWS = d->autoSaveWindowSize; |
362 | d->autoSaveWindowSize = true; // make saveMainWindowSettings save the window size | 362 | d->autoSaveWindowSize = true; // make saveMainWindowSettings save the window size |
363 | 363 | ||
364 | QString s; | 364 | QString s; |
365 | s.setNum(number); | 365 | s.setNum(number); |
366 | s.prepend(QString::fromLatin1("WindowProperties")); | 366 | s.prepend(QString::fromLatin1("WindowProperties")); |
367 | config->setGroup(s); | 367 | config->setGroup(s); |
368 | 368 | ||
369 | // store objectName, className, Width and Height for later restoring | 369 | // store objectName, className, Width and Height for later restoring |
370 | // (Only useful for session management) | 370 | // (Only useful for session management) |
371 | config->writeEntry(QString::fromLatin1("ObjectName"), name()); | 371 | config->writeEntry(QString::fromLatin1("ObjectName"), name()); |
372 | config->writeEntry(QString::fromLatin1("ClassName"), className()); | 372 | config->writeEntry(QString::fromLatin1("ClassName"), className()); |
373 | 373 | ||
374 | saveMainWindowSettings(config); // Menubar, statusbar and Toolbar settings. | 374 | saveMainWindowSettings(config); // Menubar, statusbar and Toolbar settings. |
375 | 375 | ||
376 | s.setNum(number); | 376 | s.setNum(number); |
377 | config->setGroup(s); | 377 | config->setGroup(s); |
378 | saveProperties(config); | 378 | saveProperties(config); |
379 | 379 | ||
380 | d->autoSaveWindowSize = oldASWS; | 380 | d->autoSaveWindowSize = oldASWS; |
381 | } | 381 | } |
382 | 382 | ||
383 | void KMainWindow::setStandardToolBarMenuEnabled( bool enable ) | 383 | void KMainWindow::setStandardToolBarMenuEnabled( bool enable ) |
384 | { | 384 | { |
385 | if ( enable ) | 385 | if ( enable ) |
386 | { | 386 | { |
387 | if ( d->toolBarHandler ) | 387 | if ( d->toolBarHandler ) |
388 | return; | 388 | return; |
389 | 389 | ||
390 | d->toolBarHandler = new KDEPrivate::ToolBarHandler( this ); | 390 | d->toolBarHandler = new KDEPrivate::ToolBarHandler( this ); |
391 | 391 | ||
392 | /*US if ( factory() ) | 392 | /*US if ( factory() ) |
393 | factory()->addClient( d->toolBarHandler ); | 393 | factory()->addClient( d->toolBarHandler ); |
394 | */ | 394 | */ |
395 | } | 395 | } |
396 | else | 396 | else |
397 | { | 397 | { |
398 | if ( !d->toolBarHandler ) | 398 | if ( !d->toolBarHandler ) |
399 | return; | 399 | return; |
400 | /*US | 400 | /*US |
401 | if ( factory() ) | 401 | if ( factory() ) |
402 | factory()->removeClient( d->toolBarHandler ); | 402 | factory()->removeClient( d->toolBarHandler ); |
403 | */ | 403 | */ |
404 | delete d->toolBarHandler; | 404 | delete d->toolBarHandler; |
405 | d->toolBarHandler = 0; | 405 | d->toolBarHandler = 0; |
406 | } | 406 | } |
407 | 407 | ||
408 | } | 408 | } |
409 | 409 | ||
410 | bool KMainWindow::isStandardToolBarMenuEnabled() const | 410 | bool KMainWindow::isStandardToolBarMenuEnabled() const |
411 | { | 411 | { |
412 | return ( d->toolBarHandler != 0 ); | 412 | return ( d->toolBarHandler != 0 ); |
413 | } | 413 | } |
414 | 414 | ||
415 | void KMainWindow::createStandardStatusBarAction(){ | 415 | void KMainWindow::createStandardStatusBarAction(){ |
416 | if(!d->showStatusBarAction){ | 416 | if(!d->showStatusBarAction){ |
417 | d->showStatusBarAction = KStdAction::showStatusbar(this, SLOT(setSettingsDirty()), actionCollection()); | 417 | d->showStatusBarAction = KStdAction::showStatusbar(this, SLOT(setSettingsDirty()), actionCollection()); |
418 | connect(d->showStatusBarAction, SIGNAL(toggled(bool)), statusBar(), SLOT(setShown(bool))); | 418 | connect(d->showStatusBarAction, SIGNAL(toggled(bool)), statusBar(), SLOT(setShown(bool))); |
419 | if(internalStatusBar()) | 419 | if(internalStatusBar()) |
420 | d->showStatusBarAction->setChecked(!internalStatusBar()->isHidden()); | 420 | d->showStatusBarAction->setChecked(!internalStatusBar()->isHidden()); |
421 | } | 421 | } |
422 | } | 422 | } |
423 | 423 | ||
424 | QToolBar *KMainWindow::tBar( ) | 424 | QToolBar *KMainWindow::tBar( ) |
425 | { | 425 | { |
426 | if ( ! mQToolBar ) | 426 | if ( ! mQToolBar ) |
427 | mQToolBar = new QToolBar( this ); | 427 | mQToolBar = new QToolBar( this ); |
428 | return mQToolBar; | 428 | return mQToolBar; |
429 | } | 429 | } |
430 | 430 | ||
431 | KToolBar *KMainWindow::toolBar( const char * name ) | 431 | KToolBar *KMainWindow::toolBar( const char * name ) |
432 | { | 432 | { |
433 | 433 | ||
434 | if (!name) | 434 | if (!name) |
435 | name = "mainToolBar"; | 435 | name = "mainToolBar"; |
436 | KToolBar *tb = (KToolBar*)child( name, "KToolBar" ); | 436 | KToolBar *tb = (KToolBar*)child( name, "KToolBar" ); |
437 | if ( tb ) | 437 | if ( tb ) |
438 | return tb; | 438 | return tb; |
439 | bool honor_mode = (name == "mainToolBar"); | 439 | bool honor_mode = (name == "mainToolBar"); |
440 | 440 | ||
441 | /*US | 441 | /*US |
442 | if ( builderClient() ) | 442 | if ( builderClient() ) |
443 | return new KToolBar(this, name, honor_mode); // XMLGUI constructor | 443 | return new KToolBar(this, name, honor_mode); // XMLGUI constructor |
444 | else | 444 | else |
445 | */ | 445 | */ |
446 | return new KToolBar(this, Top, false, name, honor_mode ); // non-XMLGUI | 446 | return new KToolBar(this, Top, false, name, honor_mode ); // non-XMLGUI |
447 | } | 447 | } |
448 | 448 | ||
449 | QPtrListIterator<KToolBar> KMainWindow::toolBarIterator() | 449 | QPtrListIterator<KToolBar> KMainWindow::toolBarIterator() |
450 | { | 450 | { |
451 | toolbarList.clear(); | 451 | toolbarList.clear(); |
452 | QPtrList<QToolBar> lst; | 452 | QPtrList<QToolBar> lst; |
453 | for ( int i = (int)QMainWindow::Unmanaged; i <= (int)Minimized; ++i ) { | 453 | for ( int i = (int)QMainWindow::Unmanaged; i <= (int)Minimized; ++i ) { |
454 | lst = toolBars( (ToolBarDock)i ); | 454 | lst = toolBars( (ToolBarDock)i ); |
455 | for ( QToolBar *tb = lst.first(); tb; tb = lst.next() ) { | 455 | for ( QToolBar *tb = lst.first(); tb; tb = lst.next() ) { |
456 | if ( !tb->inherits( "KToolBar" ) ) | 456 | if ( !tb->inherits( "KToolBar" ) ) |
457 | continue; | 457 | continue; |
458 | toolbarList.append( (KToolBar*)tb ); | 458 | toolbarList.append( (KToolBar*)tb ); |
459 | } | 459 | } |
460 | } | 460 | } |
461 | return QPtrListIterator<KToolBar>( toolbarList ); | 461 | return QPtrListIterator<KToolBar>( toolbarList ); |
462 | } | 462 | } |
463 | 463 | ||
464 | void KMainWindow::setAutoSaveSettings( const QString & groupName, bool saveWindowSize ) | 464 | void KMainWindow::setAutoSaveSettings( const QString & groupName, bool saveWindowSize ) |
465 | { | 465 | { |
466 | d->autoSaveSettings = true; | 466 | d->autoSaveSettings = true; |
467 | d->autoSaveGroup = groupName; | 467 | d->autoSaveGroup = groupName; |
468 | d->autoSaveWindowSize = saveWindowSize; | 468 | d->autoSaveWindowSize = saveWindowSize; |
469 | // Get notified when the user moves a toolbar around | 469 | // Get notified when the user moves a toolbar around |
470 | //US connect( this, SIGNAL( dockWindowPositionChanged( QDockWindow * ) ), | 470 | //US connect( this, SIGNAL( dockWindowPositionChanged( QDockWindow * ) ), |
471 | //US this, SLOT( setSettingsDirty() ) ); | 471 | //US this, SLOT( setSettingsDirty() ) ); |
472 | connect( this, SIGNAL( toolBarPositionChanged(QToolBar *) ), | 472 | connect( this, SIGNAL( toolBarPositionChanged(QToolBar *) ), |
473 | this, SLOT( setSettingsDirty() ) ); | 473 | this, SLOT( setSettingsDirty() ) ); |
474 | 474 | ||
475 | 475 | ||
476 | // Get default values | 476 | // Get default values |
477 | //US int scnum = QApplication::desktop()->screenNumber(parentWidget()); | 477 | //US int scnum = QApplication::desktop()->screenNumber(parentWidget()); |
478 | //US QRect desk = QApplication::desktop()->screenGeometry(scnum); | 478 | //US QRect desk = QApplication::desktop()->screenGeometry(scnum); |
479 | QRect desk = KGlobalSettings::desktopGeometry(0); | 479 | QRect desk = KGlobalSettings::desktopGeometry(0); |
480 | 480 | ||
481 | d->defaultWindowSize = QRect(desk.width(), width(), desk.height(), height()); | 481 | d->defaultWindowSize = QRect(desk.width(), width(), desk.height(), height()); |
482 | // Now read the previously saved settings | 482 | // Now read the previously saved settings |
483 | applyMainWindowSettings( KGlobal::config(), groupName ); | 483 | applyMainWindowSettings( KGlobal::config(), groupName ); |
484 | } | 484 | } |
485 | 485 | ||
486 | 486 | ||
487 | void KMainWindow::resetAutoSaveSettings() | 487 | void KMainWindow::resetAutoSaveSettings() |
488 | { | 488 | { |
489 | d->autoSaveSettings = false; | 489 | d->autoSaveSettings = false; |
490 | if ( d->settingsTimer ) | 490 | if ( d->settingsTimer ) |
491 | d->settingsTimer->stop(); | 491 | d->settingsTimer->stop(); |
492 | } | 492 | } |
493 | 493 | ||
494 | bool KMainWindow::autoSaveSettings() const | 494 | bool KMainWindow::autoSaveSettings() const |
495 | { | 495 | { |
496 | return d->autoSaveSettings; | 496 | return d->autoSaveSettings; |
497 | } | 497 | } |
498 | 498 | ||
499 | QString KMainWindow::autoSaveGroup() const | 499 | QString KMainWindow::autoSaveGroup() const |
500 | { | 500 | { |
501 | return d->autoSaveGroup; | 501 | return d->autoSaveGroup; |
502 | } | 502 | } |
503 | 503 | ||
504 | void KMainWindow::saveAutoSaveSettings() | 504 | void KMainWindow::saveAutoSaveSettings() |
505 | { | 505 | { |
506 | ASSERT( d->autoSaveSettings ); | 506 | ASSERT( d->autoSaveSettings ); |
507 | //kdDebug(200) << "KMainWindow::saveAutoSaveSettings -> saving settings" << endl; | 507 | //kdDebug(200) << "KMainWindow::saveAutoSaveSettings -> saving settings" << endl; |
508 | saveMainWindowSettings( KGlobal::config(), d->autoSaveGroup ); | 508 | saveMainWindowSettings( KGlobal::config(), d->autoSaveGroup ); |
509 | KGlobal::config()->sync(); | 509 | KGlobal::config()->sync(); |
510 | d->settingsDirty = false; | 510 | d->settingsDirty = false; |
511 | if ( d->settingsTimer ) | 511 | if ( d->settingsTimer ) |
512 | d->settingsTimer->stop(); | 512 | d->settingsTimer->stop(); |
513 | } | 513 | } |
514 | 514 | ||
515 | void KMainWindow::createGUI( const QString &xmlfile, bool _conserveMemory ) | 515 | void KMainWindow::createGUI( const QString &xmlfile, bool _conserveMemory ) |
516 | { | 516 | { |
517 | // disabling the updates prevents unnecessary redraws | 517 | // disabling the updates prevents unnecessary redraws |
518 | setUpdatesEnabled( false ); | 518 | setUpdatesEnabled( false ); |
519 | 519 | ||
520 | // just in case we are rebuilding, let's remove our old client | 520 | // just in case we are rebuilding, let's remove our old client |
521 | //US guiFactory()->removeClient( this ); | 521 | //US guiFactory()->removeClient( this ); |
522 | 522 | ||
523 | // make sure to have an empty GUI | 523 | // make sure to have an empty GUI |
524 | QMenuBar* mb = internalMenuBar(); | 524 | QMenuBar* mb = internalMenuBar(); |
525 | if ( mb ) | 525 | if ( mb ) |
526 | mb->clear(); | 526 | mb->clear(); |
527 | 527 | ||
528 | (void)toolBarIterator(); // make sure toolbarList is most-up-to-date | 528 | (void)toolBarIterator(); // make sure toolbarList is most-up-to-date |
529 | toolbarList.setAutoDelete( true ); | 529 | toolbarList.setAutoDelete( true ); |
530 | toolbarList.clear(); | 530 | toolbarList.clear(); |
531 | toolbarList.setAutoDelete( false ); | 531 | toolbarList.setAutoDelete( false ); |
532 | /*US | 532 | /*US |
533 | // don't build a help menu unless the user ask for it | 533 | // don't build a help menu unless the user ask for it |
534 | if (d->showHelpMenu) { | 534 | if (d->showHelpMenu) { |
535 | // we always want a help menu | 535 | // we always want a help menu |
536 | if (helpMenu2 == 0) | 536 | if (helpMenu2 == 0) |
537 | helpMenu2 = new KHelpMenu(this, instance()->aboutData(), true, | 537 | helpMenu2 = new KHelpMenu(this, instance()->aboutData(), true, |
538 | actionCollection()); | 538 | actionCollection()); |
539 | } | 539 | } |
540 | 540 | ||
541 | // we always want to load in our global standards file | 541 | // we always want to load in our global standards file |
542 | setXMLFile( locate( "config", "ui/ui_standards.rc", instance() ) ); | 542 | setXMLFile( locate( "config", "ui/ui_standards.rc", instance() ) ); |
543 | 543 | ||
544 | // now, merge in our local xml file. if this is null, then that | 544 | // now, merge in our local xml file. if this is null, then that |
545 | // means that we will be only using the global file | 545 | // means that we will be only using the global file |
546 | if ( !xmlfile.isNull() ) { | 546 | if ( !xmlfile.isNull() ) { |
547 | setXMLFile( xmlfile, true ); | 547 | setXMLFile( xmlfile, true ); |
548 | } else { | 548 | } else { |
549 | QString auto_file(instance()->instanceName() + "ui.rc"); | 549 | QString auto_file(instance()->instanceName() + "ui.rc"); |
550 | setXMLFile( auto_file, true ); | 550 | setXMLFile( auto_file, true ); |
551 | } | 551 | } |
552 | 552 | ||
553 | // make sure we don't have any state saved already | 553 | // make sure we don't have any state saved already |
554 | setXMLGUIBuildDocument( QDomDocument() ); | 554 | setXMLGUIBuildDocument( QDomDocument() ); |
555 | 555 | ||
556 | // do the actual GUI building | 556 | // do the actual GUI building |
557 | guiFactory()->addClient( this ); | 557 | guiFactory()->addClient( this ); |
558 | 558 | ||
559 | // try and get back *some* of our memory | 559 | // try and get back *some* of our memory |
560 | if ( _conserveMemory ) | 560 | if ( _conserveMemory ) |
561 | { | 561 | { |
562 | // before freeing the memory allocated by the DOM document we also | 562 | // before freeing the memory allocated by the DOM document we also |
563 | // free all memory allocated internally in the KXMLGUIFactory for | 563 | // free all memory allocated internally in the KXMLGUIFactory for |
564 | // the menubar and the toolbars . This however implies that we | 564 | // the menubar and the toolbars . This however implies that we |
565 | // have to take care of deleting those widgets ourselves. For | 565 | // have to take care of deleting those widgets ourselves. For |
566 | // destruction this is no problem, but when rebuilding we have | 566 | // destruction this is no problem, but when rebuilding we have |
567 | // to take care of that (and we want to rebuild the GUI when | 567 | // to take care of that (and we want to rebuild the GUI when |
568 | // using stuff like the toolbar editor ). | 568 | // using stuff like the toolbar editor ). |
569 | // In addition we have to take care of not removing containers | 569 | // In addition we have to take care of not removing containers |
570 | // like popupmenus, defined in the XML document. | 570 | // like popupmenus, defined in the XML document. |
571 | // this code should probably go into a separate method in KMainWindow. | 571 | // this code should probably go into a separate method in KMainWindow. |
572 | // there's just one problem: I'm bad in finding names ;-) , so | 572 | // there's just one problem: I'm bad in finding names ;-) , so |
573 | // I skipped this ;-) | 573 | // I skipped this ;-) |
574 | 574 | ||
575 | QDomDocument doc = domDocument(); | 575 | QDomDocument doc = domDocument(); |
576 | 576 | ||
577 | QDomElement e = doc.documentElement().firstChild().toElement(); | 577 | QDomElement e = doc.documentElement().firstChild().toElement(); |
578 | for (; !e.isNull(); e = e.nextSibling().toElement() ) { | 578 | for (; !e.isNull(); e = e.nextSibling().toElement() ) { |
579 | if ( e.tagName().lower() == "toolbar" ) | 579 | if ( e.tagName().lower() == "toolbar" ) |
580 | factory_->resetContainer( e.attribute( "name" ) ); | 580 | factory_->resetContainer( e.attribute( "name" ) ); |
581 | else if ( e.tagName().lower() == "menubar" ) | 581 | else if ( e.tagName().lower() == "menubar" ) |
582 | factory_->resetContainer( e.tagName(), true ); | 582 | factory_->resetContainer( e.tagName(), true ); |
583 | } | 583 | } |
584 | 584 | ||
585 | conserveMemory(); | 585 | conserveMemory(); |
586 | } | 586 | } |
587 | */ | 587 | */ |
588 | setUpdatesEnabled( true ); | 588 | setUpdatesEnabled( true ); |
589 | updateGeometry(); | 589 | updateGeometry(); |
590 | } | 590 | } |
591 | 591 | ||
592 | void KMainWindow::saveMainWindowSettings(KConfig *config, const QString &configGroup) | 592 | void KMainWindow::saveMainWindowSettings(KConfig *config, const QString &configGroup) |
593 | { | 593 | { |
594 | kdDebug(200) << "KMainWindow::saveMainWindowSettings " << configGroup << endl; | 594 | kdDebug(200) << "KMainWindow::saveMainWindowSettings " << configGroup << endl; |
595 | //US QStrList entryList; | 595 | //US QStrList entryList; |
596 | QStringList entryList; | 596 | QStringList entryList; |
597 | QString oldGroup; | 597 | QString oldGroup; |
598 | 598 | ||
599 | if (!configGroup.isEmpty()) | 599 | if (!configGroup.isEmpty()) |
600 | { | 600 | { |
601 | oldGroup = config->group(); | 601 | oldGroup = config->group(); |
602 | config->setGroup(configGroup); | 602 | config->setGroup(configGroup); |
603 | } | 603 | } |
604 | 604 | ||
605 | // Called by session management - or if we want to save the window size anyway | 605 | // Called by session management - or if we want to save the window size anyway |
606 | if ( d->autoSaveWindowSize ) | 606 | if ( d->autoSaveWindowSize ) |
607 | saveWindowSize( config ); | 607 | saveWindowSize( config ); |
608 | 608 | ||
609 | QStatusBar* sb = internalStatusBar(); | 609 | QStatusBar* sb = internalStatusBar(); |
610 | if (sb) { | 610 | if (sb) { |
611 | entryList.clear(); | 611 | entryList.clear(); |
612 | if ( sb->isHidden() ) | 612 | if ( sb->isHidden() ) |
613 | entryList.append("Disabled"); | 613 | entryList.append("Disabled"); |
614 | else | 614 | else |
615 | entryList.append("Enabled"); | 615 | entryList.append("Enabled"); |
616 | 616 | ||
617 | if(sb->isHidden()) | 617 | if(sb->isHidden()) |
618 | //US config->writeEntry(QString::fromLatin1("StatusBar"), entryList, ';'); | 618 | //US config->writeEntry(QString::fromLatin1("StatusBar"), entryList, ';'); |
619 | config->writeEntry(QString::fromLatin1("StatusBar"), entryList); | 619 | config->writeEntry(QString::fromLatin1("StatusBar"), entryList); |
620 | else | 620 | else |
621 | config->deleteEntry(QString::fromLatin1("StatusBar")); | 621 | config->deleteEntry(QString::fromLatin1("StatusBar")); |
622 | } | 622 | } |
623 | 623 | ||
624 | QMenuBar* mb = internalMenuBar(); | 624 | QMenuBar* mb = internalMenuBar(); |
625 | if (mb) { | 625 | if (mb) { |
626 | entryList.clear(); | 626 | entryList.clear(); |
627 | if ( mb->isHidden() ) | 627 | if ( mb->isHidden() ) |
628 | entryList.append("Disabled"); | 628 | entryList.append("Disabled"); |
629 | else | 629 | else |
630 | entryList.append("Enabled"); | 630 | entryList.append("Enabled"); |
631 | 631 | ||
632 | // By default we don't hide. | 632 | // By default we don't hide. |
633 | if(mb->isHidden()) | 633 | if(mb->isHidden()) |
634 | //US config->writeEntry(QString::fromLatin1("MenuBar"), entryList, ';'); | 634 | //US config->writeEntry(QString::fromLatin1("MenuBar"), entryList, ';'); |
635 | config->writeEntry(QString::fromLatin1("MenuBar"), entryList); | 635 | config->writeEntry(QString::fromLatin1("MenuBar"), entryList); |
636 | else | 636 | else |
637 | config->deleteEntry(QString::fromLatin1("MenuBar")); | 637 | config->deleteEntry(QString::fromLatin1("MenuBar")); |
638 | } | 638 | } |
639 | 639 | ||
640 | int n = 1; // Toolbar counter. toolbars are counted from 1, | 640 | int n = 1; // Toolbar counter. toolbars are counted from 1, |
641 | KToolBar *toolbar = 0; | 641 | KToolBar *toolbar = 0; |
642 | QPtrListIterator<KToolBar> it( toolBarIterator() ); | 642 | QPtrListIterator<KToolBar> it( toolBarIterator() ); |
643 | while ( ( toolbar = it.current() ) ) { | 643 | while ( ( toolbar = it.current() ) ) { |
644 | ++it; | 644 | ++it; |
645 | QString group; | 645 | QString group; |
646 | if (!configGroup.isEmpty()) | 646 | if (!configGroup.isEmpty()) |
647 | { | 647 | { |
648 | // Give a number to the toolbar, but prefer a name if there is one, | 648 | // 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 | 649 | // because there's no real guarantee on the ordering of toolbars |
650 | group = (!::qstrcmp(toolbar->name(), "unnamed") ? QString::number(n) : QString(" ")+toolbar->name()); | 650 | group = (!::qstrcmp(toolbar->name(), "unnamed") ? QString::number(n) : QString(" ")+toolbar->name()); |
651 | group.prepend(" Toolbar"); | 651 | group.prepend(" Toolbar"); |
652 | group.prepend(configGroup); | 652 | group.prepend(configGroup); |
653 | } | 653 | } |
654 | toolbar->saveSettings(config, group); | 654 | toolbar->saveSettings(config, group); |
655 | n++; | 655 | n++; |
656 | } | 656 | } |
657 | if (!configGroup.isEmpty()) | 657 | if (!configGroup.isEmpty()) |
658 | config->setGroup(oldGroup); | 658 | config->setGroup(oldGroup); |
659 | } | 659 | } |
660 | 660 | ||
661 | bool KMainWindow::readPropertiesInternal( KConfig *config, int number ) | 661 | bool KMainWindow::readPropertiesInternal( KConfig *config, int number ) |
662 | { | 662 | { |
663 | if ( number == 1 ) | 663 | if ( number == 1 ) |
664 | readGlobalProperties( config ); | 664 | readGlobalProperties( config ); |
665 | 665 | ||
666 | // in order they are in toolbar list | 666 | // in order they are in toolbar list |
667 | QString s; | 667 | QString s; |
668 | s.setNum(number); | 668 | s.setNum(number); |
669 | s.prepend(QString::fromLatin1("WindowProperties")); | 669 | s.prepend(QString::fromLatin1("WindowProperties")); |
670 | 670 | ||
671 | config->setGroup(s); | 671 | config->setGroup(s); |
672 | 672 | ||
673 | // restore the object name (window role) | 673 | // restore the object name (window role) |
674 | if ( config->hasKey(QString::fromLatin1("ObjectName" )) ) | 674 | if ( config->hasKey(QString::fromLatin1("ObjectName" )) ) |
675 | setName( config->readEntry(QString::fromLatin1("ObjectName")).latin1()); // latin1 is right here | 675 | setName( config->readEntry(QString::fromLatin1("ObjectName")).latin1()); // latin1 is right here |
676 | 676 | ||
677 | applyMainWindowSettings(config); // Menubar, statusbar and toolbar settings. | 677 | applyMainWindowSettings(config); // Menubar, statusbar and toolbar settings. |
678 | 678 | ||
679 | s.setNum(number); | 679 | s.setNum(number); |
680 | config->setGroup(s); | 680 | config->setGroup(s); |
681 | readProperties(config); | 681 | readProperties(config); |
682 | return true; | 682 | return true; |
683 | } | 683 | } |
684 | 684 | ||
685 | void KMainWindow::applyMainWindowSettings(KConfig *config, const QString &configGroup) | 685 | void KMainWindow::applyMainWindowSettings(KConfig *config, const QString &configGroup) |
686 | { | 686 | { |
687 | kdDebug(200) << "KMainWindow::applyMainWindowSettings" << endl; | 687 | kdDebug(200) << "KMainWindow::applyMainWindowSettings" << endl; |
688 | QString entry; | 688 | QString entry; |
689 | //US QStrList entryList; | 689 | //US QStrList entryList; |
690 | QStringList entryList; | 690 | QStringList entryList; |
691 | int i = 0; // Number of entries in list | 691 | int i = 0; // Number of entries in list |
692 | 692 | ||
693 | if (!configGroup.isEmpty()) | 693 | if (!configGroup.isEmpty()) |
694 | config->setGroup(configGroup); | 694 | config->setGroup(configGroup); |
695 | 695 | ||
696 | restoreWindowSize(config); | 696 | restoreWindowSize(config); |
697 | 697 | ||
698 | QStatusBar* sb = internalStatusBar(); | 698 | QStatusBar* sb = internalStatusBar(); |
699 | if (sb) { | 699 | if (sb) { |
700 | entryList.clear(); | 700 | entryList.clear(); |
701 | //US i = config->readListEntry (QString::fromLatin1("StatusBar"), entryList, ';'); | 701 | //US i = config->readListEntry (QString::fromLatin1("StatusBar"), entryList, ';'); |
702 | entryList = config->readListEntry (QString::fromLatin1("StatusBar")); | 702 | entryList = config->readListEntry (QString::fromLatin1("StatusBar")); |
703 | entry = entryList.first(); | 703 | entry = entryList.first(); |
704 | if (entry == QString::fromLatin1("Disabled")) | 704 | if (entry == QString::fromLatin1("Disabled")) |
705 | sb->hide(); | 705 | sb->hide(); |
706 | else | 706 | else |
707 | sb->show(); | 707 | sb->show(); |
708 | if(d->showStatusBarAction) | 708 | if(d->showStatusBarAction) |
709 | d->showStatusBarAction->setChecked(!sb->isHidden()); | 709 | d->showStatusBarAction->setChecked(!sb->isHidden()); |
710 | } | 710 | } |
711 | 711 | ||
712 | QMenuBar* mb = internalMenuBar(); | 712 | QMenuBar* mb = internalMenuBar(); |
713 | if (mb) { | 713 | if (mb) { |
714 | entryList.clear(); | 714 | entryList.clear(); |
715 | //US i = config->readListEntry (QString::fromLatin1("MenuBar"), entryList, ';'); | 715 | //US i = config->readListEntry (QString::fromLatin1("MenuBar"), entryList, ';'); |
716 | entryList = config->readListEntry (QString::fromLatin1("MenuBar")); | 716 | entryList = config->readListEntry (QString::fromLatin1("MenuBar")); |
717 | entry = entryList.first(); | 717 | entry = entryList.first(); |
718 | if (entry==QString::fromLatin1("Disabled")) | 718 | if (entry==QString::fromLatin1("Disabled")) |
719 | { | 719 | { |
720 | mb->hide(); | 720 | mb->hide(); |
721 | } else | 721 | } else |
722 | { | 722 | { |
723 | mb->show(); | 723 | mb->show(); |
724 | } | 724 | } |
725 | } | 725 | } |
726 | 726 | ||
727 | int n = 1; // Toolbar counter. toolbars are counted from 1, | 727 | int n = 1; // Toolbar counter. toolbars are counted from 1, |
728 | KToolBar *toolbar; | 728 | KToolBar *toolbar; |
729 | QPtrListIterator<KToolBar> it( toolBarIterator() ); // must use own iterator | 729 | QPtrListIterator<KToolBar> it( toolBarIterator() ); // must use own iterator |
730 | 730 | ||
731 | for ( ; it.current(); ++it) { | 731 | for ( ; it.current(); ++it) { |
732 | toolbar= it.current(); | 732 | toolbar= it.current(); |
733 | QString group; | 733 | QString group; |
734 | if (!configGroup.isEmpty()) | 734 | if (!configGroup.isEmpty()) |
735 | { | 735 | { |
736 | // Give a number to the toolbar, but prefer a name if there is one, | 736 | // 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 | 737 | // because there's no real guarantee on the ordering of toolbars |
738 | group = (!::qstrcmp(toolbar->name(), "unnamed") ? QString::number(n) : QString(" ")+toolbar->name()); | 738 | group = (!::qstrcmp(toolbar->name(), "unnamed") ? QString::number(n) : QString(" ")+toolbar->name()); |
739 | group.prepend(" Toolbar"); | 739 | group.prepend(" Toolbar"); |
740 | group.prepend(configGroup); | 740 | group.prepend(configGroup); |
741 | } | 741 | } |
742 | toolbar->applySettings(config, group); | 742 | toolbar->applySettings(config, group); |
743 | n++; | 743 | n++; |
744 | } | 744 | } |
745 | 745 | ||
746 | finalizeGUI( true ); | 746 | finalizeGUI( true ); |
747 | } | 747 | } |
748 | 748 | ||
749 | void KMainWindow::finalizeGUI( bool force ) | 749 | void KMainWindow::finalizeGUI( bool force ) |
750 | { | 750 | { |
751 | //kdDebug(200) << "KMainWindow::finalizeGUI force=" << force << endl; | 751 | //kdDebug(200) << "KMainWindow::finalizeGUI force=" << force << endl; |
752 | // The whole reason for this is that moveToolBar relies on the indexes | 752 | // 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 | 753 | // of the other toolbars, so in theory it should be called only once per |
754 | // toolbar, but in increasing order of indexes. | 754 | // toolbar, but in increasing order of indexes. |
755 | // Since we can't do that immediately, we move them, and _then_ | 755 | // Since we can't do that immediately, we move them, and _then_ |
756 | // we call positionYourself again for each of them, but this time | 756 | // we call positionYourself again for each of them, but this time |
757 | // the toolbariterator should give them in the proper order. | 757 | // the toolbariterator should give them in the proper order. |
758 | // Both the XMLGUI and applySettings call this, hence "force" for the latter. | 758 | // Both the XMLGUI and applySettings call this, hence "force" for the latter. |
759 | QPtrListIterator<KToolBar> it( toolBarIterator() ); | 759 | QPtrListIterator<KToolBar> it( toolBarIterator() ); |
760 | for ( ; it.current() ; ++ it ) | 760 | for ( ; it.current() ; ++ it ) |
761 | it.current()->positionYourself( force ); | 761 | it.current()->positionYourself( force ); |
762 | 762 | ||
763 | d->settingsDirty = false; | 763 | d->settingsDirty = false; |
764 | } | 764 | } |
765 | 765 | ||
766 | void KMainWindow::saveWindowSize( KConfig * config ) const | 766 | void KMainWindow::saveWindowSize( KConfig * config ) const |
767 | { | 767 | { |
768 | /*US | 768 | /*US |
769 | int scnum = QApplication::desktop()->screenNumber(parentWidget()); | 769 | int scnum = QApplication::desktop()->screenNumber(parentWidget()); |
770 | QRect desk = QApplication::desktop()->screenGeometry(scnum); | 770 | QRect desk = QApplication::desktop()->screenGeometry(scnum); |
771 | */ | 771 | */ |
772 | QRect desk = KGlobalSettings::desktopGeometry(0); | 772 | QRect desk = KGlobalSettings::desktopGeometry(0); |
773 | 773 | ||
774 | QRect size( desk.width(), width(), desk.height(), height() ); | 774 | QRect size( desk.width(), width(), desk.height(), height() ); |
775 | if(size != d->defaultWindowSize){ | 775 | if(size != d->defaultWindowSize){ |
776 | config->writeEntry(QString::fromLatin1("Width %1").arg(desk.width()), width() ); | 776 | config->writeEntry(QString::fromLatin1("Width %1").arg(desk.width()), width() ); |
777 | config->writeEntry(QString::fromLatin1("Height %1").arg(desk.height()), height() ); | 777 | config->writeEntry(QString::fromLatin1("Height %1").arg(desk.height()), height() ); |
778 | } | 778 | } |
779 | else{ | 779 | else{ |
780 | config->deleteEntry(QString::fromLatin1("Width %1").arg(desk.width())); | 780 | config->deleteEntry(QString::fromLatin1("Width %1").arg(desk.width())); |
781 | config->deleteEntry(QString::fromLatin1("Height %1").arg(desk.height())); | 781 | config->deleteEntry(QString::fromLatin1("Height %1").arg(desk.height())); |
782 | } | 782 | } |
783 | } | 783 | } |
784 | 784 | ||
785 | void KMainWindow::restoreWindowSize( KConfig * config ) | 785 | void KMainWindow::restoreWindowSize( KConfig * config ) |
786 | { | 786 | { |
787 | if (d->care_about_geometry) { | 787 | if (d->care_about_geometry) { |
788 | parseGeometry(true); | 788 | parseGeometry(true); |
789 | } else { | 789 | } else { |
790 | // restore the size | 790 | // restore the size |
791 | /*US int scnum = QApplication::desktop()->screenNumber(parentWidget()); | 791 | /*US int scnum = QApplication::desktop()->screenNumber(parentWidget()); |
792 | QRect desk = QApplication::desktop()->screenGeometry(scnum); | 792 | QRect desk = QApplication::desktop()->screenGeometry(scnum); |
793 | */ | 793 | */ |
794 | QRect desk = KGlobalSettings::desktopGeometry(0); | 794 | QRect desk = KGlobalSettings::desktopGeometry(0); |
795 | 795 | ||
796 | QSize size( config->readNumEntry( QString::fromLatin1("Width %1").arg(desk.width()), 0 ), | 796 | QSize size( config->readNumEntry( QString::fromLatin1("Width %1").arg(desk.width()), 0 ), |
797 | config->readNumEntry( QString::fromLatin1("Height %1").arg(desk.height()), 0 ) ); | 797 | config->readNumEntry( QString::fromLatin1("Height %1").arg(desk.height()), 0 ) ); |
798 | if (size.isEmpty()) { | 798 | if (size.isEmpty()) { |
799 | // try the KDE 2.0 way | 799 | // try the KDE 2.0 way |
800 | size = QSize( config->readNumEntry( QString::fromLatin1("Width"), 0 ), | 800 | size = QSize( config->readNumEntry( QString::fromLatin1("Width"), 0 ), |
801 | config->readNumEntry( QString::fromLatin1("Height"), 0 ) ); | 801 | config->readNumEntry( QString::fromLatin1("Height"), 0 ) ); |
802 | if (!size.isEmpty()) { | 802 | if (!size.isEmpty()) { |
803 | // make sure the other resolutions don't get old settings | 803 | // make sure the other resolutions don't get old settings |
804 | config->writeEntry( QString::fromLatin1("Width"), 0 ); | 804 | config->writeEntry( QString::fromLatin1("Width"), 0 ); |
805 | config->writeEntry( QString::fromLatin1("Height"), 0 ); | 805 | config->writeEntry( QString::fromLatin1("Height"), 0 ); |
806 | } | 806 | } |
807 | } | 807 | } |
808 | if ( !size.isEmpty() ) | 808 | if ( !size.isEmpty() ) |
809 | resize( size ); | 809 | resize( size ); |
810 | } | 810 | } |
811 | } | 811 | } |
812 | 812 | ||
813 | bool KMainWindow::initialGeometrySet() const | 813 | bool KMainWindow::initialGeometrySet() const |
814 | { | 814 | { |
815 | return d->care_about_geometry; | 815 | return d->care_about_geometry; |
816 | } | 816 | } |
817 | 817 | ||
818 | void KMainWindow::ignoreInitialGeometry() | 818 | void KMainWindow::ignoreInitialGeometry() |
819 | { | 819 | { |
820 | d->care_about_geometry = false; | 820 | d->care_about_geometry = false; |
821 | } | 821 | } |
822 | 822 | ||
823 | void KMainWindow::setSettingsDirty() | 823 | void KMainWindow::setSettingsDirty() |
824 | { | 824 | { |
825 | //kdDebug(200) << "KMainWindow::setSettingsDirty" << endl; | 825 | //kdDebug(200) << "KMainWindow::setSettingsDirty" << endl; |
826 | d->settingsDirty = true; | 826 | d->settingsDirty = true; |
827 | if ( d->autoSaveSettings ) | 827 | if ( d->autoSaveSettings ) |
828 | { | 828 | { |
829 | // Use a timer to save "immediately" user-wise, but not too immediately | 829 | // 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) | 830 | // (to compress calls and save only once, in case of multiple changes) |
831 | if ( !d->settingsTimer ) | 831 | if ( !d->settingsTimer ) |
832 | { | 832 | { |
833 | d->settingsTimer = new QTimer( this ); | 833 | d->settingsTimer = new QTimer( this ); |
834 | connect( d->settingsTimer, SIGNAL( timeout() ), SLOT( saveAutoSaveSettings() ) ); | 834 | connect( d->settingsTimer, SIGNAL( timeout() ), SLOT( saveAutoSaveSettings() ) ); |
835 | } | 835 | } |
836 | d->settingsTimer->start( 500, true ); | 836 | d->settingsTimer->start( 500, true ); |
837 | } | 837 | } |
838 | } | 838 | } |
839 | 839 | ||
840 | bool KMainWindow::settingsDirty() const | 840 | bool KMainWindow::settingsDirty() const |
841 | { | 841 | { |
842 | return d->settingsDirty; | 842 | return d->settingsDirty; |
843 | } | 843 | } |
844 | 844 | ||
845 | QString KMainWindow::settingsGroup() const | 845 | QString KMainWindow::settingsGroup() const |
846 | { | 846 | { |
847 | return d->autoSaveGroup; | 847 | return d->autoSaveGroup; |
848 | } | 848 | } |
849 | 849 | ||
850 | void KMainWindow::resizeEvent( QResizeEvent * ) | 850 | void KMainWindow::resizeEvent( QResizeEvent * e) |
851 | { | 851 | { |
852 | if ( d->autoSaveWindowSize ) | 852 | if ( d->autoSaveWindowSize ) |
853 | setSettingsDirty(); | 853 | setSettingsDirty(); |
854 | QMainWindow::resizeEvent( e ); | ||
854 | } | 855 | } |
855 | 856 | ||
856 | bool KMainWindow::hasMenuBar() | 857 | bool KMainWindow::hasMenuBar() |
857 | { | 858 | { |
858 | return (internalMenuBar()); | 859 | return (internalMenuBar()); |
859 | } | 860 | } |
860 | 861 | ||
861 | //US KMenuBar *KMainWindow::menuBar() | 862 | //US KMenuBar *KMainWindow::menuBar() |
862 | QMenuBar *KMainWindow::menuBar() | 863 | QMenuBar *KMainWindow::menuBar() |
863 | { | 864 | { |
864 | //US KMenuBar * mb = internalMenuBar(); | 865 | //US KMenuBar * mb = internalMenuBar(); |
865 | QMenuBar * mb = internalMenuBar(); | 866 | QMenuBar * mb = internalMenuBar(); |
866 | if ( !mb ) { | 867 | if ( !mb ) { |
867 | //US mb = new KMenuBar( this ); | 868 | //US mb = new KMenuBar( this ); |
868 | mb = new QMenuBar( this ); | 869 | mb = new QMenuBar( this ); |
869 | // trigger a re-layout and trigger a call to the private | 870 | // trigger a re-layout and trigger a call to the private |
870 | // setMenuBar method. | 871 | // setMenuBar method. |
871 | QMainWindow::menuBar(); | 872 | QMainWindow::menuBar(); |
872 | } | 873 | } |
873 | return mb; | 874 | return mb; |
874 | } | 875 | } |
875 | 876 | ||
876 | //US KStatusBar *KMainWindow::statusBar() | 877 | //US KStatusBar *KMainWindow::statusBar() |
877 | QStatusBar *KMainWindow::statusBar() | 878 | QStatusBar *KMainWindow::statusBar() |
878 | { | 879 | { |
879 | //US KStatusBar * sb = internalStatusBar(); | 880 | //US KStatusBar * sb = internalStatusBar(); |
880 | QStatusBar * sb = internalStatusBar(); | 881 | QStatusBar * sb = internalStatusBar(); |
881 | if ( !sb ) { | 882 | if ( !sb ) { |
882 | //US sb = new KStatusBar( this ); | 883 | //US sb = new KStatusBar( this ); |
883 | sb = new QStatusBar( this ); | 884 | sb = new QStatusBar( this ); |
884 | // trigger a re-layout and trigger a call to the private | 885 | // trigger a re-layout and trigger a call to the private |
885 | // setStatusBar method. | 886 | // setStatusBar method. |
886 | QMainWindow::statusBar(); | 887 | QMainWindow::statusBar(); |
887 | } | 888 | } |
888 | return sb; | 889 | return sb; |
889 | } | 890 | } |
890 | 891 | ||
891 | void KMainWindow::shuttingDown() | 892 | void KMainWindow::shuttingDown() |
892 | { | 893 | { |
893 | // Needed for Qt <= 3.0.3 at least to prevent reentrancy | 894 | // Needed for Qt <= 3.0.3 at least to prevent reentrancy |
894 | // when queryExit() shows a dialog. Check before removing! | 895 | // when queryExit() shows a dialog. Check before removing! |
895 | static bool reentrancy_protection = false; | 896 | static bool reentrancy_protection = false; |
896 | if (!reentrancy_protection) | 897 | if (!reentrancy_protection) |
897 | { | 898 | { |
898 | reentrancy_protection = true; | 899 | reentrancy_protection = true; |
899 | // call the virtual queryExit | 900 | // call the virtual queryExit |
900 | queryExit(); | 901 | queryExit(); |
901 | reentrancy_protection = false; | 902 | reentrancy_protection = false; |
902 | } | 903 | } |
903 | 904 | ||
904 | } | 905 | } |
905 | 906 | ||
906 | //US KMenuBar *KMainWindow::internalMenuBar() | 907 | //US KMenuBar *KMainWindow::internalMenuBar() |
907 | QMenuBar *KMainWindow::internalMenuBar() | 908 | QMenuBar *KMainWindow::internalMenuBar() |
908 | { | 909 | { |
909 | //US QObjectList *l = queryList( "KMenuBar", 0, false, false ); | 910 | //US QObjectList *l = queryList( "KMenuBar", 0, false, false ); |
910 | QObjectList *l = queryList( "QMenuBar", 0, false, false ); | 911 | QObjectList *l = queryList( "QMenuBar", 0, false, false ); |
911 | if ( !l || !l->first() ) { | 912 | if ( !l || !l->first() ) { |
912 | delete l; | 913 | delete l; |
913 | return 0; | 914 | return 0; |
914 | } | 915 | } |
915 | 916 | ||
916 | //US KMenuBar *m = (KMenuBar*)l->first(); | 917 | //US KMenuBar *m = (KMenuBar*)l->first(); |
917 | QMenuBar *m = (QMenuBar*)l->first(); | 918 | QMenuBar *m = (QMenuBar*)l->first(); |
918 | delete l; | 919 | delete l; |
919 | return m; | 920 | return m; |
920 | } | 921 | } |
921 | 922 | ||
922 | //US KStatusBar *KMainWindow::internalStatusBar() | 923 | //US KStatusBar *KMainWindow::internalStatusBar() |
923 | QStatusBar *KMainWindow::internalStatusBar() | 924 | QStatusBar *KMainWindow::internalStatusBar() |
924 | { | 925 | { |
925 | //US QObjectList *l = queryList( "KStatusBar", 0, false, false ); | 926 | //US QObjectList *l = queryList( "KStatusBar", 0, false, false ); |
926 | QObjectList *l = queryList( "QStatusBar", 0, false, false ); | 927 | QObjectList *l = queryList( "QStatusBar", 0, false, false ); |
927 | if ( !l || !l->first() ) { | 928 | if ( !l || !l->first() ) { |
928 | delete l; | 929 | delete l; |
929 | return 0; | 930 | return 0; |
930 | } | 931 | } |
931 | 932 | ||
932 | //US KStatusBar *s = (KStatusBar*)l->first(); | 933 | //US KStatusBar *s = (KStatusBar*)l->first(); |
933 | QStatusBar *s = (QStatusBar*)l->first(); | 934 | QStatusBar *s = (QStatusBar*)l->first(); |
934 | delete l; | 935 | delete l; |
935 | return s; | 936 | return s; |
936 | } | 937 | } |
937 | 938 | ||
938 | void KMainWindow::childEvent( QChildEvent* e) | 939 | void KMainWindow::childEvent( QChildEvent* e) |
939 | { | 940 | { |
940 | QMainWindow::childEvent( e ); | 941 | QMainWindow::childEvent( e ); |
941 | } | 942 | } |
942 | 943 | ||
943 | void KMainWindow::paintEvent( QPaintEvent * ) | 944 | void KMainWindow::paintEvent( QPaintEvent * e) |
944 | { | 945 | { |
945 | // do nothing | 946 | QMainWindow::paintEvent( e ); |
946 | } | 947 | } |
947 | 948 | ||
948 | QSize KMainWindow::sizeForCentralWidgetSize(QSize size) | 949 | QSize KMainWindow::sizeForCentralWidgetSize(QSize size) |
949 | { | 950 | { |
950 | KToolBar *tb = (KToolBar*)child( "mainToolBar", "KToolBar" ); | 951 | KToolBar *tb = (KToolBar*)child( "mainToolBar", "KToolBar" ); |
951 | if (tb && !tb->isHidden()) { | 952 | if (tb && !tb->isHidden()) { |
952 | switch( tb->barPos() ) | 953 | switch( tb->barPos() ) |
953 | { | 954 | { |
954 | case KToolBar::Top: | 955 | case KToolBar::Top: |
955 | case KToolBar::Bottom: | 956 | case KToolBar::Bottom: |
956 | size += QSize(0, tb->sizeHint().height()); | 957 | size += QSize(0, tb->sizeHint().height()); |
957 | break; | 958 | break; |
958 | 959 | ||
959 | case KToolBar::Left: | 960 | case KToolBar::Left: |
960 | case KToolBar::Right: | 961 | case KToolBar::Right: |
961 | size += QSize(toolBar()->sizeHint().width(), 0); | 962 | size += QSize(toolBar()->sizeHint().width(), 0); |
962 | break; | 963 | break; |
963 | 964 | ||
964 | case KToolBar::Flat: | 965 | case KToolBar::Flat: |
965 | //US size += QSize(0, 3+kapp->style().pixelMetric( QStyle::PM_DockWindowHandleExtent )); | 966 | //US size += QSize(0, 3+kapp->style().pixelMetric( QStyle::PM_DockWindowHandleExtent )); |
966 | size += QSize(0, tb->sizeHint().height()); | 967 | size += QSize(0, tb->sizeHint().height()); |
967 | break; | 968 | break; |
968 | 969 | ||
969 | default: | 970 | default: |
970 | break; | 971 | break; |
971 | } | 972 | } |
972 | } | 973 | } |
973 | //US KMenuBar *mb = menuBar(); | 974 | //US KMenuBar *mb = menuBar(); |
974 | QMenuBar *mb = menuBar(); | 975 | QMenuBar *mb = menuBar(); |
975 | if (!mb->isHidden()) { | 976 | if (!mb->isHidden()) { |
976 | size += QSize(0,mb->heightForWidth(size.width())); | 977 | size += QSize(0,mb->heightForWidth(size.width())); |
977 | /*US if (style().styleHint(QStyle::SH_MainWindow_SpaceBelowMenuBar, this)) | 978 | /*US if (style().styleHint(QStyle::SH_MainWindow_SpaceBelowMenuBar, this)) |
978 | size += QSize( 0, dockWindowsMovable() ? 1 : 2); | 979 | size += QSize( 0, dockWindowsMovable() ? 1 : 2); |
979 | */ | 980 | */ |
980 | size += QSize( 0, 2); | 981 | size += QSize( 0, 2); |
981 | } | 982 | } |
982 | QStatusBar *sb = internalStatusBar(); | 983 | QStatusBar *sb = internalStatusBar(); |
983 | if( sb && !sb->isHidden() ) | 984 | if( sb && !sb->isHidden() ) |
984 | size += QSize(0, sb->sizeHint().height()); | 985 | size += QSize(0, sb->sizeHint().height()); |
985 | 986 | ||
986 | return size; | 987 | return size; |
987 | } | 988 | } |
988 | 989 | ||
989 | // why do we support old gcc versions? using KXMLGUIBuilder::finalizeGUI; | 990 | // why do we support old gcc versions? using KXMLGUIBuilder::finalizeGUI; |
990 | void KMainWindow::finalizeGUI( KXMLGUIClient *client ) | 991 | void KMainWindow::finalizeGUI( KXMLGUIClient *client ) |
991 | { /*US KXMLGUIBuilder::finalizeGUI( client );*/ } | 992 | { /*US KXMLGUIBuilder::finalizeGUI( client );*/ } |
992 | 993 | ||
993 | void KMainWindow::virtual_hook( int id, void* data ) | 994 | void KMainWindow::virtual_hook( int id, void* data ) |
994 | { /*US KXMLGUIBuilder::virtual_hook( id, data );*/ | 995 | { /*US KXMLGUIBuilder::virtual_hook( id, data );*/ |
995 | KXMLGUIClient::virtual_hook( id, data ); } | 996 | KXMLGUIClient::virtual_hook( id, data ); } |
diff --git a/microkde/kdeui/kmainwindow.h b/microkde/kdeui/kmainwindow.h index 2aafb9d..2dc8033 100644 --- a/microkde/kdeui/kmainwindow.h +++ b/microkde/kdeui/kmainwindow.h | |||
@@ -1,777 +1,777 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the KDE libraries | 2 | This file is part of the KDE libraries |
3 | 3 | ||
4 | This library is free software; you can redistribute it and/or | 4 | This library is free software; you can redistribute it and/or |
5 | modify it under the terms of the GNU Library General Public | 5 | modify it under the terms of the GNU Library General Public |
6 | License version 2 as published by the Free Software Foundation. | 6 | License version 2 as published by the Free Software Foundation. |
7 | 7 | ||
8 | This library is distributed in the hope that it will be useful, | 8 | This library is distributed in the hope that it will be useful, |
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
11 | Library General Public License for more details. | 11 | Library General Public License for more details. |
12 | 12 | ||
13 | You should have received a copy of the GNU Library General Public License | 13 | You should have received a copy of the GNU Library General Public License |
14 | along with this library; see the file COPYING.LIB. If not, write to | 14 | along with this library; see the file COPYING.LIB. If not, write to |
15 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 15 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
16 | Boston, MA 02111-1307, USA. | 16 | Boston, MA 02111-1307, USA. |
17 | 17 | ||
18 | $Id$ | 18 | $Id$ |
19 | 19 | ||
20 | */ | 20 | */ |
21 | 21 | ||
22 | 22 | ||
23 | 23 | ||
24 | #ifndef KMAINWINDOW_H | 24 | #ifndef KMAINWINDOW_H |
25 | #define KMAINWINDOW_H | 25 | #define KMAINWINDOW_H |
26 | 26 | ||
27 | /*US | 27 | /*US |
28 | #include "kxmlguifactory.h" | 28 | #include "kxmlguifactory.h" |
29 | #include "kxmlguiclient.h" | 29 | #include "kxmlguiclient.h" |
30 | #include "kxmlguibuilder.h" | 30 | #include "kxmlguibuilder.h" |
31 | #include <qmetaobject.h> | 31 | #include <qmetaobject.h> |
32 | 32 | ||
33 | class KPopupMenu; | 33 | class KPopupMenu; |
34 | class KXMLGUIFactory; | 34 | class KXMLGUIFactory; |
35 | class KConfig; | 35 | class KConfig; |
36 | class KHelpMenu; | 36 | class KHelpMenu; |
37 | class KStatusBar; | 37 | class KStatusBar; |
38 | class QStatusBar; | 38 | class QStatusBar; |
39 | class KMenuBar; | 39 | class KMenuBar; |
40 | class KMWSessionManaged; | 40 | class KMWSessionManaged; |
41 | class KAccel; | 41 | class KAccel; |
42 | class KToolBarMenuAction; | 42 | class KToolBarMenuAction; |
43 | */ | 43 | */ |
44 | 44 | ||
45 | class QMenuBar; | 45 | class QMenuBar; |
46 | class QStatusBar; | 46 | class QStatusBar; |
47 | class KMainWindowPrivate; | 47 | class KMainWindowPrivate; |
48 | class KAction; | 48 | class KAction; |
49 | 49 | ||
50 | #include <ktoolbar.h> | 50 | #include <ktoolbar.h> |
51 | #include <ktoolbarhandler.h> | 51 | #include <ktoolbarhandler.h> |
52 | #include <kxmlguiclient.h> | 52 | #include <kxmlguiclient.h> |
53 | #include <qmainwindow.h> | 53 | #include <qmainwindow.h> |
54 | #include <qptrlist.h> | 54 | #include <qptrlist.h> |
55 | 55 | ||
56 | class KActionCollection; | 56 | class KActionCollection; |
57 | 57 | ||
58 | class KMainWindow : public QMainWindow, virtual public KXMLGUIClient | 58 | class KMainWindow : public QMainWindow, virtual public KXMLGUIClient |
59 | { | 59 | { |
60 | Q_OBJECT | 60 | Q_OBJECT |
61 | 61 | ||
62 | private: | 62 | private: |
63 | //US create private defaultconstructor | 63 | //US create private defaultconstructor |
64 | KMainWindow() {;}; | 64 | KMainWindow() {;}; |
65 | 65 | ||
66 | 66 | ||
67 | public: | 67 | public: |
68 | /** | 68 | /** |
69 | * Construct a main window. | 69 | * Construct a main window. |
70 | * | 70 | * |
71 | * @param parent The widget parent. This is usually 0 but it may also be the window | 71 | * @param parent The widget parent. This is usually 0 but it may also be the window |
72 | * group leader. In that case, the KMainWindow becomes sort of a | 72 | * group leader. In that case, the KMainWindow becomes sort of a |
73 | * secondary window. | 73 | * secondary window. |
74 | * | 74 | * |
75 | * @param name The object name. For session management and window management to work | 75 | * @param name The object name. For session management and window management to work |
76 | * properly, all main windows in the application should have a | 76 | * properly, all main windows in the application should have a |
77 | * different name. When passing 0 (the default), KMainWindow will create | 77 | * different name. When passing 0 (the default), KMainWindow will create |
78 | * a unique name, but it's recommended to explicitly pass a window name that will | 78 | * a unique name, but it's recommended to explicitly pass a window name that will |
79 | * also describe the type of the window. If there can be several windows of the same | 79 | * also describe the type of the window. If there can be several windows of the same |
80 | * type, append '#' (hash) to the name, and KMainWindow will append numbers to make | 80 | * type, append '#' (hash) to the name, and KMainWindow will append numbers to make |
81 | * the names unique. For example, for a mail client which has one main window showing | 81 | * the names unique. For example, for a mail client which has one main window showing |
82 | * the mails and folders, and which can also have one or more windows for composing | 82 | * the mails and folders, and which can also have one or more windows for composing |
83 | * mails, the name for the folders window should be e.g. "mainwindow" and | 83 | * mails, the name for the folders window should be e.g. "mainwindow" and |
84 | * for the composer windows "composer#". | 84 | * for the composer windows "composer#". |
85 | * | 85 | * |
86 | * @param f Specify the widget flags. The default is | 86 | * @param f Specify the widget flags. The default is |
87 | * WType_TopLevel and WDestructiveClose. TopLevel indicates that a | 87 | * WType_TopLevel and WDestructiveClose. TopLevel indicates that a |
88 | * main window is a toplevel window, regardless of whether it has a | 88 | * main window is a toplevel window, regardless of whether it has a |
89 | * parent or not. DestructiveClose indicates that a main window is | 89 | * parent or not. DestructiveClose indicates that a main window is |
90 | * automatically destroyed when its window is closed. Pass 0 if | 90 | * automatically destroyed when its window is closed. Pass 0 if |
91 | * you do not want this behavior. | 91 | * you do not want this behavior. |
92 | * | 92 | * |
93 | * KMainWindows must be created on the heap with 'new', like: | 93 | * KMainWindows must be created on the heap with 'new', like: |
94 | * <pre> KMainWindow *kmw = new KMainWindow (...</pre> | 94 | * <pre> KMainWindow *kmw = new KMainWindow (...</pre> |
95 | **/ | 95 | **/ |
96 | //LR remove WDestructiveClose | 96 | //LR remove WDestructiveClose |
97 | KMainWindow( QWidget* parent = 0, const char *name = 0, WFlags f = WType_TopLevel /*| WDestructiveClose*/ ); | 97 | KMainWindow( QWidget* parent = 0, const char *name = 0 ); //, WFlags f = WType_TopLevel /*| WDestructiveClose*/ ; |
98 | 98 | ||
99 | 99 | ||
100 | /** | 100 | /** |
101 | * Destructor. | 101 | * Destructor. |
102 | * | 102 | * |
103 | * Will also destroy the toolbars, and menubar if | 103 | * Will also destroy the toolbars, and menubar if |
104 | * needed. | 104 | * needed. |
105 | */ | 105 | */ |
106 | virtual ~KMainWindow(); | 106 | virtual ~KMainWindow(); |
107 | 107 | ||
108 | /** | 108 | /** |
109 | * Retrieve the standard help menu. | 109 | * Retrieve the standard help menu. |
110 | * | 110 | * |
111 | * It contains entires for the | 111 | * It contains entires for the |
112 | * help system (activated by F1), an optional "What's This?" entry | 112 | * help system (activated by F1), an optional "What's This?" entry |
113 | * (activated by Shift F1), an application specific dialog box, | 113 | * (activated by Shift F1), an application specific dialog box, |
114 | * and an "About KDE" dialog box. | 114 | * and an "About KDE" dialog box. |
115 | * | 115 | * |
116 | * Example (adding a standard help menu to your application): | 116 | * Example (adding a standard help menu to your application): |
117 | * <pre> | 117 | * <pre> |
118 | * KPopupMenu *help = helpMenu( <myTextString> ); | 118 | * KPopupMenu *help = helpMenu( <myTextString> ); |
119 | * menuBar()->insertItem( i18n("&Help"), help ); | 119 | * menuBar()->insertItem( i18n("&Help"), help ); |
120 | * </pre> | 120 | * </pre> |
121 | * | 121 | * |
122 | * @param aboutAppText The string that is used in the application | 122 | * @param aboutAppText The string that is used in the application |
123 | * specific dialog box. If you leave this string empty the | 123 | * specific dialog box. If you leave this string empty the |
124 | * information in the global @ref KAboutData of the | 124 | * information in the global @ref KAboutData of the |
125 | * application will be used to make a standard dialog box. | 125 | * application will be used to make a standard dialog box. |
126 | * | 126 | * |
127 | * @param showWhatsThis Set this to false if you do not want to include | 127 | * @param showWhatsThis Set this to false if you do not want to include |
128 | * the "What's This" menu entry. | 128 | * the "What's This" menu entry. |
129 | * | 129 | * |
130 | * @return A standard help menu. | 130 | * @return A standard help menu. |
131 | */ | 131 | */ |
132 | //US KPopupMenu* helpMenu( const QString &aboutAppText = QString::null, | 132 | //US KPopupMenu* helpMenu( const QString &aboutAppText = QString::null, |
133 | //US bool showWhatsThis = TRUE ); | 133 | //US bool showWhatsThis = TRUE ); |
134 | 134 | ||
135 | /** | 135 | /** |
136 | * Returns the help menu. Creates a standard help menu if none exists yet. | 136 | * Returns the help menu. Creates a standard help menu if none exists yet. |
137 | * | 137 | * |
138 | * It contains entries for the | 138 | * It contains entries for the |
139 | * help system (activated by F1), an optional "What's This?" entry | 139 | * help system (activated by F1), an optional "What's This?" entry |
140 | * (activated by Shift F1), an application specific dialog box, | 140 | * (activated by Shift F1), an application specific dialog box, |
141 | * and an "About KDE" dialog box. You must create the application | 141 | * and an "About KDE" dialog box. You must create the application |
142 | * specific dialog box yourself. When the "About application" | 142 | * specific dialog box yourself. When the "About application" |
143 | * menu entry is activated, a signal will trigger the | 143 | * menu entry is activated, a signal will trigger the |
144 | * @ref showAboutApplication slot. See @ref showAboutApplication for more | 144 | * @ref showAboutApplication slot. See @ref showAboutApplication for more |
145 | * information. | 145 | * information. |
146 | * | 146 | * |
147 | * Example (adding a help menu to your application): | 147 | * Example (adding a help menu to your application): |
148 | * <pre> | 148 | * <pre> |
149 | * menuBar()->insertItem( i18n("&Help"), customHelpMenu() ); | 149 | * menuBar()->insertItem( i18n("&Help"), customHelpMenu() ); |
150 | * </pre> | 150 | * </pre> |
151 | * | 151 | * |
152 | * @param showWhatsThis Set this to @p false if you do not want to include | 152 | * @param showWhatsThis Set this to @p false if you do not want to include |
153 | * the "What's This" menu entry. | 153 | * the "What's This" menu entry. |
154 | * | 154 | * |
155 | * @return A standard help menu. | 155 | * @return A standard help menu. |
156 | */ | 156 | */ |
157 | //US KPopupMenu* customHelpMenu( bool showWhatsThis = TRUE ); | 157 | //US KPopupMenu* customHelpMenu( bool showWhatsThis = TRUE ); |
158 | 158 | ||
159 | /** | 159 | /** |
160 | * @sect Session Management | 160 | * @sect Session Management |
161 | * | 161 | * |
162 | * Try to restore the toplevel widget as defined by the number (1..X). | 162 | * Try to restore the toplevel widget as defined by the number (1..X). |
163 | * | 163 | * |
164 | * If the session did not contain so high a number, the configuration | 164 | * If the session did not contain so high a number, the configuration |
165 | * is not changed and @p false returned. | 165 | * is not changed and @p false returned. |
166 | * | 166 | * |
167 | * That means clients could simply do the following: | 167 | * That means clients could simply do the following: |
168 | * <pre> | 168 | * <pre> |
169 | * if (kapp->isRestored()){ | 169 | * if (kapp->isRestored()){ |
170 | * int n = 1; | 170 | * int n = 1; |
171 | * while (KMainWindow::canBeRestored(n)){ | 171 | * while (KMainWindow::canBeRestored(n)){ |
172 | * (new childMW)->restore(n); | 172 | * (new childMW)->restore(n); |
173 | * n++; | 173 | * n++; |
174 | * } | 174 | * } |
175 | * } else { | 175 | * } else { |
176 | * // create default application as usual | 176 | * // create default application as usual |
177 | * } | 177 | * } |
178 | * </pre> | 178 | * </pre> |
179 | * Note that @ref QWidget::show() is called implicitly in restore. | 179 | * Note that @ref QWidget::show() is called implicitly in restore. |
180 | * | 180 | * |
181 | * With this you can easily restore all toplevel windows of your | 181 | * With this you can easily restore all toplevel windows of your |
182 | * application. | 182 | * application. |
183 | * | 183 | * |
184 | * If your application uses different kinds of toplevel | 184 | * If your application uses different kinds of toplevel |
185 | * windows, then you can use @ref KMainWindow::classNameOfToplevel(n) | 185 | * windows, then you can use @ref KMainWindow::classNameOfToplevel(n) |
186 | * to determine the exact type before calling the childMW | 186 | * to determine the exact type before calling the childMW |
187 | * constructor in the example from above. | 187 | * constructor in the example from above. |
188 | * | 188 | * |
189 | * If your client has only one kind of toplevel widgets (which | 189 | * If your client has only one kind of toplevel widgets (which |
190 | * should be pretty usual) then you should use the RESTORE-macro | 190 | * should be pretty usual) then you should use the RESTORE-macro |
191 | * for backwards compatibility with 3.1 and 3.0 branches: | 191 | * for backwards compatibility with 3.1 and 3.0 branches: |
192 | * | 192 | * |
193 | * <pre> | 193 | * <pre> |
194 | * if (kapp->isRestored()) | 194 | * if (kapp->isRestored()) |
195 | * RESTORE(childMW) | 195 | * RESTORE(childMW) |
196 | * else { | 196 | * else { |
197 | * // create default application as usual | 197 | * // create default application as usual |
198 | * } | 198 | * } |
199 | * </pre> | 199 | * </pre> |
200 | * | 200 | * |
201 | * The macro expands to the term above but is easier to use and | 201 | * The macro expands to the term above but is easier to use and |
202 | * less code to write. | 202 | * less code to write. |
203 | * | 203 | * |
204 | * For new code or if you have more than one kind of toplevel | 204 | * For new code or if you have more than one kind of toplevel |
205 | * widget (each derived from @ref KMainWindow, of course), you can | 205 | * widget (each derived from @ref KMainWindow, of course), you can |
206 | * use the templated @ref kRestoreMainWindows global functions: | 206 | * use the templated @ref kRestoreMainWindows global functions: |
207 | * | 207 | * |
208 | * <pre> | 208 | * <pre> |
209 | * if (kapp->isRestored()) | 209 | * if (kapp->isRestored()) |
210 | * kRestoreMainWindows< childMW1, childMW2, childMW3 >(); | 210 | * kRestoreMainWindows< childMW1, childMW2, childMW3 >(); |
211 | * else { | 211 | * else { |
212 | * // create default application as usual | 212 | * // create default application as usual |
213 | * } | 213 | * } |
214 | * </pre> | 214 | * </pre> |
215 | * | 215 | * |
216 | * Currently, these functions are provided for up to three | 216 | * Currently, these functions are provided for up to three |
217 | * template arguments. If you need more, tell us. To help you in | 217 | * template arguments. If you need more, tell us. To help you in |
218 | * deciding whether or not you can use @ref kRestoreMainWindows, a | 218 | * deciding whether or not you can use @ref kRestoreMainWindows, a |
219 | * define KDE_RESTORE_MAIN_WINDOWS_NUM_TEMPLATE_ARGS is provided. | 219 | * define KDE_RESTORE_MAIN_WINDOWS_NUM_TEMPLATE_ARGS is provided. |
220 | * | 220 | * |
221 | * @see restore() | 221 | * @see restore() |
222 | * @see classNameOfToplevel() | 222 | * @see classNameOfToplevel() |
223 | * | 223 | * |
224 | **/ | 224 | **/ |
225 | static bool canBeRestored( int number ); | 225 | static bool canBeRestored( int number ); |
226 | 226 | ||
227 | /** | 227 | /** |
228 | * Returns the @ref className() of the @p number of the toplevel window which | 228 | * Returns the @ref className() of the @p number of the toplevel window which |
229 | * should be restored. | 229 | * should be restored. |
230 | * | 230 | * |
231 | * This is only useful if your application uses | 231 | * This is only useful if your application uses |
232 | * different kinds of toplevel windows. | 232 | * different kinds of toplevel windows. |
233 | */ | 233 | */ |
234 | static const QString classNameOfToplevel( int number ); | 234 | static const QString classNameOfToplevel( int number ); |
235 | 235 | ||
236 | /** | 236 | /** |
237 | * Restore the session specified by @p number. | 237 | * Restore the session specified by @p number. |
238 | * | 238 | * |
239 | * Returns @p false if this | 239 | * Returns @p false if this |
240 | * fails, otherwise returns @p true and shows the window. | 240 | * fails, otherwise returns @p true and shows the window. |
241 | * You should call @ref canBeRestored() first. | 241 | * You should call @ref canBeRestored() first. |
242 | * If @p show is true (default), this widget will be shown automatically. | 242 | * If @p show is true (default), this widget will be shown automatically. |
243 | */ | 243 | */ |
244 | bool restore( int number, bool show = TRUE ); | 244 | bool restore( int number, bool show = TRUE ); |
245 | 245 | ||
246 | //US virtual KXMLGUIFactory *guiFactory(); | 246 | //US virtual KXMLGUIFactory *guiFactory(); |
247 | 247 | ||
248 | /** | 248 | /** |
249 | * Create a GUI given a local XML file. | 249 | * Create a GUI given a local XML file. |
250 | * | 250 | * |
251 | * If @p xmlfile is NULL, | 251 | * If @p xmlfile is NULL, |
252 | * then it will try to construct a local XML filename like | 252 | * then it will try to construct a local XML filename like |
253 | * appnameui.rc where 'appname' is your app's name. If that file | 253 | * appnameui.rc where 'appname' is your app's name. If that file |
254 | * does not exist, then the XML UI code will only use the global | 254 | * does not exist, then the XML UI code will only use the global |
255 | * (standard) XML file for the layout purposes. | 255 | * (standard) XML file for the layout purposes. |
256 | * | 256 | * |
257 | * Note that when passing true for the conserveMemory argument subsequent | 257 | * Note that when passing true for the conserveMemory argument subsequent |
258 | * calls to guiFactory()->addClient/removeClient may not work as expected. | 258 | * calls to guiFactory()->addClient/removeClient may not work as expected. |
259 | * Also retrieving references to containers like popup menus or toolbars using | 259 | * Also retrieving references to containers like popup menus or toolbars using |
260 | * the container method will not work. | 260 | * the container method will not work. |
261 | * | 261 | * |
262 | * @param xmlfile The local xmlfile (relative or absolute) | 262 | * @param xmlfile The local xmlfile (relative or absolute) |
263 | * @param _conserveMemory Specify whether createGUI() should call | 263 | * @param _conserveMemory Specify whether createGUI() should call |
264 | * @ref KXMLGuiClient::conserveMemory() to free all memory | 264 | * @ref KXMLGuiClient::conserveMemory() to free all memory |
265 | * allocated by the @ref QDomDocument and by the KXMLGUIFactory. | 265 | * allocated by the @ref QDomDocument and by the KXMLGUIFactory. |
266 | */ | 266 | */ |
267 | void createGUI( const QString &xmlfile = QString::null, bool _conserveMemory = TRUE ); | 267 | void createGUI( const QString &xmlfile = QString::null, bool _conserveMemory = TRUE ); |
268 | 268 | ||
269 | /** | 269 | /** |
270 | * Enables the build of a standard help menu when calling createGUI(). | 270 | * Enables the build of a standard help menu when calling createGUI(). |
271 | * | 271 | * |
272 | * The default behavior is to build one, you must call this function | 272 | * The default behavior is to build one, you must call this function |
273 | * to disable it | 273 | * to disable it |
274 | */ | 274 | */ |
275 | void setHelpMenuEnabled(bool showHelpMenu = true); | 275 | void setHelpMenuEnabled(bool showHelpMenu = true); |
276 | 276 | ||
277 | /** | 277 | /** |
278 | * Return @p true when the help menu is enabled | 278 | * Return @p true when the help menu is enabled |
279 | */ | 279 | */ |
280 | bool isHelpMenuEnabled(); | 280 | bool isHelpMenuEnabled(); |
281 | 281 | ||
282 | 282 | ||
283 | /** | 283 | /** |
284 | * Returns true, if there is a menubar | 284 | * Returns true, if there is a menubar |
285 | * @since 3.1 | 285 | * @since 3.1 |
286 | */ | 286 | */ |
287 | bool hasMenuBar(); | 287 | bool hasMenuBar(); |
288 | 288 | ||
289 | /** | 289 | /** |
290 | * Returns a pointer to the menu bar. | 290 | * Returns a pointer to the menu bar. |
291 | * | 291 | * |
292 | * If there is no menu bar yet one will be created. | 292 | * If there is no menu bar yet one will be created. |
293 | **/ | 293 | **/ |
294 | //US KMenuBar *menuBar(); | 294 | //US KMenuBar *menuBar(); |
295 | QMenuBar *menuBar(); | 295 | QMenuBar *menuBar(); |
296 | 296 | ||
297 | /** | 297 | /** |
298 | * Returns a pointer to the status bar. | 298 | * Returns a pointer to the status bar. |
299 | * | 299 | * |
300 | * If there is no | 300 | * If there is no |
301 | * status bar yet one will be created. | 301 | * status bar yet one will be created. |
302 | */ | 302 | */ |
303 | //US KStatusBar *statusBar(); | 303 | //US KStatusBar *statusBar(); |
304 | QStatusBar *statusBar(); | 304 | QStatusBar *statusBar(); |
305 | 305 | ||
306 | /** | 306 | /** |
307 | * List of members of KMainWindow class. | 307 | * List of members of KMainWindow class. |
308 | */ | 308 | */ |
309 | //US static QPtrList<KMainWindow>* memberList; | 309 | //US static QPtrList<KMainWindow>* memberList; |
310 | 310 | ||
311 | /** | 311 | /** |
312 | * Returns a pointer to the toolbar with the specified name. | 312 | * Returns a pointer to the toolbar with the specified name. |
313 | * This refers to toolbars created dynamically from the XML UI | 313 | * This refers to toolbars created dynamically from the XML UI |
314 | * framework. If the toolbar does not exist one will be created. | 314 | * framework. If the toolbar does not exist one will be created. |
315 | * | 315 | * |
316 | * @param name The internal name of the toolbar. If no name is | 316 | * @param name The internal name of the toolbar. If no name is |
317 | * specified "mainToolBar" is assumed. | 317 | * specified "mainToolBar" is assumed. |
318 | * | 318 | * |
319 | * @return A pointer to the toolbar | 319 | * @return A pointer to the toolbar |
320 | **/ | 320 | **/ |
321 | KToolBar *toolBar( const char *name=0 ); | 321 | KToolBar *toolBar( const char *name=0 ); |
322 | // method for getting rid of KDE-Crap | 322 | // method for getting rid of KDE-Crap |
323 | QToolBar *tBar( ); | 323 | QToolBar *tBar( ); |
324 | 324 | ||
325 | /** | 325 | /** |
326 | * @return An iterator over the list of all toolbars for this window. | 326 | * @return An iterator over the list of all toolbars for this window. |
327 | */ | 327 | */ |
328 | QPtrListIterator<KToolBar> toolBarIterator(); | 328 | QPtrListIterator<KToolBar> toolBarIterator(); |
329 | 329 | ||
330 | /** | 330 | /** |
331 | * @return A KAccel instance bound to this mainwindow. Used automatically | 331 | * @return A KAccel instance bound to this mainwindow. Used automatically |
332 | * by KAction to make keybindings work in all cases. | 332 | * by KAction to make keybindings work in all cases. |
333 | */ | 333 | */ |
334 | KAccel *accel(); | 334 | KAccel *accel(); |
335 | 335 | ||
336 | void setFrameBorderWidth( int ) {} | 336 | void setFrameBorderWidth( int ) {} |
337 | 337 | ||
338 | /** | 338 | /** |
339 | * Call this to enable "auto-save" of toolbar/menubar/statusbar settings | 339 | * Call this to enable "auto-save" of toolbar/menubar/statusbar settings |
340 | * (and optionally window size). | 340 | * (and optionally window size). |
341 | * If the *bars were moved around/shown/hidden when the window is closed, | 341 | * If the *bars were moved around/shown/hidden when the window is closed, |
342 | * saveMainWindowSettings( KGlobal::config(), groupName ) will be called. | 342 | * saveMainWindowSettings( KGlobal::config(), groupName ) will be called. |
343 | * | 343 | * |
344 | * @param groupName a name that identifies this "type of window". | 344 | * @param groupName a name that identifies this "type of window". |
345 | * You can have several types of window in the same application. | 345 | * You can have several types of window in the same application. |
346 | * | 346 | * |
347 | * @param saveWindowSize set it to true to include the window size | 347 | * @param saveWindowSize set it to true to include the window size |
348 | * when saving. | 348 | * when saving. |
349 | * | 349 | * |
350 | * Typically, you will call setAutoSaveSettings() in your | 350 | * Typically, you will call setAutoSaveSettings() in your |
351 | * KMainWindow-inherited class constructor, and it will take care | 351 | * KMainWindow-inherited class constructor, and it will take care |
352 | * of restoring and saving automatically. Make sure you call this | 352 | * of restoring and saving automatically. Make sure you call this |
353 | * _after all_ your *bars have been created. | 353 | * _after all_ your *bars have been created. |
354 | */ | 354 | */ |
355 | void setAutoSaveSettings( const QString & groupName = QString::fromLatin1("MainWindow"), | 355 | void setAutoSaveSettings( const QString & groupName = QString::fromLatin1("MainWindow"), |
356 | bool saveWindowSize = true ); | 356 | bool saveWindowSize = true ); |
357 | 357 | ||
358 | /** | 358 | /** |
359 | * Disable the auto-save-settings feature. | 359 | * Disable the auto-save-settings feature. |
360 | * You don't normally need to call this, ever. | 360 | * You don't normally need to call this, ever. |
361 | */ | 361 | */ |
362 | void resetAutoSaveSettings(); | 362 | void resetAutoSaveSettings(); |
363 | 363 | ||
364 | /** | 364 | /** |
365 | * @return the current autosave setting, i.e. true if setAutoSaveSettings() was called, | 365 | * @return the current autosave setting, i.e. true if setAutoSaveSettings() was called, |
366 | * false by default or if resetAutoSaveSettings() was called. | 366 | * false by default or if resetAutoSaveSettings() was called. |
367 | * @since 3.1 | 367 | * @since 3.1 |
368 | */ | 368 | */ |
369 | bool autoSaveSettings() const; | 369 | bool autoSaveSettings() const; |
370 | 370 | ||
371 | /** | 371 | /** |
372 | * @return the group used for setting-autosaving. | 372 | * @return the group used for setting-autosaving. |
373 | * Only meaningful if setAutoSaveSettings() was called. | 373 | * Only meaningful if setAutoSaveSettings() was called. |
374 | * This can be useful for forcing a save or an apply, e.g. before and after | 374 | * This can be useful for forcing a save or an apply, e.g. before and after |
375 | * using KEditToolbar. | 375 | * using KEditToolbar. |
376 | * @since 3.1 | 376 | * @since 3.1 |
377 | */ | 377 | */ |
378 | QString autoSaveGroup() const; | 378 | QString autoSaveGroup() const; |
379 | 379 | ||
380 | /** | 380 | /** |
381 | * Read settings for statusbar, menubar and toolbar from their respective | 381 | * Read settings for statusbar, menubar and toolbar from their respective |
382 | * groups in the config file and apply them. | 382 | * groups in the config file and apply them. |
383 | * | 383 | * |
384 | * @param config Config file to read the settings from. | 384 | * @param config Config file to read the settings from. |
385 | * @param groupName Group name to use. If not specified, the last used | 385 | * @param groupName Group name to use. If not specified, the last used |
386 | * group name is used. | 386 | * group name is used. |
387 | */ | 387 | */ |
388 | void applyMainWindowSettings(KConfig *config, const QString &groupName = QString::null); | 388 | void applyMainWindowSettings(KConfig *config, const QString &groupName = QString::null); |
389 | 389 | ||
390 | /** | 390 | /** |
391 | * Save settings for statusbar, menubar and toolbar to their respective | 391 | * Save settings for statusbar, menubar and toolbar to their respective |
392 | * groups in the config file @p config. | 392 | * groups in the config file @p config. |
393 | * | 393 | * |
394 | * @param config Config file to save the settings to. | 394 | * @param config Config file to save the settings to. |
395 | * @param groupName Group name to use. If not specified, the last used | 395 | * @param groupName Group name to use. If not specified, the last used |
396 | * group name is used | 396 | * group name is used |
397 | */ | 397 | */ |
398 | void saveMainWindowSettings(KConfig *config, const QString &groupName = QString::null); | 398 | void saveMainWindowSettings(KConfig *config, const QString &groupName = QString::null); |
399 | 399 | ||
400 | /** | 400 | /** |
401 | * Sets whether KMainWindow should provide a menu that allows showing/hiding | 401 | * Sets whether KMainWindow should provide a menu that allows showing/hiding |
402 | * the available toolbars ( using @ref KToggleToolBarAction ) . In case there | 402 | * the available toolbars ( using @ref KToggleToolBarAction ) . In case there |
403 | * is only one toolbar configured a simple 'Show <toolbar name here>' menu item | 403 | * is only one toolbar configured a simple 'Show <toolbar name here>' menu item |
404 | * is shown. | 404 | * is shown. |
405 | * | 405 | * |
406 | * The menu / menu item is implemented using xmlgui. It will be inserted in your | 406 | * The menu / menu item is implemented using xmlgui. It will be inserted in your |
407 | * menu structure in the 'Settings' menu. | 407 | * menu structure in the 'Settings' menu. |
408 | * | 408 | * |
409 | * If your application uses a non-standard xmlgui resource file then you can | 409 | * If your application uses a non-standard xmlgui resource file then you can |
410 | * specify the exact position of the menu / menu item by adding a | 410 | * specify the exact position of the menu / menu item by adding a |
411 | * <Merge name="StandardToolBarMenuHandler" /> | 411 | * <Merge name="StandardToolBarMenuHandler" /> |
412 | * line to the settings menu section of your resource file ( usually appname.rc ). | 412 | * line to the settings menu section of your resource file ( usually appname.rc ). |
413 | * | 413 | * |
414 | * Note that you should enable this feature before calling createGUI() ( or similar ) . | 414 | * Note that you should enable this feature before calling createGUI() ( or similar ) . |
415 | * You enable/disable it anytime if you pass false to the conserveMemory argument of createGUI. | 415 | * You enable/disable it anytime if you pass false to the conserveMemory argument of createGUI. |
416 | * @since 3.1 | 416 | * @since 3.1 |
417 | */ | 417 | */ |
418 | void setStandardToolBarMenuEnabled( bool enable ); | 418 | void setStandardToolBarMenuEnabled( bool enable ); |
419 | /// @since 3.1 | 419 | /// @since 3.1 |
420 | bool isStandardToolBarMenuEnabled() const; | 420 | bool isStandardToolBarMenuEnabled() const; |
421 | 421 | ||
422 | 422 | ||
423 | /** | 423 | /** |
424 | * Sets whether KMainWindow should provide a menu that allows showing/hiding | 424 | * Sets whether KMainWindow should provide a menu that allows showing/hiding |
425 | * of the statusbar ( using @ref KToggleStatusBarAction ). | 425 | * of the statusbar ( using @ref KToggleStatusBarAction ). |
426 | * | 426 | * |
427 | * The menu / menu item is implemented using xmlgui. It will be inserted | 427 | * The menu / menu item is implemented using xmlgui. It will be inserted |
428 | * in your menu structure in the 'Settings' menu. | 428 | * in your menu structure in the 'Settings' menu. |
429 | * | 429 | * |
430 | * Note that you should enable this feature before calling createGUI() | 430 | * Note that you should enable this feature before calling createGUI() |
431 | * ( or similar ). | 431 | * ( or similar ). |
432 | * | 432 | * |
433 | * If an application maintains the action on its own (i.e. never calls | 433 | * If an application maintains the action on its own (i.e. never calls |
434 | * this function) a connection needs to be made to let KMainWindow | 434 | * this function) a connection needs to be made to let KMainWindow |
435 | * know when that status (hidden/shown) of the statusbar has changed. | 435 | * know when that status (hidden/shown) of the statusbar has changed. |
436 | * For example: | 436 | * For example: |
437 | * connect(action, SIGNAL(activated()), | 437 | * connect(action, SIGNAL(activated()), |
438 | * kmainwindow, SLOT(setSettingsDirty())); | 438 | * kmainwindow, SLOT(setSettingsDirty())); |
439 | * Otherwise the status (hidden/show) of the statusbar might not be saved | 439 | * Otherwise the status (hidden/show) of the statusbar might not be saved |
440 | * by KMainWindow. | 440 | * by KMainWindow. |
441 | * @since 3.2 | 441 | * @since 3.2 |
442 | */ | 442 | */ |
443 | void createStandardStatusBarAction(); | 443 | void createStandardStatusBarAction(); |
444 | 444 | ||
445 | 445 | ||
446 | /** | 446 | /** |
447 | * Returns a pointer to the mainwindows action responsible for the toolbars menu | 447 | * Returns a pointer to the mainwindows action responsible for the toolbars menu |
448 | * @since 3.1 | 448 | * @since 3.1 |
449 | */ | 449 | */ |
450 | KAction *toolBarMenuAction(); | 450 | KAction *toolBarMenuAction(); |
451 | 451 | ||
452 | // why do we support old gcc versions? using KXMLGUIBuilder::finalizeGUI; | 452 | // why do we support old gcc versions? using KXMLGUIBuilder::finalizeGUI; |
453 | /// @since 3.1 | 453 | /// @since 3.1 |
454 | virtual void finalizeGUI( KXMLGUIClient *client ); | 454 | virtual void finalizeGUI( KXMLGUIClient *client ); |
455 | 455 | ||
456 | /** | 456 | /** |
457 | * @internal | 457 | * @internal |
458 | */ | 458 | */ |
459 | void finalizeGUI( bool force ); | 459 | void finalizeGUI( bool force ); |
460 | 460 | ||
461 | /** | 461 | /** |
462 | * @return true if a -geometry argument was given on the command line, | 462 | * @return true if a -geometry argument was given on the command line, |
463 | * and this is the first window created (the one on which this option applies) | 463 | * and this is the first window created (the one on which this option applies) |
464 | */ | 464 | */ |
465 | bool initialGeometrySet() const; | 465 | bool initialGeometrySet() const; |
466 | 466 | ||
467 | /** | 467 | /** |
468 | * @internal | 468 | * @internal |
469 | * Used from Konqueror when reusing the main window. | 469 | * Used from Konqueror when reusing the main window. |
470 | */ | 470 | */ |
471 | void ignoreInitialGeometry(); | 471 | void ignoreInitialGeometry(); |
472 | 472 | ||
473 | /** | 473 | /** |
474 | * @return the size the mainwindow should have so that the central | 474 | * @return the size the mainwindow should have so that the central |
475 | * widget will be of @p size. | 475 | * widget will be of @p size. |
476 | */ | 476 | */ |
477 | QSize sizeForCentralWidgetSize(QSize size); | 477 | QSize sizeForCentralWidgetSize(QSize size); |
478 | 478 | ||
479 | public slots: | 479 | public slots: |
480 | /** | 480 | /** |
481 | * Makes a KDE compliant caption. | 481 | * Makes a KDE compliant caption. |
482 | * | 482 | * |
483 | * @param caption Your caption. @em Do @em not include the application name | 483 | * @param caption Your caption. @em Do @em not include the application name |
484 | * in this string. It will be added automatically according to the KDE | 484 | * in this string. It will be added automatically according to the KDE |
485 | * standard. | 485 | * standard. |
486 | */ | 486 | */ |
487 | virtual void setCaption( const QString &caption ); | 487 | virtual void setCaption( const QString &caption ); |
488 | /** | 488 | /** |
489 | * Makes a KDE compliant caption. | 489 | * Makes a KDE compliant caption. |
490 | * | 490 | * |
491 | * @param caption Your caption. @em Do @em not include the application name | 491 | * @param caption Your caption. @em Do @em not include the application name |
492 | * in this string. It will be added automatically according to the KDE | 492 | * in this string. It will be added automatically according to the KDE |
493 | * standard. | 493 | * standard. |
494 | * @param modified Specify whether the document is modified. This displays | 494 | * @param modified Specify whether the document is modified. This displays |
495 | * an additional sign in the title bar, usually "**". | 495 | * an additional sign in the title bar, usually "**". |
496 | */ | 496 | */ |
497 | virtual void setCaption( const QString &caption, bool modified ); | 497 | virtual void setCaption( const QString &caption, bool modified ); |
498 | 498 | ||
499 | /** | 499 | /** |
500 | * Make a plain caption without any modifications. | 500 | * Make a plain caption without any modifications. |
501 | * | 501 | * |
502 | * @param caption Your caption. This is the string that will be | 502 | * @param caption Your caption. This is the string that will be |
503 | * displayed in the window title. | 503 | * displayed in the window title. |
504 | */ | 504 | */ |
505 | virtual void setPlainCaption( const QString &caption ); | 505 | virtual void setPlainCaption( const QString &caption ); |
506 | 506 | ||
507 | /** | 507 | /** |
508 | * Open the help page for the application. | 508 | * Open the help page for the application. |
509 | * | 509 | * |
510 | * The application name is | 510 | * The application name is |
511 | * used as a key to determine what to display and the system will attempt | 511 | * used as a key to determine what to display and the system will attempt |
512 | * to open <appName>/index.html. | 512 | * to open <appName>/index.html. |
513 | * | 513 | * |
514 | * This method is intended for use by a help button in the toolbar or | 514 | * This method is intended for use by a help button in the toolbar or |
515 | * components outside the regular help menu. Use @ref helpMenu() when you | 515 | * components outside the regular help menu. Use @ref helpMenu() when you |
516 | * want to provide access to the help system from the help menu. | 516 | * want to provide access to the help system from the help menu. |
517 | * | 517 | * |
518 | * Example (adding a help button to the first toolbar): | 518 | * Example (adding a help button to the first toolbar): |
519 | * | 519 | * |
520 | * <pre> | 520 | * <pre> |
521 | * KIconLoader &loader = *KGlobal::iconLoader(); | 521 | * KIconLoader &loader = *KGlobal::iconLoader(); |
522 | * QPixmap pixmap = loader.loadIcon( "help" ); | 522 | * QPixmap pixmap = loader.loadIcon( "help" ); |
523 | * toolBar(0)->insertButton( pixmap, 0, SIGNAL(clicked()), | 523 | * toolBar(0)->insertButton( pixmap, 0, SIGNAL(clicked()), |
524 | * this, SLOT(appHelpActivated()), true, i18n("Help") ); | 524 | * this, SLOT(appHelpActivated()), true, i18n("Help") ); |
525 | * </pre> | 525 | * </pre> |
526 | * | 526 | * |
527 | */ | 527 | */ |
528 | //US void appHelpActivated( void ); | 528 | //US void appHelpActivated( void ); |
529 | 529 | ||
530 | /** | 530 | /** |
531 | * Apply a state change | 531 | * Apply a state change |
532 | * | 532 | * |
533 | * Enable and disable actions as defined in the XML rc file | 533 | * Enable and disable actions as defined in the XML rc file |
534 | * @since 3.1 | 534 | * @since 3.1 |
535 | */ | 535 | */ |
536 | virtual void slotStateChanged(const QString &newstate); | 536 | virtual void slotStateChanged(const QString &newstate); |
537 | 537 | ||
538 | /** | 538 | /** |
539 | * Apply a state change | 539 | * Apply a state change |
540 | * | 540 | * |
541 | * Enable and disable actions as defined in the XML rc file, | 541 | * Enable and disable actions as defined in the XML rc file, |
542 | * can "reverse" the state (disable the actions which should be | 542 | * can "reverse" the state (disable the actions which should be |
543 | * enabled, and vice-versa) if specified. | 543 | * enabled, and vice-versa) if specified. |
544 | * @since 3.1 | 544 | * @since 3.1 |
545 | */ | 545 | */ |
546 | void slotStateChanged(const QString &newstate, | 546 | void slotStateChanged(const QString &newstate, |
547 | KXMLGUIClient::ReverseStateChange); // KDE 4.0: remove this | 547 | KXMLGUIClient::ReverseStateChange); // KDE 4.0: remove this |
548 | 548 | ||
549 | 549 | ||
550 | /** | 550 | /** |
551 | * Apply a state change | 551 | * Apply a state change |
552 | * | 552 | * |
553 | * Enable and disable actions as defined in the XML rc file, | 553 | * Enable and disable actions as defined in the XML rc file, |
554 | * can "reverse" the state (disable the actions which should be | 554 | * can "reverse" the state (disable the actions which should be |
555 | * enabled, and vice-versa) if specified. | 555 | * enabled, and vice-versa) if specified. |
556 | */ | 556 | */ |
557 | // void slotStateChanged(const QString &newstate, | 557 | // void slotStateChanged(const QString &newstate, |
558 | // bool reverse); // KDE 4.0: enable this | 558 | // bool reverse); // KDE 4.0: enable this |
559 | 559 | ||
560 | /** | 560 | /** |
561 | * Tell the main window that it should save its settings when being closed. | 561 | * Tell the main window that it should save its settings when being closed. |
562 | * This is part of the auto-save-settings feature. | 562 | * This is part of the auto-save-settings feature. |
563 | * For everything related to toolbars this happens automatically, | 563 | * For everything related to toolbars this happens automatically, |
564 | * but you have to call setSettingsDirty() in the slot that toggles | 564 | * but you have to call setSettingsDirty() in the slot that toggles |
565 | * the visibility of the statusbar. | 565 | * the visibility of the statusbar. |
566 | */ | 566 | */ |
567 | void setSettingsDirty(); | 567 | void setSettingsDirty(); |
568 | 568 | ||
569 | protected: | 569 | protected: |
570 | void paintEvent( QPaintEvent* e ); | 570 | void paintEvent( QPaintEvent* e ); |
571 | void childEvent( QChildEvent* e); | 571 | void childEvent( QChildEvent* e); |
572 | void resizeEvent( QResizeEvent* e); | 572 | void resizeEvent( QResizeEvent* e); |
573 | /** | 573 | /** |
574 | * Reimplemented to call the queryClose() and queryExit() handlers. | 574 | * Reimplemented to call the queryClose() and queryExit() handlers. |
575 | * | 575 | * |
576 | * We recommend that you reimplement the handlers rather than @ref closeEvent(). | 576 | * We recommend that you reimplement the handlers rather than @ref closeEvent(). |
577 | * If you do it anyway, ensure to call the base implementation to keep | 577 | * If you do it anyway, ensure to call the base implementation to keep |
578 | * @ref queryExit() running. | 578 | * @ref queryExit() running. |
579 | */ | 579 | */ |
580 | virtual void closeEvent ( QCloseEvent *); | 580 | virtual void closeEvent ( QCloseEvent *); |
581 | 581 | ||
582 | // KDE4 This seems to be flawed to me. Either the app has only one | 582 | // KDE4 This seems to be flawed to me. Either the app has only one |
583 | // mainwindow, so queryClose() is enough, or if it can have more of them, | 583 | // mainwindow, so queryClose() is enough, or if it can have more of them, |
584 | // then the windows should take care of themselves, and queryExit() | 584 | // then the windows should take care of themselves, and queryExit() |
585 | // would be useful only for the annoying 'really quit' dialog, which | 585 | // would be useful only for the annoying 'really quit' dialog, which |
586 | // also doesn't make sense in apps with multiple mainwindows. | 586 | // also doesn't make sense in apps with multiple mainwindows. |
587 | // And saving configuration in something called queryExit()? IMHO | 587 | // And saving configuration in something called queryExit()? IMHO |
588 | // one can e.g. use KApplication::shutDown(), which if nothing else | 588 | // one can e.g. use KApplication::shutDown(), which if nothing else |
589 | // has at least better fitting name. | 589 | // has at least better fitting name. |
590 | // See also KApplication::sessionSaving(). | 590 | // See also KApplication::sessionSaving(). |
591 | // This stuff should get changed somehow, so that it at least doesn't | 591 | // This stuff should get changed somehow, so that it at least doesn't |
592 | // mess with session management. | 592 | // mess with session management. |
593 | /** | 593 | /** |
594 | Called before the very last window is closed, either by the | 594 | Called before the very last window is closed, either by the |
595 | user or indirectly by the session manager. | 595 | user or indirectly by the session manager. |
596 | 596 | ||
597 | It is not recommended to do any user interaction in this | 597 | It is not recommended to do any user interaction in this |
598 | function other than indicating severe errors. Better ask the | 598 | function other than indicating severe errors. Better ask the |
599 | user on @ref queryClose() (see below). | 599 | user on @ref queryClose() (see below). |
600 | 600 | ||
601 | A typical usage of @ref queryExit() is to write configuration data back. | 601 | A typical usage of @ref queryExit() is to write configuration data back. |
602 | Note that the application may continue to run after @ref queryExit() | 602 | Note that the application may continue to run after @ref queryExit() |
603 | (the user may have cancelled a shutdown), so you should not do any cleanups | 603 | (the user may have cancelled a shutdown), so you should not do any cleanups |
604 | here. The purpose of @ref queryExit() is purely to prepare the application | 604 | here. The purpose of @ref queryExit() is purely to prepare the application |
605 | (with possible user interaction) so it can safely be closed later (without | 605 | (with possible user interaction) so it can safely be closed later (without |
606 | user interaction). | 606 | user interaction). |
607 | 607 | ||
608 | If you need to do serious things on exit (like shutting a | 608 | If you need to do serious things on exit (like shutting a |
609 | dial-up connection down), connect to the signal | 609 | dial-up connection down), connect to the signal |
610 | @ref KApplication::shutDown(). | 610 | @ref KApplication::shutDown(). |
611 | 611 | ||
612 | Default implementation returns @p true. Returning @p false will | 612 | Default implementation returns @p true. Returning @p false will |
613 | cancel the exiting. In the latter case, the last window will | 613 | cancel the exiting. In the latter case, the last window will |
614 | remain visible. If KApplication::sessionSaving() is true, refusing | 614 | remain visible. If KApplication::sessionSaving() is true, refusing |
615 | the exit will also cancel KDE logout. | 615 | the exit will also cancel KDE logout. |
616 | 616 | ||
617 | @see queryClose() | 617 | @see queryClose() |
618 | @see KApplication::sessionSaving() | 618 | @see KApplication::sessionSaving() |
619 | */ | 619 | */ |
620 | virtual bool queryExit(); | 620 | virtual bool queryExit(); |
621 | 621 | ||
622 | /** | 622 | /** |
623 | Called before the window is closed, either by the user or indirectly by | 623 | Called before the window is closed, either by the user or indirectly by |
624 | the session manager. | 624 | the session manager. |
625 | 625 | ||
626 | The purpose of this function is to prepare the window in a way that it is | 626 | The purpose of this function is to prepare the window in a way that it is |
627 | safe to close it, i.e. without the user losing some data. | 627 | safe to close it, i.e. without the user losing some data. |
628 | 628 | ||
629 | Default implementation returns true. Returning @p false will cancel | 629 | Default implementation returns true. Returning @p false will cancel |
630 | the closing, and, if KApplication::sessionSaving() is true, it will also | 630 | the closing, and, if KApplication::sessionSaving() is true, it will also |
631 | cancel KDE logout. | 631 | cancel KDE logout. |
632 | 632 | ||
633 | Reimplement this function to prevent the user from losing data. | 633 | Reimplement this function to prevent the user from losing data. |
634 | Example: | 634 | Example: |
635 | <pre> | 635 | <pre> |
636 | 636 | ||
637 | switch ( KMessageBox::warningYesNoCancel( this, | 637 | switch ( KMessageBox::warningYesNoCancel( this, |
638 | i18n("Save changes to document foo?")) ) { | 638 | i18n("Save changes to document foo?")) ) { |
639 | case KMessageBox::Yes : | 639 | case KMessageBox::Yes : |
640 | // save document here. If saving fails, return FALSE; | 640 | // save document here. If saving fails, return FALSE; |
641 | return TRUE; | 641 | return TRUE; |
642 | case KMessageBox::No : | 642 | case KMessageBox::No : |
643 | return TRUE; | 643 | return TRUE; |
644 | default: // cancel | 644 | default: // cancel |
645 | return FALSE; | 645 | return FALSE; |
646 | 646 | ||
647 | </pre> | 647 | </pre> |
648 | 648 | ||
649 | @see queryExit() | 649 | @see queryExit() |
650 | @see KApplication::sessionSaving() | 650 | @see KApplication::sessionSaving() |
651 | 651 | ||
652 | */ | 652 | */ |
653 | virtual bool queryClose(); | 653 | virtual bool queryClose(); |
654 | /** | 654 | /** |
655 | * Save your instance-specific properties. The function is | 655 | * Save your instance-specific properties. The function is |
656 | * invoked when the session manager requests your application | 656 | * invoked when the session manager requests your application |
657 | * to save its state. | 657 | * to save its state. |
658 | * | 658 | * |
659 | * You @em must @em not change the group of the @p kconfig object, since | 659 | * You @em must @em not change the group of the @p kconfig object, since |
660 | * KMainWindow uses one group for each window. Please | 660 | * KMainWindow uses one group for each window. Please |
661 | * reimplement these function in childclasses. | 661 | * reimplement these function in childclasses. |
662 | * | 662 | * |
663 | * Note: No user interaction is allowed | 663 | * Note: No user interaction is allowed |
664 | * in this function! | 664 | * in this function! |
665 | * | 665 | * |
666 | */ | 666 | */ |
667 | virtual void saveProperties( KConfig* ) {} | 667 | virtual void saveProperties( KConfig* ) {} |
668 | 668 | ||
669 | /** | 669 | /** |
670 | * Read your instance-specific properties. | 670 | * Read your instance-specific properties. |
671 | */ | 671 | */ |
672 | virtual void readProperties( KConfig* ) {} | 672 | virtual void readProperties( KConfig* ) {} |
673 | 673 | ||
674 | /** | 674 | /** |
675 | * Save your application-wide properties. The function is | 675 | * Save your application-wide properties. The function is |
676 | * invoked when the session manager requests your application | 676 | * invoked when the session manager requests your application |
677 | * to save its state. | 677 | * to save its state. |
678 | * | 678 | * |
679 | * This function is similar to @ref saveProperties() but is only called for | 679 | * This function is similar to @ref saveProperties() but is only called for |
680 | * the very first main window, regardless how many main window are open. | 680 | * the very first main window, regardless how many main window are open. |
681 | 681 | ||
682 | * Override it if you need to save other data about your documents on | 682 | * Override it if you need to save other data about your documents on |
683 | * session end. sessionConfig is a config to which that data should be | 683 | * session end. sessionConfig is a config to which that data should be |
684 | * saved. Normally, you don't need this function. But if you want to save | 684 | * saved. Normally, you don't need this function. But if you want to save |
685 | * data about your documents that are not in opened windows you might need | 685 | * data about your documents that are not in opened windows you might need |
686 | * it. | 686 | * it. |
687 | * | 687 | * |
688 | * Default implementation does nothing. | 688 | * Default implementation does nothing. |
689 | */ | 689 | */ |
690 | virtual void saveGlobalProperties( KConfig* sessionConfig ); | 690 | virtual void saveGlobalProperties( KConfig* sessionConfig ); |
691 | 691 | ||
692 | /** | 692 | /** |
693 | * The counterpart of @ref saveGlobalProperties(). | 693 | * The counterpart of @ref saveGlobalProperties(). |
694 | * | 694 | * |
695 | * Read the application-specific properties in again. | 695 | * Read the application-specific properties in again. |
696 | */ | 696 | */ |
697 | virtual void readGlobalProperties( KConfig* sessionConfig ); | 697 | virtual void readGlobalProperties( KConfig* sessionConfig ); |
698 | void savePropertiesInternal( KConfig*, int ); | 698 | void savePropertiesInternal( KConfig*, int ); |
699 | bool readPropertiesInternal( KConfig*, int ); | 699 | bool readPropertiesInternal( KConfig*, int ); |
700 | 700 | ||
701 | /** | 701 | /** |
702 | * For inherited classes | 702 | * For inherited classes |
703 | */ | 703 | */ |
704 | bool settingsDirty() const; | 704 | bool settingsDirty() const; |
705 | /** | 705 | /** |
706 | * For inherited classes | 706 | * For inherited classes |
707 | */ | 707 | */ |
708 | QString settingsGroup() const; | 708 | QString settingsGroup() const; |
709 | /** | 709 | /** |
710 | * For inherited classes | 710 | * For inherited classes |
711 | * Note that the group must be set before calling | 711 | * Note that the group must be set before calling |
712 | */ | 712 | */ |
713 | void saveWindowSize( KConfig * config ) const; | 713 | void saveWindowSize( KConfig * config ) const; |
714 | /** | 714 | /** |
715 | * For inherited classes | 715 | * For inherited classes |
716 | * Note that the group must be set before calling, and that | 716 | * Note that the group must be set before calling, and that |
717 | * a -geometry on the command line has priority. | 717 | * a -geometry on the command line has priority. |
718 | */ | 718 | */ |
719 | void restoreWindowSize( KConfig * config ); | 719 | void restoreWindowSize( KConfig * config ); |
720 | 720 | ||
721 | /// parse the geometry from the geometry command line argument | 721 | /// parse the geometry from the geometry command line argument |
722 | void parseGeometry(bool parsewidth); | 722 | void parseGeometry(bool parsewidth); |
723 | 723 | ||
724 | protected slots: | 724 | protected slots: |
725 | 725 | ||
726 | /** | 726 | /** |
727 | * This slot does nothing. | 727 | * This slot does nothing. |
728 | * | 728 | * |
729 | * It must be reimplemented if you want | 729 | * It must be reimplemented if you want |
730 | * to use a custom About Application dialog box. This slot is | 730 | * to use a custom About Application dialog box. This slot is |
731 | * connected to the About Application entry in the menu returned | 731 | * connected to the About Application entry in the menu returned |
732 | * by @ref customHelpMenu. | 732 | * by @ref customHelpMenu. |
733 | * | 733 | * |
734 | * Example: | 734 | * Example: |
735 | * <pre> | 735 | * <pre> |
736 | * | 736 | * |
737 | * void MyMainLevel::setupInterface() | 737 | * void MyMainLevel::setupInterface() |
738 | * { | 738 | * { |
739 | * .. | 739 | * .. |
740 | * menuBar()->insertItem( i18n("&Help"), customHelpMenu() ); | 740 | * menuBar()->insertItem( i18n("&Help"), customHelpMenu() ); |
741 | * .. | 741 | * .. |
742 | * } | 742 | * } |
743 | * | 743 | * |
744 | * void MyMainLevel::showAboutApplication() | 744 | * void MyMainLevel::showAboutApplication() |
745 | * { | 745 | * { |
746 | * <activate your custom dialog> | 746 | * <activate your custom dialog> |
747 | * } | 747 | * } |
748 | * </pre> | 748 | * </pre> |
749 | */ | 749 | */ |
750 | //US virtual void showAboutApplication(); | 750 | //US virtual void showAboutApplication(); |
751 | 751 | ||
752 | private slots: | 752 | private slots: |
753 | /** | 753 | /** |
754 | * Called when the app is shutting down. | 754 | * Called when the app is shutting down. |
755 | */ | 755 | */ |
756 | void shuttingDown(); | 756 | void shuttingDown(); |
757 | 757 | ||
758 | void saveAutoSaveSettings(); | 758 | void saveAutoSaveSettings(); |
759 | 759 | ||
760 | private: | 760 | private: |
761 | QToolBar * mQToolBar; | 761 | QToolBar * mQToolBar; |
762 | //US KMenuBar *internalMenuBar(); | 762 | //US KMenuBar *internalMenuBar(); |
763 | QMenuBar *internalMenuBar(); | 763 | QMenuBar *internalMenuBar(); |
764 | //US KStatusBar *internalStatusBar(); | 764 | //US KStatusBar *internalStatusBar(); |
765 | QStatusBar *internalStatusBar(); | 765 | QStatusBar *internalStatusBar(); |
766 | 766 | ||
767 | KMainWindowPrivate *d; | 767 | KMainWindowPrivate *d; |
768 | void initKMainWindow(const char *name); | 768 | void initKMainWindow(const char *name); |
769 | 769 | ||
770 | QPtrList<KToolBar> toolbarList; | 770 | QPtrList<KToolBar> toolbarList; |
771 | 771 | ||
772 | protected: | 772 | protected: |
773 | virtual void virtual_hook( int id, void* data ); | 773 | virtual void virtual_hook( int id, void* data ); |
774 | 774 | ||
775 | }; | 775 | }; |
776 | 776 | ||
777 | #endif | 777 | #endif |