mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-31 12:55:33 +08:00
[UI] As discussed in FSC channel, display "save" message
* save was only shown ("overlay") if a mapping component is available
* make sure an message is also show in component is used in dialog
* change utility functions and display in "table view" without mapping component
https://discordapp.com/channels/539048679160676382/594962359441948682/643529608070692925
This commit is contained in:
committed by
Mat Sutcliffe
parent
087410039c
commit
3b0001d113
@@ -33,16 +33,16 @@ namespace BlackGui
|
||||
m_mappingComponent = m;
|
||||
}
|
||||
|
||||
void CDbMappingComponentAware::showMappingComponentOverlayMessage(const CStatusMessage &message, int timeoutMs)
|
||||
bool CDbMappingComponentAware::showMappingComponentOverlayMessage(const CStatusMessage &message, int timeoutMs)
|
||||
{
|
||||
if (!m_mappingComponent) { return; }
|
||||
m_mappingComponent->showOverlayMessage(message, timeoutMs);
|
||||
if (!m_mappingComponent) { return false; }
|
||||
return m_mappingComponent->showOverlayMessage(message, timeoutMs);
|
||||
}
|
||||
|
||||
void CDbMappingComponentAware::showMappingComponentOverlayHtmlMessage(const CStatusMessage &message, int timeoutMs)
|
||||
bool CDbMappingComponentAware::showMappingComponentOverlayHtmlMessage(const CStatusMessage &message, int timeoutMs)
|
||||
{
|
||||
if (!m_mappingComponent) { return; }
|
||||
m_mappingComponent->showOverlayHTMLMessage(message, timeoutMs);
|
||||
if (!m_mappingComponent) { return false; }
|
||||
return m_mappingComponent->showOverlayHTMLMessage(message, timeoutMs);
|
||||
}
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
@@ -45,8 +45,8 @@ namespace BlackGui
|
||||
CDbMappingComponentAware &operator =(const CDbMappingComponentAware &) = default;
|
||||
|
||||
//! Overlay messages @{
|
||||
void showMappingComponentOverlayMessage(const BlackMisc::CStatusMessage &message, int timeoutMs = -1);
|
||||
void showMappingComponentOverlayHtmlMessage(const BlackMisc::CStatusMessage &message, int timeoutMs = -1);
|
||||
bool showMappingComponentOverlayMessage(const BlackMisc::CStatusMessage &message, int timeoutMs = -1);
|
||||
bool showMappingComponentOverlayHtmlMessage(const BlackMisc::CStatusMessage &message, int timeoutMs = -1);
|
||||
//! @}
|
||||
|
||||
private :
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
* or distributed except according to the terms contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "blackgui/guiapplication.h"
|
||||
#include "blackgui/components/dbmappingcomponent.h"
|
||||
#include "blackgui/components/dbownmodelsetcomponent.h"
|
||||
#include "blackgui/components/dbownmodelsetformdialog.h"
|
||||
@@ -19,6 +18,8 @@
|
||||
#include "blackgui/views/aircraftmodelview.h"
|
||||
#include "blackgui/views/viewbase.h"
|
||||
#include "blackgui/views/aircraftmodelstatisticsdialog.h"
|
||||
#include "blackgui/guiapplication.h"
|
||||
#include "blackgui/guiutility.h"
|
||||
#include "blackmisc/simulation/aircraftmodelutils.h"
|
||||
#include "blackmisc/simulation/aircraftmodellist.h"
|
||||
#include "blackmisc/simulation/distributorlist.h"
|
||||
@@ -238,15 +239,24 @@ namespace BlackGui
|
||||
if (!ownModelSet.isEmpty())
|
||||
{
|
||||
const CSimulatorInfo sim = this->getSelectedSimulator();
|
||||
const CStatusMessage m = this->setCachedModels(ownModelSet, sim);
|
||||
const CStatusMessage m = this->setCachedModels(ownModelSet, sim);
|
||||
CLogMessage::preformatted(m);
|
||||
if (m.isSuccess())
|
||||
{
|
||||
this->showMappingComponentOverlayHtmlMessage(QStringLiteral("Save model set for '%1'").arg(sim.toQString(true)), 5000);
|
||||
const QString msg = QStringLiteral("Saved model set for '%1'").arg(sim.toQString(true));
|
||||
|
||||
// display either as overlay of componet or view
|
||||
if (!this->showMappingComponentOverlayHtmlMessage(msg, 5000))
|
||||
{
|
||||
ui->tvp_OwnModelSet->showOverlayHTMLMessage(msg, 5000);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this->showMappingComponentOverlayMessage(m);
|
||||
if (!this->showMappingComponentOverlayMessage(m))
|
||||
{
|
||||
ui->tvp_OwnModelSet->showOverlayMessage(m);
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
@@ -493,6 +503,11 @@ namespace BlackGui
|
||||
}
|
||||
}
|
||||
|
||||
bool CDbOwnModelSetComponent::runsInDialog()
|
||||
{
|
||||
return CGuiUtility::findParentDialog(this, 5);
|
||||
}
|
||||
|
||||
void CDbOwnModelSetComponent::CLoadModelSetMenu::customMenu(CMenuActions &menuActions)
|
||||
{
|
||||
// for the moment I use all sims, I could restrict to CSimulatorInfo::getLocallyInstalledSimulators();
|
||||
|
||||
@@ -179,6 +179,9 @@ namespace BlackGui
|
||||
//! Update distributor order
|
||||
void updateDistributorOrder(const BlackMisc::Simulation::CSimulatorInfo &simulator);
|
||||
|
||||
//! Is that component running in a dialog
|
||||
bool runsInDialog();
|
||||
|
||||
QScopedPointer<Ui::CDbOwnModelSetComponent> ui;
|
||||
QScopedPointer<CDbOwnModelSetFormDialog> m_modelSetFormDialog;
|
||||
QScopedPointer<CFirstModelSetDialog> m_firstModelSetDialog;
|
||||
|
||||
@@ -591,17 +591,17 @@ namespace BlackGui
|
||||
return QApplication::topLevelWidgets().contains(widget);
|
||||
}
|
||||
|
||||
bool CGuiUtility::isQMainWindow(QWidget *widget)
|
||||
bool CGuiUtility::isQMainWindow(const QWidget *widget)
|
||||
{
|
||||
if (!widget) { return false; }
|
||||
QMainWindow *mw = qobject_cast<QMainWindow *>(widget);
|
||||
const QMainWindow *mw = qobject_cast<const QMainWindow *>(widget);
|
||||
return mw;
|
||||
}
|
||||
|
||||
bool CGuiUtility::isDialog(QWidget *widget)
|
||||
bool CGuiUtility::isDialog(const QWidget *widget)
|
||||
{
|
||||
if (!widget) { return false; }
|
||||
QDialog *mw = qobject_cast<QDialog *>(widget);
|
||||
const QDialog *mw = qobject_cast<const QDialog *>(widget);
|
||||
return mw;
|
||||
}
|
||||
|
||||
@@ -789,6 +789,20 @@ namespace BlackGui
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
QDialog *CGuiUtility::findParentDialog(QWidget *widget, int maxLevel)
|
||||
{
|
||||
if (CGuiUtility::isDialog(widget)) { return qobject_cast<QDialog *>(widget); }
|
||||
int level = 0;
|
||||
while (widget->parent())
|
||||
{
|
||||
level++;
|
||||
if (level > maxLevel) { return nullptr; }
|
||||
widget = widget->parentWidget();
|
||||
if (CGuiUtility::isDialog(widget)) { return qobject_cast<QDialog *>(widget); }
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void CGuiUtility::setElidedText(QLabel *label, const QString &text, Qt::TextElideMode mode)
|
||||
{
|
||||
if (!label) { return; }
|
||||
|
||||
@@ -206,8 +206,8 @@ namespace BlackGui
|
||||
static bool isTopLevelWindow(QWidget *widget);
|
||||
|
||||
//! Check window type @{
|
||||
static bool isQMainWindow(QWidget *widget);
|
||||
static bool isDialog(QWidget *widget);
|
||||
static bool isQMainWindow(const QWidget *widget);
|
||||
static bool isDialog(const QWidget *widget);
|
||||
//! @}
|
||||
|
||||
//! Fade in a widget
|
||||
@@ -261,6 +261,9 @@ namespace BlackGui
|
||||
//! Find parent dialog if there is any, otherwise null
|
||||
static QDialog *findParentDialog(QWidget *widget);
|
||||
|
||||
//! Find parent dialog if there is any, otherwise null
|
||||
static QDialog *findParentDialog(QWidget *widget, int maxLevel);
|
||||
|
||||
//! Set elided text
|
||||
static void setElidedText(QLabel *label, const QString &text, Qt::TextElideMode mode = Qt::ElideMiddle);
|
||||
|
||||
|
||||
@@ -188,21 +188,23 @@ namespace BlackGui
|
||||
}
|
||||
|
||||
//! \copydoc BlackGui::COverlayMessages::showOverlayMessage
|
||||
void showOverlayMessage(const BlackMisc::CStatusMessage &message, int timeOutMs = -1)
|
||||
bool showOverlayMessage(const BlackMisc::CStatusMessage &message, int timeOutMs = -1)
|
||||
{
|
||||
if (message.isEmpty()) { return; }
|
||||
if (message.isEmpty()) { return false; }
|
||||
this->initInnerFrame();
|
||||
m_overlayMessages->showOverlayMessage(message, timeOutMs);
|
||||
WIDGET::repaint();
|
||||
return true;
|
||||
}
|
||||
|
||||
//! \copydoc BlackGui::COverlayMessages::showOverlayTextMessage
|
||||
void showOverlayTextMessage(const BlackMisc::Network::CTextMessage &textMessage, int timeOutMs = -1)
|
||||
bool showOverlayTextMessage(const BlackMisc::Network::CTextMessage &textMessage, int timeOutMs = -1)
|
||||
{
|
||||
if (textMessage.isEmpty()) { return; }
|
||||
if (textMessage.isEmpty()) { return false; }
|
||||
this->initInnerFrame();
|
||||
m_overlayMessages->showOverlayTextMessage(textMessage, timeOutMs);
|
||||
WIDGET::repaint();
|
||||
return true;
|
||||
}
|
||||
|
||||
//! \copydoc BlackGui::COverlayMessages::showOverlayVariant
|
||||
@@ -231,19 +233,21 @@ namespace BlackGui
|
||||
}
|
||||
|
||||
//! \copydoc BlackGui::COverlayMessages::showHTMLMessage
|
||||
void showOverlayHTMLMessage(const QString &htmlMessage, int timeOutMs = -1)
|
||||
bool showOverlayHTMLMessage(const QString &htmlMessage, int timeOutMs = -1)
|
||||
{
|
||||
this->initMinimalFrame();
|
||||
m_overlayMessages->showHTMLMessage(htmlMessage, timeOutMs);
|
||||
WIDGET::repaint();
|
||||
return true;
|
||||
}
|
||||
|
||||
//! \copydoc BlackGui::COverlayMessages::showHTMLMessage
|
||||
void showOverlayHTMLMessage(const BlackMisc::CStatusMessage &message, int timeOutMs = -1)
|
||||
bool showOverlayHTMLMessage(const BlackMisc::CStatusMessage &message, int timeOutMs = -1)
|
||||
{
|
||||
this->initMinimalFrame();
|
||||
m_overlayMessages->showHTMLMessage(message, timeOutMs);
|
||||
WIDGET::repaint();
|
||||
return true;
|
||||
}
|
||||
|
||||
//! \copydoc BlackGui::COverlayMessages::showDownloadProgress
|
||||
|
||||
Reference in New Issue
Block a user