Add QAction: Dock all windows

pull/33/head
wh201906 4 years ago
parent 799e00d66e
commit 019afed198

@ -6,9 +6,15 @@ MainWindow::MainWindow(QWidget *parent):
, ui(new Ui::MainWindow) , ui(new Ui::MainWindow)
{ {
ui->setupUi(this); ui->setupUi(this);
dockAllWindows = new QAction(tr("Dock all windows"), this);
myInfo = new QAction("wh201906", this); myInfo = new QAction("wh201906", this);
currVersion = new QAction("Ver: " + QApplication::applicationVersion().section('.', 0, -2), this); // ignore the 4th version number currVersion = new QAction(tr("Ver: ") + QApplication::applicationVersion().section('.', 0, -2), this); // ignore the 4th version number
checkUpdate = new QAction(tr("Check Update"), this); checkUpdate = new QAction(tr("Check Update"), this);
connect(dockAllWindows, &QAction::triggered, [ = ]()
{
for(int i = 0; i < dockList.size(); i++)
dockList[i]->setFloating(false);
});
connect(myInfo, &QAction::triggered, [ = ]() connect(myInfo, &QAction::triggered, [ = ]()
{ {
QDesktopServices::openUrl(QUrl("https://github.com/wh201906")); QDesktopServices::openUrl(QUrl("https://github.com/wh201906"));
@ -17,9 +23,6 @@ MainWindow::MainWindow(QWidget *parent):
{ {
QDesktopServices::openUrl(QUrl("https://github.com/wh201906/Proxmark3GUI/releases")); QDesktopServices::openUrl(QUrl("https://github.com/wh201906/Proxmark3GUI/releases"));
}); });
this->addAction(myInfo);
this->addAction(currVersion);
this->addAction(checkUpdate);
settings = new QSettings("GUIsettings.ini", QSettings::IniFormat); settings = new QSettings("GUIsettings.ini", QSettings::IniFormat);
settings->setIniCodec("UTF-8"); settings->setIniCodec("UTF-8");
@ -47,6 +50,14 @@ MainWindow::MainWindow(QWidget *parent):
connect(portSearchTimer, &QTimer::timeout, this, &MainWindow::on_portSearchTimer_timeout); connect(portSearchTimer, &QTimer::timeout, this, &MainWindow::on_portSearchTimer_timeout);
portSearchTimer->start(); portSearchTimer->start();
contextMenu = new QMenu();
contextMenu->addAction(dockAllWindows);
contextMenu->addSeparator();
contextMenu->addAction(myInfo);
currVersion->setEnabled(false);
contextMenu->addAction(currVersion);
contextMenu->addAction(checkUpdate);
} }
MainWindow::~MainWindow() MainWindow::~MainWindow()
@ -1304,6 +1315,7 @@ void MainWindow::dockInit()
qDebug() << "dock name" << ui->funcTab->tabText(0); qDebug() << "dock name" << ui->funcTab->tabText(0);
dock->setFeatures(QDockWidget::DockWidgetFloatable | QDockWidget::DockWidgetMovable);// movable is necessary, otherwise the dock cannot be dragged dock->setFeatures(QDockWidget::DockWidgetFloatable | QDockWidget::DockWidgetMovable);// movable is necessary, otherwise the dock cannot be dragged
dock->setAllowedAreas(Qt::BottomDockWidgetArea); dock->setAllowedAreas(Qt::BottomDockWidgetArea);
dock->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
widget = ui->funcTab->widget(0); widget = ui->funcTab->widget(0);
dock->setWidget(widget); dock->setWidget(widget);
if(widget->objectName() == "rawTab") if(widget->objectName() == "rawTab")
@ -1317,3 +1329,8 @@ void MainWindow::dockInit()
dockList[0]->setVisible(true); dockList[0]->setVisible(true);
dockList[0]->raise(); dockList[0]->raise();
} }
void MainWindow::contextMenuEvent(QContextMenuEvent *event)
{
contextMenu->exec(event->globalPos());
}

@ -25,6 +25,7 @@
#include <QTimer> #include <QTimer>
#include <QDateTime> #include <QDateTime>
#include <QDockWidget> #include <QDockWidget>
#include <QMenu>
#include "common/myeventfilter.h" #include "common/myeventfilter.h"
#include "common/pm3process.h" #include "common/pm3process.h"
@ -203,6 +204,7 @@ private:
QLabel* programStatusBar; QLabel* programStatusBar;
QLabel* PM3VersionBar; QLabel* PM3VersionBar;
QPushButton* stopButton; QPushButton* stopButton;
QAction* dockAllWindows;
QAction* myInfo; QAction* myInfo;
QAction* currVersion; QAction* currVersion;
QAction* checkUpdate; QAction* checkUpdate;
@ -230,6 +232,7 @@ private:
Util* util; Util* util;
QList<QDockWidget*> dockList; QList<QDockWidget*> dockList;
QMenu* contextMenu;
MF_trailerDecoderDialog* decDialog; MF_trailerDecoderDialog* decDialog;
@ -240,6 +243,8 @@ private:
void saveClientPath(const QString& path); void saveClientPath(const QString& path);
void onLFfreqConfChanged(int value, bool isCustomized); void onLFfreqConfChanged(int value, bool isCustomized);
void dockInit(); void dockInit();
protected:
void contextMenuEvent(QContextMenuEvent *event) override;
signals: signals:
void connectPM3(const QString& path, const QStringList args); void connectPM3(const QString& path, const QStringList args);
void reconnectPM3(); void reconnectPM3();

@ -16,9 +16,6 @@
<height>600</height> <height>600</height>
</size> </size>
</property> </property>
<property name="contextMenuPolicy">
<enum>Qt::ActionsContextMenu</enum>
</property>
<property name="windowTitle"> <property name="windowTitle">
<string>Proxmark3GUI</string> <string>Proxmark3GUI</string>
</property> </property>
@ -47,11 +44,14 @@
</property> </property>
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout"> <layout class="QHBoxLayout" name="horizontalLayout">
<property name="sizeConstraint">
<enum>QLayout::SetMaximumSize</enum>
</property>
<item> <item>
<widget class="QLabel" name="label"> <widget class="QLabel" name="label">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text"> <property name="text">
<string>Client Path:</string> <string>Client Path:</string>
</property> </property>
@ -62,6 +62,12 @@
</item> </item>
<item> <item>
<widget class="QLabel" name="label_18"> <widget class="QLabel" name="label_18">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text"> <property name="text">
<string>Port:</string> <string>Port:</string>
</property> </property>
@ -130,7 +136,7 @@
</sizepolicy> </sizepolicy>
</property> </property>
<property name="currentIndex"> <property name="currentIndex">
<number>3</number> <number>0</number>
</property> </property>
<widget class="QWidget" name="mifareTab"> <widget class="QWidget" name="mifareTab">
<attribute name="title"> <attribute name="title">

Loading…
Cancel
Save