• Skip to content
  • Skip to link menu
KDE 4.2 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      (C) 2000-2008 David Faure (faure@kde.org)
00012 
00013     This library is free software; you can redistribute it and/or
00014     modify it under the terms of the GNU Library General Public
00015     License version 2 as published by the Free Software Foundation.
00016 
00017     This library is distributed in the hope that it will be useful,
00018     but WITHOUT ANY WARRANTY; without even the implied warranty of
00019     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00020     Library General Public License for more details.
00021 
00022     You should have received a copy of the GNU Library General Public License
00023     along with this library; see the file COPYING.LIB.  If not, write to
00024     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00025     Boston, MA 02110-1301, USA.
00026 
00027 
00028 */
00029 
00030 #ifndef KMAINWINDOW_H
00031 #define KMAINWINDOW_H
00032 
00033 #include <kdeui_export.h>
00034 
00035 #include <QtGui/QMainWindow>
00036 #include <QtCore/QMetaClassInfo>
00037 
00038 class KMenu;
00039 class KConfig;
00040 class KConfigGroup;
00041 class KStatusBar;
00042 class KMenuBar;
00043 class KMWSessionManager;
00044 class KMainWindowPrivate;
00045 class KToolBar;
00046 
00047 // internal, not public API, may change any time
00048 #define KDEUI_DECLARE_PRIVATE(classname) \
00049     inline classname ## Private *k_func() { return reinterpret_cast<classname ## Private *>(k_ptr); } \
00050     inline const classname ## Private *k_func() const { return reinterpret_cast<classname ## Private *>(k_ptr); } \
00051     friend class classname ## Private;
00052 
00053 // This is mostly from KDE3. TODO KDE5: remove the constructor parameter.
00054 #define KDE_DEFAULT_WINDOWFLAGS 0
00055 
00105 class KDEUI_EXPORT KMainWindow : public QMainWindow
00106 {
00107     friend class KMWSessionManager;
00108     friend class DockResizeListener;
00109     KDEUI_DECLARE_PRIVATE(KMainWindow)
00110     Q_OBJECT
00111     Q_PROPERTY( bool hasMenuBar READ hasMenuBar )
00112     Q_PROPERTY( bool autoSaveSettings READ autoSaveSettings )
00113     Q_PROPERTY( QString autoSaveGroup READ autoSaveGroup )
00114     Q_PROPERTY( bool initialGeometrySet READ initialGeometrySet )
00115 
00116 public:
00149     explicit KMainWindow( QWidget* parent = 0, Qt::WindowFlags f = KDE_DEFAULT_WINDOWFLAGS );
00150 
00157     virtual ~KMainWindow();
00158 
00183     KMenu* helpMenu( const QString &aboutAppText = QString(),
00184               bool showWhatsThis = true );
00185 
00208     KMenu* customHelpMenu( bool showWhatsThis = true );
00209 
00276     static bool canBeRestored( int number );
00277 
00285     static const QString classNameOfToplevel( int number );
00286 
00295     bool restore( int number, bool show = true );
00296 
00300      bool hasMenuBar();
00301 
00307     KMenuBar *menuBar();
00308 
00320     KStatusBar *statusBar();
00321 
00322 
00326     static QList<KMainWindow*> memberList();
00327 
00338     KToolBar *toolBar( const QString& name = QString() );
00339 
00343     QList<KToolBar*> toolBars() const;
00344 
00376     void setAutoSaveSettings( const QString & groupName = QLatin1String("MainWindow"),
00377                               bool saveWindowSize = true );
00378 
00384     void setAutoSaveSettings(const KConfigGroup & group,
00385                              bool saveWindowSize = true);
00386 
00391     void resetAutoSaveSettings();
00392 
00397     bool autoSaveSettings() const;
00398 
00408     QString autoSaveGroup() const;
00409 
00416     KConfigGroup autoSaveConfigGroup() const;
00417 
00425     virtual void applyMainWindowSettings( const KConfigGroup &config, bool force = false);
00426 
00433     void saveMainWindowSettings(const KConfigGroup &config);
00434 
00439     bool initialGeometrySet() const;
00440 
00445     void ignoreInitialGeometry();
00446 
00451     QString dbusName() const;
00452 
00453 public Q_SLOTS:
00461     virtual void setCaption( const QString &caption );
00471     virtual void setCaption( const QString &caption, bool modified );
00472 
00479     virtual void setPlainCaption( const QString &caption );
00480 
00500     void appHelpActivated( void );
00501 
00509     void setSettingsDirty();
00510 
00511 protected:
00517     virtual bool event( QEvent * event );
00518 
00526     virtual void closeEvent ( QCloseEvent *);
00527 
00528     // KDE4 This seems to be flawed to me. Either the app has only one
00529     // mainwindow, so queryClose() is enough, or if it can have more of them,
00530     // then the windows should take care of themselves, and queryExit()
00531     // would be useful only for the annoying 'really quit' dialog, which
00532     // also doesn't make sense in apps with multiple mainwindows.
00533     // And saving configuration in something called queryExit()? IMHO
00534     // one can e.g. use QCoreApplication::aboutToQuit(), which if nothing else
00535     // has at least better fitting name.
00536     // See also KApplication::sessionSaving().
00537     // This stuff should get changed somehow, so that it at least doesn't
00538     // mess with session management.
00566     virtual bool queryExit();
00567 
00602     virtual bool queryClose();
00603 
00615     virtual void saveProperties( KConfigGroup & ) {}
00616 
00620     virtual void readProperties( const KConfigGroup & ) {}
00621 
00638     virtual void saveGlobalProperties( KConfig* sessionConfig );
00639 
00645     virtual void readGlobalProperties( KConfig* sessionConfig );
00646     void savePropertiesInternal( KConfig*, int );
00647     bool readPropertiesInternal( KConfig*, int );
00648 
00652     bool settingsDirty() const;
00656     void saveWindowSize( const KConfigGroup &config ) const;
00661     void restoreWindowSize( const KConfigGroup & config );
00662 
00664     void parseGeometry(bool parsewidth);
00665 
00666 protected Q_SLOTS:
00691     virtual void showAboutApplication();
00692 
00714     void saveAutoSaveSettings();
00715 
00716 protected:
00717     KMainWindow(KMainWindowPrivate &dd, QWidget *parent, Qt::WFlags f);
00718 
00719     KMainWindowPrivate * const k_ptr;
00720 private:
00721     Q_PRIVATE_SLOT(k_func(), void _k_shuttingDown())
00722     Q_PRIVATE_SLOT(k_func(), void _k_slotSettingsChanged(int))
00723     Q_PRIVATE_SLOT(k_func(), void _k_slotSaveAutoSaveSize())
00724 };
00725 
00726 #define RESTORE(type) { int n = 1;\
00727     while (KMainWindow::canBeRestored(n)){\
00728       (new type)->restore(n);\
00729       n++;}}
00730 
00731 #define KDE_RESTORE_MAIN_WINDOWS_NUM_TEMPLATE_ARGS 3
00732 
00740 template <typename T>
00741 inline void kRestoreMainWindows() {
00742   for ( int n = 1 ; KMainWindow::canBeRestored( n ) ; ++n ) {
00743     const QString className = KMainWindow::classNameOfToplevel( n );
00744     if ( className == QLatin1String( T::staticMetaObject.className() ) )
00745       (new T)->restore( n );
00746   }
00747 }
00748 
00749 template <typename T0, typename T1>
00750 inline void kRestoreMainWindows() {
00751   const char * classNames[2];
00752   classNames[0] = T0::staticMetaObject.className();
00753   classNames[1] = T1::staticMetaObject.className();
00754   for ( int n = 1 ; KMainWindow::canBeRestored( n ) ; ++n ) {
00755     const QString className = KMainWindow::classNameOfToplevel( n );
00756     if ( className == QLatin1String( classNames[0] ) )
00757       (new T0)->restore( n );
00758     else if ( className == QLatin1String( classNames[1] ) )
00759       (new T1)->restore( n );
00760   }
00761 }
00762 
00763 template <typename T0, typename T1, typename T2>
00764 inline void kRestoreMainWindows() {
00765   const char * classNames[3];
00766   classNames[0] = T0::staticMetaObject.className();
00767   classNames[1] = T1::staticMetaObject.className();
00768   classNames[2] = T2::staticMetaObject.className();
00769   for ( int n = 1 ; KMainWindow::canBeRestored( n ) ; ++n ) {
00770     const QString className = KMainWindow::classNameOfToplevel( n );
00771     if ( className == QLatin1String( classNames[0] ) )
00772       (new T0)->restore( n );
00773     else if ( className == QLatin1String( classNames[1] ) )
00774       (new T1)->restore( n );
00775     else if ( className == QLatin1String( classNames[2] ) )
00776       (new T2)->restore( n );
00777   }
00778 }
00779 
00780 #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
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • Kross
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.5.7
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