diff --git a/RedPandaIDE/RedPandaIDE.pro b/RedPandaIDE/RedPandaIDE.pro index e3195568..6e5a4656 100644 --- a/RedPandaIDE/RedPandaIDE.pro +++ b/RedPandaIDE/RedPandaIDE.pro @@ -43,6 +43,7 @@ SOURCES += \ settingsdialog/editorcodecompletionwidget.cpp \ settingsdialog/editormiscwidget.cpp \ settingsdialog/formattergeneralwidget.cpp \ + settingsdialog/projectfileswidget.cpp \ settingsdialog/projectgeneralwidget.cpp \ widgets/classbrowser.cpp \ widgets/codecompletionlistview.cpp \ @@ -126,6 +127,7 @@ HEADERS += \ settingsdialog/editorcodecompletionwidget.h \ settingsdialog/editormiscwidget.h \ settingsdialog/formattergeneralwidget.h \ + settingsdialog/projectfileswidget.h \ settingsdialog/projectgeneralwidget.h \ widgets/classbrowser.h \ widgets/codecompletionlistview.h \ @@ -185,6 +187,7 @@ FORMS += \ settingsdialog/editorcodecompletionwidget.ui \ settingsdialog/editormiscwidget.ui \ settingsdialog/formattergeneralwidget.ui \ + settingsdialog/projectfileswidget.ui \ settingsdialog/projectgeneralwidget.ui \ widgets/cpudialog.ui \ mainwindow.ui \ diff --git a/RedPandaIDE/mainwindow.cpp b/RedPandaIDE/mainwindow.cpp index 0a142b27..4d00bb5e 100644 --- a/RedPandaIDE/mainwindow.cpp +++ b/RedPandaIDE/mainwindow.cpp @@ -2878,3 +2878,13 @@ void MainWindow::on_actionClose_Project_triggered() mClosing = false; } + +void MainWindow::on_actionProject_options_triggered() +{ + if (!mProject) + return; + QString oldName = mProject->name(); + PSettingsDialog dialog = SettingsDialog::projectOptionDialog(); + dialog->exec(); +} + diff --git a/RedPandaIDE/mainwindow.h b/RedPandaIDE/mainwindow.h index eb5cef33..95acc908 100644 --- a/RedPandaIDE/mainwindow.h +++ b/RedPandaIDE/mainwindow.h @@ -307,6 +307,8 @@ private slots: void on_actionClose_Project_triggered(); + void on_actionProject_options_triggered(); + private: Ui::MainWindow *ui; EditorList *mEditorList; diff --git a/RedPandaIDE/mainwindow.ui b/RedPandaIDE/mainwindow.ui index a19b3ffd..925fcc3e 100644 --- a/RedPandaIDE/mainwindow.ui +++ b/RedPandaIDE/mainwindow.ui @@ -276,7 +276,7 @@ QTabWidget::South - 4 + 1 @@ -330,16 +330,6 @@ - - - - :/icons/images/newlook24/068-resrc.png - - - - Resource - - @@ -890,10 +880,17 @@ + + + Project + + + + @@ -1624,6 +1621,16 @@ Close Project + + + + :/icons/images/newlook24/060-projopt.png + + + + Project options + + diff --git a/RedPandaIDE/project.cpp b/RedPandaIDE/project.cpp index 4d8a7c84..63808d0e 100644 --- a/RedPandaIDE/project.cpp +++ b/RedPandaIDE/project.cpp @@ -1405,16 +1405,11 @@ const QList &Project::units() const return mUnits; } -const ProjectOptions &Project::options() const +ProjectOptions &Project::options() { return mOptions; } -void Project::setOptions(const ProjectOptions &newOptions) -{ - mOptions = newOptions; -} - ProjectModel *Project::model() { return &mModel; @@ -1437,7 +1432,10 @@ const QString &Project::name() const void Project::setName(const QString &newName) { - mName = newName; + if (newName != mName) { + mName = newName; + mNode->text = newName; + } } const QString &Project::filename() const diff --git a/RedPandaIDE/project.h b/RedPandaIDE/project.h index a967c758..2c9ced65 100644 --- a/RedPandaIDE/project.h +++ b/RedPandaIDE/project.h @@ -225,8 +225,7 @@ public: const PFolderNode &node() const; void setNode(const PFolderNode &newNode); - const ProjectOptions &options() const; - void setOptions(const ProjectOptions &newOptions); + ProjectOptions &options(); ProjectModel* model() ; diff --git a/RedPandaIDE/settingsdialog/projectfileswidget.cpp b/RedPandaIDE/settingsdialog/projectfileswidget.cpp new file mode 100644 index 00000000..81c71220 --- /dev/null +++ b/RedPandaIDE/settingsdialog/projectfileswidget.cpp @@ -0,0 +1,14 @@ +#include "projectfileswidget.h" +#include "ui_projectfileswidget.h" + +ProjectFilesWidget::ProjectFilesWidget(QWidget *parent) : + QWidget(parent), + ui(new Ui::ProjectFilesWidget) +{ + ui->setupUi(this); +} + +ProjectFilesWidget::~ProjectFilesWidget() +{ + delete ui; +} diff --git a/RedPandaIDE/settingsdialog/projectfileswidget.h b/RedPandaIDE/settingsdialog/projectfileswidget.h new file mode 100644 index 00000000..1b75fb9b --- /dev/null +++ b/RedPandaIDE/settingsdialog/projectfileswidget.h @@ -0,0 +1,23 @@ +#ifndef PROJECTFILESWIDGET_H +#define PROJECTFILESWIDGET_H + +#include +#include "settings.h" + +namespace Ui { +class ProjectFilesWidget; +} + +class ProjectFilesWidget : public Settings +{ + Q_OBJECT + +public: + explicit ProjectFilesWidget(QWidget *parent = nullptr); + ~ProjectFilesWidget(); + +private: + Ui::ProjectFilesWidget *ui; +}; + +#endif // PROJECTFILESWIDGET_H diff --git a/RedPandaIDE/settingsdialog/projectfileswidget.ui b/RedPandaIDE/settingsdialog/projectfileswidget.ui new file mode 100644 index 00000000..77aac799 --- /dev/null +++ b/RedPandaIDE/settingsdialog/projectfileswidget.ui @@ -0,0 +1,116 @@ + + + ProjectFilesWidget + + + + 0 + 0 + 753 + 503 + + + + Form + + + + + + Qt::Horizontal + + + + + 0 + 0 + + + + + + + 1 + 0 + + + + File Options + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Include in linking + + + + + + + Build Priority: + + + + + + + true + + + Include in compilation + + + + + + + Compile files as C++ + + + + + + + Encoding + + + + + + + + + + + + + + + + Override build command: + + + + + + + + + + + + diff --git a/RedPandaIDE/settingsdialog/projectgeneralwidget.cpp b/RedPandaIDE/settingsdialog/projectgeneralwidget.cpp index 4780be16..753ff9c9 100644 --- a/RedPandaIDE/settingsdialog/projectgeneralwidget.cpp +++ b/RedPandaIDE/settingsdialog/projectgeneralwidget.cpp @@ -53,11 +53,27 @@ void ProjectGeneralWidget::doLoad() ui->cbDefaultEncoding->addItem(ENCODING_AUTO_DETECT); ui->cbDefaultEncoding->addItem(ENCODING_SYSTEM_DEFAULT); ui->cbDefaultEncoding->addItem(ENCODING_UTF8); + QList codecNames; + QSet codecAlias; + codecAlias.insert("system"); + codecAlias.insert("utf-8"); + foreach (const QByteArray& name, QTextCodec::availableCodecs()){ - if (name == "system") + QByteArray lname = name.toLower(); + if (lname.startsWith("cp")) continue; - if (name == "utf-8") + if (codecAlias.contains(lname)) continue; + codecNames.append(lname); + QTextCodec* codec = QTextCodec::codecForName(name); + if (codec) { + foreach (const QByteArray& alias, codec->aliases()) { + codecAlias.insert(alias.toLower()); + } + } + } + std::sort(codecNames.begin(),codecNames.end()); + foreach (const QByteArray& name,codecNames) { ui->cbDefaultEncoding->addItem(name); } ui->cbDefaultEncoding->setCurrentText(project->options().encoding); @@ -72,3 +88,21 @@ void ProjectGeneralWidget::doLoad() ui->lblICon->setPixmap(icon); } } + +void ProjectGeneralWidget::doSave() +{ + std::shared_ptr project = pMainWindow->project(); + if (!project) + return; + project->setName(ui->txtName->text().trimmed()); + + project->options().encoding = ui->cbDefaultEncoding->currentText(); + + int row = std::max(0,ui->lstType->currentRow()); + project->options().type = static_cast(row); + + project->options().useGPP = ui->cbDefaultCpp->isChecked(); + project->options().supportXPThemes = ui->cbSupportXPTheme->isChecked(); + project->options().icon = mIconPath; + project->saveOptions(); +} diff --git a/RedPandaIDE/settingsdialog/projectgeneralwidget.ui b/RedPandaIDE/settingsdialog/projectgeneralwidget.ui index 849c9b88..4fe8c0a2 100644 --- a/RedPandaIDE/settingsdialog/projectgeneralwidget.ui +++ b/RedPandaIDE/settingsdialog/projectgeneralwidget.ui @@ -145,7 +145,7 @@ - QFrame::StyledPanel + QFrame::Panel diff --git a/RedPandaIDE/settingsdialog/settingsdialog.cpp b/RedPandaIDE/settingsdialog/settingsdialog.cpp index 1e8759cb..186788b9 100644 --- a/RedPandaIDE/settingsdialog/settingsdialog.cpp +++ b/RedPandaIDE/settingsdialog/settingsdialog.cpp @@ -16,6 +16,7 @@ #include "executorgeneralwidget.h" #include "debuggeneralwidget.h" #include "formattergeneralwidget.h" +#include "projectgeneralwidget.h" #include #include #include @@ -144,6 +145,19 @@ PSettingsDialog SettingsDialog::optionDialog() return dialog; } +PSettingsDialog SettingsDialog::projectOptionDialog() +{ + PSettingsDialog dialog = std::make_shared(); + + SettingsWidget* widget = new ProjectGeneralWidget(tr("General"),tr("Project")); + widget->init(); + dialog->addWidget(widget); + + dialog->selectFirstWidget(); + + return dialog; +} + void SettingsDialog::on_widgetsView_clicked(const QModelIndex &index) { diff --git a/RedPandaIDE/settingsdialog/settingsdialog.h b/RedPandaIDE/settingsdialog/settingsdialog.h index 9547e562..1a4afa05 100644 --- a/RedPandaIDE/settingsdialog/settingsdialog.h +++ b/RedPandaIDE/settingsdialog/settingsdialog.h @@ -28,6 +28,7 @@ public: void selectFirstWidget(); static PSettingsDialog optionDialog(); + static PSettingsDialog projectOptionDialog(); private slots: void widget_settings_changed(bool value);