Shannon Sterz [Fri, 3 Jan 2025 10:26:25 +0000 (11:26 +0100)]
tree wide: apply auto-appliable clippy fix-ups
this mostly includes:
- switching from `Into` to `From` implementations as that also provides
an `Into` implementation for "free"
- adding `Default` implementations where possible (e.g. if a `new`
function without parameters exists)
- removing unnecessary reference and dereference operations (e.g. if the
compiler would do that automatically anyway)
- using more idiomatic syntax (e.g. using `contains` instead of `<` and
`>=` operators)
- removing closures where they aren't necessary
- removing `format!` macros where `to_string()` would do to improve
performance
- remove unnecessary convertions and into calls
these should not change the semantics of the exists code itself, so
there are no breaking changes. however, adding `Default` implementations
and such, does add new public APIs for some types.
Dominik Csapak [Fri, 20 Dec 2024 10:31:39 +0000 (11:31 +0100)]
widget: dropdown: update picker placement after showing
It seems that under certain circumstances (e.g. a dropdown in a
dialog) updating the position of the picker before it's opened (it's a
popover) does not work properly in safari/webkit/epiphany.
When trying to open such a dropdown, it (or some parts of it) would be
rendered with a height of 0px, even though the elements have a height
set explicitly.
To fix this, update the picker placement after opening it. What
exactly is the cause (e.g. if it's a browser bug or our css/aligning)
is yet to be determined.
This fixes an issue on webkit (tested with epiphany) that opening
dropdowns in a dialog did not show the dropdown properly.
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com> Tested-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
[ TL: extend comment to mention webkit explicitly ] Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Thomas Lamprecht [Thu, 19 Dec 2024 11:13:16 +0000 (12:13 +0100)]
whitepaper: re-flow text to 80 cc width
Wrap at a consistent text-width of 80 character columns, that is
a relatively standard width for prose and a good balance for having
more context visible at the same time while not requiring to much neck
moving.
Also fix a unclosed code-block by adding the third backtick
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Dominik Csapak [Wed, 18 Dec 2024 14:25:08 +0000 (15:25 +0100)]
widget: display: don't set inital value
when doing that, a new value that is set via `new` won't get used as a
value anymore, which is undesired. only use the value for the default,
which was the original intenion.
This fixes an issue where the value of a display field changes after the
first creation and would not update it's displayed value.
Shannon Sterz [Tue, 17 Dec 2024 15:09:46 +0000 (16:09 +0100)]
catalog_loader: don't try to load the catalog if the language is empty
this means that the Language value in the local storage is not set. by
default this would try to load `catalog-.mo` as language is an empty
string, so just skip trying to load something here and simply initialize
with an empty catalog instead, avoiding a failed load.
Dominik Csapak [Mon, 16 Dec 2024 13:18:38 +0000 (14:18 +0100)]
widget: data table: beter handle navigation input
when inside a cell, we generally want to navigate with arrow keys,
except if we're inside an input element. In that case, use tab/shift+tab
to navigate out and don't catch arrows/space to allow navigation within
the input field (and input a space).
Thomas Lamprecht [Sat, 14 Dec 2024 12:58:52 +0000 (13:58 +0100)]
theme density: rework naming to more telling variants
Rework the naming and doc comments of the theme density type but
include backward compatibility for the old variants when parsing the
density from a string. There's nothing to adapt on the actual UI
examples or products.
The bigger improvement is avoiding "Auto" for the default theme
spacing/density, as "auto" is widely used for something that
dynamically adapts on some environment aspects. But all our themes do
not have any such queries for high/low dpi or screen width to choose a
fitting spacing dynamically. Use `Preset` to avoid clashing with the
widely used `Default` trait from the rust std lib, albeit we could use
that if we really want.
The smaller fine tuning is renaming "High" to "Compact" and "Touch" to
"Relaxed".
The reasoning for the first is that most people, including our user
base, does not work with density a lot in their every day life, be it
physical density or screen density, so "higher density", while
definitively correct for what it does, is not that intuitive, i.e.
when "higher" makes things "smaller" we have a sort of double-negation
that is almost never good to have for UX.
The reasoning for the second (Touch -> Relaxed) is that this is not
doing anything with touch directly, it just might correlate with that
use case, and coupling a setting name with one specific use case is a
bit confusing for peoples coming from other use cases, like simply
having a higher DPI but not doing desktop wide scaling.
Note the naming was initially suggested by me with Thunderbird as
example, so this is really just improving on my own short comings from
the past. It also seems that newer Thunderbird Versions (e.g., latest
134.0b4) changed the wording to something similar than we now have
after this commit.
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Shannon Sterz [Tue, 3 Dec 2024 11:04:50 +0000 (12:04 +0100)]
language: make LANGUAGE thread local
in rust edition 2024 [1] it is no longer allowed to use references to
`static mut` variables. the recommended way of dealing with this is to
use inner mutability. this usually requires the wrapped trait to
implement `Sync` to be thread safe. however, `SharedState` uses `Rc`s
for its implementation, which do not implement `Sync` and so
`SharedState` cannot be `Sync`.
using `Rc`s in WASM is usually fine as WASM code generally isn't
multi-threaded. there are some ways to exploit parallelism, but they are
fairly limited (e.g. web workers). so following this logic, make
`LANGUAGE` thread local. this will allow us to use edition 2024 without
too many changes.
Shannon Sterz [Tue, 3 Dec 2024 11:04:49 +0000 (12:04 +0100)]
gettext_wrapper: use inner mutability for CATALOG
in the rust edition 2024 [1] `static mut` are not allowed to be
referenced anymore, as doing so has always been undefined behaviour. the
recommended way to work around this is to use inner mutability. so use a
`RWLock` here.
Shannon Sterz [Tue, 3 Dec 2024 11:04:48 +0000 (12:04 +0100)]
language: use inner mutability for AVAILABLE_LANUGAGES
in rust edition 2024 taking references to `static mut` variables will be
disallowed [1]. the recommended way to adapting to this is using inner
mutability. so use a OnceLock here to ensure that the set of available
languages can only be set once.
in the `load` method, we just setup the loading itself, but the write
guard does that on every `Drop`. To prevent that and only trigger
the `on_change` callback when the data really changed, combine the
calls to `write()` here so we only have one guard and disable the
notification on it.
Dominik Csapak [Mon, 18 Nov 2024 12:02:34 +0000 (13:02 +0100)]
widget: dropdown: make popover behavior manual
otherwise the popover is dismissed by e.g. clicking in the field
when it's editable, which produces an undesired effect.
(It's then "closed" but still visible because of our css classes, and
now our aligning logic is wrong because popovers behave differently when
open vs closed)
Dominik Csapak [Thu, 14 Nov 2024 14:36:48 +0000 (15:36 +0100)]
widget: dropdown: properly focus the selected element
we currently always have a datatable as a picker, so the selected
element must be the cell, as the row (which gets the 'selected' class)
is not selectable (it has no tabindex)
Dominik Csapak [Thu, 14 Nov 2024 14:36:47 +0000 (15:36 +0100)]
widget: dropdown: use popover instead of a dialog
by using popovers, we don't have get the messy focus behaviour of
dialogs, for example those focus the first element when the dialog is
opened, which often is the header menu of a datatable.
This also makes the code a bit shorter, since we can restore the focus
before the popover is fully closed (and simply hide it as soon as
possible).
for now we have to use our own bindings to show/hide/togglePopover, but
this can be removed with a later web-sys version.