kmainwindow.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef KMAINWINDOW_H
00023 #define KMAINWINDOW_H
00024
00025 #include "kxmlguifactory.h"
00026 #include "kxmlguiclient.h"
00027 #include "kxmlguibuilder.h"
00028 #include <qmainwindow.h>
00029 #include <ktoolbar.h>
00030
00031 class KPopupMenu;
00032 class KXMLGUIFactory;
00033 class KConfig;
00034 class KHelpMenu;
00035 class KStatusBar;
00036 class QStatusBar;
00037 class KMenuBar;
00038 class KMWSessionManaged;
00039 class KMainWindowPrivate;
00040 class KAccel;
00041 class KToolBarMenuAction;
00042
00043
00044 #define KDE_DEFAULT_WINDOWFLAGS WType_TopLevel | WDestructiveClose
00045
00046
00097 class KMainWindow : public QMainWindow, public KXMLGUIBuilder, virtual public KXMLGUIClient
00098 {
00099 friend class KMWSessionManaged;
00100 Q_OBJECT
00101
00102 public:
00131 KMainWindow( QWidget* parent = 0, const char *name = 0, WFlags f = WType_TopLevel | WDestructiveClose );
00132
00133
00140 virtual ~KMainWindow();
00141
00166 KPopupMenu* helpMenu( const QString &aboutAppText = QString::null,
00167 bool showWhatsThis = TRUE );
00168
00191 KPopupMenu* customHelpMenu( bool showWhatsThis = TRUE );
00192
00241 static bool canBeRestored( int number );
00242
00250 static const QString classNameOfToplevel( int number );
00251
00260 bool restore( int number, bool show = TRUE );
00261
00262 virtual KXMLGUIFactory *guiFactory();
00263
00283 void createGUI( const QString &xmlfile = QString::null, bool _conserveMemory = TRUE );
00284
00291 void setHelpMenuEnabled(bool showHelpMenu = true);
00292
00296 bool isHelpMenuEnabled();
00297
00298
00303 bool hasMenuBar();
00304
00310 KMenuBar *menuBar();
00311
00318 KStatusBar *statusBar();
00319
00323 static QPtrList<KMainWindow>* memberList;
00324
00335 KToolBar *toolBar( const char *name=0 );
00336
00340 QPtrListIterator<KToolBar> toolBarIterator();
00341
00346 KAccel *accel();
00347
00348 void setFrameBorderWidth( int ) {}
00349
00367 void setAutoSaveSettings( const QString & groupName = QString::fromLatin1("MainWindow"),
00368 bool saveWindowSize = true );
00369
00374 void resetAutoSaveSettings();
00375
00381 bool autoSaveSettings() const;
00382
00390 QString autoSaveGroup() const;
00391
00400 void applyMainWindowSettings(KConfig *config, const QString &groupName = QString::null);
00401
00410 void saveMainWindowSettings(KConfig *config, const QString &groupName = QString::null);
00411
00430 void setStandardToolBarMenuEnabled( bool enable );
00432 bool isStandardToolBarMenuEnabled() const;
00433
00438 KAction *toolBarMenuAction();
00439
00440
00442
00443
00447 void finalizeGUI( bool force );
00448
00453 bool initialGeometrySet() const;
00454
00459 QSize sizeForCentralWidgetSize(QSize size);
00460
00461 public slots:
00469 virtual void setCaption( const QString &caption );
00479 virtual void setCaption( const QString &caption, bool modified );
00480
00487 virtual void setPlainCaption( const QString &caption );
00488
00510 void appHelpActivated( void );
00511
00518 virtual void slotStateChanged(const QString &newstate);
00519
00528 void slotStateChanged(const QString &newstate,
00529 KXMLGUIClient::ReverseStateChange);
00530
00531
00539
00540
00541
00545 void setSettingsDirty();
00546
00547 protected:
00548 void paintEvent( QPaintEvent* e );
00549 void childEvent( QChildEvent* e);
00550 void resizeEvent( QResizeEvent* e);
00558 virtual void closeEvent ( QCloseEvent *);
00586 virtual bool queryExit();
00587
00617 virtual bool queryClose();
00631 virtual void saveProperties( KConfig* ) {}
00632
00636 virtual void readProperties( KConfig* ) {}
00637
00654 virtual void saveGlobalProperties( KConfig* sessionConfig );
00655
00661 virtual void readGlobalProperties( KConfig* sessionConfig );
00662 void savePropertiesInternal( KConfig*, int );
00663 bool readPropertiesInternal( KConfig*, int );
00664
00668 bool settingsDirty() const;
00672 QString settingsGroup() const;
00677 void saveWindowSize( KConfig * config ) const;
00683 void restoreWindowSize( KConfig * config );
00684
00686 void parseGeometry(bool parsewidth);
00687
00688 protected slots:
00689
00714 virtual void showAboutApplication();
00715
00716 private slots:
00720 void shuttingDown();
00721
00722 void saveAutoSaveSettings();
00723
00724 private:
00725 KMenuBar *internalMenuBar();
00726 KStatusBar *internalStatusBar();
00727 KHelpMenu *mHelpMenu, *helpMenu2;
00728 KXMLGUIFactory *factory_;
00729 QPtrList<KToolBar> toolbarList;
00730 protected:
00731 virtual void virtual_hook( int id, void* data );
00732 private:
00733 KMainWindowPrivate *d;
00734 void initKMainWindow(const char *name);
00735 };
00736
00737 #define RESTORE(type) { int n = 1;\
00738 while (KMainWindow::canBeRestored(n)){\
00739 (new type)->restore(n);\
00740 n++;}}
00741
00742
00743 #endif
This file is part of the documentation for kdelibs Version 3.1.0.