refs #275, own info window component

* added to CVariant for value object
* signal in text message to indicate overlay messages
* info window component (currently not runtme aware, maybe changed in future)
* removed old window, adjusted GUI
This commit is contained in:
Klaus Basan
2014-06-17 17:59:14 +02:00
parent ab77f19544
commit 0547b2847e
13 changed files with 435 additions and 239 deletions

View File

@@ -1,41 +0,0 @@
#include "infowindow.h"
#include "ui_infowindow.h"
#include <QTimer>
#include <QDesktopWidget>
/*
* Constructor
*/
CInfoWindow::CInfoWindow(QWidget *parent) :
QWizardPage(parent),
ui(new Ui::InfoWindow)
{
ui->setupUi(this);
}
/*
* Destructor
*/
CInfoWindow::~CInfoWindow() { }
/*
* Info message for some time
*/
void CInfoWindow::setInfoMessage(const QString &message, int displayTimeMs)
{
// 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);
// message and display
this->ui->te_Message->setText(message);
this->show();
// hide after some time
QTimer::singleShot(displayTimeMs, this, SLOT(hide()));
}

View File

@@ -1,44 +0,0 @@
/* Copyright (C) 2013 VATSIM Community / authors
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef SAMPLE_INFOWINDOW_H
#define SAMPLE_INFOWINDOW_H
#include <QWizardPage>
#include <QScopedPointer>
namespace Ui
{
class InfoWindow;
}
class CInfoWindow : public QWizardPage
{
Q_OBJECT
public:
/*!
* \brief Constructor
* \param parent
*/
explicit CInfoWindow(QWidget *parent = nullptr);
/*!
* \brief Destructor
*/
~CInfoWindow();
/*!
* \brief Set info message displayed for some time
* \param message
* \param displayTimeMs
*/
void setInfoMessage(const QString &message, int displayTimeMs = 4000);
private:
QScopedPointer<Ui::InfoWindow> ui;
};
#endif // guard

View File

