diff --git a/assets/i18n/en.po b/assets/i18n/en.po index e9f9793..be8159b 100644 --- a/assets/i18n/en.po +++ b/assets/i18n/en.po @@ -190,3 +190,9 @@ msgstr "Loading available downloads" msgid "Powered by" msgstr "Powered by" + +msgid "Error" +msgstr "Error" + +msgid "Could not write to the working directory. Please check the permissions." +msgstr "Could not write to the working directory. Please check the permissions." diff --git a/assets/i18n/fr.po b/assets/i18n/fr.po index a82e371..4906540 100644 --- a/assets/i18n/fr.po +++ b/assets/i18n/fr.po @@ -185,6 +185,12 @@ msgstr "Nom d'utilisateur SSH" msgid "Connect" msgstr "Connecter" +msgid "Error" +msgstr "Erreur" + +msgid "Could not write to the working directory. Please check the permissions." +msgstr "Impossible d'écrire dans le répertoire de travail. Veuillez vérifier les permissions." + msgid "Loading available downloads" msgstr "Chargement des téléchargements disponibles" diff --git a/assets/i18n/quickgui.pot b/assets/i18n/quickgui.pot index 44342c9..d9a8a3d 100644 --- a/assets/i18n/quickgui.pot +++ b/assets/i18n/quickgui.pot @@ -187,6 +187,12 @@ msgstr "" msgid "Connect" msgstr "" +msgid "Error" +msgstr "" + +msgid "Could not write to the working directory. Please check the permissions." +msgstr "" + msgid "Loading available downloads" msgstr "" diff --git a/lib/src/widgets/home_page/home_page_button_group.dart b/lib/src/widgets/home_page/home_page_button_group.dart index b86acca..c8fea0f 100644 --- a/lib/src/widgets/home_page/home_page_button_group.dart +++ b/lib/src/widgets/home_page/home_page_button_group.dart @@ -2,6 +2,8 @@ import 'dart:io'; import 'package:flutter/material.dart'; import 'package:gettext_i18n/gettext_i18n.dart'; +import 'package:quickgui/src/globals.dart'; +import 'package:quickgui/src/mixins/preferences_mixin.dart'; import 'package:tuple/tuple.dart'; import '../../model/operating_system.dart'; @@ -19,7 +21,8 @@ class HomePageButtonGroup extends StatefulWidget { State createState() => _HomePageButtonGroupState(); } -class _HomePageButtonGroupState extends State { +class _HomePageButtonGroupState extends State + with PreferencesMixin { OperatingSystem? _selectedOperatingSystem; Version? _selectedVersion; Option? _selectedOption; @@ -85,16 +88,50 @@ class _HomePageButtonGroupState extends State { text: context.t('Download'), onPressed: (_selectedVersion == null) ? null - : () { - Navigator.of(context).push( - MaterialPageRoute( - builder: (context) => Downloader( - operatingSystem: _selectedOperatingSystem!, - version: _selectedVersion!, - option: _selectedOption, + : () async { + final workingDirectory = + await getPreference(prefWorkingDirectory); + final tmpFile = File("$workingDirectory/modecheck.tmp"); + if (tmpFile.existsSync()) { + tmpFile.deleteSync(); + } + try { + tmpFile.createSync(); + } catch (e) { + // Do nothing + } + if (tmpFile.existsSync()) { + tmpFile.deleteSync(); + + Navigator.of(context).push( + MaterialPageRoute( + builder: (context) => Downloader( + operatingSystem: _selectedOperatingSystem!, + version: _selectedVersion!, + option: _selectedOption, + ), ), - ), - ); + ); + } else { + showDialog( + context: context, + builder: (context) => AlertDialog( + title: Text(context.t('Error')), + content: Text( + context.t( + 'Could not write to the working directory. Please check the permissions.'), + ), + actions: [ + TextButton( + onPressed: () { + Navigator.of(context).pop(); + }, + child: Text(context.t('OK')), + ), + ], + ), + ); + } }, ), ],