00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef _TDEAPP_H
00022 #define _TDEAPP_H
00023
00024
00025 #include "tdeversion.h"
00026 #include "tdelibs_export.h"
00027
00028 class TDEConfig;
00029 class KCharsets;
00030 class DCOPClient;
00031 class DCOPObject;
00032
00033 #include <tqtglobaldefines.h>
00034
00035 typedef unsigned long Atom;
00036 #if !defined(Q_WS_X11)
00037 typedef void Display;
00038 #endif
00039
00040 #include <tqapplication.h>
00041 #include <tqpixmap.h>
00042 #include <kinstance.h>
00043
00044 struct _IceConn;
00045 class TQPopupMenu;
00046 class TQStrList;
00047 class KSessionManaged;
00048 class TDEStyle;
00049 class KURL;
00050
00051 #define kapp TDEApplication::kApplication()
00052
00053 class TDEApplicationPrivate;
00054
00096 class TDECORE_EXPORT TDEApplication : public TQApplication, public TDEInstance
00097 {
00098
00099 Q_OBJECT
00100 public:
00106 enum CaptionLayout {
00107 CaptionAppLast=1 ,
00108 CaptionAppFirst ,
00109 CaptionNoApp
00110 };
00111
00131 TDEApplication( bool allowStyles=true, bool GUIenabled=true, bool SMenabled=true);
00132
00133 #ifdef Q_QDOC
00134 #else // Q_QDOC
00135 #ifdef TDEAPPLICATION_BINARY_COMPAT_HACK
00136
00137
00138
00139 TDEApplication( bool allowStyles=true, bool GUIenabled=true);
00140 #endif // TDEAPPLICATION_BINARY_COMPAT_HACK
00141 #endif // Q_QDOC
00142
00143 #ifdef Q_WS_X11
00144
00161 TDEApplication(Display *display, bool allowStyles);
00162
00190 TDEApplication(Display *display, bool disable_argb, Qt::HANDLE visual, Qt::HANDLE colormap, bool allowStyles);
00191
00215 TDEApplication(Display *display, Qt::HANDLE visual = 0, Qt::HANDLE colormap = 0,
00216 bool allowStyles=true);
00217
00242 TDEApplication(Display *display, int& argc, char** argv, const TQCString& rAppName,
00243 bool allowStyles=true, bool GUIenabled=true);
00244 #endif
00245
00268
00269
00270 TDEApplication(int& argc, char** argv,
00271 const TQCString& rAppName, bool allowStyles=true, bool GUIenabled=true, bool SMenabled=true) KDE_DEPRECATED;
00272
00273 #ifdef Q_QDOC
00274 #else // Q_QDOC
00275 #ifdef TDEAPPLICATION_BINARY_COMPAT_HACK
00276
00277
00278
00279 TDEApplication(int& argc, char** argv,
00280 const TQCString& rAppName, bool allowStyles, bool GUIenabled) KDE_DEPRECATED;
00281 #endif // TDEAPPLICATION_BINARY_COMPAT_HACK
00282 #endif // Q_QDOC
00283
00287 static void addCmdLineOptions();
00288
00289 virtual ~TDEApplication();
00290
00301 static TDEApplication* kApplication() { return KApp; }
00302
00310 TDEConfig* sessionConfig();
00311
00320 bool isRestored() const { return TQApplication::isSessionRestored(); }
00321
00328 void disableSessionManagement();
00329
00336 void enableSessionManagement();
00337
00341 enum ShutdownConfirm {
00345 ShutdownConfirmDefault = -1,
00349 ShutdownConfirmNo = 0,
00353 ShutdownConfirmYes = 1
00354 };
00355
00359 enum ShutdownType {
00363 ShutdownTypeDefault = -1,
00367 ShutdownTypeNone = 0,
00371 ShutdownTypeReboot = 1,
00375 ShutdownTypeHalt = 2
00376 };
00377
00381 enum ShutdownMode {
00385 ShutdownModeDefault = -1,
00390 ShutdownModeSchedule = 0,
00394 ShutdownModeTryNow = 1,
00398 ShutdownModeForceNow = 2,
00402 ShutdownModeInteractive = 3
00403 };
00404
00420 bool requestShutDown( ShutdownConfirm confirm = ShutdownConfirmDefault,
00421 ShutdownType sdtype = ShutdownTypeDefault,
00422 ShutdownMode sdmode = ShutdownModeDefault );
00423
00437 void propagateSessionManager();
00438
00444 void commitData( TQSessionManager& sm );
00445
00451 void saveState( TQSessionManager& sm );
00452
00462 bool sessionSaving() const;
00463
00470 static DCOPClient *dcopClient();
00471
00476 static void disableAutoDcopRegistration();
00477
00482 TQPixmap icon() const;
00483
00488 TQString iconName() const;
00489
00494 TQPixmap miniIcon() const;
00495
00500 TQString miniIconName() const;
00501
00512 void setTopWidget( TQWidget *topWidget );
00513
00526 void invokeHelp( const TQString& anchor,
00527 const TQString& appname,
00528 const TQCString& startup_id ) const;
00529
00530
00531 void invokeHelp( const TQString& anchor = TQString::null,
00532 const TQString& appname = TQString::null ) const;
00533
00548 void invokeHTMLHelp( const TQString& aFilename, const TQString& aTopic = TQString::null ) const KDE_DEPRECATED;
00549
00558 void invokeMailer( const TQString &address, const TQString &subject, const TQCString& startup_id );
00559
00560 void invokeMailer( const TQString &address, const TQString &subject );
00561
00571 void invokeMailer( const KURL &mailtoURL, const TQCString& startup_id, bool allowAttachments );
00572
00573 void invokeMailer( const KURL &mailtoURL, const TQCString& startup_id );
00574
00575 void invokeMailer( const KURL &mailtoURL );
00576
00592 void invokeMailer(const TQString &to, const TQString &cc, const TQString &bcc,
00593 const TQString &subject, const TQString &body,
00594 const TQString &messageFile, const TQStringList &attachURLs,
00595 const TQCString& startup_id );
00596
00597 void invokeMailer(const TQString &to, const TQString &cc, const TQString &bcc,
00598 const TQString &subject, const TQString &body,
00599 const TQString &messageFile = TQString::null, const TQStringList &attachURLs = TQStringList());
00600
00601 public slots:
00612 void invokeBrowser( const TQString &url, const TQCString& startup_id );
00613
00618 void invokeBrowser( const TQString &url );
00619
00627 void cut();
00628
00636 void copy();
00637
00645 void paste();
00646
00672 void clear();
00673
00681 void selectAll();
00682
00689 void broadcastKeyCode(unsigned int keyCode);
00690
00691 public:
00697 static TQCString launcher();
00698
00719 static int startServiceByName( const TQString& _name, const TQString &URL,
00720 TQString *error=0, TQCString *dcopService=0, int *pid=0, const TQCString &startup_id = "", bool noWait = false );
00721
00742 static int startServiceByName( const TQString& _name, const TQStringList &URLs=TQStringList(),
00743 TQString *error=0, TQCString *dcopService=0, int *pid=0, const TQCString &startup_id = "", bool noWait = false );
00744
00765 static int startServiceByDesktopPath( const TQString& _name, const TQString &URL,
00766 TQString *error=0, TQCString *dcopService=0, int *pid = 0, const TQCString &startup_id = "", bool noWait = false );
00767
00788 static int startServiceByDesktopPath( const TQString& _name, const TQStringList &URLs=TQStringList(),
00789 TQString *error=0, TQCString *dcopService=0, int *pid = 0, const TQCString &startup_id = "", bool noWait = false );
00790
00811 static int startServiceByDesktopName( const TQString& _name, const TQString &URL,
00812 TQString *error=0, TQCString *dcopService=0, int *pid = 0, const TQCString &startup_id = "", bool noWait = false );
00813
00834 static int startServiceByDesktopName( const TQString& _name, const TQStringList &URLs=TQStringList(),
00835 TQString *error=0, TQCString *dcopService=0, int *pid = 0, const TQCString &startup_id = "", bool noWait = false );
00836
00854 static int tdeinitExec( const TQString& name, const TQStringList &args,
00855 TQString *error, int *pid, const TQCString& startup_id );
00856
00857 static int tdeinitExec( const TQString& name, const TQStringList &args=TQStringList(),
00858 TQString *error=0, int *pid = 0 );
00859
00877 static int tdeinitExecWait( const TQString& name, const TQStringList &args,
00878 TQString *error, int *pid, const TQCString& startup_id );
00879
00880 static int tdeinitExecWait( const TQString& name, const TQStringList &args=TQStringList(),
00881 TQString *error=0, int *pid = 0 );
00882
00891 TQString caption() const;
00892
00896 KDE_DEPRECATED TDEStyle* tdestyle() const { return 0; }
00897
00915 TQString makeStdCaption( const TQString &userCaption,
00916 bool withAppName=true, bool modified=false ) const;
00917
00925 TQString tempSaveName( const TQString& pFilename ) const;
00926
00936 TQString checkRecoverFile( const TQString& pFilename, bool& bRecover ) const;
00937
00938 #if defined(Q_WS_X11)
00939
00944 Display *getDisplay() { return display; }
00945 #endif
00946
00951 void getX11RGBAInformation(Display *dpy);
00952
00960 static bool isCompositionManagerAvailable();
00961
00970 bool detectCompositionManagerAvailable(bool force_available=false, bool available=true);
00971
00980 static Display* openX11RGBADisplay();
00981
00987 Qt::HANDLE getX11RGBAVisual(Display *dpy);
00988
00994 Qt::HANDLE getX11RGBAColormap(Display *dpy);
00995
01012 bool isX11CompositionAvailable();
01013
01021 void enableStyles();
01022
01030 void disableStyles();
01031
01041 void installX11EventFilter( TQWidget* filter );
01042
01047 void removeX11EventFilter( const TQWidget* filter );
01048
01053 static int random();
01054
01060 static TQString randomString(int length);
01061
01071 void addKipcEventMask(int id);
01072
01081 void removeKipcEventMask(int id);
01082
01088 TQCString startupId() const;
01089
01097 void setStartupId( const TQCString& startup_id );
01098
01105 void updateUserTimestamp( unsigned long time = 0 );
01106
01112 unsigned long userTimestamp() const;
01113
01122 void updateRemoteUserTimestamp( const TQCString& dcopId, unsigned long time = 0 );
01123
01129 TQString geometryArgument() const;
01130
01135 void installKDEPropertyMap();
01136
01142 bool authorize(const TQString &genericAction);
01143
01151 bool authorizeTDEAction(const char *action);
01152
01166 bool authorizeURLAction(const TQString &action, const KURL &baseURL, const KURL &destURL);
01167
01177 void allowURLAction(const TQString &action, const KURL &_baseURL, const KURL &_destURL);
01178
01186 bool authorizeControlModule(const TQString &menuId);
01187
01196 TQStringList authorizeControlModules(const TQStringList &menuIds);
01197
01207 static ButtonState keyboardMouseState();
01208
01209
01210 enum { ShiftModifier = 1<<0,
01211 LockModifier = 1<<1,
01212 ControlModifier = 1<<2,
01213 Modifier1 = 1<<3,
01214 Modifier2 = 1<<4,
01215 Modifier3 = 1<<5,
01216 Modifier4 = 1<<6,
01217 Modifier5 = 1<<7 };
01222 static uint keyboardModifiers() KDE_DEPRECATED;
01223
01225 enum { Button1Pressed = 1<<8,
01226 Button2Pressed = 1<<9,
01227 Button3Pressed = 1<<10,
01228 Button4Pressed = 1<<11,
01229 Button5Pressed = 1<<12 };
01234 static uint mouseState() KDE_DEPRECATED;
01235
01241 static int currentX11VT();
01242
01243
01244 public slots:
01251 void ref();
01252
01257 void deref();
01258
01259 protected:
01263 TDEApplication( bool allowStyles, bool GUIenabled, TDEInstance* _instance );
01264
01265 #ifdef Q_WS_X11
01266
01269 TDEApplication( Display *display, Qt::HANDLE visual, Qt::HANDLE colormap,
01270 bool allowStyles, TDEInstance* _instance );
01271
01275 bool x11EventFilter( XEvent * );
01276
01277 Display *display;
01278 #endif
01279 Atom kipcCommAtom;
01280 int kipcEventMask;
01281
01283 static TDEApplication *KApp;
01284 int pArgc;
01285
01317 void invokeEditSlot( const char *slot );
01318
01319 private slots:
01320 void dcopFailure(const TQString &);
01321 void dcopBlockUserInput( bool );
01322 void x11FilterDestroyed();
01323 void checkAppStartedSlot();
01324
01325 private:
01326 TQString sessionConfigName() const;
01327 TDEConfig* pSessionConfig;
01328 static DCOPClient *s_DCOPClient;
01329 static bool s_dcopClientNeedsPostInit;
01330 TQString aCaption;
01331 bool bSessionManagement;
01332 struct oldPixmapType { TQPixmap a, b; };
01333 mutable union {
01334 struct {
01335 TQPixmap *icon, *miniIcon;
01336 } pm;
01337 char unused[sizeof(oldPixmapType)];
01338 } aIconPixmap;
01339 TQString aIconName;
01340 TQString aMiniIconName;
01341 bool useStyles;
01342 TQWidget *smw;
01343
01344 void init( bool GUIenabled );
01345
01346 void parseCommandLine( );
01347
01348 void read_app_startup_id();
01349
01350 void dcopAutoRegistration();
01351 void dcopClientPostInit();
01352 void initUrlActionRestrictions();
01353
01354 bool argb_visual;
01355 #if defined(Q_WS_X11)
01356 Qt::HANDLE argb_x11_visual;
01357 Qt::HANDLE argb_x11_colormap;
01358 #endif
01359
01360 public:
01364 bool notify(TQObject *receiver, TQEvent *event);
01365
01369 int xErrhandler( Display*, void* );
01370
01374 int xioErrhandler( Display* );
01375
01379 void iceIOErrorHandler( _IceConn *conn );
01380
01384 static bool loadedByKdeinit;
01385
01389 static void startKdeinit();
01390
01394 enum SettingsCategory { SETTINGS_MOUSE, SETTINGS_COMPLETION, SETTINGS_PATHS,
01395 SETTINGS_POPUPMENU, SETTINGS_QT, SETTINGS_SHORTCUTS };
01396
01405 static TQPalette createApplicationPalette();
01406
01411 static TQPalette createApplicationPalette( TDEConfig *config, int contrast );
01412
01420 static void installSigpipeHandler();
01421
01428 static bool guiEnabled();
01429
01430 signals:
01437 void tdedisplayPaletteChanged();
01438
01446 void tdedisplayStyleChanged();
01447
01459 void tdedisplayFontChanged();
01460
01466 void appearanceChanged();
01467
01471 void toolbarAppearanceChanged(int);
01472
01478 void backgroundChanged(int desk);
01479
01486 void settingsChanged(int category);
01487
01492 void iconChanged(int group);
01493
01503 void kipcMessage(int id, int data);
01504
01534 void saveYourself();
01535
01543 void shutDown();
01544
01549 void updateIconLoaders();
01550
01555 void coreFakeKeyPress(unsigned int keyCode);
01556
01557 private:
01558 void propagateSettings(SettingsCategory category);
01559 void tdedisplaySetPalette();
01560 void tdedisplaySetStyle();
01561 void tdedisplaySetFont();
01562 void applyGUIStyle();
01563 static void sigpipeHandler(int);
01564
01565 int captionLayout;
01566
01567 TDEApplication(const TDEApplication&);
01568 TDEApplication& operator=(const TDEApplication&);
01569 protected:
01570 virtual void virtual_hook( int id, void* data );
01571 private:
01572 TDEApplicationPrivate* d;
01573 };
01574
01575
01593 TDECORE_EXPORT bool checkAccess(const TQString& pathname, int mode);
01594
01595 class KSessionManagedPrivate;
01596
01613 class TDECORE_EXPORT KSessionManaged
01614 {
01615 public:
01616 KSessionManaged();
01617 virtual ~KSessionManaged();
01618
01628 virtual bool saveState( TQSessionManager& sm );
01638 virtual bool commitData( TQSessionManager& sm );
01639
01640 protected:
01641 virtual void virtual_hook( int id, void* data );
01642 private:
01643 KSessionManagedPrivate *d;
01644 };
01645
01646
01647 #endif
01648