File indexing completed on 2025-01-26 05:06:18

0001 /*
0002     SPDX-FileCopyrightText: 2016, 2019 Kai Uwe Broulik <kde@privat.broulik.de>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include <QObject>
0010 #include <QUrl>
0011 #include <QWeakPointer>
0012 
0013 #include "smartlauncherbackend.h"
0014 
0015 namespace SmartLauncher
0016 {
0017 class Item : public QObject
0018 {
0019     Q_OBJECT
0020 
0021     Q_PROPERTY(QUrl launcherUrl READ launcherUrl WRITE setLauncherUrl NOTIFY launcherUrlChanged)
0022 
0023     Q_PROPERTY(int count READ count NOTIFY countChanged)
0024     Q_PROPERTY(bool countVisible READ countVisible NOTIFY countVisibleChanged)
0025     Q_PROPERTY(int progress READ progress NOTIFY progressChanged)
0026     Q_PROPERTY(bool progressVisible READ progressVisible NOTIFY progressVisibleChanged)
0027     Q_PROPERTY(bool urgent READ urgent NOTIFY urgentChanged)
0028 
0029 public:
0030     explicit Item(QObject *parent = nullptr);
0031     ~Item() override = default;
0032 
0033     QUrl launcherUrl() const;
0034     void setLauncherUrl(const QUrl &launcherUrl);
0035 
0036     int count() const;
0037     bool countVisible() const;
0038     int progress() const;
0039     bool progressVisible() const;
0040     bool urgent() const;
0041 
0042 Q_SIGNALS:
0043     void launcherUrlChanged(const QUrl &launcherUrl);
0044 
0045     void countChanged(int count);
0046     void countVisibleChanged(bool countVisible);
0047     void progressChanged(int progress);
0048     void progressVisibleChanged(bool progressVisible);
0049     void urgentChanged(bool urgent);
0050 
0051 private:
0052     void init();
0053 
0054     void populate();
0055     void clear();
0056 
0057     void setCount(int count);
0058     void setCountVisible(bool countVisible);
0059     void setProgress(int progress);
0060     void setProgressVisible(bool progressVisible);
0061     void setUrgent(bool urgent);
0062 
0063     static std::weak_ptr<Backend> s_backend;
0064 
0065     std::shared_ptr<Backend> m_backendPtr;
0066 
0067     QUrl m_launcherUrl;
0068     QString m_storageId;
0069 
0070     bool m_inited = false;
0071 
0072     int m_count = 0;
0073     bool m_countVisible = false;
0074     int m_progress = 0;
0075     bool m_progressVisible = false;
0076     bool m_urgent = false;
0077 };
0078 
0079 } // namespace SmartLauncher