mirror of
https://github.com/veeso/termscp.git
synced 2025-12-07 09:36:00 -08:00
Quit popup
This commit is contained in:
@@ -58,6 +58,7 @@ const COMPONENT_INPUT_USERNAME: &str = "INPUT_USERNAME";
|
|||||||
const COMPONENT_INPUT_PASSWORD: &str = "INPUT_PASSWORD";
|
const COMPONENT_INPUT_PASSWORD: &str = "INPUT_PASSWORD";
|
||||||
const COMPONENT_INPUT_BOOKMARK_NAME: &str = "INPUT_BOOKMARK_NAME";
|
const COMPONENT_INPUT_BOOKMARK_NAME: &str = "INPUT_BOOKMARK_NAME";
|
||||||
const COMPONENT_RADIO_PROTOCOL: &str = "RADIO_PROTOCOL";
|
const COMPONENT_RADIO_PROTOCOL: &str = "RADIO_PROTOCOL";
|
||||||
|
const COMPONENT_RADIO_QUIT: &str = "RADIO_QUIT";
|
||||||
const COMPONENT_RADIO_BOOKMARK_DEL_BOOKMARK: &str = "RADIO_DELETE_BOOKMARK";
|
const COMPONENT_RADIO_BOOKMARK_DEL_BOOKMARK: &str = "RADIO_DELETE_BOOKMARK";
|
||||||
const COMPONENT_RADIO_BOOKMARK_DEL_RECENT: &str = "RADIO_DELETE_RECENT";
|
const COMPONENT_RADIO_BOOKMARK_DEL_RECENT: &str = "RADIO_DELETE_RECENT";
|
||||||
const COMPONENT_RADIO_BOOKMARK_SAVE_PWD: &str = "RADIO_SAVE_PASSWORD";
|
const COMPONENT_RADIO_BOOKMARK_SAVE_PWD: &str = "RADIO_SAVE_PASSWORD";
|
||||||
|
|||||||
@@ -28,8 +28,8 @@ use super::{
|
|||||||
AuthActivity, COMPONENT_BOOKMARKS_LIST, COMPONENT_INPUT_ADDR, COMPONENT_INPUT_BOOKMARK_NAME,
|
AuthActivity, COMPONENT_BOOKMARKS_LIST, COMPONENT_INPUT_ADDR, COMPONENT_INPUT_BOOKMARK_NAME,
|
||||||
COMPONENT_INPUT_PASSWORD, COMPONENT_INPUT_PORT, COMPONENT_INPUT_USERNAME,
|
COMPONENT_INPUT_PASSWORD, COMPONENT_INPUT_PORT, COMPONENT_INPUT_USERNAME,
|
||||||
COMPONENT_RADIO_BOOKMARK_DEL_BOOKMARK, COMPONENT_RADIO_BOOKMARK_DEL_RECENT,
|
COMPONENT_RADIO_BOOKMARK_DEL_BOOKMARK, COMPONENT_RADIO_BOOKMARK_DEL_RECENT,
|
||||||
COMPONENT_RADIO_BOOKMARK_SAVE_PWD, COMPONENT_RADIO_PROTOCOL, COMPONENT_RECENTS_LIST,
|
COMPONENT_RADIO_BOOKMARK_SAVE_PWD, COMPONENT_RADIO_PROTOCOL, COMPONENT_RADIO_QUIT,
|
||||||
COMPONENT_TEXT_ERROR, COMPONENT_TEXT_HELP,
|
COMPONENT_RECENTS_LIST, COMPONENT_TEXT_ERROR, COMPONENT_TEXT_HELP,
|
||||||
};
|
};
|
||||||
use crate::ui::layout::{props::TextParts, Msg, Payload};
|
use crate::ui::layout::{props::TextParts, Msg, Payload};
|
||||||
// ext
|
// ext
|
||||||
@@ -124,7 +124,7 @@ impl AuthActivity {
|
|||||||
}
|
}
|
||||||
(COMPONENT_INPUT_PASSWORD, &MSG_KEY_DOWN) => {
|
(COMPONENT_INPUT_PASSWORD, &MSG_KEY_DOWN) => {
|
||||||
// Give focus to port
|
// Give focus to port
|
||||||
self.view.active(COMPONENT_INPUT_USERNAME);
|
self.view.active(COMPONENT_INPUT_ADDR);
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
// Focus ( UP )
|
// Focus ( UP )
|
||||||
@@ -375,6 +375,15 @@ impl AuthActivity {
|
|||||||
self.umount_error();
|
self.umount_error();
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
// Quit dialog
|
||||||
|
(COMPONENT_RADIO_QUIT, Msg::OnSubmit(Payload::Unsigned(choice))) => {
|
||||||
|
// If choice is 0, quit termscp
|
||||||
|
if *choice == 0 {
|
||||||
|
self.quit = true;
|
||||||
|
}
|
||||||
|
self.umount_quit();
|
||||||
|
None
|
||||||
|
}
|
||||||
// On submit on any unhandled (connect)
|
// On submit on any unhandled (connect)
|
||||||
(_, Msg::OnSubmit(_)) | (_, &MSG_KEY_ENTER) => {
|
(_, Msg::OnSubmit(_)) | (_, &MSG_KEY_ENTER) => {
|
||||||
// Match <ENTER> key for all other components
|
// Match <ENTER> key for all other components
|
||||||
@@ -391,6 +400,11 @@ impl AuthActivity {
|
|||||||
// Return None
|
// Return None
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
// <ESC> => Quit
|
||||||
|
(_, &MSG_KEY_ESC) => {
|
||||||
|
self.mount_quit();
|
||||||
|
None
|
||||||
|
}
|
||||||
(_, _) => None, // Ignore other events
|
(_, _) => None, // Ignore other events
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -259,6 +259,16 @@ impl AuthActivity {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if let Some(mut props) = self.view.get_props(super::COMPONENT_RADIO_QUIT) {
|
||||||
|
if props.build().visible {
|
||||||
|
// make popup
|
||||||
|
self.view.render(
|
||||||
|
super::COMPONENT_RADIO_QUIT,
|
||||||
|
f,
|
||||||
|
draw_area_in(f.size(), 30, 10),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
if let Some(mut props) = self
|
if let Some(mut props) = self
|
||||||
.view
|
.view
|
||||||
.get_props(super::COMPONENT_RADIO_BOOKMARK_DEL_BOOKMARK)
|
.get_props(super::COMPONENT_RADIO_BOOKMARK_DEL_BOOKMARK)
|
||||||
@@ -362,6 +372,33 @@ impl AuthActivity {
|
|||||||
self.view.umount(super::COMPONENT_TEXT_ERROR);
|
self.view.umount(super::COMPONENT_TEXT_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// ### mount_quit
|
||||||
|
///
|
||||||
|
/// Mount quit popup
|
||||||
|
pub(super) fn mount_quit(&mut self) {
|
||||||
|
// Protocol
|
||||||
|
self.view.mount(
|
||||||
|
super::COMPONENT_RADIO_QUIT,
|
||||||
|
Box::new(RadioGroup::new(
|
||||||
|
PropsBuilder::default()
|
||||||
|
.with_foreground(Color::Yellow)
|
||||||
|
.with_texts(TextParts::new(
|
||||||
|
Some(String::from("Quit TermSCP?")),
|
||||||
|
Some(vec![TextSpan::from("Yes"), TextSpan::from("No")]),
|
||||||
|
))
|
||||||
|
.build(),
|
||||||
|
)),
|
||||||
|
);
|
||||||
|
self.view.active(super::COMPONENT_RADIO_QUIT);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// ### umount_quit
|
||||||
|
///
|
||||||
|
/// Umount quit popup
|
||||||
|
pub(super) fn umount_quit(&mut self) {
|
||||||
|
self.view.umount(super::COMPONENT_RADIO_QUIT);
|
||||||
|
}
|
||||||
|
|
||||||
/// ### mount_bookmark_del_dialog
|
/// ### mount_bookmark_del_dialog
|
||||||
///
|
///
|
||||||
/// Mount bookmark delete dialog
|
/// Mount bookmark delete dialog
|
||||||
|
|||||||
Reference in New Issue
Block a user