diff --git a/flutter/lib/common.dart b/flutter/lib/common.dart index 054b4df31..2f526fb48 100644 --- a/flutter/lib/common.dart +++ b/flutter/lib/common.dart @@ -1057,6 +1057,49 @@ class CustomAlertDialog extends StatelessWidget { } } +Widget createDialogContent(String text) { + final RegExp linkRegExp = RegExp(r'(https?://[^\s]+)'); + final List spans = []; + int start = 0; + bool hasLink = false; + + linkRegExp.allMatches(text).forEach((match) { + hasLink = true; + if (match.start > start) { + spans.add(TextSpan(text: text.substring(start, match.start))); + } + spans.add(TextSpan( + text: match.group(0) ?? '', + style: TextStyle( + color: Colors.blue, + decoration: TextDecoration.underline, + ), + recognizer: TapGestureRecognizer() + ..onTap = () { + String linkText = match.group(0) ?? ''; + linkText = linkText.replaceAll(RegExp(r'[.,;!?]+$'), ''); + launchUrl(Uri.parse(linkText)); + }, + )); + start = match.end; + }); + + if (start < text.length) { + spans.add(TextSpan(text: text.substring(start))); + } + + if (!hasLink) { + return SelectableText(text, style: const TextStyle(fontSize: 15)); + } + + return SelectableText.rich( + TextSpan( + style: TextStyle(color: Colors.black, fontSize: 15), + children: spans, + ), + ); +} + void msgBox(SessionID sessionId, String type, String title, String text, String link, OverlayDialogManager dialogManager, {bool? hasCancel, ReconnectHandle? reconnect, int? reconnectTimeout}) { @@ -1214,8 +1257,7 @@ Widget msgboxContent(String type, String title, String text) { translate(title), style: TextStyle(fontSize: 21), ).marginOnly(bottom: 10), - SelectableText(translateText(text), - style: const TextStyle(fontSize: 15)), + createDialogContent(translateText(text)), ], ), ), diff --git a/libs/scrap/src/wayland/pipewire.rs b/libs/scrap/src/wayland/pipewire.rs index c7f2e62ac..640f37d0b 100644 --- a/libs/scrap/src/wayland/pipewire.rs +++ b/libs/scrap/src/wayland/pipewire.rs @@ -593,7 +593,7 @@ pub fn request_remote_desktop() -> Result< } } Err(Box::new(DBusError( - "Failed to obtain screen capture.".into(), +"Failed to obtain screen capture. You may need to upgrade the PipeWire library for better compatibility. Please check https://github.com/rustdesk/rustdesk/issues/8600#issuecomment-2254720954 for more details.".into() ))) }