mirror of
https://github.com/wh201906/Proxmark3GUI.git
synced 2026-06-30 23:34:27 +08:00
Support dragging files
This commit is contained in:
@@ -522,6 +522,9 @@ void MainWindow::uiInit()
|
||||
typeBtnGroup->addButton(ui->MF_Type_4kButton, 4);
|
||||
connect(typeBtnGroup, QOverload<int, bool>::of(&QButtonGroup::buttonToggled), this, &MainWindow::MF_onTypeChanged);
|
||||
|
||||
ui->MF_keyWidget->installEventFilter(this);
|
||||
ui->MF_dataWidget->installEventFilter(this);
|
||||
|
||||
on_Raw_CMDHistoryBox_stateChanged(Qt::Unchecked);
|
||||
on_PM3_refreshPortButton_clicked();
|
||||
}
|
||||
@@ -554,4 +557,46 @@ void MainWindow::setTableItem(QTableWidget* widget, int row, int column, const Q
|
||||
widget->setItem(row, column, new QTableWidgetItem());
|
||||
widget->item(row, column)->setText(text);
|
||||
}
|
||||
|
||||
bool MainWindow::eventFilter(QObject *watched, QEvent *event) // drag support
|
||||
{
|
||||
if(event->type() == QEvent::DragEnter)
|
||||
{
|
||||
QDragEnterEvent* dragEvent = static_cast<QDragEnterEvent*>(event);
|
||||
dragEvent->acceptProposedAction();
|
||||
return true;
|
||||
}
|
||||
else if(event->type() == QEvent::Drop)
|
||||
{
|
||||
QDropEvent* dropEvent = static_cast<QDropEvent*>(event);
|
||||
if(watched == ui->MF_keyWidget)
|
||||
{
|
||||
const QMimeData* mime = dropEvent->mimeData();
|
||||
if(mime->hasUrls())
|
||||
{
|
||||
QList<QUrl> urls = mime->urls();
|
||||
if(urls.length() == 1)
|
||||
{
|
||||
mifare->data_loadKeyFile(urls[0].toLocalFile());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(watched == ui->MF_dataWidget)
|
||||
{
|
||||
const QMimeData* mime = dropEvent->mimeData();
|
||||
if(mime->hasUrls())
|
||||
{
|
||||
QList<QUrl> urls = mime->urls();
|
||||
if(urls.length() == 1)
|
||||
{
|
||||
mifare->data_loadDataFile(urls[0].toLocalFile());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return QMainWindow::eventFilter(watched, event);
|
||||
}
|
||||
|
||||
// ***********************************************
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include <QFontDialog>
|
||||
#include <QtSerialPort/QSerialPortInfo>
|
||||
#include <QtSerialPort/QSerialPort>
|
||||
#include <QMimeData>
|
||||
|
||||
#include "common/pm3process.h"
|
||||
#include "module/mifare.h"
|
||||
@@ -33,6 +34,7 @@ public:
|
||||
~MainWindow();
|
||||
|
||||
void initUI();
|
||||
bool eventFilter(QObject *watched, QEvent *event);
|
||||
public slots:
|
||||
void refreshOutput(const QString &output);
|
||||
void refreshCMD(const QString &cmd);
|
||||
|
||||
@@ -144,6 +144,9 @@
|
||||
<pointsize>12</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="acceptDrops">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="selectionMode">
|
||||
<enum>QAbstractItemView::SingleSelection</enum>
|
||||
</property>
|
||||
@@ -284,6 +287,9 @@
|
||||
<pointsize>12</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="acceptDrops">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="selectionMode">
|
||||
<enum>QAbstractItemView::SingleSelection</enum>
|
||||
</property>
|
||||
|
||||
Reference in New Issue
Block a user