refs #471, removed old info window and migrated to overlay widget

* added small message display (more suitable for swift GUI)
* fixed nullptr bug with ESC key
* adjusted swift GUI
This commit is contained in:
Klaus Basan
2015-11-02 19:31:32 +01:00
committed by Mathew Sutcliffe
parent 012543ef02
commit 8e57914e67
15 changed files with 365 additions and 494 deletions

View File

@@ -1,143 +0,0 @@
/* Copyright (C) 2013
* swift project Community / Contributors
*
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
* including this file, may be copied, modified, propagated, or distributed except according to the terms
* contained in the LICENSE file.
*/
#include "infowindowcomponent.h"
#include "ui_infowindowcomponent.h"
#include "../stylesheetutility.h"
#include "blackmisc/icon.h"
#include <QTimer>
#include <QDesktopWidget>
using namespace BlackMisc;
using namespace BlackMisc::Network;
namespace BlackGui
{
namespace Components
{
CInfoWindowComponent::CInfoWindowComponent(QWidget *parent) :
QWizardPage(parent),
ui(new Ui::InfoWindow)
{
ui->setupUi(this);
this->hide();
this->m_hideTimer = new QTimer(this);
this->m_hideTimer->setSingleShot(true);
this->ps_onStyleSheetsChanged();
connect(this->m_hideTimer, &QTimer::timeout, this, &CInfoWindowComponent::hide);
connect(this->ui->pb_Close, &QPushButton::pressed, this, &CInfoWindowComponent::hide);
connect(&CStyleSheetUtility::instance(), &CStyleSheetUtility::styleSheetsChanged, this, &CInfoWindowComponent::ps_onStyleSheetsChanged);
}
CInfoWindowComponent::~CInfoWindowComponent() { }
void CInfoWindowComponent::displayStringMessage(const QString &message, int displayTimeMs)
{
if (message.isEmpty())
{
this->hide();
return;
}
// message and display
this->ui->te_StringMessage->setText(message);
this->setCurrentPage(this->ui->pg_StringMessage);
this->showWindow(displayTimeMs);
}
void CInfoWindowComponent::displayTextMessage(const CTextMessage &textMessage, int displayTimeMs)
{
if (textMessage.isEmpty())
{
this->hide();
return;
}
// message and display
this->ui->le_TmFrom->setText(textMessage.getSenderCallsign().asString());
this->ui->le_TmTo->setText(textMessage.getRecipientCallsign().asString());
this->ui->le_TmReceived->setText(textMessage.getFormattedUtcTimestampHms());
this->ui->te_TmText->setText(textMessage.getMessage());
this->setCurrentPage(this->ui->pg_TextMessage);
this->showWindow(displayTimeMs);
}
void CInfoWindowComponent::displayStatusMessage(const CStatusMessage &statusMessage, int displayTimeMs)
{
if (statusMessage.isEmpty())
{
this->hide();
return;
}
this->ui->le_SmSeverity->setText(statusMessage.getSeverityAsString());
this->ui->le_SmCategories->setText(statusMessage.getCategories().toQString());
this->ui->te_SmStatusMessage->setText(statusMessage.getMessage());
this->ui->lbl_SmSeverityIcon->setPixmap(statusMessage.toPixmap());
this->setCurrentPage(this->ui->pg_StatusMessage);
this->showWindow(displayTimeMs);
}
void CInfoWindowComponent::display(const BlackMisc::CVariant &variant, int displayTimeMs)
{
if (variant.isNull())
{
this->hide();
return;
}
if (variant.canConvert<CTextMessage>())
{
this->displayTextMessage(variant.value<CTextMessage>(), displayTimeMs);
}
else if (variant.canConvert<CStatusMessage>())
{
this->displayStatusMessage(variant.value<CStatusMessage>(), displayTimeMs);
}
else
{
this->displayStringMessage(variant.toQString(), displayTimeMs);
}
}
void CInfoWindowComponent::initWindow()
{
// center
const QRect parent = this->parentWidget()->geometry();
const QRect myself = this->rect();
int dx = (parent.width() - myself.width()) / 2;
int dy = (parent.height() - myself.height()) / 2;
dy -= 80; // some offset, in order to display further on top
this->move(dx, dy);
this->show();
}
void CInfoWindowComponent::showWindow(int displayTimeMs)
{
this->initWindow();
// hide after some time
this->m_hideTimer->start(displayTimeMs);
}
void CInfoWindowComponent::setCurrentPage(QWidget *widget)
{
this->ui->sw_DifferentModes->setCurrentWidget(widget);
}
void CInfoWindowComponent::ps_onStyleSheetsChanged()
{
QString st = CStyleSheetUtility::instance().style(CStyleSheetUtility::fileNameInfoWindow());
this->setStyleSheet(st);
}
}
} // namespace

