diff --git a/samples/blackcore/main.cpp b/samples/blackcore/main.cpp index b52e86591..75e4ab9d0 100644 --- a/samples/blackcore/main.cpp +++ b/samples/blackcore/main.cpp @@ -8,6 +8,7 @@ #include "blackcore/context_settings.h" #include "blackcore/context_application.h" #include "blackcore/context_application_impl.h" +#include "blackmisc/iconsstandard.h" #include "blackmisc/networkutils.h" #include "blackmisc/blackmiscfreefunctions.h" #include "blackmisc/project.h" @@ -26,7 +27,7 @@ int main(int argc, char *argv[]) { // metadata are registered in runtime QApplication a(argc, argv); // not QCoreApplication because of icon, http://qt-project.org/forums/viewthread/15412 - QIcon icon(":/blackcore/icons/tower.png"); + QIcon icon(BlackMisc::CIconsStandard::swiftNova24()); QApplication::setWindowIcon(icon); QTextStream cin(stdin); diff --git a/samples/blackcore/sample_blackcore.pro b/samples/blackcore/sample_blackcore.pro index 05c5cf3ad..dcae83a78 100644 --- a/samples/blackcore/sample_blackcore.pro +++ b/samples/blackcore/sample_blackcore.pro @@ -33,7 +33,7 @@ DESTDIR = ../../bin HEADERS += *.h SOURCES += *.cpp OTHER_FILES += readme.txt blackcore.rc blackcore.ico -RESOURCES += blackcore.qrc +RESOURCES += win32: RC_FILE = blackcore.rc include (../../libraries.pri) diff --git a/samples/blackgui/main.cpp b/samples/blackgui/main.cpp index 93638d6bc..4a270d11d 100644 --- a/samples/blackgui/main.cpp +++ b/samples/blackgui/main.cpp @@ -1,16 +1,20 @@ #include "introwindow.h" #include "mainwindow.h" #include "guimodeenums.h" +#include "blackgui/stylesheetutility.h" #include "blackcore/blackcorefreefunctions.h" #include "blackcore/context_runtime_config.h" #include "blacksim/blacksimfreefunctions.h" #include "blackmisc/blackmiscfreefunctions.h" +#include "blackmisc/iconsstandard.h" #include #include #include #include +using namespace BlackGui; + /*! * \brief Main * \param argc @@ -20,13 +24,13 @@ int main(int argc, char *argv[]) { // register - Q_INIT_RESOURCE(blackgui); BlackMisc::initResources(); BlackMisc::registerMetadata(); BlackSim::registerMetadata(); BlackCore::registerMetadata(); // BlackMisc::displayAllUserMetatypesTypes(); + // Translations QFile file(":blackmisc/translations/blackmisc_i18n_de.qm"); qDebug() << (file.exists() ? "Found translations in resources" : "No translations in resources"); QTranslator translator; @@ -35,9 +39,18 @@ int main(int argc, char *argv[]) qDebug() << "Translator loaded"; } - // app + // application QApplication a(argc, argv); + QIcon icon(BlackMisc::CIconsStandard::swift24()); + QApplication::setWindowIcon(icon); + const QString s = CStyleSheetUtility::instance().styles( + { + CStyleSheetUtility::fileNameFonts(), + CStyleSheetUtility::fileNameMainWindow() + } + ); a.installTranslator(&translator); + a.setStyleSheet(s); // modes GuiModes::WindowMode windowMode; @@ -45,6 +58,7 @@ int main(int argc, char *argv[]) // Dialog to decide external or internal core CIntroWindow intro; + intro.setWindowIcon(icon); BlackCore::CRuntimeConfig runtimeConfig; if (intro.exec() == QDialog::Rejected) { diff --git a/samples/blackgui/mainwindow.cpp b/samples/blackgui/mainwindow.cpp index dd9af668c..ecd2c97b9 100644 --- a/samples/blackgui/mainwindow.cpp +++ b/samples/blackgui/mainwindow.cpp @@ -1,6 +1,9 @@ #include "mainwindow.h" #include "ui_mainwindow.h" -#include "blackgui/atcstationlistmodel.h" +#include "blackmisc/iconsstandard.h" +#include "blackmisc/iconsnetwork.h" +#include "blackgui/stylesheetutility.h" +#include "blackgui/models/atcstationlistmodel.h" #include "blackcore/dbus_server.h" #include "blackcore/context_network.h" #include "blackcore/context_application.h" @@ -11,6 +14,7 @@ using namespace BlackCore; using namespace BlackMisc; using namespace BlackGui; +using namespace BlackGui::Components; using namespace BlackMisc::Network; using namespace BlackMisc::Aviation; using namespace BlackMisc::PhysicalQuantities; @@ -51,7 +55,6 @@ MainWindow::MainWindow(GuiModes::WindowMode windowMode, QWidget *parent) : // GUI ui->setupUi(this); this->m_compInfoWindow = new CInfoWindowComponent(this); // setupUi has to be first! - } /* @@ -99,7 +102,7 @@ void MainWindow::gracefulShutdown() } if (this->getIContextSimulator()) - this->disconnect(this->getIContextSimulator(), &IContextSimulator::connectionChanged, this, &MainWindow::simulatorConnectionChanged); + this->disconnect(this->getIContextSimulator(), &IContextSimulator::connectionChanged, this, &MainWindow::ps_onSimulatorConnectionChanged); } /* @@ -139,7 +142,7 @@ void MainWindow::mousePressEvent(QMouseEvent *event) /* * Select correct main page */ -void MainWindow::setMainPage(bool start) +void MainWindow::ps_setMainPage(bool start) { if (start) { @@ -150,28 +153,55 @@ 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(MainPageStatus); - else if (sender == this->ui->pb_MainAtc) - this->ui->sw_MainMiddle->setCurrentIndex(MainPageAtc); - else if (sender == this->ui->pb_MainAircrafts) - this->ui->sw_MainMiddle->setCurrentIndex(MainPageAircrafts); else if (sender == this->ui->pb_MainCockpit) this->ui->sw_MainMiddle->setCurrentIndex(MainPageCockpit); - else if (sender == this->ui->pb_MainUsers) - this->ui->sw_MainMiddle->setCurrentIndex(MainPageUsers); - else if (sender == this->ui->pb_MainTextMessages) - this->ui->sw_MainMiddle->setCurrentIndex(MainPageTextMessages); - else if (sender == this->ui->pb_MainFlightplan) - this->ui->sw_MainMiddle->setCurrentIndex(MainPageFlightplan); - else if (sender == this->ui->pb_MainSettings) - this->ui->sw_MainMiddle->setCurrentIndex(MainPageSettings); - else if (sender == this->ui->pb_MainSimulator) - this->ui->sw_MainMiddle->setCurrentIndex(MainPageSimulator); + else + { + this->ui->sw_MainMiddle->setCurrentIndex(MainPageFoo); + + if (sender == this->ui->pb_MainAircrafts) + { + this->ui->comp_MainInfoArea->selectArea(CMainInfoAreaComponent::InfoAreaAircrafts); + } + if (sender == this->ui->pb_MainAtc) + { + this->ui->comp_MainInfoArea->selectArea(CMainInfoAreaComponent::InfoAreaAtc); + } + else if (sender == this->ui->pb_MainUsers) + { + this->ui->comp_MainInfoArea->selectArea(CMainInfoAreaComponent::InfoAreaUsers); + } + else if (sender == this->ui->pb_MainTextMessages) + { + this->ui->comp_MainInfoArea->selectArea(CMainInfoAreaComponent::InfoAreaTextMessages); + } + else if (sender == this->ui->pb_MainFlightplan) + { + this->ui->comp_MainInfoArea->selectArea(CMainInfoAreaComponent::InfoAreaFlightPlan); + } + else if (sender == this->ui->pb_MainSettings) + { + this->ui->comp_MainInfoArea->selectArea(CMainInfoAreaComponent::InfoAreaSettings); + } + else if (sender == this->ui->pb_MainSimulator) + { + this->ui->comp_MainInfoArea->selectArea(CMainInfoAreaComponent::InfoAreaSimulator); + } + else if (sender == this->ui->pb_MainWeather) + { + this->ui->comp_MainInfoArea->selectArea(CMainInfoAreaComponent::InfoAreaWeather); + } + else if (sender == this->ui->pb_MainMappings) + { + this->ui->comp_MainInfoArea->selectArea(CMainInfoAreaComponent::InfoAreaMappings); + } + } } /* * Set main page */ -void MainWindow::setMainPage(MainWindow::MainPageIndex mainPage) +void MainWindow::ps_setMainPage(MainWindow::MainPageIndex mainPage) { this->ui->sw_MainMiddle->setCurrentIndex(mainPage); } @@ -187,38 +217,38 @@ bool MainWindow::isMainPageSelected(MainWindow::MainPageIndex mainPage) const /* * Connect to Network */ -void MainWindow::toggleNetworkConnection() +void MainWindow::ps_toggleNetworkConnection() { CStatusMessageList msgs; if (!this->isContextNetworkAvailableCheck()) return; - this->ui->lbl_StatusNetworkConnectedIcon->setPixmap(this->m_resPixmapConnectionConnecting); + this->ui->lbl_StatusNetworkConnectedIcon->setPixmap(CIconsNetworkAndAviation::statusTransition()); if (!this->getIContextNetwork()->isConnected()) { // validation of data here is not required, network context does this // in prephase of login - this->m_ownAircraft.setCallsign(this->ui->comp_Settings->getOwnCallsignFromGui()); + this->m_ownAircraft.setCallsign(this->ui->comp_MainInfoArea->getSettingsComponent()->getOwnCallsignFromGui()); CAircraftIcao icao = this->m_ownAircraft.getIcaoInfo(); - this->ui->comp_Settings->setOwnAircraftIcaoDataFromGui(icao); + this->ui->comp_MainInfoArea->getSettingsComponent()->setOwnAircraftIcaoDataFromGui(icao); this->m_ownAircraft.setIcaoInfo(icao); // set latest aircraft this->getIContextOwnAircraft()->updateOwnAircraft(this->m_ownAircraft, MainWindow::sampleBlackGuiOriginator()); // flight plan - this->ui->comp_Flightplan->prefillWithAircraftData(this->m_ownAircraft); + this->ui->comp_MainInfoArea->getFlightPlanComponent()->prefillWithAircraftData(this->m_ownAircraft); // Login is based on setting current server INetwork::LoginMode mode = INetwork::LoginNormal; - if (this->ui->comp_Settings->loginStealth()) + if (this->ui->comp_MainInfoArea->getSettingsComponent()->loginStealth()) { mode = INetwork::LoginStealth; - this->displayStatusMessage(CStatusMessage::getInfoMessage("login in stealth mode")); + this->ps_displayStatusMessageInGui(CStatusMessage::getInfoMessage("login in stealth mode")); } - else if (this->ui->comp_Settings->loginAsObserver()) + else if (this->ui->comp_MainInfoArea->getSettingsComponent()->loginAsObserver()) { mode = INetwork::LoginAsObserver; - this->displayStatusMessage(CStatusMessage::getInfoMessage("login in observer mode")); + this->ps_displayStatusMessageInGui(CStatusMessage::getInfoMessage("login in observer mode")); } msgs = this->getIContextNetwork()->connectToNetwork(static_cast(mode)); } @@ -229,7 +259,7 @@ void MainWindow::toggleNetworkConnection() if (this->m_contextAudioAvailable) this->getIContextAudio()->leaveAllVoiceRooms(); msgs = this->getIContextNetwork()->disconnectFromNetwork(); } - if (!msgs.isEmpty()) this->displayStatusMessages(msgs); + if (!msgs.isEmpty()) this->ps_displayStatusMessagesInGui(msgs); } /* @@ -238,7 +268,7 @@ void MainWindow::toggleNetworkConnection() bool MainWindow::isContextNetworkAvailableCheck() { if (this->m_contextNetworkAvailable) return true; - this->displayStatusMessage(CStatusMessage(CStatusMessage::TypeCore, CStatusMessage::SeverityError, "Network context not available, no updates this time")); + this->ps_displayStatusMessageInGui(CStatusMessage(CStatusMessage::TypeCore, CStatusMessage::SeverityError, "Network context not available, no updates this time")); return false; } @@ -248,14 +278,14 @@ bool MainWindow::isContextNetworkAvailableCheck() bool MainWindow::isContextAudioAvailableCheck() { if (this->m_contextAudioAvailable) return true; - this->displayStatusMessage(CStatusMessage(CStatusMessage::TypeCore, CStatusMessage::SeverityError, "Voice context not available")); + this->ps_displayStatusMessageInGui(CStatusMessage(CStatusMessage::TypeCore, CStatusMessage::SeverityError, "Voice context not available")); return false; } /* * Display a status message */ -void MainWindow::displayStatusMessage(const CStatusMessage &statusMessage) +void MainWindow::ps_displayStatusMessageInGui(const CStatusMessage &statusMessage) { if (!this->m_init) return; this->ui->sb_MainStatusBar->show(); @@ -274,12 +304,12 @@ void MainWindow::displayStatusMessage(const CStatusMessage &statusMessage) /* * Display a status message */ -void MainWindow::displayStatusMessages(const CStatusMessageList &messages) +void MainWindow::ps_displayStatusMessagesInGui(const CStatusMessageList &messages) { if (!this->m_init || messages.isEmpty()) return; foreach(CStatusMessage msg, messages) { - this->displayStatusMessage(msg); + this->ps_displayStatusMessageInGui(msg); } } @@ -290,16 +320,16 @@ void MainWindow::displayRedirectedOutput(const CStatusMessage &statusMessage, qi this->ui->te_StatusPageConsole->appendHtml(statusMessage.toHtml()); } -void MainWindow::changedSetttings(uint typeValue) +void MainWindow::ps_onChangedSetttings(uint typeValue) { IContextSettings::SettingsType type = static_cast(typeValue); - if (type == IContextSettings::SettingsHotKeys) this->registerHotkeys(); + if (type == IContextSettings::SettingsHotKeys) this->ps_registerHotkeys(); } /* * Connection terminated */ -void MainWindow::connectionTerminated() +void MainWindow::ps_onConnectionTerminated() { this->updateGuiStatusInformation(); } @@ -307,7 +337,7 @@ void MainWindow::connectionTerminated() /* * Connection status changed */ -void MainWindow::connectionStatusChanged(uint /** from **/, uint to, const QString & /* message */) +void MainWindow::ps_onConnectionStatusChanged(uint /** from **/, uint to, const QString & /* message */) { this->updateGuiStatusInformation(); INetwork::ConnectionStatus newStatus = static_cast(to); @@ -332,7 +362,7 @@ void MainWindow::connectionStatusChanged(uint /** from **/, uint to, const QStri /* * Timer event */ -void MainWindow::timerBasedUpdates() +void MainWindow::ps_handleTimerBasedUpdates() { QObject *sender = QObject::sender(); if (sender == this->m_timerContextWatchdog) @@ -346,7 +376,7 @@ void MainWindow::timerBasedUpdates() } // own aircraft - this->reloadOwnAircraft(); // regular updates + this->ps_reloadOwnAircraft(); // regular updates } /* @@ -398,21 +428,21 @@ void MainWindow::updateGuiStatusInformation() this->ui->lbl_StatusNetworkConnectedIcon->setToolTip(now); this->ui->pb_MainConnect->setText("Disconnect"); this->ui->pb_MainConnect->setStyleSheet("background-color: green"); - this->ui->lbl_StatusNetworkConnectedIcon->setPixmap(this->m_resPixmapConnectionConnected); + this->ui->lbl_StatusNetworkConnectedIcon->setPixmap(CIconsNetworkAndAviation::statusConnected()); } else { this->ui->lbl_StatusNetworkConnectedIcon->setToolTip("disconnected"); this->ui->pb_MainConnect->setText("Connect"); this->ui->pb_MainConnect->setStyleSheet("background-color: "); - this->ui->lbl_StatusNetworkConnectedIcon->setPixmap(this->m_resPixmapConnectionDisconnected); + this->ui->lbl_StatusNetworkConnectedIcon->setPixmap(CIconsNetworkAndAviation::statusDisconnected()); } } /* * Opacity 0-100 */ -void MainWindow::changeWindowOpacity(int opacity) +void MainWindow::ps_changeWindowOpacity(int opacity) { if (opacity < 0) { @@ -427,7 +457,7 @@ void MainWindow::changeWindowOpacity(int opacity) qreal o = opacity / 100.0; o = o < 0.3 ? 0.3 : o; QWidget::setWindowOpacity(o); - this->ui->comp_Settings->setGuiOpacity(o * 100.0); + this->ui->comp_MainInfoArea->getSettingsComponent()->setGuiOpacity(o * 100.0); } void MainWindow::updateSimulatorData() @@ -453,7 +483,7 @@ void MainWindow::updateSimulatorData() ui->le_SimulatorTransponder->setText(ownAircraft.getTransponderCodeFormatted()); } -void MainWindow::simulatorConnectionChanged(bool isAvailable) +void MainWindow::ps_onSimulatorConnectionChanged(bool isAvailable) { // Simulator timer, TODO remove later if (isAvailable) @@ -465,20 +495,20 @@ void MainWindow::simulatorConnectionChanged(bool isAvailable) /* * Stay on top */ -void MainWindow::toogleWindowStayOnTop() +void MainWindow::ps_toogleWindowStayOnTop() { Qt::WindowFlags flags = this->windowFlags(); if (Qt::WindowStaysOnTopHint & flags) { flags ^= Qt::WindowStaysOnTopHint; flags |= Qt::WindowStaysOnBottomHint; - this->displayStatusMessage(CStatusMessage(CStatusMessage::TypeGui, CStatusMessage::SeverityInfo, "Window on bottom")); + this->ps_displayStatusMessageInGui(CStatusMessage(CStatusMessage::TypeGui, CStatusMessage::SeverityInfo, "Window on bottom")); } else { flags ^= Qt::WindowStaysOnBottomHint; flags |= Qt::WindowStaysOnTopHint; - this->displayStatusMessage(CStatusMessage(CStatusMessage::TypeGui, CStatusMessage::SeverityInfo, "Window on top")); + this->ps_displayStatusMessageInGui(CStatusMessage(CStatusMessage::TypeGui, CStatusMessage::SeverityInfo, "Window on top")); } this->setWindowFlags(flags); this->show(); @@ -487,7 +517,7 @@ void MainWindow::toogleWindowStayOnTop() /* * Hotkeys */ -void MainWindow::registerHotkeys() +void MainWindow::ps_registerHotkeys() { if (!this->getIContextSettings()) qFatal("Missing settings"); if (!this->m_keyboard) @@ -503,11 +533,25 @@ void MainWindow::registerHotkeys() if (keys.isEmpty()) return; CKeyboardKey key = keys.keyForFunction(CKeyboardKey::HotkeyOpacity50); - if (!key.isEmpty()) this->m_keyboard->registerHotkey(key, this, [ this ](bool isPressed) { if (isPressed) this->changeWindowOpacity(50); }); + if (!key.isEmpty()) this->m_keyboard->registerHotkey(key, this, [ this ](bool isPressed) { if (isPressed) this->ps_changeWindowOpacity(50); }); key = keys.keyForFunction(CKeyboardKey::HotkeyOpacity100); - if (!key.isEmpty()) this->m_keyboard->registerHotkey(key, this, [ this ](bool isPressed) { if (isPressed) this->changeWindowOpacity(100); }); + if (!key.isEmpty()) this->m_keyboard->registerHotkey(key, this, [ this ](bool isPressed) { if (isPressed) this->ps_changeWindowOpacity(100); }); key = keys.keyForFunction(CKeyboardKey::HotkeyToogleWindowsStayOnTop); - if (!key.isEmpty()) this->m_keyboard->registerHotkey(key, this, [ this ](bool isPressed) { if (isPressed) this->toogleWindowStayOnTop(); }); + if (!key.isEmpty()) this->m_keyboard->registerHotkey(key, this, [ this ](bool isPressed) { if (isPressed) this->ps_toogleWindowStayOnTop(); }); +} + +/* + * Styles + */ +void MainWindow::ps_onStyleSheetsChanged() +{ + const QString s = CStyleSheetUtility::instance().styles( + { + CStyleSheetUtility::fileNameFonts(), + CStyleSheetUtility::fileNameMainWindow() + } + ); + this->setStyleSheet(s); } diff --git a/samples/blackgui/mainwindow.h b/samples/blackgui/mainwindow.h index 34b02078c..85c997b4c 100644 --- a/samples/blackgui/mainwindow.h +++ b/samples/blackgui/mainwindow.h @@ -18,15 +18,15 @@ #include "blackcore/context_application.h" #include "blackcore/context_simulator.h" #include "blackcore/context_runtime.h" -#include "blackgui/runtimebasedcomponent.h" +#include "blackgui/components/runtimebasedcomponent.h" +#include "blackgui/components/infowindowcomponent.h" #include "blackgui/transpondermodeselector.h" -#include "blackgui/atcstationlistmodel.h" -#include "blackgui/serverlistmodel.h" -#include "blackgui/aircraftlistmodel.h" -#include "blackgui/userlistmodel.h" -#include "blackgui/statusmessagelistmodel.h" -#include "blackgui/keyboardkeylistmodel.h" -#include "blackgui/infowindowcomponent.h" +#include "blackgui/models/atcstationlistmodel.h" +#include "blackgui/models/serverlistmodel.h" +#include "blackgui/models/aircraftlistmodel.h" +#include "blackgui/models/userlistmodel.h" +#include "blackgui/models/statusmessagelistmodel.h" +#include "blackgui/models/keyboardkeylistmodel.h" #include "blackmisc/nwtextmessage.h" #include "blacksound/soundgenerator.h" #include @@ -38,10 +38,8 @@ namespace Ui { class MainWindow; } -/*! - * \brief GUI - */ -class MainWindow : public QMainWindow, public BlackGui::CRuntimeBasedComponent +//! swift GUI +class MainWindow : public QMainWindow, public BlackGui::Components::CRuntimeBasedComponent { Q_OBJECT @@ -73,19 +71,13 @@ protected: enum MainPageIndex { MainPageStatus = 0, - MainPageAtc = 1, - MainPageAircrafts = 2, - MainPageUsers = 3, MainPageCockpit = 4, - MainPageTextMessages = 5, - MainPageFlightplan = 6, - MainPageSettings = 7, - MainPageSimulator = 8 + MainPageFoo = 9 }; private: QScopedPointer ui; - BlackGui::CInfoWindowComponent *m_compInfoWindow; + BlackGui::Components::CInfoWindowComponent *m_compInfoWindow; bool m_init; GuiModes::WindowMode m_windowMode; BlackInput::IKeyboard *m_keyboard; //!< hotkeys @@ -99,14 +91,6 @@ private: QTimer *m_timerStatusBar; /*!< cleaning up status bar */ QTimer *m_timerSimulator; /*!< update simulator data */ - // pixmaps - QPixmap m_resPixmapConnectionConnected; - QPixmap m_resPixmapConnectionDisconnected; - QPixmap m_resPixmapConnectionConnecting; - QPixmap m_resPixmapVoiceHigh; - QPixmap m_resPixmapVoiceLow; - QPixmap m_resPixmapVoiceMuted; - // frameless window QPoint m_dragPosition; /*!< position, if moving is handled with frameless window */ @@ -193,29 +177,29 @@ private slots: // //! Reload own aircraft - bool reloadOwnAircraft(); + bool ps_reloadOwnAircraft(); //! Display status message - void displayStatusMessage(const BlackMisc::CStatusMessage &sendStatusMessage); + void ps_displayStatusMessageInGui(const BlackMisc::CStatusMessage &sendStatusMessage); //! Display status messages - void displayStatusMessages(const BlackMisc::CStatusMessageList &messages); + void ps_displayStatusMessagesInGui(const BlackMisc::CStatusMessageList &messages); //! Redirected output void displayRedirectedOutput(const BlackMisc::CStatusMessage &sendStatusMessage, qint64 contextId); //! Settings have been changed - void changedSetttings(uint typeValue); + void ps_onChangedSetttings(uint typeValue); /*! * \brief Connection status changed * \param from old status, as uint so it is compliant with DBus * \param to new status, as uint so it is compliant with DBus */ - void connectionStatusChanged(uint from, uint to, const QString &message); + void ps_onConnectionStatusChanged(uint from, uint to, const QString &message); //! Simulator available - void simulatorConnectionChanged(bool isAvailable); + void ps_onSimulatorConnectionChanged(bool isAvailable); // // GUI related slots @@ -225,43 +209,46 @@ private slots: * \brief Set the main page * \param start Startup phase */ - void setMainPage(bool start = false); + void ps_setMainPage(bool start = false); /*! * \brief setMainPage * \param mainPage */ - void setMainPage(MainPageIndex mainPage); + void ps_setMainPage(MainPageIndex mainPage); //! Connect to network - void toggleNetworkConnection(); + void ps_toggleNetworkConnection(); //! Menu item clicked - void menuClicked(); + void ps_onMenuClicked(); //! Terminated connection - void connectionTerminated(); + void ps_onConnectionTerminated(); //! Update timer - void timerBasedUpdates(); + void ps_handleTimerBasedUpdates(); //! Audio volume handling and mute - void audioVolumes(); + void ps_setAudioVolumes(); /*! * \brief changeOpacity * \param opacity 0-100 */ - void changeWindowOpacity(int opacity = -1); + void ps_changeWindowOpacity(int opacity = -1); //! Context menu for audio - void audioIconContextMenu(const QPoint &position); + void ps_displayAudioIconContextMenu(const QPoint &position); //! Toogle Windows stay on top - void toogleWindowStayOnTop(); + void ps_toogleWindowStayOnTop(); //! Set the hotkeys - void registerHotkeys(); + void ps_registerHotkeys(); + + //! Style sheet has been changed + void ps_onStyleSheetsChanged(); }; #pragma pop_macro("interface") diff --git a/samples/blackgui/mainwindow.ui b/samples/blackgui/mainwindow.ui index 472fed902..f41a69fdd 100644 --- a/samples/blackgui/mainwindow.ui +++ b/samples/blackgui/mainwindow.ui @@ -26,349 +26,11 @@ 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 **/ -} - -QProgressBar { - border: 1px solid green; - border-radius: 5px; - text-align: center; - padding: 0px; - height: 16px; -} - -QProgressBar::chunk { - background-color: darkblue; - width: 10px; - margin: 0.5px; -} - -#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; -} - -QGroupBox { - border: 1px solid green; - margin-top: 2ex; /* leave space at the top for the title */ -} - -QGroupBox::title { - subcontrol-origin: margin; - subcontrol-position: middle center; /* position at the top center */ - padding: 0 3px; -} - -QToolBox { - border: none; -} - -QToolBox::tab { - border: 1px solid green; - border-radius: 6px; - min-width: 30px; - padding: 2px; - padding-left: 4px; - padding-right: 4px; -} - -QToolBox::tab::selected { - background-color: rgba(0, 0, 255, 128); -} - -QRadioButton { - font: 10px; -} - -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; -} - -QStatusBar { - background: darkslategray; -} - -QStatusBar::item { - border: none; -} - -QStatusBar QLabel { - border: none; -} - + Qt::ToolButtonIconOnly @@ -422,10 +84,7 @@ QStatusBar QLabel { - - - 0 - + 0 @@ -438,7 +97,350 @@ QStatusBar QLabel { 0 - + + + + + 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 + + + + 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 + + + + Text/Chat + + + + + + + + 0 + 0 + + + + + 16777215 + 22 + + + + Flightplan + + + + + + + Users + + + + + + + Ident + + + + + + + Simulator + + + + + + + Foo + + + + + + + + 0 + 0 + + + + + 16777215 + 22 + + + + ATC + + + + + + + + 0 + 0 + + + + + 16777215 + 22 + + + + Aircrafts + + + + + + + @@ -448,7 +450,6 @@ QStatusBar QLabel { - -1 75 false true @@ -542,7 +543,7 @@ QStatusBar QLabel { - :/blackgui/icons/loginred.png + :/blackgui/icons/loginred.png @@ -552,7 +553,7 @@ QStatusBar QLabel { - :/blackgui/icons/audiovolumelow.png + :/blackgui/icons/audiovolumelow.png @@ -571,8 +572,8 @@ QStatusBar QLabel { 0 0 - 86 - 59 + 79 + 71 @@ -595,7 +596,7 @@ QStatusBar QLabel { 0 - + QAbstractItemView::SingleSelection @@ -614,8 +615,8 @@ QStatusBar QLabel { 0 0 - 90 - 55 + 83 + 71 @@ -647,7 +648,6 @@ QStatusBar QLabel { - -1 75 false true @@ -693,36 +693,6 @@ QStatusBar QLabel { 0 - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - - -1 - 75 - false - true - - - - - - - -1 - - - @@ -742,9 +712,6 @@ QStatusBar QLabel { 0 - - - @@ -764,9 +731,6 @@ QStatusBar QLabel { 0 - - - @@ -787,7 +751,7 @@ QStatusBar QLabel { 0 - + @@ -808,13 +772,6 @@ QStatusBar QLabel { 0 - - - - -1 - - - @@ -834,9 +791,6 @@ QStatusBar QLabel { 0 - - - @@ -856,13 +810,6 @@ QStatusBar QLabel { 0 - - - - -1 - - - @@ -1049,342 +996,28 @@ QStatusBar QLabel { - - - - - - - 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 - - - - - - - Simulator - - - - + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + @@ -1398,7 +1031,7 @@ QStatusBar QLabel { 0 0 350 - 15 + 21 @@ -1455,6 +1088,8 @@ QStatusBar QLabel { + + @@ -1519,54 +1154,34 @@ QStatusBar QLabel { Reset settings + + + Reload style sheets + + + + + Font + + - BlackGui::CStatusMessageView + BlackGui::Views::CStatusMessageView QTableView -
blackgui/statusmessageview.h
+
blackgui/views/statusmessageview.h
- BlackGui::CFlightPlanComponent - QTabWidget -
blackgui/flightplancomponent.h
- 1 -
- - BlackGui::CUserComponent - QTabWidget -
blackgui/usercomponent.h
- 1 -
- - BlackGui::CAircraftComponent - QTabWidget -
blackgui/aircraftcomponent.h
- 1 -
- - BlackGui::CAtcStationComponent - QTabWidget -
blackgui/atcstationcomponent.h
- 1 -
- - BlackGui::CTextMessageComponent - QTabWidget -
blackgui/textmessagecomponent.h
- 1 -
- - BlackGui::CCockpitV1Component + BlackGui::Components::CCockpitV1Component QWidget -
blackgui/cockpitv1component.h
+
blackgui/components/cockpitv1component.h
1
- BlackGui::CSettingsComponent - QTabWidget -
blackgui/settingscomponent.h
+ BlackGui::Components::CMainInfoAreaComponent + QWidget +
blackgui/components/maininfoareacomponent.h
1
@@ -1576,20 +1191,15 @@ QStatusBar QLabel { le_StatusAudioContext tvp_StatusMessages le_CommandLineInput - comp_AtcStations - comp_TextMessages - comp_Settings pb_MainConnect pb_MainStatus pb_MainWeather pb_MainFlightplan - pb_MainAtc - pb_MainAircrafts pb_MainUsers pb_CockpitIdent pb_MainCockpit pb_MainTextMessages - pb_Mappings + pb_MainMappings pb_MainSettings pb_MainKeypadOpacity100 pb_MainKeypadOpacity050 @@ -1597,9 +1207,7 @@ QStatusBar QLabel { pb_SoundMaxVolume te_StatusPageConsole - - - + setMainPage() diff --git a/samples/blackgui/mainwindow_aircraft.cpp b/samples/blackgui/mainwindow_aircraft.cpp index c3ed2ea15..04238afbc 100644 --- a/samples/blackgui/mainwindow_aircraft.cpp +++ b/samples/blackgui/mainwindow_aircraft.cpp @@ -1,6 +1,6 @@ #include "mainwindow.h" #include "ui_mainwindow.h" -#include "blackgui/atcstationlistmodel.h" +#include "blackgui/models/atcstationlistmodel.h" #include "blackcore/dbus_server.h" #include "blackcore/context_network.h" @@ -15,9 +15,9 @@ using namespace BlackMisc::Settings; using namespace BlackMisc::Audio; /* - * Read own aircraft + * Load own aircraft */ -bool MainWindow::reloadOwnAircraft() +bool MainWindow::ps_reloadOwnAircraft() { if (!this->isContextNetworkAvailableCheck()) return false; @@ -27,7 +27,7 @@ bool MainWindow::reloadOwnAircraft() if (loadedAircraft != this->m_ownAircraft) { this->m_ownAircraft = loadedAircraft; - this->ui->comp_Flightplan->prefillWithAircraftData(this->m_ownAircraft); + this->ui->comp_MainInfoArea->getFlightPlanComponent()->prefillWithAircraftData(this->m_ownAircraft); changed = true; } return changed; diff --git a/samples/blackgui/mainwindow_init.cpp b/samples/blackgui/mainwindow_init.cpp index 2936bf645..bf8fa44ab 100644 --- a/samples/blackgui/mainwindow_init.cpp +++ b/samples/blackgui/mainwindow_init.cpp @@ -12,9 +12,12 @@ #include "blackcore/context_audio_impl.h" #include "blackcore/context_audio_proxy.h" #include "blackcore/context_runtime.h" -#include "blackgui/atcstationlistmodel.h" -#include "blackgui/keyboardkeylistmodel.h" -#include "blackgui/textmessagecomponent.h" +#include "blackgui/stylesheetutility.h" +#include "blackgui/guiutility.h" +#include "blackgui/components/textmessagecomponent.h" +#include "blackgui/models/atcstationlistmodel.h" +#include "blackgui/models/keyboardkeylistmodel.h" +#include "blackmisc/iconsstandard.h" #include "blackmisc/avselcal.h" #include "blackmisc/project.h" #include @@ -25,6 +28,7 @@ using namespace BlackCore; using namespace BlackMisc; using namespace BlackMisc::Hardware; using namespace BlackGui; +using namespace BlackGui::Components; /* @@ -34,19 +38,23 @@ void MainWindow::init(const CRuntimeConfig &runtimeConfig) { if (this->m_init) return; + // icon, initial position where intro was before + this->setWindowIcon(CIconsStandard::swift24()); + this->setWindowTitle(CProject::systemNameAndVersion()); + QPoint pos = CGuiUtility::introWindowPosition(); + this->move(pos); + // with frameless window, we shift menu and statusbar into central widget // http://stackoverflow.com/questions/18316710/frameless-and-transparent-window-qt5 - this->setWindowTitle(CProject::systemNameAndVersion()); 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")); + closeIcon->setIcon(CIconsStandard::close16()); QObject::connect(closeIcon, &QPushButton::clicked, this, &QMainWindow::close); menuBarLayout->addWidget(this->ui->mb_MainMenuBar, 0, Qt::AlignTop | Qt::AlignLeft); menuBarLayout->addWidget(closeIcon, 0, Qt::AlignTop | Qt::AlignRight); @@ -70,14 +78,6 @@ void MainWindow::init(const CRuntimeConfig &runtimeConfig) // 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"); - // status bar if (!this->m_statusBarLabel) { @@ -94,22 +94,22 @@ void MainWindow::init(const CRuntimeConfig &runtimeConfig) // signal / slots contexts / timers bool connect; - this->connect(this->getIContextApplication(), &IContextApplication::statusMessage, this, &MainWindow::displayStatusMessage); - this->connect(this->getIContextApplication(), &IContextApplication::statusMessages, this, &MainWindow::displayStatusMessages); + this->connect(this->getIContextApplication(), &IContextApplication::statusMessage, this, &MainWindow::ps_displayStatusMessageInGui); + this->connect(this->getIContextApplication(), &IContextApplication::statusMessages, this, &MainWindow::ps_displayStatusMessagesInGui); this->connect(this->getIContextApplication(), &IContextApplication::redirectedOutput, this, &MainWindow::displayRedirectedOutput); - this->connect(this->getIContextNetwork(), &IContextNetwork::connectionTerminated, this, &MainWindow::connectionTerminated); - this->connect(this->getIContextNetwork(), &IContextNetwork::connectionStatusChanged, this, &MainWindow::connectionStatusChanged); - connect = this->connect(this->getIContextNetwork(), SIGNAL(textMessagesReceived(BlackMisc::Network::CTextMessageList)), this->ui->comp_TextMessages, SLOT(appendTextMessagesToGui(BlackMisc::Network::CTextMessageList))); + this->connect(this->getIContextNetwork(), &IContextNetwork::connectionTerminated, this, &MainWindow::ps_onConnectionTerminated); + this->connect(this->getIContextNetwork(), &IContextNetwork::connectionStatusChanged, this, &MainWindow::ps_onConnectionStatusChanged); + connect = this->connect(this->getIContextNetwork(), SIGNAL(textMessagesReceived(BlackMisc::Network::CTextMessageList)), this->ui->comp_MainInfoArea->getTextMessageComponent(), SLOT(appendTextMessagesToGui(BlackMisc::Network::CTextMessageList))); Q_ASSERT(connect); - this->connect(this->getIContextSimulator(), &IContextSimulator::connectionChanged, this, &MainWindow::simulatorConnectionChanged); - this->connect(this->m_timerContextWatchdog, &QTimer::timeout, this, &MainWindow::timerBasedUpdates); - this->connect(this->m_timerSimulator, &QTimer::timeout, this, &MainWindow::timerBasedUpdates); - this->connect(this->getIContextSettings(), &IContextSettings::changedSettings, this, &MainWindow::changedSetttings); + this->connect(this->getIContextSimulator(), &IContextSimulator::connectionChanged, this, &MainWindow::ps_onSimulatorConnectionChanged); + this->connect(this->m_timerContextWatchdog, &QTimer::timeout, this, &MainWindow::ps_handleTimerBasedUpdates); + this->connect(this->m_timerSimulator, &QTimer::timeout, this, &MainWindow::ps_handleTimerBasedUpdates); + this->connect(this->getIContextSettings(), &IContextSettings::changedSettings, this, &MainWindow::ps_onChangedSetttings); // sliders - this->connect(this->ui->comp_Settings, &CSettingsComponent::changedUsersUpdateInterval, this->ui->comp_Users, &BlackGui::CUserComponent::setUpdateIntervalSeconds); - this->connect(this->ui->comp_Settings, &CSettingsComponent::changedAircraftsUpdateInterval, this->ui->comp_Aircrafts, &BlackGui::CAircraftComponent::setUpdateIntervalSeconds); - this->connect(this->ui->comp_Settings, &CSettingsComponent::changedAtcStationsUpdateInterval, this->ui->comp_AtcStations, &BlackGui::CAtcStationComponent::setUpdateIntervalSeconds); + this->connect(this->ui->comp_MainInfoArea->getSettingsComponent(), &CSettingsComponent::changedUsersUpdateInterval, this->ui->comp_MainInfoArea->getUserComponent(), &CUserComponent::setUpdateIntervalSeconds); + this->connect(this->ui->comp_MainInfoArea->getSettingsComponent(), &CSettingsComponent::changedAircraftsUpdateInterval, this->ui->comp_MainInfoArea->getAircraftComponent(), &CAircraftComponent::setUpdateIntervalSeconds); + this->connect(this->ui->comp_MainInfoArea->getSettingsComponent(), &CSettingsComponent::changedAtcStationsUpdateInterval, this->ui->comp_MainInfoArea->getAtcStationComponent(), &::CAtcStationComponent::setUpdateIntervalSeconds); Q_ASSERT(connect); Q_UNUSED(connect); // suppress GCC warning in release build @@ -127,7 +127,7 @@ void MainWindow::init(const CRuntimeConfig &runtimeConfig) this->initialDataReads(); // start screen - this->setMainPage(true); + this->ps_setMainPage(true); // init context menus this->initContextMenus(); @@ -136,14 +136,14 @@ void MainWindow::init(const CRuntimeConfig &runtimeConfig) this->getIContextApplication()->notifyAboutComponentChange(IContextApplication::ComponentGui, IContextApplication::ActionStarts); // We don't receive signals from the past. So ask for it simulate an initial signal - simulatorConnectionChanged(this->getIContextSimulator()->isConnected()); + ps_onSimulatorConnectionChanged(this->getIContextSimulator()->isConnected()); // info this->ui->te_StatusPageConsole->appendPlainText(CProject::systemNameAndVersion()); this->ui->te_StatusPageConsole->appendPlainText(CProject::compiledInfo()); // hotkeys - this->registerHotkeys(); + this->ps_registerHotkeys(); // update timers this->startUpdateTimers(); @@ -164,58 +164,65 @@ void MainWindow::initGuiSignals() // This is why we still have some "old" SIGNAL/SLOT connections here // MAIN buttons - connected = this->connect(this->ui->pb_MainAircrafts, SIGNAL(released()), this, SLOT(setMainPage())); + connected = this->connect(this->ui->pb_MainAircrafts, SIGNAL(released()), this, SLOT(ps_setMainPage())); Q_ASSERT(connected); - connected = this->connect(this->ui->pb_MainAtc, SIGNAL(released()), this, SLOT(setMainPage())); + connected = this->connect(this->ui->pb_MainAtc, SIGNAL(released()), this, SLOT(ps_setMainPage())); Q_ASSERT(connected); - connected = this->connect(this->ui->pb_MainCockpit, SIGNAL(released()), this, SLOT(setMainPage())); + connected = this->connect(this->ui->pb_MainCockpit, SIGNAL(released()), this, SLOT(ps_setMainPage())); Q_ASSERT(connected); - connected = this->connect(this->ui->pb_MainConnect, SIGNAL(released()), this, SLOT(setMainPage())); + connected = this->connect(this->ui->pb_MainConnect, SIGNAL(released()), this, SLOT(ps_setMainPage())); Q_ASSERT(connected); - connected = this->connect(this->ui->pb_MainConnect, SIGNAL(released()), this, SLOT(toggleNetworkConnection())); + connected = this->connect(this->ui->pb_MainConnect, SIGNAL(released()), this, SLOT(ps_toggleNetworkConnection())); Q_ASSERT(connected); - connected = this->connect(this->ui->pb_MainFlightplan, SIGNAL(released()), this, SLOT(setMainPage())); + connected = this->connect(this->ui->pb_MainFlightplan, SIGNAL(released()), this, SLOT(ps_setMainPage())); Q_ASSERT(connected); - connected = this->connect(this->ui->pb_MainSettings, SIGNAL(released()), this, SLOT(setMainPage())); + connected = this->connect(this->ui->pb_MainSettings, SIGNAL(released()), this, SLOT(ps_setMainPage())); Q_ASSERT(connected); - connected = this->connect(this->ui->pb_MainSimulator, SIGNAL(released()), this, SLOT(setMainPage())); + connected = this->connect(this->ui->pb_MainSimulator, SIGNAL(released()), this, SLOT(ps_setMainPage())); Q_ASSERT(connected); - connected = this->connect(this->ui->pb_MainStatus, SIGNAL(released()), this, SLOT(setMainPage())); + connected = this->connect(this->ui->pb_MainStatus, SIGNAL(released()), this, SLOT(ps_setMainPage())); Q_ASSERT(connected); - connected = this->connect(this->ui->pb_MainUsers, SIGNAL(released()), this, SLOT(setMainPage())); + connected = this->connect(this->ui->pb_MainUsers, SIGNAL(released()), this, SLOT(ps_setMainPage())); Q_ASSERT(connected); - connected = this->connect(this->ui->pb_MainTextMessages, SIGNAL(released()), this, SLOT(setMainPage())); + connected = this->connect(this->ui->pb_MainTextMessages, SIGNAL(released()), this, SLOT(ps_setMainPage())); Q_ASSERT(connected); - connected = this->connect(this->ui->pb_MainWeather, SIGNAL(released()), this, SLOT(setMainPage())); + connected = this->connect(this->ui->pb_MainWeather, SIGNAL(released()), this, SLOT(ps_setMainPage())); Q_ASSERT(connected); - connected = this->connect(this->ui->pb_MainKeypadOpacity050, SIGNAL(clicked()), this, SLOT(changeWindowOpacity())); + connected = this->connect(this->ui->pb_MainMappings, SIGNAL(released()), this, SLOT(ps_setMainPage())); Q_ASSERT(connected); - connected = this->connect(this->ui->pb_MainKeypadOpacity100, SIGNAL(clicked()), this, SLOT(changeWindowOpacity())); + connected = this->connect(this->ui->pb_MainKeypadOpacity050, SIGNAL(clicked()), this, SLOT(ps_changeWindowOpacity())); + Q_ASSERT(connected); + connected = this->connect(this->ui->pb_MainKeypadOpacity100, SIGNAL(clicked()), this, SLOT(ps_changeWindowOpacity())); + Q_ASSERT(connected); + connected = this->connect(this->ui->pb_Foo, SIGNAL(released()), this, SLOT(ps_setMainPage())); Q_ASSERT(connected); // Sound buttons - this->connect(this->ui->pb_SoundMute, &QPushButton::clicked, this, &MainWindow::audioVolumes); - this->connect(this->ui->pb_SoundMaxVolume, &QPushButton::clicked, this, &MainWindow::audioVolumes); - this->connect(this->ui->comp_Cockpit, &CCockpitV1Component::audioVolumeChanged, this, &MainWindow::audioVolumes); + this->connect(this->ui->pb_SoundMute, &QPushButton::clicked, this, &MainWindow::ps_setAudioVolumes); + this->connect(this->ui->pb_SoundMaxVolume, &QPushButton::clicked, this, &MainWindow::ps_setAudioVolumes); + this->connect(this->ui->comp_Cockpit, &CCockpitV1Component::audioVolumeChanged, this, &MainWindow::ps_setAudioVolumes); // 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); - this->connect(this->ui->menu_FileSettingsDirectory, &QAction::triggered, this, &MainWindow::menuClicked); - this->connect(this->ui->menu_FileResetSettings, &QAction::triggered, this, &MainWindow::menuClicked); + this->connect(this->ui->menu_ReloadSettings, &QAction::triggered, this, &MainWindow::ps_onMenuClicked); + this->connect(this->ui->menu_TestLocationsEDDF, &QAction::triggered, this, &MainWindow::ps_onMenuClicked); + this->connect(this->ui->menu_TestLocationsEDDM, &QAction::triggered, this, &MainWindow::ps_onMenuClicked); + this->connect(this->ui->menu_TestLocationsEDNX, &QAction::triggered, this, &MainWindow::ps_onMenuClicked); + this->connect(this->ui->menu_TestLocationsEDRY, &QAction::triggered, this, &MainWindow::ps_onMenuClicked); + this->connect(this->ui->menu_FileClose, &QAction::triggered, this, &MainWindow::ps_onMenuClicked); + this->connect(this->ui->menu_FileSettingsDirectory, &QAction::triggered, this, &MainWindow::ps_onMenuClicked); + this->connect(this->ui->menu_FileResetSettings, &QAction::triggered, this, &MainWindow::ps_onMenuClicked); + this->connect(this->ui->menu_FileReloadStyleSheets, &QAction::triggered, this, &MainWindow::ps_onMenuClicked); + this->connect(this->ui->menu_FileFont, &QAction::triggered, this, &MainWindow::ps_onMenuClicked); // command line / text messages - connected = this->connect(this->ui->le_CommandLineInput, SIGNAL(returnPressed()), this->ui->comp_TextMessages, SLOT(commandEntered())); + connected = this->connect(this->ui->le_CommandLineInput, SIGNAL(returnPressed()), this->ui->comp_MainInfoArea->getTextMessageComponent(), SLOT(commandEntered())); Q_ASSERT(connected); - this->connect(this->ui->comp_TextMessages, &CTextMessageComponent::displayInInfoWindow, this->m_compInfoWindow, &CInfoWindowComponent::display); - this->ui->comp_TextMessages->setSelcalCallback(std::bind(&CCockpitV1Component::getSelcalCode, this->ui->comp_Cockpit)); + this->connect(this->ui->comp_MainInfoArea->getTextMessageComponent(), &CTextMessageComponent::displayInInfoWindow, this->m_compInfoWindow, &CInfoWindowComponent::display); + this->ui->comp_MainInfoArea->getTextMessageComponent()->setSelcalCallback(std::bind(&CCockpitV1Component::getSelcalCode, this->ui->comp_Cockpit)); - // settings (GUI component) - this->connect(this->ui->comp_Settings, &CSettingsComponent::changedWindowsOpacity, this, &MainWindow::changeWindowOpacity); + // settings (GUI component), styles + this->connect(this->ui->comp_MainInfoArea->getSettingsComponent(), &CSettingsComponent::changedWindowsOpacity, this, &MainWindow::ps_changeWindowOpacity); + this->connect(&CStyleSheetUtility::instance(), &CStyleSheetUtility::styleSheetsChanged, this, &MainWindow::ps_onStyleSheetsChanged); // no warnings in release build Q_UNUSED(connected); @@ -230,14 +237,14 @@ void MainWindow::initialDataReads() this->m_coreAvailable = (this->getIContextNetwork()->usingLocalObjects() || (this->getIContextApplication()->ping(t) == t)); if (!this->m_coreAvailable) { - this->displayStatusMessage(CStatusMessage(CStatusMessage::TypeGui, CStatusMessage::SeverityError, - "no initial data read as network context is not available")); + this->ps_displayStatusMessageInGui(CStatusMessage(CStatusMessage::TypeGui, CStatusMessage::SeverityError, + "no initial data read as network context is not available")); return; } - this->ui->comp_Settings->reloadSettings(); // init read - this->reloadOwnAircraft(); // init read, independent of traffic network - this->displayStatusMessage(CStatusMessage(CStatusMessage::TypeGui, CStatusMessage::SeverityInfo, "initial data read")); + this->ui->comp_MainInfoArea->getSettingsComponent()->reloadSettings(); // init read + this->ps_reloadOwnAircraft(); // init read, independent of traffic network + this->ps_displayStatusMessageInGui(CStatusMessage(CStatusMessage::TypeGui, CStatusMessage::SeverityInfo, "initial data read")); } /* @@ -245,9 +252,9 @@ void MainWindow::initialDataReads() */ void MainWindow::startUpdateTimers() { - this->ui->comp_Aircrafts->setUpdateIntervalSeconds(this->ui->comp_Settings->getAircraftUpdateIntervalSeconds()); - this->ui->comp_AtcStations->setUpdateIntervalSeconds(this->ui->comp_Settings->getAtcUpdateIntervalSeconds()); - this->ui->comp_Users->setUpdateIntervalSeconds(this->ui->comp_Settings->getUsersUpdateIntervalSeconds()); + this->ui->comp_MainInfoArea->getAircraftComponent()->setUpdateIntervalSeconds(this->ui->comp_MainInfoArea->getSettingsComponent()->getAircraftUpdateIntervalSeconds()); + this->ui->comp_MainInfoArea->getAtcStationComponent()->setUpdateIntervalSeconds(this->ui->comp_MainInfoArea->getSettingsComponent()->getAtcUpdateIntervalSeconds()); + this->ui->comp_MainInfoArea->getUserComponent()->setUpdateIntervalSeconds(this->ui->comp_MainInfoArea->getSettingsComponent()->getUsersUpdateIntervalSeconds()); } /* @@ -255,11 +262,14 @@ void MainWindow::startUpdateTimers() */ void MainWindow::stopUpdateTimers() { - this->ui->comp_AtcStations->stopTimer(); - this->ui->comp_Aircrafts->stopTimer(); - this->ui->comp_Users->stopTimer(); + this->ui->comp_MainInfoArea->getAtcStationComponent()->stopTimer(); + this->ui->comp_MainInfoArea->getAircraftComponent()->stopTimer(); + this->ui->comp_MainInfoArea->getUserComponent()->stopTimer(); } +/* + * Stop all timers + */ void MainWindow::stopAllTimers(bool disconnect) { this->m_timerStatusBar->stop(); diff --git a/samples/blackgui/mainwindow_menus.cpp b/samples/blackgui/mainwindow_menus.cpp index 53d8726cf..cf3d54dea 100644 --- a/samples/blackgui/mainwindow_menus.cpp +++ b/samples/blackgui/mainwindow_menus.cpp @@ -1,12 +1,15 @@ #include "mainwindow.h" #include "ui_mainwindow.h" +#include "blackgui/stylesheetutility.h" #include "blackmisc/statusmessagelist.h" #include "blackmisc/avaltitude.h" #include #include #include #include +#include +using namespace BlackGui; using namespace BlackMisc; using namespace BlackMisc::PhysicalQuantities; using namespace BlackMisc::Aviation; @@ -14,7 +17,7 @@ using namespace BlackMisc::Aviation; /* * Menu clicked */ -void MainWindow::menuClicked() +void MainWindow::ps_onMenuClicked() { QObject *sender = QObject::sender(); CStatusMessageList msgs; @@ -37,9 +40,29 @@ void MainWindow::menuClicked() } else if (sender == this->ui->menu_ReloadSettings) { - this->ui->comp_Settings->reloadSettings(); + this->ui->comp_MainInfoArea->getSettingsComponent()->reloadSettings(); msgs.insert(CStatusMessage::getInfoMessage("Settings reloaded")); } + else if (sender == this->ui->menu_FileReloadStyleSheets) + { + CStyleSheetUtility::instance().read(); + } + else if (sender == this->ui->menu_FileFont) + { + bool ok = false; + QFont font = QFontDialog::getFont(&ok, this->font(), this, "Application fonts", QFontDialog::ProportionalFonts); + qDebug() << font.toString(); + if (ok) + { + // the user clicked OK and font is set to the font the user selected + // this->setFont(font); + CStyleSheetUtility::instance().updateFonts(font); + } + else + { + // the user canceled the dialog; font is set to the initial + } + } else if (sender == this->ui->menu_FileClose) { msgs.insert(CStatusMessage::getInfoMessage("Closing")); @@ -55,7 +78,7 @@ void MainWindow::menuClicked() Q_ASSERT(this->getIContextSettings()); msgs.insert(this->getIContextSettings()->reset(true)); } - if (!msgs.isEmpty()) this->displayStatusMessages(msgs); + if (!msgs.isEmpty()) this->ps_displayStatusMessagesInGui(msgs); } /* @@ -64,13 +87,13 @@ void MainWindow::menuClicked() void MainWindow::initContextMenus() { this->ui->lbl_StatusVoiceStatus->setContextMenuPolicy(Qt::CustomContextMenu); - connect(this->ui->lbl_StatusVoiceStatus, &QLabel::customContextMenuRequested, this, &MainWindow::audioIconContextMenu); + connect(this->ui->lbl_StatusVoiceStatus, &QLabel::customContextMenuRequested, this, &MainWindow::ps_displayAudioIconContextMenu); } /* * Audio context menu */ -void MainWindow::audioIconContextMenu(const QPoint &position) +void MainWindow::ps_displayAudioIconContextMenu(const QPoint &position) { // position for most widgets QWidget *sender = qobject_cast(QWidget::sender()); diff --git a/samples/blackgui/mainwindow_voice.cpp b/samples/blackgui/mainwindow_voice.cpp index 55c6b6798..381920c06 100644 --- a/samples/blackgui/mainwindow_voice.cpp +++ b/samples/blackgui/mainwindow_voice.cpp @@ -1,6 +1,7 @@ #include "mainwindow.h" #include "ui_mainwindow.h" -#include "blackgui/atcstationlistmodel.h" +#include "blackmisc/iconsstandard.h" +#include "blackgui/models/atcstationlistmodel.h" #include "blackcore/dbus_server.h" #include "blackcore/context_network.h" #include "blackcore/context_audio.h" @@ -21,7 +22,7 @@ using namespace BlackMisc::Math; /* * Select audio device */ -void MainWindow::audioVolumes() +void MainWindow::ps_setAudioVolumes() { if (!this->m_contextAudioAvailable) { @@ -75,8 +76,8 @@ void MainWindow::audioVolumes() com1.setEnabled(!muted); com2.setEnabled(!muted); this->ui->pb_SoundMute->setText(muted ? "Unmute" : "Mute"); - this->ui->lbl_StatusVoiceStatus->setPixmap(muted ? this->m_resPixmapVoiceMuted : this->m_resPixmapVoiceHigh); - this->ui->comp_Cockpit->setCockpitVoiceStatusPixmap(muted ? this->m_resPixmapVoiceMuted : this->m_resPixmapVoiceHigh); + this->ui->lbl_StatusVoiceStatus->setPixmap(muted ? CIconsStandard::volumneMuted16() : CIconsStandard::volumneHigh16()); + this->ui->comp_Cockpit->setCockpitVoiceStatusPixmap(muted ? CIconsStandard::volumneMuted16() : CIconsStandard::volumneHigh16()); this->ui->pb_SoundMute->setStyleSheet(muted ? "background-color: red;" : ""); if (muted) this->m_compInfoWindow->displayStringMessage("Sound is muted!"); @@ -92,6 +93,6 @@ void MainWindow::audioVolumes() void MainWindow::playNotifcationSound(CNotificationSounds::Notification notification) const { if (!this->m_contextAudioAvailable) return; - if (!this->ui->comp_Settings->playNotificationSounds()) return; + if (!this->ui->comp_MainInfoArea->getSettingsComponent()->playNotificationSounds()) return; this->getIContextAudio()->playNotification(static_cast(notification), true); } diff --git a/samples/blackgui2/main.cpp b/samples/blackgui2/main.cpp index dfd8c7e0b..65a07828d 100644 --- a/samples/blackgui2/main.cpp +++ b/samples/blackgui2/main.cpp @@ -17,7 +17,6 @@ int main(int argc, char *argv[]) { // register - Q_INIT_RESOURCE(blackgui); BlackMisc::initResources(); BlackMisc::registerMetadata(); BlackCore::registerMetadata(); diff --git a/src/blackgui/blackgui.qrc b/src/blackgui/blackgui.qrc index b6cfb7c8f..7646d2b36 100644 --- a/src/blackgui/blackgui.qrc +++ b/src/blackgui/blackgui.qrc @@ -1,15 +1 @@ - - - icons/logingreen.png - icons/loginred.png - icons/loginyellow.png - icons/audiovolumehigh.png - icons/audiovolumelow.png - icons/audiovolumemuted.png - icons/resize.png - icons/close.png - icons/aircraftdeparture.png - icons/apronsmall.jpg - icons/tower.png - - +