00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef _KAPP_H
00024 #define _KAPP_H
00025
00026
00027 #include "kdeversion.h"
00028
00029 class KConfig;
00030 class KCharsets;
00031 class DCOPClient;
00032 class DCOPObject;
00033
00034 typedef unsigned long Atom;
00035 #ifdef Q_WS_QWS
00036 typedef void Display;
00037 #endif
00038
00039 #include <qapplication.h>
00040 #include <qpixmap.h>
00041 #include <kinstance.h>
00042
00043 struct _IceConn;
00044 class QPopupMenu;
00045 class QStrList;
00046 class KSessionManaged;
00047 class KStyle;
00048 class KURL;
00049
00050 #define kapp KApplication::kApplication()
00051
00052 class KApplicationPrivate;
00053
00091 class KApplication : public QApplication, public KInstance
00092 {
00093
00094 Q_OBJECT
00095 public:
00096 enum CaptionLayout { CaptionAppLast=1, CaptionAppFirst, CaptionNoApp };
00097
00111 KApplication( bool allowStyles=true, bool GUIenabled=true);
00112
00113 #ifndef Q_WS_QWS
00114
00134 KApplication(Display *display, int& argc, char** argv, const QCString& rAppName,
00135 bool allowStyles=true, bool GUIenabled=true);
00136 #endif
00137
00158 KApplication(int& argc, char** argv,
00159 const QCString& rAppName, bool allowStyles=true, bool GUIenabled=true);
00160
00164 static void addCmdLineOptions();
00165
00166 virtual ~KApplication();
00167
00178 static KApplication* kApplication() { return KApp; }
00179
00187 KConfig* sessionConfig();
00188
00197 bool isRestored() const { return QApplication::isSessionRestored(); }
00198
00205 void disableSessionManagement();
00206
00210 enum ShutdownConfirm {
00214 ShutdownConfirmDefault = -1,
00218 ShutdownConfirmNo = 0,
00222 ShutdownConfirmYes = 1
00223 };
00224
00228 enum ShutdownType {
00232 ShutdownTypeDefault = -1,
00236 ShutdownTypeNone = 0,
00240 ShutdownTypeReboot = 1,
00244 ShutdownTypeHalt = 2
00245 };
00246
00250 enum ShutdownMode {
00254 ShutdownModeDefault = -1,
00259 ShutdownModeSchedule = 0,
00263 ShutdownModeTryNow = 1,
00267 ShutdownModeForceNow = 2,
00271 ShutdownModeInteractive = 3
00272 };
00273
00289 bool requestShutDown( ShutdownConfirm confirm = ShutdownConfirmDefault,
00290 ShutdownType sdtype = ShutdownTypeDefault,
00291 ShutdownMode sdmode = ShutdownModeDefault );
00292
00306 void propagateSessionManager();
00307
00308
00309
00310
00311
00312
00313 void commitData( QSessionManager& sm );
00314
00315
00316
00317
00318
00319
00320 void saveState( QSessionManager& sm );
00321
00331 bool sessionSaving() const;
00332
00339 static DCOPClient *dcopClient();
00340
00345 static void disableAutoDcopRegistration();
00346
00351 QPixmap icon() const;
00352
00357 QString iconName() const;
00358
00363 QPixmap miniIcon() const;
00364
00369 QString miniIconName() const;
00370
00381 void setTopWidget( QWidget *topWidget );
00382
00393 void invokeHelp( const QString& anchor = QString::null,
00394 const QString& appname = QString::null ) const;
00395
00410 void invokeHTMLHelp( const QString& aFilename, const QString& aTopic = QString::null ) const;
00411
00418 void invokeMailer( const QString &address, const QString &subject );
00419
00425 void invokeMailer( const KURL &mailtoURL );
00426
00440 void invokeMailer(const QString &to, const QString &cc, const QString &bcc,
00441 const QString &subject, const QString &body,
00442 const QString &messageFile = QString::null, const QStringList &attachURLs = QStringList());
00443
00444 public slots:
00453 void invokeBrowser( const QString &url );
00454
00455 public:
00461 static QCString launcher();
00462
00483 static int startServiceByName( const QString& _name, const QString &URL,
00484 QString *error=0, QCString *dcopService=0, int *pid=0, const QCString &startup_id = "", bool noWait = false );
00485
00506 static int startServiceByName( const QString& _name, const QStringList &URLs=QStringList(),
00507 QString *error=0, QCString *dcopService=0, int *pid=0, const QCString &startup_id = "", bool noWait = false );
00508
00529 static int startServiceByDesktopPath( const QString& _name, const QString &URL,
00530 QString *error=0, QCString *dcopService=0, int *pid = 0, const QCString &startup_id = "", bool noWait = false );
00531
00552 static int startServiceByDesktopPath( const QString& _name, const QStringList &URLs=QStringList(),
00553 QString *error=0, QCString *dcopService=0, int *pid = 0, const QCString &startup_id = "", bool noWait = false );
00554
00575 static int startServiceByDesktopName( const QString& _name, const QString &URL,
00576 QString *error=0, QCString *dcopService=0, int *pid = 0, const QCString &startup_id = "", bool noWait = false );
00577
00598 static int startServiceByDesktopName( const QString& _name, const QStringList &URLs=QStringList(),
00599 QString *error=0, QCString *dcopService=0, int *pid = 0, const QCString &startup_id = "", bool noWait = false );
00600
00618 static int kdeinitExec( const QString& name, const QStringList &args=QStringList(),
00619 QString *error=0, int *pid = 0 );
00620
00636 static int kdeinitExecWait( const QString& name, const QStringList &args=QStringList(),
00637 QString *error=0, int *pid = 0 );
00638
00647 QString caption() const;
00648
00652 KStyle* kstyle() const { return 0; }
00653
00671 QString makeStdCaption( const QString &userCaption,
00672 bool withAppName=true, bool modified=false ) const;
00673
00681 QString tempSaveName( const QString& pFilename ) const;
00682
00692 QString checkRecoverFile( const QString& pFilename, bool& bRecover ) const;
00693
00694 #ifdef Q_WS_X11
00695
00699 Display *getDisplay() { return display; }
00700 #endif
00701
00709 void enableStyles();
00710
00718 void disableStyles();
00719
00729 void installX11EventFilter( QWidget* filter );
00730
00735 static int random();
00736
00742 static QString randomString(int length);
00743
00753 void addKipcEventMask(int id);
00754
00763 void removeKipcEventMask(int id);
00764
00770 QCString startupId() const;
00771
00777 void setStartupId( const QCString& startup_id );
00778
00784 QString geometryArgument() const;
00785
00790 void installKDEPropertyMap();
00791
00797 bool authorize(const QString &genericAction);
00798
00806 bool authorizeKAction(const char *action);
00807
00821 bool authorizeURLAction(const QString &action, const KURL &baseURL, const KURL &destURL);
00822
00823
00824
00825 enum { ShiftModifier = 1<<0,
00826 LockModifier = 1<<1,
00827 ControlModifier = 1<<2,
00828 Modifier1 = 1<<3,
00829 Modifier2 = 1<<4,
00830 Modifier3 = 1<<5,
00831 Modifier4 = 1<<6,
00832 Modifier5 = 1<<7 };
00843 static uint keyboardModifiers();
00844
00845
00846 enum { Button1Pressed = 1<<8,
00847 Button2Pressed = 1<<9,
00848 Button3Pressed = 1<<10,
00849 Button4Pressed = 1<<11,
00850 Button5Pressed = 1<<12 };
00860 static uint mouseState();
00861
00862
00863 public slots:
00870 void ref();
00871
00876 void deref();
00877
00878 protected:
00882 KApplication( bool allowStyles, bool GUIenabled, KInstance* _instance );
00883
00884 #ifdef Q_WS_X11
00885
00888 bool x11EventFilter( XEvent * );
00889
00890 Display *display;
00891 #endif
00892 Atom kipcCommAtom;
00893 int kipcEventMask;
00894
00896 static KApplication *KApp;
00897 int pArgc;
00898
00899 private slots:
00900 void dcopFailure(const QString &);
00901 void dcopBlockUserInput( bool );
00902 void x11FilterDestroyed();
00903
00904 private:
00905 QString sessionConfigName() const;
00906 KConfig* pSessionConfig;
00907 static DCOPClient *s_DCOPClient;
00908 static bool s_dcopClientNeedsPostInit;
00909 QString aCaption;
00910 bool bSessionManagement;
00911 QPixmap aIconPixmap;
00912 QPixmap aMiniIconPixmap;
00913 QString aIconName;
00914 QString aMiniIconName;
00915 bool useStyles;
00916 QWidget *smw;
00917
00918 void init( bool GUIenabled );
00919
00920 void parseCommandLine( );
00921
00922 void read_app_startup_id();
00923
00924 void dcopAutoRegistration();
00925 void dcopClientPostInit();
00926 void initUrlActionRestrictions();
00927 public:
00931 bool notify(QObject *receiver, QEvent *event);
00932
00936 int xioErrhandler();
00937
00941 void iceIOErrorHandler( _IceConn *conn );
00942
00946 static bool loadedByKdeinit;
00947
00951 static void startKdeinit();
00952
00956 enum SettingsCategory { SETTINGS_MOUSE, SETTINGS_COMPLETION, SETTINGS_PATHS,
00957 SETTINGS_POPUPMENU, SETTINGS_QT, SETTINGS_SHORTCUTS };
00958
00967 static QPalette createApplicationPalette();
00968
00973 static QPalette createApplicationPalette( KConfig *config, int contrast );
00974
00975 signals:
00982 void kdisplayPaletteChanged();
00983
00991 void kdisplayStyleChanged();
00992
01000 void kdisplayFontChanged();
01001
01007 void appearanceChanged();
01008
01012 void toolbarAppearanceChanged(int);
01013
01019 void backgroundChanged(int desk);
01020
01027 void settingsChanged(int category);
01028
01033 void iconChanged(int group);
01034
01044 void kipcMessage(int id, int data);
01045
01075 void saveYourself();
01076
01084 void shutDown();
01085
01086 private:
01087 void propagateSettings(SettingsCategory category);
01088 void kdisplaySetPalette();
01089 void kdisplaySetStyle();
01090 void kdisplaySetFont();
01091 void applyGUIStyle();
01092
01093 int captionLayout;
01094
01095 KApplication(const KApplication&);
01096 KApplication& operator=(const KApplication&);
01097 protected:
01098 virtual void virtual_hook( int id, void* data );
01099 private:
01100 KApplicationPrivate* d;
01101 };
01102
01103
01119 bool checkAccess(const QString& pathname, int mode);
01120
01121
01122 class KSessionManagedPrivate;
01123
01140 class KSessionManaged
01141 {
01142 public:
01143 KSessionManaged();
01144 virtual ~KSessionManaged();
01145
01155 virtual bool saveState( QSessionManager& sm );
01165 virtual bool commitData( QSessionManager& sm );
01166
01167 protected:
01168 virtual void virtual_hook( int id, void* data );
01169 private:
01170 KSessionManagedPrivate *d;
01171 };
01172
01173
01174 #endif
01175