123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156 |
- #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/min.png"));
- QString imageFile(":/icon/doc/icons/add.png");
- 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( //正常状态样式
- "QPushButton{"
- "background-color:rgba(0,191,255,50);"//背景色(也可以设置图片)
- "border-style:outset;" //边框样式(inset/outset)
- "border-width:4px;" //边框宽度像素
- "border-radius:10px;" //边框圆角半径像素
- "border-color:rgba(255,255,255,0);" //边框颜色
- // "font:bold 15px;" //字体,字体大小
- // "color:rgba(0,0,0,255);" //字体颜色
- "padding:7px;" //填衬
- "}"
- //鼠标按下样式
- "QPushButton:pressed{"
- "background-color:rgba(100,255,100,100);"
- "border-color:rgba(255,255,255,200);"
- "color:rgba(0,0,0,255);"
- "}"
- //界面背景色
- "QMainWindow{"
- "background-color:rgba(255,255,255,255);"
- "}"
- );
- 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();
- }
- }
|