Skip to content

Commit

Permalink
fix: the vertical lines of the datat chart becomes thicker while the …
Browse files Browse the repository at this point in the history
…zoom of the screen changes

After increasing the zoom of the control center screen,
the longitudinal line of the data chart becomes thicker

Log: After increasing the zoom of the control center screen,
the longitudinal line of the data chart becomes thicker
Bug: https://pms.uniontech.com/bug-view-241661.html
  • Loading branch information
lJxDabab committed Feb 21, 2024
1 parent fc1ad81 commit 0473b62
Show file tree
Hide file tree
Showing 10 changed files with 86 additions and 51 deletions.
9 changes: 5 additions & 4 deletions deepin-system-monitor-main/compact_cpu_monitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,10 @@ void CompactCpuMonitor::resizeEvent(QResizeEvent *event)
void CompactCpuMonitor::resizeItemRect()
{
m_detailButton->setFixedSize(m_detailButton->fontMetrics().width(m_detailButton->text()) + 12, m_detailButton->fontMetrics().height() + 4);
const QSize &detailtextSize = m_detailButton->size();
//additonPoses to align with the cpu text
int additionPosX=3;
int additionPoxY=3;
const QSize &detailtextSize = m_detailButton->size();
// additonPoses to align with the cpu text
int additionPosX = 3;
int additionPoxY = 3;
m_detailButton->setGeometry(this->width() - detailtextSize.width() + additionPosX, additionPoxY, detailtextSize.width(), detailtextSize.height());
}

Expand Down Expand Up @@ -258,6 +258,7 @@ void CompactCpuMonitor::paintEvent(QPaintEvent *)
dashes << 2 << space;
gridPen.setDashPattern(dashes);
gridPen.setColor(frameColor);
gridPen.setWidth(0);
painter.setPen(gridPen);

int gridLineX = gridX;
Expand Down
2 changes: 1 addition & 1 deletion deepin-system-monitor-main/compact_disk_monitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ void CompactDiskMonitor::paintEvent(QPaintEvent *)
qreal space = 2;
dashes << 2 << space;
gridPen.setColor(frameColor);
gridPen.setWidth(penSize);
gridPen.setWidth(0);
gridPen.setDashPattern(dashes);
painter.setPen(gridPen);

Expand Down
2 changes: 1 addition & 1 deletion deepin-system-monitor-main/compact_network_monitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ void CompactNetworkMonitor::paintEvent(QPaintEvent *)
qreal space = 2;
dashes << 2 << space;
gridPen.setColor(m_frameColor);
gridPen.setWidth(penSize);
gridPen.setWidth(0);
gridPen.setDashPattern(dashes);
painter.setPen(gridPen);

