kiran-control-panel/0002-feature-display-When-switching-resolutions-refresh-r.patch
luoqing cdec05d97f fix(network):After receiving the Connection::Update signal from an active connection, the connection is no longer automatically reactivated; When switching resolutions, refresh rate preferentially selects the recommended refresh rate
- 收到已激活的连接的更新信号Connection::Update后,不再自动重新激活连接
  切换分辨率时,刷新率优先选择推荐的刷新率

Related #13231,#13283
2023-08-23 16:07:00 +08:00

64 lines
2.3 KiB
Diff

From 8468d6df5794ede71a39905e2d31f4cadda244b7 Mon Sep 17 00:00:00 2001
From: luoqing <luoqing@kylinsec.com.cn>
Date: Wed, 23 Aug 2023 11:11:09 +0800
Subject: [PATCH] feature(display):When switching resolutions, refresh rate
preferentially selects the recommended refresh rate
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- 切换分辨率时,刷新率优先选择推荐的刷新率
Related #13283
---
plugins/display/src/display-page.cpp | 21 +++++++++++++++++----
1 file changed, 17 insertions(+), 4 deletions(-)
diff --git a/plugins/display/src/display-page.cpp b/plugins/display/src/display-page.cpp
index a885b8b..23b5e8e 100644
--- a/plugins/display/src/display-page.cpp
+++ b/plugins/display/src/display-page.cpp
@@ -263,22 +263,35 @@ void DisplayPage::initExtraComboBoxRefreshRate(QComboBox *comboBox, const QList<
{
comboBox->clear();
- QString recommend;
QList<DisplayModesStu> list = m_displayConfig->listPreferredModes(m_curMonitorPath);
+ double recommendRefreshRate;
if (!list.isEmpty())
{
- double refreshRate = list.first().refreshRate;
- recommend = QString("%1HZ").arg(QString::asprintf("%.2f", refreshRate));
+ recommendRefreshRate = list.first().refreshRate;
}
+ QString strPostfix = tr(" (recommended)");
QList<double> t_refreshRateList = refreshRateList;
std::sort(t_refreshRateList.begin(), t_refreshRateList.end(), std::greater<double>());
foreach (double r, t_refreshRateList)
{
QString text = QString("%1HZ").arg(QString::asprintf("%.2f", r));
- if (text == recommend) text += tr(" (recommended)");
+ if (QString::asprintf("%.2f", r) == QString::asprintf("%.2f", recommendRefreshRate))
+ {
+ text.append(strPostfix);
+ }
comboBox->addItem(text, r);
}
+
+ for (size_t i = 0; i < comboBox->count(); i++)
+ {
+ double refreshRate = comboBox->itemData(i).toDouble();
+ if(QString::asprintf("%.2f", refreshRate) == QString::asprintf("%.2f", recommendRefreshRate))
+ {
+ comboBox->setCurrentIndex(i);
+ break;
+ }
+ }
}
void DisplayPage::selectResolutionComboboxItem(QComboBox *comboBox, const int &w, const int &h)
--
2.33.0