From ab2796862e79ed1dc6d183bebd4382bb0bc1f9ec Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Mon, 13 Jan 2014 01:32:55 +0100 Subject: [PATCH] Infowindow, a popup window window showing important messages. Example: user receives private chat message, while text message window is hidden. --- samples/blackgui/infowindow.cpp | 43 +++++++++++++++ samples/blackgui/infowindow.h | 43 +++++++++++++++ samples/blackgui/infowindow.ui | 96 +++++++++++++++++++++++++++++++++ 3 files changed, 182 insertions(+) create mode 100644 samples/blackgui/infowindow.cpp create mode 100644 samples/blackgui/infowindow.h create mode 100644 samples/blackgui/infowindow.ui diff --git a/samples/blackgui/infowindow.cpp b/samples/blackgui/infowindow.cpp new file mode 100644 index 000000000..04b8788c7 --- /dev/null +++ b/samples/blackgui/infowindow.cpp @@ -0,0 +1,43 @@ +#include "infowindow.h" +#include "ui_infowindow.h" +#include +#include + +/* + * Constructor + */ +CInfoWindow::CInfoWindow(QWidget *parent) : + QWizardPage(parent), + ui(new Ui::InfoWindow) +{ + ui->setupUi(this); +} + +/* + * Destructor + */ +CInfoWindow::~CInfoWindow() +{ + delete ui; +} + +/* + * 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())); +} diff --git a/samples/blackgui/infowindow.h b/samples/blackgui/infowindow.h new file mode 100644 index 000000000..5305e2ee0 --- /dev/null +++ b/samples/blackgui/infowindow.h @@ -0,0 +1,43 @@ +/* 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 + +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: + Ui::InfoWindow *ui; +}; + +#endif // guard diff --git a/samples/blackgui/infowindow.ui b/samples/blackgui/infowindow.ui new file mode 100644 index 000000000..9f53f638d --- /dev/null +++ b/samples/blackgui/infowindow.ui @@ -0,0 +1,96 @@ + + + InfoWindow + + + + 0 + 0 + 245 + 89 + + + + WizardPage + + + 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; +} + + + + + + + true + + + + + + + + 0 + 0 + + + + + 20 + 20 + + + + + + + + :/blackgui/icons/close.png:/blackgui/icons/close.png + + + + + + + + + + + pb_Close + clicked() + InfoWindow + hide() + + + 272 + 52 + + + 302 + 67 + + + + +