diff --git a/src/blackgui/components/configurationwizard.cpp b/src/blackgui/components/configurationwizard.cpp index 0dbe5886a..3fe0833fa 100644 --- a/src/blackgui/components/configurationwizard.cpp +++ b/src/blackgui/components/configurationwizard.cpp @@ -75,14 +75,8 @@ namespace BlackGui bool CConfigurationWizard::event(QEvent *event) { - if (event->type() != QEvent::EnterWhatsThisMode) { return QDialog::event(event); } - const QPointer myself(this); - QTimer::singleShot(0, this, [ = ] - { - if (myself.isNull() || !sGui || sGui->isShuttingDown()) { return; } - sGui->showHelp(this); - }); - return true; + if (CGuiApplication::triggerShowHelp(this, event)) { return true; } + return QDialog::event(event); } void CConfigurationWizard::wizardCurrentIdChanged(int id) diff --git a/src/blackgui/components/copyconfigurationdialog.cpp b/src/blackgui/components/copyconfigurationdialog.cpp index 827897179..f15e7bb03 100644 --- a/src/blackgui/components/copyconfigurationdialog.cpp +++ b/src/blackgui/components/copyconfigurationdialog.cpp @@ -9,6 +9,7 @@ #include "copyconfigurationdialog.h" #include "ui_copyconfigurationdialog.h" +#include "blackgui/guiapplication.h" namespace BlackGui { @@ -49,5 +50,11 @@ namespace BlackGui { ui->comp_CopyConfiguration->setWithBootstrapFile(withBootstrapFile); } + + bool CCopyConfigurationDialog::event(QEvent *event) + { + if (CGuiApplication::triggerShowHelp(this, event)) { return true; } + return QDialog::event(event); + } } // ns } // ns diff --git a/src/blackgui/components/copyconfigurationdialog.h b/src/blackgui/components/copyconfigurationdialog.h index d48bd43fa..5a2426269 100644 --- a/src/blackgui/components/copyconfigurationdialog.h +++ b/src/blackgui/components/copyconfigurationdialog.h @@ -50,6 +50,10 @@ namespace BlackGui //! \copydoc CCopyConfigurationComponent::setWithBootstrapFile void setWithBootstrapFile(bool withBootstrapFile); + protected: + //! \copydoc QObject::event + virtual bool event(QEvent *event) override; + private: QScopedPointer ui; }; diff --git a/src/blackgui/components/dbownmodelsetformdialog.cpp b/src/blackgui/components/dbownmodelsetformdialog.cpp index f1e901a09..cf13facaa 100644 --- a/src/blackgui/components/dbownmodelsetformdialog.cpp +++ b/src/blackgui/components/dbownmodelsetformdialog.cpp @@ -11,6 +11,7 @@ #include "blackgui/components/dbmappingcomponent.h" #include "blackgui/components/dbownmodelsetformdialog.h" #include "blackgui/editors/ownmodelsetform.h" +#include "blackgui/guiapplication.h" #include "blackmisc/logcategory.h" #include "blackmisc/logcategorylist.h" #include "blackmisc/simulation/distributorlist.h" @@ -71,6 +72,12 @@ namespace BlackGui return QDialog::exec(); } + bool CDbOwnModelSetFormDialog::event(QEvent *event) + { + if (CGuiApplication::triggerShowHelp(this, event)) { return true; } + return QDialog::event(event); + } + void CDbOwnModelSetFormDialog::buttonClicked() { const QObject *sender = QObject::sender(); diff --git a/src/blackgui/components/dbownmodelsetformdialog.h b/src/blackgui/components/dbownmodelsetformdialog.h index 657f63b88..4255cea03 100644 --- a/src/blackgui/components/dbownmodelsetformdialog.h +++ b/src/blackgui/components/dbownmodelsetformdialog.h @@ -62,6 +62,10 @@ namespace BlackGui //! Exec and display simulator virtual int exec() override; + protected: + //! \copydoc QObject::event + virtual bool event(QEvent *event) override; + private: QScopedPointer ui; BlackMisc::Simulation::CAircraftModelList m_modelSet; diff --git a/src/blackgui/components/interpolationlogdisplaydialog.cpp b/src/blackgui/components/interpolationlogdisplaydialog.cpp index e864d5762..4c230949f 100644 --- a/src/blackgui/components/interpolationlogdisplaydialog.cpp +++ b/src/blackgui/components/interpolationlogdisplaydialog.cpp @@ -9,6 +9,7 @@ #include "interpolationlogdisplaydialog.h" #include "ui_interpolationlogdisplaydialog.h" +#include "blackgui/guiapplication.h" #include "blackcore/simulator.h" using namespace BlackCore; @@ -22,7 +23,6 @@ namespace BlackGui ui(new Ui::CInterpolationLogDisplayDialog) { ui->setupUi(this); - this->setWindowFlags(this->windowFlags() & ~Qt::WindowContextHelpButtonHint); this->setSimulator(simulator); if (airspaceMonitor) @@ -50,5 +50,11 @@ namespace BlackGui { ui->comp_InterpolationLogDisplay->setAirspaceMonitor(airspaceMonitor); } + + bool CInterpolationLogDisplayDialog::event(QEvent *event) + { + if (CGuiApplication::triggerShowHelp(this, event)) { return true; } + return QDialog::event(event); + } } // ns } // ns diff --git a/src/blackgui/components/interpolationlogdisplaydialog.h b/src/blackgui/components/interpolationlogdisplaydialog.h index 55ed84385..c85c5bdd3 100644 --- a/src/blackgui/components/interpolationlogdisplaydialog.h +++ b/src/blackgui/components/interpolationlogdisplaydialog.h @@ -48,6 +48,10 @@ namespace BlackGui //! Set airspace monitor void setAirspaceMonitor(BlackCore::CAirspaceMonitor *airspaceMonitor); + protected: + //! \copydoc QObject::event + virtual bool event(QEvent *event) override; + private: QScopedPointer ui; }; diff --git a/src/blackgui/components/updateinfodialog.cpp b/src/blackgui/components/updateinfodialog.cpp index debfe9b67..bbf5b0af6 100644 --- a/src/blackgui/components/updateinfodialog.cpp +++ b/src/blackgui/components/updateinfodialog.cpp @@ -56,9 +56,8 @@ namespace BlackGui bool CUpdateInfoDialog::event(QEvent *event) { - if (event->type() != QEvent::EnterWhatsThisMode) { return QDialog::event(event); } - QTimer::singleShot(0, this, &CUpdateInfoDialog::requestHelp); - return true; + if (CGuiApplication::triggerShowHelp(this, event)) { return true; } + return QDialog::event(event); } void CUpdateInfoDialog::onDontShowAgain(bool dontShowAgain) @@ -71,10 +70,5 @@ namespace BlackGui const bool nv = ui->comp_UpdateInfo->isNewPilotClientVersionAvailable(); ui->bb_UpdateInfolDialog->button(QDialogButtonBox::Ok)->setVisible(nv); } - - void CUpdateInfoDialog::requestHelp() - { - if (sGui) { sGui->showHelp(this); } - } } // ns } // ns diff --git a/src/blackgui/components/updateinfodialog.h b/src/blackgui/components/updateinfodialog.h index efe8abe32..69cba1a41 100644 --- a/src/blackgui/components/updateinfodialog.h +++ b/src/blackgui/components/updateinfodialog.h @@ -41,6 +41,7 @@ namespace BlackGui //! \copydoc QDialog::exec virtual int exec() override; + protected: //! \copydoc QObject::event virtual bool event(QEvent *event) override; @@ -53,9 +54,6 @@ namespace BlackGui //! Selection in distribution component changed void selectionChanged(); - - //! Request context help - void requestHelp(); }; } // ns } // ns diff --git a/src/blackgui/guiapplication.cpp b/src/blackgui/guiapplication.cpp index 81af8c421..6e794fa34 100644 --- a/src/blackgui/guiapplication.cpp +++ b/src/blackgui/guiapplication.cpp @@ -55,6 +55,7 @@ #include #include #include +#include using namespace BlackConfig; using namespace BlackMisc; @@ -721,6 +722,7 @@ namespace BlackGui void CGuiApplication::showHelp(const QString &context) const { + if (this->isShuttingDown()) { return; } const CGlobalSetup gs = this->getGlobalSetup(); const CUrl helpPage = gs.getHelpPageUrl(context); if (helpPage.isEmpty()) @@ -733,10 +735,26 @@ namespace BlackGui void CGuiApplication::showHelp(const QObject *qObject) const { + if (this->isShuttingDown()) { return; } if (!qObject || qObject->objectName().isEmpty()) { return this->showHelp(); } return this->showHelp(qObject->objectName()); } + bool CGuiApplication::triggerShowHelp(const QWidget *widget, QEvent *event) + { + if (!widget) { return false; } + if (!event) { return false; } + if (event->type() != QEvent::EnterWhatsThisMode) { return false; } + QWhatsThis::leaveWhatsThisMode(); + const QPointer wp(widget); + QTimer::singleShot(0, sGui, [ = ] + { + if (wp.isNull() || !sGui || sGui->isShuttingDown()) { return; } + sGui->showHelp(widget); + }); + return true; + } + const CStyleSheetUtility &CGuiApplication::getStyleSheetUtility() const { return m_styleSheetUtility; diff --git a/src/blackgui/guiapplication.h b/src/blackgui/guiapplication.h index cf7676137..428815b69 100644 --- a/src/blackgui/guiapplication.h +++ b/src/blackgui/guiapplication.h @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -159,6 +160,9 @@ namespace BlackGui //! Show help page (online help), use QObject::objectName as 2nd level context void showHelp(const QObject *qObject) const; + //! Static version used with dialogs + static bool triggerShowHelp(const QWidget *widget, QEvent *event); + //! Style sheet handling const CStyleSheetUtility &getStyleSheetUtility() const;