fix(Nm): 统一删除图元和边界切换确认界面

- 使用纯文本展示图元名称、类型及边界切换信息
- 统一提示图标、底部按钮和自适应布局,减少多余留白
- 补充中文注释和翻译,清理旧确认文案
- 保持原有删除及边界绘制流程
feature/Dialog-Unification-20261106
lh 1 week ago
parent 06d1dfb658
commit 6c26313713

Binary file not shown.

@ -2449,22 +2449,11 @@ No valid error was returned; keep the last accepted result and reduce the step.<
</context>
<context>
<name>nmDeleteConfirmationDlg</name>
<message>
<source>confirm</source>
<translation type="unfinished">确认信息</translation>
</message>
<message>
<source>Do you confirm the deletion of the selected fault?</source>
<translation type="unfinished">您确认要删除该内容吗?</translation>
</message>
<message>
<source>Yes</source>
<translation type="unfinished">确定</translation>
</message>
<message>
<source>No</source>
<translation type="unfinished">取消</translation>
</message>
<message><source>Delete object</source><translation>删除图元</translation></message>
<message><source>Delete %1 "%2"?</source><translation>确定删除%1“%2”?</translation></message>
<message><source>Unnamed object</source><translation>未命名图元</translation></message>
<message><source>Delete</source><translation>删除</translation></message>
<message><source>Cancel</source><translation>取消</translation></message>
</context>
<context>
<name>nmGuiPlot</name>
@ -3907,22 +3896,12 @@ Supported types: Vertical, Vertical Fractured, and Horizontal Multi-Fractured We
</context>
<context>
<name>nmSwitchOutlineConfirmationDlg</name>
<message>
<source>confirm</source>
<translation type="unfinished">确认信息</translation>
</message>
<message>
<source>Are you sure you want to switch outline?</source>
<translation type="unfinished">您确认要切换边界吗?</translation>
</message>
<message>
<source>Yes</source>
<translation type="unfinished">确定</translation>
</message>
<message>
<source>No</source>
<translation type="unfinished">取消</translation>
</message>
<message><source>Redraw boundary</source><translation>重新绘制边界</translation></message>
<message><source>Change boundary</source><translation>更换边界</translation></message>
<message><source>Redraw %1?</source><translation>确定重新绘制%1?</translation></message>
<message><source>Replace %1 with %2 and start drawing?</source><translation>确定将%1更换为%2并开始绘制?</translation></message>
<message><source>Start drawing</source><translation>开始绘制</translation></message>
<message><source>Cancel</source><translation>取消</translation></message>
</context>
<context>
<name>nmTranslationManager</name>
@ -9242,4 +9221,23 @@ Average pressure in contour: %2 MPa</source>
<translation>第 %1 行的几何或物性参数无效。</translation>
</message>
</context>
<context>
<name>nmSubWxsPlotDialogController</name>
<message><source>Well</source><translation>井</translation></message>
<message><source>Fault</source><translation>断层</translation></message>
<message><source>Fracture</source><translation>裂缝</translation></message>
<message><source>Rectangular boundary</source><translation>矩形边界</translation></message>
<message><source>Polygonal boundary</source><translation>多边形边界</translation></message>
<message><source>Circular boundary</source><translation>圆形边界</translation></message>
<message><source>Measurement line</source><translation>测量线</translation></message>
<message><source>Measuring scale</source><translation>比例尺</translation></message>
<message><source>Composite region</source><translation>复合区</translation></message>
<message><source>Region marker</source><translation>区域标记</translation></message>
<message><source>Point</source><translation>点</translation></message>
<message><source>Line</source><translation>线</translation></message>
<message><source>Polygon</source><translation>多边形</translation></message>
<message><source>Rectangle</source><translation>矩形</translation></message>
<message><source>Circle</source><translation>圆形</translation></message>
<message><source>Object</source><translation>图元</translation></message>
</context>
</TS>

