00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
#ifndef KMAINWINDOW_H
00022
#define KMAINWINDOW_H
00023
00024
#include "kxmlguifactory.h"
00025
#include "kxmlguiclient.h"
00026
#include "kxmlguibuilder.h"
00027
#include <qmainwindow.h>
00028
#include <qmetaobject.h>
00029
#include <ktoolbar.h>
00030
#include <kdemacros.h>
00031
00032
class KPopupMenu;
00033
class KXMLGUIFactory;
00034
class KConfig;
00035
class KHelpMenu;
00036
class KStatusBar;
00037
class QStatusBar;
00038
class KMenuBar;
00039
class KMWSessionManaged;
00040
class KMainWindowPrivate;
00041
class KAccel;
00042
class KToolBarMenuAction;
00043
class DCOPObject;
00044
00045
#define KDE_DEFAULT_WINDOWFLAGS WType_TopLevel | WDestructiveClose
00046
00047
00098 class KMainWindow :
public QMainWindow,
public KXMLGUIBuilder,
virtual public KXMLGUIClient
00099 {
00100
friend class KMWSessionManaged;
00101 Q_OBJECT
00102
00103
public:
00136
KMainWindow(
QWidget* parent = 0,
const char *name = 0, WFlags f = WType_TopLevel | WDestructiveClose );
00137
00148 enum CreationFlags
00149 {
00150 NoDCOPObject = 1
00151 };
00152
00158
KMainWindow(
int cflags,
QWidget* parent = 0,
const char *name = 0, WFlags f = WType_TopLevel | WDestructiveClose );
00159
00166
virtual ~KMainWindow();
00167
00192
KPopupMenu*
helpMenu(
const QString &aboutAppText = QString::null,
00193
bool showWhatsThis =
true );
00194
00217
KPopupMenu*
customHelpMenu(
bool showWhatsThis =
true );
00218
00285
static bool canBeRestored(
int number );
00286
00294
00295
static const QString classNameOfToplevel(
int number );
00296
00300
00301
virtual void show();
00302
00306
00307
virtual void hide();
00308
00317
bool restore(
int number,
bool show =
true );
00318
00319
virtual KXMLGUIFactory *guiFactory();
00320
00340
void createGUI(
const QString &xmlfile = QString::null,
bool _conserveMemory =
true );
00341
00348
void setHelpMenuEnabled(
bool showHelpMenu =
true);
00349
00353
bool isHelpMenuEnabled();
00354
00355
00360
bool hasMenuBar();
00361
00367
KMenuBar *
menuBar();
00368
00375
KStatusBar *
statusBar();
00376
00380
static QPtrList<KMainWindow>* memberList;
00381
00392
KToolBar *
toolBar(
const char *name=0 );
00393
00397
QPtrListIterator<KToolBar> toolBarIterator();
00398
00403
KAccel *
accel();
00404
00405
void setFrameBorderWidth(
int ) {}
00406
00438
void setAutoSaveSettings(
const QString & groupName = QString::fromLatin1(
"MainWindow"),
00439
bool saveWindowSize =
true );
00440
00445
void resetAutoSaveSettings();
00446
00452
bool autoSaveSettings() const;
00453
00461
QString autoSaveGroup() const;
00462
00472
void applyMainWindowSettings(
KConfig *config, const
QString &groupName,
bool force);
00473
00474
void applyMainWindowSettings(
KConfig *config, const
QString &groupName =
QString::null);
00475
00484
void saveMainWindowSettings(
KConfig *config, const
QString &groupName =
QString::null);
00485
00504
void setStandardToolBarMenuEnabled(
bool enable );
00506
bool isStandardToolBarMenuEnabled() const;
00507
00508
00529
void createStandardStatusBarAction();
00530
00534 enum StandardWindowOptions
00535 {
00544
ToolBar = 1,
00545
00549
Keys = 2,
00550
00555
StatusBar = 4,
00556
00567
Save = 8,
00568
00573
Create = 16
00574 };
00575
00587
void setupGUI(
int options = ToolBar | Keys | StatusBar | Save | Create,
const QString& xmlfile = QString::null );
00588
00593
KAction *
toolBarMenuAction();
00594
00595
00597
virtual void finalizeGUI(
KXMLGUIClient *client );
00598
00602
void finalizeGUI(
bool force );
00603
00608
bool initialGeometrySet() const;
00609
00614
void ignoreInitialGeometry();
00615
00631
00632
QSize sizeForCentralWidgetSize(
QSize size) KDE_DEPRECATED;
00633
00634 public slots:
00647
int configureToolbars();
00648
00656 virtual
void setCaption( const
QString &caption );
00666 virtual
void setCaption( const
QString &caption,
bool modified );
00667
00674 virtual
void setPlainCaption( const
QString &caption );
00675
00697
void appHelpActivated(
void );
00698
00705 virtual
void slotStateChanged(const
QString &newstate);
00706
00715
void slotStateChanged(const
QString &newstate,
00716
KXMLGUIClient::ReverseStateChange);
00717
00718
00726
00727
00728
00736
void setSettingsDirty();
00737
00738 protected:
00739
void paintEvent(
QPaintEvent* e );
00740
void childEvent(
QChildEvent* e);
00741
void resizeEvent(
QResizeEvent* e);
00749 virtual
void closeEvent (
QCloseEvent *);
00750
00751
00752
00753
00754
00755
00756
00757
00758
00759
00760
00761
00789 virtual
bool queryExit();
00790
00825 virtual
bool queryClose();
00826
00840 virtual
void saveProperties(
KConfig* ) {}
00841
00845 virtual void readProperties(
KConfig* ) {}
00846
00863
virtual void saveGlobalProperties(
KConfig* sessionConfig );
00864
00870
virtual void readGlobalProperties(
KConfig* sessionConfig );
00871
void savePropertiesInternal(
KConfig*,
int );
00872
bool readPropertiesInternal(
KConfig*,
int );
00873
00877
bool settingsDirty() const;
00881
QString settingsGroup() const;
00886
void saveWindowSize(
KConfig * config ) const;
00892
void restoreWindowSize(
KConfig * config );
00893
00895
void parseGeometry(
bool parsewidth);
00896
00897 protected slots:
00902
void saveNewToolbarConfig();
00903
00928 virtual
void showAboutApplication();
00929
00953
void saveAutoSaveSettings();
00954
00955 private slots:
00959
void shuttingDown();
00960
00961 private:
00962
KMenuBar *internalMenuBar();
00963
KStatusBar *internalStatusBar();
00964
KHelpMenu *mHelpMenu, *helpMenu2;
00965
KXMLGUIFactory *factory_;
00966
QPtrList<
KToolBar> toolbarList;
00967 protected:
00968 virtual
void virtual_hook(
int id,
void* data );
00969 private:
00970 KMainWindowPrivate *d;
00971
void initKMainWindow(const
char *name,
int cflags);
00972 };
00973
00974 #define RESTORE(type) {
int n = 1;\
00975
while (
KMainWindow::canBeRestored(n)){\
00976 (
new type)->restore(n);\
00977 n++;}}
00978
00979
#define KDE_RESTORE_MAIN_WINDOWS_NUM_TEMPLATE_ARGS 3
00980
00991
template <
typename T>
00992
inline void kRestoreMainWindows() {
00993
for (
int n = 1 ;
KMainWindow::canBeRestored( n ) ; ++n ) {
00994
const QString className =
KMainWindow::classNameOfToplevel( n );
00995
if ( className == QString::fromLatin1( T::staticMetaObject()->className() ) )
00996 (
new T)->restore( n );
00997 }
00998 }
00999
01000
template <
typename T0,
typename T1>
01001
inline void kRestoreMainWindows() {
01002
const char * classNames[2];
01003 classNames[0] = T0::staticMetaObject()->className();
01004 classNames[1] = T1::staticMetaObject()->className();
01005
for (
int n = 1 ;
KMainWindow::canBeRestored( n ) ; ++n ) {
01006
const QString className =
KMainWindow::classNameOfToplevel( n );
01007
if ( className == QString::fromLatin1( classNames[0] ) )
01008 (
new T0)->restore( n );
01009
else if ( className == QString::fromLatin1( classNames[1] ) )
01010 (
new T1)->restore( n );
01011 }
01012 }
01013
01014
template <
typename T0,
typename T1,
typename T2>
01015
inline void kRestoreMainWindows() {
01016
const char * classNames[3];
01017 classNames[0] = T0::staticMetaObject()->className();
01018 classNames[1] = T1::staticMetaObject()->className();
01019 classNames[2] = T1::staticMetaObject()->className();
01020
for (
int n = 1 ;
KMainWindow::canBeRestored( n ) ; ++n ) {
01021
const QString className =
KMainWindow::classNameOfToplevel( n );
01022
if ( className == QString::fromLatin1( classNames[0] ) )
01023 (
new T0)->restore( n );
01024
else if ( className == QString::fromLatin1( classNames[1] ) )
01025 (
new T1)->restore( n );
01026
else if ( className == QString::fromLatin1( classNames[2] ) )
01027 (
new T2)->restore( n );
01028 }
01029 }
01030
01031
#endif