Expand Down
20 changes: 13 additions & 7 deletions deepin-system-monitor-main/gui/base/base_detail_item_delegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,19 @@ void BaseDetailItemDelegate::paint(QPainter *painter,
{
QBrush background;
QColor backgroundColor;
if(DApplicationHelper::instance()->themeType()==Dtk::Gui::DGuiApplicationHelper::ColorType::LightType){
backgroundColor=QColor(0,0,0);
if (DApplicationHelper::instance()->themeType() == Dtk::Gui::DGuiApplicationHelper::ColorType::LightType)
{
backgroundColor = QColor(0, 0, 0);
backgroundColor.setAlphaF(0);
if (!(index.row() & 1)) backgroundColor.setAlphaF(0.03);
}else{
backgroundColor=QColor(255,255,255);
if (!(index.row() & 1))
backgroundColor.setAlphaF(0.03);
}
else
{
backgroundColor = QColor(255, 255, 255);
backgroundColor.setAlphaF(0);
if (!(index.row() & 1)) backgroundColor.setAlphaF(0.03);
if (!(index.row() & 1))
backgroundColor.setAlphaF(0.03);
}
background = backgroundColor;
painter->save();
Expand All @@ -55,7 +60,8 @@ void BaseDetailItemDelegate::paint(QPainter *painter,
painter->setBrush(background);
painter->drawRect(option.rect);

if (index.isValid()) {
if (index.isValid())
{
const auto &ltextpalette = index.data(Qt::TextColorRole).value<QColor>();
painter->setPen(ltextpalette);

Expand Down
14 changes: 9 additions & 5 deletions deepin-system-monitor-main/gui/base/base_header_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,17 @@ QSize BaseHeaderView::sizeHint() const
void BaseHeaderView::paintEvent(QPaintEvent *event)
{
DHeaderView::paintEvent(event);
if(DApplicationHelper::instance()->themeType()==Dtk::Gui::DGuiApplicationHelper::ColorType::LightType){
setStyleSheet("border-radius: 8px;border: 1px solid white;");
}else{
if (DApplicationHelper::instance()->themeType() == Dtk::Gui::DGuiApplicationHelper::ColorType::LightType)
{
setStyleSheet("border-radius: 8px;border: 1px solid white;");
}
else
{
setStyleSheet("border-radius: 8px;border: 1px solid rgba(0,0,0,12);");
}
// draw focus
if (hasFocus() && m_focusReason == Qt::TabFocusReason) {
if (hasFocus() && m_focusReason == Qt::TabFocusReason)
{
QPainter painter(viewport());
painter.setRenderHint(QPainter::Antialiasing);

Expand All @@ -53,7 +57,7 @@ void BaseHeaderView::paintEvent(QPaintEvent *event)
QStyleOptionFocusRect o;
o.QStyleOption::operator=(option);
// need take scroll offset into consideration
QRect focusRect {rect.x() - offset(), rect.y(), length() - sectionPosition(0), rect.height()};
QRect focusRect{rect.x() - offset(), rect.y(), length() - sectionPosition(0), rect.height()};
o.rect = style->visualRect(layoutDirection(), rect, focusRect);
style->drawPrimitive(DStyle::PE_FrameFocusRect, &o, &painter);
}
Expand Down
1 change: 1 addition & 0 deletions deepin-system-monitor-main/gui/chart_view_widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ void ChartViewWidget::drawBackPixmap()
dashes << space << space;
gridPen.setDashPattern(dashes);
gridPen.setColor(frameColor);
gridPen.setWidth(0);
painter.setPen(gridPen);

int gridLineX = gridX;
Expand Down
1 change: 1 addition & 0 deletions deepin-system-monitor-main/gui/cpu_detail_widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ void CPUDetailGrapTableItem::drawBackground(QPainter &painter, const QRect &grap
dashes << space << space;
gridPen.setDashPattern(dashes);
gridPen.setColor(frameColor);
gridPen.setWidth(0);
painter.setPen(gridPen);
int section = 10;

Expand Down
56 changes: 38 additions & 18 deletions deepin-system-monitor-main/gui/netif_summary_view_widget.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,24 @@ class NetInfoDetailItemDelegate : public QStyledItemDelegate
const QStyleOptionViewItem &option,
const QModelIndex &index) const
{
const auto &palette =DApplicationHelper::instance()->applicationPalette();
QColor backgroundColor = palette.color(DPalette::Active,DPalette::Background);
QBrush background = backgroundColor;

if (!(index.row() & 1)){
QColor backgroundObviousColor = palette.color(DPalette::Active,DPalette::ItemBackground);
background = backgroundObviousColor;
const auto &palette = DApplicationHelper::instance()->applicationPalette();
QBrush background;
QColor backgroundColor;
if (DApplicationHelper::instance()->themeType() == Dtk::Gui::DGuiApplicationHelper::ColorType::LightType)
{
backgroundColor = QColor(0, 0, 0);
backgroundColor.setAlphaF(0);
if (!(index.row() & 1))
backgroundColor.setAlphaF(0.03);
}
else
{
backgroundColor = QColor(255, 255, 255);
backgroundColor.setAlphaF(0);
if (!(index.row() & 1))
backgroundColor.setAlphaF(0.03);
}
background = backgroundColor;

painter->save();
QPainterPath clipPath;
Expand All @@ -113,7 +123,8 @@ class NetInfoDetailItemDelegate : public QStyledItemDelegate
painter->setBrush(background);
painter->drawRect(option.rect);

if (index.isValid()) {
if (index.isValid())
{
QRect textRect = option.rect;
textRect.setX(textRect.x() + LEFTMARGIN);

Expand All @@ -124,28 +135,35 @@ class NetInfoDetailItemDelegate : public QStyledItemDelegate

ShowInfo stInfo = index.data(Qt::UserRole).value<ShowInfo>();

if (index.column() == 1 && stInfo.eType != ShowInfo::Normal) {
if (index.column() == 1 && stInfo.eType != ShowInfo::Normal)
{
// 绘制第2列IPV
QStringList listKey;
QStringList listValue = stInfo.strValue.split("/");

if (stInfo.eType == ShowInfo::IPV4) {
if (stInfo.eType == ShowInfo::IPV4)
{
listKey << QApplication::translate("NetInfoDetailItemDelegate", "IP address:") << QApplication::translate("NetInfoDetailItemDelegate", "Netmask:") << QApplication::translate("NetInfoDetailItemDelegate", "Broadcast:");
} else {
}
else
{
listKey << QApplication::translate("NetInfoDetailItemDelegate", "IP address:") << QApplication::translate("NetInfoDetailItemDelegate", "Prefixlen:") << QApplication::translate("NetInfoDetailItemDelegate", "Scope:");
}

if ((listKey.count() == listValue.count()) && (listValue.count() == 3)) {
if ((listKey.count() == listValue.count()) && (listValue.count() == 3))
{
// 获取key最宽的数值
QFontMetrics fm(painter->font());
int iMaxW = fm.width(listKey[0]);
for (int i = 1; i < listKey.count(); ++i) {
for (int i = 1; i < listKey.count(); ++i)
{
if (iMaxW < fm.width(listKey[i]))
iMaxW = fm.width(listKey[i]);
}

// 绘制内容
for (int i = 0; i < listKey.count(); ++i) {
for (int i = 0; i < listKey.count(); ++i)
{
// 绘制IPV标题
QRect titleRect;
titleRect.setX(textRect.x());
Expand All @@ -163,16 +181,18 @@ class NetInfoDetailItemDelegate : public QStyledItemDelegate
painter->drawText(valueRect, Qt::AlignLeft | Qt::AlignVCenter, listValue[i]);
}
}

} else if (index.column() == 0 && stInfo.eType != ShowInfo::Normal) {
}
else if (index.column() == 0 && stInfo.eType != ShowInfo::Normal)
{
// 绘制第1列IPV
textRect.setY(textRect.y() + TOPMARGIN);
painter->drawText(textRect, Qt::AlignLeft | Qt::AlignTop, stInfo.strKey);
} else {
}
else
{
// 其余左对齐、垂直居中
painter->drawText(textRect, Qt::AlignLeft | Qt::AlignVCenter, index.data(Qt::DisplayRole).toString());
}

}
painter->restore();
}
Expand Down
4 changes: 2 additions & 2 deletions deepin-system-monitor-main/gui/process_table_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ void ProcessTableView::onThemeTypeChanged()
palette.setColor(DPalette::Text, palette.color(DPalette::PlaceholderText));
m_notFoundLabel->setPalette(palette);

// palette.setColor(DPalette::Button, palette.color(DPalette::Base));
// header()->setPalette(palette);
// palette.setColor(DPalette::Button, palette.color(DPalette::Base));
// header()->setPalette(palette);
}

QString ProcessTableView::getProcessName(int pid)
Expand Down
28 changes: 15 additions & 13 deletions deepin-system-monitor-main/gui/system_service_table_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -412,8 +412,8 @@ void SystemServiceTableView::initUI(bool settingsLoaded)
m_noMatchingResultLabel->setPalette(palette);
m_noMatchingResultLabel->setVisible(false);

// palette.setColor(DPalette::Button, palette.color(DPalette::Base));
// header()->setPalette(palette);
// palette.setColor(DPalette::Button, palette.color(DPalette::Base));
// header()->setPalette(palette);

// header view instance
auto *hdr = header();
Expand Down Expand Up @@ -443,7 +443,8 @@ void SystemServiceTableView::initUI(bool settingsLoaded)
setContextMenuPolicy(Qt::CustomContextMenu);

// set service table default style when backup settings can not be loaded
if (!settingsLoaded) {
if (!settingsLoaded)
{
setColumnWidth(SystemServiceTableModel::kSystemServiceNameColumn, 200);
setColumnHidden(SystemServiceTableModel::kSystemServiceNameColumn, false);
setColumnWidth(SystemServiceTableModel::kSystemServiceLoadStateColumn, 100);
Expand Down Expand Up @@ -495,35 +496,36 @@ void SystemServiceTableView::initUI(bool settingsLoaded)
m_headerContextMenu = new DMenu(this);
// load state column action
m_loadStateHeaderAction = m_headerContextMenu->addAction(
DApplication::translate("Service.Table.Header", kSystemServiceLoadState));
DApplication::translate("Service.Table.Header", kSystemServiceLoadState));
m_loadStateHeaderAction->setCheckable(true);
// active state column action
m_activeStateHeaderAction = m_headerContextMenu->addAction(
DApplication::translate("Service.Table.Header", kSystemServiceActiveState));
DApplication::translate("Service.Table.Header", kSystemServiceActiveState));
m_activeStateHeaderAction->setCheckable(true);
// sub state column action
m_subStateHeaderAction = m_headerContextMenu->addAction(
DApplication::translate("Service.Table.Header", kSystemServiceSubState));
DApplication::translate("Service.Table.Header", kSystemServiceSubState));
m_subStateHeaderAction->setCheckable(true);
// state column action
m_stateHeaderAction = m_headerContextMenu->addAction(
DApplication::translate("Service.Table.Header", kSystemServiceState));
DApplication::translate("Service.Table.Header", kSystemServiceState));
m_stateHeaderAction->setCheckable(true);
// description column action
m_descriptionHeaderAction = m_headerContextMenu->addAction(
DApplication::translate("Service.Table.Header", kSystemServiceDescription));
DApplication::translate("Service.Table.Header", kSystemServiceDescription));
m_descriptionHeaderAction->setCheckable(true);
// pid column
m_pidHeaderAction = m_headerContextMenu->addAction(
DApplication::translate("Service.Table.Header", kSystemServicePID));
DApplication::translate("Service.Table.Header", kSystemServicePID));
m_pidHeaderAction->setCheckable(true);
// startup mode column
m_startupModeHeaderAction = m_headerContextMenu->addAction(
DApplication::translate("Service.Table.Header", kSystemServiceStartupMode));
DApplication::translate("Service.Table.Header", kSystemServiceStartupMode));
m_startupModeHeaderAction->setCheckable(true);

// set default checkable state when backup settings load without success
if (!settingsLoaded) {
if (!settingsLoaded)
{
m_loadStateHeaderAction->setChecked(false);
m_activeStateHeaderAction->setChecked(true);
m_subStateHeaderAction->setChecked(true);
Expand Down Expand Up @@ -566,8 +568,8 @@ void SystemServiceTableView::initConnections()
m_noMatchingResultLabel->setPalette(palette);
}

// palette.setColor(DPalette::Button, palette.color(DPalette::Base));
// header()->setPalette(palette);
// palette.setColor(DPalette::Button, palette.color(DPalette::Base));
// header()->setPalette(palette);

auto pa = DApplicationHelper::instance()->applicationPalette();
// set spinner color
Expand Down

0 comments on commit 0473b62

Please sign in to comment.