Fork me on GitHub
2.15.20
FGx
A cross-platform launcher for FlightGear
headerwidget.cpp
Go to the documentation of this file.
1 // -=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=-=-
2 // FGx FlightGear Launcher // headerwidget.cpp
3 // -=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=-=-
4 // (c) 2010-2012
5 // Yves Sablonier, Pete Morgan
6 // Geoff McLane
7 // GNU GPLv2, see main.cpp and shipped licence.txt for further information
8 
9 
10 #include "app_config.h"
11 #include <QtDebug>
12 
13 #include <QVBoxLayout>
14 
15 #include "launcher/headerwidget.h"
16 #include "utilities/utilities.h"
17 
18 /*! \class HeaderWidget
19  * \brief The HeaderWidget is the top part of the LauncherWindow and contains the info and a normally hidden message/info box
20  *
21 */
23  QWidget(parent)
24 {
25 
26  mainObject = mob;
27 
28 
29  QGridLayout *mainLayout = new QGridLayout();
30  mainLayout->setSpacing(2);
31  setLayout(mainLayout);
32 
33  //= Fgx Logo is a QLabel with background image
34  QLabel *iconLabel = new QLabel("");
35  iconLabel->setFixedHeight(40);
36  iconLabel->setFixedWidth(40);
37  iconLabel->setStyleSheet("QLabel { margin: 0px; background-image: url(:artwork/fgx-logo-flyer); background-repeat: none;}");
38  mainLayout->addWidget(iconLabel, 0, 0, 2, 1);
39 
40  //= Main header
41  headerLabel = new QLabel("");
42  headerLabel->setStyleSheet("color: #333333; font-size: 18pt; font-family: monospace; padding: 2px; border-radius: 8px;");
43  mainLayout->addWidget(headerLabel, 0, 1, 1, 1);
44 
45  //= Callsing Full words
46  callsignLabel = new QLabel("");
47  callsignLabel->setStyleSheet("color: #333333; font-size: 8pt; font-family: monospace; margin-left: 10px;");
48  mainLayout->addWidget(callsignLabel, 1, 1, 1, 1);
49 
50 
51  //= Message Label
52  messageLabel = new QLabel();
53  messageLabel->setText("FGx booted ;-)");
54  mainLayout->addWidget(messageLabel, 0, 2,2,1);
55 
56 }
57 
58 //========================================================================
59 //= Show Message
60 void HeaderWidget::showMessage(QString message){
61  showMessage(message, DEF_TO_MS);
62 }
63 
64 void HeaderWidget::showMessage(QString message, int timeout){
65 
66  messageLabel->setStyleSheet("QLabel { color: #666666; font-size: 16px; padding-left: 5px; background-color: yellow; }");
67  messageLabel->setText(message);
68 
69  QTimer::singleShot(timeout, this, SLOT(cancel_message()) );
70 }
71 
72 //== Cancel message
74 {
75  messageLabel->setStyleSheet("");
76  messageLabel->setText("");
77 }
78 
79 
80 //========================================================================
81 //= Set Header
82 void HeaderWidget::setHeader(QString text)
83 {
84  headerLabel->setText(text);
85 
86 }
87 
88 //= Set Callsign Sentence
89 void HeaderWidget::setCallsign(QString text)
90 {
91  text = text.toUpper();
92  QStringList words;
93  for (int i = 0; i < text.size(); ++i) {
94  words << abc_to_telephony(text.at(i).toLatin1());
95  }
96  callsignLabel->setText(words.join(" ").toUpper());
97 
98 }
MainObject * mainObject
Definition: headerwidget.h:29
void setHeader(QString text)
The MainObject is an extended QObject, and the main "controller" for FGx.
Definition: mainobject.h:66
QLabel * headerLabel
Definition: headerwidget.h:34
HeaderWidget(MainObject *mob, QWidget *parent=0)
#define DEF_TO_MS
Definition: app_config.h:19
void setCallsign(QString text)
void showMessage(QString message, int timeout)
void cancel_message()
QLabel * callsignLabel
Definition: headerwidget.h:35
QLabel * messageLabel
Definition: headerwidget.h:38