KGlobal
Functions | |
KComponentData | activeComponent () |
QString | caption () |
KCharsets * | charsets () |
KSharedConfigPtr | config () |
void | deref () |
KStandardDirs * | dirs () |
template<typename T > | |
T | findDirectChild (const QObject *object) |
QObject * | findDirectChild_helper (const QObject *parent, const QMetaObject &mo) |
bool | hasLocale () |
bool | hasMainComponent () |
LocaleWrapper | locale () |
const KComponentData & | mainComponent () |
void | ref () |
void | setActiveComponent (const KComponentData &d) |
void | setAllowQuit (bool allowQuit) |
const QString & | staticQString (const char *str) |
const QString & | staticQString (const QString &str) |
mode_t | umask () |
Detailed Description
Access to the KDE global objects.
KGlobal provides you with pointers of many central objects that exist only once in the process. It is also responsible for managing instances of KStaticDeleterBase.
- See also
- KStaticDeleterBase
Function Documentation
◆ activeComponent()
KComponentData KGlobal::activeComponent | ( | ) |
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.
- Deprecated:
- since 5.0 see KComponentData::activeComponent() about why you should do without this concept (or let your app remember the active part/plugin if it cares)
Definition at line 138 of file kglobal.cpp.
◆ caption()
QString KGlobal::caption | ( | ) |
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
- Deprecated:
- since 5.0. Don't use in window titles anymore, Qt takes care of it. If you really need this, use QGuiApplication::applicationDisplayName(), and if that's empty, QCoreApplication::applicationName().
Definition at line 175 of file kglobal.cpp.
◆ charsets()
KCharsets * KGlobal::charsets | ( | ) |
The global charset manager.
- Returns
- the global charset manager
- Deprecated:
- since 5.0, use KCharsets::charsets()
Definition at line 127 of file kglobal.cpp.
◆ config()
KSharedConfig::Ptr KGlobal::config | ( | ) |
Returns the general config object.
- Returns
- the global configuration object.
- Deprecated:
- since 5.0, use KSharedConfig::openConfig()
Definition at line 102 of file kglobal.cpp.
◆ deref()
void KGlobal::deref | ( | ) |
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.
- Deprecated:
- since 5.0, use QEventLoopLocker, its destructor does the equivalent of unref
Definition at line 213 of file kglobal.cpp.
◆ dirs()
KStandardDirs * KGlobal::dirs | ( | ) |
Returns the application standard dirs object.
- Returns
- the global standard dir object
Definition at line 89 of file kglobal.cpp.
◆ findDirectChild()
|
inline |
Returns the child of the given object that can be cast into type T, or 0 if there is no such object.
Unlike QObject::findChild, the search is NOT performed recursively.
- Since
- 4.4
- Deprecated:
- since Qt 5, use QObject::findChild(FindDirectChildrenOnly)
◆ findDirectChild_helper()
QObject * KGlobal::findDirectChild_helper | ( | const QObject * | parent, |
const QMetaObject & | mo | ||
) |
Definition at line 229 of file kglobal.cpp.
◆ hasLocale()
bool KGlobal::hasLocale | ( | ) |
Returns whether KGlobal has a valid KLocale object
- Deprecated:
- since 5.0, port to if (qApp) because KLocale::global() can be called, as soon as a qApp exists.
Definition at line 122 of file kglobal.cpp.
◆ hasMainComponent()
bool KGlobal::hasMainComponent | ( | ) |
Returns whether a main KComponentData is available.
- Deprecated:
- since 5.0, use KComponentData::hasMainComponent() if you really need a KComponentData
Definition at line 112 of file kglobal.cpp.
◆ locale()
KGlobal::LocaleWrapper KGlobal::locale | ( | ) |
Returns the global locale object.
- Returns
- the global locale object
Note: in multi-threaded programs, you should call KLocale::global() in the main thread (e.g. in main(), after creating the QCoreApplication and setting the main component), to ensure that the initialization is done in the main thread. However KApplication takes care of this, so this is only needed when not using KApplication.
- Deprecated:
- since 5.0, use KLocale::global()
Definition at line 117 of file kglobal.cpp.
◆ mainComponent()
const KComponentData & KGlobal::mainComponent | ( | ) |
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
- Deprecated:
- since 5.0 use KComponentData::mainComponent() if you really need a KComponentData
Definition at line 107 of file kglobal.cpp.
◆ ref()
void KGlobal::ref | ( | ) |
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.
- Deprecated:
- since 5.0, use QEventLoopLocker, its constructor does the equivalent of ref
Definition at line 207 of file kglobal.cpp.
◆ setActiveComponent()
void KGlobal::setActiveComponent | ( | const 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()
- Deprecated:
- since 5.0 see KComponentData::setActiveComponent about why you can probably just remove the call.
Definition at line 143 of file kglobal.cpp.
◆ setAllowQuit()
void KGlobal::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 D-Bus object) and use KGlobal::ref() + KGlobal::deref() in that object.
- Since
- 4.1.1
- Deprecated:
- since 5.0, not necessary anymore, with QCoreApplication and QEventLoopLocker
Definition at line 222 of file kglobal.cpp.
◆ staticQString() [1/2]
const QString & KGlobal::staticQString | ( | const char * | str | ) |
Creates a static QString.
Create a static QString.
To be used inside functions(!) like:
- Attention
- Do NOT use code such as:
- Parameters
-
str the string to create
- Returns
- the static string
- Deprecated:
- since 5.0, use QLatin1String() or QStringLiteral()
To be used inside functions(!) like: static const QString &myString = KGlobal::staticQString("myText");
Definition at line 154 of file kglobal.cpp.
◆ staticQString() [2/2]
Creates a static QString.
Create a static QString.
To be used inside functions(!) like:
- Attention
- Do NOT use code such as:
- Parameters
-
str the string to create
- Returns
- the static string
- Deprecated:
- since 5.0 don't make the string static
To be used inside functions(!) like: static const QString &myString = KGlobal::staticQString(i18n("My Text"));
Definition at line 165 of file kglobal.cpp.
◆ umask()
mode_t KGlobal::umask | ( | ) |
Returns the umask of the process.
- Returns
- the umask of the process
Definition at line 132 of file kglobal.cpp.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Sun Oct 1 2023 03:56:34 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.