mirror of
https://github.com/wh201906/Proxmark3GUI.git
synced 2025-03-03 13:27:39 +08:00
New project structure
Load translation file in the executable.
This commit is contained in:
parent
b319f9fbe1
commit
f86cba8d56
73
.gitignore
vendored
73
.gitignore
vendored
@ -1,72 +1 @@
|
||||
# This file is used to ignore files which are generated
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
*~
|
||||
*.autosave
|
||||
*.a
|
||||
*.core
|
||||
*.moc
|
||||
*.o
|
||||
*.obj
|
||||
*.orig
|
||||
*.rej
|
||||
*.so
|
||||
*.so.*
|
||||
*_pch.h.cpp
|
||||
*_resource.rc
|
||||
.#*
|
||||
*.*#
|
||||
core
|
||||
!core/
|
||||
tags
|
||||
.DS_Store
|
||||
.directory
|
||||
*.debug
|
||||
Makefile*
|
||||
*.prl
|
||||
*.app
|
||||
moc_*.cpp
|
||||
ui_*.h
|
||||
qrc_*.cpp
|
||||
Thumbs.db
|
||||
*.res
|
||||
*.rc
|
||||
/.qmake.cache
|
||||
/.qmake.stash
|
||||
|
||||
# qtcreator generated files
|
||||
*.pro.user*
|
||||
|
||||
# xemacs temporary files
|
||||
*.flc
|
||||
|
||||
# Vim temporary files
|
||||
.*.swp
|
||||
|
||||
# Visual Studio generated files
|
||||
*.ib_pdb_index
|
||||
*.idb
|
||||
*.ilk
|
||||
*.pdb
|
||||
*.sln
|
||||
*.suo
|
||||
*.vcproj
|
||||
*vcproj.*.*.user
|
||||
*.ncb
|
||||
*.sdf
|
||||
*.opensdf
|
||||
*.vcxproj
|
||||
*vcxproj.*
|
||||
|
||||
# MinGW generated files
|
||||
*.Debug
|
||||
*.Release
|
||||
|
||||
# Python byte code
|
||||
*.pyc
|
||||
|
||||
# Binaries
|
||||
# --------
|
||||
*.dll
|
||||
*.exe
|
||||
|
||||
/build*
|
@ -55,12 +55,9 @@ Great thanks to him.
|
||||
sudo apt-get install qt5-default libqt5serialport5 libqt5serialport5-dev
|
||||
git clone https://github.com/wh201906/Proxmark3GUI.git --depth=1
|
||||
cd Proxmark3GUI
|
||||
mkdir build
|
||||
cd build
|
||||
qmake ../
|
||||
make
|
||||
make clean
|
||||
cp -r ../lang ./
|
||||
mkdir build && cd build
|
||||
qmake ../src
|
||||
make -j4 && make clean
|
||||
cp -r ../config ./
|
||||
./Proxmark3GUI
|
||||
|
||||
|
@ -54,12 +54,9 @@ release页面中有含客户端的GUI。这个GUI也可以搭配你自己的客
|
||||
sudo apt-get install qt5-default libqt5serialport5 libqt5serialport5-dev
|
||||
git clone https://github.com/wh201906/Proxmark3GUI.git --depth=1
|
||||
cd Proxmark3GUI
|
||||
mkdir build
|
||||
cd build
|
||||
qmake ../
|
||||
make
|
||||
make clean
|
||||
cp -r ../lang ./
|
||||
mkdir build && cd build
|
||||
qmake ../src
|
||||
make -j4 && make clean
|
||||
cp -r ../config ./
|
||||
./Proxmark3GUI
|
||||
|
||||
|
@ -1,3 +0,0 @@
|
||||
[Languages]
|
||||
en_US=English
|
||||
zh_CN=简体中文
|
72
src/.gitignore
vendored
Normal file
72
src/.gitignore
vendored
Normal file
@ -0,0 +1,72 @@
|
||||
# This file is used to ignore files which are generated
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
*~
|
||||
*.autosave
|
||||
*.a
|
||||
*.core
|
||||
*.moc
|
||||
*.o
|
||||
*.obj
|
||||
*.orig
|
||||
*.rej
|
||||
*.so
|
||||
*.so.*
|
||||
*_pch.h.cpp
|
||||
*_resource.rc
|
||||
.#*
|
||||
*.*#
|
||||
core
|
||||
!core/
|
||||
tags
|
||||
.DS_Store
|
||||
.directory
|
||||
*.debug
|
||||
Makefile*
|
||||
*.prl
|
||||
*.app
|
||||
moc_*.cpp
|
||||
ui_*.h
|
||||
qrc_*.cpp
|
||||
Thumbs.db
|
||||
*.res
|
||||
*.rc
|
||||
/.qmake.cache
|
||||
/.qmake.stash
|
||||
|
||||
# qtcreator generated files
|
||||
*.pro.user*
|
||||
|
||||
# xemacs temporary files
|
||||
*.flc
|
||||
|
||||
# Vim temporary files
|
||||
.*.swp
|
||||
|
||||
# Visual Studio generated files
|
||||
*.ib_pdb_index
|
||||
*.idb
|
||||
*.ilk
|
||||
*.pdb
|
||||
*.sln
|
||||
*.suo
|
||||
*.vcproj
|
||||
*vcproj.*.*.user
|
||||
*.ncb
|
||||
*.sdf
|
||||
*.opensdf
|
||||
*.vcxproj
|
||||
*vcxproj.*
|
||||
|
||||
# MinGW generated files
|
||||
*.Debug
|
||||
*.Release
|
||||
|
||||
# Python byte code
|
||||
*.pyc
|
||||
|
||||
# Binaries
|
||||
# --------
|
||||
*.dll
|
||||
*.exe
|
||||
|
@ -22,6 +22,7 @@ SOURCES += \
|
||||
common/util.cpp \
|
||||
module/lf.cpp \
|
||||
module/mifare.cpp \
|
||||
module/t55xxtab.cpp \
|
||||
ui/mf_trailerdecoderdialog.cpp \
|
||||
ui/mf_sim_simdialog.cpp \
|
||||
ui/mf_uid_parameterdialog.cpp \
|
||||
@ -34,6 +35,7 @@ HEADERS += \
|
||||
common/util.h \
|
||||
module/lf.h \
|
||||
module/mifare.h \
|
||||
module/t55xxtab.h \
|
||||
ui/mf_trailerdecoderdialog.h \
|
||||
ui/mf_sim_simdialog.h \
|
||||
ui/mf_uid_parameterdialog.h \
|
||||
@ -41,6 +43,7 @@ HEADERS += \
|
||||
ui/mf_attack_hardnesteddialog.h \
|
||||
|
||||
FORMS += \
|
||||
ui/t55xxtab.ui \
|
||||
ui/mf_trailerdecoderdialog.ui \
|
||||
ui/mf_sim_simdialog.ui \
|
||||
ui/mf_uid_parameterdialog.ui \
|
||||
@ -48,8 +51,8 @@ FORMS += \
|
||||
ui/mf_attack_hardnesteddialog.ui
|
||||
|
||||
TRANSLATIONS += \
|
||||
lang/zh_CN.ts \
|
||||
lang/en_US.ts
|
||||
i18n/zh_CN.ts \
|
||||
i18n/en_US.ts
|
||||
|
||||
# Default rules for deployment.
|
||||
qnx: target.path = /tmp/$${TARGET}/bin
|
||||
@ -60,3 +63,6 @@ VERSION = 0.2.3
|
||||
QMAKE_TARGET_PRODUCT = "Proxmark3GUI"
|
||||
QMAKE_TARGET_DESCRIPTION = "Proxmark3GUI"
|
||||
QMAKE_TARGET_COMPANY = "wh201906"
|
||||
|
||||
RESOURCES += \
|
||||
i18n/language.qrc
|
@ -106,7 +106,7 @@ void Util::setRunningState(bool st)
|
||||
bool Util::chooseLanguage(QSettings* guiSettings, QMainWindow* window)
|
||||
{
|
||||
// make sure the GUISettings is not in any group
|
||||
QSettings* langSettings = new QSettings("lang/languages.ini", QSettings::IniFormat);
|
||||
QSettings* langSettings = new QSettings(":/i18n/languages.ini", QSettings::IniFormat);
|
||||
QMap<QString, QString> langMap;
|
||||
langSettings->setIniCodec("UTF-8");
|
||||
langSettings->beginGroup("Languages");
|
7
src/i18n/language.qrc
Normal file
7
src/i18n/language.qrc
Normal file
@ -0,0 +1,7 @@
|
||||
<RCC>
|
||||
<qresource prefix="/i18n">
|
||||
<file>en_US.qm</file>
|
||||
<file>languages.ini</file>
|
||||
<file>zh_CN.qm</file>
|
||||
</qresource>
|
||||
</RCC>
|
4
src/i18n/languages.ini
Normal file
4
src/i18n/languages.ini
Normal file
@ -0,0 +1,4 @@
|
||||
[Languages]
|
||||
en_US=English
|
||||
zh_CN=简体中文
|
||||
ext=Load from external file
|
@ -694,7 +694,7 @@ Use this to get raw data from a tag.</source>
|
||||
If the antenna voltage has a obvious drop after putting card on the antenna, it is likely that the tag is a LF tag.
|
||||
On Iceman/RRG repo, press the button on PM3 to stop measuring</source>
|
||||
<translation>测量低频天线谐振频率。
|
||||
如果天线电压在放置卡片后出现明显下降,则该卡片很可能是低频卡。
|
||||
如果天线电压在放置卡片后明显下降,则该卡片很可能是低频卡。
|
||||
在冰人版固件下,如果需要停止测量,请按下PM3侧面的按钮</translation>
|
||||
</message>
|
||||
<message>
|
@ -1,63 +1,63 @@
|
||||
#include "ui/mainwindow.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QSettings>
|
||||
#include <QTranslator>
|
||||
#include <QMessageBox>
|
||||
#include <QTextCodec>
|
||||
#include <QDir>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
// A trick to handle non-ascii path
|
||||
// The application cannot find the plugins when the path contains non ascii characters.
|
||||
// However, the plugins will be load after creating MainWindow(or QApplication?).
|
||||
// QDir will handle the path correctly.
|
||||
QDir* pluginDir = new QDir;
|
||||
if(pluginDir->cd("plugins")) // has plugins folder
|
||||
{
|
||||
qputenv("QT_PLUGIN_PATH", pluginDir->absolutePath().toLocal8Bit());
|
||||
}
|
||||
delete pluginDir;
|
||||
|
||||
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
||||
QTextCodec::setCodecForLocale(QTextCodec::codecForName("UTF-8"));
|
||||
QDir *langPath = new QDir();
|
||||
QApplication a(argc, argv);
|
||||
MainWindow w;
|
||||
|
||||
QSettings* settings = new QSettings("GUIsettings.ini", QSettings::IniFormat);
|
||||
settings->setIniCodec("UTF-8");
|
||||
settings->beginGroup("lang");
|
||||
QString currLang = settings->value("language", "").toString();
|
||||
settings->endGroup();
|
||||
if(currLang == "")
|
||||
{
|
||||
if(Util::chooseLanguage(settings, &w))
|
||||
{
|
||||
settings->beginGroup("lang");
|
||||
currLang = settings->value("language", "").toString();
|
||||
settings->endGroup();
|
||||
}
|
||||
else
|
||||
currLang = "en_US";
|
||||
}
|
||||
currLang += ".qm";
|
||||
langPath->cd("lang");
|
||||
QTranslator* translator = new QTranslator(&w);
|
||||
if(translator->load(currLang, langPath->absolutePath()))
|
||||
{
|
||||
a.installTranslator(translator);
|
||||
}
|
||||
else
|
||||
{
|
||||
QMessageBox::information(&w, "Error", "Can't load " + currLang + " as translation file.");
|
||||
}
|
||||
delete settings;
|
||||
delete langPath;
|
||||
w.initUI();
|
||||
w.show();
|
||||
return a.exec();
|
||||
}
|
||||
|
||||
|
||||
#include "ui/mainwindow.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QSettings>
|
||||
#include <QTranslator>
|
||||
#include <QMessageBox>
|
||||
#include <QTextCodec>
|
||||
#include <QDir>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
// A trick to handle non-ascii path
|
||||
// The application cannot find the plugins when the path contains non ascii characters.
|
||||
// However, the plugins will be load after creating MainWindow(or QApplication?).
|
||||
// QDir will handle the path correctly.
|
||||
QDir* pluginDir = new QDir;
|
||||
if(pluginDir->cd("plugins")) // has plugins folder
|
||||
{
|
||||
qputenv("QT_PLUGIN_PATH", pluginDir->absolutePath().toLocal8Bit());
|
||||
}
|
||||
delete pluginDir;
|
||||
|
||||
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
||||
QTextCodec::setCodecForLocale(QTextCodec::codecForName("UTF-8"));
|
||||
QApplication a(argc, argv);
|
||||
MainWindow w;
|
||||
|
||||
QSettings* settings = new QSettings("GUIsettings.ini", QSettings::IniFormat);
|
||||
settings->setIniCodec("UTF-8");
|
||||
settings->beginGroup("lang");
|
||||
QString currLang = settings->value("language", "").toString();
|
||||
settings->endGroup();
|
||||
if(currLang == "")
|
||||
{
|
||||
if(Util::chooseLanguage(settings, &w))
|
||||
{
|
||||
settings->beginGroup("lang");
|
||||
currLang = settings->value("language", "").toString();
|
||||
settings->endGroup();
|
||||
}
|
||||
else
|
||||
currLang = "en_US";
|
||||
}
|
||||
if(currLang == "ext")
|
||||
currLang = QFileDialog::getOpenFileName(nullptr, "Select the translation file:");
|
||||
else
|
||||
currLang = ":/i18n/" + currLang + ".qm";
|
||||
QTranslator* translator = new QTranslator(&w);
|
||||
if(translator->load(currLang))
|
||||
{
|
||||
a.installTranslator(translator);
|
||||
}
|
||||
else
|
||||
{
|
||||
QMessageBox::information(&w, "Error", "Can't load " + currLang + " as translation file.");
|
||||
}
|
||||
delete settings;
|
||||
w.initUI();
|
||||
w.show();
|
||||
return a.exec();
|
||||
}
|
||||
|
||||
|
14
src/module/t55xxtab.cpp
Normal file
14
src/module/t55xxtab.cpp
Normal file
@ -0,0 +1,14 @@
|
||||
#include "t55xxtab.h"
|
||||
#include "ui_t55xxtab.h"
|
||||
|
||||
T55xxTab::T55xxTab(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::T55xxTab)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
}
|
||||
|
||||
T55xxTab::~T55xxTab()
|
||||
{
|
||||
delete ui;
|
||||
}
|
22
src/module/t55xxtab.h
Normal file
22
src/module/t55xxtab.h
Normal file
@ -0,0 +1,22 @@
|
||||
#ifndef T55XXTAB_H
|
||||
#define T55XXTAB_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
namespace Ui {
|
||||
class T55xxTab;
|
||||
}
|
||||
|
||||
class T55xxTab : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit T55xxTab(QWidget *parent = nullptr);
|
||||
~T55xxTab();
|
||||
|
||||
private:
|
||||
Ui::T55xxTab *ui;
|
||||
};
|
||||
|
||||
#endif // T55XXTAB_H
|
@ -136,7 +136,7 @@
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
<number>2</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="mifareTab">
|
||||
<attribute name="title">
|
21
src/ui/t55xxtab.ui
Normal file
21
src/ui/t55xxtab.ui
Normal file
@ -0,0 +1,21 @@
|
||||
<ui version="4.0">
|
||||
<author/>
|
||||
<comment/>
|
||||
<exportmacro/>
|
||||
<class>T55xxTab</class>
|
||||
<widget class="QWidget" name="T55xxTab">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
</widget>
|
||||
<pixmapfunction/>
|
||||
<connections/>
|
||||
</ui>
|
Loading…
x
Reference in New Issue
Block a user