13 #include <QtCore/QCoreApplication>
14 #include <QtCore/QFileInfo>
17 #include "kdsingleapplication_localsocket_p.h"
21 class KDSingleApplicationPrivate
24 explicit KDSingleApplicationPrivate(
const QString &name, KDSingleApplication::Options options,
KDSingleApplication *q);
31 bool isPrimaryInstance()
const
33 return m_impl.isPrimaryInstance();
36 bool sendMessage(
const QByteArray &message,
int timeout)
38 return m_impl.sendMessage(message, timeout);
47 KDSingleApplicationLocalSocket m_impl;
50 KDSingleApplicationPrivate::KDSingleApplicationPrivate(
const QString &name, KDSingleApplication::Options options,
KDSingleApplication *q)
53 , m_impl(name, options)
55 if (Q_UNLIKELY(name.isEmpty()))
56 qFatal(
"KDSingleApplication requires a non-empty application name");
58 if (isPrimaryInstance()) {
59 QObject::connect(&m_impl, &KDSingleApplicationLocalSocket::messageReceived,
66 return QFileInfo(applicationFilePath).fileName();
76 , d_ptr(new KDSingleApplicationPrivate(name,
Option::IncludeUsernameInSocketName |
Option::IncludeSessionInSocketName, this))
82 , d_ptr(new KDSingleApplicationPrivate(name, options, this))
95 return d->isPrimaryInstance();
108 return d->sendMessage(message, timeout);
bool sendMessage(const QByteArray &message)
bool sendMessageWithTimeout(const QByteArray &message, int timeout)
void messageReceived(const QByteArray &message)
KDSingleApplication(QObject *parent=nullptr)
static QString extractExecutableName(const QString &applicationFilePath)