UI: explain dangerous operations, screen modes and host filtering
Four items from a user-side review of the master. The common thread: the UI
now says what it is about to do instead of leaving the user to guess.
Confirm boxes. Logout, restart, shutdown, delete host and uninstall client
all asked "are you sure" without naming the action or the hosts, so a
multi-selection could not be checked. DescribeTargetHosts() lists
"note (or computer name) (ip)" capped at five lines, and the default button
is No. The preview is dropped before the modal box and targets are
re-resolved after it, since the list can reshuffle in between.
Screen modes. High Speed / Ultra Speed became High Quality (DXGI +
differential: lossless, bandwidth hungry) and Smooth (GDI + H264: lossy,
cheap). TranslateMenu looks menus up by displayed text, so the .rc entries,
the FeatureLimitsDlg item names and the language pack keys changed together.
Host filter. The Ctrl+F bar was find-next; it now filters as you type over
IP, location, note, OS and version, and Esc clears the filter. The status
line reads "filtered: N / M total" while active. Commands still resolve by
clientID and m_FilteredIndices still maps row to m_HostList index, so no
command path changes. SearchBarDlg drops from 446 to 312 lines.
Quality changes. The adaptive level now shows its reason for twenty seconds
("Good (high latency)") instead of silently changing. The full-screen info
bar was a fixed 170px, so that reason was clipped; the width is now measured
from the text with the same font that paints it, 170 becoming the floor and
16px quantisation so changing digits do not jitter the window. Cosmetic
only: no threshold, hysteresis, cooldown or lock-out logic is touched.
Verified: debug server build, 0 errors; new strings present in .res and in
the exe. UI not exercised - the debug master would fight the running release
master for the listening port in Bin/settings.ini.
This commit is contained in:
1 parent
a190c21217
commit
6b87a31c6f
12 files changed
+364
-220
No files matched your search
@@ -446,6 +446,16 @@ void CScreenSpyDlg::DoDataExchange(CDataExchange* pDX)
|
||||
|
||||
// ========== CStatusInfoWnd 实现 ==========
|
||||
|
||||
namespace {
|
||||
// 原来宽度是写死的 170:档位名后面一旦跟出「(链路改善)」「(带宽不足)」这类
|
||||
// 切档原因,文本就被截掉。改成按文本实测宽度,170 退化成下限。
|
||||
const int kStatusInfoMinWidth = 170;
|
||||
const int kStatusInfoHeight = 24;
|
||||
const int kStatusInfoPadX = 16; // 文本左右留白
|
||||
// 宽度按 16px 取整:FPS / KB/s 每秒都在变,位数进位会让窗口每秒抖动一两个像素
|
||||
const int kStatusInfoWidthStep = 16;
|
||||
}
|
||||
|
||||
BEGIN_MESSAGE_MAP(CStatusInfoWnd, CWnd)
|
||||
ON_WM_PAINT()
|
||||
ON_WM_ERASEBKGND()
|
||||
@@ -473,14 +483,54 @@ BOOL CStatusInfoWnd::Create(CWnd* pParent)
|
||||
}
|
||||
|
||||
if (!CreateEx(dwExStyle, szClassName, _T(""), dwStyle,
|
||||
CRect(0, 0, 170, 24), pParent, 0))
|
||||
CRect(0, 0, m_nWidth, kStatusInfoHeight), pParent, 0))
|
||||
return FALSE;
|
||||
|
||||
// 字体建一次给绘制和测量共用:两边字体不一致的话,算出来的宽度和画出来的宽度
|
||||
// 就对不上,仍然会截字。
|
||||
m_infoFont.CreatePointFont(90, _T("Segoe UI"));
|
||||
|
||||
SetLayeredWindowAttributes(0, 220, LWA_ALPHA);
|
||||
LoadSettings();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int CStatusInfoWnd::MeasureWidth()
|
||||
{
|
||||
if (m_strInfo.IsEmpty())
|
||||
return kStatusInfoMinWidth;
|
||||
|
||||
CClientDC dc(this);
|
||||
CFont* pOldFont = dc.SelectObject(&m_infoFont);
|
||||
CSize sz = dc.GetTextExtent(m_strInfo);
|
||||
dc.SelectObject(pOldFont);
|
||||
|
||||
int w = sz.cx + kStatusInfoPadX * 2;
|
||||
if (w < kStatusInfoMinWidth)
|
||||
w = kStatusInfoMinWidth;
|
||||
w = (w + kStatusInfoWidthStep - 1) / kStatusInfoWidthStep * kStatusInfoWidthStep;
|
||||
return w;
|
||||
}
|
||||
|
||||
void CStatusInfoWnd::ResizeToFit()
|
||||
{
|
||||
if (!GetSafeHwnd())
|
||||
return;
|
||||
|
||||
const int w = MeasureWidth();
|
||||
if (w == m_nWidth)
|
||||
return;
|
||||
|
||||
CRect rc;
|
||||
GetWindowRect(&rc);
|
||||
m_nWidth = w;
|
||||
// 两边各让一半,保持中心不动:默认位置是屏幕居中,拖动过的是用户选的中心点,
|
||||
// 只往右边长会让这两种情况都偏。
|
||||
const int dx = (rc.Width() - w) / 2;
|
||||
SetWindowPos(NULL, rc.left + dx, rc.top, w, rc.Height(),
|
||||
SWP_NOZORDER | SWP_NOACTIVATE);
|
||||
}
|
||||
|
||||
void CStatusInfoWnd::UpdateInfo(double fps, double kbps, const CString& quality)
|
||||
{
|
||||
if (kbps >= 1024)
|
||||
@@ -488,6 +538,10 @@ void CStatusInfoWnd::UpdateInfo(double fps, double kbps, const CString& quality)
|
||||
else
|
||||
m_strInfo.Format(_T("%.0f FPS | %.0f KB/s | %s"), fps, kbps, quality.GetString());
|
||||
|
||||
// 文本变了宽度就可能变(切档原因的四种文案长度不同),隐藏时也算,
|
||||
// 免得下次 Show 出来先窄一帧再撑开。
|
||||
ResizeToFit();
|
||||
|
||||
if (m_bVisible)
|
||||
Invalidate(FALSE);
|
||||
}
|
||||
@@ -518,7 +572,7 @@ void CStatusInfoWnd::SetOpacityLevel(int level)
|
||||
|
||||
void CStatusInfoWnd::UpdatePosition(const RECT& rcMonitor)
|
||||
{
|
||||
int width = 170, height = 24;
|
||||
const int width = m_nWidth, height = kStatusInfoHeight;
|
||||
int monWidth = rcMonitor.right - rcMonitor.left;
|
||||
|
||||
int x, y;
|
||||
@@ -651,9 +705,7 @@ void CStatusInfoWnd::OnPaint()
|
||||
// 文字
|
||||
dc.SetBkMode(TRANSPARENT);
|
||||
dc.SetTextColor(RGB(220, 220, 220));
|
||||
CFont font;
|
||||
font.CreatePointFont(90, _T("Segoe UI"));
|
||||
CFont* pOldFont = dc.SelectObject(&font);
|
||||
CFont* pOldFont = dc.SelectObject(&m_infoFont);
|
||||
dc.DrawText(m_strInfo, rc, DT_CENTER | DT_VCENTER | DT_SINGLELINE);
|
||||
dc.SelectObject(pOldFont);
|
||||
}
|
||||
@@ -2631,7 +2683,7 @@ void CScreenSpyDlg::OnTimer(UINT_PTR nIDEvent)
|
||||
// 更新全屏状态信息窗口
|
||||
if (m_pStatusInfoWnd && m_pStatusInfoWnd->IsVisible()) {
|
||||
CString qualityName = m_Settings.QualityLevel == QUALITY_DISABLED ? _T("Off") :
|
||||
CString(GetQualityName(m_AdaptiveQuality.currentLevel));
|
||||
GetQualityDisplayName();
|
||||
m_pStatusInfoWnd->UpdateInfo(m_dFrameRate, m_dTransferRate, qualityName);
|
||||
}
|
||||
}
|
||||
@@ -2658,7 +2710,7 @@ void CScreenSpyDlg::UpdateWindowTitle()
|
||||
|
||||
// 构建质量名称:关闭显示 "Off",自适应和手动都会显示 "当前等级"
|
||||
CString qualityName = m_Settings.QualityLevel == QUALITY_DISABLED ? "" :
|
||||
CString(" | ") + GetQualityName(m_AdaptiveQuality.currentLevel);
|
||||
CString(" | ") + GetQualityDisplayName();
|
||||
|
||||
CString strTitle;
|
||||
UINT fps = (UINT)(m_dFrameRate + 0.5); // 四舍五入显示
|
||||
@@ -2689,6 +2741,27 @@ const char* CScreenSpyDlg::GetQualityName(int level)
|
||||
return "Unknown";
|
||||
}
|
||||
|
||||
// 记下"为什么切档"。只影响界面显示,不参与任何判据 —— 判据仍然只看 RTT / 吞吐。
|
||||
// 20 秒后自动失效:档位稳定在低档时用户更需要知道"链路一直差",而不是一直挂着
|
||||
// 一个已经过时的原因。手动选档时由 ApplyQualityLevel(persist=true) 清空。
|
||||
void CScreenSpyDlg::SetQualityChangeReason(LPCTSTR key)
|
||||
{
|
||||
m_AdaptiveQuality.reason = _L(key);
|
||||
m_AdaptiveQuality.reasonUntil = GetTickCount64() + 20000;
|
||||
}
|
||||
|
||||
CString CScreenSpyDlg::GetQualityDisplayName()
|
||||
{
|
||||
CString name = GetQualityName(m_AdaptiveQuality.currentLevel);
|
||||
if (!m_AdaptiveQuality.reason.IsEmpty() &&
|
||||
GetTickCount64() < m_AdaptiveQuality.reasonUntil) {
|
||||
name += _T(" (");
|
||||
name += m_AdaptiveQuality.reason;
|
||||
name += _T(")");
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
void CScreenSpyDlg::UpdateQualityMenuCheck(CMenu* SysMenu)
|
||||
{
|
||||
if (!SysMenu) SysMenu = GetSystemMenu(FALSE);
|
||||
@@ -2931,6 +3004,8 @@ void CScreenSpyDlg::EvaluateQuality()
|
||||
targetLevel, m_AdaptiveQuality.levelCeiling);
|
||||
}
|
||||
if (dual) NoteAdaptiveChange(now);
|
||||
// 原因只在这里可得:再往下就没有 byLoad / levelRTT 了
|
||||
SetQualityChangeReason(byLoad ? _T("带宽不足") : _T("延迟高"));
|
||||
ApplyQualityLevel(targetLevel);
|
||||
if (byLoad) m_AdaptiveQuality.loadProbeTime = GetTickCount64();
|
||||
}
|
||||
@@ -2948,6 +3023,7 @@ void CScreenSpyDlg::EvaluateQuality()
|
||||
m_AdaptiveQuality.lastUpFromLevel = currentLevel;
|
||||
NoteAdaptiveChange(now);
|
||||
}
|
||||
SetQualityChangeReason(_T("链路改善"));
|
||||
ApplyQualityLevel(currentLevel - 1);
|
||||
}
|
||||
}
|
||||
@@ -3006,6 +3082,9 @@ void CScreenSpyDlg::ApplyQualityLevel(int level, bool persist)
|
||||
m_AdaptiveQuality.lockUntil = 0;
|
||||
m_AdaptiveQuality.changeWindowStart = 0;
|
||||
m_AdaptiveQuality.changeCountInWindow = 0;
|
||||
// 用户自己点的档位,不需要解释"为什么变";顺手清掉上一次自适应留下的原因
|
||||
m_AdaptiveQuality.reason.Empty();
|
||||
m_AdaptiveQuality.reasonUntil = 0;
|
||||
}
|
||||
|
||||
// 1. 发送 FPS 和算法 (persist=1 表示手动选择需要保存)
|
||||
@@ -3579,6 +3658,9 @@ void CScreenSpyDlg::EnterFullScreen()
|
||||
m_pStatusInfoWnd = new CStatusInfoWnd();
|
||||
m_pStatusInfoWnd->Create(this);
|
||||
}
|
||||
// 先把宽度按当前文本算出来再定位,否则第一次显示会先窄一帧再撑开
|
||||
m_pStatusInfoWnd->UpdateInfo(m_dFrameRate, m_dTransferRate,
|
||||
m_Settings.QualityLevel == QUALITY_DISABLED ? _T("Off") : GetQualityDisplayName());
|
||||
m_pStatusInfoWnd->UpdatePosition(rcMonitor);
|
||||
// 同步工具栏透明度
|
||||
if (m_pToolbar) {
|
||||
|
||||
Reference in new issue
Block a user