New project structure

Load translation file in the executable.
pull/33/head
wh201906 3 years ago
parent b319f9fbe1
commit f86cba8d56

73
.gitignore vendored

@ -1,72 +1 @@
# This file is used to ignore files which are generated /build*
# ----------------------------------------------------------------------------
*~
*.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

@ -55,12 +55,9 @@ Great thanks to him.
sudo apt-get install qt5-default libqt5serialport5 libqt5serialport5-dev sudo apt-get install qt5-default libqt5serialport5 libqt5serialport5-dev
git clone https://github.com/wh201906/Proxmark3GUI.git --depth=1 git clone https://github.com/wh201906/Proxmark3GUI.git --depth=1
cd Proxmark3GUI cd Proxmark3GUI
mkdir build mkdir build && cd build
cd build qmake ../src
qmake ../ make -j4 && make clean
make
make clean
cp -r ../lang ./
cp -r ../config ./ cp -r ../config ./
./Proxmark3GUI ./Proxmark3GUI

@ -54,12 +54,9 @@ release页面中有含客户端的GUI。这个GUI也可以搭配你自己的客
sudo apt-get install qt5-default libqt5serialport5 libqt5serialport5-dev sudo apt-get install qt5-default libqt5serialport5 libqt5serialport5-dev
git clone https://github.com/wh201906/Proxmark3GUI.git --depth=1 git clone https://github.com/wh201906/Proxmark3GUI.git --depth=1
cd Proxmark3GUI cd Proxmark3GUI
mkdir build mkdir build && cd build
cd build qmake ../src
qmake ../ make -j4 && make clean
make
make clean
cp -r ../lang ./
cp -r ../config ./ cp -r ../config ./
./Proxmark3GUI ./Proxmark3GUI

@ -1,3 +0,0 @@
[Languages]
en_US=English
zh_CN=简体中文

72
src/.gitignore vendored

@ -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 \ common/util.cpp \
module/lf.cpp \ module/lf.cpp \
module/mifare.cpp \ module/mifare.cpp \
module/t55xxtab.cpp \
ui/mf_trailerdecoderdialog.cpp \ ui/mf_trailerdecoderdialog.cpp \
ui/mf_sim_simdialog.cpp \ ui/mf_sim_simdialog.cpp \
ui/mf_uid_parameterdialog.cpp \ ui/mf_uid_parameterdialog.cpp \
@ -34,6 +35,7 @@ HEADERS += \
common/util.h \ common/util.h \
module/lf.h \ module/lf.h \
module/mifare.h \ module/mifare.h \
module/t55xxtab.h \
ui/mf_trailerdecoderdialog.h \ ui/mf_trailerdecoderdialog.h \
ui/mf_sim_simdialog.h \ ui/mf_sim_simdialog.h \
ui/mf_uid_parameterdialog.h \ ui/mf_uid_parameterdialog.h \
@ -41,6 +43,7 @@ HEADERS += \
ui/mf_attack_hardnesteddialog.h \ ui/mf_attack_hardnesteddialog.h \
FORMS += \ FORMS += \
ui/t55xxtab.ui \
ui/mf_trailerdecoderdialog.ui \ ui/mf_trailerdecoderdialog.ui \
ui/mf_sim_simdialog.ui \ ui/mf_sim_simdialog.ui \
ui/mf_uid_parameterdialog.ui \ ui/mf_uid_parameterdialog.ui \
@ -48,8 +51,8 @@ FORMS += \
ui/mf_attack_hardnesteddialog.ui ui/mf_attack_hardnesteddialog.ui
TRANSLATIONS += \ TRANSLATIONS += \
lang/zh_CN.ts \ i18n/zh_CN.ts \
lang/en_US.ts i18n/en_US.ts
# Default rules for deployment. # Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin qnx: target.path = /tmp/$${TARGET}/bin
@ -60,3 +63,6 @@ VERSION = 0.2.3
QMAKE_TARGET_PRODUCT = "Proxmark3GUI" QMAKE_TARGET_PRODUCT = "Proxmark3GUI"
QMAKE_TARGET_DESCRIPTION = "Proxmark3GUI" QMAKE_TARGET_DESCRIPTION = "Proxmark3GUI"
QMAKE_TARGET_COMPANY = "wh201906" QMAKE_TARGET_COMPANY = "wh201906"
RESOURCES += \
i18n/language.qrc

