📄 newprojdlg.cpp
字号:
#include "newprojdlg.h"#include "portdef.h"#include <qlayout.h>#include <qlabel.h>#include <qhbox.h>#include <qpushbutton.h>#include <qmessagebox.h>#include <qfileinfo.h>#include <qstring.h>#include "proj_cpp.xpm"#include "proj_c.xpm"#include "proj_java.xpm"NewProjDlg::NewProjDlg(QWidget *parent, const char *name) : QDialog(parent, name, true){ QVBoxLayout *vbox = new QVBoxLayout(this); vbox->setSpacing(5); QLabel *lblName = new QLabel("Project Name", this); editName = new QLineEdit(this); QLabel *lblRoot = new QLabel("Project Directory", this); editRoot = new QLineEdit(this); QLabel *lblAuthor = new QLabel("Author", this); editAuthor = new QLineEdit(this); QLabel *lblLang = new QLabel("Language", this); listLang = new QListBox(this); listLang->insertItem(QPixmap(const_cast<const char **>(proj_cpp)), "C++"); listLang->insertItem(QPixmap(const_cast<const char **>(proj_c)), "C"); listLang->insertItem(QPixmap(const_cast<const char **>(proj_java)), "Java"); listLang->setSelected(0, true); vbox->addWidget(lblName); vbox->addWidget(editName); vbox->addWidget(lblRoot); vbox->addWidget(editRoot); vbox->addWidget(lblAuthor); vbox->addWidget(editAuthor); vbox->addWidget(lblLang); vbox->addWidget(listLang); QHBox *hbox = new QHBox(this); hbox->setMaximumWidth(200); QPushButton *ok = new QPushButton("Create", hbox); ok->setDefault(true); QPushButton *cancel = new QPushButton("Cancel", hbox); vbox->addWidget(hbox); QObject::connect(ok, SIGNAL(clicked()), this, SLOT(verify())); QObject::connect(cancel, SIGNAL(clicked()), this, SLOT(reject())); setFixedWidth(400); setFixedHeight(250); setCaption("New Project");}int NewProjDlg::exec(){ return QDialog::exec();}void NewProjDlg::verify(){ QString msg = ""; if (editName->text() == "") { msg = "Missing project name."; QMessageBox::warning(this, "hIDE", msg); editName->setFocus(); return; } else if (editRoot->text() == "") { msg = "Missing project root directory."; QMessageBox::warning(this, "hIDE", msg); editRoot->setFocus(); return; } QFileInfo fi; fi.setFile(editRoot->text()); if (!fi.isDir()) { msg = (QString) fi.absFilePath() + " does not exist."; QMessageBox::warning(this, "hIDE", msg); editRoot->setFocus(); return; } QString fp = fi.absFilePath(); fi.setFile((QString) fp + FILE_SEP + editName->text()); if (fi.exists() && fi.isDir()) { msg = (QString) "A project named " + editName->text() + " already exists in this directory."; QMessageBox::warning(this, "hIDE", msg); editName->setFocus(); return; } editRoot->setText(fp); accept();}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -