vdi-cloud/terminal/kiosk-shell/src/desktop_settings_dialog.cpp
宋一鸣 26fde0369e 重构:移除 RDP 管线并完善会话退出与串流过场
变更详情:删除 RDP 渲染管线,协议统一 Moonlight;退出三层设计与串流过场层落地

- 移除 rdp_session.*、FreeRDP 构建依赖与代码内协议概念,Moonlight 为唯一会话通道
- Ctrl+Alt+Shift+Q 退串流回列表(kiosk 兜底 + moonlight-qt 主路径);登录页去退出按钮
- 新增 TransitionOverlay:全屏过场层盖住串流启动闪烁,进程 CPU 首帧检测后淡出
- Sunshine 写入 sw_preset=ultrafast;实测推翻 x264 瓶颈结论(21.6FPS 帽子在虚拟显示/捕获节奏,CPU≈0%)
- 文档:麒麟(101/.71)/Ubuntu(102/.72) 接入信息与四件事落地记录;MEMORY 根因修正
2026-10-29 17:37:38 +08:00

137 lines
4.8 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include "desktop_settings_dialog.h"
#include <QComboBox>
#include <QDialogButtonBox>
#include <QFormLayout>
#include <QLabel>
#include <QLineEdit>
#include <QPushButton>
#include <QVBoxLayout>
#include <cstdio>
#include "desktop_store.h"
namespace vdi {
DesktopSettingsDialog::DesktopSettingsDialog(std::vector<DesktopInfo> desktops,
const QString& selectId, QWidget* parent)
: QDialog(parent), desktops_(std::move(desktops)) {
setWindowTitle(QStringLiteral("桌面连接设置"));
setMinimumWidth(560);
// Kiosk 主窗口是全屏窗口,必须置顶否则对话框会被完全遮挡
setWindowFlags(windowFlags() | Qt::WindowStaysOnTopHint);
auto* root = new QVBoxLayout(this);
root->setSpacing(14);
auto* hint = new QLabel(
QStringLiteral("为每张桌面配置连接参数。地址支持 IP、域名或 VPN 隧道地址;"
"地址留空表示待分配,卡片将不可连接。"),
this);
hint->setWordWrap(true);
hint->setStyleSheet(QStringLiteral("color: #8a94a6;"));
root->addWidget(hint);
auto* form = new QFormLayout();
form->setHorizontalSpacing(14);
form->setVerticalSpacing(12);
comboDesktop_ = new QComboBox(this);
for (const DesktopInfo& d : desktops_) {
comboDesktop_->addItem(d.name, d.id);
}
form->addRow(QStringLiteral("桌面"), comboDesktop_);
// 会话通道统一 Moonlight,无协议选项(地址/应用名即连接参数)
editEndpoint_ = new QLineEdit(this);
editEndpoint_->setPlaceholderText(QStringLiteral("例如 192.168.1.70 或 VPN 隧道地址"));
form->addRow(QStringLiteral("服务器地址"), editEndpoint_);
editApp_ = new QLineEdit(this);
editApp_->setPlaceholderText(QStringLiteral("Sunshine 应用名,通常为 Desktop"));
form->addRow(QStringLiteral("应用名"), editApp_);
comboResolution_ = new QComboBox(this);
const char* resolutions[] = {"1920x1080", "2560x1440", "1920x1440", "3840x2160", "1280x720"};
for (const char* r : resolutions) {
comboResolution_->addItem(QString::fromLatin1(r), QString::fromLatin1(r));
}
form->addRow(QStringLiteral("分辨率"), comboResolution_);
comboFps_ = new QComboBox(this);
comboFps_->addItem(QStringLiteral("60"), 60);
comboFps_->addItem(QStringLiteral("30"), 30);
form->addRow(QStringLiteral("帧率"), comboFps_);
root->addLayout(form);
auto* buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this);
buttons->button(QDialogButtonBox::Ok)->setText(QStringLiteral("保存"));
buttons->button(QDialogButtonBox::Cancel)->setText(QStringLiteral("取消"));
root->addWidget(buttons);
connect(comboDesktop_, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
&DesktopSettingsDialog::onDesktopChanged);
connect(buttons, &QDialogButtonBox::accepted, this, &DesktopSettingsDialog::onAccepted);
connect(buttons, &QDialogButtonBox::rejected, this, &QDialog::reject);
// 预选指定桌面
int index = 0;
if (!selectId.isEmpty()) {
for (int i = 0; i < comboDesktop_->count(); ++i) {
if (comboDesktop_->itemData(i).toString() == selectId) {
index = i;
break;
}
}
}
comboDesktop_->setCurrentIndex(index);
loadCurrent();
}
void DesktopSettingsDialog::onDesktopChanged(int index) {
Q_UNUSED(index);
loadCurrent();
}
void DesktopSettingsDialog::loadCurrent() {
const QString id = comboDesktop_->currentData().toString();
for (const DesktopInfo& d : desktops_) {
if (d.id != id) {
continue;
}
loading_ = true;
editEndpoint_->setText(d.endpoint);
editApp_->setText(d.app);
int resIndex = comboResolution_->findData(
QStringLiteral("%1x%2").arg(d.width).arg(d.height));
comboResolution_->setCurrentIndex(resIndex >= 0 ? resIndex : 0);
int fpsIndex = comboFps_->findData(d.fps);
comboFps_->setCurrentIndex(fpsIndex >= 0 ? fpsIndex : 0);
loading_ = false;
break;
}
}
void DesktopSettingsDialog::onAccepted() {
const QString id = comboDesktop_->currentData().toString();
for (DesktopInfo& d : desktops_) {
if (d.id != id) {
continue;
}
d.endpoint = editEndpoint_->text().trimmed();
d.app = editApp_->text().trimmed();
const QString res = comboResolution_->currentData().toString();
sscanf(res.toLatin1().constData(), "%dx%d", &d.width, &d.height);
d.fps = comboFps_->currentData().toInt();
d.state = d.endpoint.isEmpty() ? DesktopState::kUnassigned : DesktopState::kAvailable;
DesktopStore::update(d);
break;
}
accept();
}
} // namespace vdi