kdeui Library API Documentation

kmainwindow.h

00001 /* 00002 This file is part of the KDE libraries 00003 00004 This library is free software; you can redistribute it and/or 00005 modify it under the terms of the GNU Library General Public 00006 License version 2 as published by the Free Software Foundation. 00007 00008 This library is distributed in the hope that it will be useful, 00009 but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00011 Library General Public License for more details. 00012 00013 You should have received a copy of the GNU Library General Public License 00014 along with this library; see the file COPYING.LIB. If not, write to 00015 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 00016 Boston, MA 02111-1307, USA. 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 // KDE 4 return QCString - QObject::className() returns const char* 00295 static const QString classNameOfToplevel( int number ); 00296 00300 // KDE4 remove this method if this has been fixed in Qt 00301 virtual void show(); 00302 00306 // KDE4 remove this method if this has been fixed in Qt 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 00380 KStatusBar *statusBar(); 00381 00385 static QPtrList<KMainWindow>* memberList; 00386 00387 //KDE4: replace with memberList() and make memberList member private 00392 static QPtrList<KMainWindow>* getMemberList(); 00393 00404 KToolBar *toolBar( const char *name=0 ); 00405 00409 QPtrListIterator<KToolBar> toolBarIterator(); 00410 00415 KAccel *accel(); 00416 00417 void setFrameBorderWidth( int ) {} 00418 00450 void setAutoSaveSettings( const QString & groupName = QString::fromLatin1("MainWindow"), 00451 bool saveWindowSize = true ); 00452 00457 void resetAutoSaveSettings(); 00458 00464 bool autoSaveSettings() const; 00465 00473 QString autoSaveGroup() const; 00474 00484 void applyMainWindowSettings(KConfig *config, const QString &groupName, bool force); 00485 // KDE4 merge with force=false 00486 void applyMainWindowSettings(KConfig *config, const QString &groupName = QString::null); 00487 00496 void saveMainWindowSettings(KConfig *config, const QString &groupName = QString::null); 00497 00516 void setStandardToolBarMenuEnabled( bool enable ); 00518 bool isStandardToolBarMenuEnabled() const; 00519 00520 00541 void createStandardStatusBarAction(); 00542 00546 enum StandardWindowOptions 00547 { 00553 ToolBar = 1, 00554 00558 Keys = 2, 00559 00564 StatusBar = 4, 00565 00576 Save = 8, 00577 00582 Create = 16 00583 }; 00584 00596 void setupGUI( int options = ToolBar | Keys | StatusBar | Save | Create, const QString& xmlfile = QString::null ); 00597 00602 KAction *toolBarMenuAction(); 00603 00608 void setupToolbarMenuActions(); 00609 00610 // why do we support old gcc versions? using KXMLGUIBuilder::finalizeGUI; 00612 virtual void finalizeGUI( KXMLGUIClient *client ); 00613 00617 void finalizeGUI( bool force ); 00618 00623 bool initialGeometrySet() const; 00624 00629 void ignoreInitialGeometry(); 00630 00646 // KDE4 to be removed 00647 QSize sizeForCentralWidgetSize(QSize size) KDE_DEPRECATED; 00648 00652 // KDE4 remove 00653 virtual void setIcon( const QPixmap & ); 00654 00655 public slots: 00668 int configureToolbars(); // TODO KDE4: make virtual and reimplement in KParts::MainWindow 00669 00677 virtual void setCaption( const QString &caption ); 00687 virtual void setCaption( const QString &caption, bool modified ); 00688 00695 virtual void setPlainCaption( const QString &caption ); 00696 00718 void appHelpActivated( void ); 00719 00726 virtual void slotStateChanged(const QString &newstate); 00727 00736 void slotStateChanged(const QString &newstate, 00737 KXMLGUIClient::ReverseStateChange); // KDE 4.0: remove this 00738 00739 00747 // void slotStateChanged(const QString &newstate, 00748 // bool reverse); // KDE 4.0: enable this 00749 00757 void setSettingsDirty(); 00758 00759 protected: 00760 void paintEvent( QPaintEvent* e ); 00761 void childEvent( QChildEvent* e); 00762 void resizeEvent( QResizeEvent* e); 00770 virtual void closeEvent ( QCloseEvent *); 00771 00772 // KDE4 This seems to be flawed to me. Either the app has only one 00773 // mainwindow, so queryClose() is enough, or if it can have more of them, 00774 // then the windows should take care of themselves, and queryExit() 00775 // would be useful only for the annoying 'really quit' dialog, which 00776 // also doesn't make sense in apps with multiple mainwindows. 00777 // And saving configuration in something called queryExit()? IMHO 00778 // one can e.g. use KApplication::shutDown(), which if nothing else 00779 // has at least better fitting name. 00780 // See also KApplication::sessionSaving(). 00781 // This stuff should get changed somehow, so that it at least doesn't 00782 // mess with session management. 00810 virtual bool queryExit(); 00811 00846 virtual bool queryClose(); 00847 00861 virtual void saveProperties( KConfig* ) {} 00862 00866 virtual void readProperties( KConfig* ) {} 00867 00884 virtual void saveGlobalProperties( KConfig* sessionConfig ); 00885 00891 virtual void readGlobalProperties( KConfig* sessionConfig ); 00892 void savePropertiesInternal( KConfig*, int ); 00893 bool readPropertiesInternal( KConfig*, int ); 00894 00898 bool settingsDirty() const; 00902 QString settingsGroup() const; 00907 void saveWindowSize( KConfig * config ) const; 00913 void restoreWindowSize( KConfig * config ); 00914 00916 void parseGeometry(bool parsewidth); 00917 00918 protected slots: 00923 void saveNewToolbarConfig(); // TODO KDE4: make virtual and reimplement in KParts::MainWindow 00924 00949 virtual void showAboutApplication(); 00950 00974 void saveAutoSaveSettings(); 00975 00976 private slots: 00980 void shuttingDown(); 00981 00982 private: 00983 KMenuBar *internalMenuBar(); 00984 KStatusBar *internalStatusBar(); 00985 KHelpMenu *mHelpMenu, *helpMenu2; 00986 KXMLGUIFactory *factory_; 00987 QPtrList<KToolBar> toolbarList; 00988 protected: 00989 virtual void virtual_hook( int id, void* data ); 00990 private: 00991 KMainWindowPrivate *d; 00992 void initKMainWindow(const char *name, int cflags); 00993 }; 00994 00995 #define RESTORE(type) { int n = 1;\ 00996 while (KMainWindow::canBeRestored(n)){\ 00997 (new type)->restore(n);\ 00998 n++;}} 00999 01000 #define KDE_RESTORE_MAIN_WINDOWS_NUM_TEMPLATE_ARGS 3 01001 01012 template <typename T> 01013 inline void kRestoreMainWindows() { 01014 for ( int n = 1 ; KMainWindow::canBeRestored( n ) ; ++n ) { 01015 const QString className = KMainWindow::classNameOfToplevel( n ); 01016 if ( className == QString::fromLatin1( T::staticMetaObject()->className() ) ) 01017 (new T)->restore( n ); 01018 } 01019 } 01020 01021 template <typename T0, typename T1> 01022 inline void kRestoreMainWindows() { 01023 const char * classNames[2]; 01024 classNames[0] = T0::staticMetaObject()->className(); 01025 classNames[1] = T1::staticMetaObject()->className(); 01026 for ( int n = 1 ; KMainWindow::canBeRestored( n ) ; ++n ) { 01027 const QString className = KMainWindow::classNameOfToplevel( n ); 01028 if ( className == QString::fromLatin1( classNames[0] ) ) 01029 (new T0)->restore( n ); 01030 else if ( className == QString::fromLatin1( classNames[1] ) ) 01031 (new T1)->restore( n ); 01032 } 01033 } 01034 01035 template <typename T0, typename T1, typename T2> 01036 inline void kRestoreMainWindows() { 01037 const char * classNames[3]; 01038 classNames[0] = T0::staticMetaObject()->className(); 01039 classNames[1] = T1::staticMetaObject()->className(); 01040 classNames[2] = T2::staticMetaObject()->className(); 01041 for ( int n = 1 ; KMainWindow::canBeRestored( n ) ; ++n ) { 01042 const QString className = KMainWindow::classNameOfToplevel( n ); 01043 if ( className == QString::fromLatin1( classNames[0] ) ) 01044 (new T0)->restore( n ); 01045 else if ( className == QString::fromLatin1( classNames[1] ) ) 01046 (new T1)->restore( n ); 01047 else if ( className == QString::fromLatin1( classNames[2] ) ) 01048 (new T2)->restore( n ); 01049 } 01050 } 01051 01052 #endif
KDE Logo
This file is part of the documentation for kdeui Library Version 3.4.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Thu Apr 14 00:10:13 2005 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003