diff --git a/Bin/Config/Lang/cn/nmNum_cn.qm b/Bin/Config/Lang/cn/nmNum_cn.qm index dfb74b52..10778061 100644 Binary files a/Bin/Config/Lang/cn/nmNum_cn.qm and b/Bin/Config/Lang/cn/nmNum_cn.qm differ diff --git a/Bin/Config/Lang/cn/nmNum_cn.ts b/Bin/Config/Lang/cn/nmNum_cn.ts index 692dd6f4..026cd99c 100644 --- a/Bin/Config/Lang/cn/nmNum_cn.ts +++ b/Bin/Config/Lang/cn/nmNum_cn.ts @@ -2449,22 +2449,11 @@ No valid error was returned; keep the last accepted result and reduce the step.< nmDeleteConfirmationDlg - - confirm - 确认信息 - - - Do you confirm the deletion of the selected fault? - 您确认要删除该内容吗? - - - Yes - 确定 - - - No - 取消 - + Delete object删除图元 + Delete %1 "%2"?确定删除%1“%2”? + Unnamed object未命名图元 + Delete删除 + Cancel取消 nmGuiPlot @@ -3907,22 +3896,12 @@ Supported types: Vertical, Vertical Fractured, and Horizontal Multi-Fractured We nmSwitchOutlineConfirmationDlg - - confirm - 确认信息 - - - Are you sure you want to switch outline? - 您确认要切换边界吗? - - - Yes - 确定 - - - No - 取消 - + Redraw boundary重新绘制边界 + Change boundary更换边界 + Redraw %1?确定重新绘制%1? + Replace %1 with %2 and start drawing?确定将%1更换为%2并开始绘制? + Start drawing开始绘制 + Cancel取消 nmTranslationManager @@ -9242,4 +9221,23 @@ Average pressure in contour: %2 MPa 第 %1 行的几何或物性参数无效。 + + nmSubWxsPlotDialogController + Well井 + Fault断层 + Fracture裂缝 + Rectangular boundary矩形边界 + Polygonal boundary多边形边界 + Circular boundary圆形边界 + Measurement line测量线 + Measuring scale比例尺 + Composite region复合区 + Region marker区域标记 + Point点 + Line线 + Polygon多边形 + Rectangle矩形 + Circle圆形 + Object图元 + diff --git a/Include/nmNum/nmPlot/nmPlotDialogContextProvider.h b/Include/nmNum/nmPlot/nmPlotDialogContextProvider.h index 2e771f9d..15f44b70 100644 --- a/Include/nmNum/nmPlot/nmPlotDialogContextProvider.h +++ b/Include/nmNum/nmPlot/nmPlotDialogContextProvider.h @@ -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 打开井编辑窗口并返回确认后的独立井副本。 diff --git a/Include/nmNum/nmSubWxs/nmDeleteConfirmationDlg.h b/Include/nmNum/nmSubWxs/nmDeleteConfirmationDlg.h index 54228834..51d03292 100644 --- a/Include/nmNum/nmSubWxs/nmDeleteConfirmationDlg.h +++ b/Include/nmNum/nmSubWxs/nmDeleteConfirmationDlg.h @@ -4,15 +4,28 @@ #include "iDlgBase.h" #include "nmSubWxs_global.h" +#include + +/** @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 diff --git a/Include/nmNum/nmSubWxs/nmSubWxsPlotDialogController.h b/Include/nmNum/nmSubWxs/nmSubWxsPlotDialogController.h index 57382e7b..22c435b6 100644 --- a/Include/nmNum/nmSubWxs/nmSubWxsPlotDialogController.h +++ b/Include/nmNum/nmSubWxs/nmSubWxsPlotDialogController.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); }; diff --git a/Include/nmNum/nmSubWxs/nmSwitchOutlineConfirmationDlg.h b/Include/nmNum/nmSubWxs/nmSwitchOutlineConfirmationDlg.h index 5af5881f..5a4d6076 100644 --- a/Include/nmNum/nmSubWxs/nmSwitchOutlineConfirmationDlg.h +++ b/Include/nmNum/nmSubWxs/nmSwitchOutlineConfirmationDlg.h @@ -4,15 +4,28 @@ #include "iDlgBase.h" #include "nmSubWxs_global.h" +#include + +/** @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 diff --git a/Src/nmNum/nmPlot/nmGuiPlot.cpp b/Src/nmNum/nmPlot/nmGuiPlot.cpp index 5ac7c9ab..578e32f8 100644 --- a/Src/nmNum/nmPlot/nmGuiPlot.cpp +++ b/Src/nmNum/nmPlot/nmGuiPlot.cpp @@ -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(obj); if(pDeleteTool) { // 确保 obj 不是空指针 diff --git a/Src/nmNum/nmPlot/nmGuiPlotCmdHelper.cpp b/Src/nmNum/nmPlot/nmGuiPlotCmdHelper.cpp index 35e879ba..7186c748 100644 --- a/Src/nmNum/nmPlot/nmGuiPlotCmdHelper.cpp +++ b/Src/nmNum/nmPlot/nmGuiPlotCmdHelper.cpp @@ -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(); diff --git a/Src/nmNum/nmSubWxs/nmDeleteConfirmationDlg.cpp b/Src/nmNum/nmSubWxs/nmDeleteConfirmationDlg.cpp index ca6b3add..45c8beba 100644 --- a/Src/nmNum/nmSubWxs/nmDeleteConfirmationDlg.cpp +++ b/Src/nmNum/nmSubWxs/nmDeleteConfirmationDlg.cpp @@ -1,39 +1,82 @@ #include "nmDeleteConfirmationDlg.h" +#include "ZxBaseUtil.h" -#include +#include +#include #include #include -#include - +#include +#include +#include -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; } diff --git a/Src/nmNum/nmSubWxs/nmSubWxsPlotDialogController.cpp b/Src/nmNum/nmSubWxs/nmSubWxsPlotDialogController.cpp index c20c1d00..a631c62d 100644 --- a/Src/nmNum/nmSubWxs/nmSubWxsPlotDialogController.cpp +++ b/Src/nmNum/nmSubWxs/nmSubWxsPlotDialogController.cpp @@ -8,6 +8,7 @@ #include "nmWxPointerPosDlg.h" #include "nmWxWellEditor.h" +#include #include 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, diff --git a/Src/nmNum/nmSubWxs/nmSwitchOutlineConfirmationDlg.cpp b/Src/nmNum/nmSubWxs/nmSwitchOutlineConfirmationDlg.cpp index 0db0fddb..83a1f67f 100644 --- a/Src/nmNum/nmSubWxs/nmSwitchOutlineConfirmationDlg.cpp +++ b/Src/nmNum/nmSubWxs/nmSwitchOutlineConfirmationDlg.cpp @@ -1,39 +1,83 @@ #include "nmSwitchOutlineConfirmationDlg.h" +#include "ZxBaseUtil.h" -#include +#include +#include #include #include -#include - +#include +#include +#include -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; }