Files
pilotclient/samples/blackgui/infowindow.cpp
Klaus Basan ab2796862e Infowindow, a popup window window showing important messages.
Example: user receives private chat message, while text message
window is hidden.
2014-01-13 01:32:55 +01:00

44 lines
913 B
C++

#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()));
}