andreikop / enki

A text editor for programmers
http://enki-editor.org
GNU General Public License v2.0
161 stars 38 forks source link

Suggestion: only pre-select filename when renaming a file. #185

Closed vi closed 10 years ago

vi commented 10 years ago

Steps:

  1. Open some file in Enki;
  2. Trigger Filesystem->Rename;
  3. The window with input text field with full path of the file gets opened, for example /mnt/something/src/myproject/QqqTest.java;

What happens:

What I want to happen:

andreikop commented 10 years ago

vi, I agree with you that it would be useful, but I wouldn't like to do implement it. Current rename file implementation is only 32 LOC, because it uses standard Qt dialogue. But to implement custom selection I'll have to write custom dialog. Enki will become bigger and slower.

Except it, I have 15 more issues opened by you, which I'd like to implement.

vi commented 10 years ago

Can't just this aspect of standard dialogue be modified without re-implementing anything? Small change => small fix...

Something like:

  1. Open standard dialogue, let it select what it wants;
  2. Fix up selection. Something like theDialog->getChild("theTextField")->setSelectionRange(from,to)?
andreikop commented 10 years ago

Now dialog creation and execution is just a 1 line Qt function call. I don't even have access to the instance of the dialogue. https://github.com/hlamer/enki/blob/master/enki/plugins/workspace_actions.py#L160

andreikop commented 10 years ago

We should create .ui file which copies current QInputDialog but shares QLineEdit instance as public member. vi, will you like to try to implement it?

vi commented 10 years ago

My version just shows dialog with only filename present. Maybe it's even cleaner than showing dialog with a little part selected.

We should create .ui file which copies current QInputDialog -> Looks a bit like overkill... Can't we go to that lineEdit by any sort of reflection (or how it's called in Qt) using getChildren or some?

Abandoning QInputDialog and making our own window is good approach if we want it to be more complex in future. What additional features regaring renaming can we have in future?..

  1. Explicit checkbox for deletion (I've discovered /dev/null feature only when looked to the source code);
  2. Maybe language-specific things like "rename the Java class as well";
  3. "Copy file, not rename" checkbox (both files should become opened)...

The action then should be "move/rename/copy/delete", not just "rename"...

vi commented 10 years ago

I also noticed that Enki suggests renaming the file when I single click selected entry in "Opened files" list (without opening any dialog). Is it complicated to pre-select filename there as well?

andreikop commented 10 years ago

Maybe it's even cleaner than showing dialog with a little part selected.

It is, but I don't want to have 1 more menu item.

Abandoning QInputDialog and making our own window is good approach if we want it to be more complex in future.

I wouldn't like to extend this functionality. getChildren() might work, but might be broken on next Qt version, because widget name changed. .ui is public API and it will work. I'll accept both solutions if somebody implemented it.

andreikop commented 10 years ago

See #198