From af3a239e401407658102dcbef20b505c33acfd25 Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Mon, 17 Feb 2014 02:36:00 +0100 Subject: [PATCH] refs #139 added tab in GUI for changing hotkeys In order to better identify the models, the model members have been prefixed with "model" --- samples/blackgui/mainwindow.cpp | 11 +-- samples/blackgui/mainwindow.h | 25 ++++-- samples/blackgui/mainwindow.ui | 101 +++++++++++++++++++---- samples/blackgui/mainwindow_aircraft.cpp | 2 +- samples/blackgui/mainwindow_atc.cpp | 8 +- samples/blackgui/mainwindow_cockpit.cpp | 8 +- samples/blackgui/mainwindow_init.cpp | 99 +++++++++++++--------- samples/blackgui/mainwindow_settings.cpp | 40 +++++++-- 8 files changed, 207 insertions(+), 87 deletions(-) diff --git a/samples/blackgui/mainwindow.cpp b/samples/blackgui/mainwindow.cpp index a1146ed12..8f0bd236d 100644 --- a/samples/blackgui/mainwindow.cpp +++ b/samples/blackgui/mainwindow.cpp @@ -27,8 +27,8 @@ MainWindow::MainWindow(GuiModes::WindowMode windowMode, QWidget *parent) : m_dBusConnection("dummy"), // table view models m_statusMessageList(nullptr), - m_atcListOnline(nullptr), m_atcListBooked(nullptr), m_trafficServerList(nullptr), m_aircraftsInRange(nullptr), - m_allUsers(nullptr), m_usersVoiceCom1(nullptr), m_usersVoiceCom2(nullptr), + m_modelAtcListOnline(nullptr), m_modelAtcListBooked(nullptr), m_modelTrafficServerList(nullptr), m_modelAircraftsInRange(nullptr), + m_modelAllUsers(nullptr), m_modelUsersVoiceCom1(nullptr), m_modelUsersVoiceCom2(nullptr), m_modelSettingsHotKeys(nullptr), // contexts and runtime m_coreMode(GuiModes::CoreExternal), m_coreAvailable(false), m_contextNetworkAvailable(false), m_contextVoiceAvailable(false), @@ -108,8 +108,9 @@ void MainWindow::gracefulShutdown() */ void MainWindow::closeEvent(QCloseEvent *event) { + Q_UNUSED(event); this->gracefulShutdown(); - QMainWindow::closeEvent(event); + // if (this->sender() != this) QMainWindow::closeEvent(event); QApplication::exit(); } @@ -372,7 +373,7 @@ void MainWindow::middlePanelChanged(int /* index */) if (this->ui->sw_MainMiddle->currentWidget() == this->ui->pg_AircraftsInRange) { - if (this->m_aircraftsInRange->rowCount() < 1) + if (this->m_modelAircraftsInRange->rowCount() < 1) this->reloadAircraftsInRange(); } } @@ -483,7 +484,7 @@ void MainWindow::displayOverlayInfo(const CStatusMessage &message) void MainWindow::reloadAllUsers() { if (!this->isContextNetworkAvailableCheck()) return; - this->m_allUsers->update(this->m_contextNetwork->getUsers()); + this->m_modelAllUsers->update(this->m_contextNetwork->getUsers()); this->ui->tv_AllUsers->resizeColumnsToContents(); this->ui->tv_AllUsers->resizeRowsToContents(); this->ui->tv_AllUsers->horizontalHeader()->setStretchLastSection(true); diff --git a/samples/blackgui/mainwindow.h b/samples/blackgui/mainwindow.h index 672f18057..a22975a9c 100644 --- a/samples/blackgui/mainwindow.h +++ b/samples/blackgui/mainwindow.h @@ -22,6 +22,7 @@ #include "blackgui/aircraftlistmodel.h" #include "blackgui/userlistmodel.h" #include "blackgui/statusmessagelistmodel.h" +#include "blackgui/keyboardkeylistmodel.h" #include "blackmisc/nwtextmessage.h" #include #include @@ -113,13 +114,14 @@ private: // the table view models // normal pointers, as these will be deleted by parent BlackGui::CStatusMessageListModel *m_statusMessageList; - BlackGui::CAtcListModel *m_atcListOnline; - BlackGui::CAtcListModel *m_atcListBooked; - BlackGui::CServerListModel *m_trafficServerList; - BlackGui::CAircraftListModel *m_aircraftsInRange; - BlackGui::CUserListModel *m_allUsers; - BlackGui::CUserListModel *m_usersVoiceCom1; - BlackGui::CUserListModel *m_usersVoiceCom2; + BlackGui::CAtcListModel *m_modelAtcListOnline; + BlackGui::CAtcListModel *m_modelAtcListBooked; + BlackGui::CServerListModel *m_modelTrafficServerList; + BlackGui::CAircraftListModel *m_modelAircraftsInRange; + BlackGui::CUserListModel *m_modelAllUsers; + BlackGui::CUserListModel *m_modelUsersVoiceCom1; + BlackGui::CUserListModel *m_modelUsersVoiceCom2; + BlackGui::CKeyboardKeyListModel *m_modelSettingsHotKeys; // contexts GuiModes::CoreMode m_coreMode; @@ -423,7 +425,7 @@ private slots: /*! * \brief Network settings have been changed */ - void changedNetworkSettings(); + void changedSettings(); /*! * \brief Update timer @@ -504,10 +506,15 @@ private slots: //! \brief start the MIC tests (Squelch) void startAudioTest(); - //! \brief inputFocusChanged + //! \brief Input focus changed, used to detect whether an input control has focus //! \sa QApplication::focusChanged void inputFocusChanged(QWidget *oldWidget, QWidget *newWidget); + //! Save the Hotkeys + void saveHotkeys(); + + //! Clear single hotkey + void clearHotkey(); }; #pragma pop_macro("interface") diff --git a/samples/blackgui/mainwindow.ui b/samples/blackgui/mainwindow.ui index 6aa9d67ea..975783655 100644 --- a/samples/blackgui/mainwindow.ui +++ b/samples/blackgui/mainwindow.ui @@ -564,7 +564,7 @@ QStatusBar QLabel { 0 0 - 86 + 90 59 @@ -1800,7 +1800,7 @@ QStatusBar QLabel { - 0 + 4 @@ -2306,6 +2306,22 @@ QStatusBar QLabel { + + + + 100 + + + 10 + + + 100 + + + Qt::Horizontal + + + @@ -2367,22 +2383,6 @@ QStatusBar QLabel { - - - - 100 - - - 10 - - - 100 - - - Qt::Horizontal - - - @@ -2416,6 +2416,71 @@ QStatusBar QLabel { + + + Misc + + + + 3 + + + 2 + + + 2 + + + 2 + + + 2 + + + + + true + + + false + + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + Save + + + + + + + Remove + + + + + + + Cancel + + + + + + + + diff --git a/samples/blackgui/mainwindow_aircraft.cpp b/samples/blackgui/mainwindow_aircraft.cpp index dfd6019f5..94583e4b8 100644 --- a/samples/blackgui/mainwindow_aircraft.cpp +++ b/samples/blackgui/mainwindow_aircraft.cpp @@ -20,7 +20,7 @@ using namespace BlackMisc::Voice; void MainWindow::reloadAircraftsInRange() { if (!this->isContextNetworkAvailableCheck()) return; - this->m_aircraftsInRange->update(this->m_contextNetwork->getAircraftsInRange()); + this->m_modelAircraftsInRange->update(this->m_contextNetwork->getAircraftsInRange()); this->ui->tv_AircraftsInRange->resizeColumnsToContents(); this->ui->tv_AircraftsInRange->resizeRowsToContents(); } diff --git a/samples/blackgui/mainwindow_atc.cpp b/samples/blackgui/mainwindow_atc.cpp index 1a124d4ff..567a671c9 100644 --- a/samples/blackgui/mainwindow_atc.cpp +++ b/samples/blackgui/mainwindow_atc.cpp @@ -20,7 +20,7 @@ using namespace BlackMisc::Settings; void MainWindow::reloadAtcStationsBooked() { if (!this->isContextNetworkAvailableCheck()) return; - this->m_atcListBooked->update(this->m_contextNetwork->getAtcStationsBooked()); + this->m_modelAtcListBooked->update(this->m_contextNetwork->getAtcStationsBooked()); this->ui->tv_AtcStationsBooked->resizeColumnsToContents(); this->ui->tv_AtcStationsBooked->resizeRowsToContents(); } @@ -31,7 +31,7 @@ void MainWindow::reloadAtcStationsBooked() void MainWindow::reloadAtcStationsOnline() { if (!this->isContextNetworkAvailableCheck()) return; - this->m_atcListOnline->update(this->m_contextNetwork->getAtcStationsOnline()); + this->m_modelAtcListOnline->update(this->m_contextNetwork->getAtcStationsOnline()); this->ui->tv_AtcStationsOnline->resizeColumnsToContents(); this->ui->tv_AtcStationsOnline->resizeRowsToContents(); @@ -51,7 +51,7 @@ void MainWindow::reloadAtcStationsOnline() void MainWindow::onlineAtcStationSelected(QModelIndex index) { this->ui->te_AtcStationsOnlineInfo->setText(""); // reset - const CAtcStation stationClicked = this->m_atcListOnline->at(index); + const CAtcStation stationClicked = this->m_modelAtcListOnline->at(index); QString infoMessage; if (stationClicked.hasAtis()) @@ -101,7 +101,7 @@ void MainWindow::atcStationTabChanged(int /** tabIndex **/) { if (this->ui->tw_AtcStations->currentWidget() == this->ui->tb_AtcStationsBooked) { - if (this->m_atcListBooked->rowCount() < 1) + if (this->m_modelAtcListBooked->rowCount() < 1) this->reloadAtcStationsBooked(); } else if (this->ui->tw_AtcStations->currentWidget() == this->ui->tb_AtcStationsOnline) diff --git a/samples/blackgui/mainwindow_cockpit.cpp b/samples/blackgui/mainwindow_cockpit.cpp index 508e4b5f1..e5c0ea4bb 100644 --- a/samples/blackgui/mainwindow_cockpit.cpp +++ b/samples/blackgui/mainwindow_cockpit.cpp @@ -136,8 +136,8 @@ void MainWindow::updateCockpitFromContext() // these are the ones featuring the real audio status CVoiceRoomList rooms = this->m_contextVoice->getComVoiceRoomsWithAudioStatus(); Q_ASSERT(rooms.size() == 2); - Q_ASSERT(this->m_usersVoiceCom1); - Q_ASSERT(this->m_usersVoiceCom2); + Q_ASSERT(this->m_modelUsersVoiceCom1); + Q_ASSERT(this->m_modelUsersVoiceCom2); CVoiceRoom room1 = rooms[0]; CVoiceRoom room2 = rooms[1]; @@ -145,12 +145,12 @@ void MainWindow::updateCockpitFromContext() bool com2Connected = room2.isConnected(); // update views - this->m_usersVoiceCom1->update(this->m_contextVoice->getCom1RoomUsers()); + this->m_modelUsersVoiceCom1->update(this->m_contextVoice->getCom1RoomUsers()); this->ui->tv_CockpitVoiceRoom1->resizeColumnsToContents(); this->ui->tv_CockpitVoiceRoom1->resizeRowsToContents(); this->ui->tv_CockpitVoiceRoom1->horizontalHeader()->setStretchLastSection(true); - this->m_usersVoiceCom2->update(this->m_contextVoice->getCom2RoomUsers()); + this->m_modelUsersVoiceCom2->update(this->m_contextVoice->getCom2RoomUsers()); this->ui->tv_CockpitVoiceRoom2->resizeColumnsToContents(); this->ui->tv_CockpitVoiceRoom2->resizeRowsToContents(); this->ui->tv_CockpitVoiceRoom2->horizontalHeader()->setStretchLastSection(true); diff --git a/samples/blackgui/mainwindow_init.cpp b/samples/blackgui/mainwindow_init.cpp index 3391df036..14ba7ad8d 100644 --- a/samples/blackgui/mainwindow_init.cpp +++ b/samples/blackgui/mainwindow_init.cpp @@ -4,6 +4,7 @@ #include "blackcore/context_network.h" #include "blackcore/coreruntime.h" #include "blackgui/atcstationlistmodel.h" +#include "blackgui/keyboardkeylistmodel.h" #include "blackmisc/avselcal.h" #include #include @@ -50,30 +51,33 @@ void MainWindow::init(GuiModes::CoreMode coreMode) if (this->m_statusMessageList != nullptr) this->m_statusMessageList->deleteLater(); this->m_statusMessageList = new CStatusMessageListModel(this); - if (this->m_atcListBooked != nullptr) this->m_atcListBooked->deleteLater(); - this->m_atcListBooked = new CAtcListModel(this); + if (this->m_modelAtcListBooked != nullptr) this->m_modelAtcListBooked->deleteLater(); + this->m_modelAtcListBooked = new CAtcListModel(this); - if (this->m_atcListOnline != nullptr) this->m_atcListOnline->deleteLater(); - this->m_atcListOnline = new CAtcListModel(this); + if (this->m_modelAtcListOnline != nullptr) this->m_modelAtcListOnline->deleteLater(); + this->m_modelAtcListOnline = new CAtcListModel(this); - if (this->m_trafficServerList != nullptr) this->m_trafficServerList->deleteLater(); - this->m_trafficServerList = new CServerListModel(this); + if (this->m_modelTrafficServerList != nullptr) this->m_modelTrafficServerList->deleteLater(); + this->m_modelTrafficServerList = new CServerListModel(this); - if (this->m_aircraftsInRange != nullptr) this->m_aircraftsInRange->deleteLater(); - this->m_aircraftsInRange = new CAircraftListModel(this); + if (this->m_modelAircraftsInRange != nullptr) this->m_modelAircraftsInRange->deleteLater(); + this->m_modelAircraftsInRange = new CAircraftListModel(this); - if (this->m_allUsers != nullptr) this->m_allUsers->deleteLater(); - this->m_allUsers = new CUserListModel(this); + if (this->m_modelAllUsers != nullptr) this->m_modelAllUsers->deleteLater(); + this->m_modelAllUsers = new CUserListModel(this); - if (this->m_usersVoiceCom1 != nullptr) this->m_usersVoiceCom1->deleteLater(); - this->m_usersVoiceCom1 = new CUserListModel(this); + if (this->m_modelUsersVoiceCom1 != nullptr) this->m_modelUsersVoiceCom1->deleteLater(); + this->m_modelUsersVoiceCom1 = new CUserListModel(this); - if (this->m_usersVoiceCom2 != nullptr) this->m_usersVoiceCom2->deleteLater(); - this->m_usersVoiceCom2 = new CUserListModel(this); + if (this->m_modelUsersVoiceCom2 != nullptr) this->m_modelUsersVoiceCom2->deleteLater(); + this->m_modelUsersVoiceCom2 = new CUserListModel(this); + + if (this->m_modelSettingsHotKeys != nullptr) this->m_modelSettingsHotKeys->deleteLater(); + this->m_modelSettingsHotKeys = new CKeyboardKeyListModel(this); // set sort order and models // enable first, otherwise order in the model will be reset - this->ui->tv_SettingsTnServers->setModel(this->m_trafficServerList); + this->ui->tv_SettingsTnServers->setModel(this->m_modelTrafficServerList); this->ui->tv_StatusMessages->setSortingEnabled(true); this->ui->tv_StatusMessages->setModel(this->m_statusMessageList); @@ -82,52 +86,62 @@ void MainWindow::init(GuiModes::CoreMode coreMode) this->ui->tv_StatusMessages->horizontalHeader()->setSortIndicator(this->m_statusMessageList->getSortColumn(), this->m_statusMessageList->getSortOrder()); this->ui->tv_AtcStationsOnline->setSortingEnabled(true); - this->ui->tv_AtcStationsOnline->setModel(this->m_atcListOnline); - this->m_atcListBooked->setSortColumnByPropertyIndex(BlackMisc::Aviation::CAtcStation::IndexDistance); - if (this->m_atcListOnline->hasValidSortColumn()) - this->ui->tv_AtcStationsOnline->horizontalHeader()->setSortIndicator(this->m_atcListOnline->getSortColumn(), this->m_atcListOnline->getSortOrder()); + this->ui->tv_AtcStationsOnline->setModel(this->m_modelAtcListOnline); + this->m_modelAtcListBooked->setSortColumnByPropertyIndex(BlackMisc::Aviation::CAtcStation::IndexDistance); + if (this->m_modelAtcListOnline->hasValidSortColumn()) + this->ui->tv_AtcStationsOnline->horizontalHeader()->setSortIndicator(this->m_modelAtcListOnline->getSortColumn(), this->m_modelAtcListOnline->getSortOrder()); this->ui->tv_AtcStationsBooked->setSortingEnabled(true); - this->ui->tv_AtcStationsBooked->setModel(this->m_atcListBooked); - this->m_atcListBooked->setSortColumnByPropertyIndex(BlackMisc::Aviation::CAtcStation::IndexBookedFrom); - if (this->m_atcListBooked->hasValidSortColumn()) - this->ui->tv_AtcStationsBooked->horizontalHeader()->setSortIndicator(this->m_atcListBooked->getSortColumn(), this->m_atcListBooked->getSortOrder()); + this->ui->tv_AtcStationsBooked->setModel(this->m_modelAtcListBooked); + this->m_modelAtcListBooked->setSortColumnByPropertyIndex(BlackMisc::Aviation::CAtcStation::IndexBookedFrom); + if (this->m_modelAtcListBooked->hasValidSortColumn()) + this->ui->tv_AtcStationsBooked->horizontalHeader()->setSortIndicator(this->m_modelAtcListBooked->getSortColumn(), this->m_modelAtcListBooked->getSortOrder()); this->ui->tv_AircraftsInRange->setSortingEnabled(true); - this->ui->tv_AircraftsInRange->setModel(this->m_aircraftsInRange); - this->m_atcListBooked->setSortColumnByPropertyIndex(BlackMisc::Aviation::CAircraft::IndexDistance); - if (this->m_aircraftsInRange->hasValidSortColumn()) - this->ui->tv_AircraftsInRange->horizontalHeader()->setSortIndicator(this->m_aircraftsInRange->getSortColumn(), this->m_aircraftsInRange->getSortOrder()); + this->ui->tv_AircraftsInRange->setModel(this->m_modelAircraftsInRange); + this->m_modelAtcListBooked->setSortColumnByPropertyIndex(BlackMisc::Aviation::CAircraft::IndexDistance); + if (this->m_modelAircraftsInRange->hasValidSortColumn()) + this->ui->tv_AircraftsInRange->horizontalHeader()->setSortIndicator(this->m_modelAircraftsInRange->getSortColumn(), this->m_modelAircraftsInRange->getSortOrder()); this->ui->tv_AircraftsInRange->resizeColumnsToContents(); this->ui->tv_AircraftsInRange->resizeRowsToContents(); this->ui->tv_AllUsers->setSortingEnabled(true); - this->ui->tv_AllUsers->setModel(this->m_allUsers); - this->m_allUsers->setSortColumnByPropertyIndex(BlackMisc::Network::CUser::IndexRealName); - if (this->m_allUsers->hasValidSortColumn()) - this->ui->tv_AllUsers->horizontalHeader()->setSortIndicator(this->m_allUsers->getSortColumn(), this->m_allUsers->getSortOrder()); + this->ui->tv_AllUsers->setModel(this->m_modelAllUsers); + this->m_modelAllUsers->setSortColumnByPropertyIndex(BlackMisc::Network::CUser::IndexRealName); + if (this->m_modelAllUsers->hasValidSortColumn()) + this->ui->tv_AllUsers->horizontalHeader()->setSortIndicator(this->m_modelAllUsers->getSortColumn(), this->m_modelAllUsers->getSortOrder()); this->ui->tv_AllUsers->resizeColumnsToContents(); this->ui->tv_AllUsers->resizeRowsToContents(); this->ui->tv_AllUsers->horizontalHeader()->setStretchLastSection(true); this->ui->tv_CockpitVoiceRoom1->setSortingEnabled(true); - this->ui->tv_CockpitVoiceRoom1->setModel(this->m_usersVoiceCom1); - this->m_usersVoiceCom1->setSortColumnByPropertyIndex(BlackMisc::Network::CUser::IndexRealName); - if (this->m_usersVoiceCom1->hasValidSortColumn()) - this->ui->tv_CockpitVoiceRoom1->horizontalHeader()->setSortIndicator(this->m_usersVoiceCom1->getSortColumn(), this->m_usersVoiceCom1->getSortOrder()); + this->ui->tv_CockpitVoiceRoom1->setModel(this->m_modelUsersVoiceCom1); + this->m_modelUsersVoiceCom1->setSortColumnByPropertyIndex(BlackMisc::Network::CUser::IndexRealName); + if (this->m_modelUsersVoiceCom1->hasValidSortColumn()) + this->ui->tv_CockpitVoiceRoom1->horizontalHeader()->setSortIndicator(this->m_modelUsersVoiceCom1->getSortColumn(), this->m_modelUsersVoiceCom1->getSortOrder()); this->ui->tv_CockpitVoiceRoom1->resizeColumnsToContents(); this->ui->tv_CockpitVoiceRoom1->resizeRowsToContents(); this->ui->tv_CockpitVoiceRoom1->horizontalHeader()->setStretchLastSection(true); this->ui->tv_CockpitVoiceRoom2->setSortingEnabled(true); - this->ui->tv_CockpitVoiceRoom2->setModel(this->m_usersVoiceCom2); - this->m_usersVoiceCom2->setSortColumnByPropertyIndex(BlackMisc::Network::CUser::IndexRealName); - if (this->m_usersVoiceCom1->hasValidSortColumn()) - this->ui->tv_CockpitVoiceRoom2->horizontalHeader()->setSortIndicator(this->m_usersVoiceCom2->getSortColumn(), this->m_usersVoiceCom2->getSortOrder()); + this->ui->tv_CockpitVoiceRoom2->setModel(this->m_modelUsersVoiceCom2); + this->m_modelUsersVoiceCom2->setSortColumnByPropertyIndex(BlackMisc::Network::CUser::IndexRealName); + if (this->m_modelUsersVoiceCom1->hasValidSortColumn()) + this->ui->tv_CockpitVoiceRoom2->horizontalHeader()->setSortIndicator(this->m_modelUsersVoiceCom2->getSortColumn(), this->m_modelUsersVoiceCom2->getSortOrder()); this->ui->tv_CockpitVoiceRoom2->resizeColumnsToContents(); this->ui->tv_CockpitVoiceRoom2->resizeRowsToContents(); this->ui->tv_CockpitVoiceRoom2->horizontalHeader()->setStretchLastSection(true); + this->ui->tv_SettingsMiscHotkeys->setSortingEnabled(true); + this->ui->tv_SettingsMiscHotkeys->setModel(this->m_modelSettingsHotKeys); + this->m_modelSettingsHotKeys->setSortColumnByPropertyIndex(BlackMisc::Hardware::CKeyboardKey::IndexFunctionAsString); + if (this->m_modelSettingsHotKeys->hasValidSortColumn()) + this->ui->tv_SettingsMiscHotkeys->horizontalHeader()->setSortIndicator(this->m_modelSettingsHotKeys->getSortColumn(), this->m_modelSettingsHotKeys->getSortOrder()); + this->ui->tv_SettingsMiscHotkeys->resizeColumnsToContents(); + this->ui->tv_SettingsMiscHotkeys->resizeRowsToContents(); + this->ui->tv_SettingsMiscHotkeys->horizontalHeader()->setStretchLastSection(true); + this->ui->tv_SettingsMiscHotkeys->setItemDelegate(new BlackGui::CKeyboardKeyItemDelegate(this->ui->tv_SettingsMiscHotkeys)); + // SELCAL pairs in cockpit this->ui->cb_CockpitSelcal1->clear(); this->ui->cb_CockpitSelcal2->clear(); @@ -191,7 +205,7 @@ void MainWindow::init(GuiModes::CoreMode coreMode) this->connect(this->m_contextNetwork, &IContextNetwork::statusMessages, this, &MainWindow::displayStatusMessages); this->connect(this->m_contextNetwork, &IContextNetwork::connectionTerminated, this, &MainWindow::connectionTerminated); this->connect(this->m_contextNetwork, &IContextNetwork::connectionStatusChanged, this, &MainWindow::connectionStatusChanged); - this->connect(this->m_contextSettings, &IContextSettings::changedNetworkSettings, this, &MainWindow::changedNetworkSettings); + this->connect(this->m_contextSettings, &IContextSettings::changedSettings, this, &MainWindow::changedSettings); connect = this->connect(this->m_contextNetwork, SIGNAL(textMessagesReceived(BlackMisc::Network::CTextMessageList)), this, SLOT(appendTextMessagesToGui(BlackMisc::Network::CTextMessageList))); Q_ASSERT(connect); this->connect(this->m_timerUpdateAircraftsInRange, &QTimer::timeout, this, &MainWindow::timerBasedUpdates); @@ -328,6 +342,11 @@ void MainWindow::initGuiSignals() // Settings this->connect(this->ui->hs_SettingsGuiOpacity, &QSlider::valueChanged, this, &MainWindow::changeWindowOpacity); + // Settings hotkeys + this->connect(this->ui->pb_SettingsMiscCancel, &QPushButton::clicked, this, &MainWindow::reloadSettings); + this->connect(this->ui->pb_SettingsMiscSave, &QPushButton::clicked, this, &MainWindow::saveHotkeys); + this->connect(this->ui->pb_SettingsMiscRemove, &QPushButton::clicked, this, &MainWindow::clearHotkey); + // no warnings in release build Q_UNUSED(connected); } diff --git a/samples/blackgui/mainwindow_settings.cpp b/samples/blackgui/mainwindow_settings.cpp index 412b0573e..34e5399fa 100644 --- a/samples/blackgui/mainwindow_settings.cpp +++ b/samples/blackgui/mainwindow_settings.cpp @@ -3,6 +3,7 @@ #include "blackgui/atcstationlistmodel.h" #include "blackcore/dbus_server.h" #include "blackcore/context_network.h" +#include "blackmisc/hwkeyboardkey.h" using namespace BlackCore; using namespace BlackMisc; @@ -22,11 +23,16 @@ void MainWindow::reloadSettings() CSettingsNetwork nws = this->m_contextSettings->getNetworkSettings(); // update servers - this->m_trafficServerList->setSelectedServer(nws.getCurrentNetworkServer()); - this->m_trafficServerList->update(nws.getTrafficNetworkServers()); + this->m_modelTrafficServerList->setSelectedServer(nws.getCurrentNetworkServer()); + this->m_modelTrafficServerList->update(nws.getTrafficNetworkServers()); this->ui->tv_SettingsTnServers->resizeColumnsToContents(); this->ui->tv_SettingsTnServers->resizeRowsToContents(); + // update hot keys + this->m_modelSettingsHotKeys->update(this->m_contextSettings->getHotkeys()); + this->ui->tv_SettingsMiscHotkeys->resizeColumnsToContents(); + this->ui->tv_SettingsMiscHotkeys->resizeRowsToContents(); + // fake setting for sound notifications this->ui->cb_SettingsAudioPlayNotificationSounds->setChecked(true); this->ui->cb_SettingsAudioNotificationTextMessage->setChecked(true); @@ -37,7 +43,7 @@ void MainWindow::reloadSettings() */ void MainWindow::networkServerSelected(QModelIndex index) { - const CServer clickedServer = this->m_trafficServerList->at(index); + const CServer clickedServer = this->m_modelTrafficServerList->at(index); this->updateGuiSelectedServerTextboxes(clickedServer); } @@ -54,7 +60,7 @@ void MainWindow::alterTrafficServer() return; } - const QString path = CSettingUtilities::appendPaths(IContextSettings::PathNetworkSettings(), CSettingsNetwork::PathTrafficServer()); + const QString path = CSettingUtilities::appendPaths(IContextSettings::PathNetworkSettings(), CSettingsNetwork::ValueTrafficServer()); QObject *sender = QObject::sender(); CStatusMessageList msgs; if (sender == this->ui->pb_SettingsTnCurrentServer) @@ -75,9 +81,9 @@ void MainWindow::alterTrafficServer() } /* - * Network settings did changed + * Settings did changed */ -void MainWindow::changedNetworkSettings() +void MainWindow::changedSettings() { this->reloadSettings(); } @@ -118,3 +124,25 @@ CServer MainWindow::selectedServerFromTextboxes() const return server; } + +/* + * Save the hotkeys + */ +void MainWindow::saveHotkeys() +{ + const QString path = CSettingUtilities::appendPaths(IContextSettings::PathRoot(), IContextSettings::PathHotkeys()); + CStatusMessageList msgs = this->m_contextSettings->value(path, CSettingUtilities::CmdUpdate(), this->m_modelSettingsHotKeys->getContainer().toQVariant()); + + // status messages + this->displayStatusMessages(msgs); +} + +void MainWindow::clearHotkey() +{ + QModelIndex i = this->ui->tv_SettingsMiscHotkeys->currentIndex(); + if (i.row() < 0 || i.row() >= this->m_modelSettingsHotKeys->rowCount()) return; + BlackMisc::Hardware::CKeyboardKey key = this->m_modelSettingsHotKeys->at(i); + BlackMisc::Hardware::CKeyboardKey defKey; + defKey.setFunction(key.getFunction()); + this->m_modelSettingsHotKeys->update(i, defKey); +}