- enhancement: After compiler settings changed, run/debug current file will auto recompile.
This commit is contained in:
parent
81fab89e1f
commit
814f3a28db
1
NEWS.md
1
NEWS.md
|
@ -14,6 +14,7 @@ Red Panda C++ Version 2.25
|
||||||
- fix: Press '>' after '-' don't show completion suggestion info.
|
- fix: Press '>' after '-' don't show completion suggestion info.
|
||||||
- fix: Icon position not correct under hiPDI devices.
|
- fix: Icon position not correct under hiPDI devices.
|
||||||
- change: Add Mesa3D for windows opengl driver to the integrated mingw-gcc for windows 32 version.
|
- change: Add Mesa3D for windows opengl driver to the integrated mingw-gcc for windows 32 version.
|
||||||
|
- enhancement: After compiler settings changed, run/debug current file will auto recompile.
|
||||||
|
|
||||||
Red Panda C++ Version 2.24
|
Red Panda C++ Version 2.24
|
||||||
|
|
||||||
|
|
|
@ -2126,7 +2126,9 @@ void MainWindow::runExecutable(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!filename.isEmpty() && compareFileModifiedTime(filename,exeName)>=0) {
|
if (!filename.isEmpty() &&
|
||||||
|
( compareFileModifiedTime(filename,exeName)>=0
|
||||||
|
|| compareFileModifiedTime(exeName, pSettings->compilerSets().defaultIndexTimestamp())<=0 )) {
|
||||||
doCompileRun(runType);
|
doCompileRun(runType);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -2435,7 +2437,9 @@ void MainWindow::debug()
|
||||||
mCompileSuccessionTask->binDirs = binDirs;
|
mCompileSuccessionTask->binDirs = binDirs;
|
||||||
compile();
|
compile();
|
||||||
return;
|
return;
|
||||||
} else if (compareFileModifiedTime(e->filename(),filePath)>=0) {
|
} else if (
|
||||||
|
compareFileModifiedTime(e->filename(),filePath)>=0
|
||||||
|
|| compareFileModifiedTime(filePath, pSettings->compilerSets().defaultIndexTimestamp())<=0 ) {
|
||||||
mCompileSuccessionTask=std::make_shared<CompileSuccessionTask>();
|
mCompileSuccessionTask=std::make_shared<CompileSuccessionTask>();
|
||||||
mCompileSuccessionTask->type = CompileSuccessionTaskType::Debug;
|
mCompileSuccessionTask->type = CompileSuccessionTaskType::Debug;
|
||||||
mCompileSuccessionTask->binDirs = binDirs;
|
mCompileSuccessionTask->binDirs = binDirs;
|
||||||
|
|
|
@ -3158,11 +3158,13 @@ void Settings::CompilerSets::saveSets()
|
||||||
saveSet(i);
|
saveSet(i);
|
||||||
}
|
}
|
||||||
if (mDefaultIndex>=(int)mList.size()) {
|
if (mDefaultIndex>=(int)mList.size()) {
|
||||||
mDefaultIndex = mList.size()-1;
|
setDefaultIndex( mList.size()-1 );
|
||||||
}
|
}
|
||||||
mSettings->mSettings.beginGroup(SETTING_COMPILTER_SETS);
|
mSettings->mSettings.beginGroup(SETTING_COMPILTER_SETS);
|
||||||
mSettings->mSettings.setValue(SETTING_COMPILTER_SETS_DEFAULT_INDEX,mDefaultIndex);
|
mSettings->mSettings.setValue(SETTING_COMPILTER_SETS_DEFAULT_INDEX,mDefaultIndex);
|
||||||
|
mSettings->mSettings.setValue(SETTING_COMPILTER_SETS_DEFAULT_INDEX_TIMESTAMP,mDefaultIndexTimeStamp);
|
||||||
mSettings->mSettings.setValue(SETTING_COMPILTER_SETS_COUNT,(int)mList.size());
|
mSettings->mSettings.setValue(SETTING_COMPILTER_SETS_COUNT,(int)mList.size());
|
||||||
|
|
||||||
mSettings->mSettings.endGroup();
|
mSettings->mSettings.endGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3170,7 +3172,8 @@ void Settings::CompilerSets::loadSets()
|
||||||
{
|
{
|
||||||
mList.clear();
|
mList.clear();
|
||||||
mSettings->mSettings.beginGroup(SETTING_COMPILTER_SETS);
|
mSettings->mSettings.beginGroup(SETTING_COMPILTER_SETS);
|
||||||
mDefaultIndex =mSettings->mSettings.value(SETTING_COMPILTER_SETS_DEFAULT_INDEX,-1).toInt();
|
mDefaultIndex = mSettings->mSettings.value(SETTING_COMPILTER_SETS_DEFAULT_INDEX,-1).toInt();
|
||||||
|
mDefaultIndexTimeStamp = mSettings->mSettings.value(SETTING_COMPILTER_SETS_DEFAULT_INDEX_TIMESTAMP,0).toLongLong();
|
||||||
int listSize = mSettings->mSettings.value(SETTING_COMPILTER_SETS_COUNT,0).toInt();
|
int listSize = mSettings->mSettings.value(SETTING_COMPILTER_SETS_COUNT,0).toInt();
|
||||||
mSettings->mSettings.endGroup();
|
mSettings->mSettings.endGroup();
|
||||||
bool loadError = false;
|
bool loadError = false;
|
||||||
|
@ -3184,7 +3187,7 @@ void Settings::CompilerSets::loadSets()
|
||||||
}
|
}
|
||||||
if (loadError) {
|
if (loadError) {
|
||||||
mList.clear();
|
mList.clear();
|
||||||
mDefaultIndex = -1;
|
setDefaultIndex(-1);
|
||||||
}
|
}
|
||||||
PCompilerSet pCurrentSet = defaultSet();
|
PCompilerSet pCurrentSet = defaultSet();
|
||||||
if (pCurrentSet) {
|
if (pCurrentSet) {
|
||||||
|
@ -3241,7 +3244,7 @@ void Settings::CompilerSets::loadSets()
|
||||||
pCurrentSet = defaultSet();
|
pCurrentSet = defaultSet();
|
||||||
if (!pCurrentSet) {
|
if (!pCurrentSet) {
|
||||||
mList.clear();
|
mList.clear();
|
||||||
mDefaultIndex = -1;
|
setDefaultIndex(-1);
|
||||||
saveSets();
|
saveSets();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -3254,6 +3257,7 @@ void Settings::CompilerSets::saveDefaultIndex()
|
||||||
{
|
{
|
||||||
mSettings->mSettings.beginGroup(SETTING_COMPILTER_SETS);
|
mSettings->mSettings.beginGroup(SETTING_COMPILTER_SETS);
|
||||||
mSettings->mSettings.setValue(SETTING_COMPILTER_SETS_DEFAULT_INDEX,mDefaultIndex);
|
mSettings->mSettings.setValue(SETTING_COMPILTER_SETS_DEFAULT_INDEX,mDefaultIndex);
|
||||||
|
mSettings->mSettings.setValue(SETTING_COMPILTER_SETS_DEFAULT_INDEX_TIMESTAMP,mDefaultIndexTimeStamp);
|
||||||
mSettings->mSettings.endGroup();
|
mSettings->mSettings.endGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3266,9 +3270,6 @@ void Settings::CompilerSets::deleteSet(int index)
|
||||||
mSettings->mSettings.endGroup();
|
mSettings->mSettings.endGroup();
|
||||||
}
|
}
|
||||||
mList.erase(std::begin(mList)+index);
|
mList.erase(std::begin(mList)+index);
|
||||||
if (mDefaultIndex>=(int)mList.size()) {
|
|
||||||
mDefaultIndex = mList.size()-1;
|
|
||||||
}
|
|
||||||
saveSets();
|
saveSets();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3282,9 +3283,15 @@ int Settings::CompilerSets::defaultIndex() const
|
||||||
return mDefaultIndex;
|
return mDefaultIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
qint64 Settings::CompilerSets::defaultIndexTimestamp() const
|
||||||
|
{
|
||||||
|
return mDefaultIndexTimeStamp;
|
||||||
|
}
|
||||||
|
|
||||||
void Settings::CompilerSets::setDefaultIndex(int value)
|
void Settings::CompilerSets::setDefaultIndex(int value)
|
||||||
{
|
{
|
||||||
mDefaultIndex = value;
|
mDefaultIndex = value;
|
||||||
|
mDefaultIndexTimeStamp = QDateTime::currentMSecsSinceEpoch();
|
||||||
}
|
}
|
||||||
|
|
||||||
Settings::PCompilerSet Settings::CompilerSets::defaultSet()
|
Settings::PCompilerSet Settings::CompilerSets::defaultSet()
|
||||||
|
|
|
@ -45,6 +45,7 @@
|
||||||
#define SETTING_CODE_FORMATTER "CodeFormatter"
|
#define SETTING_CODE_FORMATTER "CodeFormatter"
|
||||||
#define SETTING_COMPILTER_SETS "CompilerSets"
|
#define SETTING_COMPILTER_SETS "CompilerSets"
|
||||||
#define SETTING_COMPILTER_SETS_DEFAULT_INDEX "defaultIndex"
|
#define SETTING_COMPILTER_SETS_DEFAULT_INDEX "defaultIndex"
|
||||||
|
#define SETTING_COMPILTER_SETS_DEFAULT_INDEX_TIMESTAMP "defaultIndexTimestamp"
|
||||||
#define SETTING_COMPILTER_SETS_COUNT "count"
|
#define SETTING_COMPILTER_SETS_COUNT "count"
|
||||||
#define SETTING_COMPILTER_SET "CompilerSet_%1"
|
#define SETTING_COMPILTER_SET "CompilerSet_%1"
|
||||||
#define SETTING_EDITOR_DEFAULT_ENCODING "default_encoding"
|
#define SETTING_EDITOR_DEFAULT_ENCODING "default_encoding"
|
||||||
|
@ -1547,6 +1548,7 @@ public:
|
||||||
size_t size() const;
|
size_t size() const;
|
||||||
int defaultIndex() const;
|
int defaultIndex() const;
|
||||||
void setDefaultIndex(int value);
|
void setDefaultIndex(int value);
|
||||||
|
qint64 defaultIndexTimestamp() const;
|
||||||
PCompilerSet defaultSet();
|
PCompilerSet defaultSet();
|
||||||
PCompilerSet getSet(int index);
|
PCompilerSet getSet(int index);
|
||||||
|
|
||||||
|
@ -1567,6 +1569,7 @@ public:
|
||||||
private:
|
private:
|
||||||
CompilerSetList mList;
|
CompilerSetList mList;
|
||||||
int mDefaultIndex;
|
int mDefaultIndex;
|
||||||
|
qint64 mDefaultIndexTimeStamp;
|
||||||
Settings* mSettings;
|
Settings* mSettings;
|
||||||
QStringList mCompilerCompatibleIndex; // index for old settings compatibility
|
QStringList mCompilerCompatibleIndex; // index for old settings compatibility
|
||||||
};
|
};
|
||||||
|
|
|
@ -202,6 +202,8 @@ void CompilerSetOptionWidget::doSave()
|
||||||
if (pSettings->compilerSets().size()>0) {
|
if (pSettings->compilerSets().size()>0) {
|
||||||
saveCurrentCompilerSet();
|
saveCurrentCompilerSet();
|
||||||
}
|
}
|
||||||
|
//update default index timestamp
|
||||||
|
pSettings->compilerSets().setDefaultIndex(pSettings->compilerSets().defaultIndex());
|
||||||
pSettings->compilerSets().saveSets();
|
pSettings->compilerSets().saveSets();
|
||||||
pMainWindow->updateCompilerSet();
|
pMainWindow->updateCompilerSet();
|
||||||
}
|
}
|
||||||
|
|
|
@ -743,3 +743,14 @@ void clearQPlainTextEditFormat(QTextEdit *editor)
|
||||||
cursor.setCharFormat(QTextCharFormat());
|
cursor.setCharFormat(QTextCharFormat());
|
||||||
cursor.clearSelection();
|
cursor.clearSelection();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int compareFileModifiedTime(const QString &filename, qint64 timestamp)
|
||||||
|
{
|
||||||
|
QFileInfo fileInfo1(filename);
|
||||||
|
qint64 time=fileInfo1.lastModified().toMSecsSinceEpoch();
|
||||||
|
if (time > timestamp)
|
||||||
|
return 1;
|
||||||
|
if (time < timestamp)
|
||||||
|
return -1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
|
@ -147,6 +147,7 @@ QString escapeSpacesInString(const QString& str);
|
||||||
bool isReadOnly(const QString& filename);
|
bool isReadOnly(const QString& filename);
|
||||||
|
|
||||||
int compareFileModifiedTime(const QString& filename1, const QString& filename2);
|
int compareFileModifiedTime(const QString& filename1, const QString& filename2);
|
||||||
|
int compareFileModifiedTime(const QString& filename1, qint64 timestamp);
|
||||||
|
|
||||||
/* UI utils */
|
/* UI utils */
|
||||||
void inflateRect(QRect& rect, int delta);
|
void inflateRect(QRect& rect, int delta);
|
||||||
|
|
Loading…
Reference in New Issue