Commit graph

365 commits

Author SHA1 Message Date
Andrew Kaster
347bf6459d Applications+LibGUI: Convert all GML consumers to use the LibCore finder
Remove Widget::find_child_by_name and Widget::find_descendant_by_name,
and convert all users to using the type-safer version in Core::Object.
2021-01-01 14:45:09 +01:00
Andreas Kling
71663a9431 FileManager: Hide unnecessary scrollbars in DirectoryView 2021-01-01 02:12:39 +01:00
Andreas Kling
4ea4cd5ee3 FileManager: Defer setting FileSystemModel root path in DirectoryView
Otherwise we always load the root directory on startup before switching
to whatever directory we actually wanted to open.
2021-01-01 01:55:30 +01:00
Andreas Kling
412a91d58f LibGfx: Add Gfx::Font::bold_variant() that does a proper font lookup
We previously had a cached bold variant font in Gfx::Font that was very
haphazardly located by filename pattern. This patches replaces that
mechanism with a proper Gfx::FontDatabase lookup for the same font but
with bold weight (700).
2020-12-31 01:51:18 +01:00
Andreas Kling
bc0658ce27 FileManager: Use GUI::SeparatorWidget in the properties dialog
This looks a lot better than putting a GUI::Frame in there.
2020-12-30 03:53:37 +01:00
Andreas Kling
1cca2405fc LibGUI: Give some widgets a reasonable default fixed height
Instead of hard-coding 22 in random places, just make the following
widgets have a fixed height of 22 by default: Button, CheckBox,
ColorInput, ComboBox, RadioButton, SpinBox, TextBox.

In the future we can make this relative to the current font size,
but for now at least this centralizes the setting a bit better.
2020-12-30 01:54:53 +01:00
Andreas Kling
7dc5a3ead8 LibGUI: Rewrite layout system in terms of min and max sizes
This patch removes size policies and preferred sizes, and replaces them
with min-size and max-size for each widget.

Box layout now works in 3 passes:

    1) Set all items (widgets/spacers) to their min-size
    2) Distribute remaining space evenly, respecting max-size
    3) Place widgets one after the other, adding spacing in between

I've also added convenience helpers for setting a fixed size (which is
the same as setting min-size and max-size to the same value.)

This significantly reduces the verbosity of widget layout and makes GML
a bit more pleasant to write, too. :^)
2020-12-30 01:36:41 +01:00
Andreas Kling
f7116bba43 LibGUI: Refactor AbstractView "multi select" mode into "selection mode"
There are three possible selection modes for a GUI::AbstractView.

- NoSelection
- SingleSelection
- MultiSelection

We don't enforce these modes fully yet, this patch mostly adds them in
place of the old "multi select" flag.
2020-12-28 21:28:40 +01:00
Idan Horowitz
b4bb2b141c FileManager: Implement the cut file operation
This exploits the comment lines in the text/uri-list specification:
https://tools.ietf.org/rfc/rfc2483.txt (page 11), which might be a bit
hackish, but the specification suggests doing the same for other uses,
so it should be fine.
2020-12-28 19:13:45 +01:00
Idan Horowitz
7450f20b81 FileManager: Add a delete_path helper for singular paths
This is just the syscalls and error handling that was done for each
file in delete_paths.

