feat: add active color to settings provider.
This commit is contained in:
@@ -96,7 +96,16 @@ class H {
|
||||
'shortcut': GestureType.shortcut,
|
||||
'commandline': GestureType.commandline,
|
||||
}[typeName] ??
|
||||
GestureType.built_in;
|
||||
GestureType.built_in;
|
||||
|
||||
static Color? parseQtActiveColor(String? inp) {
|
||||
if (inp == null) return null;
|
||||
var list = inp.split(',');
|
||||
if (list.length != 4) return null;
|
||||
var rgba = list.map<int>((e) => int.parse(e) ~/ 257).toList();
|
||||
rgba.sout();
|
||||
return Color.fromARGB(rgba[3], rgba[0], rgba[1], rgba[2]);
|
||||
}
|
||||
}
|
||||
|
||||
class PreferredPanelsStatus {
|
||||
|
||||
@@ -18,8 +18,11 @@ Future<void> initEvents(BuildContext context) async {
|
||||
} else {
|
||||
var xsettings = GSettings('com.deepin.xsettings');
|
||||
String? themeName;
|
||||
Color? activeColor;
|
||||
try {
|
||||
themeName = (await xsettings.get('theme-name')).toString();
|
||||
var _activeColor = (await xsettings.get('qt-active-color'));
|
||||
activeColor = H.parseQtActiveColor(_activeColor.toNative());
|
||||
} catch (e) {
|
||||
print(e);
|
||||
context.read<SettingsProvider>().setProps(isDarkMode: false);
|
||||
@@ -27,10 +30,14 @@ Future<void> initEvents(BuildContext context) async {
|
||||
|
||||
if (themeName != null) {
|
||||
context.read<SettingsProvider>().setProps(isDarkMode: themeName.contains('dark'));
|
||||
context.read<SettingsProvider>().setProps(activeColor: activeColor);
|
||||
xsettings.keysChanged.listen((event) {
|
||||
xsettings.get('theme-name').then((value) {
|
||||
context.read<SettingsProvider>().setProps(isDarkMode: value.toString().contains('dark'));
|
||||
});
|
||||
xsettings.get('qt-active-color').then((value) {
|
||||
context.read<SettingsProvider>().setProps(activeColor: H.parseQtActiveColor(value.toNative()));
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user