12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- #include "RenameWidget.h"
- #include <Widgets/Button.h>
- #include <Widgets/LineEdit.h>
- #include <QBoxLayout>
- #include <QLabel>
- RenameWidget::RenameWidget(QWidget *parent) : QDialog(parent)
- {
- initWindow();
- initialize();
- initLayout();
- connectSignalsAndSlots();
- }
- void RenameWidget::clearInputs()
- {
- m_nameLineEdit->clear();
- }
- void RenameWidget::initWindow()
- {
- setWindowTitle("修改工程名称");
- setModal(true);
- setWindowFlags(Qt::Dialog);
- setWindowFlag(Qt::WindowContextHelpButtonHint, false);
- resize(350, 180);
- }
- void RenameWidget::initialize()
- {
- m_vBoxLayout = new QVBoxLayout(this);
- m_oldNameLayout = new QHBoxLayout();
- m_oldNameLabel = new QLabel(this);
- m_oldNameLabel->setObjectName("oldNameLabel");
- m_oldNameLabel->setText("原名称:");
- m_oldNameValueLabel = new QLabel(this);
- m_oldNameValueLabel->setObjectName("oldNameValueLabel");
- m_oldNameValueLabel->setText("工程1");
- m_nameLineEdit = new LineEdit(this);
- m_nameLineEdit->setPlaceholderText("请输入新工程名");
- m_buttonLayout = new QHBoxLayout();
- m_confirmButton = new PushButton("确定", this);
- m_cancelButton = new PushButton("取消", this);
- setStyleSheet("QLabel {color:rgb(88,88,88); font-size:14px}");
- }
- void RenameWidget::initLayout()
- {
- m_vBoxLayout->setMargin(20);
- m_vBoxLayout->addLayout(m_oldNameLayout);
- m_oldNameLayout->addWidget(m_oldNameLabel);
- m_oldNameLayout->addWidget(m_oldNameValueLabel);
- m_oldNameLayout->addStretch();
- m_vBoxLayout->addSpacing(10);
- m_vBoxLayout->addWidget(m_nameLineEdit);
- m_vBoxLayout->addStretch();
- m_vBoxLayout->addLayout(m_buttonLayout);
- m_buttonLayout->addStretch();
- m_buttonLayout->addWidget(m_confirmButton);
- m_buttonLayout->addWidget(m_cancelButton);
- }
- void RenameWidget::connectSignalsAndSlots()
- {
- connect(m_confirmButton, &ToolButton::clicked, this, &RenameWidget::slotConfirmClicked);
- connect(m_cancelButton, &ToolButton::clicked, this, &RenameWidget::slotCancelClicked);
- }
- void RenameWidget::updateRenameButtonState() { }
- void RenameWidget::slotTextChanged(const QString &) { }
- void RenameWidget::slotConfirmClicked()
- {
- close();
- }
- void RenameWidget::slotCancelClicked()
- {
- close();
- }
|