00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
#ifndef KMAINWINDOW_H
00023
#define KMAINWINDOW_H
00024
00025
#include "kxmlguifactory.h"
00026
#include "kxmlguiclient.h"
00027
#include "kxmlguibuilder.h"
00028
#include <qmainwindow.h>
00029
#include <qmetaobject.h>
00030
#include <ktoolbar.h>
00031
#include <kdemacros.h>
00032
00033
class KPopupMenu;
00034
class KXMLGUIFactory;
00035
class KConfig;
00036
class KHelpMenu;
00037
class KStatusBar;
00038
class QStatusBar;
00039
class KMenuBar;
00040
class KMWSessionManaged;
00041
class KMainWindowPrivate;
00042
class KAccel;
00043
class KToolBarMenuAction;
00044
class DCOPObject;
00045
00046
#define KDE_DEFAULT_WINDOWFLAGS WType_TopLevel | WDestructiveClose
00047
00048
00099 class KMainWindow :
public QMainWindow,
public KXMLGUIBuilder,
virtual public KXMLGUIClient
00100 {
00101
friend class KMWSessionManaged;
00102 Q_OBJECT
00103
00104
public:
00137
KMainWindow(
QWidget* parent = 0,
const char *name = 0, WFlags f = WType_TopLevel | WDestructiveClose );
00138
00149 enum CreationFlags
00150 {
00151 NoDCOPObject = 1
00152 };
00153
00159
KMainWindow(
int cflags,
QWidget* parent = 0,
const char *name = 0, WFlags f = WType_TopLevel | WDestructiveClose );
00160
00167
virtual ~KMainWindow();
00168
00193
KPopupMenu*
helpMenu(
const QString &aboutAppText = QString::null,
00194
bool showWhatsThis =
true );
00195
00218
KPopupMenu*
customHelpMenu(
bool showWhatsThis =
true );
00219
00286
static bool canBeRestored(
int number );
00287
00295
00296
static const QString classNameOfToplevel(
int number );
00297
00301
00302
virtual void show();
00303
00307
00308
virtual void hide();
00309
00318
bool restore(
int number,
bool show =
true );
00319
00320
virtual KXMLGUIFactory *guiFactory();
00321
00341
void createGUI(
const QString &xmlfile = QString::null,
bool _conserveMemory =
true );
00342
00349
void setHelpMenuEnabled(
bool showHelpMenu =
true);
00350
00354
bool isHelpMenuEnabled();
00355
00356
00361
bool hasMenuBar();
00362
00368
KMenuBar *
menuBar();
00369
00376
KStatusBar *
statusBar();
00377
00381
static QPtrList<KMainWindow>* memberList;
00382
00393
KToolBar *
toolBar(
const char *name=0 );
00394
00398
QPtrListIterator<KToolBar> toolBarIterator();
00399
00404
KAccel *
accel();
00405
00406
void setFrameBorderWidth(
int ) {}
00407
00425
void setAutoSaveSettings(
const QString & groupName = QString::fromLatin1(
"MainWindow"),
00426
bool saveWindowSize =
true );
00427
00432
void resetAutoSaveSettings();
00433
00439
bool autoSaveSettings() const;
00440
00448
QString autoSaveGroup() const;
00449
00458
void applyMainWindowSettings(
KConfig *config, const
QString &groupName =
QString::null);
00459
00468
void saveMainWindowSettings(
KConfig *config, const
QString &groupName =
QString::null);
00469
00488
void setStandardToolBarMenuEnabled(
bool enable );
00490
bool isStandardToolBarMenuEnabled() const;
00491
00492
00513
void createStandardStatusBarAction();
00514
00515
00520
KAction *toolBarMenuAction();
00521
00522
00524 virtual
void finalizeGUI(
KXMLGUIClient *client );
00525
00529
void finalizeGUI(
bool force );
00530
00535
bool initialGeometrySet() const;
00536
00541
void ignoreInitialGeometry();
00542
00558
00559
QSize sizeForCentralWidgetSize(
QSize size) KDE_DEPRECATED;
00560
00561 public slots:
00569 virtual
void setCaption( const
QString &caption );
00579 virtual
void setCaption( const
QString &caption,
bool modified );
00580
00587 virtual
void setPlainCaption( const
QString &caption );
00588
00610
void appHelpActivated(
void );
00611
00618 virtual
void slotStateChanged(const
QString &newstate);
00619
00628
void slotStateChanged(const
QString &newstate,
00629
KXMLGUIClient::ReverseStateChange);
00630
00631
00639
00640
00641
00649
void setSettingsDirty();
00650
00651 protected:
00652
void paintEvent(
QPaintEvent* e );
00653
void childEvent(
QChildEvent* e);
00654
void resizeEvent(
QResizeEvent* e);
00662 virtual
void closeEvent (
QCloseEvent *);
00663
00664
00665
00666
00667
00668
00669
00670
00671
00672
00673
00674
00702 virtual
bool queryExit();
00703
00738 virtual
bool queryClose();
00739
00753 virtual
void saveProperties(
KConfig* ) {}
00754
00758 virtual void readProperties(
KConfig* ) {}
00759
00776
virtual void saveGlobalProperties(
KConfig* sessionConfig );
00777
00783
virtual void readGlobalProperties(
KConfig* sessionConfig );
00784
void savePropertiesInternal(
KConfig*,
int );
00785
bool readPropertiesInternal(
KConfig*,
int );
00786
00790
bool settingsDirty() const;
00794
QString settingsGroup() const;
00799
void saveWindowSize(
KConfig * config ) const;
00805
void restoreWindowSize(
KConfig * config );
00806
00808
void parseGeometry(
bool parsewidth);
00809
00810 protected slots:
00811
00836 virtual
void showAboutApplication();
00837
00861
void saveAutoSaveSettings();
00862
00863 private slots:
00867
void shuttingDown();
00868
00869 private:
00870
KMenuBar *internalMenuBar();
00871
KStatusBar *internalStatusBar();
00872
KHelpMenu *mHelpMenu, *helpMenu2;
00873
KXMLGUIFactory *factory_;
00874
QPtrList<
KToolBar> toolbarList;
00875 protected:
00876 virtual
void virtual_hook(
int id,
void* data );
00877 private:
00878 KMainWindowPrivate *d;
00879
void initKMainWindow(const
char *name,
int cflags);
00880 };
00881
00882 #define RESTORE(type) {
int n = 1;\
00883
while (
KMainWindow::canBeRestored(n)){\
00884 (
new type)->restore(n);\
00885 n++;}}
00886
00887
#define KDE_RESTORE_MAIN_WINDOWS_NUM_TEMPLATE_ARGS 3
00888
00899
template <
typename T>
00900
inline void kRestoreMainWindows() {
00901
for (
int n = 1 ;
KMainWindow::canBeRestored( n ) ; ++n ) {
00902
const QString className =
KMainWindow::classNameOfToplevel( n );
00903
if ( className ==
QString::fromLatin1( T::staticMetaObject()->className() ) )
00904 (
new T)->restore( n );
00905 }
00906 }
00907
00908
template <
typename T0,
typename T1>
00909
inline void kRestoreMainWindows() {
00910
const char * classNames[2];
00911 classNames[0] = T0::staticMetaObject()->className();
00912 classNames[1] = T1::staticMetaObject()->className();
00913
for (
int n = 1 ;
KMainWindow::canBeRestored( n ) ; ++n ) {
00914
const QString className =
KMainWindow::classNameOfToplevel( n );
00915
if ( className ==
QString::fromLatin1( classNames[0] ) )
00916 (
new T0)->restore( n );
00917
else if ( className ==
QString::fromLatin1( classNames[1] ) )
00918 (
new T1)->restore( n );
00919 }
00920 }
00921
00922
template <
typename T0,
typename T1,
typename T2>
00923
inline void kRestoreMainWindows() {
00924
const char * classNames[3];
00925 classNames[0] = T0::staticMetaObject()->className();
00926 classNames[1] = T1::staticMetaObject()->className();
00927 classNames[2] = T1::staticMetaObject()->className();
00928
for (
int n = 1 ;
KMainWindow::canBeRestored( n ) ; ++n ) {
00929
const QString className =
KMainWindow::classNameOfToplevel( n );
00930
if ( className ==
QString::fromLatin1( classNames[0] ) )
00931 (
new T0)->restore( n );
00932
else if ( className ==
QString::fromLatin1( classNames[1] ) )
00933 (
new T1)->restore( n );
00934
else if ( className ==
QString::fromLatin1( classNames[2] ) )
00935 (
new T2)->restore( n );
00936 }
00937 }
00938
00939
#endif