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.306.2.1 2004/04/08 09:56:29 lunakl 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 
00143   KApplication(Display *display, int& argc, char** argv, const QCString& rAppName,
00144                bool allowStyles=true, bool GUIenabled=true);
00145 #endif
00146 
00169   // REMOVE FOR KDE 4.0 - using it only gives crashing applications because
00170   // KCmdLineArgs::init isn't called
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      * Reimplemented for internal purposes, mainly the highlevel
00331      *  handling of session management with KSessionManaged.
00332      * @internal
00333      */
00334   void commitData( QSessionManager& sm );
00335 
00336     /*
00337      * Reimplemented for internal purposes, mainly the highlevel
00338      *  handling of session management with KSessionManaged.
00339      * @internal
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   // KDE4 merge with above with startup_id = ""
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   // KDE4 merge with above with startup_id = ""
00450   void invokeMailer( const QString &address, const QString &subject );
00451 
00459   void invokeMailer( const KURL &mailtoURL, const QCString& startup_id );
00460   // KDE4 merge with above with startup_id = ""
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   // KDE4 merge with above with startup_id = ""
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   // KDE4 merge with above with startup_id = ""
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   // KDE4 merge with above with startup_id = ""
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   // KDE4 merge with above with startup_id = ""
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   unsigned long userTimestamp() const;
00919 
00925   QString geometryArgument() const;
00926 
00931   void installKDEPropertyMap();
00932 
00938   bool authorize(const QString &genericAction);
00939 
00947   bool authorizeKAction(const char *action);
00948 
00962   bool authorizeURLAction(const QString &action, const KURL &baseURL, const KURL &destURL);
00963 
00973   void allowURLAction(const QString &action, const KURL &_baseURL, const KURL &_destURL);
00974 
00982   bool authorizeControlModule(const QString &menuId);
00983   
00992   QStringList authorizeControlModules(const QStringList &menuIds);
00993 
00994 
00995   // Same values as ShiftMask etc. in X.h
00996   enum { ShiftModifier = 1<<0,
00997          LockModifier = 1<<1,
00998          ControlModifier = 1<<2,
00999          Modifier1 = 1<<3,
01000          Modifier2 = 1<<4,
01001          Modifier3 = 1<<5,
01002          Modifier4 = 1<<6,
01003          Modifier5 = 1<<7 };
01014   static uint keyboardModifiers();
01015 
01016   // Same values as Button1Mask etc. in X.h
01017   enum { Button1Pressed = 1<<8,
01018          Button2Pressed = 1<<9,
01019          Button3Pressed = 1<<10,
01020          Button4Pressed = 1<<11,
01021          Button5Pressed = 1<<12 };
01031   static uint mouseState();
01032 
01033 
01034 public slots:
01041   void ref();
01042 
01047   void deref();
01048 
01049 protected:
01053   KApplication( bool allowStyles, bool GUIenabled, KInstance* _instance );
01054 
01055 #ifdef Q_WS_X11
01056 
01059   bool x11EventFilter( XEvent * );
01060 
01061   Display *display;
01062 #endif
01063   Atom kipcCommAtom;
01064   int kipcEventMask;
01065 
01067   static KApplication *KApp;
01068   int pArgc;
01069 
01101   void invokeEditSlot( const char *slot );
01102 
01103 private slots:
01104   void dcopFailure(const QString &);
01105   void dcopBlockUserInput( bool );
01106   void x11FilterDestroyed();
01107   void checkAppStartedSlot();
01108 
01109 private:
01110   QString sessionConfigName() const;
01111   KConfig* pSessionConfig; //instance specific application config object
01112   static DCOPClient *s_DCOPClient; // app specific application communication client
01113   static bool s_dcopClientNeedsPostInit;
01114   QString aCaption; // the name for the window title
01115   bool bSessionManagement;
01116   QPixmap aIconPixmap; // BIC (KDE 4) make a pointer, to avoid creating if noGUI
01117   QPixmap aMiniIconPixmap; // BIC (KDE 4) make a pointer, to avoid creating if noGUI
01118   QString aIconName;
01119   QString aMiniIconName;
01120   bool useStyles;
01121   QWidget *smw;
01122 
01123   void init( bool GUIenabled );
01124 
01125   void parseCommandLine( ); // Handle KDE arguments (Using KCmdLineArgs)
01126 
01127   void read_app_startup_id();
01128 
01129   void dcopAutoRegistration();
01130   void dcopClientPostInit();
01131   void initUrlActionRestrictions();
01132 
01133 public:
01137   bool notify(QObject *receiver, QEvent *event);
01138 
01142   int xErrhandler( Display*, void* );
01143 
01147   int xioErrhandler( Display* );
01148 
01152   void iceIOErrorHandler( _IceConn *conn );
01153 
01157   static bool loadedByKdeinit;
01158 
01162   static void startKdeinit();
01163 
01167   enum SettingsCategory { SETTINGS_MOUSE, SETTINGS_COMPLETION, SETTINGS_PATHS,
01168          SETTINGS_POPUPMENU, SETTINGS_QT, SETTINGS_SHORTCUTS };
01169 
01178   static QPalette createApplicationPalette();
01179 
01184   static QPalette createApplicationPalette( KConfig *config, int contrast );
01185 
01193   static void installSigpipeHandler();
01194 
01201   static bool guiEnabled();
01202 
01203 signals:
01210   void kdisplayPaletteChanged();
01211 
01219   void kdisplayStyleChanged();
01220 
01232   void kdisplayFontChanged();
01233 
01239   void appearanceChanged();
01240 
01244   void toolbarAppearanceChanged(int);
01245 
01251   void backgroundChanged(int desk);
01252 
01259   void settingsChanged(int category);
01260 
01265   void iconChanged(int group);
01266 
01276   void kipcMessage(int id, int data);
01277 
01307   void saveYourself();
01308 
01316   void shutDown();
01317 
01318 private:
01319   void propagateSettings(SettingsCategory category);
01320   void kdisplaySetPalette();
01321   void kdisplaySetStyle();
01322   void kdisplaySetFont();
01323   void applyGUIStyle();
01324   static void sigpipeHandler(int);
01325 
01326   int captionLayout;
01327 
01328   KApplication(const KApplication&);
01329   KApplication& operator=(const KApplication&);
01330 protected:
01331   virtual void virtual_hook( int id, void* data );
01332 private:
01333   KApplicationPrivate* d;
01334 };
01335 
01336 
01354 bool checkAccess(const QString& pathname, int mode);
01355 
01356 class KSessionManagedPrivate;
01357 
01374 class KSessionManaged
01375 {
01376 public:
01377   KSessionManaged();
01378   virtual ~KSessionManaged();
01379 
01389   virtual bool saveState( QSessionManager& sm );
01399   virtual bool commitData( QSessionManager& sm );
01400 
01401 protected:
01402   virtual void virtual_hook( int id, void* data );
01403 private:
01404   KSessionManagedPrivate *d;
01405 };
01406 
01407 
01408 #endif
01409 
KDE Logo
This file is part of the documentation for kdecore Library Version 3.2.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sun May 16 22:01:17 2004 by doxygen 1.2.15 written by Dimitri van Heesch, © 1997-2003