KDSingleApplication API Documentation 1.1
Loading...
Searching...
No Matches
kdsingleapplication.h
Go to the documentation of this file.
1/*
2 This file is part of KDSingleApplication.
3
4 SPDX-FileCopyrightText: 2019 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
5
6 SPDX-License-Identifier: MIT
7
8 Contact KDAB at <info@kdab.com> for commercial licensing options.
9*/
10#ifndef KDSINGLEAPPLICATION_H
11#define KDSINGLEAPPLICATION_H
12
13#include <QtCore/QObject>
14#include <QtCore/QFlags>
15
16#include <memory>
17
19
20class KDSingleApplicationPrivate;
21
23{
24 Q_OBJECT
25 Q_PROPERTY(QString name READ name CONSTANT)
26 Q_PROPERTY(bool isPrimaryInstance READ isPrimaryInstance CONSTANT)
27
28public:
29 // IncludeUsernameInSocketName - Include the username in the socket name.
30 // IncludeSessionInSocketName - Include the graphical session in the socket name.
31 enum class Option {
32 None = 0x0,
33 IncludeUsernameInSocketName = 0x1,
34 IncludeSessionInSocketName = 0x2,
35 };
36 Q_DECLARE_FLAGS(Options, Option)
37
38 explicit KDSingleApplication(QObject *parent = nullptr);
39 explicit KDSingleApplication(const QString &name, QObject *parent = nullptr);
40 explicit KDSingleApplication(const QString &name, Options options, QObject *parent = nullptr);
42
43 QString name() const;
44 bool isPrimaryInstance() const;
45
46public Q_SLOTS:
47 // avoid default arguments and overloads, as they don't mix with connections
48 bool sendMessage(const QByteArray &message);
49 bool sendMessageWithTimeout(const QByteArray &message, int timeout);
50
52 void messageReceived(const QByteArray &message);
53
54private:
55 Q_DECLARE_PRIVATE(KDSingleApplication)
56 std::unique_ptr<KDSingleApplicationPrivate> d_ptr;
57};
58
59Q_DECLARE_OPERATORS_FOR_FLAGS(KDSingleApplication::Options)
60
61#endif // KDSINGLEAPPLICATION_H
void messageReceived(const QByteArray &message)
#define KDSINGLEAPPLICATION_EXPORT
Q_PROPERTY(...)
Q_SIGNALSQ_SIGNALS
Q_SLOTSQ_SLOTS

© Klarälvdalens Datakonsult AB (KDAB)
"The Qt, C++ and OpenGL Experts"
https://www.kdab.com/
KDSingleApplication
A helper class for single-instance policy Qt applications
Generated on Tue Jul 9 2024 00:00:38 for KDSingleApplication API Documentation by doxygen 1.9.8