KApplication

#include <kapplication.h>

Inheritance diagram for KApplication:

Signals

void saveYourself ()
 

Public Slots

void commitData (QSessionManager &sm)
 
Q_SCRIPTABLE void quit ()
 
Q_SCRIPTABLE void reparseConfiguration ()
 
void saveState (QSessionManager &sm)
 
Q_SCRIPTABLE void updateUserTimestamp (int time=0)
 

Public Member Functions

 KApplication (bool GUIenabled=true)
 
void clearStartupId ()
 
void disableSessionManagement ()
 
void enableSessionManagement ()
 
void installX11EventFilter (QWidget *filter)
 
void removeX11EventFilter (const QWidget *filter)
 
KConfigsessionConfig ()
 
bool sessionSaving () const
 
void setStartupId (const QByteArray &startup_id)
 
void setTopWidget (QWidget *topWidget)
 
QByteArray startupId () const
 
void updateRemoteUserTimestamp (const QString &service, int time=0)
 
unsigned long userTimestamp () const
 
- Public Member Functions inherited from QApplication
 QApplication (int &argc, char **argv)
 
bool autoSipEnabled () const const
 
void focusChanged (QWidget *old, QWidget *now)
 
virtual bool notify (QObject *receiver, QEvent *e) override
 
 qApp qApp
 
void setAutoSipEnabled (const bool enabled)
 
void setStyleSheet (const QString &sheet)
 
QString styleSheet () const const
 
- Public Member Functions inherited from QGuiApplication
 QGuiApplication (int &argc, char **argv)
 
void applicationDisplayNameChanged ()
 
void applicationStateChanged (Qt::ApplicationState state)
 
void commitDataRequest (QSessionManager &manager)
 
qreal devicePixelRatio () const const
 
void focusObjectChanged (QObject *focusObject)
 
void focusWindowChanged (QWindow *focusWindow)
 
void fontChanged (const QFont &font)
 
void fontDatabaseChanged ()
 
bool isSavingSession () const const
 
bool isSessionRestored () const const
 
void lastWindowClosed ()
 
void layoutDirectionChanged (Qt::LayoutDirection direction)
 
void paletteChanged (const QPalette &palette)
 
void primaryScreenChanged (QScreen *screen)
 
 qGuiApp qGuiApp
 
void saveStateRequest (QSessionManager &manager)
 
void screenAdded (QScreen *screen)
 
void screenRemoved (QScreen *screen)
 
QString sessionId () const const
 
QString sessionKey () const const
 
- Public Member Functions inherited from QCoreApplication
 QCoreApplication (int &argc, char **argv)
 
void aboutToQuit ()
 
void applicationNameChanged ()
 
void applicationVersionChanged ()
 
void installNativeEventFilter (QAbstractNativeEventFilter *filterObj)
 
void organizationDomainChanged ()
 
void organizationNameChanged ()
 
 Q_COREAPP_STARTUP_FUNCTION (ptr)
 
 Q_DECLARE_TR_FUNCTIONS (context)
 
void qAddPostRoutine (QtCleanUpFunction ptr)
 
void qRemovePostRoutine (QtCleanUpFunction ptr)
 
void removeNativeEventFilter (QAbstractNativeEventFilter *filterObject)
 
- Public Member Functions inherited from QObject
 QObject (QObject *parent)
 
bool blockSignals (bool block)
 
const QObjectListchildren () const const
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const const
 
void deleteLater ()
 
void destroyed (QObject *obj)
 
bool disconnect (const char *signal, const QObject *receiver, const char *method) const const
 
bool disconnect (const QObject *receiver, const char *method) const const
 
void dumpObjectInfo ()
 
void dumpObjectInfo () const const
 
void dumpObjectTree ()
 
void dumpObjectTree () const const
 
QList< QByteArraydynamicPropertyNames () const const
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
findChild (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegExp &regExp, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegularExpression &re, Qt::FindChildOptions options) const const
 
bool inherits (const char *className) const const
 
void installEventFilter (QObject *filterObj)
 
bool isWidgetType () const const
 
bool isWindowType () const const
 
void killTimer (int id)
 
virtual const QMetaObjectmetaObject () const const
 
void moveToThread (QThread *targetThread)
 
QString objectName () const const
 
void objectNameChanged (const QString &objectName)
 
QObjectparent () const const
 
