#include "shortcutconfig.h"
#include "ui_shortcutconfig.h"
#include "globalinfo.h"

ShortcutConfig::ShortcutConfig(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::ShortcutConfig)
{
    ui->setupUi(this);
    //    ui->keySequenceEdit
    QSettings configIniWrite("jcxclient.ini", QSettings::IniFormat);

    QVariant key1 = configIniWrite.value("Shortcut/key1", "F1");
    QVariant key2 = configIniWrite.value("Shortcut/key2", "F2");
    QVariant key3 = configIniWrite.value("Shortcut/key3", "F3");

    ui->keySequenceEdit->setKeySequence(key1.toString());
    ui->keySequenceEdit_2->setKeySequence(key2.toString());
    ui->keySequenceEdit_3->setKeySequence(key3.toString());

//    configIniWrite.value("Shortcut/key2");
//    configIniWrite.value("Shortcut/key3");

//    configIniWrite.setValue("Shortcut/key1", "192.168.0.1");
//    configIniWrite.setValue("Shortcut/key2", "127.0.0.1");
//    configIniWrite.setValue("Shortcut/key3", "2222");

}

ShortcutConfig::~ShortcutConfig()
{
    delete ui;
}

void ShortcutConfig::on_pushButton_clicked()
{

    QSettings configIniWrite("jcxclient.ini", QSettings::IniFormat);

    configIniWrite.setValue("Shortcut/key1", ui->keySequenceEdit->keySequence().toString());
    configIniWrite.setValue("Shortcut/key2", ui->keySequenceEdit_2->keySequence().toString());
    configIniWrite.setValue("Shortcut/key3", ui->keySequenceEdit_3->keySequence().toString());

    emit setShortcutConfig();
}
