File indexing completed on 2024-05-05 05:29:12
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 0008 #include "UnityLauncher.h" 0009 0010 #include <QDBusConnection> 0011 #include <QDBusMessage> 0012 #include <QVariantMap> 0013 0014 UnityLauncher::UnityLauncher(QObject *parent) 0015 : QObject(parent) 0016 { 0017 } 0018 0019 UnityLauncher::~UnityLauncher() = default; 0020 0021 QString UnityLauncher::launcherId() const 0022 { 0023 return m_launcherId; 0024 } 0025 0026 void UnityLauncher::setLauncherId(const QString &launcherId) 0027 { 0028 m_launcherId = launcherId; 0029 } 0030 0031 bool UnityLauncher::progressVisible() const 0032 { 0033 return m_progressVisible; 0034 } 0035 0036 void UnityLauncher::setProgressVisible(bool progressVisible) 0037 { 0038 if (m_progressVisible != progressVisible) { 0039 m_progressVisible = progressVisible; 0040 0041 update({{QStringLiteral("progress-visible"), progressVisible}}); 0042 } 0043 } 0044 0045 int UnityLauncher::progress() const 0046 { 0047 return m_progress; 0048 } 0049 0050 void UnityLauncher::setProgress(int progress) 0051 { 0052 if (m_progress != progress) { 0053 m_progress = progress; 0054 0055 update({{QStringLiteral("progress"), progress / 100.0}}); 0056 } 0057 } 0058 0059 void UnityLauncher::update(const QVariantMap &properties) 0060 { 0061 if (m_launcherId.isEmpty()) { 0062 return; 0063 } 0064 0065 QDBusMessage message = QDBusMessage::createSignal(QStringLiteral("/org/discover/UnityLauncher"), 0066 QStringLiteral("com.canonical.Unity.LauncherEntry"), 0067 QStringLiteral("Update")); 0068 message.setArguments({m_launcherId, properties}); 0069 QDBusConnection::sessionBus().send(message); 0070 }