Merge pull request #5696 from sahilyeole/feat/optional_update_check

Feat optional update check and closable update card
This commit is contained in:
RustDesk 2023-09-15 09:20:00 +08:00 committed by GitHub
commit e8510ddc58
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
38 changed files with 77 additions and 7 deletions

View File

@ -48,6 +48,7 @@ class _DesktopHomePageState extends State<DesktopHomePage>
var watchIsInputMonitoring = false; var watchIsInputMonitoring = false;
var watchIsCanRecordAudio = false; var watchIsCanRecordAudio = false;
Timer? _updateTimer; Timer? _updateTimer;
bool isCardClosed = false;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -321,14 +322,15 @@ class _DesktopHomePageState extends State<DesktopHomePage>
} }
Future<Widget> buildHelpCards() async { Future<Widget> buildHelpCards() async {
if (updateUrl.isNotEmpty) { if (updateUrl.isNotEmpty && !isCardClosed) {
return buildInstallCard( return buildInstallCard(
"Status", "Status",
"There is a newer version of ${bind.mainGetAppNameSync()} ${bind.mainGetNewVersion()} available.", "There is a newer version of ${bind.mainGetAppNameSync()} ${bind.mainGetNewVersion()} available.",
"Click to download", () async { "Click to download", () async {
final Uri url = Uri.parse('https://rustdesk.com/download'); final Uri url = Uri.parse('https://rustdesk.com/download');
await launchUrl(url); await launchUrl(url);
}); },
closeButton: true);
} }
if (systemError.isNotEmpty) { if (systemError.isNotEmpty) {
return buildInstallCard("", systemError, "", () {}); return buildInstallCard("", systemError, "", () {});
@ -394,11 +396,20 @@ class _DesktopHomePageState extends State<DesktopHomePage>
Widget buildInstallCard(String title, String content, String btnText, Widget buildInstallCard(String title, String content, String btnText,
GestureTapCallback onPressed, GestureTapCallback onPressed,
{String? help, String? link}) { {String? help, String? link, bool? closeButton}) {
return Container(
margin: EdgeInsets.only(top: 20), void closeCard() {
child: Container( setState(() {
decoration: BoxDecoration( isCardClosed = true;
});
}
return Stack(
children: [
Container(
margin: EdgeInsets.only(top: 20),
child: Container(
decoration: BoxDecoration(
gradient: LinearGradient( gradient: LinearGradient(
begin: Alignment.centerLeft, begin: Alignment.centerLeft,
end: Alignment.centerRight, end: Alignment.centerRight,
@ -467,6 +478,21 @@ class _DesktopHomePageState extends State<DesktopHomePage>
)).marginOnly(top: 6)), )).marginOnly(top: 6)),
] ]
: <Widget>[]))), : <Widget>[]))),
),
if (closeButton != null && closeButton == true)
Positioned(
top: 18,
right: 0,
child: IconButton(
icon: Icon(
Icons.close,
color: Colors.white,
size: 20,
),
onPressed: closeCard,
),
),
],
); );
} }

View File

