mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-12 23:35:33 +08:00
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:
committed by
Mathew Sutcliffe
parent
012543ef02
commit
8e57914e67
@@ -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
|
||||
@@ -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
|
||||
@@ -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>
|
||||
Reference in New Issue
Block a user