View File

@@ -1,77 +0,0 @@
/* Copyright (C) 2013
* swift project Community / Contributors
*
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
* including this file, may be copied, modified, propagated, or distributed except according to the terms
* contained in the LICENSE file.
*/
//! \file
#ifndef BLACKGUI_INFOWINDOW_H
#define BLACKGUI_INFOWINDOW_H
#include "blackgui/blackguiexport.h"
#include "blackmisc/network/textmessage.h"
#include "blackmisc/statusmessage.h"
#include "blackmisc/variant.h"
#include <QWizardPage>
#include <QScopedPointer>
namespace Ui { class InfoWindow; }
namespace BlackGui
{
namespace Components
{
/*!
* Multi purpose info window (like pop up window)
*/
class BLACKGUI_EXPORT CInfoWindowComponent : public QWizardPage
{
Q_OBJECT
public:
const static int DefaultDisplayTimeMs = 4000; //!< Display n milliseconds
//! Constructor
explicit CInfoWindowComponent(QWidget *parent = nullptr);
//! Destructor
~CInfoWindowComponent();
public slots:
//! Info message, pure string
void displayStringMessage(const QString &message, int displayTimeMs = DefaultDisplayTimeMs);
//! Info message, based on text message
void displayTextMessage(const BlackMisc::Network::CTextMessage &textMessage, int displayTimeMs = DefaultDisplayTimeMs);
//! Info message, based on status message
void displayStatusMessage(const BlackMisc::CStatusMessage &statusMessage, int displayTimeMs = DefaultDisplayTimeMs);
//! Display any of the specialized types
void display(const BlackMisc::CVariant &variant, int displayTimeMs = DefaultDisplayTimeMs);
private:
QScopedPointer<Ui::InfoWindow> ui; //!< user interface
QTimer *m_hideTimer = nullptr;
//! Init the window
void initWindow();
//! Show window, hide after some time
void showWindow(int displayTimeMs);
//! Current page
void setCurrentPage(QWidget *widget);
private slots:
//! Style sheet changed
void ps_onStyleSheetsChanged();
};
} // namespace
} // namespace
#endif // guard

View File

