mirror of
https://github.com/wh201906/Proxmark3GUI.git
synced 2025-02-16 22:21:30 +08:00
Support dragging files
This commit is contained in:
parent
e34c36e572
commit
2b8e31e452
12
main.cpp
12
main.cpp
@ -14,18 +14,30 @@ int main(int argc, char *argv[])
|
||||
QVariant lang = settings->value("lang", "null");
|
||||
if(lang == "null")
|
||||
{
|
||||
#ifdef Q_OS_WIN
|
||||
lang = "lang/en_US.qm";
|
||||
#else
|
||||
lang = "lang/en_US.ts";
|
||||
#endif
|
||||
QStringList langList;
|
||||
langList.append("English");
|
||||
langList.append("简体中文");
|
||||
QString seletedText = QInputDialog::getItem(&w, "", "Choose a language:", langList, 0, false);
|
||||
if(seletedText == "English")
|
||||
{
|
||||
#ifdef Q_OS_WIN
|
||||
lang = "lang/en_US.qm";
|
||||
#else
|
||||
lang = "lang/en_US.ts";
|
||||
#endif
|
||||
}
|
||||
else if(seletedText == "简体中文")
|
||||
{
|
||||
#ifdef Q_OS_WIN
|
||||
lang = "lang/zh_CN.qm";
|
||||
#else
|
||||
lang = "lang/zh_CN.ts";
|
||||
#endif
|
||||
}
|
||||
}
|
||||
QTranslator* translator = new QTranslator(&w);
|
||||
|
@ -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>
|
||||
|
Loading…
x
Reference in New Issue
Block a user