Commit Graph

82 Commits

Author SHA1 Message Date
Adam Harald Jørgensen
4d3c06ffe3 LibGUI: Fetch data on a Node before traversing it, instead of after
Before this it wouldn't be possible to make decisions in
Node::traverse_if_needed based on the Node data because it would be
invalid.
2023-10-26 11:09:24 +02:00
Adam Harald Jørgensen
60f9aa5cb8 LibGUI: Handle metadata changes in FileSystemModel 2023-10-26 11:09:24 +02:00
Adam Harald Jørgensen
cbfa363b2b LibGUI: Preserve correct child order in FileSystemModel
When handling child creation in FileSystemModel, the new child should
be inserted such that the children still follow the correct order of
being grouped by directory-and-file and then sorted alphabetically,
instead of just being appended at the end.
2023-10-26 11:09:24 +02:00
MacDue
f0cd7adaf8 LibGUI: Fix FileSystemModel/FileManager after aeee98b
Previously, the null state of m_root_path was use to (subtly) mark the
parent of the root. The empty path is always replaced with "." so after
aeee98b there was no "parent of root" node. This lead to the file
manager crashing when opened.
2023-10-15 21:34:15 +03:30
Ali Mohammad Pur
aeee98b3a1 AK+Everywhere: Remove the null state of DeprecatedString
This commit removes DeprecatedString's "null" state, and replaces all
its users with one of the following:
- A normal, empty DeprecatedString
- Optional<DeprecatedString>

Note that null states of DeprecatedFlyString/StringView/etc are *not*
affected by this commit. However, DeprecatedString::empty() is now
considered equal to a null StringView.
2023-10-13 18:33:21 +03:30
Tim Ledbetter
debb4edcc8 LibGUI: Update model every 100ms when generating thumbmnails
This dramatically improves the responsiveness of FileManager when
navigating to folders with many images.
2023-10-06 22:18:40 +02:00
Karol Kosek
9ce2682ce6 Userland: Port lists of mime types to String 2023-09-29 14:40:21 +01:00
Karol Kosek
e75d694974 Userland: Compare event MIME type list with a StringView
The following commit will port MIME types to String. Traits<String>
- used in Vector::contains_slow - can't compare String type with char*,
so we need to use StringView instead.
2023-09-29 14:40:21 +01:00
Lucas CHOLLET
3f35ffb648 Userland: Prefer _string over _short_string
As `_string` can't fail anymore (since 3434412), there are no real
benefits to use the short variant in most cases.
2023-08-08 07:37:21 +02:00
Andreas Kling
34344120f2 AK: Make "foo"_string infallible
Stop worrying about tiny OOMs.

Work towards #20405.
2023-08-07 16:03:27 +02:00
MacDue
8784568a36 LibGUI: Pass ideal size when requesting thumbnail bitmaps
This makes thumbnails for vector graphics look much nicer :^)
2023-07-14 06:51:05 +02:00
Sam Atkins
f33824d2e9 LibGUI+Userland: Propagate errors in Model::column_name() 2023-06-14 17:53:59 +02:00
Karol Kosek
945f05ed76 Userland: Port Model::column_name() to String 2023-05-15 06:42:10 +02:00
Tom
e758545b91 FileManager+LibGUI: Cache the FileSystem::can_delete_or_move value
Add the function FileSystemModel::Node::can_delete_or_move which will
cache the result of FileSystem::can_delete_or_move for a node. This
prevents having to make system calls repeatedly to obtain this
information.

