diff --git a/ui/mainwindow.cpp b/ui/mainwindow.cpp index 62f27f5..faec518 100644 --- a/ui/mainwindow.cpp +++ b/ui/mainwindow.cpp @@ -6,9 +6,15 @@ MainWindow::MainWindow(QWidget *parent): , ui(new Ui::MainWindow) { ui->setupUi(this); + dockAllWindows = new QAction(tr("Dock all windows"), 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); + connect(dockAllWindows, &QAction::triggered, [ = ]() + { + for(int i = 0; i < dockList.size(); i++) + dockList[i]->setFloating(false); + }); connect(myInfo, &QAction::triggered, [ = ]() { QDesktopServices::openUrl(QUrl("https://github.com/wh201906")); @@ -17,9 +23,6 @@ MainWindow::MainWindow(QWidget *parent): { 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->setIniCodec("UTF-8"); @@ -47,6 +50,14 @@ MainWindow::MainWindow(QWidget *parent): connect(portSearchTimer, &QTimer::timeout, this, &MainWindow::on_portSearchTimer_timeout); portSearchTimer->start(); + contextMenu = new QMenu(); + contextMenu->addAction(dockAllWindows); + contextMenu->addSeparator(); + contextMenu->addAction(myInfo); + currVersion->setEnabled(false); + contextMenu->addAction(currVersion); + contextMenu->addAction(checkUpdate); + } MainWindow::~MainWindow() @@ -1304,6 +1315,7 @@ void MainWindow::dockInit() 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); + dock->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); widget = ui->funcTab->widget(0); dock->setWidget(widget); if(widget->objectName() == "rawTab") @@ -1317,3 +1329,8 @@ void MainWindow::dockInit() dockList[0]->setVisible(true); dockList[0]->raise(); } + +void MainWindow::contextMenuEvent(QContextMenuEvent *event) +{ + contextMenu->exec(event->globalPos()); +} diff --git a/ui/mainwindow.h b/ui/mainwindow.h index 6fc8078..beef663 100644 --- a/ui/mainwindow.h +++ b/ui/mainwindow.h @@ -25,6 +25,7 @@ #include #include #include +#include #include "common/myeventfilter.h" #include "common/pm3process.h" @@ -203,6 +204,7 @@ private: QLabel* programStatusBar; QLabel* PM3VersionBar; QPushButton* stopButton; + QAction* dockAllWindows; QAction* myInfo; QAction* currVersion; QAction* checkUpdate; @@ -230,6 +232,7 @@ private: Util* util; QList dockList; + QMenu* contextMenu; MF_trailerDecoderDialog* decDialog; @@ -240,6 +243,8 @@ private: void saveClientPath(const QString& path); void onLFfreqConfChanged(int value, bool isCustomized); void dockInit(); +protected: + void contextMenuEvent(QContextMenuEvent *event) override; signals: void connectPM3(const QString& path, const QStringList args); void reconnectPM3(); diff --git a/ui/mainwindow.ui b/ui/mainwindow.ui index 0be8763..c837607 100644 --- a/ui/mainwindow.ui +++ b/ui/mainwindow.ui @@ -16,9 +16,6 @@ 600 - - Qt::ActionsContextMenu - Proxmark3GUI @@ -47,11 +44,14 @@ - - QLayout::SetMaximumSize - + + + 0 + 0 + + Client Path: @@ -62,6 +62,12 @@ + + + 0 + 0 + + Port: @@ -130,7 +136,7 @@ - 3 + 0