- fix: Refresh files view shouldn'tchange open/save dialog's default folder

- enhancement: "locate in files view" will request user's confirmation when change the working folder
This commit is contained in:
Roy Qu 2022-03-10 20:28:01 +08:00
parent 4c8bed0445
commit 1b240f21ee
5 changed files with 97 additions and 62 deletions

View File

@ -1,5 +1,7 @@
Red Panda C++ Version 1.0.0
- fix: calculation for code snippets's tab stop positions is not correct
- fix: Refresh files view shouldn'tchange open/save dialog's default folder
- enhancement: "locate in files view" will request user's confirmation when change the working folder
Red Panda C++ Version 0.14.5
- fix: the "gnu c++ 20" option in compiler set options is wrong

View File

@ -1270,12 +1270,12 @@ Are you really want to continue?</oldsource>
<translation type="vanished"></translation>
</message>
<message>
<location filename="editor.cpp" line="259"/>
<location filename="editor.cpp" line="338"/>
<location filename="editor.cpp" line="1228"/>
<location filename="editor.cpp" line="1233"/>
<location filename="editor.cpp" line="1251"/>
<location filename="editor.cpp" line="1256"/>
<location filename="editor.cpp" line="261"/>
<location filename="editor.cpp" line="340"/>
<location filename="editor.cpp" line="1237"/>
<location filename="editor.cpp" line="1242"/>
<location filename="editor.cpp" line="1260"/>
<location filename="editor.cpp" line="1265"/>
<source>Error</source>
<translation></translation>
</message>
@ -1284,39 +1284,39 @@ Are you really want to continue?</oldsource>
<translation type="vanished">&quot;%1&quot;</translation>
</message>
<message>
<location filename="editor.cpp" line="289"/>
<location filename="editor.cpp" line="291"/>
<source>Save As</source>
<translation></translation>
</message>
<message>
<location filename="editor.cpp" line="1229"/>
<location filename="editor.cpp" line="1238"/>
<source>The text to be copied exceeds count limit!</source>
<translation></translation>
</message>
<message>
<location filename="editor.cpp" line="1234"/>
<location filename="editor.cpp" line="1243"/>
<source>The text to be copied exceeds character limit!</source>
<translation></translation>
</message>
<message>
<location filename="editor.cpp" line="1252"/>
<location filename="editor.cpp" line="1261"/>
<source>The text to be cut exceeds count limit!</source>
<translation></translation>
</message>
<message>
<location filename="editor.cpp" line="1257"/>
<location filename="editor.cpp" line="1266"/>
<source>The text to be cut exceeds character limit!</source>
<translation></translation>
</message>
<message>
<location filename="editor.cpp" line="2582"/>
<location filename="editor.cpp" line="2685"/>
<source>Print Document</source>
<translation></translation>
</message>
<message>
<location filename="editor.cpp" line="3179"/>
<location filename="editor.cpp" line="3218"/>
<location filename="editor.cpp" line="3272"/>
<location filename="editor.cpp" line="3282"/>
<location filename="editor.cpp" line="3321"/>
<location filename="editor.cpp" line="3375"/>
<source>Ctrl+click for more info</source>
<translation>Ctrl+</translation>
</message>
@ -1325,27 +1325,27 @@ Are you really want to continue?</oldsource>
<translation type="vanished">&apos;%1&apos;!</translation>
</message>
<message>
<location filename="editor.cpp" line="4000"/>
<location filename="editor.cpp" line="4110"/>
<source>astyle not found</source>
<translation>astyle程序</translation>
</message>
<message>
<location filename="editor.cpp" line="4001"/>
<location filename="editor.cpp" line="4111"/>
<source>Can&apos;t find astyle in &quot;%1&quot;.</source>
<translation>astyle程序&quot;%1&quot;.</translation>
</message>
<message>
<location filename="editor.cpp" line="4151"/>
<location filename="editor.cpp" line="4261"/>
<source>Break point condition</source>
<translation></translation>
</message>
<message>
<location filename="editor.cpp" line="4152"/>
<location filename="editor.cpp" line="4262"/>
<source>Enter the condition of the breakpoint:</source>
<translation>:</translation>
</message>
<message>
<location filename="editor.cpp" line="4367"/>
<location filename="editor.cpp" line="4477"/>
<source>Readonly</source>
<translation></translation>
</message>
@ -4199,7 +4199,7 @@ Are you really want to continue?</oldsource>
<message>
<location filename="mainwindow.ui" line="359"/>
<location filename="mainwindow.ui" line="362"/>
<location filename="mainwindow.cpp" line="6269"/>
<location filename="mainwindow.cpp" line="6284"/>
<source>New Problem Set</source>
<translation></translation>
</message>
@ -4218,14 +4218,14 @@ Are you really want to continue?</oldsource>
<message>
<location filename="mainwindow.ui" line="401"/>
<location filename="mainwindow.ui" line="404"/>
<location filename="mainwindow.cpp" line="6312"/>
<location filename="mainwindow.cpp" line="6327"/>
<source>Save Problem Set</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.ui" line="415"/>
<location filename="mainwindow.ui" line="418"/>
<location filename="mainwindow.cpp" line="6336"/>
<location filename="mainwindow.cpp" line="6351"/>
<source>Load Problem Set</source>
<translation></translation>
</message>
@ -5172,7 +5172,7 @@ Are you really want to continue?</oldsource>
</message>
<message>
<location filename="mainwindow.cpp" line="277"/>
<location filename="mainwindow.cpp" line="6278"/>
<location filename="mainwindow.cpp" line="6293"/>
<source>Problem Set %1</source>
<translation>%1</translation>
</message>
@ -5452,7 +5452,7 @@ Are you really want to continue?</oldsource>
</message>
<message>
<location filename="mainwindow.cpp" line="3802"/>
<location filename="mainwindow.cpp" line="6272"/>
<location filename="mainwindow.cpp" line="6287"/>
<source>Do you want to save it?</source>
<translation></translation>
</message>
@ -5476,7 +5476,7 @@ Are you really want to continue?</oldsource>
<location filename="mainwindow.cpp" line="4049"/>
<location filename="mainwindow.cpp" line="4059"/>
<location filename="mainwindow.cpp" line="4071"/>
<location filename="mainwindow.cpp" line="6325"/>
<location filename="mainwindow.cpp" line="6340"/>
<source>Save Error</source>
<translation></translation>
</message>
@ -5546,71 +5546,87 @@ Are you really want to continue?</oldsource>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="6850"/>
<location filename="mainwindow.cpp" line="6223"/>
<source>Change working folder</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="6224"/>
<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="6227"/>
<source>Do you want to change working folder to &apos;%1&apos;?</source>
<translation>&apos;%1&apos;?</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="6865"/>
<source>Can&apos;t Commit</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="6851"/>
<location filename="mainwindow.cpp" line="6866"/>
<source>Git needs user info to commit.</source>
<translation>Git需要用信息进行提交</translation>
</message>
<message>
<location filename="mainwindow.ui" line="2556"/>
<location filename="mainwindow.ui" line="2559"/>
<location filename="mainwindow.cpp" line="6248"/>
<location filename="mainwindow.cpp" line="6263"/>
<source>Choose Working Folder</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="6618"/>
<location filename="mainwindow.cpp" line="6670"/>
<location filename="mainwindow.cpp" line="6633"/>
<location filename="mainwindow.cpp" line="6685"/>
<source>Header Exists</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="6619"/>
<location filename="mainwindow.cpp" line="6671"/>
<location filename="mainwindow.cpp" line="6634"/>
<location filename="mainwindow.cpp" line="6686"/>
<source>Header file &quot;%1&quot; already exists!</source>
<translation>&quot;%1&quot;</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="6676"/>
<location filename="mainwindow.cpp" line="6691"/>
<source>Source Exists</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="6677"/>
<location filename="mainwindow.cpp" line="6692"/>
<source>Source file &quot;%1&quot; already exists!</source>
<translation>&quot;%1&quot;</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="6829"/>
<location filename="mainwindow.cpp" line="6844"/>
<source>Can&apos;t commit!</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="6830"/>
<location filename="mainwindow.cpp" line="6845"/>
<source>The following files are in conflicting:</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="6835"/>
<location filename="mainwindow.cpp" line="6850"/>
<source>Commit Message</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="6835"/>
<location filename="mainwindow.cpp" line="6850"/>
<source>Commit Message:</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="6838"/>
<location filename="mainwindow.cpp" line="6853"/>
<source>Commit Failed</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="6839"/>
<location filename="mainwindow.cpp" line="6854"/>
<source>Commit message shouldn&apos;t be empty!</source>
<translation></translation>
</message>
@ -5715,29 +5731,29 @@ Are you really want to continue?</oldsource>
<translation>HTML文件 (*.html)</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="6270"/>
<location filename="mainwindow.cpp" line="6285"/>
<source>The current problem set is not empty.</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="6288"/>
<location filename="mainwindow.cpp" line="6303"/>
<source>Problem %1</source>
<translation>%1</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="6314"/>
<location filename="mainwindow.cpp" line="6338"/>
<location filename="mainwindow.cpp" line="6329"/>
<location filename="mainwindow.cpp" line="6353"/>
<source>Problem Set Files (*.pbs)</source>
<translation> (*.pbs)</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="6344"/>
<location filename="mainwindow.cpp" line="6359"/>
<source>Load Error</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="3478"/>
<location filename="mainwindow.cpp" line="6358"/>
<location filename="mainwindow.cpp" line="6373"/>
<source>Problem Case %1</source>
<translation>%1</translation>
</message>
@ -7994,7 +8010,7 @@ Are you really want to continue?</oldsource>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="6259"/>
<location filename="mainwindow.cpp" line="6274"/>
<location filename="settingsdialog/settingsdialog.cpp" line="170"/>
<location filename="settingsdialog/settingsdialog.cpp" line="203"/>
<location filename="settingsdialog/settingsdialog.cpp" line="209"/>
@ -8070,15 +8086,15 @@ Are you really want to continue?</oldsource>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="6260"/>
<location filename="mainwindow.cpp" line="6573"/>
<location filename="mainwindow.cpp" line="6275"/>
<location filename="mainwindow.cpp" line="6588"/>
<location filename="settingsdialog/settingsdialog.cpp" line="203"/>
<location filename="settingsdialog/settingsdialog.cpp" line="206"/>
<source>Program Runner</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="6572"/>
<location filename="mainwindow.cpp" line="6587"/>
<location filename="settingsdialog/settingsdialog.cpp" line="206"/>
<source>Problem Set</source>
<translation></translation>

