Repository navigation
General settings - #365
Merged
Merged
General settings#365
Conversation
`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
marked this pull request as ready for review
December 9, 2023 16:57
This was referenced Dec 10, 2023
Closed
Owner
Author
|
Hey @joshuamegnauth54 I finally merged to |
1 task done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.
custom path for the output report, to find the file more easily or reduce the number of disk writes in case of SSDs(this will be implemented while adding support for PCAP generation)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.