2022-01-27 17:29:50 +08:00
|
|
|
#include "newclassdialog.h"
|
|
|
|
#include "ui_newclassdialog.h"
|
|
|
|
#include "../iconsmanager.h"
|
2022-01-27 18:46:37 +08:00
|
|
|
#include "../settings.h"
|
2022-01-27 17:29:50 +08:00
|
|
|
#include <QFileDialog>
|
|
|
|
|
|
|
|
NewClassDialog::NewClassDialog(QWidget *parent) :
|
|
|
|
QDialog(parent),
|
|
|
|
ui(new Ui::NewClassDialog)
|
|
|
|
{
|
2022-02-02 17:34:37 +08:00
|
|
|
setWindowFlag(Qt::WindowContextHelpButtonHint,false);
|
2022-01-27 17:29:50 +08:00
|
|
|
ui->setupUi(this);
|
2022-01-27 18:46:37 +08:00
|
|
|
resize(pSettings->ui().newClassDialogWidth(),pSettings->ui().newClassDialogHeight());
|
2022-04-08 17:22:24 +08:00
|
|
|
onUpdateIcons();
|
|
|
|
connect(pIconsManager,&IconsManager::actionIconsUpdated,
|
|
|
|
this, &NewClassDialog::onUpdateIcons);
|
2022-02-01 16:17:28 +08:00
|
|
|
ui->txtClassName->setFocus();
|
2022-01-27 17:29:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
NewClassDialog::~NewClassDialog()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
QString NewClassDialog::className() const
|
|
|
|
{
|
|
|
|
return ui->txtClassName->text();
|
|
|
|
}
|
|
|
|
|
|
|
|
QString NewClassDialog::baseClass() const
|
|
|
|
{
|
|
|
|
return ui->cbBaseClass->currentText();
|
|
|
|
}
|
|
|
|
|
|
|
|
QString NewClassDialog::headerName() const
|
|
|
|
{
|
|
|
|
return ui->txtHeaderName->text();
|
|
|
|
}
|
|
|
|
|
|
|
|
QString NewClassDialog::sourceName() const
|
|
|
|
{
|
|
|
|
return ui->txtSourceName->text();
|
|
|
|
}
|
|
|
|
|
|
|
|
QString NewClassDialog::path() const
|
|
|
|
{
|
|
|
|
return ui->txtPath->text();
|
|
|
|
}
|
|
|
|
|
|
|
|
void NewClassDialog::setPath(const QString &location)
|
|
|
|
{
|
|
|
|
ui->txtPath->setText(location);
|
|
|
|
}
|
|
|
|
|
|
|
|
void NewClassDialog::on_btnCancel_clicked()
|
|
|
|
{
|
|
|
|
this->reject();
|
|
|
|
}
|
|
|
|
|
|
|
|
void NewClassDialog::closeEvent(QCloseEvent *event)
|
|
|
|
{
|
|
|
|
this->reject();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void NewClassDialog::on_btnCreate_clicked()
|
|
|
|
{
|
|
|
|
this->accept();
|
|
|
|
}
|
|
|
|
|
2022-04-08 17:22:24 +08:00
|
|
|
void NewClassDialog::onUpdateIcons()
|
2022-01-27 17:29:50 +08:00
|
|
|
{
|
|
|
|
pIconsManager->setIcon(ui->btnBrowsePath, IconsManager::ACTION_FILE_OPEN_FOLDER);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void NewClassDialog::on_btnBrowsePath_clicked()
|
|
|
|
{
|
|
|
|
QString fileName = QFileDialog::getExistingDirectory(
|
|
|
|
this,
|
2022-01-27 18:46:37 +08:00
|
|
|
tr("Path"),
|
2022-01-27 17:29:50 +08:00
|
|
|
ui->txtPath->text());
|
|
|
|
ui->txtPath->setText(fileName);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void NewClassDialog::on_txtClassName_textChanged(const QString &/* arg1 */)
|
|
|
|
{
|
|
|
|
ui->txtHeaderName->setText(ui->txtClassName->text().toLower()+".h");
|
|
|
|
ui->txtSourceName->setText(ui->txtClassName->text().toLower()+".cpp");
|
|
|
|
}
|
|
|
|
|