- enhancement: prompt for filename when create new project unit file

This commit is contained in:
royqh1979@gmail.com 2021-10-25 13:16:15 +08:00
parent b7aa67c9a4
commit 148e99e483
4 changed files with 139 additions and 84 deletions

View File

@ -13,6 +13,7 @@ Version 0.7.3
- fix: syntax issues' filepath info not correct when build projects
- fix: compiler autolinks options widget don't show autolink infos
- fix: autolink parameters are repeated when compile single files
- enhancement: prompt for filename when create new project unit file
Version 0.7.2
- fix: rainbow parenthesis stop functioning when change editor's general options

View File

@ -485,7 +485,7 @@
<translation>[]</translation>
</message>
<message>
<location filename="compiler/compiler.cpp" line="575"/>
<location filename="compiler/compiler.cpp" line="579"/>
<source>The compiler process for &apos;%1&apos; failed to start.</source>
<translation>&apos;%1&apos;</translation>
</message>
@ -494,27 +494,27 @@
<translation type="vanished"></translation>
</message>
<message>
<location filename="compiler/compiler.cpp" line="579"/>
<location filename="compiler/compiler.cpp" line="583"/>
<source>The compiler process crashed after starting successfully.</source>
<translation></translation>
</message>
<message>
<location filename="compiler/compiler.cpp" line="582"/>
<location filename="compiler/compiler.cpp" line="586"/>
<source>The last waitFor...() function timed out.</source>
<translation>waitFor()</translation>
</message>
<message>
<location filename="compiler/compiler.cpp" line="585"/>
<location filename="compiler/compiler.cpp" line="589"/>
<source>An error occurred when attempting to write to the compiler process.</source>
<translation></translation>
</message>
<message>
<location filename="compiler/compiler.cpp" line="588"/>
<location filename="compiler/compiler.cpp" line="592"/>
<source>An error occurred when attempting to read from the compiler process.</source>
<translation></translation>
</message>
<message>
<location filename="compiler/compiler.cpp" line="591"/>
<location filename="compiler/compiler.cpp" line="595"/>
<source>An unknown error occurred.</source>
<translation></translation>
</message>
@ -550,44 +550,44 @@
<context>
<name>CompilerManager</name>
<message>
<location filename="compiler/compilermanager.cpp" line="47"/>
<location filename="compiler/compilermanager.cpp" line="88"/>
<location filename="compiler/compilermanager.cpp" line="118"/>
<location filename="compiler/compilermanager.cpp" line="150"/>
<location filename="compiler/compilermanager.cpp" line="169"/>
<location filename="compiler/compilermanager.cpp" line="52"/>
<location filename="compiler/compilermanager.cpp" line="93"/>
<location filename="compiler/compilermanager.cpp" line="123"/>
<location filename="compiler/compilermanager.cpp" line="155"/>
<location filename="compiler/compilermanager.cpp" line="174"/>
<source>No compiler set</source>
<translation></translation>
</message>
<message>
<location filename="compiler/compilermanager.cpp" line="48"/>
<location filename="compiler/compilermanager.cpp" line="89"/>
<location filename="compiler/compilermanager.cpp" line="119"/>
<location filename="compiler/compilermanager.cpp" line="151"/>
<location filename="compiler/compilermanager.cpp" line="170"/>
<location filename="compiler/compilermanager.cpp" line="53"/>
<location filename="compiler/compilermanager.cpp" line="94"/>
<location filename="compiler/compilermanager.cpp" line="124"/>
<location filename="compiler/compilermanager.cpp" line="156"/>
<location filename="compiler/compilermanager.cpp" line="175"/>
<source>No compiler set is configured.</source>
<translation></translation>
</message>
<message>
<location filename="compiler/compilermanager.cpp" line="48"/>
<location filename="compiler/compilermanager.cpp" line="89"/>
<location filename="compiler/compilermanager.cpp" line="119"/>
<location filename="compiler/compilermanager.cpp" line="151"/>
<location filename="compiler/compilermanager.cpp" line="170"/>
<location filename="compiler/compilermanager.cpp" line="53"/>
<location filename="compiler/compilermanager.cpp" line="94"/>
<location filename="compiler/compilermanager.cpp" line="124"/>
<location filename="compiler/compilermanager.cpp" line="156"/>
<location filename="compiler/compilermanager.cpp" line="175"/>
<source>Can&apos;t start debugging.</source>
<translation></translation>
</message>
<message>
<location filename="compiler/compilermanager.cpp" line="58"/>
<location filename="compiler/compilermanager.cpp" line="63"/>
<source>Encoding not support</source>
<translation></translation>
</message>
<message>
<location filename="compiler/compilermanager.cpp" line="59"/>
<location filename="compiler/compilermanager.cpp" line="64"/>
<source>Clang only support utf-8 encoding.</source>
<translation>Clang只支持UTF-8</translation>
</message>
<message>
<location filename="compiler/compilermanager.cpp" line="61"/>
<location filename="compiler/compilermanager.cpp" line="66"/>
<source>Strings in the program might be wrongly processed.</source>
<translation></translation>
</message>
@ -1077,23 +1077,23 @@ Are you really want to continue?</source>
<translation>Ctrl+</translation>
</message>
<message>
<location filename="editor.cpp" line="3151"/>
<location filename="editor.cpp" line="3181"/>
<location filename="editor.cpp" line="3161"/>
<location filename="editor.cpp" line="3191"/>
<source>Symbol &apos;%1&apos; not found!</source>
<translation>&apos;%1&apos;!</translation>
</message>
<message>
<location filename="editor.cpp" line="3596"/>
<location filename="editor.cpp" line="3606"/>
<source>Break point condition</source>
<translation></translation>
</message>
<message>
<location filename="editor.cpp" line="3597"/>
<location filename="editor.cpp" line="3607"/>
<source>Enter the condition of the breakpoint:</source>
<translation>:</translation>
</message>
<message>
<location filename="editor.cpp" line="3778"/>
<location filename="editor.cpp" line="3788"/>
<source>Readonly</source>
<translation></translation>
</message>
@ -1872,7 +1872,7 @@ Are you really want to continue?</source>
<context>
<name>ExecutableRunner</name>
<message>
<location filename="compiler/executablerunner.cpp" line="117"/>
<location filename="compiler/executablerunner.cpp" line="126"/>
<source>The runner process &apos;%1&apos; failed to start.</source>
<oldsource>The runner process failed to start.</oldsource>
<translation>&apos;%1&apos;</translation>
@ -1882,17 +1882,17 @@ Are you really want to continue?</source>
<translation type="vanished"></translation>
</message>
<message>
<location filename="compiler/executablerunner.cpp" line="124"/>
<location filename="compiler/executablerunner.cpp" line="133"/>
<source>The last waitFor...() function timed out.</source>
<translation>waitFor()</translation>
</message>
<message>
<location filename="compiler/executablerunner.cpp" line="127"/>
<location filename="compiler/executablerunner.cpp" line="136"/>
<source>An error occurred when attempting to write to the runner process.</source>
<translation></translation>
</message>
<message>
<location filename="compiler/executablerunner.cpp" line="130"/>
<location filename="compiler/executablerunner.cpp" line="139"/>
<source>An error occurred when attempting to read from the runner process.</source>
<translation></translation>
</message>
@ -1982,7 +1982,7 @@ Are you really want to continue?</source>
</message>
<message>
<location filename="compiler/filecompiler.cpp" line="35"/>
<location filename="compiler/filecompiler.cpp" line="88"/>
<location filename="compiler/filecompiler.cpp" line="89"/>
<source>Can&apos;t delete the old executable file &quot;%1&quot;.
</source>
<translation>&quot;%1&quot;.</translation>
@ -1994,22 +1994,22 @@ Are you really want to continue?</source>
<translation>%1</translation>
</message>
<message>
<location filename="compiler/filecompiler.cpp" line="65"/>
<location filename="compiler/filecompiler.cpp" line="66"/>
<source>The Compiler &apos;%1&apos; doesn&apos;t exists!</source>
<translation>&quot;%1&quot;</translation>
</message>
<message>
<location filename="compiler/filecompiler.cpp" line="68"/>
<location filename="compiler/filecompiler.cpp" line="69"/>
<source>Processing %1 source file:</source>
<translation>%1:</translation>
</message>
<message>
<location filename="compiler/filecompiler.cpp" line="70"/>
<location filename="compiler/filecompiler.cpp" line="71"/>
<source>%1 Compiler: %2</source>
<translation>%1: %2</translation>
</message>
<message>
<location filename="compiler/filecompiler.cpp" line="71"/>
<location filename="compiler/filecompiler.cpp" line="72"/>
<source>Command: %1 %2</source>
<translation>: %1 %2</translation>
</message>
@ -2811,6 +2811,7 @@ Are you really want to continue?</source>
<location filename="mainwindow.cpp" line="3115"/>
<location filename="mainwindow.cpp" line="3119"/>
<location filename="mainwindow.cpp" line="3122"/>
<location filename="mainwindow.cpp" line="4518"/>
<source>Issues</source>
<translation></translation>
</message>
@ -3566,7 +3567,7 @@ Are you really want to continue?</source>
</message>
<message>
<location filename="mainwindow.ui" line="1934"/>
<location filename="mainwindow.cpp" line="4453"/>
<location filename="mainwindow.cpp" line="4475"/>
<source>Rename Symbol</source>
<translation></translation>
</message>
@ -3587,13 +3588,13 @@ Are you really want to continue?</source>
</message>
<message>
<location filename="mainwindow.ui" line="1954"/>
<location filename="mainwindow.cpp" line="4566"/>
<location filename="mainwindow.cpp" line="4597"/>
<source>Export As RTF</source>
<translation>RTF</translation>
</message>
<message>
<location filename="mainwindow.ui" line="1959"/>
<location filename="mainwindow.cpp" line="4588"/>
<location filename="mainwindow.cpp" line="4619"/>
<source>Export As HTML</source>
<translation>HTML</translation>
</message>
@ -3639,7 +3640,7 @@ Are you really want to continue?</source>
</message>
<message>
<location filename="mainwindow.ui" line="2018"/>
<location filename="mainwindow.cpp" line="4726"/>
<location filename="mainwindow.cpp" line="4757"/>
<source>Open Folder</source>
<translation></translation>
</message>
@ -3890,15 +3891,15 @@ Are you really want to continue?</source>
</message>
<message>
<location filename="mainwindow.cpp" line="1771"/>
<location filename="mainwindow.cpp" line="4646"/>
<location filename="mainwindow.cpp" line="4686"/>
<location filename="mainwindow.cpp" line="4677"/>
<location filename="mainwindow.cpp" line="4717"/>
<source>Bookmark Description</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="1772"/>
<location filename="mainwindow.cpp" line="4647"/>
<location filename="mainwindow.cpp" line="4687"/>
<location filename="mainwindow.cpp" line="4678"/>
<location filename="mainwindow.cpp" line="4718"/>
<source>Description:</source>
<translation></translation>
</message>
@ -4102,48 +4103,73 @@ Are you really want to continue?</source>
<translation>使</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="4226"/>
<location filename="mainwindow.cpp" line="4212"/>
<source>untitled</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="4221"/>
<source>New Project File Name</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="4222"/>
<source>File Name:</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="4228"/>
<source>File Already Exists!</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="4229"/>
<source>File &apos;%1&apos; already exists!</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="4248"/>
<source>Add to project</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="4439"/>
<location filename="mainwindow.cpp" line="4461"/>
<source>Rename Error</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="4440"/>
<location filename="mainwindow.cpp" line="4462"/>
<source>Symbol &apos;%1&apos; is defined in system header.</source>
<translation>&apos;%1&apos;</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="4454"/>
<location filename="mainwindow.cpp" line="4476"/>
<source>New Name</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="4511"/>
<location filename="mainwindow.cpp" line="4521"/>
<location filename="mainwindow.cpp" line="4542"/>
<location filename="mainwindow.cpp" line="4552"/>
<source>Replace Error</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="4512"/>
<location filename="mainwindow.cpp" line="4543"/>
<source>Can&apos;t open file &apos;%1&apos; for replace!</source>
<translation>&apos;%1&apos;</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="4522"/>
<location filename="mainwindow.cpp" line="4553"/>
<source>Contents has changed since last search!</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="4568"/>
<location filename="mainwindow.cpp" line="4599"/>
<source>Rich Text Format Files (*.rtf)</source>
<translation>RTF格式文件 (*.rtf)</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="4590"/>
<location filename="mainwindow.cpp" line="4621"/>
<source>HTML Files (*.html)</source>
<translation>HTML文件 (*.html)</translation>
</message>
@ -4322,62 +4348,67 @@ Are you really want to continue?</source>
<translation>&apos;%1&apos;.</translation>
</message>
<message>
<location filename="project.cpp" line="771"/>
<location filename="project.cpp" line="669"/>
<source>Error Load File</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="project.cpp" line="777"/>
<source>File Exists</source>
<translation></translation>
</message>
<message>
<location filename="project.cpp" line="772"/>
<location filename="project.cpp" line="778"/>
<source>File &apos;%1&apos; is already in the project</source>
<translation>&apos;%1&apos;</translation>
</message>
<message>
<location filename="project.cpp" line="1137"/>
<location filename="project.cpp" line="1143"/>
<source>Project Updated</source>
<translation></translation>
</message>
<message>
<location filename="project.cpp" line="1138"/>
<location filename="project.cpp" line="1144"/>
<source>Your project was succesfully updated to a newer file format!</source>
<translation></translation>
</message>
<message>
<location filename="project.cpp" line="1140"/>
<location filename="project.cpp" line="1146"/>
<source>If something has gone wrong, we kept a backup-file: &apos;%1&apos;...</source>
<translation>&apos;%1&apos;</translation>
</message>
<message>
<location filename="project.cpp" line="1316"/>
<location filename="project.cpp" line="1322"/>
<source>Settings need update</source>
<translation></translation>
</message>
<message>
<location filename="project.cpp" line="1317"/>
<location filename="project.cpp" line="1323"/>
<source>The compiler settings format of Dev-C++ has changed.</source>
<translation>Dev-C++</translation>
</message>
<message>
<location filename="project.cpp" line="1319"/>
<location filename="project.cpp" line="1325"/>
<source>Please update your settings at Project &gt;&gt; Project Options &gt;&gt; Compiler and save your project.</source>
<translation> &gt;&gt; &gt;&gt; </translation>
</message>
<message>
<location filename="project.cpp" line="1355"/>
<location filename="project.cpp" line="1361"/>
<source>Compiler not found</source>
<translation></translation>
</message>
<message>
<location filename="project.cpp" line="1356"/>
<location filename="project.cpp" line="1362"/>
<source>The compiler set you have selected for this project, no longer exists.</source>
<translation></translation>
</message>
<message>
<location filename="project.cpp" line="1358"/>
<location filename="project.cpp" line="1364"/>
<source>It will be substituted by the global compiler set.</source>
<translation></translation>
</message>
<message>
<location filename="project.cpp" line="1383"/>
<location filename="project.cpp" line="1389"/>
<source>Developed using the Red Panda Dev-C++ IDE</source>
<translation>使Dev-C++</translation>
</message>
@ -4763,24 +4794,24 @@ Are you really want to continue?</source>
<context>
<name>ProjectModel</name>
<message>
<location filename="project.cpp" line="1870"/>
<location filename="project.cpp" line="1876"/>
<source>File exists</source>
<translation></translation>
</message>
<message>
<location filename="project.cpp" line="1871"/>
<location filename="project.cpp" line="1877"/>
<source>File &apos;%1&apos; already exists. Delete it now?</source>
<translation>&apos;%1&apos;</translation>
</message>
<message>
<location filename="project.cpp" line="1889"/>
<location filename="project.cpp" line="1909"/>
<location filename="project.cpp" line="1895"/>
<location filename="project.cpp" line="1915"/>
<source>Remove failed</source>
<translation></translation>
</message>
<message>
<location filename="project.cpp" line="1890"/>
<location filename="project.cpp" line="1910"/>
<location filename="project.cpp" line="1896"/>
<location filename="project.cpp" line="1916"/>
<source>Failed to remove file &apos;%1&apos;</source>
<translation>&apos;%1&apos;</translation>
</message>
@ -6039,7 +6070,7 @@ Are you really want to continue?</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="4737"/>
<location filename="mainwindow.cpp" line="4768"/>
<location filename="settingsdialog/settingsdialog.cpp" line="130"/>
<location filename="settingsdialog/settingsdialog.cpp" line="174"/>
<location filename="settingsdialog/settingsdialog.cpp" line="178"/>
@ -6115,7 +6146,7 @@ Are you really want to continue?</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="4738"/>
<location filename="mainwindow.cpp" line="4769"/>
<location filename="settingsdialog/settingsdialog.cpp" line="174"/>
<source>Program Runner</source>
<translation></translation>
@ -6271,22 +6302,22 @@ Are you really want to continue?</source>
<translation>%1</translation>
</message>
<message>
<location filename="compiler/stdincompiler.cpp" line="53"/>
<location filename="compiler/stdincompiler.cpp" line="54"/>
<source>The Compiler &apos;%1&apos; doesn&apos;t exists!</source>
<translation>&apos;%1&apos;</translation>
</message>
<message>
<location filename="compiler/stdincompiler.cpp" line="56"/>
<location filename="compiler/stdincompiler.cpp" line="57"/>
<source>Processing %1 source file:</source>
<translation>%1:</translation>
</message>
<message>
<location filename="compiler/stdincompiler.cpp" line="58"/>
<location filename="compiler/stdincompiler.cpp" line="59"/>
<source>%1 Compiler: %2</source>
<translation>%1: %2</translation>
</message>
<message>
<location filename="compiler/stdincompiler.cpp" line="59"/>
<location filename="compiler/stdincompiler.cpp" line="60"/>
<source>Command: %1 %2</source>
<translation>: %1 %2</translation>
</message>

