Skip to content

Commit 93e1f29

Browse files
committed
move the port selection in settings page to reduce clutter
1 parent fd1f2a1 commit 93e1f29

File tree

5 files changed

+44
-43
lines changed

5 files changed

+44
-43
lines changed

RustApp/.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@
99
/flatpak-out
1010
/repo
1111
/log
12-
/config/
12+
/config/
13+
/src/streamer/_.rs

RustApp/i18n/en/android_mic.ftl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ channel_count = Channel count
3131
audio_format = Audio format
3232
use_recommended_audio_format = Use Recommended Audio Format
3333
34+
title_connection = Connection
35+
3436
denoise = Noise reduction
3537
denoise_enabled = Enabled
3638
denoise_type = Type

RustApp/src/ui/app.rs

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -561,26 +561,6 @@ impl Application for AppState {
561561
self.network_adapter = Some(adapter.clone());
562562
return self.add_log(format!("Selected network adapter: {adapter}").as_str());
563563
}
564-
AppMsg::PortTextInput(text) => {
565-
self.port_input = text;
566-
}
567-
AppMsg::PortSave => {
568-
let port = if self.port_input.is_empty() {
569-
55555
570-
} else {
571-
match self.port_input.parse() {
572-
Ok(p) => p,
573-
Err(_) => {
574-
self.port_input = "55555".to_string();
575-
self.config.update(|c| c.port = 55555);
576-
return self.add_log("Invalid port number, using default 55555");
577-
}
578-
}
579-
};
580-
self.config.update(|c| c.port = port);
581-
self.port_input = port.to_string();
582-
return self.add_log(format!("Changed port to {}", port).as_str());
583-
}
584564
AppMsg::Connect => {
585565
return self.connect();
586566
}
@@ -613,6 +593,27 @@ impl Application for AppState {
613593
}
614594
},
615595
AppMsg::Config(msg) => match msg {
596+
ConfigMsg::PortTextInput(text) => {
597+
self.port_input = text;
598+
}
599+
ConfigMsg::PortSave => {
600+
let port = if self.port_input.is_empty() {
601+
55555
602+
} else {
603+
match self.port_input.parse() {
604+
Ok(p) => p,
605+
Err(_) => {
606+
self.port_input = "55555".to_string();
607+
self.config.update(|c| c.port = 55555);
608+
return self.add_log("Invalid port number, using default 55555");
609+
}
610+
}
611+
};
612+
self.config.update(|c| c.port = port);
613+
self.port_input = port.to_string();
614+
return self.add_log(format!("Changed port to {}", port).as_str());
615+
}
616+
616617
ConfigMsg::SampleRate(sample_rate) => {
617618
self.config.update(|s| s.sample_rate = sample_rate);
618619
return self.update_audio_stream();

RustApp/src/ui/message.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ pub enum AppMsg {
1515
Streamer(StreamerMsg),
1616
Device(AudioDevice),
1717
Adapter(NetworkAdapter),
18-
PortTextInput(String),
19-
PortSave,
2018
Connect,
2119
Stop,
2220
ToggleSettingsWindow,
@@ -55,6 +53,8 @@ pub enum ConfigMsg {
5553
Amplify(bool),
5654
AmplifyValue(f32),
5755
ToggleAboutWindow,
56+
PortTextInput(String),
57+
PortSave,
5858
}
5959

6060
#[derive(Debug, Clone, PartialEq, Eq, Copy)]

RustApp/src/ui/view.rs

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ pub fn main_window(app: &AppState) -> Element<'_, AppMsg> {
4444
column()
4545
.width(Length::FillPortion(1))
4646
.height(Length::Fill)
47+
.spacing(35)
4748
.align_x(Horizontal::Center)
4849
.push(network_adapter(app))
49-
.push(port(app))
5050
.push(audio(app))
5151
.push(vertical_space())
5252
.push(connection_type(app)),
@@ -159,25 +159,6 @@ fn network_adapter(app: &AppState) -> Element<'_, AppMsg> {
159159
.into()
160160
}
161161

162-
fn port(app: &AppState) -> Element<'_, AppMsg> {
163-
column()
164-
.spacing(20)
165-
.align_x(Horizontal::Center)
166-
.push(text::title4(fl!("port")))
167-
.push(
168-
row()
169-
.width(Length::Fill)
170-
.spacing(5)
171-
.push(
172-
text_input("", &app.port_input)
173-
.on_input(AppMsg::PortTextInput)
174-
.width(Length::Fixed(150.0)),
175-
)
176-
.push(button::text(fl!("save")).on_press(AppMsg::PortSave)),
177-
)
178-
.into()
179-
}
180-
181162
fn connection_type(app: &AppState) -> Element<'_, AppMsg> {
182163
let connection_mode = &app.config.data().connection_mode;
183164

@@ -299,6 +280,22 @@ pub fn settings_window(app: &AppState) -> Element<'_, ConfigMsg> {
299280
.push(horizontal_space()),
300281
),
301282
)
283+
.push(
284+
settings::section().title(fl!("title_connection")).add(
285+
row()
286+
.width(Length::Fill)
287+
.align_y(Vertical::Center)
288+
.spacing(5)
289+
.push(text(fl!("port")))
290+
.push(horizontal_space())
291+
.push(
292+
text_input("", &app.port_input)
293+
.on_input(ConfigMsg::PortTextInput)
294+
.width(Length::Fixed(150.0)),
295+
)
296+
.push(button::text(fl!("save")).on_press(ConfigMsg::PortSave)),
297+
),
298+
)
302299
.push(
303300
settings::section()
304301
.title(fl!("denoise"))

0 commit comments

Comments
 (0)