File indexing completed on 2024-04-28 04:37:28
0001 /* 0002 SPDX-FileCopyrightText: 2016 Kai Uwe Broulik <kde@privat.broulik.de> 0003 0004 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0005 */ 0006 0007 #include "unitylauncher.h" 0008 0009 #include <QDBusConnection> 0010 #include <QDBusMessage> 0011 #include <QVariantMap> 0012 0013 using namespace KDevelop; 0014 0015 UnityLauncher::UnityLauncher(QObject *parent) : QObject(parent) 0016 { 0017 0018 } 0019 0020 UnityLauncher::~UnityLauncher() = default; 0021 0022 QString UnityLauncher::launcherId() const 0023 { 0024 return m_launcherId; 0025 } 0026 0027 void UnityLauncher::setLauncherId(const QString &launcherId) 0028 { 0029 m_launcherId = launcherId; 0030 } 0031 0032 bool UnityLauncher::progressVisible() const 0033 { 0034 return m_progressVisible; 0035 } 0036 0037 void UnityLauncher::setProgressVisible(bool progressVisible) 0038 { 0039 if (m_progressVisible != progressVisible) { 0040 m_progressVisible = progressVisible; 0041 0042 update({ {QStringLiteral("progress-visible"), progressVisible} }); 0043 } 0044 } 0045 0046 int UnityLauncher::progress() const 0047 { 0048 return m_progress; 0049 } 0050 0051 void UnityLauncher::setProgress(int progress) 0052 { 0053 if (m_progress != progress) { 0054 m_progress = progress; 0055 0056 update({ {QStringLiteral("progress"), progress / 100.0} }); 0057 } 0058 } 0059 0060 void UnityLauncher::update(const QVariantMap &properties) 0061 { 0062 if (m_launcherId.isEmpty()) { 0063 return; 0064 } 0065 0066 QDBusMessage message = QDBusMessage::createSignal(QStringLiteral("/org/kdevelop/UnityLauncher"), 0067 QStringLiteral("com.canonical.Unity.LauncherEntry"), 0068 QStringLiteral("Update")); 0069 message.setArguments({m_launcherId, properties}); 0070 QDBusConnection::sessionBus().send(message); 0071 } 0072 0073 #include "moc_unitylauncher.cpp"