From b9ad793dd57fb311d6288599e280bb9784c19b90 Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Mon, 13 Jan 2014 01:09:56 +0100 Subject: [PATCH] New GUI based on Qt style sheets. This is the main window. --- samples/blackgui/mainwindow.cpp | 187 +- samples/blackgui/mainwindow.h | 140 +- samples/blackgui/mainwindow.ui | 4306 ++++++++++-------- samples/blackgui/mainwindow_aircraft.cpp | 1 + samples/blackgui/mainwindow_atc.cpp | 2 + samples/blackgui/mainwindow_cockpit.cpp | 25 +- samples/blackgui/mainwindow_init.cpp | 166 +- samples/blackgui/mainwindow_menus.cpp | 86 + samples/blackgui/mainwindow_settings.cpp | 2 + samples/blackgui/mainwindow_textmessages.cpp | 158 +- samples/blackgui/mainwindow_voice.cpp | 68 + 11 files changed, 3075 insertions(+), 2066 deletions(-) create mode 100644 samples/blackgui/mainwindow_menus.cpp diff --git a/samples/blackgui/mainwindow.cpp b/samples/blackgui/mainwindow.cpp index c413ac3b4..81aa8cfd3 100644 --- a/samples/blackgui/mainwindow.cpp +++ b/samples/blackgui/mainwindow.cpp @@ -3,6 +3,7 @@ #include "blackgui/atcstationlistmodel.h" #include "blackcore/dbus_server.h" #include "blackcore/context_network.h" +#include using namespace BlackCore; using namespace BlackMisc; @@ -17,9 +18,11 @@ using namespace BlackMisc::Voice; /* * Constructor */ -MainWindow::MainWindow(QWidget *parent) : - QMainWindow(parent), ui(new Ui::MainWindow), - m_init(false), m_withDBus(true), +MainWindow::MainWindow(GuiModes::WindowMode windowMode, QWidget *parent) : + QMainWindow(parent, windowMode == GuiModes::WindowFrameless ? (Qt::Window | Qt::FramelessWindowHint) : Qt::Tool), + ui(new Ui::MainWindow), + m_infoWindow(nullptr), + m_windowMode(windowMode), m_init(false), m_coreMode(GuiModes::CoreExternal), m_coreAvailable(false), m_contextNetworkAvailable(false), m_contextVoiceAvailable(false), m_dBusConnection("dummy"), m_coreRuntime(nullptr), m_atcListOnline(nullptr), m_atcListBooked(nullptr), @@ -29,8 +32,16 @@ MainWindow::MainWindow(QWidget *parent) : m_contextSettings(nullptr), m_ownAircraft(), m_voiceRoomCom1(), m_voiceRoomCom2(), m_timerUpdateAtcStationsOnline(nullptr), m_timerUpdateAircraftsInRange(nullptr), - m_timerCollectedCockpitUpdates(nullptr), m_timerContextWatchdog(nullptr) + m_timerCollectedCockpitUpdates(nullptr), m_timerContextWatchdog(nullptr), + m_contextMenuAudio(nullptr) { + if (windowMode == GuiModes::WindowFrameless) + { + // http://stackoverflow.com/questions/18316710/frameless-and-transparent-window-qt5 + this->setAttribute(Qt::WA_NoSystemBackground, true); + this->setAttribute(Qt::WA_TranslucentBackground, true); + // this->setAttribute(Qt::WA_PaintOnScreen); + } ui->setupUi(this); } @@ -84,6 +95,39 @@ void MainWindow::gracefulShutdown() } } +/* + * Close event, window closes + */ +void MainWindow::closeEvent(QCloseEvent *event) +{ + this->gracefulShutdown(); + QMainWindow::closeEvent(event); + QApplication::exit(); +} + +void MainWindow::mouseMoveEvent(QMouseEvent *event) +{ + // this->ui->fr_PseudoWindowBar->geometry().contains(event->pos()) + if (this->m_windowMode == GuiModes::WindowFrameless && event->buttons() & Qt::LeftButton) + { + move(event->globalPos() - this->m_dragPosition); + event->accept(); + return; + } + QWidget::mouseMoveEvent(event); +} + +void MainWindow::mousePressEvent(QMouseEvent *event) +{ + if (this->m_windowMode == GuiModes::WindowFrameless && event->button() == Qt::LeftButton) + { + this->m_dragPosition = event->globalPos() - this->frameGeometry().topLeft(); + event->accept(); + return; + } + QWidget::mousePressEvent(event); +} + /* * Select correct main page */ @@ -97,19 +141,35 @@ void MainWindow::setMainPage(bool start) QObject *sender = QObject::sender(); if (sender == this->ui->pb_MainConnect || sender == this->ui->pb_MainStatus) - this->ui->sw_MainMiddle->setCurrentIndex(0); + this->ui->sw_MainMiddle->setCurrentIndex(MainPageStatus); else if (sender == this->ui->pb_MainAtc) - this->ui->sw_MainMiddle->setCurrentIndex(1); + this->ui->sw_MainMiddle->setCurrentIndex(MainPageAtc); else if (sender == this->ui->pb_MainAircrafts) - this->ui->sw_MainMiddle->setCurrentIndex(2); + this->ui->sw_MainMiddle->setCurrentIndex(MainPageAircrafts); else if (sender == this->ui->pb_MainCockpit) - this->ui->sw_MainMiddle->setCurrentIndex(3); + this->ui->sw_MainMiddle->setCurrentIndex(MainPageCockpit); else if (sender == this->ui->pb_MainTextMessages) - this->ui->sw_MainMiddle->setCurrentIndex(4); + this->ui->sw_MainMiddle->setCurrentIndex(MainPageTextMessages); else if (sender == this->ui->pb_MainFlightplan) - this->ui->sw_MainMiddle->setCurrentIndex(5); + this->ui->sw_MainMiddle->setCurrentIndex(MainPageFlightplan); else if (sender == this->ui->pb_MainSettings) - this->ui->sw_MainMiddle->setCurrentIndex(6); + this->ui->sw_MainMiddle->setCurrentIndex(MainPageSettings); +} + +/* + * Set main page + */ +void MainWindow::setMainPage(MainWindow::MainPageIndex mainPage) +{ + this->ui->sw_MainMiddle->setCurrentIndex(mainPage); +} + +/* + * Given main page selected? + */ +bool MainWindow::isMainPageSelected(MainWindow::MainPageIndex mainPage) const +{ + return this->ui->sw_MainMiddle->currentIndex() == static_cast(mainPage); } /* @@ -119,6 +179,8 @@ void MainWindow::toggleNetworkConnection() { CStatusMessageList msgs; if (!this->isContextNetworkAvailableCheck()) return; + + this->ui->lbl_StatusNetworkConnectedIcon->setPixmap(this->m_resPixmapConnectionConnecting); if (!this->m_contextNetwork->isConnected()) { QString cs = this->ui->le_SettingsAircraftCallsign->text(); @@ -133,8 +195,8 @@ void MainWindow::toggleNetworkConnection() } else { + if (this->m_contextVoiceAvailable) this->m_contextVoice->leaveAllVoiceRooms(); msgs = this->m_contextNetwork->disconnectFromNetwork(); - this->m_contextVoice->leaveAllVoiceRooms(); } if (!msgs.isEmpty()) this->displayStatusMessages(msgs); } @@ -180,39 +242,6 @@ void MainWindow::displayStatusMessages(const CStatusMessageList &messages) } } -/* - * Menu clicked - */ -void MainWindow::menuClicked() -{ - QObject *sender = QObject::sender(); - CStatusMessageList msgs; - - if (sender == this->ui->menu_TestLocationsEDRY) - { - this->setTestPosition("N 049° 18' 17", "E 008° 27' 05", CAltitude(312, CAltitude::MeanSeaLevel, CLengthUnit::ft())); - } - else if (sender == this->ui->menu_TestLocationsEDNX) - { - this->setTestPosition("N 048° 14′ 22", "E 011° 33′ 41", CAltitude(486, CAltitude::MeanSeaLevel, CLengthUnit::m())); - } - else if (sender == this->ui->menu_TestLocationsEDDM) - { - this->setTestPosition("N 048° 21′ 14", "E 011° 47′ 10", CAltitude(448, CAltitude::MeanSeaLevel, CLengthUnit::m())); - } - else if (sender == this->ui->menu_TestLocationsEDDF) - { - this->setTestPosition("N 50° 2′ 0", "E 8° 34′ 14", CAltitude(100, CAltitude::MeanSeaLevel, CLengthUnit::m())); - } - else if (sender == this->ui->menu_ReloadSettings) - { - this->reloadSettings(); - msgs.push_back(CStatusMessage::getInfoMessage("Settings reloaded")); - } - - if (!msgs.isEmpty()) this->displayStatusMessages(msgs); -} - /* * Connection terminated */ @@ -227,12 +256,12 @@ void MainWindow::connectionTerminated() void MainWindow::connectionStatusChanged(uint /** from **/, uint to) { // CContextNetwork::ConnectionStatus statusFrom = static_cast(from); - CContextNetwork::ConnectionStatus statusTo = static_cast(to); + INetwork::ConnectionStatus statusTo = static_cast(to); // always this->updateGuiStatusInformation(); - if (statusTo == CContextNetwork::ConnectionStatusConnected) + if (statusTo == INetwork::Connected) { QTimer::singleShot(5 * 1000, this, SLOT(reloadAircraftsInRange())); QTimer::singleShot(5 * 1000, this, SLOT(reloadAtcStationsOnline())); @@ -242,19 +271,19 @@ void MainWindow::connectionStatusChanged(uint /** from **/, uint to) /* * Timer event */ -void MainWindow::updateTimer() +void MainWindow::timerBasedUpdates() { QObject *sender = QObject::sender(); if (sender == this->m_timerUpdateAtcStationsOnline) { - int t = this->ui->hs_AtcStationsOnline->value() * 1000; + int t = this->ui->hs_SettingsGuiAtcRefreshTime->value() * 1000; this->m_timerUpdateAtcStationsOnline->start(t); if (ui->tv_AtcStationsOnline->isVisible()) this->reloadAtcStationsOnline(); } if (sender == this->m_timerUpdateAircraftsInRange) { - int t = this->ui->hs_AtcStationsOnline->value() * 1000; + int t = this->ui->hs_SettingsGuiAircraftRefreshTime->value() * 1000; this->m_timerUpdateAircraftsInRange->start(t); if (ui->tv_AircraftsInRange->isVisible()) this->reloadAircraftsInRange(); @@ -312,28 +341,78 @@ void MainWindow::updateGuiStatusInformation() network = this->m_contextNetwork->usingLocalObjects() ? "local" : now; } + // handle voice, mute QString voice("unavailable"); if (this->m_contextVoiceAvailable) { voice = this->m_contextVoice->usingLocalObjects() ? "local" : now; + this->ui->pb_SoundMute->setEnabled(true); + } + else + { + // voice not available + this->ui->pb_SoundMute->setEnabled(false); } + // update status fields this->ui->le_StatusNetworkContext->setText(network); this->ui->le_StatusVoiceContext->setText(voice); - this->ui->cb_StatusWithDBus->setCheckState(this->m_withDBus ? Qt::Checked : Qt::Unchecked); + this->ui->cb_StatusWithDBus->setCheckState(this->m_coreMode ? Qt::Checked : Qt::Unchecked); // Connected button if (this->m_contextNetworkAvailable && this->m_contextNetwork->isConnected()) { + if (this->ui->lbl_StatusNetworkConnectedIcon->toolTip().startsWith("dis", Qt::CaseInsensitive)) + this->ui->lbl_StatusNetworkConnectedIcon->setToolTip(now); this->ui->pb_MainConnect->setText("Disconnect"); this->ui->pb_MainConnect->setStyleSheet("background-color: green"); - if (!this->ui->le_StatusNetworkConnected->text().startsWith("2")) - this->ui->le_StatusNetworkConnected->setText(now); + this->ui->lbl_StatusNetworkConnectedIcon->setPixmap(this->m_resPixmapConnectionConnected); } else { + this->ui->lbl_StatusNetworkConnectedIcon->setToolTip("disconnected"); this->ui->pb_MainConnect->setText("Connect"); this->ui->pb_MainConnect->setStyleSheet("background-color: "); - this->ui->le_StatusNetworkConnected->setText("Disconnected"); + this->ui->lbl_StatusNetworkConnectedIcon->setPixmap(this->m_resPixmapConnectionDisconnected); + } +} + +/* + * Opacity 0-100 + */ +void MainWindow::changeWindowOpacity(int opacity) +{ + if (opacity < 0) + { + QObject *sender = QObject::sender(); + if (sender == this->ui->pb_MainKeypadOpacity050) + opacity = 50; + else if (sender == this->ui->pb_MainKeypadOpacity100) + opacity = 100; + else + return; + } + qreal o = opacity / 100.0; + QWidget::setWindowOpacity(o); +} + +/* + * Display the info window + */ +void MainWindow::displayOverlayInfo(const QString &message) +{ + if (!this->m_infoWindow) + { + this->m_infoWindow = new CInfoWindow(this); + } + + // display window + if (message.isEmpty()) + { + this->m_infoWindow->hide(); + } + else + { + this->m_infoWindow->setInfoMessage(message); } } diff --git a/samples/blackgui/mainwindow.h b/samples/blackgui/mainwindow.h index 1fd8eec02..4190e87ff 100644 --- a/samples/blackgui/mainwindow.h +++ b/samples/blackgui/mainwindow.h @@ -1,10 +1,19 @@ -#ifndef BLACKMISC_MAINWINDOW_H -#define BLACKMISC_MAINWINDOW_H +/* 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_MAINWINDOW_H +#define SAMPLE_MAINWINDOW_H // clash with struct interface in objbase.h used to happen #pragma push_macro("interface") #undef interface +#include +#include +#include +#include #include "blackgui/atcstationlistmodel.h" #include "blackgui/serverlistmodel.h" #include "blackgui/aircraftlistmodel.h" @@ -15,10 +24,8 @@ #include "blackcore/context_settings_interface.h" #include "blackcore/context_application_interface.h" #include "blackcore/coreruntime.h" -#include -#include -#include -#include +#include "infowindow.h" +#include "guimodeenums.h" namespace Ui { @@ -35,9 +42,10 @@ class MainWindow : public QMainWindow public: /*! * \brief Constructor + * \param windowMode * \param parent */ - explicit MainWindow(QWidget *parent = nullptr); + explicit MainWindow(GuiModes::WindowMode windowMode, QWidget *parent = nullptr); /*! * Destructor @@ -46,19 +54,54 @@ public: /*! * \brief Init data - * \param withDBus + * \param coreMode */ - void init(bool withDBus); + void init(GuiModes::CoreMode coreMode); /*! * \brief Graceful shutdown */ void gracefulShutdown(); +protected: + /*! + * \brief Close event, e.g. when window is closed + * \param event + */ + void closeEvent(QCloseEvent *event); + + /*! + * \brief Mouse moving, required for frameless window + * \param event + */ + void mouseMoveEvent(QMouseEvent *event); + + /*! + * \brief Mouse press, required for frameless window + * \param event + */ + void mousePressEvent(QMouseEvent *event); + + /*! + * \brief Main page indexes + */ + enum MainPageIndex + { + MainPageStatus = 0, + MainPageAtc = 1, + MainPageAircrafts = 2, + MainPageCockpit = 3, + MainPageTextMessages = 4, + MainPageFlightplan = 5, + MainPageSettings = 6 + }; + private: Ui::MainWindow *ui; + CInfoWindow *m_infoWindow; bool m_init; - bool m_withDBus; + GuiModes::WindowMode m_windowMode; + GuiModes::CoreMode m_coreMode; bool m_coreAvailable; bool m_contextNetworkAvailable; bool m_contextVoiceAvailable; @@ -75,10 +118,18 @@ private: BlackMisc::Aviation::CAircraft m_ownAircraft; /*!< own aircraft's state */ BlackMisc::Voice::CVoiceRoom m_voiceRoomCom1; BlackMisc::Voice::CVoiceRoom m_voiceRoomCom2; - QTimer *m_timerUpdateAtcStationsOnline; /*!< update stations */ - QTimer *m_timerUpdateAircraftsInRange; /*!< update aircrafts */ + QTimer *m_timerUpdateAtcStationsOnline; /*!< timer for update of stations */ + QTimer *m_timerUpdateAircraftsInRange; /*!< timer for update of aircrafts */ QTimer *m_timerCollectedCockpitUpdates; /*!< collect cockpit updates over a short period before sending */ QTimer *m_timerContextWatchdog; /*!< core available? */ + QPixmap m_resPixmapConnectionConnected; + QPixmap m_resPixmapConnectionDisconnected; + QPixmap m_resPixmapConnectionConnecting; + QPixmap m_resPixmapVoiceHigh; + QPixmap m_resPixmapVoiceLow; + QPixmap m_resPixmapVoiceMuted; + QPoint m_dragPosition; /*!< position, if moving is handled with frameless window */ + QMenu *m_contextMenuAudio; /*! Audio context menu */ /*! * \brief GUI status update @@ -102,6 +153,11 @@ private: */ void initialDataReads(); + /*! + * \brief Init GUI signals + */ + void initGuiSignals(); + /*! * \brief Context network availability check, otherwise status message * \return @@ -137,7 +193,7 @@ private: * \param name * \return */ - QWidget *findTextMessageTabByName(const QString &name); + QWidget *findTextMessageTabByName(const QString &name) const; /*! * \brief Private channel text message @@ -147,7 +203,8 @@ private: void addPrivateChannelTextMessage(const BlackMisc::Network::CTextMessage &textMessage, bool sending = false); /*! - * \brief stub for sending a text message (eihter radio or private message) + * Stub for sending a text message (eihter radio or private message). + * Sets sender / receiver depending on frequency / channel situation. * \return */ BlackMisc::Network::CTextMessage getTextMessageStubForChannel(); @@ -171,6 +228,30 @@ private: */ void setTestPosition(const QString &wgsLatitude, const QString &wgsLongitude, const BlackMisc::Aviation::CAltitude &altitude); + /*! + * \brief Display the overlay window + */ + void displayOverlayInfo(const QString &message = ""); + + /*! + * \brief Is given main page selected? + * \param mainPage + * \return + */ + bool isMainPageSelected(MainPageIndex mainPage) const; + + /*! + * \brief For this text message's receiver, is the current tab selected + * \param textMessage + * \return + */ + bool isCorrespondingTextMessageTabSelected(BlackMisc::Network::CTextMessage textMessage) const; + + /*! + * \brief Init the context menus + */ + void initContextMenus(); + private slots: // @@ -218,11 +299,11 @@ private slots: void connectionStatusChanged(uint from, uint to); /*! - * \brief Text messages received + * \brief Append text messages (received, to be sent) to GUI * \param messages * \param sending */ - void textMessageReceived(const BlackMisc::Network::CTextMessageList &messages, bool sending = false); + void appendTextMessagesToGui(const BlackMisc::Network::CTextMessageList &messages, bool sending = false); /*! * \brief Reload settings @@ -240,9 +321,16 @@ private slots: /*! * \brief Set the main page + * \param start Startup phase */ void setMainPage(bool start = false); + /*! + * \brief setMainPage + * \param mainPage + */ + void setMainPage(MainPageIndex mainPage); + /*! * \brief Connect to network * \param userId @@ -285,7 +373,7 @@ private slots: /*! * \brief Update timer */ - void updateTimer(); + void timerBasedUpdates(); /*! * \brief ATC station, tab changed, reload data @@ -337,10 +425,26 @@ private slots: void resetTransponderModerToCharly(); /*! - * \brief Override voice room + * \brief Override voice room (allows to set an arbitrary voice room for testing purposes) */ void voiceRoomOverride(); + /*! + * \brief Audio volume handling and mute + */ + void audioVolumes(); + + /*! + * \brief changeOpacity + * \param opacity 0-100 + */ + void changeWindowOpacity(int opacity = -1); + + /*! + * \brief Context menu for audio + */ + void audioIconContextMenu(const QPoint &position); + }; #pragma pop_macro("interface") diff --git a/samples/blackgui/mainwindow.ui b/samples/blackgui/mainwindow.ui index a0270aedf..70751a761 100644 --- a/samples/blackgui/mainwindow.ui +++ b/samples/blackgui/mainwindow.ui @@ -6,22 +6,2352 @@ 0 0 - 615 - 541 + 350 + 550 - + 0 0 + + + 350 + 550 + + Black GUI - + + + :/blackgui/icons/aircraftdeparture.png:/blackgui/icons/aircraftdeparture.png + + + /** http://qt-project.org/doc/qt-4.8/stylesheet-examples.html **/ + +QWidget { + background-color: black; + font: bold 10px; + color: white; /** font **/ +} + +QStatusBar { + background-color: darkslategray; +} + +#wi_CentralWidgetOutside { + /** there is no opacity with background image, so we need semitransparent images **/ + /** background-image: url(:/blackgui/icons/titaniumtexture.jpg) **/ + /** border: 2px solid green; **/ + /** border-radius: 20px; **/ + background-color: darkslategray; + margin: 0px; + padding: 5px; +} + +#fr_CentralFrameInside { + background-color: darkslategray; + margin: 5px; +} + +#wi_MainKeypadArea { + background-color: darkslategray; +} + +#gb_AtcStationsOnlineInfo { + border-style: none; +} + +#sw_MainMiddle { + padding: 3px; + border: 0px; + border-radius: 10px; +} + +#sw_MainMiddle QPushButton { + font-family: arial-rounded; + background-color: rgba(0, 0, 255, 128); + border-style: none; + border-radius:3px; + color: yellow; + padding: 3px; +} + +/* No style for Dial +#sw_MainMiddel QDial { + background-color: rgba(0, 0, 255, 128); +} +*/ + +#wi_MainKeypadArea QPushButton { + font-family: arial-rounded; + background-color: black; + border-style: solid; + border-width:1px; + border-radius:6px; + border-color: green; + max-height:20px; + min-width:60px; + min-height:20px; +} + +#wi_MainKeypadAreaWindow { + background-color: darkslategray; +} + +#le_CommandLineInput { + margin-bottom: 5px; + padding: 3px; + border-radius: 5px; +} + +QTabWidget::pane { /* The tab widget frame */ + border: none; + } + +QTabWidget::tab-bar { + left: 5px; /* move to the right by 5px */ +} + +QTabBar::tab { + border: 1px solid green; + border-top-left-radius: 6px; + border-top-right-radius: 6px; + min-width: 30px; + padding: 2px; + padding-left: 4px; + padding-right: 4px; + margin-right: 3px; +} + +QTabBar::tab::selected { + background-color: rgba(0, 0, 255, 128); +} + +QLabel { + background: transparent; +} + +QLineEdit { + background: black; + border: 1px solid green; + border-radius: 5px; +} + +QLineEdit[readOnly="true"] { + background: black; +} + +QCheckBox { + color: white; /** font **/ + border: 0px solid green; + background: transparent; +} + +QTextEdit { + border: 1px solid green; + background: transparent; + border-radius: 5px; +} + +QPlainTextEdit { + border: 1px solid green; + background: transparent; + border-radius: 5px; +} + +QComboBox { + border: 1px solid green; + border-radius: 5px; + padding: 1px; + background: transparent; +} + +QDoubleSpinBox { + border: 1px solid green; + border-radius: 5px; + padding: 1px; + background: transparent; +} + +QMenuBar { + background: darkslategray; +} + +QMenu { + background: black; + margin: 2px; /* some spacing around the menu */ + } + +QMenu::item { + padding: 2px 25px 1px 20px; + border: 2px solid darkslategray; /* reserve space for selection border */ + background: black; + } + + QMenu::item:selected { + border-color: darkblue; + background: black; + } + +QMenu::indicator { + background-color: black; + } + +QMenuBar { + background-color: darkslategray; + } + +QMenuBar::item { + spacing: 3px; /* spacing between menu bar items */ + padding: 1px 4px; + background: transparent; + border-radius: 4px; + } + +QMenuBar::item:selected { /* when selected using mouse or keyboard */ + background: black; + } + +QMenuBar::item:pressed { + background: black; + } + +QScrollBar:horizontal { + border: 2px solid gray; + background: slategray; + height: 10px; + margin: 0px 5px 0 5px; + } + +QScrollBar:vertical { + border: 2px solid gray; + background: slategray; + width: 10px; + margin: 5px 0 5px 0; + } + +QScrollBar::handle:horizontal { + background: black; + min-width: 15px; + } + +QScrollBar::handle:vertical { + background: black; + min-height: 15px; + } + +QScrollBar::add-line:horizontal { + border: 2px solid gray; + background: blue; + width: 5px; + subcontrol-position: right; + subcontrol-origin: margin; + } + +QScrollBar::sub-line:horizontal { + border: 2px solid gray; + background: blue; + width: 5px; + subcontrol-position: left; + subcontrol-origin: margin; + } + +QScrollBar::add-line:vertical { + border: 2px solid gray; + background: blue; + height: 5px; + subcontrol-position: bottom; + subcontrol-origin: margin; + } + + QScrollBar::sub-line:vertical { + border: 2px solid gray; + background: blue; + height: 5px; + subcontrol-position: top; + subcontrol-origin: margin; + } + +QHeaderView::section { + border: 1px solid blue; + background-color: darkslategray; + padding: 1px; + margin: 0px; +} + +QTableView { + border: 1px solid green; + border-radius: 5px; + background-color: black; + alternate-background-color: darkslategray; + selection-background-color: blue; + margin-left: 2px; + margin-top: 0; + margin-bottom: 0; + padding:0; + } + +QSlider::groove:horizontal { + border: 1px solid gray; + height: 4px; /* the groove expands to the size of the slider by default. by giving it a height, it has a fixed size */ + background: darkslategray; + } + +QSlider::handle:horizontal { + background: lightgray; + border: 1px solid darkslategra; + width: 18px; + margin: -2px 0; /* handle is placed by default on the contents rect of the groove. Expand outside the groove */ + border-radius: 3px; + } + +QSizeGrip { + image: url(:/blackgui/icons/resize.png); + width: 16px; + height: 16px; + } + + + Qt::ToolButtonIconOnly + + + QTabWidget::Rounded + + - + + 0 + 0 + + + + + 350 + 500 + + + + + 16777215 + 16777215 + + + + + 0 + + + 2 + + + + + + 0 + 0 + + + + + + + + 0 + + + 0 + + + + + + 0 + 0 + + + + + -1 + 75 + false + true + + + + + + + QFrame::NoFrame + + + 6 + + + + + 0 + 0 + + + + + 2 + + + 2 + + + + + + + DBus + + + true + + + false + + + + + + + true + + + + + + + Network connected + + + + + + + Network context + + + + + + + Voice context + + + + + + + true + + + + + + + + + + :/blackgui/icons/loginred.png + + + + + + + + + + :/blackgui/icons/audiovolumelow.png + + + + + + + + + + 0 + 0 + + + + QPlainTextEdit::NoWrap + + + true + + + + + + + + + 0 + 0 + + + + + + + + 0 + + + 0 + + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + + -1 + 75 + false + true + + + + + + + 0 + + + + In range + + + + 2 + + + 2 + + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + + + + QAbstractItemView::SingleSelection + + + QAbstractItemView::SelectRows + + + true + + + false + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + + 16777215 + 110 + + + + Info (ATIS, METAR, ...) + + + + 0 + + + 0 + + + 12 + + + 0 + + + 2 + + + + + + 0 + 0 + + + + + 0 + 0 + + + + + 16777215 + 100 + + + + + + + + + + + + 0 + 0 + + + + + 16777215 + 25 + + + + QFrame::NoFrame + + + QFrame::Raised + + + + QLayout::SetDefaultConstraint + + + 5 + + + 0 + + + 2 + + + 0 + + + + + + 0 + 0 + + + + Load METAR + + + + + + + + 0 + 0 + + + + Reload ATIS + + + + + + + + 0 + 0 + + + + + 60 + 16777215 + + + + + + + EDDF + + + 5 + + + true + + + + + + + + + + + Bookings + + + + 3 + + + 0 + + + 3 + + + 0 + + + 3 + + + + + QFrame::StyledPanel + + + QFrame::Sunken + + + 1 + + + true + + + QAbstractItemView::SingleSelection + + + QAbstractItemView::SelectRows + + + true + + + true + + + false + + + + + + + Reload + + + + + + + + + + + + + 0 + + + 0 + + + + + false + + + + + + + + + 5 + + + 2 + + + + + 4 + + + 2 + + + 4 + + + 2 + + + 5 + + + 3 + + + + + + -1 + 75 + false + true + + + + COM 1 + + + + + + + + 0 + 0 + + + + + 0 + 18 + + + + + 16777215 + 16777215 + + + + 3 + + + 118.000000000000000 + + + 136.000000000000000 + + + 0.250000000000000 + + + 118.000000000000000 + + + + + + + + -1 + 75 + false + true + + + + COM 2 + + + + + + + + 0 + 0 + + + + + 75 + 18 + + + + + 16777215 + 16777215 + + + + 3 + + + 118.000000000000000 + + + 136.000000000000000 + + + 0.250000000000000 + + + 119.000000000000000 + + + + + + + + 0 + 0 + + + + + 0 + 18 + + + + false + + + 3 + + + 118.000000000000000 + + + 136.000000000000000 + + + 0.250000000000000 + + + 118.250000000000000 + + + + + + + + 0 + 0 + + + + + 0 + 18 + + + + 3 + + + 118.000000000000000 + + + 136.000000000000000 + + + 0.250000000000000 + + + 119.250000000000000 + + + + + + + + 40 + 16777215 + + + + <> + + + + + + + <> + + + + + + + + 32 + 32 + + + + Volume COM1 + + + 100 + + + 5 + + + 5 + + + 100 + + + false + + + false + + + false + + + false + + + + + + + + 32 + 32 + + + + Volume COM2 + + + 100 + + + 5 + + + 5 + + + 100 + + + + + + + Test + + + + + + + + 0 + 0 + + + + + -1 + 75 + false + true + + + + Transponder + + + + + + + + 0 + 0 + + + + SELCAL + + + + + + + + 0 + 0 + + + + + AB + + + + + AC + + + + + AD + + + + + AE + + + + + + + + + 0 + 0 + + + + + AB + + + + + AC + + + + + AD + + + + + + + + Qt::Vertical + + + + 20 + 32 + + + + + + + + Qt::Vertical + + + + 20 + 32 + + + + + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + + S + + + + + C + + + + + I + + + + + + + + + 0 + 0 + + + + + 0 + 18 + + + + 0 + + + 7777.000000000000000 + + + 7000.000000000000000 + + + + + + + + + + + + 2 + + + 2 + + + + + + -1 + 75 + false + true + + + + true + + + + + + + Ovr. + + + + + + + + + + + 2 + + + 2 + + + + + + -1 + 75 + false + true + + + + true + + + + + + + Ovr. + + + + + + + + + + + + + + + + + + + + 0 + + + 0 + + + + + 0 + + + + All + + + + 0 + + + 2 + + + 3 + + + 2 + + + 0 + + + + + QTextEdit::NoWrap + + + true + + + 10 + + + + + + + + UNICOM + + + + 0 + + + 2 + + + 3 + + + 2 + + + 0 + + + + + QTextEdit::NoWrap + + + true + + + 10 + + + + + + + + COM 1 + + + + 0 + + + 2 + + + 3 + + + 2 + + + 0 + + + + + QTextEdit::NoWrap + + + true + + + 10 + + + + + + + + COM 2 + + + + 0 + + + 2 + + + 3 + + + 2 + + + 0 + + + + + QTextEdit::NoWrap + + + true + + + 10 + + + + + + + + + + + + + 0 + + + 0 + + + + + + + 0 + + + 0 + + + + + 0 + + + + Traffic Network + + + + 2 + + + 1 + + + + + QAbstractItemView::AnyKeyPressed|QAbstractItemView::DoubleClicked|QAbstractItemView::EditKeyPressed + + + QAbstractItemView::SingleSelection + + + QAbstractItemView::SelectRows + + + false + + + + + + + QFormLayout::AllNonFixedFieldsGrow + + + 6 + + + + + Name + + + + + + + + + + + + + + Description + + + + + + + + + + Address + + + + + + + + + + Port + + + + + + + 5 + + + + + + + Real name + + + + + + + + + + + + + + Id: + + + + + + + + + + + + + + Password + + + + + + + + + + 32 + + + QLineEdit::Password + + + + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + 3 + + + 3 + + + + + Save + + + + + + + Remove + + + + + + + Current server + + + + + + + + + + + Aircraft + + + + + + + + Callsign + + + + + + + BLACK + + + + + + + ICAO type (e.g. A320) + + + + + + + + + + ICAO airline (e.g.DLH) + + + + + + + + + + Plane type + + + + + + + + + + Modes + + + + + + + Stealth mode + + + + + + + Observer + + + + + + + + + + Voice + + + + 2 + + + 2 + + + + + QFormLayout::AllNonFixedFieldsGrow + + + 2 + + + 4 + + + 2 + + + 2 + + + + + In + + + + + + + + + + Out + + + + + + + + + + Qt::Vertical + + + + 20 + 20 + + + + + + + + Tests + + + + + + + + 0 + + + 0 + + + + + + 125 + 16777215 + + + + Start MIC test + + + + + + + + 125 + 16777215 + + + + false + + + Start Squelch test + + + + + + + + + + + + + GUI + + + + + + QFormLayout::AllNonFixedFieldsGrow + + + + + Opacity (0-100%) + + + + + + + Aircraft refresh time (5-30s) + + + + + + + 5 + + + 30 + + + 5 + + + 5 + + + 10 + + + Qt::Horizontal + + + QSlider::NoTicks + + + + + + + ATC refresh time (5-30s) + + + + + + + 5 + + + 30 + + + 5 + + + 5 + + + 10 + + + Qt::Horizontal + + + + + + + 100 + + + 10 + + + 100 + + + Qt::Horizontal + + + + + + + + + + + + + + + + + + 0 + 0 + + + + + QLayout::SetDefaultConstraint + + + 2 + + + 6 + + + 2 + + + 0 + + + 2 + + + + + + 0 + 0 + + + + + 16777215 + 22 + + + + Cockpit + + + + + + + + 0 + 0 + + + + + 16777215 + 22 + + + + Mappings + + + + + + + + 0 + 0 + + + + + 16777215 + 22 + + + + Weather + + + + + + + + 0 + 0 + + + + + 16777215 + 22 + + + + Status + + + + + + + + 0 + 0 + + + + <commands go here> + + + + + + + + 0 + 0 + + + + + 16777215 + 22 + + + + ATC + + + + + + + + 0 + 0 + + + + + 16777215 + 22 + + + + Qt::LeftToRight + + + Settings + + + + + + + + 16777215 + 22 + + + + Mute + + + + + + + + 0 + 0 + + + + + 62 + 22 + + + + + 16777215 + 22 + + + + 50% + + + + + + + + 0 + 0 + + + + + 16777215 + 22 + + + + Connect + + + + + + + + 16777215 + 22 + + + + Maximum volume + + + Max.vol. + + + + + + + + 0 + 0 + + + + + 62 + 22 + + + + + 16777215 + 22 + + + + 100% + + + + + + + + 0 + 0 + + + + + 16777215 + 22 + + + + Aircrafts + + + + + + + + 0 + 0 + + + + + 16777215 + 22 + + + + Text/Chat + + + + + + + + 0 + 0 + + + + + 16777215 + 22 + + + + Flightplan + + + + + + + Users + + + + + + + Ident + + + + + + + + + + + + + + + 0 + 0 + 350 + 15 + + + + 0 0 @@ -32,1331 +2362,20 @@ 16777215 - - - - - 0 - - - 0 - - - - - 10 - - - QLayout::SetMinimumSize - - - 0 - - - 5 - - - - - - 0 - 0 - - - - - 60 - 23 - - - - Connect - - - - - - - - 60 - 16777215 - - - - Status - - - - - - - - 60 - 16777215 - - - - ATC - - - - - - - - 60 - 16777215 - - - - Aircrafts - - - - - - - - 60 - 16777215 - - - - Mappings - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - 0 - - - - - - 0 - 0 - - - - 3 - - - - - - - - - true - - - - - - - DBus - - - true - - - false - - - - - - - true - - - - - - - true - - - - - - - Voice context - - - - - - - Network connected - - - - - - - Network context - - - - - - - - - QPlainTextEdit::NoWrap - - - true - - - - - - - - - 0 - 0 - - - - - 2 - - - 0 - - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - 0 - - - - In range - - - - 2 - - - 2 - - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - QAbstractItemView::SingleSelection - - - QAbstractItemView::SelectRows - - - true - - - false - - - - - - - - 0 - 0 - - - - - 16777215 - 110 - - - - Info (ATIS, METAR, ...) - - - - 0 - - - 0 - - - 0 - - - 0 - - - 2 - - - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - - 16777215 - 100 - - - - - - - - - 0 - 0 - - - - - 16777215 - 25 - - - - QFrame::NoFrame - - - QFrame::Raised - - - - 2 - - - QLayout::SetDefaultConstraint - - - 2 - - - 0 - - - 2 - - - 0 - - - - - - 80 - 20 - - - - - 16777215 - 20 - - - - 5 - - - 30 - - - 5 - - - 10 - - - Qt::Horizontal - - - QSlider::TicksAbove - - - 5 - - - - - - - - 60 - 16777215 - - - - - - - 5 - - - - - - - Load METAR - - - - - - - - 20 - 20 - - - - Reload ATIS - - - - - - - - - - - Bookings - - - - 0 - - - QLayout::SetMaximumSize - - - 0 - - - - - true - - - QAbstractItemView::SingleSelection - - - QAbstractItemView::SelectRows - - - true - - - false - - - - - - - - - Reload - - - - - - - - - - - - - - - - - false - - - - - - - - 0 - 0 - - - - - 16777215 - 25 - - - - QFrame::NoFrame - - - QFrame::Raised - - - - 2 - - - QLayout::SetDefaultConstraint - - - 2 - - - 0 - - - 2 - - - 0 - - - - - - 80 - 20 - - - - - 16777215 - 20 - - - - 5 - - - 30 - - - 5 - - - 10 - - - Qt::Horizontal - - - QSlider::TicksAbove - - - 5 - - - - - - - - - - - - - - 3 - - - - - - 75 - 0 - - - - - 16777215 - 16777215 - - - - 3 - - - 118.000000000000000 - - - 136.000000000000000 - - - 0.250000000000000 - - - 119.000000000000000 - - - - - - - - 50 - 16777215 - - - - - S - - - - - C - - - - - I - - - - - - - - 3 - - - 118.000000000000000 - - - 136.000000000000000 - - - 0.250000000000000 - - - 119.250000000000000 - - - - - - - - 12 - - - - Transponder - - - - - - - - 12 - - - - COM 1 - - - - - - - - 12 - - - - COM 2 - - - - - - - false - - - 3 - - - 118.000000000000000 - - - 136.000000000000000 - - - 0.250000000000000 - - - 118.250000000000000 - - - - - - - - 75 - 16777215 - - - - 3 - - - 118.000000000000000 - - - 136.000000000000000 - - - 0.250000000000000 - - - 118.000000000000000 - - - - - - - 0 - - - 7777.000000000000000 - - - 7000.000000000000000 - - - - - - - - - - - - - - - - - - 2 - - - 2 - - - - - - 7 - - - - true - - - - - - - Ovr. - - - - - - - - - - - 2 - - - 2 - - - - - - 7 - - - - true - - - - - - - Ovr. - - - - - - - - - - - - - - - - 0 - - - - All - - - - - - QTextEdit::NoWrap - - - true - - - 10 - - - - - - - - UNICOM - - - - - - QTextEdit::NoWrap - - - true - - - 10 - - - - - - - - COM 1 - - - - - - QTextEdit::NoWrap - - - true - - - 10 - - - - - - - - COM 2 - - - - - - QTextEdit::NoWrap - - - true - - - 10 - - - - - - - - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - 0 - - - 0 - - - - - - - - - - - - - 0 - - - 0 - - - - - - - 0 - - - 0 - - - - - 0 - - - - Traffic Network - - - - 2 - - - 1 - - - - - QAbstractItemView::AnyKeyPressed|QAbstractItemView::DoubleClicked|QAbstractItemView::EditKeyPressed - - - QAbstractItemView::SingleSelection - - - QAbstractItemView::SelectRows - - - false - - - - - - - QFormLayout::AllNonFixedFieldsGrow - - - 6 - - - - - Name - - - - - - - - - - - - - - Description - - - - - - - - - - Address - - - - - - - - - - Port - - - - - - - 5 - - - - - - - Real name - - - - - - - - - - - - - - Id: - - - - - - - - - - - - - - Password - - - - - - - - - - 32 - - - QLineEdit::Password - - - - - - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - - - Save - - - - - - - Remove - - - - - - - Current server - - - - - - - - - - - Voice - - - - - - QFormLayout::AllNonFixedFieldsGrow - - - - - In - - - - - - - - - - Out - - - - - - - - - - - - - Aircraft - - - - - - - - Callsign - - - - - - - BLACK - - - - - - - - - - - - - - - - - - - 10 - - - QLayout::SetFixedSize - - - 5 - - - - - - 0 - 0 - - - - - 60 - 16777215 - - - - Qt::LeftToRight - - - Settings - - - - - - - - 60 - 16777215 - - - - Cockpit - - - - - - - - 60 - 16777215 - - - - Weather - - - - - - - - 60 - 16777215 - - - - Text/Chat - - - - - - - - 60 - 16777215 - - - - Flightplan - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - - - - 0 - 0 - 615 - 21 - + + + + + Test + + + Set plane positions @@ -1374,17 +2393,38 @@ + + + Help + + + + + File + + + + + - - - TopToolBarArea - - + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + false - + - Position EDDF (Frankfurt, GER) @@ -1410,603 +2450,17 @@ Position EDNX (Schleißheim, GER) + + + Close + + - - - - pb_MainAtc - released() - MainWindow - setMainPage() - - - 47 - 132 - - - 4 - 278 - - - - - pb_MainSettings - released() - MainWindow - setMainPage() - - - 569 - 50 - - - 599 - 251 - - - - - pb_MainConnect - released() - MainWindow - setMainPage() - - - 70 - 66 - - - 4 - 209 - - - - - pb_MainFlightplan - released() - MainWindow - setMainPage() - - - 588 - 198 - - - 299 - 199 - - - - - pb_MainCockpit - released() - MainWindow - setMainPage() - - - 580 - 99 - - - 299 - 199 - - - - - pb_MainConnect - released() - MainWindow - toggleNetworkConnection() - - - 22 - 50 - - - 0 - 37 - - - - - menu_TestLocationsEDRY - triggered() - MainWindow - menuClicked() - - - -1 - -1 - - - 299 - 199 - - - - - menu_ReloadSettings - triggered() - MainWindow - menuClicked() - - - -1 - -1 - - - 299 - 238 - - - - - pb_MainAircrafts - released() - MainWindow - setMainPage() - - - 16 - 158 - - - 0 - 137 - - - - - tv_SettingsTnServers - clicked(QModelIndex) - MainWindow - networkServerSelected(QModelIndex) - - - 175 - 52 - - - 265 - 36 - - - - - pb_SettingsTnSaveServer - released() - MainWindow - alterTrafficServer() - - - 109 - 74 - - - -4 - 459 - - - - - pb_SettingsTnRemoveServer - released() - MainWindow - alterTrafficServer() - - - 137 - 74 - - - -10 - 491 - - - - - pb_SettingsTnCurrentServer - released() - MainWindow - alterTrafficServer() - - - 165 - 74 - - - -17 - 436 - - - - - pb_ReloadAtcStationsBooked - released() - MainWindow - reloadAtcStationsBooked() - - - 175 - 72 - - - 2 - 509 - - - - - tv_AtcStationsOnline - clicked(QModelIndex) - MainWindow - onlineAtcStationSelected(QModelIndex) - - - 174 - 50 - - - -1 - 392 - - - - - pb_MainStatus - released() - MainWindow - setMainPage() - - - 19 - 98 - - - -8 - 101 - - - - - pb_MainTextMessages - released() - MainWindow - setMainPage() - - - 588 - 165 - - - -8 - 169 - - - - - pb_MainWeather - released() - MainWindow - setMainPage() - - - 588 - 132 - - - -26 - 118 - - - - - le_TextMessagesInput - returnPressed() - MainWindow - commandEntered() - - - 166 - 63 - - - 4 - 569 - - - - - pushButton - released() - MainWindow - getMetar() - - - 145 - 71 - - - 20 - 431 - - - - - le_AtcStationsOnlineMetar - returnPressed() - MainWindow - getMetar() - - - 118 - 71 - - - 341 - 515 - - - - - ds_CockpitCom1Active - editingFinished() - MainWindow - cockpitValuesChanged() - - - 449 - 73 - - - 337 - -8 - - - - - ds_CockpitCom1Standby - editingFinished() - MainWindow - cockpitValuesChanged() - - - 463 - 64 - - - 412 - -8 - - - - - ds_CockpitCom2Active - editingFinished() - MainWindow - cockpitValuesChanged() - - - 449 - 96 - - - 253 - -17 - - - - - ds_CockpitCom2Standby - editingFinished() - MainWindow - cockpitValuesChanged() - - - 478 - 85 - - - 481 - -17 - - - - - cb_CockpitTransponderMode - currentIndexChanged(QString) - MainWindow - cockpitValuesChanged() - - - 454 - 109 - - - 436 - -2 - - - - - ds_CockpitTransponder - editingFinished() - MainWindow - cockpitValuesChanged() - - - 449 - 119 - - - 1 - 127 - - - - - cb_VoiceOutputDevice - currentIndexChanged(int) - MainWindow - audioDeviceSelected(int) - - - 166 - 63 - - - 2 - 316 - - - - - cb_VoiceOutputDevice - currentIndexChanged(int) - MainWindow - audioDeviceSelected(int) - - - 166 - 63 - - - 20 - 379 - - - - - cb_VoiceInputDevice - currentIndexChanged(int) - MainWindow - audioDeviceSelected(int) - - - 166 - 55 - - - 26 - 355 - - - - - menu_TestLocationsEDNX - triggered() - MainWindow - menuClicked() - - - -1 - -1 - - - 307 - 270 - - - - - menu_TestLocationsEDDF - triggered() - MainWindow - menuClicked() - - - -1 - -1 - - - 307 - 270 - - - - - menu_TestLocationsEDDM - triggered() - MainWindow - menuClicked() - - - -1 - -1 - - - 307 - 270 - - - - - le_CockpitVoiceRoomCom1 - returnPressed() - MainWindow - voiceRoomOverride() - - - 232 - 64 - - - 40 - 388 - - - - - le_CockpitVoiceRoomCom2 - returnPressed() - MainWindow - voiceRoomOverride() - - - 253 - 82 - - - 70 - 304 - - - - - cb_CockpitVoiceRoom2Override - clicked() - MainWindow - voiceRoomOverride() - - - 346 - 91 - - - 559 - 412 - - - - - cb_CockpitVoiceRoom1Override - clicked() - MainWindow - voiceRoomOverride() - - - 368 - 61 - - - 587 - 340 - - - - + + + + setMainPage() toggleNetworkConnection() diff --git a/samples/blackgui/mainwindow_aircraft.cpp b/samples/blackgui/mainwindow_aircraft.cpp index a4af91159..68ada682e 100644 --- a/samples/blackgui/mainwindow_aircraft.cpp +++ b/samples/blackgui/mainwindow_aircraft.cpp @@ -22,6 +22,7 @@ void MainWindow::reloadAircraftsInRange() if (!this->isContextNetworkAvailableCheck()) return; this->m_aircraftsInRange->update(this->m_contextNetwork->getAircraftsInRange()); this->ui->tv_AircraftsInRange->resizeColumnsToContents(); + this->ui->tv_AircraftsInRange->resizeRowsToContents(); } /* diff --git a/samples/blackgui/mainwindow_atc.cpp b/samples/blackgui/mainwindow_atc.cpp index 57717d9d0..d4d82561b 100644 --- a/samples/blackgui/mainwindow_atc.cpp +++ b/samples/blackgui/mainwindow_atc.cpp @@ -22,6 +22,7 @@ void MainWindow::reloadAtcStationsBooked() if (!this->isContextNetworkAvailableCheck()) return; this->m_atcListBooked->update(this->m_contextNetwork->getAtcStationsBooked()); this->ui->tv_AtcStationsBooked->resizeColumnsToContents(); + this->ui->tv_AtcStationsBooked->resizeRowsToContents(); } /* @@ -32,6 +33,7 @@ void MainWindow::reloadAtcStationsOnline() if (!this->isContextNetworkAvailableCheck()) return; this->m_atcListOnline->update(this->m_contextNetwork->getAtcStationsOnline()); this->ui->tv_AtcStationsOnline->resizeColumnsToContents(); + this->ui->tv_AtcStationsOnline->resizeRowsToContents(); } /* diff --git a/samples/blackgui/mainwindow_cockpit.cpp b/samples/blackgui/mainwindow_cockpit.cpp index cb8577e16..0e41eb04a 100644 --- a/samples/blackgui/mainwindow_cockpit.cpp +++ b/samples/blackgui/mainwindow_cockpit.cpp @@ -21,6 +21,29 @@ void MainWindow::cockpitValuesChanged() { Q_ASSERT(this->m_timerCollectedCockpitUpdates); + // frequency switch? + QObject *sender = QObject::sender(); + if (sender == this->ui->pb_CockpitToggleCom1) + { + if (this->ui->ds_CockpitCom1Standby->value() == this->ui->ds_CockpitCom1Active->value()) return; + double f = this->ui->ds_CockpitCom1Active->value(); + this->ui->ds_CockpitCom1Active->setValue(this->ui->ds_CockpitCom1Standby->value()); + this->ui->ds_CockpitCom1Standby->setValue(f); + } + else if (sender == this->ui->pb_CockpitToggleCom2) + { + if (this->ui->ds_CockpitCom2Standby->value() == this->ui->ds_CockpitCom2Active->value()) return; + double f = this->ui->ds_CockpitCom2Active->value(); + this->ui->ds_CockpitCom2Active->setValue(this->ui->ds_CockpitCom2Standby->value()); + this->ui->ds_CockpitCom2Standby->setValue(f); + } + else if (sender == this->ui->pb_CockpitIdent) + { + // trigger the real button + this->ui->cb_CockpitTransponderMode->setCurrentText("I"); + return; + } + // this will call send cockpit updates with all changes made this->m_timerCollectedCockpitUpdates->stop(); this->m_timerCollectedCockpitUpdates->start(1000); // start @@ -87,7 +110,7 @@ void MainWindow::updateCockpitFromContext() } // - // voice + // Voice room override // if (!this->ui->cb_CockpitVoiceRoom1Override->isChecked()) { diff --git a/samples/blackgui/mainwindow_init.cpp b/samples/blackgui/mainwindow_init.cpp index 59ae0f830..d3549bd70 100644 --- a/samples/blackgui/mainwindow_init.cpp +++ b/samples/blackgui/mainwindow_init.cpp @@ -5,6 +5,8 @@ #include "blackcore/context_network.h" #include "blackcore/coreruntime.h" #include +#include +#include using namespace BlackCore; using namespace BlackMisc; @@ -14,10 +16,34 @@ using namespace BlackGui; /* * Init data */ -void MainWindow::init(bool withDBus) +void MainWindow::init(GuiModes::CoreMode coreMode) { if (this->m_init) return; - this->m_withDBus = withDBus; + this->m_coreMode = coreMode; + + // with frameless window, we shift menu and statusbar into central widget + // http://stackoverflow.com/questions/18316710/frameless-and-transparent-window-qt5 + if (this->m_windowMode == GuiModes::WindowFrameless) + { + + this->ui->wi_CentralWidgetOutside->setStyleSheet("#wi_CentralWidgetOutside {border: 2px solid green; border-radius: 20px; }"); + this->ui->vl_CentralWidgetOutside->setContentsMargins(8, 8, 8, 8); + + QHBoxLayout *menuBarLayout = new QHBoxLayout(); + QPushButton *closeIcon = new QPushButton(this); + closeIcon->setStyleSheet("margin: 0; padding: 0; background: transparent;"); + closeIcon->setIcon(QIcon(":/blackgui/icons/close.png")); + QObject::connect(closeIcon, SIGNAL(clicked()), this, SLOT(close())); + menuBarLayout->addWidget(this->ui->mb_MainMenuBar, 0, Qt::AlignTop | Qt::AlignLeft); + menuBarLayout->addWidget(closeIcon, 0, Qt::AlignTop | Qt::AlignRight); + this->ui->vl_CentralWidgetOutside->insertLayout(0, menuBarLayout, 0); + + QSizeGrip *grip = new QSizeGrip(this); + grip->setStyleSheet("margin-right: 25px; background-color: transparent;"); + this->ui->sb_MainStatusBar->setParent(this->ui->wi_CentralWidgetOutside); + this->ui->vl_CentralWidgetOutside->addWidget(this->ui->sb_MainStatusBar, 0); + this->ui->sb_MainStatusBar->addPermanentWidget(grip); + } // init models, the delete allows to re-init if (this->m_atcListBooked != nullptr) this->m_atcListBooked->deleteLater(); @@ -51,6 +77,8 @@ void MainWindow::init(bool withDBus) this->ui->tv_AircraftsInRange->horizontalHeader()->setSortIndicator(this->m_aircraftsInRange->getSortColumn(), this->m_aircraftsInRange->getSortOrder()); this->ui->tv_SettingsTnServers->setModel(this->m_trafficServerList); + this->ui->tv_AircraftsInRange->resizeColumnsToContents(); + this->ui->tv_AircraftsInRange->resizeRowsToContents(); if (this->m_timerUpdateAircraftsInRange == nullptr) this->m_timerUpdateAircraftsInRange = new QTimer(this); if (this->m_timerUpdateAtcStationsOnline == nullptr) this->m_timerUpdateAtcStationsOnline = new QTimer(this); @@ -58,7 +86,7 @@ void MainWindow::init(bool withDBus) if (this->m_timerCollectedCockpitUpdates == nullptr) this->m_timerCollectedCockpitUpdates = new QTimer(this); // context - if (this->m_withDBus) + if (this->m_coreMode != GuiModes::CoreInGuiProcess) { this->m_dBusConnection = QDBusConnection::sessionBus(); this->m_contextNetwork = new BlackCore::IContextNetwork(BlackCore::CDBusServer::ServiceName, this->m_dBusConnection, this); @@ -75,6 +103,17 @@ void MainWindow::init(bool withDBus) this->m_contextApplication = this->m_coreRuntime->getIContextApplication(); } + // wire GUI signals + this->initGuiSignals(); + + // images + this->m_resPixmapConnectionConnected = QPixmap(":/blackgui/icons/logingreen.png"); + this->m_resPixmapConnectionDisconnected = QPixmap(":/blackgui/icons/loginred.png"); + this->m_resPixmapConnectionConnecting = QPixmap(":/blackgui/icons/loginyellow.png"); + this->m_resPixmapVoiceLow = QPixmap(":/blackgui/icons/audiovolumelow.png"); + this->m_resPixmapVoiceHigh = QPixmap(":/blackgui/icons/audiovolumehigh.png"); + this->m_resPixmapVoiceMuted = QPixmap(":/blackgui/icons/audiovolumemuted.png"); + // relay status messages bool connect; connect = this->connect(this->m_contextNetwork, SIGNAL(statusMessage(BlackMisc::CStatusMessage)), @@ -94,38 +133,26 @@ void MainWindow::init(bool withDBus) Q_ASSERT_X(connect, "init", "cannot connect change network status"); connect = this->connect(this->m_contextNetwork, SIGNAL(textMessagesReceived(BlackMisc::Network::CTextMessageList)), - this, SLOT(textMessageReceived(BlackMisc::Network::CTextMessageList))); + this, SLOT(appendTextMessagesToGui(BlackMisc::Network::CTextMessageList))); Q_ASSERT_X(connect, "init", "cannot connect text message received"); connect = this->connect(this->m_timerUpdateAircraftsInRange, SIGNAL(timeout()), - this, SLOT(updateTimer())); + this, SLOT(timerBasedUpdates())); Q_ASSERT_X(connect, "init", "cannot connect timer"); connect = this->connect(this->m_timerUpdateAtcStationsOnline, SIGNAL(timeout()), - this, SLOT(updateTimer())); + this, SLOT(timerBasedUpdates())); Q_ASSERT_X(connect, "init", "cannot connect timer"); connect = this->connect(this->m_timerContextWatchdog, SIGNAL(timeout()), - this, SLOT(updateTimer())); + this, SLOT(timerBasedUpdates())); Q_ASSERT_X(connect, "init", "cannot connect timer (watchdog)"); connect = this->connect(this->m_timerCollectedCockpitUpdates, SIGNAL(timeout()), this, SLOT(sendCockpitUpdates())); Q_ASSERT_X(connect, "init", "cannot connect timer (cockpit updates)"); - - // - // GUI - // - connect = this->connect(this->ui->tw_AtcStations, SIGNAL(currentChanged(int)), - this, SLOT(atcStationTabChanged(int))); - Q_ASSERT_X(connect, "init", "cannot connect stations tab changed"); - - connect = this->connect(this->ui->sw_MainMiddle, SIGNAL(currentChanged(int)), - this, SLOT(middlePanelChanged(int))); - Q_ASSERT_X(connect, "init", "cannot connect middle panle changed"); Q_UNUSED(connect); - // start timers this->m_timerUpdateAircraftsInRange->start(10 * 1000); this->m_timerUpdateAtcStationsOnline->start(10 * 1000); @@ -143,11 +170,112 @@ void MainWindow::init(bool withDBus) // start screen this->setMainPage(true); + // init context menus + this->initContextMenus(); + // do this as last statement, so it can be used as flag // whether init has been completed this->m_init = true; } +// +// GUI +// +void MainWindow::initGuiSignals() +{ + bool connected; + + // Remark: With new style, only methods of same signature can be connected + // This is why we still have some "old" SIGNAL/SLOT connections here + + // MAIN buttons + this->connect(this->ui->sw_MainMiddle, &QStackedWidget::currentChanged, this, &MainWindow::middlePanelChanged); + connected = this->connect(this->ui->pb_MainAircrafts, SIGNAL(released()), this, SLOT(setMainPage())); + Q_ASSERT(connected); + connected = this->connect(this->ui->pb_MainAtc, SIGNAL(released()), this, SLOT(setMainPage())); + Q_ASSERT(connected); + connected = this->connect(this->ui->pb_MainCockpit, SIGNAL(released()), this, SLOT(setMainPage())); + Q_ASSERT(connected); + connected = this->connect(this->ui->pb_MainConnect, SIGNAL(released()), this, SLOT(setMainPage())); + Q_ASSERT(connected); + connected = this->connect(this->ui->pb_MainConnect, SIGNAL(released()), this, SLOT(toggleNetworkConnection())); + Q_ASSERT(connected); + connected = this->connect(this->ui->pb_MainFlightplan, SIGNAL(released()), this, SLOT(setMainPage())); + Q_ASSERT(connected); + connected = this->connect(this->ui->pb_MainSettings, SIGNAL(released()), this, SLOT(setMainPage())); + Q_ASSERT(connected); + connected = this->connect(this->ui->pb_MainStatus, SIGNAL(released()), this, SLOT(setMainPage())); + Q_ASSERT(connected); + connected = this->connect(this->ui->pb_MainTextMessages, SIGNAL(released()), this, SLOT(setMainPage())); + Q_ASSERT(connected); + connected = this->connect(this->ui->pb_MainWeather, SIGNAL(released()), this, SLOT(setMainPage())); + Q_ASSERT(connected); + this->connect(this->ui->pb_MainKeypadOpacity050, &QPushButton::clicked, this, &MainWindow::changeWindowOpacity); + this->connect(this->ui->pb_MainKeypadOpacity100, &QPushButton::clicked, this, &MainWindow::changeWindowOpacity); + + // Sound buttons + this->connect(this->ui->pb_SoundMute, &QPushButton::clicked, this, &MainWindow::audioVolumes); + this->connect(this->ui->pb_SoundMaxVolume, &QPushButton::clicked, this, &MainWindow::audioVolumes); + connected = this->connect(this->ui->di_CockpitCom1Volume, &QDial::valueChanged, this, &MainWindow::audioVolumes); + connected = this->connect(this->ui->di_CockpitCom2Volume, &QDial::valueChanged, this, &MainWindow::audioVolumes); + + // menu + this->connect(this->ui->menu_ReloadSettings, &QAction::triggered, this, &MainWindow::menuClicked); + this->connect(this->ui->menu_TestLocationsEDDF, &QAction::triggered, this, &MainWindow::menuClicked); + this->connect(this->ui->menu_TestLocationsEDDM, &QAction::triggered, this, &MainWindow::menuClicked); + this->connect(this->ui->menu_TestLocationsEDNX, &QAction::triggered, this, &MainWindow::menuClicked); + this->connect(this->ui->menu_TestLocationsEDRY, &QAction::triggered, this, &MainWindow::menuClicked); + this->connect(this->ui->menu_FileClose, &QAction::triggered, this, &MainWindow::menuClicked); + + // command line + this->connect(this->ui->le_CommandLineInput, &QLineEdit::returnPressed, this, &MainWindow::commandEntered); + + // cockpit + connected = this->connect(this->ui->cb_CockpitTransponderMode, SIGNAL(currentIndexChanged(QString)), + this, SLOT(cockpitValuesChanged())); + Q_ASSERT(connected); + this->connect(this->ui->ds_CockpitCom1Active, &QDoubleSpinBox::editingFinished, this, &MainWindow::cockpitValuesChanged); + this->connect(this->ui->ds_CockpitCom2Active, &QDoubleSpinBox::editingFinished, this, &MainWindow::cockpitValuesChanged); + this->connect(this->ui->ds_CockpitCom1Standby, &QDoubleSpinBox::editingFinished, this, &MainWindow::cockpitValuesChanged); + this->connect(this->ui->ds_CockpitCom2Standby, &QDoubleSpinBox::editingFinished, this, &MainWindow::cockpitValuesChanged); + this->connect(this->ui->ds_CockpitTransponder, &QDoubleSpinBox::editingFinished, this, &MainWindow::cockpitValuesChanged); + + this->connect(this->ui->cb_CockpitVoiceRoom1Override, &QCheckBox::clicked, this, &MainWindow::voiceRoomOverride); + this->connect(this->ui->cb_CockpitVoiceRoom2Override, &QCheckBox::clicked, this, &MainWindow::voiceRoomOverride); + this->connect(this->ui->le_CockpitVoiceRoomCom1, &QLineEdit::returnPressed, this, &MainWindow::voiceRoomOverride); + this->connect(this->ui->le_CockpitVoiceRoomCom2, &QLineEdit::returnPressed, this, &MainWindow::voiceRoomOverride); + this->connect(this->ui->pb_CockpitToggleCom1, &QPushButton::clicked, this, &MainWindow::cockpitValuesChanged); + this->connect(this->ui->pb_CockpitToggleCom2, &QPushButton::clicked, this, &MainWindow::cockpitValuesChanged); + this->connect(this->ui->pb_CockpitIdent, &QPushButton::clicked, this, &MainWindow::cockpitValuesChanged); + + // voice + connected = this->connect(this->ui->cb_VoiceInputDevice, SIGNAL(currentIndexChanged(int)), this, SLOT(audioDeviceSelected(int))); + Q_ASSERT(connected); + connected = this->connect(this->ui->cb_VoiceOutputDevice, SIGNAL(currentIndexChanged(int)), this, SLOT(audioDeviceSelected(int))); + Q_ASSERT(connected); + + // ATC + connected = this->connect(this->ui->le_AtcStationsOnlineMetar, SIGNAL(returnPressed()), this, SLOT(getMetar())); + Q_ASSERT(connected); + connected = this->connect(this->ui->pb_AtcStationsLoadMetar, SIGNAL(clicked()), this, SLOT(getMetar())); + Q_ASSERT(connected); + this->connect(this->ui->tw_AtcStations, &QTabWidget::currentChanged, this, &MainWindow::atcStationTabChanged); + this->connect(this->ui->pb_ReloadAtcStationsBooked, &QPushButton::clicked, this, &MainWindow::reloadAtcStationsBooked); + this->connect(this->ui->tv_AtcStationsOnline, &QTableView::clicked, this, &MainWindow::onlineAtcStationSelected); + + // Settings server + this->connect(this->ui->pb_SettingsTnCurrentServer, &QPushButton::released, this, &MainWindow::alterTrafficServer); + this->connect(this->ui->pb_SettingsTnRemoveServer, &QPushButton::released, this, &MainWindow::alterTrafficServer); + this->connect(this->ui->pb_SettingsTnSaveServer, &QPushButton::released, this, &MainWindow::alterTrafficServer); + this->connect(this->ui->tv_SettingsTnServers, &QTableView::clicked, this, &MainWindow::networkServerSelected); + + // Settings + this->connect(this->ui->hs_SettingsGuiOpacity, &QSlider::valueChanged, this, &MainWindow::changeWindowOpacity); + + // no warnings in release build + Q_UNUSED(connected); +} + /* * Init data when started */ diff --git a/samples/blackgui/mainwindow_menus.cpp b/samples/blackgui/mainwindow_menus.cpp new file mode 100644 index 000000000..608a6b645 --- /dev/null +++ b/samples/blackgui/mainwindow_menus.cpp @@ -0,0 +1,86 @@ +#include "mainwindow.h" +#include "ui_mainwindow.h" +#include "blackmisc/statusmessagelist.h" +#include "blackmisc/avaltitude.h" +#include +#include +#include +#include + +using namespace BlackMisc; +using namespace BlackMisc::PhysicalQuantities; +using namespace BlackMisc::Aviation; + +/* + * Menu clicked + */ +void MainWindow::menuClicked() +{ + QObject *sender = QObject::sender(); + CStatusMessageList msgs; + + if (sender == this->ui->menu_TestLocationsEDRY) + { + this->setTestPosition("N 049° 18' 17", "E 008° 27' 05", CAltitude(312, CAltitude::MeanSeaLevel, CLengthUnit::ft())); + } + else if (sender == this->ui->menu_TestLocationsEDNX) + { + this->setTestPosition("N 048° 14′ 22", "E 011° 33′ 41", CAltitude(486, CAltitude::MeanSeaLevel, CLengthUnit::m())); + } + else if (sender == this->ui->menu_TestLocationsEDDM) + { + this->setTestPosition("N 048° 21′ 14", "E 011° 47′ 10", CAltitude(448, CAltitude::MeanSeaLevel, CLengthUnit::m())); + } + else if (sender == this->ui->menu_TestLocationsEDDF) + { + this->setTestPosition("N 50° 2′ 0", "E 8° 34′ 14", CAltitude(100, CAltitude::MeanSeaLevel, CLengthUnit::m())); + } + else if (sender == this->ui->menu_ReloadSettings) + { + this->reloadSettings(); + msgs.insert(CStatusMessage::getInfoMessage("Settings reloaded")); + } + else if (sender == this->ui->menu_FileClose) + { + msgs.insert(CStatusMessage::getInfoMessage("Closing")); + this->close(); + } + if (!msgs.isEmpty()) this->displayStatusMessages(msgs); +} + +/* + * Reload settings + */ +void MainWindow::initContextMenus() +{ + this->ui->lbl_VoiceStatus->setContextMenuPolicy(Qt::CustomContextMenu); + connect(this->ui->lbl_VoiceStatus, SIGNAL(customContextMenuRequested(const QPoint &)), + this, SLOT(audioIconContextMenu(const QPoint &))); +} + +/* + * Reload settings + */ +void MainWindow::audioIconContextMenu(const QPoint &position) +{ + // for most widgets + QPoint globalPosition = this->ui->lbl_VoiceStatus->mapToGlobal(position); + + if (!this->m_contextMenuAudio) + { + this->m_contextMenuAudio = new QMenu(this); + if (QSysInfo::WindowsVersion && QSysInfo::WV_NT_based) + { + this->m_contextMenuAudio->addAction("Mixer"); + } + } + + QAction *selectedItem = this->m_contextMenuAudio->exec(globalPosition); + if (selectedItem) + { + // http://forum.technical-assistance.co.uk/sndvol32exe-command-line-parameters-vt1348.html + const QList actions = this->m_contextMenuAudio->actions(); + QStringList parameterlist; + if (selectedItem == actions.at(0)) QProcess::startDetached("SndVol.exe", parameterlist); + } +} diff --git a/samples/blackgui/mainwindow_settings.cpp b/samples/blackgui/mainwindow_settings.cpp index ffee45264..93b296976 100644 --- a/samples/blackgui/mainwindow_settings.cpp +++ b/samples/blackgui/mainwindow_settings.cpp @@ -24,6 +24,8 @@ void MainWindow::reloadSettings() // update servers this->m_trafficServerList->setSelectedServer(nws.getCurrentNetworkServer()); this->m_trafficServerList->update(nws.getTrafficNetworkServers()); + this->ui->tv_SettingsTnServers->resizeColumnsToContents(); + this->ui->tv_SettingsTnServers->resizeRowsToContents(); } /* diff --git a/samples/blackgui/mainwindow_textmessages.cpp b/samples/blackgui/mainwindow_textmessages.cpp index e269fb7e1..c85140a7c 100644 --- a/samples/blackgui/mainwindow_textmessages.cpp +++ b/samples/blackgui/mainwindow_textmessages.cpp @@ -11,33 +11,89 @@ using namespace BlackMisc::Geo; using namespace BlackMisc::Settings; /* - * Text messages received + * Text messages received or send, append to GUI */ -void MainWindow::textMessageReceived(const CTextMessageList &messages, bool sending) +void MainWindow::appendTextMessagesToGui(const CTextMessageList &messages, bool sending) { if (messages.isEmpty()) return; foreach(CTextMessage message, messages) { + bool relevantForMe = false; QString m = message.asString(true, true, "\t"); - this->ui->te_TextMessagesAll->append(m); - m = message.asString(true, false, "\t"); - if (message.isSendToUnicom()) this->ui->te_TextMessagesUnicom->append(m); - // check for own COM frequencies - if (message.isRadioMessage()) + if (message.isSendToUnicom()) { - if (message.isSendToFrequency(this->m_ownAircraft.getCom1System().getFrequencyActive())) - this->ui->te_TextMessagesCOM1->append(m); - if (message.isSendToFrequency(this->m_ownAircraft.getCom2System().getFrequencyActive())) - this->ui->te_TextMessagesCOM2->append(m); + this->ui->te_TextMessagesUnicom->append(m); + relevantForMe = true; } - // individual channel text messages - if (message.isPrivateMessage()) this->addPrivateChannelTextMessage(message, sending); + // check message + if (message.isRadioMessage()) + { + // check for own COM frequencies + if (message.isSendToFrequency(this->m_ownAircraft.getCom1System().getFrequencyActive())) + { + this->ui->te_TextMessagesCOM1->append(m); + relevantForMe = true; + } + if (message.isSendToFrequency(this->m_ownAircraft.getCom2System().getFrequencyActive())) + { + this->ui->te_TextMessagesCOM2->append(m); + relevantForMe = true; + } + } + else if (message.isPrivateMessage() && !message.isServerMessage()) + { + // private message + this->addPrivateChannelTextMessage(message, sending); + relevantForMe = true; + } + + // message for me? right frequency? otherwise quit + if (relevantForMe || message.isServerMessage()) this->ui->te_TextMessagesAll->append(m); + if (!relevantForMe) return; + + // overlay message if this channel is not selected + if (!sending && !message.isSendToUnicom() && !message.isServerMessage()) + { + // if the channel is selected, do nothing + if (!this->isCorrespondingTextMessageTabSelected(message)) + this->displayOverlayInfo(m); + } } } +/* + * Is the tab of the message's receiver selected? + */ +bool MainWindow::isCorrespondingTextMessageTabSelected(CTextMessage textMessage) const +{ + if (!this->isMainPageSelected(MainPageTextMessages)) return false; + if (!textMessage.hasValidRecipient()) return false; + if (textMessage.isEmpty()) return false; // ignore empty message + if (textMessage.isPrivateMessage()) + { + // private message + CCallsign cs = textMessage.getSenderCallsign(); + if (cs.isEmpty()) return false; + QWidget *tab = this->findTextMessageTabByName(cs.getStringAsSet()); + if (!tab) return false; + return this->ui->tw_TextMessages->currentWidget() == tab; + } + else + { + // frequency message + if (this->ui->tw_TextMessages->currentWidget() == this->ui->tb_TextMessagesAll) return true; + if (textMessage.isSendToFrequency(this->m_ownAircraft.getCom1System().getFrequencyActive())) + return this->ui->tw_TextMessages->currentWidget() == this->ui->tb_TextMessagesCOM1; + if (textMessage.isSendToFrequency(this->m_ownAircraft.getCom2System().getFrequencyActive())) + return this->ui->tw_TextMessages->currentWidget() == this->ui->tb_TextMessagesCOM2; + return false; + } +} + + /* * Add new text message tab */ @@ -47,6 +103,9 @@ QWidget *MainWindow::addNewTextMessageTab(const QString &tabName) QPushButton *closeButton = new QPushButton("Close", newTab); QVBoxLayout *layout = new QVBoxLayout(newTab); QTextEdit *textEdit = new QTextEdit(newTab); + int marginLeft, marginRight, marginTop, marginBottom; + this->ui->tb_TextMessagesAll->layout()->getContentsMargins(&marginLeft, &marginTop, &marginRight, &marginBottom); + newTab->layout()->setContentsMargins(marginLeft, marginTop, marginRight, 2); textEdit->setReadOnly(true); textEdit->setWordWrapMode(QTextOption::NoWrap); layout->addWidget(textEdit); @@ -64,7 +123,7 @@ QWidget *MainWindow::addNewTextMessageTab(const QString &tabName) void MainWindow::addPrivateChannelTextMessage(const CTextMessage &textMessage, bool sending) { if (!textMessage.isPrivateMessage()) return; - CCallsign cs = sending ? textMessage.getRecipient() : textMessage.getSender(); + CCallsign cs = sending ? textMessage.getRecipientCallsign() : textMessage.getSenderCallsign(); if (cs.isEmpty()) return; QWidget *tab = this->findTextMessageTabByName(cs.getStringAsSet()); if (tab == nullptr) tab = this->findTextMessageTabByName(cs.asString()); @@ -79,7 +138,7 @@ void MainWindow::addPrivateChannelTextMessage(const CTextMessage &textMessage, b /* * Message tab by name */ -QWidget *MainWindow::findTextMessageTabByName(const QString &name) +QWidget *MainWindow::findTextMessageTabByName(const QString &name) const { if (name.isEmpty()) return nullptr; QString n = name.trimmed(); @@ -94,7 +153,7 @@ QWidget *MainWindow::findTextMessageTabByName(const QString &name) } /* - * Selected tab text + * Text message stub (sender/receiver) for current channel */ CTextMessage MainWindow::getTextMessageStubForChannel() { @@ -104,28 +163,24 @@ CTextMessage MainWindow::getTextMessageStubForChannel() if (index == this->ui->tw_TextMessages->indexOf(this->ui->tb_TextMessagesAll)) return tm; // from - tm.setSender(this->m_ownAircraft.getCallsign()); + tm.setSenderCallsign(this->m_ownAircraft.getCallsign()); - if (index == this->ui->tw_TextMessages->indexOf(this->ui->tb_TextMessagesCOM1) || - index == this->ui->tw_TextMessages->indexOf(this->ui->tb_TextMessagesCOM2) || - index == this->ui->tw_TextMessages->indexOf(this->ui->tb_TextMessagesUnicom)) + // frequency text message? + if (index == this->ui->tw_TextMessages->indexOf(this->ui->tb_TextMessagesCOM1)) { - // frequency text message - if (index == this->ui->tw_TextMessages->indexOf(this->ui->tb_TextMessagesCOM1)) - { - tm.setFrequency(this->m_ownAircraft.getCom1System().getFrequencyActive()); - } - else if (index == this->ui->tw_TextMessages->indexOf(this->ui->tb_TextMessagesCOM2)) - { - tm.setFrequency(this->m_ownAircraft.getCom2System().getFrequencyActive()); - } - else if (index == this->ui->tw_TextMessages->indexOf(this->ui->tb_TextMessagesUnicom)) - { - tm.setFrequency(CPhysicalQuantitiesConstants::FrequencyUnicom()); - } + tm.setFrequency(this->m_ownAircraft.getCom1System().getFrequencyActive()); + } + else if (index == this->ui->tw_TextMessages->indexOf(this->ui->tb_TextMessagesCOM2)) + { + tm.setFrequency(this->m_ownAircraft.getCom2System().getFrequencyActive()); + } + else if (index == this->ui->tw_TextMessages->indexOf(this->ui->tb_TextMessagesUnicom)) + { + tm.setFrequency(CPhysicalQuantitiesConstants::FrequencyUnicom()); } else { + // not a standard channel QString selectedTabText = this->ui->tw_TextMessages->tabText(index); bool isNumber; double frequency = selectedTabText.toDouble(&isNumber); @@ -138,14 +193,14 @@ CTextMessage MainWindow::getTextMessageStubForChannel() } else { - CCallsign recipient(selectedTabText); - tm.setRecipient(recipient); + CCallsign toCallsign(selectedTabText); + tm.setRecipientCallsign(toCallsign); } } else { - CCallsign recipient(selectedTabText); - tm.setRecipient(recipient); + CCallsign toCallsign(selectedTabText); + tm.setRecipientCallsign(toCallsign); } } return tm; // now valid message stub with receiver @@ -176,7 +231,7 @@ void MainWindow::commandEntered() // TODO: just a first draft of the command line parser // needs to be refactored, as soon as a first version works - QString cmdLine = this->ui->le_TextMessagesInput->text().simplified(); + QString cmdLine = this->ui->le_CommandLineInput->text().simplified(); if (cmdLine.isEmpty()) return; QList parts = cmdLine.toLower().split(' '); if (parts.length() < 1) return; @@ -193,9 +248,10 @@ void MainWindow::commandEntered() this->displayStatusMessage(CStatusMessage(CStatusMessage::TypeValidation, CStatusMessage::SeverityError, "incorrect message")); return; } - QString p = parts[1].trimmed(); + QString p = parts[1].trimmed(); // receiver // select current tab by command + this->setMainPage(MainPageTextMessages); if (p == "c1" || p == "com1") { this->ui->tw_TextMessages->setCurrentWidget(this->ui->tb_TextMessagesCOM1); @@ -215,7 +271,7 @@ void MainWindow::commandEntered() this->ui->tw_TextMessages->setCurrentWidget(tab); } CTextMessage tm = this->getTextMessageStubForChannel(); - int index = cmdLine.indexOf(tm.getRecipient().getStringAsSet(), 0, Qt::CaseInsensitive); + int index = cmdLine.indexOf(tm.getRecipientCallsign().getStringAsSet(), 0, Qt::CaseInsensitive); if (index < 0) { this->displayStatusMessage( @@ -224,14 +280,14 @@ void MainWindow::commandEntered() ); return; } - QString msg(cmdLine.mid(index + tm.getRecipient().asString().length() + 1)); + QString msg(cmdLine.mid(index + tm.getRecipientCallsign().asString().length() + 1)); tm.setMessage(msg); if (tm.isEmpty()) return; if (!this->isContextNetworkAvailableCheck()) return; CTextMessageList tml(tm); this->m_contextNetwork->sendTextMessages(tml); - this->textMessageReceived(tml, true); - this->ui->le_TextMessagesInput->setText(""); + this->appendTextMessagesToGui(tml, true); + this->ui->le_CommandLineInput->setText(""); } else if (cmd.startsWith(".")) { @@ -240,13 +296,19 @@ void MainWindow::commandEntered() else { // single line, no command - // just send + // line is considered to be a message to the selected channel, send if (!this->m_contextNetwork->isConnected()) { this->displayStatusMessage(CStatusMessage(CStatusMessage::TypeTrafficNetwork, CStatusMessage::SeverityError, "network needs to be connected")); return; } + if (!this->isMainPageSelected(MainPageTextMessages)) + { + this->displayStatusMessage(CStatusMessage(CStatusMessage::TypeTrafficNetwork, CStatusMessage::SeverityError, "text messages can only be sent from corresponding page")); + return; + } + int index = this->ui->tw_TextMessages->currentIndex(); if (index < 0 || index == this->ui->tw_TextMessages->indexOf(this->ui->tb_TextMessagesAll)) { @@ -258,10 +320,10 @@ void MainWindow::commandEntered() tm.setMessage(cmdLine); if (tm.isEmpty()) return; if (!this->isContextNetworkAvailableCheck()) return; - CTextMessageList tml(tm); - this->m_contextNetwork->sendTextMessages(tml); - this->textMessageReceived(tml, true); - this->ui->le_TextMessagesInput->setText(""); + CTextMessageList textMessageList(tm); + this->m_contextNetwork->sendTextMessages(textMessageList); + this->appendTextMessagesToGui(textMessageList, true); + this->ui->le_CommandLineInput->setText(""); } } } diff --git a/samples/blackgui/mainwindow_voice.cpp b/samples/blackgui/mainwindow_voice.cpp index c9d6193dc..c6b6cd22b 100644 --- a/samples/blackgui/mainwindow_voice.cpp +++ b/samples/blackgui/mainwindow_voice.cpp @@ -77,3 +77,71 @@ void MainWindow::audioDeviceSelected(int index) this->m_contextVoice->setCurrentAudioDevice(selectedDevice); } } + +/* + * Select audio device + */ +void MainWindow::audioVolumes() +{ + if (!this->m_contextVoiceAvailable) + { + this->ui->pb_SoundMute->setEnabled(false); + this->ui->pb_SoundMaxVolume->setEnabled(false); + return; + } + + // enable the buttons, as we have a voice context + this->ui->pb_SoundMute->setEnabled(true); + this->ui->pb_SoundMaxVolume->setEnabled(true); + QObject *sender = QObject::sender(); + + CComSystem com1 = this->m_ownAircraft.getCom1System(); + CComSystem com2 = this->m_ownAircraft.getCom2System(); + bool muted; + + if (sender == this->ui->pb_SoundMute) + { + if (this->m_contextVoice->isMuted()) + { + // muted right now, now unmute + muted = false; + } + else + { + // unmuted right now, now mute + muted = true; + } + } + else if (sender == this->ui->pb_SoundMaxVolume) + { + muted = false; + com1.setVolumeOutput(100); + com2.setVolumeOutput(100); + this->ui->di_CockpitCom1Volume->setValue(100); + this->ui->di_CockpitCom2Volume->setValue(100); + } + else if (sender == this->ui->di_CockpitCom1Volume || + sender == this->ui->di_CockpitCom2Volume) + { + muted = false; + com1.setVolumeOutput(this->ui->di_CockpitCom1Volume->value()); + com2.setVolumeOutput(this->ui->di_CockpitCom2Volume->value()); + } + else + { + return; + } + + // mute / umute + com1.setEnabled(!muted); + com2.setEnabled(!muted); + this->ui->pb_SoundMute->setText(muted ? "Unmute" : "Mute"); + this->ui->lbl_VoiceStatus->setPixmap(muted ? this->m_resPixmapVoiceMuted : this->m_resPixmapVoiceHigh); + this->ui->pb_SoundMute->setStyleSheet(muted ? "background-color: red;" : ""); + if (muted) this->displayOverlayInfo("Sound is muted!"); + + // update own aircraft, also set volume/mute in voice + this->m_ownAircraft.setCom1System(com1); + this->m_ownAircraft.setCom1System(com2); + this->m_contextVoice->setVolumes(this->m_ownAircraft.getCom1System(), this->m_ownAircraft.getCom1System()); +}