Akseli Lahtinen [Thu, 21 Nov 2024 12:42:45 +0000 (12:42 +0000)]
DolphinView: beginAnchoredSelection after setSelected in selectNextItem
Currently when next item is set selected, it's not set as an anchor.
This means that shift-click will not select items between the selection
and the next item, and instead behaves like ctrl-click.
This is rather inconsistent behavior.
We should set the next selected item as an anchor so that shift-click
will work: This change starts the `beginAnchoredSelection`
process after `setSelection`.
For example, if user trashes an item and the next item is selected,
shift-click would stop working.
Eren Karakas [Tue, 19 Nov 2024 09:08:45 +0000 (09:08 +0000)]
natural sort: exclude extension when comparing filenames
Currently natural sort compares the entire filenames
(basename.extension) when sorting. This causes eg.
"a 2.txt" to appear before "a.txt" when sorted by ascending.
This is unintuitive since people prioritize basenames more
than file extensions.
Instead, change natural sort to compare by basename only and
fallback to comparing extensions if basenames were equal.
This change causes "a.txt" to appear before "a 2.txt" and
matches how other platforms such as GNOME and Windows behave.
Akseli Lahtinen [Wed, 13 Nov 2024 09:41:45 +0000 (11:41 +0200)]
generalviewsettingspage: Use qobject_cast instead of static_cast
In generalViewSettingsPage, ActiveWindow is not necessarily a
mainWindow, which can cause dolphin to crash. For example when user
opens folder properties and then dolphin settings, this part thinks
the folder settings is mainWindow.
Instead of static_cast, use qobject_cast, since it will return nullptr
if the DolphinMainWindow is not found.
Felix Ernst [Sun, 10 Nov 2024 15:47:19 +0000 (16:47 +0100)]
Avoid flickering of space info on startup
Prior to this commit, when Dolphin was opening in a directory for
which the free space information cannot be retrieved, the free
space info in the status bar would still briefly be visible before
hiding for good.
This commit avoids this flickering by keeping the space info hidden
until space info has been successfully retrieved. There is no use
showing an empty/wrong space info before that anyway.
I assume the error in the previous code was that it assumed that
one could prevent a widget from being shown by overriding
QWidget::showEvent(). This does not work because this method is
only called to notify QWidgets of their state change.
This commit was primarily written because the brief showing of an
empty space info was messing with automatic tests.
Felix Ernst [Tue, 12 Nov 2024 10:52:16 +0000 (10:52 +0000)]
Test that each object has distinguishable accessible info
This commit extends the dolphinmainwindowtest for the accessible tree
to test that each object a user can reach through the Tab key or the
Shift+Tab key combination is distinguishable by its accessible info
from the previous object.
Objects are considered distinguishable if they have different
accessible names or their first ancestor with an accessible name is
different.
Felix Ernst [Mon, 4 Nov 2024 01:06:29 +0000 (02:06 +0100)]
Skip splitter in Tab order
When moving through Dolphin by repeatedly pressing the Tab key,
there is one seemingly invisible object that catches keyboard
focus. On a default toolbar it receives keyboard focus between the
"Details View Mode" button and the first button of the location
bar. That object is the splitter of the location bar itself, which
never requires manipulation by keyboard. This commit skips this
object by setting its focusProxy to the primaryUrlNavigator()
instead.
Felix Ernst [Mon, 28 Oct 2024 02:58:45 +0000 (03:58 +0100)]
Make Escape move focus from location bar to view
Pressing Escape on the location bar while in breadcrumb mode has no
effect at all. This commit changes this to instead move the focus
to the active view. This is more logical because a user pressing
escape while having focus on the location bar is no longer
interested in interacting and changing the location in the location
bar. They most likely want to act on the current location instead.
Felix Ernst [Mon, 28 Oct 2024 02:22:05 +0000 (03:22 +0100)]
Have "Replace Location" toggle focus of the view
The "Replace Location" action moves focus to the location bar and
selects the full path there so it can easily be replaced with a
different path.
When the full path is already selected, triggering "Replace
Location" will toggle the editable state of the location bar.
This commit makes it, that this also moves the focus to the view.
This way, pressing Ctrl+L multiple times will switch back and forth
between focusing and selecting the location bar path and focusing
the view. This seems more sensible than only partially resetting
the state when the "Replace Location" keyboard shortcut is pressed
twice.
Felix Ernst [Mon, 28 Oct 2024 13:25:10 +0000 (13:25 +0000)]
Overhaul main view accessibility
This commit brings the main view of Dolphin into a usable state
accessibility-wise. Users of screen readers should have a way better
experience while browsing files and folders and navigating along the
file system hierarchy.
This commit fixes most of the remaining already-identified
accessibility issues listed in
https://invent.kde.org/teams/accessibility/collaboration/-/issues/28,
but not all. Namely, these should now be fixed:
1. Orca should read the element type in dolphin (file, folder, device,
link to folder, link to file)
2. Orca should read complete label in icon and compact view mode,
currently it only speaks the name, but there could be additional
information like the number of elements or the file size.
3. Orca is not able to announce Selecting / Unselecting files in
Dolphin. It also never announces how many items are selected in total.
(Announcing the total selection can be done by reading out the view
element or by pressing the Tab key to get to the status bar with the
relevant information.)
4. Dolphin opens on the home directory, but Orca doesn't tell you so.
Consider enclosing the area in a frame/panel which updates its
accessible name each time you modify the current path by entering or
leaving a directory.
5. I don't know what the folder presentation widget is, but it should
be presented as a grid view. Currently, we have a terrible experience
because the entire row of folders is read at once, with no indication
that we can move left and right with the arrows to go between the
elements of a row. When I found that out, however, I discovered that
when you're on the last icon of the first row and press right arrow,
you get to the first icon of the next row, but that's not announced,
instead, the whole row is announced at once
6. Orca should announce the current elements instead of "layered pane"
when the Folder / File view gets the focus in dolphin
7. Orca reads only name in Table View only of Dolphin
8. Items are sometimes confusingly announced as "collapsed" in contexts
in which there is no concept of collapsing/expanding e.g. in icon view
mode.
A lot of code was moved around and renamed. The three accessibility
classes, which all used to be in the same file, are moved into separate
files.
*Acknowledgement*
Thanks to Christian Hempfling and bgt lover for testing as well as
originally identifying a lot of the pain points being addressed here.
This work is part of a my project funded through the NGI0 Entrust Fund,
a fund established by NLnet with financial support from the European
Commission's Next Generation Internet programme, under the aegis of DG
Communications Networks, Content and Technology.
https://kde.org/announcements/2024_ngi_openletter/
Felix Ernst [Mon, 23 Sep 2024 15:34:20 +0000 (17:34 +0200)]
Add test to avoid accidental divergence of desktop and phone ui
The dolphinui.rc and dolphinuiforphones.rc file describe parts of
the desktop and phone user interfaces for Dolphin. They are meant
to be different in specific ways, but identical in many others.
This test makes sure that the two ui files stay mostly identical by
requiring any differences between them need to be explicitly
stated/registered as an exception in the test. This way no
accidental divergence of user interfaces can happen.
Felix Ernst [Tue, 17 Sep 2024 09:34:30 +0000 (11:34 +0200)]
Move settings category switcher to the top on mobile
There is not enough horizontal space to show the full Dolphin
settings window on the average phone. This commit saves some
horizontal space by moving the category switcher in Dolphin
settings from being a list on the left to being tabs on the top.
Felix Ernst [Sun, 15 Sep 2024 16:52:49 +0000 (18:52 +0200)]
Add phone UI
Previous to this commit launching Dolphin on phones (e.g. those
running Plasma Mobile) would show Dolphin with its default user
interface optimised for desktop usage. This commit changes this so
instead a phone form factor optimised user interface is used.
The differences to the default UI configuration are:
-Toolbar at bottom
-Icon-only toolbar
-Different actions on the toolbar
-Places panel hidden
-Location bar at the top with a button to show places
-Zoom slider hidden (pinch gestures to zoom still work)
Through these changes Dolphin actually has a good user experience
on phones by default. All the features were already there.
Especially Steffen Hartleib's work to trigger selection mode on
long press leads to great UX when dealing with multiple files.
Still, this might be considered just a start towards making Dolphin
great on phone form factors. Secondary windows that Dolphin might
spawn are not yet adapted, but are usable on Plasma Mobile as they
are anyway.
Wolfgang Müller [Mon, 14 Oct 2024 16:43:28 +0000 (18:43 +0200)]
kitemlistcontroller: process forward/back buttons when double-clicking
Tapping the forward or back mouse buttons quickly enough makes Dolphin
interpret the action as a double-click of the button in question and
handle it in mouseDoubleClickEvent() instead of its normal button
handler. This means that certain button presses might seem delayed or
"swallowed" when quickly navigating forwards or backwards through the
history.
Since a double-click of the forward or back button is currently
meaningless, fix this by emitting a normal mouseButtonPressed event for
those buttons in the double-click handler and skipping any further event
processing.
Co-authored-by: Felix Ernst <felixernst@zohomail.eu>
CCBUG: 485295
Felix Ernst [Mon, 14 Oct 2024 12:44:47 +0000 (14:44 +0200)]
Fix double-click view background feature
c934e803647674b4692668f047b6ffa18121982a was meant to change the
double-click view background feature to only allow double-clicks
with the left mouse button. However, it mistakenly did the exact
opposite and allowed every double-click except ones with the left
mouse button to trigger the feature. This one-liner fixes this.
Jin Liu [Fri, 11 Oct 2024 08:21:14 +0000 (16:21 +0800)]
dolphinview: when rename dialog finishes, immediately update the model and the selection
On sucessful return of the rename dialog, we update
the model and the selection immediately to reflect
the new name. This is to avoid the short duration
after the rename during which the selection is lost.
Currently, after the rename dialog finishes, the selection
is briefly lost for about 1 second until the view
automatically refreshes.
This patch updates the model and selection immediately
after the dialog finishes, so the renamed file is still
selected.
Jin Liu [Fri, 11 Oct 2024 08:17:04 +0000 (16:17 +0800)]
dolphinview: after inline renaming, immediately update the selection
Currently, the inline renaming updates the model and
the list of selected files (m_selectedUrls) immediately
after the user presses enter, but the selection in the
view is not immediately updated. This results in the
selection to be briefly lost for about 1 second until
the view automatically refreshes.
This patch updates the selection immediately after
the user presses enter, so the renamed file is still
selected.
Jin Liu [Fri, 11 Oct 2024 08:08:31 +0000 (16:08 +0800)]
KFileItemModel: fix `setData` in the renaming usage
The `setData` function is used by inline renaming to
update the `text` role (i.e. file name) in the model
before actually do the renaming.
However, the current implementation only updates `text`
and url in KFileItem in this case, leaving the `url` role
and the `m_items` cache untouched. This makes the cache
incoherent, so `index()` won't find the renamed item. It
also makes the `url` role incoherent with the `text` role.
This also fixes the problem mentioned in bug #481561
where when inline renaming fails, it still shows the new
name. (Because `m_model->index` fails to find the new name
and rename it back on job failure.)
Felix Ernst [Thu, 3 Oct 2024 09:18:59 +0000 (11:18 +0200)]
Accessibility: Fix message boxes not being announced
This commit moves the focus to the message of newly shown passive
messages when accessibility software is used. Moving focus to an
object generally means that it will be announced, so this makes
sure that users of accessibility software know when they are being
notified of a change.
KCoreDirLister::itemsDeleted() signal is being emitted twice for the
same url. This results in Dolphin displaying an incorrect location.
Delay changing the url instead of delaying
DolphinView::currentDirectoryRemoved() so that the check for current
directory being removed in KFileItemModel::slotItemsDeleted() occurs
correctly, while still ensuring that KCoreDirLister is not prematurely
modified.
Alexander Lohnau [Mon, 16 Sep 2024 19:31:22 +0000 (21:31 +0200)]
Dolphinpart: Define KPart capabilities instead of deprecated ServiceTypes
By now, Konqueror uses the new mechanism introduced in
https://invent.kde.org/frameworks/kparts/-/merge_requests/86.
Thus, we can avoid using the deprecated SeviceTypes which are also
removed from the official KPluginMetaData API.
Wolfgang Müller [Thu, 19 Sep 2024 09:46:09 +0000 (11:46 +0200)]
Ignore trailing slashes when comparing place URLs
There's two locations where place URLs are compared in Dolphin. One
is in DolphinContextMenu::placeExists, which determines whether or not
to show an "Add to Places" context menu entry. The other one is in
DolphinViewContainer::caption, which provides the place name for use in
the window title, if applicable.
Neither of these functions correctly normalize the URL to account for
trailing slashes. Whilst placeExists() does not even attempt it,
caption() was changed in 681d8bb6c (Fix wrong window titles, 2019-09-15)
to support this using a regular expression.
However, caption() fails to escape the URL before incorporating it in
the regular expression, leading to failed matches and errors like the
following when browsing to directories that do not happen to make up a
valid regular expression:
QString(View)::contains(): called on an invalid QRegularExpression
object (pattern is '\A(?:file:///home/foo/[Z-A]/?)\z')
Instead of relying on complex and possibly brittle regular expressions,
use KFilePlacesModel's closestItem() function to find the closest
matching URL and then finally check whether the normalized URLs match
exactly.
dolphintrash.cpp: Update trash dir on device changes
Make sure we update the trash directory when storage devices are added/changed.
This ensures that whenever a mounted device, for example
USB stick is mounted/unmounted, the contents are properly
updated in the trash folder as well.
Otherwise the trash folder and USB stick trash folder will get
out of sync, making the trash folder behavior unpredictable.