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

KDEUI

  • sources
  • kde-4.12
  • kdelibs
  • kdeui
  • widgets
kmainwindow.h
Go to the documentation of this file.
1 /*
2  This file is part of the KDE libraries
3  Copyright
4  (C) 2000 Reginald Stadlbauer (reggie@kde.org)
5  (C) 1997 Stephan Kulow (coolo@kde.org)
6  (C) 1997-2000 Sven Radej (radej@kde.org)
7  (C) 1997-2000 Matthias Ettrich (ettrich@kde.org)
8  (C) 1999 Chris Schlaeger (cs@kde.org)
9  (C) 2002 Joseph Wenninger (jowenn@kde.org)
10  (C) 2005-2006 Hamish Rodda (rodda@kde.org)
11  (C) 2000-2008 David Faure (faure@kde.org)
12 
13  This library is free software; you can redistribute it and/or
14  modify it under the terms of the GNU Library General Public
15  License version 2 as published by the Free Software Foundation.
16 
17  This library is distributed in the hope that it will be useful,
18  but WITHOUT ANY WARRANTY; without even the implied warranty of
19  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20  Library General Public License for more details.
21 
22  You should have received a copy of the GNU Library General Public License
23  along with this library; see the file COPYING.LIB. If not, write to
24  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
25  Boston, MA 02110-1301, USA.
26 
27 
28 */
29 
30 #ifndef KMAINWINDOW_H
31 #define KMAINWINDOW_H
32 
33 #include <kdeui_export.h>
34 
35 #include <QtGui/QMainWindow>
36 #include <QtCore/QMetaClassInfo>
37 
38 class KMenu;
39 class KConfig;
40 class KConfigGroup;
41 class KStatusBar;
42 class KMenuBar;
43 class KMWSessionManager;
44 class KMainWindowPrivate;
45 class KToolBar;
46 
47 // internal, not public API, may change any time
48 #define KDEUI_DECLARE_PRIVATE(classname) \
49  inline classname ## Private *k_func() { return reinterpret_cast<classname ## Private *>(k_ptr); } \
50  inline const classname ## Private *k_func() const { return reinterpret_cast<classname ## Private *>(k_ptr); } \
51  friend class classname ## Private;
52 
53 // This is mostly from KDE3. TODO KDE5: remove the constructor parameter.
54 #define KDE_DEFAULT_WINDOWFLAGS 0
55 
106 class KDEUI_EXPORT KMainWindow : public QMainWindow
107 {
108  friend class KMWSessionManager;
109  friend class DockResizeListener;
110  KDEUI_DECLARE_PRIVATE(KMainWindow)
111  Q_OBJECT
112  Q_PROPERTY( bool hasMenuBar READ hasMenuBar )
113  Q_PROPERTY( bool autoSaveSettings READ autoSaveSettings )
114  Q_PROPERTY( QString autoSaveGroup READ autoSaveGroup )
115  Q_PROPERTY( bool initialGeometrySet READ initialGeometrySet )
116 
117 public:
150  explicit KMainWindow( QWidget* parent = 0, Qt::WindowFlags f = KDE_DEFAULT_WINDOWFLAGS );
151 
158  virtual ~KMainWindow();
159 
184  KMenu* helpMenu( const QString &aboutAppText = QString(),
185  bool showWhatsThis = true );
186 
209  KMenu* customHelpMenu( bool showWhatsThis = true );
210 
216  static bool canBeRestored( int number );
217 
225  static const QString classNameOfToplevel( int number );
226 
265  bool restore( int number, bool show = true );
266 
270  bool hasMenuBar();
271 
277  KMenuBar *menuBar();
278 
290  KStatusBar *statusBar();
291 
292 
296  static QList<KMainWindow*> memberList();
297 
308  KToolBar *toolBar( const QString& name = QString() );
309 
313  QList<KToolBar*> toolBars() const;
314 
346  void setAutoSaveSettings( const QString & groupName = QLatin1String("MainWindow"),
347  bool saveWindowSize = true );
348 
354  void setAutoSaveSettings(const KConfigGroup & group,
355  bool saveWindowSize = true);
356 
361  void resetAutoSaveSettings();
362 
367  bool autoSaveSettings() const;
368 
378  QString autoSaveGroup() const;
379 
386  KConfigGroup autoSaveConfigGroup() const;
387 
395  virtual void applyMainWindowSettings( const KConfigGroup &config, bool forceGlobal = false);
396 
403  void saveMainWindowSettings(const KConfigGroup &config);
404 
409  bool initialGeometrySet() const;
410 
415  void ignoreInitialGeometry();
416 
421  QString dbusName() const;
422 
423 public Q_SLOTS:
431  virtual void setCaption( const QString &caption );
441  virtual void setCaption( const QString &caption, bool modified );
442 
449  virtual void setPlainCaption( const QString &caption );
450 
470  void appHelpActivated( void );
471 
479  void setSettingsDirty();
480 
481 protected:
487  virtual bool event( QEvent * event );
488 
496  virtual void closeEvent ( QCloseEvent *);
497 
498  // KDE4 This seems to be flawed to me. Either the app has only one
499  // mainwindow, so queryClose() is enough, or if it can have more of them,
500  // then the windows should take care of themselves, and queryExit()
501  // would be useful only for the annoying 'really quit' dialog, which
502  // also doesn't make sense in apps with multiple mainwindows.
503  // And saving configuration in something called queryExit()? IMHO
504  // one can e.g. use QCoreApplication::aboutToQuit(), which if nothing else
505  // has at least better fitting name.
506  // See also KApplication::sessionSaving().
507  // This stuff should get changed somehow, so that it at least doesn't
508  // mess with session management.
536  virtual bool queryExit();
537 
572  virtual bool queryClose();
573 
585  virtual void saveProperties( KConfigGroup & ) {}
586 
592  virtual void readProperties( const KConfigGroup & ) {}
593 
610  virtual void saveGlobalProperties( KConfig* sessionConfig );
611 
617  virtual void readGlobalProperties( KConfig* sessionConfig );
618  void savePropertiesInternal( KConfig*, int );
619  bool readPropertiesInternal( KConfig*, int );
620 
624  bool settingsDirty() const;
628  void saveWindowSize( const KConfigGroup &config ) const;
633  void restoreWindowSize( const KConfigGroup & config );
634 
636  void parseGeometry(bool parsewidth);
637 
638 protected Q_SLOTS:
663  virtual void showAboutApplication();
664 
686  void saveAutoSaveSettings();
687 
688 protected:
689  KMainWindow(KMainWindowPrivate &dd, QWidget *parent, Qt::WindowFlags f);
690 
691  KMainWindowPrivate * const k_ptr;
692 private:
693  Q_PRIVATE_SLOT(k_func(), void _k_shuttingDown())
694  Q_PRIVATE_SLOT(k_func(), void _k_slotSettingsChanged(int))
695  Q_PRIVATE_SLOT(k_func(), void _k_slotSaveAutoSaveSize())
696 };
697 
725 #define RESTORE(type) { int n = 1;\
726  while (KMainWindow::canBeRestored(n)){\
727  (new type)->restore(n);\
728  n++;}}
729 
736 #define KDE_RESTORE_MAIN_WINDOWS_NUM_TEMPLATE_ARGS 3
737 
774 template <typename T>
775 inline void kRestoreMainWindows() {
776  for ( int n = 1 ; KMainWindow::canBeRestored( n ) ; ++n ) {
777  const QString className = KMainWindow::classNameOfToplevel( n );
778  if ( className == QLatin1String( T::staticMetaObject.className() ) )
779  (new T)->restore( n );
780  }
781 }
782 
783 template <typename T0, typename T1>
784 inline void kRestoreMainWindows() {
785  const char * classNames[2];
786  classNames[0] = T0::staticMetaObject.className();
787  classNames[1] = T1::staticMetaObject.className();
788  for ( int n = 1 ; KMainWindow::canBeRestored( n ) ; ++n ) {
789  const QString className = KMainWindow::classNameOfToplevel( n );
790  if ( className == QLatin1String( classNames[0] ) )
791  (new T0)->restore( n );
792  else if ( className == QLatin1String( classNames[1] ) )
793  (new T1)->restore( n );
794  }
795 }
796 
797 template <typename T0, typename T1, typename T2>
798 inline void kRestoreMainWindows() {
799  const char * classNames[3];
800  classNames[0] = T0::staticMetaObject.className();
801  classNames[1] = T1::staticMetaObject.className();
802  classNames[2] = T2::staticMetaObject.className();
803  for ( int n = 1 ; KMainWindow::canBeRestored( n ) ; ++n ) {
804  const QString className = KMainWindow::classNameOfToplevel( n );
805  if ( className == QLatin1String( classNames[0] ) )
806  (new T0)->restore( n );
807  else if ( className == QLatin1String( classNames[1] ) )
808  (new T1)->restore( n );
809  else if ( className == QLatin1String( classNames[2] ) )
810  (new T2)->restore( n );
811  }
812 }
813 
814 #endif
KMainWindow::k_ptr
KMainWindowPrivate *const k_ptr
Definition: kmainwindow.h:691
T
#define T
KMenu
A menu with keyboard searching.
Definition: kmenu.h:42
QWidget
KMenuBar
KDE Style-able menubar.
Definition: kmenubar.h:38
KStandardAction::name
const char * name(StandardAction id)
This will return the internal name of a given standard action.
Definition: kstandardaction.cpp:223
QString
KMainWindow::classNameOfToplevel
static const QString classNameOfToplevel(int number)
Returns the className() of the number of the toplevel window which should be restored.
Definition: kmainwindow.cpp:516
KStatusBar
KDE statusbar widget
Definition: kstatusbar.h:59
KMainWindow::readProperties
virtual void readProperties(const KConfigGroup &)
Read your instance-specific properties.
Definition: kmainwindow.h:592
KMainWindow
KDE top level main window
Definition: kmainwindow.h:106
KMainWindow::canBeRestored
static bool canBeRestored(int number)
If the session did contain so high a number, true is returned, else false.
Definition: kmainwindow.cpp:503
KConfigGroup
KConfig
kRestoreMainWindows
void kRestoreMainWindows()
Restores the last session.
Definition: kmainwindow.h:775
QMainWindow
KToolBar
Floatable toolbar with auto resize.
Definition: ktoolbar.h:53
kdeui_export.h
KDE_DEFAULT_WINDOWFLAGS
#define KDE_DEFAULT_WINDOWFLAGS
Definition: kmainwindow.h:54
KDEUI_DECLARE_PRIVATE
#define KDEUI_DECLARE_PRIVATE(classname)
Definition: kmainwindow.h:48
QList
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:49:15 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KDEUI

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

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  • kjsembed
  •   WTF
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Nepomuk-Core
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal