/* -*- 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 DEVICEMANAGERMAINWIDGET_H
#define DEVICEMANAGERMAINWIDGET_H

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

#include "DeviceManagerWidget.h"

enum class DeviceManagerType {
    Input = 0,
    Output
};

class DeviceManagerMainWidget : public kdk::KWidget
{
    Q_OBJECT
public:
    DeviceManagerMainWidget(QWidget* = nullptr);
    ~DeviceManagerMainWidget() = default;

public:
    void addItem(const DeviceManagerType&, const QString&, const QString&, const QString&);

    void removeItem(const DeviceManagerType&, int);

    void setChecked(const DeviceManagerType&, int, bool);

    DeviceManagerWidget* getManagerWidgetByType(const DeviceManagerType&);

Q_SIGNALS:
    void enableDeviceSignals(const QString&, const QString&, bool);

    void closeWindowSignals();

private:
    void createItems();

    void initUi();

    void initSlots();

private:
    std::unordered_map<DeviceManagerType, QStringList> m_keys {
        {DeviceManagerType::Output, QStringList(std::initializer_list<QString>{"audio-volume-overamplified-symbolic", tr("Output Device")})},
        {DeviceManagerType::Input, QStringList(std::initializer_list<QString>{"ukui-microphone-on-symbolic", tr("Input Device")})}
    };

    kdk::KNavigationBar* m_pNavigationBar = nullptr;
    std::unordered_map<DeviceManagerType, QStandardItem*> m_itemMap;
    std::unordered_map<DeviceManagerType, DeviceManagerWidget*> m_deviceWidgetMap;
};

#endif // DEVICEMANAGERMAINWIDGET_H
