refs #304, adjusted main window to previous changes

* new namespaces
* centralized icons
* dockable widgets
This commit is contained in:
Klaus Basan
2014-07-27 15:12:50 +02:00
parent 17a8425883
commit f9eca1f3a5
12 changed files with 665 additions and 992 deletions

View File

@@ -8,6 +8,7 @@
#include "blackcore/context_settings.h" #include "blackcore/context_settings.h"
#include "blackcore/context_application.h" #include "blackcore/context_application.h"
#include "blackcore/context_application_impl.h" #include "blackcore/context_application_impl.h"
#include "blackmisc/iconsstandard.h"
#include "blackmisc/networkutils.h" #include "blackmisc/networkutils.h"
#include "blackmisc/blackmiscfreefunctions.h" #include "blackmisc/blackmiscfreefunctions.h"
#include "blackmisc/project.h" #include "blackmisc/project.h"
@@ -26,7 +27,7 @@ int main(int argc, char *argv[])
{ {
// metadata are registered in runtime // metadata are registered in runtime
QApplication a(argc, argv); // not QCoreApplication because of icon, http://qt-project.org/forums/viewthread/15412 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); QApplication::setWindowIcon(icon);
QTextStream cin(stdin); QTextStream cin(stdin);

View File

@@ -33,7 +33,7 @@ DESTDIR = ../../bin
HEADERS += *.h HEADERS += *.h
SOURCES += *.cpp SOURCES += *.cpp
OTHER_FILES += readme.txt blackcore.rc blackcore.ico OTHER_FILES += readme.txt blackcore.rc blackcore.ico
RESOURCES += blackcore.qrc RESOURCES +=
win32: RC_FILE = blackcore.rc win32: RC_FILE = blackcore.rc
include (../../libraries.pri) include (../../libraries.pri)

View File

@@ -1,16 +1,20 @@
#include "introwindow.h" #include "introwindow.h"
#include "mainwindow.h" #include "mainwindow.h"
#include "guimodeenums.h" #include "guimodeenums.h"
#include "blackgui/stylesheetutility.h"
#include "blackcore/blackcorefreefunctions.h" #include "blackcore/blackcorefreefunctions.h"
#include "blackcore/context_runtime_config.h" #include "blackcore/context_runtime_config.h"
#include "blacksim/blacksimfreefunctions.h" #include "blacksim/blacksimfreefunctions.h"
#include "blackmisc/blackmiscfreefunctions.h" #include "blackmisc/blackmiscfreefunctions.h"
#include "blackmisc/iconsstandard.h"
#include <QtGlobal> #include <QtGlobal>
#include <QApplication> #include <QApplication>
#include <QMessageBox> #include <QMessageBox>
#include <QPushButton> #include <QPushButton>
using namespace BlackGui;
/*! /*!
* \brief Main * \brief Main
* \param argc * \param argc
@@ -20,13 +24,13 @@
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
// register // register
Q_INIT_RESOURCE(blackgui);
BlackMisc::initResources(); BlackMisc::initResources();
BlackMisc::registerMetadata(); BlackMisc::registerMetadata();
BlackSim::registerMetadata(); BlackSim::registerMetadata();
BlackCore::registerMetadata(); BlackCore::registerMetadata();
// BlackMisc::displayAllUserMetatypesTypes(); // BlackMisc::displayAllUserMetatypesTypes();
// Translations
QFile file(":blackmisc/translations/blackmisc_i18n_de.qm"); QFile file(":blackmisc/translations/blackmisc_i18n_de.qm");
qDebug() << (file.exists() ? "Found translations in resources" : "No translations in resources"); qDebug() << (file.exists() ? "Found translations in resources" : "No translations in resources");
QTranslator translator; QTranslator translator;
@@ -35,9 +39,18 @@ int main(int argc, char *argv[])
qDebug() << "Translator loaded"; qDebug() << "Translator loaded";
} }
// app // application
QApplication a(argc, argv); 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.installTranslator(&translator);
a.setStyleSheet(s);
// modes // modes
GuiModes::WindowMode windowMode; GuiModes::WindowMode windowMode;
@@ -45,6 +58,7 @@ int main(int argc, char *argv[])
// Dialog to decide external or internal core // Dialog to decide external or internal core
CIntroWindow intro; CIntroWindow intro;
intro.setWindowIcon(icon);
BlackCore::CRuntimeConfig runtimeConfig; BlackCore::CRuntimeConfig runtimeConfig;
if (intro.exec() == QDialog::Rejected) if (intro.exec() == QDialog::Rejected)
{ {

View File

@@ -1,6 +1,9 @@
#include "mainwindow.h" #include "mainwindow.h"
#include "ui_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/dbus_server.h"
#include "blackcore/context_network.h" #include "blackcore/context_network.h"
#include "blackcore/context_application.h" #include "blackcore/context_application.h"
@@ -11,6 +14,7 @@
using namespace BlackCore; using namespace BlackCore;
using namespace BlackMisc; using namespace BlackMisc;
using namespace BlackGui; using namespace BlackGui;
using namespace BlackGui::Components;
using namespace BlackMisc::Network; using namespace BlackMisc::Network;
using namespace BlackMisc::Aviation; using namespace BlackMisc::Aviation;
using namespace BlackMisc::PhysicalQuantities; using namespace BlackMisc::PhysicalQuantities;
@@ -51,7 +55,6 @@ MainWindow::MainWindow(GuiModes::WindowMode windowMode, QWidget *parent) :
// GUI // GUI
ui->setupUi(this); ui->setupUi(this);
this->m_compInfoWindow = new CInfoWindowComponent(this); // setupUi has to be first! this->m_compInfoWindow = new CInfoWindowComponent(this); // setupUi has to be first!
} }
/* /*
@@ -99,7 +102,7 @@ void MainWindow::gracefulShutdown()
} }
if (this->getIContextSimulator()) 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 * Select correct main page
*/ */
void MainWindow::setMainPage(bool start) void MainWindow::ps_setMainPage(bool start)
{ {
if (start) if (start)
{ {
@@ -150,28 +153,55 @@ void MainWindow::setMainPage(bool start)
QObject *sender = QObject::sender(); QObject *sender = QObject::sender();
if (sender == this->ui->pb_MainConnect || sender == this->ui->pb_MainStatus) if (sender == this->ui->pb_MainConnect || sender == this->ui->pb_MainStatus)
this->ui->sw_MainMiddle->setCurrentIndex(MainPageStatus); 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) else if (sender == this->ui->pb_MainCockpit)
this->ui->sw_MainMiddle->setCurrentIndex(MainPageCockpit); this->ui->sw_MainMiddle->setCurrentIndex(MainPageCockpit);
else if (sender == this->ui->pb_MainUsers) else
this->ui->sw_MainMiddle->setCurrentIndex(MainPageUsers); {
else if (sender == this->ui->pb_MainTextMessages) this->ui->sw_MainMiddle->setCurrentIndex(MainPageFoo);
this->ui->sw_MainMiddle->setCurrentIndex(MainPageTextMessages);
else if (sender == this->ui->pb_MainFlightplan) if (sender == this->ui->pb_MainAircrafts)
this->ui->sw_MainMiddle->setCurrentIndex(MainPageFlightplan); {
else if (sender == this->ui->pb_MainSettings) this->ui->comp_MainInfoArea->selectArea(CMainInfoAreaComponent::InfoAreaAircrafts);
this->ui->sw_MainMiddle->setCurrentIndex(MainPageSettings); }
else if (sender == this->ui->pb_MainSimulator) if (sender == this->ui->pb_MainAtc)
this->ui->sw_MainMiddle->setCurrentIndex(MainPageSimulator); {
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 * Set main page
*/ */
void MainWindow::setMainPage(MainWindow::MainPageIndex mainPage) void MainWindow::ps_setMainPage(MainWindow::MainPageIndex mainPage)
{ {
this->ui->sw_MainMiddle->setCurrentIndex(mainPage); this->ui->sw_MainMiddle->setCurrentIndex(mainPage);
} }
@@ -187,38 +217,38 @@ bool MainWindow::isMainPageSelected(MainWindow::MainPageIndex mainPage) const
/* /*
* Connect to Network * Connect to Network
*/ */
void MainWindow::toggleNetworkConnection() void MainWindow::ps_toggleNetworkConnection()
{ {
CStatusMessageList msgs; CStatusMessageList msgs;
if (!this->isContextNetworkAvailableCheck()) return; if (!this->isContextNetworkAvailableCheck()) return;
this->ui->lbl_StatusNetworkConnectedIcon->setPixmap(this->m_resPixmapConnectionConnecting); this->ui->lbl_StatusNetworkConnectedIcon->setPixmap(CIconsNetworkAndAviation::statusTransition());
if (!this->getIContextNetwork()->isConnected()) if (!this->getIContextNetwork()->isConnected())
{ {
// validation of data here is not required, network context does this // validation of data here is not required, network context does this
// in prephase of login // 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(); CAircraftIcao icao = this->m_ownAircraft.getIcaoInfo();
this->ui->comp_Settings->setOwnAircraftIcaoDataFromGui(icao); this->ui->comp_MainInfoArea->getSettingsComponent()->setOwnAircraftIcaoDataFromGui(icao);
this->m_ownAircraft.setIcaoInfo(icao); this->m_ownAircraft.setIcaoInfo(icao);
// set latest aircraft // set latest aircraft
this->getIContextOwnAircraft()->updateOwnAircraft(this->m_ownAircraft, MainWindow::sampleBlackGuiOriginator()); this->getIContextOwnAircraft()->updateOwnAircraft(this->m_ownAircraft, MainWindow::sampleBlackGuiOriginator());
// flight plan // 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 // Login is based on setting current server
INetwork::LoginMode mode = INetwork::LoginNormal; INetwork::LoginMode mode = INetwork::LoginNormal;
if (this->ui->comp_Settings->loginStealth()) if (this->ui->comp_MainInfoArea->getSettingsComponent()->loginStealth())
{ {
mode = INetwork::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; 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<uint>(mode)); msgs = this->getIContextNetwork()->connectToNetwork(static_cast<uint>(mode));
} }
@@ -229,7 +259,7 @@ void MainWindow::toggleNetworkConnection()
if (this->m_contextAudioAvailable) this->getIContextAudio()->leaveAllVoiceRooms(); if (this->m_contextAudioAvailable) this->getIContextAudio()->leaveAllVoiceRooms();
msgs = this->getIContextNetwork()->disconnectFromNetwork(); 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() bool MainWindow::isContextNetworkAvailableCheck()
{ {
if (this->m_contextNetworkAvailable) return true; 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; return false;
} }
@@ -248,14 +278,14 @@ bool MainWindow::isContextNetworkAvailableCheck()
bool MainWindow::isContextAudioAvailableCheck() bool MainWindow::isContextAudioAvailableCheck()
{ {
if (this->m_contextAudioAvailable) return true; 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; return false;
} }
/* /*
* Display a status message * Display a status message
*/ */
void MainWindow::displayStatusMessage(const CStatusMessage &statusMessage) void MainWindow::ps_displayStatusMessageInGui(const CStatusMessage &statusMessage)
{ {
if (!this->m_init) return; if (!this->m_init) return;
this->ui->sb_MainStatusBar->show(); this->ui->sb_MainStatusBar->show();
@@ -274,12 +304,12 @@ void MainWindow::displayStatusMessage(const CStatusMessage &statusMessage)
/* /*
* Display a status message * Display a status message
*/ */
void MainWindow::displayStatusMessages(const CStatusMessageList &messages) void MainWindow::ps_displayStatusMessagesInGui(const CStatusMessageList &messages)
{ {
if (!this->m_init || messages.isEmpty()) return; if (!this->m_init || messages.isEmpty()) return;
foreach(CStatusMessage msg, messages) 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()); this->ui->te_StatusPageConsole->appendHtml(statusMessage.toHtml());
} }
void MainWindow::changedSetttings(uint typeValue) void MainWindow::ps_onChangedSetttings(uint typeValue)
{ {
IContextSettings::SettingsType type = static_cast<IContextSettings::SettingsType>(typeValue); IContextSettings::SettingsType type = static_cast<IContextSettings::SettingsType>(typeValue);
if (type == IContextSettings::SettingsHotKeys) this->registerHotkeys(); if (type == IContextSettings::SettingsHotKeys) this->ps_registerHotkeys();
} }
/* /*
* Connection terminated * Connection terminated
*/ */
void MainWindow::connectionTerminated() void MainWindow::ps_onConnectionTerminated()
{ {
this->updateGuiStatusInformation(); this->updateGuiStatusInformation();
} }
@@ -307,7 +337,7 @@ void MainWindow::connectionTerminated()
/* /*
* Connection status changed * 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(); this->updateGuiStatusInformation();
INetwork::ConnectionStatus newStatus = static_cast<INetwork::ConnectionStatus>(to); INetwork::ConnectionStatus newStatus = static_cast<INetwork::ConnectionStatus>(to);
@@ -332,7 +362,7 @@ void MainWindow::connectionStatusChanged(uint /** from **/, uint to, const QStri
/* /*
* Timer event * Timer event
*/ */
void MainWindow::timerBasedUpdates() void MainWindow::ps_handleTimerBasedUpdates()
{ {
QObject *sender = QObject::sender(); QObject *sender = QObject::sender();
if (sender == this->m_timerContextWatchdog) if (sender == this->m_timerContextWatchdog)
@@ -346,7 +376,7 @@ void MainWindow::timerBasedUpdates()
} }
// own aircraft // 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->lbl_StatusNetworkConnectedIcon->setToolTip(now);
this->ui->pb_MainConnect->setText("Disconnect"); this->ui->pb_MainConnect->setText("Disconnect");
this->ui->pb_MainConnect->setStyleSheet("background-color: green"); this->ui->pb_MainConnect->setStyleSheet("background-color: green");
this->ui->lbl_StatusNetworkConnectedIcon->setPixmap(this->m_resPixmapConnectionConnected); this->ui->lbl_StatusNetworkConnectedIcon->setPixmap(CIconsNetworkAndAviation::statusConnected());
} }
else else
{ {
this->ui->lbl_StatusNetworkConnectedIcon->setToolTip("disconnected"); this->ui->lbl_StatusNetworkConnectedIcon->setToolTip("disconnected");
this->ui->pb_MainConnect->setText("Connect"); this->ui->pb_MainConnect->setText("Connect");
this->ui->pb_MainConnect->setStyleSheet("background-color: "); 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 * Opacity 0-100
*/ */
void MainWindow::changeWindowOpacity(int opacity) void MainWindow::ps_changeWindowOpacity(int opacity)
{ {
if (opacity < 0) if (opacity < 0)
{ {
@@ -427,7 +457,7 @@ void MainWindow::changeWindowOpacity(int opacity)
qreal o = opacity / 100.0; qreal o = opacity / 100.0;
o = o < 0.3 ? 0.3 : o; o = o < 0.3 ? 0.3 : o;
QWidget::setWindowOpacity(o); QWidget::setWindowOpacity(o);
this->ui->comp_Settings->setGuiOpacity(o * 100.0); this->ui->comp_MainInfoArea->getSettingsComponent()->setGuiOpacity(o * 100.0);
} }
void MainWindow::updateSimulatorData() void MainWindow::updateSimulatorData()
@@ -453,7 +483,7 @@ void MainWindow::updateSimulatorData()
ui->le_SimulatorTransponder->setText(ownAircraft.getTransponderCodeFormatted()); ui->le_SimulatorTransponder->setText(ownAircraft.getTransponderCodeFormatted());
} }
void MainWindow::simulatorConnectionChanged(bool isAvailable) void MainWindow::ps_onSimulatorConnectionChanged(bool isAvailable)
{ {
// Simulator timer, TODO remove later // Simulator timer, TODO remove later
if (isAvailable) if (isAvailable)
@@ -465,20 +495,20 @@ void MainWindow::simulatorConnectionChanged(bool isAvailable)
/* /*
* Stay on top * Stay on top
*/ */
void MainWindow::toogleWindowStayOnTop() void MainWindow::ps_toogleWindowStayOnTop()
{ {
Qt::WindowFlags flags = this->windowFlags(); Qt::WindowFlags flags = this->windowFlags();
if (Qt::WindowStaysOnTopHint & flags) if (Qt::WindowStaysOnTopHint & flags)
{ {
flags ^= Qt::WindowStaysOnTopHint; flags ^= Qt::WindowStaysOnTopHint;
flags |= Qt::WindowStaysOnBottomHint; 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 else
{ {
flags ^= Qt::WindowStaysOnBottomHint; flags ^= Qt::WindowStaysOnBottomHint;
flags |= Qt::WindowStaysOnTopHint; 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->setWindowFlags(flags);
this->show(); this->show();
@@ -487,7 +517,7 @@ void MainWindow::toogleWindowStayOnTop()
/* /*
* Hotkeys * Hotkeys
*/ */
void MainWindow::registerHotkeys() void MainWindow::ps_registerHotkeys()
{ {
if (!this->getIContextSettings()) qFatal("Missing settings"); if (!this->getIContextSettings()) qFatal("Missing settings");
if (!this->m_keyboard) if (!this->m_keyboard)
@@ -503,11 +533,25 @@ void MainWindow::registerHotkeys()
if (keys.isEmpty()) return; if (keys.isEmpty()) return;
CKeyboardKey key = keys.keyForFunction(CKeyboardKey::HotkeyOpacity50); 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); 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); 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);
} }

View File

@@ -18,15 +18,15 @@
#include "blackcore/context_application.h" #include "blackcore/context_application.h"
#include "blackcore/context_simulator.h" #include "blackcore/context_simulator.h"
#include "blackcore/context_runtime.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/transpondermodeselector.h"
#include "blackgui/atcstationlistmodel.h" #include "blackgui/models/atcstationlistmodel.h"
#include "blackgui/serverlistmodel.h" #include "blackgui/models/serverlistmodel.h"
#include "blackgui/aircraftlistmodel.h" #include "blackgui/models/aircraftlistmodel.h"
#include "blackgui/userlistmodel.h" #include "blackgui/models/userlistmodel.h"
#include "blackgui/statusmessagelistmodel.h" #include "blackgui/models/statusmessagelistmodel.h"
#include "blackgui/keyboardkeylistmodel.h" #include "blackgui/models/keyboardkeylistmodel.h"
#include "blackgui/infowindowcomponent.h"
#include "blackmisc/nwtextmessage.h" #include "blackmisc/nwtextmessage.h"
#include "blacksound/soundgenerator.h" #include "blacksound/soundgenerator.h"
#include <QMainWindow> #include <QMainWindow>
@@ -38,10 +38,8 @@
namespace Ui { class MainWindow; } namespace Ui { class MainWindow; }
/*! //! swift GUI
* \brief GUI class MainWindow : public QMainWindow, public BlackGui::Components::CRuntimeBasedComponent
*/
class MainWindow : public QMainWindow, public BlackGui::CRuntimeBasedComponent
{ {
Q_OBJECT Q_OBJECT
@@ -73,19 +71,13 @@ protected:
enum MainPageIndex enum MainPageIndex
{ {
MainPageStatus = 0, MainPageStatus = 0,
MainPageAtc = 1,
MainPageAircrafts = 2,
MainPageUsers = 3,
MainPageCockpit = 4, MainPageCockpit = 4,
MainPageTextMessages = 5, MainPageFoo = 9
MainPageFlightplan = 6,
MainPageSettings = 7,
MainPageSimulator = 8
}; };
private: private:
QScopedPointer<Ui::MainWindow> ui; QScopedPointer<Ui::MainWindow> ui;
BlackGui::CInfoWindowComponent *m_compInfoWindow; BlackGui::Components::CInfoWindowComponent *m_compInfoWindow;
bool m_init; bool m_init;
GuiModes::WindowMode m_windowMode; GuiModes::WindowMode m_windowMode;
BlackInput::IKeyboard *m_keyboard; //!< hotkeys BlackInput::IKeyboard *m_keyboard; //!< hotkeys
@@ -99,14 +91,6 @@ private:
QTimer *m_timerStatusBar; /*!< cleaning up status bar */ QTimer *m_timerStatusBar; /*!< cleaning up status bar */
QTimer *m_timerSimulator; /*!< update simulator data */ 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 // frameless window
QPoint m_dragPosition; /*!< position, if moving is handled with frameless window */ QPoint m_dragPosition; /*!< position, if moving is handled with frameless window */
@@ -193,29 +177,29 @@ private slots:
// //
//! Reload own aircraft //! Reload own aircraft
bool reloadOwnAircraft(); bool ps_reloadOwnAircraft();
//! Display status message //! Display status message
void displayStatusMessage(const BlackMisc::CStatusMessage &sendStatusMessage); void ps_displayStatusMessageInGui(const BlackMisc::CStatusMessage &sendStatusMessage);
//! Display status messages //! Display status messages
void displayStatusMessages(const BlackMisc::CStatusMessageList &messages); void ps_displayStatusMessagesInGui(const BlackMisc::CStatusMessageList &messages);
//! Redirected output //! Redirected output
void displayRedirectedOutput(const BlackMisc::CStatusMessage &sendStatusMessage, qint64 contextId); void displayRedirectedOutput(const BlackMisc::CStatusMessage &sendStatusMessage, qint64 contextId);
//! Settings have been changed //! Settings have been changed
void changedSetttings(uint typeValue); void ps_onChangedSetttings(uint typeValue);
/*! /*!
* \brief Connection status changed * \brief Connection status changed
* \param from old status, as uint so it is compliant with DBus * \param from old status, as uint so it is compliant with DBus
* \param to new 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 //! Simulator available
void simulatorConnectionChanged(bool isAvailable); void ps_onSimulatorConnectionChanged(bool isAvailable);
// //
// GUI related slots // GUI related slots
@@ -225,43 +209,46 @@ private slots:
* \brief Set the main page * \brief Set the main page
* \param start Startup phase * \param start Startup phase
*/ */
void setMainPage(bool start = false); void ps_setMainPage(bool start = false);
/*! /*!
* \brief setMainPage * \brief setMainPage
* \param mainPage * \param mainPage
*/ */
void setMainPage(MainPageIndex mainPage); void ps_setMainPage(MainPageIndex mainPage);
//! Connect to network //! Connect to network
void toggleNetworkConnection(); void ps_toggleNetworkConnection();
//! Menu item clicked //! Menu item clicked
void menuClicked(); void ps_onMenuClicked();
//! Terminated connection //! Terminated connection
void connectionTerminated(); void ps_onConnectionTerminated();
//! Update timer //! Update timer
void timerBasedUpdates(); void ps_handleTimerBasedUpdates();
//! Audio volume handling and mute //! Audio volume handling and mute
void audioVolumes(); void ps_setAudioVolumes();
/*! /*!
* \brief changeOpacity * \brief changeOpacity
* \param opacity 0-100 * \param opacity 0-100
*/ */
void changeWindowOpacity(int opacity = -1); void ps_changeWindowOpacity(int opacity = -1);
//! Context menu for audio //! Context menu for audio
void audioIconContextMenu(const QPoint &position); void ps_displayAudioIconContextMenu(const QPoint &position);
//! Toogle Windows stay on top //! Toogle Windows stay on top
void toogleWindowStayOnTop(); void ps_toogleWindowStayOnTop();
//! Set the hotkeys //! Set the hotkeys
void registerHotkeys(); void ps_registerHotkeys();
//! Style sheet has been changed
void ps_onStyleSheetsChanged();
}; };
#pragma pop_macro("interface") #pragma pop_macro("interface")

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
#include "mainwindow.h" #include "mainwindow.h"
#include "ui_mainwindow.h" #include "ui_mainwindow.h"
#include "blackgui/atcstationlistmodel.h" #include "blackgui/models/atcstationlistmodel.h"
#include "blackcore/dbus_server.h" #include "blackcore/dbus_server.h"
#include "blackcore/context_network.h" #include "blackcore/context_network.h"
@@ -15,9 +15,9 @@ using namespace BlackMisc::Settings;
using namespace BlackMisc::Audio; using namespace BlackMisc::Audio;
/* /*
* Read own aircraft * Load own aircraft
*/ */
bool MainWindow::reloadOwnAircraft() bool MainWindow::ps_reloadOwnAircraft()
{ {
if (!this->isContextNetworkAvailableCheck()) return false; if (!this->isContextNetworkAvailableCheck()) return false;
@@ -27,7 +27,7 @@ bool MainWindow::reloadOwnAircraft()
if (loadedAircraft != this->m_ownAircraft) if (loadedAircraft != this->m_ownAircraft)
{ {
this->m_ownAircraft = loadedAircraft; this->m_ownAircraft = loadedAircraft;
this->ui->comp_Flightplan->prefillWithAircraftData(this->m_ownAircraft); this->ui->comp_MainInfoArea->getFlightPlanComponent()->prefillWithAircraftData(this->m_ownAircraft);
changed = true; changed = true;
} }
return changed; return changed;

View File

@@ -12,9 +12,12 @@
#include "blackcore/context_audio_impl.h" #include "blackcore/context_audio_impl.h"
#include "blackcore/context_audio_proxy.h" #include "blackcore/context_audio_proxy.h"
#include "blackcore/context_runtime.h" #include "blackcore/context_runtime.h"
#include "blackgui/atcstationlistmodel.h" #include "blackgui/stylesheetutility.h"
#include "blackgui/keyboardkeylistmodel.h" #include "blackgui/guiutility.h"
#include "blackgui/textmessagecomponent.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/avselcal.h"
#include "blackmisc/project.h" #include "blackmisc/project.h"
#include <QSortFilterProxyModel> #include <QSortFilterProxyModel>
@@ -25,6 +28,7 @@ using namespace BlackCore;
using namespace BlackMisc; using namespace BlackMisc;
using namespace BlackMisc::Hardware; using namespace BlackMisc::Hardware;
using namespace BlackGui; using namespace BlackGui;
using namespace BlackGui::Components;
/* /*
@@ -34,19 +38,23 @@ void MainWindow::init(const CRuntimeConfig &runtimeConfig)
{ {
if (this->m_init) return; 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 // with frameless window, we shift menu and statusbar into central widget
// http://stackoverflow.com/questions/18316710/frameless-and-transparent-window-qt5 // http://stackoverflow.com/questions/18316710/frameless-and-transparent-window-qt5
this->setWindowTitle(CProject::systemNameAndVersion());
if (this->m_windowMode == GuiModes::WindowFrameless) if (this->m_windowMode == GuiModes::WindowFrameless)
{ {
this->ui->wi_CentralWidgetOutside->setStyleSheet("#wi_CentralWidgetOutside {border: 2px solid green; border-radius: 20px; }"); this->ui->wi_CentralWidgetOutside->setStyleSheet("#wi_CentralWidgetOutside {border: 2px solid green; border-radius: 20px; }");
this->ui->vl_CentralWidgetOutside->setContentsMargins(8, 8, 8, 8); this->ui->vl_CentralWidgetOutside->setContentsMargins(8, 8, 8, 8);
QHBoxLayout *menuBarLayout = new QHBoxLayout(); QHBoxLayout *menuBarLayout = new QHBoxLayout();
QPushButton *closeIcon = new QPushButton(this); QPushButton *closeIcon = new QPushButton(this);
closeIcon->setStyleSheet("margin: 0; padding: 0; background: transparent;"); 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); QObject::connect(closeIcon, &QPushButton::clicked, this, &QMainWindow::close);
menuBarLayout->addWidget(this->ui->mb_MainMenuBar, 0, Qt::AlignTop | Qt::AlignLeft); menuBarLayout->addWidget(this->ui->mb_MainMenuBar, 0, Qt::AlignTop | Qt::AlignLeft);
menuBarLayout->addWidget(closeIcon, 0, Qt::AlignTop | Qt::AlignRight); menuBarLayout->addWidget(closeIcon, 0, Qt::AlignTop | Qt::AlignRight);
@@ -70,14 +78,6 @@ void MainWindow::init(const CRuntimeConfig &runtimeConfig)
// wire GUI signals // wire GUI signals
this->initGuiSignals(); 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 // status bar
if (!this->m_statusBarLabel) if (!this->m_statusBarLabel)
{ {
@@ -94,22 +94,22 @@ void MainWindow::init(const CRuntimeConfig &runtimeConfig)
// signal / slots contexts / timers // signal / slots contexts / timers
bool connect; bool connect;
this->connect(this->getIContextApplication(), &IContextApplication::statusMessage, this, &MainWindow::displayStatusMessage); this->connect(this->getIContextApplication(), &IContextApplication::statusMessage, this, &MainWindow::ps_displayStatusMessageInGui);
this->connect(this->getIContextApplication(), &IContextApplication::statusMessages, this, &MainWindow::displayStatusMessages); this->connect(this->getIContextApplication(), &IContextApplication::statusMessages, this, &MainWindow::ps_displayStatusMessagesInGui);
this->connect(this->getIContextApplication(), &IContextApplication::redirectedOutput, this, &MainWindow::displayRedirectedOutput); this->connect(this->getIContextApplication(), &IContextApplication::redirectedOutput, this, &MainWindow::displayRedirectedOutput);
this->connect(this->getIContextNetwork(), &IContextNetwork::connectionTerminated, this, &MainWindow::connectionTerminated); this->connect(this->getIContextNetwork(), &IContextNetwork::connectionTerminated, this, &MainWindow::ps_onConnectionTerminated);
this->connect(this->getIContextNetwork(), &IContextNetwork::connectionStatusChanged, this, &MainWindow::connectionStatusChanged); this->connect(this->getIContextNetwork(), &IContextNetwork::connectionStatusChanged, this, &MainWindow::ps_onConnectionStatusChanged);
connect = this->connect(this->getIContextNetwork(), SIGNAL(textMessagesReceived(BlackMisc::Network::CTextMessageList)), this->ui->comp_TextMessages, SLOT(appendTextMessagesToGui(BlackMisc::Network::CTextMessageList))); connect = this->connect(this->getIContextNetwork(), SIGNAL(textMessagesReceived(BlackMisc::Network::CTextMessageList)), this->ui->comp_MainInfoArea->getTextMessageComponent(), SLOT(appendTextMessagesToGui(BlackMisc::Network::CTextMessageList)));
Q_ASSERT(connect); Q_ASSERT(connect);
this->connect(this->getIContextSimulator(), &IContextSimulator::connectionChanged, this, &MainWindow::simulatorConnectionChanged); this->connect(this->getIContextSimulator(), &IContextSimulator::connectionChanged, this, &MainWindow::ps_onSimulatorConnectionChanged);
this->connect(this->m_timerContextWatchdog, &QTimer::timeout, this, &MainWindow::timerBasedUpdates); this->connect(this->m_timerContextWatchdog, &QTimer::timeout, this, &MainWindow::ps_handleTimerBasedUpdates);
this->connect(this->m_timerSimulator, &QTimer::timeout, this, &MainWindow::timerBasedUpdates); this->connect(this->m_timerSimulator, &QTimer::timeout, this, &MainWindow::ps_handleTimerBasedUpdates);
this->connect(this->getIContextSettings(), &IContextSettings::changedSettings, this, &MainWindow::changedSetttings); this->connect(this->getIContextSettings(), &IContextSettings::changedSettings, this, &MainWindow::ps_onChangedSetttings);
// sliders // sliders
this->connect(this->ui->comp_Settings, &CSettingsComponent::changedUsersUpdateInterval, this->ui->comp_Users, &BlackGui::CUserComponent::setUpdateIntervalSeconds); this->connect(this->ui->comp_MainInfoArea->getSettingsComponent(), &CSettingsComponent::changedUsersUpdateInterval, this->ui->comp_MainInfoArea->getUserComponent(), &CUserComponent::setUpdateIntervalSeconds);
this->connect(this->ui->comp_Settings, &CSettingsComponent::changedAircraftsUpdateInterval, this->ui->comp_Aircrafts, &BlackGui::CAircraftComponent::setUpdateIntervalSeconds); this->connect(this->ui->comp_MainInfoArea->getSettingsComponent(), &CSettingsComponent::changedAircraftsUpdateInterval, this->ui->comp_MainInfoArea->getAircraftComponent(), &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::changedAtcStationsUpdateInterval, this->ui->comp_MainInfoArea->getAtcStationComponent(), &::CAtcStationComponent::setUpdateIntervalSeconds);
Q_ASSERT(connect); Q_ASSERT(connect);
Q_UNUSED(connect); // suppress GCC warning in release build Q_UNUSED(connect); // suppress GCC warning in release build
@@ -127,7 +127,7 @@ void MainWindow::init(const CRuntimeConfig &runtimeConfig)
this->initialDataReads(); this->initialDataReads();
// start screen // start screen
this->setMainPage(true); this->ps_setMainPage(true);
// init context menus // init context menus
this->initContextMenus(); this->initContextMenus();
@@ -136,14 +136,14 @@ void MainWindow::init(const CRuntimeConfig &runtimeConfig)
this->getIContextApplication()->notifyAboutComponentChange(IContextApplication::ComponentGui, IContextApplication::ActionStarts); this->getIContextApplication()->notifyAboutComponentChange(IContextApplication::ComponentGui, IContextApplication::ActionStarts);
// We don't receive signals from the past. So ask for it simulate an initial signal // 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 // info
this->ui->te_StatusPageConsole->appendPlainText(CProject::systemNameAndVersion()); this->ui->te_StatusPageConsole->appendPlainText(CProject::systemNameAndVersion());
this->ui->te_StatusPageConsole->appendPlainText(CProject::compiledInfo()); this->ui->te_StatusPageConsole->appendPlainText(CProject::compiledInfo());
// hotkeys // hotkeys
this->registerHotkeys(); this->ps_registerHotkeys();
// update timers // update timers
this->startUpdateTimers(); this->startUpdateTimers();
@@ -164,58 +164,65 @@ void MainWindow::initGuiSignals()
// This is why we still have some "old" SIGNAL/SLOT connections here // This is why we still have some "old" SIGNAL/SLOT connections here
// MAIN buttons // 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); 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); 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); 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); 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); 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); 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); 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); 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); 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); 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); 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); 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); 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); Q_ASSERT(connected);
// Sound buttons // Sound buttons
this->connect(this->ui->pb_SoundMute, &QPushButton::clicked, 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::audioVolumes); this->connect(this->ui->pb_SoundMaxVolume, &QPushButton::clicked, this, &MainWindow::ps_setAudioVolumes);
this->connect(this->ui->comp_Cockpit, &CCockpitV1Component::audioVolumeChanged, this, &MainWindow::audioVolumes); this->connect(this->ui->comp_Cockpit, &CCockpitV1Component::audioVolumeChanged, this, &MainWindow::ps_setAudioVolumes);
// menu // menu
this->connect(this->ui->menu_ReloadSettings, &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::menuClicked); this->connect(this->ui->menu_TestLocationsEDDF, &QAction::triggered, this, &MainWindow::ps_onMenuClicked);
this->connect(this->ui->menu_TestLocationsEDDM, &QAction::triggered, this, &MainWindow::menuClicked); this->connect(this->ui->menu_TestLocationsEDDM, &QAction::triggered, this, &MainWindow::ps_onMenuClicked);
this->connect(this->ui->menu_TestLocationsEDNX, &QAction::triggered, this, &MainWindow::menuClicked); this->connect(this->ui->menu_TestLocationsEDNX, &QAction::triggered, this, &MainWindow::ps_onMenuClicked);
this->connect(this->ui->menu_TestLocationsEDRY, &QAction::triggered, this, &MainWindow::menuClicked); this->connect(this->ui->menu_TestLocationsEDRY, &QAction::triggered, this, &MainWindow::ps_onMenuClicked);
this->connect(this->ui->menu_FileClose, &QAction::triggered, this, &MainWindow::menuClicked); this->connect(this->ui->menu_FileClose, &QAction::triggered, this, &MainWindow::ps_onMenuClicked);
this->connect(this->ui->menu_FileSettingsDirectory, &QAction::triggered, this, &MainWindow::menuClicked); this->connect(this->ui->menu_FileSettingsDirectory, &QAction::triggered, this, &MainWindow::ps_onMenuClicked);
this->connect(this->ui->menu_FileResetSettings, &QAction::triggered, this, &MainWindow::menuClicked); 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 // 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); Q_ASSERT(connected);
this->connect(this->ui->comp_TextMessages, &CTextMessageComponent::displayInInfoWindow, this->m_compInfoWindow, &CInfoWindowComponent::display); this->connect(this->ui->comp_MainInfoArea->getTextMessageComponent(), &CTextMessageComponent::displayInInfoWindow, this->m_compInfoWindow, &CInfoWindowComponent::display);
this->ui->comp_TextMessages->setSelcalCallback(std::bind(&CCockpitV1Component::getSelcalCode, this->ui->comp_Cockpit)); this->ui->comp_MainInfoArea->getTextMessageComponent()->setSelcalCallback(std::bind(&CCockpitV1Component::getSelcalCode, this->ui->comp_Cockpit));
// settings (GUI component) // settings (GUI component), styles
this->connect(this->ui->comp_Settings, &CSettingsComponent::changedWindowsOpacity, this, &MainWindow::changeWindowOpacity); 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 // no warnings in release build
Q_UNUSED(connected); Q_UNUSED(connected);
@@ -230,14 +237,14 @@ void MainWindow::initialDataReads()
this->m_coreAvailable = (this->getIContextNetwork()->usingLocalObjects() || (this->getIContextApplication()->ping(t) == t)); this->m_coreAvailable = (this->getIContextNetwork()->usingLocalObjects() || (this->getIContextApplication()->ping(t) == t));
if (!this->m_coreAvailable) if (!this->m_coreAvailable)
{ {
this->displayStatusMessage(CStatusMessage(CStatusMessage::TypeGui, CStatusMessage::SeverityError, this->ps_displayStatusMessageInGui(CStatusMessage(CStatusMessage::TypeGui, CStatusMessage::SeverityError,
"no initial data read as network context is not available")); "no initial data read as network context is not available"));
return; return;
} }
this->ui->comp_Settings->reloadSettings(); // init read this->ui->comp_MainInfoArea->getSettingsComponent()->reloadSettings(); // init read
this->reloadOwnAircraft(); // init read, independent of traffic network this->ps_reloadOwnAircraft(); // init read, independent of traffic network
this->displayStatusMessage(CStatusMessage(CStatusMessage::TypeGui, CStatusMessage::SeverityInfo, "initial data read")); this->ps_displayStatusMessageInGui(CStatusMessage(CStatusMessage::TypeGui, CStatusMessage::SeverityInfo, "initial data read"));
} }
/* /*
@@ -245,9 +252,9 @@ void MainWindow::initialDataReads()
*/ */
void MainWindow::startUpdateTimers() void MainWindow::startUpdateTimers()
{ {
this->ui->comp_Aircrafts->setUpdateIntervalSeconds(this->ui->comp_Settings->getAircraftUpdateIntervalSeconds()); this->ui->comp_MainInfoArea->getAircraftComponent()->setUpdateIntervalSeconds(this->ui->comp_MainInfoArea->getSettingsComponent()->getAircraftUpdateIntervalSeconds());
this->ui->comp_AtcStations->setUpdateIntervalSeconds(this->ui->comp_Settings->getAtcUpdateIntervalSeconds()); this->ui->comp_MainInfoArea->getAtcStationComponent()->setUpdateIntervalSeconds(this->ui->comp_MainInfoArea->getSettingsComponent()->getAtcUpdateIntervalSeconds());
this->ui->comp_Users->setUpdateIntervalSeconds(this->ui->comp_Settings->getUsersUpdateIntervalSeconds()); this->ui->comp_MainInfoArea->getUserComponent()->setUpdateIntervalSeconds(this->ui->comp_MainInfoArea->getSettingsComponent()->getUsersUpdateIntervalSeconds());
} }
/* /*
@@ -255,11 +262,14 @@ void MainWindow::startUpdateTimers()
*/ */
void MainWindow::stopUpdateTimers() void MainWindow::stopUpdateTimers()
{ {
this->ui->comp_AtcStations->stopTimer(); this->ui->comp_MainInfoArea->getAtcStationComponent()->stopTimer();
this->ui->comp_Aircrafts->stopTimer(); this->ui->comp_MainInfoArea->getAircraftComponent()->stopTimer();
this->ui->comp_Users->stopTimer(); this->ui->comp_MainInfoArea->getUserComponent()->stopTimer();
} }
/*
* Stop all timers
*/
void MainWindow::stopAllTimers(bool disconnect) void MainWindow::stopAllTimers(bool disconnect)
{ {
this->m_timerStatusBar->stop(); this->m_timerStatusBar->stop();

View File

@@ -1,12 +1,15 @@
#include "mainwindow.h" #include "mainwindow.h"
#include "ui_mainwindow.h" #include "ui_mainwindow.h"
#include "blackgui/stylesheetutility.h"
#include "blackmisc/statusmessagelist.h" #include "blackmisc/statusmessagelist.h"
#include "blackmisc/avaltitude.h" #include "blackmisc/avaltitude.h"
#include <QPoint> #include <QPoint>
#include <QMenu> #include <QMenu>
#include <QDesktopServices> #include <QDesktopServices>
#include <QProcess> #include <QProcess>
#include <QFontDialog>
using namespace BlackGui;
using namespace BlackMisc; using namespace BlackMisc;
using namespace BlackMisc::PhysicalQuantities; using namespace BlackMisc::PhysicalQuantities;
using namespace BlackMisc::Aviation; using namespace BlackMisc::Aviation;
@@ -14,7 +17,7 @@ using namespace BlackMisc::Aviation;
/* /*
* Menu clicked * Menu clicked
*/ */
void MainWindow::menuClicked() void MainWindow::ps_onMenuClicked()
{ {
QObject *sender = QObject::sender(); QObject *sender = QObject::sender();
CStatusMessageList msgs; CStatusMessageList msgs;
@@ -37,9 +40,29 @@ void MainWindow::menuClicked()
} }
else if (sender == this->ui->menu_ReloadSettings) else if (sender == this->ui->menu_ReloadSettings)
{ {
this->ui->comp_Settings->reloadSettings(); this->ui->comp_MainInfoArea->getSettingsComponent()->reloadSettings();
msgs.insert(CStatusMessage::getInfoMessage("Settings reloaded")); 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) else if (sender == this->ui->menu_FileClose)
{ {
msgs.insert(CStatusMessage::getInfoMessage("Closing")); msgs.insert(CStatusMessage::getInfoMessage("Closing"));
@@ -55,7 +78,7 @@ void MainWindow::menuClicked()
Q_ASSERT(this->getIContextSettings()); Q_ASSERT(this->getIContextSettings());
msgs.insert(this->getIContextSettings()->reset(true)); 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() void MainWindow::initContextMenus()
{ {
this->ui->lbl_StatusVoiceStatus->setContextMenuPolicy(Qt::CustomContextMenu); 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 * Audio context menu
*/ */
void MainWindow::audioIconContextMenu(const QPoint &position) void MainWindow::ps_displayAudioIconContextMenu(const QPoint &position)
{ {
// position for most widgets // position for most widgets
QWidget *sender = qobject_cast<QWidget *>(QWidget::sender()); QWidget *sender = qobject_cast<QWidget *>(QWidget::sender());

View File

@@ -1,6 +1,7 @@
#include "mainwindow.h" #include "mainwindow.h"
#include "ui_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/dbus_server.h"
#include "blackcore/context_network.h" #include "blackcore/context_network.h"
#include "blackcore/context_audio.h" #include "blackcore/context_audio.h"
@@ -21,7 +22,7 @@ using namespace BlackMisc::Math;
/* /*
* Select audio device * Select audio device
*/ */
void MainWindow::audioVolumes() void MainWindow::ps_setAudioVolumes()
{ {
if (!this->m_contextAudioAvailable) if (!this->m_contextAudioAvailable)
{ {
@@ -75,8 +76,8 @@ void MainWindow::audioVolumes()
com1.setEnabled(!muted); com1.setEnabled(!muted);
com2.setEnabled(!muted); com2.setEnabled(!muted);
this->ui->pb_SoundMute->setText(muted ? "Unmute" : "Mute"); this->ui->pb_SoundMute->setText(muted ? "Unmute" : "Mute");
this->ui->lbl_StatusVoiceStatus->setPixmap(muted ? this->m_resPixmapVoiceMuted : this->m_resPixmapVoiceHigh); this->ui->lbl_StatusVoiceStatus->setPixmap(muted ? CIconsStandard::volumneMuted16() : CIconsStandard::volumneHigh16());
this->ui->comp_Cockpit->setCockpitVoiceStatusPixmap(muted ? this->m_resPixmapVoiceMuted : this->m_resPixmapVoiceHigh); this->ui->comp_Cockpit->setCockpitVoiceStatusPixmap(muted ? CIconsStandard::volumneMuted16() : CIconsStandard::volumneHigh16());
this->ui->pb_SoundMute->setStyleSheet(muted ? "background-color: red;" : ""); this->ui->pb_SoundMute->setStyleSheet(muted ? "background-color: red;" : "");
if (muted) this->m_compInfoWindow->displayStringMessage("Sound is muted!"); if (muted) this->m_compInfoWindow->displayStringMessage("Sound is muted!");
@@ -92,6 +93,6 @@ void MainWindow::audioVolumes()
void MainWindow::playNotifcationSound(CNotificationSounds::Notification notification) const void MainWindow::playNotifcationSound(CNotificationSounds::Notification notification) const
{ {
if (!this->m_contextAudioAvailable) return; 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<uint>(notification), true); this->getIContextAudio()->playNotification(static_cast<uint>(notification), true);
} }

View File

@@ -17,7 +17,6 @@
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
// register // register
Q_INIT_RESOURCE(blackgui);
BlackMisc::initResources(); BlackMisc::initResources();
BlackMisc::registerMetadata(); BlackMisc::registerMetadata();
BlackCore::registerMetadata(); BlackCore::registerMetadata();

View File

@@ -1,15 +1 @@
<RCC> <RCC/>
<qresource prefix="/blackgui">
<file>icons/logingreen.png</file>
<file>icons/loginred.png</file>
<file>icons/loginyellow.png</file>
<file>icons/audiovolumehigh.png</file>
<file>icons/audiovolumelow.png</file>
<file>icons/audiovolumemuted.png</file>
<file>icons/resize.png</file>
<file>icons/close.png</file>
<file>icons/aircraftdeparture.png</file>
<file>icons/apronsmall.jpg</file>
<file>icons/tower.png</file>
</qresource>
</RCC>