From 81b75fece781d8b6796eb310359af19abe25fb85 Mon Sep 17 00:00:00 2001 From: zhanghongyuan Date: Fri, 30 Oct 2026 10:09:09 +0800 Subject: [PATCH] feat: convert logging calls to categorized macros (2/8) Convert uncategorized qDebug/qWarning/qInfo/qCritical calls in this part of the code to the categorized macros (appLog/serviceLog/baseLog), so the log level follows the DConfig log_rules of org.deepin.dde.diskmanager and can be switched at runtime by the debug-mode script without restart. --- .../widgets/customcontrol/dmtreeview.cpp | 123 +++--- .../customcontrol/dmtreeviewdelegate.cpp | 87 ++-- .../widgets/customcontrol/infotopframe.cpp | 101 ++--- .../customcontrol/partchartshowing.cpp | 79 ++-- .../customcontrol/partitioninfowidget.cpp | 77 ++-- .../widgets/customcontrol/partitionwidget.cpp | 393 +++++++++--------- .../customcontrol/passwordinputdialog.cpp | 69 +-- .../widgets/customcontrol/radiuswidget.cpp | 59 +-- .../customcontrol/selecteditemwidget.cpp | 25 +- .../customcontrol/selectpvitemwidget.cpp | 73 ++-- 10 files changed, 548 insertions(+), 538 deletions(-) diff --git a/application/widgets/customcontrol/dmtreeview.cpp b/application/widgets/customcontrol/dmtreeview.cpp index 30a19ab1..fc706308 100644 --- a/application/widgets/customcontrol/dmtreeview.cpp +++ b/application/widgets/customcontrol/dmtreeview.cpp @@ -1,8 +1,9 @@ -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2022 - 2026 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-only +#include "ddlog.h" #include "dmtreeview.h" #include @@ -10,16 +11,16 @@ DmTreeview::DmTreeview(QWidget *parent) : DTreeView(parent) { - qDebug() << "DmTreeview constructor"; + qCDebug(appLog) << "DmTreeview constructor"; initUI(); initModel(); initDelegate(); - qDebug() << "DmTreeview initialized"; + qCDebug(appLog) << "DmTreeview initialized"; } void DmTreeview::initUI() { - qDebug() << "DmTreeview::initUI called"; + qCDebug(appLog) << "DmTreeview::initUI called"; setFrameShape(QFrame::NoFrame); setEditTriggers(QAbstractItemView::NoEditTriggers); setVerticalScrollMode(ScrollPerItem); @@ -30,96 +31,96 @@ void DmTreeview::initUI() setWindowFlags(Qt::FramelessWindowHint); //无边框 setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); /* setAttribute(Qt::WA_TranslucentBackground)*/; //背景透明 - qDebug() << "DmTreeview::initUI finished"; + qCDebug(appLog) << "DmTreeview::initUI finished"; } QStandardItem *DmTreeview::addItem(QStandardItem *item, const DiskInfoData &data, int flag) { - qDebug() << "Adding item, level:" << data.m_level << "path:" << data.m_diskPath; + qCDebug(appLog) << "Adding item, level:" << data.m_level << "path:" << data.m_diskPath; if (data.m_level == DMDbusHandler::DISK || data.m_level == DMDbusHandler::VOLUMEGROUP) { - qDebug() << "Adding DISK or VOLUMEGROUP item"; + qCDebug(appLog) << "Adding DISK or VOLUMEGROUP item"; QStandardItem *standardItem = new QStandardItem(); standardItem->setAccessibleDescription(data.m_diskPath); standardItem->setData(QVariant::fromValue(data), Qt::UserRole + 1); item->appendRow(standardItem); - qDebug() << "DISK or VOLUMEGROUP item added"; + qCDebug(appLog) << "DISK or VOLUMEGROUP item added"; return standardItem; } else { - qDebug() << "Adding other item with partition path:" << data.m_partitionPath; + qCDebug(appLog) << "Adding other item with partition path:" << data.m_partitionPath; QStandardItem *standardItem = new QStandardItem(data.m_diskPath); standardItem->setAccessibleDescription(data.m_partitionPath); standardItem->setData(QVariant::fromValue((data)), Qt::UserRole + 1); item->appendRow(standardItem); if (flag == 0) { - qDebug() << "Expanding index (0,0)"; + qCDebug(appLog) << "Expanding index (0,0)"; setExpanded(m_model->index(0, 0), true); } - qDebug() << "Other item added"; + qCDebug(appLog) << "Other item added"; return standardItem; } } QStandardItem *DmTreeview::addTopItem(const DiskInfoData &data) { - qDebug() << "Adding top item, path:" << data.m_diskPath; + qCDebug(appLog) << "Adding top item, path:" << data.m_diskPath; QStandardItem *item = new QStandardItem; item->setAccessibleDescription(data.m_diskPath); item->setData(QVariant::fromValue(data), Qt::UserRole + 1); m_model->appendRow(item); - qDebug() << "Top item added successfully"; + qCDebug(appLog) << "Top item added successfully"; return item; } void DmTreeview::initModel() { - qDebug() << "DmTreeview::initModel called"; + qCDebug(appLog) << "DmTreeview::initModel called"; m_model = new QStandardItemModel(this); m_sortViewFilter = new QSortFilterProxyModel(this); setModel(m_model); - qDebug() << "DmTreeview::initModel finished"; + qCDebug(appLog) << "DmTreeview::initModel finished"; } void DmTreeview::initDelegate() { - qDebug() << "DmTreeview::initDelegate called"; + qCDebug(appLog) << "DmTreeview::initDelegate called"; m_delegate = new DmTreeviewDelegate(this); setItemDelegate(m_delegate); - qDebug() << "DmTreeview::initDelegate finished"; + qCDebug(appLog) << "DmTreeview::initDelegate finished"; } QStandardItem *DmTreeview::getCurItem() //获取当前item { - qDebug() << "DmTreeview::getCurItem called"; + qCDebug(appLog) << "DmTreeview::getCurItem called"; QModelIndex index = currentIndex(); if (!index.isValid()) { - qDebug() << "Current index is invalid, returning nullptr"; + qCDebug(appLog) << "Current index is invalid, returning nullptr"; return nullptr; } else { - qDebug() << "Returning item from current index"; + qCDebug(appLog) << "Returning item from current index"; return m_model->itemFromIndex(index); } } QStandardItem *DmTreeview::getItemByIndex(const QModelIndex &index) { - // qDebug() << "DmTreeview::getItemByIndex called"; + // qCDebug(appLog) << "DmTreeview::getItemByIndex called"; if (index.isValid()) { - // qDebug() << "Index is valid, returning item from index"; + // qCDebug(appLog) << "Index is valid, returning item from index"; return m_model->itemFromIndex(index); } - // qDebug() << "Index is invalid, returning nullptr"; + // qCDebug(appLog) << "Index is invalid, returning nullptr"; return nullptr; } void DmTreeview::currentChanged(const QModelIndex ¤t, const QModelIndex &previous) { - qDebug() << "DmTreeview::currentChanged called"; + qCDebug(appLog) << "DmTreeview::currentChanged called"; Q_UNUSED(previous); DiskInfoData data = current.data(Qt::UserRole + 1).value(); - qDebug() << data.m_diskPath << data.m_diskSize << data.m_partitionSize << data.m_partitionPath << data.m_level << data.m_used << data.m_unused << data.m_start << data.m_end << data.m_fstype << data.m_mountpoints << data.m_sysLabel; + qCDebug(appLog) << data.m_diskPath << data.m_diskSize << data.m_partitionSize << data.m_partitionPath << data.m_level << data.m_used << data.m_unused << data.m_start << data.m_end << data.m_fstype << data.m_mountpoints << data.m_sysLabel; if (data.m_level == DMDbusHandler::OTHER) { - qDebug() << "Ignoring OTHER level item"; + qCDebug(appLog) << "Ignoring OTHER level item"; return; } @@ -127,33 +128,33 @@ void DmTreeview::currentChanged(const QModelIndex ¤t, const QModelIndex &p m_diskNum = current.parent().row(); m_groupNum = current.parent().parent().row(); - qDebug() << "Selection position - curNum:" << m_curNum << "diskNum:" << m_diskNum << "groupNum:" << m_groupNum; + qCDebug(appLog) << "Selection position - curNum:" << m_curNum << "diskNum:" << m_diskNum << "groupNum:" << m_groupNum; emit selectItem(current); emit curSelectChanged(data.m_diskPath, data.m_partitionPath, data.m_start, data.m_end, data.m_level); m_diskSize = data.m_diskSize; - qDebug() << "Current change handled, disk size:" << m_diskSize; + qCDebug(appLog) << "Current change handled, disk size:" << m_diskSize; } void DmTreeview::mousePressEvent(QMouseEvent *event) { - qDebug() << "DmTreeview::mousePressEvent called"; + qCDebug(appLog) << "DmTreeview::mousePressEvent called"; DTreeView::mousePressEvent(event); QModelIndex curIndex = indexAt(event->pos()); QModelIndex index = curIndex.sibling(curIndex.row(), 0); if ((event->button() == Qt::LeftButton) && (index.isValid())) { - qDebug() << "Left mouse button pressed and index is valid, toggling expanded state"; + qCDebug(appLog) << "Left mouse button pressed and index is valid, toggling expanded state"; setExpanded(currentIndex(), !isExpanded(currentIndex())); } - qDebug() << "DmTreeview::mousePressEvent finished"; + qCDebug(appLog) << "DmTreeview::mousePressEvent finished"; } void DmTreeview::addItem(DmDiskinfoBox *infoBox, int flag, QStandardItem *purItem) //增加节点 { - qDebug() << "DmTreeview::addItem (overload) called"; + qCDebug(appLog) << "DmTreeview::addItem (overload) called"; QStandardItem *item = nullptr; DiskInfoData data; data.m_diskSize = infoBox->m_diskSize; @@ -173,128 +174,128 @@ void DmTreeview::addItem(DmDiskinfoBox *infoBox, int flag, QStandardItem *purIte data.m_luksFlag = infoBox->m_luksFlag; if ((infoBox->m_level <= 0) && !isGroup) { - qDebug() << "InfoBox level is 0 or less and not a group"; + qCDebug(appLog) << "InfoBox level is 0 or less and not a group"; data.m_level = DMDbusHandler::DISK; item = addTopItem(data); foreach (auto sub, infoBox->m_childs) { - qDebug() << "Adding sub item for DISK level"; + qCDebug(appLog) << "Adding sub item for DISK level"; addSubItem(sub, item, flag); } } else if (infoBox->m_level == DMDbusHandler::OTHER) { - qDebug() << "InfoBox level is OTHER"; + qCDebug(appLog) << "InfoBox level is OTHER"; data.m_level = DMDbusHandler::OTHER; item = addTopItem(data); m_lstStandardItem << item; foreach (auto sub, infoBox->m_childs) { - qDebug() << "Adding sub item for OTHER level"; + qCDebug(appLog) << "Adding sub item for OTHER level"; addSubItem(sub, item, flag); } } else { - qDebug() << "InfoBox level is not DISK or OTHER, or is a group"; + qCDebug(appLog) << "InfoBox level is not DISK or OTHER, or is a group"; if (purItem == nullptr) { - qDebug() << "purItem is nullptr, getting current item"; + qCDebug(appLog) << "purItem is nullptr, getting current item"; purItem = getCurItem(); if (purItem == nullptr) { - qDebug() << "Current item is also nullptr, returning"; + qCDebug(appLog) << "Current item is also nullptr, returning"; return; } } if (infoBox->m_level <= 0) { - qDebug() << "InfoBox level is 0 or less"; + qCDebug(appLog) << "InfoBox level is 0 or less"; QVariant var = purItem->index().data(Qt::UserRole + 1); DiskInfoData parent_data = var.value(); data.m_level = DMDbusHandler::DISK; item = addItem(purItem, data, flag); foreach (auto sub, infoBox->m_childs) { - qDebug() << "Adding sub item for DISK level (nested)"; + qCDebug(appLog) << "Adding sub item for DISK level (nested)"; addSubItem(sub, item, flag); } } else if (infoBox->m_level == DMDbusHandler::VOLUMEGROUP) { - qDebug() << "InfoBox level is VOLUMEGROUP"; + qCDebug(appLog) << "InfoBox level is VOLUMEGROUP"; QVariant var = purItem->index().data(Qt::UserRole + 1); DiskInfoData parent_data = var.value(); data.m_level = DMDbusHandler::VOLUMEGROUP; item = addItem(purItem, data, flag); foreach (auto sub, infoBox->m_childs) { - qDebug() << "Adding sub item for VOLUMEGROUP level (nested)"; + qCDebug(appLog) << "Adding sub item for VOLUMEGROUP level (nested)"; addSubItem(sub, item, flag); } } else { - qDebug() << "InfoBox level is neither DISK nor VOLUMEGROUP (nested)"; + qCDebug(appLog) << "InfoBox level is neither DISK nor VOLUMEGROUP (nested)"; QVariant var = purItem->index().data(Qt::UserRole + 1); DiskInfoData parent_data = var.value(); data.m_level = parent_data.m_level + 1; addItem(purItem, data, flag); } } - qDebug() << "DmTreeview::addItem (overload) finished"; + qCDebug(appLog) << "DmTreeview::addItem (overload) finished"; } void DmTreeview::clearData() { - qDebug() << "DmTreeview::clearData called"; + qCDebug(appLog) << "DmTreeview::clearData called"; m_lstStandardItem.clear(); - qDebug() << "DmTreeview::clearData finished"; + qCDebug(appLog) << "DmTreeview::clearData finished"; } void DmTreeview::addTopItem(DmDiskinfoBox *mailBox, int flag) { - qDebug() << "DmTreeview::addTopItem (overload) called"; + qCDebug(appLog) << "DmTreeview::addTopItem (overload) called"; if (mailBox->m_level == DMDbusHandler::OTHER) { - qDebug() << "Mailbox level is OTHER, setting isGroup to true"; + qCDebug(appLog) << "Mailbox level is OTHER, setting isGroup to true"; isGroup = true; addItem(mailBox, flag); } else { - qDebug() << "Mailbox level is not OTHER, setting isGroup to false and level to 0"; + qCDebug(appLog) << "Mailbox level is not OTHER, setting isGroup to false and level to 0"; isGroup = false; mailBox->m_level = 0; addItem(mailBox, flag); } - qDebug() << "DmTreeview::addTopItem (overload) finished"; + qCDebug(appLog) << "DmTreeview::addTopItem (overload) finished"; } void DmTreeview::addSubItem(DmDiskinfoBox *mailBox, QStandardItem *curItem, int flag) { - qDebug() << "DmTreeview::addSubItem called"; + qCDebug(appLog) << "DmTreeview::addSubItem called"; if (mailBox->m_level < 1) { - qDebug() << "Mailbox level is less than 1, setting to 0"; + qCDebug(appLog) << "Mailbox level is less than 1, setting to 0"; mailBox->m_level = 0; } addItem(mailBox, flag, curItem); - qDebug() << "DmTreeview::addSubItem finished"; + qCDebug(appLog) << "DmTreeview::addSubItem finished"; } QModelIndex DmTreeview::setDefaultdmItem() //设置默认选中节点 { - qDebug() << "DmTreeview::setDefaultdmItem called"; + qCDebug(appLog) << "DmTreeview::setDefaultdmItem called"; //QModelIndex index = m_pSortViewFilter->index(0, 0, getRootItemIndex()); #if QT_VERSION_MAJOR > 5 - qDebug() << "QT_VERSION_MAJOR > 5, setting current index"; + qCDebug(appLog) << "QT_VERSION_MAJOR > 5, setting current index"; setCurrentIndex(model()->index(0, 0, model()->index(0, 0))); #else - qDebug() << "QT_VERSION_MAJOR <= 5, setting current index"; + qCDebug(appLog) << "QT_VERSION_MAJOR <= 5, setting current index"; setCurrentIndex(model()->index(0, 0).child(0, 0)); #endif setExpanded(model()->index(0, 0), true); - qDebug() << "DmTreeview::setDefaultdmItem finished, returning index"; + qCDebug(appLog) << "DmTreeview::setDefaultdmItem finished, returning index"; return model()->index(0, 0); } void DmTreeview::setRefreshItem(int devicenum, int num) //设置刷新后默认选择操作分区 { - qDebug() << "DmTreeview::setRefreshItem called with devicenum:" << devicenum << "num:" << num; + qCDebug(appLog) << "DmTreeview::setRefreshItem called with devicenum:" << devicenum << "num:" << num; if (-1 == devicenum) { - qDebug() << "devicenum is -1, setting current index to item num"; + qCDebug(appLog) << "devicenum is -1, setting current index to item num"; setCurrentIndex(m_model->item(num)->index()); setExpanded(m_model->item(num)->index(), true); } else { #if QT_VERSION_MAJOR > 5 - qDebug() << "QT_VERSION_MAJOR > 5, setting current index with devicenum and num"; + qCDebug(appLog) << "QT_VERSION_MAJOR > 5, setting current index with devicenum and num"; setCurrentIndex(model()->index(devicenum, 0).model()->index(num, 0)); #else setCurrentIndex(model()->index(devicenum, 0).child(num, 0)); diff --git a/application/widgets/customcontrol/dmtreeviewdelegate.cpp b/application/widgets/customcontrol/dmtreeviewdelegate.cpp index 839cf3ae..22fb127c 100644 --- a/application/widgets/customcontrol/dmtreeviewdelegate.cpp +++ b/application/widgets/customcontrol/dmtreeviewdelegate.cpp @@ -1,8 +1,9 @@ -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2022 - 2026 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-only +#include "ddlog.h" #include "dmtreeviewdelegate.h" #include "common.h" #include "dmtreeview.h" @@ -17,54 +18,54 @@ DmTreeviewDelegate::DmTreeviewDelegate(QAbstractItemView *parent) : DStyledItemDelegate(parent) , m_parentView(parent) { - qDebug() << "DmTreeviewDelegate constructor"; + qCDebug(appLog) << "DmTreeviewDelegate constructor"; #if QT_VERSION_MAJOR > 5 m_parentPb = m_parentView->palette(); connect(DGuiApplicationHelper::instance(), &DGuiApplicationHelper::themeTypeChanged, this, &DmTreeviewDelegate::onHandleChangeTheme); - qDebug() << "Connected themeTypeChanged signal for QT_VERSION_MAJOR > 5"; + qCDebug(appLog) << "Connected themeTypeChanged signal for QT_VERSION_MAJOR > 5"; #else m_parentPb = DApplicationHelper::instance()->palette(m_parentView); connect(DApplicationHelper::instance(), &DApplicationHelper::themeTypeChanged, this, &DmTreeviewDelegate::onHandleChangeTheme); - qDebug() << "Connected themeTypeChanged signal for QT_VERSION_MAJOR <= 5"; + qCDebug(appLog) << "Connected themeTypeChanged signal for QT_VERSION_MAJOR <= 5"; #endif onHandleChangeTheme(); - qDebug() << "DmTreeviewDelegate initialized"; + qCDebug(appLog) << "DmTreeviewDelegate initialized"; } QSize DmTreeviewDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const { - // qDebug() << "DmTreeviewDelegate::sizeHint called"; + // qCDebug(appLog) << "DmTreeviewDelegate::sizeHint called"; Q_UNUSED(option); DiskInfoData infoData = index.data(Qt::UserRole + 1).value(); - qDebug() << "Calculating size hint for item level:" << infoData.m_level; + qCDebug(appLog) << "Calculating size hint for item level:" << infoData.m_level; int height = 55; if (infoData.m_level == DMDbusHandler::DISK || infoData.m_level == DMDbusHandler::VOLUMEGROUP) { height = 72 + static_cast((QApplication::font().pointSizeF() / 0.75 - 14) * 1); - qDebug() << "Disk/VG item size:" << QSize(180, height); + qCDebug(appLog) << "Disk/VG item size:" << QSize(180, height); return QSize(180, height); } if (infoData.m_level == DMDbusHandler::OTHER) { height = 30 + static_cast((QApplication::font().pointSizeF() / 0.75 - 14) * 1); - qDebug() << "Other item size:" << QSize(180, height); + qCDebug(appLog) << "Other item size:" << QSize(180, height); return QSize(180, height); } height = 55 + static_cast((QApplication::font().pointSizeF() / 0.75 - 14) * 1); - qDebug() << "Default item size:" << QSize(180, height); + qCDebug(appLog) << "Default item size:" << QSize(180, height); return QSize(180, height); } void DmTreeviewDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const { - // qDebug() << "DmTreeviewDelegate::paint called"; + // qCDebug(appLog) << "DmTreeviewDelegate::paint called"; if (!index.isValid()) { - qDebug() << "Invalid index, returning"; + qCDebug(appLog) << "Invalid index, returning"; return; } @@ -76,10 +77,10 @@ void DmTreeviewDelegate::paint(QPainter *painter, const QStyleOptionViewItem &op QRect rect; rect.setX(option.rect.x() + 10); if (data.m_level == DMDbusHandler::DISK || data.m_level == DMDbusHandler::OTHER || data.m_level == DMDbusHandler::VOLUMEGROUP) { - // qDebug() << "Level is DISK, OTHER, or VOLUMEGROUP, adjusting Y"; + // qCDebug(appLog) << "Level is DISK, OTHER, or VOLUMEGROUP, adjusting Y"; rect.setY(option.rect.y() + 10); } else { - // qDebug() << "Level is not DISK, OTHER, or VOLUMEGROUP, setting Y"; + // qCDebug(appLog) << "Level is not DISK, OTHER, or VOLUMEGROUP, setting Y"; rect.setY(option.rect.y()); } @@ -87,17 +88,17 @@ void DmTreeviewDelegate::paint(QPainter *painter, const QStyleOptionViewItem &op // rect.setHeight(option.rect.height()); // 分区节点间有间隔 // 去掉分区节点间隔 if (data.m_level == DMDbusHandler::DISK || data.m_level == DMDbusHandler::VOLUMEGROUP) { - // qDebug() << "Level is DISK or VOLUMEGROUP, adjusting height"; + // qCDebug(appLog) << "Level is DISK or VOLUMEGROUP, adjusting height"; rect.setHeight(option.rect.height() - 9); } else { - // qDebug() << "Level is not DISK or VOLUMEGROUP, adjusting height"; + // qCDebug(appLog) << "Level is not DISK or VOLUMEGROUP, adjusting height"; rect.setHeight(option.rect.height() + 1); } painter->setRenderHints(QPainter::SmoothPixmapTransform); QRect paintRect = QRect(rect.left(), rect.top(), rect.width() - 19, rect.height()); if (data.m_level == DMDbusHandler::OTHER) { - // qDebug() << "Level is OTHER, adjusting paintRect width"; + // qCDebug(appLog) << "Level is OTHER, adjusting paintRect width"; paintRect = QRect(rect.left(), rect.top(), rect.width() - 10, rect.height()); } @@ -127,7 +128,7 @@ void DmTreeviewDelegate::paint(QPainter *painter, const QStyleOptionViewItem &op // 设置分区选中时文本颜色 if ((option.state & QStyle::State_Selected) && (data.m_level != DMDbusHandler::OTHER)) { - // qDebug() << "Item is selected and not OTHER level, filling path with highlight color"; + // qCDebug(appLog) << "Item is selected and not OTHER level, filling path with highlight color"; QColor fillColor = m_parentPb.color(DPalette::Normal, DPalette::Highlight); painter->setBrush(QBrush(fillColor)); painter->fillPath(path, painter->brush()); @@ -142,42 +143,42 @@ void DmTreeviewDelegate::paint(QPainter *painter, const QStyleOptionViewItem &op int pixmapWidth = 8; // 伸缩按钮宽 int pixmapHeight = 8; // 伸缩按钮高 if (treeView->getItemByIndex(index) && treeView->getItemByIndex(index)->hasChildren()) { - // qDebug() << "Treeview item has children"; + // qCDebug(appLog) << "Treeview item has children"; if ((option.state & QStyle::State_Selected) && (data.m_level == DMDbusHandler::DISK || data.m_level == DMDbusHandler::VOLUMEGROUP)) { - // qDebug() << "Selected DISK or VOLUMEGROUP item"; + // qCDebug(appLog) << "Selected DISK or VOLUMEGROUP item"; if (treeView->isExpanded(index)) { - // qDebug() << "Item is expanded, using arrow_check"; + // qCDebug(appLog) << "Item is expanded, using arrow_check"; directionIcon = Common::getIcon("arrow_check"); pixmapWidth = 10; pixmapHeight = 11; } else { - // qDebug() << "Item is not expanded, using arrow_right_check"; + // qCDebug(appLog) << "Item is not expanded, using arrow_right_check"; directionIcon = Common::getIcon("arrow_right_check"); pixmapWidth = 12; pixmapHeight = 11; } } else if (data.m_level == DMDbusHandler::OTHER) { - // qDebug() << "OTHER level item"; + // qCDebug(appLog) << "OTHER level item"; if (treeView->isExpanded(index)) { - // qDebug() << "Item is expanded, using smallarrow"; + // qCDebug(appLog) << "Item is expanded, using smallarrow"; directionIcon = Common::getIcon("smallarrow"); pixmapWidth = 9; pixmapHeight = 10; } else { - // qDebug() << "Item is not expanded, using smallarrow_right"; + // qCDebug(appLog) << "Item is not expanded, using smallarrow_right"; directionIcon = Common::getIcon("smallarrow_right"); pixmapWidth = 8; pixmapHeight = 10; } } else { - // qDebug() << "Other level item"; + // qCDebug(appLog) << "Other level item"; if (treeView->isExpanded(index)) { - // qDebug() << "Item is expanded, using arrow"; + // qCDebug(appLog) << "Item is expanded, using arrow"; directionIcon = Common::getIcon("arrow"); pixmapWidth = 10; pixmapHeight = 7; } else { - // qDebug() << "Item is not expanded, using arrow_right"; + // qCDebug(appLog) << "Item is not expanded, using arrow_right"; directionIcon = Common::getIcon("arrow_right"); pixmapWidth = 8; pixmapHeight = 11; @@ -195,21 +196,21 @@ void DmTreeviewDelegate::paint(QPainter *painter, const QStyleOptionViewItem &op QString text3 = data.m_partitionSize; if (data.m_level == DMDbusHandler::LOGICALVOLUME) { - // qDebug() << "Level is LOGICALVOLUME, setting text2 to sysLabel"; + // qCDebug(appLog) << "Level is LOGICALVOLUME, setting text2 to sysLabel"; text2 = data.m_sysLabel; } if (data.m_level == DMDbusHandler::OTHER) { - // qDebug() << "Painting OTHER level item"; + // qCDebug(appLog) << "Painting OTHER level item"; QFont font = DFontSizeManager::instance()->get(DFontSizeManager::T8, QFont::Medium); DGuiApplicationHelper::ColorType themeType = DGuiApplicationHelper::instance()->themeType(); if (themeType == DGuiApplicationHelper::LightType) { - // qDebug() << "Theme is LightType, setting pen color"; + // qCDebug(appLog) << "Theme is LightType, setting pen color"; QColor color("#000000"); color.setAlphaF(0.5); painter->setPen(color); } else if (themeType == DGuiApplicationHelper::DarkType) { - // qDebug() << "Theme is DarkType, setting pen color"; + // qCDebug(appLog) << "Theme is DarkType, setting pen color"; QColor color("#ffffff"); color.setAlphaF(0.5); painter->setPen(color); @@ -224,7 +225,7 @@ void DmTreeviewDelegate::paint(QPainter *painter, const QStyleOptionViewItem &op painter->drawPixmap(lefticon1Rect, directionIcon.pixmap(17, 17)); } else if (data.m_level == DMDbusHandler::DISK || data.m_level == DMDbusHandler::VOLUMEGROUP) { - // qDebug() << "Painting DISK or VOLUMEGROUP level item"; + // qCDebug(appLog) << "Painting DISK or VOLUMEGROUP level item"; int height = 24 + static_cast((QApplication::font().pointSizeF() / 0.75 - 14) * 1); lefticon1Rect.setRect(paintRect.left() + 8, paintRect.top() + height, pixmapWidth, pixmapHeight); painter->drawPixmap(lefticon1Rect, directionIcon.pixmap(17, 17)); @@ -233,21 +234,21 @@ void DmTreeviewDelegate::paint(QPainter *painter, const QStyleOptionViewItem &op QIcon icon = Common::getIcon("treedisk"); if (data.m_level == DMDbusHandler::DISK) { - // qDebug() << "Level is DISK"; + // qCDebug(appLog) << "Level is DISK"; if (DMDbusHandler::instance()->getIsJoinAllVG().value(text) == "true") { - // qDebug() << "Disk is joined to all VG, using treevg icon"; + // qCDebug(appLog) << "Disk is joined to all VG, using treevg icon"; icon = Common::getIcon("treevg"); } else if (DMDbusHandler::instance()->getIsAllEncryption().value(text) == "true") { - // qDebug() << "Disk is encrypted, using treedisklock icon"; + // qCDebug(appLog) << "Disk is encrypted, using treedisklock icon"; icon = Common::getIcon("treedisklock"); } } else if (data.m_level == DMDbusHandler::VOLUMEGROUP) { - // qDebug() << "Level is VOLUMEGROUP"; + // qCDebug(appLog) << "Level is VOLUMEGROUP"; if (DMDbusHandler::instance()->getIsAllEncryption().value(text) == "true") { - // qDebug() << "Volume group is encrypted, using treevglock icon"; + // qCDebug(appLog) << "Volume group is encrypted, using treevglock icon"; icon = Common::getIcon("treevglock"); } else { - // qDebug() << "Volume group is not encrypted, using treevg icon"; + // qCDebug(appLog) << "Volume group is not encrypted, using treevg icon"; icon = Common::getIcon("treevg"); } } @@ -255,7 +256,7 @@ void DmTreeviewDelegate::paint(QPainter *painter, const QStyleOptionViewItem &op QFont font = DFontSizeManager::instance()->get(DFontSizeManager::T6); if ((option.state & QStyle::State_Selected) && (data.m_level == DMDbusHandler::DISK || data.m_level == DMDbusHandler::VOLUMEGROUP)) { - // qDebug() << "Selected DISK or VOLUMEGROUP, painting highlighted text"; + // qCDebug(appLog) << "Selected DISK or VOLUMEGROUP, painting highlighted text"; QColor textcolor = m_parentPb.color(DPalette::Normal, DPalette::HighlightedText); painter->setPen(textcolor); painter->setFont(font); @@ -271,7 +272,7 @@ void DmTreeviewDelegate::paint(QPainter *painter, const QStyleOptionViewItem &op QString textSize = painter->fontMetrics().elidedText(text1, Qt::ElideMiddle, 108); painter->drawText(textRect1, textSize); } else { - // qDebug() << "Not selected DISK or VOLUMEGROUP, painting normal text"; + // qCDebug(appLog) << "Not selected DISK or VOLUMEGROUP, painting normal text"; QColor textcolor = m_parentPb.color(DPalette::Normal, DPalette::Text); painter->setPen(textcolor); painter->setFont(font); @@ -367,8 +368,8 @@ void DmTreeviewDelegate::paint(QPainter *painter, const QStyleOptionViewItem &op } void DmTreeviewDelegate::onHandleChangeTheme() { - qDebug() << "Handling theme change"; + qCDebug(appLog) << "Handling theme change"; m_parentPb = Dtk::Gui::DGuiApplicationHelper::instance()->applicationPalette(); m_parentView->update(m_parentView->currentIndex()); - qDebug() << "Theme updated and view refreshed"; + qCDebug(appLog) << "Theme updated and view refreshed"; } diff --git a/application/widgets/customcontrol/infotopframe.cpp b/application/widgets/customcontrol/infotopframe.cpp index e71d5c7e..d02a8673 100644 --- a/application/widgets/customcontrol/infotopframe.cpp +++ b/application/widgets/customcontrol/infotopframe.cpp @@ -1,8 +1,9 @@ -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2022 - 2026 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-only +#include "ddlog.h" #include "infotopframe.h" #include "partedproxy/dmdbushandler.h" #include "common.h" @@ -16,7 +17,7 @@ InfoTopFrame::InfoTopFrame(DWidget *parent) : DFrame(parent) { - qDebug() << "InfoTopFrame constructor"; + qCDebug(appLog) << "InfoTopFrame constructor"; setFixedHeight(110); setBackgroundRole(DPalette::ItemBackground); @@ -26,16 +27,16 @@ InfoTopFrame::InfoTopFrame(DWidget *parent) m_pictureLabel = new DLabel(this); if (DMDbusHandler::PARTITION == DMDbusHandler::instance()->getCurLevel()) { - qDebug() << "Current level is PARTITION, setting pixmap to labeldisk"; + qCDebug(appLog) << "Current level is PARTITION, setting pixmap to labeldisk"; m_pictureLabel->setPixmap(Common::getIcon("labeldisk").pixmap(85, 85)); } else if (DMDbusHandler::DISK == DMDbusHandler::instance()->getCurLevel()) { - qDebug() << "Current level is DISK, setting pixmap to disk"; + qCDebug(appLog) << "Current level is DISK, setting pixmap to disk"; m_pictureLabel->setPixmap(Common::getIcon("disk").pixmap(85, 85)); } else if (DMDbusHandler::VOLUMEGROUP == DMDbusHandler::instance()->getCurLevel()) { - qDebug() << "Current level is VOLUMEGROUP, setting pixmap to vg"; + qCDebug(appLog) << "Current level is VOLUMEGROUP, setting pixmap to vg"; m_pictureLabel->setPixmap(Common::getIcon("vg").pixmap(85, 85)); } else if (DMDbusHandler::LOGICALVOLUME == DMDbusHandler::instance()->getCurLevel()) { - qDebug() << "Current level is LOGICALVOLUME, setting pixmap to lv"; + qCDebug(appLog) << "Current level is LOGICALVOLUME, setting pixmap to lv"; m_pictureLabel->setPixmap(Common::getIcon("lv").pixmap(85, 85)); } @@ -47,12 +48,12 @@ InfoTopFrame::InfoTopFrame(DWidget *parent) m_mainLayout->addStretch(); initRightInfo(); - qDebug() << "InfoTopFrame initialized"; + qCDebug(appLog) << "InfoTopFrame initialized"; } void InfoTopFrame::initRightInfo() { - qDebug() << "InfoTopFrame::initRightInfo called"; + qCDebug(appLog) << "InfoTopFrame::initRightInfo called"; m_allNameLabel = new DLabel(tr("Capacity")); m_allNameLabel->setAlignment(Qt::AlignRight); DFontSizeManager::instance()->bind(m_allNameLabel, DFontSizeManager::T6); @@ -68,12 +69,12 @@ void InfoTopFrame::initRightInfo() layout->addStretch(); m_mainLayout->addLayout(layout); - qDebug() << "InfoTopFrame::initRightInfo finished"; + qCDebug(appLog) << "InfoTopFrame::initRightInfo finished"; } void InfoTopFrame::initLeftInfo() { - qDebug() << "InfoTopFrame::initLeftInfo called"; + qCDebug(appLog) << "InfoTopFrame::initLeftInfo called"; m_nameLabel = new DLabel; QFont nameFont = DFontSizeManager::instance()->get(DFontSizeManager::T5); nameFont.setBold(true); @@ -96,39 +97,39 @@ void InfoTopFrame::initLeftInfo() layout->setContentsMargins(0, 0, 0, 0); m_mainLayout->addLayout(layout); - qDebug() << "InfoTopFrame::initLeftInfo finished"; + qCDebug(appLog) << "InfoTopFrame::initLeftInfo finished"; } void InfoTopFrame::updateDiskInfo() { - qDebug() << "Updating disk info for level:" + qCDebug(appLog) << "Updating disk info for level:" << DMDbusHandler::instance()->getCurLevel(); if (DMDbusHandler::PARTITION == DMDbusHandler::instance()->getCurLevel()) { - qDebug() << "Current level is PARTITION"; + qCDebug(appLog) << "Current level is PARTITION"; auto info = DMDbusHandler::instance()->getCurPartititonInfo(); if (info.m_vgFlag != LVMFlag::LVM_FLAG_NOT_PV) { - qDebug() << "Partition is a PV, setting pixmap to lv"; + qCDebug(appLog) << "Partition is a PV, setting pixmap to lv"; m_pictureLabel->setPixmap(Common::getIcon("lv").pixmap(85, 85)); } else if (info.m_luksFlag == LUKSFlag::IS_CRYPT_LUKS) { - qDebug() << "Partition is LUKS encrypted, setting pixmap to partitionlock"; + qCDebug(appLog) << "Partition is LUKS encrypted, setting pixmap to partitionlock"; m_pictureLabel->setPixmap(Common::getIcon("partitionlock").pixmap(85, 85)); } else { - qDebug() << "Partition is neither PV nor LUKS encrypted, setting pixmap to labeldisk"; + qCDebug(appLog) << "Partition is neither PV nor LUKS encrypted, setting pixmap to labeldisk"; m_pictureLabel->setPixmap(Common::getIcon("labeldisk").pixmap(85, 85)); } QFontMetrics fmDevpath = m_nameLabel->fontMetrics(); QString textDevpath = info.m_path; #if QT_VERSION_MAJOR > 5 - qDebug() << "QT_VERSION_MAJOR > 5, getting devpathWidth"; + qCDebug(appLog) << "QT_VERSION_MAJOR > 5, getting devpathWidth"; int devpathWidth = fmDevpath.boundingRect(textDevpath).width(); #else - qDebug() << "QT_VERSION_MAJOR <= 5, getting devpathWidth"; + qCDebug(appLog) << "QT_VERSION_MAJOR <= 5, getting devpathWidth"; int devpathWidth = fmDevpath.width(textDevpath); #endif if (devpathWidth > width() / 2) { - qDebug() << "Devpath width exceeds half of widget width, eliding text"; + qCDebug(appLog) << "Devpath width exceeds half of widget width, eliding text"; devpathWidth = width() / 2; textDevpath = m_nameLabel->fontMetrics().elidedText(textDevpath, Qt::ElideMiddle, devpathWidth); } @@ -143,26 +144,26 @@ void InfoTopFrame::updateDiskInfo() QString diskType = Utils::fileSystemTypeToString(static_cast(info.m_fileSystemType)); if (info.m_luksFlag == LUKSFlag::IS_CRYPT_LUKS) { - qDebug() << "Partition is LUKS encrypted, checking decryption status"; + qCDebug(appLog) << "Partition is LUKS encrypted, checking decryption status"; LUKS_INFO luksInfo = DMDbusHandler::instance()->probLUKSInfo().m_luksMap.value(info.m_path); if (luksInfo.isDecrypt) { - qDebug() << "LUKS partition is decrypted, getting encryption file system type"; + qCDebug(appLog) << "LUKS partition is decrypted, getting encryption file system type"; diskType = DMDbusHandler::instance()->getEncryptionFsType(luksInfo); } } m_typeLabel->setText(tr("File system") + ": " + diskType); } else if (DMDbusHandler::DISK == DMDbusHandler::instance()->getCurLevel()) { - qDebug() << "Current level is DISK"; + qCDebug(appLog) << "Current level is DISK"; DeviceInfo info = DMDbusHandler::instance()->getCurDeviceInfo(); if (DMDbusHandler::instance()->getIsJoinAllVG().value(info.m_path) == "true") { - qDebug() << "Disk is joined to all VG, setting pixmap to vg"; + qCDebug(appLog) << "Disk is joined to all VG, setting pixmap to vg"; m_pictureLabel->setPixmap(Common::getIcon("vg").pixmap(85, 85)); } else if (DMDbusHandler::instance()->getIsAllEncryption().value(info.m_path) == "true") { - qDebug() << "Disk is all encrypted, setting pixmap to disklock"; + qCDebug(appLog) << "Disk is all encrypted, setting pixmap to disklock"; m_pictureLabel->setPixmap(Common::getIcon("disklock").pixmap(85, 85)); } else { - qDebug() << "Disk is neither joined to all VG nor all encrypted, setting pixmap to disk"; + qCDebug(appLog) << "Disk is neither joined to all VG nor all encrypted, setting pixmap to disk"; m_pictureLabel->setPixmap(Common::getIcon("disk").pixmap(85, 85)); } @@ -170,108 +171,108 @@ void InfoTopFrame::updateDiskInfo() m_allMemoryLabel->setText(diskSize); if (info.m_luksFlag == LUKSFlag::IS_CRYPT_LUKS && info.m_partition.size() == 0) { - qDebug() << "Disk is LUKS encrypted and has no partitions, handling as full disk encryption"; + qCDebug(appLog) << "Disk is LUKS encrypted and has no partitions, handling as full disk encryption"; // 处理磁盘是整盘加密页面显示 LUKS_INFO luksInfo = DMDbusHandler::instance()->probLUKSInfo().m_luksMap.value(info.m_path); m_nameLabel->setText(info.m_path); if (luksInfo.isDecrypt) { - qDebug() << "LUKS disk is decrypted, setting type label to encryption file system type"; + qCDebug(appLog) << "LUKS disk is decrypted, setting type label to encryption file system type"; m_typeLabel->setText(tr("File system") + ": " + DMDbusHandler::instance()->getEncryptionFsType(luksInfo)); } else { - qDebug() << "LUKS disk is not decrypted, setting type label to FS_LUKS"; + qCDebug(appLog) << "LUKS disk is not decrypted, setting type label to FS_LUKS"; m_typeLabel->setText(tr("File system") + ": " + Utils::fileSystemTypeToString(FSType::FS_LUKS)); } } else { - qDebug() << "Disk is not fully LUKS encrypted or has partitions, setting name and partition table type"; + qCDebug(appLog) << "Disk is not fully LUKS encrypted or has partitions, setting name and partition table type"; m_nameLabel->setText(info.m_model); QString partitionTable; if (info.m_disktype == "gpt") { - qDebug() << "Disk type is gpt"; + qCDebug(appLog) << "Disk type is gpt"; partitionTable = "GPT"; } else if (info.m_disktype == "msdos") { - qDebug() << "Disk type is msdos"; + qCDebug(appLog) << "Disk type is msdos"; partitionTable = "MBR"; } else { - qDebug() << "Disk type is other:" << info.m_disktype; + qCDebug(appLog) << "Disk type is other:" << info.m_disktype; partitionTable = info.m_disktype; } m_typeLabel->setText(tr("%1 partition table").arg(partitionTable)); } } else if (DMDbusHandler::VOLUMEGROUP == DMDbusHandler::instance()->getCurLevel()) { - qDebug() << "Current level is VOLUMEGROUP"; + qCDebug(appLog) << "Current level is VOLUMEGROUP"; VGInfo vgInfo = DMDbusHandler::instance()->getCurVGInfo(); if (DMDbusHandler::instance()->getIsAllEncryption().value(vgInfo.m_vgName) == "true") { - qDebug() << "Volume group is all encrypted, setting pixmap to vglock"; + qCDebug(appLog) << "Volume group is all encrypted, setting pixmap to vglock"; m_pictureLabel->setPixmap(Common::getIcon("vglock").pixmap(85, 85)); } else { - qDebug() << "Volume group is not all encrypted, setting pixmap to vg"; + qCDebug(appLog) << "Volume group is not all encrypted, setting pixmap to vg"; m_pictureLabel->setPixmap(Common::getIcon("vg").pixmap(85, 85)); } m_nameLabel->setText(vgInfo.m_vgName); QString vgSize = vgInfo.m_vgSize; if (vgSize.contains("1024")) { - qDebug() << "VG size contains 1024, reformatting size"; + qCDebug(appLog) << "VG size contains 1024, reformatting size"; vgSize = Utils::LVMFormatSize(vgInfo.m_peCount * vgInfo.m_PESize + vgInfo.m_PESize); } m_allMemoryLabel->setText(vgSize); m_typeLabel->setText(tr("Volume group")); } else if (DMDbusHandler::LOGICALVOLUME == DMDbusHandler::instance()->getCurLevel()) { - qDebug() << "Current level is LOGICALVOLUME"; + qCDebug(appLog) << "Current level is LOGICALVOLUME"; LVInfo lvInfo = DMDbusHandler::instance()->getCurLVInfo(); if (lvInfo.m_luksFlag == LUKSFlag::IS_CRYPT_LUKS) { - qDebug() << "Logical volume is LUKS encrypted, setting pixmap to lvlock"; + qCDebug(appLog) << "Logical volume is LUKS encrypted, setting pixmap to lvlock"; m_pictureLabel->setPixmap(Common::getIcon("lvlock").pixmap(85, 85)); } else { - qDebug() << "Logical volume is not LUKS encrypted, setting pixmap to lv"; + qCDebug(appLog) << "Logical volume is not LUKS encrypted, setting pixmap to lv"; m_pictureLabel->setPixmap(Common::getIcon("lv").pixmap(85, 85)); } m_nameLabel->setText(lvInfo.m_lvPath); QString lvSize = lvInfo.m_lvSize; if (lvSize.contains("1024")) { - qDebug() << "LV size contains 1024, reformatting size"; + qCDebug(appLog) << "LV size contains 1024, reformatting size"; lvSize = Utils::LVMFormatSize(lvInfo.m_lvLECount * lvInfo.m_LESize + lvInfo.m_LESize); } m_allMemoryLabel->setText(lvSize); QString fstypeName = Utils::fileSystemTypeToString(static_cast(lvInfo.m_lvFsType)); if (lvInfo.m_luksFlag == LUKSFlag::IS_CRYPT_LUKS) { - qDebug() << "LV is LUKS encrypted, checking decryption status"; + qCDebug(appLog) << "LV is LUKS encrypted, checking decryption status"; LUKS_INFO luksInfo = DMDbusHandler::instance()->probLUKSInfo().m_luksMap.value(lvInfo.m_lvPath); if (luksInfo.isDecrypt) { - qDebug() << "LUKS LV is decrypted, getting encryption file system type"; + qCDebug(appLog) << "LUKS LV is decrypted, getting encryption file system type"; fstypeName = DMDbusHandler::instance()->getEncryptionFsType(luksInfo); } - qDebug() << "Disk info updated successfully"; + qCDebug(appLog) << "Disk info updated successfully"; } m_typeLabel->setText(tr("File system") + ": " + fstypeName); } - qDebug() << "InfoTopFrame::updateDiskInfo finished"; + qCDebug(appLog) << "InfoTopFrame::updateDiskInfo finished"; } void InfoTopFrame::resizeEvent(QResizeEvent *event) { - // qDebug() << "InfoTopFrame::resizeEvent called"; + // qCDebug(appLog) << "InfoTopFrame::resizeEvent called"; if (DMDbusHandler::PARTITION == DMDbusHandler::instance()->getCurLevel()) { - qDebug() << "Current level is PARTITION, adjusting textDevpath"; + qCDebug(appLog) << "Current level is PARTITION, adjusting textDevpath"; auto info = DMDbusHandler::instance()->getCurPartititonInfo(); QFontMetrics fmDevpath = m_nameLabel->fontMetrics(); QString textDevpath = info.m_path; #if QT_VERSION_MAJOR > 5 - // qDebug() << "QT_VERSION_MAJOR > 5, getting devpathWidth for resizeEvent"; + // qCDebug(appLog) << "QT_VERSION_MAJOR > 5, getting devpathWidth for resizeEvent"; int devpathWidth = fmDevpath.boundingRect(textDevpath).width(); #else - // qDebug() << "QT_VERSION_MAJOR <= 5, getting devpathWidth for resizeEvent"; + // qCDebug(appLog) << "QT_VERSION_MAJOR <= 5, getting devpathWidth for resizeEvent"; int devpathWidth = fmDevpath.width(textDevpath); #endif if (devpathWidth > width() / 2) { - qDebug() << "Devpath width exceeds half of widget width in resizeEvent, eliding text"; + qCDebug(appLog) << "Devpath width exceeds half of widget width in resizeEvent, eliding text"; devpathWidth = width() / 2; textDevpath = m_nameLabel->fontMetrics().elidedText(textDevpath, Qt::ElideMiddle, devpathWidth); } @@ -279,5 +280,5 @@ void InfoTopFrame::resizeEvent(QResizeEvent *event) } DFrame::resizeEvent(event); - // qDebug() << "InfoTopFrame::resizeEvent finished"; + // qCDebug(appLog) << "InfoTopFrame::resizeEvent finished"; } diff --git a/application/widgets/customcontrol/partchartshowing.cpp b/application/widgets/customcontrol/partchartshowing.cpp index 4a3d449f..6985f9a5 100644 --- a/application/widgets/customcontrol/partchartshowing.cpp +++ b/application/widgets/customcontrol/partchartshowing.cpp @@ -3,6 +3,7 @@ // SPDX-License-Identifier: GPL-3.0-only +#include "ddlog.h" #include "partchartshowing.h" #include @@ -18,7 +19,7 @@ PartChartShowing::PartChartShowing(QWidget *parent) : QWidget(parent) { - qDebug() << "PartChartShowing constructor"; + qCDebug(appLog) << "PartChartShowing constructor"; QColor color("#70BEFF"); //浅蓝色 QColor color1("#4293FF"); //深蓝色 QColor color2("#6751E4"); //紫色 @@ -29,39 +30,39 @@ PartChartShowing::PartChartShowing(QWidget *parent) setMouseTracking(true); m_showTipTimer = new QTimer(this); connect(m_showTipTimer, &QTimer::timeout, this, &PartChartShowing::showTipTimerSlot); - qDebug() << "PartChartShowing initialized with colors and mouse tracking"; + qCDebug(appLog) << "PartChartShowing initialized with colors and mouse tracking"; } void PartChartShowing::transInfos(const double &totals, const QVector sizeInfo) { - qDebug() << "Transferring partition info, total size:" << totals + qCDebug(appLog) << "Transferring partition info, total size:" << totals << "partition count:" << sizeInfo.size(); m_total = totals; m_partSize = sizeInfo; - qDebug() << "Partition info updated"; + qCDebug(appLog) << "Partition info updated"; } void PartChartShowing::transFlag(int flag, int value) { - qDebug() << "Transferring flag:" << flag << "value:" << value; + qCDebug(appLog) << "Transferring flag:" << flag << "value:" << value; m_flag = flag; m_sumValue = value; update(); - qDebug() << "Flag updated and widget refreshed"; + qCDebug(appLog) << "Flag updated and widget refreshed"; } void PartChartShowing::showTipTimerSlot() { - qDebug() << "Showing tooltip for hover state:" << m_hover + qCDebug(appLog) << "Showing tooltip for hover state:" << m_hover << "partition:" << m_number2 << "at position:" << m_posX; emit sendMoveFlag(m_hover, m_number2, m_posX); m_showTipTimer->stop(); - qDebug() << "Tooltip shown and timer stopped"; + qCDebug(appLog) << "Tooltip shown and timer stopped"; } void PartChartShowing::paintEvent(QPaintEvent *event) { - // qDebug() << "PartChartShowing::paintEvent called"; + // qCDebug(appLog) << "PartChartShowing::paintEvent called"; //绘制整个分区的空闲空间以及文字颜色 QPainter painter(this); painter.save(); @@ -107,10 +108,10 @@ void PartChartShowing::paintEvent(QPaintEvent *event) font.setWeight(QFont::Medium); painter.setFont(font); if (DGuiApplicationHelper::instance()->themeType() == DGuiApplicationHelper::LightType) { - // qDebug() << "Theme is LightType, setting pen color to #001A2E"; + // qCDebug(appLog) << "Theme is LightType, setting pen color to #001A2E"; painter.setPen(QColor("#001A2E")); } else if (DGuiApplicationHelper::instance()->themeType() == DGuiApplicationHelper::DarkType) { - // qDebug() << "Theme is DarkType, setting pen color to #C0C0C0"; + // qCDebug(appLog) << "Theme is DarkType, setting pen color to #C0C0C0"; painter.setPen(QColor("#C0C0C0")); } painter.drawText(textRect, tr("Unallocated")); @@ -119,12 +120,12 @@ void PartChartShowing::paintEvent(QPaintEvent *event) addPaint(&painter); painter.restore(); - // qDebug() << "PartChartShowing::paintEvent finished"; + // qCDebug(appLog) << "PartChartShowing::paintEvent finished"; } void PartChartShowing::addPaint(QPainter *painter) { - // qDebug() << "PartChartShowing::addPaint called"; + // qCDebug(appLog) << "PartChartShowing::addPaint called"; painter->setPen(Qt::NoPen); painter->setRenderHint(QPainter::Antialiasing); QRect rect; @@ -137,33 +138,33 @@ void PartChartShowing::addPaint(QPainter *painter) QPainterPath painterPath; path.append(painterPath); } - // qDebug() << "Initialized paths for partitions"; + // qCDebug(appLog) << "Initialized paths for partitions"; QPainterPath paintPath; double sum = 0.00; //绘制默认选中状态 if (m_flag == 1) { - // qDebug() << "Flag is 1, drawing rounded rectangle with highlight color"; + // qCDebug(appLog) << "Flag is 1, drawing rounded rectangle with highlight color"; painter->setPen(QPen(QColor(palette().highlight().color()), 2)); painter->drawRoundedRect(paintRect, 8, 8); } for (int i = 0; i < m_partSize.size(); i++) { - // qDebug() << "Processing partition" << i; + // qCDebug(appLog) << "Processing partition" << i; double widths = (m_partSize.at(i) / m_total) * (paintRect.width() - RADIUS); double width1 = 0.00; widths = widths - RIGHTSPACE; if (m_partSize.at(i) / m_total < 0.01 || widths < RADIUS) { - // qDebug() << "Partition size is too small or width is less than radius, setting width to 8"; + // qCDebug(appLog) << "Partition size is too small or width is less than radius, setting width to 8"; widths = 8; } sum = sum + m_partSize.at(i); m_sums = sum; //i=0,绘制第一个分区,判断num绘制选中状态 if (i == 0) { - // qDebug() << "Processing first partition (i=0)"; + // qCDebug(appLog) << "Processing first partition (i=0)"; if (static_cast(sum) < static_cast(m_total)) { - // qDebug() << "Sum is less than total, drawing first part of path"; + // qCDebug(appLog) << "Sum is less than total, drawing first part of path"; path[0].moveTo(paintRect.topLeft() + QPoint(RADIUS, 0)); path[0].arcTo(QRect(QPoint(paintRect.topLeft()), QSize(RADIUS * 2, RADIUS * 2)), 90, 90); path[0].lineTo(paintRect.bottomLeft() - QPoint(0, RADIUS)); @@ -174,9 +175,9 @@ void PartChartShowing::addPaint(QPainter *painter) path[0].lineTo(paintRect.topLeft() + QPoint((static_cast(widths) + RADIUS), 0)); path[0].lineTo(paintRect.topLeft() + QPoint(RADIUS, 0)); } - // qDebug() << path[0].currentPosition().x(); + // qCDebug(appLog) << path[0].currentPosition().x(); if (static_cast(sum) >= static_cast(m_total)) { - // qDebug() << "Sum is greater than or equal to total, drawing full rounded rectangle path"; + // qCDebug(appLog) << "Sum is greater than or equal to total, drawing full rounded rectangle path"; path[0].moveTo(paintRect.bottomRight() - QPoint(0, RADIUS)); path[0].lineTo(paintRect.topRight() + QPoint(0, RADIUS)); path[0].arcTo(QRect(QPoint(paintRect.topRight() - QPoint(RADIUS * 2, 0)), @@ -196,9 +197,9 @@ void PartChartShowing::addPaint(QPainter *painter) painter->fillPath(path[0], QBrush(m_baseColor.at(0))); if (m_number == 0) { - // qDebug() << "m_number is 0, handling selection for first partition"; + // qCDebug(appLog) << "m_number is 0, handling selection for first partition"; if ((static_cast(widths) == 8) && m_partSize.size() == 2) { - // qDebug() << (static_cast(widths) - static_cast((8 - widths))); + // qCDebug(appLog) << (static_cast(widths) - static_cast((8 - widths))); QPainterPath seclect1path; seclect1path.moveTo(paintRect.topLeft() + QPoint(RADIUS, 0)); seclect1path.arcTo(QRect(QPoint(paintRect.topLeft()), QSize(RADIUS * 2, RADIUS * 2)), 90, 90); @@ -213,7 +214,7 @@ void PartChartShowing::addPaint(QPainter *painter) painter->setPen(QPen(this->palette().color(DPalette::Normal, DPalette::Highlight), 2)); painter->drawPath(seclect1path); } else { - // qDebug() << "Drawing normal selection path for first partition"; + // qCDebug(appLog) << "Drawing normal selection path for first partition"; painter->setBrush(QBrush(m_baseColor.at(0))); painter->setPen(QPen(this->palette().color(DPalette::Normal, DPalette::Highlight), 2)); painter->drawPath(path[0]); @@ -224,17 +225,17 @@ void PartChartShowing::addPaint(QPainter *painter) } } else if (sum + 1 < m_total && i > 0) { //绘制除了第一个分区和最后一个分区以及空闲分区的填充和选中状态 - // qDebug() << "Processing middle partition (i>0)"; - // qDebug() << static_cast(sum) << static_cast(total); + // qCDebug(appLog) << "Processing middle partition (i>0)"; + // qCDebug(appLog) << static_cast(sum) << static_cast(total); width1 = (m_partSize.at(i - 1) / m_total) * (paintRect.width() - RADIUS); width1 = width1 - RIGHTSPACE; if (width1 < 8 || m_partSize.at(i - 1) / m_total < 0.01) { - // qDebug() << "Previous partition width is too small, setting width1 to 8"; + // qCDebug(appLog) << "Previous partition width is too small, setting width1 to 8"; width1 = 8; } //未避免设置最小宽度带来的图形溢出,在所画图形宽度即将到圆角时,不予新增分区 if (path[i - 1].currentPosition().x() + width1 + widths > paintRect.width() - 2 * RADIUS) { - // qDebug() << "Graphical overflow detected, emitting judgeLastPartition signal"; + // qCDebug(appLog) << "Graphical overflow detected, emitting judgeLastPartition signal"; emit judgeLastPartition(); } path[i].moveTo(path[i - 1].currentPosition() + QPoint(static_cast(width1), 0)); @@ -244,34 +245,34 @@ void PartChartShowing::addPaint(QPainter *painter) path[i].lineTo(path[i - 1].currentPosition() + QPoint((static_cast(width1)), 0)); QColor fillColor; if (i > m_baseColor.size() - 1) { - // qDebug() << "Index i is out of baseColor range, using modulo"; + // qCDebug(appLog) << "Index i is out of baseColor range, using modulo"; fillColor = m_baseColor.at(i % (m_baseColor.size() - 1)); } else { - // qDebug() << "Using baseColor at index i"; + // qCDebug(appLog) << "Using baseColor at index i"; fillColor = m_baseColor.at(i); } painter->fillPath(path[i], QBrush(fillColor)); // if (m_number > 0 && m_number != -1 && m_number == i) { if (m_number > 0 && m_number == i) { - // qDebug() << "m_number matches current index i, drawing selection rectangle"; + // qCDebug(appLog) << "m_number matches current index i, drawing selection rectangle"; painter->setBrush(fillColor); painter->setPen(QPen(this->palette().color(DPalette::Normal, DPalette::Highlight), 2)); if (width1 < 8) { - // qDebug() << "width1 is less than 8, setting to 8"; + // qCDebug(appLog) << "width1 is less than 8, setting to 8"; width1 = 8; } if (i == m_partSize.size() - 1) { - // qDebug() << "Current partition is the last one, drawing rectangle without width adjustment"; + // qCDebug(appLog) << "Current partition is the last one, drawing rectangle without width adjustment"; painter->drawRect(static_cast(path[m_number - 1].currentPosition().x() + width1), static_cast(path[m_number - 1].currentPosition().y()), static_cast(widths), paintRect.height() - 1); } else { - // qDebug() << "Current partition is not the last one, drawing rectangle with width adjustment"; + // qCDebug(appLog) << "Current partition is not the last one, drawing rectangle with width adjustment"; painter->drawRect(static_cast(path[m_number - 1].currentPosition().x() + width1), static_cast(path[m_number - 1].currentPosition().y()), static_cast(widths - 1), paintRect.height() - 1); } m_flag = 0; } } else { //绘制最后一个分区当超过整个分区容量的时候以及选中状态 - // qDebug() << "Sum value is 100 or more, handling last partition"; - // qDebug() << "sumvalue" << sumvalue; + // qCDebug(appLog) << "Sum value is 100 or more, handling last partition"; + // qCDebug(appLog) << "sumvalue" << sumvalue; double width = ((m_partSize.at(m_partSize.size() - 2) / m_total)) * (paintRect.width() - RADIUS) - RIGHTSPACE; if (m_partSize.at(m_partSize.size() - 2) / m_total < 0.01) { width = 8; @@ -300,7 +301,7 @@ void PartChartShowing::addPaint(QPainter *painter) painter->setBrush(fillColor); QPainterPath selectPath; if (static_cast((m_partSize.at(m_partSize.size() - 2) / m_total) * (paintRect.width() - RADIUS)) - 1 <= 8) { - // qDebug() << 8 - (static_cast((partsize.at(partsize.size() - 2) / total) * (paintRect.width() - RADIUS)) - 1); + // qCDebug(appLog) << 8 - (static_cast((partsize.at(partsize.size() - 2) / total) * (paintRect.width() - RADIUS)) - 1); if (static_cast((m_partSize.at(m_partSize.size() - 2) / m_total) * (paintRect.width() - RADIUS)) - 1 == 7) { selectPath.moveTo(path[m_partSize.size() - 2].currentPosition() + QPoint(static_cast((m_partSize.at(m_partSize.size() - 2) / m_total) * (paintRect.width() - RADIUS)) + (8 - (static_cast((m_partSize.at(m_partSize.size() - 2) / m_total) * (paintRect.width() - RADIUS)) + 1)), 0)); } else { @@ -352,7 +353,7 @@ void PartChartShowing::addPaint(QPainter *painter) void PartChartShowing::mousePressEvent(QMouseEvent *event) { if (event->button() != Qt::LeftButton) { - qDebug() << "Ignoring non-left mouse button press"; + qCDebug(appLog) << "Ignoring non-left mouse button press"; return; } @@ -383,7 +384,7 @@ void PartChartShowing::mousePressEvent(QMouseEvent *event) update(); } } - // qDebug() << flag; + // qCDebug(appLog) << flag; //空闲分区 double width1 = ((m_partSize.at(m_partSize.size() - 1) / m_total) * (width() - SPACE)) - RIGHTSPACE; if (m_partSize.size() > 1) { diff --git a/application/widgets/customcontrol/partitioninfowidget.cpp b/application/widgets/customcontrol/partitioninfowidget.cpp index aabdbc03..0b9448f2 100644 --- a/application/widgets/customcontrol/partitioninfowidget.cpp +++ b/application/widgets/customcontrol/partitioninfowidget.cpp @@ -1,8 +1,9 @@ -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2022 - 2026 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-only +#include "ddlog.h" #include "partitioninfowidget.h" #include @@ -12,7 +13,7 @@ PartitionInfoWidget::PartitionInfoWidget(QWidget *parent) : QWidget(parent) { - qDebug() << "PartitionInfoWidget constructor"; + qCDebug(appLog) << "PartitionInfoWidget constructor"; QColor color("#70BEFF"); //浅蓝色 QColor color1("#4293FF"); //蓝色 QColor color2("#6751E4"); //紫色 @@ -26,12 +27,12 @@ PartitionInfoWidget::PartitionInfoWidget(QWidget *parent) : QWidget(parent) m_colorInfo = QVector {color, color1, color2, color3, color4, color5, color6, color7, color8, color9}; setMouseTracking(true); - qDebug() << "PartitionInfoWidget initialized with colors and mouse tracking"; + qCDebug(appLog) << "PartitionInfoWidget initialized with colors and mouse tracking"; } void PartitionInfoWidget::setData(DeviceInfo info) { - qDebug() << "Setting partition data, partition count:" << info.m_partition.size(); + qCDebug(appLog) << "Setting partition data, partition count:" << info.m_partition.size(); m_sizeInfo.clear(); m_pathInfo.clear(); m_totalSize = 0.00; @@ -42,27 +43,27 @@ void PartitionInfoWidget::setData(DeviceInfo info) m_pathInfo.append(partitionInfo.m_path); if (FSType::FS_EXTENDED == static_cast(partitionInfo.m_fileSystemType)) { - qDebug() << "Partition is EXTENDED type, setting total size to partition size"; + qCDebug(appLog) << "Partition is EXTENDED type, setting total size to partition size"; m_totalSize = partitionSize; } } m_totalSize += Utils::sectorToUnit(info.m_length, info.m_sectorSize, SIZE_UNIT::UNIT_GIB); if (info.m_partition.isEmpty()) { - qDebug() << "No partitions found, adding unallocated space"; + qCDebug(appLog) << "No partitions found, adding unallocated space"; m_sizeInfo.append(m_totalSize); m_pathInfo.append("unallocated"); } update(); - qDebug() << "Partition data set, total size:" << m_totalSize << "GiB"; + qCDebug(appLog) << "Partition data set, total size:" << m_totalSize << "GiB"; } void PartitionInfoWidget::paintEvent(QPaintEvent *event) { - // qDebug() << "PartitionInfoWidget::paintEvent called"; + // qCDebug(appLog) << "PartitionInfoWidget::paintEvent called"; if (m_sizeInfo.isEmpty()) { - // qDebug() << "Size info is empty, returning"; + // qCDebug(appLog) << "Size info is empty, returning"; return; } @@ -76,17 +77,17 @@ void PartitionInfoWidget::paintEvent(QPaintEvent *event) QPainterPath painterPath; path.append(painterPath); } - // qDebug() << "Initialized paths for partitions"; + // qCDebug(appLog) << "Initialized paths for partitions"; DPalette palette; QColor color; DGuiApplicationHelper::ColorType themeType = DGuiApplicationHelper::instance()->themeType(); if (themeType == DGuiApplicationHelper::LightType) { - // qDebug() << "Theme is LightType, setting color alpha to 0.1"; + // qCDebug(appLog) << "Theme is LightType, setting color alpha to 0.1"; color = palette.color(DPalette::Normal, DPalette::ToolTipText); color.setAlphaF(0.1); } else if (themeType == DGuiApplicationHelper::DarkType) { - // qDebug() << "Theme is DarkType, setting color alpha to 0.2"; + // qCDebug(appLog) << "Theme is DarkType, setting color alpha to 0.2"; color = palette.color(DPalette::Normal, DPalette::BrightText); color.setAlphaF(0.2); } @@ -103,21 +104,21 @@ void PartitionInfoWidget::paintEvent(QPaintEvent *event) int smallCount = 0; for (int i = 0; i < m_sizeInfo.size(); i++) { if (m_sizeInfo[i] / m_totalSize < 0.01 || (m_sizeInfo[i] / m_totalSize) * (paintRect.width() - 8) < 8) { - // qDebug() << "Partition" << i << "is small"; + // qCDebug(appLog) << "Partition" << i << "is small"; smallCount++; smallSum += (m_sizeInfo[i] / m_totalSize) * (paintRect.width() - 8); } else { - // qDebug() << "Partition" << i << "is big"; + // qCDebug(appLog) << "Partition" << i << "is big"; bigCount++; } } double space = (smallCount * 8 - smallSum) / bigCount; - // qDebug() << "Calculated space for small partitions:" << space; + // qCDebug(appLog) << "Calculated space for small partitions:" << space; m_reectInfo.clear(); int radius = 8; if (1 == m_sizeInfo.size()) { - // qDebug() << "Only one partition, drawing full rounded rectangle"; + // qCDebug(appLog) << "Only one partition, drawing full rounded rectangle"; path[0].moveTo(paintRect.bottomRight() - QPoint(0, radius)); path[0].lineTo(paintRect.topRight() + QPoint(0, radius)); path[0].arcTo(QRect(QPoint(paintRect.topRight() - QPoint(radius * 2, 0)), @@ -132,12 +133,12 @@ void PartitionInfoWidget::paintEvent(QPaintEvent *event) QSize(radius * 2, radius * 2)), 270, 90); if (m_pathInfo.at(0) == "unallocated") { - // qDebug() << "First partition is unallocated, filling with color"; + // qCDebug(appLog) << "First partition is unallocated, filling with color"; painter.setBrush(QBrush(color)); painter.setPen(QPen(color, 3)); painter.fillPath(path[0], color); } else { - // qDebug() << "First partition is allocated, filling with base color"; + // qCDebug(appLog) << "First partition is allocated, filling with base color"; painter.setBrush(QBrush(m_colorInfo[0])); painter.setPen(QPen(QColor(m_colorInfo[0]), 3)); painter.fillPath(path[0], m_colorInfo[0]); @@ -145,19 +146,19 @@ void PartitionInfoWidget::paintEvent(QPaintEvent *event) m_reectInfo.append(path[0].controlPointRect()); } else { - // qDebug() << "Multiple partitions, iterating to draw rectangles"; + // qCDebug(appLog) << "Multiple partitions, iterating to draw rectangles"; //根据color和size数据遍历绘制矩形 for (int i = 0; i < m_sizeInfo.size(); i++) { - // qDebug() << "Drawing partition" << i; + // qCDebug(appLog) << "Drawing partition" << i; double widths = (m_sizeInfo[i] / m_totalSize) * (paintRect.width() - radius); double width1 = 0.00; widths = widths - space; if (m_sizeInfo[i] / m_totalSize < 0.01 || widths < radius) { - // qDebug() << "Partition" << i << "width is too small, setting to 8"; + // qCDebug(appLog) << "Partition" << i << "width is too small, setting to 8"; widths = 8; } if (i == 0) { - // qDebug() << "Drawing first partition of multiple partitions"; + // qCDebug(appLog) << "Drawing first partition of multiple partitions"; path[0].moveTo(paintRect.topLeft() + QPoint(radius, 0)); path[0].arcTo(QRect(QPoint(paintRect.topLeft()), QSize(radius * 2, radius * 2)), 90, 90); path[0].lineTo(paintRect.bottomLeft() - QPoint(0, radius)); @@ -167,12 +168,12 @@ void PartitionInfoWidget::paintEvent(QPaintEvent *event) path[0].lineTo(paintRect.topLeft() + QPoint(static_cast(widths + radius), 0)); path[0].lineTo(paintRect.topLeft() + QPoint(radius, 0)); if (m_pathInfo.at(0) == "unallocated") { - // qDebug() << "First partition is unallocated, filling with color"; + // qCDebug(appLog) << "First partition is unallocated, filling with color"; painter.setBrush(QBrush(color)); painter.setPen(QPen(color, 3)); painter.fillPath(path[0], color); } else { - // qDebug() << "First partition is allocated, filling with base color"; + // qCDebug(appLog) << "First partition is allocated, filling with base color"; painter.setBrush(QBrush(m_colorInfo[0])); painter.setPen(QPen(QColor(m_colorInfo[0]), 3)); painter.fillPath(path[0], m_colorInfo[0]); @@ -180,11 +181,11 @@ void PartitionInfoWidget::paintEvent(QPaintEvent *event) m_reectInfo.append(path[0].controlPointRect()); } else if (i > 0 && i < (m_sizeInfo.size() - 1)) { - // qDebug() << "Drawing middle partition" << i; + // qCDebug(appLog) << "Drawing middle partition" << i; width1 = (m_sizeInfo[i - 1] / m_totalSize) * (paintRect.width() - radius); width1 = width1 - space; if (width1 < 8 || m_sizeInfo[i - 1] / m_totalSize < 0.01) { - // qDebug() << "Previous partition width is too small, setting width1 to 8"; + // qCDebug(appLog) << "Previous partition width is too small, setting width1 to 8"; width1 = 8; } @@ -195,12 +196,12 @@ void PartitionInfoWidget::paintEvent(QPaintEvent *event) path[i].lineTo(path[i - 1].currentPosition() + QPoint(static_cast(width1), 0)); if (m_pathInfo.at(i) == "unallocated") { - // qDebug() << "Middle partition is unallocated, filling with color"; + // qCDebug(appLog) << "Middle partition is unallocated, filling with color"; painter.setBrush(QBrush(color)); painter.setPen(QPen(color, 3)); painter.fillPath(path[i], color); } else { - // qDebug() << "Middle partition is allocated, filling with base color (modulo)"; + // qCDebug(appLog) << "Middle partition is allocated, filling with base color (modulo)"; painter.setBrush(QBrush(m_colorInfo[i % (m_colorInfo.size())])); painter.setPen(QPen(QColor(m_colorInfo[i % (m_colorInfo.size())]), 3)); painter.fillPath(path[i], m_colorInfo[i % (m_colorInfo.size())]); @@ -208,10 +209,10 @@ void PartitionInfoWidget::paintEvent(QPaintEvent *event) m_reectInfo.append(path[i].controlPointRect()); } else if (i == (m_sizeInfo.size() - 1)) { - // qDebug() << "Drawing last partition"; + // qCDebug(appLog) << "Drawing last partition"; double width = ((m_sizeInfo[m_sizeInfo.size() - 2] / m_totalSize)) * (paintRect.width() - radius) - space; if (m_sizeInfo[m_sizeInfo.size() - 2] / m_totalSize < 0.01) { - // qDebug() << "Second to last partition width is too small, setting width to 8"; + // qCDebug(appLog) << "Second to last partition width is too small, setting width to 8"; width = 8; } @@ -227,12 +228,12 @@ void PartitionInfoWidget::paintEvent(QPaintEvent *event) QSize(radius * 2, radius * 2)), 270, 90); if (m_pathInfo.at(m_sizeInfo.size() - 1) == "unallocated") { - // qDebug() << "Last partition is unallocated, filling with color"; + // qCDebug(appLog) << "Last partition is unallocated, filling with color"; painter.setBrush(QBrush(color)); painter.setPen(QPen(color, 3)); painter.fillPath(path[m_sizeInfo.size() - 1], color); } else { - // qDebug() << "Last partition is allocated, filling with base color (modulo)"; + // qCDebug(appLog) << "Last partition is allocated, filling with base color (modulo)"; painter.setBrush(QBrush(m_colorInfo[(m_sizeInfo.size() - 1) % (m_colorInfo.size())])); painter.setPen(QPen(QColor(m_colorInfo[(m_sizeInfo.size() - 1) % (m_colorInfo.size())]), 3)); painter.fillPath(path[m_sizeInfo.size() - 1], m_colorInfo[(m_sizeInfo.size() - 1) % (m_colorInfo.size())]); @@ -248,11 +249,11 @@ void PartitionInfoWidget::paintEvent(QPaintEvent *event) QPainterPath painterPath; painterPath.addRoundedRect(roundRect, 3, 3); #if QT_VERSION_MAJOR > 5 - // qDebug() << "QT_VERSION_MAJOR > 5, getting application palette"; + // qCDebug(appLog) << "QT_VERSION_MAJOR > 5, getting application palette"; m_parentPb = DGuiApplicationHelper::instance()->applicationPalette();; QBrush brush = m_parentPb.dark(); #else - // qDebug() << "QT_VERSION_MAJOR <= 5, getting application palette"; + // qCDebug(appLog) << "QT_VERSION_MAJOR <= 5, getting application palette"; m_parentPb = DApplicationHelper::instance()->palette(this); QBrush brush = DApplicationHelper::instance()->palette(this).dark(); #endif @@ -273,7 +274,7 @@ void PartitionInfoWidget::paintEvent(QPaintEvent *event) painter.drawText(rectText, QString(tr("Unallocated")), option); painter.restore(); - // qDebug() << "PartitionInfoWidget::paintEvent finished"; + // qCDebug(appLog) << "PartitionInfoWidget::paintEvent finished"; } void PartitionInfoWidget::mouseMoveEvent(QMouseEvent *event) @@ -303,14 +304,14 @@ void PartitionInfoWidget::mouseMoveEvent(QMouseEvent *event) void PartitionInfoWidget::onHandleChangeTheme() { - qDebug() << "Handling theme change"; + qCDebug(appLog) << "Handling theme change"; m_parentPb = Dtk::Gui::DGuiApplicationHelper::instance()->applicationPalette(); - qDebug() << "Theme palette updated"; + qCDebug(appLog) << "Theme palette updated"; } void PartitionInfoWidget::leaveEvent(QEvent *event) { Q_UNUSED(event); - // qDebug() << "PartitionInfoWidget::leaveEvent called"; + // qCDebug(appLog) << "PartitionInfoWidget::leaveEvent called"; emit leaveWidget(); } diff --git a/application/widgets/customcontrol/partitionwidget.cpp b/application/widgets/customcontrol/partitionwidget.cpp index ef607c9a..8b4aae9e 100644 --- a/application/widgets/customcontrol/partitionwidget.cpp +++ b/application/widgets/customcontrol/partitionwidget.cpp @@ -3,6 +3,7 @@ // SPDX-License-Identifier: GPL-3.0-only +#include "ddlog.h" #include "partitionwidget.h" #include "common.h" #include "passwordinputdialog.h" @@ -18,20 +19,20 @@ constexpr double kFloatCompareEpsilon = 0.01; PartitionWidget::PartitionWidget(QWidget *parent) : DDialog(parent) { - qDebug() << "PartitionWidget constructor"; + qCDebug(appLog) << "PartitionWidget constructor"; // setAttribute(Qt::WA_DeleteOnClose, true); initUi(); recPartitionInfo(); initConnection(); - qDebug() << "PartitionWidget initialized"; + qCDebug(appLog) << "PartitionWidget initialized"; } PartitionWidget::~PartitionWidget() { - qDebug() << "PartitionWidget destructor"; + qCDebug(appLog) << "PartitionWidget destructor"; } void PartitionWidget::initUi() { - qDebug() << "PartitionWidget::initUi called"; + qCDebug(appLog) << "PartitionWidget::initUi called"; setModal(true); setFixedSize(900, 600); m_mainFrame = new QWidget(this); @@ -48,14 +49,14 @@ void PartitionWidget::initUi() tipLabel->setAlignment(Qt::AlignCenter); if (DGuiApplicationHelper::instance()->themeType() == DGuiApplicationHelper::LightType) { - qDebug() << "Theme is LightType, setting tipLabel palette"; + qCDebug(appLog) << "Theme is LightType, setting tipLabel palette"; DPalette tipPalette; QColor tipColor("#000000"); tipColor.setAlphaF(0.7); tipPalette.setColor(DPalette::WindowText, tipColor); tipLabel->setPalette(tipPalette); } else if (DGuiApplicationHelper::instance()->themeType() == DGuiApplicationHelper::DarkType) { - qDebug() << "Theme is DarkType, setting tipLabel palette"; + qCDebug(appLog) << "Theme is DarkType, setting tipLabel palette"; DPalette tipPalette; QColor tipColor("#FFFFFF"); tipColor.setAlphaF(0.7); @@ -69,12 +70,12 @@ void PartitionWidget::initUi() topFrameSetting(); m_topFrame->setFrameRounded(true); #if QT_VERSION_MAJOR > 5 - qDebug() << "QT_VERSION_MAJOR > 5, setting topFrame palette"; + qCDebug(appLog) << "QT_VERSION_MAJOR > 5, setting topFrame palette"; DPalette palette = m_topFrame->palette(); palette.setBrush(DPalette::Base, palette.itemBackground()); m_topFrame->setPalette(palette); #else - qDebug() << "QT_VERSION_MAJOR <= 5, setting topFrame palette"; + qCDebug(appLog) << "QT_VERSION_MAJOR <= 5, setting topFrame palette"; DPalette palette = DApplicationHelper::instance()->palette(m_topFrame); palette.setBrush(DPalette::Base, palette.itemBackground()); DApplicationHelper::instance()->setPalette(m_topFrame, palette); @@ -105,12 +106,12 @@ void PartitionWidget::initUi() setIcon(QIcon::fromTheme(appName)); addContent(m_mainFrame); - qDebug() << "PartitionWidget::initUi finished"; + qCDebug(appLog) << "PartitionWidget::initUi finished"; } void PartitionWidget::topFrameSetting() { - qDebug() << "PartitionWidget::topFrameSetting called"; + qCDebug(appLog) << "PartitionWidget::topFrameSetting called"; //整体水平布局 QHBoxLayout *hLayout = new QHBoxLayout(m_topFrame); hLayout->setSpacing(5); @@ -219,24 +220,24 @@ void PartitionWidget::topFrameSetting() hLayout->addWidget(picLabel); hLayout->addLayout(vLayout, 10); hLayout->setContentsMargins(20, 0, 0, 0); - qDebug() << "PartitionWidget::topFrameSetting finished"; + qCDebug(appLog) << "PartitionWidget::topFrameSetting finished"; } void PartitionWidget::midFrameSetting() { - qDebug() << "PartitionWidget::midFrameSetting called"; + qCDebug(appLog) << "PartitionWidget::midFrameSetting called"; //调用绘制的图形 m_midFrame->setMinimumHeight(85); QVBoxLayout *mainLayout = new QVBoxLayout(m_midFrame); m_partChartWidget = new PartChartShowing(m_midFrame); mainLayout->addWidget(m_partChartWidget); mainLayout->setContentsMargins(0, 0, 0, 0); - qDebug() << "PartitionWidget::midFrameSetting finished"; + qCDebug(appLog) << "PartitionWidget::midFrameSetting finished"; } void PartitionWidget::botFrameSetting() { - qDebug() << "PartitionWidget::botFrameSetting called"; + qCDebug(appLog) << "PartitionWidget::botFrameSetting called"; QVBoxLayout *vLayout = new QVBoxLayout(m_botFrame); m_partWidget = new QWidget(m_botFrame); //分区详细页 @@ -268,16 +269,16 @@ void PartitionWidget::botFrameSetting() vLayout->addLayout(btnLayout, 1); vLayout->setContentsMargins(0, 0, 0, 0); - qDebug() << "PartitionWidget::botFrameSetting finished"; + qCDebug(appLog) << "PartitionWidget::botFrameSetting finished"; } void PartitionWidget::partInfoShowing() { - qDebug() << "PartitionWidget::partInfoShowing called"; + qCDebug(appLog) << "PartitionWidget::partInfoShowing called"; auto formateList = DMDbusHandler::instance()->getAllSupportFileSystem(); formateList.removeOne("linux-swap"); if (!DMDbusHandler::instance()->getIsSystemDisk(DMDbusHandler::instance()->getCurPartititonInfo().m_devicePath)) { - qDebug() << "Disk is not a system disk, getting encryption format"; + qCDebug(appLog) << "Disk is not a system disk, getting encryption format"; formateList = DMDbusHandler::instance()->getEncryptionFormate(formateList); } @@ -312,10 +313,10 @@ void PartitionWidget::partInfoShowing() //按钮初始状态 if (m_sizeInfo.size() == 0) { - qDebug() << "Size info is empty, disabling remove button"; + qCDebug(appLog) << "Size info is empty, disabling remove button"; m_remButton->setEnabled(false); } else { - qDebug() << "Size info is not empty, enabling remove button"; + qCDebug(appLog) << "Size info is not empty, enabling remove button"; m_remButton->setEnabled(true); } @@ -386,10 +387,10 @@ void PartitionWidget::partInfoShowing() m_emptyLabel = new DLabel(m_partWidget); #if QT_VERSION_MAJOR > 5 - qDebug() << "QT_VERSION_MAJOR > 5, setting emptyLabel fixed width"; + qCDebug(appLog) << "QT_VERSION_MAJOR > 5, setting emptyLabel fixed width"; m_emptyLabel->setFixedWidth(m_partFormateLabel->fontMetrics().boundingRect(tr("File system:")).width()); #else - qDebug() << "QT_VERSION_MAJOR <= 5, setting emptyLabel fixed width"; + qCDebug(appLog) << "QT_VERSION_MAJOR <= 5, setting emptyLabel fixed width"; m_emptyLabel->setFixedWidth(m_partFormateLabel->fontMetrics().width(tr("File system:"))); #endif m_encryptionInfo = new DLabel(m_partWidget); @@ -424,19 +425,19 @@ void PartitionWidget::partInfoShowing() vLayout->setContentsMargins(0, 0, 0, 0); //输入框正则表达 setRegValidator(); - qDebug() << "PartitionWidget::partInfoShowing finished"; + qCDebug(appLog) << "PartitionWidget::partInfoShowing finished"; } void PartitionWidget::recPartitionInfo() { - qDebug() << "PartitionWidget::recPartitionInfo called"; + qCDebug(appLog) << "PartitionWidget::recPartitionInfo called"; //获取数据 QString diskSize; PartitionInfo data; auto it = DMDbusHandler::instance()->probDeviceInfo().find(DMDbusHandler::instance()->getCurPartititonInfo().m_devicePath); if (it != DMDbusHandler::instance()->probDeviceInfo().end()) { - qDebug() << "Device info found for current partition"; + qCDebug(appLog) << "Device info found for current partition"; diskSize = QString::number(Utils::sectorToUnit(it.value().m_length, it.value().m_sectorSize, SIZE_UNIT::UNIT_GIB), 'f', 2) + "GiB"; data = DMDbusHandler::instance()->getCurPartititonInfo(); } @@ -454,17 +455,17 @@ void PartitionWidget::recPartitionInfo() m_deviceFormate->setText(partFstype); m_total = Utils::sectorToUnit(data.m_sectorEnd - data.m_sectorStart + 1, data.m_sectorSize, SIZE_UNIT::UNIT_GIB); m_totalSize = m_total * 1024; - // qDebug() << mTotal << total; + // qCDebug(appLog) << mTotal << total; //初始值,显示保留两位小数,真正使用保留4位小数 m_currentEditSize = QString::number(m_totalSize, 'f', 4); m_partComboBox->setEnabled(true); setSelectUnallocatesSpace(); - qDebug() << "PartitionWidget::recPartitionInfo finished"; + qCDebug(appLog) << "PartitionWidget::recPartitionInfo finished"; } void PartitionWidget::initConnection() { - qDebug() << "PartitionWidget::initConnection called"; + qCDebug(appLog) << "PartitionWidget::initConnection called"; connect(m_slider, &DSlider::valueChanged, this, &PartitionWidget::onSliderValueChanged); connect(m_partSizeEdit, &DLineEdit::textChanged, this, &PartitionWidget::onSetSliderValue); connect(m_partNameEdit, &DLineEdit::textEdited, this, &PartitionWidget::onSetPartName); @@ -481,12 +482,12 @@ void PartitionWidget::initConnection() connect(m_partChartWidget, &PartChartShowing::sendMoveFlag, this, &PartitionWidget::onShowTip); connect(m_partChartWidget, &PartChartShowing::sendFlag, this, &PartitionWidget::onShowSelectPathInfo); connect(m_partChartWidget, &PartChartShowing::judgeLastPartition, this, &PartitionWidget::onJudgeLastPartition); - qDebug() << "PartitionWidget::initConnection finished"; + qCDebug(appLog) << "PartitionWidget::initConnection finished"; } double PartitionWidget::sumValue() { - qDebug() << "PartitionWidget::sumValue called"; + qCDebug(appLog) << "PartitionWidget::sumValue called"; double sum = 0.00; for (int i = 0; i < m_sizeInfo.count(); i++) { @@ -494,37 +495,37 @@ double PartitionWidget::sumValue() if (sum >= m_totalSize - 0.01) break; } - qDebug() << "Calculated sum value:" << sum; + qCDebug(appLog) << "Calculated sum value:" << sum; return sum; } void PartitionWidget::setSelectUnallocatesSpace() { - qDebug() << "PartitionWidget::setSelectUnallocatesSpace called"; + qCDebug(appLog) << "PartitionWidget::setSelectUnallocatesSpace called"; m_partNameEdit->lineEdit()->setPlaceholderText(tr("Unallocated")); m_partSizeEdit->setText(""); if (m_partComboBox->currentText() == "GiB") { - qDebug() << "Current unit is GiB, setting size edit text"; + qCDebug(appLog) << "Current unit is GiB, setting size edit text"; m_partSizeEdit->setText(QString::number(m_total - (sumValue() / 1024), 'f', 2)); } else { - qDebug() << "Current unit is not GiB, setting size edit text"; + qCDebug(appLog) << "Current unit is not GiB, setting size edit text"; m_partSizeEdit->setText(QString::number(m_totalSize - sumValue(), 'f', 2)); } - qDebug() << "PartitionWidget::setSelectUnallocatesSpace finished"; + qCDebug(appLog) << "PartitionWidget::setSelectUnallocatesSpace finished"; } void PartitionWidget::setAddOrRemResult(const bool &isExceed) { - qDebug() << "PartitionWidget::setAddOrRemResult called with isExceed:" << isExceed; + qCDebug(appLog) << "PartitionWidget::setAddOrRemResult called with isExceed:" << isExceed; m_partNameEdit->setText(""); m_partSizeEdit->setText(""); if (m_sizeInfo.size() == 0) { - qDebug() << "Size info is empty, setting flag to 1"; + qCDebug(appLog) << "Size info is empty, setting flag to 1"; m_flag = 1; } else { - qDebug() << "Size info is not empty, setting flag to 0"; + qCDebug(appLog) << "Size info is not empty, setting flag to 0"; m_flag = 0; } @@ -535,39 +536,39 @@ void PartitionWidget::setAddOrRemResult(const bool &isExceed) setEnable(0, isExceed); onSliderValueChanged(100); - qDebug() << "PartitionWidget::setAddOrRemResult finished"; + qCDebug(appLog) << "PartitionWidget::setAddOrRemResult finished"; } void PartitionWidget::setRegValidator() { - qDebug() << "PartitionWidget::setRegValidator called"; + qCDebug(appLog) << "PartitionWidget::setRegValidator called"; #if QT_VERSION_MAJOR > 5 QRegularExpression reg("^[0-9]+(\\.[0-9]{1,4})?$"); QRegularExpressionValidator *va = new QRegularExpressionValidator(reg, this); m_partSizeEdit->lineEdit()->setValidator(va); - qDebug() << "Set regular expression validator for partSizeEdit (QT_VERSION_MAJOR > 5)"; + qCDebug(appLog) << "Set regular expression validator for partSizeEdit (QT_VERSION_MAJOR > 5)"; QRegularExpression re("^[\u4E00-\u9FA5A-Za-z0-9_]+$"); QRegularExpressionValidator *va1 = new QRegularExpressionValidator(re, this); m_partNameEdit->lineEdit()->setValidator(va1); - qDebug() << "Set regular expression validator for partNameEdit (QT_VERSION_MAJOR > 5)"; + qCDebug(appLog) << "Set regular expression validator for partNameEdit (QT_VERSION_MAJOR > 5)"; #else QRegExp reg("^[0-9]+(\\.[0-9]{1,4})?$"); QRegExpValidator *va = new QRegExpValidator(reg, this); m_partSizeEdit->lineEdit()->setValidator(va); - qDebug() << "Set regular expression validator for partSizeEdit (QT_VERSION_MAJOR <= 5)"; + qCDebug(appLog) << "Set regular expression validator for partSizeEdit (QT_VERSION_MAJOR <= 5)"; QRegExp re("^[\u4E00-\u9FA5A-Za-z0-9_]+$"); QRegExpValidator *va1 = new QRegExpValidator(re, this); m_partNameEdit->lineEdit()->setValidator(va1); - qDebug() << "Set regular expression validator for partNameEdit (QT_VERSION_MAJOR <= 5)"; + qCDebug(appLog) << "Set regular expression validator for partNameEdit (QT_VERSION_MAJOR <= 5)"; #endif - qDebug() << "PartitionWidget::setRegValidator finished"; + qCDebug(appLog) << "PartitionWidget::setRegValidator finished"; } bool PartitionWidget::maxAmountPrimReached() { - qDebug() << "PartitionWidget::maxAmountPrimReached called"; + qCDebug(appLog) << "PartitionWidget::maxAmountPrimReached called"; bool breachMax = false; int primaryCount = 0; PartitionVec partVector = DMDbusHandler::instance()->getCurDevicePartitionArr(); @@ -577,41 +578,41 @@ bool PartitionWidget::maxAmountPrimReached() if (partVector[i].m_type == TYPE_PRIMARY || partVector[i].m_type == TYPE_EXTENDED) primaryCount++; } - qDebug() << "Current primary and extended partition count:" << primaryCount; + qCDebug(appLog) << "Current primary and extended partition count:" << primaryCount; int maxprims = DMDbusHandler::instance()->getCurDeviceInfo().m_maxPrims; if (!info.m_insideExtended && primaryCount >= maxprims) { breachMax = true; - qDebug() << "Max primary partitions reached, breachMax set to true"; - // qDebug() << QString("It is not possible to create more than %1 primary partition").arg(maxprims); - // qDebug() << QString("If you want more partitions you should first create an extended partition. Such a partition can contain other partitions." + qCDebug(appLog) << "Max primary partitions reached, breachMax set to true"; + // qCDebug(appLog) << QString("It is not possible to create more than %1 primary partition").arg(maxprims); + // qCDebug(appLog) << QString("If you want more partitions you should first create an extended partition. Such a partition can contain other partitions." // "Because an extended partition is also a primary partition it might be necessary to remove a primary partition first."); } - qDebug() << "PartitionWidget::maxAmountPrimReached finished, returning:" << breachMax; + qCDebug(appLog) << "PartitionWidget::maxAmountPrimReached finished, returning:" << breachMax; return breachMax; } void PartitionWidget::onShowSelectPathInfo(const int &flag, const int &num, const int &posX) { - qDebug() << "PartitionWidget::onShowSelectPathInfo called with flag:" << flag << "num:" << num << "posX:" << posX; + qCDebug(appLog) << "PartitionWidget::onShowSelectPathInfo called with flag:" << flag << "num:" << num << "posX:" << posX; m_flag = flag; m_number = num; if (m_flag == 0) { - qDebug() << "Flag is 0, returning"; + qCDebug(appLog) << "Flag is 0, returning"; return; } if (m_flag == 1 || m_flag == 3) { - qDebug() << "Flag is 1 or 3, setting unallocated space"; + qCDebug(appLog) << "Flag is 1 or 3, setting unallocated space"; setSelectUnallocatesSpace(); m_slider->setValue(100); m_number = -1; } else if (m_flag == 2) { - qDebug() << "Flag is 2"; + qCDebug(appLog) << "Flag is 2"; if (num < 0) { - qDebug() << "Num is less than 0, disabling partNameEdit"; + qCDebug(appLog) << "Num is less than 0, disabling partNameEdit"; #if QT_VERSION_MAJOR > 5 DPalette palette = m_partNameLabel->palette(); #else @@ -631,7 +632,7 @@ void PartitionWidget::onShowSelectPathInfo(const int &flag, const int &num, cons double clicked = m_sizeInfo.at(num); if (m_partComboBox->currentText() == "GiB") { - qDebug() << "Current unit is GiB, converting clicked size"; + qCDebug(appLog) << "Current unit is GiB, converting clicked size"; clicked = clicked / 1024; } m_partSizeEdit->setText(QString::number(clicked, 'f', 2)); @@ -639,31 +640,31 @@ void PartitionWidget::onShowSelectPathInfo(const int &flag, const int &num, cons setEnable(m_flag, m_isExceed); onShowTip(flag, num, posX); - qDebug() << "PartitionWidget::onShowSelectPathInfo finished"; + qCDebug(appLog) << "PartitionWidget::onShowSelectPathInfo finished"; } void PartitionWidget::onShowTip(const int &hover, const int &num, const int &posX) { - qDebug() << "PartitionWidget::onShowTip called with hover:" << hover << "num:" << num << "posX:" << posX; + qCDebug(appLog) << "PartitionWidget::onShowTip called with hover:" << hover << "num:" << num << "posX:" << posX; int x = frameGeometry().x(); int y = frameGeometry().y(); if (hover == 2) { - qDebug() << "Hover is 2"; + qCDebug(appLog) << "Hover is 2"; if (m_partName.at(num) != " ") { - qDebug() << "Partition name is not empty, showing tooltip"; + qCDebug(appLog) << "Partition name is not empty, showing tooltip"; QToolTip::showText(QPoint(x + posX + 5, y + 215), m_partName.at(num), this, QRect(QPoint(x + posX, y + 215), QSize(80, 20)), 1000); } } else if (hover == 3 || hover == 1) { - qDebug() << "Hover is 3 or 1, showing unallocated tooltip"; + qCDebug(appLog) << "Hover is 3 or 1, showing unallocated tooltip"; QToolTip::showText(QPoint(x + posX + 5, y + 215), tr("Unallocated"), this, QRect(QPoint(x + posX, y + 215), QSize(80, 20)), 1000); } - qDebug() << "PartitionWidget::onShowTip finished"; + qCDebug(appLog) << "PartitionWidget::onShowTip finished"; } void PartitionWidget::setEnable(const int &flag, const bool &isExceed) { - qDebug() << "PartitionWidget::setEnable called with flag:" << flag << "isExceed:" << isExceed; + qCDebug(appLog) << "PartitionWidget::setEnable called with flag:" << flag << "isExceed:" << isExceed; #if QT_VERSION_MAJOR > 5 DPalette palette = m_partNameLabel->palette(); #else @@ -671,18 +672,18 @@ void PartitionWidget::setEnable(const int &flag, const bool &isExceed) #endif if (isExceed) { //还有空闲空间剩余 - qDebug() << "There is free space remaining"; + qCDebug(appLog) << "There is free space remaining"; if (flag == 2) { //选中新建的分区 - qDebug() << "Selected new partition, disabling controls"; + qCDebug(appLog) << "Selected new partition, disabling controls"; setControlEnable(false); m_partNameEdit->setEnabled(false); } else { - qDebug() << "Not selected new partition, enabling controls"; + qCDebug(appLog) << "Not selected new partition, enabling controls"; setControlEnable(true); } // palette.setColor(DPalette::Text, QColor(this->palette().buttonText().color())); } else { //无空闲空间剩余 - qDebug() << "No free space remaining, disabling controls"; + qCDebug(appLog) << "No free space remaining, disabling controls"; setControlEnable(false); // if (flag != 2) { // palette.setBrush(DPalette::Text, palette.placeholderText()); @@ -690,47 +691,47 @@ void PartitionWidget::setEnable(const int &flag, const bool &isExceed) // } else { // palette.setColor(DPalette::Text, QColor(this->palette().buttonText().color())); m_partNameEdit->setEnabled(false); - qDebug() << "partNameEdit disabled"; + qCDebug(appLog) << "partNameEdit disabled"; // } } if (m_partNameEdit->text().toUtf8().size() <= 16) { - qDebug() << "Partition name length is within limits"; + qCDebug(appLog) << "Partition name length is within limits"; m_partNameEdit->setAlert(false); m_partNameEdit->hideAlertMessage(); } else { - qDebug() << "Partition name length exceeds limits, disabling addButton"; + qCDebug(appLog) << "Partition name length exceeds limits, disabling addButton"; m_addButton->setEnabled(false); } m_partNameLabel->setPalette(palette); //各情况下,分区名称label的样式 - qDebug() << "Set partNameLabel palette"; + qCDebug(appLog) << "Set partNameLabel palette"; m_remButton->setEnabled(m_sizeInfo.size()); m_applyBtn->setEnabled(m_sizeInfo.size()); - qDebug() << "PartitionWidget::setEnable finished"; + qCDebug(appLog) << "PartitionWidget::setEnable finished"; } void PartitionWidget::setControlEnable(const bool &isTrue) { - qDebug() << "PartitionWidget::setControlEnable called with isTrue:" << isTrue; + qCDebug(appLog) << "PartitionWidget::setControlEnable called with isTrue:" << isTrue; m_addButton->setEnabled(isTrue); m_partSizeEdit->setEnabled(isTrue); m_slider->setEnabled(isTrue); m_partComboBox->setEnabled(isTrue); m_partFormateCombox->setEnabled(isTrue); - qDebug() << "Set enable state for add button, size edit, slider, combo boxes"; + qCDebug(appLog) << "Set enable state for add button, size edit, slider, combo boxes"; m_partNameEdit->setEnabled(true); setLabelColor(isTrue); - qDebug() << "PartitionWidget::setControlEnable finished"; + qCDebug(appLog) << "PartitionWidget::setControlEnable finished"; } void PartitionWidget::setLabelColor(const bool &isOk) { - qDebug() << "PartitionWidget::setLabelColor called with isOk:" << isOk; + qCDebug(appLog) << "PartitionWidget::setLabelColor called with isOk:" << isOk; if (isOk) { - qDebug() << "isOk is true, setting frame palette color to buttonText color"; + qCDebug(appLog) << "isOk is true, setting frame palette color to buttonText color"; #if QT_VERSION_MAJOR > 5 DPalette framePalette = m_botFrame->palette(); #else @@ -739,7 +740,7 @@ void PartitionWidget::setLabelColor(const bool &isOk) framePalette.setColor(DPalette::Text, QColor(palette().buttonText().color())); m_botFrame->setPalette(framePalette); } else { - qDebug() << "isOk is false, setting frame palette brush to placeholderText"; + qCDebug(appLog) << "isOk is false, setting frame palette brush to placeholderText"; #if QT_VERSION_MAJOR > 5 DPalette palette = m_botFrame->palette(); #else @@ -759,71 +760,71 @@ void PartitionWidget::setLabelColor(const bool &isOk) palette1.setColor(DPalette::Text, QColor(palette().buttonText().color())); m_partInfoLabel->setPalette(palette1); - qDebug() << "Set partInfoLabel palette"; + qCDebug(appLog) << "Set partInfoLabel palette"; palatte2.setColor(DPalette::Text, QColor(palette().buttonText().color())); m_partDoLabel->setPalette(palatte2); - qDebug() << "PartitionWidget::setLabelColor finished"; + qCDebug(appLog) << "PartitionWidget::setLabelColor finished"; } void PartitionWidget::onComboxCurTextChange(int index) { - qDebug() << "PartitionWidget::onComboxCurTextChange called with index:" << index; - // qDebug() << partSizeEdit->text().toDouble(); + qCDebug(appLog) << "PartitionWidget::onComboxCurTextChange called with index:" << index; + // qCDebug(appLog) << partSizeEdit->text().toDouble(); if (!m_partSizeEdit->text().isEmpty()) { double m = m_currentEditSize.toDouble(); if (index == 1) { - qDebug() << "Index is 1 (MiB)"; + qCDebug(appLog) << "Index is 1 (MiB)"; if (m_sizeInfo.size() == 0 && m_slider->value() == 100) m_partSizeEdit->setText(QString::number(m_totalSize, 'f', 2)); else m_partSizeEdit->setText(QString::number(m, 'f', 2)); } else if (index == 0) { - qDebug() << "Index is 0 (GiB)"; + qCDebug(appLog) << "Index is 0 (GiB)"; // double m = partSizeEdit->text().toDouble(); if (m_sizeInfo.size() == 0 && m_slider->value() == 100) m_partSizeEdit->setText(QString::number(m_total, 'f', 2)); else m_partSizeEdit->setText(QString::number(m / 1024, 'f', 2)); } - // qDebug() << m; + // qCDebug(appLog) << m; } - qDebug() << "PartitionWidget::onComboxCurTextChange finished"; + qCDebug(appLog) << "PartitionWidget::onComboxCurTextChange finished"; } void PartitionWidget::onComboxFormatTextChange(const QString &text) { - qDebug() << "PartitionWidget::onComboxFormatTextChange called with text:" << text; + qCDebug(appLog) << "PartitionWidget::onComboxFormatTextChange called with text:" << text; if (m_partSizeEdit->isAlert()) { - qDebug() << "Part size edit is in alert state, clearing alert"; + qCDebug(appLog) << "Part size edit is in alert state, clearing alert"; m_partSizeEdit->setAlert(false); m_partSizeEdit->hideAlertMessage(); } QByteArray byteArray = m_partNameEdit->text().toUtf8(); if (text.contains("fat32")) { - qDebug() << "Format contains fat32"; + qCDebug(appLog) << "Format contains fat32"; if (byteArray.size() > 11) { - qDebug() << "Byte array size > 11, setting alert for partNameEdit"; + qCDebug(appLog) << "Byte array size > 11, setting alert for partNameEdit"; m_partNameEdit->setAlert(true); m_partNameEdit->showAlertMessage(tr("The length exceeds the limit"), -1); m_addButton->setEnabled(false); } else { - qDebug() << "Byte array size <= 11, clearing alert for partNameEdit"; + qCDebug(appLog) << "Byte array size <= 11, clearing alert for partNameEdit"; m_partNameEdit->setAlert(false); m_partNameEdit->hideAlertMessage(); m_addButton->setEnabled(true); } } else { - qDebug() << "Format does not contain fat32"; + qCDebug(appLog) << "Format does not contain fat32"; if (byteArray.size() > 16) { - qDebug() << "Byte array size > 16, setting alert for partNameEdit"; + qCDebug(appLog) << "Byte array size > 16, setting alert for partNameEdit"; m_partNameEdit->setAlert(true); m_partNameEdit->showAlertMessage(tr("The length exceeds the limit"), -1); m_addButton->setEnabled(false); } else { - qDebug() << "Byte array size <= 16, clearing alert for partNameEdit"; + qCDebug(appLog) << "Byte array size <= 16, clearing alert for partNameEdit"; m_partNameEdit->setAlert(false); m_partNameEdit->hideAlertMessage(); m_addButton->setEnabled(true); @@ -832,14 +833,14 @@ void PartitionWidget::onComboxFormatTextChange(const QString &text) m_scrollArea->setFixedWidth(m_partFormateCombox->width()); if (text.contains("AES")) { - qDebug() << "Format contains AES, setting encryption info text (AES)"; + qCDebug(appLog) << "Format contains AES, setting encryption info text (AES)"; QString text = tr("Use the aes-xts-plain64 standard algorithm to encrypt the disk. " "If it is encrypted, you should decrypt it before mounting."); m_encryptionInfo->setFixedSize(m_partFormateCombox->width(), Common::getLabelAdjustHeight(m_partFormateCombox->width(), text, m_encryptionInfo->font())); m_encryptionInfo->setText(text); } else if (text.contains("SM4")) { - qDebug() << "Format contains SM4, setting encryption info text (SM4)"; + qCDebug(appLog) << "Format contains SM4, setting encryption info text (SM4)"; QString text = tr("Use the sm4-xts-plain state cryptographic algorithm to encrypt the disk. " "If it is encrypted, you should decrypt it before mounting. " "Operating Systems that do not support the state cryptographic " @@ -848,56 +849,56 @@ void PartitionWidget::onComboxFormatTextChange(const QString &text) Common::getLabelAdjustHeight(m_partFormateCombox->width(), text, m_encryptionInfo->font()) - 1); m_encryptionInfo->setText(text); } else { - qDebug() << "Format does not contain AES or SM4, clearing encryption info text"; + qCDebug(appLog) << "Format does not contain AES or SM4, clearing encryption info text"; m_encryptionInfo->setText(""); } - qDebug() << "PartitionWidget::onComboxFormatTextChange finished"; + qCDebug(appLog) << "PartitionWidget::onComboxFormatTextChange finished"; } void PartitionWidget::onJudgeLastPartition() { - qDebug() << "PartitionWidget::onJudgeLastPartition called"; + qCDebug(appLog) << "PartitionWidget::onJudgeLastPartition called"; m_slider->setEnabled(false); m_partSizeEdit->setEnabled(false); - qDebug() << "PartitionWidget::onJudgeLastPartition finished"; + qCDebug(appLog) << "PartitionWidget::onJudgeLastPartition finished"; } void PartitionWidget::onSliderValueChanged(int value) { - qDebug() << "PartitionWidget::onSliderValueChanged called with value:" << value; + qCDebug(appLog) << "PartitionWidget::onSliderValueChanged called with value:" << value; m_value = value; QString size; if (m_block == 0) { - qDebug() << "Block is 0"; + qCDebug(appLog) << "Block is 0"; //选中分区大小与整个空闲分区的占比 if (m_flag == 2) { - qDebug() << "Flag is 2"; + qCDebug(appLog) << "Flag is 2"; if (m_partComboBox->currentText() == "MiB") { - qDebug() << "Unit is MiB, calculating size"; + qCDebug(appLog) << "Unit is MiB, calculating size"; size = QString::number((static_cast(value) / 100) * m_totalSize, 'f', 2); } else { - qDebug() << "Unit is GiB, calculating size"; + qCDebug(appLog) << "Unit is GiB, calculating size"; size = QString::number((static_cast(value) / 100) * m_total, 'f', 2); } m_partSizeEdit->setText(size); } else { //剩余空间为总大小,占比情况 - qDebug() << "Flag is not 2, calculating remaining space percentage"; + qCDebug(appLog) << "Flag is not 2, calculating remaining space percentage"; if (m_partComboBox->currentText() == "MiB") { - qDebug() << "Unit is MiB, calculating size"; + qCDebug(appLog) << "Unit is MiB, calculating size"; size = QString::number((static_cast(value) / 100) * (m_totalSize - sumValue()), 'f', 2); if (m_totalSize - sumValue() < 52) { - qDebug() << "Remaining size < 52 MiB, judging last partition"; + qCDebug(appLog) << "Remaining size < 52 MiB, judging last partition"; onJudgeLastPartition(); } } else { - qDebug() << "Unit is GiB, calculating size"; + qCDebug(appLog) << "Unit is GiB, calculating size"; size = QString::number(((static_cast(value) / 100) * (m_totalSize - sumValue())) / 1024, 'f', 2); if (m_total - sumValue() / 1024 < 0.05) { - qDebug() << "Remaining size < 0.05 GiB, judging last partition"; + qCDebug(appLog) << "Remaining size < 0.05 GiB, judging last partition"; onJudgeLastPartition(); } } @@ -907,98 +908,98 @@ void PartitionWidget::onSliderValueChanged(int value) } // QString strSize1 = QString::number((static_cast(value) / 100) * (m_totalSize - sumValue()), 'f', 2); m_currentEditSize = QString::number((static_cast(value) / 100) * (m_totalSize - sumValue()), 'f', 4); - qDebug() << m_currentEditSize << size << value << m_totalSize - sumValue(); + qCDebug(appLog) << m_currentEditSize << size << value << m_totalSize - sumValue(); m_block = 0; //m_addButton->setEnabled(m_currentEditSize <= ) - qDebug() << "PartitionWidget::onSliderValueChanged finished"; + qCDebug(appLog) << "PartitionWidget::onSliderValueChanged finished"; } void PartitionWidget::onSetSliderValue() { - qDebug() << "PartitionWidget::onSetSliderValue called"; + qCDebug(appLog) << "PartitionWidget::onSetSliderValue called"; if (m_partSizeEdit->isAlert()) { - qDebug() << "Part size edit is in alert state, clearing alert"; + qCDebug(appLog) << "Part size edit is in alert state, clearing alert"; m_partSizeEdit->setAlert(false); m_partSizeEdit->hideAlertMessage(); } double value = 0; if (m_partSizeEdit->text().trimmed().isEmpty()) { - qDebug() << "Part size edit text is empty, setting value to 0"; + qCDebug(appLog) << "Part size edit text is empty, setting value to 0"; value = 0; } value = m_partSizeEdit->text().toDouble(); if (m_partComboBox->currentText() == "MiB") { - qDebug() << "Unit is MiB, converting value to GiB"; + qCDebug(appLog) << "Unit is MiB, converting value to GiB"; value = value / 1024; } m_block = 1; m_slider->setValue(static_cast((value / (m_total - (sumValue() / 1024))) * 100)); m_currentEditSize = QString::number(value * 1024, 'f', 4); if (value == 0.00 || value > (m_total - sumValue() / 1024) + kFloatCompareEpsilon) { - qDebug() << "Value is 0 or exceeds remaining space, disabling addButton"; + qCDebug(appLog) << "Value is 0 or exceeds remaining space, disabling addButton"; m_addButton->setEnabled(false); } else { - qDebug() << "Value is valid, enabling addButton"; + qCDebug(appLog) << "Value is valid, enabling addButton"; m_addButton->setEnabled(true); } - // qDebug() << currentEditSize; - // qDebug() << value * 1024 << static_cast((value / total) * 100); - qDebug() << "PartitionWidget::onSetSliderValue finished"; + // qCDebug(appLog) << currentEditSize; + // qCDebug(appLog) << value * 1024 << static_cast((value / total) * 100); + qCDebug(appLog) << "PartitionWidget::onSetSliderValue finished"; } void PartitionWidget::onTextChanged(const QString &text) { - qDebug() << "PartitionWidget::onTextChanged called with text:" << text; + qCDebug(appLog) << "PartitionWidget::onTextChanged called with text:" << text; if (!text.isEmpty()) { - qDebug() << "Text is not empty"; + qCDebug(appLog) << "Text is not empty"; QByteArray byteArray = text.toUtf8(); if (m_partFormateCombox->currentText().contains("fat32")) { - qDebug() << "Format contains fat32"; + qCDebug(appLog) << "Format contains fat32"; if (byteArray.size() > 11) { - qDebug() << "Byte array size > 11, setting alert for partNameEdit"; + qCDebug(appLog) << "Byte array size > 11, setting alert for partNameEdit"; m_partNameEdit->setAlert(true); m_partNameEdit->showAlertMessage(tr("The length exceeds the limit"), -1); m_addButton->setEnabled(false); } else { - qDebug() << "Byte array size <= 11, clearing alert for partNameEdit"; + qCDebug(appLog) << "Byte array size <= 11, clearing alert for partNameEdit"; m_partNameEdit->setAlert(false); m_partNameEdit->hideAlertMessage(); m_addButton->setEnabled(true); } } else { - qDebug() << "Format does not contain fat32"; + qCDebug(appLog) << "Format does not contain fat32"; if (byteArray.size() > 16) { - qDebug() << "Byte array size > 16, setting alert for partNameEdit"; + qCDebug(appLog) << "Byte array size > 16, setting alert for partNameEdit"; m_partNameEdit->setAlert(true); m_partNameEdit->showAlertMessage(tr("The length exceeds the limit"), -1); m_addButton->setEnabled(false); } else { - qDebug() << "Byte array size <= 16, clearing alert for partNameEdit"; + qCDebug(appLog) << "Byte array size <= 16, clearing alert for partNameEdit"; m_partNameEdit->setAlert(false); m_partNameEdit->hideAlertMessage(); m_addButton->setEnabled(true); } } } - qDebug() << "PartitionWidget::onTextChanged finished"; + qCDebug(appLog) << "PartitionWidget::onTextChanged finished"; } void PartitionWidget::onSetPartName() { - qDebug() << "PartitionWidget::onSetPartName called"; + qCDebug(appLog) << "PartitionWidget::onSetPartName called"; if (!m_partName.isEmpty() && m_number > -1) { - qDebug() << "Part name is not empty and number is valid, replacing part name"; + qCDebug(appLog) << "Part name is not empty and number is valid, replacing part name"; m_partName.replace(m_number, m_partNameEdit->text()); } - qDebug() << "Part name edit text length:" << m_partNameEdit->text().length(); - qDebug() << "PartitionWidget::onSetPartName finished"; + qCDebug(appLog) << "Part name edit text length:" << m_partNameEdit->text().length(); + qCDebug(appLog) << "PartitionWidget::onSetPartName finished"; } void PartitionWidget::onAddPartition() { - qDebug() << "Adding new partition"; + qCDebug(appLog) << "Adding new partition"; DeviceInfo device = DMDbusHandler::instance()->getCurDeviceInfo(); int partitionCount = 0; @@ -1008,10 +1009,10 @@ void PartitionWidget::onAddPartition() partitionCount++; } } - qDebug() << "Existing allocated partition count:" << partitionCount; + qCDebug(appLog) << "Existing allocated partition count:" << partitionCount; if (m_sizeInfo.size() >= 24 || maxAmountPrimReached() == true || (partitionCount + m_sizeInfo.size()) >= device.m_maxPrims) { - qDebug() << "Partition limit exceeded"; + qCDebug(appLog) << "Partition limit exceeded"; DMessageManager::instance()->sendMessage(this, QIcon(":/icons/deepin/builtin/warning.svg"), tr("The number of new partitions exceeds the limit")); return; } @@ -1021,23 +1022,23 @@ void PartitionWidget::onAddPartition() //一次新建不超过24个分区 if (m_partNameEdit->text().isEmpty()) { - qDebug() << "Part name edit text is empty, setting to space"; + qCDebug(appLog) << "Part name edit text is empty, setting to space"; m_partNameEdit->setText(" "); } m_partName.append(m_partNameEdit->text()); //输入框内的值超过剩余空闲空间,以剩余空间新建 currentSize = m_currentEditSize.toDouble(); if (currentSize >= QString::number((m_totalSize - sumValue()), 'f', 4).toDouble()) { - qDebug() << "Current size exceeds remaining free space, adjusting current size"; + qCDebug(appLog) << "Current size exceeds remaining free space, adjusting current size"; currentSize = m_totalSize - sumValue(); part.m_blast = true; } QString formate = m_partFormateCombox->currentText(); if (formate.contains("AES") || formate.contains("SM4")) { - qDebug() << "Format contains AES or SM4"; + qCDebug(appLog) << "Format contains AES or SM4"; if (currentSize <= 100) { - qDebug() << "Current size <= 100 MiB for encryption, setting alert"; + qCDebug(appLog) << "Current size <= 100 MiB for encryption, setting alert"; m_partSizeEdit->setAlert(true); m_partSizeEdit->showAlertMessage(tr("To encrypt a partition, it should be larger than 100 MiB")); return; @@ -1052,17 +1053,17 @@ void PartitionWidget::onAddPartition() passwordInputDialog.setObjectName("passwordInputDialog"); passwordInputDialog.setAccessibleName("passwordInputDialog"); if (passwordInputDialog.exec() != DDialog::Accepted) { - qDebug() << "Password input dialog not accepted, returning"; + qCDebug(appLog) << "Password input dialog not accepted, returning"; return; } else { - qDebug() << "Password input dialog accepted"; + qCDebug(appLog) << "Password input dialog accepted"; part.m_password = passwordInputDialog.getPassword(); part.m_passwordHint = passwordInputDialog.getPasswordHint(); if (formate.contains("AES")) { - qDebug() << "Format contains AES, setting encryption to AES_XTS_PLAIN64"; + qCDebug(appLog) << "Format contains AES, setting encryption to AES_XTS_PLAIN64"; part.m_encryption = CRYPT_CIPHER::AES_XTS_PLAIN64; } else if (formate.contains("SM4")) { - qDebug() << "Format contains SM4, setting encryption to SM4_XTS_PLAIN64"; + qCDebug(appLog) << "Format contains SM4, setting encryption to SM4_XTS_PLAIN64"; part.m_encryption = CRYPT_CIPHER::SM4_XTS_PLAIN64; } part.m_isEncryption = true; @@ -1076,16 +1077,16 @@ void PartitionWidget::onAddPartition() warningBox.setGeometry(pos().x() + (width() - warningBox.width()) / 2, pos().y() + (height() - warningBox.height()) / 2, warningBox.width(), warningBox.height()); warningBox.exec(); - qDebug() << "Displayed password backup warning message box"; + qCDebug(appLog) << "Displayed password backup warning message box"; } #if QT_VERSION_MAJOR > 5 - qDebug() << "QT_VERSION_MAJOR > 5, setting botFrame palette"; + qCDebug(appLog) << "QT_VERSION_MAJOR > 5, setting botFrame palette"; DPalette palette = m_botFrame->palette(); palette.setColor(QPalette::ButtonText, color); setPalette(palette); #else - qDebug() << "QT_VERSION_MAJOR <= 5, setting botFrame palette"; + qCDebug(appLog) << "QT_VERSION_MAJOR <= 5, setting botFrame palette"; DPalette palette = DApplicationHelper::instance()->palette(m_botFrame); palette.setColor(QPalette::ButtonText, color); DApplicationHelper::instance()->setPalette(this, palette); @@ -1093,9 +1094,9 @@ void PartitionWidget::onAddPartition() formate = formate.trimmed().split(" ").at(0); } else { - qDebug() << "Format does not contain AES or SM4"; + qCDebug(appLog) << "Format does not contain AES or SM4"; if (currentSize <= 52) { - qDebug() << "Current size <= 52 MiB for non-encrypted partition, showing warning message"; + qCDebug(appLog) << "Current size <= 52 MiB for non-encrypted partition, showing warning message"; DMessageManager::instance()->sendMessage(this, QIcon(":/icons/deepin/builtin/warning.svg"), tr("To create a partition, you need at least 52 MB")); return; } @@ -1118,31 +1119,31 @@ void PartitionWidget::onAddPartition() //新增分区后样式变化 if (sumValue() >= m_totalSize - 0.01) { - qDebug() << "Sum value >= total size - 0.01, setting isExceed to false"; + qCDebug(appLog) << "Sum value >= total size - 0.01, setting isExceed to false"; m_isExceed = false; } else { - qDebug() << "Sum value < total size - 0.01, setting isExceed to true"; + qCDebug(appLog) << "Sum value < total size - 0.01, setting isExceed to true"; m_isExceed = true; } m_applyBtn->setEnabled(true); setAddOrRemResult(m_isExceed); - qDebug() << "PartitionWidget::onAddPartition finished"; + qCDebug(appLog) << "PartitionWidget::onAddPartition finished"; } void PartitionWidget::onRemovePartition() { - qDebug() << "PartitionWidget::onRemovePartition called, current partition info count:" << m_patrinfo.size(); + qCDebug(appLog) << "PartitionWidget::onRemovePartition called, current partition info count:" << m_patrinfo.size(); if (m_patrinfo.size() > 0) { - qDebug() << "Removing last partition from patrinfo"; + qCDebug(appLog) << "Removing last partition from patrinfo"; m_patrinfo.pop_back(); } m_addButton->setEnabled(true); - qDebug() << "Add button enabled"; + qCDebug(appLog) << "Add button enabled"; if (m_sizeInfo.size() > 0) { - qDebug() << "Removing last size info and part name"; + qCDebug(appLog) << "Removing last size info and part name"; m_sizeInfo.removeAt(m_sizeInfo.size() - 1); m_partName.removeAt(m_partName.size() - 1); } @@ -1150,31 +1151,31 @@ void PartitionWidget::onRemovePartition() //绘制删除分区图形 m_partChartWidget->transInfos(m_totalSize, m_sizeInfo); m_partChartWidget->update(); - qDebug() << "Chart widget updated after removal"; + qCDebug(appLog) << "Chart widget updated after removal"; //删除分区后样式变化 m_isExceed = true; setAddOrRemResult(m_isExceed); - qDebug() << "PartitionWidget::onRemovePartition finished"; + qCDebug(appLog) << "PartitionWidget::onRemovePartition finished"; } static void snapToMebibyte(DeviceInfo &device, PartitionInfo &newPart) { - qDebug() << "snapToMebibyte called for device:" << device.m_path << "and new partition"; + qCDebug(appLog) << "snapToMebibyte called for device:" << device.m_path << "and new partition"; Sector diff = 0; Sector secsPerMib = MEBIBYTE / newPart.m_sectorSize; //Align start sector diff = Sector(newPart.m_sectorStart % secsPerMib); if (diff) { - qDebug() << "Aligning start sector, diff:" << diff; + qCDebug(appLog) << "Aligning start sector, diff:" << diff; newPart.m_sectorStart += (secsPerMib - diff); } //Align end sector diff = (newPart.m_sectorEnd + 1) % secsPerMib; if (diff) { - qDebug() << "Aligning end sector, diff:" << diff; + qCDebug(appLog) << "Aligning end sector, diff:" << diff; newPart.m_sectorEnd -= diff; } @@ -1182,15 +1183,15 @@ static void snapToMebibyte(DeviceInfo &device, PartitionInfo &newPart) // from the end of the device, then reserve at least a mebibyte for the // backup partition table if ( device.m_disktype == "gpt" && ((device.m_length - newPart.m_sectorEnd) < 34)) { - qDebug() << "GPT disk type and partition ends close to device end, adjusting sectorEnd"; + qCDebug(appLog) << "GPT disk type and partition ends close to device end, adjusting sectorEnd"; newPart.m_sectorEnd -= secsPerMib; } - qDebug() << "snapToMebibyte finished"; + qCDebug(appLog) << "snapToMebibyte finished"; } void PartitionWidget::onApplyButton() { - qDebug() << "PartitionWidget::onApplyButton called"; + qCDebug(appLog) << "PartitionWidget::onApplyButton called"; bool isCreate = true; PartitionVec partVector; PartitionInfo curInfo = DMDbusHandler::instance()->getCurPartititonInfo(); @@ -1199,17 +1200,17 @@ void PartitionWidget::onApplyButton() Sector deviceLength = DMDbusHandler::instance()->getCurDeviceInfoLength(); for (int i = 0; i < m_patrinfo.size(); i++) { - qDebug() << "Processing partition info for apply, index:" << i; + qCDebug(appLog) << "Processing partition info for apply, index:" << i; PartitionInfo newPart; newPart.m_sectorStart = beforend; if (m_patrinfo.at(i).m_blast) { - qDebug() << "Partition blast flag is true, setting sectorEnd to curInfo.m_sectorEnd"; + qCDebug(appLog) << "Partition blast flag is true, setting sectorEnd to curInfo.m_sectorEnd"; newPart.m_sectorEnd = curInfo.m_sectorEnd; } else { - qDebug() << "Partition blast flag is false, calculating sectorEnd"; + qCDebug(appLog) << "Partition blast flag is false, calculating sectorEnd"; newPart.m_sectorEnd = newPart.m_sectorStart + m_patrinfo.at(i).m_count; } - qDebug() << "Before end:" << beforend << "Current info start:" << curInfo.m_sectorStart << "Current info end:" << curInfo.m_sectorEnd; + qCDebug(appLog) << "Before end:" << beforend << "Current info start:" << curInfo.m_sectorStart << "Current info end:" << curInfo.m_sectorEnd; newPart.m_fileSystemType = Utils::stringToFileSystemType(m_patrinfo.at(i).m_fstype); newPart.m_fileSystemLabel = m_patrinfo.at(i).m_labelName; @@ -1220,16 +1221,16 @@ void PartitionWidget::onApplyButton() newPart.m_fileSystemReadOnly = false; newPart.m_devicePath = curInfo.m_devicePath; if (device.m_disktype == "gpt") { - qDebug() << "Device disk type is gpt, setting new partition type to PRIMARY"; + qCDebug(appLog) << "Device disk type is gpt, setting new partition type to PRIMARY"; newPart.m_type = TYPE_PRIMARY; } else { //非逻辑分区外没有指明创建的分区类型主分区/扩展分区,默认主分区 if (curInfo.m_insideExtended) { - qDebug() << "Current info is inside extended, setting new partition type to LOGICAL"; + qCDebug(appLog) << "Current info is inside extended, setting new partition type to LOGICAL"; newPart.m_type = TYPE_LOGICAL; newPart.m_insideExtended = true; } else { - qDebug() << "Current info is not inside extended, setting new partition type to PRIMARY"; + qCDebug(appLog) << "Current info is not inside extended, setting new partition type to PRIMARY"; newPart.m_type = TYPE_PRIMARY; } } @@ -1239,7 +1240,7 @@ void PartitionWidget::onApplyButton() if ((newPart.m_insideExtended && newPart.m_type == TYPE_UNALLOCATED) || newPart.m_type == TYPE_LOGICAL || newPart.m_sectorStart <= (MEBIBYTE / newPart.m_sectorSize)) { - qDebug() << "Adjusting sectorStart and sectorEnd for extended/logical/beginning partitions"; + qCDebug(appLog) << "Adjusting sectorStart and sectorEnd for extended/logical/beginning partitions"; newPart.m_sectorStart += MEBIBYTE / newPart.m_sectorSize; newPart.m_sectorEnd += MEBIBYTE / newPart.m_sectorSize; } @@ -1247,33 +1248,33 @@ void PartitionWidget::onApplyButton() beforend = newPart.m_sectorEnd + 1; if (beforend > curInfo.m_sectorEnd && i < m_patrinfo.size() - 1) { - qDebug() << "Before end exceeds current info end and not last partition, setting isCreate to false"; + qCDebug(appLog) << "Before end exceeds current info end and not last partition, setting isCreate to false"; isCreate = false; - // qDebug() << "create too partition ,no enough space"; + // qCDebug(appLog) << "create too partition ,no enough space"; break; } else { - qDebug() << "Before end does not exceed current info end or is last partition"; + qCDebug(appLog) << "Before end does not exceed current info end or is last partition"; if (newPart.m_sectorEnd > curInfo.m_sectorEnd) { - qDebug() << "New partition sectorEnd exceeds current info sectorEnd, adjusting"; + qCDebug(appLog) << "New partition sectorEnd exceeds current info sectorEnd, adjusting"; newPart.m_sectorEnd = curInfo.m_sectorEnd; } bool isEndPartition = false; if (deviceLength == curInfo.m_sectorEnd + 1) { - qDebug() << "Device length is current info end + 1"; + qCDebug(appLog) << "Device length is current info end + 1"; if ((newPart.m_sectorEnd == curInfo.m_sectorEnd - 1) || (newPart.m_sectorEnd == curInfo.m_sectorEnd)) { - qDebug() << "New partition sectorEnd is current info sectorEnd - 1 or current info sectorEnd, adjusting for GPT"; + qCDebug(appLog) << "New partition sectorEnd is current info sectorEnd - 1 or current info sectorEnd, adjusting for GPT"; newPart.m_sectorEnd = curInfo.m_sectorEnd - 33; isEndPartition = true; } } if (!isEndPartition) { - qDebug() << "Not an end partition, aligning end sector"; + qCDebug(appLog) << "Not an end partition, aligning end sector"; Sector diff = 0; diff = (newPart.m_sectorEnd + 1) % (MEBIBYTE / newPart.m_sectorSize); if (diff) { - qDebug() << "Aligning end sector, diff:" << diff; + qCDebug(appLog) << "Aligning end sector, diff:" << diff; newPart.m_sectorEnd -= diff; } } @@ -1281,19 +1282,19 @@ void PartitionWidget::onApplyButton() beforend = newPart.m_sectorEnd + 1; if (m_patrinfo.at(i).m_isEncryption) { - qDebug() << "Partition is encrypted, setting LUKS flags"; + qCDebug(appLog) << "Partition is encrypted, setting LUKS flags"; newPart.m_luksFlag = LUKSFlag::IS_CRYPT_LUKS; newPart.m_crypt = m_patrinfo.at(i).m_encryption; QStringList tokenList; if (!m_patrinfo.at(i).m_passwordHint.isEmpty()) { - qDebug() << "Password hint is not empty, appending to tokenList"; + qCDebug(appLog) << "Password hint is not empty, appending to tokenList"; tokenList.append(m_patrinfo.at(i).m_passwordHint); } newPart.m_tokenList = tokenList; newPart.m_decryptStr = m_patrinfo.at(i).m_password; } else { - qDebug() << "Partition is not encrypted, setting NOT_CRYPT_LUKS"; + qCDebug(appLog) << "Partition is not encrypted, setting NOT_CRYPT_LUKS"; newPart.m_luksFlag = LUKSFlag::NOT_CRYPT_LUKS; newPart.m_crypt = CRYPT_CIPHER::NOT_CRYPT; newPart.m_tokenList = QStringList(); @@ -1305,16 +1306,16 @@ void PartitionWidget::onApplyButton() } } if (isCreate && partVector.size() > 0) { - qDebug() << "Creating partitions with DMDbusHandler::create"; + qCDebug(appLog) << "Creating partitions with DMDbusHandler::create"; DMDbusHandler::instance()->create(partVector); close(); } - qDebug() << "PartitionWidget::onApplyButton finished"; + qCDebug(appLog) << "PartitionWidget::onApplyButton finished"; } void PartitionWidget::onRevertButton() { - qDebug() << "Reverting all changes"; + qCDebug(appLog) << "Reverting all changes"; //复原,即清空 m_patrinfo.clear(); m_sizeInfo.clear(); @@ -1326,7 +1327,7 @@ void PartitionWidget::onRevertButton() m_isExceed = true; if (m_sizeInfo.size() == 0) { - qDebug() << "Size info is empty after revert, disabling apply button"; + qCDebug(appLog) << "Size info is empty after revert, disabling apply button"; m_applyBtn->setEnabled(false); } @@ -1336,22 +1337,22 @@ void PartitionWidget::onRevertButton() setSelectUnallocatesSpace(); m_partChartWidget->transFlag(1, 0); setEnable(1, true); - qDebug() << "All changes reverted"; + qCDebug(appLog) << "All changes reverted"; } void PartitionWidget::onCancelButton() { - qDebug() << "Canceling partition operation"; + qCDebug(appLog) << "Canceling partition operation"; close(); } bool PartitionWidget::event(QEvent *event) { - // qDebug() << "PartitionWidget::event called with event type:" << event->type(); + // qCDebug(appLog) << "PartitionWidget::event called with event type:" << event->type(); // 字体大小改变 if (QEvent::ApplicationFontChange == event->type()) { - qDebug() << "Application font change event detected"; - qDebug() << event->type() << QApplication::font().pointSizeF() / 0.75; + qCDebug(appLog) << "Application font change event detected"; + qCDebug(appLog) << event->type() << QApplication::font().pointSizeF() / 0.75; QFontMetrics fm(m_deviceNameLabel->font()); m_deviceNameLabel->setFixedWidth(fm.boundingRect(tr("Disk:")).width() + 5); #if QT_VERSION_MAJOR > 5 @@ -1369,12 +1370,12 @@ bool PartitionWidget::event(QEvent *event) void PartitionWidget::keyPressEvent(QKeyEvent *event) { - // qDebug() << "PartitionWidget::keyPressEvent called with key:" << event->key(); + // qCDebug(appLog) << "PartitionWidget::keyPressEvent called with key:" << event->key(); if (event->key() == Qt::Key::Key_Escape) { - qDebug() << "Escape key pressed, ignoring event"; + qCDebug(appLog) << "Escape key pressed, ignoring event"; event->ignore(); } else { - // qDebug() << "Other key pressed, calling DDialog::keyPressEvent"; + // qCDebug(appLog) << "Other key pressed, calling DDialog::keyPressEvent"; DDialog::keyPressEvent(event); } } diff --git a/application/widgets/customcontrol/passwordinputdialog.cpp b/application/widgets/customcontrol/passwordinputdialog.cpp index 1b6cc74c..93a3eb12 100644 --- a/application/widgets/customcontrol/passwordinputdialog.cpp +++ b/application/widgets/customcontrol/passwordinputdialog.cpp @@ -3,6 +3,7 @@ // SPDX-License-Identifier: GPL-3.0-only +#include "ddlog.h" #include "passwordinputdialog.h" #include @@ -14,15 +15,15 @@ PasswordInputDialog::PasswordInputDialog(QWidget *parent) : DDBase(parent) { - qDebug() << "PasswordInputDialog constructor called"; + qCDebug(appLog) << "PasswordInputDialog constructor called"; initUi(); initConnection(); - qDebug() << "PasswordInputDialog initialized"; + qCDebug(appLog) << "PasswordInputDialog initialized"; } void PasswordInputDialog::initUi() { - qDebug() << "PasswordInputDialog::initUi called"; + qCDebug(appLog) << "PasswordInputDialog::initUi called"; setFixedWidth(406); DPalette palette1; @@ -79,11 +80,11 @@ void PasswordInputDialog::initUi() // 限制中文和中文字符 #if QT_VERSION_MAJOR > 5 - qDebug() << "QT_VERSION_MAJOR > 5, setting regular expression validator"; + qCDebug(appLog) << "QT_VERSION_MAJOR > 5, setting regular expression validator"; QRegularExpression regExp("^[A-Za-z0-9`~!@#$%^&*()_-+=<>,.\\/ ]+$"); QRegularExpressionValidator *regExpValidator = new QRegularExpressionValidator(regExp, this); #else - qDebug() << "QT_VERSION_MAJOR <= 5, setting regular expression validator"; + qCDebug(appLog) << "QT_VERSION_MAJOR <= 5, setting regular expression validator"; QRegExp regExp("^[A-Za-z0-9`~!@#$%^&*()_-+=<>,.\\/ ]+$"); QRegExpValidator *regExpValidator = new QRegExpValidator(regExp, this); #endif @@ -153,31 +154,31 @@ void PasswordInputDialog::initUi() getButton(index)->setAccessibleName("passwordCancel"); getButton(m_okCode)->setAccessibleName("passwordConfirm"); - qDebug() << "PasswordInputDialog::initUi finished"; + qCDebug(appLog) << "PasswordInputDialog::initUi finished"; } void PasswordInputDialog::initConnection() { - qDebug() << "PasswordInputDialog::initConnection called"; + qCDebug(appLog) << "PasswordInputDialog::initConnection called"; connect(m_inputPasswordEdit, &DLineEdit::textChanged, this, &PasswordInputDialog::onInputPasswordEditTextChanged); connect(m_checkPasswordEdit, &DLineEdit::textChanged, this, &PasswordInputDialog::onCheckPasswordEditTextChanged); connect(m_textEdit, &QTextEdit::textChanged, this, &PasswordInputDialog::passwordHintTextChanged); connect(this, &PasswordInputDialog::buttonClicked, this, &PasswordInputDialog::onButtonClicked); - qDebug() << "PasswordInputDialog::initConnection finished"; + qCDebug(appLog) << "PasswordInputDialog::initConnection finished"; } void PasswordInputDialog::setDeviceName(const QString &devName) { - qDebug() << "PasswordInputDialog::setDeviceName called with devName:" << devName; + qCDebug(appLog) << "PasswordInputDialog::setDeviceName called with devName:" << devName; setTitle(tr("Set a password to encrypt %1").arg(devName)); - qDebug() << "PasswordInputDialog::setDeviceName finished"; + qCDebug(appLog) << "PasswordInputDialog::setDeviceName finished"; } void PasswordInputDialog::setTitleText(const QString &text) { - qDebug() << "PasswordInputDialog::setTitleText called with text:" << text; + qCDebug(appLog) << "PasswordInputDialog::setTitleText called with text:" << text; // This function seems to be empty, so no action needed other than logging. - qDebug() << "PasswordInputDialog::setTitleText finished"; + qCDebug(appLog) << "PasswordInputDialog::setTitleText finished"; } QString PasswordInputDialog::getPassword() @@ -192,51 +193,51 @@ QString PasswordInputDialog::getPasswordHint() void PasswordInputDialog::onInputPasswordEditTextChanged(const QString &) { - qDebug() << "PasswordInputDialog::onInputPasswordEditTextChanged called"; - qDebug() << "Password input changed, length:" << m_inputPasswordEdit->text().length(); + qCDebug(appLog) << "PasswordInputDialog::onInputPasswordEditTextChanged called"; + qCDebug(appLog) << "Password input changed, length:" << m_inputPasswordEdit->text().length(); if (m_inputPasswordEdit->isAlert() && m_inputPasswordEdit->text().length() <= 256) { - qDebug() << "Input password edit is in alert state and length is within limits, clearing alert"; + qCDebug(appLog) << "Input password edit is in alert state and length is within limits, clearing alert"; m_inputPasswordEdit->setAlert(false); m_inputPasswordEdit->hideAlertMessage(); } // 密码超出最大长度 if (m_inputPasswordEdit->text().length() > 256) { - qDebug() << "Input password length exceeds maximum, setting alert"; + qCDebug(appLog) << "Input password length exceeds maximum, setting alert"; m_inputPasswordEdit->setAlert(true); m_inputPasswordEdit->showAlertMessage(tr("The password exceeds the maximum length")); } - qDebug() << "PasswordInputDialog::onInputPasswordEditTextChanged finished"; + qCDebug(appLog) << "PasswordInputDialog::onInputPasswordEditTextChanged finished"; } void PasswordInputDialog::onCheckPasswordEditTextChanged(const QString &) { - qDebug() << "PasswordInputDialog::onCheckPasswordEditTextChanged called"; - qDebug() << "Password confirmation changed, length:" << m_checkPasswordEdit->text().length(); + qCDebug(appLog) << "PasswordInputDialog::onCheckPasswordEditTextChanged called"; + qCDebug(appLog) << "Password confirmation changed, length:" << m_checkPasswordEdit->text().length(); if (m_checkPasswordEdit->isAlert() && m_checkPasswordEdit->text().length() <= 256) { - qDebug() << "Check password edit is in alert state and length is within limits, clearing alert"; + qCDebug(appLog) << "Check password edit is in alert state and length is within limits, clearing alert"; m_checkPasswordEdit->setAlert(false); m_checkPasswordEdit->hideAlertMessage(); } // 密码超出最大长度 if (m_checkPasswordEdit->text().length() > 256) { - qDebug() << "Check password length exceeds maximum, setting alert"; + qCDebug(appLog) << "Check password length exceeds maximum, setting alert"; m_checkPasswordEdit->setAlert(true); m_checkPasswordEdit->showAlertMessage(tr("The password exceeds the maximum length")); } - qDebug() << "PasswordInputDialog::onCheckPasswordEditTextChanged finished"; + qCDebug(appLog) << "PasswordInputDialog::onCheckPasswordEditTextChanged finished"; } void PasswordInputDialog::passwordHintTextChanged() { - qDebug() << "PasswordInputDialog::passwordHintTextChanged called"; + qCDebug(appLog) << "PasswordInputDialog::passwordHintTextChanged called"; // 设置最大可输入字符 QString textContent = m_textEdit->toPlainText(); int length = textContent.count(); int maxLength = 50; // 最大字符数 if (length > maxLength) { - qDebug() << "Password hint length exceeds maximum, truncating"; + qCDebug(appLog) << "Password hint length exceeds maximum, truncating"; int position = m_textEdit->textCursor().position(); QTextCursor textCursor = m_textEdit->textCursor(); textContent.remove(position - (length - maxLength), length - maxLength); @@ -244,18 +245,18 @@ void PasswordInputDialog::passwordHintTextChanged() textCursor.setPosition(position - (length - maxLength)); m_textEdit->setTextCursor(textCursor); } - qDebug() << "PasswordInputDialog::passwordHintTextChanged finished"; + qCDebug(appLog) << "PasswordInputDialog::passwordHintTextChanged finished"; } void PasswordInputDialog::onButtonClicked(int index, const QString &text) { - qDebug() << "PasswordInputDialog::onButtonClicked called with index:" << index << "and text:" << text; + qCDebug(appLog) << "PasswordInputDialog::onButtonClicked called with index:" << index << "and text:" << text; Q_UNUSED(text); if (index == m_okCode) { - qDebug() << "Confirm button clicked, validating password"; + qCDebug(appLog) << "Confirm button clicked, validating password"; // 密码不能为空 if (m_inputPasswordEdit->text().isEmpty()) { - qDebug() << "Input password is empty, setting alert"; + qCDebug(appLog) << "Input password is empty, setting alert"; m_inputPasswordEdit->setAlert(true); m_inputPasswordEdit->showAlertMessage(tr("The password cannot be empty")); return; @@ -263,22 +264,22 @@ void PasswordInputDialog::onButtonClicked(int index, const QString &text) // 密码超出最大长度 if (m_inputPasswordEdit->text().length() > 256) { - qDebug() << "Input password length exceeds maximum, setting alert"; + qCDebug(appLog) << "Input password length exceeds maximum, setting alert"; m_inputPasswordEdit->setAlert(true); m_inputPasswordEdit->showAlertMessage(tr("The password exceeds the maximum length")); return; } // 密码不一致 - qDebug() << "Checking password match"; + qCDebug(appLog) << "Checking password match"; if (m_inputPasswordEdit->text() != m_checkPasswordEdit->text()) { - qDebug() << "Passwords do not match, setting alert"; + qCDebug(appLog) << "Passwords do not match, setting alert"; m_checkPasswordEdit->setAlert(true); m_checkPasswordEdit->showAlertMessage(tr("Passwords do not match")); return; } - qDebug() << "Checking password hint difference"; + qCDebug(appLog) << "Checking password hint difference"; if (m_inputPasswordEdit->text() == m_textEdit->toPlainText()) { // 提示内容不得与密码相同 DMessageManager::instance()->sendMessage(this, QIcon::fromTheme("://icons/deepin/builtin/warning.svg"), @@ -287,10 +288,10 @@ void PasswordInputDialog::onButtonClicked(int index, const QString &text) return; } - qDebug() << "Password validation passed"; + qCDebug(appLog) << "Password validation passed"; accept(); } else { - qDebug() << "Dialog rejected"; + qCDebug(appLog) << "Dialog rejected"; reject(); } } diff --git a/application/widgets/customcontrol/radiuswidget.cpp b/application/widgets/customcontrol/radiuswidget.cpp index d05173a6..d4502aef 100644 --- a/application/widgets/customcontrol/radiuswidget.cpp +++ b/application/widgets/customcontrol/radiuswidget.cpp @@ -1,13 +1,14 @@ -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2022 - 2026 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-only +#include "ddlog.h" #include "radiuswidget.h" RadiusWidget::RadiusWidget(QWidget *parent) : QWidget(parent) { - qDebug() << "RadiusWidget constructor called."; + qCDebug(appLog) << "RadiusWidget constructor called."; m_leftTop = false; m_leftBottom = false; m_rightTop = false; @@ -18,7 +19,7 @@ RadiusWidget::RadiusWidget(QWidget *parent) : QWidget(parent) void RadiusWidget::setMode(bool leftTop, bool leftBottom, bool rightTop, bool rightBottom) { - qDebug() << "Setting corner modes - LT:" << leftTop + qCDebug(appLog) << "Setting corner modes - LT:" << leftTop << " LB:" << leftBottom << " RT:" << rightTop << " RB:" << rightBottom; @@ -30,46 +31,46 @@ void RadiusWidget::setMode(bool leftTop, bool leftBottom, bool rightTop, bool ri void RadiusWidget::setChecked(bool isChecked) { - qDebug() << "Setting checked state:" << isChecked; + qCDebug(appLog) << "Setting checked state:" << isChecked; m_isChecked = isChecked; update(); } void RadiusWidget::paintEvent(QPaintEvent *event) { - // qDebug() << "RadiusWidget::paintEvent called."; + // qCDebug(appLog) << "RadiusWidget::paintEvent called."; QPainter painter(this); painter.setRenderHint(QPainter::Antialiasing); // 反锯齿; DGuiApplicationHelper::ColorType themeType = DGuiApplicationHelper::instance()->themeType(); - // qDebug() << "Theme type:" << themeType; + // qCDebug(appLog) << "Theme type:" << themeType; if (themeType == DGuiApplicationHelper::LightType) { - // qDebug() << "Theme is LightType."; + // qCDebug(appLog) << "Theme is LightType."; if (m_isChecked) { - // qDebug() << "m_isChecked is true, setting brush for light theme."; + // qCDebug(appLog) << "m_isChecked is true, setting brush for light theme."; painter.setBrush(QBrush(QColor(0, 0, 0, 30))); } else { - // qDebug() << "m_isChecked is false for light theme."; + // qCDebug(appLog) << "m_isChecked is false for light theme."; if (m_isEnter) { - // qDebug() << "m_isEnter is true, setting brush for light theme."; + // qCDebug(appLog) << "m_isEnter is true, setting brush for light theme."; painter.setBrush(QBrush(QColor(0, 0, 0, 30))); } else { - // qDebug() << "m_isEnter is false, setting brush for light theme."; + // qCDebug(appLog) << "m_isEnter is false, setting brush for light theme."; painter.setBrush(QBrush(QColor(0, 0, 0, 10))); } } } else if (themeType == DGuiApplicationHelper::DarkType) { - // qDebug() << "Theme is DarkType."; + // qCDebug(appLog) << "Theme is DarkType."; if (m_isChecked) { - // qDebug() << "m_isChecked is true, setting brush for dark theme."; + // qCDebug(appLog) << "m_isChecked is true, setting brush for dark theme."; painter.setBrush(QBrush(QColor(255, 255, 255, 30))); } else { - // qDebug() << "m_isChecked is false for dark theme."; + // qCDebug(appLog) << "m_isChecked is false for dark theme."; if (m_isEnter) { - // qDebug() << "m_isEnter is true, setting brush for dark theme."; + // qCDebug(appLog) << "m_isEnter is true, setting brush for dark theme."; painter.setBrush(QBrush(QColor(255, 255, 255, 30))); } else { - // qDebug() << "m_isEnter is false, setting brush for dark theme."; + // qCDebug(appLog) << "m_isEnter is false, setting brush for dark theme."; painter.setBrush(QBrush(QColor(255, 255, 255, 10))); } } @@ -87,7 +88,7 @@ void RadiusWidget::paintEvent(QPaintEvent *event) QPointF(rect.topRight().x() - 10, rect.topLeft().y()) }; painter.drawPolygon(pointstop, 4); - // qDebug() << "Drawing top polygon."; + // qCDebug(appLog) << "Drawing top polygon."; QPointF pointscenter[4] = { QPointF(rect.topLeft().x(), rect.topLeft().y() + 10), @@ -97,7 +98,7 @@ void RadiusWidget::paintEvent(QPaintEvent *event) }; painter.drawPolygon(pointscenter, 4); - // qDebug() << "Drawing center polygon."; + // qCDebug(appLog) << "Drawing center polygon."; QPointF pointsbottom[4] = { QPointF(rect.bottomLeft().x() + 10, rect.bottomLeft().y() - 10), @@ -106,42 +107,42 @@ void RadiusWidget::paintEvent(QPaintEvent *event) QPointF(rect.bottomRight().x() - 10, rect.bottomRight().y() - 10) }; painter.drawPolygon(pointsbottom, 4); - // qDebug() << "Drawing bottom polygon."; + // qCDebug(appLog) << "Drawing bottom polygon."; //给各个角画直角 if (m_leftTop) { - // qDebug() << "Drawing leftTop corner."; + // qCDebug(appLog) << "Drawing leftTop corner."; QRectF rectf(QPointF(rect.topLeft().x(), rect.topLeft().y()), QSizeF(20, 20)); painter.drawPie(rectf, 90 * 16, 90 * 16); } else { - // qDebug() << "Drawing leftTop straight corner."; + // qCDebug(appLog) << "Drawing leftTop straight corner."; painter.drawPolygon(QRect(QPoint(rect.topLeft()), QSize(10, 10))); } if (m_leftBottom) { - // qDebug() << "Drawing leftBottom corner."; + // qCDebug(appLog) << "Drawing leftBottom corner."; QRectF rectf(QPointF(rect.bottomLeft().x(), rect.bottomLeft().y() - 20), QSizeF(20, 20)); painter.drawPie(rectf, 180 * 16, 90 * 16); } else { - // qDebug() << "Drawing leftBottom straight corner."; + // qCDebug(appLog) << "Drawing leftBottom straight corner."; painter.drawPolygon(QRect(QPoint(rect.bottomLeft().x(), rect.bottomLeft().y() - 10), QSize(10, 10))); } if (m_rightTop) { - // qDebug() << "Drawing rightTop corner."; + // qCDebug(appLog) << "Drawing rightTop corner."; QRectF rectf(QPointF(rect.topRight().x() - 20, rect.topRight().y()), QSizeF(20, 20)); painter.drawPie(rectf, 0 * 16, 90 * 16); } else { - // qDebug() << "Drawing rightTop straight corner."; + // qCDebug(appLog) << "Drawing rightTop straight corner."; painter.drawPolygon(QRect(QPoint(rect.topRight().x() - 10, rect.topRight().y()), QSize(10, 10))); } if (m_rightBottom) { - // qDebug() << "Drawing rightBottom corner."; + // qCDebug(appLog) << "Drawing rightBottom corner."; QRectF rectf(QPointF(rect.bottomRight().x() - 20, rect.bottomRight().y() - 20), QSizeF(20, 20)); painter.drawPie(rectf, 270 * 16, 90 * 16); } else { - // qDebug() << "Drawing rightBottom straight corner."; + // qCDebug(appLog) << "Drawing rightBottom straight corner."; painter.drawPolygon(QRect(QPoint(rect.bottomRight().x() - 10, rect.bottomRight().y() - 10), QSize(10, 10))); } @@ -154,7 +155,7 @@ void RadiusWidget::enterEvent(QEnterEvent *event) void RadiusWidget::enterEvent(QEvent *event) #endif { - // qDebug() << "RadiusWidget::enterEvent called."; + // qCDebug(appLog) << "RadiusWidget::enterEvent called."; Q_UNUSED(event); m_isEnter =true; update(); @@ -162,7 +163,7 @@ void RadiusWidget::enterEvent(QEvent *event) void RadiusWidget::leaveEvent(QEvent *event) { - // qDebug() << "RadiusWidget::leaveEvent called."; + // qCDebug(appLog) << "RadiusWidget::leaveEvent called."; Q_UNUSED(event); m_isEnter = false; update(); diff --git a/application/widgets/customcontrol/selecteditemwidget.cpp b/application/widgets/customcontrol/selecteditemwidget.cpp index 452d8c99..43120b5b 100644 --- a/application/widgets/customcontrol/selecteditemwidget.cpp +++ b/application/widgets/customcontrol/selecteditemwidget.cpp @@ -3,6 +3,7 @@ // SPDX-License-Identifier: GPL-3.0-only +#include "ddlog.h" #include "selecteditemwidget.h" #include "partedproxy/dmdbushandler.h" @@ -15,7 +16,7 @@ SelectedItemWidget::SelectedItemWidget(PVInfoData pvInfoData, QWidget *parent) : RadiusWidget(parent) , m_pvInfoData(pvInfoData) { - qDebug() << "Creating selected item for:" + qCDebug(appLog) << "Creating selected item for:" << (m_pvInfoData.m_disktype == "unrecognized" ? m_pvInfoData.m_diskPath : m_pvInfoData.m_partitionPath); initUi(); initConnection(); @@ -23,7 +24,7 @@ SelectedItemWidget::SelectedItemWidget(PVInfoData pvInfoData, QWidget *parent) void SelectedItemWidget::initUi() { - qDebug() << "SelectedItemWidget::initUi called."; + qCDebug(appLog) << "SelectedItemWidget::initUi called."; setFixedHeight(36); DPalette paletteName; @@ -65,24 +66,24 @@ void SelectedItemWidget::initUi() m_iconButton->setFixedSize(17, 17); if (m_pvInfoData.m_disktype == "unrecognized") { - qDebug() << "Setting unrecognized disk info:" << m_pvInfoData.m_diskPath << m_pvInfoData.m_diskSize; + qCDebug(appLog) << "Setting unrecognized disk info:" << m_pvInfoData.m_diskPath << m_pvInfoData.m_diskSize; m_nameInfo->setText(m_pvInfoData.m_diskPath); m_sizeInfo->setText(m_pvInfoData.m_diskSize); } else { if (m_pvInfoData.m_partitionPath == "unallocated") { - qDebug() << "Setting unallocated partition info:" << m_pvInfoData.m_diskPath; + qCDebug(appLog) << "Setting unallocated partition info:" << m_pvInfoData.m_diskPath; m_nameInfo->setText(m_pvInfoData.m_diskPath); } else { - qDebug() << "Setting partition info:" << m_pvInfoData.m_partitionPath << m_pvInfoData.m_partitionSize; + qCDebug(appLog) << "Setting partition info:" << m_pvInfoData.m_partitionPath << m_pvInfoData.m_partitionSize; m_nameInfo->setText(m_pvInfoData.m_partitionPath); } m_sizeInfo->setText(m_pvInfoData.m_partitionSize); - qDebug() << "Setting partition size:" << m_pvInfoData.m_partitionSize; + qCDebug(appLog) << "Setting partition size:" << m_pvInfoData.m_partitionSize; } if (m_pvInfoData.m_isReadOnly) { - qDebug() << "Disk is read-only, disabling icon button."; + qCDebug(appLog) << "Disk is read-only, disabling icon button."; m_iconButton->setDisabled(true); } @@ -94,22 +95,22 @@ void SelectedItemWidget::initUi() mainLayout->addWidget(m_iconButton); mainLayout->setSpacing(0); mainLayout->setContentsMargins(10, 0, 10, 0); - qDebug() << "Main layout configured."; + qCDebug(appLog) << "Main layout configured."; setLayout(mainLayout); - qDebug() << "Layout set."; + qCDebug(appLog) << "Layout set."; } void SelectedItemWidget::initConnection() { - qDebug() << "SelectedItemWidget::initConnection called."; + qCDebug(appLog) << "SelectedItemWidget::initConnection called."; connect(m_iconButton, &DIconButton::clicked, this, &SelectedItemWidget::onDeleteClicked); } void SelectedItemWidget::onDeleteClicked() { - qDebug() << "SelectedItemWidget::onDeleteClicked called."; - qDebug() << "Delete clicked for:" + qCDebug(appLog) << "SelectedItemWidget::onDeleteClicked called."; + qCDebug(appLog) << "Delete clicked for:" << (m_pvInfoData.m_disktype == "unrecognized" ? m_pvInfoData.m_diskPath : m_pvInfoData.m_partitionPath); emit deleteItem(m_pvInfoData); } diff --git a/application/widgets/customcontrol/selectpvitemwidget.cpp b/application/widgets/customcontrol/selectpvitemwidget.cpp index 47fc528f..98af510e 100644 --- a/application/widgets/customcontrol/selectpvitemwidget.cpp +++ b/application/widgets/customcontrol/selectpvitemwidget.cpp @@ -3,6 +3,7 @@ // SPDX-License-Identifier: GPL-3.0-only +#include "ddlog.h" #include "selectpvitemwidget.h" #include "common.h" #include "partedproxy/dmdbushandler.h" @@ -15,8 +16,8 @@ SelectPVItemWidget::SelectPVItemWidget(PVInfoData pvInfoData, QWidget *parent) : RadiusWidget(parent) , m_pvInfoData(pvInfoData) { - qDebug() << "SelectPVItemWidget constructor called."; - qDebug() << "Creating PV select item for:" << pvInfoData.m_diskPath << pvInfoData.m_partitionPath; + qCDebug(appLog) << "SelectPVItemWidget constructor called."; + qCDebug(appLog) << "Creating PV select item for:" << pvInfoData.m_diskPath << pvInfoData.m_partitionPath; initUi(); initConnection(); initData(); @@ -24,7 +25,7 @@ SelectPVItemWidget::SelectPVItemWidget(PVInfoData pvInfoData, QWidget *parent) void SelectPVItemWidget::initUi() { - qDebug() << "SelectPVItemWidget::initUi called."; + qCDebug(appLog) << "SelectPVItemWidget::initUi called."; setFixedHeight(36); DPalette paletteName; @@ -66,10 +67,10 @@ void SelectPVItemWidget::initUi() mainLayout->addStretch(); mainLayout->addWidget(m_sizeLabel); mainLayout->setSpacing(0); - qDebug() << "Main layout widgets added and spacing set."; + qCDebug(appLog) << "Main layout widgets added and spacing set."; if ((m_pvInfoData.m_level == DMDbusHandler::DISK) && (m_pvInfoData.m_disktype != "unrecognized")) { - qDebug() << "PV info data is DISK level and recognized, adding icon label."; + qCDebug(appLog) << "PV info data is DISK level and recognized, adding icon label."; m_iconLabel = new DLabel(this); QIcon icon = Common::getIcon("arrow_right"); m_iconLabel->setPixmap(icon.pixmap(QSize(8, 11))); @@ -78,77 +79,77 @@ void SelectPVItemWidget::initUi() mainLayout->addWidget(m_iconLabel); mainLayout->setContentsMargins(10, 0, 12, 0); } else { - qDebug() << "PV info data is not DISK level or unrecognized, setting content margins without icon."; + qCDebug(appLog) << "PV info data is not DISK level or unrecognized, setting content margins without icon."; mainLayout->setContentsMargins(10, 0, 20, 0); } setLayout(mainLayout); - qDebug() << "Layout set."; + qCDebug(appLog) << "Layout set."; } void SelectPVItemWidget::initConnection() { - qDebug() << "SelectPVItemWidget::initConnection called."; + qCDebug(appLog) << "SelectPVItemWidget::initConnection called."; connect(m_checkBox, &DCheckBox::stateChanged, this, &SelectPVItemWidget::onCheckBoxStateChange); } void SelectPVItemWidget::initData() { - qDebug() << "SelectPVItemWidget::initData called."; + qCDebug(appLog) << "SelectPVItemWidget::initData called."; switch (m_pvInfoData.m_selectStatus) { case Qt::CheckState::Unchecked: { - qDebug() << "Setting check state to Unchecked."; + qCDebug(appLog) << "Setting check state to Unchecked."; setCheckBoxState(Qt::CheckState::Unchecked); break; } case Qt::CheckState::PartiallyChecked: { - qDebug() << "Setting check state to PartiallyChecked."; + qCDebug(appLog) << "Setting check state to PartiallyChecked."; setCheckBoxState(Qt::CheckState::PartiallyChecked); break; } case Qt::CheckState::Checked: { - qDebug() << "Setting check state to Checked."; + qCDebug(appLog) << "Setting check state to Checked."; setCheckBoxState(Qt::CheckState::Checked); break; } default: - qDebug() << "Unknown check state."; + qCDebug(appLog) << "Unknown check state."; break; } if (m_pvInfoData.m_level == DMDbusHandler::DISK) { - qDebug() << "PV info data level is DISK, setting disk path and size."; + qCDebug(appLog) << "PV info data level is DISK, setting disk path and size."; m_pathLabel->setText(m_pvInfoData.m_diskPath); m_sizeLabel->setText(m_pvInfoData.m_diskSize); } else { QString partitionPath = m_pvInfoData.m_partitionPath; if (partitionPath == "unallocated") { - qDebug() << "Partition path is unallocated, setting path label to unallocated."; + qCDebug(appLog) << "Partition path is unallocated, setting path label to unallocated."; m_pathLabel->setText(partitionPath); } else { - qDebug() << "Partition path is recognized, setting path label to modified partition path."; + qCDebug(appLog) << "Partition path is recognized, setting path label to modified partition path."; m_pathLabel->setText(partitionPath.remove(0, 5)); } m_sizeLabel->setText(m_pvInfoData.m_partitionSize); - qDebug() << "Setting partition size:" << m_pvInfoData.m_partitionSize; + qCDebug(appLog) << "Setting partition size:" << m_pvInfoData.m_partitionSize; } if (m_pvInfoData.m_isReadOnly) { - qDebug() << "PV is read-only, disabling checkbox."; + qCDebug(appLog) << "PV is read-only, disabling checkbox."; m_checkBox->setDisabled(true); } } void SelectPVItemWidget::onCheckBoxStateChange(int state) { - qDebug() << "SelectPVItemWidget::onCheckBoxStateChange called with state:" << state; + qCDebug(appLog) << "SelectPVItemWidget::onCheckBoxStateChange called with state:" << state; if (m_pvInfoData.m_level == DMDbusHandler::DISK) { - qDebug() << "PV info data level is DISK."; + qCDebug(appLog) << "PV info data level is DISK."; if (state != Qt::CheckState::PartiallyChecked) { - qDebug() << "State is not PartiallyChecked."; + qCDebug(appLog) << "State is not PartiallyChecked."; if (m_lstPVInfoData.count() != 0) { - qDebug() << "List of PV info data is not empty, updating select status."; + qCDebug(appLog) << "List of PV info data is not empty, updating select status."; QList lstData; lstData.clear(); for (int i = 0; i < m_lstPVInfoData.count(); i++) { @@ -156,66 +157,66 @@ void SelectPVItemWidget::onCheckBoxStateChange(int state) pvData.m_selectStatus = state; lstData.append(pvData); - qDebug() << "Updated PV data for item:" << pvData.m_diskPath << ", new state:" << pvData.m_selectStatus; + qCDebug(appLog) << "Updated PV data for item:" << pvData.m_diskPath << ", new state:" << pvData.m_selectStatus; } m_lstPVInfoData.clear(); m_lstPVInfoData = lstData; - qDebug() << "m_lstPVInfoData updated."; + qCDebug(appLog) << "m_lstPVInfoData updated."; } } m_pvInfoData.m_selectStatus = state; - qDebug() << "PV info data select status updated to:" << m_pvInfoData.m_selectStatus; + qCDebug(appLog) << "PV info data select status updated to:" << m_pvInfoData.m_selectStatus; emit checkBoxStateChange(state); } else { - qDebug() << "PV info data level is not DISK."; + qCDebug(appLog) << "PV info data level is not DISK."; m_pvInfoData.m_selectStatus = state; - qDebug() << "PV info data select status updated to:" << m_pvInfoData.m_selectStatus; + qCDebug(appLog) << "PV info data select status updated to:" << m_pvInfoData.m_selectStatus; emit checkBoxStateChange(state); } } void SelectPVItemWidget::setCheckBoxState(Qt::CheckState state, bool isPartiallyChecked) { - qDebug() << "Setting checkbox state:" << state << "isPartially:" << isPartiallyChecked; + qCDebug(appLog) << "Setting checkbox state:" << state << "isPartially:" << isPartiallyChecked; if(isPartiallyChecked){ - qDebug() << "isPartiallyChecked is true."; + qCDebug(appLog) << "isPartiallyChecked is true."; m_pvInfoData.m_selectStatus = state; m_checkBox->setCheckState(state); } else { - qDebug() << "isPartiallyChecked is false, blocking signals."; + qCDebug(appLog) << "isPartiallyChecked is false, blocking signals."; blockSignals(true); m_pvInfoData.m_selectStatus = state; m_checkBox->setCheckState(state); blockSignals(false); - qDebug() << "Signals unblocked."; + qCDebug(appLog) << "Signals unblocked."; } } void SelectPVItemWidget::setData(const QList &lstData) { - qDebug() << "SelectPVItemWidget::setData called, setting data with count:" << lstData.count(); + qCDebug(appLog) << "SelectPVItemWidget::setData called, setting data with count:" << lstData.count(); m_lstPVInfoData = lstData; } QList SelectPVItemWidget::getData() { - qDebug() << "SelectPVItemWidget::getData called."; + qCDebug(appLog) << "SelectPVItemWidget::getData called."; return m_lstPVInfoData; } PVInfoData SelectPVItemWidget::getCurInfo() { - qDebug() << "SelectPVItemWidget::getCurInfo called."; + qCDebug(appLog) << "SelectPVItemWidget::getCurInfo called."; return m_pvInfoData; } void SelectPVItemWidget::mousePressEvent(QMouseEvent *event) { - // qDebug() << "SelectPVItemWidget::mousePressEvent called."; + // qCDebug(appLog) << "SelectPVItemWidget::mousePressEvent called."; if (m_pvInfoData.m_level == DMDbusHandler::DISK) { - qDebug() << "PV info data level is DISK, emitting selectItem."; + qCDebug(appLog) << "PV info data level is DISK, emitting selectItem."; emit selectItem(); }