View File

@ -4209,14 +4209,37 @@ void MainWindow::on_actionProject_New_File_triggered()
if (current.isValid()) {
node = static_cast<FolderNode*>(current.internalPointer());
}
QString newFileName;
do {
newFileName = tr("untitled")+QString("%1").arg(getNewFileNumber());
if (mProject->options().useGPP) {
newFileName+=".cpp";
} else {
newFileName+=".c";
}
} while (fileExists(QDir(mProject->directory()).absoluteFilePath(newFileName)));
newFileName = QInputDialog::getText(
this,
tr("New Project File Name"),
tr("File Name:"),
QLineEdit::Normal,
newFileName);
if (newFileName.isEmpty())
return;
if (fileExists(QDir(mProject->directory()).absoluteFilePath(newFileName))) {
QMessageBox::critical(this,tr("File Already Exists!"),
tr("File '%1' already exists!").arg(newFileName));
return;
}
PProjectUnit newUnit = mProject->newUnit(
mProject->pointerToNode(node));
mProject->pointerToNode(node),newFileName);
idx = mProject->units().count()-1;
mProject->saveUnits();
updateProjectView();
Editor * editor = mProject->openUnit(idx);
editor->setUseCppSyntax(mProject->options().useGPP);
editor->setModified(true);
//editor->setUseCppSyntax(mProject->options().useGPP);
//editor->setModified(true);
editor->activate();
}

View File

@ -1725,7 +1725,7 @@ bool ProjectUnit::save()
// file is neither open, nor saved
QStringList temp;
StringsToFile(temp,mFileName);
} else if (mEditor and modified()) {
} else if (mEditor && mEditor->modified()) {
result = mEditor->save();
}
if (mNode) {