diff --git a/src/blackgui/components/settingscomponent.cpp b/src/blackgui/components/settingscomponent.cpp index 87614f7fd..64ad879bc 100644 --- a/src/blackgui/components/settingscomponent.cpp +++ b/src/blackgui/components/settingscomponent.cpp @@ -22,6 +22,7 @@ #include #include #include +#include using namespace BlackMisc; using namespace BlackMisc::Network; @@ -60,11 +61,65 @@ namespace BlackGui connect(ui->pb_SimulatorBasics, &QPushButton::released, this, &CSettingsComponent::ps_overviewButtonClicked); connect(ui->pb_DataLoadAndCaches, &QPushButton::released, this, &CSettingsComponent::ps_overviewButtonClicked); connect(ui->pb_SimulatorMessages, &QPushButton::released, this, &CSettingsComponent::ps_overviewButtonClicked); + + this->initActions(); } CSettingsComponent::~CSettingsComponent() { } + void CSettingsComponent::initActions() + { + QAction *a = nullptr; + a = new QAction(this); + a->setObjectName("overview"); + a->setShortcut(QKeySequence(Qt::ALT + Qt::Key_S, Qt::Key_O)); + connect(a, &QAction::triggered, this, &CSettingsComponent::ps_actionTriggered); + this->addAction(a); + + a = new QAction(this); + a->setObjectName("audio"); + a->setShortcut(QKeySequence(Qt::ALT + Qt::Key_S, Qt::Key_A)); + ui->pb_Audio->setToolTip(a->shortcut().toString()); + connect(a, &QAction::triggered, this, &CSettingsComponent::ps_actionTriggered); + this->addAction(a); + + a = new QAction(this); + a->setObjectName("data"); + a->setShortcut(QKeySequence(Qt::ALT + Qt::Key_S, Qt::Key_D)); + ui->pb_DataLoadAndCaches->setToolTip(a->shortcut().toString()); + connect(a, &QAction::triggered, this, &CSettingsComponent::ps_actionTriggered); + this->addAction(a); + + a = new QAction(this); + a->setObjectName("gui"); + a->setShortcut(QKeySequence(Qt::ALT + Qt::Key_S, Qt::Key_G)); + ui->pb_Gui->setToolTip(a->shortcut().toString()); + connect(a, &QAction::triggered, this, &CSettingsComponent::ps_actionTriggered); + this->addAction(a); + + a = new QAction(this); + a->setObjectName("hotkeys"); + a->setShortcut(QKeySequence(Qt::ALT + Qt::Key_S, Qt::Key_H)); + ui->pb_Hotkeys->setToolTip(a->shortcut().toString()); + connect(a, &QAction::triggered, this, &CSettingsComponent::ps_actionTriggered); + this->addAction(a); + + a = new QAction(this); + a->setObjectName("network"); + a->setShortcut(QKeySequence(Qt::ALT + Qt::Key_S, Qt::Key_N)); + ui->pb_Network->setToolTip(a->shortcut().toString()); + connect(a, &QAction::triggered, this, &CSettingsComponent::ps_actionTriggered); + this->addAction(a); + + a = new QAction(this); + a->setObjectName("simulator"); + a->setShortcut(QKeySequence(Qt::ALT + Qt::Key_S, Qt::Key_S)); + ui->pb_Simulator->setToolTip(a->shortcut().toString()); + connect(a, &QAction::triggered, this, &CSettingsComponent::ps_actionTriggered); + this->addAction(a); + } + bool CSettingsComponent::playNotificationSounds() const { return ui->comp_AudioSetup->playNotificationSounds(); @@ -95,5 +150,18 @@ namespace BlackGui if (sender == ui->pb_SimulatorMessages) { this->setCurrentIndex(SettingTabSimulatorMessages); return; } this->setCurrentIndex(SettingTabOverview); } + + void CSettingsComponent::ps_actionTriggered() + { + const QString a = QObject::sender()->objectName().toLower().trimmed(); + if (a.isEmpty()) { return; } + if (a.contains("audio")) { this->setCurrentIndex(SettingTabAudio); return; } + if (a.contains("data")) { this->setCurrentIndex(SettingTabDataAndCaches); return; } + if (a.contains("gui")) { this->setCurrentIndex(SettingTabGui); return; } + if (a.contains("hot")) { this->setCurrentIndex(SettingTabHotkeys); return; } + if (a.contains("network")) { this->setCurrentIndex(SettingTabNetwork); return; } + if (a.contains("overview")) { this->setCurrentIndex(SettingTabOverview); return; } + if (a.contains("simulator")) { this->setCurrentIndex(SettingTabSimulator); return; } + } } } // namespace diff --git a/src/blackgui/components/settingscomponent.h b/src/blackgui/components/settingscomponent.h index a3e82c519..197d595ec 100644 --- a/src/blackgui/components/settingscomponent.h +++ b/src/blackgui/components/settingscomponent.h @@ -31,7 +31,6 @@ namespace BlackGui Q_OBJECT public: - //! Tabs //! \remark needs to be in sync with tab order enum SettingTab @@ -82,7 +81,13 @@ namespace BlackGui //! An overview button was clicked void ps_overviewButtonClicked(); + //! Action triggered + void ps_actionTriggered(); + private: + //! Init actions + void initActions(); + QScopedPointer ui; }; }