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.278 2002/10/27 12:22:23 hausmann Exp $
00022 
00023 #ifndef _KAPP_H
00024 #define _KAPP_H
00025 
00026 // Version macros. Never put this further down.
00027 #include "kdeversion.h"
00028 
00029 class KConfig;
00030 class KCharsets;
00031 class DCOPClient;
00032 class DCOPObject;
00033 
00034 typedef unsigned long Atom;
00035 #ifdef Q_WS_QWS
00036 typedef void Display;
00037 #endif
00038 
00039 #include <qapplication.h>
00040 #include <qpixmap.h>
00041 #include <kinstance.h>
00042 
00043 struct _IceConn;
00044 class QPopupMenu;
00045 class QStrList;
00046 class KSessionManaged;
00047 class KStyle;
00048 class KURL;
00049 
00050 #define kapp KApplication::kApplication()
00051 
00052 class KApplicationPrivate;
00053 
00091 class KApplication : public QApplication, public KInstance
00092 {
00093 
00094   Q_OBJECT
00095 public:
00096   enum CaptionLayout { CaptionAppLast=1, CaptionAppFirst, CaptionNoApp };
00097 
00111   KApplication( bool allowStyles=true, bool GUIenabled=true);
00112 
00113 #ifndef Q_WS_QWS
00114 
00134   KApplication(Display *display, int& argc, char** argv, const QCString& rAppName,
00135                bool allowStyles=true, bool GUIenabled=true);
00136 #endif
00137 
00158   KApplication(int& argc, char** argv,
00159               const QCString& rAppName, bool allowStyles=true, bool GUIenabled=true);
00160 
00164   static void addCmdLineOptions();
00165 
00166   virtual ~KApplication();
00167 
00178   static KApplication* kApplication() { return KApp; }
00179 
00187   KConfig* sessionConfig();
00188 
00197   bool isRestored() const { return QApplication::isSessionRestored(); }
00198 
00205   void disableSessionManagement();
00206 
00210   enum ShutdownConfirm {
00214     ShutdownConfirmDefault = -1,
00218     ShutdownConfirmNo = 0,
00222     ShutdownConfirmYes = 1
00223   };
00224 
00228   enum ShutdownType {
00232     ShutdownTypeDefault = -1,
00236     ShutdownTypeNone = 0,
00240     ShutdownTypeReboot = 1,
00244     ShutdownTypeHalt = 2
00245   };
00246 
00250   enum ShutdownMode {
00254     ShutdownModeDefault = -1,
00259     ShutdownModeSchedule = 0,
00263     ShutdownModeTryNow = 1,
00267     ShutdownModeForceNow = 2,
00271     ShutdownModeInteractive = 3
00272   };
00273 
00289   bool requestShutDown( ShutdownConfirm confirm = ShutdownConfirmDefault,
00290                         ShutdownType sdtype = ShutdownTypeDefault,
00291             ShutdownMode sdmode = ShutdownModeDefault );
00292 
00306     void propagateSessionManager();
00307 
00308     /*
00309      * Reimplemented for internal purposes, mainly the highlevel
00310      *  handling of session management with @ref KSessionManaged.
00311      * @internal
00312      */
00313   void commitData( QSessionManager& sm );
00314 
00315     /*
00316      * Reimplemented for internal purposes, mainly the highlevel
00317      *  handling of session management with KSessionManaged.
00318      * @internal
00319      */
00320   void saveState( QSessionManager& sm );
00321 
00328   static DCOPClient *dcopClient();
00329 
00334   static void disableAutoDcopRegistration();
00335 
00340   QPixmap icon() const;
00341 
00346   QString iconName() const;
00347 
00352   QPixmap miniIcon() const;
00353 
00358   QString miniIconName() const;
00359 
00370   void setTopWidget( QWidget *topWidget );
00371 
00382   void invokeHelp( const QString& anchor = QString::null,
00383                    const QString& appname = QString::null ) const;
00384 
00399   void invokeHTMLHelp( const QString& aFilename, const QString& aTopic = QString::null ) const;
00400 
00407   void invokeMailer( const QString &address, const QString &subject );
00408 
00414   void invokeMailer( const KURL &mailtoURL );
00415 
00429   void invokeMailer(const QString &to, const QString &cc, const QString &bcc,
00430                     const QString &subject, const QString &body,
00431                     const QString &messageFile = QString::null, const QStringList &attachURLs = QStringList());
00432 
00433 public slots:
00442   void invokeBrowser( const QString &url );
00443 
00444 public:
00450   static QCString launcher();
00451 
00472   static int startServiceByName( const QString& _name, const QString &URL,
00473                 QString *error=0, QCString *dcopService=0, int *pid=0, const QCString &startup_id = "", bool noWait = false );
00474 
00495   static int startServiceByName( const QString& _name, const QStringList &URLs=QStringList(),
00496                 QString *error=0, QCString *dcopService=0, int *pid=0, const QCString &startup_id = "", bool noWait = false );
00497 
00518   static int startServiceByDesktopPath( const QString& _name, const QString &URL,
00519                 QString *error=0, QCString *dcopService=0, int *pid = 0, const QCString &startup_id = "", bool noWait = false );
00520 
00541   static int startServiceByDesktopPath( const QString& _name, const QStringList &URLs=QStringList(),
00542                 QString *error=0, QCString *dcopService=0, int *pid = 0, const QCString &startup_id = "", bool noWait = false );
00543 
00564   static int startServiceByDesktopName( const QString& _name, const QString &URL,
00565                 QString *error=0, QCString *dcopService=0, int *pid = 0, const QCString &startup_id = "", bool noWait = false );
00566 
00587   static int startServiceByDesktopName( const QString& _name, const QStringList &URLs=QStringList(),
00588                 QString *error=0, QCString *dcopService=0, int *pid = 0, const QCString &startup_id = "", bool noWait = false );
00589 
00607   static int kdeinitExec( const QString& name, const QStringList &args=QStringList(),
00608                 QString *error=0, int *pid = 0 );
00609 
00625   static int kdeinitExecWait( const QString& name, const QStringList &args=QStringList(),
00626                 QString *error=0, int *pid = 0 );
00627 
00636   QString caption() const;
00637 
00641   KStyle* kstyle() const { return 0; }
00642 
00660   QString makeStdCaption( const QString &userCaption,
00661                           bool withAppName=true, bool modified=false ) const;
00662 
00670   QString tempSaveName( const QString& pFilename ) const;
00671 
00681   QString checkRecoverFile( const QString& pFilename, bool& bRecover ) const;
00682 
00683 #ifdef Q_WS_X11
00684 
00688   Display *getDisplay() { return display; }
00689 #endif
00690 
00698   void enableStyles();
00699 
00707   void disableStyles();
00708 
00718   void installX11EventFilter( QWidget* filter );
00719 
00724   static int random();
00725 
00731   static QString randomString(int length);
00732 
00742   void addKipcEventMask(int id);
00743 
00752   void removeKipcEventMask(int id);
00753 
00759   QCString startupId() const;
00760 
00766   void setStartupId( const QCString& startup_id );
00767 
00773   QString geometryArgument() const;
00774 
00779   void installKDEPropertyMap();
00780 
00786   bool authorize(const QString &genericAction);
00787 
00795   bool authorizeKAction(const char *action);
00796 
00810   bool authorizeURLAction(const QString &action, const KURL &baseURL, const KURL &destURL);
00811                    
00812 
00813   // Same values as ShiftMask etc. in X.h
00814   enum { ShiftModifier = 1<<0,
00815          LockModifier = 1<<1,
00816          ControlModifier = 1<<2,
00817          Modifier1 = 1<<3,
00818          Modifier2 = 1<<4,
00819          Modifier3 = 1<<5,
00820          Modifier4 = 1<<6,
00821          Modifier5 = 1<<7 };
00832   static uint keyboardModifiers();
00833 
00834   // Same values as Button1Mask etc. in X.h
00835   enum { Button1Pressed = 1<<8,
00836          Button2Pressed = 1<<9,
00837          Button3Pressed = 1<<10,
00838          Button4Pressed = 1<<11,
00839          Button5Pressed = 1<<12 };
00849   static uint mouseState();
00850 
00851 
00852 public slots:
00859   void ref();
00860 
00865   void deref();
00866 
00867 protected:
00871   KApplication( bool allowStyles, bool GUIenabled, KInstance* _instance );
00872 
00873 #ifdef Q_WS_X11
00874 
00877   bool x11EventFilter( XEvent * );
00878 
00879   Display *display;
00880 #endif
00881   Atom kipcCommAtom;
00882   int kipcEventMask;
00883 
00885   static KApplication *KApp;
00886   int pArgc;
00887 
00888 private slots:
00889   void dcopFailure(const QString &);
00890   void dcopBlockUserInput( bool );
00891   void x11FilterDestroyed();
00892 
00893 private:
00894   QString sessionConfigName() const;
00895   KConfig* pSessionConfig; //instance specific application config object
00896   static DCOPClient *s_DCOPClient; // app specific application communication client
00897   static bool s_dcopClientNeedsPostInit;
00898   QString aCaption; // the name for the window title
00899   bool bSessionManagement;
00900   QPixmap aIconPixmap;
00901   QPixmap aMiniIconPixmap;
00902   QString aIconName;
00903   QString aMiniIconName;
00904   bool useStyles;
00905   QWidget *smw;
00906 
00907   void init( bool GUIenabled );
00908 
00909   void parseCommandLine( ); // Handle KDE arguments (Using KCmdLineArgs)
00910 
00911   void read_app_startup_id();
00912 
00913   void dcopAutoRegistration();
00914   void dcopClientPostInit();
00915   void initUrlActionRestrictions();
00916 public:
00920   bool notify(QObject *receiver, QEvent *event);
00921 
00925   int xioErrhandler();
00926 
00930   void iceIOErrorHandler( _IceConn *conn );
00931 
00935   static bool loadedByKdeinit;
00936 
00940   static void startKdeinit();
00941 
00945   enum SettingsCategory { SETTINGS_MOUSE, SETTINGS_COMPLETION, SETTINGS_PATHS,
00946          SETTINGS_POPUPMENU, SETTINGS_QT, SETTINGS_SHORTCUTS };
00947 
00956   static QPalette createApplicationPalette();
00957 
00962   static QPalette createApplicationPalette( KConfig *config, int contrast );
00963 
00964 signals:
00971   void kdisplayPaletteChanged();
00972 
00980   void kdisplayStyleChanged();
00981 
00989   void kdisplayFontChanged();
00990 
00996   void appearanceChanged();
00997 
01001   void toolbarAppearanceChanged(int);
01002 
01008   void backgroundChanged(int desk);
01009 
01016   void settingsChanged(int category);
01017 
01022   void iconChanged(int group);
01023 
01033   void kipcMessage(int id, int data);
01034 
01064   void saveYourself();
01065 
01073   void shutDown();
01074 
01075 private:
01076   void propagateSettings(SettingsCategory category);
01077   void kdisplaySetPalette();
01078   void kdisplaySetStyle();
01079   void kdisplaySetFont();
01080   void applyGUIStyle();
01081 
01082   int captionLayout;
01083 
01084   KApplication(const KApplication&);
01085   KApplication& operator=(const KApplication&);
01086 protected:
01087   virtual void virtual_hook( int id, void* data );
01088 private:
01089   KApplicationPrivate* d;
01090 };
01091 
01092 
01108 bool checkAccess(const QString& pathname, int mode);
01109 
01110 
01111 class KSessionManagedPrivate;
01112 
01129 class KSessionManaged
01130 {
01131 public:
01132   KSessionManaged();
01133   virtual ~KSessionManaged();
01134 
01144   virtual bool saveState( QSessionManager& sm );
01154   virtual bool commitData( QSessionManager& sm );
01155 
01156 protected:
01157   virtual void virtual_hook( int id, void* data );
01158 private:
01159   KSessionManagedPrivate *d;
01160 };
01161 
01162 
01163 #endif
01164 
KDE Logo
This file is part of the documentation for kdelibs Version 3.1.0.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Wed Oct 8 12:20:39 2003 by doxygen 1.2.18 written by Dimitri van Heesch, © 1997-2001