@ -106,7 +106,7 @@ void Util::setRunningState(bool st)
bool Util::chooseLanguage(QSettings* guiSettings, QMainWindow* window) bool Util::chooseLanguage(QSettings* guiSettings, QMainWindow* window)
{ {
// make sure the GUISettings is not in any group // 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; QMap<QString, QString> langMap;
langSettings->setIniCodec("UTF-8"); langSettings->setIniCodec("UTF-8");
langSettings->beginGroup("Languages"); langSettings->beginGroup("Languages");

@ -0,0 +1,7 @@
<RCC>
<qresource prefix="/i18n">
<file>en_US.qm</file>
<file>languages.ini</file>
<file>zh_CN.qm</file>
</qresource>
</RCC>

@ -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. 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> On Iceman/RRG repo, press the button on PM3 to stop measuring</source>
<translation>线 <translation>线
线 线
PM3</translation> PM3</translation>
</message> </message>
<message> <message>

@ -1,63 +1,63 @@
#include "ui/mainwindow.h" #include "ui/mainwindow.h"
#include <QApplication> #include <QApplication>
#include <QSettings> #include <QSettings>
#include <QTranslator> #include <QTranslator>
#include <QMessageBox> #include <QMessageBox>
#include <QTextCodec> #include <QTextCodec>
#include <QDir> #include <QDir>
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
// A trick to handle non-ascii path // A trick to handle non-ascii path
// The application cannot find the plugins when the path contains non ascii characters. // The application cannot find the plugins when the path contains non ascii characters.
// However, the plugins will be load after creating MainWindow(or QApplication?). // However, the plugins will be load after creating MainWindow(or QApplication?).
// QDir will handle the path correctly. // QDir will handle the path correctly.
QDir* pluginDir = new QDir; QDir* pluginDir = new QDir;
if(pluginDir->cd("plugins")) // has plugins folder if(pluginDir->cd("plugins")) // has plugins folder
{ {
qputenv("QT_PLUGIN_PATH", pluginDir->absolutePath().toLocal8Bit()); qputenv("QT_PLUGIN_PATH", pluginDir->absolutePath().toLocal8Bit());
} }
delete pluginDir; delete pluginDir;
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QTextCodec::setCodecForLocale(QTextCodec::codecForName("UTF-8")); QTextCodec::setCodecForLocale(QTextCodec::codecForName("UTF-8"));
QDir *langPath = new QDir(); QApplication a(argc, argv);
QApplication a(argc, argv); MainWindow w;
MainWindow w;
QSettings* settings = new QSettings("GUIsettings.ini", QSettings::IniFormat);
QSettings* settings = new QSettings("GUIsettings.ini", QSettings::IniFormat); settings->setIniCodec("UTF-8");
settings->setIniCodec("UTF-8"); settings->beginGroup("lang");
settings->beginGroup("lang"); QString currLang = settings->value("language", "").toString();
QString currLang = settings->value("language", "").toString(); settings->endGroup();
settings->endGroup(); if(currLang == "")
if(currLang == "") {
{ if(Util::chooseLanguage(settings, &w))
if(Util::chooseLanguage(settings, &w)) {
{ settings->beginGroup("lang");
settings->beginGroup("lang"); currLang = settings->value("language", "").toString();
currLang = settings->value("language", "").toString(); settings->endGroup();
settings->endGroup(); }
} else
else currLang = "en_US";
currLang = "en_US"; }
} if(currLang == "ext")
currLang += ".qm"; currLang = QFileDialog::getOpenFileName(nullptr, "Select the translation file:");
langPath->cd("lang"); else
QTranslator* translator = new QTranslator(&w); currLang = ":/i18n/" + currLang + ".qm";
if(translator->load(currLang, langPath->absolutePath())) QTranslator* translator = new QTranslator(&w);
{ if(translator->load(currLang))
a.installTranslator(translator); {
} a.installTranslator(translator);
else }
{ else
QMessageBox::information(&w, "Error", "Can't load " + currLang + " as translation file."); {
} QMessageBox::information(&w, "Error", "Can't load " + currLang + " as translation file.");
delete settings; }
delete langPath; delete settings;
w.initUI(); w.initUI();
w.show(); w.show();
return a.exec(); return a.exec();
} }

@ -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;
}

@ -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> </sizepolicy>
</property> </property>
<property name="currentIndex"> <property name="currentIndex">
<number>0</number> <number>2</number>
</property> </property>
<widget class="QWidget" name="mifareTab"> <widget class="QWidget" name="mifareTab">
<attribute name="title"> <attribute name="title">

@ -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…
Cancel
Save