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

KDEUI

kmainwindow.h

Go to the documentation of this file.
00001 /*
00002     This file is part of the KDE libraries
00003      Copyright
00004      (C) 2000 Reginald Stadlbauer (reggie@kde.org)
00005      (C) 1997 Stephan Kulow (coolo@kde.org)
00006      (C) 1997-2000 Sven Radej (radej@kde.org)
00007      (C) 1997-2000 Matthias Ettrich (ettrich@kde.org)
00008      (C) 1999 Chris Schlaeger (cs@kde.org)
00009      (C) 2002 Joseph Wenninger (jowenn@kde.org)
00010      (C) 2005-2006 Hamish Rodda (rodda@kde.org)
00011 
00012     This library is free software; you can redistribute it and/or
00013     modify it under the terms of the GNU Library General Public
00014     License version 2 as published by the Free Software Foundation.
00015 
00016     This library is distributed in the hope that it will be useful,
00017     but WITHOUT ANY WARRANTY; without even the implied warranty of
00018     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00019     Library General Public License for more details.
00020 
00021     You should have received a copy of the GNU Library General Public License
00022     along with this library; see the file COPYING.LIB.  If not, write to
00023     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00024     Boston, MA 02110-1301, USA.
00025 
00026 
00027 */
00028 
00029 #ifndef KMAINWINDOW_H
00030 #define KMAINWINDOW_H
00031 
00032 #include <kdeui_export.h>
00033 
00034 #include <QtGui/QMainWindow>
00035 #include <QtCore/QMetaClassInfo>
00036 
00037 class KMenu;
00038 class KConfig;
00039 class KConfigGroup;
00040 class KStatusBar;
00041 class KMenuBar;
00042 class KMWSessionManager;
00043 class KMainWindowPrivate;
00044 class KToolBar;
00045 
00046 // internal, not public API, may change any time
00047 #define KDEUI_DECLARE_PRIVATE(classname) \
00048     inline classname ## Private *k_func() { return reinterpret_cast<classname ## Private *>(k_ptr); } \
00049     inline const classname ## Private *k_func() const { return reinterpret_cast<classname ## Private *>(k_ptr); } \
00050     friend class classname ## Private;
00051 
00052 #define KDE_DEFAULT_WINDOWFLAGS 0
00053 
00105 class KDEUI_EXPORT KMainWindow : public QMainWindow
00106 {
00107     friend class KMWSessionManager;
00108     KDEUI_DECLARE_PRIVATE(KMainWindow)
00109     Q_OBJECT
00110     Q_PROPERTY( bool hasMenuBar READ hasMenuBar )
00111     Q_PROPERTY( bool autoSaveSettings READ autoSaveSettings )
00112     Q_PROPERTY( QString autoSaveGroup READ autoSaveGroup )
00113     Q_PROPERTY( bool initialGeometrySet READ initialGeometrySet )
00114 
00115 public:
00150     explicit KMainWindow( QWidget* parent = 0, Qt::WindowFlags f = KDE_DEFAULT_WINDOWFLAGS );
00151 
00158     virtual ~KMainWindow();
00159 
00184     KMenu* helpMenu( const QString &aboutAppText = QString(),
00185               bool showWhatsThis = true );
00186 
00209     KMenu* customHelpMenu( bool showWhatsThis = true );
00210 
00277     static bool canBeRestored( int number );
00278 
00286     static const QString classNameOfToplevel( int number );
00287 
00296     bool restore( int number, bool show = true );
00297 
00301      bool hasMenuBar();
00302 
00308     KMenuBar *menuBar();
00309 
00321     KStatusBar *statusBar();
00322 
00323 
00327     static QList<KMainWindow*> memberList();
00328 
00339     KToolBar *toolBar( const QString& name = QString() );
00340 
00344     QList<KToolBar*> toolBars() const;
00345 
00377     void setAutoSaveSettings( const QString & groupName = QLatin1String("MainWindow"),
00378                               bool saveWindowSize = true );
00379 
00384     void resetAutoSaveSettings();
00385 
00390     bool autoSaveSettings() const;
00391 
00398     QString autoSaveGroup() const;
00399 
00407     virtual void applyMainWindowSettings( const KConfigGroup &config, bool force = false);
00408 
00415     void saveMainWindowSettings(const KConfigGroup &config);
00416 
00421     bool initialGeometrySet() const;
00422 
00427     void ignoreInitialGeometry();
00428 
00433     QString dbusName() const;
00434 
00435 public Q_SLOTS:
00443     virtual void setCaption( const QString &caption );
00453     virtual void setCaption( const QString &caption, bool modified );
00454 
00461     virtual void setPlainCaption( const QString &caption );
00462 
00482     void appHelpActivated( void );
00483 
00491     void setSettingsDirty();
00492 
00493 protected:
00499     virtual bool event( QEvent * event );
00500 
00508     virtual void closeEvent ( QCloseEvent *);
00509 
00510     // KDE4 This seems to be flawed to me. Either the app has only one
00511     // mainwindow, so queryClose() is enough, or if it can have more of them,
00512     // then the windows should take care of themselves, and queryExit()
00513     // would be useful only for the annoying 'really quit' dialog, which
00514     // also doesn't make sense in apps with multiple mainwindows.
00515     // And saving configuration in something called queryExit()? IMHO
00516     // one can e.g. use QCoreApplication::aboutToQuit(), which if nothing else
00517     // has at least better fitting name.
00518     // See also KApplication::sessionSaving().
00519     // This stuff should get changed somehow, so that it at least doesn't
00520     // mess with session management.
00548     virtual bool queryExit();
00549 
00584     virtual bool queryClose();
00585 
00597     virtual void saveProperties( KConfigGroup & ) {}
00598 
00602     virtual void readProperties( const KConfigGroup & ) {}
00603 
00620     virtual void saveGlobalProperties( KConfig* sessionConfig );
00621 
00627     virtual void readGlobalProperties( KConfig* sessionConfig );
00628     void savePropertiesInternal( KConfig*, int );
00629     bool readPropertiesInternal( KConfig*, int );
00630 
00634     bool settingsDirty() const;
00638     void saveWindowSize( const KConfigGroup &config ) const;
00643     void restoreWindowSize( const KConfigGroup & config );
00644 
00646     void parseGeometry(bool parsewidth);
00647 
00648 protected Q_SLOTS:
00673     virtual void showAboutApplication();
00674 
00696     void saveAutoSaveSettings();
00697 
00698 protected:
00699     KMainWindow(KMainWindowPrivate &dd, QWidget *parent, Qt::WFlags f);
00700 
00701     KMainWindowPrivate * const k_ptr;
00702 private:
00703     Q_PRIVATE_SLOT(k_func(), void _k_shuttingDown())
00704 };
00705 
00706 #define RESTORE(type) { int n = 1;\
00707     while (KMainWindow::canBeRestored(n)){\
00708       (new type)->restore(n);\
00709       n++;}}
00710 
00711 #define KDE_RESTORE_MAIN_WINDOWS_NUM_TEMPLATE_ARGS 3
00712 
00720 template <typename T>
00721 inline void kRestoreMainWindows() {
00722   for ( int n = 1 ; KMainWindow::canBeRestored( n ) ; ++n ) {
00723     const QString className = KMainWindow::classNameOfToplevel( n );
00724     if ( className == QLatin1String( T::staticMetaObject.className() ) )
00725       (new T)->restore( n );
00726   }
00727 }
00728 
00729 template <typename T0, typename T1>
00730 inline void kRestoreMainWindows() {
00731   const char * classNames[2];
00732   classNames[0] = T0::staticMetaObject.className();
00733   classNames[1] = T1::staticMetaObject.className();
00734   for ( int n = 1 ; KMainWindow::canBeRestored( n ) ; ++n ) {
00735     const QString className = KMainWindow::classNameOfToplevel( n );
00736     if ( className == QLatin1String( classNames[0] ) )
00737       (new T0)->restore( n );
00738     else if ( className == QLatin1String( classNames[1] ) )
00739       (new T1)->restore( n );
00740   }
00741 }
00742 
00743 template <typename T0, typename T1, typename T2>
00744 inline void kRestoreMainWindows() {
00745   const char * classNames[3];
00746   classNames[0] = T0::staticMetaObject.className();
00747   classNames[1] = T1::staticMetaObject.className();
00748   classNames[2] = T2::staticMetaObject.className();
00749   for ( int n = 1 ; KMainWindow::canBeRestored( n ) ; ++n ) {
00750     const QString className = KMainWindow::classNameOfToplevel( n );
00751     if ( className == QLatin1String( classNames[0] ) )
00752       (new T0)->restore( n );
00753     else if ( className == QLatin1String( classNames[1] ) )
00754       (new T1)->restore( n );
00755     else if ( className == QLatin1String( classNames[2] ) )
00756       (new T2)->restore( n );
00757   }
00758 }
00759 
00760 #endif

KDEUI

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

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • KIO
  • KIOSlave
  • KJS
  •   WTF
  • KJSEmbed
  • KNewStuff
  • KParts
  • Kross
  • KUtils
  • Nepomuk
  •   core
  • Phonon
  •   Backend
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.5.4
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