Fixes #18399
2023-04-17 10:34:20 +02:00
Cameron Youell
c048cf2004 Libraries: Convert DeprecatedFile usages to LibFileSystem 2023-03-24 10:58:43 +00:00
Lucas CHOLLET
a9cc61224d LibGUI: Resolve use-after-free error
Objects taken by reference are no longer valid when used in
`deferred_invoke`. Explicitly copying them solve the issue.
2023-03-22 08:52:48 +01:00
Lucas CHOLLET
b79cd5cf6e LibGUI: Update progress of thumbnail generations on failure
Not doing it result in FileManager's progress bar being left as
incomplete even if all jobs were finish.
2023-03-19 01:26:37 +00:00
Lucas CHOLLET
ebb9c3a430 LibThreading: Execute on_error on the original EventLoop
As the user might want to have interactions with LibGUI while handling
errors, this code should be executed in the original `EventLoop`.
Similarly to what is done with the error-free path.
2023-03-19 01:26:37 +00:00
kleines Filmröllchen
d707c0a2f5 LibGUI: Make thumbnail generation resilient between FileSystemModels
With the new canceled background actions, some thumbnail generation
callbacks are not executed if the user closes the window with a
FileSystemModel quickly enough. Therefore, we remember which thumbnails
we started to generate and consider the associated promises if we're
looking up a thumbnail. Since the thumbnail generation itself continues
running and the cache is application-global, instead of never displaying
thumbnails for images that were "interrupted" generating thumbnails the
first time, we can now fetch their images immediately and reliably.
2023-03-13 12:12:17 +00:00
Andreas Kling
359d6e7b0b Everywhere: Stop using NonnullOwnPtrVector
Same as NonnullRefPtrVector: weird semantics, questionable benefits.
2023-03-06 23:46:35 +01:00
Sam Atkins
774f328783 LibCore+Everywhere: Return an Error from DirIterator::error()
This also removes DirIterator::error_string(), since the same strerror()
string will be included when you print the Error itself. Except in `ls`
which is still using fprintf() for now.
2023-03-05 20:23:42 +01:00
Tim Schumacher
d43a7eae54 LibCore: Rename File to DeprecatedFile
As usual, this removes many unused includes and moves used includes
further down the chain.
2023-02-13 00:50:07 +00:00
Marcus Nilsson
fe5dfe4cd5 LibGUI: Add allowed file extensions to FileSystemModel
This allows FileSystemModel to take an optional list of allowed file
extensions which it will use to filter out all files that don't end
with that file extension.

The file extensions are set via `set_allowed_file_extensions` which has
a coresponding `get_allowed_file_extensions`.
2023-02-02 04:05:42 -07:00
Tim Schumacher
82a152b696 LibGfx: Remove try_ prefix from bitmap creation functions
Those don't have any non-try counterpart, so we might as well just omit
it.
2023-01-26 20:24:37 +00:00
Lucas CHOLLET
2693745336 LibThreading+Everywhere: Support returning error from BackgroundAction
This patch allows returning an `Error` from the `on_complete` callback
in `BackgroundAction`.

It also adds a custom callback to manage errors returned during its
execution.
2022-12-15 17:36:57 +00:00
Linus Groh
57dc179b1f Everywhere: Rename to_{string => deprecated_string}() where applicable
This will make it easier to support both string types at the same time
while we convert code, and tracking down remaining uses.

One big exception is Value::to_string() in LibJS, where the name is
dictated by the ToString AO.
2022-12-06 08:54:33 +01:00
Linus Groh
6e19ab2bbc AK+Everywhere: Rename String to DeprecatedString
We have a new, improved string type coming up in AK (OOM aware, no null
state), and while it's going to use UTF-8, the name UTF8String is a
mouthful - so let's free up the String name by renaming the existing
class.
Making the old one have an annoying name will hopefully also help with
quick adoption :^)
2022-12-06 08:54:33 +01:00
electrikmilk
1ab510c4bb Base+LibGUI: Add Git folder icons
This adds icons for folder paths ending in ".git". This adds 16x16 and
32x32 versions of a folder with a Git logo for both the closed and open
versions of the folder icon.
2022-09-06 07:38:09 +01:00
Adam Jakubek
aa466723eb FileManager: Navigate to parent dir when current location is removed
When the location currently displayed in FileManager is removed, find
the nearest existing parent path and open it in the window.
Without the fix, the FileManager window remained in the deleted
directory.

Changing the path in 'DirectoryView' object will automatically update
other components in the FileManager (breadcrumb bar, directory tree
view).
2022-08-31 10:32:41 +01:00
Adam Jakubek
f7e6593910 LibGUI: Fix assertion when handling removal of FileSystemModel's root
This commit fixes FileSystemModel behaviour when the root path of the
model has been deleted.
In this case, the model index resolved for the root path is invalid and
passing it to 'begin_delete_rows' would trigger assertion failure.

Instead of deleting all children rows one by one, we simply invalidate
the whole model.
2022-08-31 10:32:41 +01:00
sin-ack
c8585b77d2 Everywhere: Replace single-char StringView op. arguments with chars
This prevents us from needing a sv suffix, and potentially reduces the
need to run generic code for a single character (as contains,
starts_with, ends_with etc. for a char will be just a length and
equality check).

