/* -*- Mode: C++; indent-tabs-mode: nil; tab-width: 4 -*-
 * -*- coding: utf-8 -*-
 *
 * Copyright (C) 2024 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 by
 * 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 __DEVICES_TOUCHPAD_H__
#define __DEVICES_TOUCHPAD_H__

#include <memory>
#include <QObject>
#include <QProcess>
#include <QMetaEnum>
#include <QMetaObject>
#include <QtDBus/QtDBus>
#include <QDBusInterface>
#include <QtCore/QCoreApplication>

#include "../../usd-common.h"

class TouchpadManager : public QObject {
    Q_OBJECT
    Q_CLASSINFO("D-Bus Interface", "org.ukui.Framework.Devices.Touchpad")
public:
    explicit TouchpadManager(QObject *parent = nullptr);
    ~TouchpadManager();
public Q_SLOTS:
    /**
     * @brief IsEnable 获取触摸板状态
     * @return false 关， true开
     */
    bool IsEnable();

    /**
     * @brief Enable 设置触摸板状态
     * @param state false 关闭，true开
     */
    void Enable(bool state);

    int GetTouchpadCount();

private Q_SLOTS:
    void onTouchpadStateChanged(bool state);

private:
    void connectTouchpadManager();

    template <typename...Args>
    QDBusMessage callInputDbus(const QString &method, Args &&...args);

    void initSignals();

Q_SIGNALS:
    /**
     * @brief EnableChanged 触摸板使能状态改变信号
     */
    void EnableChanged(bool);

    void TouchpadCountChanged(int count);
};

#endif
