Commit e81f4bd9 authored by Christoph Cullmann's avatar Christoph Cullmann

KateWaiter in own file

parent dbb52f23
......@@ -44,6 +44,7 @@ set (KATE_APPLICATION_SRCS
app/katerunninginstanceinfo.cpp
app/kateappcommands.cpp
app/katequickopen.cpp
app/katewaiter.h
app/main.cpp)
# create kde init executable
......
/* This file is part of the KDE libraries
Copyright (C) 2005 Christoph Cullmann <cullmann@kde.org>
Copyright (C) 2002, 2003 Joseph Wenninger <jowenn@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef __KATE_WAITER_H__
#define __KATE_WAITER_H__
#include <QCoreApplication>
#include <QObject>
#include <QDBusConnection>
#include <QDBusConnectionInterface>
class KateWaiter : public QObject {
Q_OBJECT
private:
QCoreApplication *m_app;
QString m_service;
QStringList m_tokens;
public:
KateWaiter (QCoreApplication *app, const QString &service,const QStringList &tokens)
: QObject (app), m_app (app), m_service (service),m_tokens(tokens) {
connect ( QDBusConnection::sessionBus().interface(), SIGNAL(serviceOwnerChanged(QString,QString,QString))
, this, SLOT(serviceOwnerChanged(QString,QString,QString)) );
}
public Q_SLOTS:
void exiting () {
m_app->quit ();
}
void documentClosed(const QString& token) {
m_tokens.removeAll(token);
if (m_tokens.count()==0) m_app->quit();
}
void serviceOwnerChanged( const QString & name, const QString &, const QString &) {
if (name != m_service)
return;
m_app->quit ();
}
};
#endif
......@@ -21,6 +21,7 @@
#include "kateapp.h"
#include "katerunninginstanceinfo.h"
#include "katewaiter.h"
#include <KAboutData>
#include <KLocalizedString>
......@@ -28,52 +29,16 @@
#include <QByteArray>
#include <QCommandLineParser>
#include <QCoreApplication>
#include <QLoggingCategory>
#include <QTextCodec>
#include <QUrl>
#include <QVariant>
#include <QDBusConnection>
#include <QDBusConnectionInterface>
#include <QDBusInterface>
#include <QDBusMessage>
#include <QDBusReply>
#include <QApplication>
#include <QDir>
class KateWaiter : public QObject {
Q_OBJECT
private:
QCoreApplication *m_app;
QString m_service;
QStringList m_tokens;
public:
KateWaiter (QCoreApplication *app, const QString &service,const QStringList &tokens)
: QObject (app), m_app (app), m_service (service),m_tokens(tokens) {
connect ( QDBusConnection::sessionBus().interface(), SIGNAL(serviceOwnerChanged(QString,QString,QString))
, this, SLOT(serviceOwnerChanged(QString,QString,QString)) );
}
public Q_SLOTS:
void exiting () {
m_app->quit ();
}
void documentClosed(const QString& token) {
m_tokens.removeAll(token);
if (m_tokens.count()==0) m_app->quit();
}
void serviceOwnerChanged( const QString & name, const QString &, const QString &) {
if (name != m_service)
return;
m_app->quit ();
}
};
extern "C" Q_DECL_EXPORT int kdemain( int argc, char **argv )
{
QLoggingCategory::setFilterRules(QStringLiteral("kate = true"));
......@@ -446,5 +411,3 @@ extern "C" Q_DECL_EXPORT int kdemain( int argc, char **argv )
*/
return app.exec();
}
#include "main.moc"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment