diff --git a/lib/main.dart b/lib/main.dart index 8c5e0f4..73d9857 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -58,8 +58,11 @@ void main() async { // Don't forget to also change the size in linux/my_application.cc:50 setWindowMinSize(const Size(692, 580)); setWindowMaxSize(const Size(692, 580)); - gOperatingSystems = await loadOperatingSystems(false); - AppVersion.packageInfo = await PackageInfo.fromPlatform(); + final foundQuickGet = await Process.run('which', ['quickget']); + if (foundQuickGet.exitCode == 0) { + gOperatingSystems = await loadOperatingSystems(false); + AppVersion.packageInfo = await PackageInfo.fromPlatform(); + } runApp( MultiProvider( providers: [ diff --git a/lib/src/app.dart b/lib/src/app.dart index 0b284c0..d1043ac 100644 --- a/lib/src/app.dart +++ b/lib/src/app.dart @@ -2,8 +2,10 @@ import 'dart:io'; import 'package:flutter/material.dart'; import 'package:flutter_localizations/flutter_localizations.dart'; -import 'package:provider/provider.dart'; import 'package:gettext_i18n/gettext_i18n.dart'; +import 'package:provider/provider.dart'; +import 'package:quickgui/src/mixins/app_version.dart'; +import 'package:quickgui/src/pages/deget_not_found_page.dart'; import 'package:quickgui/src/supported_locales.dart'; import 'package:shared_preferences/shared_preferences.dart'; @@ -40,13 +42,15 @@ class _AppState extends State with PreferencesMixin { theme: ThemeData(primarySwatch: Colors.pink), darkTheme: ThemeData.dark(), themeMode: appSettings.themeMode, - home: const MainPage(), + home: AppVersion.packageInfo == null + ? const DebgetNotFoundPage() + : const MainPage(), supportedLocales: supportedLocales.map((s) => s.contains("_") ? Locale(s.split("_")[0], s.split("_")[1]) : Locale(s)), localizationsDelegates: [ GettextLocalizationsDelegate(), - GlobalMaterialLocalizations.delegate, + ...GlobalMaterialLocalizations.delegates, GlobalWidgetsLocalizations.delegate, ], locale: diff --git a/lib/src/pages/deget_not_found_page.dart b/lib/src/pages/deget_not_found_page.dart new file mode 100644 index 0000000..896fe3d --- /dev/null +++ b/lib/src/pages/deget_not_found_page.dart @@ -0,0 +1,60 @@ +import 'package:flutter/gestures.dart'; +import 'package:flutter/material.dart'; +import 'package:url_launcher/url_launcher.dart'; + +class DebgetNotFoundPage extends StatelessWidget { + const DebgetNotFoundPage({Key? key}) : super(key: key); + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + const Text( + 'quickemu was not found in your PATH', + style: TextStyle( + fontSize: 24, + ), + ), + const SizedBox( + height: 16, + ), + const Text( + 'Please install it and try again.', + style: TextStyle( + fontSize: 24, + ), + ), + const SizedBox( + height: 16, + ), + Text.rich( + TextSpan( + style: const TextStyle( + fontSize: 16, + ), + text: 'See ', + children: [ + TextSpan( + recognizer: TapGestureRecognizer() + ..onTap = () { + launchUrl( + Uri.parse( + 'https://github.com/quickemu-project/quickemu'), + ); + }, + text: 'github.com/quickemu-project/quickemu', + style: const TextStyle(color: Colors.blue), + ), + const TextSpan(text: ' for more information'), + ], + ), + ), + ], + ), + ), + ); + } +} diff --git a/pubspec.yaml b/pubspec.yaml index 733e918..8fad93a 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -53,6 +53,7 @@ dependencies: desktop_notifications: ^0.6.1 flutter_svg: ^0.23.0 gettext_i18n: ^1.0.2 + url_launcher: ^6.1.6 dev_dependencies: flutter_test: