mirror of
https://bitbucket.org/smil3y/kdelibs.git
synced 2025-02-23 18:32:49 +00:00
kdeui: new KApplication::quitOnDisconnected() method, also setup quit signal handler by default
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
0f0db0c3a7
commit
38e370d475
4 changed files with 28 additions and 10 deletions
|
@ -586,7 +586,6 @@ int main(int argc, char *argv[])
|
|||
KApplication app;
|
||||
app.setQuitOnLastWindowClosed(false);
|
||||
app.disableSessionManagement();
|
||||
app.quitOnSignal();
|
||||
|
||||
QDBusConnection session = QDBusConnection::sessionBus();
|
||||
if (!session.isConnected()) {
|
||||
|
|
|
@ -465,18 +465,13 @@ void KApplicationPrivate::init()
|
|||
);
|
||||
}
|
||||
}
|
||||
|
||||
// too late to restart if the application is about to quit (e.g. if QApplication::quit() was
|
||||
// called or SIGTERM was received)
|
||||
q->connect(q, SIGNAL(aboutToQuit()), SLOT(_k_disableAutorestartSlot()));
|
||||
|
||||
// TODO: static quitOnDisconnected() method for use with QCoreApplication/QApplication
|
||||
sessionBus.connect(
|
||||
QString(),
|
||||
QString::fromLatin1("/org/freedesktop/DBus/Local"),
|
||||
QString::fromLatin1("org.freedesktop.DBus.Local"),
|
||||
QString::fromLatin1("Disconnected"),
|
||||
q, SLOT(quit())
|
||||
);
|
||||
KApplication::quitOnSignal();
|
||||
KApplication::quitOnDisconnected();
|
||||
|
||||
qRegisterMetaType<KUrl>();
|
||||
qRegisterMetaType<KUrl::List>();
|
||||
|
@ -826,6 +821,21 @@ void KApplication::quitOnSignal()
|
|||
::sigprocmask(SIG_UNBLOCK, &handlermask, NULL);
|
||||
}
|
||||
|
||||
void KApplication::quitOnDisconnected()
|
||||
{
|
||||
if (!qApp) {
|
||||
kWarning(240) << "KApplication::quitOnDisconnected() called before application instance is created";
|
||||
return;
|
||||
}
|
||||
QDBusConnection::sessionBus().connect(
|
||||
QString(),
|
||||
QString::fromLatin1("/org/freedesktop/DBus/Local"),
|
||||
QString::fromLatin1("org.freedesktop.DBus.Local"),
|
||||
QString::fromLatin1("Disconnected"),
|
||||
qApp, SLOT(quit())
|
||||
);
|
||||
}
|
||||
|
||||
void KApplication::setTopWidget( QWidget *topWidget )
|
||||
{
|
||||
if( !topWidget )
|
||||
|
|
|
@ -253,9 +253,19 @@ public:
|
|||
/**
|
||||
* Setups signal handler for SIGTERM, SIGHUP and SIGINT to call QApplication::quit() when such
|
||||
* signal is received.
|
||||
* @note By default KApplication constructor calls this static method, unless QCoreApplication
|
||||
* or QApplication instance is used you should not call it.
|
||||
*/
|
||||
static void quitOnSignal();
|
||||
|
||||
/**
|
||||
* Connects D-Bus disconnected to QApplication::quit().
|
||||
* @note By default KApplication constructor calls this static method, unless QCoreApplication
|
||||
* or QApplication instance is used you should not call it.
|
||||
* @since 4.23
|
||||
*/
|
||||
static void quitOnDisconnected();
|
||||
|
||||
#ifdef Q_WS_X11
|
||||
/**
|
||||
@internal
|
||||
|
|
|
@ -75,7 +75,6 @@ int main(int argc, char *argv[])
|
|||
KApplication app;
|
||||
app.setQuitOnLastWindowClosed(false);
|
||||
app.disableSessionManagement();
|
||||
app.quitOnSignal();
|
||||
|
||||
QDBusConnection session = QDBusConnection::sessionBus();
|
||||
if (!session.isConnected()) {
|
||||
|
|
Loading…
Add table
Reference in a new issue