#ifndef SHORTCUTUI_H
#define SHORTCUTUI_H

#include "settinggroup.h"
#include "addbutton.h"
#include "fixlabel.h"
#include "titlelabel.h"
#include "doubleclicklineedit.h"
#include "clickfixlabel.h"
#include "addshortcutdialog.h"

#include <QHBoxLayout>
#include <QWidget>
#include <QMenu>
#include <QMessageBox>

class ShortcutUi : public QWidget
{
    Q_OBJECT
public:
    ShortcutUi();
    ~ShortcutUi();
    void addSystemShortcut(const QString &name, const QString &shortcut, const QString &mediaKey, KeyEntryList *systemEntryList, KeyEntryList *customEntryList);
    void addCustomShortcut(KeyEntry keyEntry, KeyEntryList *systemEntryList, KeyEntryList *customEntryList);
    void clearCustomShorcutFrame();

private:
    void initUi();
    void initSystem();
    void initCustom();
    void updateGeneralShort(DoubleClickShortCut *shortCutEdit, QString key, QString value, bool isConflict);

    QString getShowShortcutString(QString src);
    QString keyToLib(QString key);
    QString conflictTip(const QString &key, const QString &value);
private:
    QVBoxLayout *uiLayout     = nullptr;
    QVBoxLayout *systemLayout = nullptr;
    QVBoxLayout *customLayout = nullptr;

private:
    TitleLabel   *systemTitle         = nullptr;
    SettingGroup *systemShortcutGroup = nullptr;

private:
    TitleLabel   *customTitle         = nullptr;
    SettingGroup *customShortcutGroup = nullptr;
    AddButton    *addButton           = nullptr;

    QList<KeyEntry>              mSystemEntryList;
    QList<KeyEntry>              mCustomEntryList;

    QList<DoubleClickShortCut *> mGeneralLineEdit;
    QList<ClickFixLabel *>       mGeneralName;
    QList<DoubleClickShortCut *> mCustomLineEdit;
    QList<ClickFixLabel *>       mCustomName;

    QMap<QString, QString>       mAllKeyI18nName;

Q_SIGNALS:
    void deleteShortcut(const QString &path);
    void toCreateShortcut(QString path, QString name, QString exec, QString key, bool buildFlag = true, bool convertFlag = true);
    void addButtonClicked();
    void updateSystemShortcut(const QString &key, const QString &value);
    void updateCustomShortcut(const QByteArray &path, const QString &key, const QString &value);
};

#endif // SHORTCUTUI_H
