From e9641a4dbf74926fade4b19eeda7c5db2a214d74 Mon Sep 17 00:00:00 2001 From: dreamsourcelabTAI Date: Wed, 7 Jun 2023 18:57:36 +0800 Subject: [PATCH] fix: The confirm box to swich device is too much --- DSView/pv/mainwindow.cpp | 4 +++- DSView/pv/ui/msgbox.cpp | 8 ++++++-- DSView/pv/ui/msgbox.h | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/DSView/pv/mainwindow.cpp b/DSView/pv/mainwindow.cpp index be94d87f..6270aea4 100644 --- a/DSView/pv/mainwindow.cpp +++ b/DSView/pv/mainwindow.cpp @@ -1921,9 +1921,11 @@ namespace pv { QString msgText = L_S(STR_PAGE_MSG, S_ID(IDS_MSG_TO_SWITCH_DEVICE), "To switch the new device?"); - if (MsgBox::Confirm(msgText) == false){ + if (MsgBox::Confirm(msgText, "", &_msg, NULL) == false){ + _msg = NULL; return; } + _msg = NULL; } // The store confirm is not processed. diff --git a/DSView/pv/ui/msgbox.cpp b/DSView/pv/ui/msgbox.cpp index cbf7b5fd..0397a114 100644 --- a/DSView/pv/ui/msgbox.cpp +++ b/DSView/pv/ui/msgbox.cpp @@ -85,10 +85,10 @@ void MsgBox::Show(const QString title, const QString text, const QString infoTex bool MsgBox::Confirm(const QString text, QWidget *parent) { - return MsgBox::Confirm(text, "", parent); + return MsgBox::Confirm(text, "", NULL, parent); } -bool MsgBox::Confirm(const QString text, const QString infoText, QWidget *parent) +bool MsgBox::Confirm(const QString text, const QString infoText, pv::dialogs::DSMessageBox **box, QWidget *parent) { assert(!text.isEmpty()); @@ -110,6 +110,10 @@ bool MsgBox::Confirm(const QString text, const QString infoText, QWidget *parent msg.mBox()->setInformativeText(infoText); } + if (box != NULL){ + *box = &msg; + } + msg.exec(); return msg.IsYes(); } diff --git a/DSView/pv/ui/msgbox.h b/DSView/pv/ui/msgbox.h index c3dd81b7..05bb88f7 100644 --- a/DSView/pv/ui/msgbox.h +++ b/DSView/pv/ui/msgbox.h @@ -41,5 +41,5 @@ public: static void Show(const QString title, const QString text, const QString infoText, QWidget *parent, pv::dialogs::DSMessageBox **box, bool bExecute=true); static bool Confirm(const QString text, QWidget *parent=0); - static bool Confirm(const QString text, const QString infoText, QWidget *parent=0); + static bool Confirm(const QString text, const QString infoText, pv::dialogs::DSMessageBox **box=0, QWidget *parent=0); }; \ No newline at end of file