File indexing completed on 2024-05-12 05:21:08
0001 /* This file is part of the KDE project 0002 0003 SPDX-FileCopyrightText: 2008 David Faure <faure@kde.org> 0004 0005 SPDX-License-Identifier: LGPL-2.0-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0006 */ 0007 #pragma once 0008 0009 #include "kontactinterface_export.h" 0010 0011 #include <QApplication> 0012 #include <memory> 0013 0014 class KAboutData; 0015 class QCommandLineParser; 0016 0017 namespace KontactInterface 0018 { 0019 /** 0020 * KDEPIM applications which can be integrated into kontact should use 0021 * PimUniqueApplication instead of QApplication + Dbus unique. 0022 * This makes command-line handling work, i.e. you can launch "korganizer" 0023 * and if kontact is already running, it will load the korganizer part and 0024 * switch to it. 0025 */ 0026 class KONTACTINTERFACE_EXPORT PimUniqueApplication : public QApplication 0027 { 0028 Q_OBJECT 0029 Q_CLASSINFO("D-Bus Interface", "org.kde.PIMUniqueApplication") 0030 0031 public: 0032 explicit PimUniqueApplication(int &argc, char **argv[]); 0033 ~PimUniqueApplication() override; 0034 0035 void setAboutData(KAboutData &aboutData); 0036 0037 /** 0038 * Register this process as a unique application, if not already running. 0039 * Typically called in main(). 0040 * @param arguments should start with the appname, as QCoreApplication::arguments() does. 0041 */ 0042 static bool start(const QStringList &arguments); 0043 0044 [[nodiscard]] QCommandLineParser *cmdArgs() const; 0045 0046 public Q_SLOTS: 0047 Q_SCRIPTABLE int newInstance(); 0048 Q_SCRIPTABLE virtual int newInstance(const QByteArray &startupId, const QStringList &arguments, const QString &workingDirectory); 0049 0050 protected: 0051 virtual int activate(const QStringList &arguments, const QString &workingDirectory); 0052 0053 private: 0054 //@cond PRIVATE 0055 class PimUniqueApplicationPrivate; 0056 std::unique_ptr<PimUniqueApplicationPrivate> const d; 0057 //@endcond 0058 }; 0059 0060 }