Make UI customizable

pull/4/head
wh201906 5 years ago
parent 5cccb7b8bb
commit 3181848e75

@ -11,7 +11,8 @@ int main(int argc, char *argv[])
QApplication a(argc, argv);
MainWindow w;
QSettings* settings = new QSettings("GUIsettings.ini", QSettings::IniFormat);
QVariant lang = settings->value("lang", "null");
settings->beginGroup("lang");
QVariant lang = settings->value("language", "null");
if(lang == "null")
{
#ifdef Q_OS_WIN
@ -44,12 +45,13 @@ int main(int argc, char *argv[])
if(translator->load(lang.toString()))
{
a.installTranslator(translator);
settings->setValue("lang", lang);
settings->setValue("language", lang);
}
else
{
QMessageBox::information(&w, "Error", "Can't load " + lang.toString() + " as translation file.");
}
settings->endGroup();
delete settings;
w.initUI();
w.show();

@ -15,6 +15,8 @@ MainWindow::MainWindow(QWidget *parent):
});
this->addAction(myInfo);
settings = new QSettings("GUIsettings.ini", QSettings::IniFormat);
pm3Thread = new QThread(this);
pm3 = new PM3Process(pm3Thread);
// pm3->moveToThread(pm3Thread);
@ -625,6 +627,28 @@ void MainWindow::uiInit()
ui->MF_keyWidget->installEventFilter(this);
ui->MF_dataWidget->installEventFilter(this);
settings->beginGroup("UI_grpbox_preference");
QStringList boxNames = settings->allKeys();
QGroupBox* boxptr;
foreach(QString name, boxNames)
{
boxptr = this->findChild<QGroupBox*>(name);
if(boxptr == nullptr)
continue;
if(settings->value(name, true).toBool())
{
boxptr->setMaximumHeight(16777215);
boxptr->setChecked(true);
}
else
{
boxptr->setMaximumHeight(20);
boxptr->setChecked(false);
}
}
settings->endGroup();
on_Raw_CMDHistoryBox_stateChanged(Qt::Unchecked);
on_PM3_refreshPortButton_clicked();
}
@ -639,6 +663,14 @@ void MainWindow::signalInit()
connect(this, &MainWindow::killPM3, pm3, &PM3Process::kill);
connect(util, &Util::write, pm3, &PM3Process::write);
connect(ui->MF_typeGroupBox, &QGroupBox::clicked, this, &MainWindow::on_GroupBox_clicked);
connect(ui->MF_fileGroupBox, &QGroupBox::clicked, this, &MainWindow::on_GroupBox_clicked);
connect(ui->MF_RWGroupBox, &QGroupBox::clicked, this, &MainWindow::on_GroupBox_clicked);
connect(ui->MF_normalGroupBox, &QGroupBox::clicked, this, &MainWindow::on_GroupBox_clicked);
connect(ui->MF_UIDGroupBox, &QGroupBox::clicked, this, &MainWindow::on_GroupBox_clicked);
connect(ui->MF_simGroupBox, &QGroupBox::clicked, this, &MainWindow::on_GroupBox_clicked);
connect(ui->MF_sniffGroupBox, &QGroupBox::clicked, this, &MainWindow::on_GroupBox_clicked);
}
void MainWindow::setStatusBar(QLabel* target, const QString & text)
@ -718,8 +750,22 @@ void MainWindow::setState(bool st)
ui->Raw_sendCMDButton->setEnabled(st);
}
// ***********************************************
void MainWindow::on_GroupBox_clicked(bool checked)
{
QGroupBox* box = dynamic_cast<QGroupBox*>(sender());
settings->beginGroup("UI_grpbox_preference");
if(checked)
{
box->setMaximumHeight(16777215);
settings->setValue(box->objectName(), true);
}
else
{
box->setMaximumHeight(20);
settings->setValue(box->objectName(), false);
}
settings->endGroup();
}
// ***********************************************

@ -16,6 +16,9 @@
#include <QMimeData>
#include <QAction>
#include <QDesktopServices>
#include <QGroupBox>
#include <QSizePolicy>
#include <QSettings>
#include "common/pm3process.h"
#include "module/mifare.h"
@ -132,6 +135,8 @@ private slots:
void on_MF_Sniff_saveButton_clicked();
void on_GroupBox_clicked(bool checked);
private:
Ui::MainWindow* ui;
QButtonGroup* typeBtnGroup;
@ -139,6 +144,7 @@ private:
QLabel* programStatusBar;
QLabel* PM3VersionBar;
QAction* myInfo;
QSettings* settings;
void uiInit();

@ -317,7 +317,7 @@
<string>Card Type</string>
</property>
<property name="checkable">
<bool>false</bool>
<bool>true</bool>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_10">
<property name="topMargin">
@ -365,6 +365,9 @@
<property name="title">
<string>File</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_8">
<property name="topMargin">
<number>5</number>
@ -436,6 +439,9 @@
<property name="title">
<string>Attack</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<property name="topMargin">
<number>5</number>
@ -519,6 +525,9 @@
<property name="title">
<string>Read/Write</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_12">
@ -635,6 +644,9 @@
<property name="title">
<string>Normal(Require Password)</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<property name="topMargin">
<number>5</number>
@ -713,6 +725,9 @@
<property name="title">
<string>Chinese Magic Card(Without Password)</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="topMargin">
<number>5</number>
@ -818,6 +833,9 @@
<property name="title">
<string>Simulate</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_11">
<property name="topMargin">
<number>5</number>
@ -896,6 +914,9 @@
<property name="title">
<string>Sniff</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<property name="topMargin">
<number>5</number>

Loading…
Cancel
Save