Skip to content

General settings - #365

Merged
GyulyVGC merged 80 commits into
mainfrom
advanced-settings
Dec 10, 2023
Merged

GyulyVGC merged 80 commits into
mainfrom
advanced-settings

Conversation

@GyulyVGC

@GyulyVGC GyulyVGC commented Sep 2, 2023 •

Copy link
Copy Markdown
Owner

As the application is growing, more and more configurations are needed.
The current settings are not enough to cover more advanced customisations: for this reason, advanced settings are being introduced with this PR.

Moreover, this PR introduces the ability to remember the size and position of the application window so that it will reopen with the same window properties.

joshuamegnauth54 and others added 30 commits June 7, 2023 22:52
`iced::Color` doesn't implement `serde::Deserialize` nor
`serde::Serialize`. I need `Deserialize` so that custom color schemes
can be deserialized into the palette type used in Sniffnet.

I implemented ser/de to deserialize from a hex string into the float
colors used by `iced`. My reasoning is that hexadecimal colors are
easier for color scheme artists. Anecdotally, I've also noticed
hex colors are the most prevalent for color schemes. Some schemes also
provide RGB, but I haven't encountered float colors yet.

For example:
* [Catppuccin](https://github.com/catppuccin/catppuccin)
* [Dracula](https://draculatheme.com/contribute)
* [gruvbox](https://github.com/morhetz/gruvbox)
* [Nord](https://github.com/nordtheme/nord)
* [Tokyo Night](https://github.com/folke/tokyonight.nvim)
Merge branch 'main' of github.com:joshuamegnauth54/sniffnet into add_themes
Previously, I implemented a remote type to serialize and deserialize
`iced::Color`. That implementation caused some problems when writing the
unit tests because `serde_test` expected the `iced::Color` struct. I
didn't want to overhaul the tests from their concise and more direct
implementations - especially considering I don't really understand the
problem. Anyway, using `deserialize_with` and `serialize_with` is
cleaner than remote derive so this is overall a win.

I implemented `PartialEq` for the custom style's palette's to account
for floating point's imprecision. I also fixed an incorrectly copied
number that caused the unit tests to fail.

With that, deserializing custom styles from TOML seems to work and all
unit tests pass.
- Add support for descriptions in other languages.
- Use the latest `toml` crate because `confy`'s version had a bug that
  my code is hitting. Deserializing the `Language` enum in a TOML table
  failed with an error that claimed that the enum isn't a key. Upgrading
  the `toml` crate solved that problem.
- Clean up TOML theme spec.
Primarily to keep parity with the types that derived Hash before these
patches.
`StyleType` is no longer `Copy` because the enum holds `CustomStyle`.
Iced doesn't provide a file dialog to use because that should be handled
natively or something. See [iced-rs/iced#347].
(Also, remove a debug line).
I previously wrote PartialEq implementations for `Color` and structs
that used it, but deriving it seems to work fine now.
`StyleType` should serialize as a TOML table to account for
`StyleType::Custom` taking a value.

I added two attributes to `StyleType` to hint that the `toml` crate
should serialize it as a table instead of a simple key = value.
This adds a unit test to ensure that every built in custom theme
successfully deserializes.

@GyulyVGC GyulyVGC left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ðŸšĒ

@GyulyVGC
GyulyVGC marked this pull request as ready for review December 9, 2023 16:57
@GyulyVGC GyulyVGC changed the title Advanced settings General settings Dec 10, 2023
@GyulyVGC

Copy link
Copy Markdown
Owner Author

Hey @joshuamegnauth54 I finally merged to main the changes related to custom TOML files for the style.
At the end I placed the text box where you originally placed it (at the bottom of settings style tab).
I applied some nice tricks to make it looks like one of the other standard palettes once the theme is loaded and I'm really happy with the result.
Let me know your thoughts.
Sooner or later I will also add the possibility to open a file dialog through rfd.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature, request, or improvement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Window too large on Debian Sid in X11 [Feature Request] Option to provide path to own geoip database. Font is comically large

2 participants