This will be used to prevent the unneeded construction of vectors
when performing cut operations
2020-12-28 19:13:45 +01:00
Andreas Kling
ffa241250b LibGUI: Make GUI::FileIconProvider::icon_for_executable() a public API
This way we can use it instead of icon_for_path() in a bunch of places
and avoid loading the full FileIconProvider configuration.
2020-12-28 11:41:09 +01:00
Andreas Kling
26cb083c6e FileManager: Created desktop shortcuts should use full basename
A shortcut to ReadMe.md should be called "ReadMe.md", not "ReadMe".
2020-12-28 09:38:11 +01:00
Andreas Kling
55e990cbc4 FileManager: Layout the desktop icons from top-to-bottom :^)
This looks way nicer than left-to-right!
2020-12-27 14:48:12 +01:00
Andreas Kling
5452c8a566 LibGUI: Rename Link => LinkLabel 2020-12-26 13:03:38 +01:00
Linus Groh
721b00a83a FileManager: Fix missing launch action icons
I missed this when updating everything to use GUI::FileIconProvider
rather than loading icons from .af files, it broke as a result as none
of them have icon info anymore. :^)
2020-12-26 01:09:13 +01:00
Alex McGrath
a5f4cb78cf FileManager: Add a button to open links in their real directory 2020-12-24 21:52:02 +01:00
Alex McGrath
abc98dea09 FileManager: Allow creating desktop shortcut from FileManager 2020-12-22 23:35:41 +01:00
William Marlow
39364bdda4 Build: Embed application icons directly in the executables.
New serenity_app() targets can be defined which allows application
icons to be emedded directly into the executable. The embedded
icons will then be used when creating an icon for that file in
LibGUI.
2020-12-21 00:12:59 +01:00
Lenny Maiorani
765936ebae
Everywhere: Switch from (void) to [[maybe_unused]] (#4473)
Problem:
- `(void)` simply casts the expression to void. This is understood to
  indicate that it is ignored, but this is really a compiler trick to
  get the compiler to not generate a warning.

Solution:
- Use the `[[maybe_unused]]` attribute to indicate the value is unused.

Note:
- Functions taking a `(void)` argument list have also been changed to
  `()` because this is not needed and shows up in the same grep
  command.
2020-12-21 00:09:48 +01:00
Andreas Kling
64ba41ea13 LibGUI: Make GUI::Label auto-sizing declarative
You can now set the "autosize" property on a GUI::Label and it will
automatically update its width preference to fit the text.
2020-12-20 12:36:32 +01:00
Andreas Kling
de08e7b8c9 LibGUI: Rename ProgressBar property caption => text and expose to GML 2020-12-20 12:29:40 +01:00
Andreas Kling
92afdd0c86 FileManager: Move the main window UI to GML
This was pretty straightforward although it does expose a bunch of
missing functionality (mostly properties.)
2020-12-20 12:17:59 +01:00
Andreas Kling
5eacf62ba3 FileManager: Fix assertion when drag&dropping a file to the desktop 2020-12-16 19:40:24 +01:00
Andreas Kling
04bc654ae7 FileManager: Make symlink icons show up nicely in properties dialog 2020-12-16 16:09:27 +01:00
Andreas Kling
2759d518b7 FileManager+LibGUI: Draw the item text for desktop icons with shadow
This makes it look nice regardless of wallpaper or background color.
2020-12-16 12:16:14 +01:00
Andreas Kling
dd9a77099f FileManager: Simplify breadcrumb bar hook callback
Now that we store each partial path with the segments, we can just
open up the path of the segment you clicked on.
2020-12-15 19:33:53 +01:00
Andreas Kling
b10255f93f FileManager: Use GUI::BreadcrumbBar :^)
FileManager windows now alternate between the old-style location text
box and a new-style breadcrumb bar. The location bar shows up when you
try to edit the location (with Ctrl+L) and disappears once the textbox
loses focus.

The textbox and breadcrumb bar are mutually exclusive to keep it tidy.
2020-12-14 20:43:42 +01:00
Zac
1851da9c93 FileManager: Added context menu for right-clicks on desktop icons.
Moved the same copy/paste/properties/delete functionality used in the
run_in_windowed_mode() method to the run_in_desktop_mode() method.
2020-12-11 09:36:44 +01:00
Zac
dea399ff08 FileManager: focus_dependent_delete_action is correctly enabled/disabled
The focus_dependent_delete_action that sits in the file manager's
toolbar would always remain enabled, even if nothing was selected,
activating it if nothing was selected would then crash the application.

