GridFrame/source/createEditor.cpp

76 lines
1.9 KiB
C++
Raw Normal View History

2026-03-23 11:11:55 +08:00
#include <QPushButton>
#include <QMessageBox>
#include "createEditor.h"
#include "projectManager.h"
#include "ui_createEditor.h"
2026-05-18 19:12:28 +08:00
#include "titleBar.h"
2026-05-19 11:14:04 +08:00
#include "diagramView.h"
2026-03-23 11:11:55 +08:00
2026-05-19 11:14:04 +08:00
CreateEditor::CreateEditor(QWidget *parent,DiagramView* p)
2026-03-23 11:11:55 +08:00
: QDialog(parent)
, ui(new Ui::createEditor)
2026-05-19 11:14:04 +08:00
, m_pView(p)
2026-03-23 11:11:55 +08:00
{
ui->setupUi(this);
2026-05-19 11:14:04 +08:00
setWindowModality(Qt::ApplicationModal);
2026-03-23 11:11:55 +08:00
this->setWindowFlags(Qt::FramelessWindowHint | windowFlags());
initial();
}
CreateEditor::~CreateEditor()
{
delete ui;
}
void CreateEditor::initial()
{
2026-05-18 19:12:28 +08:00
m_titleBar = new TitleBar(this);
m_titleBar->setTitle("新建");
ui->verticalLayout->insertWidget(0,m_titleBar);
2026-03-23 11:11:55 +08:00
connect(ui->btn_ok,&QPushButton::clicked,this,&CreateEditor::onOkClicked);
connect(ui->btn_cancel,&QPushButton::clicked,this,&CreateEditor::onCancelClicked);
}
void CreateEditor::showDlg()
{
show();
ui->le_name->clear();
}
void CreateEditor::onOkClicked()
{
2026-05-19 11:14:04 +08:00
bool val = m_pView->projectExist();
if(val){
QMessageBox msgBox;
msgBox.setText(QString::fromWCharArray(L"提示"));
msgBox.setInformativeText(QString::fromWCharArray(L"该操作将导致未保存数据丢失,是否继续"));
msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
msgBox.setDefaultButton(QMessageBox::Ok);
int ret = msgBox.exec();
switch (ret) {
case QMessageBox::Ok:
break;
case QMessageBox::Cancel:
return;
break;
default:
// should never be reached
break;
}
}
emit projectCreated();
2026-03-23 11:11:55 +08:00
bool res = ProjectManager::instance().createEditorProject(ui->le_name->text());
if(res){
QMessageBox::information(NULL, QString("提示"), QString::fromWCharArray(L"项目名已存在"));
return;
}
hide();
}
void CreateEditor::onCancelClicked()
{
hide();
}