QVariant property (const char *name) const const
 
 Q_CLASSINFO (Name, Value)
 
 Q_DISABLE_COPY (Class)
 
 Q_DISABLE_COPY_MOVE (Class)
 
 Q_DISABLE_MOVE (Class)
 
 Q_EMIT Q_EMIT
 
 Q_ENUM (...)
 
 Q_ENUM_NS (...)
 
 Q_ENUMS (...)
 
 Q_FLAG (...)
 
 Q_FLAG_NS (...)
 
 Q_FLAGS (...)
 
 Q_GADGET Q_GADGET
 
 Q_INTERFACES (...)
 
 Q_INVOKABLE Q_INVOKABLE
 
 Q_NAMESPACE Q_NAMESPACE
 
 Q_NAMESPACE_EXPORT (EXPORT_MACRO)
 
 Q_OBJECT Q_OBJECT
 
 Q_PROPERTY (...)
 
 Q_REVISION Q_REVISION
 
 Q_SET_OBJECT_NAME (Object)
 
 Q_SIGNAL Q_SIGNAL
 
 Q_SIGNALS Q_SIGNALS
 
 Q_SLOT Q_SLOT
 
 Q_SLOTS Q_SLOTS
 
qFindChild (const QObject *obj, const QString &name)
 
QList< T > qFindChildren (const QObject *obj, const QRegExp &regExp)
 
QList< T > qFindChildren (const QObject *obj, const QString &name)
 
qobject_cast (QObject *object)
 
qobject_cast (const QObject *object)
 
 QT_NO_NARROWING_CONVERSIONS_IN_CONNECT QT_NO_NARROWING_CONVERSIONS_IN_CONNECT
 
void removeEventFilter (QObject *obj)
 
void setObjectName (const QString &name)
 
void setParent (QObject *parent)
 
bool setProperty (const char *name, const QVariant &value)
 
bool signalsBlocked () const const
 
int startTimer (int interval, Qt::TimerType timerType)
 
int startTimer (std::chrono::milliseconds time, Qt::TimerType timerType)
 
QThreadthread () const const
 

Static Public Member Functions

static QString checkRecoverFile (const QString &pFilename, bool &bRecover)
 
static KApplicationkApplication ()
 
static QString tempSaveName (const QString &pFilename)
 
- Static Public Member Functions inherited from QApplication
void aboutQt ()
 
QWidgetactiveModalWidget ()
 
QWidgetactivePopupWidget ()
 
QWidgetactiveWindow ()
 
void alert (QWidget *widget, int msec)
 
QWidgetList allWidgets ()
 
void beep ()
 
void closeAllWindows ()
 
int colorSpec ()
 
int cursorFlashTime ()
 
QDesktopWidgetdesktop ()
 
int doubleClickInterval ()
 
int exec ()
 
QWidgetfocusWidget ()
 
QFont font ()
 
QFont font (const QWidget *widget)
 
QFont font (const char *className)
 
QFontMetrics fontMetrics ()
 
QSize globalStrut ()
 
bool isEffectEnabled (Qt::UIEffect effect)
 
int keyboardInputInterval ()
 
bool keypadNavigationEnabled ()
 
Qt::NavigationMode navigationMode ()
 
QPalette palette (const QWidget *widget)
 
QPalette palette (const char *className)
 
void setActiveWindow (QWidget *active)
 
void setColorSpec (int spec)
 
void setCursorFlashTime (int)
 
void setDoubleClickInterval (int)
 
void setEffectEnabled (Qt::UIEffect effect, bool enable)
 
void setFont (const QFont &font, const char *className)
 
void setGlobalStrut (const QSize &)
 
void setKeyboardInputInterval (int)
 
void setKeypadNavigationEnabled (bool enable)
 
void setNavigationMode (Qt::NavigationMode mode)
 
void setPalette (const QPalette &palette, const char *className)
 
void setStartDragDistance (int l)
 
void setStartDragTime (int ms)
 
void setStyle (QStyle *style)
 
QStylesetStyle (const QString &style)
 
void setWheelScrollLines (int)
 
void setWindowIcon (const QIcon &icon)
 
int startDragDistance ()
 
int startDragTime ()
 
QStylestyle ()
 
QWidgettopLevelAt (int x, int y)
 
QWidgettopLevelAt (const QPoint &point)
 
QWidgetList topLevelWidgets ()
 
int wheelScrollLines ()
 
QWidgetwidgetAt (int x, int y)
 
QWidgetwidgetAt (const QPoint &point)
 
QIcon windowIcon ()
 
- Static Public Member Functions inherited from QGuiApplication
QWindowList allWindows ()
 
QString applicationDisplayName ()
 
Qt::ApplicationState applicationState ()
 
void changeOverrideCursor (const QCursor &cursor)
 
