work save

This commit is contained in:
royqh1979@gmail.com 2021-09-07 14:04:48 +08:00
parent 090a6d3e1e
commit cc2c34fcd2
8 changed files with 212 additions and 160 deletions

View File

@ -772,7 +772,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>946</width> <width>946</width>
<height>22</height> <height>25</height>
</rect> </rect>
</property> </property>
<widget class="QMenu" name="menuFile"> <widget class="QMenu" name="menuFile">
@ -1299,7 +1299,7 @@
<string>Step Over</string> <string>Step Over</string>
</property> </property>
<property name="shortcut"> <property name="shortcut">
<string>F7</string> <string>F8</string>
</property> </property>
</action> </action>
<action name="actionStep_Into"> <action name="actionStep_Into">
@ -1312,7 +1312,7 @@
<string>Step Into</string> <string>Step Into</string>
</property> </property>
<property name="shortcut"> <property name="shortcut">
<string>F8</string> <string>F7</string>
</property> </property>
</action> </action>
<action name="actionStep_Out"> <action name="actionStep_Out">

View File

@ -250,39 +250,39 @@ void Project::buildPrivateResource(bool forceSave)
// in many cases (like in importing a MSVC project) // in many cases (like in importing a MSVC project)
// the project's resource file has already the // the project's resource file has already the
// <project_filename>.res filename. // <project_filename>.res filename.
QString res; QString rcFile;
if (!mOptions.privateResource.isEmpty()) { if (!mOptions.privateResource.isEmpty()) {
res = QDir(directory()).filePath(mOptions.privateResource); rcFile = QDir(directory()).filePath(mOptions.privateResource);
if (changeFileExt(res, DEV_PROJECT_EXT) == mFilename) if (changeFileExt(rcFile, DEV_PROJECT_EXT) == mFilename)
res = changeFileExt(mFilename,QString("_private") + RC_EXT); rcFile = changeFileExt(mFilename,QString("_private") + RC_EXT);
} else } else
res = changeFileExt(mFilename,QString("_private") + RC_EXT); rcFile = changeFileExt(mFilename,QString("_private") + RC_EXT);
res = extractRelativePath(mFilename, res); rcFile = extractRelativePath(mFilename, rcFile);
res.replace(' ','_'); rcFile.replace(' ','_');
// don't run the private resource file and header if not modified, // don't run the private resource file and header if not modified,
// unless ForceSave is true // unless ForceSave is true
if (!forceSave if (!forceSave
&& fileExists(res) && fileExists(rcFile)
&& fileExists(changeFileExt(res, H_EXT)) && fileExists(changeFileExt(rcFile, H_EXT))
&& !mModified) && !mModified)
return; return;
QStringList resFile; QStringList content;
resFile.append("/* THIS FILE WILL BE OVERWRITTEN BY DEV-C++ */"); content.append("/* THIS FILE WILL BE OVERWRITTEN BY DEV-C++ */");
resFile.append("/* DO NOT EDIT! */"); content.append("/* DO NOT EDIT! */");
resFile.append(""); content.append("");
if (mOptions.includeVersionInfo) { if (mOptions.includeVersionInfo) {
resFile.append("#include <windows.h> // include for version info constants"); content.append("#include <windows.h> // include for version info constants");
resFile.append(""); content.append("");
end; }
foreach (const PProjectUnit& unit, mUnits) { foreach (const PProjectUnit& unit, mUnits) {
if ( if (
(getFileType(unit->fileName()) == FileType::WindowsResourceSource) (getFileType(unit->fileName()) == FileType::WindowsResourceSource)
&& unit->compile() ) && unit->compile() )
resFile.append("#include \"" + content.append("#include \"" +
genMakePath( genMakePath(
extractRelativePath(directory(), unit->fileName()), extractRelativePath(directory(), unit->fileName()),
false, false,
@ -290,168 +290,203 @@ void Project::buildPrivateResource(bool forceSave)
} }
if (!mOptions.icon.isEmpty()) { if (!mOptions.icon.isEmpty()) {
resFile.append(""); content.append("");
QString icon = QDir(directory()).absoluteFilePath(mOptions.icon); QString icon = QDir(directory()).absoluteFilePath(mOptions.icon);
if (fileExists(icon)) { if (fileExists(icon)) {
icon = extractRelativePath(mFilename, icon); icon = extractRelativePath(mFilename, icon);
icon.replace('\\', '/'); icon.replace('\\', '/');
resFile.append("A ICON \"" + icon + '"'); content.append("A ICON \"" + icon + '"');
} else } else
mOptions.icon = ""; mOptions.icon = "";
} }
if (mOptions.supportXPThemes) { if (mOptions.supportXPThemes) {
resFile.append(""); content.append("");
resFile.append("//"); content.append("//");
resFile.append("// SUPPORT FOR WINDOWS XP THEMES:"); content.append("// SUPPORT FOR WINDOWS XP THEMES:");
resFile.append("// THIS WILL MAKE THE PROGRAM USE THE COMMON CONTROLS"); content.append("// THIS WILL MAKE THE PROGRAM USE THE COMMON CONTROLS");
resFile.append("// LIBRARY VERSION 6.0 (IF IT IS AVAILABLE)"); content.append("// LIBRARY VERSION 6.0 (IF IT IS AVAILABLE)");
resFile.append("//"); content.append("//");
if (!mOptions.exeOutput.isEmpty()) if (!mOptions.exeOutput.isEmpty())
resFile.append( content.append(
"1 24 \"" + "1 24 \"" +
genMakePath2( genMakePath2(
includeTrailingPathDelimiter(mOptions.exeOutput) includeTrailingPathDelimiter(mOptions.exeOutput)
+ baseFileName(executable())) + baseFileName(executable()))
+ ".Manifest\""); + ".Manifest\"");
else else
resFile.append("1 24 \"" + baseFileName(executable()) + ".Manifest\""); content.append("1 24 \"" + baseFileName(executable()) + ".Manifest\"");
} }
if Options.IncludeVersionInfo then begin if (mOptions.includeVersionInfo) {
resFile.append("'); content.append("");
resFile.append("//'); content.append("//");
resFile.append("// TO CHANGE VERSION INFORMATION, EDIT PROJECT OPTIONS...'); content.append("// TO CHANGE VERSION INFORMATION, EDIT PROJECT OPTIONS...");
resFile.append("//'); content.append("//");
resFile.append("1 VERSIONINFO'); content.append("1 VERSIONINFO");
resFile.append("FILEVERSION ' + Format('%d,%d,%d,%d', [Options.VersionInfo.Major, Options.VersionInfo.Minor, content.append("FILEVERSION " +
Options.VersionInfo.Release, Options.VersionInfo.Build])); QString("%1,%2,%3,%4")
resFile.append("PRODUCTVERSION ' + Format('%d,%d,%d,%d', [Options.VersionInfo.Major, Options.VersionInfo.Minor, .arg(mOptions.versionInfo.major)
Options.VersionInfo.Release, Options.VersionInfo.Build])); .arg(mOptions.versionInfo.minor)
case Options.typ of .arg(mOptions.versionInfo.release)
dptGUI, .arg(mOptions.versionInfo.build));
dptCon: resFile.append("FILETYPE VFT_APP'); content.append("PRODUCTVERSION " +
dptStat: resFile.append("FILETYPE VFT_STATIC_LIB'); QString("%1,%2,%3,%4")
dptDyn: resFile.append("FILETYPE VFT_DLL'); .arg(mOptions.versionInfo.major)
end; .arg(mOptions.versionInfo.minor)
resFile.append("{'); .arg(mOptions.versionInfo.release)
resFile.append(" BLOCK "StringFileInfo"'); .arg(mOptions.versionInfo.build));
resFile.append(" {'); switch(mOptions.type) {
resFile.append(" BLOCK "' + Format('%4.4x%4.4x', [fOptions.VersionInfo.LanguageID, fOptions.VersionInfo.CharsetID]) case ProjectType::GUI:
+ case ProjectType::Console:
'"'); content.append("FILETYPE VFT_APP");
resFile.append(" {'); break;
resFile.append(" VALUE "CompanyName", "' + fOptions.VersionInfo.CompanyName + '"'); case ProjectType::StaticLib:
resFile.append(" VALUE "FileVersion", "' + fOptions.VersionInfo.FileVersion + '"'); content.append("FILETYPE VFT_STATIC_LIB");
resFile.append(" VALUE "FileDescription", "' + fOptions.VersionInfo.FileDescription + '"'); break;
resFile.append(" VALUE "InternalName", "' + fOptions.VersionInfo.InternalName + '"'); case ProjectType::DynamicLib:
resFile.append(" VALUE "LegalCopyright", "' + fOptions.VersionInfo.LegalCopyright + '"'); content.append("FILETYPE VFT_DLL");
resFile.append(" VALUE "LegalTrademarks", "' + fOptions.VersionInfo.LegalTrademarks + '"'); break;
resFile.append(" VALUE "OriginalFilename", "' + fOptions.VersionInfo.OriginalFilename + '"'); }
resFile.append(" VALUE "ProductName", "' + fOptions.VersionInfo.ProductName + '"'); content.append("{");
resFile.append(" VALUE "ProductVersion", "' + fOptions.VersionInfo.ProductVersion + '"'); content.append(" BLOCK \"StringFileInfo\"");
resFile.append(" }'); content.append(" {");
resFile.append(" }'); content.append(" BLOCK \"" +
QString("%1%2")
.arg(mOptions.versionInfo.languageID,4,16,QChar('0'))
.arg(mOptions.versionInfo.charsetID,4,16,QChar('0'))
+ '"');
content.append(" {");
content.append(" VALUE \"CompanyName\", \""
+ mOptions.versionInfo.companyName
+ "\"");
content.append(" VALUE \"FileVersion\", \""
+ mOptions.versionInfo.fileVersion
+ "\"");
content.append(" VALUE \"FileDescription\", \""
+ mOptions.versionInfo.fileDescription
+ "\"");
content.append(" VALUE \"InternalName\", \""
+ mOptions.versionInfo.internalName
+ "\"");
content.append(" VALUE \"LegalCopyright\", \""
+ mOptions.versionInfo.legalCopyright
+ '"');
content.append(" VALUE \"LegalTrademarks\", \""
+ mOptions.versionInfo.legalTrademarks
+ "\"");
content.append(" VALUE \"OriginalFilename\", \""
+ mOptions.versionInfo.originalFilename
+ "\"");
content.append(" VALUE \"ProductName\", \""
+ mOptions.versionInfo.productName + "\"");
content.append(" VALUE \"ProductVersion\", \""
+ mOptions.versionInfo.productVersion + "\"");
content.append(" }");
content.append(" }");
// additional block for windows 95->NT // additional block for windows 95->NT
resFile.append(" BLOCK "VarFileInfo"'); content.append(" BLOCK \"VarFileInfo\"");
resFile.append(" {'); content.append(" {");
resFile.append(" VALUE "Translation", ' + Format('0x%4.4x, %4.4d', [fOptions.VersionInfo.LanguageID, content.append(" VALUE \"Translation\", " +
fOptions.VersionInfo.CharsetID])); QString("0x%1, %2")
resFile.append(" }'); .arg(mOptions.versionInfo.languageID,4,16,QChar('0'))
.arg(mOptions.versionInfo.charsetID));
content.append(" }");
resFile.append("}'); content.append("}");
end; }
Res := GetRealPath(Res, Directory); rcFile = QDir(directory()).absoluteFilePath(rcFile);
if resFile.Count > 3 then begin if (content.count() > 3) {
if FileExists(Res) and not ForceSave then begin StringsToFile(content,rcFile);
Original := TStringList.Create; mOptions.privateResource = extractRelativePath(directory(), rcFile);
Original.LoadFromFile(Res); } else {
if CompareStr(Original.Text, resFile.Text) <> 0 then begin if (fileExists(rcFile))
resFile.SaveToFile(Res); QFile::remove(rcFile);
end; QString resFile = changeFileExt(rcFile, RES_EXT);
Original.Free; if (fileExists(resFile))
end else begin QFile::remove(resFile);
resFile.SaveToFile(Res); mOptions.privateResource = "";
end; }
fOptions.PrivateResource := ExtractRelativePath(Directory, Res); // if fileExists(Res) then
end else begin // FileSetDate(Res, DateTimeToFileDate(Now)); // fix the "Clock skew detected" warning ;)
if FileExists(Res) then
DeleteFile(PAnsiChar(Res));
Res := ChangeFileExt(Res, RES_EXT);
if FileExists(Res) then
DeleteFile(PAnsiChar(Res));
fOptions.PrivateResource := '';
end;
if FileExists(Res) then
FileSetDate(Res, DateTimeToFileDate(Now)); // fix the "Clock skew detected" warning ;)
// create XP manifest // create XP manifest
if fOptions.SupportXPThemes then begin if (mOptions.supportXPThemes) {
resFile.Clear; QStringList content;
resFile.append("<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'); content.append("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>");
resFile.append("<assembly'); content.append("<assembly");
resFile.append(" xmlns="urn:schemas-microsoft-com:asm.v1"'); content.append(" xmlns=\"urn:schemas-microsoft-com:asm.v1\"");
resFile.append(" manifestVersion="1.0">'); content.append(" manifestVersion=\"1.0\">");
resFile.append("<assemblyIdentity'); content.append("<assemblyIdentity");
resFile.append(" name="DevCpp.Apps.' + StringReplace(Name, ' ', '_', [rfReplaceAll]) + '"'); QString name = mName;
resFile.append(" processorArchitecture="*"'); name.replace(' ','_');
resFile.append(" version="1.0.0.0"'); content.append(" name=\"DevCpp.Apps." + name + '\"');
resFile.append(" type="win32"/>'); content.append(" processorArchitecture=\"*\"");
resFile.append("<description>' + Name + '</description>'); content.append(" version=\"1.0.0.0\"");
resFile.append("<dependency>'); content.append(" type=\"win32\"/>");
resFile.append(" <dependentAssembly>'); content.append("<description>" + name + "</description>");
resFile.append(" <assemblyIdentity'); content.append("<dependency>");
resFile.append(" type="win32"'); content.append(" <dependentAssembly>");
resFile.append(" name="Microsoft.Windows.Common-Controls"'); content.append(" <assemblyIdentity");
resFile.append(" version="6.0.0.0"'); content.append(" type=\"win32\"");
resFile.append(" processorArchitecture="*"'); content.append(" name=\"Microsoft.Windows.Common-Controls\"");
resFile.append(" publicKeyToken="6595b64144ccf1df"'); content.append(" version=\"6.0.0.0\"");
resFile.append(" language="*"'); content.append(" processorArchitecture=\"*\"");
resFile.append(" />'); content.append(" publicKeyToken=\"6595b64144ccf1df\"");
resFile.append(" </dependentAssembly>'); content.append(" language=\"*\"");
resFile.append("</dependency>'); content.append(" />");
resFile.append("</assembly>'); content.append(" </dependentAssembly>");
resFile.SaveToFile(Executable + '.Manifest'); content.append("</dependency>");
FileSetDate(Executable + '.Manifest', DateTimeToFileDate(Now)); // fix the "Clock skew detected" warning ;) content.append("</assembly>");
end else if FileExists(Executable + '.Manifest') then StringsToFile(content,executable() + ".Manifest");
DeleteFile(PAnsiChar(Executable + '.Manifest')); } else if (fileExists(executable() + ".Manifest"))
QFile::remove(executable() + ".Manifest");
// create private header file // create private header file
Res := ChangeFileExt(Res, H_EXT); QString hFile = changeFileExt(rcFile, H_EXT);
resFile.Clear; content.clear();
Def := StringReplace(ExtractFilename(UpperCase(Res)), '.', '_', [rfReplaceAll]); QString def = baseFileName(rcFile);
resFile.append("/* THIS FILE WILL BE OVERWRITTEN BY DEV-C++ */'); def.replace(".","_");
resFile.append("/* DO NOT EDIT ! */'); content.append("/* THIS FILE WILL BE OVERWRITTEN BY DEV-C++ */");
resFile.append("'); content.append("/* DO NOT EDIT ! */");
resFile.append("#ifndef ' + Def); content.append("");
resFile.append("#define ' + Def); content.append("#ifndef " + def);
resFile.append("'); content.append("#define " + def);
resFile.append("/* VERSION DEFINITIONS */'); content.append("");
resFile.append("#define VER_STRING'#9 + Format('"%d.%d.%d.%d"', [fOptions.VersionInfo.Major, fOptions.VersionInfo.Minor, content.append("/* VERSION DEFINITIONS */");
fOptions.VersionInfo.Release, fOptions.VersionInfo.Build])); content.append("#define VER_STRING\t" +
resFile.append("#define VER_MAJOR'#9 + IntToStr(fOptions.VersionInfo.Major)); QString("\"%d.%d.%d.%d\"")
resFile.append("#define VER_MINOR'#9 + IntToStr(fOptions.VersionInfo.Minor)); .arg(mOptions.versionInfo.major)
resFile.append("#define VER_RELEASE'#9 + IntToStr(fOptions.VersionInfo.Release)); .arg(mOptions.versionInfo.minor)
resFile.append("#define VER_BUILD'#9 + IntToStr(fOptions.VersionInfo.Build)); .arg(mOptions.versionInfo.release)
resFile.append("#define COMPANY_NAME'#9'"' + fOptions.VersionInfo.CompanyName + '"'); .arg(mOptions.versionInfo.build));
resFile.append("#define FILE_VERSION'#9'"' + fOptions.VersionInfo.FileVersion + '"'); content.append(QString("#define VER_MAJOR\t%1").arg(mOptions.versionInfo.major));
resFile.append("#define FILE_DESCRIPTION'#9'"' + fOptions.VersionInfo.FileDescription + '"'); content.append(QString("#define VER_MINOR\t%1").arg(mOptions.versionInfo.minor));
resFile.append("#define INTERNAL_NAME'#9'"' + fOptions.VersionInfo.InternalName + '"'); content.append(QString("#define VER_RELEASE\t").arg(mOptions.versionInfo.release));
resFile.append("#define LEGAL_COPYRIGHT'#9'"' + fOptions.VersionInfo.LegalCopyright + '"'); content.append(QString("#define VER_BUILD\t").arg(mOptions.versionInfo.build));
resFile.append("#define LEGAL_TRADEMARKS'#9'"' + fOptions.VersionInfo.LegalTrademarks + '"'); content.append(QString("#define COMPANY_NAME\t\"%1\"")
resFile.append("#define ORIGINAL_FILENAME'#9'"' + fOptions.VersionInfo.OriginalFilename + '"'); .arg(mOptions.versionInfo.companyName));
resFile.append("#define PRODUCT_NAME'#9'"' + fOptions.VersionInfo.ProductName + '"'); content.append(QString("#define FILE_VERSION\t\"%1\"")
resFile.append("#define PRODUCT_VERSION'#9'"' + fOptions.VersionInfo.ProductVersion + '"'); .arg(mOptions.versionInfo.fileVersion));
resFile.append("'); content.append(QString("#define FILE_DESCRIPTION\t\"%1\"")
resFile.append("#endif /*' + Def + '*/'); .arg(mOptions.versionInfo.fileDescription));
resFile.SaveToFile(Res); content.append(QString("#define INTERNAL_NAME\t\"%1\"")
.arg(mOptions.versionInfo.internalName));
if FileExists(Res) then content.append(QString("#define LEGAL_COPYRIGHT\t\"%1\"")
FileSetDate(Res, DateTimeToFileDate(Now)); // fix the "Clock skew detected" warning ;) .arg(mOptions.versionInfo.legalCopyright));
content.append(QString("#define LEGAL_TRADEMARKS\t\"%1\"")
resFile.Free; .arg(mOptions.versionInfo.legalTrademarks));
content.append(QString("#define ORIGINAL_FILENAME\t\"%1\"")
.arg(mOptions.versionInfo.originalFilename));
content.append(QString("#define PRODUCT_NAME\t\"%1\"")
.arg(mOptions.versionInfo.productName));
content.append(QString("#define PRODUCT_VERSION\t\"%1\"")
.arg(mOptions.versionInfo.productVersion));
content.append("");
content.append("#endif /*" + def + "*/");
StringsToFile(content,hFile);
} }
void Project::sortUnitsByPriority() void Project::sortUnitsByPriority()

View File

@ -131,10 +131,10 @@ struct ProjectOptions{
bool supportXPThemes; bool supportXPThemes;
int compilerSet; int compilerSet;
QString compilerOptions; QString compilerOptions;
ProjectVersionInfo VersionInfo; ProjectVersionInfo versionInfo;
QString cmdLineArgs; QString cmdLineArgs;
bool mStaticLink; bool staticLink;
bool mAddCharset; bool addCharset;
}; };
class Project : public QObject class Project : public QObject

View File

@ -527,11 +527,13 @@ void SynDrawGradient(QPaintDevice *ACanvas, const QColor &AStartColor, const QCo
} }
} }
#ifndef Q_OS_WIN
int MulDiv(int a, int b, int c) int MulDiv(int a, int b, int c)
{ {
//todo: handle overflow? //todo: handle overflow?
return a*b/c; return a*b/c;
} }
#endif
SynFontStyles getFontStyles(const QFont &font) SynFontStyles getFontStyles(const QFont &font)
{ {

View File

@ -21,7 +21,9 @@ using IntArray = QVector<int>;
using PIntArray = std::shared_ptr<IntArray>; using PIntArray = std::shared_ptr<IntArray>;
int MinMax(int x, int mi, int ma); int MinMax(int x, int mi, int ma);
#ifndef Q_OS_WIN
int MulDiv(int a, int b, int c); int MulDiv(int a, int b, int c);
#endif
void SwapInt(int& l, int &r); void SwapInt(int& l, int &r);
BufferCoord MaxBufferCoord(const BufferCoord& P1, const BufferCoord& P2); BufferCoord MaxBufferCoord(const BufferCoord& P1, const BufferCoord& P2);
BufferCoord MinBufferCoord(const BufferCoord& P1, const BufferCoord& P2); BufferCoord MinBufferCoord(const BufferCoord& P1, const BufferCoord& P2);

View File

@ -20,6 +20,7 @@
#define DEV_PROJECT_EXT "dev" #define DEV_PROJECT_EXT "dev"
#define RC_EXT "rc" #define RC_EXT "rc"
#define RES_EXT "rc"
#define H_EXT "h" #define H_EXT "h"
#ifdef Q_OS_WIN #ifdef Q_OS_WIN

View File

@ -647,3 +647,13 @@ QString genMakePath(const QString &fileName, bool escapeSpaces, bool encloseInQu
result = '"'+result+'"'; result = '"'+result+'"';
return result; return result;
} }
QString genMakePath1(const QString &fileName)
{
return genMakePath(fileName, false, true);
}
QString genMakePath2(const QString &fileName)
{
return genMakePath(fileName, true, false);
}

View File

@ -126,6 +126,8 @@ FileType getFileType(const QString& filename);
QString changeFileExt(const QString& filename, const QString& ext); QString changeFileExt(const QString& filename, const QString& ext);
QString extractRelativePath(const QString& base, const QString& dest); QString extractRelativePath(const QString& base, const QString& dest);
QString genMakePath(const QString& fileName,bool escapeSpaces, bool encloseInQuotes); QString genMakePath(const QString& fileName,bool escapeSpaces, bool encloseInQuotes);
QString genMakePath1(const QString& fileName);
QString genMakePath2(const QString& fileName);
QString getCompiledExecutableName(const QString& filename); QString getCompiledExecutableName(const QString& filename);
void splitStringArguments(const QString& arguments, QStringList& argumentList); void splitStringArguments(const QString& arguments, QStringList& argumentList);
bool programHasConsole(const QString& filename); bool programHasConsole(const QString& filename);