kdecore Library API Documentation

kapplication.h

00001 /* This file is part of the KDE libraries 00002 Copyright (C) 1997 Matthias Kalle Dalheimer (kalle@kde.org) 00003 Copyright (c) 1998, 1999 KDE Team 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Library General Public 00007 License as published by the Free Software Foundation; either 00008 version 2 of the License, or (at your option) any later version. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Library General Public License for more details. 00014 00015 You should have received a copy of the GNU Library General Public License 00016 along with this library; see the file COPYING.LIB. If not, write to 00017 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 00018 Boston, MA 02111-1307, USA. 00019 */ 00020 00021 // $Id: kapplication.h,v 1.312 2004/07/22 16:50:04 waba Exp $ 00022 00023 #ifndef _KAPP_H 00024 #define _KAPP_H 00025 00026 // Version macros. Never put this further down. 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 00142 KApplication(Display *display, Qt::HANDLE visual = 0, Qt::HANDLE colormap = 0, 00143 bool allowStyles=true); 00144 00169 KApplication(Display *display, int& argc, char** argv, const QCString& rAppName, 00170 bool allowStyles=true, bool GUIenabled=true); 00171 #endif 00172 00195 // REMOVE FOR KDE 4.0 - using it only gives crashing applications because 00196 // KCmdLineArgs::init isn't called 00197 KApplication(int& argc, char** argv, 00198 const QCString& rAppName, bool allowStyles=true, bool GUIenabled=true) KDE_DEPRECATED; 00199 00203 static void addCmdLineOptions(); 00204 00205 virtual ~KApplication(); 00206 00217 static KApplication* kApplication() { return KApp; } 00218 00226 KConfig* sessionConfig(); 00227 00236 bool isRestored() const { return QApplication::isSessionRestored(); } 00237 00244 void disableSessionManagement(); 00245 00252 void enableSessionManagement(); 00253 00257 enum ShutdownConfirm { 00261 ShutdownConfirmDefault = -1, 00265 ShutdownConfirmNo = 0, 00269 ShutdownConfirmYes = 1 00270 }; 00271 00275 enum ShutdownType { 00279 ShutdownTypeDefault = -1, 00283 ShutdownTypeNone = 0, 00287 ShutdownTypeReboot = 1, 00291 ShutdownTypeHalt = 2 00292 }; 00293 00297 enum ShutdownMode { 00301 ShutdownModeDefault = -1, 00306 ShutdownModeSchedule = 0, 00310 ShutdownModeTryNow = 1, 00314 ShutdownModeForceNow = 2, 00318 ShutdownModeInteractive = 3 00319 }; 00320 00336 bool requestShutDown( ShutdownConfirm confirm = ShutdownConfirmDefault, 00337 ShutdownType sdtype = ShutdownTypeDefault, 00338 ShutdownMode sdmode = ShutdownModeDefault ); 00339 00353 void propagateSessionManager(); 00354 00355 /* 00356 * Reimplemented for internal purposes, mainly the highlevel 00357 * handling of session management with KSessionManaged. 00358 * @internal 00359 */ 00360 void commitData( QSessionManager& sm ); 00361 00362 /* 00363 * Reimplemented for internal purposes, mainly the highlevel 00364 * handling of session management with KSessionManaged. 00365 * @internal 00366 */ 00367 void saveState( QSessionManager& sm ); 00368 00378 bool sessionSaving() const; 00379 00386 static DCOPClient *dcopClient(); 00387 00392 static void disableAutoDcopRegistration(); 00393 00398 QPixmap icon() const; 00399 00404 QString iconName() const; 00405 00410 QPixmap miniIcon() const; 00411 00416 QString miniIconName() const; 00417 00428 void setTopWidget( QWidget *topWidget ); 00429 00442 void invokeHelp( const QString& anchor, 00443 const QString& appname, 00444 const QCString& startup_id ) const; 00445 00446 // KDE4 merge with above with startup_id = "" 00447 void invokeHelp( const QString& anchor = QString::null, 00448 const QString& appname = QString::null ) const; 00449 00464 void invokeHTMLHelp( const QString& aFilename, const QString& aTopic = QString::null ) const KDE_DEPRECATED; 00465 00474 void invokeMailer( const QString &address, const QString &subject, const QCString& startup_id ); 00475 // KDE4 merge with above with startup_id = "" 00476 void invokeMailer( const QString &address, const QString &subject ); 00477 00487 void invokeMailer( const KURL &mailtoURL, const QCString& startup_id, bool allowAttachments ); 00488 // KDE4 merge with above with allowAttachments = false 00489 void invokeMailer( const KURL &mailtoURL, const QCString& startup_id ); 00490 // KDE4 merge with above with startup_id = "" 00491 void invokeMailer( const KURL &mailtoURL ); 00492 00508 void invokeMailer(const QString &to, const QString &cc, const QString &bcc, 00509 const QString &subject, const QString &body, 00510 const QString &messageFile, const QStringList &attachURLs, 00511 const QCString& startup_id ); 00512 // KDE4 merge with above with startup_id = "" 00513 void invokeMailer(const QString &to, const QString &cc, const QString &bcc, 00514 const QString &subject, const QString &body, 00515 const QString &messageFile = QString::null, const QStringList &attachURLs = QStringList()); 00516 00517 public slots: 00528 void invokeBrowser( const QString &url, const QCString& startup_id ); 00529 // KDE4 merge with above with startup_id = "" 00530 void invokeBrowser( const QString &url ); 00531 00539 void cut(); 00540 00548 void copy(); 00549 00557 void paste(); 00558 00584 void clear(); 00585 00593 void selectAll(); 00594 00595 public: 00601 static QCString launcher(); 00602 00623 static int startServiceByName( const QString& _name, const QString &URL, 00624 QString *error=0, QCString *dcopService=0, int *pid=0, const QCString &startup_id = "", bool noWait = false ); 00625 00646 static int startServiceByName( const QString& _name, const QStringList &URLs=QStringList(), 00647 QString *error=0, QCString *dcopService=0, int *pid=0, const QCString &startup_id = "", bool noWait = false ); 00648 00669 static int startServiceByDesktopPath( const QString& _name, const QString &URL, 00670 QString *error=0, QCString *dcopService=0, int *pid = 0, const QCString &startup_id = "", bool noWait = false ); 00671 00692 static int startServiceByDesktopPath( const QString& _name, const QStringList &URLs=QStringList(), 00693 QString *error=0, QCString *dcopService=0, int *pid = 0, const QCString &startup_id = "", bool noWait = false ); 00694 00715 static int startServiceByDesktopName( const QString& _name, const QString &URL, 00716 QString *error=0, QCString *dcopService=0, int *pid = 0, const QCString &startup_id = "", bool noWait = false ); 00717 00738 static int startServiceByDesktopName( const QString& _name, const QStringList &URLs=QStringList(), 00739 QString *error=0, QCString *dcopService=0, int *pid = 0, const QCString &startup_id = "", bool noWait = false ); 00740 00760 static int kdeinitExec( const QString& name, const QStringList &args, 00761 QString *error, int *pid, const QCString& startup_id ); 00762 // KDE4 merge with above with startup_id = "" 00763 static int kdeinitExec( const QString& name, const QStringList &args=QStringList(), 00764 QString *error=0, int *pid = 0 ); 00765 00783 static int kdeinitExecWait( const QString& name, const QStringList &args, 00784 QString *error, int *pid, const QCString& startup_id ); 00785 // KDE4 merge with above with startup_id = "" 00786 static int kdeinitExecWait( const QString& name, const QStringList &args=QStringList(), 00787 QString *error=0, int *pid = 0 ); 00788 00797 QString caption() const; 00798 00802 KDE_DEPRECATED KStyle* kstyle() const { return 0; } 00803 00821 QString makeStdCaption( const QString &userCaption, 00822 bool withAppName=true, bool modified=false ) const; 00823 00831 QString tempSaveName( const QString& pFilename ) const; 00832 00842 QString checkRecoverFile( const QString& pFilename, bool& bRecover ) const; 00843 00844 #ifdef Q_WS_X11 00845 00849 Display *getDisplay() { return display; } 00850 #endif 00851 00859 void enableStyles(); 00860 00868 void disableStyles(); 00869 00879 void installX11EventFilter( QWidget* filter ); 00880 00885 void removeX11EventFilter( const QWidget* filter ); 00886 00891 static int random(); 00892 00898 static QString randomString(int length); 00899 00909 void addKipcEventMask(int id); 00910 00919 void removeKipcEventMask(int id); 00920 00926 QCString startupId() const; 00927 00935 void setStartupId( const QCString& startup_id ); 00936 00943 void updateUserTimestamp( unsigned long time = 0 ); 00944 00950 unsigned long userTimestamp() const; 00951 00960 void updateRemoteUserTimestamp( const QCString& dcopId, unsigned long time = 0 ); 00961 00967 QString geometryArgument() const; 00968 00973 void installKDEPropertyMap(); 00974 00980 bool authorize(const QString &genericAction); 00981 00989 bool authorizeKAction(const char *action); 00990 01004 bool authorizeURLAction(const QString &action, const KURL &baseURL, const KURL &destURL); 01005 01015 void allowURLAction(const QString &action, const KURL &_baseURL, const KURL &_destURL); 01016 01024 bool authorizeControlModule(const QString &menuId); 01025 01034 QStringList authorizeControlModules(const QStringList &menuIds); 01035 01036 01037 // Same values as ShiftMask etc. in X.h 01038 enum { ShiftModifier = 1<<0, 01039 LockModifier = 1<<1, 01040 ControlModifier = 1<<2, 01041 Modifier1 = 1<<3, 01042 Modifier2 = 1<<4, 01043 Modifier3 = 1<<5, 01044 Modifier4 = 1<<6, 01045 Modifier5 = 1<<7 }; 01056 static uint keyboardModifiers(); 01057 01058 // Same values as Button1Mask etc. in X.h 01059 enum { Button1Pressed = 1<<8, 01060 Button2Pressed = 1<<9, 01061 Button3Pressed = 1<<10, 01062 Button4Pressed = 1<<11, 01063 Button5Pressed = 1<<12 }; 01073 static uint mouseState(); 01074 01075 01076 public slots: 01083 void ref(); 01084 01089 void deref(); 01090 01091 protected: 01095 KApplication( bool allowStyles, bool GUIenabled, KInstance* _instance ); 01096 01097 #ifdef Q_WS_X11 01098 01101 KApplication( Display *display, Qt::HANDLE visual, Qt::HANDLE colormap, 01102 bool allowStyles, KInstance* _instance ); 01103 01107 bool x11EventFilter( XEvent * ); 01108 01109 Display *display; 01110 #endif 01111 Atom kipcCommAtom; 01112 int kipcEventMask; 01113 01115 static KApplication *KApp; 01116 int pArgc; 01117 01149 void invokeEditSlot( const char *slot ); 01150 01151 private slots: 01152 void dcopFailure(const QString &); 01153 void dcopBlockUserInput( bool ); 01154 void x11FilterDestroyed(); 01155 void checkAppStartedSlot(); 01156 01157 private: 01158 QString sessionConfigName() const; 01159 KConfig* pSessionConfig; //instance specific application config object 01160 static DCOPClient *s_DCOPClient; // app specific application communication client 01161 static bool s_dcopClientNeedsPostInit; 01162 QString aCaption; // the name for the window title 01163 bool bSessionManagement; 01164 QPixmap aIconPixmap; // BIC (KDE 4) make a pointer, to avoid creating if noGUI 01165 QPixmap aMiniIconPixmap; // BIC (KDE 4) make a pointer, to avoid creating if noGUI 01166 QString aIconName; 01167 QString aMiniIconName; 01168 bool useStyles; 01169 QWidget *smw; 01170 01171 void init( bool GUIenabled ); 01172 01173 void parseCommandLine( ); // Handle KDE arguments (Using KCmdLineArgs) 01174 01175 void read_app_startup_id(); 01176 01177 void dcopAutoRegistration(); 01178 void dcopClientPostInit(); 01179 void initUrlActionRestrictions(); 01180 01181 public: 01185 bool notify(QObject *receiver, QEvent *event); 01186 01190 int xErrhandler( Display*, void* ); 01191 01195 int xioErrhandler( Display* ); 01196 01200 void iceIOErrorHandler( _IceConn *conn ); 01201 01205 static bool loadedByKdeinit; 01206 01210 static void startKdeinit(); 01211 01215 enum SettingsCategory { SETTINGS_MOUSE, SETTINGS_COMPLETION, SETTINGS_PATHS, 01216 SETTINGS_POPUPMENU, SETTINGS_QT, SETTINGS_SHORTCUTS }; 01217 01226 static QPalette createApplicationPalette(); 01227 01232 static QPalette createApplicationPalette( KConfig *config, int contrast ); 01233 01241 static void installSigpipeHandler(); 01242 01249 static bool guiEnabled(); 01250 01251 signals: 01258 void kdisplayPaletteChanged(); 01259 01267 void kdisplayStyleChanged(); 01268 01280 void kdisplayFontChanged(); 01281 01287 void appearanceChanged(); 01288 01292 void toolbarAppearanceChanged(int); 01293 01299 void backgroundChanged(int desk); 01300 01307 void settingsChanged(int category); 01308 01313 void iconChanged(int group); 01314 01324 void kipcMessage(int id, int data); 01325 01355 void saveYourself(); 01356 01364 void shutDown(); 01365 01366 private: 01367 void propagateSettings(SettingsCategory category); 01368 void kdisplaySetPalette(); 01369 void kdisplaySetStyle(); 01370 void kdisplaySetFont(); 01371 void applyGUIStyle(); 01372 static void sigpipeHandler(int); 01373 01374 int captionLayout; 01375 01376 KApplication(const KApplication&); 01377 KApplication& operator=(const KApplication&); 01378 protected: 01379 virtual void virtual_hook( int id, void* data ); 01380 private: 01381 KApplicationPrivate* d; 01382 }; 01383 01384 01402 bool checkAccess(const QString& pathname, int mode); 01403 01404 class KSessionManagedPrivate; 01405 01422 class KSessionManaged 01423 { 01424 public: 01425 KSessionManaged(); 01426 virtual ~KSessionManaged(); 01427 01437 virtual bool saveState( QSessionManager& sm ); 01447 virtual bool commitData( QSessionManager& sm ); 01448 01449 protected: 01450 virtual void virtual_hook( int id, void* data ); 01451 private: 01452 KSessionManagedPrivate *d; 01453 }; 01454 01455 01456 #endif 01457
KDE Logo
This file is part of the documentation for kdecore Library Version 3.3.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Sep 29 09:43:09 2004 by doxygen 1.3.8 written by Dimitri van Heesch, © 1997-2003