View File

@ -352,9 +352,6 @@ int main(int argc, char *argv[])
QMessageBox::Ok);
}
//set default open folder
QDir::setCurrent(pSettings->environment().defaultOpenFolder());
MainWindow mainWindow;
pMainWindow = &mainWindow;
if (app.arguments().count()>1) {
@ -375,6 +372,10 @@ int main(int argc, char *argv[])
setScreenDPI(mainWindow.screen()->logicalDotsPerInch());
#endif
mainWindow.show();
//reset default open folder
QDir::setCurrent(pSettings->environment().defaultOpenFolder());
#ifdef Q_OS_WIN
WindowLogoutEventFilter filter;
app.installNativeEventFilter(&filter);

View File

@ -5929,13 +5929,14 @@ void MainWindow::showSearchReplacePanel(bool show)
mSearchResultTreeModel->setSelectable(show);
}
void MainWindow::setFilesViewRoot(const QString &path)
void MainWindow::setFilesViewRoot(const QString &path, bool setOpenFolder)
{
mFileSystemModelIconProvider.setRootFolder(path);
mFileSystemModel.setIconProvider(&mFileSystemModelIconProvider);
mFileSystemModel.setRootPath(path);
ui->treeFiles->setRootIndex(mFileSystemModel.index(path));
pSettings->environment().setCurrentFolder(path);
if (setOpenFolder)
QDir::setCurrent(path);
int pos = ui->cbFilesPath->findText(path);
if (pos<0) {
@ -6216,15 +6217,30 @@ void MainWindow::on_actionLocate_in_Files_View_triggered()
{
Editor * editor = mEditorList->getEditor();
if (editor) {
QModelIndex index = mFileSystemModel.index(editor->filename());
if (!index.isValid()) {
QFileInfo fileInfo(editor->filename());
if (!fileInfo.absoluteFilePath().startsWith(
mFileSystemModel.rootDirectory().absolutePath()+"/",
PATH_SENSITIVITY
)) {
QString fileDir = extractFileDir(editor->filename());
if (QMessageBox::question(this,
tr("Change working folder"),
tr("File '%1' is not in the current working folder.")
.arg(extractFileName(editor->filename()))
+"<br />"
+tr("Do you want to change working folder to '%1'?")
.arg(fileDir),
QMessageBox::Yes | QMessageBox::No,
QMessageBox::Yes
)!=QMessageBox::Yes) {
return;
}
if (!fileDir.isEmpty())
setFilesViewRoot(fileDir);
setFilesViewRoot(fileDir,true);
else
return;
index = mFileSystemModel.index(editor->filename());
}
QModelIndex index = mFileSystemModel.index(editor->filename());
ui->treeFiles->setCurrentIndex(index);
ui->treeFiles->scrollTo(index, QAbstractItemView::PositionAtCenter);
ui->tabInfos->setCurrentWidget(ui->tabFiles);
@ -6252,7 +6268,7 @@ void MainWindow::on_actionOpen_Folder_triggered()
QString folder = QFileDialog::getExistingDirectory(this,tr("Choose Working Folder"),
pSettings->environment().currentFolder());
if (!folder.isEmpty()) {
setFilesViewRoot(folder);
setFilesViewRoot(folder,true);
}
}

View File

@ -243,7 +243,7 @@ private:
void scanActiveProject(bool parse=false);
void includeOrSkipDirs(const QStringList& dirs, bool skip);
void showSearchReplacePanel(bool show);
void setFilesViewRoot(const QString& path);
void setFilesViewRoot(const QString& path, bool setOpenFolder=false);
void clearIssues();
void doCompileRun(RunType runType);
void updateProblemCaseOutput(POJProblemCase problemCase);