Fork me on GitHub
2.15.20
FGx
A cross-platform launcher for FlightGear
xmessagelabel.cpp
Go to the documentation of this file.
1 
2 #include <QtDebug>
3 
4 
5 #include "xmessagelabel.h"
7 
9  QLabel(parent)
10 {
11 
12  //= Fade Timer
13  fadeTimer = new QTimer(this);
14  connect(fadeTimer, SIGNAL(timeout()), this, SLOT(on_fade_timer()) );
15  fadeTimer->setInterval(60);
16 
17  //= Init Label
18  setText("Hello Message Label");
19 
20  //setStyleSheet("font-size: 20pt; background-color: #ffffff;");
21  //setStyleSheet(" font-family: freeuniversal; color: #333333; font-size: 16px; background-image: url(:/artwork/fgx-logo-flyer-yellow); background-repeat: none; padding-left: 40px; padding-top: 3px; padding-bottom: 5px; padding-right: 5px; margin-top: 10px; margin-bottom: 20px; ");
22 
23  //===========================================
24  //= Popup Message
25 
26  //= Popup Widget/Window
27  popWidget = new QWidget(this);
28  //#popWidget->hide();
29  popWidget->move(100,100);
30  //popWidget->setWindowFlags(Qt::FramelessWindowHint);
31  popWidget->setFixedWidth(400);
32  popWidget->setFixedHeight(40);
33  popWidget->show();
34 
35  //= Popup Layout
36  QVBoxLayout *popLay = new QVBoxLayout();
37  popWidget->setLayout(popLay);
38 
39  //= Popup Label with content and style
40  popLabel = new QLabel();
41  popLay->addWidget(popLabel);
42  popLabel->setText("yesssssssssssssssssssssssssssssss");
43  QString style_str("font-weight: italic; color: blue; padding: 10px; border: 1px outset yellow;");
44  style_str.append("background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0, stop: 0 #F8FAC3, stop: 1 #F0DD17);");
45  popLabel->setStyleSheet(style_str);
46 
47  popWidget->show();
48 
49 
50 }
51 
52 void XMessageLabel::showMessage(QString message){
53  showMessage(message, 3000);
54 }
55 
56 void XMessageLabel::showMessage(QString message, int timeout){
57  return;
58  //#if pos:
59  // offPos = QtCore.QPoint( pos.x() - self.width(), pos.y() )
60  //self.move(offPos)
61 
62  popLabel->setText(message);
63  popWidget->setWindowOpacity(1.0);
64  popWidget->show();
65  return;
66 
67  QTimer::singleShot(timeout, this, SLOT(start_fade()) );
68 }
69 
70 
71 
72 
73 
75  setStyleSheet("font-family: freeuniversal; color: #666666; font-size: 16px; background-image: url(:/artwork/fgx-logo-flyer); background-repeat: none; padding-left: 40px; padding-top: 3px; padding-bottom: 5px; padding-right: 5px; margin-top: 10px; margin-bottom: 20px;");
76 }
77 
78 
80 {
81  if(popWidget->windowOpacity() == 0.0){
82  fadeTimer->stop();
83  popWidget->hide();
84  }else{
85  popWidget->setWindowOpacity( popWidget->windowOpacity() - 0.1 );
86  }
87 }
XMessageLabel(QWidget *parent=0)
void on_fade_timer()
QWidget * popWidget
Definition: xmessagelabel.h:15
QLabel * popLabel
Definition: xmessagelabel.h:16
QTimer * fadeTimer
Definition: xmessagelabel.h:13
void showMessage(QString message, int timeout)