From 4380470cef22cbc344d40a76a134e3ff5fa4b093 Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Tue, 25 Oct 2022 21:49:35 +0800 Subject: [PATCH] - enhancement: when create a new folder in the files view, auto select that folder and rename it - enhancement: when new header in the project view, auto select basename in the filename dialog - enhancement: when add file in the project view, auto select basename in the filename dialog - change: Don't generate localized filename when new header/add file in the project view --- NEWS.md | 5 +++++ RedPandaIDE/mainwindow.cpp | 3 ++- RedPandaIDE/widgets/newheaderdialog.cpp | 6 +++++- RedPandaIDE/widgets/newprojectunitdialog.cpp | 8 +++++++- 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/NEWS.md b/NEWS.md index 9bbcec88..12b11397 100644 --- a/NEWS.md +++ b/NEWS.md @@ -26,6 +26,11 @@ Red Panda C++ Version 2.0 - enhancement: use "todo" and "fixme" as the keyword for TODO comments - fix: rules for obj missing in the makefile generated for project - enhancement: before run a project'executable, check if there's project file newer than the executable + - enhancement: when create a new folder in the files view, auto select that folder and rename it + - enhancement: when new header in the project view, auto select basename in the filename dialog + - enhancement: when add file in the project view, auto select basename in the filename dialog + - change: Don't generate localized filename when new header/add file in the project view + Red Panda C++ Version 1.5 diff --git a/RedPandaIDE/mainwindow.cpp b/RedPandaIDE/mainwindow.cpp index 420fa14a..015836c4 100644 --- a/RedPandaIDE/mainwindow.cpp +++ b/RedPandaIDE/mainwindow.cpp @@ -3865,6 +3865,7 @@ void MainWindow::onFilesViewCreateFolder() } QModelIndex newIndex = mFileSystemModel.mkdir(parentIndex,folderName); ui->treeFiles->setCurrentIndex(newIndex); + ui->treeFiles->edit(newIndex); } void MainWindow::onFilesViewCreateFile() @@ -7830,7 +7831,7 @@ void MainWindow::on_actionNew_Header_triggered() QString newFileName; int i=1; do { - newFileName = tr("untitled")+QString("%1").arg(i); + newFileName = QString("untitled%1").arg(i); newFileName += ".h"; i++; } while (QDir(mProject->directory()).exists(newFileName)); diff --git a/RedPandaIDE/widgets/newheaderdialog.cpp b/RedPandaIDE/widgets/newheaderdialog.cpp index 25422fb1..03f414fa 100644 --- a/RedPandaIDE/widgets/newheaderdialog.cpp +++ b/RedPandaIDE/widgets/newheaderdialog.cpp @@ -52,7 +52,11 @@ QString NewHeaderDialog::path() const void NewHeaderDialog::setHeaderName(const QString &name) { ui->txtHeader->setText(name); - ui->txtHeader->selectAll(); + int pos = name.lastIndexOf('.'); + if (pos>=0) + ui->txtHeader->setSelection(0,pos); + else + ui->txtHeader->selectAll(); } void NewHeaderDialog::setPath(const QString &location) diff --git a/RedPandaIDE/widgets/newprojectunitdialog.cpp b/RedPandaIDE/widgets/newprojectunitdialog.cpp index 39dbafd9..cb5dfacb 100644 --- a/RedPandaIDE/widgets/newprojectunitdialog.cpp +++ b/RedPandaIDE/widgets/newprojectunitdialog.cpp @@ -57,7 +57,7 @@ void NewProjectUnitDialog::setFolder(const QString &folderName) ext = QFileInfo(filename()).suffix(); } do { - newFileName = tr("untitled")+QString("%1").arg(getNewFileNumber()); + newFileName = QString("untitled%1").arg(getNewFileNumber()); if (!ext.isEmpty()) newFileName += "." + ext; } while (dir.exists(newFileName)); @@ -74,6 +74,12 @@ QString NewProjectUnitDialog::filename() const void NewProjectUnitDialog::setFilename(const QString &filename) { ui->txtFilename->setText(filename); + ui->txtFilename->setFocus(); + int pos = filename.lastIndexOf('.'); + if (pos>=0) + ui->txtFilename->setSelection(0,pos); + else + ui->txtFilename->selectAll(); } void NewProjectUnitDialog::onUpdateIcons()