diff --git a/RedPandaIDE/RedPandaIDE.pro b/RedPandaIDE/RedPandaIDE.pro index 497ba817..e3195568 100644 --- a/RedPandaIDE/RedPandaIDE.pro +++ b/RedPandaIDE/RedPandaIDE.pro @@ -43,6 +43,7 @@ SOURCES += \ settingsdialog/editorcodecompletionwidget.cpp \ settingsdialog/editormiscwidget.cpp \ settingsdialog/formattergeneralwidget.cpp \ + settingsdialog/projectgeneralwidget.cpp \ widgets/classbrowser.cpp \ widgets/codecompletionlistview.cpp \ widgets/codecompletionpopup.cpp \ @@ -125,6 +126,7 @@ HEADERS += \ settingsdialog/editorcodecompletionwidget.h \ settingsdialog/editormiscwidget.h \ settingsdialog/formattergeneralwidget.h \ + settingsdialog/projectgeneralwidget.h \ widgets/classbrowser.h \ widgets/codecompletionlistview.h \ widgets/codecompletionpopup.h \ @@ -183,6 +185,7 @@ FORMS += \ settingsdialog/editorcodecompletionwidget.ui \ settingsdialog/editormiscwidget.ui \ settingsdialog/formattergeneralwidget.ui \ + settingsdialog/projectgeneralwidget.ui \ widgets/cpudialog.ui \ mainwindow.ui \ settingsdialog/compilersetdirectorieswidget.ui \ diff --git a/RedPandaIDE/compiler/projectcompiler.cpp b/RedPandaIDE/compiler/projectcompiler.cpp index fbe1240c..8729af3a 100644 --- a/RedPandaIDE/compiler/projectcompiler.cpp +++ b/RedPandaIDE/compiler/projectcompiler.cpp @@ -326,10 +326,13 @@ void ProjectCompiler::writeMakeObjFilesRules(QFile &file) if (unit->encoding() == ENCODING_AUTO_DETECT) { if (unit->editor() && unit->editor()->fileEncoding()!=ENCODING_ASCII) encodingStr = QString(" -finput-charset=%1 -fexec-charset=%2") - .arg(unit->editor()->fileEncoding(),getDefaultSystemEncoding()); + .arg(unit->editor()->fileEncoding(),getDefaultSystemEncoding()); } else if (unit->encoding()!=ENCODING_ASCII) { encodingStr = QString(" -finput-charset=%1 -fexec-charset=%2") .arg(unit->encoding(),getDefaultSystemEncoding()); + } else if (unit->encoding()!=ENCODING_SYSTEM_DEFAULT) { + encodingStr = QString(" -finput-charset=%1 -fexec-charset=%2") + .arg(getDefaultSystemEncoding(),getDefaultSystemEncoding()); } } diff --git a/RedPandaIDE/settingsdialog/projectgeneralwidget.cpp b/RedPandaIDE/settingsdialog/projectgeneralwidget.cpp new file mode 100644 index 00000000..4780be16 --- /dev/null +++ b/RedPandaIDE/settingsdialog/projectgeneralwidget.cpp @@ -0,0 +1,74 @@ +#include "projectgeneralwidget.h" +#include "ui_projectgeneralwidget.h" +#include "../project.h" +#include "../mainwindow.h" + +#include +#include + +ProjectGeneralWidget::ProjectGeneralWidget(const QString &name, const QString &group, QWidget *parent) : + SettingsWidget(name,group,parent), + ui(new Ui::ProjectGeneralWidget) +{ + ui->setupUi(this); +} + +ProjectGeneralWidget::~ProjectGeneralWidget() +{ + delete ui; +} + +void ProjectGeneralWidget::doLoad() +{ + std::shared_ptr project = pMainWindow->project(); + if (!project) + return; + ui->txtName->setText(project->name()); + ui->txtFileName->setText(project->filename()); + ui->txtOutputFile->setText(project->executable()); + + int srcCount=0,headerCount=0,resCount=0,otherCount=0, totalCount=0; + foreach (const PProjectUnit& unit, project->units()) { + switch(getFileType(unit->fileName())) { + case FileType::CSource: + case FileType::CppSource: + srcCount++; + break; + case FileType::CppHeader: + case FileType::CHeader: + headerCount++; + break; + case FileType::WindowsResourceSource: + resCount++; + break; + default: + otherCount++; + } + totalCount++; + } + ui->lblFiles->setText(tr("%1 files [ %2 sources, %3 headers, %4 resources, %5 other files ]") + .arg(totalCount).arg(srcCount).arg(headerCount) + .arg(resCount).arg(otherCount)); + + ui->cbDefaultEncoding->addItem(ENCODING_AUTO_DETECT); + ui->cbDefaultEncoding->addItem(ENCODING_SYSTEM_DEFAULT); + ui->cbDefaultEncoding->addItem(ENCODING_UTF8); + foreach (const QByteArray& name, QTextCodec::availableCodecs()){ + if (name == "system") + continue; + if (name == "utf-8") + continue; + ui->cbDefaultEncoding->addItem(name); + } + ui->cbDefaultEncoding->setCurrentText(project->options().encoding); + + ui->lstType->setCurrentRow( static_cast(project->options().type)); + + ui->cbDefaultCpp->setChecked(project->options().useGPP); + ui->cbSupportXPTheme->setChecked(project->options().supportXPThemes); + mIconPath = project->options().icon; + if (!mIconPath.isEmpty()) { + QPixmap icon(project->options().icon); + ui->lblICon->setPixmap(icon); + } +} diff --git a/RedPandaIDE/settingsdialog/projectgeneralwidget.h b/RedPandaIDE/settingsdialog/projectgeneralwidget.h new file mode 100644 index 00000000..079c6049 --- /dev/null +++ b/RedPandaIDE/settingsdialog/projectgeneralwidget.h @@ -0,0 +1,29 @@ +#ifndef PROJECTGENERALWIDGET_H +#define PROJECTGENERALWIDGET_H + +#include +#include "settingswidget.h" + +namespace Ui { +class ProjectGeneralWidget; +} + +class ProjectGeneralWidget : public SettingsWidget +{ + Q_OBJECT + +public: + explicit ProjectGeneralWidget(const QString& name, const QString& group, QWidget *parent = nullptr); + ~ProjectGeneralWidget(); + +private: + Ui::ProjectGeneralWidget *ui; + QString mIconPath; + + // SettingsWidget interface +protected: + void doLoad() override; + void doSave() override; +}; + +#endif // PROJECTGENERALWIDGET_H diff --git a/RedPandaIDE/settingsdialog/projectgeneralwidget.ui b/RedPandaIDE/settingsdialog/projectgeneralwidget.ui new file mode 100644 index 00000000..849c9b88 --- /dev/null +++ b/RedPandaIDE/settingsdialog/projectgeneralwidget.ui @@ -0,0 +1,296 @@ + + + ProjectGeneralWidget + + + + 0 + 0 + 674 + 639 + + + + Form + + + + + + true + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Name: + + + + + + + File Name: + + + + + + + + + + true + + + + + + + Files: + + + + + + + + + + TextLabel + + + + + + + Default encoding: + + + + + + + + + + + 0 + 0 + + + + Icon + + + + + + Remove + + + + :/icons/images/newlook24/011-clrhist.png:/icons/images/newlook24/011-clrhist.png + + + + + + + Library + + + + :/icons/images/newlook24/005-arricon.png + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + 64 + 64 + + + + QFrame::StyledPanel + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + Browse + + + + :/icons/images/newlook24/053-open.png + + + + + + + + + + + Type + + + + + + + 0 + 0 + + + + QAbstractScrollArea::AdjustToContents + + + QAbstractItemView::NoEditTriggers + + + QListView::Fixed + + + QListView::SinglePass + + + QListView::ListMode + + + + Win32 GUI + + + + + Win32 Console + + + + + Win32 Static Library + + + + + Win32 DLL + + + + + + + + Default to C++ when creating new files + + + + + + + Support Windows XP Themes + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + Output File: + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + +