Skip to content

Commit

Permalink
language is now part of general settings
Browse files Browse the repository at this point in the history
  • Loading branch information
GyulyVGC committed Dec 10, 2023
1 parent c0b8c77 commit 4a80c88
Show file tree
Hide file tree
Showing 14 changed files with 217 additions and 321 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
All Sniffnet releases with the relative changes are documented in this file.

## [UNRELEASED]
- The size of text and widgets can now be customised by setting a proper scale factor value (fixes [#202](https://github.com/GyulyVGC/sniffnet/issues/202) and [#344](https://github.com/GyulyVGC/sniffnet/issues/344))
- The size of text and widgets can now be customised by setting a proper zoom value (fixes [#202](https://github.com/GyulyVGC/sniffnet/issues/202) and [#344](https://github.com/GyulyVGC/sniffnet/issues/344))
- Added possibility to totally customize the app's theme via styles defined in TOML files ([#286](https://github.com/GyulyVGC/sniffnet/pull/286))
- Added Japanese translation 🇯🇵 ([#343](https://github.com/GyulyVGC/sniffnet/pull/343))
- Added Uzbek translation 🇺🇿 ([#385](https://github.com/GyulyVGC/sniffnet/pull/385))
- Window size and position are now remembered, so that Sniffnet can reopen with the same window properties
- Users can now provide custom paths for MMDB files to allow using the commercial versions of the country and ASN databases (fixes [#243](https://github.com/GyulyVGC/sniffnet/issues/243))
- The app's configurations are now stored only on application close, instead of needlessly store them each time the settings popup is closed
- The textual output report is not generated anymore
- Settings "Language" tab has been removed. Language selection and other options are now included in a new settings tab "General".
- Updated Portuguese translation to v1.2 ([#398](https://github.com/GyulyVGC/sniffnet/pull/398))
- Cleaned code implementing the concept of first class theming ([#339](https://github.com/GyulyVGC/sniffnet/pull/339))
- Added documentation about Sniffnet installation on Nix and Tiny Core Linux (respectively [#394](https://github.com/GyulyVGC/sniffnet/pull/394) and [#341](https://github.com/GyulyVGC/sniffnet/pull/341))
Expand Down
3 changes: 0 additions & 3 deletions src/configs/types/config_advanced_settings.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//! Module defining the `ConfigAdvancedSettings` struct, which allows to save and reload
//! the application advanced settings.
use crate::utils::formatted_strings::get_default_report_file_path;
use serde::{Deserialize, Serialize};

#[derive(Serialize, Deserialize, Clone, PartialEq)]
Expand All @@ -10,7 +9,6 @@ pub struct ConfigAdvancedSettings {
pub mmdb_country: String,
pub mmdb_asn: String,
pub style_path: String,
pub output_path: String,
}

impl ConfigAdvancedSettings {
Expand Down Expand Up @@ -42,7 +40,6 @@ impl Default for ConfigAdvancedSettings {
mmdb_country: String::new(),
mmdb_asn: String::new(),
style_path: String::new(),
output_path: get_default_report_file_path(),
}
}
}
6 changes: 2 additions & 4 deletions src/gui/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ use crate::gui::pages::initial_page::initial_page;
use crate::gui::pages::inspect_page::inspect_page;
use crate::gui::pages::notifications_page::notifications_page;
use crate::gui::pages::overview_page::overview_page;
use crate::gui::pages::settings_advanced_page::settings_advanced_page;
use crate::gui::pages::settings_language_page::settings_language_page;
use crate::gui::pages::settings_general_page::settings_general_page;
use crate::gui::pages::settings_notifications_page::settings_notifications_page;
use crate::gui::pages::settings_style_page::settings_style_page;
use crate::gui::pages::types::running_page::RunningPage;
Expand Down Expand Up @@ -96,8 +95,7 @@ impl Application for Sniffer {
let overlay = match settings_page {
SettingsPage::Notifications => settings_notifications_page(self),
SettingsPage::Appearance => settings_style_page(self),
SettingsPage::Language => settings_language_page(self),
SettingsPage::Advanced => settings_advanced_page(self),
SettingsPage::General => settings_general_page(self),
};

Modal::new(content, overlay)
Expand Down
34 changes: 1 addition & 33 deletions src/gui/components/radio.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use iced::widget::horizontal_space;
use iced::widget::{Column, Radio, Row, Text};
use iced::{Alignment, Font, Length, Renderer};
use iced::{Alignment, Font, Renderer};

use crate::gui::styles::style_constants::FONT_SIZE_SUBTITLE;
use crate::gui::styles::text::TextType;
Expand Down Expand Up @@ -68,37 +67,6 @@ pub fn transport_protocol_radios(
ret_val
}

pub fn language_radios(
active: Language,
collection: &[Language],
font: Font,
) -> Row<'static, Message, Renderer<StyleType>> {
let mut ret_val = Row::new().spacing(10).align_items(Alignment::Center);
for option in collection {
ret_val = ret_val.push(
Row::new().align_items(Alignment::Center).push(
Row::new()
.align_items(Alignment::Center)
.width(Length::Fixed(200.0))
.push(
Radio::new(
format!("{} ({:?})", option.get_radio_label(), option),
*option,
Some(active),
Message::LanguageSelection,
)
.spacing(7)
.font(font)
.size(15),
)
.push(horizontal_space(Length::Fixed(15.0)))
.push(option.get_flag()),
),
);
}
ret_val
}

pub fn sound_packets_threshold_radios(
packets_notification: PacketsNotification,
font: Font,
Expand Down
19 changes: 7 additions & 12 deletions src/gui/components/tab.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ fn new_settings_tab(
language: Language,
font: Font,
) -> Button<'static, Message, Renderer<StyleType>> {
let mut content = Row::new()
let content = Row::new()
.align_items(Alignment::Center)
.push(horizontal_space(Length::FillPortion(1)))
.push(
Expand All @@ -147,9 +147,9 @@ fn new_settings_tab(
})
.horizontal_alignment(alignment::Horizontal::Center)
.vertical_alignment(alignment::Vertical::Center),
);
if page.ne(&SettingsPage::Advanced) {
content = content.push(horizontal_space(10)).push(
)
.push(horizontal_space(10))
.push(
Text::new(page.get_tab_label(language).to_string())
.font(font)
.size(FONT_SIZE_SUBTITLE)
Expand All @@ -160,18 +160,13 @@ fn new_settings_tab(
})
.horizontal_alignment(alignment::Horizontal::Center)
.vertical_alignment(alignment::Vertical::Center),
);
}
content = content.push(horizontal_space(Length::FillPortion(1)));
)
.push(horizontal_space(Length::FillPortion(1)));

button(content)
.height(Length::Fixed(if active { 35.0 } else { 30.0 }))
.padding(0)
.width(if page.eq(&SettingsPage::Advanced) {
Length::Fixed(45.0)
} else {
Length::FillPortion(1)
})
.width(Length::FillPortion(1))
.style(if active {
ButtonType::TabActive
} else {
Expand Down
3 changes: 1 addition & 2 deletions src/gui/pages/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ pub mod initial_page;
pub mod inspect_page;
pub mod notifications_page;
pub mod overview_page;
pub mod settings_advanced_page;
pub mod settings_language_page;
pub mod settings_general_page;
pub mod settings_notifications_page;
pub mod settings_style_page;
pub mod types;
Loading

0 comments on commit 4a80c88

Please sign in to comment.