@@ -1,220 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>InfoWindow</class>
<widget class="QWizardPage" name="InfoWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>300</width>
<height>185</height>
</rect>
</property>
<property name="windowTitle">
<string>WizardPage</string>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="title">
<string>Information</string>
</property>
<layout class="QVBoxLayout" name="vl_InfoWindow">
<property name="spacing">
<number>2</number>
</property>
<property name="leftMargin">
<number>2</number>
</property>
<property name="topMargin">
<number>2</number>
</property>
<property name="rightMargin">
<number>2</number>
</property>
<property name="bottomMargin">
<number>2</number>
</property>
<item>
<widget class="QFrame" name="fr_InfoWindow">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QVBoxLayout" name="vl_layoutInfoFrame">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item alignment="Qt::AlignRight">
<widget class="QPushButton" name="pb_Close">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../../blackmisc/blackmisc.qrc">
<normaloff>:/diagona/icons/diagona/icons/cross-button.png</normaloff>:/diagona/icons/diagona/icons/cross-button.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QStackedWidget" name="sw_DifferentModes">
<property name="currentIndex">
<number>2</number>
</property>
<widget class="QWidget" name="pg_StringMessage">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QTextEdit" name="te_StringMessage">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="pg_TextMessage">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QGridLayout" name="gl_TextMessage">
<item row="0" column="2">
<widget class="QLabel" name="lbl_TmTo">
<property name="text">
<string>To</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Received</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="le_TmReceived"/>
</item>
<item row="0" column="0">
<widget class="QLabel" name="lbl_TmFrom">
<property name="text">
<string>From</string>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QLineEdit" name="le_TmTo">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="le_TmFrom">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="1" colspan="3">
<widget class="QTextEdit" name="te_TmText"/>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QWidget" name="pg_StatusMessage">
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QGridLayout" name="gl_StatusMessage">
<item row="2" column="0">
<widget class="QLabel" name="lbl_SmCategories">
<property name="toolTip">
<string>Categories</string>
</property>
<property name="text">
<string>Cat.</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="le_SmSeverity">
<property name="text">
<string>severity</string>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="le_SmCategories">
<property name="text">
<string>type</string>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="3" column="0" colspan="3">
<widget class="QTextEdit" name="te_SmStatusMessage">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="lbl_SmSeverity">
<property name="text">
<string>Severity</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QLabel" name="lbl_SmSeverityIcon">
<property name="text">
<string>icon</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources>
<include location="../../blackmisc/blackmisc.qrc"/>
</resources>
<connections/>
</ui>

View File