@ -329,6 +329,10 @@ class _GeneralState extends State<_General> {
message: translate('software_render_tip'), message: translate('software_render_tip'),
child: _OptionCheckBox(context, "Always use software rendering", child: _OptionCheckBox(context, "Always use software rendering",
'allow-always-software-render'), 'allow-always-software-render'),
));
children.add(
_OptionCheckBox(context, 'Check for software update on startup','enable-check-update',
isServer: false,
)); ));
if (bind.mainShowOption(key: 'allow-linux-headless')) { if (bind.mainShowOption(key: 'allow-linux-headless')) {
children.add(_OptionCheckBox( children.add(_OptionCheckBox(

View File

@ -1,3 +1,5 @@
use hbb_common::config::Config;
#[cfg(not(any(target_os = "android", target_os = "ios")))] #[cfg(not(any(target_os = "android", target_os = "ios")))]
use crate::common::get_default_sound_input; use crate::common::get_default_sound_input;
use crate::{ use crate::{
@ -1074,6 +1076,9 @@ pub fn main_get_last_remote_id() -> String {
} }
pub fn main_get_software_update_url() -> String { pub fn main_get_software_update_url() -> String {
if (get_local_option("enable-check-update".to_string()) != "N") {
crate::common::check_software_update();
}
crate::common::SOFTWARE_UPDATE_URL.lock().unwrap().clone() crate::common::SOFTWARE_UPDATE_URL.lock().unwrap().clone()
} }

View File

@ -554,5 +554,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Timeout in minutes", ""), ("Timeout in minutes", ""),
("auto_disconnect_option_tip", ""), ("auto_disconnect_option_tip", ""),
("Connection failed due to inactivity", ""), ("Connection failed due to inactivity", ""),
("Check for software update on startup", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -554,5 +554,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Timeout in minutes", ""), ("Timeout in minutes", ""),
("auto_disconnect_option_tip", ""), ("auto_disconnect_option_tip", ""),
("Connection failed due to inactivity", ""), ("Connection failed due to inactivity", ""),
("Check for software update on startup", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -554,5 +554,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Timeout in minutes", "超时(分钟)"), ("Timeout in minutes", "超时(分钟)"),
("auto_disconnect_option_tip", "自动关闭不活跃的会话"), ("auto_disconnect_option_tip", "自动关闭不活跃的会话"),
("Connection failed due to inactivity", "由于长时间无操作, 连接被自动断开"), ("Connection failed due to inactivity", "由于长时间无操作, 连接被自动断开"),
("Check for software update on startup", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -554,5 +554,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Timeout in minutes", ""), ("Timeout in minutes", ""),
("auto_disconnect_option_tip", ""), ("auto_disconnect_option_tip", ""),
("Connection failed due to inactivity", ""), ("Connection failed due to inactivity", ""),
("Check for software update on startup", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -554,5 +554,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Timeout in minutes", ""), ("Timeout in minutes", ""),
("auto_disconnect_option_tip", ""), ("auto_disconnect_option_tip", ""),
("Connection failed due to inactivity", ""), ("Connection failed due to inactivity", ""),
("Check for software update on startup", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -554,5 +554,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Timeout in minutes", "Zeitüberschreitung in Minuten"), ("Timeout in minutes", "Zeitüberschreitung in Minuten"),
("auto_disconnect_option_tip", "Automatisches Schließen eingehender Sitzungen bei Inaktivität des Benutzers"), ("auto_disconnect_option_tip", "Automatisches Schließen eingehender Sitzungen bei Inaktivität des Benutzers"),
("Connection failed due to inactivity", "Automatische Trennung der Verbindung aufgrund von Inaktivität"), ("Connection failed due to inactivity", "Automatische Trennung der Verbindung aufgrund von Inaktivität"),
("Check for software update on startup", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -554,5 +554,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Timeout in minutes", ""), ("Timeout in minutes", ""),
("auto_disconnect_option_tip", ""), ("auto_disconnect_option_tip", ""),
("Connection failed due to inactivity", ""), ("Connection failed due to inactivity", ""),
("Check for software update on startup", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -554,5 +554,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Timeout in minutes", ""), ("Timeout in minutes", ""),
("auto_disconnect_option_tip", ""), ("auto_disconnect_option_tip", ""),
("Connection failed due to inactivity", ""), ("Connection failed due to inactivity", ""),
("Check for software update on startup", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -554,5 +554,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Timeout in minutes", ""), ("Timeout in minutes", ""),
("auto_disconnect_option_tip", ""), ("auto_disconnect_option_tip", ""),
("Connection failed due to inactivity", ""), ("Connection failed due to inactivity", ""),
("Check for software update on startup", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -554,5 +554,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Timeout in minutes", ""), ("Timeout in minutes", ""),
("auto_disconnect_option_tip", ""), ("auto_disconnect_option_tip", ""),
("Connection failed due to inactivity", ""), ("Connection failed due to inactivity", ""),
("Check for software update on startup", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -554,5 +554,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Timeout in minutes", ""), ("Timeout in minutes", ""),
("auto_disconnect_option_tip", ""), ("auto_disconnect_option_tip", ""),
("Connection failed due to inactivity", ""), ("Connection failed due to inactivity", ""),
("Check for software update on startup", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -554,5 +554,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Timeout in minutes", ""), ("Timeout in minutes", ""),
("auto_disconnect_option_tip", ""), ("auto_disconnect_option_tip", ""),
("Connection failed due to inactivity", ""), ("Connection failed due to inactivity", ""),
("Check for software update on startup", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -554,5 +554,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Timeout in minutes", ""), ("Timeout in minutes", ""),
("auto_disconnect_option_tip", ""), ("auto_disconnect_option_tip", ""),
("Connection failed due to inactivity", ""), ("Connection failed due to inactivity", ""),
("Check for software update on startup", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -554,5 +554,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Timeout in minutes", "Timeout in minuti"), ("Timeout in minutes", "Timeout in minuti"),
("auto_disconnect_option_tip", ""), ("auto_disconnect_option_tip", ""),
("Connection failed due to inactivity", "Connessione non riuscita a causa di inattività"), ("Connection failed due to inactivity", "Connessione non riuscita a causa di inattività"),
("Check for software update on startup", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -554,5 +554,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Timeout in minutes", ""), ("Timeout in minutes", ""),
("auto_disconnect_option_tip", ""), ("auto_disconnect_option_tip", ""),
("Connection failed due to inactivity", ""), ("Connection failed due to inactivity", ""),
("Check for software update on startup", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -554,5 +554,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Timeout in minutes", ""), ("Timeout in minutes", ""),
("auto_disconnect_option_tip", ""), ("auto_disconnect_option_tip", ""),
("Connection failed due to inactivity", ""), ("Connection failed due to inactivity", ""),
("Check for software update on startup", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -554,5 +554,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Timeout in minutes", ""), ("Timeout in minutes", ""),
("auto_disconnect_option_tip", ""), ("auto_disconnect_option_tip", ""),
("Connection failed due to inactivity", ""), ("Connection failed due to inactivity", ""),
("Check for software update on startup", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -554,5 +554,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Timeout in minutes", ""), ("Timeout in minutes", ""),
("auto_disconnect_option_tip", ""), ("auto_disconnect_option_tip", ""),
("Connection failed due to inactivity", ""), ("Connection failed due to inactivity", ""),
("Check for software update on startup", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -554,5 +554,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Timeout in minutes", ""), ("Timeout in minutes", ""),
("auto_disconnect_option_tip", ""), ("auto_disconnect_option_tip", ""),
("Connection failed due to inactivity", ""), ("Connection failed due to inactivity", ""),
("Check for software update on startup", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -554,5 +554,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Timeout in minutes", "Czas bezczynności w minutach"), ("Timeout in minutes", "Czas bezczynności w minutach"),
("auto_disconnect_option_tip", "Automatycznie rozłącz sesje przychodzące przy braku aktywności użytkownika"), ("auto_disconnect_option_tip", "Automatycznie rozłącz sesje przychodzące przy braku aktywności użytkownika"),
("Connection failed due to inactivity", "Automatycznie rozłącz przy bezczynności"), ("Connection failed due to inactivity", "Automatycznie rozłącz przy bezczynności"),
("Check for software update on startup", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -554,5 +554,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Timeout in minutes", ""), ("Timeout in minutes", ""),
("auto_disconnect_option_tip", ""), ("auto_disconnect_option_tip", ""),
("Connection failed due to inactivity", ""), ("Connection failed due to inactivity", ""),
("Check for software update on startup", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -554,5 +554,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Timeout in minutes", ""), ("Timeout in minutes", ""),
("auto_disconnect_option_tip", ""), ("auto_disconnect_option_tip", ""),
("Connection failed due to inactivity", ""), ("Connection failed due to inactivity", ""),
("Check for software update on startup", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -554,5 +554,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Timeout in minutes", ""), ("Timeout in minutes", ""),
("auto_disconnect_option_tip", ""), ("auto_disconnect_option_tip", ""),
("Connection failed due to inactivity", ""), ("Connection failed due to inactivity", ""),
("Check for software update on startup", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -554,5 +554,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Timeout in minutes", ""), ("Timeout in minutes", ""),
("auto_disconnect_option_tip", ""), ("auto_disconnect_option_tip", ""),
("Connection failed due to inactivity", ""), ("Connection failed due to inactivity", ""),
("Check for software update on startup", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -554,5 +554,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Timeout in minutes", ""), ("Timeout in minutes", ""),
("auto_disconnect_option_tip", ""), ("auto_disconnect_option_tip", ""),
("Connection failed due to inactivity", ""), ("Connection failed due to inactivity", ""),
("Check for software update on startup", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -554,5 +554,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Timeout in minutes", ""), ("Timeout in minutes", ""),
("auto_disconnect_option_tip", ""), ("auto_disconnect_option_tip", ""),
("Connection failed due to inactivity", ""), ("Connection failed due to inactivity", ""),
("Check for software update on startup", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -554,5 +554,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Timeout in minutes", ""), ("Timeout in minutes", ""),
("auto_disconnect_option_tip", ""), ("auto_disconnect_option_tip", ""),
("Connection failed due to inactivity", ""), ("Connection failed due to inactivity", ""),
("Check for software update on startup", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -554,5 +554,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Timeout in minutes", ""), ("Timeout in minutes", ""),
("auto_disconnect_option_tip", ""), ("auto_disconnect_option_tip", ""),
("Connection failed due to inactivity", ""), ("Connection failed due to inactivity", ""),
("Check for software update on startup", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -554,5 +554,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Timeout in minutes", ""), ("Timeout in minutes", ""),
("auto_disconnect_option_tip", ""), ("auto_disconnect_option_tip", ""),
("Connection failed due to inactivity", ""), ("Connection failed due to inactivity", ""),
("Check for software update on startup", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -554,5 +554,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Timeout in minutes", ""), ("Timeout in minutes", ""),
("auto_disconnect_option_tip", ""), ("auto_disconnect_option_tip", ""),
("Connection failed due to inactivity", ""), ("Connection failed due to inactivity", ""),
("Check for software update on startup", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -554,5 +554,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Timeout in minutes", ""), ("Timeout in minutes", ""),
("auto_disconnect_option_tip", ""), ("auto_disconnect_option_tip", ""),
("Connection failed due to inactivity", ""), ("Connection failed due to inactivity", ""),
("Check for software update on startup", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -554,5 +554,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Timeout in minutes", ""), ("Timeout in minutes", ""),
("auto_disconnect_option_tip", ""), ("auto_disconnect_option_tip", ""),
("Connection failed due to inactivity", ""), ("Connection failed due to inactivity", ""),
("Check for software update on startup", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -554,5 +554,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Timeout in minutes", ""), ("Timeout in minutes", ""),
("auto_disconnect_option_tip", ""), ("auto_disconnect_option_tip", ""),
("Connection failed due to inactivity", ""), ("Connection failed due to inactivity", ""),
("Check for software update on startup", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -554,5 +554,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Timeout in minutes", ""), ("Timeout in minutes", ""),
("auto_disconnect_option_tip", ""), ("auto_disconnect_option_tip", ""),
("Connection failed due to inactivity", ""), ("Connection failed due to inactivity", ""),
("Check for software update on startup", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -554,5 +554,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Timeout in minutes", ""), ("Timeout in minutes", ""),
("auto_disconnect_option_tip", ""), ("auto_disconnect_option_tip", ""),
("Connection failed due to inactivity", ""), ("Connection failed due to inactivity", ""),
("Check for software update on startup", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }