use open instead of egui OpenUrl for mailto link
Signed-off-by: kernelkind <kernelkind@gmail.com>
This commit is contained in:
37
Cargo.lock
generated
37
Cargo.lock
generated
@@ -2067,6 +2067,15 @@ version = "2.10.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "187674a687eed5fe42285b40c6291f9a01517d415fad1c3cbc6a9f778af7fcd4"
|
checksum = "187674a687eed5fe42285b40c6291f9a01517d415fad1c3cbc6a9f778af7fcd4"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "is-docker"
|
||||||
|
version = "0.2.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "928bae27f42bc99b60d9ac7334e3a21d10ad8f1835a4e12ec3ec0464765ed1b3"
|
||||||
|
dependencies = [
|
||||||
|
"once_cell",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "is-terminal"
|
name = "is-terminal"
|
||||||
version = "0.4.13"
|
version = "0.4.13"
|
||||||
@@ -2078,6 +2087,16 @@ dependencies = [
|
|||||||
"windows-sys 0.52.0",
|
"windows-sys 0.52.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "is-wsl"
|
||||||
|
version = "0.4.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "173609498df190136aa7dea1a91db051746d339e18476eed5ca40521f02d7aa5"
|
||||||
|
dependencies = [
|
||||||
|
"is-docker",
|
||||||
|
"once_cell",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "is_terminal_polyfill"
|
name = "is_terminal_polyfill"
|
||||||
version = "1.70.1"
|
version = "1.70.1"
|
||||||
@@ -2591,6 +2610,7 @@ dependencies = [
|
|||||||
"indexmap",
|
"indexmap",
|
||||||
"log",
|
"log",
|
||||||
"nostrdb",
|
"nostrdb",
|
||||||
|
"open",
|
||||||
"poll-promise",
|
"poll-promise",
|
||||||
"puffin",
|
"puffin",
|
||||||
"puffin_egui",
|
"puffin_egui",
|
||||||
@@ -2887,6 +2907,17 @@ version = "0.3.1"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381"
|
checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "open"
|
||||||
|
version = "5.3.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "61a877bf6abd716642a53ef1b89fb498923a4afca5c754f9050b4d081c05c4b3"
|
||||||
|
dependencies = [
|
||||||
|
"is-wsl",
|
||||||
|
"libc",
|
||||||
|
"pathdiff",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "openssl-probe"
|
name = "openssl-probe"
|
||||||
version = "0.1.5"
|
version = "0.1.5"
|
||||||
@@ -2963,6 +2994,12 @@ version = "1.0.15"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a"
|
checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "pathdiff"
|
||||||
|
version = "0.2.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d61c5ce1153ab5b689d0c074c4e7fc613e942dfb7dd9eea5ab202d2ad91fe361"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pbkdf2"
|
name = "pbkdf2"
|
||||||
version = "0.12.2"
|
version = "0.12.2"
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ indexmap = "2.6.0"
|
|||||||
dirs = "5.0.1"
|
dirs = "5.0.1"
|
||||||
tracing-appender = "0.2.3"
|
tracing-appender = "0.2.3"
|
||||||
urlencoding = "2.1.3"
|
urlencoding = "2.1.3"
|
||||||
|
open = "5.3.0"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
tempfile = "3.13.0"
|
tempfile = "3.13.0"
|
||||||
|
|||||||
@@ -1,49 +0,0 @@
|
|||||||
use egui::{Button, Response, Ui, Widget};
|
|
||||||
|
|
||||||
pub struct ButtonHyperlink<'a> {
|
|
||||||
url: String,
|
|
||||||
button: Button<'a>,
|
|
||||||
new_tab: bool,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'a> ButtonHyperlink<'a> {
|
|
||||||
pub fn new(button: Button<'a>, url: impl ToString) -> Self {
|
|
||||||
let url = url.to_string();
|
|
||||||
Self {
|
|
||||||
url: url.clone(),
|
|
||||||
button,
|
|
||||||
new_tab: false,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn open_in_new_tab(mut self, new_tab: bool) -> Self {
|
|
||||||
self.new_tab = new_tab;
|
|
||||||
self
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'a> Widget for ButtonHyperlink<'a> {
|
|
||||||
fn ui(self, ui: &mut Ui) -> Response {
|
|
||||||
let response = ui.add(self.button);
|
|
||||||
|
|
||||||
if response.clicked() {
|
|
||||||
let modifiers = ui.ctx().input(|i| i.modifiers);
|
|
||||||
ui.ctx().open_url(egui::OpenUrl {
|
|
||||||
url: self.url.clone(),
|
|
||||||
new_tab: self.new_tab || modifiers.any(),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if response.middle_clicked() {
|
|
||||||
ui.ctx().open_url(egui::OpenUrl {
|
|
||||||
url: self.url.clone(),
|
|
||||||
new_tab: true,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if ui.style().url_in_tooltip {
|
|
||||||
response.on_hover_text(self.url)
|
|
||||||
} else {
|
|
||||||
response
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -2,7 +2,6 @@ pub mod account_login_view;
|
|||||||
pub mod account_management;
|
pub mod account_management;
|
||||||
pub mod add_column;
|
pub mod add_column;
|
||||||
pub mod anim;
|
pub mod anim;
|
||||||
pub mod button_hyperlink;
|
|
||||||
pub mod mention;
|
pub mod mention;
|
||||||
pub mod note;
|
pub mod note;
|
||||||
pub mod preview;
|
pub mod preview;
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
use egui::{vec2, Button, Label, Layout, RichText};
|
use egui::{vec2, Button, Label, Layout, RichText};
|
||||||
|
use tracing::error;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
app_style::{get_font_size, NotedeckTextStyle},
|
app_style::{get_font_size, NotedeckTextStyle},
|
||||||
@@ -7,7 +8,7 @@ use crate::{
|
|||||||
support::Support,
|
support::Support,
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::{button_hyperlink::ButtonHyperlink, padding};
|
use super::padding;
|
||||||
|
|
||||||
pub struct SupportView<'a> {
|
pub struct SupportView<'a> {
|
||||||
support: &'a mut Support,
|
support: &'a mut Support,
|
||||||
@@ -31,15 +32,18 @@ impl<'a> SupportView<'a> {
|
|||||||
ui.label("Open your default email client to get help from the Damus team");
|
ui.label("Open your default email client to get help from the Damus team");
|
||||||
let size = vec2(120.0, 40.0);
|
let size = vec2(120.0, 40.0);
|
||||||
ui.allocate_ui_with_layout(size, Layout::top_down(egui::Align::Center), |ui| {
|
ui.allocate_ui_with_layout(size, Layout::top_down(egui::Align::Center), |ui| {
|
||||||
ui.add(ButtonHyperlink::new(
|
let font_size = get_font_size(ui.ctx(), &NotedeckTextStyle::Body);
|
||||||
Button::new(
|
let button_resp = ui.add(open_email_button(font_size, size));
|
||||||
RichText::new("Open Email")
|
if button_resp.clicked() {
|
||||||
.size(get_font_size(ui.ctx(), &NotedeckTextStyle::Body)),
|
if let Err(e) = open::that(self.support.get_mailto_url()) {
|
||||||
)
|
error!(
|
||||||
.fill(PINK)
|
"Failed to open URL {} because: {}",
|
||||||
.min_size(size),
|
self.support.get_mailto_url(),
|
||||||
self.support.get_mailto_url(),
|
e
|
||||||
));
|
);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
button_resp.on_hover_text_at_pointer(self.support.get_mailto_url());
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -74,3 +78,9 @@ impl<'a> SupportView<'a> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn open_email_button(font_size: f32, size: egui::Vec2) -> impl egui::Widget {
|
||||||
|
Button::new(RichText::new("Open Email").size(font_size))
|
||||||
|
.fill(PINK)
|
||||||
|
.min_size(size)
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user