No functional changes.
2022-07-12 23:11:35 +02:00
offtkp
d24ec130bf FileManager: Don't show new dotfiles if the option is disabled 2022-05-07 20:31:40 +02:00
Marco Rebhan
a4639fced9 LibGUI: Don't try to get link target value if read_link failed 2022-04-14 23:44:09 +02:00
Ali Mohammad Pur
f899c19d41 LibGUI: Return Optional<Node const&> from node_for_path() 2022-04-04 12:48:31 +02:00
Kenneth Myhra
4a57be824c Userland+Tests: Convert File::read_link() from String to ErrorOr<String>
This converts the return value of File::read_link() from String to
ErrorOr<String>.

The rest of the change is to support the potential of an Error being
returned and subsequent release of the value when no Error is returned.
Unfortunately at this stage none of the places affected can utililize
our TRY() macro.
2022-03-24 11:57:51 +01:00
Lenny Maiorani
fe3b846ac8 Libraries: Use default constructors/destructors in LibGUI
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#cother-other-default-operation-rules

"The compiler is more likely to get the default semantics right and
you cannot implement these functions better than the compiler."
2022-03-12 14:44:43 -08:00
Marcus Nilsson
a0ba21e442 LibGUI: Print error when failing to load thumbnail in FileSystemModel
If a thumbnail cannot load it's a good opportunity to print out the
error message.
On top of that, we still want to update m_thumbnail_progress so that
the progress bar doesn't get stuck instead of returning early from
the lambda.
2022-01-12 19:44:17 +01:00
Andreas Kling
2375e1bcda LibGUI: Rename ModelSelection::remove_matching => remove_all_matching
Let's be consistent with how Vector, HashTable and HashMap names these.
2022-01-05 18:57:14 +01:00
Sam Atkins
d2024f04bd Userland: Cast unused BackgroundAction::construct() results to void
User code does not need to keep this alive, so casting to void is safe.
But maybe a bit weird.
2021-12-05 15:31:03 +01:00
Andreas Kling
8e4eebe9b1 LibGUI: Use ErrorOr<T> in the file system thumbnail generator 2021-11-21 20:22:48 +01:00
Andreas Kling
8b1108e485 Everywhere: Pass AK::StringView by value 2021-11-11 01:27:46 +01:00
Andreas Kling
0de33b3d6c LibGfx: Use ErrorOr<T> for Bitmap::try_create()
Another one that was used in a fajillion places.
2021-11-08 00:35:27 +01:00
Andreas Kling
235f39e449 LibGfx: Use ErrorOr<T> for Bitmap::try_load_from_file()
This was used in a lot of places, so this patch makes liberal use of
ErrorOr<T>::release_value_but_fixme_should_propagate_errors().
2021-11-08 00:35:27 +01:00
Ben Wiederhake
59619572d6 LibThreading: Remove redundant method 2021-11-02 11:07:26 +01:00
Marcus Nilsson
d660e86d13 LibGUI: Implement automatic scrolling in AbstractView
This adds automatic scrolling when dragging items in TreeViews and other
widgets that inherit from AbstractView when the overloaded
accepts_drag() returns true. This is implemented in FileSystemModel to
allow directories and files to be dragged.
2021-09-29 23:58:55 +02:00
Marco Cutecchia
05630d2d5d LibGUI: Add 'on_rename_successful' callback to FileSystemModel 2021-09-27 01:20:48 +02:00
Itamar
de31603028 LibGUI: Remove Indices with dangling FileSystemModel::Node on deletion
When a file deletion event happens, we now iterate over all views of the
FileSystemModel and remove any selection & cursor indices that hold
dangling references do the deleted filesystem node.

This fixes #9602.
2021-09-12 21:33:39 +02:00
Dawid Wolosowicz
484b9c1ba3 LibGUI: West Const to East Const refactor 2021-09-08 15:48:02 +04:30
Dawid Wolosowicz
2d91ba2737 LibGUI: Remove an unnecessarily specific inline capacity 2021-09-08 15:48:02 +04:30
Andreas Kling
887ab3cc9a LibGUI: Rename FileSystemModel's "Owner" column to "User"
A file is owned by a User+Group, not an Owner+Group.
2021-08-31 01:35:08 +02:00