kmainwindow.h
/*
This file is part of the KDE libraries
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License version 2 as published by the Free Software Foundation.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef KMAINWINDOW_H
#define KMAINWINDOW_H
#include "kxmlguifactory.h"
#include "kxmlguiclient.h"
#include "kxmlguibuilder.h"
#include <qmainwindow.h>
#include <qmetaobject.h>
#include <ktoolbar.h>
class KPopupMenu;
class KXMLGUIFactory;
class KConfig;
class KHelpMenu;
class KStatusBar;
class QStatusBar;
class KMenuBar;
class KMWSessionManaged;
class KMainWindowPrivate;
class KAccel;
class KToolBarMenuAction;
class DCOPObject;
#define KDE_DEFAULT_WINDOWFLAGS WType_TopLevel | WDestructiveClose
class KDEUI_EXPORT KMainWindow : public QMainWindow, public KXMLGUIBuilder, virtual public KXMLGUIClient
{
friend class KMWSessionManaged;
Q_OBJECT
public:
KMainWindow( QWidget* parent = 0, const char *name = 0, WFlags f = WType_TopLevel | WDestructiveClose );
enum CreationFlags
{
NoDCOPObject = 1
};
KMainWindow( int cflags, QWidget* parent = 0, const char *name = 0, WFlags f = WType_TopLevel | WDestructiveClose );
virtual ~KMainWindow();
KPopupMenu* helpMenu( const QString &aboutAppText = QString::null,
bool showWhatsThis = true );
KPopupMenu* customHelpMenu( bool showWhatsThis = true );
static bool canBeRestored( int number );
// KDE 4 return QCString - QObject::className() returns const char*
static const QString classNameOfToplevel( int number );
// KDE4 remove this method if this has been fixed in Qt
virtual void show();
// KDE4 remove this method if this has been fixed in Qt
virtual void hide();
bool restore( int number, bool show = true );
virtual KXMLGUIFactory *guiFactory();
void createGUI( const QString &xmlfile = QString::null, bool _conserveMemory = true );
void setHelpMenuEnabled(bool showHelpMenu = true);
bool isHelpMenuEnabled();
bool hasMenuBar();
KMenuBar *menuBar();
KStatusBar *statusBar();
static QPtrList<KMainWindow>* memberList;
//KDE4: replace with memberList() and make memberList member private
static QPtrList<KMainWindow>* getMemberList();
KToolBar *toolBar( const char *name=0 );
QPtrListIterator<KToolBar> toolBarIterator();
KAccel *accel();
void setFrameBorderWidth( int ) {}
void setAutoSaveSettings( const QString & groupName = QString::fromLatin1("MainWindow"),
bool saveWindowSize = true );
void resetAutoSaveSettings();
bool autoSaveSettings() const;
QString autoSaveGroup() const;
void applyMainWindowSettings(KConfig *config, const QString &groupName, bool force);
// KDE4 merge with force=false
void applyMainWindowSettings(KConfig *config, const QString &groupName = QString::null);
void saveMainWindowSettings(KConfig *config, const QString &groupName = QString::null);
void setStandardToolBarMenuEnabled( bool enable );
bool isStandardToolBarMenuEnabled() const;
void createStandardStatusBarAction();
enum StandardWindowOptions
{
ToolBar = 1,
Keys = 2,
StatusBar = 4,
Save = 8,
Create = 16
};
void setupGUI( int options = ToolBar | Keys | StatusBar | Save | Create, const QString& xmlfile = QString::null );
void setupGUI( QSize defaultSize, int options = ToolBar | Keys | StatusBar | Save | Create, const QString& xmlfile = QString::null );
KAction *toolBarMenuAction();
void setupToolbarMenuActions();
// why do we support old gcc versions? using KXMLGUIBuilder::finalizeGUI;
virtual void finalizeGUI( KXMLGUIClient *client );
void finalizeGUI( bool force );
bool initialGeometrySet() const;
void ignoreInitialGeometry();
// KDE4 to be removed
QSize sizeForCentralWidgetSize(QSize size) KDE_DEPRECATED;
// KDE4 remove
virtual void setIcon( const QPixmap & );
public slots:
int configureToolbars(); // TODO KDE4: make virtual and reimplement in KParts::MainWindow
virtual void setCaption( const QString &caption );
virtual void setCaption( const QString &caption, bool modified );
virtual void setPlainCaption( const QString &caption );
void appHelpActivated( void );
virtual void slotStateChanged(const QString &newstate);
void slotStateChanged(const QString &newstate,
KXMLGUIClient::ReverseStateChange); // KDE 4.0: remove this
// void slotStateChanged(const QString &newstate,
// bool reverse); // KDE 4.0: enable this
void setSettingsDirty();
protected:
void paintEvent( QPaintEvent* e );
void childEvent( QChildEvent* e);
void resizeEvent( QResizeEvent* e);
virtual void closeEvent ( QCloseEvent *);
// KDE4 This seems to be flawed to me. Either the app has only one
// mainwindow, so queryClose() is enough, or if it can have more of them,
// then the windows should take care of themselves, and queryExit()
// would be useful only for the annoying 'really quit' dialog, which
// also doesn't make sense in apps with multiple mainwindows.
// And saving configuration in something called queryExit()? IMHO
// one can e.g. use KApplication::shutDown(), which if nothing else
// has at least better fitting name.
// See also KApplication::sessionSaving().
// This stuff should get changed somehow, so that it at least doesn't
// mess with session management.
virtual bool queryExit();
virtual bool queryClose();
virtual void saveProperties( KConfig* ) {}
virtual void readProperties( KConfig* ) {}
virtual void saveGlobalProperties( KConfig* sessionConfig );
virtual void readGlobalProperties( KConfig* sessionConfig );
void savePropertiesInternal( KConfig*, int );
bool readPropertiesInternal( KConfig*, int );
bool settingsDirty() const;
QString settingsGroup() const;
void saveWindowSize( KConfig * config ) const;
void restoreWindowSize( KConfig * config );
void parseGeometry(bool parsewidth);
protected slots:
void saveNewToolbarConfig(); // TODO KDE4: make virtual and reimplement in KParts::MainWindow
virtual void showAboutApplication();
void saveAutoSaveSettings();
private slots:
void shuttingDown();
private:
KMenuBar *internalMenuBar();
KStatusBar *internalStatusBar();
KHelpMenu *mHelpMenu, *helpMenu2;
KXMLGUIFactory *factory_;
QPtrList<KToolBar> toolbarList;
protected:
virtual void virtual_hook( int id, void* data );
private:
KMainWindowPrivate *d;
void initKMainWindow(const char *name, int cflags);
};
#define RESTORE(type) { int n = 1;\
while (KMainWindow::canBeRestored(n)){\
(new type)->restore(n);\
n++;}}
#define KDE_RESTORE_MAIN_WINDOWS_NUM_TEMPLATE_ARGS 3
template <typename T>
inline void kRestoreMainWindows() {
for ( int n = 1 ; KMainWindow::canBeRestored( n ) ; ++n ) {
const QString className = KMainWindow::classNameOfToplevel( n );
if ( className == QString::fromLatin1( T::staticMetaObject()->className() ) )
(new T)->restore( n );
}
}
template <typename T0, typename T1>
inline void kRestoreMainWindows() {
const char * classNames[2];
classNames[0] = T0::staticMetaObject()->className();
classNames[1] = T1::staticMetaObject()->className();
for ( int n = 1 ; KMainWindow::canBeRestored( n ) ; ++n ) {
const QString className = KMainWindow::classNameOfToplevel( n );
if ( className == QString::fromLatin1( classNames[0] ) )
(new T0)->restore( n );
else if ( className == QString::fromLatin1( classNames[1] ) )
(new T1)->restore( n );
}
}
template <typename T0, typename T1, typename T2>
inline void kRestoreMainWindows() {
const char * classNames[3];
classNames[0] = T0::staticMetaObject()->className();
classNames[1] = T1::staticMetaObject()->className();
classNames[2] = T2::staticMetaObject()->className();
for ( int n = 1 ; KMainWindow::canBeRestored( n ) ; ++n ) {
const QString className = KMainWindow::classNameOfToplevel( n );
if ( className == QString::fromLatin1( classNames[0] ) )
(new T0)->restore( n );
else if ( className == QString::fromLatin1( classNames[1] ) )
(new T1)->restore( n );
else if ( className == QString::fromLatin1( classNames[2] ) )
(new T2)->restore( n );
}
}
#endif
KAccel
KXMLGUIClient
A KXMLGUIClient can be used with KXMLGUIFactory to create a GUI from actions and an XML document...
Definition: kxmlguiclient.h:43
KMainWindow::saveProperties
virtual void saveProperties(KConfig *)
Save your instance-specific properties.
Definition: kmainwindow.h:876
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:364
KStatusBar
KDE statusbar widget
Definition: kstatusbar.h:87
KMainWindow::CreationFlags
CreationFlags
Flags that can be passed in an argument to the constructor to change the behavior.
Definition: kmainwindow.h:148
KMainWindow
KDE top level main window
Definition: kmainwindow.h:98
KXMLGUIBuilder
Abstract interface for a "GUI builder", used by the GUIFactory This interface is implemented by KMain...
Definition: kxmlguibuilder.h:39
KMainWindow::canBeRestored
static bool canBeRestored(int number)
Session Management
Definition: kmainwindow.cpp:352
KXMLGUIFactory
KXMLGUIFactory, together with KXMLGUIClient objects, can be used to create a GUI of container widgets...
Definition: kxmlguifactory.h:62
KMainWindow::memberList
static QPtrList< KMainWindow > * memberList
List of members of KMainWindow class.
Definition: kmainwindow.h:385
KConfig
KToolBar
Floatable toolbar with auto resize.
Definition: ktoolbar.h:103
KMainWindow::readProperties
virtual void readProperties(KConfig *)
Read your instance-specific properties.
Definition: kmainwindow.h:881
KAction
Class to encapsulate user-driven action or event.
Definition: kaction.h:202
KMainWindow::StandardWindowOptions
StandardWindowOptions
Definition: kmainwindow.h:546
DCOPObject

KDE Home | KDE Accessibility Home | Description of Access Keys