Ref T506, make dock widget overlay message compliant

* overlay widget can used that functionality directly
* no need to use COverlayMessagesFrame
* added COverlayMessagesDockWidget
This commit is contained in:
Klaus Basan
2019-01-06 20:20:12 +01:00
committed by Mat Sutcliffe
parent d6f3932e5b
commit 8696f45a7c
10 changed files with 103 additions and 33 deletions

View File

@@ -7,24 +7,25 @@
* contained in the LICENSE file.
*/
#include "blackgui/components/atcstationcomponent.h"
#include "blackgui/views/atcstationview.h"
#include "blackgui/views/viewbase.h"
#include "blackgui/models/atcstationlistmodel.h"
#include "blackgui/models/atcstationtreemodel.h"
#include "blackgui/uppercasevalidator.h"
#include "blackgui/guiapplication.h"
#include "blackgui/guiutility.h"
#include "blackgui/dockwidgetinfoarea.h"
#include "blackgui/infoarea.h"
#include "blackcore/context/contextnetwork.h"
#include "blackcore/context/contextownaircraft.h"
#include "blackcore/webdataservices.h"
#include "blackgui/components/atcstationcomponent.h"
#include "blackgui/guiapplication.h"
#include "blackgui/guiutility.h"
#include "blackgui/infoarea.h"
#include "blackgui/uppercasevalidator.h"
#include "blackgui/models/atcstationlistmodel.h"
#include "blackgui/models/atcstationtreemodel.h"
#include "blackgui/views/atcstationview.h"
#include "blackgui/views/viewbase.h"
#include "blackmisc/aviation/atcstationlist.h"
#include "blackmisc/aviation/informationmessage.h"
#include "blackmisc/weather/metar.h"
#include "blackmisc/compare.h"
#include "blackmisc/icons.h"
#include "blackmisc/logmessage.h"
#include "blackmisc/weather/metar.h"
#include "ui_atcstationcomponent.h"
#include <QAbstractItemModel>
@@ -57,7 +58,7 @@ namespace BlackGui
namespace Components
{
CAtcStationComponent::CAtcStationComponent(QWidget *parent) :
COverlayMessagesFrame(parent),
QFrame(parent),
CIdentifiable(this),
ui(new Ui::CAtcStationComponent)
{
@@ -124,10 +125,13 @@ namespace BlackGui
connect(ui->gb_Details, &QGroupBox::toggled, this, &CAtcStationComponent::onDetailsToggled);
// runtime based connects
if (sGui)
{
connect(sGui->getIContextNetwork(), &IContextNetwork::changedAtcStationsOnlineDigest, this, &CAtcStationComponent::changedAtcStationsOnline, Qt::QueuedConnection);
connect(sGui->getIContextNetwork(), &IContextNetwork::changedAtcStationsBookedDigest, this, &CAtcStationComponent::changedAtcStationsBooked, Qt::QueuedConnection);
connect(sGui->getIContextNetwork(), &IContextNetwork::changedAtcStationOnlineConnectionStatus, this, &CAtcStationComponent::changedAtcStationOnlineConnectionStatus, Qt::QueuedConnection);
connect(sGui->getIContextNetwork(), &IContextNetwork::connectionStatusChanged, this, &CAtcStationComponent::connectionStatusChanged, Qt::QueuedConnection);
}
// selection
ui->tvp_AtcStationsOnline->acceptClickSelection(true);
@@ -138,7 +142,7 @@ namespace BlackGui
m_stretch.push_back(layout->stretch(1));
// web readers
if (sGui->hasWebDataServices())
if (sGui && sGui->hasWebDataServices())
{
connect(sGui->getWebDataServices(), &CWebDataServices::swiftDbAirportsRead, this, &CAtcStationComponent::airportsRead);
this->airportsRead();
@@ -465,7 +469,7 @@ namespace BlackGui
void CAtcStationComponent::showOverlayInlineTextMessage()
{
COverlayMessagesFrame::showOverlayInlineTextMessage(TextMessagesCom1);
CEnableForDockWidgetInfoArea::showOverlayInlineTextMessage(TextMessagesCom1);
}
void CAtcStationComponent::onDetailsToggled(bool checked)

View File

@@ -15,7 +15,6 @@
#include "blackgui/components/enablefordockwidgetinfoarea.h"
#include "blackgui/settings/viewupdatesettings.h"
#include "blackgui/settings/atcstationssettings.h"
#include "blackgui/overlaymessagesframe.h"
#include "blackgui/blackguiexport.h"
#include "blackcore/network.h"
#include "blackmisc/aviation/atcstation.h"
@@ -29,6 +28,7 @@
#include <QScopedPointer>
#include <QString>
#include <QTabWidget>
#include <QFrame>
#include <QtGlobal>
#include <QVBoxLayout>
#include <QTimer>
@@ -39,11 +39,12 @@ namespace BlackMisc { namespace Aviation { class CCallsign; } }
namespace BlackGui
{
class CDockWidgetInfoArea;
namespace Components
{
//! ATC stations component
class BLACKGUI_EXPORT CAtcStationComponent :
public COverlayMessagesFrame,
public QFrame,
public CEnableForDockWidgetInfoArea,
public BlackMisc::CIdentifiable
{

View File

@@ -122,11 +122,8 @@ namespace BlackGui
void CCockpitComponent::mouseDoubleClickEvent(QMouseEvent *event)
{
if (event)
{
this->showOverlayInlineTextMessage(TextMessagesAll);
}
COverlayMessagesFrame::mouseDoubleClickEvent(event);
if (event) { this->showOverlayInlineTextMessage(TextMessagesAll); }
QWidget::mouseDoubleClickEvent(event);
}
void CCockpitComponent::onRequestTextMessageCom1()

View File

@@ -13,9 +13,9 @@
#define BLACKGUI_COMPONENTS_COCKPITCOMPONENT_H
#include "blackgui/components/enablefordockwidgetinfoarea.h"
#include "blackgui/overlaymessagesframe.h"
#include "blackgui/blackguiexport.h"
#include <QFrame>
#include <QObject>
#include <QScopedPointer>
#include <QSize>

View File

@@ -17,7 +17,10 @@
#include <QMetaObject>
#include <QObject>
#include <QtGlobal>
#include <QTimer>
#include <QPointer>
using namespace BlackMisc::Aviation;
using namespace BlackGui;
namespace BlackGui
@@ -31,6 +34,36 @@ namespace BlackGui
m_parentDockableInfoArea = parentInfoArea;
}
void CEnableForDockWidgetInfoArea::deferredActivate(QObject *relatedObject, int delayMs)
{
if (!relatedObject) { return; }
QPointer<QObject> myself(relatedObject);
QTimer::singleShot(delayMs, relatedObject, [ = ]
{
if (myself) { this->activateTextMessages(true); }
});
}
void CEnableForDockWidgetInfoArea::initOverlayMessages(QSize inner)
{
if (m_parentDockableInfoArea) { m_parentDockableInfoArea->initOverlayMessages(inner); }
}
void CEnableForDockWidgetInfoArea::activateTextMessages(bool activate)
{
if (m_parentDockableInfoArea) { m_parentDockableInfoArea->activateTextMessages(activate); }
}
void CEnableForDockWidgetInfoArea::showOverlayInlineTextMessage(TextMessageTab tab)
{
if (m_parentDockableInfoArea) { m_parentDockableInfoArea->showOverlayInlineTextMessage(tab); }
}
void CEnableForDockWidgetInfoArea::showOverlayInlineTextMessage(const CCallsign &callsign)
{
if (m_parentDockableInfoArea) { m_parentDockableInfoArea->showOverlayInlineTextMessage(callsign); }
}
bool CEnableForDockWidgetInfoArea::setParentDockWidgetInfoArea(CDockWidgetInfoArea *parentDockableWidget)
{
// sanity check

View File

@@ -12,7 +12,9 @@
#ifndef BLACKGUI_ENABLEFORDOCKWIDGETINFOAREA_H
#define BLACKGUI_ENABLEFORDOCKWIDGETINFOAREA_H
#include "blackgui/components/textmessagecomponenttab.h"
#include "blackgui/blackguiexport.h"
#include "blackmisc/aviation/callsign.h"
#include "blackmisc/connectionguard.h"
class QWidget;
@@ -50,7 +52,7 @@ namespace BlackGui
bool isVisibleWidget() const;
//! Main application window if any
BlackGui::CEnableForFramelessWindow *mainApplicationWindow() const;
CEnableForFramelessWindow *mainApplicationWindow() const;
//! Main application window widget if any
QWidget *mainApplicationWindowWidget() const;
@@ -63,9 +65,24 @@ namespace BlackGui
//! \remarks Normally the info area will be provided later \sa setParentDockWidgetInfoArea
CEnableForDockWidgetInfoArea(CDockWidgetInfoArea *parentInfoArea = nullptr);
// Destructor
//! Destructor
virtual ~CEnableForDockWidgetInfoArea() {}
//! Deferred activation, as dockwidget is not directly initalized
void deferredActivate(QObject *relatedObject, int delayMs = 2500);
//! \copydoc BlackGui::COverlayMessages::initOverlayMessages
void initOverlayMessages(QSize inner = {});
//! \copydoc BlackGui::COverlayMessages::showKillButton
void activateTextMessages(bool activate);
//! \copydoc BlackGui::COverlayMessages::showOverlayImage
void showOverlayInlineTextMessage(Components::TextMessageTab tab);
//! \copydoc BlackGui::COverlayMessages::showOverlayImage
void showOverlayInlineTextMessage(const BlackMisc::Aviation::CCallsign &callsign);
private:
CDockWidgetInfoArea *m_parentDockableInfoArea = nullptr; //!< my parent dockable widget
BlackMisc::CConnectionGuard m_connections;

View File

@@ -43,7 +43,7 @@ using namespace BlackGui::Menus;
namespace BlackGui
{
CDockWidget::CDockWidget(bool allowStatusBar, QWidget *parent) :
QDockWidget(parent),
COverlayMessagesDockWidget(parent),
CEnableForFramelessWindow(CEnableForFramelessWindow::WindowTool, false, "framelessDockWidget", this),
m_allowStatusBar(allowStatusBar)
{
@@ -88,7 +88,7 @@ namespace BlackGui
void CDockWidget::setOriginalTitleBar()
{
if (!m_titleBarWidgetOriginal) { this->initTitleBarWidgets(); }
if (this->titleBarWidget() == m_titleBarWidgetOriginal) return; // on purpose, as I do not know what happens when I call setTitleBar
if (this->titleBarWidget() == m_titleBarWidgetOriginal) { return; } // on purpose, as I do not know what happens when I call setTitleBar
this->setTitleBarWidget(m_titleBarWidgetOriginal);
}

View File

@@ -12,12 +12,13 @@
#ifndef BLACKGUI_DOCKWIDGET_H
#define BLACKGUI_DOCKWIDGET_H
#include "blackgui/blackguiexport.h"
#include "blackgui/overlaymessagesframe.h"
#include "blackgui/enableforframelesswindow.h"
#include "blackgui/managedstatusbar.h"
#include "blackgui/settings/dockwidgetsettings.h"
#include "blackmisc/statusmessage.h"
#include "blackgui/blackguiexport.h"
#include "blackmisc/statusmessagelist.h"
#include "blackmisc/statusmessage.h"
#include <QDockWidget>
#include <QMargins>
@@ -47,7 +48,7 @@ namespace BlackGui
//! \sa CDockWidgetInfoArea
//! \sa CDockWidgetInfoBar
class BLACKGUI_EXPORT CDockWidget :
public QDockWidget,
public COverlayMessagesDockWidget,
public CEnableForFramelessWindow
{
Q_OBJECT

View File

@@ -34,6 +34,10 @@ namespace BlackGui
COverlayMessagesWizardPage::COverlayMessagesWizardPage(QWidget *parent) : COverlayMessagesBase(parent)
{ }
COverlayMessagesDockWidget::COverlayMessagesDockWidget(QWidget *parent) : COverlayMessagesBase(parent)
{ }
} // ns

View File

@@ -24,6 +24,7 @@
#include <QFrame>
#include <QTabWidget>
#include <QWizardPage>
#include <QDockWidget>
#include <QMessageBox>
#include <QObject>
#include <QSize>
@@ -362,6 +363,18 @@ namespace BlackGui
explicit COverlayMessagesWizardPage(QWidget *parent = nullptr);
};
/*!
* Using this class provides a QDockWidget with the overlay functionality already integrated.
*/
class BLACKGUI_EXPORT COverlayMessagesDockWidget : public COverlayMessagesBase<QDockWidget>
{
Q_OBJECT
public:
//! Constructor
explicit COverlayMessagesDockWidget(QWidget *parent = nullptr);
};
} // ns
#endif // guard