Skip to content

Commit

Permalink
chore: adapt compact mode
Browse files Browse the repository at this point in the history
Adjust content select row height to 24px.

Log: Adapt compact mode.
  • Loading branch information
starhcq authored and rb-union committed Dec 5, 2024
1 parent 7806e75 commit 93310b7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 54 deletions.
51 changes: 4 additions & 47 deletions application/filtercontent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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")
Expand All @@ -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")
Expand Down Expand Up @@ -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
}

/**
Expand Down Expand Up @@ -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));
}
}
5 changes: 0 additions & 5 deletions application/filtercontent.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions application/logviewitemdelegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 93310b7

Please sign in to comment.