diff --git a/README.md b/README.md index 3bde4c5..06cecd9 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,7 @@ Great thanks to him. make make clean cp -r ../lang ./ - cp ../configs.json ./ + cp -r ../config ./ ./Proxmark3GUI *** diff --git a/common/pm3process.cpp b/common/pm3process.cpp index 171b761..0546e2c 100644 --- a/common/pm3process.cpp +++ b/common/pm3process.cpp @@ -108,7 +108,7 @@ void PM3Process::setSerialListener(bool state) void PM3Process::onTimeout() //when the proxmark3 client is unexpectedly terminated or the PM3 hardware is removed, the isBusy() will return false(only tested on Windows); { // isBusy() is a deprecated function because it will block the serial port when the port is not in use. -// However, the PM3 client is supposed to use the serial port exclusively, so it should be fine +// However, the PM3 client is supposed to use the target serial port exclusively, so it should be fine // isBusy() will always return false on Raspbian, in this case, check "Keep the client active" in the Settings panel. // // qDebug()<isBusy(); diff --git a/configs_official.json b/config/config_official.json similarity index 100% rename from configs_official.json rename to config/config_official.json diff --git a/configs_rrgv4.13.json b/config/config_rrgv4.13.json similarity index 100% rename from configs_rrgv4.13.json rename to config/config_rrgv4.13.json diff --git a/ui/mainwindow.cpp b/ui/mainwindow.cpp index b3c04a9..d901c55 100644 --- a/ui/mainwindow.cpp +++ b/ui/mainwindow.cpp @@ -40,16 +40,6 @@ MainWindow::MainWindow(QWidget *parent): mifare = new Mifare(ui, util, this); lf = new LF(ui, util, this); - QFile configList("configs.json"); - if(!configList.open(QFile::ReadOnly | QFile::Text)) - { - ; - } - - QByteArray configData = configList.readAll(); - QJsonDocument configJson(QJsonDocument::fromJson(configData)); - mifare->setConfigMap(configJson.object()["mifare classic"].toObject().toVariantMap()); - keyEventFilter = new MyEventFilter(QEvent::KeyPress); resizeEventFilter = new MyEventFilter(QEvent::Resize); @@ -82,6 +72,21 @@ MainWindow::~MainWindow() delete pm3Thread; } +void MainWindow::loadConfig() +{ + QFile configList(ui->Set_Client_configPathEdit->text()); + if(!configList.open(QFile::ReadOnly | QFile::Text)) + { + QMessageBox::information(this, tr("Info"), tr("Failed to load config file")); + return; + } + + QByteArray configData = configList.readAll(); + QJsonDocument configJson(QJsonDocument::fromJson(configData)); + mifare->setConfigMap(configJson.object()["mifare classic"].toObject().toVariantMap()); + +} + void MainWindow::initUI() // will be called by main.app { ui->retranslateUi(this); @@ -120,7 +125,7 @@ void MainWindow::on_PM3_connectButton_clicked() // on RRG repo, if no port is specified, the client will search the available port if(port == "" && startArgs.contains("")) // has , no port { - QMessageBox::information(NULL, tr("Info"), tr("Plz choose a port first"), QMessageBox::Ok); + QMessageBox::information(this, tr("Info"), tr("Plz choose a port first"), QMessageBox::Ok); return; } @@ -170,6 +175,7 @@ void MainWindow::on_PM3_connectButton_clicked() qDebug() << clientWorkingDir->absolutePath(); emit setWorkingDir(clientWorkingDir->absolutePath()); + loadConfig(); emit connectPM3(ui->PM3_pathEdit->text(), args); if(port != "" && !keepClientActive) emit setSerialListener(port, true); @@ -1057,6 +1063,7 @@ void MainWindow::uiInit() settings->beginGroup("Client_Env"); ui->Set_Client_envScriptEdit->setText(settings->value("scriptPath").toString()); ui->Set_Client_workingDirEdit->setText(settings->value("workingDir", "../data").toString()); + ui->Set_Client_configPathEdit->setText(settings->value("configPath", "config.json").toString()); settings->endGroup(); ui->MF_RW_keyTypeBox->addItem("A", Mifare::KEY_A); @@ -1248,13 +1255,21 @@ void MainWindow::on_Set_Client_envScriptEdit_editingFinished() settings->endGroup(); } -void MainWindow::on_Set_Client_saveWorkingDirButton_clicked() +void MainWindow::on_Set_Client_workingDirEdit_editingFinished() { settings->beginGroup("Client_Env"); settings->setValue("workingDir", ui->Set_Client_workingDirEdit->text()); settings->endGroup(); } + +void MainWindow::on_Set_Client_configPathEdit_editingFinished() +{ + settings->beginGroup("Client_Env"); + settings->setValue("configPath", ui->Set_Client_configPathEdit->text()); + settings->endGroup(); +} + void MainWindow::on_Set_Client_keepClientActiveBox_stateChanged(int arg1) { settings->beginGroup("Client_keepClientActive"); @@ -1388,3 +1403,4 @@ void MainWindow::on_LF_Conf_resetButton_clicked() lf->resetConfig(); setState(true); } + diff --git a/ui/mainwindow.h b/ui/mainwindow.h index 0909979..615a027 100644 --- a/ui/mainwindow.h +++ b/ui/mainwindow.h @@ -177,8 +177,6 @@ private slots: void on_Set_Client_envScriptEdit_editingFinished(); - void on_Set_Client_saveWorkingDirButton_clicked(); - void on_Set_Client_keepClientActiveBox_stateChanged(int arg1); void on_LF_Conf_freqSlider_valueChanged(int value); @@ -203,6 +201,10 @@ private slots: void on_LF_Conf_resetButton_clicked(); + void on_Set_Client_workingDirEdit_editingFinished(); + + void on_Set_Client_configPathEdit_editingFinished(); + private: Ui::MainWindow* ui; QButtonGroup* MFCardTypeBtnGroup; @@ -249,6 +251,7 @@ private: void saveClientPath(const QString& path); void onLFfreqConfChanged(int value, bool isCustomized); void dockInit(); + void loadConfig(); protected: void contextMenuEvent(QContextMenuEvent *event) override; signals: diff --git a/ui/mainwindow.ui b/ui/mainwindow.ui index dc004a1..6952485 100644 --- a/ui/mainwindow.ui +++ b/ui/mainwindow.ui @@ -7,7 +7,7 @@ 0 0 1050 - 700 + 750 @@ -2650,7 +2650,7 @@ or the communication between a tag and a reader. - Preload script path: + Preload script path(Reconnect to apply): @@ -2664,9 +2664,7 @@ or the communication between a tag and a reader. - Note: -If the client requires some enviroment variables, you can make a script file(*.bat on Windows or *.sh on Linux) to configure them, -then put the path of the script there + If the client requires some enviroment variables, you can make a script file(*.bat on Windows or *.sh on Linux) to configure them, then put the path of the script there. true @@ -2683,33 +2681,21 @@ then put the path of the script there - Client working directory: + Client working directory(Reconnect to apply): - - - - - ../data - - - - - - - Save - - - - + + + ../data + + - Note: -On Windows, the client working directory should not be identical to the path of GUI, otherwise the client will use the wrong .dll file. + On Windows, the client working directory should not be identical to the path of GUI, otherwise the client will use the wrong .dll file. true @@ -2726,7 +2712,7 @@ On Windows, the client working directory should not be identical to the path of - Start arguments + Start arguments(Reconnect to apply): @@ -2740,10 +2726,7 @@ On Windows, the client working directory should not be identical to the path of - Note: --f is necessary because the GUI need to handle the output in time -In some cases the arguments should be set to "-p /dev/<port> -f" -or "-p <port> -f" + -f is necessary because the GUI need to handle the output in time. In some cases, the arguments should be set to "-p /dev/<port> -f" or "-p <port> -f". true @@ -2757,6 +2740,37 @@ or "-p <port> -f" + + + + Config file path(Reconnect to apply): + + + + + + + config.json + + + + + + + Different clients require different config files. You can change the content of config file if the command format changes. + + + true + + + + + + + Qt::Horizontal + + + @@ -2912,6 +2926,9 @@ or "-p <port> -f" Qt::Horizontal + + QSizePolicy::Minimum + 0