@ -57,11 +57,15 @@ public:
// 创建坐标显示弹窗
virtual QWidget* createPointerPosDialog(QWidget* pParent) = 0;
// 确认是否删除图元
virtual bool confirmDeleteObject() = 0;
/** @brief 根据图元名称和稳定类型标识请求删除确认,不修改图元或业务数据。 */
virtual bool confirmDeleteObject(QWidget* pParent,
const QString& sObjectName,
const QString& sObjectTag) = 0;
// 确认是否切换边界类型
virtual bool confirmSwitchOutline() = 0;
/** @brief 显示当前和目标边界类型;确认后的删除及绘制时机仍由调用方决定。 */
virtual bool confirmSwitchOutline(QWidget* pParent,
const QString& sCurrentTag,
const QString& sTargetTag) = 0;
/**
* @brief 打开井编辑窗口并返回确认后的独立井副本。

@ -4,15 +4,28 @@
#include "iDlgBase.h"
#include "nmSubWxs_global.h"
#include <QString>
/** @brief 展示待删除图元的名称和类型,仅返回用户确认结果。 */
class NM_SUB_WXS_EXPORT nmDeleteConfirmationDlg : public iDlgBase
{
Q_OBJECT
Q_OBJECT
public:
nmDeleteConfirmationDlg();
/** @brief 按传入的名称和类型创建删除确认窗口,父窗口为所属画布。 */
explicit nmDeleteConfirmationDlg(
const QString& sObjectName,
const QString& sObjectType,
QWidget* pParent = nullptr);
private:
void initUI();
Q_DISABLE_COPY(nmDeleteConfirmationDlg)
/** @brief 创建图标、可换行的纯文本确认信息及统一底栏,尺寸随内容与主题调整。 */
void createUi(const QString& sObjectName,
const QString& sObjectType);
/** @brief 创建确认和取消按钮,默认焦点停留在取消,操作结果由 accept/reject 返回。 */
QWidget* createFooter();
};
#endif // NMWXMEASURINGSCALEDLG_H
#endif // NMDELETECONFIRMATIONDLG_H

@ -20,16 +20,23 @@ public:
// 创建坐标显示弹窗
virtual QWidget* createPointerPosDialog(QWidget* pParent) override;
// 确认是否删除图元
virtual bool confirmDeleteObject() override;
/** @brief 将稳定图元类型翻译为展示名称,在所属画布上打开删除确认窗口。 */
virtual bool confirmDeleteObject(QWidget* pParent,
const QString& sObjectName,
const QString& sObjectTag) override;
// 确认是否切换边界类型
virtual bool confirmSwitchOutline() override;
/** @brief 展示当前和目标边界类型,保留原有确认、取消返回语义。 */
virtual bool confirmSwitchOutline(QWidget* pParent,
const QString& sCurrentTag,
const QString& sTargetTag) override;
/** @brief 执行新版编辑井窗口并转移确认后的工作副本。 */
virtual bool editWell(QWidget* pParent, const nmWellEditContext& oContext,
nmDataWellBase*& pModifiedWell) override;
private:
/** @brief 控制器由单例入口创建,不持有当前图元或分析数据。 */
nmSubWxsPlotDialogController() {}
/** @brief 将图元稳定标识映射为界面类型名称,未知类型回退为通用图元。 */
static QString objectTypeText(const QString& sObjectTag);
};

@ -4,15 +4,28 @@
#include "iDlgBase.h"
#include "nmSubWxs_global.h"
#include <QString>
/** @brief 展示当前和目标边界类型,绘制流程仍由绘图层负责。 */
class NM_SUB_WXS_EXPORT nmSwitchOutlineConfirmationDlg : public iDlgBase
{
Q_OBJECT
Q_OBJECT
public:
nmSwitchOutlineConfirmationDlg();
/** @brief 创建更换或重新绘制边界的确认窗口,仅保存展示所需信息。 */
explicit nmSwitchOutlineConfirmationDlg(
const QString& sCurrentType,
const QString& sTargetType,
QWidget* pParent = nullptr);
private:
void initUI();
Q_DISABLE_COPY(nmSwitchOutlineConfirmationDlg)
/** @brief 创建图标、可换行的纯文本确认信息及统一底栏,尺寸随内容与主题调整。 */
void createUi(const QString& sCurrentType,
const QString& sTargetType);
/** @brief 创建确认和取消按钮,默认焦点停留在取消,操作结果由 accept/reject 返回。 */
QWidget* createFooter();
};
#endif // NMSWITCHOUTLINECONFIRMATIONDLG_H