QClipboardclipboard ()
 
QString desktopFileName ()
 
bool desktopSettingsAware ()
 
int exec ()
 
QObjectfocusObject ()
 
QWindowfocusWindow ()
 
QFont font ()
 
Qt::HighDpiScaleFactorRoundingPolicy highDpiScaleFactorRoundingPolicy ()
 
QInputMethodinputMethod ()
 
bool isFallbackSessionManagementEnabled ()
 
bool isLeftToRight ()
 
bool isRightToLeft ()
 
Qt::KeyboardModifiers keyboardModifiers ()
 
Qt::LayoutDirection layoutDirection ()
 
QWindowmodalWindow ()
 
Qt::MouseButtons mouseButtons ()
 
QCursoroverrideCursor ()
 
QPalette palette ()
 
QFunctionPointer platformFunction (const QByteArray &function)
 
QString platformName ()
 
QPlatformNativeInterface * platformNativeInterface ()
 
QScreenprimaryScreen ()
 
Qt::KeyboardModifiers queryKeyboardModifiers ()
 
bool quitOnLastWindowClosed ()
 
void restoreOverrideCursor ()
 
QScreenscreenAt (const QPoint &point)
 
QList< QScreen * > screens ()
 
void setApplicationDisplayName (const QString &name)
 
void setDesktopFileName (const QString &name)
 
void setDesktopSettingsAware (bool on)
 
void setFallbackSessionManagementEnabled (bool enabled)
 
void setFont (const QFont &font)
 
void setHighDpiScaleFactorRoundingPolicy (Qt::HighDpiScaleFactorRoundingPolicy policy)
 
void setLayoutDirection (Qt::LayoutDirection direction)
 
void setOverrideCursor (const QCursor &cursor)
 
void setPalette (const QPalette &pal)
 
void setQuitOnLastWindowClosed (bool quit)
 
void setWindowIcon (const QIcon &icon)
 
QStyleHintsstyleHints ()
 
void sync ()
 
QWindowtopLevelAt (const QPoint &pos)
 
QWindowList topLevelWindows ()
 
QIcon windowIcon ()
 
- Static Public Member Functions inherited from QCoreApplication
void addLibraryPath (const QString &path)
 
QString applicationDirPath ()
 
QString applicationFilePath ()
 
QString applicationName ()
 
qint64 applicationPid ()
 
QString applicationVersion ()
 
QStringList arguments ()
 
bool closingDown ()
 
QAbstractEventDispatchereventDispatcher ()
 
int exec ()
 
void exit (int returnCode)
 
void flush ()
 
bool hasPendingEvents ()
 
bool installTranslator (QTranslator *translationFile)
 
QCoreApplicationinstance ()
 
bool isQuitLockEnabled ()
 
bool isSetuidAllowed ()
 
QStringList libraryPaths ()
 
QString organizationDomain ()
 
QString organizationName ()
 
void postEvent (QObject *receiver, QEvent *event, int priority)
 
void processEvents (QEventLoop::ProcessEventsFlags flags)
 
void processEvents (QEventLoop::ProcessEventsFlags flags, int ms)
 
void quit ()
 
void removeLibraryPath (const QString &path)
 
void removePostedEvents (QObject *receiver, int eventType)
 
bool removeTranslator (QTranslator *translationFile)
 
bool sendEvent (QObject *receiver, QEvent *event)
 
void sendPostedEvents (QObject *receiver, int event_type)
 
void setApplicationName (const QString &application)
 
void setApplicationVersion (const QString &version)
 
void setAttribute (Qt::ApplicationAttribute attribute, bool on)
 
void setEventDispatcher (QAbstractEventDispatcher *eventDispatcher)
 
void setLibraryPaths (const QStringList &paths)
 
void setOrganizationDomain (const QString &orgDomain)
 
void setOrganizationName (const QString &orgName)
 
void setQuitLockEnabled (bool enabled)
 
void setSetuidAllowed (bool allow)
 
bool startingUp ()
 
bool testAttribute (Qt::ApplicationAttribute attribute)
 
QString translate (const char *context, const char *sourceText, const char *disambiguation, int n)
 
QString translate (const char *context, const char *key, const char *disambiguation, QCoreApplication::Encoding encoding, int n)
 
- Static Public Member Functions inherited from QObject
QMetaObject::Connection connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, Functor functor)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type)
 
bool disconnect (const QMetaObject::Connection &connection)
 
bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method)
 
bool disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method)
 
bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method)
 
QString tr (const char *sourceText, const char *disambiguation, int n)
 
