mirror of
https://gitlab.com/gabmus/envision.git
synced 2025-07-29 20:28:48 +00:00
feat: button to show and copy profile uuid in debug view menu
This commit is contained in:
parent
5d0131a00c
commit
1b41029a30
2 changed files with 59 additions and 9 deletions
|
@ -653,6 +653,9 @@ impl SimpleComponent for App {
|
|||
self.main_view
|
||||
.sender()
|
||||
.emit(MainViewMsg::UpdateSelectedProfile(profile.clone()));
|
||||
self.debug_view
|
||||
.sender()
|
||||
.emit(DebugViewMsg::UpdateSelectedProfile(profile.clone()));
|
||||
}
|
||||
Msg::OpenLibsurviveSetup => {
|
||||
self.libsurvive_setup_window
|
||||
|
@ -871,6 +874,7 @@ impl SimpleComponent for App {
|
|||
ret.set_enabled(false);
|
||||
ret
|
||||
};
|
||||
let selected_profile = config.get_selected_profile(&profiles);
|
||||
|
||||
let mut model = App {
|
||||
tracker: 0,
|
||||
|
@ -880,7 +884,7 @@ impl SimpleComponent for App {
|
|||
main_view: MainView::builder()
|
||||
.launch(MainViewInit {
|
||||
config: config.clone(),
|
||||
selected_profile: config.get_selected_profile(&profiles),
|
||||
selected_profile: selected_profile.clone(),
|
||||
root_win: root.clone().into(),
|
||||
})
|
||||
.forward(sender.input_sender(), |message| match message {
|
||||
|
@ -891,12 +895,13 @@ impl SimpleComponent for App {
|
|||
MainViewOutMsg::SaveProfile(p) => Msg::SaveProfile(p),
|
||||
MainViewOutMsg::OpenLibsurviveSetup => Msg::OpenLibsurviveSetup,
|
||||
}),
|
||||
debug_view: DebugView::builder().launch(DebugViewInit {}).forward(
|
||||
sender.input_sender(),
|
||||
|message| match message {
|
||||
debug_view: DebugView::builder()
|
||||
.launch(DebugViewInit {
|
||||
profile: selected_profile,
|
||||
})
|
||||
.forward(sender.input_sender(), |message| match message {
|
||||
DebugViewOutMsg::StartWithDebug => Msg::StartWithDebug,
|
||||
},
|
||||
),
|
||||
}),
|
||||
about_dialog: AboutDialog::builder()
|
||||
.transient_for(&root)
|
||||
.launch(())
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
use super::term_widget::TermWidget;
|
||||
use super::util::copy_text;
|
||||
use crate::log_level::LogLevel;
|
||||
use crate::log_parser::MonadoLog;
|
||||
use crate::profile::Profile;
|
||||
use crate::ui::app::{DebugCopyEnvVarsAction, DebugOpenDataAction, DebugOpenPrefixAction};
|
||||
use gtk::glib::clone;
|
||||
use gtk::prelude::*;
|
||||
|
@ -13,6 +15,7 @@ pub enum SearchDirection {
|
|||
Backward,
|
||||
}
|
||||
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
#[derive(Debug)]
|
||||
pub enum DebugViewMsg {
|
||||
LogUpdated(Vec<String>),
|
||||
|
@ -21,6 +24,8 @@ pub enum DebugViewMsg {
|
|||
SearchFindMatch(SearchDirection),
|
||||
LogLevelChanged(LogLevel),
|
||||
XRServiceActiveChanged(bool),
|
||||
UpdateSelectedProfile(Profile),
|
||||
CopyProfileId,
|
||||
SetColorScheme,
|
||||
}
|
||||
|
||||
|
@ -42,9 +47,15 @@ pub struct DebugView {
|
|||
log_level: LogLevel,
|
||||
#[tracker::do_not_track]
|
||||
term: TermWidget,
|
||||
#[tracker::do_not_track]
|
||||
profile_id_widget: gtk::Button,
|
||||
#[no_eq]
|
||||
profile: Profile,
|
||||
}
|
||||
|
||||
pub struct DebugViewInit {}
|
||||
pub struct DebugViewInit {
|
||||
pub profile: Profile,
|
||||
}
|
||||
|
||||
#[relm4::component(pub)]
|
||||
impl SimpleComponent for DebugView {
|
||||
|
@ -54,6 +65,9 @@ impl SimpleComponent for DebugView {
|
|||
|
||||
menu! {
|
||||
debug_menu: {
|
||||
section! {
|
||||
custom: "profile_id_widget",
|
||||
},
|
||||
section! {
|
||||
"Open _Data Folder" => DebugOpenDataAction,
|
||||
"Open _Prefix Folder" => DebugOpenPrefixAction,
|
||||
|
@ -72,7 +86,7 @@ impl SimpleComponent for DebugView {
|
|||
add_css_class: "flat",
|
||||
pack_end: debug_menu_btn = >k::MenuButton {
|
||||
set_icon_name: "view-more-symbolic",
|
||||
set_tooltip_text: Some("Debug Actions..."),
|
||||
set_tooltip_text: Some("Debug Actions"),
|
||||
set_menu_model: Some(&debug_menu),
|
||||
},
|
||||
pack_end: search_toggle = >k::ToggleButton {
|
||||
|
@ -189,11 +203,19 @@ impl SimpleComponent for DebugView {
|
|||
Self::Input::SetColorScheme => {
|
||||
self.term.set_color_scheme();
|
||||
}
|
||||
Self::Input::UpdateSelectedProfile(prof) => {
|
||||
self.set_profile(prof);
|
||||
self.profile_id_widget
|
||||
.set_label(&format!("Profile id: {}", self.profile.uuid))
|
||||
}
|
||||
Self::Input::CopyProfileId => {
|
||||
copy_text(&self.profile.uuid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn init(
|
||||
_init: Self::Init,
|
||||
init: Self::Init,
|
||||
root: Self::Root,
|
||||
sender: ComponentSender<Self>,
|
||||
) -> ComponentParts<Self> {
|
||||
|
@ -238,14 +260,37 @@ impl SimpleComponent for DebugView {
|
|||
dropdown: None,
|
||||
log_level: LogLevel::Trace,
|
||||
term: TermWidget::new(),
|
||||
profile_id_widget: gtk::Button::builder()
|
||||
.css_classes(["flat", "dim-label", "caption"])
|
||||
.label(format!("Profile id: {}", init.profile.uuid))
|
||||
.tooltip_text("Copy")
|
||||
.build(),
|
||||
profile: init.profile,
|
||||
};
|
||||
model.term.set_color_scheme();
|
||||
|
||||
model.profile_id_widget.connect_clicked(clone!(
|
||||
#[strong]
|
||||
sender,
|
||||
move |_| {
|
||||
sender.input(Self::Input::CopyProfileId);
|
||||
}
|
||||
));
|
||||
|
||||
let widgets = view_output!();
|
||||
model.searchbar = Some(widgets.searchbar.clone());
|
||||
model.search_entry = Some(widgets.search_entry.clone());
|
||||
model.dropdown = Some(log_level_dropdown.clone());
|
||||
|
||||
widgets
|
||||
.debug_menu_btn
|
||||
.popover()
|
||||
.clone()
|
||||
.unwrap()
|
||||
.downcast::<gtk::PopoverMenu>()
|
||||
.unwrap()
|
||||
.add_child(&model.profile_id_widget, "profile_id_widget");
|
||||
|
||||
ComponentParts { model, widgets }
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue