Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions deepin-devicemanager/src/DeviceManager/DeviceManager.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
// SPDX-FileCopyrightText: 2022 - 2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

Expand Down Expand Up @@ -1935,8 +1935,6 @@
out << "\n";
}



void DeviceManager::overviewToHtml(QFile &html)
{
qCDebug(appLog) << "Exporting overview to html";
Expand Down Expand Up @@ -2179,6 +2177,16 @@
}
}

void DeviceManager::setCpuHeaderInfo(const QList<QList<QPair<QString, QString> > > &info)
{
m_ListCpuHeaderInfo = info;
}

void DeviceManager::getCpuHeaderInfo(QList<QList<QPair<QString, QString> > > &info) const

Check warning on line 2185 in deepin-devicemanager/src/DeviceManager/DeviceManager.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

The function 'getCpuHeaderInfo' is never used.

Check warning on line 2185 in deepin-devicemanager/src/DeviceManager/DeviceManager.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

The function 'getCpuHeaderInfo' is never used.
{
info = m_ListCpuHeaderInfo;
}

bool DeviceManager::validateKeyboardVidPid(const QString &vid, const QString &pid, QString &normalizedVid, QString &normalizedPid)
{
qCDebug(appLog) << "Validating keyboard VID:" << vid << "PID:" << pid;
Expand Down
7 changes: 5 additions & 2 deletions deepin-devicemanager/src/DeviceManager/DeviceManager.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd.
// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
// SPDX-FileCopyrightText: 2019 - 2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

Expand Down Expand Up @@ -632,6 +631,9 @@ class DeviceManager : public QObject
*/
void setCpuFrequencyIsCur(const bool &flag);

void setCpuHeaderInfo(const QList<QList<QPair<QString, QString>>> &info);
void getCpuHeaderInfo(QList<QList<QPair<QString, QString>>> &info) const;

/**
* @brief validateKeyboardVidPid:校验有效的vid和pid
* @param vid
Expand Down Expand Up @@ -680,6 +682,7 @@ class DeviceManager : public QObject

static int m_CurrentXlsRow; //<! xlsx表格当前行
QStringList m_networkDriver; //网络驱动
QList<QList<QPair<QString, QString>>> m_ListCpuHeaderInfo; // 所有物理CPU个体的头部信息
};

#endif // DEVICEMANAGER_H
65 changes: 65 additions & 0 deletions deepin-devicemanager/src/GenerateDevice/DeviceGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,10 @@
device->setCpuInfo(*it, lshw, dmidecode, coreNum, logicalNum);
DeviceManager::instance()->addCpuDevice(device);
}

// 计算并设置CPU头部信息(当前没有多个物理CPU的环境,所以只能编码单物理CPU的逻辑)
if (lsCpu.size() > 0)
calAndSetCpuHeaderInfo(lsCpu.at(0), coreNum, logicalNum);
}

void DeviceGenerator::generatorBiosDevice()
Expand Down Expand Up @@ -1512,7 +1516,68 @@
return "";
}

void DeviceGenerator::calAndSetCpuHeaderInfo(const QMap<QString, QString> &firstProcessorInfo,
int coreNum, int logicalNum)
{
QList<QList<QPair<QString, QString>>> cpuHeaderInfo;
QList<QPair<QString, QString>> singleCpuHeaderInfo;

if (firstProcessorInfo.contains("model name")) {
QPair<QString, QString> modelName(tr("Model Name"), firstProcessorInfo.value("model name"));
singleCpuHeaderInfo.push_back(modelName);
}
if (firstProcessorInfo.contains("vendor_id")) {
QPair<QString, QString> vendorID(tr("Vendor ID"), firstProcessorInfo.value("vendor_id"));
singleCpuHeaderInfo.push_back(vendorID);
}
if (firstProcessorInfo.contains("Architecture")) {
QPair<QString, QString> arch(tr("Architecture"), firstProcessorInfo.value("Architecture"));
singleCpuHeaderInfo.push_back(arch);
}
if (coreNum > 0) {
QPair<QString, QString> coreCount(tr("Core(s)"), QString::number(coreNum));
singleCpuHeaderInfo.push_back(coreCount);
QPair<QString, QString> threadPerCore(tr("Thread(s)"), QString::number(logicalNum / coreNum));
singleCpuHeaderInfo.push_back(threadPerCore);
}
if (firstProcessorInfo.contains("L1d cache")) {
QString strL1dCache = firstProcessorInfo.value("L1d cache");
QString strTotalL1dCache = Common::formatTotalCache(strL1dCache, coreNum);
if (!strTotalL1dCache.isEmpty()) {
QPair<QString, QString> totalL1dCache(tr("L1d cache"), strTotalL1dCache);
singleCpuHeaderInfo.push_back(totalL1dCache);
}
}
if (firstProcessorInfo.contains("L1i cache")) {
QString strL1iCache = firstProcessorInfo.value("L1i cache");
QString strTotalL1iCache = Common::formatTotalCache(strL1iCache, coreNum);
if (!strTotalL1iCache.isEmpty()) {
QPair<QString, QString> totalL1iCache(tr("L1i cache"), strTotalL1iCache);
singleCpuHeaderInfo.push_back(totalL1iCache);
}
}
if (firstProcessorInfo.contains("L2 cache")) {
QString strL2Cache = firstProcessorInfo.value("L2 cache");
QString strTotalL2Cache = Common::formatTotalCache(strL2Cache, coreNum);
if (!strTotalL2Cache.isEmpty()) {
QPair<QString, QString> totalL2Cache(tr("L2 cache"), strTotalL2Cache);
singleCpuHeaderInfo.push_back(totalL2Cache);
}
}
if (firstProcessorInfo.contains("L3 cache")) {
QString strL3Cache = firstProcessorInfo.value("L3 cache");
QString strTotalL3Cache = Common::formatTotalCache(strL3Cache, 1);
if (!strTotalL3Cache.isEmpty()) {
QPair<QString, QString> totalL3Cache(tr("L3 cache"), strTotalL3Cache);
singleCpuHeaderInfo.push_back(totalL3Cache);
}
}

cpuHeaderInfo.push_back(singleCpuHeaderInfo);
DeviceManager::instance()->setCpuHeaderInfo(cpuHeaderInfo);
}

void DeviceGenerator::generatorInfoFromToml(DeviceType deviceType)

Check warning on line 1580 in deepin-devicemanager/src/GenerateDevice/DeviceGenerator.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

The function 'generatorInfoFromToml' is never used.

Check warning on line 1580 in deepin-devicemanager/src/GenerateDevice/DeviceGenerator.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

The function 'generatorInfoFromToml' is never used.
{
qCDebug(appLog) << "Generator info from toml";
DeviceManager::instance()->tomlDeviceSet(deviceType);
Expand Down
7 changes: 5 additions & 2 deletions deepin-devicemanager/src/GenerateDevice/DeviceGenerator.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd.
// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
// SPDX-FileCopyrightText: 2019 - 2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

Expand Down Expand Up @@ -338,6 +337,10 @@ class DeviceGenerator : public QObject

protected:
QStringList m_ListBusID;

private:
void calAndSetCpuHeaderInfo(const QMap<QString, QString> &firstProcessorInfo,
int coreNum, int logicalNum);
};

#endif // DEVICEGENERATOR_H
4 changes: 2 additions & 2 deletions deepin-devicemanager/src/Page/MainWindow.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
// SPDX-FileCopyrightText: 2022 - 2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

Expand Down Expand Up @@ -50,7 +50,7 @@ DWIDGET_USE_NAMESPACE
using namespace DDLog;
// 主界面需要的一些宏定义
#define INIT_WIDTH 1000 // 窗口的初始化宽度
#define INIT_HEIGHT 720 // 窗口的初始化高度
#define INIT_HEIGHT 802 // 窗口的初始化高度
#define MIN_WIDTH 680 // 窗口的最小宽度
#define MIN_HEIGHT 300 // 窗口的最小高度

Expand Down
77 changes: 66 additions & 11 deletions deepin-devicemanager/src/Page/PageMultiInfo.cpp
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
// SPDX-FileCopyrightText: 2022 - 2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

// 项目自身文件
#include "PageMultiInfo.h"
#include "headerinfotablewidget.h"

Check warning on line 7 in deepin-devicemanager/src/Page/PageMultiInfo.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "headerinfotablewidget.h" not found.

Check warning on line 7 in deepin-devicemanager/src/Page/PageMultiInfo.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

Include file: "headerinfotablewidget.h" not found.
#include "PageTableHeader.h"
#include "PageDetail.h"
#include "MacroDefinition.h"

Check warning on line 10 in deepin-devicemanager/src/Page/PageMultiInfo.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "MacroDefinition.h" not found.

Check warning on line 10 in deepin-devicemanager/src/Page/PageMultiInfo.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

Include file: "MacroDefinition.h" not found.
#include "DeviceInfo.h"
#include "PageDriverControl.h"
#include "DevicePrint.h"

Check warning on line 13 in deepin-devicemanager/src/Page/PageMultiInfo.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "DevicePrint.h" not found.

Check warning on line 13 in deepin-devicemanager/src/Page/PageMultiInfo.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

Include file: "DevicePrint.h" not found.
#include "DeviceInput.h"

Check warning on line 14 in deepin-devicemanager/src/Page/PageMultiInfo.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "DeviceInput.h" not found.

Check warning on line 14 in deepin-devicemanager/src/Page/PageMultiInfo.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

Include file: "DeviceInput.h" not found.
#include "DeviceNetwork.h"

Check warning on line 15 in deepin-devicemanager/src/Page/PageMultiInfo.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "DeviceNetwork.h" not found.

Check warning on line 15 in deepin-devicemanager/src/Page/PageMultiInfo.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

Include file: "DeviceNetwork.h" not found.
#include "DeviceCpu.h"

Check warning on line 16 in deepin-devicemanager/src/Page/PageMultiInfo.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "DeviceCpu.h" not found.

Check warning on line 16 in deepin-devicemanager/src/Page/PageMultiInfo.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

Include file: "DeviceCpu.h" not found.
#include "DDLog.h"

Check warning on line 17 in deepin-devicemanager/src/Page/PageMultiInfo.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "DDLog.h" not found.

Check warning on line 17 in deepin-devicemanager/src/Page/PageMultiInfo.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

Include file: "DDLog.h" not found.
#include "commonfunction.h"

Check warning on line 18 in deepin-devicemanager/src/Page/PageMultiInfo.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "commonfunction.h" not found.

Check warning on line 18 in deepin-devicemanager/src/Page/PageMultiInfo.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

Include file: "commonfunction.h" not found.

// Dtk头文件
#include <DFontSizeManager>
Expand All @@ -22,7 +24,6 @@
#include <DMessageManager>

// Qt库文件
#include <QVBoxLayout>
#include <QAction>
#include <QIcon>
#include <QLoggingCategory>
Expand All @@ -33,10 +34,14 @@
using namespace DDLog;

#define LEAST_PAGE_HEIGHT 315 // PageMultiInfo最小高度 当小于这个高度时,上方的表格就要变小
static constexpr int kHeaderInfoDefaultHeight = 362; // 滚动区域默认高度

PageMultiInfo::PageMultiInfo(QWidget *parent)
: PageInfo(parent)
, mp_Label(new DLabel(this))
, mp_HeaderInfoWidget(new DScrollArea(this))
, mp_HeaderInfoContainer(new DWidget(mp_HeaderInfoWidget))
, mp_HeaderInfoWidgetLay(new QVBoxLayout(mp_HeaderInfoContainer))
, mp_Table(new PageTableHeader(this))
, mp_Detail(new PageDetail(this))
{
Expand Down Expand Up @@ -64,6 +69,11 @@
{
qCDebug(appLog) << "PageMultiInfo destructor start";
// 清空指针
if (mp_HeaderInfoWidget) {
delete mp_HeaderInfoWidget;
mp_HeaderInfoWidget = nullptr;
mp_HeaderInfoContainer = nullptr;
}
if (mp_Table) {
qCDebug(appLog) << "Deleting table";
delete mp_Table;
Expand All @@ -89,6 +99,26 @@
qCWarning(appLog) << "Empty device list provided";
return;
}

// 当前为CPU页面,显示头部信息视图
DeviceCpu *cpuInfo = dynamic_cast<DeviceCpu *>(lst.at(0));
if (cpuInfo) {
QList<QList<QPair<QString, QString>>> headerInfo;
DeviceManager::instance()->getCpuHeaderInfo(headerInfo);
clearLayout(mp_HeaderInfoWidgetLay);
for (int i = 0; i < headerInfo.size(); ++i) {
HeaderInfoTableWidget *headerWidget = new HeaderInfoTableWidget(mp_HeaderInfoWidget);
headerWidget->updateData(headerInfo.at(i));
mp_HeaderInfoWidgetLay->addWidget(headerWidget);
}
mp_HeaderInfoWidget->setMaximumHeight(kHeaderInfoDefaultHeight);
mp_HeaderInfoWidget->resize(this->width(), kHeaderInfoDefaultHeight);
mp_HeaderInfoWidget->setVisible(true);
} else {
mp_HeaderInfoWidget->setVisible(false);
mp_HeaderInfoWidget->setMaximumHeight(0);
}

m_deviceList.clear();
m_menuControlList.clear();

Expand Down Expand Up @@ -285,23 +315,35 @@
{
qCDebug(appLog) << "PageMultiInfo::initWidgets";
// 初始化界面布局
QVBoxLayout *hLayout = new QVBoxLayout();
QVBoxLayout *vLayout = new QVBoxLayout();
QHBoxLayout *labelLayout = new QHBoxLayout();
labelLayout->addSpacing(10);
labelLayout->addWidget(mp_Label);

// Label 距离上下控件的距离LABEL_MARGIN
hLayout->addSpacing(LABEL_MARGIN);
hLayout->addLayout(labelLayout);
hLayout->addSpacing(LABEL_MARGIN);
vLayout->addSpacing(LABEL_MARGIN);
vLayout->addLayout(labelLayout);
vLayout->addSpacing(LABEL_MARGIN);

// 添加头部信息视图
mp_HeaderInfoWidget->setWidget(mp_HeaderInfoContainer);
mp_HeaderInfoWidget->setWidgetResizable(true);
mp_HeaderInfoWidget->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
mp_HeaderInfoWidget->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
mp_HeaderInfoWidget->setFrameShape(QFrame::NoFrame);
mp_HeaderInfoWidget->setMaximumHeight(kHeaderInfoDefaultHeight);
mp_HeaderInfoWidget->setMinimumHeight(0);
mp_HeaderInfoWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
mp_HeaderInfoWidgetLay->setContentsMargins(0, 0, 0, 0);
mp_HeaderInfoWidget->setVisible(false);
vLayout->addWidget(mp_HeaderInfoWidget, 1); // stretch=1,允许随窗口缩放

mp_Table->setFixedHeight(TABLE_HEIGHT);
vLayout->addWidget(mp_Table);
vLayout->addWidget(mp_Detail);
vLayout->setContentsMargins(10, 10, 10, 0);

hLayout->addWidget(mp_Table);
hLayout->addWidget(mp_Detail);
hLayout->setContentsMargins(10, 10, 10, 0);

setLayout(hLayout);
setLayout(vLayout);
}

void PageMultiInfo::getTableListInfo(const QList<DeviceBaseInfo *> &lst, QList<QStringList> &deviceList, QList<QStringList> &menuControlList)
Expand Down Expand Up @@ -341,3 +383,16 @@
}
qCDebug(appLog) << "PageMultiInfo::getTableListInfo end";
}

void PageMultiInfo::clearLayout(QLayout *layout)
{
QLayoutItem *item;
while ((item = layout->takeAt(0)) != nullptr) {
// 如果布局项包含控件,删除该控件
if (QWidget *widget = item->widget()) {
widget->deleteLater(); // 安全删除,避免事件冲突
}
// 删除布局项本身(注意:如果 item 是子布局,需递归处理,本例仅处理直接控件)
delete item;
}
}
11 changes: 9 additions & 2 deletions deepin-devicemanager/src/Page/PageMultiInfo.h
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
// Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd.
// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
// SPDX-FileCopyrightText: 2019 - 2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

#ifndef DEVICEPAGE_H
#define DEVICEPAGE_H

#include <QObject>
#include <QVBoxLayout>
#include <DWidget>
#include <DLabel>
#include <DScrollArea>

#include "PageInfo.h"

Expand Down Expand Up @@ -122,8 +123,14 @@ private slots:
*/
void getTableListInfo(const QList<DeviceBaseInfo *> &lst, QList<QStringList>& deviceList, QList<QStringList>& menuList);

// 清空布局中的所有 Widget
void clearLayout(QLayout *layout);

private:
DLabel *mp_Label;
DScrollArea *mp_HeaderInfoWidget;
DWidget *mp_HeaderInfoContainer;
QVBoxLayout *mp_HeaderInfoWidgetLay;
PageTableHeader *mp_Table; //<! 上面的表格
PageDetail *mp_Detail; //<! 下面的详细内容
QList<DeviceBaseInfo *> m_lstDevice; //<! 保存设备列表
Expand Down
38 changes: 38 additions & 0 deletions deepin-devicemanager/src/Widget/headerinfotableDelegate.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// SPDX-FileCopyrightText: 2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

#include <DApplication>
#include <DPaletteHelper>
#include <DPalette>

#include "headerinfotableDelegate.h"

DWIDGET_USE_NAMESPACE

HeaderInfoDelegate::HeaderInfoDelegate(QObject *parent)
: QStyledItemDelegate(parent)
{
}

void HeaderInfoDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
QStyleOptionViewItem opt(option);
initStyleOption(&opt, index);

QWidget *wnd = DApplication::activeWindow();
DPalette::ColorGroup cg = wnd ? DPalette::Active : DPalette::Inactive;
auto palette = DPaletteHelper::instance()->palette(option.widget);

if (opt.state & QStyle::State_Selected) {
QColor highlightColor = palette.color(cg, DPalette::HighlightedText);
opt.palette.setColor(QPalette::Text, highlightColor);
opt.palette.setColor(QPalette::WindowText, highlightColor);
} else {
QColor normalColor = palette.color(cg, DPalette::Text);
opt.palette.setColor(QPalette::Text, normalColor);
opt.palette.setColor(QPalette::WindowText, normalColor);
}

QStyledItemDelegate::paint(painter, opt, index);
}
Loading
Loading