- fix: save as file dialog's operation mode is not correct

This commit is contained in:
royqh1979@gmail.com 2021-10-19 22:41:38 +08:00
parent cd91df6fb8
commit d188d8897f
4 changed files with 11 additions and 5 deletions

View File

@ -1,5 +1,6 @@
Version 0.7.0
- fix: Backspace still works in readonly mode
- fix: save as file dialog's operation mode is not correct
Version 0.6.8
- enhancement: add link to cppreference in the help menu

View File

@ -245,16 +245,21 @@ bool Editor::saveAs(const QString &name, bool fromProject){
QString newName = name;
if (name.isEmpty()) {
QString selectedFileFilter;
if (pSettings->editor().defaultFileCpp())
QString defaultExt;
if (pSettings->editor().defaultFileCpp()) {
selectedFileFilter = pSystemConsts->defaultCPPFileFilter();
else
defaultExt = "cpp";
} else {
selectedFileFilter = pSystemConsts->defaultCFileFilter();
defaultExt = "c";
}
QFileDialog dialog(this,tr("Save As"),extractFilePath(mFilename),
pSystemConsts->defaultFileFilters().join(";;"));
dialog.selectNameFilter(selectedFileFilter);
dialog.setDefaultSuffix(defaultExt);
dialog.selectFile(mFilename);
dialog.setFileMode(QFileDialog::AnyFile);
dialog.setOption(QFileDialog::DontConfirmOverwrite,false);
dialog.setAcceptMode(QFileDialog::AcceptSave);
connect(&dialog, &QFileDialog::filterSelected,
[&dialog](const QString &filter){
int pos = filter.indexOf("*.");

View File

@ -3910,7 +3910,7 @@ void MainWindow::on_actionAdd_to_project_triggered()
mProject->directory(),
pSystemConsts->defaultFileFilters().join(";;"));
dialog.setFileMode(QFileDialog::ExistingFiles);
dialog.setOption(QFileDialog::DontConfirmOverwrite,true);
dialog.setAcceptMode(QFileDialog::AcceptOpen);
if (dialog.exec()) {
QModelIndex current = ui->projectView->currentIndex();
FolderNode * node = nullptr;