work save: new project dialog
This commit is contained in:
parent
ca728a2900
commit
02b3d43e5d
|
@ -34,6 +34,7 @@ SOURCES += \
|
|||
parser/parserutils.cpp \
|
||||
parser/statementmodel.cpp \
|
||||
project.cpp \
|
||||
projectoptions.cpp \
|
||||
projecttemplate.cpp \
|
||||
qsynedit/Search.cpp \
|
||||
qsynedit/SearchBase.cpp \
|
||||
|
@ -99,6 +100,7 @@ SOURCES += \
|
|||
widgets/filepropertiesdialog.cpp \
|
||||
widgets/headercompletionpopup.cpp \
|
||||
widgets/issuestable.cpp \
|
||||
widgets/newprojectdialog.cpp \
|
||||
widgets/qconsole.cpp \
|
||||
widgets/qpatchedcombobox.cpp \
|
||||
widgets/searchdialog.cpp \
|
||||
|
@ -127,6 +129,7 @@ HEADERS += \
|
|||
parser/statementmodel.h \
|
||||
platform.h \
|
||||
project.h \
|
||||
projectoptions.h \
|
||||
projecttemplate.h \
|
||||
qsynedit/Search.h \
|
||||
qsynedit/SearchBase.h \
|
||||
|
@ -193,6 +196,7 @@ HEADERS += \
|
|||
widgets/filepropertiesdialog.h \
|
||||
widgets/headercompletionpopup.h \
|
||||
widgets/issuestable.h \
|
||||
widgets/newprojectdialog.h \
|
||||
widgets/qconsole.h \
|
||||
widgets/qpatchedcombobox.h \
|
||||
widgets/searchdialog.h \
|
||||
|
@ -229,6 +233,7 @@ FORMS += \
|
|||
settingsdialog/settingsdialog.ui \
|
||||
widgets/custommakefileinfodialog.ui \
|
||||
widgets/filepropertiesdialog.ui \
|
||||
widgets/newprojectdialog.ui \
|
||||
widgets/searchdialog.ui
|
||||
|
||||
TRANSLATIONS += \
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
#include <QTextCodec>
|
||||
#include "settings.h"
|
||||
#include <QDebug>
|
||||
#include "SimpleIni.h"
|
||||
|
||||
Project::Project(const QString &filename, const QString &name, QObject *parent) :
|
||||
QObject(parent),
|
||||
mModel(this)
|
||||
|
@ -1403,16 +1403,6 @@ void Project::updateFolderNode(PFolderNode node)
|
|||
}
|
||||
}
|
||||
|
||||
QByteArray toByteArray(const QString &s)
|
||||
{
|
||||
return s.toLocal8Bit();
|
||||
}
|
||||
|
||||
QString fromByteArray(const QByteArray &s)
|
||||
{
|
||||
return QString::fromLocal8Bit(s);
|
||||
}
|
||||
|
||||
const QList<PProjectUnit> &Project::units() const
|
||||
{
|
||||
return mUnits;
|
||||
|
@ -1718,24 +1708,3 @@ QVariant ProjectModel::data(const QModelIndex &index, int role) const
|
|||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
ProjectVersionInfo::ProjectVersionInfo()
|
||||
{
|
||||
major = 1;
|
||||
minor = 0;
|
||||
release = 0;
|
||||
build = 0;
|
||||
languageID = 0x0409; // US English
|
||||
charsetID = 0x04E4; // Windows multilingual
|
||||
companyName = "";
|
||||
fileVersion = "";
|
||||
fileDescription = "Developed using the Red Panda Dev-C++ IDE";
|
||||
internalName = "";
|
||||
legalCopyright = "";
|
||||
legalTrademarks = "";
|
||||
originalFilename = "";
|
||||
productName = "";
|
||||
productVersion = "";
|
||||
autoIncBuildNr = false;
|
||||
syncProduct = true;
|
||||
}
|
||||
|
|
|
@ -5,15 +5,8 @@
|
|||
#include <QObject>
|
||||
#include <QSettings>
|
||||
#include <memory>
|
||||
#include "SimpleIni.h"
|
||||
|
||||
using SimpleIni = CSimpleIniA;
|
||||
enum class ProjectType {
|
||||
GUI=0,
|
||||
Console=1,
|
||||
StaticLib=2,
|
||||
DynamicLib=3
|
||||
};
|
||||
#include "projectoptions.h"
|
||||
#include "utils.h"
|
||||
|
||||
class Project;
|
||||
class Editor;
|
||||
|
@ -82,62 +75,7 @@ private:
|
|||
|
||||
using PProjectUnit = std::shared_ptr<ProjectUnit>;
|
||||
|
||||
struct ProjectVersionInfo{
|
||||
explicit ProjectVersionInfo();
|
||||
int major;
|
||||
int minor;
|
||||
int release;
|
||||
int build;
|
||||
int languageID;
|
||||
int charsetID;
|
||||
QString companyName;
|
||||
QString fileVersion;
|
||||
QString fileDescription;
|
||||
QString internalName;
|
||||
QString legalCopyright;
|
||||
QString legalTrademarks;
|
||||
QString originalFilename;
|
||||
QString productName;
|
||||
QString productVersion;
|
||||
bool autoIncBuildNr;
|
||||
bool syncProduct;
|
||||
};
|
||||
|
||||
struct ProjectOptions{
|
||||
ProjectType type;
|
||||
int version;
|
||||
QStringList objFiles;
|
||||
QString compilerCmd;
|
||||
QString cppCompilerCmd;
|
||||
QString linkerCmd;
|
||||
QStringList includes;
|
||||
QStringList libs;
|
||||
QString privateResource;
|
||||
QStringList resourceIncludes;
|
||||
QStringList makeIncludes;
|
||||
bool useGPP;
|
||||
QString icon;
|
||||
QString exeOutput;
|
||||
QString objectOutput;
|
||||
QString logOutput;
|
||||
bool logOutputEnabled;
|
||||
bool useCustomMakefile;
|
||||
QString customMakefile;
|
||||
bool usePrecompiledHeader;
|
||||
QString precompiledHeader;
|
||||
bool overrideOutput;
|
||||
QString overridenOutput;
|
||||
QString hostApplication;
|
||||
bool includeVersionInfo;
|
||||
bool supportXPThemes;
|
||||
int compilerSet;
|
||||
QByteArray compilerOptions;
|
||||
ProjectVersionInfo versionInfo;
|
||||
QString cmdLineArgs;
|
||||
bool staticLink;
|
||||
bool addCharset;
|
||||
QString encoding;
|
||||
};
|
||||
|
||||
class ProjectModel : public QAbstractItemModel {
|
||||
Q_OBJECT
|
||||
|
@ -253,7 +191,4 @@ private:
|
|||
ProjectModel mModel;
|
||||
};
|
||||
|
||||
QByteArray toByteArray(const QString& s);
|
||||
QString fromByteArray(const QByteArray& s);
|
||||
|
||||
#endif // PROJECT_H
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
#include "projectoptions.h"
|
||||
|
||||
ProjectVersionInfo::ProjectVersionInfo()
|
||||
{
|
||||
major = 1;
|
||||
minor = 0;
|
||||
release = 0;
|
||||
build = 0;
|
||||
languageID = 0x0409; // US English
|
||||
charsetID = 0x04E4; // Windows multilingual
|
||||
companyName = "";
|
||||
fileVersion = "";
|
||||
fileDescription = "Developed using the Red Panda Dev-C++ IDE";
|
||||
internalName = "";
|
||||
legalCopyright = "";
|
||||
legalTrademarks = "";
|
||||
originalFilename = "";
|
||||
productName = "";
|
||||
productVersion = "";
|
||||
autoIncBuildNr = false;
|
||||
syncProduct = true;
|
||||
}
|
||||
|
||||
ProjectOptions::ProjectOptions()
|
||||
{
|
||||
type = ProjectType::GUI;
|
||||
version = 2;
|
||||
useGPP = false;
|
||||
logOutputEnabled = false;
|
||||
useCustomMakefile = false;
|
||||
usePrecompiledHeader = false;
|
||||
overrideOutput = false;
|
||||
includeVersionInfo = false;
|
||||
supportXPThemes = false;
|
||||
compilerSet = 0;
|
||||
staticLink = true;
|
||||
addCharset = true;
|
||||
}
|
|
@ -0,0 +1,70 @@
|
|||
#ifndef PROJECTOPTIONS_H
|
||||
#define PROJECTOPTIONS_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
enum class ProjectType {
|
||||
GUI=0,
|
||||
Console=1,
|
||||
StaticLib=2,
|
||||
DynamicLib=3
|
||||
};
|
||||
|
||||
struct ProjectVersionInfo{
|
||||
explicit ProjectVersionInfo();
|
||||
int major;
|
||||
int minor;
|
||||
int release;
|
||||
int build;
|
||||
int languageID;
|
||||
int charsetID;
|
||||
QString companyName;
|
||||
QString fileVersion;
|
||||
QString fileDescription;
|
||||
QString internalName;
|
||||
QString legalCopyright;
|
||||
QString legalTrademarks;
|
||||
QString originalFilename;
|
||||
QString productName;
|
||||
QString productVersion;
|
||||
bool autoIncBuildNr;
|
||||
bool syncProduct;
|
||||
};
|
||||
|
||||
struct ProjectOptions{
|
||||
explicit ProjectOptions();
|
||||
ProjectType type;
|
||||
int version;
|
||||
QStringList objFiles;
|
||||
QString compilerCmd;
|
||||
QString cppCompilerCmd;
|
||||
QString linkerCmd;
|
||||
QStringList includes;
|
||||
QStringList libs;
|
||||
QString privateResource;
|
||||
QStringList resourceIncludes;
|
||||
QStringList makeIncludes;
|
||||
bool useGPP;
|
||||
QString icon;
|
||||
QString exeOutput;
|
||||
QString objectOutput;
|
||||
QString logOutput;
|
||||
bool logOutputEnabled;
|
||||
bool useCustomMakefile;
|
||||
QString customMakefile;
|
||||
bool usePrecompiledHeader;
|
||||
QString precompiledHeader;
|
||||
bool overrideOutput;
|
||||
QString overridenOutput;
|
||||
QString hostApplication;
|
||||
bool includeVersionInfo;
|
||||
bool supportXPThemes;
|
||||
int compilerSet;
|
||||
QByteArray compilerOptions;
|
||||
ProjectVersionInfo versionInfo;
|
||||
QString cmdLineArgs;
|
||||
bool staticLink;
|
||||
bool addCharset;
|
||||
QString encoding;
|
||||
};
|
||||
#endif // PROJECTOPTIONS_H
|
|
@ -1,7 +1,8 @@
|
|||
#include "projecttemplate.h"
|
||||
#include "SimpleIni.h"
|
||||
|
||||
#include <QFile>
|
||||
#include <QMessageBox>
|
||||
#include "mainwindow.h"
|
||||
|
||||
ProjectTemplate::ProjectTemplate(QObject *parent) : QObject(parent)
|
||||
{
|
||||
|
||||
|
@ -9,53 +10,181 @@ ProjectTemplate::ProjectTemplate(QObject *parent) : QObject(parent)
|
|||
|
||||
int ProjectTemplate::unitCount()
|
||||
{
|
||||
if (mFileName.isEmpty() || !QFile(mFileName).exists())
|
||||
return -1;
|
||||
SimpleIni ini;
|
||||
ini.LoadFile(toByteArray(mFileName));
|
||||
int ver = ini.GetLongValue("Template","Ver",0);
|
||||
if (ver<=0)
|
||||
return 0;
|
||||
return ini.GetLongValue("Project","UnitCount",0);
|
||||
if (!mIni || mVersion<=0)
|
||||
return mIni->GetLongValue("Project","UnitCount",0);
|
||||
}
|
||||
|
||||
PTemplateUnit ProjectTemplate::unit(int index)
|
||||
{
|
||||
if (mFileName.isEmpty() || !QFile(mFileName).exists())
|
||||
return PTemplateUnit();
|
||||
SimpleIni ini;
|
||||
ini.LoadFile(toByteArray(mFileName));
|
||||
int ver = ini.GetLongValue("Template","Ver",0);
|
||||
if (ver<=0)
|
||||
if (!mIni || mVersion<=0)
|
||||
return PTemplateUnit();
|
||||
QString section = QString("Unit%1").arg(index);
|
||||
PTemplateUnit unit = std::make_shared<TemplateUnit>();
|
||||
unit->CText = fromByteArray(ini.GetValue(toByteArray(section), "C", ""));
|
||||
unit->CppText = fromByteArray(ini.GetValue(toByteArray(section), "Cpp", ""));
|
||||
unit->CText = fromByteArray(mIni->GetValue(toByteArray(section), "C", ""));
|
||||
unit->CppText = fromByteArray(mIni->GetValue(toByteArray(section), "Cpp", ""));
|
||||
if (unit->CppText.isEmpty())
|
||||
unit->CppText = unit->CText;
|
||||
|
||||
unit->CName = fromByteArray(ini.GetValue(toByteArray(section), "CName", ""));
|
||||
unit->CppName = fromByteArray(ini.GetValue(toByteArray(section), "CppName", ""));
|
||||
unit->CName = fromByteArray(mIni->GetValue(toByteArray(section), "CName", ""));
|
||||
unit->CppName = fromByteArray(mIni->GetValue(toByteArray(section), "CppName", ""));
|
||||
if (unit->CppName.isEmpty())
|
||||
unit->CppName = unit->CName;
|
||||
return unit;
|
||||
}
|
||||
|
||||
void ProjectTemplate::setUnit(int index, PTemplateUnit newUnit)
|
||||
{
|
||||
if (!newUnit)
|
||||
return;
|
||||
if (mFileName.isEmpty() || !QFile(mFileName).exists())
|
||||
return;
|
||||
SimpleIni ini;
|
||||
ini.LoadFile(toByteArray(mFileName));
|
||||
int ver = ini.GetLongValue("Template","Ver",0);
|
||||
if (ver<=0)
|
||||
if (!mIni || mVersion<=0)
|
||||
return;
|
||||
QByteArray section = toByteArray(QString("Unit%1").arg(index));
|
||||
ini.SetValue(section,"C", toByteArray(newUnit->CText));
|
||||
ini.SetValue(section,"Cpp", toByteArray(newUnit->CppText));
|
||||
ini.SetValue(section,"CName", toByteArray(newUnit->CName));
|
||||
ini.SetValue(section,"CppName", toByteArray(newUnit->CppName));
|
||||
ini.SaveFile(toByteArray(mFileName));
|
||||
mIni->SetValue(section,"C", toByteArray(newUnit->CText));
|
||||
mIni->SetValue(section,"Cpp", toByteArray(newUnit->CppText));
|
||||
mIni->SetValue(section,"CName", toByteArray(newUnit->CName));
|
||||
mIni->SetValue(section,"CppName", toByteArray(newUnit->CppName));
|
||||
}
|
||||
|
||||
int ProjectTemplate::addUnit()
|
||||
{
|
||||
if (!mIni || mVersion<=0)
|
||||
return -1;
|
||||
int count = unitCount() +1;
|
||||
QByteArray section = toByteArray(QString("Unit%1").arg(count));
|
||||
mIni->SetValue(section, "C", "");
|
||||
mIni->SetValue(section, "Cpp", "");
|
||||
mIni->SetLongValue("Project", "UnitCount", count);
|
||||
return count;
|
||||
}
|
||||
|
||||
void ProjectTemplate::readTemplateFile(const QString &fileName)
|
||||
{
|
||||
if (mIni)
|
||||
mIni=nullptr;
|
||||
if (QFile(fileName).exists()) {
|
||||
mFileName = fileName;
|
||||
mIni = std::make_shared<SimpleIni>();
|
||||
if (mIni->LoadFile(toByteArray(mFileName)) != SI_OK) {
|
||||
QMessageBox::critical(pMainWindow,
|
||||
tr("Read failed."),
|
||||
tr("Can't read template file '%1'.").arg(fileName),
|
||||
QMessageBox::Ok);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
QMessageBox::critical(pMainWindow,
|
||||
tr("Template not exist"),
|
||||
tr("Template file '%1' doesn't exist.").arg(fileName),
|
||||
QMessageBox::Ok);
|
||||
return;
|
||||
}
|
||||
|
||||
mVersion = mIni->GetLongValue("Template", "Ver", 0);
|
||||
if (mVersion<=0) {
|
||||
QMessageBox::critical(pMainWindow,
|
||||
tr("Old version template"),
|
||||
tr("Template file '%1' has version '%2', which is unsupported.")
|
||||
.arg(fileName)
|
||||
.arg(mVersion),
|
||||
QMessageBox::Ok);
|
||||
return;
|
||||
}
|
||||
|
||||
// template info
|
||||
mDescription = fromByteArray(mIni->GetValue("Template", "Description", ""));
|
||||
mIcon = fromByteArray(mIni->GetValue("Template", "Icon", ""));
|
||||
mCategory = fromByteArray(mIni->GetValue("Template", "Category", ""));
|
||||
mName = fromByteArray(mIni->GetValue("Template", "Name", ""));
|
||||
|
||||
mOptions.icon = mIni->GetValue("Project", "Icon", "");
|
||||
mOptions.type = static_cast<ProjectType>(mIni->GetLongValue("Project", "Type", 0)); // default = gui
|
||||
mOptions.objFiles = fromByteArray(mIni->GetValue("Project", "ObjFiles", "")).split(";",Qt::SkipEmptyParts);
|
||||
mOptions.includes = fromByteArray(mIni->GetValue("Project", "Includes", "")).split(";",Qt::SkipEmptyParts);
|
||||
mOptions.libs = fromByteArray(mIni->GetValue("Project", "Libs", "")).split(";",Qt::SkipEmptyParts);
|
||||
mOptions.resourceIncludes = fromByteArray(mIni->GetValue("Project", "ResourceIncludes", "")).split(";",Qt::SkipEmptyParts);
|
||||
mOptions.compilerCmd = fromByteArray(mIni->GetValue("Project", "Compiler", ""));
|
||||
mOptions.cppCompilerCmd = fromByteArray(mIni->GetValue("Project", "CppCompiler", ""));
|
||||
mOptions.linkerCmd = fromByteArray(mIni->GetValue("Project", "Linker",""));
|
||||
mOptions.useGPP = mIni->GetBoolValue("Project", "IsCpp", false);
|
||||
mOptions.includeVersionInfo = mIni->GetBoolValue("Project", "IncludeVersionInfo", false);
|
||||
mOptions.supportXPThemes = mIni->GetBoolValue("Project", "SupportXPThemes", false);
|
||||
mOptions.exeOutput = fromByteArray(mIni->GetValue("Project", "ExeOutput", ""));
|
||||
mOptions.objectOutput = fromByteArray(mIni->GetValue("Project", "ObjectOutput", ""));
|
||||
mOptions.logOutput = fromByteArray(mIni->GetValue("Project", "LogOutput", ""));
|
||||
mOptions.staticLink = mIni->GetBoolValue("Project", "StaticLink",true);
|
||||
mOptions.addCharset = mIni->GetBoolValue("Project", "AddCharset",true);
|
||||
bool useUTF8 = mIni->GetBoolValue("Project", "UseUTF8", false);
|
||||
if (useUTF8) {
|
||||
mOptions.encoding = fromByteArray(mIni->GetValue("Project","Encoding", ENCODING_UTF8));
|
||||
} else {
|
||||
mOptions.encoding = fromByteArray(mIni->GetValue("Project","Encoding", ENCODING_AUTO_DETECT));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
bool ProjectTemplate::save()
|
||||
{
|
||||
if (mIni) {
|
||||
return mIni->SaveFile(toByteArray(mFileName)) == SI_OK ;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
const QString &ProjectTemplate::category() const
|
||||
{
|
||||
return mCategory;
|
||||
}
|
||||
|
||||
void ProjectTemplate::setCategory(const QString &newCategory)
|
||||
{
|
||||
mCategory = newCategory;
|
||||
}
|
||||
|
||||
const QString &ProjectTemplate::description() const
|
||||
{
|
||||
return mDescription;
|
||||
}
|
||||
|
||||
void ProjectTemplate::setDescription(const QString &newDescription)
|
||||
{
|
||||
mDescription = newDescription;
|
||||
}
|
||||
|
||||
const QString &ProjectTemplate::fileName() const
|
||||
{
|
||||
return mFileName;
|
||||
}
|
||||
|
||||
void ProjectTemplate::setFileName(const QString &newFileName)
|
||||
{
|
||||
mFileName = newFileName;
|
||||
}
|
||||
|
||||
const QString &ProjectTemplate::icon() const
|
||||
{
|
||||
return mIcon;
|
||||
}
|
||||
|
||||
void ProjectTemplate::setIcon(const QString &newIcon)
|
||||
{
|
||||
mIcon = newIcon;
|
||||
}
|
||||
|
||||
const QString &ProjectTemplate::name() const
|
||||
{
|
||||
return mName;
|
||||
}
|
||||
|
||||
void ProjectTemplate::setName(const QString &newName)
|
||||
{
|
||||
mName = newName;
|
||||
}
|
||||
|
||||
const ProjectOptions &ProjectTemplate::options() const
|
||||
{
|
||||
return mOptions;
|
||||
}
|
||||
|
||||
void ProjectTemplate::setOptions(const ProjectOptions &newOptions)
|
||||
{
|
||||
mOptions = newOptions;
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
#define PROJECTTEMPLATE_H
|
||||
|
||||
#include <QObject>
|
||||
#include "project.h"
|
||||
#include "utils.h"
|
||||
#include "projectoptions.h"
|
||||
|
||||
struct TemplateUnit {
|
||||
QString CName;
|
||||
|
@ -21,17 +22,39 @@ public:
|
|||
int unitCount();
|
||||
PTemplateUnit unit(int index);
|
||||
void setUnit(int index, PTemplateUnit newUnit);
|
||||
int addUnit();
|
||||
void readTemplateFile(const QString& fileName);
|
||||
bool save();
|
||||
const QString &category() const;
|
||||
void setCategory(const QString &newCategory);
|
||||
|
||||
const QString &description() const;
|
||||
void setDescription(const QString &newDescription);
|
||||
|
||||
const QString &fileName() const;
|
||||
void setFileName(const QString &newFileName);
|
||||
|
||||
const QString &icon() const;
|
||||
void setIcon(const QString &newIcon);
|
||||
|
||||
const QString &name() const;
|
||||
void setName(const QString &newName);
|
||||
|
||||
const ProjectOptions &options() const;
|
||||
void setOptions(const ProjectOptions &newOptions);
|
||||
|
||||
private:
|
||||
QString mFileName;
|
||||
ProjectOptions mOptions;
|
||||
QString mDesc;
|
||||
QString mDescription;
|
||||
QString mCategory;
|
||||
QString mName;
|
||||
QString mIcon; // icon in project form
|
||||
PSimpleIni mIni;
|
||||
int mVersion;
|
||||
signals:
|
||||
|
||||
};
|
||||
using PProjectTemplate = std::shared_ptr<ProjectTemplate>;
|
||||
|
||||
#endif // PROJECTTEMPLATE_H
|
||||
|
|
|
@ -152,6 +152,16 @@ QString Settings::Dirs::app() const
|
|||
return QApplication::instance()->applicationDirPath();
|
||||
}
|
||||
|
||||
QString Settings::Dirs::templateDir() const
|
||||
{
|
||||
return includeTrailingPathDelimiter(app()) + "templates";
|
||||
}
|
||||
|
||||
QString Settings::Dirs::projectDir() const
|
||||
{
|
||||
return includeTrailingPathDelimiter(app()) + "projects";
|
||||
}
|
||||
|
||||
QString Settings::Dirs::data(Settings::Dirs::DataType dataType) const
|
||||
{
|
||||
using DataType = Settings::Dirs::DataType;
|
||||
|
|
|
@ -83,6 +83,8 @@ public:
|
|||
};
|
||||
explicit Dirs(Settings * settings);
|
||||
QString app() const;
|
||||
QString templateDir() const;
|
||||
QString projectDir() const;
|
||||
QString data(DataType dataType = DataType::None) const;
|
||||
QString config(DataType dataType = DataType::None) const;
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#define DEF_EXT "def"
|
||||
#define LIB_EXT "a"
|
||||
#define GCH_EXT "gch"
|
||||
#define TEMPLATE_EXT "template"
|
||||
#define DEV_INTERNAL_OPEN "$__DEV_INTERNAL_OPEN"
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
|
|
|
@ -707,3 +707,13 @@ QString extractFileDir(const QString &fileName)
|
|||
{
|
||||
return extractFilePath(fileName);
|
||||
}
|
||||
|
||||
QByteArray toByteArray(const QString &s)
|
||||
{
|
||||
return s.toLocal8Bit();
|
||||
}
|
||||
|
||||
QString fromByteArray(const QByteArray &s)
|
||||
{
|
||||
return QString::fromLocal8Bit(s);
|
||||
}
|
||||
|
|
|
@ -8,6 +8,10 @@
|
|||
#include <QRect>
|
||||
#include <QStringList>
|
||||
#include <memory>
|
||||
#include "SimpleIni.h"
|
||||
|
||||
using SimpleIni = CSimpleIniA;
|
||||
using PSimpleIni = std::shared_ptr<SimpleIni>;
|
||||
|
||||
class QByteArray;
|
||||
class QTextStream;
|
||||
|
@ -170,6 +174,10 @@ QString extractAbsoluteFilePath(const QString& filePath);
|
|||
QString getSizeString(int size);
|
||||
bool isReadOnly(const QString& filename);
|
||||
|
||||
|
||||
QByteArray toByteArray(const QString& s);
|
||||
QString fromByteArray(const QByteArray& s);
|
||||
|
||||
int getNewFileNumber();
|
||||
|
||||
class CppParser;
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
<string>Information for custom makefile</string>
|
||||
</property>
|
||||
<layout class="QGridLayout">
|
||||
<item row="1" column="1">
|
||||
|
@ -50,7 +50,7 @@
|
|||
<item row="0" column="0" colspan="3">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string><html><head/><body><p>Dev-C++'s Makefile has two important targets:</p><p>- all (which builds the executable)</p><p>- clean (which cleans up object files)</p><p><br/>&quot;all&quot; depends on 2 targets: all-before and all-after. All-before</p><p>gets called before the compilation process, and all-after gets</p><p>called after the compilation process.</p><p><br/>&quot;clean&quot; depends on the target clean-custom, which gets called</p><p>before the cleaning process.<br/></p><p>You can change the Makefile's behavior by defining the targets</p><p>that &quot;all&quot; and &quot;clean&quot; depend on.</p></body></html></string>
|
||||
<string><html><head/><body><p>Red Panda Dev-C++'s Makefile has two important targets:</p><p>- all (which builds the executable)</p><p>- clean (which cleans up object files)</p><p><br/>&quot;all&quot; depends on 2 targets: all-before and all-after. All-before</p><p>gets called before the compilation process, and all-after gets</p><p>called after the compilation process.</p><p><br/>&quot;clean&quot; depends on the target clean-custom, which gets called</p><p>before the cleaning process.<br/></p><p>You can change the Makefile's behavior by defining the targets</p><p>that &quot;all&quot; and &quot;clean&quot; depend on.</p></body></html></string>
|
||||
</property>
|
||||
<property name="textFormat">
|
||||
<enum>Qt::RichText</enum>
|
||||
|
|
|
@ -0,0 +1,87 @@
|
|||
#include "newprojectdialog.h"
|
||||
#include "ui_newprojectdialog.h"
|
||||
#include "settings.h"
|
||||
#include "systemconsts.h"
|
||||
|
||||
#include <QDir>
|
||||
#include <QFile>
|
||||
|
||||
NewProjectDialog::NewProjectDialog(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::NewProjectDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
mTemplatesTabBar = new QTabBar(this);
|
||||
ui->verticalLayout->insertWidget(0,mTemplatesTabBar);
|
||||
}
|
||||
|
||||
NewProjectDialog::~NewProjectDialog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void NewProjectDialog::addTemplate(const QString &filename)
|
||||
{
|
||||
if (!QFile(filename).exists())
|
||||
return;
|
||||
PProjectTemplate t = std::make_shared<ProjectTemplate>();
|
||||
t->readTemplateFile(filename);
|
||||
mTemplates.append(t);
|
||||
}
|
||||
|
||||
void NewProjectDialog::readTemplateDir()
|
||||
{
|
||||
QString templateExt(".");
|
||||
templateExt += TEMPLATE_EXT;
|
||||
QDir dir(pSettings->dirs().templateDir());
|
||||
foreach (const QFileInfo& fileInfo,dir.entryInfoList()) {
|
||||
if (fileInfo.isFile()
|
||||
&& fileInfo.fileName().endsWith(templateExt)) {
|
||||
addTemplate(fileInfo.absoluteFilePath());
|
||||
}
|
||||
}
|
||||
updateView();
|
||||
}
|
||||
|
||||
void NewProjectDialog::updateView()
|
||||
{
|
||||
while (mTemplatesTabBar->count()>0) {
|
||||
mTemplatesTabBar->removeTab(0);
|
||||
}
|
||||
QMap<QString,int> categories;
|
||||
foreach (const PProjectTemplate& t, mTemplates) {
|
||||
QString category = t->category();
|
||||
if (category.isEmpty())
|
||||
category = tr("Default");
|
||||
// Add a page for each unique category
|
||||
int tabIndex = categories.value(category,-1);
|
||||
if (tabIndex<0) {
|
||||
tabIndex = mTemplatesTabBar->addTab(category);
|
||||
categories.insert(category,tabIndex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Only add if we're viewing this category
|
||||
if SameText(TemplateItem.Category, TabsMain.Tabs[TabsMain.TabIndex]) then begin
|
||||
ListItem := ProjView.Items.Add;
|
||||
ListItem.Caption := TemplateItem.Name;
|
||||
ListItem.Data := pointer(I);
|
||||
IconFileName := ValidateFile(TemplateItem.Icon, '', true);
|
||||
if IconFileName <> '' then begin
|
||||
|
||||
// Add icon to central dump and tell ListItem to use it
|
||||
IconItem := TIcon.Create;
|
||||
try
|
||||
IconItem.LoadFromFile(IconFileName); // ValidateFile prepends path
|
||||
ListItem.ImageIndex := ImageList.AddIcon(IconItem);
|
||||
if ListItem.ImageIndex = -1 then
|
||||
ListItem.ImageIndex := 0;
|
||||
finally
|
||||
IconItem.Free;
|
||||
end;
|
||||
end else
|
||||
ListItem.ImageIndex := 0; // don't use an icon
|
||||
end;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
#ifndef NEWPROJECTDIALOG_H
|
||||
#define NEWPROJECTDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QTabBar>
|
||||
#include "projecttemplate.h"
|
||||
|
||||
namespace Ui {
|
||||
class NewProjectDialog;
|
||||
}
|
||||
|
||||
class NewProjectDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit NewProjectDialog(QWidget *parent = nullptr);
|
||||
~NewProjectDialog();
|
||||
private:
|
||||
void addTemplate(const QString& filename);
|
||||
void readTemplateDir();
|
||||
void updateView();
|
||||
private:
|
||||
Ui::NewProjectDialog *ui;
|
||||
QList<PProjectTemplate> mTemplates;
|
||||
QTabBar* mTemplatesTabBar;
|
||||
};
|
||||
|
||||
#endif // NEWPROJECTDIALOG_H
|
|
@ -0,0 +1,167 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>NewProjectDialog</class>
|
||||
<widget class="QDialog" name="NewProjectDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>670</width>
|
||||
<height>528</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>New Project</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QListView" name="lstTemplates">
|
||||
<property name="flow">
|
||||
<enum>QListView::LeftToRight</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="widget" native="true">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="lblDescription">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="widget_2" native="true">
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<property name="verticalSpacing">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<item row="2" column="0">
|
||||
<widget class="QCheckBox" name="chkMakeDefault">
|
||||
<property name="text">
|
||||
<string>Make default language</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QRadioButton" name="rdCProject">
|
||||
<property name="text">
|
||||
<string>C Project</string>
|
||||
</property>
|
||||
<attribute name="buttonGroup">
|
||||
<string notr="true">btnGroupLanguage</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QRadioButton" name="rdCppProject">
|
||||
<property name="text">
|
||||
<string>C++ Project</string>
|
||||
</property>
|
||||
<attribute name="buttonGroup">
|
||||
<string notr="true">btnGroupLanguage</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="widget_3" native="true">
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Name:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Location:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QLineEdit" name="txtLocation"/>
|
||||
</item>
|
||||
<item row="1" column="3">
|
||||
<widget class="QToolButton" name="toolButton">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normalon>:/icons/images/newlook24/053-open.png</normalon>
|
||||
</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2" colspan="2">
|
||||
<widget class="QLineEdit" name="txtName"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>NewProjectDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>NewProjectDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
<buttongroups>
|
||||
<buttongroup name="btnGroupLanguage"/>
|
||||
</buttongroups>
|
||||
</ui>
|
Loading…
Reference in New Issue