mirror of
https://github.com/wh201906/Proxmark3GUI.git
synced 2025-02-16 22:21:30 +08:00
Replace QTabWidget with QDockWidget
dock it(√) doki(?)
This commit is contained in:
parent
ae9e4d1a4f
commit
799e00d66e
@ -2,6 +2,11 @@
|
||||
|
||||
Util::ClientType Util::clientType = CLIENTTYPE_OFFICIAL;
|
||||
|
||||
int Util::rawTabIndex = 0;
|
||||
QDockWidget* Util::rawDockPtr = nullptr;
|
||||
Ui::MainWindow* Util::ui = nullptr;
|
||||
|
||||
|
||||
Util::Util(QObject *parent) : QObject(parent)
|
||||
{
|
||||
isRequiringOutput = false;
|
||||
@ -10,6 +15,7 @@ Util::Util(QObject *parent) : QObject(parent)
|
||||
qRegisterMetaType<Util::ClientType>("Util::ClientType");
|
||||
}
|
||||
|
||||
|
||||
void Util::processOutput(const QString& output)
|
||||
{
|
||||
// qDebug() << "Util::processOutput:" << output;
|
||||
@ -120,3 +126,22 @@ bool Util::chooseLanguage(QSettings* guiSettings, QMainWindow* window)
|
||||
}
|
||||
return isOk;
|
||||
}
|
||||
|
||||
void Util::gotoRawTab()
|
||||
{
|
||||
Util::ui->funcTab->setCurrentIndex(Util::rawTabIndex);
|
||||
Util::rawDockPtr->setVisible(true);
|
||||
Util::rawDockPtr->raise();
|
||||
}
|
||||
|
||||
void Util::setUI(Ui::MainWindow *ui)
|
||||
{
|
||||
Util::ui = ui;
|
||||
}
|
||||
|
||||
|
||||
void Util::setRawTab(QDockWidget *dockPtr, int tabIndex)
|
||||
{
|
||||
Util::rawDockPtr = dockPtr;
|
||||
Util::rawTabIndex = tabIndex;
|
||||
}
|
||||
|
@ -13,6 +13,9 @@
|
||||
#include <QSettings>
|
||||
#include <QMainWindow>
|
||||
#include <QInputDialog>
|
||||
#include <QDockWidget>
|
||||
|
||||
#include "ui_mainwindow.h"
|
||||
|
||||
class Util : public QObject
|
||||
{
|
||||
@ -53,19 +56,23 @@ public:
|
||||
QString execCMDWithOutput(const QString& cmd, ReturnTrigger trigger = 10000);
|
||||
void delay(unsigned int msec);
|
||||
static ClientType getClientType();
|
||||
static const int rawTabIndex = 2;
|
||||
static int rawTabIndex;
|
||||
static QDockWidget* rawDockPtr;
|
||||
static bool chooseLanguage(QSettings *guiSettings, QMainWindow *window);
|
||||
public slots:
|
||||
void processOutput(const QString& output);
|
||||
static void setClientType(Util::ClientType clientType);
|
||||
void setRunningState(bool st);
|
||||
|
||||
static void gotoRawTab();
|
||||
static void setUI(Ui::MainWindow *ui);
|
||||
static void setRawTab(QDockWidget* dockPtr, int tabIndex);
|
||||
private:
|
||||
bool isRequiringOutput;
|
||||
bool isRunning;
|
||||
QString* requiredOutput;
|
||||
QTime timeStamp;
|
||||
static ClientType clientType;
|
||||
static Ui::MainWindow *ui;
|
||||
signals:
|
||||
void refreshOutput(const QString& output);
|
||||
void write(QString data); // connected to PM3Process::write(QString data);
|
||||
|
@ -14,7 +14,7 @@ void LF::read()
|
||||
util->execCMD("lf read");
|
||||
else if(Util::getClientType() == Util::CLIENTTYPE_ICEMAN)
|
||||
util->execCMD("lf read -v");
|
||||
ui->funcTab->setCurrentIndex(Util::rawTabIndex);
|
||||
Util::gotoRawTab();
|
||||
util->execCMD("data plot");
|
||||
}
|
||||
|
||||
@ -24,7 +24,7 @@ void LF::sniff()
|
||||
util->execCMD("lf snoop");
|
||||
else if(Util::getClientType() == Util::CLIENTTYPE_ICEMAN)
|
||||
util->execCMD("lf sniff -v");
|
||||
ui->funcTab->setCurrentIndex(Util::rawTabIndex);
|
||||
Util::gotoRawTab();
|
||||
util->execCMD("data plot");
|
||||
}
|
||||
|
||||
@ -34,7 +34,7 @@ void LF::search()
|
||||
util->execCMD("lf search u");
|
||||
else if(Util::getClientType() == Util::CLIENTTYPE_ICEMAN)
|
||||
util->execCMD("lf search -u");
|
||||
ui->funcTab->setCurrentIndex(Util::rawTabIndex);
|
||||
Util::gotoRawTab();
|
||||
}
|
||||
|
||||
void LF::tune()
|
||||
@ -43,5 +43,5 @@ void LF::tune()
|
||||
util->execCMD("hw tune l");
|
||||
else if(Util::getClientType() == Util::CLIENTTYPE_ICEMAN)
|
||||
util->execCMD("lf tune"); // TODO: if freq is set, append it as a parameter
|
||||
ui->funcTab->setCurrentIndex(Util::rawTabIndex);
|
||||
Util::gotoRawTab();
|
||||
}
|
||||
|
@ -106,7 +106,7 @@ QString Mifare::info(bool isRequiringOutput)
|
||||
else
|
||||
{
|
||||
util->execCMD("hf 14a info");
|
||||
ui->funcTab->setCurrentIndex(Util::rawTabIndex);
|
||||
Util::gotoRawTab();
|
||||
}
|
||||
}
|
||||
return "";
|
||||
@ -255,7 +255,7 @@ void Mifare::hardnested()
|
||||
MF_Attack_hardnestedDialog dialog(cardType.block_size);
|
||||
connect(&dialog, &MF_Attack_hardnestedDialog::sendCMD, util, &Util::execCMD);
|
||||
if(dialog.exec() == QDialog::Accepted)
|
||||
ui->funcTab->setCurrentIndex(Util::rawTabIndex);
|
||||
Util::gotoRawTab();
|
||||
}
|
||||
|
||||
void Mifare::darkside()
|
||||
@ -265,7 +265,7 @@ void Mifare::darkside()
|
||||
else if(Util::getClientType() == Util::CLIENTTYPE_ICEMAN)
|
||||
util->execCMD("hf mf darkside");
|
||||
|
||||
ui->funcTab->setCurrentIndex(Util::rawTabIndex);
|
||||
Util::gotoRawTab();
|
||||
}
|
||||
|
||||
void Mifare::sniff()
|
||||
@ -275,7 +275,7 @@ void Mifare::sniff()
|
||||
else if(Util::getClientType() == Util::CLIENTTYPE_ICEMAN)
|
||||
util->execCMD("hf sniff");
|
||||
|
||||
ui->funcTab->setCurrentIndex(Util::rawTabIndex);
|
||||
Util::gotoRawTab();
|
||||
}
|
||||
|
||||
void Mifare::sniff14a()
|
||||
@ -285,7 +285,7 @@ void Mifare::sniff14a()
|
||||
else if(Util::getClientType() == Util::CLIENTTYPE_ICEMAN)
|
||||
util->execCMD("hf 14a sniff");
|
||||
|
||||
ui->funcTab->setCurrentIndex(Util::rawTabIndex);
|
||||
Util::gotoRawTab();
|
||||
}
|
||||
|
||||
void Mifare::list()
|
||||
@ -295,7 +295,7 @@ void Mifare::list()
|
||||
else if(Util::getClientType() == Util::CLIENTTYPE_ICEMAN)
|
||||
util->execCMD("trace list -t mf");
|
||||
|
||||
ui->funcTab->setCurrentIndex(Util::rawTabIndex);
|
||||
Util::gotoRawTab();
|
||||
}
|
||||
|
||||
QString Mifare::_readblk(int blockId, KeyType keyType, const QString& key, TargetType targetType, int waitTime)
|
||||
@ -742,14 +742,14 @@ void Mifare::dump()
|
||||
{
|
||||
if(Util::getClientType() == Util::CLIENTTYPE_OFFICIAL || Util::getClientType() == Util::CLIENTTYPE_ICEMAN)
|
||||
util->execCMD("hf mf dump");
|
||||
ui->funcTab->setCurrentIndex(Util::rawTabIndex);
|
||||
Util::gotoRawTab();
|
||||
}
|
||||
|
||||
void Mifare::restore()
|
||||
{
|
||||
if(Util::getClientType() == Util::CLIENTTYPE_OFFICIAL || Util::getClientType() == Util::CLIENTTYPE_ICEMAN)
|
||||
util->execCMD("hf mf restore");
|
||||
ui->funcTab->setCurrentIndex(Util::rawTabIndex);
|
||||
Util::gotoRawTab();
|
||||
}
|
||||
|
||||
void Mifare::wipeC()
|
||||
@ -765,7 +765,7 @@ void Mifare::wipeC()
|
||||
{
|
||||
util->execCMD("hf mf cwipe");
|
||||
}
|
||||
ui->funcTab->setCurrentIndex(Util::rawTabIndex);
|
||||
Util::gotoRawTab();
|
||||
}
|
||||
|
||||
void Mifare::setParameterC()
|
||||
@ -786,7 +786,7 @@ void Mifare::setParameterC()
|
||||
MF_UID_parameterDialog dialog(lis[1].toUpper(), lis[2].toUpper(), lis[3].toUpper());
|
||||
connect(&dialog, &MF_UID_parameterDialog::sendCMD, util, &Util::execCMD);
|
||||
if(dialog.exec() == QDialog::Accepted)
|
||||
ui->funcTab->setCurrentIndex(Util::rawTabIndex);
|
||||
Util::gotoRawTab();
|
||||
}
|
||||
}
|
||||
|
||||
@ -823,7 +823,7 @@ void Mifare::simulate()
|
||||
MF_Sim_simDialog dialog(cardType.type, cardType.typeText);
|
||||
connect(&dialog, &MF_Sim_simDialog::sendCMD, util, &Util::execCMD);
|
||||
if(dialog.exec() == QDialog::Accepted)
|
||||
ui->funcTab->setCurrentIndex(Util::rawTabIndex);
|
||||
Util::gotoRawTab();
|
||||
}
|
||||
|
||||
void Mifare::loadSniff(const QString& file)
|
||||
@ -836,7 +836,7 @@ void Mifare::loadSniff(const QString& file)
|
||||
util->execCMD("trace list -t mf");
|
||||
}
|
||||
|
||||
ui->funcTab->setCurrentIndex(Util::rawTabIndex);
|
||||
Util::gotoRawTab();
|
||||
}
|
||||
|
||||
void Mifare::saveSniff(const QString& file)
|
||||
@ -846,7 +846,7 @@ void Mifare::saveSniff(const QString& file)
|
||||
else if(Util::getClientType() == Util::CLIENTTYPE_ICEMAN)
|
||||
util->execCMD("trace save -f " + file);
|
||||
|
||||
ui->funcTab->setCurrentIndex(Util::rawTabIndex);
|
||||
Util::gotoRawTab();
|
||||
}
|
||||
|
||||
void Mifare::data_syncWithDataWidget(bool syncAll, int block)
|
||||
|
@ -31,6 +31,7 @@ MainWindow::MainWindow(QWidget *parent):
|
||||
clientWorkingDir = new QDir;
|
||||
|
||||
util = new Util(this);
|
||||
Util::setUI(ui);
|
||||
mifare = new Mifare(ui, util, this);
|
||||
lf = new LF(ui, util, this);
|
||||
|
||||
@ -64,6 +65,7 @@ void MainWindow::initUI() // will be called by main.app
|
||||
uiInit();
|
||||
signalInit();
|
||||
setState(false);
|
||||
dockInit();
|
||||
}
|
||||
|
||||
// ******************** basic functions ********************
|
||||
@ -1288,3 +1290,30 @@ void MainWindow::on_LF_Op_sniffButton_clicked()
|
||||
lf->sniff();
|
||||
setState(true);
|
||||
}
|
||||
|
||||
void MainWindow::dockInit()
|
||||
{
|
||||
setDockNestingEnabled(true);
|
||||
QDockWidget* dock;
|
||||
QWidget* widget;
|
||||
int count = ui->funcTab->count();
|
||||
qDebug() << "dock count" << count;
|
||||
for(int i = 0; i < count; i++)
|
||||
{
|
||||
dock = new QDockWidget(ui->funcTab->tabText(0), this);
|
||||
qDebug() << "dock name" << ui->funcTab->tabText(0);
|
||||
dock->setFeatures(QDockWidget::DockWidgetFloatable | QDockWidget::DockWidgetMovable);// movable is necessary, otherwise the dock cannot be dragged
|
||||
dock->setAllowedAreas(Qt::BottomDockWidgetArea);
|
||||
widget = ui->funcTab->widget(0);
|
||||
dock->setWidget(widget);
|
||||
if(widget->objectName() == "rawTab")
|
||||
Util::setRawTab(dock, i);
|
||||
addDockWidget(Qt::BottomDockWidgetArea, dock);
|
||||
if(!dockList.isEmpty())
|
||||
tabifyDockWidget(dockList[0], dock);
|
||||
dockList.append(dock);
|
||||
}
|
||||
ui->funcTab->setVisible(false);
|
||||
dockList[0]->setVisible(true);
|
||||
dockList[0]->raise();
|
||||
}
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include <QScrollBar>
|
||||
#include <QTimer>
|
||||
#include <QDateTime>
|
||||
#include <QDockWidget>
|
||||
|
||||
#include "common/myeventfilter.h"
|
||||
#include "common/pm3process.h"
|
||||
@ -228,6 +229,8 @@ private:
|
||||
LF* lf;
|
||||
Util* util;
|
||||
|
||||
QList<QDockWidget*> dockList;
|
||||
|
||||
MF_trailerDecoderDialog* decDialog;
|
||||
|
||||
void signalInit();
|
||||
@ -236,6 +239,7 @@ private:
|
||||
void setState(bool st);
|
||||
void saveClientPath(const QString& path);
|
||||
void onLFfreqConfChanged(int value, bool isCustomized);
|
||||
void dockInit();
|
||||
signals:
|
||||
void connectPM3(const QString& path, const QStringList args);
|
||||
void reconnectPM3();
|
||||
|
@ -130,7 +130,7 @@
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>1</number>
|
||||
<number>3</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="mifareTab">
|
||||
<attribute name="title">
|
||||
|
Loading…
x
Reference in New Issue
Block a user