Always launch VMs with --display spice, if the spicy client is available.
This commit is contained in:
parent
fcf1ab92f0
commit
e078126b22
|
|
@ -24,7 +24,7 @@ class Manager extends StatefulWidget {
|
||||||
class _ManagerState extends State<Manager> with PreferencesMixin {
|
class _ManagerState extends State<Manager> with PreferencesMixin {
|
||||||
List<String> _currentVms = [];
|
List<String> _currentVms = [];
|
||||||
Map<String, VmInfo> _activeVms = {};
|
Map<String, VmInfo> _activeVms = {};
|
||||||
final List<String> _spicyVms = [];
|
bool _spicy = false;
|
||||||
final List<String> _sshVms = [];
|
final List<String> _sshVms = [];
|
||||||
String? _terminalEmulator;
|
String? _terminalEmulator;
|
||||||
Timer? refreshTimer;
|
Timer? refreshTimer;
|
||||||
|
|
@ -33,6 +33,7 @@ class _ManagerState extends State<Manager> with PreferencesMixin {
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
_getTerminalEmulator();
|
_getTerminalEmulator();
|
||||||
|
_detectSpice();
|
||||||
getPreference<String>(prefWorkingDirectory).then((pref) {
|
getPreference<String>(prefWorkingDirectory).then((pref) {
|
||||||
setState(() {
|
setState(() {
|
||||||
if (pref == null) {
|
if (pref == null) {
|
||||||
|
|
@ -53,7 +54,6 @@ class _ManagerState extends State<Manager> with PreferencesMixin {
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void _getTerminalEmulator() async {
|
void _getTerminalEmulator() async {
|
||||||
ProcessResult result = Process.runSync('x-terminal-emulator', ['-h']);
|
ProcessResult result = Process.runSync('x-terminal-emulator', ['-h']);
|
||||||
RegExp pattern = RegExp(r"usage:\s+([^\s]+)", multiLine: true, caseSensitive: false);
|
RegExp pattern = RegExp(r"usage:\s+([^\s]+)", multiLine: true, caseSensitive: false);
|
||||||
|
|
@ -65,6 +65,13 @@ class _ManagerState extends State<Manager> with PreferencesMixin {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _detectSpice() async {
|
||||||
|
ProcessResult result = await Process.run('which', ['spicy']);
|
||||||
|
setState(() {
|
||||||
|
_spicy = result.exitCode == 0;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
VmInfo _parseVmInfo(name) {
|
VmInfo _parseVmInfo(name) {
|
||||||
VmInfo info = VmInfo();
|
VmInfo info = VmInfo();
|
||||||
List<String> lines = File(name + '/' + name + '.ports').readAsLinesSync();
|
List<String> lines = File(name + '/' + name + '.ports').readAsLinesSync();
|
||||||
|
|
@ -212,41 +219,24 @@ class _ManagerState extends State<Manager> with PreferencesMixin {
|
||||||
trailing: Row(
|
trailing: Row(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
IconButton(
|
|
||||||
icon: Icon(Icons.monitor,
|
|
||||||
color: spicy ? Colors.red : null, semanticLabel: spicy ? context.t('Using SPICE display') : context.t('Click to use SPICE display')),
|
|
||||||
tooltip: spicy ? context.t('Using SPICE display') : context.t('Use SPICE display'),
|
|
||||||
onPressed: () {
|
|
||||||
if (spicy) {
|
|
||||||
setState(() {
|
|
||||||
_spicyVms.remove(currentVm);
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
setState(() {
|
|
||||||
_spicyVms.add(currentVm);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
IconButton(
|
IconButton(
|
||||||
icon: Icon(
|
icon: Icon(
|
||||||
active ? Icons.play_arrow : Icons.play_arrow_outlined,
|
active ? Icons.play_arrow : Icons.play_arrow_outlined,
|
||||||
color: active ? Colors.green : null,
|
color: active ? Colors.green : null,
|
||||||
semanticLabel: active ? 'Running' : 'Run',
|
semanticLabel: active ? 'Running' : 'Run',
|
||||||
),
|
),
|
||||||
onPressed: () async {
|
onPressed: active ? null : () async {
|
||||||
if (!active) {
|
Map<String, VmInfo> activeVms = _activeVms;
|
||||||
Map<String, VmInfo> activeVms = _activeVms;
|
List<String> args = ['--vm', currentVm + '.conf'];
|
||||||
List<String> args = ['--vm', currentVm + '.conf'];
|
if (_spicy) {
|
||||||
if (spicy) {
|
args.addAll(['--display', 'spice']);
|
||||||
args.addAll(['--display', 'spice']);
|
|
||||||
}
|
|
||||||
await Process.start('quickemu', args);
|
|
||||||
VmInfo info = _parseVmInfo(currentVm);
|
|
||||||
activeVms[currentVm] = info;
|
|
||||||
setState(() {
|
|
||||||
_activeVms = activeVms;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
await Process.start('quickemu', args);
|
||||||
|
VmInfo info = _parseVmInfo(currentVm);
|
||||||
|
activeVms[currentVm] = info;
|
||||||
|
setState(() {
|
||||||
|
_activeVms = activeVms;
|
||||||
|
});
|
||||||
}),
|
}),
|
||||||
IconButton(
|
IconButton(
|
||||||
icon: Icon(
|
icon: Icon(
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue