- enhancement: Create a temporary copy of the current file when saving files (it's removed after the saving sucessfully finished).

This commit is contained in:
Roy Qu 2023-01-14 22:52:04 +08:00
parent 6072944c23
commit ac20a2c458
7 changed files with 228 additions and 194 deletions

View File

@ -4,6 +4,7 @@ Red Panda C++ Version 2.9
- fix: syntax highlighting for cpp style line comment is not correct.
- fix: Save may crash app if the encoding codec is failed to load.
- enhancement: support open and save utf-16/utf-32 BOM files. (but gcc can't compile)
- enhancement: Create a temporary copy of the current file when saving files (it's removed after the saving sucessfully finished).
Red Panda C++ Version 2.8

View File

@ -244,13 +244,30 @@ void Editor::saveFile(QString filename) {
QByteArray encoding = mFileEncoding;
if (mEncodingOption!=ENCODING_AUTO_DETECT || mFileEncoding==ENCODING_ASCII)
encoding = mEncodingOption;
QString backupFilename=filename+".savebak";
int count=1;
while (fileExists(backupFilename)) {
backupFilename=filename+QString(".savebak%1").arg(count);
count++;
}
if (!fileExists(filename)) {
if (!stringToFile(text(),backupFilename)) {
QMessageBox::critical(pMainWindow,tr("Error"),
tr("Can't generate temporary backup file '%1'.").arg(backupFilename));
return;
}
} else if (!QFile::copy(filename,backupFilename)) {
QMessageBox::critical(pMainWindow,tr("Error"),
tr("Can't generate temporary backup file '%1'.").arg(backupFilename));
return;
}
this->document()->saveToFile(file,encoding,
pSettings->editor().defaultEncoding(),
mFileEncoding);
if (isVisible() && mParentPageControl)
pMainWindow->updateForEncodingInfo(this);
emit fileSaved(filename, inProject());
QFile::remove(backupFilename);
}
void Editor::convertToEncoding(const QByteArray &encoding)
@ -264,9 +281,9 @@ bool Editor::save(bool force, bool doReparse) {
if (this->mIsNew && !force) {
return saveAs();
}
while (pMainWindow->parsing()) {
QThread::msleep(200);
}
// while (pMainWindow->parsing()) {
// QThread::msleep(200);
// }
//is this file writable;
pMainWindow->fileSystemWatcher()->removePath(mFilename);

View File

@ -1034,6 +1034,10 @@
<source>Readonly</source>
<translation>Apenas leitura</translation>
</message>
<message>
<source>Can&apos;t generate temporary backup file &apos;%1&apos;.</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>EditorAutoSaveWidget</name>

View File

@ -588,7 +588,7 @@ p, li { white-space: pre-wrap; }
<translation>[]</translation>
</message>
<message>
<location filename="../compiler/compiler.cpp" line="716"/>
<location filename="../compiler/compiler.cpp" line="720"/>
<source>The compiler process for &apos;%1&apos; failed to start.</source>
<translation>&apos;%1&apos;</translation>
</message>
@ -597,27 +597,27 @@ p, li { white-space: pre-wrap; }
<translation type="vanished"></translation>
</message>
<message>
<location filename="../compiler/compiler.cpp" line="720"/>
<location filename="../compiler/compiler.cpp" line="724"/>
<source>The compiler process crashed after starting successfully.</source>
<translation></translation>
</message>
<message>
<location filename="../compiler/compiler.cpp" line="723"/>
<location filename="../compiler/compiler.cpp" line="727"/>
<source>The last waitFor...() function timed out.</source>
<translation>waitFor()</translation>
</message>
<message>
<location filename="../compiler/compiler.cpp" line="726"/>
<location filename="../compiler/compiler.cpp" line="730"/>
<source>An error occurred when attempting to write to the compiler process.</source>
<translation></translation>
</message>
<message>
<location filename="../compiler/compiler.cpp" line="729"/>
<location filename="../compiler/compiler.cpp" line="733"/>
<source>An error occurred when attempting to read from the compiler process.</source>
<translation></translation>
</message>
<message>
<location filename="../compiler/compiler.cpp" line="732"/>
<location filename="../compiler/compiler.cpp" line="736"/>
<source>An unknown error occurred.</source>
<translation></translation>
</message>
@ -1379,13 +1379,14 @@ Are you really want to continue?</oldsource>
<translation type="vanished"></translation>
</message>
<message>
<location filename="../editor.cpp" line="285"/>
<location filename="../editor.cpp" line="371"/>
<location filename="../editor.cpp" line="400"/>
<location filename="../editor.cpp" line="1470"/>
<location filename="../editor.cpp" line="1475"/>
<location filename="../editor.cpp" line="1495"/>
<location filename="../editor.cpp" line="1500"/>
<location filename="../editor.cpp" line="254"/>
<location filename="../editor.cpp" line="297"/>
<location filename="../editor.cpp" line="383"/>
<location filename="../editor.cpp" line="412"/>
<location filename="../editor.cpp" line="1482"/>
<location filename="../editor.cpp" line="1487"/>
<location filename="../editor.cpp" line="1507"/>
<location filename="../editor.cpp" line="1512"/>
<source>Error</source>
<translation></translation>
</message>
@ -1394,44 +1395,49 @@ Are you really want to continue?</oldsource>
<translation type="vanished">&quot;%1&quot;</translation>
</message>
<message>
<location filename="../editor.cpp" line="315"/>
<location filename="../editor.cpp" line="255"/>
<source>Can&apos;t generate temporary backup file &apos;%1&apos;.</source>
<translation type="unfinished">&quot;%1&quot;</translation>
</message>
<message>
<location filename="../editor.cpp" line="327"/>
<source>Save As</source>
<translation></translation>
</message>
<message>
<location filename="../editor.cpp" line="372"/>
<location filename="../editor.cpp" line="384"/>
<source>File %1 already openned!</source>
<translation>%1</translation>
</message>
<message>
<location filename="../editor.cpp" line="1471"/>
<location filename="../editor.cpp" line="1483"/>
<source>The text to be copied exceeds count limit!</source>
<translation></translation>
</message>
<message>
<location filename="../editor.cpp" line="1476"/>
<location filename="../editor.cpp" line="1488"/>
<source>The text to be copied exceeds character limit!</source>
<translation></translation>
</message>
<message>
<location filename="../editor.cpp" line="1496"/>
<location filename="../editor.cpp" line="1508"/>
<source>The text to be cut exceeds count limit!</source>
<translation></translation>
</message>
<message>
<location filename="../editor.cpp" line="1501"/>
<location filename="../editor.cpp" line="1513"/>
<source>The text to be cut exceeds character limit!</source>
<translation></translation>
</message>
<message>
<location filename="../editor.cpp" line="2983"/>
<location filename="../editor.cpp" line="2995"/>
<source>Print Document</source>
<translation></translation>
</message>
<message>
<location filename="../editor.cpp" line="3618"/>
<location filename="../editor.cpp" line="3665"/>
<location filename="../editor.cpp" line="3710"/>
<location filename="../editor.cpp" line="3630"/>
<location filename="../editor.cpp" line="3677"/>
<location filename="../editor.cpp" line="3722"/>
<source>Ctrl+click for more info</source>
<translation>Ctrl+</translation>
</message>
@ -1440,27 +1446,27 @@ Are you really want to continue?</oldsource>
<translation type="vanished">&apos;%1&apos;!</translation>
</message>
<message>
<location filename="../editor.cpp" line="4549"/>
<location filename="../editor.cpp" line="4561"/>
<source>astyle not found</source>
<translation>astyle程序</translation>
</message>
<message>
<location filename="../editor.cpp" line="4550"/>
<location filename="../editor.cpp" line="4562"/>
<source>Can&apos;t find astyle in &quot;%1&quot;.</source>
<translation>astyle程序&quot;%1&quot;.</translation>
</message>
<message>
<location filename="../editor.cpp" line="4709"/>
<location filename="../editor.cpp" line="4721"/>
<source>Break point condition</source>
<translation></translation>
</message>
<message>
<location filename="../editor.cpp" line="4710"/>
<location filename="../editor.cpp" line="4722"/>
<source>Enter the condition of the breakpoint:</source>
<translation>:</translation>
</message>
<message>
<location filename="../editor.cpp" line="4953"/>
<location filename="../editor.cpp" line="4965"/>
<source>Readonly</source>
<translation></translation>
</message>
@ -4119,11 +4125,11 @@ Are you really want to continue?</oldsource>
<message>
<location filename="../mainwindow.ui" line="947"/>
<location filename="../mainwindow.ui" line="2968"/>
<location filename="../mainwindow.cpp" line="5494"/>
<location filename="../mainwindow.cpp" line="5497"/>
<location filename="../mainwindow.cpp" line="5501"/>
<location filename="../mainwindow.cpp" line="5504"/>
<location filename="../mainwindow.cpp" line="7609"/>
<location filename="../mainwindow.cpp" line="5496"/>
<location filename="../mainwindow.cpp" line="5499"/>
<location filename="../mainwindow.cpp" line="5503"/>
<location filename="../mainwindow.cpp" line="5506"/>
<location filename="../mainwindow.cpp" line="7644"/>
<source>Issues</source>
<translation></translation>
</message>
@ -4561,7 +4567,7 @@ Are you really want to continue?</oldsource>
<location filename="../mainwindow.ui" line="777"/>
<location filename="../mainwindow.ui" line="780"/>
<location filename="../mainwindow.cpp" line="2463"/>
<location filename="../mainwindow.cpp" line="8046"/>
<location filename="../mainwindow.cpp" line="8081"/>
<source>New Problem Set</source>
<translation></translation>
</message>
@ -4583,7 +4589,7 @@ Are you really want to continue?</oldsource>
<location filename="../mainwindow.ui" line="819"/>
<location filename="../mainwindow.ui" line="822"/>
<location filename="../mainwindow.cpp" line="2477"/>
<location filename="../mainwindow.cpp" line="8107"/>
<location filename="../mainwindow.cpp" line="8142"/>
<source>Save Problem Set</source>
<translation></translation>
</message>
@ -4591,7 +4597,7 @@ Are you really want to continue?</oldsource>
<location filename="../mainwindow.ui" line="833"/>
<location filename="../mainwindow.ui" line="836"/>
<location filename="../mainwindow.cpp" line="2484"/>
<location filename="../mainwindow.cpp" line="8143"/>
<location filename="../mainwindow.cpp" line="8178"/>
<source>Load Problem Set</source>
<translation></translation>
</message>
@ -4722,14 +4728,14 @@ Are you really want to continue?</oldsource>
<message>
<location filename="../mainwindow.ui" line="847"/>
<location filename="../mainwindow.cpp" line="2490"/>
<location filename="../mainwindow.cpp" line="9259"/>
<location filename="../mainwindow.cpp" line="9294"/>
<source>Import FPS Problem Set</source>
<translation>FPS试题集</translation>
</message>
<message>
<location filename="../mainwindow.ui" line="858"/>
<location filename="../mainwindow.cpp" line="2496"/>
<location filename="../mainwindow.cpp" line="9290"/>
<location filename="../mainwindow.cpp" line="9325"/>
<source>Export FPS Problem Set</source>
<translation>FPS试题集</translation>
</message>
@ -4971,7 +4977,7 @@ Are you really want to continue?</oldsource>
</message>
<message>
<location filename="../mainwindow.ui" line="2634"/>
<location filename="../mainwindow.cpp" line="6410"/>
<location filename="../mainwindow.cpp" line="6445"/>
<source>Clear all breakpoints</source>
<translation></translation>
</message>
@ -5223,7 +5229,7 @@ Are you really want to continue?</oldsource>
</message>
<message>
<location filename="../mainwindow.ui" line="2797"/>
<location filename="../mainwindow.cpp" line="7552"/>
<location filename="../mainwindow.cpp" line="7587"/>
<source>Rename Symbol</source>
<translation></translation>
</message>
@ -5244,13 +5250,13 @@ Are you really want to continue?</oldsource>
</message>
<message>
<location filename="../mainwindow.ui" line="2817"/>
<location filename="../mainwindow.cpp" line="7818"/>
<location filename="../mainwindow.cpp" line="7853"/>
<source>Export As RTF</source>
<translation>RTF</translation>
</message>
<message>
<location filename="../mainwindow.ui" line="2822"/>
<location filename="../mainwindow.cpp" line="7840"/>
<location filename="../mainwindow.cpp" line="7875"/>
<source>Export As HTML</source>
<translation>HTML</translation>
</message>
@ -5623,22 +5629,22 @@ Are you really want to continue?</oldsource>
<message>
<location filename="../mainwindow.cpp" line="2075"/>
<location filename="../mainwindow.cpp" line="2241"/>
<location filename="../mainwindow.cpp" line="5547"/>
<location filename="../mainwindow.cpp" line="5554"/>
<location filename="../mainwindow.cpp" line="5574"/>
<location filename="../mainwindow.cpp" line="5581"/>
<source>Wrong Compiler Settings</source>
<translation></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="2076"/>
<location filename="../mainwindow.cpp" line="2242"/>
<location filename="../mainwindow.cpp" line="5548"/>
<location filename="../mainwindow.cpp" line="5555"/>
<location filename="../mainwindow.cpp" line="5575"/>
<location filename="../mainwindow.cpp" line="5582"/>
<source>Compiler is set not to generate executable.</source>
<translation></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="2077"/>
<location filename="../mainwindow.cpp" line="5549"/>
<location filename="../mainwindow.cpp" line="5576"/>
<source>We need the executabe to run problem case.</source>
<translation></translation>
</message>
@ -5704,7 +5710,7 @@ Are you really want to continue?</oldsource>
</message>
<message>
<location filename="../mainwindow.cpp" line="2243"/>
<location filename="../mainwindow.cpp" line="5556"/>
<location filename="../mainwindow.cpp" line="5583"/>
<source>Please correct this before start debugging</source>
<translation></translation>
</message>
@ -5762,22 +5768,22 @@ Are you really want to continue?</oldsource>
<translation></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="9158"/>
<location filename="../mainwindow.cpp" line="9193"/>
<source>Go to Line</source>
<translation></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="9158"/>
<location filename="../mainwindow.cpp" line="9193"/>
<source>Line</source>
<translation></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="9180"/>
<location filename="../mainwindow.cpp" line="9215"/>
<source>Template Exists</source>
<translation></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="9181"/>
<location filename="../mainwindow.cpp" line="9216"/>
<source>Template %1 already exists. Do you want to overwrite?</source>
<translation>%1</translation>
</message>
@ -5803,7 +5809,7 @@ Are you really want to continue?</oldsource>
</message>
<message>
<location filename="../mainwindow.cpp" line="327"/>
<location filename="../mainwindow.cpp" line="8055"/>
<location filename="../mainwindow.cpp" line="8090"/>
<source>Problem Set %1</source>
<translation>%1</translation>
</message>
@ -5877,15 +5883,15 @@ Are you really want to continue?</oldsource>
</message>
<message>
<location filename="../mainwindow.cpp" line="4386"/>
<location filename="../mainwindow.cpp" line="7904"/>
<location filename="../mainwindow.cpp" line="7946"/>
<location filename="../mainwindow.cpp" line="7939"/>
<location filename="../mainwindow.cpp" line="7981"/>
<source>Bookmark Description</source>
<translation></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="4387"/>
<location filename="../mainwindow.cpp" line="7905"/>
<location filename="../mainwindow.cpp" line="7947"/>
<location filename="../mainwindow.cpp" line="7940"/>
<location filename="../mainwindow.cpp" line="7982"/>
<source>Description:</source>
<translation></translation>
</message>
@ -6066,7 +6072,7 @@ Are you really want to continue?</oldsource>
<location filename="../mainwindow.cpp" line="2801"/>
<location filename="../mainwindow.cpp" line="4267"/>
<location filename="../mainwindow.cpp" line="4273"/>
<location filename="../mainwindow.cpp" line="7144"/>
<location filename="../mainwindow.cpp" line="7179"/>
<source>Delete</source>
<translation></translation>
</message>
@ -6130,17 +6136,17 @@ Are you really want to continue?</oldsource>
<translation type="vanished"></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="9261"/>
<location filename="../mainwindow.cpp" line="9296"/>
<source>FPS Problem Set Files (*.fps;*.xml)</source>
<translation>FPS试题集文件(*.fps;*.xml)</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="9292"/>
<location filename="../mainwindow.cpp" line="9327"/>
<source>FPS Problem Set Files (*.fps)</source>
<translation>FPS试题集文件(*.fps)</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="9297"/>
<location filename="../mainwindow.cpp" line="9332"/>
<source>Export Error</source>
<translation></translation>
</message>
@ -6184,47 +6190,47 @@ Are you really want to continue?</oldsource>
</message>
<message>
<location filename="../mainwindow.cpp" line="4972"/>
<location filename="../mainwindow.cpp" line="8049"/>
<location filename="../mainwindow.cpp" line="8084"/>
<source>Do you want to save it?</source>
<translation></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="5072"/>
<location filename="../mainwindow.cpp" line="5086"/>
<location filename="../mainwindow.cpp" line="5074"/>
<location filename="../mainwindow.cpp" line="5088"/>
<source>File Changed</source>
<translation></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="5157"/>
<location filename="../mainwindow.cpp" line="5159"/>
<source>New Project File?</source>
<translation>?</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="5158"/>
<location filename="../mainwindow.cpp" line="5160"/>
<source>Do you want to add the new file to the project?</source>
<translation>?</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="5245"/>
<location filename="../mainwindow.cpp" line="5256"/>
<location filename="../mainwindow.cpp" line="5266"/>
<location filename="../mainwindow.cpp" line="8132"/>
<location filename="../mainwindow.cpp" line="5247"/>
<location filename="../mainwindow.cpp" line="5258"/>
<location filename="../mainwindow.cpp" line="5268"/>
<location filename="../mainwindow.cpp" line="8167"/>
<source>Save Error</source>
<translation></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="5412"/>
<location filename="../mainwindow.cpp" line="5414"/>
<source>Change Project Compiler Set</source>
<translation></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="5413"/>
<location filename="../mainwindow.cpp" line="5415"/>
<source>Change the project&apos;s compiler set will lose all custom compiler set options.</source>
<translation></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="3993"/>
<location filename="../mainwindow.cpp" line="5415"/>
<location filename="../mainwindow.cpp" line="5417"/>
<source>Do you really want to do that?</source>
<translation></translation>
</message>
@ -6247,78 +6253,78 @@ Are you really want to continue?</oldsource>
<translation type="vanished">%1</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="6278"/>
<location filename="../mainwindow.cpp" line="6313"/>
<source>Modify Watch</source>
<translation></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="6279"/>
<location filename="../mainwindow.cpp" line="6314"/>
<source>Watch Expression</source>
<translation></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="6411"/>
<location filename="../mainwindow.cpp" line="6446"/>
<source>Do you really want to clear all breakpoints in this file?</source>
<translation></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="6612"/>
<location filename="../mainwindow.cpp" line="6647"/>
<source>New project</source>
<translation></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="6613"/>
<location filename="../mainwindow.cpp" line="6648"/>
<source>Close %1 and start new project?</source>
<translation>&apos;%1&apos;?</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="6626"/>
<location filename="../mainwindow.cpp" line="6661"/>
<source>Folder not exist</source>
<translation></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="6627"/>
<location filename="../mainwindow.cpp" line="6662"/>
<source>Folder &apos;%1&apos; doesn&apos;t exist. Create it now?</source>
<translation>&apos;%1&apos;</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="6634"/>
<location filename="../mainwindow.cpp" line="6669"/>
<source>Can&apos;t create folder</source>
<translation></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="6635"/>
<location filename="../mainwindow.cpp" line="6670"/>
<source>Failed to create folder &apos;%1&apos;.</source>
<translation>&apos;%1&apos;</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="6650"/>
<location filename="../mainwindow.cpp" line="6685"/>
<source>Save new project as</source>
<translation></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="7145"/>
<location filename="../mainwindow.cpp" line="7180"/>
<source>Folder %1 is not empty.</source>
<translation>%1</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="7146"/>
<location filename="../mainwindow.cpp" line="7181"/>
<source>Do you really want to delete it?</source>
<translation></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="7969"/>
<location filename="../mainwindow.cpp" line="8004"/>
<source>Change working folder</source>
<translation></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="7970"/>
<location filename="../mainwindow.cpp" line="8005"/>
<source>File &apos;%1&apos; is not in the current working folder.</source>
<oldsource>File &apos;%1&apos; is not in the current working folder</oldsource>
<translation>&apos;%1&apos;</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="7973"/>
<location filename="../mainwindow.cpp" line="8008"/>
<source>Do you want to change working folder to &apos;%1&apos;?</source>
<translation>&apos;%1&apos;?</translation>
</message>
@ -6327,28 +6333,28 @@ Are you really want to continue?</oldsource>
<translation type="vanished">...</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="8680"/>
<location filename="../mainwindow.cpp" line="8715"/>
<source>Can&apos;t Commit</source>
<translation></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="8681"/>
<location filename="../mainwindow.cpp" line="8716"/>
<source>Git needs user info to commit.</source>
<translation>Git需要用信息进行提交</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="8949"/>
<location filename="../mainwindow.cpp" line="8984"/>
<source>Choose Input Data File</source>
<translation></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="8951"/>
<location filename="../mainwindow.cpp" line="9006"/>
<location filename="../mainwindow.cpp" line="8986"/>
<location filename="../mainwindow.cpp" line="9041"/>
<source>All files (*.*)</source>
<translation> (*.*)</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="9004"/>
<location filename="../mainwindow.cpp" line="9039"/>
<source>Choose Expected Output Data File</source>
<oldsource>Choose Expected Input Data File</oldsource>
<translation></translation>
@ -6360,59 +6366,59 @@ Are you really want to continue?</oldsource>
<message>
<location filename="../mainwindow.ui" line="2887"/>
<location filename="../mainwindow.ui" line="2890"/>
<location filename="../mainwindow.cpp" line="8025"/>
<location filename="../mainwindow.cpp" line="8060"/>
<source>Choose Working Folder</source>
<translation></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="8449"/>
<location filename="../mainwindow.cpp" line="8498"/>
<location filename="../mainwindow.cpp" line="8484"/>
<location filename="../mainwindow.cpp" line="8533"/>
<source>Header Exists</source>
<translation></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="8450"/>
<location filename="../mainwindow.cpp" line="8499"/>
<location filename="../mainwindow.cpp" line="8485"/>
<location filename="../mainwindow.cpp" line="8534"/>
<source>Header file &quot;%1&quot; already exists!</source>
<translation>&quot;%1&quot;</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="8504"/>
<location filename="../mainwindow.cpp" line="8539"/>
<source>Source Exists</source>
<translation></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="8505"/>
<location filename="../mainwindow.cpp" line="8540"/>
<source>Source file &quot;%1&quot; already exists!</source>
<translation>&quot;%1&quot;</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="8659"/>
<location filename="../mainwindow.cpp" line="8694"/>
<source>Can&apos;t commit!</source>
<translation></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="8660"/>
<location filename="../mainwindow.cpp" line="8695"/>
<source>The following files are in conflicting:</source>
<translation></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="8665"/>
<location filename="../mainwindow.cpp" line="8700"/>
<source>Commit Message</source>
<translation></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="8665"/>
<location filename="../mainwindow.cpp" line="8700"/>
<source>Commit Message:</source>
<translation></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="8668"/>
<location filename="../mainwindow.cpp" line="8703"/>
<source>Commit Failed</source>
<translation></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="8669"/>
<location filename="../mainwindow.cpp" line="8704"/>
<source>Commit message shouldn&apos;t be empty!</source>
<translation></translation>
</message>
@ -6421,22 +6427,22 @@ Are you really want to continue?</oldsource>
<translation type="vanished">Dev-C++ (*.dev)</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="6664"/>
<location filename="../mainwindow.cpp" line="6699"/>
<source>New project fail</source>
<translation></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="6665"/>
<location filename="../mainwindow.cpp" line="6700"/>
<source>Can&apos;t assign project template</source>
<translation>使</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="6766"/>
<location filename="../mainwindow.cpp" line="6801"/>
<source>Remove file</source>
<translation></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="6767"/>
<location filename="../mainwindow.cpp" line="6802"/>
<source>Remove the file from disk?</source>
<translation></translation>
</message>
@ -6445,27 +6451,27 @@ Are you really want to continue?</oldsource>
<translation type="vanished"></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="7068"/>
<location filename="../mainwindow.cpp" line="7103"/>
<source>New Project File Name</source>
<translation></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="7069"/>
<location filename="../mainwindow.cpp" line="7104"/>
<source>File Name:</source>
<translation></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="7077"/>
<location filename="../mainwindow.cpp" line="7112"/>
<source>File Already Exists!</source>
<translation></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="7078"/>
<location filename="../mainwindow.cpp" line="7113"/>
<source>File &apos;%1&apos; already exists!</source>
<translation>&apos;%1&apos;</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="6720"/>
<location filename="../mainwindow.cpp" line="6755"/>
<source>Add to project</source>
<translation></translation>
</message>
@ -6496,78 +6502,78 @@ Are you really want to continue?</oldsource>
<translation></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="6652"/>
<location filename="../mainwindow.cpp" line="6687"/>
<source>Red Panda C++ project file (*.dev)</source>
<translation>C++(*.dev)</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="7525"/>
<location filename="../mainwindow.cpp" line="7560"/>
<source>Rename Error</source>
<translation></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="7526"/>
<location filename="../mainwindow.cpp" line="7561"/>
<source>Symbol &apos;%1&apos; is defined in system header.</source>
<translation>&apos;%1&apos;</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="7553"/>
<location filename="../mainwindow.cpp" line="7588"/>
<source>New Name</source>
<translation></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="7723"/>
<location filename="../mainwindow.cpp" line="7746"/>
<location filename="../mainwindow.cpp" line="7757"/>
<location filename="../mainwindow.cpp" line="7778"/>
<location filename="../mainwindow.cpp" line="7758"/>
<location filename="../mainwindow.cpp" line="7781"/>
<location filename="../mainwindow.cpp" line="7792"/>
<location filename="../mainwindow.cpp" line="7813"/>
<source>Replace Error</source>
<translation></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="7724"/>
<location filename="../mainwindow.cpp" line="7759"/>
<source>Can&apos;t open file &apos;%1&apos; for replace!</source>
<translation>&apos;%1&apos;</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="7758"/>
<location filename="../mainwindow.cpp" line="7793"/>
<source>Contents has changed since last search!</source>
<translation></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="7820"/>
<location filename="../mainwindow.cpp" line="7855"/>
<source>Rich Text Format Files (*.rtf)</source>
<translation>RTF格式文件 (*.rtf)</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="7842"/>
<location filename="../mainwindow.cpp" line="7877"/>
<source>HTML Files (*.html)</source>
<translation>HTML文件 (*.html)</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="8047"/>
<location filename="../mainwindow.cpp" line="8082"/>
<source>The current problem set is not empty.</source>
<translation></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="8066"/>
<location filename="../mainwindow.cpp" line="8101"/>
<source>Problem %1</source>
<translation>%1</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="8114"/>
<location filename="../mainwindow.cpp" line="8145"/>
<location filename="../mainwindow.cpp" line="8149"/>
<location filename="../mainwindow.cpp" line="8180"/>
<source>Problem Set Files (*.pbs)</source>
<translation> (*.pbs)</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="8159"/>
<location filename="../mainwindow.cpp" line="9269"/>
<location filename="../mainwindow.cpp" line="8194"/>
<location filename="../mainwindow.cpp" line="9304"/>
<source>Load Error</source>
<translation></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="4075"/>
<location filename="../mainwindow.cpp" line="8173"/>
<location filename="../mainwindow.cpp" line="8208"/>
<source>Problem Case %1</source>
<translation>%1</translation>
</message>
@ -6581,13 +6587,13 @@ Are you really want to continue?</oldsource>
<location filename="../mainwindow.cpp" line="1458"/>
<location filename="../mainwindow.cpp" line="3201"/>
<location filename="../mainwindow.cpp" line="3318"/>
<location filename="../mainwindow.cpp" line="5079"/>
<location filename="../mainwindow.cpp" line="5197"/>
<location filename="../mainwindow.cpp" line="5378"/>
<location filename="../mainwindow.cpp" line="5390"/>
<location filename="../mainwindow.cpp" line="5843"/>
<location filename="../mainwindow.cpp" line="5855"/>
<location filename="../mainwindow.cpp" line="9089"/>
<location filename="../mainwindow.cpp" line="5081"/>
<location filename="../mainwindow.cpp" line="5199"/>
<location filename="../mainwindow.cpp" line="5380"/>
<location filename="../mainwindow.cpp" line="5392"/>
<location filename="../mainwindow.cpp" line="5870"/>
<location filename="../mainwindow.cpp" line="5882"/>
<location filename="../mainwindow.cpp" line="9124"/>
<source>Error</source>
<translation></translation>
</message>
@ -6614,79 +6620,79 @@ Are you really want to continue?</oldsource>
<translation></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="5073"/>
<location filename="../mainwindow.cpp" line="5075"/>
<source>File &apos;%1&apos; was changed.</source>
<translation>&apos;%1&apos;</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="5073"/>
<location filename="../mainwindow.cpp" line="5075"/>
<source>Reload its content from disk?</source>
<translation></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="5087"/>
<location filename="../mainwindow.cpp" line="5089"/>
<source>File &apos;%1&apos; was removed.</source>
<translation>&apos;%1&apos;</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="5087"/>
<location filename="../mainwindow.cpp" line="5089"/>
<source>Keep it open?</source>
<translation>C++</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="5190"/>
<location filename="../mainwindow.cpp" line="5192"/>
<source>Open</source>
<translation></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="5614"/>
<location filename="../mainwindow.cpp" line="5641"/>
<source>Compile Failed</source>
<translation></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="5620"/>
<location filename="../mainwindow.cpp" line="5647"/>
<source>Run Failed</source>
<translation></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="3349"/>
<location filename="../mainwindow.cpp" line="5872"/>
<location filename="../mainwindow.cpp" line="5886"/>
<location filename="../mainwindow.cpp" line="9072"/>
<location filename="../mainwindow.cpp" line="5899"/>
<location filename="../mainwindow.cpp" line="5913"/>
<location filename="../mainwindow.cpp" line="9107"/>
<source>Confirm Convertion</source>
<translation></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="3350"/>
<location filename="../mainwindow.cpp" line="5873"/>
<location filename="../mainwindow.cpp" line="5887"/>
<location filename="../mainwindow.cpp" line="9073"/>
<location filename="../mainwindow.cpp" line="5900"/>
<location filename="../mainwindow.cpp" line="5914"/>
<location filename="../mainwindow.cpp" line="9108"/>
<source>The editing file will be saved using %1 encoding. &lt;br /&gt;This operation can&apos;t be reverted. &lt;br /&gt;Are you sure to continue?</source>
<translation>使%1&lt;br /&gt;&lt;br /&gt;</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="6031"/>
<location filename="../mainwindow.cpp" line="6058"/>
<source>New Watch Expression</source>
<translation></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="6032"/>
<location filename="../mainwindow.cpp" line="6059"/>
<source>Enter Watch Expression (it is recommended to use &apos;this-&gt;&apos; for class members):</source>
<translation></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="6089"/>
<location filename="../mainwindow.cpp" line="6116"/>
<source>Parsing file %1 of %2: &quot;%3&quot;</source>
<translation>%1/%2&quot;%3&quot;</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="6111"/>
<location filename="../mainwindow.cpp" line="6117"/>
<location filename="../mainwindow.cpp" line="6138"/>
<location filename="../mainwindow.cpp" line="6144"/>
<source>Done parsing %1 files in %2 seconds</source>
<translation>%1,%2</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="6114"/>
<location filename="../mainwindow.cpp" line="6141"/>
<source>(%1 files per second)</source>
<translation>(%1</translation>
</message>
@ -7307,42 +7313,42 @@ Are you really want to continue?</oldsource>
<translation>- : %1</translation>
</message>
<message>
<location filename="../compiler/projectcompiler.cpp" line="539"/>
<location filename="../compiler/projectcompiler.cpp" line="543"/>
<source>Compiling project changes...</source>
<translation>...</translation>
</message>
<message>
<location filename="../compiler/projectcompiler.cpp" line="541"/>
<location filename="../compiler/projectcompiler.cpp" line="545"/>
<source>- Project Filename: %1</source>
<translation>- : %1</translation>
</message>
<message>
<location filename="../compiler/projectcompiler.cpp" line="542"/>
<location filename="../compiler/projectcompiler.cpp" line="546"/>
<source>- Compiler Set Name: %1</source>
<translation>- : %1</translation>
</message>
<message>
<location filename="../compiler/projectcompiler.cpp" line="551"/>
<location filename="../compiler/projectcompiler.cpp" line="555"/>
<source>Make program &apos;%1&apos; doesn&apos;t exists!</source>
<translation>Make程序%1</translation>
</message>
<message>
<location filename="../compiler/projectcompiler.cpp" line="553"/>
<location filename="../compiler/projectcompiler.cpp" line="557"/>
<source>Please check the &quot;program&quot; page of compiler settings.</source>
<translation></translation>
</message>
<message>
<location filename="../compiler/projectcompiler.cpp" line="583"/>
<location filename="../compiler/projectcompiler.cpp" line="587"/>
<source>Processing makefile:</source>
<translation>makefile...</translation>
</message>
<message>
<location filename="../compiler/projectcompiler.cpp" line="585"/>
<location filename="../compiler/projectcompiler.cpp" line="589"/>
<source>- makefile processer: %1</source>
<translation>- makefile处理器: %1</translation>
</message>
<message>
<location filename="../compiler/projectcompiler.cpp" line="586"/>
<location filename="../compiler/projectcompiler.cpp" line="590"/>
<source>- Command: %1 %2</source>
<translation>- : %1 %2</translation>
</message>
@ -9351,7 +9357,7 @@ Are you really want to continue?</oldsource>
<message>
<location filename="../mainwindow.cpp" line="2118"/>
<location filename="../mainwindow.cpp" line="2213"/>
<location filename="../mainwindow.cpp" line="9097"/>
<location filename="../mainwindow.cpp" line="9132"/>
<location filename="../settingsdialog/settingsdialog.cpp" line="167"/>
<location filename="../settingsdialog/settingsdialog.cpp" line="250"/>
<source>Compiler Set</source>
@ -9360,7 +9366,7 @@ Are you really want to continue?</oldsource>
<message>
<location filename="../mainwindow.cpp" line="2119"/>
<location filename="../mainwindow.cpp" line="2214"/>
<location filename="../mainwindow.cpp" line="9098"/>
<location filename="../mainwindow.cpp" line="9133"/>
<location filename="../settingsdialog/settingsdialog.cpp" line="167"/>
<location filename="../settingsdialog/settingsdialog.cpp" line="170"/>
<source>Compiler</source>
@ -9372,7 +9378,7 @@ Are you really want to continue?</oldsource>
<translation></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="8036"/>
<location filename="../mainwindow.cpp" line="8071"/>
<location filename="../settingsdialog/settingsdialog.cpp" line="173"/>
<location filename="../settingsdialog/settingsdialog.cpp" line="209"/>
<location filename="../settingsdialog/settingsdialog.cpp" line="215"/>
@ -9449,15 +9455,15 @@ Are you really want to continue?</oldsource>
<translation></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="8037"/>
<location filename="../mainwindow.cpp" line="8396"/>
<location filename="../mainwindow.cpp" line="8072"/>
<location filename="../mainwindow.cpp" line="8431"/>
<location filename="../settingsdialog/settingsdialog.cpp" line="209"/>
<location filename="../settingsdialog/settingsdialog.cpp" line="212"/>
<source>Program Runner</source>
<translation></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="8395"/>
<location filename="../mainwindow.cpp" line="8430"/>
<location filename="../settingsdialog/settingsdialog.cpp" line="212"/>
<source>Problem Set</source>
<translation></translation>

View File

@ -927,6 +927,10 @@
<source>Readonly</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Can&apos;t generate temporary backup file &apos;%1&apos;.</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>EditorAutoSaveWidget</name>

View File

@ -381,20 +381,22 @@ QByteArray readFileToByteArray(const QString &fileName)
return QByteArray();
}
void stringToFile(const QString &str, const QString &fileName)
bool stringToFile(const QString &str, const QString &fileName)
{
QFile file(fileName);
if (file.open(QIODevice::WriteOnly | QIODevice::Truncate)) {
if (!file.open(QIODevice::WriteOnly | QIODevice::Truncate))
return false;
QTextStream stream(&file);
stream<<str;
}
return true;
}
void stringsToFile(const QStringList &list, const QString &fileName)
bool stringsToFile(const QStringList &list, const QString &fileName)
{
QFile file(fileName);
if (file.open(QIODevice::WriteOnly | QIODevice::Truncate)) {
if (file.open(QIODevice::WriteOnly | QIODevice::Truncate))
return false;
QTextStream stream(&file);
for (const QString& s:list) {
stream<<s
@ -404,7 +406,7 @@ void stringsToFile(const QStringList &list, const QString &fileName)
<<endl;
#endif
}
}
return true;
}
bool fileExists(const QString &file)

View File

@ -108,8 +108,8 @@ void readFileToLines(const QString& fileName, QTextCodec* codec, LineProcessFunc
QByteArray readFileToByteArray(const QString& fileName);
void stringsToFile(const QStringList& list, const QString& fileName);
void stringToFile(const QString& str, const QString& fileName);
bool stringsToFile(const QStringList& list, const QString& fileName);
bool stringToFile(const QString& str, const QString& fileName);
void createFile(const QString& fileName);
/* File I/O utils */