| 34 | } |
| 35 | |
| 36 | void CVirtualKeyboardSettingsDialog::setupUi() |
| 37 | { |
| 38 | QVBoxLayout *mainLayout = new QVBoxLayout(this); |
| 39 | |
| 40 | // ===== 语言设置组 ===== |
| 41 | QGroupBox *languageGroup = new QGroupBox(tr("输入语言"), this); |
| 42 | QVBoxLayout *languageLayout = new QVBoxLayout(languageGroup); |
| 43 | |
| 44 | m_languageCombo = new QComboBox(this); |
| 45 | m_localeList = getAvailableLocales(); |
| 46 | |
| 47 | // 填充语言下拉框 |
| 48 | for (const QString &locale : m_localeList) { |
| 49 | QLocale loc(locale); |
| 50 | QString displayName = QString("%1 (%2)") |
| 51 | .arg(loc.nativeLanguageName()) |
| 52 | .arg(loc.nativeCountryName()); |
| 53 | m_languageCombo->addItem(displayName, locale); |
| 54 | } |
| 55 | |
| 56 | languageLayout->addWidget(new QLabel(tr("选择输入语言:"), this)); |
| 57 | languageLayout->addWidget(m_languageCombo); |
| 58 | languageLayout->addStretch(); |
| 59 | |
| 60 | // ===== 外观设置组 ===== |
| 61 | QGroupBox *appearanceGroup = new QGroupBox(tr("外观设置"), this); |
| 62 | QVBoxLayout *appearanceLayout = new QVBoxLayout(appearanceGroup); |
| 63 | |
| 64 | // 主题选择 |
| 65 | QHBoxLayout *themeLayout = new QHBoxLayout(); |
| 66 | themeLayout->addWidget(new QLabel(tr("键盘主题:"), this)); |
| 67 | m_themeCombo = new QComboBox(this); |
| 68 | QStringList themes = getAvailableStyles(); |
| 69 | themes.prepend("默认"); // 添加默认主题选项 |
| 70 | m_themeCombo->addItems(themes); |
| 71 | themeLayout->addWidget(m_themeCombo); |
| 72 | themeLayout->addStretch(); |
| 73 | appearanceLayout->addLayout(themeLayout); |
| 74 | |
| 75 | // 按键大小调节 |
| 76 | QHBoxLayout *keySizeLayout = new QHBoxLayout(); |
| 77 | keySizeLayout->addWidget(new QLabel(tr("按键大小:"), this)); |
| 78 | m_keySizeSlider = new QSlider(Qt::Horizontal, this); |
| 79 | m_keySizeSlider->setRange(50, 150); |
| 80 | m_keySizeSlider->setValue(100); |
| 81 | m_keySizeSlider->setTickPosition(QSlider::TicksBelow); |
| 82 | m_keySizeSlider->setTickInterval(10); |
| 83 | keySizeLayout->addWidget(m_keySizeSlider, 1); |
| 84 | |
| 85 | m_keySizeLabel = new QLabel("100%", this); |
| 86 | keySizeLayout->addWidget(m_keySizeLabel); |
| 87 | appearanceLayout->addLayout(keySizeLayout); |
| 88 | |
| 89 | // 连接滑块信号更新百分比显示 |
| 90 | connect(m_keySizeSlider, &QSlider::valueChanged, [this](int value) { |
| 91 | m_keySizeLabel->setText(QString("%1%").arg(value)); |
| 92 | }); |
| 93 |
no test coverage detected