File indexing completed on 2024-07-21 04:58:11

0001 /*
0002     SPDX-FileCopyrightText: 2020 Michail Vourlakos <mvourlakos@gmail.com>
0003     SPDX-License-Identifier: GPL-2.0-or-later
0004 */
0005 
0006 #ifndef INDICATORUIMANAGER_H
0007 #define INDICATORUIMANAGER_H
0008 
0009 //Qt
0010 #include <QList>
0011 #include <QObject>
0012 #include <QQuickItem>
0013 #include <QPointer>
0014 
0015 namespace KDeclarative
0016 {
0017 class QmlObjectSharedEngine;
0018 }
0019 
0020 namespace Latte {
0021 class View;
0022 }
0023 
0024 namespace Latte {
0025 namespace ViewPart {
0026 class PrimaryConfigView;
0027 }
0028 }
0029 
0030 namespace Latte {
0031 namespace ViewPart {
0032 namespace Config {
0033 
0034 struct IndicatorUiData
0035 {
0036     QString type;
0037     QString pluginPath;
0038     QString name;
0039     QPointer<Latte::View> view;
0040     QPointer<KDeclarative::QmlObjectSharedEngine> ui;
0041 };
0042 
0043 class IndicatorUiManager : public QObject
0044 {
0045     Q_OBJECT
0046 
0047 public:
0048     IndicatorUiManager(ViewPart::PrimaryConfigView *parent);
0049     ~IndicatorUiManager() override;
0050 
0051 public slots:
0052     Q_INVOKABLE void addIndicator();
0053     Q_INVOKABLE void downloadIndicator();
0054     Q_INVOKABLE void removeIndicator(QString pluginId);
0055     Q_INVOKABLE void setParentItem(QQuickItem *parentItem);
0056     Q_INVOKABLE void ui(const QString &type, Latte::View *view);
0057 
0058     Q_INVOKABLE int index(const QString &type);
0059 private:
0060     bool contains(const QString &type);
0061 
0062     void hideAllUi();
0063     void showNextIndicator();
0064 
0065 private:
0066     QQuickItem *m_parentItem{nullptr};
0067     PrimaryConfigView *m_primary{nullptr};
0068 
0069     QList<IndicatorUiData> m_uidata;
0070 
0071 };
0072 
0073 }
0074 }
0075 }
0076 
0077 #endif
0078