The action is now correctly enabled/disabled, but due to the way
selection works in TreeViews, something is always selected, what really
matters is if the TreeView has something selected, and it has focus.
As it currently stands, there is no way to know when the TreeView's
is_focused status changes. In order for this to work I added a callback
to the Widget class which fires when a widget receives or looses focus.
In that callback, the focus_dependent_delete_action's enabled value is
recalculated.
2020-12-11 09:36:44 +01:00
Zac
df44ab8599 FileManager: TreeView accepts drags from the DirectoryView. 2020-12-11 09:36:44 +01:00
Zac
eb810d14c3
FileManager: Fix TreeView collapsing on file system changes (#4348)
TreeViews using FileSystemModels collapse whenever the file system is
changed in anyway. This includes creating, dragging, deleting or
pasting any files/folders. This commit updates the refresh_tree_view()
lambda, which seems to have stopped working at some point, and calls it
whenever any of the actions mentioned above are activated.
2020-12-08 17:51:53 +01:00
Zac
99e301510e FileManager: Call on_selection_change with the correct view 2020-12-01 11:05:08 +01:00
Andreas Kling
c31cc8c060 FileManager: Ignore model updates during widget construction
We can't use current_view() before we've actually constructed the
subviews, so just ignore statusbar update requests before they get
a chance to call current_view().

This is not the most beautiful thing, and maybe we can think of a
nicer approach.
2020-10-22 18:52:54 +02:00
Andreas Kling
460d3e3969 FileManager: Update the error label overlay on back/forward navigation
Fixes #3817.
2020-10-22 18:27:28 +02:00
Andreas Kling
39a7358b51 FileManager: Set up the model error/complete callbacks earlier
We need to set these up before calling set_root_path, as that's where
the error callbacks would fire from.
2020-10-22 18:26:59 +02:00
Linus Groh
20907780bd FileManager: Only set ~/Desktop as model root path in desktop mode
Setting it as model root path in DirectoryView::setup_model() for
windowed mode as well would cause an issue with the following:

- "open ~/Desktop"
- "FileManager ~/Desktop"
- "Show in FileManager..." from Desktop context menu

When viewing the Desktop as the initial path it would be the same and
on_path_change wasn't called, leading to various widgets and window
properties not being updated.

Fixes #3772.
2020-10-15 23:49:34 +02:00
Kesse Jones
31791945ab FileManager: Added menu to show dotfiles in directory context menu 2020-10-10 23:29:18 +02:00
Linus Groh
fcd263f17b FileManager: Fix file creation error message
s/String::format/String::formatted/ - the error message was not being
formatted properly.
2020-10-10 00:53:09 +02:00
asynts
ee9c18c118 FileManager: Use new format functions. 2020-10-05 16:25:50 +02:00
Linus Groh
bcfc6f0c57 Everywhere: Fix more typos 2020-10-03 12:36:49 +02:00
Andreas Kling
7d30cf7122 FileManager: Teach DirectoryView subviews to create editing delegates
This enables inline editing of filenames for table views, where this is
already supported. More work in LibGUI will be required to support the
feature in icon and columns views.
2020-09-24 11:36:02 +02:00
Andreas Kling
e1965a5a8e FileManager: Prevent feedback loop between treeview and directory view
When opening something in the left-side treeview, it also opens in the
right-side directory view. That triggers the "path changed" hook in the
directory view, which causes us to fully reveal the opened directory
in the left-side treeview.

This feedback loop made the UI feel weird since it caused directories
to expand just by selecting them in the left-side treeview. So let's
break that loop.
2020-09-19 14:09:59 +02:00
Andreas Kling
eb24603da0 FileManager: Properly reveal newly opened directories in the treeview
Use the new TreeView::expand_all_parent_of() API to ensure that newly
opened directories are revealed and scrolled-into-view in the left-side
treeview. :^)
2020-09-18 21:29:01 +02:00
Andreas Kling
56328409d9 FileManager: Update GUI when "entering" an inaccessible directory
When we enter an inaccessible directory, we still allow that directory
to become selected in the left-side treeview, so we need to update the
location box and window title to reflect the new current path.

This is not perfectly factored and there's a bit of duplication between
the model's on_error and on_complete hook callbacks in DirectoryView.
Needs more work. :^)
2020-09-18 21:29:01 +02:00
Andreas Kling
8075db683b FileManager: Show an inline error message for inaccessible directories
Instead of popping up a message box whenever we can't read an opened
directory, show the error message inside the DirectoryView (as a label)
instead.

This fixes a visual inconsistency where an inaccessible directory would
be selected in the left-side treeview while the previous directory's
contents were still showing on the right.

This also makes keyboard navigation a bit more pleasant since you're
not suddenly interrupted by a message box.
2020-09-18 21:29:01 +02:00
Andreas Kling
65b246aaf4 FileManager: Remove an unused enum in DirectoryView 2020-09-18 21:29:01 +02:00
Andreas Kling
07d4b41bac FileManager: Move DirectoryView into the FileManager namespace 2020-09-17 17:23:37 +02:00
Andreas Kling
8055f7a1f5 FileManager: Move the DesktopWidget to its own compilation unit 2020-09-17 14:34:47 +02:00
Andreas Kling
4e8c50d92d FileManager: Handle drop events in DirectoryView
This makes it possible to drag & drop files to/from the desktop! :^)
2020-09-17 14:30:00 +02:00
Andreas Kling
e1e58d5bc9 FileManager: Use GUI::FileIconProvider for the location box icon 2020-09-16 21:08:55 +02:00