|
|
Controls and provides information to all KDE applications.
Only one object of this class can be instantiated in a single app. This instance is always accessible via the kApplication() method.
This class provides the following services to all KDE applications.
enum CaptionLayout { CaptionAppLast=1, CaptionAppFirst, CaptionNoApp } | CaptionLayout |
KApplication ( bool allowStyles=true, bool GUIenabled=true)
| KApplication |
This constructor takes aboutData and command line arguments from KCmdLineArgs.
Parameters:
allowStyles | Set to false to disable the loading on plugin based
styles. This is only useful to applications that do not display a GUI
normally. If you do create an application with allowStyles set to false
it normally runs in the background but under special circumstances
displays widgets. Call enableStyles() before displaying any widgets.
|
GUIenabled | Set to false to disable all GUI stuff. This implies no styles either. |
KApplication (Display *display, int& argc, char** argv, const QCString& rAppName,
bool allowStyles=true, bool GUIenabled=true)
| KApplication |
Constructor. Parses command-line arguments. Use this constructor to use KApplication in a Motif or Xt program.
Parameters:
display | Will be passed to Qt as the X display. The display must be valid and already opened. |
rAppName | application name. Will be used for finding the associated message files and icon files, and as the default registration name for DCOP. This is a mandatory parameter. |
allowStyles | Set to false to disable the loading on plugin based
styles. This is only useful to applications that do not display a GUI
normally. If you do create an application with allowStyles set to false
that normally runs in the background but under special circumstances
displays widgets call enableStyles() before displaying any widgets.
|
GUIenabled | Set to false to disable all GUI stuff. This implies no styles either. |
KApplication (int& argc, char** argv,
const QCString& rAppName, bool allowStyles=true, bool GUIenabled=true)
| KApplication |
Constructor. Parses command-line arguments.
Parameters:
rAppName | application name. Will be used for finding the associated message files and icon files, and as the default registration name for DCOP. This is a mandatory parameter. |
allowStyles | Set to false to disable the loading on plugin based
styles. This is only useful to applications that do not display a GUI
normally. If you do create an application with allowStyles set to false
that normally runs in the background but under special circumstances
displays widgets call enableStyles() before displaying any widgets.
|
GUIenabled | Set to false to disable all GUI stuff. This implies no styles either. |
void addCmdLineOptions ()
| addCmdLineOptions |
[static]
Add Qt and KDE command line options to KCmdLineArgs.
~KApplication ()
| ~KApplication |
[virtual]
KApplication* kApplication ()
| kApplication |
[static]
Retrieve the current application object.
This is similar to the global QApplication pointer qApp. It allows access to the single global KApplication object, since more than one cannot be created in the same application. It saves you the trouble of having to pass the pointer explicitly to every function that may require it.
KConfig* sessionConfig ()
| sessionConfig |
Retrieve the application session config object.
Returns: A pointer to the application's instance specific KConfig object.
See also: KConfig
bool isRestored ()
| isRestored |
[const]
Is the application restored from the session manager?
Returns: If true
, this application was restored by the session manager.
Note that this may mean the config object returned by
sessionConfig() contains data saved by a session closedown.
See also: sessionConfig()
void disableSessionManagement ()
| disableSessionManagement |
Disable session management for this application.
Useful in case your application is started by the initial "startkde" script.
bool requestShutDown ()
| requestShutDown |
Asks the session manager to shut the session down.
Returns TRUE on sucess, FALSE if the session manager could not be contacted.
bool requestShutDown ( bool bFast )
| requestShutDown |
void propagateSessionManager ()
| propagateSessionManager |
Propagates the network address of the session manager in the SESSION_MANAGER environment variable so that child processes can pick it up.
If SESSION_MANAGER isn't defined yet, the address is searched in $HOME/.KSMserver.
This function is called by clients that are started outside the session ( i.e. before ksmserver is started), but want to launch other processes that should participate in the session. Examples are kdesktop or kicker.
void commitData ( QSessionManager& sm )
| commitData |
Reimplemented from QApplication.
void saveState ( QSessionManager& sm )
| saveState |
Reimplemented from QApplication.
DCOPClient * dcopClient ()
| dcopClient |
[virtual]
Retrieve a pointer to a DCOPClient for the application.
QPixmap icon ()
| icon |
[const]
Get the application icon.
Returns: a QPixmap with the icon.
See also: QPixmap
QPixmap miniIcon ()
| miniIcon |
[const]
Get the mini-icon for the application.
Returns: a QPixmap with the icon.
See also: QPixmap
void setTopWidget ( QWidget *topWidget )
| setTopWidget |
Set the top widget of the application.
This means basically applying the right window caption and icon. An application may have several top widgets. You don't need to call this function manually when using KMainWindow.
Parameters:
topWidget | A top widget of the application. |
See also: icon(), caption()
void invokeHelp ( const QString& anchor = QString::null,
const QString& appname = QString::null )
| invokeHelp |
[const]
Invoke the KHelpCenter HTML help viewer from docbook sources.
Parameters:
anchor | This has to be a defined anchor in your docbook sources. If empty the main index is loaded |
appname | This allows you to show the help of another application. If empty the current name() is used |
void invokeHTMLHelp ( const QString& aFilename, const QString& aTopic = QString::null )
| invokeHTMLHelp |
[const]
Invoke the khelpcenter HTML help viewer from HTML sources. Please use invokeHelp() instead.
Parameters:
aFilename | The filename that is to be loaded. Its
location is computed automatically
according to the KFSSTND. If aFilename
is empty, the logical appname with .html
appended to it is used.
|
aTopic | This allows context-sensitive help. Its value will be appended to the filename, prefixed with a "#" (hash) character. |
void invokeMailer ( const QString &address, const QString &subject )
| invokeMailer |
Convenience method; invokes the standard email application.
Parameters:
address | The destination address |
subject | Subject string. Can be QString::null. |
void invokeMailer ( const KURL &mailtoURL )
| invokeMailer |
Invokes the standard email application.
Parameters:
mailtoURL | A mailto URL. |
void invokeBrowser ( const QString &url )
| invokeBrowser |
Invoke the standard browser.
Parameters:
url | The destination address |
QCString launcher ()
| launcher |
[static]
Get the DCOP name of the service launcher. This will be something like klaucher_$host_$uid.
Returns: The DCOP name of the launcher.
int startServiceByName ( const QString& _name, const QString &URL,
QString *error, QCString *dcopService, int *pid, const QCString& startup_id )
| startServiceByName |
[static]
Starts a service based on the (translated) name of the service. E.g. "Web Browser"
Parameters:
URL | - if not empty this URL is passed to the service |
startup_id | - for app startup notification, "0" for none, "" ( empty string ) is the default |
Returns: On failure, 'error' contains a description of the error that occured.
int startServiceByName ( const QString& _name, const QStringList &URLs,
QString *error, QCString *dcopService, int *pid, const QCString& startup_id )
| startServiceByName |
[static]
int startServiceByName ( const QString& _name, const QString &URL,
QString *error=0, QCString *dcopService=0, int *pid=0 )
| startServiceByName |
[static]
int startServiceByName ( const QString& _name, const QStringList &URLs=QStringList(),
QString *error=0, QCString *dcopService=0, int *pid=0 )
| startServiceByName |
[static]
int startServiceByDesktopPath ( const QString& _name, const QString &URL,
QString *error, QCString *dcopService, int *pid, const QCString& startup_id )
| startServiceByDesktopPath |
[static]
Starts a service based on the desktop path of the service. E.g. "Applications/konqueror.desktop" or "/home/user/bla/myfile.desktop"
Parameters:
URL | - if not empty this URL is passed to the service |
startup_id | - for app startup notification, "0" for none, "" ( empty string ) is the default |
Returns: On failure, 'error' contains a description of the error that occured.
int startServiceByDesktopPath ( const QString& _name, const QStringList &URLs,
QString *error, QCString *dcopService, int *pid, const QCString& startup_id )
| startServiceByDesktopPath |
[static]
int startServiceByDesktopPath ( const QString& _name, const QString &URL,
QString *error=0, QCString *dcopService=0, int *pid = 0 )
| startServiceByDesktopPath |
[static]
int startServiceByDesktopPath ( const QString& _name, const QStringList &URLs=QStringList(),
QString *error=0, QCString *dcopService=0, int *pid = 0 )
| startServiceByDesktopPath |
[static]
int startServiceByDesktopName ( const QString& _name, const QString &URL,
QString *error, QCString *dcopService, int *pid, const QCString& startup_id )
| startServiceByDesktopName |
[static]
Starts a service based on the desktop name of the service. E.g. "konqueror"
Parameters:
URL | - if not empty this URL is passed to the service |
startup_id | - for app startup notification, "0" for none, "" ( empty string ) is the default |
Returns: On failure, 'error' contains a description of the error that occured.
int startServiceByDesktopName ( const QString& _name, const QStringList &URLs,
QString *error, QCString *dcopService, int *pid, const QCString& startup_id )
| startServiceByDesktopName |
[static]
int startServiceByDesktopName ( const QString& _name, const QString &URL,
QString *error=0, QCString *dcopService=0, int *pid = 0 )
| startServiceByDesktopName |
[static]
int startServiceByDesktopName ( const QString& _name, const QStringList &URLs=QStringList(),
QString *error=0, QCString *dcopService=0, int *pid = 0 )
| startServiceByDesktopName |
[static]
int kdeinitExec ( const QString& name, const QStringList &args=QStringList(),
QString *error=0, int *pid = 0 )
| kdeinitExec |
[static]
Start a program via kdeinit. There will be no application startup notification, so you should use it only for starting internal processes.
program name and arguments are converted to according to the local encoding and passed as is to kdeinit.
Parameters:
prog | Name of the program to start |
args | Arguments to pass to the program |
Returns: On failure, 'error' contains a description of the error that occured.
int kdeinitExecWait ( const QString& name, const QStringList &args=QStringList(),
QString *error=0, int *pid = 0 )
| kdeinitExecWait |
[static]
Start a program via kdeinit and wait for it to finish.
Like kdeinitExec but it waits till the program is finished. As such it behaves similair to the system(...) function.
KStyle* kstyle ()
| kstyle |
[const]
Retrieve the current KDE style object if a plugin is in use, or else NULL if a Qt internal style is being used.
bool kdeFonts (QStringList &)
| kdeFonts |
[const]
QString caption ()
| caption |
[const]
Return a text for the window caption.
This may be set by "-caption", otherwise it will be equivalent to the name of the executable.
QString makeStdCaption ( const QString &userCaption,
bool withAppName=true, bool modified=false )
| makeStdCaption |
[const]
Build a caption that contains the application name along with the userCaption() using a standard layout.
To make a compliant caption
for your window, simply do: setCaption
(kapp->makeStdCaption(yourCaption));
Parameters:
userCaption | The caption string you want to display in the window caption area. Do not include the application name! |
withAppName | Indicates that the method shall include or ignore
the application name when making the caption string. You are not
compliant if you set this to false .
|
modified | If true, a 'modified' sign will be included in the returned string. This is useful when indicating that a file is modified, i.e., it contains data that has not been saved. |
QString tempSaveName ( const QString& pFilename )
| tempSaveName |
[const]
Get a file name in order to make a temporary copy of your document.
Parameters:
pFilename | The full path to the current file of your document. |
Returns: A new filename for auto-saving.
QString checkRecoverFile ( const QString& pFilename, bool& bRecover )
| checkRecoverFile |
[const]
Check whether an auto-save file exists for the document you want to open.
Parameters:
pFilename | The full path to the document you want to open. |
bRecover | This gets set to true if there was a recover file. |
Returns: The full path of the file to open.
Display * getDisplay ()
| getDisplay |
Get the X11 display
void enableStyles ()
| enableStyles |
Enable style plugins.
This is useful only to applications that normally
do not display a GUI and create the KApplication with
allowStyles
set to false
.
void disableStyles ()
| disableStyles |
Disable style plugins.
Current style plugins do not get unloaded.
This is only usefull when used in combination with enableStyles.
void installX11EventFilter ( QWidget* filter )
| installX11EventFilter |
Install widget filter as global X11 event filter.
The widget filter receives XEvents in its standard QWidget::x11Event() function.
Warning: Only do this when absolutely necessary. An installed X11 filter can slow things down.
int random ()
| random |
[static]
Generate a uniform random number.
Returns: A truly unpredictable number in the range [0, RAND_MAX)
QString randomString (int length)
| randomString |
[static]
Generate a random string. It operates in the range [A-Za-z0-9]
Parameters:
length | Generate a string of this length. |
void addKipcEventMask (int id)
| addKipcEventMask |
Add a message type to the KIPC event mask. You can only add "system messages" to the event mask. These are the messages with id < 32. Messages with id >= 32 are user messages.
Parameters:
id | The message id. See KIPC::Message. |
void removeKipcEventMask (int id)
| removeKipcEventMask |
Remove a message type from the KIPC event mask. This message will not be handled anymore.
Parameters:
id | The message id. |
KDesktopWidget * desktop ()
| desktop |
[static]
Return a desktop widget that overrides the one in QT. This is to provide Xinerama support.
Reimplemented from QApplication.
const QCString startupId ()
| startupId |
[const]
Returns the app startup notification identifier for this running application.
void setStartupId ( const QCString& startup_id )
| setStartupId |
Sets a new value for the application startup notification window property for newly created toplevel windows.
void ref ()
| ref |
[slot]
Tell KApplication about one more operation that should be finished before the application exits. The standard behaviour is to exit on the "last window closed" event, but some events should outlive the last window closed (e.g. a file copy for a file manager, or 'compacting folders on exit' for a mail client).
void deref ()
| deref |
[slot]
Tell KApplication that one operation such as those described in ref just finished. The application exits if the counter is back to 0.
QString geometryArgument ()
| geometryArgument |
[const slot]
Returns the argument to --geometry if any, so the geometry can be set wherever necessary
bool x11EventFilter ( XEvent * )
| x11EventFilter |
[protected]
Used to catch X11 events
Display * display | display |
[protected]
Atom kipcCommAtom | kipcCommAtom |
[protected]
int kipcEventMask | kipcEventMask |
[protected]
static KApplication * KApp | KApp |
[protected]
int pArgc | pArgc |
[protected]
bool notify (QObject *receiver, QEvent *event)
| notify |
Reimplemented from QApplication.
int xioErrhandler ()
| xioErrhandler |
void iceIOErrorHandler ( _IceConn *conn )
| iceIOErrorHandler |
static bool loadedByKdeinit | loadedByKdeinit |
void startKdeinit ()
| startKdeinit |
[static]
enum SettingsCategory { SETTINGS_MOUSE, SETTINGS_COMPLETION, SETTINGS_PATHS, SETTINGS_POPUPMENU, SETTINGS_QT } | SettingsCategory |
Valid values for the settingsChanged signal
void kdisplayPaletteChanged ()
| kdisplayPaletteChanged |
[signal]
KApplication has changed its palette due to a KDisplay request.
Normally, widgets will update their palettes automatically, but you should connect to this to program special behaviour.
void kdisplayStyleChanged ()
| kdisplayStyleChanged |
[signal]
KApplication has changed its GUI style in response to a KDisplay request.
Normally, widgets will update their styles automatically (as they would respond to an explicit setGUIStyle() call), but you should connect to this to program special behaviour.
void kdisplayFontChanged ()
| kdisplayFontChanged |
[signal]
KApplication has changed its font in response to a KDisplay request.
Normally widgets will update their fonts automatically, but you should connect to this to monitor global font changes, especially if you are using explicit fonts.
void appearanceChanged ()
| appearanceChanged |
[signal]
KApplication has changed either its GUI style, its font or its palette in response to a kdisplay request. Normally, widgets will update their styles automatically, but you should connect to this to program special behavior.
void toolbarAppearanceChanged (int)
| toolbarAppearanceChanged |
[signal]
The settings for toolbars have been changed. KToolBar will know what to do.
void backgroundChanged (int desk)
| backgroundChanged |
[signal]
The desktop background has been changed by kcmdisplay
.
Parameters:
desk | The desktop whose background has changed. |
void settingsChanged (int category)
| settingsChanged |
[signal]
The global settings have been changed - see KGlobalSettings KApplication takes care of calling reparseConfiguration on KGlobal::config() so that applications/classes using this only have to re-read the configuration
Parameters:
category | the category among the enum above |
void iconChanged (int group)
| iconChanged |
[signal]
The global icon settings have been changed.
void kipcMessage (int id, int data)
| kipcMessage |
[signal]
Emitted when a KIPC user message has been received.
void saveYourself ()
| saveYourself |
[signal]
Session management asks you to save the state of your application.
This signal is provided for compatibility only. For new appliations, simply use KMainWindow. By reimplementing KMainWindow::queryClose(), KMainWindow::saveProperties() and KMainWindow::readProperties() you can simply handle session management for applications with multiple toplevel windows.
For purposes without KMainWindow, create an instance of KSessionManaged and reimplement the functions KSessionManaged::commitData() and/or KSessionManaged::saveState()
If you still want to use this signal, here is what you should do:
Connect to this signal in order to save your data. Do NOT manipulate the UI in that slot, it is blocked by the session manager.
Use the sessionConfig() KConfig object to store all your instance specific datas.
Do not do any closing at this point! The user may still select Cancel wanting to continue working with your application. Cleanups could be done after shutDown() (see the following).
void shutDown ()
| shutDown |
[signal]
Your application is killed. Either by your program itself,
xkill
or (the usual case) by KDE's logout.
The signal is particularly useful if your application has to do some last-second cleanups. Note that no user interaction is possible at this state.