From 76dcd8b41fab4a71a40d4c41e39ee6117914fe2c Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Thu, 27 Jan 2022 17:29:50 +0800 Subject: [PATCH] work save --- .../widgets/codecompletionlistview.cpp | 1 + RedPandaIDE/widgets/newclassdialog.cpp | 86 +++++++++++ RedPandaIDE/widgets/newclassdialog.h | 45 ++++++ RedPandaIDE/widgets/newclassdialog.ui | 142 ++++++++++++++++++ 4 files changed, 274 insertions(+) create mode 100644 RedPandaIDE/widgets/newclassdialog.cpp create mode 100644 RedPandaIDE/widgets/newclassdialog.h create mode 100644 RedPandaIDE/widgets/newclassdialog.ui diff --git a/RedPandaIDE/widgets/codecompletionlistview.cpp b/RedPandaIDE/widgets/codecompletionlistview.cpp index db56e165..5fc0f553 100644 --- a/RedPandaIDE/widgets/codecompletionlistview.cpp +++ b/RedPandaIDE/widgets/codecompletionlistview.cpp @@ -25,6 +25,7 @@ CodeCompletionListView::CodeCompletionListView(QWidget *parent) : QListView(parent) { + setUniformItemSizes(true); setItemDelegate(&mDelegate); } diff --git a/RedPandaIDE/widgets/newclassdialog.cpp b/RedPandaIDE/widgets/newclassdialog.cpp new file mode 100644 index 00000000..624ccb5f --- /dev/null +++ b/RedPandaIDE/widgets/newclassdialog.cpp @@ -0,0 +1,86 @@ +#include "newclassdialog.h" +#include "ui_newclassdialog.h" +#include "../iconsmanager.h" + +#include + +NewClassDialog::NewClassDialog(QWidget *parent) : + QDialog(parent), + ui(new Ui::NewClassDialog) +{ + ui->setupUi(this); + updateIcons(); +} + +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(); +} + +void NewClassDialog::updateIcons() +{ + pIconsManager->setIcon(ui->btnBrowsePath, IconsManager::ACTION_FILE_OPEN_FOLDER); +} + + +void NewClassDialog::on_btnBrowsePath_clicked() +{ + QString fileName = QFileDialog::getExistingDirectory( + this, + tr("Location"), + 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"); +} + diff --git a/RedPandaIDE/widgets/newclassdialog.h b/RedPandaIDE/widgets/newclassdialog.h new file mode 100644 index 00000000..11877a61 --- /dev/null +++ b/RedPandaIDE/widgets/newclassdialog.h @@ -0,0 +1,45 @@ +#ifndef NEWCLASSDIALOG_H +#define NEWCLASSDIALOG_H + +#include + +namespace Ui { +class NewClassDialog; +} + +class NewClassDialog : public QDialog +{ + Q_OBJECT + +public: + explicit NewClassDialog(QWidget *parent = nullptr); + ~NewClassDialog(); + + QString className() const; + QString baseClass() const; + QString headerName() const; + QString sourceName() const; + QString path() const; + void setPath(const QString& location); + +private slots: + void on_btnCancel_clicked(); + + void on_btnCreate_clicked(); + + void on_btnBrowsePath_clicked(); + + void on_txtClassName_textChanged(const QString &arg1); + +private: + Ui::NewClassDialog *ui; + +private: + void updateIcons(); + + // QWidget interface +protected: + void closeEvent(QCloseEvent *event) override; +}; + +#endif // NEWCLASSDIALOG_H diff --git a/RedPandaIDE/widgets/newclassdialog.ui b/RedPandaIDE/widgets/newclassdialog.ui new file mode 100644 index 00000000..dc176ccd --- /dev/null +++ b/RedPandaIDE/widgets/newclassdialog.ui @@ -0,0 +1,142 @@ + + + NewClassDialog + + + + 0 + 0 + 642 + 300 + + + + Dialog + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + Header Name: + + + + + + + + + + + + + Class Name: + + + + + + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Create + + + + + + + Cancel + + + + + + + + + + Path: + + + + + + + Base Class: + + + + + + + ... + + + + :/icons/images/newlook24/053-open.png:/icons/images/newlook24/053-open.png + + + + + + + + + + Source Name: + + + + + + + + + + + + +