Choose config file path

pull/33/head
wh201906 3 years ago
parent 0c339e91af
commit 222f271a31

@ -59,7 +59,7 @@ Great thanks to him.
make
make clean
cp -r ../lang ./
cp ../configs.json ./
cp -r ../config ./
./Proxmark3GUI
***

@ -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()<<portInfo->isBusy();

@ -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("<port>")) // has <port>, 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);
}

@ -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:

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>1050</width>
<height>700</height>
<height>750</height>
</rect>
</property>
<property name="minimumSize">
@ -2650,7 +2650,7 @@ or the communication between a tag and a reader.</string>
<item>
<widget class="QLabel" name="label_11">
<property name="text">
<string>Preload script path:</string>
<string>Preload script path(Reconnect to apply):</string>
</property>
</widget>
</item>
@ -2664,9 +2664,7 @@ or the communication between a tag and a reader.</string>
<item>
<widget class="QLabel" name="label_13">
<property name="text">
<string>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</string>
<string>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.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
@ -2683,33 +2681,21 @@ then put the path of the script there</string>
<item>
<widget class="QLabel" name="label_19">
<property name="text">
<string>Client working directory:</string>
<string>Client working directory(Reconnect to apply):</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_15">
<item>
<widget class="QLineEdit" name="Set_Client_workingDirEdit">
<property name="text">
<string>../data</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="Set_Client_saveWorkingDirButton">
<property name="text">
<string>Save</string>
</property>
</widget>
</item>
</layout>
<widget class="QLineEdit" name="Set_Client_workingDirEdit">
<property name="text">
<string>../data</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_20">
<property name="text">
<string>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.</string>
<string>On Windows, the client working directory should not be identical to the path of GUI, otherwise the client will use the wrong .dll file.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
@ -2726,7 +2712,7 @@ On Windows, the client working directory should not be identical to the path of
<item>
<widget class="QLabel" name="label_12">
<property name="text">
<string>Start arguments</string>
<string>Start arguments(Reconnect to apply):</string>
</property>
</widget>
</item>
@ -2740,10 +2726,7 @@ On Windows, the client working directory should not be identical to the path of
<item>
<widget class="QLabel" name="label_14">
<property name="text">
<string>Note:
-f is necessary because the GUI need to handle the output in time
In some cases the arguments should be set to &quot;-p /dev/&lt;port&gt; -f&quot;
or &quot;-p &lt;port&gt; -f&quot;</string>
<string>-f is necessary because the GUI need to handle the output in time. In some cases, the arguments should be set to &quot;-p /dev/&lt;port&gt; -f&quot; or &quot;-p &lt;port&gt; -f&quot;.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
@ -2757,6 +2740,37 @@ or &quot;-p &lt;port&gt; -f&quot;</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_63">
<property name="text">
<string>Config file path(Reconnect to apply):</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="Set_Client_configPathEdit">
<property name="text">
<string>config.json</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_64">
<property name="text">
<string>Different clients require different config files. You can change the content of config file if the command format changes.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="Line" name="line_8">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_16">
<item>
@ -2912,6 +2926,9 @@ or &quot;-p &lt;port&gt; -f&quot;</string>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Minimum</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>

Loading…
Cancel
Save