-rw-r--r-- | microkde/kdeui/kmainwindow.h | 776 |
1 files changed, 776 insertions, 0 deletions
diff --git a/microkde/kdeui/kmainwindow.h b/microkde/kdeui/kmainwindow.h new file mode 100644 index 0000000..e76e732 --- a/dev/null +++ b/microkde/kdeui/kmainwindow.h | |||
@@ -0,0 +1,776 @@ | |||
1 | /* | ||
2 | This file is part of the KDE libraries | ||
3 | |||
4 | This library is free software; you can redistribute it and/or | ||
5 | modify it under the terms of the GNU Library General Public | ||
6 | License version 2 as published by the Free Software Foundation. | ||
7 | |||
8 | This library is distributed in the hope that it will be useful, | ||
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
11 | Library General Public License for more details. | ||
12 | |||
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 | ||
15 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
16 | Boston, MA 02111-1307, USA. | ||
17 | |||
18 | $Id$ | ||
19 | |||
20 | */ | ||
21 | |||
22 | |||
23 | |||
24 | #ifndef KMAINWINDOW_H | ||
25 | #define KMAINWINDOW_H | ||
26 | |||
27 | /*US | ||
28 | #include "kxmlguifactory.h" | ||
29 | #include "kxmlguiclient.h" | ||
30 | #include "kxmlguibuilder.h" | ||
31 | #include <qmetaobject.h> | ||
32 | |||
33 | class KPopupMenu; | ||
34 | class KXMLGUIFactory; | ||
35 | class KConfig; | ||
36 | class KHelpMenu; | ||
37 | class KStatusBar; | ||
38 | class QStatusBar; | ||
39 | class KMenuBar; | ||
40 | class KMWSessionManaged; | ||
41 | class KAccel; | ||
42 | class KToolBarMenuAction; | ||
43 | */ | ||
44 | |||
45 | class QMenuBar; | ||
46 | class QStatusBar; | ||
47 | class KMainWindowPrivate; | ||
48 | class KAction; | ||
49 | |||
50 | #include <ktoolbar.h> | ||
51 | #include <ktoolbarhandler.h> | ||
52 | #include <kxmlguiclient.h> | ||
53 | #include <qmainwindow.h> | ||
54 | #include <qptrlist.h> | ||
55 | |||
56 | class KActionCollection; | ||
57 | |||
58 | class KMainWindow : public QMainWindow, virtual public KXMLGUIClient | ||
59 | { | ||
60 | Q_OBJECT | ||
61 | |||
62 | private: | ||
63 | //US create private defaultconstructor | ||
64 | KMainWindow() {;}; | ||
65 | |||
66 | public: | ||
67 | public: | ||
68 | /** | ||
69 | * Construct a main window. | ||
70 | * | ||
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 | ||
73 | * secondary window. | ||
74 | * | ||
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 | ||
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 | ||
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 | ||
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 | ||
83 | * mails, the name for the folders window should be e.g. "mainwindow" and | ||
84 | * for the composer windows "composer#". | ||
85 | * | ||
86 | * @param f Specify the widget flags. The default is | ||
87 | * WType_TopLevel and WDestructiveClose. TopLevel indicates that 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 | ||
90 | * automatically destroyed when its window is closed. Pass 0 if | ||
91 | * you do not want this behavior. | ||
92 | * | ||
93 | * KMainWindows must be created on the heap with 'new', like: | ||
94 | * <pre> KMainWindow *kmw = new KMainWindow (...</pre> | ||
95 | **/ | ||
96 | KMainWindow( QWidget* parent = 0, const char *name = 0, WFlags f = WType_TopLevel | WDestructiveClose ); | ||
97 | |||
98 | |||
99 | /** | ||
100 | * Destructor. | ||
101 | * | ||
102 | * Will also destroy the toolbars, and menubar if | ||
103 | * needed. | ||
104 | */ | ||
105 | virtual ~KMainWindow(); | ||
106 | |||
107 | /** | ||
108 | * Retrieve the standard help menu. | ||
109 | * | ||
110 | * It contains entires for the | ||
111 | * help system (activated by F1), an optional "What's This?" entry | ||
112 | * (activated by Shift F1), an application specific dialog box, | ||
113 | * and an "About KDE" dialog box. | ||
114 | * | ||
115 | * Example (adding a standard help menu to your application): | ||
116 | * <pre> | ||
117 | * KPopupMenu *help = helpMenu( <myTextString> ); | ||
118 | * menuBar()->insertItem( i18n("&Help"), help ); | ||
119 | * </pre> | ||
120 | * | ||
121 | * @param aboutAppText The string that is used in the application | ||
122 | * specific dialog box. If you leave this string empty the | ||
123 | * information in the global @ref KAboutData of the | ||
124 | * application will be used to make a standard dialog box. | ||
125 | * | ||
126 | * @param showWhatsThis Set this to false if you do not want to include | ||
127 | * the "What's This" menu entry. | ||
128 | * | ||
129 | * @return A standard help menu. | ||
130 | */ | ||
131 | //US KPopupMenu* helpMenu( const QString &aboutAppText = QString::null, | ||
132 | //US bool showWhatsThis = TRUE ); | ||
133 | |||
134 | /** | ||
135 | * Returns the help menu. Creates a standard help menu if none exists yet. | ||
136 | * | ||
137 | * It contains entries for the | ||
138 | * help system (activated by F1), an optional "What's This?" entry | ||
139 | * (activated by Shift F1), an application specific dialog box, | ||
140 | * and an "About KDE" dialog box. You must create the application | ||
141 | * specific dialog box yourself. When the "About application" | ||
142 | * menu entry is activated, a signal will trigger the | ||
143 | * @ref showAboutApplication slot. See @ref showAboutApplication for more | ||
144 | * information. | ||
145 | * | ||
146 | * Example (adding a help menu to your application): | ||
147 | * <pre> | ||
148 | * menuBar()->insertItem( i18n("&Help"), customHelpMenu() ); | ||
149 | * </pre> | ||
150 | * | ||
151 | * @param showWhatsThis Set this to @p false if you do not want to include | ||
152 | * the "What's This" menu entry. | ||
153 | * | ||
154 | * @return A standard help menu. | ||
155 | */ | ||
156 | //US KPopupMenu* customHelpMenu( bool showWhatsThis = TRUE ); | ||
157 | |||
158 | /** | ||
159 | * @sect Session Management | ||
160 | * | ||
161 | * Try to restore the toplevel widget as defined by the number (1..X). | ||
162 | * | ||
163 | * If the session did not contain so high a number, the configuration | ||
164 | * is not changed and @p false returned. | ||
165 | * | ||
166 | * That means clients could simply do the following: | ||
167 | * <pre> | ||
168 | * if (kapp->isRestored()){ | ||
169 | * int n = 1; | ||
170 | * while (KMainWindow::canBeRestored(n)){ | ||
171 | * (new childMW)->restore(n); | ||
172 | * n++; | ||
173 | * } | ||
174 | * } else { | ||
175 | * // create default application as usual | ||
176 | * } | ||
177 | * </pre> | ||
178 | * Note that @ref QWidget::show() is called implicitly in restore. | ||
179 | * | ||
180 | * With this you can easily restore all toplevel windows of your | ||
181 | * application. | ||
182 | * | ||
183 | * If your application uses different kinds of toplevel | ||
184 | * windows, then you can use @ref KMainWindow::classNameOfToplevel(n) | ||
185 | * to determine the exact type before calling the childMW | ||
186 | * constructor in the example from above. | ||
187 | * | ||
188 | * If your client has only one kind of toplevel widgets (which | ||
189 | * should be pretty usual) then you should use the RESTORE-macro | ||
190 | * for backwards compatibility with 3.1 and 3.0 branches: | ||
191 | * | ||
192 | * <pre> | ||
193 | * if (kapp->isRestored()) | ||
194 | * RESTORE(childMW) | ||
195 | * else { | ||
196 | * // create default application as usual | ||
197 | * } | ||
198 | * </pre> | ||
199 | * | ||
200 | * The macro expands to the term above but is easier to use and | ||
201 | * less code to write. | ||
202 | * | ||
203 | * For new code or if you have more than one kind of toplevel | ||
204 | * widget (each derived from @ref KMainWindow, of course), you can | ||
205 | * use the templated @ref kRestoreMainWindows global functions: | ||
206 | * | ||
207 | * <pre> | ||
208 | * if (kapp->isRestored()) | ||
209 | * kRestoreMainWindows< childMW1, childMW2, childMW3 >(); | ||
210 | * else { | ||
211 | * // create default application as usual | ||
212 | * } | ||
213 | * </pre> | ||
214 | * | ||
215 | * Currently, these functions are provided for up to three | ||
216 | * template arguments. If you need more, tell us. To help you in | ||
217 | * deciding whether or not you can use @ref kRestoreMainWindows, a | ||
218 | * define KDE_RESTORE_MAIN_WINDOWS_NUM_TEMPLATE_ARGS is provided. | ||
219 | * | ||
220 | * @see restore() | ||
221 | * @see classNameOfToplevel() | ||
222 | * | ||
223 | **/ | ||
224 | static bool canBeRestored( int number ); | ||
225 | |||
226 | /** | ||
227 | * Returns the @ref className() of the @p number of the toplevel window which | ||
228 | * should be restored. | ||
229 | * | ||
230 | * This is only useful if your application uses | ||
231 | * different kinds of toplevel windows. | ||
232 | */ | ||
233 | static const QString classNameOfToplevel( int number ); | ||
234 | |||
235 | /** | ||
236 | * Restore the session specified by @p number. | ||
237 | * | ||
238 | * Returns @p false if this | ||
239 | * fails, otherwise returns @p true and shows the window. | ||
240 | * You should call @ref canBeRestored() first. | ||
241 | * If @p show is true (default), this widget will be shown automatically. | ||
242 | */ | ||
243 | bool restore( int number, bool show = TRUE ); | ||
244 | |||
245 | //US virtual KXMLGUIFactory *guiFactory(); | ||
246 | |||
247 | /** | ||
248 | * Create a GUI given a local XML file. | ||
249 | * | ||
250 | * If @p xmlfile is NULL, | ||
251 | * then it will try to construct a local XML filename like | ||
252 | * appnameui.rc where 'appname' is your app's name. If that file | ||
253 | * does not exist, then the XML UI code will only use the global | ||
254 | * (standard) XML file for the layout purposes. | ||
255 | * | ||
256 | * Note that when passing true for the conserveMemory argument subsequent | ||
257 | * calls to guiFactory()->addClient/removeClient may not work as expected. | ||
258 | * Also retrieving references to containers like popup menus or toolbars using | ||
259 | * the container method will not work. | ||
260 | * | ||
261 | * @param xmlfile The local xmlfile (relative or absolute) | ||
262 | * @param _conserveMemory Specify whether createGUI() should call | ||
263 | * @ref KXMLGuiClient::conserveMemory() to free all memory | ||
264 | * allocated by the @ref QDomDocument and by the KXMLGUIFactory. | ||
265 | */ | ||
266 | void createGUI( const QString &xmlfile = QString::null, bool _conserveMemory = TRUE ); | ||
267 | |||
268 | /** | ||
269 | * Enables the build of a standard help menu when calling createGUI(). | ||
270 | * | ||
271 | * The default behavior is to build one, you must call this function | ||
272 | * to disable it | ||
273 | */ | ||
274 | void setHelpMenuEnabled(bool showHelpMenu = true); | ||
275 | |||
276 | /** | ||
277 | * Return @p true when the help menu is enabled | ||
278 | */ | ||
279 | bool isHelpMenuEnabled(); | ||
280 | |||
281 | |||
282 | /** | ||
283 | * Returns true, if there is a menubar | ||
284 | * @since 3.1 | ||
285 | */ | ||
286 | bool hasMenuBar(); | ||
287 | |||
288 | /** | ||
289 | * Returns a pointer to the menu bar. | ||
290 | * | ||
291 | * If there is no menu bar yet one will be created. | ||
292 | **/ | ||
293 | //US KMenuBar *menuBar(); | ||
294 | QMenuBar *menuBar(); | ||
295 | |||
296 | /** | ||
297 | * Returns a pointer to the status bar. | ||
298 | * | ||
299 | * If there is no | ||
300 | * status bar yet one will be created. | ||
301 | */ | ||
302 | //US KStatusBar *statusBar(); | ||
303 | QStatusBar *statusBar(); | ||
304 | |||
305 | /** | ||
306 | * List of members of KMainWindow class. | ||
307 | */ | ||
308 | //US static QPtrList<KMainWindow>* memberList; | ||
309 | |||
310 | /** | ||
311 | * Returns a pointer to the toolbar with the specified name. | ||
312 | * This refers to toolbars created dynamically from the XML UI | ||
313 | * framework. If the toolbar does not exist one will be created. | ||
314 | * | ||
315 | * @param name The internal name of the toolbar. If no name is | ||
316 | * specified "mainToolBar" is assumed. | ||
317 | * | ||
318 | * @return A pointer to the toolbar | ||
319 | **/ | ||
320 | KToolBar *toolBar( const char *name=0 ); | ||
321 | // method for getting rid of KDE-Crap | ||
322 | QToolBar *tBar( ); | ||
323 | |||
324 | /** | ||
325 | * @return An iterator over the list of all toolbars for this window. | ||
326 | */ | ||
327 | QPtrListIterator<KToolBar> toolBarIterator(); | ||
328 | |||
329 | /** | ||
330 | * @return A KAccel instance bound to this mainwindow. Used automatically | ||
331 | * by KAction to make keybindings work in all cases. | ||
332 | */ | ||
333 | KAccel *accel(); | ||
334 | |||
335 | void setFrameBorderWidth( int ) {} | ||
336 | |||
337 | /** | ||
338 | * Call this to enable "auto-save" of toolbar/menubar/statusbar settings | ||
339 | * (and optionally window size). | ||
340 | * If the *bars were moved around/shown/hidden when the window is closed, | ||
341 | * saveMainWindowSettings( KGlobal::config(), groupName ) will be called. | ||
342 | * | ||
343 | * @param groupName a name that identifies this "type of window". | ||
344 | * You can have several types of window in the same application. | ||
345 | * | ||
346 | * @param saveWindowSize set it to true to include the window size | ||
347 | * when saving. | ||
348 | * | ||
349 | * Typically, you will call setAutoSaveSettings() in your | ||
350 | * KMainWindow-inherited class constructor, and it will take care | ||
351 | * of restoring and saving automatically. Make sure you call this | ||
352 | * _after all_ your *bars have been created. | ||
353 | */ | ||
354 | void setAutoSaveSettings( const QString & groupName = QString::fromLatin1("MainWindow"), | ||
355 | bool saveWindowSize = true ); | ||
356 | |||
357 | /** | ||
358 | * Disable the auto-save-settings feature. | ||
359 | * You don't normally need to call this, ever. | ||
360 | */ | ||
361 | void resetAutoSaveSettings(); | ||
362 | |||
363 | /** | ||
364 | * @return the current autosave setting, i.e. true if setAutoSaveSettings() was called, | ||
365 | * false by default or if resetAutoSaveSettings() was called. | ||
366 | * @since 3.1 | ||
367 | */ | ||
368 | bool autoSaveSettings() const; | ||
369 | |||
370 | /** | ||
371 | * @return the group used for setting-autosaving. | ||
372 | * Only meaningful if setAutoSaveSettings() was called. | ||
373 | * This can be useful for forcing a save or an apply, e.g. before and after | ||
374 | * using KEditToolbar. | ||
375 | * @since 3.1 | ||
376 | */ | ||
377 | QString autoSaveGroup() const; | ||
378 | |||
379 | /** | ||
380 | * Read settings for statusbar, menubar and toolbar from their respective | ||
381 | * groups in the config file and apply them. | ||
382 | * | ||
383 | * @param config Config file to read the settings from. | ||
384 | * @param groupName Group name to use. If not specified, the last used | ||
385 | * group name is used. | ||
386 | */ | ||
387 | void applyMainWindowSettings(KConfig *config, const QString &groupName = QString::null); | ||
388 | |||
389 | /** | ||
390 | * Save settings for statusbar, menubar and toolbar to their respective | ||
391 | * groups in the config file @p config. | ||
392 | * | ||
393 | * @param config Config file to save the settings to. | ||
394 | * @param groupName Group name to use. If not specified, the last used | ||
395 | * group name is used | ||
396 | */ | ||
397 | void saveMainWindowSettings(KConfig *config, const QString &groupName = QString::null); | ||
398 | |||
399 | /** | ||
400 | * Sets whether KMainWindow should provide a menu that allows showing/hiding | ||
401 | * the available toolbars ( using @ref KToggleToolBarAction ) . In case there | ||
402 | * is only one toolbar configured a simple 'Show <toolbar name here>' menu item | ||
403 | * is shown. | ||
404 | * | ||
405 | * The menu / menu item is implemented using xmlgui. It will be inserted in your | ||
406 | * menu structure in the 'Settings' menu. | ||
407 | * | ||
408 | * If your application uses a non-standard xmlgui resource file then you can | ||
409 | * specify the exact position of the menu / menu item by adding a | ||
410 | * <Merge name="StandardToolBarMenuHandler" /> | ||
411 | * line to the settings menu section of your resource file ( usually appname.rc ). | ||
412 | * | ||
413 | * Note that you should enable this feature before calling createGUI() ( or similar ) . | ||
414 | * You enable/disable it anytime if you pass false to the conserveMemory argument of createGUI. | ||
415 | * @since 3.1 | ||
416 | */ | ||
417 | void setStandardToolBarMenuEnabled( bool enable ); | ||
418 | /// @since 3.1 | ||
419 | bool isStandardToolBarMenuEnabled() const; | ||
420 | |||
421 | |||
422 | /** | ||
423 | * Sets whether KMainWindow should provide a menu that allows showing/hiding | ||
424 | * of the statusbar ( using @ref KToggleStatusBarAction ). | ||
425 | * | ||
426 | * The menu / menu item is implemented using xmlgui. It will be inserted | ||
427 | * in your menu structure in the 'Settings' menu. | ||
428 | * | ||
429 | * Note that you should enable this feature before calling createGUI() | ||
430 | * ( or similar ). | ||
431 | * | ||
432 | * If an application maintains the action on its own (i.e. never calls | ||
433 | * this function) a connection needs to be made to let KMainWindow | ||
434 | * know when that status (hidden/shown) of the statusbar has changed. | ||
435 | * For example: | ||
436 | * connect(action, SIGNAL(activated()), | ||
437 | * kmainwindow, SLOT(setSettingsDirty())); | ||
438 | * Otherwise the status (hidden/show) of the statusbar might not be saved | ||
439 | * by KMainWindow. | ||
440 | * @since 3.2 | ||
441 | */ | ||
442 | void createStandardStatusBarAction(); | ||
443 | |||
444 | |||
445 | /** | ||
446 | * Returns a pointer to the mainwindows action responsible for the toolbars menu | ||
447 | * @since 3.1 | ||
448 | */ | ||
449 | KAction *toolBarMenuAction(); | ||
450 | |||
451 | // why do we support old gcc versions? using KXMLGUIBuilder::finalizeGUI; | ||
452 | /// @since 3.1 | ||
453 | virtual void finalizeGUI( KXMLGUIClient *client ); | ||
454 | |||
455 | /** | ||
456 | * @internal | ||
457 | */ | ||
458 | void finalizeGUI( bool force ); | ||
459 | |||
460 | /** | ||
461 | * @return true if a -geometry argument was given on the command line, | ||
462 | * and this is the first window created (the one on which this option applies) | ||
463 | */ | ||
464 | bool initialGeometrySet() const; | ||
465 | |||
466 | /** | ||
467 | * @internal | ||
468 | * Used from Konqueror when reusing the main window. | ||
469 | */ | ||
470 | void ignoreInitialGeometry(); | ||
471 | |||
472 | /** | ||
473 | * @return the size the mainwindow should have so that the central | ||
474 | * widget will be of @p size. | ||
475 | */ | ||
476 | QSize sizeForCentralWidgetSize(QSize size); | ||
477 | |||
478 | public slots: | ||
479 | /** | ||
480 | * Makes a KDE compliant caption. | ||
481 | * | ||
482 | * @param caption Your caption. @em Do @em not include the application name | ||
483 | * in this string. It will be added automatically according to the KDE | ||
484 | * standard. | ||
485 | */ | ||
486 | virtual void setCaption( const QString &caption ); | ||
487 | /** | ||
488 | * Makes a KDE compliant caption. | ||
489 | * | ||
490 | * @param caption Your caption. @em Do @em not include the application name | ||
491 | * in this string. It will be added automatically according to the KDE | ||
492 | * standard. | ||
493 | * @param modified Specify whether the document is modified. This displays | ||
494 | * an additional sign in the title bar, usually "**". | ||
495 | */ | ||
496 | virtual void setCaption( const QString &caption, bool modified ); | ||
497 | |||
498 | /** | ||
499 | * Make a plain caption without any modifications. | ||
500 | * | ||
501 | * @param caption Your caption. This is the string that will be | ||
502 | * displayed in the window title. | ||
503 | */ | ||
504 | virtual void setPlainCaption( const QString &caption ); | ||
505 | |||
506 | /** | ||
507 | * Open the help page for the application. | ||
508 | * | ||
509 | * The application name is | ||
510 | * used as a key to determine what to display and the system will attempt | ||
511 | * to open <appName>/index.html. | ||
512 | * | ||
513 | * This method is intended for use by a help button in the toolbar or | ||
514 | * components outside the regular help menu. Use @ref helpMenu() when you | ||
515 | * want to provide access to the help system from the help menu. | ||
516 | * | ||
517 | * Example (adding a help button to the first toolbar): | ||
518 | * | ||
519 | * <pre> | ||
520 | * KIconLoader &loader = *KGlobal::iconLoader(); | ||
521 | * QPixmap pixmap = loader.loadIcon( "help" ); | ||
522 | * toolBar(0)->insertButton( pixmap, 0, SIGNAL(clicked()), | ||
523 | * this, SLOT(appHelpActivated()), true, i18n("Help") ); | ||
524 | * </pre> | ||
525 | * | ||
526 | */ | ||
527 | //US void appHelpActivated( void ); | ||
528 | |||
529 | /** | ||
530 | * Apply a state change | ||
531 | * | ||
532 | * Enable and disable actions as defined in the XML rc file | ||
533 | * @since 3.1 | ||
534 | */ | ||
535 | virtual void slotStateChanged(const QString &newstate); | ||
536 | |||
537 | /** | ||
538 | * Apply a state change | ||
539 | * | ||
540 | * Enable and disable actions as defined in the XML rc file, | ||
541 | * can "reverse" the state (disable the actions which should be | ||
542 | * enabled, and vice-versa) if specified. | ||
543 | * @since 3.1 | ||
544 | */ | ||
545 | void slotStateChanged(const QString &newstate, | ||
546 | KXMLGUIClient::ReverseStateChange); // KDE 4.0: remove this | ||
547 | |||
548 | |||
549 | /** | ||
550 | * Apply a state change | ||
551 | * | ||
552 | * Enable and disable actions as defined in the XML rc file, | ||
553 | * can "reverse" the state (disable the actions which should be | ||
554 | * enabled, and vice-versa) if specified. | ||
555 | */ | ||
556 | // void slotStateChanged(const QString &newstate, | ||
557 | // bool reverse); // KDE 4.0: enable this | ||
558 | |||
559 | /** | ||
560 | * Tell the main window that it should save its settings when being closed. | ||
561 | * This is part of the auto-save-settings feature. | ||
562 | * For everything related to toolbars this happens automatically, | ||
563 | * but you have to call setSettingsDirty() in the slot that toggles | ||
564 | * the visibility of the statusbar. | ||
565 | */ | ||
566 | void setSettingsDirty(); | ||
567 | |||
568 | protected: | ||
569 | void paintEvent( QPaintEvent* e ); | ||
570 | void childEvent( QChildEvent* e); | ||
571 | void resizeEvent( QResizeEvent* e); | ||
572 | /** | ||
573 | * Reimplemented to call the queryClose() and queryExit() handlers. | ||
574 | * | ||
575 | * We recommend that you reimplement the handlers rather than @ref closeEvent(). | ||
576 | * If you do it anyway, ensure to call the base implementation to keep | ||
577 | * @ref queryExit() running. | ||
578 | */ | ||
579 | virtual void closeEvent ( QCloseEvent *); | ||
580 | |||
581 | // KDE4 This seems to be flawed to me. Either the app has only one | ||
582 | // mainwindow, so queryClose() is enough, or if it can have more of them, | ||
583 | // then the windows should take care of themselves, and queryExit() | ||
584 | // would be useful only for the annoying 'really quit' dialog, which | ||
585 | // also doesn't make sense in apps with multiple mainwindows. | ||
586 | // And saving configuration in something called queryExit()? IMHO | ||
587 | // one can e.g. use KApplication::shutDown(), which if nothing else | ||
588 | // has at least better fitting name. | ||
589 | // See also KApplication::sessionSaving(). | ||
590 | // This stuff should get changed somehow, so that it at least doesn't | ||
591 | // mess with session management. | ||
592 | /** | ||
593 | Called before the very last window is closed, either by the | ||
594 | user or indirectly by the session manager. | ||
595 | |||
596 | It is not recommended to do any user interaction in this | ||
597 | function other than indicating severe errors. Better ask the | ||
598 | user on @ref queryClose() (see below). | ||
599 | |||
600 | A typical usage of @ref queryExit() is to write configuration data back. | ||
601 | Note that the application may continue to run after @ref queryExit() | ||
602 | (the user may have cancelled a shutdown), so you should not do any cleanups | ||
603 | here. The purpose of @ref queryExit() is purely to prepare the application | ||
604 | (with possible user interaction) so it can safely be closed later (without | ||
605 | user interaction). | ||
606 | |||
607 | If you need to do serious things on exit (like shutting a | ||
608 | dial-up connection down), connect to the signal | ||
609 | @ref KApplication::shutDown(). | ||
610 | |||
611 | Default implementation returns @p true. Returning @p false will | ||
612 | cancel the exiting. In the latter case, the last window will | ||
613 | remain visible. If KApplication::sessionSaving() is true, refusing | ||
614 | the exit will also cancel KDE logout. | ||
615 | |||
616 | @see queryClose() | ||
617 | @see KApplication::sessionSaving() | ||
618 | */ | ||
619 | virtual bool queryExit(); | ||
620 | |||
621 | /** | ||
622 | Called before the window is closed, either by the user or indirectly by | ||
623 | the session manager. | ||
624 | |||
625 | The purpose of this function is to prepare the window in a way that it is | ||
626 | safe to close it, i.e. without the user losing some data. | ||
627 | |||
628 | Default implementation returns true. Returning @p false will cancel | ||
629 | the closing, and, if KApplication::sessionSaving() is true, it will also | ||
630 | cancel KDE logout. | ||
631 | |||
632 | Reimplement this function to prevent the user from losing data. | ||
633 | Example: | ||
634 | <pre> | ||
635 | |||
636 | switch ( KMessageBox::warningYesNoCancel( this, | ||
637 | i18n("Save changes to document foo?")) ) { | ||
638 | case KMessageBox::Yes : | ||
639 | // save document here. If saving fails, return FALSE; | ||
640 | return TRUE; | ||
641 | case KMessageBox::No : | ||
642 | return TRUE; | ||
643 | default: // cancel | ||
644 | return FALSE; | ||
645 | |||
646 | </pre> | ||
647 | |||
648 | @see queryExit() | ||
649 | @see KApplication::sessionSaving() | ||
650 | |||
651 | */ | ||
652 | virtual bool queryClose(); | ||
653 | /** | ||
654 | * Save your instance-specific properties. The function is | ||
655 | * invoked when the session manager requests your application | ||
656 | * to save its state. | ||
657 | * | ||
658 | * You @em must @em not change the group of the @p kconfig object, since | ||
659 | * KMainWindow uses one group for each window. Please | ||
660 | * reimplement these function in childclasses. | ||
661 | * | ||
662 | * Note: No user interaction is allowed | ||
663 | * in this function! | ||
664 | * | ||
665 | */ | ||
666 | virtual void saveProperties( KConfig* ) {} | ||
667 | |||
668 | /** | ||
669 | * Read your instance-specific properties. | ||
670 | */ | ||
671 | virtual void readProperties( KConfig* ) {} | ||
672 | |||
673 | /** | ||
674 | * Save your application-wide properties. The function is | ||
675 | * invoked when the session manager requests your application | ||
676 | * to save its state. | ||
677 | * | ||
678 | * This function is similar to @ref saveProperties() but is only called for | ||
679 | * the very first main window, regardless how many main window are open. | ||
680 | |||
681 | * Override it if you need to save other data about your documents on | ||
682 | * session end. sessionConfig is a config to which that data should be | ||
683 | * saved. Normally, you don't need this function. But if you want to save | ||
684 | * data about your documents that are not in opened windows you might need | ||
685 | * it. | ||
686 | * | ||
687 | * Default implementation does nothing. | ||
688 | */ | ||
689 | virtual void saveGlobalProperties( KConfig* sessionConfig ); | ||
690 | |||
691 | /** | ||
692 | * The counterpart of @ref saveGlobalProperties(). | ||
693 | * | ||
694 | * Read the application-specific properties in again. | ||
695 | */ | ||
696 | virtual void readGlobalProperties( KConfig* sessionConfig ); | ||
697 | void savePropertiesInternal( KConfig*, int ); | ||
698 | bool readPropertiesInternal( KConfig*, int ); | ||
699 | |||
700 | /** | ||
701 | * For inherited classes | ||
702 | */ | ||
703 | bool settingsDirty() const; | ||
704 | /** | ||
705 | * For inherited classes | ||
706 | */ | ||
707 | QString settingsGroup() const; | ||
708 | /** | ||
709 | * For inherited classes | ||
710 | * Note that the group must be set before calling | ||
711 | */ | ||
712 | void saveWindowSize( KConfig * config ) const; | ||
713 | /** | ||
714 | * For inherited classes | ||
715 | * Note that the group must be set before calling, and that | ||
716 | * a -geometry on the command line has priority. | ||
717 | */ | ||
718 | void restoreWindowSize( KConfig * config ); | ||
719 | |||
720 | /// parse the geometry from the geometry command line argument | ||
721 | void parseGeometry(bool parsewidth); | ||
722 | |||
723 | protected slots: | ||
724 | |||
725 | /** | ||
726 | * This slot does nothing. | ||
727 | * | ||
728 | * It must be reimplemented if you want | ||
729 | * to use a custom About Application dialog box. This slot is | ||
730 | * connected to the About Application entry in the menu returned | ||
731 | * by @ref customHelpMenu. | ||
732 | * | ||
733 | * Example: | ||
734 | * <pre> | ||
735 | * | ||
736 | * void MyMainLevel::setupInterface() | ||
737 | * { | ||
738 | * .. | ||
739 | * menuBar()->insertItem( i18n("&Help"), customHelpMenu() ); | ||
740 | * .. | ||
741 | * } | ||
742 | * | ||
743 | * void MyMainLevel::showAboutApplication() | ||
744 | * { | ||
745 | * <activate your custom dialog> | ||
746 | * } | ||
747 | * </pre> | ||
748 | */ | ||
749 | //US virtual void showAboutApplication(); | ||
750 | |||
751 | private slots: | ||
752 | /** | ||
753 | * Called when the app is shutting down. | ||
754 | */ | ||
755 | void shuttingDown(); | ||
756 | |||
757 | void saveAutoSaveSettings(); | ||
758 | |||
759 | private: | ||
760 | QToolBar * mQToolBar; | ||
761 | //US KMenuBar *internalMenuBar(); | ||
762 | QMenuBar *internalMenuBar(); | ||
763 | //US KStatusBar *internalStatusBar(); | ||
764 | QStatusBar *internalStatusBar(); | ||
765 | |||
766 | KMainWindowPrivate *d; | ||
767 | void initKMainWindow(const char *name); | ||
768 | |||
769 | QPtrList<KToolBar> toolbarList; | ||
770 | |||
771 | protected: | ||
772 | virtual void virtual_hook( int id, void* data ); | ||
773 | |||
774 | }; | ||
775 | |||
776 | #endif | ||