@@ -1,96 +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>245</width>
<height>89</height>
</rect>
</property>
<property name="windowTitle">
<string>WizardPage</string>
</property>
<property name="styleSheet">
<string notr="true">QWidget {
font-family: arial-rounded;
font: bold 10px;
color: black; /** font **/
}
QPushButton {
background-color: transparent;
border-style: solid;
border-width: 0px;
border-radius:3px;
border-color: green;
max-height:20px;
}
QTextEdit {
background-color: rgba(255, 255, 0, 240); /* transparent yellow */
border-style: solid;
border-width:1px;
border-radius:6px;
border-color: green;
opacity: 0.5;
}
</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QTextEdit" name="te_Message">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item alignment="Qt::AlignTop">
<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="../../src/blackgui/blackgui.qrc">
<normaloff>:/blackgui/icons/close.png</normaloff>:/blackgui/icons/close.png</iconset>
</property>
</widget>
</item>
</layout>
</widget>
<resources>
<include location="../../src/blackgui/blackgui.qrc"/>
</resources>
<connections>
<connection>
<sender>pb_Close</sender>
<signal>clicked()</signal>
<receiver>InfoWindow</receiver>
<slot>hide()</slot>
<hints>
<hint type="sourcelabel">
<x>272</x>
<y>52</y>
</hint>
<hint type="destinationlabel">
<x>302</x>
<y>67</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@@ -24,7 +24,7 @@ using namespace BlackMisc::Audio;
MainWindow::MainWindow(GuiModes::WindowMode windowMode, QWidget *parent) :
QMainWindow(parent, windowMode == GuiModes::WindowFrameless ? (Qt::Window | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint) : (Qt::Tool | Qt::WindowStaysOnTopHint)),
ui(new Ui::MainWindow),
m_infoWindow(nullptr),
m_compInfoWindow(nullptr),
m_init(false), m_windowMode(windowMode), m_audioTestRunning(NoAudioTest),
// contexts and runtime
m_coreAvailable(false), m_contextNetworkAvailable(false), m_contextAudioAvailable(false),
@@ -48,7 +48,11 @@ MainWindow::MainWindow(GuiModes::WindowMode windowMode, QWidget *parent) :
this->setAttribute(Qt::WA_TranslucentBackground, true);
// this->setAttribute(Qt::WA_PaintOnScreen);
}
// GUI
ui->setupUi(this);
this->m_compInfoWindow = new CInfoWindowComponent(this); // setupUi has to be first!
}
/*
@@ -73,10 +77,10 @@ void MainWindow::gracefulShutdown()
this->getIContextApplication()->notifyAboutComponentChange(IContextApplication::ComponentGui, IContextApplication::ActionStops);
// close info window
if (this->m_infoWindow)
if (this->m_compInfoWindow)
{
this->m_infoWindow->close();
this->m_infoWindow = nullptr;
this->m_compInfoWindow->close();
this->m_compInfoWindow = nullptr;
}
// shut down all timers
@@ -266,7 +270,7 @@ void MainWindow::displayStatusMessage(const CStatusMessage &statusMessage)
// display overlay for errors, but not for validation
if (statusMessage.getSeverity() == CStatusMessage::SeverityError && statusMessage.getType() != CStatusMessage::TypeValidation)
this->displayOverlayInfo(statusMessage);
this->m_compInfoWindow->displayStatusMessage(statusMessage);
}
/*
@@ -426,36 +430,6 @@ void MainWindow::changeWindowOpacity(int opacity)
this->ui->hs_SettingsGuiOpacity->setValue(o * 100.0);
}
/*
* Display the info window
*/
void MainWindow::displayOverlayInfo(const QString &message)
{
if (!this->m_infoWindow)
{
this->m_infoWindow = new CInfoWindow(this);
}
// display window
if (message.isEmpty())
{
this->m_infoWindow->hide();
}
else
{
this->m_infoWindow->setInfoMessage(message);
}
}
/*
* Info window by
*/
void MainWindow::displayOverlayInfo(const CStatusMessage &message)
{
this->displayOverlayInfo(message.getMessage());
// further code goes here, such as marking errors as red ...
}
void MainWindow::updateSimulatorData()
{
if (this->getIContextSimulator()->isConnected())

View File

@@ -10,7 +10,6 @@
#pragma push_macro("interface")
#undef interface
#include "infowindow.h"
#include "guimodeenums.h"
#include "blackinput/keyboard.h"
#include "blackcore/context_audio.h"
@@ -27,6 +26,7 @@
#include "blackgui/userlistmodel.h"
#include "blackgui/statusmessagelistmodel.h"
#include "blackgui/keyboardkeylistmodel.h"
#include "blackgui/infowindowcomponent.h"
#include "blackmisc/nwtextmessage.h"
#include "blacksound/soundgenerator.h"
#include <QMainWindow>
@@ -93,7 +93,7 @@ protected:
private:
QScopedPointer<Ui::MainWindow> ui;
CInfoWindow *m_infoWindow;
BlackGui::CInfoWindowComponent *m_compInfoWindow;
bool m_init;
GuiModes::WindowMode m_windowMode;
AudioTest m_audioTestRunning;
@@ -314,14 +314,6 @@ private slots:
//! Toogle Windows stay on top
void toogleWindowStayOnTop();
//! Display the overlay window
//! Empty string hides window
void displayOverlayInfo(const QString &message = "");
//! Overlay info displaying status message
void displayOverlayInfo(const BlackMisc::CStatusMessage &message);
};
#pragma pop_macro("interface")

View File

@@ -214,8 +214,7 @@ void MainWindow::initGuiSignals()
// command line / text messages
connected = this->connect(this->ui->le_CommandLineInput, SIGNAL(returnPressed()), this->ui->comp_TextMessages, SLOT(commandEntered()));
Q_ASSERT(connected);
this->connect(this->ui->comp_TextMessages, SIGNAL(displayOverlayInfo(BlackMisc::CStatusMessage)), this, SLOT(displayOverlayInfo(BlackMisc::CStatusMessage)));
Q_ASSERT(connected);
this->connect(this->ui->comp_TextMessages, &CTextMessageComponent::displayInInfoWindow, this->m_compInfoWindow, &CInfoWindowComponent::display);
this->ui->comp_TextMessages->setSelcalCallback(std::bind(&CCockpitV1Component::getSelcalCode, this->ui->comp_Cockpit));
// voice

View File

@@ -140,7 +140,7 @@ void MainWindow::audioVolumes()
this->ui->lbl_StatusVoiceStatus->setPixmap(muted ? this->m_resPixmapVoiceMuted : this->m_resPixmapVoiceHigh);
this->ui->comp_Cockpit->setCockpitVoiceStatusPixmap(muted ? this->m_resPixmapVoiceMuted : this->m_resPixmapVoiceHigh);
this->ui->pb_SoundMute->setStyleSheet(muted ? "background-color: red;" : "");
if (muted) this->displayOverlayInfo("Sound is muted!");
if (muted) this->m_compInfoWindow->displayStringMessage("Sound is muted!");
// update own aircraft, also set volume/mute in voice
this->m_ownAircraft.setCom1System(com1);