Merge ca64652e5f into 74949e0861
This commit is contained in:
commit
26a3957f05
|
|
@ -20,7 +20,6 @@ Future<List<OperatingSystem>> loadOperatingSystems(bool showUbuntus) async {
|
||||||
var process = await Process.run('quickget', ['--list-csv']);
|
var process = await Process.run('quickget', ['--list-csv']);
|
||||||
var stdout = process.stdout as String;
|
var stdout = process.stdout as String;
|
||||||
var output = <OperatingSystem>[];
|
var output = <OperatingSystem>[];
|
||||||
|
|
||||||
OperatingSystem? currentOperatingSystem;
|
OperatingSystem? currentOperatingSystem;
|
||||||
Version? currentVersion;
|
Version? currentVersion;
|
||||||
|
|
||||||
|
|
@ -32,8 +31,7 @@ Future<List<OperatingSystem>> loadOperatingSystems(bool showUbuntus) async {
|
||||||
.forEach((element) {
|
.forEach((element) {
|
||||||
var chunks = element.split(",");
|
var chunks = element.split(",");
|
||||||
Tuple5 supportedVersion;
|
Tuple5 supportedVersion;
|
||||||
if (chunks.length == 4) // Legacy version of quickget
|
if (chunks.length == 4) {
|
||||||
{
|
|
||||||
supportedVersion = Tuple5.fromList([...chunks, "curl"]);
|
supportedVersion = Tuple5.fromList([...chunks, "curl"]);
|
||||||
} else {
|
} else {
|
||||||
var t5 = [chunks[0], chunks[1], chunks[2], chunks[3], chunks[4]].toList();
|
var t5 = [chunks[0], chunks[1], chunks[2], chunks[3], chunks[4]].toList();
|
||||||
|
|
@ -46,10 +44,12 @@ Future<List<OperatingSystem>> loadOperatingSystems(bool showUbuntus) async {
|
||||||
output.add(currentOperatingSystem!);
|
output.add(currentOperatingSystem!);
|
||||||
currentVersion = null;
|
currentVersion = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentVersion?.version != supportedVersion.item3) {
|
if (currentVersion?.version != supportedVersion.item3) {
|
||||||
currentVersion = Version(supportedVersion.item3);
|
currentVersion = Version(supportedVersion.item3);
|
||||||
currentOperatingSystem!.versions.add(currentVersion!);
|
currentOperatingSystem!.versions.add(currentVersion!);
|
||||||
}
|
}
|
||||||
|
|
||||||
currentVersion!.options
|
currentVersion!.options
|
||||||
.add(Option(supportedVersion.item4, supportedVersion.item5));
|
.add(Option(supportedVersion.item4, supportedVersion.item5));
|
||||||
});
|
});
|
||||||
|
|
@ -58,22 +58,30 @@ Future<List<OperatingSystem>> loadOperatingSystems(bool showUbuntus) async {
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> getIcons() async {
|
Future<void> getIcons() async {
|
||||||
final manifestContent = await rootBundle.loadString('AssetManifest.json');
|
try {
|
||||||
final Map<String, dynamic> manifestMap = json.decode(manifestContent);
|
final manifestContent = await rootBundle.loadString('AssetManifest.json');
|
||||||
final imagePaths = manifestMap.keys
|
final Map<String, dynamic> manifestMap = json.decode(manifestContent);
|
||||||
.where((String key) => key.contains('quickemu-icons/'))
|
final imagePaths = manifestMap.keys
|
||||||
.where((String key) => key.contains('.svg'))
|
.where((String key) => key.contains('quickemu-icons/'))
|
||||||
.toList();
|
.where((String key) => key.contains('.svg'))
|
||||||
for (final imagePath in imagePaths) {
|
.toList();
|
||||||
String filename = imagePath.split('/').last;
|
|
||||||
String id = filename.substring(0, filename.lastIndexOf('.'));
|
for (final imagePath in imagePaths) {
|
||||||
osIcons[id] = imagePath;
|
String filename = imagePath.split('/').last;
|
||||||
|
String id = filename.substring(0, filename.lastIndexOf('.'));
|
||||||
|
osIcons[id] = imagePath;
|
||||||
|
}
|
||||||
|
} on FlutterError catch (e) {
|
||||||
|
debugPrint('Warning: Could not load AssetManifest.json: $e');
|
||||||
|
// Icons will use fallback/default when not found
|
||||||
|
} catch (e) {
|
||||||
|
debugPrint('Warning: Failed to load icons: $e');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void main() async {
|
void main() async {
|
||||||
WidgetsFlutterBinding.ensureInitialized();
|
WidgetsFlutterBinding.ensureInitialized();
|
||||||
// Don't forget to also change the size in linux/my_application.cc:50
|
|
||||||
if (Platform.isMacOS) {
|
if (Platform.isMacOS) {
|
||||||
setWindowMinSize(const Size(692 + 2, 580 + 30));
|
setWindowMinSize(const Size(692 + 2, 580 + 30));
|
||||||
setWindowMaxSize(const Size(692 + 2, 580 + 30));
|
setWindowMaxSize(const Size(692 + 2, 580 + 30));
|
||||||
|
|
@ -81,12 +89,18 @@ void main() async {
|
||||||
setWindowMinSize(const Size(692, 580));
|
setWindowMinSize(const Size(692, 580));
|
||||||
setWindowMaxSize(const Size(800, 720));
|
setWindowMaxSize(const Size(800, 720));
|
||||||
}
|
}
|
||||||
|
|
||||||
final foundQuickGet = await Process.run('which', ['quickget']);
|
final foundQuickGet = await Process.run('which', ['quickget']);
|
||||||
if (foundQuickGet.exitCode == 0) {
|
if (foundQuickGet.exitCode == 0) {
|
||||||
gOperatingSystems = loadOperatingSystems(false);
|
gOperatingSystems = loadOperatingSystems(false);
|
||||||
getIcons();
|
await getIcons(); // Added await for proper error handling
|
||||||
AppVersion.packageInfo = await PackageInfo.fromPlatform();
|
try {
|
||||||
|
AppVersion.packageInfo = await PackageInfo.fromPlatform();
|
||||||
|
} catch (e) {
|
||||||
|
debugPrint('Warning: Could not get package info: $e');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
runApp(
|
runApp(
|
||||||
MultiProvider(
|
MultiProvider(
|
||||||
providers: [
|
providers: [
|
||||||
|
|
|
||||||
|
|
@ -16,13 +16,18 @@ class DownloaderMenu extends StatefulWidget {
|
||||||
}
|
}
|
||||||
|
|
||||||
class _DownloaderMenuState extends State<DownloaderMenu> with PreferencesMixin {
|
class _DownloaderMenuState extends State<DownloaderMenu> with PreferencesMixin {
|
||||||
|
String _currentPath = Directory.current.path;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
getPreference<String>(prefWorkingDirectory).then((pref) {
|
getPreference<String>(prefWorkingDirectory).then((pref) {
|
||||||
setState(() {
|
if (pref != null && pref.isNotEmpty && Directory(pref).existsSync()) {
|
||||||
Directory.current = pref;
|
setState(() {
|
||||||
});
|
Directory.current = pref;
|
||||||
|
_currentPath = pref;
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -44,9 +49,7 @@ class _DownloaderMenuState extends State<DownloaderMenu> with PreferencesMixin {
|
||||||
color: Theme.of(context).colorScheme.onPrimaryContainer,
|
color: Theme.of(context).colorScheme.onPrimaryContainer,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(
|
const SizedBox(width: 8),
|
||||||
width: 8,
|
|
||||||
),
|
|
||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
style: ElevatedButton.styleFrom(
|
style: ElevatedButton.styleFrom(
|
||||||
foregroundColor: Theme.of(context).colorScheme.onSurface,
|
foregroundColor: Theme.of(context).colorScheme.onSurface,
|
||||||
|
|
@ -55,22 +58,20 @@ class _DownloaderMenuState extends State<DownloaderMenu> with PreferencesMixin {
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
var folder = await FilePicker.platform
|
var folder = await FilePicker.platform
|
||||||
.getDirectoryPath(dialogTitle: "Pick a folder");
|
.getDirectoryPath(dialogTitle: "Pick a folder");
|
||||||
if (folder != null) {
|
if (folder != null && folder.isNotEmpty) {
|
||||||
setState(() {
|
setState(() {
|
||||||
Directory.current = folder;
|
Directory.current = folder;
|
||||||
|
_currentPath = folder;
|
||||||
});
|
});
|
||||||
savePreference(
|
savePreference(prefWorkingDirectory, folder);
|
||||||
prefWorkingDirectory, Directory.current.path);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
child: Text(Directory.current.path),
|
child: Text(_currentPath),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const Divider(
|
const Divider(thickness: 2),
|
||||||
thickness: 2,
|
|
||||||
),
|
|
||||||
const Row(
|
const Row(
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
Expanded(
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue