From e09fdf1b9b705909187b14f8c6e28c0bfc4b59bc Mon Sep 17 00:00:00 2001 From: wh201906 <62299611+wh201906@users.noreply.github.com> Date: Wed, 8 Apr 2020 18:18:53 +0800 Subject: [PATCH] add command history --- mainwindow.cpp | 38 ++++++++++++++++ mainwindow.h | 7 +++ mainwindow.ui | 118 +++++++++++++++++++++++++++++++++++++++++-------- mifare.cpp | 3 ++ 4 files changed, 148 insertions(+), 18 deletions(-) diff --git a/mainwindow.cpp b/mainwindow.cpp index be30e8a..4bea3eb 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -1,4 +1,6 @@ #include "mainwindow.h" +#include "mainwindow.h" +#include "mainwindow.h" #include "ui_mainwindow.h" MainWindow::MainWindow(QWidget *parent) @@ -41,6 +43,9 @@ MainWindow::MainWindow(QWidget *parent) ui->keyView->setColumnWidth(0,50); ui->keyView->setColumnWidth(1,200); ui->keyView->setColumnWidth(2,200); + + on_moreFuncCheckBox_stateChanged(0); + on_portButton_clicked(); } MainWindow::~MainWindow() @@ -60,6 +65,8 @@ void MainWindow::on_connectButton_clicked() void MainWindow::on_sendButton_clicked() { + if(ui->CMDHistoryWidget->count()==0 || ui->CMDHistoryWidget->item(ui->CMDHistoryWidget->count()-1)->text()!=ui->commandEdit->text()) + ui->CMDHistoryWidget->addItem(ui->commandEdit->text()); qDebug()<<(ui->commandEdit->text().toLocal8Bit()); pm3->write((ui->commandEdit->text()+"\r\n").toLocal8Bit()); pm3->waitForBytesWritten(3000); @@ -102,3 +109,34 @@ void MainWindow::on_portButton_clicked() ui->portBox->addItem(port); } } + +void MainWindow::on_moreFuncCheckBox_stateChanged(int arg1) +{ + if(ui->moreFuncCheckBox->isChecked()) + { + ui->CMDTreeView->setVisible(true); + ui->CMDTreeLabel->setVisible(true); + ui->CMDHistoryWidget->setVisible(true); + ui->CMDHistoryLabel->setVisible(true); + ui->clearHistoryButton->setVisible(true); + } + else + { + ui->CMDTreeView->setVisible(false); + ui->CMDTreeLabel->setVisible(false); + ui->CMDHistoryWidget->setVisible(false); + ui->CMDHistoryLabel->setVisible(false); + ui->clearHistoryButton->setVisible(false); + } +} + +void MainWindow::on_clearHistoryButton_clicked() +{ + ui->CMDHistoryWidget->clear(); +} + +void MainWindow::on_CMDHistoryWidget_itemDoubleClicked(QListWidgetItem *item) +{ + ui->commandEdit->setText(item->text()); + ui->commandEdit->setFocus(); +} diff --git a/mainwindow.h b/mainwindow.h index c695d92..36daec9 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -6,6 +6,7 @@ #include #include #include +#include #include "pm3process.h" #include "mifare.h" @@ -35,6 +36,12 @@ private slots: void sendMSG(); void on_portButton_clicked(); + void on_moreFuncCheckBox_stateChanged(int arg1); + + void on_clearHistoryButton_clicked(); + + void on_CMDHistoryWidget_itemDoubleClicked(QListWidgetItem *item); + private: Ui::MainWindow *ui; PM3Process* pm3; diff --git a/mainwindow.ui b/mainwindow.ui index 693bc0f..cc37c7d 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -6,8 +6,8 @@ 0 0 - 1038 - 758 + 881 + 656 @@ -42,7 +42,7 @@ - proxmark3 + E:\Documents\source\qt\pm3\win64\proxmark3 @@ -81,7 +81,7 @@ - 0 + 1 @@ -213,7 +213,15 @@ - + + + + 0 + 0 + 520 + 194 + + @@ -254,19 +262,93 @@ RawCommand - + - - - Qt::ScrollBarAlwaysOn - - - QAbstractScrollArea::AdjustIgnored - - - true - - + + + + + + 2 + 0 + + + + Qt::ScrollBarAlwaysOn + + + QAbstractScrollArea::AdjustIgnored + + + true + + + + + + + + + Command List: + + + + + + + + 1 + 0 + + + + + + + + History: + + + + + + + + 1 + 0 + + + + + + + + + 0 + 0 + + + + Qt::LeftToRight + + + ClearHistory + + + + + + + Qt::RightToLeft + + + + + + + + + @@ -303,7 +385,7 @@ 0 0 - 1038 + 881 22 diff --git a/mifare.cpp b/mifare.cpp index 80f9c5a..e831f78 100644 --- a/mifare.cpp +++ b/mifare.cpp @@ -11,6 +11,9 @@ void Mifare::processData(const QString str) if(isProcessingData) { if(inputType==FROM_RDBL) + { + + } } } void Mifare::processKey(const QString str)