File indexing completed on 2024-05-12 04:50:47
0001 /* 0002 This file is part of KDSingleApplication. 0003 0004 SPDX-FileCopyrightText: 2019-2023 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com> 0005 0006 SPDX-License-Identifier: MIT 0007 0008 Contact KDAB at <info@kdab.com> for commercial licensing options. 0009 */ 0010 #ifndef KDSINGLEAPPLICATION_H 0011 #define KDSINGLEAPPLICATION_H 0012 0013 #include <QtCore/QObject> 0014 0015 #include <memory> 0016 0017 class KDSingleApplicationPrivate; 0018 0019 class KDSingleApplication : public QObject 0020 { 0021 Q_OBJECT 0022 Q_PROPERTY(QString name READ name CONSTANT) 0023 Q_PROPERTY(bool isPrimaryInstance READ isPrimaryInstance CONSTANT) 0024 0025 public: 0026 explicit KDSingleApplication(QObject *parent = nullptr); 0027 explicit KDSingleApplication(const QString &name, QObject *parent = nullptr); 0028 ~KDSingleApplication(); 0029 0030 QString name() const; 0031 bool isPrimaryInstance() const; 0032 0033 public Q_SLOTS: 0034 // avoid default arguments and overloads, as they don't mix with connections 0035 bool sendMessage(const QByteArray &message); 0036 bool sendMessageWithTimeout(const QByteArray &message, int timeout); 0037 0038 Q_SIGNALS: 0039 void messageReceived(const QByteArray &message); 0040 0041 private: 0042 Q_DECLARE_PRIVATE(KDSingleApplication) 0043 std::unique_ptr<KDSingleApplicationPrivate> d_ptr; 0044 }; 0045 0046 #endif // KDSINGLEAPPLICATION_H