00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef _KAPP_H
00022 #define _KAPP_H
00023
00024
00025 #include "kdeversion.h"
00026 #include "kdelibs_export.h"
00027
00028 class KConfig;
00029 class KCharsets;
00030 class DCOPClient;
00031 class DCOPObject;
00032
00033 typedef unsigned long Atom;
00034 #if !defined(Q_WS_X11)
00035 typedef void Display;
00036 #endif
00037
00038 #include <qapplication.h>
00039 #include <qpixmap.h>
00040 #include <kinstance.h>
00041
00042 struct _IceConn;
00043 class QPopupMenu;
00044 class QStrList;
00045 class KSessionManaged;
00046 class KStyle;
00047 class KURL;
00048
00049 #define kapp KApplication::kApplication()
00050
00051 class KApplicationPrivate;
00052
00094 class KDECORE_EXPORT KApplication : public QApplication, public KInstance
00095 {
00096
00097 Q_OBJECT
00098 public:
00104 enum CaptionLayout {
00105 CaptionAppLast=1 ,
00106 CaptionAppFirst ,
00107 CaptionNoApp
00108 };
00109
00123 KApplication( bool allowStyles=true, bool GUIenabled=true);
00124
00125 #ifdef Q_WS_X11
00126
00149 KApplication(Display *display, Qt::HANDLE visual = 0, Qt::HANDLE colormap = 0,
00150 bool allowStyles=true);
00151
00176 KApplication(Display *display, int& argc, char** argv, const QCString& rAppName,
00177 bool allowStyles=true, bool GUIenabled=true);
00178 #endif
00179
00202
00203
00204 KApplication(int& argc, char** argv,
00205 const QCString& rAppName, bool allowStyles=true, bool GUIenabled=true) KDE_DEPRECATED;
00206
00210 static void addCmdLineOptions();
00211
00212 virtual ~KApplication();
00213
00224 static KApplication* kApplication() { return KApp; }
00225
00233 KConfig* sessionConfig();
00234
00243 bool isRestored() const { return QApplication::isSessionRestored(); }
00244
00251 void disableSessionManagement();
00252
00259 void enableSessionManagement();
00260
00264 enum ShutdownConfirm {
00268 ShutdownConfirmDefault = -1,
00272 ShutdownConfirmNo = 0,
00276 ShutdownConfirmYes = 1
00277 };
00278
00282 enum ShutdownType {
00286 ShutdownTypeDefault = -1,
00290 ShutdownTypeNone = 0,
00294 ShutdownTypeReboot = 1,
00298 ShutdownTypeHalt = 2
00299 };
00300
00304 enum ShutdownMode {
00308 ShutdownModeDefault = -1,
00313 ShutdownModeSchedule = 0,
00317 ShutdownModeTryNow = 1,
00321 ShutdownModeForceNow = 2,
00325 ShutdownModeInteractive = 3
00326 };
00327
00343 bool requestShutDown( ShutdownConfirm confirm = ShutdownConfirmDefault,
00344 ShutdownType sdtype = ShutdownTypeDefault,
00345 ShutdownMode sdmode = ShutdownModeDefault );
00346
00360 void propagateSessionManager();
00361
00367 void commitData( QSessionManager& sm );
00368
00374 void saveState( QSessionManager& sm );
00375
00385 bool sessionSaving() const;
00386
00393 static DCOPClient *dcopClient();
00394
00399 static void disableAutoDcopRegistration();
00400
00405 QPixmap icon() const;
00406
00411 QString iconName() const;
00412
00417 QPixmap miniIcon() const;
00418
00423 QString miniIconName() const;
00424
00435 void setTopWidget( QWidget *topWidget );
00436
00449 void invokeHelp( const QString& anchor,
00450 const QString& appname,
00451 const QCString& startup_id ) const;
00452
00453
00454 void invokeHelp( const QString& anchor = QString::null,
00455 const QString& appname = QString::null ) const;
00456
00471 void invokeHTMLHelp( const QString& aFilename, const QString& aTopic = QString::null ) const KDE_DEPRECATED;
00472
00481 void invokeMailer( const QString &address, const QString &subject, const QCString& startup_id );
00482
00483 void invokeMailer( const QString &address, const QString &subject );
00484
00494 void invokeMailer( const KURL &mailtoURL, const QCString& startup_id, bool allowAttachments );
00495
00496 void invokeMailer( const KURL &mailtoURL, const QCString& startup_id );
00497
00498 void invokeMailer( const KURL &mailtoURL );
00499
00515 void invokeMailer(const QString &to, const QString &cc, const QString &bcc,
00516 const QString &subject, const QString &body,
00517 const QString &messageFile, const QStringList &attachURLs,
00518 const QCString& startup_id );
00519
00520 void invokeMailer(const QString &to, const QString &cc, const QString &bcc,
00521 const QString &subject, const QString &body,
00522 const QString &messageFile = QString::null, const QStringList &attachURLs = QStringList());
00523
00524 public slots:
00535 void invokeBrowser( const QString &url, const QCString& startup_id );
00536
00541 void invokeBrowser( const QString &url );
00542
00550 void cut();
00551
00559 void copy();
00560
00568 void paste();
00569
00595 void clear();
00596
00604 void selectAll();
00605
00606 public:
00612 static QCString launcher();
00613
00634 static int startServiceByName( const QString& _name, const QString &URL,
00635 QString *error=0, QCString *dcopService=0, int *pid=0, const QCString &startup_id = "", bool noWait = false );
00636
00657 static int startServiceByName( const QString& _name, const QStringList &URLs=QStringList(),
00658 QString *error=0, QCString *dcopService=0, int *pid=0, const QCString &startup_id = "", bool noWait = false );
00659
00680 static int startServiceByDesktopPath( const QString& _name, const QString &URL,
00681 QString *error=0, QCString *dcopService=0, int *pid = 0, const QCString &startup_id = "", bool noWait = false );
00682
00703 static int startServiceByDesktopPath( const QString& _name, const QStringList &URLs=QStringList(),
00704 QString *error=0, QCString *dcopService=0, int *pid = 0, const QCString &startup_id = "", bool noWait = false );
00705
00726 static int startServiceByDesktopName( const QString& _name, const QString &URL,
00727 QString *error=0, QCString *dcopService=0, int *pid = 0, const QCString &startup_id = "", bool noWait = false );
00728
00749 static int startServiceByDesktopName( const QString& _name, const QStringList &URLs=QStringList(),
00750 QString *error=0, QCString *dcopService=0, int *pid = 0, const QCString &startup_id = "", bool noWait = false );
00751
00769 static int kdeinitExec( const QString& name, const QStringList &args,
00770 QString *error, int *pid, const QCString& startup_id );
00771
00772 static int kdeinitExec( const QString& name, const QStringList &args=QStringList(),
00773 QString *error=0, int *pid = 0 );
00774
00792 static int kdeinitExecWait( const QString& name, const QStringList &args,
00793 QString *error, int *pid, const QCString& startup_id );
00794
00795 static int kdeinitExecWait( const QString& name, const QStringList &args=QStringList(),
00796 QString *error=0, int *pid = 0 );
00797
00806 QString caption() const;
00807
00811 KDE_DEPRECATED KStyle* kstyle() const { return 0; }
00812
00830 QString makeStdCaption( const QString &userCaption,
00831 bool withAppName=true, bool modified=false ) const;
00832
00840 QString tempSaveName( const QString& pFilename ) const;
00841
00851 QString checkRecoverFile( const QString& pFilename, bool& bRecover ) const;
00852
00853 #ifdef Q_WS_X11
00854
00858 Display *getDisplay() { return display; }
00859 #endif
00860
00868 void enableStyles();
00869
00877 void disableStyles();
00878
00888 void installX11EventFilter( QWidget* filter );
00889
00894 void removeX11EventFilter( const QWidget* filter );
00895
00900 static int random();
00901
00907 static QString randomString(int length);
00908
00918 void addKipcEventMask(int id);
00919
00928 void removeKipcEventMask(int id);
00929
00935 QCString startupId() const;
00936
00944 void setStartupId( const QCString& startup_id );
00945
00952 void updateUserTimestamp( unsigned long time = 0 );
00953
00959 unsigned long userTimestamp() const;
00960
00969 void updateRemoteUserTimestamp( const QCString& dcopId, unsigned long time = 0 );
00970
00976 QString geometryArgument() const;
00977
00982 void installKDEPropertyMap();
00983
00989 bool authorize(const QString &genericAction);
00990
00998 bool authorizeKAction(const char *action);
00999
01013 bool authorizeURLAction(const QString &action, const KURL &baseURL, const KURL &destURL);
01014
01024 void allowURLAction(const QString &action, const KURL &_baseURL, const KURL &_destURL);
01025
01033 bool authorizeControlModule(const QString &menuId);
01034
01043 QStringList authorizeControlModules(const QStringList &menuIds);
01044
01054 static ButtonState keyboardMouseState();
01055
01056
01057 enum { ShiftModifier = 1<<0,
01058 LockModifier = 1<<1,
01059 ControlModifier = 1<<2,
01060 Modifier1 = 1<<3,
01061 Modifier2 = 1<<4,
01062 Modifier3 = 1<<5,
01063 Modifier4 = 1<<6,
01064 Modifier5 = 1<<7 };
01069 static uint keyboardModifiers() KDE_DEPRECATED;
01070
01072 enum { Button1Pressed = 1<<8,
01073 Button2Pressed = 1<<9,
01074 Button3Pressed = 1<<10,
01075 Button4Pressed = 1<<11,
01076 Button5Pressed = 1<<12 };
01081 static uint mouseState() KDE_DEPRECATED;
01082
01083
01084 public slots:
01091 void ref();
01092
01097 void deref();
01098
01099 protected:
01103 KApplication( bool allowStyles, bool GUIenabled, KInstance* _instance );
01104
01105 #ifdef Q_WS_X11
01106
01109 KApplication( Display *display, Qt::HANDLE visual, Qt::HANDLE colormap,
01110 bool allowStyles, KInstance* _instance );
01111
01115 bool x11EventFilter( XEvent * );
01116
01117 Display *display;
01118 #endif
01119 Atom kipcCommAtom;
01120 int kipcEventMask;
01121
01123 static KApplication *KApp;
01124 int pArgc;
01125
01157 void invokeEditSlot( const char *slot );
01158
01159 private slots:
01160 void dcopFailure(const QString &);
01161 void dcopBlockUserInput( bool );
01162 void x11FilterDestroyed();
01163 void checkAppStartedSlot();
01164
01165 private:
01166 QString sessionConfigName() const;
01167 KConfig* pSessionConfig;
01168 static DCOPClient *s_DCOPClient;
01169 static bool s_dcopClientNeedsPostInit;
01170 QString aCaption;
01171 bool bSessionManagement;
01172 struct oldPixmapType { QPixmap a, b; };
01173 mutable union {
01174 struct {
01175 QPixmap *icon, *miniIcon;
01176 } pm;
01177 char unused[sizeof(oldPixmapType)];
01178 } aIconPixmap;
01179 QString aIconName;
01180 QString aMiniIconName;
01181 bool useStyles;
01182 QWidget *smw;
01183
01184 void init( bool GUIenabled );
01185
01186 void parseCommandLine( );
01187
01188 void read_app_startup_id();
01189
01190 void dcopAutoRegistration();
01191 void dcopClientPostInit();
01192 void initUrlActionRestrictions();
01193
01194 public:
01198 bool notify(QObject *receiver, QEvent *event);
01199
01203 int xErrhandler( Display*, void* );
01204
01208 int xioErrhandler( Display* );
01209
01213 void iceIOErrorHandler( _IceConn *conn );
01214
01218 static bool loadedByKdeinit;
01219
01223 static void startKdeinit();
01224
01228 enum SettingsCategory { SETTINGS_MOUSE, SETTINGS_COMPLETION, SETTINGS_PATHS,
01229 SETTINGS_POPUPMENU, SETTINGS_QT, SETTINGS_SHORTCUTS };
01230
01239 static QPalette createApplicationPalette();
01240
01245 static QPalette createApplicationPalette( KConfig *config, int contrast );
01246
01254 static void installSigpipeHandler();
01255
01262 static bool guiEnabled();
01263
01264 signals:
01271 void kdisplayPaletteChanged();
01272
01280 void kdisplayStyleChanged();
01281
01293 void kdisplayFontChanged();
01294
01300 void appearanceChanged();
01301
01305 void toolbarAppearanceChanged(int);
01306
01312 void backgroundChanged(int desk);
01313
01320 void settingsChanged(int category);
01321
01326 void iconChanged(int group);
01327
01337 void kipcMessage(int id, int data);
01338
01368 void saveYourself();
01369
01377 void shutDown();
01378
01383 void updateIconLoaders();
01384
01385 private:
01386 void propagateSettings(SettingsCategory category);
01387 void kdisplaySetPalette();
01388 void kdisplaySetStyle();
01389 void kdisplaySetFont();
01390 void applyGUIStyle();
01391 static void sigpipeHandler(int);
01392
01393 int captionLayout;
01394
01395 KApplication(const KApplication&);
01396 KApplication& operator=(const KApplication&);
01397 protected:
01398 virtual void virtual_hook( int id, void* data );
01399 private:
01400 KApplicationPrivate* d;
01401 };
01402
01403
01421 KDECORE_EXPORT bool checkAccess(const QString& pathname, int mode);
01422
01423 class KSessionManagedPrivate;
01424
01441 class KDECORE_EXPORT KSessionManaged
01442 {
01443 public:
01444 KSessionManaged();
01445 virtual ~KSessionManaged();
01446
01456 virtual bool saveState( QSessionManager& sm );
01466 virtual bool commitData( QSessionManager& sm );
01467
01468 protected:
01469 virtual void virtual_hook( int id, void* data );
01470 private:
01471 KSessionManagedPrivate *d;
01472 };
01473
01474
01475 #endif
01476