#ifndef SHORTCUTINTERFACE_H
#define SHORTCUTINTERFACE_H

#include <QObject>
#include <QtDBus>
#include <QMap>
#include "getshortcutworker.h"
#include "type.h"
#include "../../universalinterface.h"

class ShortcutInterface : public QObject {
    Q_OBJECT
    Q_CLASSINFO("D-Bus Interface", "org.ukui.ukcc.session.Shortcut")

public:
    ShortcutInterface();
    ~ShortcutInterface();

Q_SIGNALS:
    void changed(QString key);

public Q_SLOTS:
    QList<QStringPair> getSystemShortcut();
    QList<QStringPair> getWindowShortcut();
    QList<KeyEntry> getSystemShortcutEntry();
    QList<KeyEntry> getWindowShortcutEntry();
    QList<KeyEntry> getCustomShortcutEntry();
    QVariantMap getShortKeyValue();
    void updateShortcut();
    void setSystemShortcut(const QString &key, const QString &value);
    void setCustomShortcut(const QString &key, const QString &value);
    void setWindowShortcut(const QString &key, const QString &oldValue, const QString &value);
    void defaultShortcut();

private:
    void getShortcutThread();
    void defaultWindowShortcut();
    void defaultGeneralShortcut();
    QMap<QString, QString> MergerOfTheSamekind(QMap<QString, QString> desktopMap);
    void buildGeneralWidget(QString schema, QMap<QString, QString> subShortcutsMap);
    QString getShowShortcutString(QString src);
    void workerCompleteSlot();
    void generalShortcutSlot(QString schema, QString key, QString value);
    void windowShortcutSlot(QString name, QString key, QString value);
    void customShortcutSlot(QString path,
                            QString name,
                            QString binding,
                            QString action);
    void setDefaultShortcut(QString key, QString value);

private:
    QList<KeyEntry> m_systemEntries;
    QList<KeyEntry> m_windowEntries;
    QList<KeyEntry> m_customEntries;
    QList<KeyEntry> m_windowSortEntries;
    QVariantMap m_shortKeyValue;
    QList<QStringPair> m_systemShortcutList;
    QList<QStringPair> m_windowShortcutList;
};

#endif // SHORTCUTINTERFACE_H
