Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

General settings #365

Merged
merged 80 commits into from
Dec 10, 2023
Merged

General settings #365

merged 80 commits into from
Dec 10, 2023

Conversation

GyulyVGC
Copy link
Owner

@GyulyVGC GyulyVGC commented Sep 2, 2023

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.
Copy link
Owner Author

@GyulyVGC GyulyVGC left a comment

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 GyulyVGC merged commit e9143e0 into main Dec 10, 2023
6 checks passed
@GyulyVGC GyulyVGC deleted the advanced-settings branch December 10, 2023 22:28
@GyulyVGC
Copy link
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
2 participants