Bug 461161 - Regression: Current File Name Not Suggested as File Name When "Save As" of File
Summary: Regression: Current File Name Not Suggested as File Name When "Save As" of File
Status: RESOLVED FIXED
Alias: None
Product: kate
Classification: Applications
Component: application (show other bugs)
Version: 22.08.2
Platform: Neon Linux
: NOR minor
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords:
: 467211 (view as bug list)
Depends on:
Blocks:
 
Reported: 2022-10-29 13:52 UTC by Peter Ped Helcmanovsky
Modified: 2023-03-11 18:11 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Peter Ped Helcmanovsky 2022-10-29 13:52:15 UTC
SUMMARY

When I hit "Save As" (alt+f, a OR ctrl+shift+s) , "Name:" is empty.

STEPS TO REPRODUCE
1.  open some text file in Kate
2. do "Save As"

OBSERVED RESULT

"Name:" in file picker dialog is empty

EXPECTED RESULT

"Name:" with current file name selected (up to extension is now common behaviour in KDE?) and ready to be edited by keyboard.

ADDITIONAL INFORMATION

See also #415837, but that should be now fixed and it looks like the Kate has specific way to introduce this.
Comment 1 Christoph Cullmann 2022-10-29 17:38:27 UTC
We altered that to avoid confusion, perhaps that was  bad idea.

QUrl KTextEditor::DocumentPrivate::getSaveFileUrl(const QString &dialogTitle)
{
    // per default we use the url of the current document
    // if that is empty, we will try to get the url of the last used view, we assume some properly ordered views() list is around
    QUrl startUrl = url();
    if (auto mainWindow = KTextEditor::Editor::instance()->application()->activeMainWindow(); mainWindow && !startUrl.isValid()) {
        const auto views = mainWindow->views();
        for (auto view : views) {
            if (view->document()->url().isValid()) {
                startUrl = view->document()->url();
                break;
            }
        }
    }

    // spawn the dialog, dialogParent will take care of proper parent
    // we remove the filename, otherwise we propose to save as some other already existing file, that is confusing
    // beside we need to do that to avoid to use the filename as directory name, see bug 454648
    return QFileDialog::getSaveFileUrl(dialogParent(), dialogTitle, startUrl.isValid() ? startUrl.adjusted(QUrl::RemoveFilename) : QUrl());
}
Comment 2 Peter Ped Helcmanovsky 2022-10-29 20:32:12 UTC
(In reply to Christoph Cullmann from comment #1)
> We altered that to avoid confusion, perhaps that was  bad idea.

Interesting. The way how I tend to work it just makes usage more tedious, as I either use old file as template for new one, and I start typing completely new name (replacing the pre-selected base name), or I actually want to either save the file with same filename to different folder or save some temporary "backup" of it by just appending something to the name, so I guess in like 10+% I'm just missing the original name. I learned to click on the original file in the picker to pre-fill the "Name" again, and continue from there.

(just anecdotal "does not work for me", not claiming I'm an expert on UX or know how majority of users use it)
Comment 3 Christoph Cullmann 2022-10-30 16:25:37 UTC
I see a point in that, I use that sometimes, too, that way and miss it a bit.
Perhaps it would be better if the save dialog would actually work better if the url is a full file name.
At least the Qt docs don't hint that a full file name is bad. But perhaps I read them wrong.
Comment 4 Christoph Cullmann 2022-10-30 19:18:34 UTC
Git commit 7a6f9d8ee3027867a0ee8b99faf209d4685934c9 by Christoph Cullmann.
Committed on 30/10/2022 at 19:18.
Pushed by cullmann into branch 'master'.

remove file name for saveas only for remote files

or for the case we use the file of some other view to have
some better start directory

M  +13   -6    src/document/katedocument.cpp

https://invent.kde.org/frameworks/ktexteditor/commit/7a6f9d8ee3027867a0ee8b99faf209d4685934c9
Comment 5 Christoph Cullmann 2022-10-30 19:18:59 UTC
The pushed fix should still fix the old issue for remote files but avoid the regression for local ones.
Comment 6 Christoph Cullmann 2023-03-11 18:11:24 UTC
*** Bug 467211 has been marked as a duplicate of this bug. ***