mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-30 11:55:35 +08:00
refs #912, settings hotkey component, added default hotkey entry for PTT
This commit is contained in:
committed by
Mathew Sutcliffe
parent
142bc82e03
commit
946795a35f
@@ -32,6 +32,8 @@
|
|||||||
using namespace BlackMisc;
|
using namespace BlackMisc;
|
||||||
using namespace BlackMisc::Input;
|
using namespace BlackMisc::Input;
|
||||||
using namespace BlackGui::Models;
|
using namespace BlackGui::Models;
|
||||||
|
using namespace BlackCore;
|
||||||
|
using namespace BlackCore::Context;
|
||||||
|
|
||||||
namespace BlackGui
|
namespace BlackGui
|
||||||
{
|
{
|
||||||
@@ -55,13 +57,25 @@ namespace BlackGui
|
|||||||
CSettingsHotkeyComponent::~CSettingsHotkeyComponent()
|
CSettingsHotkeyComponent::~CSettingsHotkeyComponent()
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
|
void CSettingsHotkeyComponent::saveSettings()
|
||||||
|
{
|
||||||
|
const CStatusMessage msg = m_actionHotkeys.save();
|
||||||
|
CLogMessage(this).preformatted(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSettingsHotkeyComponent::registerDummyPttEntry()
|
||||||
|
{
|
||||||
|
CInputManager::instance()->registerAction(IContextAudio::pttHotkeyAction(), IContextAudio::pttHotkeyIcon());
|
||||||
|
}
|
||||||
|
|
||||||
void CSettingsHotkeyComponent::ps_addEntry()
|
void CSettingsHotkeyComponent::ps_addEntry()
|
||||||
{
|
{
|
||||||
BlackMisc::CIdentifierList registeredApps;
|
BlackMisc::CIdentifierList registeredApps;
|
||||||
if (sGui->getIContextApplication()) registeredApps = sGui->getIContextApplication()->getRegisteredApplications();
|
if (sGui->getIContextApplication()) registeredApps = sGui->getIContextApplication()->getRegisteredApplications();
|
||||||
|
|
||||||
// add local application
|
// add local application
|
||||||
registeredApps.push_back(CIdentifier());
|
registeredApps.push_back(CIdentifier());
|
||||||
auto selectedActionHotkey = CHotkeyDialog::getActionHotkey(CActionHotkey(), registeredApps, this);
|
const auto selectedActionHotkey = CHotkeyDialog::getActionHotkey(CActionHotkey(), registeredApps, this);
|
||||||
if (selectedActionHotkey.isValid() && checkAndConfirmConflicts(selectedActionHotkey))
|
if (selectedActionHotkey.isValid() && checkAndConfirmConflicts(selectedActionHotkey))
|
||||||
{
|
{
|
||||||
addHotkeytoSettings(selectedActionHotkey);
|
addHotkeytoSettings(selectedActionHotkey);
|
||||||
@@ -74,7 +88,7 @@ namespace BlackGui
|
|||||||
|
|
||||||
void CSettingsHotkeyComponent::ps_editEntry()
|
void CSettingsHotkeyComponent::ps_editEntry()
|
||||||
{
|
{
|
||||||
auto index = ui->tv_Hotkeys->selectionModel()->currentIndex();
|
const auto index = ui->tv_Hotkeys->selectionModel()->currentIndex();
|
||||||
if (!index.isValid()) return;
|
if (!index.isValid()) return;
|
||||||
|
|
||||||
const auto model = ui->tv_Hotkeys->model();
|
const auto model = ui->tv_Hotkeys->model();
|
||||||
@@ -97,7 +111,7 @@ namespace BlackGui
|
|||||||
|
|
||||||
void CSettingsHotkeyComponent::ps_removeEntry()
|
void CSettingsHotkeyComponent::ps_removeEntry()
|
||||||
{
|
{
|
||||||
QModelIndexList indexes = ui->tv_Hotkeys->selectionModel()->selectedRows();
|
const QModelIndexList indexes = ui->tv_Hotkeys->selectionModel()->selectedRows();
|
||||||
for (const auto &index : indexes)
|
for (const auto &index : indexes)
|
||||||
{
|
{
|
||||||
CActionHotkey actionHotkey = index.data(CActionHotkeyListModel::ActionHotkeyRole).value<CActionHotkey>();
|
CActionHotkey actionHotkey = index.data(CActionHotkeyListModel::ActionHotkeyRole).value<CActionHotkey>();
|
||||||
@@ -129,7 +143,7 @@ namespace BlackGui
|
|||||||
|
|
||||||
bool CSettingsHotkeyComponent::checkAndConfirmConflicts(const CActionHotkey &actionHotkey, const CActionHotkeyList &ignore)
|
bool CSettingsHotkeyComponent::checkAndConfirmConflicts(const CActionHotkey &actionHotkey, const CActionHotkeyList &ignore)
|
||||||
{
|
{
|
||||||
auto configuredHotkeys = m_actionHotkeys.getThreadLocal();
|
const auto configuredHotkeys = m_actionHotkeys.getThreadLocal();
|
||||||
CActionHotkeyList conflicts = configuredHotkeys.findSupersetsOf(actionHotkey);
|
CActionHotkeyList conflicts = configuredHotkeys.findSupersetsOf(actionHotkey);
|
||||||
conflicts.push_back(configuredHotkeys.findSubsetsOf(actionHotkey));
|
conflicts.push_back(configuredHotkeys.findSubsetsOf(actionHotkey));
|
||||||
conflicts.removeIfIn(ignore);
|
conflicts.removeIfIn(ignore);
|
||||||
@@ -143,9 +157,7 @@ namespace BlackGui
|
|||||||
message += "\n";
|
message += "\n";
|
||||||
}
|
}
|
||||||
message += "\n Do you want to use it anway?";
|
message += "\n Do you want to use it anway?";
|
||||||
auto reply = QMessageBox::warning(this, "SettingsHotkeyComponent",
|
const auto reply = QMessageBox::warning(this, "SettingsHotkeyComponent", message, QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
|
||||||
message,
|
|
||||||
QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
|
|
||||||
if (reply == QMessageBox::No) { return false; }
|
if (reply == QMessageBox::No) { return false; }
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -155,11 +167,13 @@ namespace BlackGui
|
|||||||
{
|
{
|
||||||
const CActionHotkeyList hotkeys = m_actionHotkeys.getThreadLocal();
|
const CActionHotkeyList hotkeys = m_actionHotkeys.getThreadLocal();
|
||||||
m_model.clear();
|
m_model.clear();
|
||||||
for (const auto &hotkey : hotkeys)
|
|
||||||
|
// list of all defined hotkeys (not the dialog)
|
||||||
|
for (const CActionHotkey &hotkey : hotkeys)
|
||||||
{
|
{
|
||||||
const int position = m_model.rowCount();
|
const int position = m_model.rowCount();
|
||||||
m_model.insertRows(position, 1, QModelIndex());
|
m_model.insertRows(position, 1, QModelIndex());
|
||||||
QModelIndex index = m_model.index(position, 0, QModelIndex());
|
const QModelIndex index = m_model.index(position, 0, QModelIndex());
|
||||||
m_model.setData(index, QVariant::fromValue(hotkey), CActionHotkeyListModel::ActionHotkeyRole);
|
m_model.setData(index, QVariant::fromValue(hotkey), CActionHotkeyListModel::ActionHotkeyRole);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -168,5 +182,12 @@ namespace BlackGui
|
|||||||
{
|
{
|
||||||
if (keyDown) { QMessageBox::information(this, "Test", "Hotkey test"); }
|
if (keyDown) { QMessageBox::information(this, "Test", "Hotkey test"); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CConfigHotkeyWizardPage::validatePage()
|
||||||
|
{
|
||||||
|
if (CConfigurationWizard::lastWizardStepSkipped(this->wizard())) { return true; }
|
||||||
|
m_config->saveSettings();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
} // ns
|
} // ns
|
||||||
} // ns
|
} // ns
|
||||||
|
|||||||
@@ -16,13 +16,12 @@
|
|||||||
#include "blackcore/application/applicationsettings.h"
|
#include "blackcore/application/applicationsettings.h"
|
||||||
#include "blackgui/blackguiexport.h"
|
#include "blackgui/blackguiexport.h"
|
||||||
#include "blackgui/models/actionhotkeylistmodel.h"
|
#include "blackgui/models/actionhotkeylistmodel.h"
|
||||||
#include "blackmisc/input/actionhotkey.h"
|
|
||||||
#include "blackmisc/input/actionhotkeylist.h"
|
|
||||||
#include "blackmisc/settingscache.h"
|
#include "blackmisc/settingscache.h"
|
||||||
#include "blackmisc/icons.h"
|
#include "blackmisc/icons.h"
|
||||||
|
|
||||||
#include <QFrame>
|
#include <QFrame>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
#include <QWizardPage>
|
||||||
#include <QScopedPointer>
|
#include <QScopedPointer>
|
||||||
|
|
||||||
class QWidget;
|
class QWidget;
|
||||||
@@ -45,6 +44,12 @@ namespace BlackGui
|
|||||||
//! Destructor
|
//! Destructor
|
||||||
virtual ~CSettingsHotkeyComponent();
|
virtual ~CSettingsHotkeyComponent();
|
||||||
|
|
||||||
|
//! Save settings
|
||||||
|
void saveSettings();
|
||||||
|
|
||||||
|
//! Create dummy/emtpy Ptt entry for wizard
|
||||||
|
void registerDummyPttEntry();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void ps_addEntry();
|
void ps_addEntry();
|
||||||
void ps_editEntry();
|
void ps_editEntry();
|
||||||
@@ -63,6 +68,25 @@ namespace BlackGui
|
|||||||
BlackMisc::CSetting<BlackCore::Application::TActionHotkeys> m_actionHotkeys { this };
|
BlackMisc::CSetting<BlackCore::Application::TActionHotkeys> m_actionHotkeys { this };
|
||||||
BlackCore::CActionBind m_action { "/Test/Message", BlackMisc::CIcons::wrench16(), this, &CSettingsHotkeyComponent::ps_hotkeySlot };
|
BlackCore::CActionBind m_action { "/Test/Message", BlackMisc::CIcons::wrench16(), this, &CSettingsHotkeyComponent::ps_hotkeySlot };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wizard page for CConfigSimulatorComponent
|
||||||
|
*/
|
||||||
|
class CConfigHotkeyWizardPage : public QWizardPage
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
//! Constructors
|
||||||
|
using QWizardPage::QWizardPage;
|
||||||
|
|
||||||
|
//! Set config
|
||||||
|
void setConfigComponent(CSettingsHotkeyComponent *config) { m_config = config; }
|
||||||
|
|
||||||
|
//! \copydoc QWizardPage::validatePage
|
||||||
|
virtual bool validatePage() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
CSettingsHotkeyComponent *m_config = nullptr;
|
||||||
|
};
|
||||||
} // ns
|
} // ns
|
||||||
} // ns
|
} // ns
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user