kmainwindow.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef KMAINWINDOW_H
00022 #define KMAINWINDOW_H
00023
00024 #include "kxmlguifactory.h"
00025 #include "kxmlguiclient.h"
00026 #include "kxmlguibuilder.h"
00027 #include <qmainwindow.h>
00028 #include <qmetaobject.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 class DCOPObject;
00043
00044 #define KDE_DEFAULT_WINDOWFLAGS WType_TopLevel | WDestructiveClose
00045
00046
00098 class KDEUI_EXPORT KMainWindow : public QMainWindow, public KXMLGUIBuilder, virtual public KXMLGUIClient
00099 {
00100 friend class KMWSessionManaged;
00101 Q_OBJECT
00102
00103 public:
00136 KMainWindow( QWidget* parent = 0, const char *name = 0, WFlags f = WType_TopLevel | WDestructiveClose );
00137
00148 enum CreationFlags
00149 {
00150 NoDCOPObject = 1
00151 };
00152
00158 KMainWindow( int cflags, QWidget* parent = 0, const char *name = 0, WFlags f = WType_TopLevel | WDestructiveClose );
00159
00166 virtual ~KMainWindow();
00167
00192 KPopupMenu* helpMenu( const QString &aboutAppText = QString::null,
00193 bool showWhatsThis = true );
00194
00217 KPopupMenu* customHelpMenu( bool showWhatsThis = true );
00218
00285 static bool canBeRestored( int number );
00286
00294
00295 static const QString classNameOfToplevel( int number );
00296
00300
00301 virtual void show();
00302
00306
00307 virtual void hide();
00308
00317 bool restore( int number, bool show = true );
00318
00319 virtual KXMLGUIFactory *guiFactory();
00320
00340 void createGUI( const QString &xmlfile = QString::null, bool _conserveMemory = true );
00341
00348 void setHelpMenuEnabled(bool showHelpMenu = true);
00349
00353 bool isHelpMenuEnabled();
00354
00355
00360 bool hasMenuBar();
00361
00367 KMenuBar *menuBar();
00368
00375 KStatusBar *statusBar();
00376
00380 static QPtrList<KMainWindow>* memberList;
00381
00382
00393 KToolBar *toolBar( const char *name=0 );
00394
00398 QPtrListIterator<KToolBar> toolBarIterator();
00399
00404 KAccel *accel();
00405
00406 void setFrameBorderWidth( int ) {}
00407
00439 void setAutoSaveSettings( const QString & groupName = QString::fromLatin1("MainWindow"),
00440 bool saveWindowSize = true );
00441
00446 void resetAutoSaveSettings();
00447
00453 bool autoSaveSettings() const;
00454
00462 QString autoSaveGroup() const;
00463
00473 void applyMainWindowSettings(KConfig *config, const QString &groupName, bool force);
00474
00475 void applyMainWindowSettings(KConfig *config, const QString &groupName = QString::null);
00476
00485 void saveMainWindowSettings(KConfig *config, const QString &groupName = QString::null);
00486
00505 void setStandardToolBarMenuEnabled( bool enable );
00507 bool isStandardToolBarMenuEnabled() const;
00508
00509
00530 void createStandardStatusBarAction();
00531
00535 enum StandardWindowOptions
00536 {
00542 ToolBar = 1,
00543
00547 Keys = 2,
00548
00553 StatusBar = 4,
00554
00565 Save = 8,
00566
00571 Create = 16
00572 };
00573
00585 void setupGUI( int options = ToolBar | Keys | StatusBar | Save | Create, const QString& xmlfile = QString::null );
00586
00591 KAction *toolBarMenuAction();
00592
00597 void setupToolbarMenuActions();
00598
00599
00601 virtual void finalizeGUI( KXMLGUIClient *client );
00602
00606 void finalizeGUI( bool force );
00607
00612 bool initialGeometrySet() const;
00613
00618 void ignoreInitialGeometry();
00619
00635
00636 QSize sizeForCentralWidgetSize(QSize size) KDE_DEPRECATED;
00637
00641
00642 virtual void setIcon( const QPixmap & );
00643
00644 public slots:
00657 int configureToolbars();
00658
00666 virtual void setCaption( const QString &caption );
00676 virtual void setCaption( const QString &caption, bool modified );
00677
00684 virtual void setPlainCaption( const QString &caption );
00685
00707 void appHelpActivated( void );
00708
00715 virtual void slotStateChanged(const QString &newstate);
00716
00725 void slotStateChanged(const QString &newstate,
00726 KXMLGUIClient::ReverseStateChange);
00727
00728
00736
00737
00738
00746 void setSettingsDirty();
00747
00748 protected:
00749 void paintEvent( QPaintEvent* e );
00750 void childEvent( QChildEvent* e);
00751 void resizeEvent( QResizeEvent* e);
00759 virtual void closeEvent ( QCloseEvent *);
00760
00761
00762
00763
00764
00765
00766
00767
00768
00769
00770
00771
00799 virtual bool queryExit();
00800
00835 virtual bool queryClose();
00836
00850 virtual void saveProperties( KConfig* ) {}
00851
00855 virtual void readProperties( KConfig* ) {}
00856
00873 virtual void saveGlobalProperties( KConfig* sessionConfig );
00874
00880 virtual void readGlobalProperties( KConfig* sessionConfig );
00881 void savePropertiesInternal( KConfig*, int );
00882 bool readPropertiesInternal( KConfig*, int );
00883
00887 bool settingsDirty() const;
00891 QString settingsGroup() const;
00896 void saveWindowSize( KConfig * config ) const;
00902 void restoreWindowSize( KConfig * config );
00903
00905 void parseGeometry(bool parsewidth);
00906
00907 protected slots:
00912 void saveNewToolbarConfig();
00913
00938 virtual void showAboutApplication();
00939
00963 void saveAutoSaveSettings();
00964
00965 private slots:
00969 void shuttingDown();
00970
00971 private:
00972 KMenuBar *internalMenuBar();
00973 KStatusBar *internalStatusBar();
00974 KHelpMenu *mHelpMenu, *helpMenu2;
00975 KXMLGUIFactory *factory_;
00976 QPtrList<KToolBar> toolbarList;
00977 protected:
00978 virtual void virtual_hook( int id, void* data );
00979 private:
00980 KMainWindowPrivate *d;
00981 void initKMainWindow(const char *name, int cflags);
00982 };
00983
00984 #define RESTORE(type) { int n = 1;\
00985 while (KMainWindow::canBeRestored(n)){\
00986 (new type)->restore(n);\
00987 n++;}}
00988
00989 #define KDE_RESTORE_MAIN_WINDOWS_NUM_TEMPLATE_ARGS 3
00990
01001 template <typename T>
01002 inline void kRestoreMainWindows() {
01003 for ( int n = 1 ; KMainWindow::canBeRestored( n ) ; ++n ) {
01004 const QString className = KMainWindow::classNameOfToplevel( n );
01005 if ( className == QString::fromLatin1( T::staticMetaObject()->className() ) )
01006 (new T)->restore( n );
01007 }
01008 }
01009
01010 template <typename T0, typename T1>
01011 inline void kRestoreMainWindows() {
01012 const char * classNames[2];
01013 classNames[0] = T0::staticMetaObject()->className();
01014 classNames[1] = T1::staticMetaObject()->className();
01015 for ( int n = 1 ; KMainWindow::canBeRestored( n ) ; ++n ) {
01016 const QString className = KMainWindow::classNameOfToplevel( n );
01017 if ( className == QString::fromLatin1( classNames[0] ) )
01018 (new T0)->restore( n );
01019 else if ( className == QString::fromLatin1( classNames[1] ) )
01020 (new T1)->restore( n );
01021 }
01022 }
01023
01024 template <typename T0, typename T1, typename T2>
01025 inline void kRestoreMainWindows() {
01026 const char * classNames[3];
01027 classNames[0] = T0::staticMetaObject()->className();
01028 classNames[1] = T1::staticMetaObject()->className();
01029 classNames[2] = T2::staticMetaObject()->className();
01030 for ( int n = 1 ; KMainWindow::canBeRestored( n ) ; ++n ) {
01031 const QString className = KMainWindow::classNameOfToplevel( n );
01032 if ( className == QString::fromLatin1( classNames[0] ) )
01033 (new T0)->restore( n );
01034 else if ( className == QString::fromLatin1( classNames[1] ) )
01035 (new T1)->restore( n );
01036 else if ( className == QString::fromLatin1( classNames[2] ) )
01037 (new T2)->restore( n );
01038 }
01039 }
01040
01041 #endif
This file is part of the documentation for kdeui Library Version 3.3.90.