mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-05-01 22:55:41 +08:00
refs #892, key sequences / actions for settings
This commit is contained in:
committed by
Mathew Sutcliffe
parent
d504bfbee0
commit
72200d4bba
@@ -22,6 +22,7 @@
|
|||||||
#include <QTabBar>
|
#include <QTabBar>
|
||||||
#include <QToolButton>
|
#include <QToolButton>
|
||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
|
#include <QKeySequence>
|
||||||
|
|
||||||
using namespace BlackMisc;
|
using namespace BlackMisc;
|
||||||
using namespace BlackMisc::Network;
|
using namespace BlackMisc::Network;
|
||||||
@@ -60,11 +61,65 @@ namespace BlackGui
|
|||||||
connect(ui->pb_SimulatorBasics, &QPushButton::released, this, &CSettingsComponent::ps_overviewButtonClicked);
|
connect(ui->pb_SimulatorBasics, &QPushButton::released, this, &CSettingsComponent::ps_overviewButtonClicked);
|
||||||
connect(ui->pb_DataLoadAndCaches, &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);
|
connect(ui->pb_SimulatorMessages, &QPushButton::released, this, &CSettingsComponent::ps_overviewButtonClicked);
|
||||||
|
|
||||||
|
this->initActions();
|
||||||
}
|
}
|
||||||
|
|
||||||
CSettingsComponent::~CSettingsComponent()
|
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
|
bool CSettingsComponent::playNotificationSounds() const
|
||||||
{
|
{
|
||||||
return ui->comp_AudioSetup->playNotificationSounds();
|
return ui->comp_AudioSetup->playNotificationSounds();
|
||||||
@@ -95,5 +150,18 @@ namespace BlackGui
|
|||||||
if (sender == ui->pb_SimulatorMessages) { this->setCurrentIndex(SettingTabSimulatorMessages); return; }
|
if (sender == ui->pb_SimulatorMessages) { this->setCurrentIndex(SettingTabSimulatorMessages); return; }
|
||||||
this->setCurrentIndex(SettingTabOverview);
|
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
|
} // namespace
|
||||||
|
|||||||
@@ -31,7 +31,6 @@ namespace BlackGui
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
//! Tabs
|
//! Tabs
|
||||||
//! \remark needs to be in sync with tab order
|
//! \remark needs to be in sync with tab order
|
||||||
enum SettingTab
|
enum SettingTab
|
||||||
@@ -82,7 +81,13 @@ namespace BlackGui
|
|||||||
//! An overview button was clicked
|
//! An overview button was clicked
|
||||||
void ps_overviewButtonClicked();
|
void ps_overviewButtonClicked();
|
||||||
|
|
||||||
|
//! Action triggered
|
||||||
|
void ps_actionTriggered();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
//! Init actions
|
||||||
|
void initActions();
|
||||||
|
|
||||||
QScopedPointer<Ui::CSettingsComponent> ui;
|
QScopedPointer<Ui::CSettingsComponent> ui;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user