fix(nmSubWxs): 统一包含井对话框底部操作按钮

- 增加带图标的帮助按钮并接入系统帮助
- 为确定和取消按钮增加平台标准图标
- 使用标准按钮框统一底部布局
- 移除标题栏帮助按钮并补充中文翻译
feature/nmNum-multi-gauge-record
lh 2 days ago
parent 64db611de3
commit 755ed34b17

@ -14,6 +14,8 @@
#include <QVector>
class nmDataAnalyzeManager;
class QDialogButtonBox;
class QToolButton;
/**
* @brief Include Other Wells
@ -76,7 +78,7 @@ private:
void initUI();
/** @brief 从所属数据管理器收集候选主动井并建立表格。 */
void setupTable();
/** @brief 创建确定和取消按钮。 */
/** @brief 创建帮助及带图标的确定、取消按钮。 */
void setupButtons();
/** @brief 组装表格与底部按钮布局。 */
void setupLayouts();
@ -104,6 +106,8 @@ private:
const WellDataRow& data) const;
private slots:
/** @brief 打开系统帮助文档。 */
void slotHelp();
/** @brief 把复选框状态同步回对应的 WellDataRow。 */
void onCheckBoxStateChanged(int state);
/** @brief 切换某一相使用的流量记录;其他已选相同步到同一记录。 */
@ -117,6 +121,8 @@ private:
/** @brief 当前对话框所属的数据管理器,不拥有对象。 */
nmDataAnalyzeManager* m_pDataManager;
QTableWidget* m_pTableWidget; ///< 其他有产量井及其数据摘要表格。
QToolButton* m_pFooterHelpButton; ///< 底部帮助命令。
QDialogButtonBox* m_pButtonBox; ///< 确定和取消按钮区。
QPushButton* m_pOkButton; ///< 提交当前勾选状态的确定按钮。
QPushButton* m_pCancelButton; ///< 放弃本次编辑的取消按钮。
QHBoxLayout* m_pButtonLayout; ///< 底部操作按钮布局。

@ -1,14 +1,17 @@
#include "nmWxIncludeOtherWells.h"
#include "nmDataAnalyzeManager.h"
#include "nmDataWellBase.h"
#include "ZxBaseUtil.h"
#include <QAbstractItemView>
#include <QApplication>
#include <QCheckBox>
#include <QDesktopWidget>
#include <QDialogButtonBox>
#include <QHBoxLayout>
#include <QStringList>
#include <QStyle>
#include <QToolButton>
#include <QWidget>
namespace
@ -244,6 +247,7 @@ nmWxIncludeOtherWells::nmWxIncludeOtherWells(
nmDataAnalyzeManager* pDataManager,
QWidget* pParent)
: iDlgBase(pParent), m_pDataManager(pDataManager), m_pTableWidget(nullptr),
m_pFooterHelpButton(nullptr), m_pButtonBox(nullptr),
m_pOkButton(nullptr), m_pCancelButton(nullptr),
m_pButtonLayout(nullptr), m_pMainLayout(nullptr)
{
@ -263,6 +267,7 @@ void nmWxIncludeOtherWells::initUI()
this->setupConnections();
this->setWindowTitle(tr("Include Other Wells"));
this->setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
// 初始尺寸跟随列宽和井数量,手动缩小时仍由滚动条保护表头及下拉内容。
this->setMinimumSize(720, 240);
this->adjustDialogSizeToTable();
@ -486,8 +491,9 @@ void nmWxIncludeOtherWells::adjustDialogSizeToTable()
int nBottom = 0;
m_pMainLayout->getContentsMargins(&nLeft, &nTop, &nRight, &nBottom);
const int nLayoutWidth = nLeft + nRight;
const int nButtonHeight = qMax(m_pOkButton->sizeHint().height(),
m_pCancelButton->sizeHint().height());
const int nButtonHeight = qMax(m_pFooterHelpButton->sizeHint().height(),
qMax(m_pOkButton->sizeHint().height(),
m_pCancelButton->sizeHint().height()));
const int nLayoutHeight = nTop + nBottom + nButtonHeight +
m_pMainLayout->spacing();
@ -845,16 +851,33 @@ QVector<WellDataRow> nmWxIncludeOtherWells::getWellData() const
void nmWxIncludeOtherWells::setupButtons()
{
m_pOkButton = new QPushButton(tr("OK"), this);
m_pCancelButton = new QPushButton(tr("Cancel"), this);
m_pFooterHelpButton = new QToolButton(this);
m_pFooterHelpButton->setText(tr("Help"));
m_pFooterHelpButton->setIcon(zxLoadIcon("Help"));
m_pFooterHelpButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
m_pFooterHelpButton->setAutoRaise(true);
m_pButtonBox = new QDialogButtonBox(
QDialogButtonBox::Ok | QDialogButtonBox::Cancel,
Qt::Horizontal, this);
m_pOkButton = m_pButtonBox->button(QDialogButtonBox::Ok);
m_pCancelButton = m_pButtonBox->button(QDialogButtonBox::Cancel);
if(m_pOkButton != nullptr) {
m_pOkButton->setIcon(zxLoadIcon("OK"));
m_pOkButton->setText(tr("OK"));
}
if(m_pCancelButton != nullptr) {
m_pCancelButton->setIcon(zxLoadIcon("Cancel"));
m_pCancelButton->setText(tr("Cancel"));
}
}
void nmWxIncludeOtherWells::setupLayouts()
{
m_pButtonLayout = new QHBoxLayout();
m_pButtonLayout->addWidget(m_pFooterHelpButton);
m_pButtonLayout->addStretch();
m_pButtonLayout->addWidget(m_pOkButton);
m_pButtonLayout->addWidget(m_pCancelButton);
m_pButtonLayout->addWidget(m_pButtonBox);
m_pMainLayout = new QVBoxLayout(this);
m_pMainLayout->addWidget(m_pTableWidget, 1);
@ -864,6 +887,12 @@ void nmWxIncludeOtherWells::setupLayouts()
void nmWxIncludeOtherWells::setupConnections()
{
connect(m_pOkButton, SIGNAL(clicked()), this, SLOT(accept()));
connect(m_pCancelButton, SIGNAL(clicked()), this, SLOT(reject()));
connect(m_pFooterHelpButton, SIGNAL(clicked()), this, SLOT(slotHelp()));
connect(m_pButtonBox, SIGNAL(accepted()), this, SLOT(accept()));
connect(m_pButtonBox, SIGNAL(rejected()), this, SLOT(reject()));
}
void nmWxIncludeOtherWells::slotHelp()
{
ZxBaseUtil::startHelp();
}

Loading…
Cancel
Save