# kdecore Library API Documentation

Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Namespaces | Source Files

# 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 #ifndef _KAPP_H
    00022 #define _KAPP_H
    00023
    00024 // Version macros. Never put this further down.
    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:
    00099   enum CaptionLayout { CaptionAppLast=1, CaptionAppFirst, CaptionNoApp };
    00100
    00114   KApplication( bool allowStyles=true, bool GUIenabled=true);
    00115
    00116 #ifdef Q_WS_X11
    00117
    00140   KApplication(Display *display, Qt::HANDLE visual = 0, Qt::HANDLE colormap = 0,
    00141                bool allowStyles=true);
    00142
    00167   KApplication(Display *display, int& argc, char** argv, const QCString& rAppName,
    00168                bool allowStyles=true, bool GUIenabled=true);
    00169 #endif
    00170
    00193   // REMOVE FOR KDE 4.0 - using it only gives crashing applications because
    00194   // KCmdLineArgs::init isn't called
    00195  KApplication(int& argc, char** argv,
    00196               const QCString& rAppName, bool allowStyles=true, bool GUIenabled=true) KDE_DEPRECATED;
    00197
    00201   static void addCmdLineOptions();
    00202
    00203   virtual ~KApplication();
    00204
    00215   static KApplication* kApplication() { return KApp; }
    00216
    00224   KConfig* sessionConfig();
    00225
    00234   bool isRestored() const { return QApplication::isSessionRestored(); }
    00235
    00242   void disableSessionManagement();
    00243
    00250   void enableSessionManagement();
    00251
    00255   enum ShutdownConfirm {
    00259     ShutdownConfirmDefault = -1,
    00263     ShutdownConfirmNo = 0,
    00267     ShutdownConfirmYes = 1
    00268   };
    00269
    00273   enum ShutdownType {
    00277     ShutdownTypeDefault = -1,
    00281     ShutdownTypeNone = 0,
    00285     ShutdownTypeReboot = 1,
    00289     ShutdownTypeHalt = 2
    00290   };
    00291
    00295   enum ShutdownMode {
    00299     ShutdownModeDefault = -1,
    00304     ShutdownModeSchedule = 0,
    00308     ShutdownModeTryNow = 1,
    00312     ShutdownModeForceNow = 2,
    00316     ShutdownModeInteractive = 3
    00317   };
    00318
    00334   bool requestShutDown( ShutdownConfirm confirm = ShutdownConfirmDefault,
    00335                         ShutdownType sdtype = ShutdownTypeDefault,
    00336             ShutdownMode sdmode = ShutdownModeDefault );
    00337
    00351     void propagateSessionManager();
    00352
    00353     /*
    00354      * Reimplemented for internal purposes, mainly the highlevel
    00355      *  handling of session management with KSessionManaged.
    00356      * @internal
    00357      */
    00358   void commitData( QSessionManager& sm );
    00359
    00360     /*
    00361      * Reimplemented for internal purposes, mainly the highlevel
    00362      *  handling of session management with KSessionManaged.
    00363      * @internal
    00364      */
    00365   void saveState( QSessionManager& sm );
    00366
    00376   bool sessionSaving() const;
    00377
    00384   static DCOPClient *dcopClient();
    00385
    00390   static void disableAutoDcopRegistration();
    00391
    00396   QPixmap icon() const;
    00397
    00402   QString iconName() const;
    00403
    00408   QPixmap miniIcon() const;
    00409
    00414   QString miniIconName() const;
    00415
    00426   void setTopWidget( QWidget *topWidget );
    00427
    00440   void invokeHelp( const QString& anchor,
    00441                    const QString& appname,
    00442                    const QCString& startup_id ) const;
    00443
    00444   // KDE4 merge with above with startup_id = ""
    00445   void invokeHelp( const QString& anchor = QString::null,
    00446                    const QString& appname = QString::null ) const;
    00447
    00462   void invokeHTMLHelp( const QString& aFilename, const QString& aTopic = QString::null ) const KDE_DEPRECATED;
    00463
    00472   void invokeMailer( const QString &address, const QString &subject, const QCString& startup_id );
    00473   // KDE4 merge with above with startup_id = ""
    00474   void invokeMailer( const QString &address, const QString &subject );
    00475
    00485   void invokeMailer( const KURL &mailtoURL, const QCString& startup_id, bool allowAttachments );
    00486   // KDE4 merge with above with allowAttachments = false
    00487   void invokeMailer( const KURL &mailtoURL, const QCString& startup_id );
    00488   // KDE4 merge with above with startup_id = ""
    00489   void invokeMailer( const KURL &mailtoURL );
    00490
    00506   void invokeMailer(const QString &to, const QString &cc, const QString &bcc,
    00507                     const QString &subject, const QString &body,
    00508                     const QString &messageFile, const QStringList &attachURLs,
    00509                     const QCString& startup_id );
    00510   // KDE4 merge with above with startup_id = ""
    00511   void invokeMailer(const QString &to, const QString &cc, const QString &bcc,
    00512                     const QString &subject, const QString &body,
    00513                     const QString &messageFile = QString::null, const QStringList &attachURLs = QStringList());
    00514
    00515 public slots:
    00526   void invokeBrowser( const QString &url, const QCString& startup_id );
    00527   // KDE4 merge with above with startup_id = ""
    00528   void invokeBrowser( const QString &url );
    00529
    00537   void cut();
    00538
    00546   void copy();
    00547
    00555   void paste();
    00556
    00582   void clear();
    00583
    00591   void selectAll();
    00592
    00593 public:
    00599   static QCString launcher();
    00600
    00621   static int startServiceByName( const QString& _name, const QString &URL,
    00622                 QString *error=0, QCString *dcopService=0, int *pid=0, const QCString &startup_id = "", bool noWait = false );
    00623
    00644   static int startServiceByName( const QString& _name, const QStringList &URLs=QStringList(),
    00645                 QString *error=0, QCString *dcopService=0, int *pid=0, const QCString &startup_id = "", bool noWait = false );
    00646
    00667   static int startServiceByDesktopPath( const QString& _name, const QString &URL,
    00668                 QString *error=0, QCString *dcopService=0, int *pid = 0, const QCString &startup_id = "", bool noWait = false );
    00669
    00690   static int startServiceByDesktopPath( const QString& _name, const QStringList &URLs=QStringList(),
    00691                 QString *error=0, QCString *dcopService=0, int *pid = 0, const QCString &startup_id = "", bool noWait = false );
    00692
    00713   static int startServiceByDesktopName( const QString& _name, const QString &URL,
    00714                 QString *error=0, QCString *dcopService=0, int *pid = 0, const QCString &startup_id = "", bool noWait = false );
    00715
    00736   static int startServiceByDesktopName( const QString& _name, const QStringList &URLs=QStringList(),
    00737                 QString *error=0, QCString *dcopService=0, int *pid = 0, const QCString &startup_id = "", bool noWait = false );
    00738
    00758   static int kdeinitExec( const QString& name, const QStringList &args,
    00759                 QString *error, int *pid, const QCString& startup_id );
    00760   // KDE4 merge with above with startup_id = ""
    00761   static int kdeinitExec( const QString& name, const QStringList &args=QStringList(),
    00762                 QString *error=0, int *pid = 0 );
    00763
    00781   static int kdeinitExecWait( const QString& name, const QStringList &args,
    00782                 QString *error, int *pid, const QCString& startup_id );
    00783   // KDE4 merge with above with startup_id = ""
    00784   static int kdeinitExecWait( const QString& name, const QStringList &args=QStringList(),
    00785                 QString *error=0, int *pid = 0 );
    00786
    00795   QString caption() const;
    00796
    00800   KDE_DEPRECATED KStyle* kstyle() const { return 0; }
    00801
    00819   QString makeStdCaption( const QString &userCaption,
    00820                           bool withAppName=true, bool modified=false ) const;
    00821
    00829   QString tempSaveName( const QString& pFilename ) const;
    00830
    00840   QString checkRecoverFile( const QString& pFilename, bool& bRecover ) const;
    00841
    00842 #ifdef Q_WS_X11
    00843
    00847   Display *getDisplay() { return display; }
    00848 #endif
    00849
    00857   void enableStyles();
    00858
    00866   void disableStyles();
    00867
    00877   void installX11EventFilter( QWidget* filter );
    00878
    00883   void removeX11EventFilter( const QWidget* filter );
    00884
    00889   static int random();
    00890
    00896   static QString randomString(int length);
    00897
    00907   void addKipcEventMask(int id);
    00908
    00917   void removeKipcEventMask(int id);
    00918
    00924   QCString startupId() const;
    00925
    00933   void setStartupId( const QCString& startup_id );
    00934
    00941   void updateUserTimestamp( unsigned long time = 0 );
    00942
    00948   unsigned long userTimestamp() const;
    00949
    00958   void updateRemoteUserTimestamp( const QCString& dcopId, unsigned long time = 0 );
    00959
    00965   QString geometryArgument() const;
    00966
    00971   void installKDEPropertyMap();
    00972
    00978   bool authorize(const QString &genericAction);
    00979
    00987   bool authorizeKAction(const char *action);
    00988
    01002   bool authorizeURLAction(const QString &action, const KURL &baseURL, const KURL &destURL);
    01003
    01013   void allowURLAction(const QString &action, const KURL &_baseURL, const KURL &_destURL);
    01014
    01022   bool authorizeControlModule(const QString &menuId);
    01023
    01032   QStringList authorizeControlModules(const QStringList &menuIds);
    01033
    01043   static ButtonState keyboardMouseState();
    01044
    01045   // Same values as ShiftMask etc. in X.h
    01046   enum { ShiftModifier = 1<<0,
    01047          LockModifier = 1<<1,
    01048          ControlModifier = 1<<2,
    01049          Modifier1 = 1<<3,
    01050          Modifier2 = 1<<4,
    01051          Modifier3 = 1<<5,
    01052          Modifier4 = 1<<6,
    01053          Modifier5 = 1<<7 };
    01058   static uint keyboardModifiers() KDE_DEPRECATED;
    01059
    01061   enum { Button1Pressed = 1<<8,
    01062          Button2Pressed = 1<<9,
    01063          Button3Pressed = 1<<10,
    01064          Button4Pressed = 1<<11,
    01065          Button5Pressed = 1<<12 };
    01070   static uint mouseState() KDE_DEPRECATED;
    01071
    01072
    01073 public slots:
    01080   void ref();
    01081
    01086   void deref();
    01087
    01088 protected:
    01092   KApplication( bool allowStyles, bool GUIenabled, KInstance* _instance );
    01093
    01094 #ifdef Q_WS_X11
    01098   KApplication( Display *display, Qt::HANDLE visual, Qt::HANDLE colormap,
    01099           bool allowStyles, KInstance* _instance );
    01100
    01104   bool x11EventFilter( XEvent * );
    01105
    01106   Display *display;
    01107 #endif
    01108   Atom kipcCommAtom;
    01109   int kipcEventMask;
    01110
    01112   static KApplication *KApp;
    01113   int pArgc;
    01114
    01146   void invokeEditSlot( const char *slot );
    01147
    01148 private slots:
    01149   void dcopFailure(const QString &);
    01150   void dcopBlockUserInput( bool );
    01151   void x11FilterDestroyed();
    01152   void checkAppStartedSlot();
    01153
    01154 private:
    01155   QString sessionConfigName() const;
    01156   KConfig* pSessionConfig; //instance specific application config object
    01157   static DCOPClient *s_DCOPClient; // app specific application communication client
    01158   static bool s_dcopClientNeedsPostInit;
    01159   QString aCaption; // the name for the window title
    01160   bool bSessionManagement;
    01161   struct oldPixmapType { QPixmap a, b; };
    01162   mutable union {
    01163     struct {
    01164       QPixmap *icon, *miniIcon;
    01165     } pm;
    01166     char unused[sizeof(oldPixmapType)];
    01167   } aIconPixmap; // KDE4: remove me
    01168   QString aIconName;
    01169   QString aMiniIconName;
    01170   bool useStyles;
    01171   QWidget *smw;
    01172
    01173   void init( bool GUIenabled );
    01174
    01175   void parseCommandLine( ); // Handle KDE arguments (Using KCmdLineArgs)
    01176
    01177   void read_app_startup_id();
    01178
    01179   void dcopAutoRegistration();
    01180   void dcopClientPostInit();
    01181   void initUrlActionRestrictions();
    01182
    01183 public:
    01187   bool notify(QObject *receiver, QEvent *event);
    01188
    01192   int xErrhandler( Display*, void* );
    01193
    01197   int xioErrhandler( Display* );
    01198
    01202   void iceIOErrorHandler( _IceConn *conn );
    01203
    01207   static bool loadedByKdeinit;
    01208
    01212   static void startKdeinit();
    01213
    01217   enum SettingsCategory { SETTINGS_MOUSE, SETTINGS_COMPLETION, SETTINGS_PATHS,
    01218          SETTINGS_POPUPMENU, SETTINGS_QT, SETTINGS_SHORTCUTS };
    01219
    01228   static QPalette createApplicationPalette();
    01229
    01234   static QPalette createApplicationPalette( KConfig *config, int contrast );
    01235
    01243   static void installSigpipeHandler();
    01244
    01251   static bool guiEnabled();
    01252
    01253 signals:
    01260   void kdisplayPaletteChanged();
    01261
    01269   void kdisplayStyleChanged();
    01270
    01282   void kdisplayFontChanged();
    01283
    01289   void appearanceChanged();
    01290
    01294   void toolbarAppearanceChanged(int);
    01295
    01301   void backgroundChanged(int desk);
    01302
    01309   void settingsChanged(int category);
    01310
    01315   void iconChanged(int group);
    01316
    01326   void kipcMessage(int id, int data);
    01327
    01357   void saveYourself();
    01358
    01366   void shutDown();
    01367
    01368 private:
    01369   void propagateSettings(SettingsCategory category);
    01370   void kdisplaySetPalette();
    01371   void kdisplaySetStyle();
    01372   void kdisplaySetFont();
    01373   void applyGUIStyle();
    01374   static void sigpipeHandler(int);
    01375
    01376   int captionLayout;
    01377
    01378   KApplication(const KApplication&);
    01379   KApplication& operator=(const KApplication&);
    01380 protected:
    01381   virtual void virtual_hook( int id, void* data );
    01382 private:
    01383   KApplicationPrivate* d;
    01384 };
    01385
    01386
    01404 KDECORE_EXPORT bool checkAccess(const QString& pathname, int mode);
    01405
    01406 class KSessionManagedPrivate;
    01407
    01424 class KDECORE_EXPORT KSessionManaged
    01425 {
    01426 public:
    01427   KSessionManaged();
    01428   virtual ~KSessionManaged();
    01429
    01439   virtual bool saveState( QSessionManager& sm );
    01449   virtual bool commitData( QSessionManager& sm );
    01450
    01451 protected:
    01452   virtual void virtual_hook( int id, void* data );
    01453 private:
    01454   KSessionManagedPrivate *d;
    01455 };
    01456
    01457
    01458 #endif
    01459

This file is part of the documentation for kdecore Library Version 3.4.1.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sat Jun 11 20:18:01 2005 by doxygen 1.4.1 written by Dimitri van Heesch, © 1997-2003