• Skip to content
  • Skip to link menu
KDE 4.1 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     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:
00148     explicit KMainWindow( QWidget* parent = 0, Qt::WindowFlags f = KDE_DEFAULT_WINDOWFLAGS );
00149 
00156     virtual ~KMainWindow();
00157 
00182     KMenu* helpMenu( const QString &aboutAppText = QString(),
00183               bool showWhatsThis = true );
00184 
00207     KMenu* customHelpMenu( bool showWhatsThis = true );
00208 
00275     static bool canBeRestored( int number );
00276 
00284     static const QString classNameOfToplevel( int number );
00285 
00294     bool restore( int number, bool show = true );
00295 
00299      bool hasMenuBar();
00300 
00306     KMenuBar *menuBar();
00307 
00319     KStatusBar *statusBar();
00320 
00321 
00325     static QList<KMainWindow*> memberList();
00326 
00337     KToolBar *toolBar( const QString& name = QString() );
00338 
00342     QList<KToolBar*> toolBars() const;
00343 
00375     void setAutoSaveSettings( const QString & groupName = QLatin1String("MainWindow"),
00376                               bool saveWindowSize = true );
00377 
00383     void setAutoSaveSettings(const KConfigGroup & group,
00384                              bool saveWindowSize = true);
00385 
00390     void resetAutoSaveSettings();
00391 
00396     bool autoSaveSettings() const;
00397 
00407     QString autoSaveGroup() const;
00408 
00415     KConfigGroup autoSaveConfigGroup() const;
00416 
00424     virtual void applyMainWindowSettings( const KConfigGroup &config, bool force = false);
00425 
00432     void saveMainWindowSettings(const KConfigGroup &config);
00433 
00438     bool initialGeometrySet() const;
00439 
00444     void ignoreInitialGeometry();
00445 
00450     QString dbusName() const;
00451 
00452 public Q_SLOTS:
00460     virtual void setCaption( const QString &caption );
00470     virtual void setCaption( const QString &caption, bool modified );
00471 
00478     virtual void setPlainCaption( const QString &caption );
00479 
00499     void appHelpActivated( void );
00500 
00508     void setSettingsDirty();
00509 
00510 protected:
00516     virtual bool event( QEvent * event );
00517 
00525     virtual void closeEvent ( QCloseEvent *);
00526 
00527     // KDE4 This seems to be flawed to me. Either the app has only one
00528     // mainwindow, so queryClose() is enough, or if it can have more of them,
00529     // then the windows should take care of themselves, and queryExit()
00530     // would be useful only for the annoying 'really quit' dialog, which
00531     // also doesn't make sense in apps with multiple mainwindows.
00532     // And saving configuration in something called queryExit()? IMHO
00533     // one can e.g. use QCoreApplication::aboutToQuit(), which if nothing else
00534     // has at least better fitting name.
00535     // See also KApplication::sessionSaving().
00536     // This stuff should get changed somehow, so that it at least doesn't
00537     // mess with session management.
00565     virtual bool queryExit();
00566 
00601     virtual bool queryClose();
00602 
00614     virtual void saveProperties( KConfigGroup & ) {}
00615 
00619     virtual void readProperties( const KConfigGroup & ) {}
00620 
00637     virtual void saveGlobalProperties( KConfig* sessionConfig );
00638 
00644     virtual void readGlobalProperties( KConfig* sessionConfig );
00645     void savePropertiesInternal( KConfig*, int );
00646     bool readPropertiesInternal( KConfig*, int );
00647 
00651     bool settingsDirty() const;
00655     void saveWindowSize( const KConfigGroup &config ) const;
00660     void restoreWindowSize( const KConfigGroup & config );
00661 
00663     void parseGeometry(bool parsewidth);
00664 
00665 protected Q_SLOTS:
00690     virtual void showAboutApplication();
00691 
00713     void saveAutoSaveSettings();
00714 
00715 protected:
00716     KMainWindow(KMainWindowPrivate &dd, QWidget *parent, Qt::WFlags f);
00717 
00718     KMainWindowPrivate * const k_ptr;
00719 private:
00720     Q_PRIVATE_SLOT(k_func(), void _k_shuttingDown())
00721     Q_PRIVATE_SLOT(k_func(), void _k_slotSettingsChanged(int))
00722 };
00723 
00724 #define RESTORE(type) { int n = 1;\
00725     while (KMainWindow::canBeRestored(n)){\
00726       (new type)->restore(n);\
00727       n++;}}
00728 
00729 #define KDE_RESTORE_MAIN_WINDOWS_NUM_TEMPLATE_ARGS 3
00730 
00738 template <typename T>
00739 inline void kRestoreMainWindows() {
00740   for ( int n = 1 ; KMainWindow::canBeRestored( n ) ; ++n ) {
00741     const QString className = KMainWindow::classNameOfToplevel( n );
00742     if ( className == QLatin1String( T::staticMetaObject.className() ) )
00743       (new T)->restore( n );
00744   }
00745 }
00746 
00747 template <typename T0, typename T1>
00748 inline void kRestoreMainWindows() {
00749   const char * classNames[2];
00750   classNames[0] = T0::staticMetaObject.className();
00751   classNames[1] = T1::staticMetaObject.className();
00752   for ( int n = 1 ; KMainWindow::canBeRestored( n ) ; ++n ) {
00753     const QString className = KMainWindow::classNameOfToplevel( n );
00754     if ( className == QLatin1String( classNames[0] ) )
00755       (new T0)->restore( n );
00756     else if ( className == QLatin1String( classNames[1] ) )
00757       (new T1)->restore( n );
00758   }
00759 }
00760 
00761 template <typename T0, typename T1, typename T2>
00762 inline void kRestoreMainWindows() {
00763   const char * classNames[3];
00764   classNames[0] = T0::staticMetaObject.className();
00765   classNames[1] = T1::staticMetaObject.className();
00766   classNames[2] = T2::staticMetaObject.className();
00767   for ( int n = 1 ; KMainWindow::canBeRestored( n ) ; ++n ) {
00768     const QString className = KMainWindow::classNameOfToplevel( n );
00769     if ( className == QLatin1String( classNames[0] ) )
00770       (new T0)->restore( n );
00771     else if ( className == QLatin1String( classNames[1] ) )
00772       (new T1)->restore( n );
00773     else if ( className == QLatin1String( classNames[2] ) )
00774       (new T2)->restore( n );
00775   }
00776 }
00777 
00778 #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
  • 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