home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / kapplication.h < prev    next >
Encoding:
C/C++ Source or Header  |  2006-10-01  |  51.4 KB  |  1,477 lines

  1. /* This file is part of the KDE libraries
  2.     Copyright (C) 1997 Matthias Kalle Dalheimer (kalle@kde.org)
  3.     Copyright (c) 1998, 1999 KDE Team
  4.  
  5.     This library is free software; you can redistribute it and/or
  6.     modify it under the terms of the GNU Library General Public
  7.     License as published by the Free Software Foundation; either
  8.     version 2 of the License, or (at your option) any later version.
  9.  
  10.     This library is distributed in the hope that it will be useful,
  11.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13.     Library General Public License for more details.
  14.  
  15.     You should have received a copy of the GNU Library General Public License
  16.     along with this library; see the file COPYING.LIB.  If not, write to
  17.     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  18.     Boston, MA 02110-1301, USA.
  19. */
  20.  
  21. #ifndef _KAPP_H
  22. #define _KAPP_H
  23.  
  24. // Version macros. Never put this further down.
  25. #include "kdeversion.h"
  26. #include "kdelibs_export.h"
  27.  
  28. class KConfig;
  29. class KCharsets;
  30. class DCOPClient;
  31. class DCOPObject;
  32.  
  33. typedef unsigned long Atom;
  34. #if !defined(Q_WS_X11)
  35. typedef void Display;
  36. #endif
  37.  
  38. #include <qapplication.h>
  39. #include <qpixmap.h>
  40. #include <kinstance.h>
  41.  
  42. struct _IceConn;
  43. class QPopupMenu;
  44. class QStrList;
  45. class KSessionManaged;
  46. class KStyle;
  47. class KURL;
  48.  
  49. #define kapp KApplication::kApplication()
  50.  
  51. class KApplicationPrivate;
  52.  
  53. /**
  54. * Controls and provides information to all KDE applications.
  55. *
  56. * Only one object of this class can be instantiated in a single app.
  57. * This instance is always accessible via the 'kapp' global variable.
  58. * See cut() for an example.
  59. *
  60. * This class provides the following services to all KDE applications.
  61. *
  62. * @li It controls the event queue (see QApplication ).
  63. * @li It provides the application with KDE resources such as
  64. * accelerators, common menu entries, a KConfig object. session
  65. * management events, help invocation etc.
  66. * @li Installs a signal handler for the SIGCHLD signal in order to
  67. * avoid zombie children. If you want to catch this signal yourself or
  68. * don't want it to be caught at all, you have set a new signal handler
  69. * (or SIG_IGN) after KApplication's constructor has run.
  70. * @li Installs an empty signal handler for the SIGPIPE signal using
  71. * installSigpipeHandler(). If you want to catch this signal
  72. * yourself, you have set a new signal handler after KApplication's
  73. * constructor has run.
  74. * @li It can start new services
  75. *
  76. *
  77. * The way a service gets started depends on the 'X-DCOP-ServiceType'
  78. * entry in the desktop file of the service:
  79. *
  80. * There are three possibilities:
  81. * @li X-DCOP-ServiceType=None (default)
  82. *    Always start a new service,
  83. *    don't wait till the service registers with dcop.
  84. * @li X-DCOP-ServiceType=Multi
  85. *    Always start a new service,
  86. *    wait until the service has registered with dcop.
  87. * @li X-DCOP-ServiceType=Unique
  88. *    Only start the service if it isn't already running,
  89. *    wait until the service has registered with dcop.
  90. *
  91. * @short Controls and provides information to all KDE applications.
  92. * @author Matthias Kalle Dalheimer <kalle@kde.org>
  93. */
  94. class KDECORE_EXPORT KApplication : public QApplication, public KInstance
  95. {
  96.  
  97.   Q_OBJECT
  98. public:
  99.   /** Position of the caption (presumably in the application window's
  100.   *   title bar). This enum appears to be unused.
  101.   *
  102.   * @todo Find out if this is used anywhere.
  103.   */
  104.   enum CaptionLayout {
  105.     CaptionAppLast=1 /**< Display the application name last (before document name). */, 
  106.     CaptionAppFirst /**< Display the application name first. */ , 
  107.     CaptionNoApp  /**< Do not display application name at all. */
  108.   };
  109.  
  110.   /**
  111.    * This constructor takes aboutData and command line
  112.    *  arguments from KCmdLineArgs.
  113.    *
  114.    * @param allowStyles Set to false to disable the loading on plugin based
  115.    * styles. This is only useful to applications that do not display a GUI
  116.    * normally. If you do create an application with @p allowStyles set to false
  117.    * it normally runs in the background but under special circumstances
  118.    * displays widgets.  Call enableStyles() before displaying any widgets.
  119.    *
  120.    * @param GUIenabled Set to false to disable all GUI stuff. This implies
  121.    * no styles either.
  122.    */
  123.   KApplication( bool allowStyles=true, bool GUIenabled=true);
  124.  
  125. #ifdef Q_WS_X11
  126.   /**
  127.    * Constructor. Parses command-line arguments. Use this constructor when you
  128.    * you need to use a non-default visual or colormap. 
  129.    *
  130.    * @param display Will be passed to Qt as the X display. The display must be
  131.    * valid and already opened.
  132.    *
  133.    * @param visual A pointer to the X11 visual that should be used by the
  134.    * appliction. Note that only TrueColor visuals are supported on depths
  135.    * greater than 8 bpp. If this parameter is NULL, the default visual will
  136.    * be used instead.
  137.    *
  138.    * @param colormap The colormap that should be used by the application. If
  139.    * this parameter is 0, the default colormap will be used instead.
  140.    *
  141.    * @param allowStyles Set to false to disable the loading on plugin based
  142.    * styles. This is only useful to applications that do not display a GUI
  143.    * normally. If you do create an application with @p allowStyles set to false
  144.    * that normally runs in the background but under special circumstances
  145.    * displays widgets call enableStyles() before displaying any widgets.
  146.    *
  147.    * @since KDE 3.3
  148.    */
  149.   KApplication(Display *display, Qt::HANDLE visual = 0, Qt::HANDLE colormap = 0,
  150.                bool allowStyles=true);
  151.  
  152.   /**
  153.    * Constructor. Parses command-line arguments. Use this constructor to use KApplication
  154.    * in a Motif or Xt program.
  155.    *
  156.    * @param display Will be passed to Qt as the X display. The display must be valid and already
  157.    * opened.
  158.    *
  159.    * @param argc command line argument count
  160.    *
  161.    * @param argv command line argument value(s)
  162.    *
  163.    * @param rAppName application name. Will be used for finding the
  164.    * associated message files and icon files, and as the default
  165.    * registration name for DCOP. This is a mandatory parameter.
  166.    *
  167.    * @param allowStyles Set to false to disable the loading on plugin based
  168.    * styles. This is only useful to applications that do not display a GUI
  169.    * normally. If you do create an application with @p allowStyles set to false
  170.    * that normally runs in the background but under special circumstances
  171.    * displays widgets call enableStyles() before displaying any widgets.
  172.    *
  173.    * @param GUIenabled Set to false to disable all GUI stuff. This implies
  174.    * no styles either.
  175.    */
  176.   KApplication(Display *display, int& argc, char** argv, const QCString& rAppName,
  177.                bool allowStyles=true, bool GUIenabled=true);
  178. #endif
  179.  
  180.   /**
  181.    * @deprecated do not use it at all, it will make your application crash, use KCmdLineArgs
  182.    *
  183.    * Constructor. Parses command-line arguments.
  184.    *
  185.    * @param argc command line argument count
  186.    *
  187.    * @param argv command line argument value(s)
  188.    *
  189.    * @param rAppName application name. Will be used for finding the
  190.    * associated message files and icon files, and as the default
  191.    * registration name for DCOP. This is a mandatory parameter.
  192.    *
  193.    * @param allowStyles Set to false to disable the loading on plugin based
  194.    * styles. This is only useful to applications that do not display a GUI
  195.    * normally. If you do create an application with @p allowStyles set to false
  196.    * that normally runs in the background but under special circumstances
  197.    * displays widgets call enableStyles() before displaying any widgets.
  198.    *
  199.    * @param GUIenabled Set to false to disable all GUI stuff. This implies
  200.    * no styles either.
  201.    */
  202.   // REMOVE FOR KDE 4.0 - using it only gives crashing applications because
  203.   // KCmdLineArgs::init isn't called
  204.  KApplication(int& argc, char** argv,
  205.               const QCString& rAppName, bool allowStyles=true, bool GUIenabled=true) KDE_DEPRECATED;
  206.  
  207.   /**
  208.     * Add Qt and KDE command line options to KCmdLineArgs.
  209.     */
  210.   static void addCmdLineOptions();
  211.  
  212.   virtual ~KApplication();
  213.  
  214.   /**
  215.    * Returns the current application object.
  216.    *
  217.    * This is similar to the global QApplication pointer qApp. It
  218.    * allows access to the single global KApplication object, since
  219.    * more than one cannot be created in the same application. It
  220.    * saves you the trouble of having to pass the pointer explicitly
  221.    * to every function that may require it.
  222.    * @return the current application object
  223.    */
  224.   static KApplication* kApplication() { return KApp; }
  225.  
  226.   /**
  227.    * Returns the application session config object.
  228.    *
  229.    * @return A pointer to the application's instance specific
  230.    * KConfig object.
  231.    * @see KConfig
  232.    */
  233.   KConfig* sessionConfig();
  234.  
  235.   /**
  236.    * Is the application restored from the session manager?
  237.    *
  238.    * @return If true, this application was restored by the session manager.
  239.    *    Note that this may mean the config object returned by
  240.    * sessionConfig() contains data saved by a session closedown.
  241.    * @see sessionConfig()
  242.    */
  243.   bool isRestored() const { return QApplication::isSessionRestored(); }
  244.  
  245.   /**
  246.    * Disables session management for this application.
  247.    *
  248.    * Useful in case  your application is started by the
  249.    * initial "startkde" script.
  250.    */
  251.   void disableSessionManagement();
  252.  
  253.   /**
  254.    * Enables again session management for this application, formerly
  255.    * disabled by calling disableSessionManagement(). You usually
  256.    * shouldn't call this function, as the session management is enabled
  257.    * by default.
  258.    */
  259.   void enableSessionManagement();
  260.  
  261.   /**
  262.    * The possible values for the @p confirm parameter of requestShutDown().
  263.    */
  264.   enum ShutdownConfirm {
  265.     /**
  266.      * Obey the user's confirmation setting.
  267.      */
  268.     ShutdownConfirmDefault = -1,
  269.     /**
  270.      * Don't confirm, shutdown without asking.
  271.      */
  272.     ShutdownConfirmNo = 0,
  273.     /**
  274.      * Always confirm, ask even if the user turned it off.
  275.      */
  276.     ShutdownConfirmYes = 1
  277.   };
  278.  
  279.   /**
  280.    * The possible values for the @p sdtype parameter of requestShutDown().
  281.    */
  282.   enum ShutdownType {
  283.     /**
  284.      * Select previous action or the default if it's the first time.
  285.      */
  286.     ShutdownTypeDefault = -1,
  287.     /**
  288.      * Only log out.
  289.      */
  290.     ShutdownTypeNone = 0,
  291.     /**
  292.      * Log out and reboot the machine.
  293.      */
  294.     ShutdownTypeReboot = 1,
  295.     /**
  296.      * Log out and halt the machine.
  297.      */
  298.     ShutdownTypeHalt = 2
  299.   };
  300.  
  301.   /**
  302.    * The possible values for the @p sdmode parameter of requestShutDown().
  303.    */
  304.   enum ShutdownMode {
  305.     /**
  306.      * Select previous mode or the default if it's the first time.
  307.      */
  308.     ShutdownModeDefault = -1,
  309.     /**
  310.      * Schedule a shutdown (halt or reboot) for the time all active sessions
  311.      * have exited.
  312.      */
  313.     ShutdownModeSchedule = 0,
  314.     /**
  315.      * Shut down, if no sessions are active. Otherwise do nothing.
  316.      */
  317.     ShutdownModeTryNow = 1,
  318.     /**
  319.      * Force shutdown. Kill any possibly active sessions.
  320.      */
  321.     ShutdownModeForceNow = 2,
  322.     /**
  323.      * Pop up a dialog asking the user what to do if sessions are still active.
  324.      */
  325.     ShutdownModeInteractive = 3
  326.   };
  327.  
  328.   /**
  329.    * Asks the session manager to shut the session down.
  330.    *
  331.    * Using @p confirm == ShutdownConfirmYes or @p sdtype != ShutdownTypeDefault or
  332.    * @p sdmode != ShutdownModeDefault causes the use of ksmserver's DCOP
  333.    * interface. The remaining two combinations use the standard XSMP and
  334.    * will work with any session manager compliant with it.
  335.    *
  336.    * @param confirm Whether to ask the user if he really wants to log out.
  337.    * ShutdownConfirm
  338.    * @param sdtype The action to take after logging out. ShutdownType
  339.    * @param sdmode If/When the action should be taken. ShutdownMode
  340.    * @return true on success, false if the session manager could not be
  341.    * contacted.
  342.    */
  343.   bool requestShutDown( ShutdownConfirm confirm = ShutdownConfirmDefault,
  344.                         ShutdownType sdtype = ShutdownTypeDefault,
  345.             ShutdownMode sdmode = ShutdownModeDefault );
  346.  
  347.   /**
  348.    * Propagates the network address of the session manager in the
  349.    * SESSION_MANAGER environment variable so that child processes can
  350.    * pick it up.
  351.    *
  352.    * If SESSION_MANAGER isn't defined yet, the address is searched in
  353.    * $HOME/.KSMserver.
  354.    *
  355.    * This function is called by clients that are started outside the
  356.    * session ( i.e. before ksmserver is started), but want to launch
  357.    * other processes that should participate in the session.  Examples
  358.    * are kdesktop or kicker.
  359.    */
  360.     void propagateSessionManager();
  361.  
  362.     /**
  363.      * Reimplemented for internal purposes, mainly the highlevel
  364.      *  handling of session management with KSessionManaged.
  365.      * @internal
  366.      */
  367.   void commitData( QSessionManager& sm );
  368.  
  369.     /**
  370.      * Reimplemented for internal purposes, mainly the highlevel
  371.      *  handling of session management with KSessionManaged.
  372.      * @internal
  373.      */
  374.   void saveState( QSessionManager& sm );
  375.  
  376.   /**
  377.    * Returns true if the application is currently saving its session
  378.    * data (most probably before KDE logout). This is intended for use
  379.    * mainly in KMainWindow::queryClose() and KMainWindow::queryExit().
  380.    *
  381.    * @see KMainWindow::queryClose
  382.    * @see KMainWindow::queryExit
  383.    * @since 3.1.1
  384.    */
  385.   bool sessionSaving() const;
  386.  
  387.   /**
  388.    * Returns a pointer to a DCOPClient for the application.
  389.    * If a client does not exist yet, it is created when this
  390.    * function is called.
  391.    * @return the DCOPClient for the application
  392.    */
  393.   static DCOPClient *dcopClient();
  394.  
  395.   /**
  396.    * Disable automatic dcop registration
  397.    * Must be called before creating a KApplication instance to have an effect.
  398.    */
  399.   static void disableAutoDcopRegistration();
  400.  
  401.   /**
  402.    * Returns a QPixmap with the application icon.
  403.    * @return the application icon
  404.    */
  405.   QPixmap icon() const;
  406.  
  407.   /**
  408.    * Returns the name of the application icon.
  409.    * @return the icon's name
  410.    */
  411.   QString iconName() const;
  412.  
  413.   /**
  414.    * Returns the mini-icon for the application as a QPixmap.
  415.    * @return the application's mini icon
  416.    */
  417.   QPixmap miniIcon() const;
  418.  
  419.   /**
  420.    * Returns the name of the mini-icon for the application.
  421.    * @return the mini icon's name
  422.    */
  423.   QString miniIconName() const;
  424.  
  425.   /**
  426.    *  Sets the top widget of the application.
  427.    *  This means basically applying the right window caption and
  428.    *  icon. An application may have several top widgets. You don't
  429.    *  need to call this function manually when using KMainWindow.
  430.    *
  431.    *  @param topWidget A top widget of the application.
  432.    *
  433.    *  @see icon(), caption()
  434.    **/
  435.   void setTopWidget( QWidget *topWidget );
  436.  
  437.   /**
  438.    * Invokes the KHelpCenter HTML help viewer from docbook sources.
  439.    *
  440.    * @param anchor      This has to be a defined anchor in your
  441.    *                    docbook sources. If empty the main index
  442.    *                    is loaded
  443.    * @param appname     This allows you to show the help of another
  444.    *                    application. If empty the current name() is
  445.    *                    used
  446.    * @param startup_id for app startup notification, "0" for none,
  447.    *           "" ( empty string ) is the default
  448.    */
  449.   void invokeHelp( const QString& anchor,
  450.                    const QString& appname,
  451.                    const QCString& startup_id ) const;
  452.  
  453.   // KDE4 merge with above with startup_id = ""
  454.   void invokeHelp( const QString& anchor = QString::null,
  455.                    const QString& appname = QString::null ) const;
  456.  
  457.   /**
  458.    * @deprecated
  459.    * Invoke the khelpcenter HTML help viewer from HTML sources.
  460.    * Please use invokeHelp() instead.
  461.    *
  462.    * @param aFilename  The filename that is to be loaded. Its
  463.    *                   location is computed automatically
  464.    *                   according to the KFSSTND.  If @p aFilename
  465.    *                   is empty, the logical appname with .html
  466.    *                   appended to it is used.
  467.    * @param aTopic     This allows context-sensitive help. Its
  468.    *                   value will be appended to the filename,
  469.    *                   prefixed with a "#" (hash) character.
  470.    */
  471.   void invokeHTMLHelp( const QString& aFilename, const QString& aTopic = QString::null ) const KDE_DEPRECATED;
  472.  
  473.   /**
  474.    * Convenience method; invokes the standard email application.
  475.    *
  476.    * @param address The destination address
  477.    * @param subject Subject string. Can be QString::null.
  478.    * @param startup_id for app startup notification, "0" for none,
  479.    *           "" ( empty string ) is the default
  480.    */
  481.   void invokeMailer( const QString &address, const QString &subject, const QCString& startup_id );
  482.   // KDE4 merge with above with startup_id = ""
  483.   void invokeMailer( const QString &address, const QString &subject );
  484.  
  485.   /**
  486.    * Invokes the standard email application.
  487.    *
  488.    * @param mailtoURL A mailto URL.
  489.    * @param startup_id for app startup notification, "0" for none,
  490.    *           "" ( empty string ) is the default
  491.    * @param allowAttachments whether attachments specified in mailtoURL should be honoured.
  492.                The default is false; do not honour requests for attachments.
  493.    */
  494.   void invokeMailer( const KURL &mailtoURL, const QCString& startup_id, bool allowAttachments );
  495.   // KDE4 merge with above with allowAttachments = false
  496.   void invokeMailer( const KURL &mailtoURL, const QCString& startup_id );
  497.   // KDE4 merge with above with startup_id = ""
  498.   void invokeMailer( const KURL &mailtoURL );
  499.  
  500.   /**
  501.    * Convenience method; invokes the standard email application.
  502.    *
  503.    * All parameters are optional.
  504.    *
  505.    * @param to          The destination address.
  506.    * @param cc          The Cc field
  507.    * @param bcc         The Bcc field
  508.    * @param subject     Subject string
  509.    * @param body        A string containing the body of the mail (exclusive with messageFile)
  510.    * @param messageFile A file (URL) containing the body of the mail (exclusive with body) - currently unsupported
  511.    * @param attachURLs  List of URLs to be attached to the mail.
  512.    * @param startup_id for app startup notification, "0" for none,
  513.    *           "" ( empty string ) is the default
  514.    */
  515.   void invokeMailer(const QString &to, const QString &cc, const QString &bcc,
  516.                     const QString &subject, const QString &body,
  517.                     const QString &messageFile, const QStringList &attachURLs,
  518.                     const QCString& startup_id );
  519.   // KDE4 merge with above with startup_id = ""
  520.   void invokeMailer(const QString &to, const QString &cc, const QString &bcc,
  521.                     const QString &subject, const QString &body,
  522.                     const QString &messageFile = QString::null, const QStringList &attachURLs = QStringList());
  523.  
  524. public slots:
  525.   /**
  526.    * Invokes the standard browser.
  527.    * Note that you should only do this when you know for sure that the browser can
  528.    * handle the URL (i.e. its mimetype). In doubt, if the URL can point to an image
  529.    * or anything else than directory or HTML, prefer to use new KRun( url ).
  530.    *
  531.    * @param url The destination address
  532.    * @param startup_id for app startup notification, "0" for none,
  533.    *           "" ( empty string ) is the default
  534.    */
  535.   void invokeBrowser( const QString &url, const QCString& startup_id );
  536.   // KDE4 merge with above with startup_id = ""
  537.   /**
  538.   * Invoke the standard browser. Uses a @p startup_id of "" (empty)
  539.   * and is otherwise the same as the above function.
  540.   */
  541.   void invokeBrowser( const QString &url );
  542.  
  543.   /**
  544.    * If the widget with focus provides a cut() slot, call that slot.  Thus for a
  545.    * simple application cut can be implemented as:
  546.    * \code
  547.    * KStdAction::cut( kapp, SLOT( cut() ), actionCollection() );
  548.    * \endcode
  549.    */
  550.   void cut();
  551.  
  552.   /**
  553.    * If the widget with focus provides a copy() slot, call that slot.  Thus for a
  554.    * simple application copy can be implemented as:
  555.    * \code
  556.    * KStdAction::copy( kapp, SLOT( copy() ), actionCollection() );
  557.    * \endcode
  558.    */
  559.   void copy();
  560.  
  561.   /**
  562.    * If the widget with focus provides a paste() slot, call that slot.  Thus for a
  563.    * simple application copy can be implemented as:
  564.    * \code
  565.    * KStdAction::paste( kapp, SLOT( paste() ), actionCollection() );
  566.    * \endcode
  567.    */
  568.   void paste();
  569.  
  570.   /**
  571.    * If the widget with focus provides a clear() slot, call that slot.  Thus for a
  572.    * simple application clear() can be implemented as:
  573.    * \code
  574.    * new KAction( i18n( "Clear" ), "editclear", 0, kapp, SLOT( clear() ), actionCollection(), "clear" );
  575.    * \endcode
  576.    *
  577.    * Note that for some widgets, this may not provide the intended bahavior.  For
  578.    * example if you make use of the code above and a KListView has the focus, clear()
  579.    * will clear all of the items in the list.  If this is not the intened behavior
  580.    * and you want to make use of this slot, you can subclass KListView and reimplement
  581.    * this slot.  For example the following code would implement a KListView without this
  582.    * behavior:
  583.    *
  584.    * \code
  585.    * class MyListView : public KListView {
  586.    *   Q_OBJECT
  587.    * public:
  588.    *   MyListView( QWidget * parent = 0, const char * name = 0, WFlags f = 0 ) : KListView( parent, name, f ) {}
  589.    *   virtual ~MyListView() {}
  590.    * public slots:
  591.    *   virtual void clear() {}
  592.    * };
  593.    * \endcode
  594.    */
  595.   void clear();
  596.  
  597.   /**
  598.    * If the widget with focus provides a selectAll() slot, call that slot.  Thus for a
  599.    * simple application select all can be implemented as:
  600.    * \code
  601.    * KStdAction::selectAll( kapp, SLOT( selectAll() ), actionCollection() );
  602.    * \endcode
  603.    */
  604.   void selectAll();
  605.  
  606. public:
  607.   /**
  608.    * Returns the DCOP name of the service launcher. This will be something like
  609.    * klaucher_$host_$uid.
  610.    * @return the name of the service launcher
  611.    */
  612.   static QCString launcher();
  613.  
  614.   /**
  615.    * Starts a service based on the (translated) name of the service.
  616.    * E.g. "Web Browser"
  617.    *
  618.    * @param _name the name of the service
  619.    * @param URL if not empty this URL is passed to the service
  620.    * @param error On failure, @p error contains a description of the error
  621.    *         that occurred. If the pointer is 0, the argument will be
  622.    *         ignored
  623.    * @param dcopService On success, @p dcopService contains the DCOP name
  624.    *         under which this service is available. If empty, the service does
  625.    *         not provide DCOP services. If the pointer is 0 the argument
  626.    *         will be ignored
  627.    * @param pid On success, the process id of the new service will be written
  628.    *        here. If the pointer is 0, the argument will be ignored.
  629.    * @param startup_id for app startup notification, "0" for none,
  630.    *           "" ( empty string ) is the default
  631.    * @param noWait if set, the function does not wait till the service is running.
  632.    * @return an error code indicating success (== 0) or failure (> 0).
  633.    */
  634.   static int startServiceByName( const QString& _name, const QString &URL,
  635.                 QString *error=0, QCString *dcopService=0, int *pid=0, const QCString &startup_id = "", bool noWait = false );
  636.  
  637.   /**
  638.    * Starts a service based on the (translated) name of the service.
  639.    * E.g. "Web Browser"
  640.    *
  641.    * @param _name the name of the service
  642.    * @param URLs if not empty these URLs will be passed to the service
  643.    * @param error On failure, @p error contains a description of the error
  644.    *         that occurred. If the pointer is 0, the argument will be
  645.    *         ignored
  646.    * @param dcopService On success, @p dcopService contains the DCOP name
  647.    *         under which this service is available. If empty, the service does
  648.    *         not provide DCOP services. If the pointer is 0 the argument
  649.    *         will be ignored
  650.    * @param pid On success, the process id of the new service will be written
  651.    *        here. If the pointer is 0, the argument will be ignored.
  652.    * @param startup_id for app startup notification, "0" for none,
  653.    *           "" ( empty string ) is the default
  654.    * @param noWait if set, the function does not wait till the service is running.
  655.    * @return an error code indicating success (== 0) or failure (> 0).
  656.    */
  657.   static int startServiceByName( const QString& _name, const QStringList &URLs=QStringList(),
  658.                 QString *error=0, QCString *dcopService=0, int *pid=0, const QCString &startup_id = "", bool noWait = false );
  659.  
  660.   /**
  661.    * Starts a service based on the desktop path of the service.
  662.    * E.g. "Applications/konqueror.desktop" or "/home/user/bla/myfile.desktop"
  663.    *
  664.    * @param _name the path of the desktop file
  665.    * @param URL if not empty this URL is passed to the service
  666.    * @param error On failure, @p error contains a description of the error
  667.    *         that occurred. If the pointer is 0, the argument will be
  668.    *         ignored
  669.    * @param dcopService On success, @p dcopService contains the DCOP name
  670.    *         under which this service is available. If empty, the service does
  671.    *         not provide DCOP services. If the pointer is 0 the argument
  672.    *         will be ignored
  673.    * @param pid On success, the process id of the new service will be written
  674.    *        here. If the pointer is 0, the argument will be ignored.
  675.    * @param startup_id for app startup notification, "0" for none,
  676.    *           "" ( empty string ) is the default
  677.    * @param noWait if set, the function does not wait till the service is running.
  678.    * @return an error code indicating success (== 0) or failure (> 0).
  679.    */
  680.   static int startServiceByDesktopPath( const QString& _name, const QString &URL,
  681.                 QString *error=0, QCString *dcopService=0, int *pid = 0, const QCString &startup_id = "", bool noWait = false );
  682.  
  683.   /**
  684.    * Starts a service based on the desktop path of the service.
  685.    * E.g. "Applications/konqueror.desktop" or "/home/user/bla/myfile.desktop"
  686.    *
  687.    * @param _name the path of the desktop file
  688.    * @param URLs if not empty these URLs will be passed to the service
  689.    * @param error On failure, @p error contains a description of the error
  690.    *         that occurred. If the pointer is 0, the argument will be
  691.    *         ignored
  692.    * @param dcopService On success, @p dcopService contains the DCOP name
  693.    *         under which this service is available. If empty, the service does
  694.    *         not provide DCOP services. If the pointer is 0 the argument
  695.    *         will be ignored
  696.    * @param pid On success, the process id of the new service will be written
  697.    *        here. If the pointer is 0, the argument will be ignored.
  698.    * @param startup_id for app startup notification, "0" for none,
  699.    *           "" ( empty string ) is the default
  700.    * @param noWait if set, the function does not wait till the service is running.
  701.    * @return an error code indicating success (== 0) or failure (> 0).
  702.    */
  703.   static int startServiceByDesktopPath( const QString& _name, const QStringList &URLs=QStringList(),
  704.                 QString *error=0, QCString *dcopService=0, int *pid = 0, const QCString &startup_id = "", bool noWait = false );
  705.  
  706.   /**
  707.    * Starts a service based on the desktop name of the service.
  708.    * E.g. "konqueror"
  709.    *
  710.    * @param _name the desktop name of the service
  711.    * @param URL if not empty this URL is passed to the service
  712.    * @param error On failure, @p error contains a description of the error
  713.    *         that occurred. If the pointer is 0, the argument will be
  714.    *         ignored
  715.    * @param dcopService On success, @p dcopService contains the DCOP name
  716.    *         under which this service is available. If empty, the service does
  717.    *         not provide DCOP services. If the pointer is 0 the argument
  718.    *         will be ignored
  719.    * @param pid On success, the process id of the new service will be written
  720.    *        here. If the pointer is 0, the argument will be ignored.
  721.    * @param startup_id for app startup notification, "0" for none,
  722.    *           "" ( empty string ) is the default
  723.    * @param noWait if set, the function does not wait till the service is running.
  724.    * @return an error code indicating success (== 0) or failure (> 0).
  725.    */
  726.   static int startServiceByDesktopName( const QString& _name, const QString &URL,
  727.                 QString *error=0, QCString *dcopService=0, int *pid = 0, const QCString &startup_id = "", bool noWait = false );
  728.  
  729.   /**
  730.    * Starts a service based on the desktop name of the service.
  731.    * E.g. "konqueror"
  732.    *
  733.    * @param _name the desktop name of the service
  734.    * @param URLs if not empty these URLs will be passed to the service
  735.    * @param error On failure, @p error contains a description of the error
  736.    *         that occurred. If the pointer is 0, the argument will be
  737.    *         ignored
  738.    * @param dcopService On success, @p dcopService contains the DCOP name
  739.    *         under which this service is available. If empty, the service does
  740.    *         not provide DCOP services. If the pointer is 0 the argument
  741.    *         will be ignored
  742.    * @param pid On success, the process id of the new service will be written
  743.    *        here. If the pointer is 0, the argument will be ignored.
  744.    * @param startup_id for app startup notification, "0" for none,
  745.    *           "" ( empty string ) is the default
  746.    * @param noWait if set, the function does not wait till the service is running.
  747.    * @return an error code indicating success (== 0) or failure (> 0).
  748.    */
  749.   static int startServiceByDesktopName( const QString& _name, const QStringList &URLs=QStringList(),
  750.                 QString *error=0, QCString *dcopService=0, int *pid = 0, const QCString &startup_id = "", bool noWait = false );
  751.  
  752.   /**
  753.    * Starts a program via kdeinit.
  754.    *
  755.    * program name and arguments are converted to according to the
  756.    * local encoding and passed as is to kdeinit.
  757.    *
  758.    * @param name Name of the program to start
  759.    * @param args Arguments to pass to the program
  760.    * @param error On failure, @p error contains a description of the error
  761.    *         that occurred. If the pointer is 0, the argument will be
  762.    *         ignored
  763.    * @param pid On success, the process id of the new service will be written
  764.    *        here. If the pointer is 0, the argument will be ignored.
  765.    * @param startup_id for app startup notification, "0" for none,
  766.    *           "" ( empty string ) is the default
  767.    * @return an error code indicating success (== 0) or failure (> 0).
  768.    */
  769.   static int kdeinitExec( const QString& name, const QStringList &args,
  770.                 QString *error, int *pid, const QCString& startup_id );
  771.   // KDE4 merge with above with startup_id = ""
  772.   static int kdeinitExec( const QString& name, const QStringList &args=QStringList(),
  773.                 QString *error=0, int *pid = 0 );
  774.  
  775.   /**
  776.    * Starts a program via kdeinit and wait for it to finish.
  777.    *
  778.    * Like kdeinitExec(), but it waits till the program is finished.
  779.    * As such it behaves similar to the system(...) function.
  780.    *
  781.    * @param name Name of the program to start
  782.    * @param args Arguments to pass to the program
  783.    * @param error On failure, @p error contains a description of the error
  784.    *         that occurred. If the pointer is 0, the argument will be
  785.    *         ignored
  786.    * @param pid On success, the process id of the new service will be written
  787.    *        here. If the pointer is 0, the argument will be ignored.
  788.    * @param startup_id for app startup notification, "0" for none,
  789.    *           "" ( empty string ) is the default
  790.    * @return an error code indicating success (== 0) or failure (> 0).
  791.    */
  792.   static int kdeinitExecWait( const QString& name, const QStringList &args,
  793.                 QString *error, int *pid, const QCString& startup_id );
  794.   // KDE4 merge with above with startup_id = ""
  795.   static int kdeinitExecWait( const QString& name, const QStringList &args=QStringList(),
  796.                 QString *error=0, int *pid = 0 );
  797.  
  798.   /**
  799.    * Returns a text for the window caption.
  800.    *
  801.    * This may be set by
  802.    * "-caption", otherwise it will be equivalent to the name of the
  803.    * executable.
  804.    * @return the text for the window caption
  805.    */
  806.   QString caption() const;
  807.  
  808.   /**
  809.    * @deprecated
  810.    */
  811.   KDE_DEPRECATED KStyle* kstyle() const { return 0; }
  812.  
  813.   /**
  814.    * Builds a caption that contains the application name along with the
  815.    * userCaption using a standard layout.
  816.    *
  817.    * To make a compliant caption
  818.    * for your window, simply do: @p setCaption(kapp->makeStdCaption(yourCaption));
  819.    *
  820.    * @param userCaption The caption string you want to display in the
  821.    * window caption area. Do not include the application name!
  822.    * @param withAppName Indicates that the method shall include or ignore
  823.    * the application name when making the caption string. You are not
  824.    * compliant if you set this to @p false.
  825.    * @param modified If true, a 'modified' sign will be included in the
  826.    * returned string. This is useful when indicating that a file is
  827.    * modified, i.e., it contains data that has not been saved.
  828.    * @return the created caption
  829.    */
  830.   QString makeStdCaption( const QString &userCaption,
  831.                           bool withAppName=true, bool modified=false ) const;
  832.  
  833.   /**
  834.    * Get a file name in order to make a temporary copy of your document.
  835.    *
  836.    * @param pFilename The full path to the current file of your
  837.    * document.
  838.    * @return A new filename for auto-saving.
  839.    */
  840.   QString tempSaveName( const QString& pFilename ) const;
  841.  
  842.   /**
  843.    * Check whether  an auto-save file exists for the document you want to
  844.    * open.
  845.    *
  846.    * @param pFilename The full path to the document you want to open.
  847.    * @param bRecover  This gets set to true if there was a recover
  848.    * file.
  849.    * @return The full path of the file to open.
  850.    */
  851.   QString checkRecoverFile( const QString& pFilename, bool& bRecover ) const;
  852.  
  853. #ifdef Q_WS_X11
  854.   /**
  855.    * Get the X11 display
  856.    * @return the X11 Display
  857.    */
  858.   Display *getDisplay() { return display; }
  859. #endif
  860.  
  861.   /**
  862.    * Enables style plugins.
  863.    *
  864.    * This is useful only to applications that normally
  865.    * do not display a GUI and create the KApplication with
  866.    * allowStyles set to false.
  867.    */
  868.   void enableStyles();
  869.  
  870.   /**
  871.    * Disables style plugins.
  872.    *
  873.    * Current style plugins do not get unloaded.
  874.    *
  875.    * This is only useful when used in combination with enableStyles().
  876.    */
  877.   void disableStyles();
  878.  
  879.   /**
  880.    *  Installs widget filter as global X11 event filter.
  881.    *
  882.    * The widget
  883.    *  filter receives XEvents in its standard QWidget::x11Event() function.
  884.    *
  885.    *  Warning: Only do this when absolutely necessary. An installed X11 filter
  886.    *  can slow things down.
  887.    **/
  888.   void installX11EventFilter( QWidget* filter );
  889.  
  890.   /**
  891.    * Removes global X11 event filter previously installed by
  892.    * installX11EventFilter().
  893.    */
  894.   void removeX11EventFilter( const QWidget* filter );
  895.  
  896.   /**
  897.    * Generates a uniform random number.
  898.    * @return A truly unpredictable number in the range [0, RAND_MAX)
  899.    */
  900.   static int random();
  901.  
  902.   /**
  903.    * Generates a random string.  It operates in the range [A-Za-z0-9]
  904.    * @param length Generate a string of this length.
  905.    * @return the random string
  906.    */
  907.   static QString randomString(int length);
  908.  
  909.   /**
  910.    * Adds a message type to the KIPC event mask. You can only add "system
  911.    * messages" to the event mask. These are the messages with id < 32.
  912.    * Messages with id >= 32 are user messages.
  913.    * @param id The message id. See KIPC::Message.
  914.    * @see KIPC
  915.    * @see removeKipcEventMask()
  916.    * @see kipcMessage()
  917.    */
  918.   void addKipcEventMask(int id);
  919.  
  920.   /**
  921.    * Removes a message type from the KIPC event mask. This message will
  922.    * not be handled anymore.
  923.    * @param id The message id.
  924.    * @see KIPC
  925.    * @see addKipcEventMask()
  926.    * @see kipcMessage()
  927.    */
  928.   void removeKipcEventMask(int id);
  929.  
  930.   /**
  931.    * Returns the app startup notification identifier for this running
  932.    * application.
  933.    * @return the startup notification identifier
  934.    */
  935.   QCString startupId() const;
  936.  
  937.   /**
  938.    * @internal
  939.    * Sets a new value for the application startup notification window property for newly
  940.    * created toplevel windows. 
  941.    * @param startup_id the startup notification identifier
  942.    * @see KStartupInfo::setNewStartupId
  943.    */
  944.   void setStartupId( const QCString& startup_id );
  945.  
  946.   /**
  947.    * Updates the last user action timestamp to the given time, or to the current time,
  948.    * if 0 is given. Do not use unless you're really sure what you're doing.
  949.    * Consult focus stealing prevention section in kdebase/kwin/README.
  950.    * @since 3.2
  951.    */
  952.   void updateUserTimestamp( unsigned long time = 0 );
  953.   
  954.   /**
  955.    * Returns the last user action timestamp or 0 if no user activity has taken place yet.
  956.    * @since 3.2.3
  957.    * @see updateuserTimestamp
  958.    */
  959.   unsigned long userTimestamp() const;
  960.  
  961.   /**
  962.    * Updates the last user action timestamp in the application registered to DCOP with dcopId
  963.    * to the given time, or to this application's user time, if 0 is given.
  964.    * Use before causing user interaction in the remote application, e.g. invoking a dialog
  965.    * in the application using a DCOP call.
  966.    * Consult focus stealing prevention section in kdebase/kwin/README.
  967.    * @since 3.3
  968.    */
  969.   void updateRemoteUserTimestamp( const QCString& dcopId, unsigned long time = 0 );
  970.   
  971.     /**
  972.     * Returns the argument to --geometry if any, so the geometry can be set
  973.     * wherever necessary
  974.     * @return the geometry argument, or QString::null if there is none
  975.     */
  976.   QString geometryArgument() const;
  977.  
  978.   /**
  979.    * Install a Qt SQL property map with entries for all KDE widgets
  980.    * Call this in any application using KDE widgets in QSqlForm or QDataView.
  981.    */
  982.   void installKDEPropertyMap();
  983.  
  984.   /**
  985.    * Returns whether a certain action is authorized
  986.    * @param genericAction The name of a generic  action
  987.    * @return true if the action is authorized
  988.    */
  989.   bool authorize(const QString &genericAction);
  990.  
  991.   /**
  992.    * Returns whether a certain KAction is authorized.
  993.    *
  994.    * @param action The name of a KAction action. The name is prepended
  995.    * with "action/" before being passed to authorize()
  996.    * @return true if the KAction is authorized
  997.    */
  998.   bool authorizeKAction(const char *action);
  999.  
  1000.   /**
  1001.    * Returns whether a certain URL related action is authorized.
  1002.    *
  1003.    * @param action The name of the action. Known actions are
  1004.    * list (may be listed (e.g. in file selection dialog)),
  1005.    * link (may be linked to),
  1006.    * open (may open) and
  1007.    * redirect (may be redirected to)
  1008.    * @param baseURL The url where the action originates from
  1009.    * @param destURL The object of the action
  1010.    * @return true when the action is authorized, false otherwise.
  1011.    * @since 3.1
  1012.    */
  1013.   bool authorizeURLAction(const QString &action, const KURL &baseURL, const KURL &destURL);
  1014.  
  1015.   /**
  1016.    * Allow a certain URL action. This can be useful if your application
  1017.    * needs to ensure access to an application specific directory that may 
  1018.    * otherwise be subject to KIOSK restrictions.
  1019.    * @param action The name of the action.
  1020.    * @param _baseURL The url where the action originates from
  1021.    * @param _destURL The object of the action
  1022.    * @since 3.2
  1023.    */
  1024.   void allowURLAction(const QString &action, const KURL &_baseURL, const KURL &_destURL);
  1025.  
  1026.   /**
  1027.    * Returns whether access to a certain control module is authorized.
  1028.    *
  1029.    * @param menuId identifying the control module, e.g. kde-mouse.desktop
  1030.    * @return true if access to the module is authorized, false otherwise.
  1031.    * @since 3.2
  1032.    */
  1033.   bool authorizeControlModule(const QString &menuId);
  1034.   
  1035.   /**
  1036.    * Returns whether access to a certain control modules is authorized.
  1037.    *
  1038.    * @param menuIds list of menu-ids of control module, 
  1039.    * an example of a menu-id is kde-mouse.desktop.
  1040.    * @return Those control modules for which access has been authorized.
  1041.    * @since 3.2
  1042.    */
  1043.   QStringList authorizeControlModules(const QStringList &menuIds);
  1044.  
  1045.   /**
  1046.    * Returns the state of the currently pressed keyboard modifiers (e.g. shift, control, etc.)
  1047.    * and mouse buttons, similarly to QKeyEvent::state() and QMouseEvent::state().
  1048.    * You usually should simply use the information provided by QKeyEvent and QMouseEvent,
  1049.    * but it can be useful to query for the status of the modifiers at another moment
  1050.    * (e.g. some KDE apps do that upon a drop event).
  1051.    * @return the keyboard modifiers and mouse buttons state
  1052.    * @since 3.4
  1053.    */
  1054.   static ButtonState keyboardMouseState();
  1055.  
  1056.   // Same values as ShiftMask etc. in X.h
  1057.   enum { ShiftModifier = 1<<0,
  1058.          LockModifier = 1<<1,
  1059.          ControlModifier = 1<<2,
  1060.          Modifier1 = 1<<3,
  1061.          Modifier2 = 1<<4,
  1062.          Modifier3 = 1<<5,
  1063.          Modifier4 = 1<<6,
  1064.          Modifier5 = 1<<7 };
  1065.   /**
  1066.    * @deprecated Use keyboardMouseState()
  1067.    * @since 3.1
  1068.    */
  1069.   static uint keyboardModifiers() KDE_DEPRECATED;
  1070.  
  1071.   /** @deprecated Same values as Button1Mask etc. in X.h */
  1072.   enum { Button1Pressed = 1<<8,
  1073.          Button2Pressed = 1<<9,
  1074.          Button3Pressed = 1<<10,
  1075.          Button4Pressed = 1<<11,
  1076.          Button5Pressed = 1<<12 };
  1077.   /**
  1078.    * @deprecated Use keyboardMouseState()
  1079.    * @since 3.1
  1080.    */
  1081.   static uint mouseState() KDE_DEPRECATED;
  1082.  
  1083.  
  1084. public slots:
  1085.   /**
  1086.    * Tells KApplication about one more operation that should be finished
  1087.    * before the application exits. The standard behavior is to exit on the
  1088.    * "last window closed" event, but some events should outlive the last window closed
  1089.    * (e.g. a file copy for a file manager, or 'compacting folders on exit' for a mail client).
  1090.    */
  1091.   void ref();
  1092.  
  1093.   /**
  1094.    * Tells KApplication that one operation such as those described in ref() just finished.
  1095.    * The application exits if the counter is back to 0.
  1096.    */
  1097.   void deref();
  1098.  
  1099. protected:
  1100.   /**
  1101.    * @internal Used by KUniqueApplication
  1102.    */
  1103.   KApplication( bool allowStyles, bool GUIenabled, KInstance* _instance );
  1104.  
  1105. #ifdef Q_WS_X11
  1106.   /**
  1107.    * @internal Used by KUniqueApplication
  1108.    */
  1109.   KApplication( Display *display, Qt::HANDLE visual, Qt::HANDLE colormap,
  1110.           bool allowStyles, KInstance* _instance );
  1111.  
  1112.   /**
  1113.    * Used to catch X11 events
  1114.    */
  1115.   bool x11EventFilter( XEvent * );
  1116.  
  1117.   Display *display;
  1118. #endif
  1119.   Atom kipcCommAtom;
  1120.   int kipcEventMask;
  1121.  
  1122.   /// Current application object.
  1123.   static KApplication *KApp;
  1124.   int pArgc;
  1125.  
  1126.   /**
  1127.    * This method is used internally to determine which edit slots are implemented
  1128.    * by the widget that has the focus, and to invoke those slots if available.
  1129.    *
  1130.    * @param slot is the slot as returned using the SLOT() macro, for example SLOT( cut() )
  1131.    *
  1132.    * This method can be used in KApplication subclasses to implement application wide
  1133.    * edit actions not supported by the KApplication class.  For example (in your subclass):
  1134.    *
  1135.    * \code
  1136.    * void MyApplication::deselect()
  1137.    * {
  1138.    *   invokeEditSlot( SLOT( deselect() ) );
  1139.    * }
  1140.    * \endcode
  1141.    *
  1142.    * Now in your application calls to MyApplication::deselect() will call this slot on the
  1143.    * focused widget if it provides this slot.  You can combine this with KAction with:
  1144.    *
  1145.    * \code
  1146.    * KStdAction::deselect( static_cast<MyApplication *>( kapp ), SLOT( cut() ), actionCollection() );
  1147.    * \endcode
  1148.    *
  1149.    * @see cut()
  1150.    * @see copy()
  1151.    * @see paste()
  1152.    * @see clear()
  1153.    * @see selectAll()
  1154.    *
  1155.    * @since 3.2
  1156.    */
  1157.   void invokeEditSlot( const char *slot );
  1158.  
  1159. private slots:
  1160.   void dcopFailure(const QString &);
  1161.   void dcopBlockUserInput( bool );
  1162.   void x11FilterDestroyed();
  1163.   void checkAppStartedSlot();
  1164.  
  1165. private:
  1166.   QString sessionConfigName() const;
  1167.   KConfig* pSessionConfig; //instance specific application config object
  1168.   static DCOPClient *s_DCOPClient; // app specific application communication client
  1169.   static bool s_dcopClientNeedsPostInit;
  1170.   QString aCaption; // the name for the window title
  1171.   bool bSessionManagement;
  1172.   struct oldPixmapType { QPixmap a, b; };
  1173.   mutable union {
  1174.     struct {
  1175.       QPixmap *icon, *miniIcon;
  1176.     } pm;
  1177.     char unused[sizeof(oldPixmapType)];
  1178.   } aIconPixmap; // KDE4: remove me
  1179.   QString aIconName;
  1180.   QString aMiniIconName;
  1181.   bool useStyles;
  1182.   QWidget *smw;
  1183.  
  1184.   void init( bool GUIenabled );
  1185.  
  1186.   void parseCommandLine( ); // Handle KDE arguments (Using KCmdLineArgs)
  1187.  
  1188.   void read_app_startup_id();
  1189.  
  1190.   void dcopAutoRegistration();
  1191.   void dcopClientPostInit();
  1192.   void initUrlActionRestrictions();
  1193.  
  1194. public:
  1195.   /**
  1196.    * @internal
  1197.    */
  1198.   bool notify(QObject *receiver, QEvent *event);
  1199.  
  1200.   /**
  1201.       @internal
  1202.     */
  1203.   int xErrhandler( Display*, void* );
  1204.  
  1205.   /**
  1206.       @internal
  1207.     */
  1208.   int xioErrhandler( Display* );
  1209.  
  1210.   /**
  1211.    * @internal
  1212.    */
  1213.   void iceIOErrorHandler( _IceConn *conn );
  1214.  
  1215.   /**
  1216.    * @internal
  1217.    */
  1218.   static bool loadedByKdeinit;
  1219.  
  1220.   /**
  1221.    * @internal
  1222.    */
  1223.   static void startKdeinit();
  1224.  
  1225.   /**
  1226.    * Valid values for the settingsChanged signal
  1227.    */
  1228.   enum SettingsCategory { SETTINGS_MOUSE, SETTINGS_COMPLETION, SETTINGS_PATHS,
  1229.          SETTINGS_POPUPMENU, SETTINGS_QT, SETTINGS_SHORTCUTS };
  1230.  
  1231.   /**
  1232.    * Used to obtain the QPalette that will be used to set the application palette.
  1233.    *
  1234.    * This is only useful for configuration modules such as krdb and should not be
  1235.    * used in normal circumstances.
  1236.    * @return the QPalette
  1237.    * @since 3.1
  1238.    */
  1239.   static QPalette createApplicationPalette();
  1240.  
  1241.   /**
  1242.    * @internal
  1243.    * Raw access for use by KDM.
  1244.    */
  1245.   static QPalette createApplicationPalette( KConfig *config, int contrast );
  1246.  
  1247.   /**
  1248.    * Installs a handler for the SIGPIPE signal. It is thrown when you write to
  1249.    * a pipe or socket that has been closed.
  1250.    * The handler is installed automatically in the constructor, but you may
  1251.    * need it if your application or component does not have a KApplication
  1252.    * instance.
  1253.    */
  1254.   static void installSigpipeHandler();
  1255.  
  1256.   /**
  1257.    * @internal
  1258.    * Whether widgets can be used. 
  1259.    *
  1260.    * @since 3.2
  1261.    */
  1262.   static bool guiEnabled();
  1263.  
  1264. signals:
  1265.   /**
  1266.    * Emitted when KApplication has changed its palette due to a KControl request.
  1267.    *
  1268.    * Normally, widgets will update their palette automatically, but you
  1269.    * should connect to this to program special behavior.
  1270.    */
  1271.   void kdisplayPaletteChanged();
  1272.  
  1273.   /**
  1274.    * Emitted when KApplication has changed its GUI style in response to a KControl request.
  1275.    *
  1276.    * Normally, widgets will update their styles automatically (as they would
  1277.    * respond to an explicit setGUIStyle() call), but you should connect to
  1278.    * this to program special behavior.
  1279.    */
  1280.   void kdisplayStyleChanged();
  1281.  
  1282.   /**
  1283.    * Emitted when KApplication has changed its font in response to a KControl request.
  1284.    *
  1285.    * Normally widgets will update their fonts automatically, but you should
  1286.    * connect to this to monitor global font changes, especially if you are
  1287.    * using explicit fonts.
  1288.    *
  1289.    * Note: If you derive from a QWidget-based class, a faster method is to
  1290.    *       reimplement QWidget::fontChange(). This is the preferred way
  1291.    *       to get informed about font updates.
  1292.    */
  1293.   void kdisplayFontChanged();
  1294.  
  1295.   /**
  1296.    * Emitted when KApplication has changed either its GUI style, its font or its palette
  1297.    * in response to a kdisplay request. Normally, widgets will update their styles
  1298.    * automatically, but you should connect to this to program special
  1299.    * behavior. */
  1300.   void appearanceChanged();
  1301.  
  1302.   /**
  1303.    * Emitted when the settings for toolbars have been changed. KToolBar will know what to do.
  1304.    */
  1305.   void toolbarAppearanceChanged(int);
  1306.  
  1307.   /**
  1308.    * Emitted when the desktop background has been changed by @p kcmdisplay.
  1309.    *
  1310.    * @param desk The desktop whose background has changed.
  1311.    */
  1312.   void backgroundChanged(int desk);
  1313.  
  1314.   /**
  1315.    * Emitted when the global settings have been changed - see KGlobalSettings
  1316.    * KApplication takes care of calling reparseConfiguration on KGlobal::config()
  1317.    * so that applications/classes using this only have to re-read the configuration
  1318.    * @param category the category among the enum above
  1319.    */
  1320.   void settingsChanged(int category);
  1321.  
  1322.   /**
  1323.    * Emitted when the global icon settings have been changed.
  1324.    * @param group the new group
  1325.    */
  1326.   void iconChanged(int group);
  1327.  
  1328.   /**
  1329.    * Emitted when a KIPC user message has been received.
  1330.    * @param id the message id
  1331.    * @param data the data
  1332.    * @see KIPC
  1333.    * @see KIPC::Message
  1334.    * @see addKipcEventMask
  1335.    * @see removeKipcEventMask
  1336.    */
  1337.   void kipcMessage(int id, int data);
  1338.  
  1339.   /**
  1340.       Session management asks you to save the state of your application.
  1341.  
  1342.      This signal is provided for compatibility only. For new
  1343.      applications, simply use KMainWindow. By reimplementing 
  1344.      KMainWindow::queryClose(), KMainWindow::saveProperties() and
  1345.  KMainWindow::readProperties() you can simply handle session
  1346.      management for applications with multiple toplevel windows.
  1347.  
  1348.      For purposes without KMainWindow, create an instance of
  1349.      KSessionManaged and reimplement the functions 
  1350.      KSessionManaged::commitData() and/or 
  1351.      KSessionManaged::saveState()
  1352.  
  1353.      If you still want to use this signal, here is what you should do:
  1354.  
  1355.      Connect to this signal in order to save your data. Do NOT
  1356.      manipulate the UI in that slot, it is blocked by the session
  1357.      manager.
  1358.  
  1359.      Use the sessionConfig() KConfig object to store all your
  1360.      instance specific data.
  1361.  
  1362.      Do not do any closing at this point! The user may still select
  1363.      Cancel  wanting to continue working with your
  1364.      application. Cleanups could be done after shutDown() (see
  1365.      the following).
  1366.  
  1367.   */
  1368.   void saveYourself();
  1369.  
  1370.   /** Your application is killed. Either by your program itself,
  1371.       @p xkill or (the usual case) by KDE's logout.
  1372.  
  1373.       The signal is particularly useful if your application has to do some
  1374.       last-second cleanups. Note that no user interaction is possible at
  1375.       this state.
  1376.    */
  1377.   void shutDown();
  1378.  
  1379.   /**
  1380.    * @internal
  1381.    * Used to notify KIconLoader objects that they need to reload.
  1382.    */
  1383.   void updateIconLoaders();
  1384.  
  1385. private:
  1386.   void propagateSettings(SettingsCategory category);
  1387.   void kdisplaySetPalette();
  1388.   void kdisplaySetStyle();
  1389.   void kdisplaySetFont();
  1390.   void applyGUIStyle();
  1391.   static void sigpipeHandler(int);
  1392.  
  1393.   int captionLayout;
  1394.  
  1395.   KApplication(const KApplication&);
  1396.   KApplication& operator=(const KApplication&);
  1397. protected:
  1398.   virtual void virtual_hook( int id, void* data );
  1399. private:
  1400.   KApplicationPrivate* d;
  1401. };
  1402.  
  1403.  
  1404. /**
  1405.  * \relates KGlobal
  1406.  * Check, if a file may be accessed in a given mode.
  1407.  * This is a wrapper around the access() system call.
  1408.  * checkAccess() calls access() with the given parameters.
  1409.  * If this is OK, checkAccess() returns true. If not, and W_OK
  1410.  * is part of mode, it is checked if there is write access to
  1411.  * the directory. If yes, checkAccess() returns true.
  1412.  * In all other cases checkAccess() returns false.
  1413.  *
  1414.  * Other than access() this function EXPLICITLY ignores non-existant
  1415.  * files if checking for write access.
  1416.  *
  1417.  * @param pathname The full path of the file you want to test
  1418.  * @param mode     The access mode, as in the access() system call.
  1419.  * @return Whether the access is allowed, true = Access allowed
  1420.  */
  1421. KDECORE_EXPORT bool checkAccess(const QString& pathname, int mode);
  1422.  
  1423. class KSessionManagedPrivate;
  1424.  
  1425. /**
  1426.    Provides highlevel access to session management on a per-object
  1427.    base.
  1428.  
  1429.    KSessionManaged makes it possible to provide implementations for
  1430.  QApplication::commitData() and QApplication::saveState(), without
  1431.    subclassing KApplication. KMainWindow internally makes use of this.
  1432.  
  1433.    You don't need to do anything with this class when using
  1434.    KMainWindow. Instead, use KMainWindow::saveProperties(),
  1435.  KMainWindow::readProperties(), KMainWindow::queryClose(),
  1436.  KMainWindow::queryExit() and friends.
  1437.  
  1438.   @short Highlevel access to session management.
  1439.   @author Matthias Ettrich <ettrich@kde.org>
  1440.  */
  1441. class KDECORE_EXPORT KSessionManaged
  1442. {
  1443. public:
  1444.   KSessionManaged();
  1445.   virtual ~KSessionManaged();
  1446.  
  1447.     /**
  1448.        See QApplication::saveState() for documentation.
  1449.  
  1450.        This function is just a convenience version to avoid subclassing KApplication.
  1451.  
  1452.        Return true to indicate a successful state save or false to
  1453.        indicate a problem and to halt the shutdown process (will
  1454.        implicitly call sm.cancel() ).
  1455.      */
  1456.   virtual bool saveState( QSessionManager& sm );
  1457.     /**
  1458.        See QApplication::commitData() for documentation.
  1459.  
  1460.        This function is just a convenience version to avoid subclassing KApplication.
  1461.  
  1462.        Return true to indicate a successful commit of data or false to
  1463.        indicate a problem and to halt the shutdown process (will
  1464.        implicitly call sm.cancel() ).
  1465.      */
  1466.   virtual bool commitData( QSessionManager& sm );
  1467.  
  1468. protected:
  1469.   virtual void virtual_hook( int id, void* data );
  1470. private:
  1471.   KSessionManagedPrivate *d;
  1472. };
  1473.  
  1474.  
  1475. #endif
  1476.  
  1477.