/* -*- Mode: C++; indent-tabs-mode: nil; tab-width: 4 -*-
 * -*- coding: utf-8 -*-
 *
 * Copyright (C) 2025 KylinSoft Co., Ltd.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published
 * the Free Software Foundation, either version 3 of the License, or
 * any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef APPMANAGERMAINWIDGET_H
#define APPMANAGERMAINWIDGET_H

#include <QWidget>
#include <kwidget.h>
#include <knavigationbar.h>
#include <QStackedWidget>

#include "AppManagerItemWidget.h"
#include "DBusClient.h"

class AppManagerMainWidget : public kdk::KWidget
{
    Q_OBJECT
public:
    AppManagerMainWidget(std::list<AppManagerItem>&, QWidget* = nullptr);
    ~AppManagerMainWidget() = default;

public:
    void addItem(int, int, int, bool, const QString&, const QString&, const QList<ClientDeviceInfo>&, const QList<ClientDeviceInfo>&);

    void removeItem(const QString&);

    void setValue(const QString&, int);

    void setMute(const QString&, bool);

    void setCurrentItem(int);

    void setCurrentIndex(const QString&, const NodeType&, int);

    void addPortToAppItem(const QString&, const NodeType&, const QString&, const QVariant&);

    void setAppCbxEnabled(const QString&, const NodeType&, bool);

    void removeProtFromAppItem(const QString&, const NodeType&, int);

    std::list<AppManagerItem>& getAppItems();

    AppManagerItemWidget* getAppWidgetByIndex(int);

Q_SIGNALS:
    void valueChangedSignals(int, int);

    void muteChangedSignals(int);

    void currentIndexChangedSignals(const NodeType&, int, const QString&, const QString&);

    void closeWindowSignals();

private:
    void initUi();

    void initSlots();

private:
    kdk::KNavigationBar* m_pNavigationBar {};
    QStackedWidget* m_pStackedWidget {};
    std::map<QString, QStandardItem*> m_itemMap {};
    std::list<AppManagerItem>& m_appWidgetList;
    QStringList m_blackList {
        "sound-theme-player",
        "ukui-control-center",
        "Echo-Cancel Sink Stream",
        "Echo-Cancel Source Stream"
    };
};

#endif // APPMANAGERMAINWIDGET_H
