fix(Nm): 统一删除图元和边界切换确认界面
- 使用纯文本展示图元名称、类型及边界切换信息 - 统一提示图标、底部按钮和自适应布局,减少多余留白 - 补充中文注释和翻译,清理旧确认文案 - 保持原有删除及边界绘制流程feature/Dialog-Unification-20261106
parent
06d1dfb658
commit
6c26313713
Binary file not shown.
@ -1,39 +1,82 @@
|
||||
#include "nmDeleteConfirmationDlg.h"
|
||||
#include "ZxBaseUtil.h"
|
||||
|
||||
#include <QVBoxLayout>
|
||||
#include <QDialogButtonBox>
|
||||
#include <QHBoxLayout>
|
||||
#include <QLabel>
|
||||
#include <QPushButton>
|
||||
#include <QHBoxLayout>
|
||||
|
||||
#include <QSizePolicy>
|
||||
#include <QStyle>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
nmDeleteConfirmationDlg::nmDeleteConfirmationDlg() {
|
||||
this->initUI();
|
||||
this->resize(250,80);
|
||||
nmDeleteConfirmationDlg::nmDeleteConfirmationDlg(
|
||||
const QString& sObjectName, const QString& sObjectType, QWidget* pParent)
|
||||
: iDlgBase(pParent)
|
||||
{
|
||||
createUi(sObjectName, sObjectType);
|
||||
// 按提示文字、图标和按钮计算初始尺寸,避免短提示右侧出现额外留白。
|
||||
adjustSize();
|
||||
}
|
||||
|
||||
void nmDeleteConfirmationDlg::initUI() {
|
||||
// 设置对话框的窗口标题
|
||||
this->setWindowTitle(tr("confirm"));
|
||||
|
||||
// 创建布局和控件
|
||||
QVBoxLayout *mainLayout = new QVBoxLayout(this);
|
||||
QLabel *messageLabel = new QLabel(tr("Do you confirm the deletion of the selected fault?"), this);
|
||||
mainLayout->addWidget(messageLabel);
|
||||
void nmDeleteConfirmationDlg::createUi(
|
||||
const QString& sObjectName, const QString& sObjectType)
|
||||
{
|
||||
setWindowTitle(tr("Delete object"));
|
||||
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
||||
setModal(true);
|
||||
// Esc 和取消按钮均只返回拒绝结果,不执行任何删除或边界切换操作。
|
||||
setIgnoreEsc(false);
|
||||
|
||||
// 创建按钮
|
||||
QHBoxLayout *buttonLayout = new QHBoxLayout;
|
||||
QPushButton *yesButton = new QPushButton(tr("Yes"), this);
|
||||
QPushButton *noButton = new QPushButton(tr("No"), this);
|
||||
QVBoxLayout* pMainLayout = new QVBoxLayout(this);
|
||||
pMainLayout->setContentsMargins(12, 10, 12, 0);
|
||||
pMainLayout->setSpacing(10);
|
||||
|
||||
// 连接按钮的点击信号
|
||||
connect(yesButton, SIGNAL(clicked()), this, SLOT(accept()));
|
||||
connect(noButton, SIGNAL(clicked()), this, SLOT(reject()));
|
||||
QWidget* pContent = new QWidget(this);
|
||||
pContent->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
||||
QHBoxLayout* pContentLayout = new QHBoxLayout(pContent);
|
||||
pContentLayout->setContentsMargins(0, 0, 0, 0);
|
||||
pContentLayout->setSpacing(10);
|
||||
|
||||
buttonLayout->addStretch();
|
||||
buttonLayout->addWidget(yesButton);
|
||||
buttonLayout->addWidget(noButton);
|
||||
mainLayout->addLayout(buttonLayout);
|
||||
// 提示图标与确认文字并排展示,避免把只供核对的信息排成参数编辑表单。
|
||||
QLabel* pIconLabel = new QLabel(pContent);
|
||||
const int nIconSize = style()->pixelMetric(QStyle::PM_MessageBoxIconSize);
|
||||
pIconLabel->setPixmap(style()->standardIcon(QStyle::SP_MessageBoxWarning).pixmap(nIconSize, nIconSize));
|
||||
pContentLayout->addWidget(pIconLabel, 0, Qt::AlignTop);
|
||||
const QString sDisplayName = sObjectName.trimmed().isEmpty()
|
||||
? tr("Unnamed object") : sObjectName;
|
||||
const QString sMessage = tr("Delete %1 \"%2\"?").arg(sObjectType, sDisplayName);
|
||||
QLabel* pMessageLabel = new QLabel(sMessage, pContent);
|
||||
// 名称中的尖括号等字符按原文显示,不被解释为富文本;长文字随窗口换行。
|
||||
pMessageLabel->setTextFormat(Qt::PlainText);
|
||||
pMessageLabel->setWordWrap(true);
|
||||
pMessageLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
|
||||
pContentLayout->addWidget(pMessageLabel, 1);
|
||||
pMainLayout->addWidget(pContent);
|
||||
pMainLayout->addStretch(1);
|
||||
pMainLayout->addWidget(createFooter());
|
||||
}
|
||||
|
||||
// 设置对话框的主布局
|
||||
this->setLayout(mainLayout);
|
||||
QWidget* nmDeleteConfirmationDlg::createFooter()
|
||||
{
|
||||
QWidget* pFooter = new QWidget(this);
|
||||
pFooter->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
|
||||
QHBoxLayout* pLayout = new QHBoxLayout(pFooter);
|
||||
pLayout->setContentsMargins(4, 5, 4, 5);
|
||||
pLayout->setSpacing(8);
|
||||
pLayout->addStretch(1);
|
||||
QDialogButtonBox* pButtons = new QDialogButtonBox(
|
||||
QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, pFooter);
|
||||
QPushButton* pConfirmButton = pButtons->button(QDialogButtonBox::Ok);
|
||||
QPushButton* pCancelButton = pButtons->button(QDialogButtonBox::Cancel);
|
||||
pConfirmButton->setText(tr("Delete"));
|
||||
pConfirmButton->setIcon(zxLoadIcon("NmDelete"));
|
||||
pConfirmButton->setDefault(false);
|
||||
pCancelButton->setText(tr("Cancel"));
|
||||
pCancelButton->setIcon(zxLoadIcon("Cancel"));
|
||||
pCancelButton->setDefault(true);
|
||||
pCancelButton->setFocus(Qt::OtherFocusReason);
|
||||
pLayout->addWidget(pButtons);
|
||||
connect(pButtons, SIGNAL(accepted()), this, SLOT(accept()));
|
||||
connect(pButtons, SIGNAL(rejected()), this, SLOT(reject()));
|
||||
return pFooter;
|
||||
}
|
||||
|
||||
@ -1,39 +1,83 @@
|
||||
#include "nmSwitchOutlineConfirmationDlg.h"
|
||||
#include "ZxBaseUtil.h"
|
||||
|
||||
#include <QVBoxLayout>
|
||||
#include <QDialogButtonBox>
|
||||
#include <QHBoxLayout>
|
||||
#include <QLabel>
|
||||
#include <QPushButton>
|
||||
#include <QHBoxLayout>
|
||||
|
||||
#include <QSizePolicy>
|
||||
#include <QStyle>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
nmSwitchOutlineConfirmationDlg::nmSwitchOutlineConfirmationDlg() {
|
||||
this->initUI();
|
||||
this->resize(250,80);
|
||||
nmSwitchOutlineConfirmationDlg::nmSwitchOutlineConfirmationDlg(
|
||||
const QString& sCurrentType, const QString& sTargetType, QWidget* pParent)
|
||||
: iDlgBase(pParent)
|
||||
{
|
||||
createUi(sCurrentType, sTargetType);
|
||||
// 按提示文字、图标和按钮计算初始尺寸,避免短提示右侧出现额外留白。
|
||||
adjustSize();
|
||||
}
|
||||
|
||||
void nmSwitchOutlineConfirmationDlg::initUI() {
|
||||
// 设置对话框的窗口标题
|
||||
this->setWindowTitle(tr("confirm"));
|
||||
|
||||
// 创建布局和控件
|
||||
QVBoxLayout *mainLayout = new QVBoxLayout(this);
|
||||
QLabel *messageLabel = new QLabel(tr("Are you sure you want to switch outline?"), this);
|
||||
mainLayout->addWidget(messageLabel);
|
||||
void nmSwitchOutlineConfirmationDlg::createUi(
|
||||
const QString& sCurrentType, const QString& sTargetType)
|
||||
{
|
||||
const bool bRedraw = sCurrentType == sTargetType;
|
||||
setWindowTitle(bRedraw ? tr("Redraw boundary") : tr("Change boundary"));
|
||||
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
||||
setModal(true);
|
||||
// Esc 和取消按钮均只返回拒绝结果,不执行任何删除或边界切换操作。
|
||||
setIgnoreEsc(false);
|
||||
|
||||
// 创建按钮
|
||||
QHBoxLayout *buttonLayout = new QHBoxLayout;
|
||||
QPushButton *yesButton = new QPushButton(tr("Yes"), this);
|
||||
QPushButton *noButton = new QPushButton(tr("No"), this);
|
||||
QVBoxLayout* pMainLayout = new QVBoxLayout(this);
|
||||
pMainLayout->setContentsMargins(12, 10, 12, 0);
|
||||
pMainLayout->setSpacing(10);
|
||||
|
||||
// 连接按钮的点击信号
|
||||
connect(yesButton, SIGNAL(clicked()), this, SLOT(accept()));
|
||||
connect(noButton, SIGNAL(clicked()), this, SLOT(reject()));
|
||||
QWidget* pContent = new QWidget(this);
|
||||
pContent->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
||||
QHBoxLayout* pContentLayout = new QHBoxLayout(pContent);
|
||||
pContentLayout->setContentsMargins(0, 0, 0, 0);
|
||||
pContentLayout->setSpacing(10);
|
||||
|
||||
buttonLayout->addStretch();
|
||||
buttonLayout->addWidget(yesButton);
|
||||
buttonLayout->addWidget(noButton);
|
||||
mainLayout->addLayout(buttonLayout);
|
||||
// 提示图标与确认文字并排展示,避免把只供核对的信息排成参数编辑表单。
|
||||
QLabel* pIconLabel = new QLabel(pContent);
|
||||
const int nIconSize = style()->pixelMetric(QStyle::PM_MessageBoxIconSize);
|
||||
pIconLabel->setPixmap(style()->standardIcon(QStyle::SP_MessageBoxQuestion).pixmap(nIconSize, nIconSize));
|
||||
pContentLayout->addWidget(pIconLabel, 0, Qt::AlignTop);
|
||||
const QString sMessage = bRedraw
|
||||
? tr("Redraw %1?").arg(sCurrentType)
|
||||
: tr("Replace %1 with %2 and start drawing?").arg(sCurrentType, sTargetType);
|
||||
QLabel* pMessageLabel = new QLabel(sMessage, pContent);
|
||||
// 名称中的尖括号等字符按原文显示,不被解释为富文本;长文字随窗口换行。
|
||||
pMessageLabel->setTextFormat(Qt::PlainText);
|
||||
pMessageLabel->setWordWrap(true);
|
||||
pMessageLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
|
||||
pContentLayout->addWidget(pMessageLabel, 1);
|
||||
pMainLayout->addWidget(pContent);
|
||||
pMainLayout->addStretch(1);
|
||||
pMainLayout->addWidget(createFooter());
|
||||
}
|
||||
|
||||
// 设置对话框的主布局
|
||||
this->setLayout(mainLayout);
|
||||
QWidget* nmSwitchOutlineConfirmationDlg::createFooter()
|
||||
{
|
||||
QWidget* pFooter = new QWidget(this);
|
||||
pFooter->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
|
||||
QHBoxLayout* pLayout = new QHBoxLayout(pFooter);
|
||||
pLayout->setContentsMargins(4, 5, 4, 5);
|
||||
pLayout->setSpacing(8);
|
||||
pLayout->addStretch(1);
|
||||
QDialogButtonBox* pButtons = new QDialogButtonBox(
|
||||
QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, pFooter);
|
||||
QPushButton* pConfirmButton = pButtons->button(QDialogButtonBox::Ok);
|
||||
QPushButton* pCancelButton = pButtons->button(QDialogButtonBox::Cancel);
|
||||
pConfirmButton->setText(tr("Start drawing"));
|
||||
pConfirmButton->setIcon(zxLoadIcon("OK"));
|
||||
pConfirmButton->setDefault(false);
|
||||
pCancelButton->setText(tr("Cancel"));
|
||||
pCancelButton->setIcon(zxLoadIcon("Cancel"));
|
||||
pCancelButton->setDefault(true);
|
||||
pCancelButton->setFocus(Qt::OtherFocusReason);
|
||||
pLayout->addWidget(pButtons);
|
||||
connect(pButtons, SIGNAL(accepted()), this, SLOT(accept()));
|
||||
connect(pButtons, SIGNAL(rejected()), this, SLOT(reject()));
|
||||
return pFooter;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue