Skip to content

Commit

Permalink
feat: add fetchQuickemuVersion() and display version in the menu
Browse files Browse the repository at this point in the history
  • Loading branch information
flexiondotorg committed Jul 1, 2024
1 parent 6f30c78 commit dcadfb6
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 3 deletions.
12 changes: 12 additions & 0 deletions lib/src/globals.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,15 @@ var gIsSnap = Platform.environment['SNAP']?.isNotEmpty ?? false;
const String prefWorkingDirectory = 'workingDirectory';
const String prefThemeMode = 'themeMode';
const String prefCurrentLocale = 'currentLocale';

Future<String> fetchQuickemuVersion() async {
// Get the version of quickemu
var result = await Process.run('quickemu', ['--version']);

// If successful return the trimmed version
if (result.exitCode == 0) {
return result.stdout.trim();
} else {
return '';
}
}
33 changes: 30 additions & 3 deletions lib/src/widgets/left_menu.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class _LeftMenuState extends State<LeftMenu> with PreferencesMixin {
@override
void initState() {
super.initState();
fetchQuickemuVersion();
_dropdownMenuItems = supportedLocales
.map((e) => DropdownMenuItem(child: Text(e), value: e))
.toList();
Expand All @@ -48,9 +49,35 @@ class _LeftMenuState extends State<LeftMenu> with PreferencesMixin {
return Drawer(
child: ListView(
children: [
ListTile(
title: Text("Quickgui $_version",
style: const TextStyle(fontSize: 24.0, fontWeight: FontWeight.bold)),
Padding(
// Minimal bottom padding
padding: EdgeInsets.only(bottom: 0).add(EdgeInsets.symmetric(horizontal: 16)),
child: Container(
padding: EdgeInsets.symmetric(vertical: 4.0),
child: Text("Quickgui $_version",
style: const TextStyle(fontSize: 24.0, fontWeight: FontWeight.bold)),
),
),
FutureBuilder<String>(
future: fetchQuickemuVersion(),
builder: (BuildContext context, AsyncSnapshot<String> snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
return CircularProgressIndicator(); // or some other widget while waiting
} else {
String poweredByText = context.t('Powered by') + " Quickemu";
if (snapshot.hasData) {
poweredByText += " ${snapshot.data}";
}
return Padding(
// Minimal top padding
padding: EdgeInsets.only(top: 0).add(EdgeInsets.symmetric(horizontal: 16)),
child: Container(
child: Text(poweredByText,
style: const TextStyle(fontSize: 12.0, fontWeight: FontWeight.bold)),
),
);
}
},
),
Container(
height: 4.0,
Expand Down

0 comments on commit dcadfb6

Please sign in to comment.