Skip to content

Commit aad2b82

Browse files
committed
fix: Fix the problem of network speed width jumping
1 parent e86a912 commit aad2b82

4 files changed

Lines changed: 57 additions & 68 deletions

File tree

dde-dock-plugin/NetPlugins.json

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
22
"WinDdeDock":{
33
"ColorAndFont":{
4-
"FontSize":8,
5-
"FontType":"Noto Sans CJK SC",
6-
"FontTypeIndex":59,
4+
"FontSize":9,
5+
"FontType":"Monospace",
6+
"FontTypeIndex":26,
77
"LabTextColor":"#000000",
88
"TextColor":"#000000"
99
},
@@ -29,11 +29,6 @@
2929
"DisolayDisk":false,
3030
"DisolayNet":true
3131
},
32-
{
33-
"LocationExchangeCPUAndMenory":false,
34-
"LocationExchangeDisk":false,
35-
"LocationExchangeNet":false
36-
},
3732
{
3833
"FractionalAccuracy":0,
3934
"RefreshInterval":1000

dde-dock-plugin/WinDdeDockSetting.cpp

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,6 @@ void WinDdeDockSetting::initSigConnectWinDdeDock()
109109
connect(ui->lineLabMemory, &QLineEdit::textChanged, this, &WinDdeDockSetting::sigLabMemoryText);
110110
connect(ui->checkBoxDisolayNet, &QCheckBox::clicked, this, &WinDdeDockSetting::sigDisolayNet);
111111
connect(ui->checkBoxDisolayCPUAndMemory, &QCheckBox::clicked, this, &WinDdeDockSetting::sigDisolayCPUAndMemory);
112-
connect(ui->checkBoxLocationExchangeNet, &QCheckBox::clicked, this, &WinDdeDockSetting::sigLocationExchangeNet);
113-
connect(ui->checkBoxLocationExchangeCPUAndMenory, &QCheckBox::clicked, this, &WinDdeDockSetting::sigLocationExchangeCPUAndMenory);
114112

115113
connect(ui->spinBoxFractionalAccuracy, pFun, this, &WinDdeDockSetting::sigFractionalAccuracy);
116114
void (QComboBox::*pFunDoubleClick)(int) = &QComboBox::currentIndexChanged;
@@ -171,10 +169,8 @@ void WinDdeDockSetting::readConfigWinDdeDock()
171169

172170
ui->checkBoxDisolayNet->setChecked(jsDisplayText[2]["DisolayNet"]);
173171
ui->checkBoxDisolayCPUAndMemory->setChecked(jsDisplayText[2]["DisolayCPUAndMemory"]);
174-
ui->checkBoxLocationExchangeNet->setChecked(jsDisplayText[3]["LocationExchangeNet"]);
175-
ui->checkBoxLocationExchangeCPUAndMenory->setChecked(jsDisplayText[3]["LocationExchangeCPUAndMenory"]);
176-
ui->spinBoxFractionalAccuracy->setValue(jsDisplayText[4]["FractionalAccuracy"]);
177-
ui->spinBoxRefreshInterval->setValue(jsDisplayText[4]["RefreshInterval"]);
172+
ui->spinBoxFractionalAccuracy->setValue(jsDisplayText[3]["FractionalAccuracy"]);
173+
ui->spinBoxRefreshInterval->setValue(jsDisplayText[3]["RefreshInterval"]);
178174

179175
json jsDockWindow = m_js["WinDdeDock"]["DockWindow"];
180176
ui->checkBoxHoverDisplay->setChecked(jsDockWindow["HoverDisplay"]);
@@ -241,10 +237,10 @@ void WinDdeDockSetting::saveConfigWinDdeDock()
241237

242238
jsDisplayText[2]["DisolayNet"] = ui->checkBoxDisolayNet->isChecked();
243239
jsDisplayText[2]["DisolayCPUAndMemory"] = ui->checkBoxDisolayCPUAndMemory->isChecked();
244-
jsDisplayText[3]["LocationExchangeNet"] = ui->checkBoxLocationExchangeNet->isChecked();
245-
jsDisplayText[3]["LocationExchangeCPUAndMenory"] = ui->checkBoxLocationExchangeCPUAndMenory->isChecked();
246-
jsDisplayText[4]["FractionalAccuracy"] = ui->spinBoxFractionalAccuracy->value();
247-
jsDisplayText[4]["RefreshInterval"] = ui->spinBoxRefreshInterval->value();
240+
// jsDisplayText[3]["LocationExchangeNet"] = ui->checkBoxLocationExchangeNet->isChecked();
241+
// jsDisplayText[3]["LocationExchangeCPUAndMenory"] = ui->checkBoxLocationExchangeCPUAndMenory->isChecked();
242+
jsDisplayText[3]["FractionalAccuracy"] = ui->spinBoxFractionalAccuracy->value();
243+
jsDisplayText[3]["RefreshInterval"] = ui->spinBoxRefreshInterval->value();
248244

249245
json &jsDockWindow = m_js["WinDdeDock"]["DockWindow"];
250246
jsDockWindow["HoverDisplay"] = ui->checkBoxHoverDisplay->isChecked();

dde-dock-plugin/WinDdeDockSetting.ui

Lines changed: 40 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,33 @@
66
<rect>
77
<x>0</x>
88
<y>0</y>
9-
<width>466</width>
10-
<height>602</height>
9+
<width>442</width>
10+
<height>525</height>
1111
</rect>
1212
</property>
1313
<property name="windowTitle">
1414
<string>Form</string>
1515
</property>
1616
<layout class="QVBoxLayout" name="verticalLayout_7">
17+
<property name="leftMargin">
18+
<number>0</number>
19+
</property>
20+
<property name="topMargin">
21+
<number>0</number>
22+
</property>
23+
<property name="rightMargin">
24+
<number>0</number>
25+
</property>
26+
<property name="bottomMargin">
27+
<number>0</number>
28+
</property>
1729
<item>
1830
<widget class="QTabWidget" name="tabWidget">
1931
<property name="autoFillBackground">
2032
<bool>false</bool>
2133
</property>
2234
<property name="currentIndex">
23-
<number>1</number>
35+
<number>0</number>
2436
</property>
2537
<widget class="QWidget" name="tabDockSetting">
2638
<attribute name="title">
@@ -470,35 +482,6 @@
470482
<layout class="QVBoxLayout" name="verticalLayout_6">
471483
<item>
472484
<layout class="QGridLayout" name="gridLayout">
473-
<item row="0" column="0">
474-
<widget class="QCheckBox" name="checkBoxDisolayNet">
475-
<property name="enabled">
476-
<bool>true</bool>
477-
</property>
478-
<property name="autoFillBackground">
479-
<bool>false</bool>
480-
</property>
481-
<property name="text">
482-
<string>Show [Upload/Download]</string>
483-
</property>
484-
<property name="checked">
485-
<bool>true</bool>
486-
</property>
487-
<property name="tristate">
488-
<bool>false</bool>
489-
</property>
490-
</widget>
491-
</item>
492-
<item row="0" column="1">
493-
<widget class="QCheckBox" name="checkBoxDisolayCPUAndMemory">
494-
<property name="text">
495-
<string>Show [CPU/Memory]</string>
496-
</property>
497-
<property name="checked">
498-
<bool>true</bool>
499-
</property>
500-
</widget>
501-
</item>
502485
<item row="0" column="2">
503486
<spacer name="horizontalSpacer_5">
504487
<property name="orientation">
@@ -512,17 +495,32 @@
512495
</property>
513496
</spacer>
514497
</item>
515-
<item row="1" column="1">
516-
<widget class="QCheckBox" name="checkBoxLocationExchangeCPUAndMenory">
498+
<item row="0" column="1">
499+
<widget class="QCheckBox" name="checkBoxDisolayCPUAndMemory">
517500
<property name="text">
518-
<string>Swap [CPU/Memory]</string>
501+
<string>Show [CPU/Memory]</string>
502+
</property>
503+
<property name="checked">
504+
<bool>true</bool>
519505
</property>
520506
</widget>
521507
</item>
522-
<item row="1" column="0">
523-
<widget class="QCheckBox" name="checkBoxLocationExchangeNet">
508+
<item row="0" column="0">
509+
<widget class="QCheckBox" name="checkBoxDisolayNet">
510+
<property name="enabled">
511+
<bool>true</bool>
512+
</property>
513+
<property name="autoFillBackground">
514+
<bool>false</bool>
515+
</property>
524516
<property name="text">
525-
<string>Swap [Upload/Download]</string>
517+
<string>Show [Upload/Download]</string>
518+
</property>
519+
<property name="checked">
520+
<bool>true</bool>
521+
</property>
522+
<property name="tristate">
523+
<bool>false</bool>
526524
</property>
527525
</widget>
528526
</item>
@@ -709,19 +707,19 @@
709707
</attribute>
710708
<layout class="QVBoxLayout" name="verticalLayout_20">
711709
<item>
712-
<widget class="QLabel" name="label_91">
710+
<widget class="QLabel" name="label_92">
713711
<property name="text">
714-
<string>NetPlugins</string>
712+
<string>LOGO</string>
715713
</property>
716714
<property name="alignment">
717715
<set>Qt::AlignCenter</set>
718716
</property>
719717
</widget>
720718
</item>
721719
<item>
722-
<widget class="QLabel" name="label_92">
720+
<widget class="QLabel" name="label_91">
723721
<property name="text">
724-
<string>LOGO</string>
722+
<string>NetPlugins</string>
725723
</property>
726724
<property name="alignment">
727725
<set>Qt::AlignCenter</set>

dde-dock-plugin/WinDockNet.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ void WinDockNet::initSigConnect()
7575
// 响应 WinDdeDockSetting 发射的信号
7676
connect(m_winSetting, &WinDdeDockSetting::sigCurrentFont, this, &WinDockNet::onCurrentFont);
7777
connect(m_winSetting, &WinDdeDockSetting::sigFontSize, this, &WinDockNet::onFontSize);
78+
7879
connect(m_winSetting, &WinDdeDockSetting::sigUnitModel, this, &WinDockNet::onUnitModel);
7980
connect(m_winSetting, &WinDdeDockSetting::sigUnitModelIndex, this, &WinDockNet::onUnitModelIndex);
8081
connect(m_winSetting, &WinDdeDockSetting::sigShowModel, this, &WinDockNet::onShowModel);
@@ -212,14 +213,14 @@ void WinDockNet::onNet()
212213
QString unit = "";
213214

214215
m_info->netInfo(upload, down);
215-
double increaseUpload = m_info->netShowUnit((upload - m_upload) / (m_timer->interval() / 1000.0), netUnit);
216+
double increaseUpload = m_info->netShowUnit((upload - m_upload) / (m_timer->interval() / 1000.0), netUnit);
216217
unit = m_info->netModelUnit(netUnit, m_modelUnit);
217-
m_vecLabel[1]->setText(QString("%1").arg(increaseUpload, 0, 'f', m_precision, QLatin1Char(' ')) + unit);
218+
m_vecLabel[1]->setText(QString("%1").arg(increaseUpload, 3, 'f', m_precision, QLatin1Char(' ')) + unit);
218219

219220
netUnit = Byte;
220221
double increaseDown = m_info->netShowUnit((down - m_down) / (m_timer->interval() / 1000.0), netUnit);
221222
unit = m_info->netModelUnit(netUnit, m_modelUnit);
222-
m_vecLabel[3]->setText(QString("%1").arg(increaseDown, 0, 'f', m_precision, QLatin1Char(' ')) + unit);
223+
m_vecLabel[3]->setText(QString("%1").arg(increaseDown, 3, 'f', m_precision, QLatin1Char(' ')) + unit);
223224

224225
m_upload = upload;
225226
m_down = down;
@@ -275,14 +276,13 @@ void WinDockNet::onCurrentFont(const QFont &font)
275276

276277
void WinDockNet::onFontSize(int size)
277278
{
278-
QFont font;
279-
font.setPointSize(size);
280-
281279
int nCount = m_gridLayout->count();
282280
for (int i = 0; i < nCount; ++i) {
283281
QLayoutItem *it = m_gridLayout->itemAt(i);
284-
QLabel * lab = static_cast<QLabel *>(it->widget());
285-
lab->setFont(font);
282+
QLabel *lab = static_cast<QLabel *>(it->widget());
283+
QFont *font = const_cast<QFont *>(&(lab->font()));
284+
font->setPointSize(size);
285+
// qDebug()<<"---------2@-------->"<<lab->font().family()<<lab->font().pointSize();
286286
}
287287
}
288288

0 commit comments

Comments
 (0)