mirror of
https://github.com/wh201906/Proxmark3GUI.git
synced 2025-04-20 03:32:12 +08:00
Misc
add config file to resource system move language folder
This commit is contained in:
parent
757fdcfc21
commit
9c89df4519
@ -58,7 +58,6 @@ Great thanks to him.
|
||||
mkdir build && cd build
|
||||
qmake ../src
|
||||
make -j4 && make clean
|
||||
cp -r ../config ./
|
||||
./Proxmark3GUI
|
||||
|
||||
***
|
||||
|
6
config/config.qrc
Normal file
6
config/config.qrc
Normal file
@ -0,0 +1,6 @@
|
||||
<RCC>
|
||||
<qresource prefix="/config">
|
||||
<file>config_official.json</file>
|
||||
<file>config_rrgv4.13.json</file>
|
||||
</qresource>
|
||||
</RCC>
|
@ -57,7 +57,6 @@ release页面中有含客户端的GUI。这个GUI也可以搭配你自己的客
|
||||
mkdir build && cd build
|
||||
qmake ../src
|
||||
make -j4 && make clean
|
||||
cp -r ../config ./
|
||||
./Proxmark3GUI
|
||||
|
||||
***
|
||||
|
@ -1,4 +1,4 @@
|
||||
[Languages]
|
||||
en_US=English
|
||||
zh_CN=简体中文
|
||||
ext=Load from external file
|
||||
(ext)=Load from external file
|
@ -65,4 +65,5 @@ QMAKE_TARGET_DESCRIPTION = "Proxmark3GUI"
|
||||
QMAKE_TARGET_COMPANY = "wh201906"
|
||||
|
||||
RESOURCES += \
|
||||
i18n/language.qrc
|
||||
../i18n/language.qrc \
|
||||
../config/config.qrc
|
||||
|
@ -28,7 +28,7 @@ void PM3Process::connectPM3(const QString& path, const QStringList args)
|
||||
currArgs = args;
|
||||
|
||||
// using "-f" option to make the client output flushed after every print.
|
||||
// single '\r' might appears. Don't use QProcess::Text there or '\r' is ignored.
|
||||
// single '\r' might appear. Don't use QProcess::Text there or '\r' is ignored.
|
||||
start(path, args, QProcess::Unbuffered | QProcess::ReadWrite);
|
||||
if(waitForStarted(10000))
|
||||
{
|
||||
|
@ -123,13 +123,24 @@ bool Util::chooseLanguage(QSettings* guiSettings, QMainWindow* window)
|
||||
delete langSettings;
|
||||
bool isOk = false;
|
||||
QString selectedText = QInputDialog::getItem(window, "", "Choose a language:", langMap.keys(), 0, false, &isOk);
|
||||
if(isOk)
|
||||
if(!isOk)
|
||||
return false;
|
||||
if(langMap[selectedText] == "(ext)")
|
||||
{
|
||||
guiSettings->beginGroup("lang");
|
||||
guiSettings->setValue("language", langMap[selectedText]);
|
||||
QString extPath = QFileDialog::getOpenFileName(nullptr, "Select the translation file:");
|
||||
if(extPath.isEmpty())
|
||||
return false;
|
||||
|
||||
guiSettings->beginGroup("language");
|
||||
guiSettings->setValue("extPath", extPath);
|
||||
guiSettings->endGroup();
|
||||
guiSettings->sync();
|
||||
}
|
||||
|
||||
guiSettings->beginGroup("language");
|
||||
guiSettings->setValue("name", langMap[selectedText]);
|
||||
guiSettings->endGroup();
|
||||
guiSettings->sync();
|
||||
|
||||
return isOk;
|
||||
}
|
||||
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include <QSettings>
|
||||
#include <QMainWindow>
|
||||
#include <QInputDialog>
|
||||
#include <QFileDialog>
|
||||
#include <QDockWidget>
|
||||
|
||||
#include "ui_mainwindow.h"
|
||||
|
31
src/main.cpp
31
src/main.cpp
@ -27,33 +27,34 @@ int main(int argc, char *argv[])
|
||||
|
||||
QSettings* settings = new QSettings("GUIsettings.ini", QSettings::IniFormat);
|
||||
settings->setIniCodec("UTF-8");
|
||||
settings->beginGroup("lang");
|
||||
QString currLang = settings->value("language", "").toString();
|
||||
settings->beginGroup("language");
|
||||
QString languageFile = settings->value("extPath").toString();
|
||||
QString languageName = settings->value("name").toString();
|
||||
settings->endGroup();
|
||||
if(currLang == "")
|
||||
if(languageName == "")
|
||||
{
|
||||
if(Util::chooseLanguage(settings, &w))
|
||||
{
|
||||
settings->beginGroup("lang");
|
||||
currLang = settings->value("language", "").toString();
|
||||
settings->beginGroup("language");
|
||||
languageName = settings->value("name").toString();
|
||||
settings->endGroup();
|
||||
}
|
||||
else
|
||||
currLang = "en_US";
|
||||
languageName = "en_US";
|
||||
}
|
||||
if(languageName == "(ext)")
|
||||
{
|
||||
settings->beginGroup("language");
|
||||
languageFile = settings->value("extPath").toString();
|
||||
settings->endGroup();
|
||||
}
|
||||
if(currLang == "ext")
|
||||
currLang = QFileDialog::getOpenFileName(nullptr, "Select the translation file:");
|
||||
else
|
||||
currLang = ":/i18n/" + currLang + ".qm";
|
||||
languageFile = ":/i18n/" + languageName + ".qm";
|
||||
QTranslator* translator = new QTranslator(&w);
|
||||
if(translator->load(currLang))
|
||||
{
|
||||
if(translator->load(languageFile))
|
||||
a.installTranslator(translator);
|
||||
}
|
||||
else
|
||||
{
|
||||
QMessageBox::information(&w, "Error", "Can't load " + currLang + " as translation file.");
|
||||
}
|
||||
QMessageBox::information(&w, "Error", "Can't load " + languageFile + " as translation file.");
|
||||
delete settings;
|
||||
w.initUI();
|
||||
w.show();
|
||||
|
@ -2,6 +2,7 @@
|
||||
#include "ui_mainwindow.h"
|
||||
|
||||
#include <QJsonDocument>
|
||||
#include <QDirIterator>
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent):
|
||||
QMainWindow(parent)
|
||||
@ -79,7 +80,11 @@ MainWindow::~MainWindow()
|
||||
|
||||
void MainWindow::loadConfig()
|
||||
{
|
||||
QFile configList(ui->Set_Client_configPathEdit->text());
|
||||
QString filename = ui->Set_Client_configFileBox->currentData().toString();
|
||||
if(filename == "(ext)")
|
||||
filename = ui->Set_Client_configPathEdit->text();
|
||||
qDebug() << "config file:" << filename;
|
||||
QFile configList(filename);
|
||||
if(!configList.open(QFile::ReadOnly | QFile::Text))
|
||||
{
|
||||
QMessageBox::information(this, tr("Info"), tr("Failed to load config file"));
|
||||
@ -1106,11 +1111,27 @@ void MainWindow::uiInit()
|
||||
ui->Set_Client_keepClientActiveBox->setChecked(keepClientActive);
|
||||
settings->endGroup();
|
||||
|
||||
QDirIterator configFiles(":/config/");
|
||||
ui->Set_Client_configFileBox->blockSignals(true);
|
||||
while(configFiles.hasNext())
|
||||
{
|
||||
configFiles.next();
|
||||
ui->Set_Client_configFileBox->addItem(configFiles.fileName(), configFiles.filePath());
|
||||
}
|
||||
ui->Set_Client_configFileBox->addItem(tr("External file"), "(ext)");
|
||||
|
||||
int configId = -1;
|
||||
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());
|
||||
configId = ui->Set_Client_configFileBox->findData(settings->value("configFile"));
|
||||
ui->Set_Client_configPathEdit->setText(settings->value("extConfigFilePath", "config.json").toString());
|
||||
settings->endGroup();
|
||||
if(configId != -1)
|
||||
ui->Set_Client_configFileBox->setCurrentIndex(configId);
|
||||
ui->Set_Client_configFileBox->blockSignals(false);
|
||||
on_Set_Client_configFileBox_currentIndexChanged(ui->Set_Client_configFileBox->currentIndex());
|
||||
|
||||
|
||||
ui->MF_RW_keyTypeBox->addItem("A", Mifare::KEY_A);
|
||||
ui->MF_RW_keyTypeBox->addItem("B", Mifare::KEY_B);
|
||||
@ -1314,7 +1335,7 @@ void MainWindow::on_Set_Client_workingDirEdit_editingFinished()
|
||||
void MainWindow::on_Set_Client_configPathEdit_editingFinished()
|
||||
{
|
||||
settings->beginGroup("Client_Env");
|
||||
settings->setValue("configPath", ui->Set_Client_configPathEdit->text());
|
||||
settings->setValue("extConfigFilePath", ui->Set_Client_configPathEdit->text());
|
||||
settings->endGroup();
|
||||
}
|
||||
|
||||
@ -1452,3 +1473,11 @@ void MainWindow::on_LF_LFConf_resetButton_clicked()
|
||||
setState(true);
|
||||
}
|
||||
|
||||
void MainWindow::on_Set_Client_configFileBox_currentIndexChanged(int index)
|
||||
{
|
||||
ui->Set_Client_configPathEdit->setVisible(ui->Set_Client_configFileBox->itemData(index).toString() == "(ext)");
|
||||
settings->beginGroup("Client_Env");
|
||||
settings->setValue("configFile", ui->Set_Client_configFileBox->currentData());
|
||||
settings->endGroup();
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,7 @@ public:
|
||||
~MainWindow();
|
||||
|
||||
void initUI();
|
||||
bool eventFilter(QObject *watched, QEvent *event);
|
||||
bool eventFilter(QObject *watched, QEvent *event) override;
|
||||
public slots:
|
||||
void refreshOutput(const QString& output);
|
||||
void refreshCMD(const QString& cmd);
|
||||
@ -209,6 +209,9 @@ private slots:
|
||||
void on_Set_Client_configPathEdit_editingFinished();
|
||||
|
||||
void setState(bool st);
|
||||
|
||||
void on_Set_Client_configFileBox_currentIndexChanged(int index);
|
||||
|
||||
private:
|
||||
Ui::MainWindow* ui;
|
||||
QButtonGroup* MFCardTypeBtnGroup;
|
||||
|
@ -2763,10 +2763,34 @@ or the communication between a tag and a reader.</string>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_63">
|
||||
<property name="text">
|
||||
<string>Config file path(Reconnect to apply):</string>
|
||||
<string>Config file(Reconnect to apply):</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_15">
|
||||
<item>
|
||||
<widget class="QComboBox" name="Set_Client_configFileBox">
|
||||
<property name="sizeAdjustPolicy">
|
||||
<enum>QComboBox::AdjustToContents</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_13">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="Set_Client_configPathEdit">
|
||||
<property name="text">
|
||||
|
Loading…
x
Reference in New Issue
Block a user