mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-15 01:05:35 +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)
|
bool CConfigurationWizard::event(QEvent *event)
|
||||||
{
|
{
|
||||||
if (event->type() != QEvent::EnterWhatsThisMode) { return QDialog::event(event); }
|
if (CGuiApplication::triggerShowHelp(this, event)) { return true; }
|
||||||
const QPointer<CConfigurationWizard> myself(this);
|
return QDialog::event(event);
|
||||||
QTimer::singleShot(0, this, [ = ]
|
|
||||||
{
|
|
||||||
if (myself.isNull() || !sGui || sGui->isShuttingDown()) { return; }
|
|
||||||
sGui->showHelp(this);
|
|
||||||
});
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CConfigurationWizard::wizardCurrentIdChanged(int id)
|
void CConfigurationWizard::wizardCurrentIdChanged(int id)
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
#include "copyconfigurationdialog.h"
|
#include "copyconfigurationdialog.h"
|
||||||
#include "ui_copyconfigurationdialog.h"
|
#include "ui_copyconfigurationdialog.h"
|
||||||
|
#include "blackgui/guiapplication.h"
|
||||||
|
|
||||||
namespace BlackGui
|
namespace BlackGui
|
||||||
{
|
{
|
||||||
@@ -49,5 +50,11 @@ namespace BlackGui
|
|||||||
{
|
{
|
||||||
ui->comp_CopyConfiguration->setWithBootstrapFile(withBootstrapFile);
|
ui->comp_CopyConfiguration->setWithBootstrapFile(withBootstrapFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CCopyConfigurationDialog::event(QEvent *event)
|
||||||
|
{
|
||||||
|
if (CGuiApplication::triggerShowHelp(this, event)) { return true; }
|
||||||
|
return QDialog::event(event);
|
||||||
|
}
|
||||||
} // ns
|
} // ns
|
||||||
} // ns
|
} // ns
|
||||||
|
|||||||
@@ -50,6 +50,10 @@ namespace BlackGui
|
|||||||
//! \copydoc CCopyConfigurationComponent::setWithBootstrapFile
|
//! \copydoc CCopyConfigurationComponent::setWithBootstrapFile
|
||||||
void setWithBootstrapFile(bool withBootstrapFile);
|
void setWithBootstrapFile(bool withBootstrapFile);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
//! \copydoc QObject::event
|
||||||
|
virtual bool event(QEvent *event) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QScopedPointer<Ui::CCopyConfigurationDialog> ui;
|
QScopedPointer<Ui::CCopyConfigurationDialog> ui;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
#include "blackgui/components/dbmappingcomponent.h"
|
#include "blackgui/components/dbmappingcomponent.h"
|
||||||
#include "blackgui/components/dbownmodelsetformdialog.h"
|
#include "blackgui/components/dbownmodelsetformdialog.h"
|
||||||
#include "blackgui/editors/ownmodelsetform.h"
|
#include "blackgui/editors/ownmodelsetform.h"
|
||||||
|
#include "blackgui/guiapplication.h"
|
||||||
#include "blackmisc/logcategory.h"
|
#include "blackmisc/logcategory.h"
|
||||||
#include "blackmisc/logcategorylist.h"
|
#include "blackmisc/logcategorylist.h"
|
||||||
#include "blackmisc/simulation/distributorlist.h"
|
#include "blackmisc/simulation/distributorlist.h"
|
||||||
@@ -71,6 +72,12 @@ namespace BlackGui
|
|||||||
return QDialog::exec();
|
return QDialog::exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CDbOwnModelSetFormDialog::event(QEvent *event)
|
||||||
|
{
|
||||||
|
if (CGuiApplication::triggerShowHelp(this, event)) { return true; }
|
||||||
|
return QDialog::event(event);
|
||||||
|
}
|
||||||
|
|
||||||
void CDbOwnModelSetFormDialog::buttonClicked()
|
void CDbOwnModelSetFormDialog::buttonClicked()
|
||||||
{
|
{
|
||||||
const QObject *sender = QObject::sender();
|
const QObject *sender = QObject::sender();
|
||||||
|
|||||||
@@ -62,6 +62,10 @@ namespace BlackGui
|
|||||||
//! Exec and display simulator
|
//! Exec and display simulator
|
||||||
virtual int exec() override;
|
virtual int exec() override;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
//! \copydoc QObject::event
|
||||||
|
virtual bool event(QEvent *event) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QScopedPointer<Ui::CDbOwnModelSetFormDialog> ui;
|
QScopedPointer<Ui::CDbOwnModelSetFormDialog> ui;
|
||||||
BlackMisc::Simulation::CAircraftModelList m_modelSet;
|
BlackMisc::Simulation::CAircraftModelList m_modelSet;
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
#include "interpolationlogdisplaydialog.h"
|
#include "interpolationlogdisplaydialog.h"
|
||||||
#include "ui_interpolationlogdisplaydialog.h"
|
#include "ui_interpolationlogdisplaydialog.h"
|
||||||
|
#include "blackgui/guiapplication.h"
|
||||||
#include "blackcore/simulator.h"
|
#include "blackcore/simulator.h"
|
||||||
|
|
||||||
using namespace BlackCore;
|
using namespace BlackCore;
|
||||||
@@ -22,7 +23,6 @@ namespace BlackGui
|
|||||||
ui(new Ui::CInterpolationLogDisplayDialog)
|
ui(new Ui::CInterpolationLogDisplayDialog)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
this->setWindowFlags(this->windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
|
||||||
this->setSimulator(simulator);
|
this->setSimulator(simulator);
|
||||||
|
|
||||||
if (airspaceMonitor)
|
if (airspaceMonitor)
|
||||||
@@ -50,5 +50,11 @@ namespace BlackGui
|
|||||||
{
|
{
|
||||||
ui->comp_InterpolationLogDisplay->setAirspaceMonitor(airspaceMonitor);
|
ui->comp_InterpolationLogDisplay->setAirspaceMonitor(airspaceMonitor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CInterpolationLogDisplayDialog::event(QEvent *event)
|
||||||
|
{
|
||||||
|
if (CGuiApplication::triggerShowHelp(this, event)) { return true; }
|
||||||
|
return QDialog::event(event);
|
||||||
|
}
|
||||||
} // ns
|
} // ns
|
||||||
} // ns
|
} // ns
|
||||||
|
|||||||
@@ -48,6 +48,10 @@ namespace BlackGui
|
|||||||
//! Set airspace monitor
|
//! Set airspace monitor
|
||||||
void setAirspaceMonitor(BlackCore::CAirspaceMonitor *airspaceMonitor);
|
void setAirspaceMonitor(BlackCore::CAirspaceMonitor *airspaceMonitor);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
//! \copydoc QObject::event
|
||||||
|
virtual bool event(QEvent *event) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QScopedPointer<Ui::CInterpolationLogDisplayDialog> ui;
|
QScopedPointer<Ui::CInterpolationLogDisplayDialog> ui;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -56,9 +56,8 @@ namespace BlackGui
|
|||||||
|
|
||||||
bool CUpdateInfoDialog::event(QEvent *event)
|
bool CUpdateInfoDialog::event(QEvent *event)
|
||||||
{
|
{
|
||||||
if (event->type() != QEvent::EnterWhatsThisMode) { return QDialog::event(event); }
|
if (CGuiApplication::triggerShowHelp(this, event)) { return true; }
|
||||||
QTimer::singleShot(0, this, &CUpdateInfoDialog::requestHelp);
|
return QDialog::event(event);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CUpdateInfoDialog::onDontShowAgain(bool dontShowAgain)
|
void CUpdateInfoDialog::onDontShowAgain(bool dontShowAgain)
|
||||||
@@ -71,10 +70,5 @@ namespace BlackGui
|
|||||||
const bool nv = ui->comp_UpdateInfo->isNewPilotClientVersionAvailable();
|
const bool nv = ui->comp_UpdateInfo->isNewPilotClientVersionAvailable();
|
||||||
ui->bb_UpdateInfolDialog->button(QDialogButtonBox::Ok)->setVisible(nv);
|
ui->bb_UpdateInfolDialog->button(QDialogButtonBox::Ok)->setVisible(nv);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CUpdateInfoDialog::requestHelp()
|
|
||||||
{
|
|
||||||
if (sGui) { sGui->showHelp(this); }
|
|
||||||
}
|
|
||||||
} // ns
|
} // ns
|
||||||
} // ns
|
} // ns
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ namespace BlackGui
|
|||||||
//! \copydoc QDialog::exec
|
//! \copydoc QDialog::exec
|
||||||
virtual int exec() override;
|
virtual int exec() override;
|
||||||
|
|
||||||
|
protected:
|
||||||
//! \copydoc QObject::event
|
//! \copydoc QObject::event
|
||||||
virtual bool event(QEvent *event) override;
|
virtual bool event(QEvent *event) override;
|
||||||
|
|
||||||
@@ -53,9 +54,6 @@ namespace BlackGui
|
|||||||
|
|
||||||
//! Selection in distribution component changed
|
//! Selection in distribution component changed
|
||||||
void selectionChanged();
|
void selectionChanged();
|
||||||
|
|
||||||
//! Request context help
|
|
||||||
void requestHelp();
|
|
||||||
};
|
};
|
||||||
} // ns
|
} // ns
|
||||||
} // ns
|
} // ns
|
||||||
|
|||||||
@@ -55,6 +55,7 @@
|
|||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
|
#include <QWhatsThis>
|
||||||
|
|
||||||
using namespace BlackConfig;
|
using namespace BlackConfig;
|
||||||
using namespace BlackMisc;
|
using namespace BlackMisc;
|
||||||
@@ -721,6 +722,7 @@ namespace BlackGui
|
|||||||
|
|
||||||
void CGuiApplication::showHelp(const QString &context) const
|
void CGuiApplication::showHelp(const QString &context) const
|
||||||
{
|
{
|
||||||
|
if (this->isShuttingDown()) { return; }
|
||||||
const CGlobalSetup gs = this->getGlobalSetup();
|
const CGlobalSetup gs = this->getGlobalSetup();
|
||||||
const CUrl helpPage = gs.getHelpPageUrl(context);
|
const CUrl helpPage = gs.getHelpPageUrl(context);
|
||||||
if (helpPage.isEmpty())
|
if (helpPage.isEmpty())
|
||||||
@@ -733,10 +735,26 @@ namespace BlackGui
|
|||||||
|
|
||||||
void CGuiApplication::showHelp(const QObject *qObject) const
|
void CGuiApplication::showHelp(const QObject *qObject) const
|
||||||
{
|
{
|
||||||
|
if (this->isShuttingDown()) { return; }
|
||||||
if (!qObject || qObject->objectName().isEmpty()) { return this->showHelp(); }
|
if (!qObject || qObject->objectName().isEmpty()) { return this->showHelp(); }
|
||||||
return this->showHelp(qObject->objectName());
|
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
|
const CStyleSheetUtility &CGuiApplication::getStyleSheetUtility() const
|
||||||
{
|
{
|
||||||
return m_styleSheetUtility;
|
return m_styleSheetUtility;
|
||||||
|
|||||||
@@ -26,6 +26,7 @@
|
|||||||
#include <QCommandLineOption>
|
#include <QCommandLineOption>
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
#include <QEvent>
|
||||||
#include <QPixmap>
|
#include <QPixmap>
|
||||||
#include <QScopedPointer>
|
#include <QScopedPointer>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
@@ -159,6 +160,9 @@ namespace BlackGui
|
|||||||
//! Show help page (online help), use QObject::objectName as 2nd level context
|
//! Show help page (online help), use QObject::objectName as 2nd level context
|
||||||
void showHelp(const QObject *qObject) const;
|
void showHelp(const QObject *qObject) const;
|
||||||
|
|
||||||
|
//! Static version used with dialogs
|
||||||
|
static bool triggerShowHelp(const QWidget *widget, QEvent *event);
|
||||||
|
|
||||||
//! Style sheet handling
|
//! Style sheet handling
|
||||||
const CStyleSheetUtility &getStyleSheetUtility() const;
|
const CStyleSheetUtility &getStyleSheetUtility() const;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user