|
|
|
|
@ -15,6 +15,10 @@
|
|
|
|
|
#include <QFormLayout> |
|
|
|
|
#include <QSpinBox> |
|
|
|
|
#include <QCheckBox> |
|
|
|
|
#include <QKeyEvent> |
|
|
|
|
#ifdef Q_OS_WIN |
|
|
|
|
#include <qt_windows.h> |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
RadioSettingsPage::RadioSettingsPage(DbManager* db, QWidget* parent) : QWidget(parent), m_db(db) { |
|
|
|
|
auto* layout = new QVBoxLayout(this); |
|
|
|
|
@ -136,6 +140,7 @@ RadioSettingsPage::~RadioSettingsPage() {
|
|
|
|
|
|
|
|
|
|
void RadioSettingsPage::startCapture(int index) { |
|
|
|
|
finishCapture(false); |
|
|
|
|
DEBUG_INFO(DEBUG_CATEGORY_RADIO, "PTT: recording requested slot=%d", index + 1); |
|
|
|
|
if (!PttHotkeyManager::instance()->beginCapture()) { |
|
|
|
|
m_labels[index]->setText(QCoreApplication::translate("ChatGui", "Failed to start key recording. See the radio log for details.")); |
|
|
|
|
return; |
|
|
|
|
@ -152,7 +157,11 @@ void RadioSettingsPage::finishCapture(bool save) {
|
|
|
|
|
int index = m_captureIndex; |
|
|
|
|
if (save) { |
|
|
|
|
m_chords[index] = m_capture.candidate; |
|
|
|
|
DEBUG_INFO(DEBUG_CATEGORY_RADIO, "PTT: captured chord=%s", qPrintable(PttHotkeyManager::instance()->describe(m_capture.candidate))); |
|
|
|
|
DEBUG_INFO(DEBUG_CATEGORY_RADIO, "PTT: captured slot=%d chord=[%s] codes=[%s]", index + 1, |
|
|
|
|
qPrintable(PttHotkeyManager::instance()->describe(m_capture.candidate)), qPrintable(pttEncodeChord(m_capture.candidate))); |
|
|
|
|
} else { |
|
|
|
|
DEBUG_INFO(DEBUG_CATEGORY_RADIO, "PTT: recording cancelled slot=%d candidate=[%s]", index + 1, |
|
|
|
|
qPrintable(pttEncodeChord(m_capture.candidate))); |
|
|
|
|
} |
|
|
|
|
m_captureIndex = -1; |
|
|
|
|
qApp->removeEventFilter(this); |
|
|
|
|
@ -164,7 +173,26 @@ void RadioSettingsPage::finishCapture(bool save) {
|
|
|
|
|
bool RadioSettingsPage::eventFilter(QObject* object, QEvent* event) { |
|
|
|
|
if (m_captureIndex >= 0) { |
|
|
|
|
if (event->type() == QEvent::ShortcutOverride) { event->accept(); return true; } |
|
|
|
|
if (event->type() == QEvent::KeyPress || event->type() == QEvent::KeyRelease) return true; |
|
|
|
|
if (event->type() == QEvent::KeyPress || event->type() == QEvent::KeyRelease) { |
|
|
|
|
auto* key = static_cast<QKeyEvent*>(event); |
|
|
|
|
// Только ручная запись: сравниваем доставку событий окну с независимым опросом ОС.
|
|
|
|
|
if (!key->isAutoRepeat()) { |
|
|
|
|
DEBUG_DEBUG(DEBUG_CATEGORY_DEBUG, "PTT: capture window event=%s slot=%d qt=0x%x native_vk=%u scan=%u modifiers=0x%x", |
|
|
|
|
event->type() == QEvent::KeyPress ? "press" : "release", m_captureIndex + 1, |
|
|
|
|
unsigned(key->key()), unsigned(key->nativeVirtualKey()), unsigned(key->nativeScanCode()), |
|
|
|
|
unsigned(key->nativeModifiers())); |
|
|
|
|
#ifdef Q_OS_WIN |
|
|
|
|
int vk = int(key->nativeVirtualKey()); |
|
|
|
|
if (vk > 0 && vk < 256) { |
|
|
|
|
unsigned asyncState = static_cast<unsigned short>(GetAsyncKeyState(vk)); |
|
|
|
|
unsigned queueState = static_cast<unsigned short>(GetKeyState(vk)); |
|
|
|
|
DEBUG_DEBUG(DEBUG_CATEGORY_DEBUG, "PTT: capture Windows vk=%d async=0x%04x queue=0x%04x remote_session=%d", |
|
|
|
|
vk, asyncState, queueState, GetSystemMetrics(SM_REMOTESESSION)); |
|
|
|
|
} |
|
|
|
|
#endif |
|
|
|
|
} |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return QWidget::eventFilter(object, event); |
|
|
|
|
} |
|
|
|
|
|