/
proximacentav
/
ZMP
Обзор
Документация
Войти
/
proximacentav
/
ZMP
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
2
Аналитика
Безопасность
main
deviceswidget.cpp
35 строк
1 KB
proximacentav
feat(i18n): add English & German localization with in-app language switcher
24 июл 2026, 11:47
24 июл 2026, 11:47
83da6f3
Код
Авторство
О чём код?
#include "deviceswidget.h" #include "translator.h" #include <QVBoxLayout> #include <QLabel> #include <QMediaDevices> DevicesWidget::DevicesWidget(QWidget *parent) : QWidget(parent) { QVBoxLayout *layout = new QVBoxLayout(this); layout->addWidget(ztrLabel(m_retrans, "Устройство вывода звука:", this)); m_combo = new QComboBox(this); layout->addWidget(m_combo); m_devices = QMediaDevices::audioOutputs(); for (const QAudioDevice &dev : m_devices) { m_combo->addItem(dev.description(), QVariant::fromValue(dev)); } if (m_combo->count() > 0) m_combo->setCurrentIndex(0); connect(m_combo, &QComboBox::currentIndexChanged, this, &DevicesWidget::onCurrentIndexChanged); connect(&Translator::instance(), &Translator::languageChanged, this, &DevicesWidget::retranslateUi); } void DevicesWidget::retranslateUi() { runRetrans(m_retrans); } QAudioDevice DevicesWidget::selectedDevice() const { int idx = m_combo->currentIndex(); return (idx >= 0 && idx < m_devices.size()) ? m_devices[idx] : QAudioDevice(); } void DevicesWidget::onCurrentIndexChanged(int index) { if (index >= 0 && index < m_devices.size()) emit deviceChanged(m_devices[index]); }