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
00328 static DCOPClient *dcopClient();
00329
00334 static void disableAutoDcopRegistration();
00335
00340 QPixmap icon() const;
00341
00346 QString iconName() const;
00347
00352 QPixmap miniIcon() const;
00353
00358 QString miniIconName() const;
00359
00370 void setTopWidget( QWidget *topWidget );
00371
00382 void invokeHelp( const QString& anchor = QString::null,
00383 const QString& appname = QString::null ) const;
00384
00399 void invokeHTMLHelp( const QString& aFilename, const QString& aTopic = QString::null ) const;
00400
00407 void invokeMailer( const QString &address, const QString &subject );
00408
00414 void invokeMailer( const KURL &mailtoURL );
00415
00429 void invokeMailer(const QString &to, const QString &cc, const QString &bcc,
00430 const QString &subject, const QString &body,
00431 const QString &messageFile = QString::null, const QStringList &attachURLs = QStringList());
00432
00433 public slots:
00442 void invokeBrowser( const QString &url );
00443
00444 public:
00450 static QCString launcher();
00451
00472 static int startServiceByName( const QString& _name, const QString &URL,
00473 QString *error=0, QCString *dcopService=0, int *pid=0, const QCString &startup_id = "", bool noWait = false );
00474
00495 static int startServiceByName( const QString& _name, const QStringList &URLs=QStringList(),
00496 QString *error=0, QCString *dcopService=0, int *pid=0, const QCString &startup_id = "", bool noWait = false );
00497
00518 static int startServiceByDesktopPath( const QString& _name, const QString &URL,
00519 QString *error=0, QCString *dcopService=0, int *pid = 0, const QCString &startup_id = "", bool noWait = false );
00520
00541 static int startServiceByDesktopPath( const QString& _name, const QStringList &URLs=QStringList(),
00542 QString *error=0, QCString *dcopService=0, int *pid = 0, const QCString &startup_id = "", bool noWait = false );
00543
00564 static int startServiceByDesktopName( const QString& _name, const QString &URL,
00565 QString *error=0, QCString *dcopService=0, int *pid = 0, const QCString &startup_id = "", bool noWait = false );
00566
00587 static int startServiceByDesktopName( const QString& _name, const QStringList &URLs=QStringList(),
00588 QString *error=0, QCString *dcopService=0, int *pid = 0, const QCString &startup_id = "", bool noWait = false );
00589
00607 static int kdeinitExec( const QString& name, const QStringList &args=QStringList(),
00608 QString *error=0, int *pid = 0 );
00609
00625 static int kdeinitExecWait( const QString& name, const QStringList &args=QStringList(),
00626 QString *error=0, int *pid = 0 );
00627
00636 QString caption() const;
00637
00641 KStyle* kstyle() const { return 0; }
00642
00660 QString makeStdCaption( const QString &userCaption,
00661 bool withAppName=true, bool modified=false ) const;
00662
00670 QString tempSaveName( const QString& pFilename ) const;
00671
00681 QString checkRecoverFile( const QString& pFilename, bool& bRecover ) const;
00682
00683 #ifdef Q_WS_X11
00684
00688 Display *getDisplay() { return display; }
00689 #endif
00690
00698 void enableStyles();
00699
00707 void disableStyles();
00708
00718 void installX11EventFilter( QWidget* filter );
00719
00724 static int random();
00725
00731 static QString randomString(int length);
00732
00742 void addKipcEventMask(int id);
00743
00752 void removeKipcEventMask(int id);
00753
00759 QCString startupId() const;
00760
00766 void setStartupId( const QCString& startup_id );
00767
00773 QString geometryArgument() const;
00774
00779 void installKDEPropertyMap();
00780
00786 bool authorize(const QString &genericAction);
00787
00795 bool authorizeKAction(const char *action);
00796
00810 bool authorizeURLAction(const QString &action, const KURL &baseURL, const KURL &destURL);
00811
00812
00813
00814 enum { ShiftModifier = 1<<0,
00815 LockModifier = 1<<1,
00816 ControlModifier = 1<<2,
00817 Modifier1 = 1<<3,
00818 Modifier2 = 1<<4,
00819 Modifier3 = 1<<5,
00820 Modifier4 = 1<<6,
00821 Modifier5 = 1<<7 };
00832 static uint keyboardModifiers();
00833
00834
00835 enum { Button1Pressed = 1<<8,
00836 Button2Pressed = 1<<9,
00837 Button3Pressed = 1<<10,
00838 Button4Pressed = 1<<11,
00839 Button5Pressed = 1<<12 };
00849 static uint mouseState();
00850
00851
00852 public slots:
00859 void ref();
00860
00865 void deref();
00866
00867 protected:
00871 KApplication( bool allowStyles, bool GUIenabled, KInstance* _instance );
00872
00873 #ifdef Q_WS_X11
00874
00877 bool x11EventFilter( XEvent * );
00878
00879 Display *display;
00880 #endif
00881 Atom kipcCommAtom;
00882 int kipcEventMask;
00883
00885 static KApplication *KApp;
00886 int pArgc;
00887
00888 private slots:
00889 void dcopFailure(const QString &);
00890 void dcopBlockUserInput( bool );
00891 void x11FilterDestroyed();
00892
00893 private:
00894 QString sessionConfigName() const;
00895 KConfig* pSessionConfig;
00896 static DCOPClient *s_DCOPClient;
00897 static bool s_dcopClientNeedsPostInit;
00898 QString aCaption;
00899 bool bSessionManagement;
00900 QPixmap aIconPixmap;
00901 QPixmap aMiniIconPixmap;
00902 QString aIconName;
00903 QString aMiniIconName;
00904 bool useStyles;
00905 QWidget *smw;
00906
00907 void init( bool GUIenabled );
00908
00909 void parseCommandLine( );
00910
00911 void read_app_startup_id();
00912
00913 void dcopAutoRegistration();
00914 void dcopClientPostInit();
00915 void initUrlActionRestrictions();
00916 public:
00920 bool notify(QObject *receiver, QEvent *event);
00921
00925 int xioErrhandler();
00926
00930 void iceIOErrorHandler( _IceConn *conn );
00931
00935 static bool loadedByKdeinit;
00936
00940 static void startKdeinit();
00941
00945 enum SettingsCategory { SETTINGS_MOUSE, SETTINGS_COMPLETION, SETTINGS_PATHS,
00946 SETTINGS_POPUPMENU, SETTINGS_QT, SETTINGS_SHORTCUTS };
00947
00956 static QPalette createApplicationPalette();
00957
00962 static QPalette createApplicationPalette( KConfig *config, int contrast );
00963
00964 signals:
00971 void kdisplayPaletteChanged();
00972
00980 void kdisplayStyleChanged();
00981
00989 void kdisplayFontChanged();
00990
00996 void appearanceChanged();
00997
01001 void toolbarAppearanceChanged(int);
01002
01008 void backgroundChanged(int desk);
01009
01016 void settingsChanged(int category);
01017
01022 void iconChanged(int group);
01023
01033 void kipcMessage(int id, int data);
01034
01064 void saveYourself();
01065
01073 void shutDown();
01074
01075 private:
01076 void propagateSettings(SettingsCategory category);
01077 void kdisplaySetPalette();
01078 void kdisplaySetStyle();
01079 void kdisplaySetFont();
01080 void applyGUIStyle();
01081
01082 int captionLayout;
01083
01084 KApplication(const KApplication&);
01085 KApplication& operator=(const KApplication&);
01086 protected:
01087 virtual void virtual_hook( int id, void* data );
01088 private:
01089 KApplicationPrivate* d;
01090 };
01091
01092
01108 bool checkAccess(const QString& pathname, int mode);
01109
01110
01111 class KSessionManagedPrivate;
01112
01129 class KSessionManaged
01130 {
01131 public:
01132 KSessionManaged();
01133 virtual ~KSessionManaged();
01134
01144 virtual bool saveState( QSessionManager& sm );
01154 virtual bool commitData( QSessionManager& sm );
01155
01156 protected:
01157 virtual void virtual_hook( int id, void* data );
01158 private:
01159 KSessionManagedPrivate *d;
01160 };
01161
01162
01163 #endif
01164