From 93310b7b21c33d6e4198e4771a525e6fa5c6e9ed Mon Sep 17 00:00:00 2001 From: houchengqiu Date: Fri, 8 Nov 2024 13:50:22 +0800 Subject: [PATCH] chore: adapt compact mode Adjust content select row height to 24px. Log: Adapt compact mode. --- application/filtercontent.cpp | 51 +++-------------------------- application/filtercontent.h | 5 --- application/logviewitemdelegate.cpp | 4 +-- 3 files changed, 6 insertions(+), 54 deletions(-) diff --git a/application/filtercontent.cpp b/application/filtercontent.cpp index a7556d60..c81d2a10 100644 --- a/application/filtercontent.cpp +++ b/application/filtercontent.cpp @@ -105,7 +105,7 @@ void FilterContent::initUI() lvTxt->setAlignment(Qt::AlignRight | Qt::AlignVCenter); cbx_lv = new LogCombox(this); cbx_lv->view()->setAccessibleName("combobox_level_view"); - cbx_lv->setMinimumSize(QSize(LEVEL_COMBO_WIDTH, BUTTON_HEIGHT_MIN)); + cbx_lv->setMinimumWidth(LEVEL_COMBO_WIDTH); cbx_lv->addItems(QStringList() << DApplication::translate("ComboBox", "All") << DApplication::translate("ComboBox", "Emergency") << DApplication::translate("ComboBox", "Alert") @@ -126,7 +126,7 @@ void FilterContent::initUI() dnflvTxt->setAlignment(Qt::AlignRight | Qt::AlignVCenter); cbx_dnf_lv = new LogCombox(this); cbx_dnf_lv->view()->setAccessibleName("combobox_dnflevel_view"); - cbx_dnf_lv->setMinimumSize(QSize(198, BUTTON_HEIGHT_MIN)); + cbx_dnf_lv->setMinimumWidth(198); cbx_dnf_lv->addItem(DApplication::translate("ComboBox", "All"), DNFLVALL); cbx_dnf_lv->addItem(DApplication::translate("ComboBox", "Super critical"), SUPERCRITICAL); cbx_dnf_lv->addItem(DApplication::translate("ComboBox", "Critical"), CRITICAL); @@ -145,7 +145,7 @@ void FilterContent::initUI() cbx_app = new LogCombox(this); cbx_app->view()->setAccessibleName("combobox_app_view"); - cbx_app->setMinimumSize(QSize(160, BUTTON_HEIGHT_MIN)); + cbx_app->setMinimumWidth(160); hLayout_app->addWidget(appTxt); hLayout_app->addWidget(cbx_app, 1); hLayout_app->setSpacing(6); @@ -157,7 +157,7 @@ void FilterContent::initUI() cbx_submodule = new LogCombox(this); cbx_submodule->view()->setAccessibleName("combobox_submodule_view"); - cbx_submodule->setMinimumSize(QSize(143, BUTTON_HEIGHT_MIN)); + cbx_submodule->setMinimumWidth(143); hLayout_submodule->addWidget(submoduleTxt); hLayout_submodule->addWidget(cbx_submodule, 1); hLayout_submodule->setSpacing(6); @@ -170,7 +170,6 @@ void FilterContent::initUI() cbx_status = new LogCombox(this); cbx_status->view()->setAccessibleName("combobox_status_view"); cbx_status->setMinimumWidth(120); - cbx_status->setMinimumSize(QSize(120, BUTTON_HEIGHT_MIN)); cbx_status->addItems(QStringList() << DApplication::translate("ComboBox", "All") << "OK" << "Failed"); hLayout_status->addWidget(statusTxt); @@ -184,7 +183,6 @@ void FilterContent::initUI() typeCbx = new LogCombox(this); typeCbx->view()->setAccessibleName("combobox_eventtype_view"); typeCbx->setMinimumWidth(120); - typeCbx->setMinimumSize(QSize(120, BUTTON_HEIGHT_MIN)); typeCbx->addItems(QStringList() << DApplication::translate("ComboBox", "All") << DApplication::translate("ComboBox", "Login") << DApplication::translate("ComboBox", "Boot") @@ -199,7 +197,6 @@ void FilterContent::initUI() auditTypeTxt = new DLabel(DApplication::translate("Label", "Audit Type:"), this); auditTypeCbx = new LogCombox(this); auditTypeCbx->setMinimumWidth(120); - auditTypeCbx->setMinimumSize(QSize(120, BUTTON_HEIGHT_MIN)); auditTypeCbx->addItems(QStringList() << DApplication::translate("ComboBox", "All") << DApplication::translate("ComboBox", "Identity authentication") << DApplication::translate("ComboBox", "Discretionary Access Control") @@ -251,11 +248,6 @@ void FilterContent::initConnections() connect(typeCbx, SIGNAL(currentIndexChanged(int)), this, SLOT(slot_cbxLogTypeChanged(int))); // add by Airy connect(auditTypeCbx, SIGNAL(currentIndexChanged(int)), this, SLOT(slot_cbxAuditTypeChanged(int))); -#ifdef DTKWIDGET_CLASS_DSizeMode - // 紧凑模式信号处理 - connect(DGuiApplicationHelper::instance(), &DGuiApplicationHelper::sizeModeChanged, this, &FilterContent::updateSizeMode); - updateSizeMode(); -#endif } /** @@ -962,38 +954,3 @@ void FilterContent::setChangedcomboxstate(bool value) { m_bIsCombox = value; } - -void FilterContent::updateSizeMode() -{ - int nBtnHeight = BUTTON_HEIGHT_MIN; -#ifdef DTKWIDGET_CLASS_DSizeMode - if (DGuiApplicationHelper::isCompactMode()) - nBtnHeight = BUTTON_HEIGHT_MIN_COMPACT; - else - nBtnHeight = BUTTON_HEIGHT_MIN; -#else - nBtnHeight = BUTTON_HEIGHT_MIN; -#endif - - if (cbx_lv) { - cbx_lv->setMinimumSize(QSize(LEVEL_COMBO_WIDTH, nBtnHeight)); - } - if (cbx_dnf_lv) { - cbx_dnf_lv->setMinimumSize(QSize(LEVEL_COMBO_WIDTH, nBtnHeight)); - } - if (cbx_app) { - cbx_app->setMinimumSize(QSize(LEVEL_COMBO_WIDTH, nBtnHeight)); - } - if (cbx_submodule) { - cbx_submodule->setMinimumSize(QSize(LEVEL_COMBO_WIDTH, nBtnHeight)); - } - if (cbx_status) { - cbx_status->setMinimumSize(QSize(LEVEL_COMBO_WIDTH, nBtnHeight)); - } - if (typeCbx) { - typeCbx->setMinimumSize(QSize(LEVEL_COMBO_WIDTH, nBtnHeight)); - } - if (auditTypeCbx) { - auditTypeCbx->setMinimumSize(QSize(LEVEL_COMBO_WIDTH, nBtnHeight)); - } -} diff --git a/application/filtercontent.h b/application/filtercontent.h index 03dab621..5be12089 100644 --- a/application/filtercontent.h +++ b/application/filtercontent.h @@ -59,11 +59,6 @@ class FilterContent : public Dtk::Widget::DFrame */ void setChangedcomboxstate(bool value); -private slots: - /** - * @brief 根据布局模式(紧凑)变更更新界面布局 - */ - void updateSizeMode(); protected: // void resizeEvent(QResizeEvent *event) override; void paintEvent(QPaintEvent *event) override; diff --git a/application/logviewitemdelegate.cpp b/application/logviewitemdelegate.cpp index ccb6b661..0d5b8265 100644 --- a/application/logviewitemdelegate.cpp +++ b/application/logviewitemdelegate.cpp @@ -21,8 +21,8 @@ DWIDGET_USE_NAMESPACE #define ICON_WIDTH 24 #define ICON_HEIGHT 24 -#define ROW_HEIGHT 36 -#define ROW_HEIGHT_COMPACT 24 +#define ROW_HEIGHT 38 +#define ROW_HEIGHT_COMPACT 26 LogViewItemDelegate::LogViewItemDelegate(QObject *parent) : QStyledItemDelegate(parent)