mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-31 21:15:33 +08:00
Improved context sensitive help
- create utilty function CGuiApplication::triggerShowHelp - this function also uses "QWhatsThis::leaveWhatsThisMode" which solves the problem that the help was not properly called a 2nd time - adjusted using classes
This commit is contained in:
@@ -75,14 +75,8 @@ namespace BlackGui
|
||||
|
||||
bool CConfigurationWizard::event(QEvent *event)
|
||||
{
|
||||
if (event->type() != QEvent::EnterWhatsThisMode) { return QDialog::event(event); }
|
||||
const QPointer<CConfigurationWizard> 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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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::CCopyConfigurationDialog> ui;
|
||||
};
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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::CDbOwnModelSetFormDialog> ui;
|
||||
BlackMisc::Simulation::CAircraftModelList m_modelSet;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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::CInterpolationLogDisplayDialog> ui;
|
||||
};
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -55,6 +55,7 @@
|
||||
#include <QWidget>
|
||||
#include <QMainWindow>
|
||||
#include <QtGlobal>
|
||||
#include <QWhatsThis>
|
||||
|
||||
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<const QWidget> 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;
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include <QCommandLineOption>
|
||||
#include <QDialog>
|
||||
#include <QObject>
|
||||
#include <QEvent>
|
||||
#include <QPixmap>
|
||||
#include <QScopedPointer>
|
||||
#include <QString>
|
||||
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user