@ -1456,7 +1456,9 @@ void nmGuiPlot::slotDeleteOneObj(QString sName, void* obj)
nmPlotDialogContextProvider* pDialogProvider = nmPlotDialogContext::provider();
if(pDialogProvider != nullptr && pDialogProvider->confirmDeleteObject()) {
// 只传递展示快照及所属画布,弹窗不接管图元;确认后的删除路径保持原样。
if(pDialogProvider != nullptr && pDialogProvider->confirmDeleteObject(
this, nmObj->getName(), nmObj->getTagName())) {
nmObjDeleteTool* pDeleteTool = static_cast<nmObjDeleteTool*>(obj);
if(pDeleteTool) { // 确保 obj 不是空指针

@ -103,6 +103,11 @@ bool nmGuiPlotCmdHelper::runAction(QString sAction) {
sAction == "nmInsertObjRectOutline" || \
sAction == "nmInsertObjRoundOutline" )
{
// 目标类型仅用于确认窗口展示,不改变确认后先删除旧边界再进入绘制的流程。
const QString sTargetOutlineTag = sAction == "nmInsertObjRectOutline"
? QLatin1String("nObjRectOutline")
: (sAction == "nmInsertObjRoundOutline"
? QLatin1String("nObjRoundOutline") : QLatin1String("nObjPolygonOutline"));
int objCount = pPlot->getObjCount();
for(int i = 0; i < objCount; i++) {
@ -122,7 +127,8 @@ bool nmGuiPlotCmdHelper::runAction(QString sAction) {
// 检查是否为矩形轮廓
if (_isSame("nObjRectOutline", nmObj->getTagName())) {
nmPlotDialogContextProvider* pDialogProvider = nmPlotDialogContext::provider();
if (pDialogProvider != nullptr && pDialogProvider->confirmSwitchOutline()) {
if (pDialogProvider != nullptr && pDialogProvider->confirmSwitchOutline(
pNmPlot, nmObj->getTagName(), sTargetOutlineTag)) {
// 删除图元
pPlot->removeObjByName(nmObj->getName());
nmObj->removeData();
@ -134,7 +140,8 @@ bool nmGuiPlotCmdHelper::runAction(QString sAction) {
// 检查是否为多边形轮廓
if (_isSame("nObjPolygonOutline", nmObj->getTagName())) {
nmPlotDialogContextProvider* pDialogProvider = nmPlotDialogContext::provider();
if (pDialogProvider != nullptr && pDialogProvider->confirmSwitchOutline()) {
if (pDialogProvider != nullptr && pDialogProvider->confirmSwitchOutline(
pNmPlot, nmObj->getTagName(), sTargetOutlineTag)) {
// 删除图元
pPlot->removeObjByName(nmObj->getName());
nmObj->removeData();
@ -146,7 +153,8 @@ bool nmGuiPlotCmdHelper::runAction(QString sAction) {
// 检查是否为圆形轮廓
if (_isSame("nObjRoundOutline", nmObj->getTagName())) {
nmPlotDialogContextProvider* pDialogProvider = nmPlotDialogContext::provider();
if (pDialogProvider != nullptr && pDialogProvider->confirmSwitchOutline()) {
if (pDialogProvider != nullptr && pDialogProvider->confirmSwitchOutline(
pNmPlot, nmObj->getTagName(), sTargetOutlineTag)) {
// 删除图元
pPlot->removeObjByName(nmObj->getName());
nmObj->removeData();

@ -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;
}

@ -8,6 +8,7 @@
#include "nmWxPointerPosDlg.h"
#include "nmWxWellEditor.h"
#include <QCoreApplication>
#include <QMessageBox>
namespace
@ -50,18 +51,48 @@ QWidget* nmSubWxsPlotDialogController::createPointerPosDialog(QWidget* pParent)
return new nmWxPointerPosDlg(pParent);
}
// 确认是否删除图元
bool nmSubWxsPlotDialogController::confirmDeleteObject()
QString nmSubWxsPlotDialogController::objectTypeText(const QString& sObjectTag)
{
nmDeleteConfirmationDlg dialog;
return dialog.exec() == QDialog::Accepted;
// 类型标识只在界面适配层解释,绘图层不依赖具体对话框或已翻译的文本。
const char* const arrTypeTexts[][2] = {
{ "nObjPointWell", QT_TRANSLATE_NOOP("nmSubWxsPlotDialogController", "Well") },
{ "nObjLineFault", QT_TRANSLATE_NOOP("nmSubWxsPlotDialogController", "Fault") },
{ "nObjLineFracture", QT_TRANSLATE_NOOP("nmSubWxsPlotDialogController", "Fracture") },
{ "nObjRectOutline", QT_TRANSLATE_NOOP("nmSubWxsPlotDialogController", "Rectangular boundary") },
{ "nObjPolygonOutline", QT_TRANSLATE_NOOP("nmSubWxsPlotDialogController", "Polygonal boundary") },
{ "nObjRoundOutline", QT_TRANSLATE_NOOP("nmSubWxsPlotDialogController", "Circular boundary") },
{ "nObjLineMeasure", QT_TRANSLATE_NOOP("nmSubWxsPlotDialogController", "Measurement line") },
{ "nObjLineMeasuringScale", QT_TRANSLATE_NOOP("nmSubWxsPlotDialogController", "Measuring scale") },
{ "nObjRegion", QT_TRANSLATE_NOOP("nmSubWxsPlotDialogController", "Composite region") },
{ "nObjRegionMark", QT_TRANSLATE_NOOP("nmSubWxsPlotDialogController", "Region marker") },
{ "nObjPoint", QT_TRANSLATE_NOOP("nmSubWxsPlotDialogController", "Point") },
{ "nObjLine", QT_TRANSLATE_NOOP("nmSubWxsPlotDialogController", "Line") },
{ "nObjPolygon", QT_TRANSLATE_NOOP("nmSubWxsPlotDialogController", "Polygon") },
{ "nObjRect", QT_TRANSLATE_NOOP("nmSubWxsPlotDialogController", "Rectangle") },
{ "nObjRound", QT_TRANSLATE_NOOP("nmSubWxsPlotDialogController", "Circle") }
};
const int nTypeCount = sizeof(arrTypeTexts) / sizeof(arrTypeTexts[0]);
for(int nType = 0; nType < nTypeCount; ++nType) {
if(sObjectTag.compare(QLatin1String(arrTypeTexts[nType][0]), Qt::CaseInsensitive) == 0) {
return QCoreApplication::translate("nmSubWxsPlotDialogController", arrTypeTexts[nType][1]);
}
}
return QCoreApplication::translate("nmSubWxsPlotDialogController", "Object");
}
bool nmSubWxsPlotDialogController::confirmDeleteObject(
QWidget* pParent, const QString& sObjectName, const QString& sObjectTag)
{
nmDeleteConfirmationDlg oDialog(sObjectName, objectTypeText(sObjectTag), pParent);
return oDialog.exec() == QDialog::Accepted;
}
// 确认是否切换边界类型
bool nmSubWxsPlotDialogController::confirmSwitchOutline()
bool nmSubWxsPlotDialogController::confirmSwitchOutline(
QWidget* pParent, const QString& sCurrentTag, const QString& sTargetTag)
{
nmSwitchOutlineConfirmationDlg dialog;
return dialog.exec() == QDialog::Accepted;
nmSwitchOutlineConfirmationDlg oDialog(
objectTypeText(sCurrentTag), objectTypeText(sTargetTag), pParent);
return oDialog.exec() == QDialog::Accepted;
}
bool nmSubWxsPlotDialogController::editWell(QWidget* pParent,

@ -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…
Cancel
Save