KGlobal Namespace Reference
from PyKDE4.kdecore.KGlobal import *
Detailed Description
Enumerations | |
CopyCatalogs | { DoCopyCatalogs, DontCopyCatalogs } |
Functions | |
KComponentData | activeComponent () |
QString | caption () |
KCharsets | charsets () |
KCharsets | charsets () |
KSharedConfigPtr | config () |
deref () | |
KStandardDirs | dirs () |
bool | hasLocale () |
bool | hasMainComponent () |
KLocale | locale () |
KComponentData | mainComponent () |
ref () | |
setActiveComponent (KComponentData d) | |
setAllowQuit (bool allowQuit) | |
setLocale (KLocale a0, KGlobal.CopyCatalogs copy=KGlobal.DoCopyCatalogs) | |
QString | staticQString (QString str) |
QString | staticQString (QString str) |
mode_t | umask () |
Enumeration Documentation
CopyCatalogs |
For setLocale
- Enumerator:
-
DoCopyCatalogs DontCopyCatalogs
Function Documentation
KComponentData activeComponent | ( | self ) |
The component currently active (useful in a multi-component application, such as a KParts application). Don't use this - it's mainly for KAboutDialog and KBugReport.
- Internal:
QString caption | ( | self ) |
Returns a text for the window caption.
This may be set by "-caption", otherwise it will be equivalent to the name of the executable.
- Returns:
- the text for the window caption
KCharsets charsets | ( | self ) |
The global charset manager.
- Returns:
- the global charset manager
KCharsets charsets | ( | self ) |
KSharedConfigPtr config | ( | self ) |
Returns the general config object.
- Returns:
- the global configuration object.
deref | ( | self ) |
Tells KGlobal that one operation such as those described in ref() just finished. This call makes the QApplication quit if the counter is back to 0.
KStandardDirs dirs | ( | self ) |
Returns the application standard dirs object.
- Returns:
- the global standard dir object
bool hasLocale | ( | self ) |
- Internal:
- Returns whether KGlobal has a valid KLocale object
bool hasMainComponent | ( | self ) |
- Internal:
- Returns whether a main KComponentData is available.
KLocale locale | ( | self ) |
Returns the global locale object.
- Returns:
- the global locale object
KComponentData mainComponent | ( | self ) |
Returns the global component data. There is always at least one instance of a component in one application (in most cases the application itself).
- Returns:
- the global component data
ref | ( | self ) |
Tells KGlobal about one more operations that should be finished before the application exits. The standard behavior 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), or simply any application with a system tray icon.
We have some use cases that we want to take care of (the format is "action refcount"): - open window -> setAllowQuit(true) 1 ; close window 0 => EXIT - job start 1; job end 0 [don't exit yet]; open window -> setAllowQuit(true) 1 ; close window 0 => EXIT - job start 1; open window -> setAllowQuit(true) 2; close window 1; job end 0 => EXIT - job start 1; open window -> setAllowQuit(true) 2; job end 1; close window 0 => EXIT - open dialog 0; close dialog 0; => DO NOT EXIT - job start 1; job end 0; create two main objects 2; delete both main objects 0 => EXIT - open window -> setAllowQuit(true) 1; add systray icon 2; close window 1 => DO NOT EXIT - open window -> setAllowQuit(true) 1; add systray icon 2; remove systray icon 1; close window 0 => EXIT - unit test which opens and closes many windows: should call ref() to avoid subevent-loops quitting too early.
Note that for this to happen you must call qApp->setQuitOnLastWindowClosed(false), in main() for instance.
setActiveComponent | ( | KComponentData | d | |
) |
Set the active component for use by KAboutDialog and KBugReport. To be used only by a multi-component (KParts) application.
- See also:
- activeComponent()
setAllowQuit | ( | bool | allowQuit | |
) |
If refcounting reaches 0 (or less), and allowQuit is true, the instance of the application will automatically be exited. Otherwise, the application will not exit automatically.
This is used by KMainWindow to allow quitting after the first mainwindow is created, and is used by special applications like kfmclient, to allow quitting even though no mainwindow was created.
However, don't try to call setAllowQuit(false) in applications, it doesn't make sense. If you find that the application quits too early when closing a window, then consider _what_ is making your application still alive to the user (like a systray icon or a dbus object) and use KGlobal.ref() + KGlobal.deref() in that object.
- Since:
- 4.1.1
setLocale | ( | KLocale | a0, | |
KGlobal.CopyCatalogs | copy=KGlobal.DoCopyCatalogs | |||
) |
- Internal:
Creates a static QString.
To be used inside functions(!) like:
static const QString &myString = KGlobal.staticQString("myText");
Do NOT use code such as:
static QString myString = KGlobal.staticQString("myText");This creates a static object (instead of a static reference) and as you know static objects are EVIL.
- Parameters:
-
str the string to create
- Returns:
- the static string
Creates a static QString.
To be used inside functions(!) like:
static const QString &myString = KGlobal.staticQString(i18n("My Text"));
Do NOT use code such as:
static QString myString = KGlobal.staticQString(i18n("myText"));This creates a static object (instead of a static reference) and as you know static objects are EVIL.
- Parameters:
-
str the string to create
- Returns:
- the static string
mode_t umask | ( | self ) |
Returns the umask of the process.
- Returns:
- the umask of the process