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 #include "kdemacros.h"
00029
00030 class KConfig;
00031 class KCharsets;
00032 class DCOPClient;
00033 class DCOPObject;
00034
00035 typedef unsigned long Atom;
00036 #ifdef Q_WS_QWS
00037 typedef void Display;
00038 #endif
00039
00040 #include <qapplication.h>
00041 #include <qpixmap.h>
00042 #include <kinstance.h>
00043
00044 struct _IceConn;
00045 class QPopupMenu;
00046 class QStrList;
00047 class KSessionManaged;
00048 class KStyle;
00049 class KURL;
00050
00051 #define kapp KApplication::kApplication()
00052
00053 class KApplicationPrivate;
00054
00096 class KApplication : public QApplication, public KInstance
00097 {
00098
00099 Q_OBJECT
00100 public:
00101 enum CaptionLayout { CaptionAppLast=1, CaptionAppFirst, CaptionNoApp };
00102
00116 KApplication( bool allowStyles=true, bool GUIenabled=true);
00117
00118 #ifndef Q_WS_QWS
00119
00143 KApplication(Display *display, int& argc, char** argv, const QCString& rAppName,
00144 bool allowStyles=true, bool GUIenabled=true);
00145 #endif
00146
00169
00170
00171 KApplication(int& argc, char** argv,
00172 const QCString& rAppName, bool allowStyles=true, bool GUIenabled=true) KDE_DEPRECATED;
00173
00177 static void addCmdLineOptions();
00178
00179 virtual ~KApplication();
00180
00191 static KApplication* kApplication() { return KApp; }
00192
00200 KConfig* sessionConfig();
00201
00210 bool isRestored() const { return QApplication::isSessionRestored(); }
00211
00218 void disableSessionManagement();
00219
00226 void enableSessionManagement();
00227
00231 enum ShutdownConfirm {
00235 ShutdownConfirmDefault = -1,
00239 ShutdownConfirmNo = 0,
00243 ShutdownConfirmYes = 1
00244 };
00245
00249 enum ShutdownType {
00253 ShutdownTypeDefault = -1,
00257 ShutdownTypeNone = 0,
00261 ShutdownTypeReboot = 1,
00265 ShutdownTypeHalt = 2
00266 };
00267
00271 enum ShutdownMode {
00275 ShutdownModeDefault = -1,
00280 ShutdownModeSchedule = 0,
00284 ShutdownModeTryNow = 1,
00288 ShutdownModeForceNow = 2,
00292 ShutdownModeInteractive = 3
00293 };
00294
00310 bool requestShutDown( ShutdownConfirm confirm = ShutdownConfirmDefault,
00311 ShutdownType sdtype = ShutdownTypeDefault,
00312 ShutdownMode sdmode = ShutdownModeDefault );
00313
00327 void propagateSessionManager();
00328
00329
00330
00331
00332
00333
00334 void commitData( QSessionManager& sm );
00335
00336
00337
00338
00339
00340
00341 void saveState( QSessionManager& sm );
00342
00352 bool sessionSaving() const;
00353
00360 static DCOPClient *dcopClient();
00361
00366 static void disableAutoDcopRegistration();
00367
00372 QPixmap icon() const;
00373
00378 QString iconName() const;
00379
00384 QPixmap miniIcon() const;
00385
00390 QString miniIconName() const;
00391
00402 void setTopWidget( QWidget *topWidget );
00403
00416 void invokeHelp( const QString& anchor,
00417 const QString& appname,
00418 const QCString& startup_id ) const;
00419
00420
00421 void invokeHelp( const QString& anchor = QString::null,
00422 const QString& appname = QString::null ) const;
00423
00438 void invokeHTMLHelp( const QString& aFilename, const QString& aTopic = QString::null ) const KDE_DEPRECATED;
00439
00448 void invokeMailer( const QString &address, const QString &subject, const QCString& startup_id );
00449
00450 void invokeMailer( const QString &address, const QString &subject );
00451
00459 void invokeMailer( const KURL &mailtoURL, const QCString& startup_id );
00460
00461 void invokeMailer( const KURL &mailtoURL );
00462
00478 void invokeMailer(const QString &to, const QString &cc, const QString &bcc,
00479 const QString &subject, const QString &body,
00480 const QString &messageFile, const QStringList &attachURLs,
00481 const QCString& startup_id );
00482
00483 void invokeMailer(const QString &to, const QString &cc, const QString &bcc,
00484 const QString &subject, const QString &body,
00485 const QString &messageFile = QString::null, const QStringList &attachURLs = QStringList());
00486
00487 public slots:
00498 void invokeBrowser( const QString &url, const QCString& startup_id );
00499
00500 void invokeBrowser( const QString &url );
00501
00509 void cut();
00510
00518 void copy();
00519
00527 void paste();
00528
00554 void clear();
00555
00563 void selectAll();
00564
00565 public:
00571 static QCString launcher();
00572
00593 static int startServiceByName( const QString& _name, const QString &URL,
00594 QString *error=0, QCString *dcopService=0, int *pid=0, const QCString &startup_id = "", bool noWait = false );
00595
00616 static int startServiceByName( const QString& _name, const QStringList &URLs=QStringList(),
00617 QString *error=0, QCString *dcopService=0, int *pid=0, const QCString &startup_id = "", bool noWait = false );
00618
00639 static int startServiceByDesktopPath( const QString& _name, const QString &URL,
00640 QString *error=0, QCString *dcopService=0, int *pid = 0, const QCString &startup_id = "", bool noWait = false );
00641
00662 static int startServiceByDesktopPath( const QString& _name, const QStringList &URLs=QStringList(),
00663 QString *error=0, QCString *dcopService=0, int *pid = 0, const QCString &startup_id = "", bool noWait = false );
00664
00685 static int startServiceByDesktopName( const QString& _name, const QString &URL,
00686 QString *error=0, QCString *dcopService=0, int *pid = 0, const QCString &startup_id = "", bool noWait = false );
00687
00708 static int startServiceByDesktopName( const QString& _name, const QStringList &URLs=QStringList(),
00709 QString *error=0, QCString *dcopService=0, int *pid = 0, const QCString &startup_id = "", bool noWait = false );
00710
00730 static int kdeinitExec( const QString& name, const QStringList &args,
00731 QString *error, int *pid, const QCString& startup_id );
00732
00733 static int kdeinitExec( const QString& name, const QStringList &args=QStringList(),
00734 QString *error=0, int *pid = 0 );
00735
00753 static int kdeinitExecWait( const QString& name, const QStringList &args,
00754 QString *error, int *pid, const QCString& startup_id );
00755
00756 static int kdeinitExecWait( const QString& name, const QStringList &args=QStringList(),
00757 QString *error=0, int *pid = 0 );
00758
00767 QString caption() const;
00768
00772 KDE_DEPRECATED KStyle* kstyle() const { return 0; }
00773
00791 QString makeStdCaption( const QString &userCaption,
00792 bool withAppName=true, bool modified=false ) const;
00793
00801 QString tempSaveName( const QString& pFilename ) const;
00802
00812 QString checkRecoverFile( const QString& pFilename, bool& bRecover ) const;
00813
00814 #ifdef Q_WS_X11
00815
00819 Display *getDisplay() { return display; }
00820 #endif
00821
00829 void enableStyles();
00830
00838 void disableStyles();
00839
00849 void installX11EventFilter( QWidget* filter );
00850
00855 void removeX11EventFilter( const QWidget* filter );
00856
00861 static int random();
00862
00868 static QString randomString(int length);
00869
00879 void addKipcEventMask(int id);
00880
00889 void removeKipcEventMask(int id);
00890
00896 QCString startupId() const;
00897
00903 void setStartupId( const QCString& startup_id );
00904
00911 void updateUserTimestamp( unsigned long time = 0 );
00912
00918 QString geometryArgument() const;
00919
00924 void installKDEPropertyMap();
00925
00931 bool authorize(const QString &genericAction);
00932
00940 bool authorizeKAction(const char *action);
00941
00955 bool authorizeURLAction(const QString &action, const KURL &baseURL, const KURL &destURL);
00956
00966 void allowURLAction(const QString &action, const KURL &_baseURL, const KURL &_destURL);
00967
00975 bool authorizeControlModule(const QString &menuId);
00976
00985 QStringList authorizeControlModules(const QStringList &menuIds);
00986
00987
00988
00989 enum { ShiftModifier = 1<<0,
00990 LockModifier = 1<<1,
00991 ControlModifier = 1<<2,
00992 Modifier1 = 1<<3,
00993 Modifier2 = 1<<4,
00994 Modifier3 = 1<<5,
00995 Modifier4 = 1<<6,
00996 Modifier5 = 1<<7 };
01007 static uint keyboardModifiers();
01008
01009
01010 enum { Button1Pressed = 1<<8,
01011 Button2Pressed = 1<<9,
01012 Button3Pressed = 1<<10,
01013 Button4Pressed = 1<<11,
01014 Button5Pressed = 1<<12 };
01024 static uint mouseState();
01025
01026
01027 public slots:
01034 void ref();
01035
01040 void deref();
01041
01042 protected:
01046 KApplication( bool allowStyles, bool GUIenabled, KInstance* _instance );
01047
01048 #ifdef Q_WS_X11
01049
01052 bool x11EventFilter( XEvent * );
01053
01054 Display *display;
01055 #endif
01056 Atom kipcCommAtom;
01057 int kipcEventMask;
01058
01060 static KApplication *KApp;
01061 int pArgc;
01062
01094 void invokeEditSlot( const char *slot );
01095
01096 private slots:
01097 void dcopFailure(const QString &);
01098 void dcopBlockUserInput( bool );
01099 void x11FilterDestroyed();
01100 void checkAppStartedSlot();
01101
01102 private:
01103 QString sessionConfigName() const;
01104 KConfig* pSessionConfig;
01105 static DCOPClient *s_DCOPClient;
01106 static bool s_dcopClientNeedsPostInit;
01107 QString aCaption;
01108 bool bSessionManagement;
01109 QPixmap aIconPixmap;
01110 QPixmap aMiniIconPixmap;
01111 QString aIconName;
01112 QString aMiniIconName;
01113 bool useStyles;
01114 QWidget *smw;
01115
01116 void init( bool GUIenabled );
01117
01118 void parseCommandLine( );
01119
01120 void read_app_startup_id();
01121
01122 void dcopAutoRegistration();
01123 void dcopClientPostInit();
01124 void initUrlActionRestrictions();
01125
01126 public:
01130 bool notify(QObject *receiver, QEvent *event);
01131
01135 int xErrhandler( Display*, void* );
01136
01140 int xioErrhandler( Display* );
01141
01145 void iceIOErrorHandler( _IceConn *conn );
01146
01150 static bool loadedByKdeinit;
01151
01155 static void startKdeinit();
01156
01160 enum SettingsCategory { SETTINGS_MOUSE, SETTINGS_COMPLETION, SETTINGS_PATHS,
01161 SETTINGS_POPUPMENU, SETTINGS_QT, SETTINGS_SHORTCUTS };
01162
01171 static QPalette createApplicationPalette();
01172
01177 static QPalette createApplicationPalette( KConfig *config, int contrast );
01178
01186 static void installSigpipeHandler();
01187
01194 static bool guiEnabled();
01195
01196 signals:
01203 void kdisplayPaletteChanged();
01204
01212 void kdisplayStyleChanged();
01213
01225 void kdisplayFontChanged();
01226
01232 void appearanceChanged();
01233
01237 void toolbarAppearanceChanged(int);
01238
01244 void backgroundChanged(int desk);
01245
01252 void settingsChanged(int category);
01253
01258 void iconChanged(int group);
01259
01269 void kipcMessage(int id, int data);
01270
01300 void saveYourself();
01301
01309 void shutDown();
01310
01311 private:
01312 void propagateSettings(SettingsCategory category);
01313 void kdisplaySetPalette();
01314 void kdisplaySetStyle();
01315 void kdisplaySetFont();
01316 void applyGUIStyle();
01317 static void sigpipeHandler(int);
01318
01319 int captionLayout;
01320
01321 KApplication(const KApplication&);
01322 KApplication& operator=(const KApplication&);
01323 protected:
01324 virtual void virtual_hook( int id, void* data );
01325 private:
01326 KApplicationPrivate* d;
01327 };
01328
01329
01347 bool checkAccess(const QString& pathname, int mode);
01348
01349 class KSessionManagedPrivate;
01350
01367 class KSessionManaged
01368 {
01369 public:
01370 KSessionManaged();
01371 virtual ~KSessionManaged();
01372
01382 virtual bool saveState( QSessionManager& sm );
01392 virtual bool commitData( QSessionManager& sm );
01393
01394 protected:
01395 virtual void virtual_hook( int id, void* data );
01396 private:
01397 KSessionManagedPrivate *d;
01398 };
01399
01400
01401 #endif
01402