refs #139 added tab in GUI for changing hotkeys

In order to better identify the models, the model members have been prefixed with "model"
This commit is contained in:
Klaus Basan
2014-02-17 02:36:00 +01:00
parent 87352df468
commit af3a239e40
8 changed files with 207 additions and 87 deletions

View File

@@ -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);

View File

@@ -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 <QMainWindow>
#include <QTextEdit>
@@ -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")

View File

@@ -564,7 +564,7 @@ QStatusBar QLabel {
<rect>
<x>0</x>
<y>0</y>
<width>86</width>
<width>90</width>
<height>59</height>
</rect>
</property>
@@ -1800,7 +1800,7 @@ QStatusBar QLabel {
<item>
<widget class="QTabWidget" name="tb_Settings">
<property name="currentIndex">
<number>0</number>
<number>4</number>
</property>
<widget class="QWidget" name="tb_SettingsTrafficNetwork">
<attribute name="title">
@@ -2306,6 +2306,22 @@ QStatusBar QLabel {
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QSlider" name="hs_SettingsGuiOpacity">
<property name="maximum">
<number>100</number>
</property>
<property name="singleStep">
<number>10</number>
</property>
<property name="value">
<number>100</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="lbl_SettingsGuiAircraftRefreshTime">
<property name="text">
@@ -2367,22 +2383,6 @@ QStatusBar QLabel {
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QSlider" name="hs_SettingsGuiOpacity">
<property name="maximum">
<number>100</number>
</property>
<property name="singleStep">
<number>10</number>
</property>
<property name="value">
<number>100</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="lbl_SettingsGuiUserRefreshTime">
<property name="text">
@@ -2416,6 +2416,71 @@ QStatusBar QLabel {
</item>
</layout>
</widget>
<widget class="QWidget" name="tb_SettingsMisc">
<attribute name="title">
<string>Misc</string>
</attribute>
<layout class="QVBoxLayout" name="vl_SettingsMisc">
<property name="spacing">
<number>3</number>
</property>
<property name="leftMargin">
<number>2</number>
</property>
<property name="topMargin">
<number>2</number>
</property>
<property name="rightMargin">
<number>2</number>
</property>
<property name="bottomMargin">
<number>2</number>
</property>
<item>
<widget class="QTableView" name="tv_SettingsMiscHotkeys">
<property name="cornerButtonEnabled">
<bool>true</bool>
</property>
<attribute name="verticalHeaderVisible">
<bool>false</bool>
</attribute>
</widget>
</item>
<item>
<widget class="QFrame" name="fr_SettingsMisc">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QPushButton" name="pb_SettingsMiscSave">
<property name="text">
<string>Save</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pb_SettingsMiscRemove">
<property name="text">
<string>Remove</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pb_SettingsMiscCancel">
<property name="text">
<string>Cancel</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>

View File

@@ -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();
}

View File

@@ -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)

View File

@@ -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);

View File

@@ -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 <QSortFilterProxyModel>
#include <QSizeGrip>
@@ -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);
}

View File

@@ -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);
}