diff --git a/lib/src/pages/downloader.dart b/lib/src/pages/downloader.dart index ac0d381..a723588 100644 --- a/lib/src/pages/downloader.dart +++ b/lib/src/pages/downloader.dart @@ -77,7 +77,9 @@ class _DownloaderState extends State { } else if (widget.option!.downloader == 'zsync') { controller.add(-1); } else if (widget.option!.downloader == 'macrecovery') { - process.stdout.transform(utf8.decoder).forEach(parseMacRecoveryProgress); + process.stdout + .transform(utf8.decoder) + .forEach(parseMacRecoveryProgress); } process.exitCode.then((value) { @@ -86,7 +88,9 @@ class _DownloaderState extends State { setState(() { _downloadFinished = true; notificationsClient.notify( - _cancelled ? context.t('Download cancelled') : context.t('Download complete'), + _cancelled + ? context.t('Download cancelled') + : context.t('Download complete'), body: _cancelled ? context.t( 'Download of {0} has completed.', @@ -111,8 +115,12 @@ class _DownloaderState extends State { return Scaffold( appBar: AppBar( title: Text( - context.t('Downloading {0}', - args: ['${widget.operatingSystem.name} ${widget.version.version}' + (widget.option!.option.isNotEmpty ? ' (${widget.option!.option})' : '')]), + context.t('Downloading {0}', args: [ + '${widget.operatingSystem.name} ${widget.version.version}' + + (widget.option!.option.isNotEmpty + ? ' (${widget.option!.option})' + : '') + ]), ), automaticallyImplyLeading: false, ), @@ -122,7 +130,10 @@ class _DownloaderState extends State { child: StreamBuilder( stream: _progressStream, builder: (context, AsyncSnapshot snapshot) { - var data = !snapshot.hasData || widget.option!.downloader != 'wget' ? null : snapshot.data; + var data = + !snapshot.hasData || widget.option!.downloader != 'wget' + ? null + : snapshot.data; return Column( mainAxisAlignment: MainAxisAlignment.center, children: [ @@ -137,7 +148,8 @@ class _DownloaderState extends State { ), Padding( padding: const EdgeInsets.only(top: 32), - child: Text(context.t('Target folder : {0}', args: [Directory.current.path])), + child: Text(context.t('Target folder : {0}', + args: [Directory.current.path])), ), ], ); diff --git a/lib/src/pages/main_page.dart b/lib/src/pages/main_page.dart index 61c66ed..ca0c469 100644 --- a/lib/src/pages/main_page.dart +++ b/lib/src/pages/main_page.dart @@ -17,7 +17,8 @@ class _MainPageState extends State { @override void didChangeDependencies() { super.didChangeDependencies(); - setWindowTitle(context.t('Quickgui : a Flutter frontend for Quickget and Quickemu')); + setWindowTitle( + context.t('Quickgui : a Flutter frontend for Quickget and Quickemu')); } @override diff --git a/lib/src/pages/manager.dart b/lib/src/pages/manager.dart index 082702e..897b2fc 100644 --- a/lib/src/pages/manager.dart +++ b/lib/src/pages/manager.dart @@ -61,7 +61,8 @@ class _ManagerState extends State with PreferencesMixin { } Directory.current = pref; }); - Future.delayed(Duration.zero, () => _getVms(context)); // Reload VM list when we enter the page. + Future.delayed(Duration.zero, + () => _getVms(context)); // Reload VM list when we enter the page. }); refreshTimer = Timer.periodic(const Duration(seconds: 5), (Timer t) { _getVms(context); @@ -78,7 +79,8 @@ class _ManagerState extends State with PreferencesMixin { // Find out which terminal emulator we have set as the default. ProcessResult result = await Process.run('which', ['x-terminal-emulator']); if (result.exitCode == 0) { - String terminalEmulator = await File(result.stdout.toString().trim()).resolveSymbolicLinks(); + String terminalEmulator = + await File(result.stdout.toString().trim()).resolveSymbolicLinks(); terminalEmulator = path.basenameWithoutExtension(terminalEmulator); if (_supportedTerminalEmulators.contains(terminalEmulator)) { setState(() { @@ -130,7 +132,8 @@ class _ManagerState extends State with PreferencesMixin { List currentVms = []; Map activeVms = {}; - await for (var entity in Directory.current.list(recursive: false, followLinks: true)) { + await for (var entity + in Directory.current.list(recursive: false, followLinks: true)) { if ((entity.path.endsWith('.conf')) && (_isValidConf(entity.path))) { String name = path.basenameWithoutExtension(entity.path); currentVms.add(name); @@ -169,7 +172,9 @@ class _ManagerState extends State with PreferencesMixin { Widget _buildVmList() { List _widgetList = []; - final Color buttonColor = Theme.of(context).brightness == Brightness.dark ? Colors.white70 : Theme.of(context).colorScheme.primary; + final Color buttonColor = Theme.of(context).brightness == Brightness.dark + ? Colors.white70 + : Theme.of(context).colorScheme.primary; _widgetList.add( Row( mainAxisAlignment: MainAxisAlignment.center, @@ -181,7 +186,8 @@ class _ManagerState extends State with PreferencesMixin { width: 8, ), ElevatedButton( - style: ElevatedButton.styleFrom(primary: Theme.of(context).canvasColor, onPrimary: buttonColor), + style: ElevatedButton.styleFrom( + primary: Theme.of(context).canvasColor, onPrimary: buttonColor), onPressed: () async { String? result = await FilePicker.platform.getDirectoryPath(); if (result != null) { @@ -276,7 +282,9 @@ class _ManagerState extends State with PreferencesMixin { context: context, builder: (BuildContext context) => AlertDialog( title: Text(context.t('Stop The Virtual Machine?')), - content: Text(context.t('You are about to terminate the virtual machine', args: [currentVm])), + content: Text(context.t( + 'You are about to terminate the virtual machine', + args: [currentVm])), actions: [ TextButton( onPressed: () => Navigator.pop(context, false), @@ -300,44 +308,49 @@ class _ManagerState extends State with PreferencesMixin { }, ), IconButton( - icon: Icon( - Icons.delete, - color: active ? null : buttonColor, - semanticLabel: 'Delete' - ), - onPressed: active ? null : () { - showDialog( - context: context, - builder: (BuildContext context) => AlertDialog( - title: Text('Delete ' + currentVm), - content: Text( - 'You are about to delete ' + currentVm + '. This cannot be undone. ' + - 'Would you like to delete the disk image but keep the ' + - 'configuration, or delete the whole VM?' - ), - actions: [ - TextButton( - child: Text('Cancel'), - onPressed: () => Navigator.pop(context, 'cancel'), - ), - TextButton( - child: Text('Delete disk image'), - onPressed: () => Navigator.pop(context, 'disk'), - ), - TextButton( - child: Text('Delete whole VM'), - onPressed: () => Navigator.pop(context, 'vm'), - ) // set up the AlertDialog - ], - ), - ).then((result) async { - result = result ?? 'cancel'; - if (result != 'cancel') { - List args = ['--vm', currentVm + '.conf', '--delete-' + result]; - await Process.start('quickemu', args); - } - }); - }, + icon: Icon(Icons.delete, + color: active ? null : buttonColor, + semanticLabel: 'Delete'), + onPressed: active + ? null + : () { + showDialog( + context: context, + builder: (BuildContext context) => AlertDialog( + title: Text('Delete ' + currentVm), + content: Text('You are about to delete ' + + currentVm + + '. This cannot be undone. ' + + 'Would you like to delete the disk image but keep the ' + + 'configuration, or delete the whole VM?'), + actions: [ + TextButton( + child: Text('Cancel'), + onPressed: () => + Navigator.pop(context, 'cancel'), + ), + TextButton( + child: Text('Delete disk image'), + onPressed: () => Navigator.pop(context, 'disk'), + ), + TextButton( + child: Text('Delete whole VM'), + onPressed: () => Navigator.pop(context, 'vm'), + ) // set up the AlertDialog + ], + ), + ).then((result) async { + result = result ?? 'cancel'; + if (result != 'cancel') { + List args = [ + '--vm', + currentVm + '.conf', + '--delete-' + result + ]; + await Process.start('quickemu', args); + } + }); + }, ), ], )), @@ -351,7 +364,9 @@ class _ManagerState extends State with PreferencesMixin { color: _spicy ? buttonColor : null, semanticLabel: 'Connect display with SPICE', ), - tooltip: _spicy ? 'Connect display with SPICE' : 'SPICE client not found', + tooltip: _spicy + ? 'Connect display with SPICE' + : 'SPICE client not found', onPressed: !_spicy ? null : () { @@ -359,19 +374,25 @@ class _ManagerState extends State with PreferencesMixin { }, ), IconButton( - icon: SvgPicture.asset('assets/images/console.svg', semanticsLabel: 'Connect with SSH', color: sshy ? buttonColor : Colors.grey), - tooltip: sshy ? 'Connect with SSH' : 'SSH server not detected on guest', + icon: SvgPicture.asset('assets/images/console.svg', + semanticsLabel: 'Connect with SSH', + color: sshy ? buttonColor : Colors.grey), + tooltip: sshy + ? 'Connect with SSH' + : 'SSH server not detected on guest', onPressed: !sshy ? null : () { - TextEditingController _usernameController = TextEditingController(); + TextEditingController _usernameController = + TextEditingController(); showDialog( context: context, builder: (BuildContext context) => AlertDialog( title: Text('Launch SSH connection to $currentVm'), content: TextField( controller: _usernameController, - decoration: const InputDecoration(hintText: "SSH username"), + decoration: const InputDecoration( + hintText: "SSH username"), ), actions: [ TextButton( @@ -387,10 +408,16 @@ class _ManagerState extends State with PreferencesMixin { ).then((result) { result = result ?? false; if (result) { - List sshArgs = ['ssh', '-p', vmInfo.sshPort!, _usernameController.text + '@localhost']; + List sshArgs = [ + 'ssh', + '-p', + vmInfo.sshPort!, + _usernameController.text + '@localhost' + ]; // Set the arguments to execute the ssh command in the default terminal. // Strip the extension as x-terminal-emulator may point to a .wrapper - switch (path.basenameWithoutExtension(_terminalEmulator!)) { + switch (path + .basenameWithoutExtension(_terminalEmulator!)) { case 'gnome-terminal': case 'mate-terminal': sshArgs.insert(0, '--'); diff --git a/lib/src/pages/operating_system_selection.dart b/lib/src/pages/operating_system_selection.dart index 4506604..d395ce9 100644 --- a/lib/src/pages/operating_system_selection.dart +++ b/lib/src/pages/operating_system_selection.dart @@ -10,7 +10,8 @@ class OperatingSystemSelection extends StatefulWidget { const OperatingSystemSelection({Key? key}) : super(key: key); @override - State createState() => _OperatingSystemSelectionState(); + State createState() => + _OperatingSystemSelectionState(); } class _OperatingSystemSelectionState extends State { @@ -25,7 +26,9 @@ class _OperatingSystemSelectionState extends State { @override Widget build(BuildContext context) { - var list = gOperatingSystems.where((os) => os.name.toLowerCase().contains(term.toLowerCase())).toList(); + var list = gOperatingSystems + .where((os) => os.name.toLowerCase().contains(term.toLowerCase())) + .toList(); return Scaffold( appBar: AppBar( title: Text(context.t('Select operating system')), @@ -47,7 +50,8 @@ class _OperatingSystemSelectionState extends State { Expanded( child: TextField( focusNode: focusNode, - decoration: InputDecoration.collapsed(hintText: context.t('Search operating system')), + decoration: InputDecoration.collapsed( + hintText: context.t('Search operating system')), onChanged: (value) { setState(() { term = value; diff --git a/lib/src/pages/option_selection.dart b/lib/src/pages/option_selection.dart index 6431650..67128d2 100644 --- a/lib/src/pages/option_selection.dart +++ b/lib/src/pages/option_selection.dart @@ -24,7 +24,9 @@ class _OptionSelectionState extends State { @override Widget build(BuildContext context) { - var list = widget.version.options.where((e) => e.option.toLowerCase().contains(term.toLowerCase())).toList(); + var list = widget.version.options + .where((e) => e.option.toLowerCase().contains(term.toLowerCase())) + .toList(); return Scaffold( appBar: AppBar( @@ -49,7 +51,8 @@ class _OptionSelectionState extends State { Expanded( child: TextField( focusNode: focusNode, - decoration: InputDecoration.collapsed(hintText: context.t('Search option')), + decoration: InputDecoration.collapsed( + hintText: context.t('Search option')), onChanged: (value) { setState(() { term = value; diff --git a/lib/src/pages/version_selection.dart b/lib/src/pages/version_selection.dart index 51aa03d..cba1b8b 100644 --- a/lib/src/pages/version_selection.dart +++ b/lib/src/pages/version_selection.dart @@ -8,7 +8,8 @@ import '../model/version.dart'; import 'option_selection.dart'; class VersionSelection extends StatefulWidget { - const VersionSelection({Key? key, required this.operatingSystem}) : super(key: key); + const VersionSelection({Key? key, required this.operatingSystem}) + : super(key: key); final OperatingSystem operatingSystem; @@ -21,7 +22,8 @@ class _VersionSelectionState extends State { Widget build(BuildContext context) { return Scaffold( appBar: AppBar( - title: Text(context.t('Select version for {0}', args: [widget.operatingSystem.name])), + title: Text(context + .t('Select version for {0}', args: [widget.operatingSystem.name])), ), body: SingleChildScrollView( child: Column( @@ -36,17 +38,23 @@ class _VersionSelectionState extends State { child: ListTile( title: Text(item.version), onTap: () { - if (widget.operatingSystem.versions[index].options.length > 1) { + if (widget + .operatingSystem.versions[index].options.length > + 1) { Navigator.of(context) - .push