mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 23:05:36 +08:00
Infowindow, a popup window window showing important messages.
Example: user receives private chat message, while text message window is hidden.
This commit is contained in:
43
samples/blackgui/infowindow.cpp
Normal file
43
samples/blackgui/infowindow.cpp
Normal file
@@ -0,0 +1,43 @@
|
||||
#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()
|
||||
{
|
||||
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()));
|
||||
}
|
||||
43
samples/blackgui/infowindow.h
Normal file
43
samples/blackgui/infowindow.h
Normal file
@@ -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 <QWizardPage>
|
||||
|
||||
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
|
||||
96
samples/blackgui/infowindow.ui
Normal file
96
samples/blackgui/infowindow.ui
Normal file
@@ -0,0 +1,96 @@
|
||||
<?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>
|
||||
Reference in New Issue
Block a user