QString trUtf8 (const char *sourceText, const char *disambiguation, int n)
 

Protected Member Functions

 KApplication (bool GUIenabled, const KComponentData &cData)
 
- Protected Member Functions inherited from QApplication
virtual bool event (QEvent *e) override
 
- Protected Member Functions inherited from QObject
virtual void childEvent (QChildEvent *event)
 
virtual void connectNotify (const QMetaMethod &signal)
 
virtual void customEvent (QEvent *event)
 
virtual void disconnectNotify (const QMetaMethod &signal)
 
bool isSignalConnected (const QMetaMethod &signal) const const
 
int receivers (const char *signal) const const
 
QObjectsender () const const
 
int senderSignalIndex () const const
 
virtual void timerEvent (QTimerEvent *event)
 

Static Protected Attributes

static KApplicationKApp = nullptr
 

Additional Inherited Members

- Public Types inherited from QApplication
enum  ColorSpec
 
- Public Types inherited from QCoreApplication
enum  Encoding
 
- Properties inherited from QApplication
 autoSipEnabled
 
 cursorFlashTime
 
 doubleClickInterval
 
 globalStrut
 
 keyboardInputInterval
 
 startDragDistance
 
 startDragTime
 
 styleSheet
 
 wheelScrollLines
 
 windowIcon
 
- Properties inherited from QGuiApplication
 applicationDisplayName
 
 desktopFileName
 
 layoutDirection
 
 platformName
 
 primaryScreen
 
 quitOnLastWindowClosed
 
 windowIcon
 
- Properties inherited from QCoreApplication
 applicationName
 
 applicationVersion
 
 organizationDomain
 
 organizationName
 
 quitLockEnabled
 
- Properties inherited from QObject
 objectName
 
- Public Attributes inherited from QApplication
 CustomColor
 
 ManyColor
 
 NormalColor
 
- Public Attributes inherited from QCoreApplication
 CodecForTr
 
 DefaultCodec
 
 Latin1
 
 UnicodeUTF8
 
- Public Attributes inherited from QObject
typedef QObjectList
 

Detailed Description

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 'kapp' global variable.

This class provides the following services to all KDE applications.

  • It controls the event queue (see QApplication ).
  • It provides the application with KDE resources such as accelerators, common menu entries, a KConfig object. session management events, help invocation etc.
  • Installs an empty signal handler for the SIGPIPE signal. If you want to catch this signal yourself, you have set a new signal handler after KApplication's constructor has run.
  • It can start new services

Controls and provides information to all KDE applications.

Author
Matthias Kalle Dalheimer kalle[email protected]@kde[email protected].org

Definition at line 76 of file kapplication.h.

Constructor & Destructor Documentation

KApplication::KApplication ( bool  GUIenabled = true)
explicit

This constructor is the one you should use.

It takes aboutData and command line arguments from KCmdLineArgs.

Parameters
GUIenabledSet to false to disable all GUI stuff. Note that for a non-GUI daemon, you might want to use QCoreApplication and a KComponentData instance instead. You'll save an unnecessary dependency to kdeui. The main difference is that you will have to do a number of things yourself:

Definition at line 302 of file kapplication.cpp.

KApplication::KApplication ( bool  GUIenabled,
const KComponentData cData 
)
protected

Used by KUniqueApplication

Definition at line 312 of file kapplication.cpp.

Member Function Documentation

QString KApplication::checkRecoverFile ( const QString pFilename,
bool &  bRecover 
)
static

Check whether an auto-save file exists for the document you want to open.

Parameters
pFilenameThe full path to the document you want to open.
bRecoverThis gets set to true if there was a recover file.
Returns
The full path of the file to open.

Definition at line 904 of file kapplication.cpp.

void KApplication::clearStartupId ( )

Used only by KStartupId.

Definition at line 966 of file kapplication.cpp.

void KApplication::commitData ( QSessionManager sm)
slot

Slot connected to QGuiApplication::commitDataRequest() to implement highlevel handling of session management with KSessionManager.

Definition at line 547 of file kapplication.cpp.

void KApplication::disableSessionManagement ( )

Disables session management for this application.

Useful in case your application is started by the initial "startkde" script.

Deprecated:
, use qunsetenv("SESSION_MANAGER") (X11-specific) or

TODO: contribute a QGuiApplication::disableSessionManagement() method

Definition at line 515 of file kapplication.cpp.

void KApplication::enableSessionManagement ( )

Enables session management for this application, formerly disabled by calling disableSessionManagement().

You usually shouldn't call this function, as session management is enabled by default.

Definition at line 520 of file kapplication.cpp.

