|
|
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.
KApplication (int& argc, char** argv, const QCString& rAppName, bool allowStyles=true, bool GUIenabled=true) |
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. |
KApplication ( bool allowStyles=true, bool GUIenabled=true) |
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. |
void addCmdLineOptions () |
Add Qt and KDE command line options to KCmdLineArgs.
int argc () |
Retrieve the number of command line arguments, i. e. the length of the array KApplication::argv().
In this array, the arguments handled by KApplication itself (eg. '-icon') are already removed
KApplication* kApplication () |
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 () |
Retrieve the application session config object.
Returns: A pointer to the application's instance specific KConfig object.
bool isRestored () |
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.
void disableSessionManagement () |
Disable session management for this application.
Useful in case your application is started by the inital "startkde" script.
DCOPClient * dcopClient () |
Retrieve a pointer to a DCOPClient for the application.
QPixmap icon () |
Get the application icon.
Returns: a QPixmap with the icon.
QPixmap miniIcon () |
Get the mini-icon for the application.
Returns: a QPixmap with the icon.
void setTopWidget ( QWidget *topWidget ) |
Set the top widget of the application.
This means bascially 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 KTMainWindow.
Parameters:
topWidget | A top widget of the application. |
See also: icon(), caption()
void invokeHTMLHelp ( QString aFilename, QString aTopic ) |
Invoke the khelpcenter HTML help viewer.
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 ) |
Invoke the standard email application.
Parameters:
address | The destination address |
subject | Subject string. Can be QString::null. |
void invokeBrowser ( const QString &url ) |
Invoke the standard browser.
Parameters:
url | The destination address |
KStyle* kstyle () |
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 &fontlist) |
Get the KDE font list.
This method allows you to get the KDE font list which was composed by the user with kfontmanager. Usually you should work only with those fonts in your KDE application.
Parameters:
fontlist | A reference to a list to fill with fonts. |
Returns: true on success.
QString caption () |
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 ) |
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., contains data the has not been saved. |
QString tempSaveName ( const QString& pFilename ) |
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 ) |
Check if there is an auto-save file 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 () |
Get the X11 display
void enableStyles () |
Enable style plugins.
This is useful only to applications that normally
do not display a GUI and create the KApplication with allowStyles
= @pfalse.
void installX11EventFilter ( QWidget* filter ) |
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 () |
Generate a uniform random number.
Returns: A truly unpredictable number in the range [0, MAX_RAND)
bool x11EventFilter ( XEvent * ) |
Used to catch X11 events
int xioErrhandler () |
void kdisplayPaletteChanged () |
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 () |
KApplication has changed its GUI Style due 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 () |
KApplication has changed its Font due 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 () |
KApplication has changed either its GUI style, its font or its palette due to a kdisplay request. Normally, widgets will update their styles automatically, but you should connect to this to program special behavior.
void backgroundChanged (int desk) |
The desktop background has been changed by kcmdisplay.
NOTE: this method should move out of here as soon as DCOP is in place.
Parameters:
desk | The desktop whose background has changed. |
void saveYourself () |
Session management asks you to save the state of your application.
This signal is provided for compatibility only. For new appliations, simply use KTMainWindow. By reimplementing KTMainWindow::queryClose, KTMainWindow::saveProperties and KTMainWindow::readProperties you can simply handle session management for applications with multiple toplevel windows.
For purposes without KTMainWindow, 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 ::getSessionConfig KConfig object to store all your instance specific datas.
Do not do any closing at this point! The user may still select "cancel" and then he wants to continue working with your application. Cleanups could be done after shutDown() (see below)
void shutDown () |
Your application is killed. Either by your program itself, kwm's killwindow function, 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.