123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135 |
- #include "launchpage.h"
- #include "mainwindow.h"
- #include "ui_launchpage.h"
- #include <iostream>
- LaunchPage::LaunchPage(QWidget *parent) :
- QMainWindow(parent),
- ui(new Ui::LaunchPage)
- {
- ui->setupUi(this);
- setWindowTitle("启动页");
- setWindowIcon(QIcon(":/icon/doc/icons/pvIcon.svg"));
- QString imageFile(":/icon/doc/icons/pvIcon.svg");
- QImage *image = new QImage;
- if(!(image->load(imageFile)))
- {
- std::cout << "load image error!!!"<< std::endl;
- delete image;
- return;
- }
- ui->imagelabel->setPixmap(QPixmap::fromImage(*image));
- ui->createExample ->setChecked(true);
- setStyleSheet(lanchStyle);
- connect(ui->cancelButton,&QPushButton::clicked,this,&QMainWindow::close);
- }
- LaunchPage::~LaunchPage()
- {
- delete ui;
- }
- void LaunchPage::on_confirmButton_clicked()
- {
- mSetName = ui->setName->text();
- if((!mSetName.isEmpty() && !mChosePath.isEmpty() )||(ui->openExample->isChecked()&& !mFileName.isEmpty() && !mFilePath.isEmpty()))
- {
- projectManager* pro = new projectManager();
- if(ui->openExample->isChecked())
- {
- pro->mName = mFileName.toStdString();
- pro->mPath = mFilePath.toStdString();
- pro->queryProject(pro->mId);
- }
- else if(ui->createExample->isChecked())
- {
- pro->mName = mSetName.toStdString();
- pro->mPath = mChosePath.toStdString();
- pro->createProject(pro->mId,pro->mName,pro->mDesc,pro->mPath);
- }
- MainWindow* w = new MainWindow();
- w->show();
- this->close();
- }
- else
- {
- QMessageBox mes(this);
- mes.warning(this,"warning","还未创建或打开算例",QDialogButtonBox::Ok,QDialogButtonBox::NoButton);
- }
- }
- void LaunchPage::on_openExample_toggled(bool checked)
- {
- if(checked)
- {
- mOpenDialog = new QFileDialog(this);
- mOpenDialog->setModal(QFileDialog::ExistingFile);
- QString FileName = mOpenDialog->getOpenFileName(this,"打开算例","./","ALL(*.*)、Images(*.png *.jpg)、CPP文件(*.cpp)");
- int temp = FileName.lastIndexOf("/");
- mFileName = FileName.right(FileName.length()-temp-1);
- mFilePath = FileName.left(temp+1);
- ui->readName->setText(mFileName);
- ui->readPath->setText(mFilePath);
- if(!mFileName.isEmpty() && !mFilePath.isEmpty())
- {
- ui->openLabel1->show();
- ui->openLabel2->show();
- ui->readName->show();
- ui->readPath->show();
- }
- else
- {
- ui->createExample ->setChecked(true);
- }
- }
- else
- {
- ui->openLabel1->hide();
- ui->openLabel2->hide();
- ui->readName->hide();
- ui->readPath->hide();
- ui->setName->show();
- ui->setPath->show();
- ui->browseButton->show();
- ui->label->show();
- ui->label_2->show();
- }
- }
- void LaunchPage::on_browseButton_clicked()
- {
- mViewDialog = new QFileDialog(this);
- mChosePath = mViewDialog->getExistingDirectory(this,"浏览","./");
- ui->setPath->setText(mChosePath);
- }
- void LaunchPage::on_createExample_toggled(bool checked)
- {
- if(checked)
- {
- ui->openLabel1->hide();
- ui->openLabel2->hide();
- ui->readName->hide();
- ui->readPath->hide();
- }
- else
- {
- ui->setName->hide();
- ui->setPath->hide();
- ui->browseButton->hide();
- ui->label->hide();
- ui->label_2->hide();
- }
- }
|