@@ -23,6 +23,7 @@ namespace BlackGui
ui(new Ui::COverlayMessages)
{
this->init(w, h);
connect(&CStyleSheetUtility::instance(), &CStyleSheetUtility::styleSheetsChanged, this, &COverlayMessages::ps_onStyleSheetsChanged);
}
COverlayMessages::COverlayMessages(const QString &headerText, int w, int h, QWidget *parent) :
@@ -56,6 +57,16 @@ namespace BlackGui
}
}
void COverlayMessages::ps_onStyleSheetsChanged()
{
// stlye sheet
}
bool COverlayMessages::useSmall() const
{
return (this->width() < 400);
}
COverlayMessages::~COverlayMessages()
{}
@@ -70,8 +81,16 @@ namespace BlackGui
void COverlayMessages::showMessage(const BlackMisc::CStatusMessage &message, int timeOutMs)
{
if (message.isEmpty()) { return; }
this->setModeToMessage();
this->ui->form_StatusMessage->setValue(message);
if (this->useSmall())
{
this->setModeToMessageSmall();
this->ui->form_StatusMessageSmall->setValue(message);
}
else
{
this->setModeToMessage();
this->ui->form_StatusMessage->setValue(message);
}
this->display(timeOutMs);
}
@@ -118,6 +137,12 @@ namespace BlackGui
this->setHeader("Message");
}
void COverlayMessages::setModeToMessageSmall()
{
this->ui->sw_StatusMessagesComponent->setCurrentWidget(this->ui->pg_StatusMessageSmall);
this->setHeader("Message");
}
void COverlayMessages::setModeToTextMessage()
{
this->ui->sw_StatusMessagesComponent->setCurrentWidget(this->ui->pg_TextMessage);
@@ -126,11 +151,15 @@ namespace BlackGui
void COverlayMessages::keyPressEvent(QKeyEvent *event)
{
if (event->key() == Qt::Key_Escape)
if (this->isVisible() && event->key() == Qt::Key_Escape)
{
this->close();
event->setAccepted(true);
}
else
{
QFrame::keyPressEvent(event);
}
}
void COverlayMessages::close()

View File

@@ -12,6 +12,7 @@
#ifndef BLACKGUI_OVERLAYMESSAGES_H
#define BLACKGUI_OVERLAYMESSAGES_H
#include "blackgui/blackguiexport.h"
#include "blackmisc/network/textmessage.h"
#include "blackmisc/statusmessagelist.h"
#include "blackmisc/variant.h"
@@ -26,7 +27,7 @@ namespace BlackGui
/*!
* Display status messages (nested in another widget)
*/
class COverlayMessages : public QFrame
class BLACKGUI_EXPORT COverlayMessages : public QFrame
{
Q_OBJECT
@@ -40,6 +41,22 @@ namespace BlackGui
//! Destructor
~COverlayMessages();
//! Messages mode
void setModeToMessages();
//! Single Message mode
void setModeToMessage();
//! Single Message mode
void setModeToMessageSmall();
//! Single Text message mode
void setModeToTextMessage();
//! Set header text
void setHeaderText(const QString &header);
public slots:
//! Show multiple messages
void showMessages(const BlackMisc::CStatusMessageList &messages, int timeOutMs = -1);
@@ -52,19 +69,6 @@ namespace BlackGui
//! Display one of the supported types
void showVariant(const BlackMisc::CVariant &variant, int timeOutMs = -1);
//! Messages mode
void setModeToMessages();
//! Single Message mode
void setModeToMessage();
//! Single Text message mode
void setModeToTextMessage();
//! Set header text
void setHeaderText(const QString &header);
public slots:
//! Close button clicked
void close();
@@ -78,6 +82,13 @@ namespace BlackGui
//! \copydoc QFrame::paintEvent
virtual void paintEvent(QPaintEvent *event) override;
private slots:
//! Stylesheet changed
void ps_onStyleSheetsChanged();
//! Small
bool useSmall() const;
private:
QScopedPointer<Ui::COverlayMessages> ui;
QString m_header;

View File

@@ -113,6 +113,9 @@
</item>
<item>
<widget class="QStackedWidget" name="sw_StatusMessagesComponent">
<property name="currentIndex">
<number>2</number>
</property>
<widget class="QWidget" name="pg_StatusMessages">
<layout class="QVBoxLayout" name="vl_PgStatusMessages">
<property name="spacing">
@@ -174,6 +177,35 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="pg_StatusMessageSmall">
<layout class="QVBoxLayout" name="vl_StatusMessageSmall">
<property name="spacing">
<number>4</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="BlackGui::CStatusMessageFormSmall" name="form_StatusMessageSmall">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="pg_TextMessage">
<layout class="QVBoxLayout" name="vl_TextMessage">
<property name="spacing">
@@ -257,6 +289,12 @@
<header>blackgui/statusmessageform.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>BlackGui::CStatusMessageFormSmall</class>
<extends>QFrame</extends>
<header>blackgui/statusmessageformsmall.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources>
<include location="../blackmisc/blackmisc.qrc"/>

View File

@@ -28,22 +28,37 @@ namespace BlackGui
void COverlayMessagesFrame::hideStatusMessagesFrame()
{
if (!m_statusMessages) { return; }
if (!m_overlayMessages) { return; }
}
void COverlayMessagesFrame::showMessages(const BlackMisc::CStatusMessageList &messages)
{
if (messages.isEmpty()) { return; }
this->initInnerFrame();
this->m_statusMessages->showMessages(messages);
this->repaint();
}
void COverlayMessagesFrame::showMessage(const BlackMisc::CStatusMessage &message)
void COverlayMessagesFrame::showMessage(const BlackMisc::CStatusMessage &message, int timeOutMs)
{
if (message.isEmpty()) { return; }
this->initInnerFrame();
this->m_statusMessages->showMessage(message);
this->m_overlayMessages->showMessage(message, timeOutMs);
this->repaint();
}
void COverlayMessagesFrame::showMessages(const BlackMisc::CStatusMessageList &messages, int timeOutMs)
{
if (messages.isEmpty()) { return; }
this->initInnerFrame();
this->m_overlayMessages->showMessages(messages, timeOutMs);
this->repaint();
}
void COverlayMessagesFrame::showTextMessage(const BlackMisc::Network::CTextMessage &textMessage, int timeOutMs)
{
if (textMessage.isEmpty()) { return; }
this->initInnerFrame();
this->m_overlayMessages->showTextMessage(textMessage, timeOutMs);
this->repaint();
}
void COverlayMessagesFrame::showVariant(const BlackMisc::CVariant &variant, int timeOutMs)
{
this->initInnerFrame();
this->m_overlayMessages->showVariant(variant, timeOutMs);
this->repaint();
}
@@ -56,10 +71,9 @@ namespace BlackGui
void COverlayMessagesFrame::keyPressEvent(QKeyEvent *event)
{
if (!m_statusMessages) { QFrame::keyPressEvent(event); }
if (event->key() == Qt::Key_Escape)
if (m_overlayMessages && event->key() == Qt::Key_Escape)
{
m_statusMessages->close();
m_overlayMessages->close();
event->setAccepted(true);
}
else
@@ -80,9 +94,9 @@ namespace BlackGui
void COverlayMessagesFrame::initInnerFrame()
{
QSize inner(innerFrameSize());
if (!this->m_statusMessages)
if (!this->m_overlayMessages)
{
this->m_statusMessages = new COverlayMessages(inner.width(), inner.height(), this);
this->m_overlayMessages = new COverlayMessages(inner.width(), inner.height(), this);
}
QPoint middle = this->geometry().center();
@@ -90,6 +104,6 @@ namespace BlackGui
int h = inner.height();
int x = middle.x() - w / 2;
int y = middle.y() - h / 2;
this->m_statusMessages->setGeometry(x, y, w, h);
this->m_overlayMessages->setGeometry(x, y, w, h);
}
} // ns

View File

@@ -12,6 +12,7 @@
#ifndef BLACKGUI_OVERLAYMESSAGES_FRAME_H
#define BLACKGUI_OVERLAYMESSAGES_FRAME_H
#include "blackgui/blackguiexport.h"
#include "blackgui/overlaymessages.h"
#include <QFrame>
@@ -20,7 +21,7 @@ namespace BlackGui
/*!
* Display status messages (nested in another widget)
*/
class COverlayMessagesFrame : public QFrame
class BLACKGUI_EXPORT COverlayMessagesFrame : public QFrame
{
Q_OBJECT
@@ -37,11 +38,18 @@ namespace BlackGui
//! Hide the inner frame
void hideStatusMessagesFrame();
//! Show multiple messages
void showMessages(const BlackMisc::CStatusMessageList &messages);
public slots:
//! \copydoc COverlayMessages::showMessages
void showMessages(const BlackMisc::CStatusMessageList &messages, int timeOutMs = -1);
//! Show single message
void showMessage(const BlackMisc::CStatusMessage &message);
//! \copydoc COverlayMessages::showMessage
void showMessage(const BlackMisc::CStatusMessage &message, int timeOutMs = -1);
//! \copydoc COverlayMessages::showTextMessage
void showTextMessage(const BlackMisc::Network::CTextMessage &textMessage, int timeOutMs = -1);
//! \copydoc COverlayMessages::showVariant
void showVariant(const BlackMisc::CVariant &variant, int timeOutMs = -1);
protected:
//! \copydoc QFrame::paintEvent
@@ -50,7 +58,7 @@ namespace BlackGui
//! \copydoc QFrame::keyPressEvent
virtual void keyPressEvent(QKeyEvent *event) override;
COverlayMessages *m_statusMessages = nullptr; //!< embedded QFrame with Status messages
COverlayMessages *m_overlayMessages = nullptr; //!< embedded QFrame with Status messages
private:
//! Calculate inner frame size
@@ -59,7 +67,6 @@ namespace BlackGui
//! Init the inner frame (if not yet initialized)
void initInnerFrame();
};
} // ns
#endif // guard

View File

@@ -0,0 +1,48 @@
/* Copyright (C) 2015
* swift project Community / Contributors
*
* This file is part of swift Project. It is subject to the license terms in the LICENSE file found in the top-level
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
* including this file, may be copied, modified, propagated, or distributed except according to the terms
* contained in the LICENSE file.
*/
#include "statusmessageformsmall.h"
#include "ui_statusmessageformsmall.h"
#include <QLabel>
using namespace BlackMisc;
namespace BlackGui
{
CStatusMessageFormSmall::CStatusMessageFormSmall(QWidget *parent) :
QFrame(parent),
ui(new Ui::CStatusMessageFormSmall)
{
ui->setupUi(this);
}
CStatusMessageFormSmall::~CStatusMessageFormSmall()
{ }
void CStatusMessageFormSmall::setVariant(const CVariant &messageVariant)
{
if (!this->isVisible()) { return; }
this->setValue(messageVariant.value<CStatusMessage>());
}
void CStatusMessageFormSmall::setValue(const CStatusMessage &message)
{
ui->te_Message->setPlainText(message.getMessage());
ui->lbl_SeverityIcon->setPixmap(message.toPixmap());
ui->le_Categories->setText(message.getCategories().toQString(true));
ui->le_Severity->setText(message.getSeverityAsString());
ui->le_Timestamp->setText(message.getFormattedUtcTimestampYmdhms());
}
void CStatusMessageFormSmall::toggleVisibility()
{
this->setVisible(!isVisible());
}
} // ns

View File

@@ -0,0 +1,52 @@
/* Copyright (C) 2015
* swift project Community / Contributors
*
* This file is part of swift Project. It is subject to the license terms in the LICENSE file found in the top-level
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
* including this file, may be copied, modified, propagated, or distributed except according to the terms
* contained in the LICENSE file.
*/
//! \file
#ifndef BLACKGUI_STATUSMESSAGEFORMSMALL_H
#define BLACKGUI_STATUSMESSAGEFORMSMALL_H
#include "blackgui/blackguiexport.h"
#include "blackmisc/statusmessage.h"
#include <QFrame>
namespace Ui { class CStatusMessageFormSmall; }
namespace BlackGui
{
/*!
* Display details about a single status message
*/
class BLACKGUI_EXPORT CStatusMessageFormSmall : public QFrame
{
Q_OBJECT
public:
//! Constructor
explicit CStatusMessageFormSmall(QWidget *parent = nullptr);
//! Destructor
~CStatusMessageFormSmall();
public slots:
//! Set message
void setVariant(const BlackMisc::CVariant &messageVariant);
//! Set message
void setValue(const BlackMisc::CStatusMessage &message);
//! Toggle visibility
void toggleVisibility();
private:
QScopedPointer<Ui::CStatusMessageFormSmall> ui;
};
} // ns
#endif // guard

View File

@@ -0,0 +1,115 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CStatusMessageFormSmall</class>
<widget class="QFrame" name="CStatusMessageFormSmall">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>266</width>
<height>274</height>
</rect>
</property>
<property name="windowTitle">
<string>Frame</string>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="leftMargin">
<number>4</number>
</property>
<property name="topMargin">
<number>4</number>
</property>
<property name="rightMargin">
<number>4</number>
</property>
<property name="bottomMargin">
<number>4</number>
</property>
<property name="spacing">
<number>4</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="lbl_Severity">
<property name="text">
<string>Severity:</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLineEdit" name="le_Severity">
<property name="maximumSize">
<size>
<width>200</width>
<height>16777215</height>
</size>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="4" column="0" colspan="3">
<widget class="QPlainTextEdit" name="te_Message">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="QLineEdit" name="le_Categories">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QLineEdit" name="le_Timestamp">
<property name="maximumSize">
<size>
<width>200</width>
<height>16777215</height>
</size>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="lbl_SeverityIcon">
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="../blackmisc/blackmisc.qrc">:/diagona/icons/diagona/icons/question.png</pixmap>
</property>
</widget>
</item>
<item row="2" column="0" colspan="2">
<widget class="QLabel" name="lbl_Timestamp">
<property name="text">
<string>Timestamp:</string>
</property>
</widget>
</item>
<item row="3" column="0" colspan="2">
<widget class="QLabel" name="lbl_Categories">
<property name="text">
<string>Categories:</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources>
<include location="../blackmisc/blackmisc.qrc"/>
</resources>
<connections/>
</ui>

View File

@@ -48,7 +48,6 @@ SwiftGuiStd::SwiftGuiStd(BlackGui::CEnableForFramelessWindow::WindowMode windowM
// GUI
ui->setupUi(this);
this->setDynamicProperties(windowMode == CEnableForFramelessWindow::WindowFrameless);
this->m_compInfoWindow = new CInfoWindowComponent(this); // setupUi has to be first!
}
SwiftGuiStd::~SwiftGuiStd()
@@ -97,13 +96,6 @@ void SwiftGuiStd::performGracefulShutdown()
this->ui->comp_MainInfoArea->dockAllWidgets();
this->ui->comp_InvisibleInfoArea->dockAllWidgets();
// close info window
if (this->m_compInfoWindow)
{
this->m_compInfoWindow->close();
this->m_compInfoWindow = nullptr;
}
// allow some other parts to react
QApplication::processEvents(QEventLoop::AllEvents, 100);
@@ -256,7 +248,7 @@ void SwiftGuiStd::ps_displayStatusMessageInGui(const CStatusMessage &statusMessa
// display overlay for errors, but not for validation
if (statusMessage.getSeverity() == CStatusMessage::SeverityError && ! statusMessage.getCategories().contains(CLogCategory::validation()))
{
this->m_compInfoWindow->displayStatusMessage(statusMessage);
this->ui->fr_CentralFrameInside->showMessage(statusMessage);
}
}

View File

@@ -21,7 +21,6 @@
#include "blackcore/actionbind.h"
#include "blackcore/data/globalsetup.h"
#include "blackgui/components/enableforruntime.h"
#include "blackgui/components/infowindowcomponent.h"
#include "blackgui/components/maininfoareacomponent.h"
#include "blackgui/transpondermodeselector.h"
#include "blackgui/models/atcstationlistmodel.h"
@@ -30,6 +29,7 @@
#include "blackgui/models/statusmessagelistmodel.h"
#include "blackgui/enableforframelesswindow.h"
#include "blackgui/managedstatusbar.h"
#include "blackgui/overlaymessagesframe.h"
#include "blackmisc/network/textmessage.h"
#include "blackmisc/loghandler.h"
#include "blackmisc/identifiable.h"
@@ -111,7 +111,6 @@ protected:
private:
QScopedPointer<Ui::SwiftGuiStd> ui;
bool m_init = false;
BlackGui::Components::CInfoWindowComponent *m_compInfoWindow = nullptr; //!< the info window (popup
BlackGui::CManagedStatusBar m_statusBar;
BlackMisc::CLogSubscriber m_logSubscriber { this, &SwiftGuiStd::ps_displayStatusMessageInGui };
BlackCore::CData<BlackCore::Data::GlobalSetup> m_setup {this}; //!< setup cache

View File

@@ -76,7 +76,7 @@
<number>2</number>
</property>
<item>
<widget class="QFrame" name="fr_CentralFrameInside">
<widget class="BlackGui::COverlayMessagesFrame" name="fr_CentralFrameInside">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
@@ -573,6 +573,12 @@
<header>blackgui/components/invisibleinfoareacomponent.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>BlackGui::COverlayMessagesFrame</class>
<extends>QFrame</extends>
<header>blackgui/overlaymessagesframe.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>

View File

@@ -186,7 +186,7 @@ void SwiftGuiStd::initGuiSignals()
connect(this->ui->menu_InternalsDisplayCachedFiles, &QAction::triggered, this, &SwiftGuiStd::ps_onMenuClicked);
// command line / text messages
connect(this->ui->comp_MainInfoArea->getTextMessageComponent(), &CTextMessageComponent::displayInInfoWindow, this->m_compInfoWindow, &CInfoWindowComponent::display);
connect(this->ui->comp_MainInfoArea->getTextMessageComponent(), &CTextMessageComponent::displayInInfoWindow, this->ui->fr_CentralFrameInside, &COverlayMessagesFrame::showVariant);
// settings (GUI component), styles
connect(this->ui->comp_MainInfoArea->getSettingsComponent(), &CSettingsComponent::changedWindowsOpacity, this, &SwiftGuiStd::ps_onChangedWindowOpacity);