void KApplication::installX11EventFilter ( QWidget filter)
Deprecated:
since 5.0, use QCoreApplication::installNativeEventFilter Installs 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.

Definition at line 257 of file kapplication.cpp.

KApplication * KApplication::kApplication ( )
static

Returns 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.

Returns
the current application object

Definition at line 495 of file kapplication.cpp.

void KApplication::removeX11EventFilter ( const QWidget filter)
Deprecated:
since 5.0, use QCoreApplication::removeNativeEventFilter Removes global X11 event filter previously installed by installX11EventFilter().

Definition at line 274 of file kapplication.cpp.

void KApplication::saveState ( QSessionManager sm)
slot

Slot connected to QGuiApplication::saveStateRequest() to implement highlevel handling of session management with KSessionManager.

Definition at line 643 of file kapplication.cpp.

void KApplication::saveYourself ( )
signal
Deprecated:
since 5.0, connect to saveStateRequest instead

Session management asks you to save the state of your application.

This signal is provided for compatibility only. For new applications, 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 KSessionManager and reimplement the functions KSessionManager::commitData() and/or KSessionManager::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 data.

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 aboutToQuit().

KConfig * KApplication::sessionConfig ( )
Deprecated:
Returns the application session config object.
Returns
A pointer to the application's instance specific KConfig object.
See also
KConfigGui::sessionConfig

Definition at line 500 of file kapplication.cpp.

bool KApplication::sessionSaving ( ) const
Deprecated:
since 5.0, use QGuiApplication::isSavingSession()

Returns true if the application is currently saving its session data (most probably before KDE logout). This is intended for use mainly in KMainWindow::queryClose() and KMainWindow::queryExit().

See also
KMainWindow::queryClose
KMainWindow::queryExit

Definition at line 728 of file kapplication.cpp.

void KApplication::setStartupId ( const QByteArray startup_id)
Deprecated:
Sets a new value for the application startup notification window property for newly created toplevel windows.
Parameters
startup_idthe startup notification identifier
See also
KStartupInfo::setStartupId
KStartupInfo::setNewStartupId

Definition at line 961 of file kapplication.cpp.

void KApplication::setTopWidget ( QWidget topWidget)

Sets the top widget of the application.

This means basically applying the right window caption. An application may have several top widgets. You don't need to call this function manually when using KMainWindow.

Parameters
topWidgetA top widget of the application.
See also
icon(), caption()
Deprecated:
since 5.0. This was doing two things: 1) setting the window title to include the appname; Qt now takes care of that on platforms where this is wanted. 2) setting the window startup ID, which Qt should take care of in the future. -> simply remove this call.

Definition at line 939 of file kapplication.cpp.

QByteArray KApplication::startupId ( ) const
Deprecated:
Returns the app startup notification identifier for this running application.
Returns
the startup notification identifier
See also
KStartupInfo::startupId

Definition at line 956 of file kapplication.cpp.

QString KApplication::tempSaveName ( const QString pFilename)
static

Get a file name in order to make a temporary copy of your document.

Parameters
pFilenameThe full path to the current file of your document.
Returns
A new filename for auto-saving.
Deprecated:
use QTemporaryFile, QSaveFile or KAutoSaveFile instead

Definition at line 876 of file kapplication.cpp.

void KApplication::updateRemoteUserTimestamp ( const QString service,
int  time = 0 
)

Updates the last user action timestamp in the application registered to DBUS with id service to the given time, or to this application's user time, if 0 is given.

Use before causing user interaction in the remote application, e.g. invoking a dialog in the application using a DCOP call. Consult focus stealing prevention section in kdebase/kwin/README.

Definition at line 859 of file kapplication.cpp.

void KApplication::updateUserTimestamp ( int  time = 0)
slot
Deprecated:
Updates the last user action timestamp to the given time, or to the current time, if 0 is given.

Do not use unless you're really sure what you're doing. Consult focus stealing prevention section in kdebase/kwin/README.

See also
KUserTimestamp::updateUserTimestamp

Definition at line 849 of file kapplication.cpp.

unsigned long KApplication::userTimestamp ( ) const
Deprecated:
Returns the last user action timestamp or 0 if no user activity has taken place yet.
See also
updateuserTimestamp
KUserTimestamp::userTimestamp

Definition at line 854 of file kapplication.cpp.

Member Data Documentation

KApplication * KApplication::KApp = nullptr
staticprotected

Current application object.

Definition at line 411 of file kapplication.h.


The documentation for this class was generated from the following files:
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Tue Jul 7 2020 22:56:52 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.