global desktop mode feature

This commit is contained in:
Fabian Freund
2026-06-06 13:02:23 +02:00
parent ae7c9feb08
commit 4a12acab99
14 changed files with 229 additions and 4 deletions
@@ -154,6 +154,11 @@ class GeneralSettings with FastEquatable {
/// Only takes effect when the effective brightness is dark. Defaults to false.
final bool pureBlack;
/// Browser-wide default desktop mode. When true, newly opened tabs request
/// the desktop version of sites by default. The per-tab desktop-mode toggle
/// still overrides this for an individual tab. Defaults to false.
final bool globalDesktopMode;
GeneralSettings({
required this.themeMode,
required this.uiScaleFactor,
@@ -214,6 +219,7 @@ class GeneralSettings with FastEquatable {
required this.indexPrivateTabs,
required this.acceptSuggestionOnSubmit,
required this.pureBlack,
required this.globalDesktopMode,
});
GeneralSettings.withDefaults({
@@ -276,6 +282,7 @@ class GeneralSettings with FastEquatable {
bool? indexPrivateTabs,
bool? acceptSuggestionOnSubmit,
bool? pureBlack,
bool? globalDesktopMode,
}) : themeMode = themeMode ?? ThemeMode.dark,
uiScaleFactor = uiScaleFactor ?? defaultUiScaleFactor,
disableAnimations = disableAnimations ?? false,
@@ -346,7 +353,8 @@ class GeneralSettings with FastEquatable {
enableLocalSearchIndex = enableLocalSearchIndex ?? true,
indexPrivateTabs = indexPrivateTabs ?? false,
acceptSuggestionOnSubmit = acceptSuggestionOnSubmit ?? false,
pureBlack = pureBlack ?? false;
pureBlack = pureBlack ?? false,
globalDesktopMode = globalDesktopMode ?? false;
factory GeneralSettings.fromJson(Map<String, dynamic> json) {
// Migrate legacy `newTabPosition` setting to direction settings.
@@ -459,5 +467,6 @@ class GeneralSettings with FastEquatable {
indexPrivateTabs,
acceptSuggestionOnSubmit,
pureBlack,
globalDesktopMode,
];
}
@@ -147,6 +147,8 @@ abstract class _$GeneralSettingsCWProxy {
GeneralSettings pureBlack(bool pureBlack);
GeneralSettings globalDesktopMode(bool globalDesktopMode);
/// Creates a new instance with the provided field values.
/// Passing `null` to a nullable field nullifies it, while `null` for a non-nullable field is ignored. To update a single field use `GeneralSettings(...).copyWith.fieldName(value)`.
///
@@ -214,6 +216,7 @@ abstract class _$GeneralSettingsCWProxy {
bool indexPrivateTabs,
bool acceptSuggestionOnSubmit,
bool pureBlack,
bool globalDesktopMode,
});
}
@@ -474,6 +477,10 @@ class _$GeneralSettingsCWProxyImpl implements _$GeneralSettingsCWProxy {
@override
GeneralSettings pureBlack(bool pureBlack) => call(pureBlack: pureBlack);
@override
GeneralSettings globalDesktopMode(bool globalDesktopMode) =>
call(globalDesktopMode: globalDesktopMode);
@override
/// Creates a new instance with the provided field values.
/// Passing `null` to a nullable field nullifies it, while `null` for a non-nullable field is ignored. To update a single field use `GeneralSettings(...).copyWith.fieldName(value)`.
@@ -543,6 +550,7 @@ class _$GeneralSettingsCWProxyImpl implements _$GeneralSettingsCWProxy {
Object? indexPrivateTabs = const $CopyWithPlaceholder(),
Object? acceptSuggestionOnSubmit = const $CopyWithPlaceholder(),
Object? pureBlack = const $CopyWithPlaceholder(),
Object? globalDesktopMode = const $CopyWithPlaceholder(),
}) {
return GeneralSettings(
themeMode: themeMode == const $CopyWithPlaceholder() || themeMode == null
@@ -891,6 +899,12 @@ class _$GeneralSettingsCWProxyImpl implements _$GeneralSettingsCWProxy {
? _value.pureBlack
// ignore: cast_nullable_to_non_nullable
: pureBlack as bool,
globalDesktopMode:
globalDesktopMode == const $CopyWithPlaceholder() ||
globalDesktopMode == null
? _value.globalDesktopMode
// ignore: cast_nullable_to_non_nullable
: globalDesktopMode as bool,
);
}
}
@@ -1019,6 +1033,7 @@ GeneralSettings _$GeneralSettingsFromJson(
indexPrivateTabs: json['indexPrivateTabs'] as bool?,
acceptSuggestionOnSubmit: json['acceptSuggestionOnSubmit'] as bool?,
pureBlack: json['pureBlack'] as bool?,
globalDesktopMode: json['globalDesktopMode'] as bool?,
);
Map<String, dynamic> _$GeneralSettingsToJson(
@@ -1096,6 +1111,7 @@ Map<String, dynamic> _$GeneralSettingsToJson(
'indexPrivateTabs': instance.indexPrivateTabs,
'acceptSuggestionOnSubmit': instance.acceptSuggestionOnSubmit,
'pureBlack': instance.pureBlack,
'globalDesktopMode': instance.globalDesktopMode,
};
const _$ThemeModeEnumMap = {
@@ -273,6 +273,10 @@ class GeneralSettingsRepository extends _$GeneralSettingsRepository {
DriftSqlType.bool,
db.typeMapping,
),
'globalDesktopMode': settings['globalDesktopMode']?.readAs(
DriftSqlType.bool,
db.typeMapping,
),
});
}