• Skip to content
  • Skip to link menu
KDE 3.5 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

kdeui

kmainwindow.h

Go to the documentation of this file.
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., 51 Franklin Street, Fifth Floor,
00016     Boston, MA 02110-1301, 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 
00611     void setupGUI( QSize defaultSize, int options = ToolBar | Keys | StatusBar | Save | Create, const QString& xmlfile = QString::null );
00612 
00617     KAction *toolBarMenuAction();
00618 
00623     void setupToolbarMenuActions();
00624 
00625     // why do we support old gcc versions? using KXMLGUIBuilder::finalizeGUI;
00627     virtual void finalizeGUI( KXMLGUIClient *client );
00628 
00632     void finalizeGUI( bool force );
00633 
00638     bool initialGeometrySet() const;
00639 
00644     void ignoreInitialGeometry();
00645 
00661     // KDE4 to be removed
00662     QSize sizeForCentralWidgetSize(QSize size) KDE_DEPRECATED;
00663 
00667     // KDE4 remove
00668     virtual void setIcon( const QPixmap & );
00669 
00670 public slots:
00683    int configureToolbars(); // TODO KDE4: make virtual and reimplement in KParts::MainWindow
00684 
00692     virtual void setCaption( const QString &caption );
00702     virtual void setCaption( const QString &caption, bool modified );
00703 
00710     virtual void setPlainCaption( const QString &caption );
00711 
00733     void appHelpActivated( void );
00734 
00741     virtual void slotStateChanged(const QString &newstate);
00742 
00751     void slotStateChanged(const QString &newstate,
00752                           KXMLGUIClient::ReverseStateChange); // KDE 4.0: remove this
00753 
00754 
00762 //     void slotStateChanged(const QString &newstate,
00763 //                           bool reverse); // KDE 4.0: enable this
00764 
00772     void setSettingsDirty();
00773 
00774 protected:
00775     void paintEvent( QPaintEvent* e );
00776     void childEvent( QChildEvent* e);
00777     void resizeEvent( QResizeEvent* e);
00785     virtual void closeEvent ( QCloseEvent *);
00786 
00787     // KDE4 This seems to be flawed to me. Either the app has only one
00788     // mainwindow, so queryClose() is enough, or if it can have more of them,
00789     // then the windows should take care of themselves, and queryExit()
00790     // would be useful only for the annoying 'really quit' dialog, which
00791     // also doesn't make sense in apps with multiple mainwindows.
00792     // And saving configuration in something called queryExit()? IMHO
00793     // one can e.g. use KApplication::shutDown(), which if nothing else
00794     // has at least better fitting name.
00795     // See also KApplication::sessionSaving().
00796     // This stuff should get changed somehow, so that it at least doesn't
00797     // mess with session management.
00825     virtual bool queryExit();
00826 
00861     virtual bool queryClose();
00862 
00876     virtual void saveProperties( KConfig* ) {}
00877 
00881     virtual void readProperties( KConfig* ) {}
00882 
00899     virtual void saveGlobalProperties( KConfig* sessionConfig );
00900 
00906     virtual void readGlobalProperties( KConfig* sessionConfig );
00907     void savePropertiesInternal( KConfig*, int );
00908     bool readPropertiesInternal( KConfig*, int );
00909 
00913     bool settingsDirty() const;
00917     QString settingsGroup() const;
00922     void saveWindowSize( KConfig * config ) const;
00928     void restoreWindowSize( KConfig * config );
00929 
00931     void parseGeometry(bool parsewidth);
00932 
00933 protected slots:
00938    void saveNewToolbarConfig(); // TODO KDE4: make virtual and reimplement in KParts::MainWindow
00939 
00964     virtual void showAboutApplication();
00965 
00989     void saveAutoSaveSettings();
00990 
00991 private slots:
00995     void shuttingDown();
00996 
00997 private:
00998     KMenuBar *internalMenuBar();
00999     KStatusBar *internalStatusBar();
01000     KHelpMenu *mHelpMenu, *helpMenu2;
01001     KXMLGUIFactory *factory_;
01002     QPtrList<KToolBar> toolbarList;
01003 protected:
01004     virtual void virtual_hook( int id, void* data );
01005 private:
01006     KMainWindowPrivate *d;
01007     void initKMainWindow(const char *name, int cflags);
01008 };
01009 
01010 #define RESTORE(type) { int n = 1;\
01011     while (KMainWindow::canBeRestored(n)){\
01012       (new type)->restore(n);\
01013       n++;}}
01014 
01015 #define KDE_RESTORE_MAIN_WINDOWS_NUM_TEMPLATE_ARGS 3
01016 
01027 template <typename T>
01028 inline void kRestoreMainWindows() {
01029   for ( int n = 1 ; KMainWindow::canBeRestored( n ) ; ++n ) {
01030     const QString className = KMainWindow::classNameOfToplevel( n );
01031     if ( className == QString::fromLatin1( T::staticMetaObject()->className() ) )
01032       (new T)->restore( n );
01033   }
01034 }
01035 
01036 template <typename T0, typename T1>
01037 inline void kRestoreMainWindows() {
01038   const char * classNames[2];
01039   classNames[0] = T0::staticMetaObject()->className();
01040   classNames[1] = T1::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   }
01048 }
01049 
01050 template <typename T0, typename T1, typename T2>
01051 inline void kRestoreMainWindows() {
01052   const char * classNames[3];
01053   classNames[0] = T0::staticMetaObject()->className();
01054   classNames[1] = T1::staticMetaObject()->className();
01055   classNames[2] = T2::staticMetaObject()->className();
01056   for ( int n = 1 ; KMainWindow::canBeRestored( n ) ; ++n ) {
01057     const QString className = KMainWindow::classNameOfToplevel( n );
01058     if ( className == QString::fromLatin1( classNames[0] ) )
01059       (new T0)->restore( n );
01060     else if ( className == QString::fromLatin1( classNames[1] ) )
01061       (new T1)->restore( n );
01062     else if ( className == QString::fromLatin1( classNames[2] ) )
01063       (new T2)->restore( n );
01064   }
01065 }
01066 
01067 #endif

kdeui

Skip menu "kdeui"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

API Reference

Skip menu "API Reference"
  • dcop
  • DNSSD
  • interfaces
  • Kate
  • kconf_update
  • KDECore
  • KDED
  • kdefx
  • KDEsu
  • kdeui
  • KDocTools
  • KHTML
  • KImgIO
  • KInit
  • kio
  • kioslave
  • KJS
  • KNewStuff
  • KParts
  • KUtils
Generated for API Reference by doxygen 1.5.9
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal