mirror of
https://github.com/yattee/yattee.git
synced 2025-08-09 20:24:06 +00:00
Add default profiles and option to reset to defaults
This commit is contained in:
@@ -68,6 +68,7 @@ struct LocationsSettings: View {
|
||||
Section(header: SettingsHeader(text: "Custom Locations")) {
|
||||
#if os(macOS)
|
||||
InstancesSettings()
|
||||
.environmentObject(model)
|
||||
#else
|
||||
ForEach(instances) { instance in
|
||||
AccountsNavigationLink(instance: instance)
|
||||
|
@@ -1,3 +1,4 @@
|
||||
import Defaults
|
||||
import SwiftUI
|
||||
|
||||
struct QualityProfileForm: View {
|
||||
@@ -14,6 +15,8 @@ struct QualityProfileForm: View {
|
||||
@State private var resolution = ResolutionSetting.hd1080p60
|
||||
@State private var formats = [QualityProfile.Format]()
|
||||
|
||||
@Default(.qualityProfiles) private var qualityProfiles
|
||||
|
||||
var qualityProfile: QualityProfile! {
|
||||
if let id = qualityProfileID {
|
||||
return QualityProfilesModel.shared.find(id)
|
||||
@@ -131,7 +134,7 @@ struct QualityProfileForm: View {
|
||||
.modifier(SettingsPickerModifier())
|
||||
|
||||
#if os(iOS)
|
||||
return HStack {
|
||||
HStack {
|
||||
Text("Resolution")
|
||||
Spacer()
|
||||
Menu {
|
||||
@@ -175,7 +178,7 @@ struct QualityProfileForm: View {
|
||||
}
|
||||
.modifier(SettingsPickerModifier())
|
||||
#if os(iOS)
|
||||
return HStack {
|
||||
HStack {
|
||||
Text("Backend")
|
||||
Spacer()
|
||||
Menu {
|
||||
@@ -321,7 +324,12 @@ struct QualityProfileForm: View {
|
||||
if editing {
|
||||
QualityProfilesModel.shared.update(qualityProfile, formProfile)
|
||||
} else {
|
||||
let wasEmpty = qualityProfiles.isEmpty
|
||||
QualityProfilesModel.shared.add(formProfile)
|
||||
|
||||
if wasEmpty {
|
||||
QualityProfilesModel.shared.applyToAll(formProfile)
|
||||
}
|
||||
}
|
||||
|
||||
presentationMode.wrappedValue.dismiss()
|
||||
|
@@ -5,8 +5,9 @@ struct QualitySettings: View {
|
||||
@State private var presentingProfileForm = false
|
||||
@State private var editedProfileID: QualityProfile.ID?
|
||||
|
||||
@Default(.qualityProfiles) private var qualityProfiles
|
||||
@EnvironmentObject<SettingsModel> private var settings
|
||||
|
||||
@Default(.qualityProfiles) private var qualityProfiles
|
||||
@Default(.batteryCellularProfile) private var batteryCellularProfile
|
||||
@Default(.batteryNonCellularProfile) private var batteryNonCellularProfile
|
||||
@Default(.chargingCellularProfile) private var chargingCellularProfile
|
||||
@@ -75,6 +76,25 @@ struct QualitySettings: View {
|
||||
}
|
||||
}
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
|
||||
HStack {
|
||||
Button {
|
||||
settings.presentAlert(
|
||||
Alert(
|
||||
title: Text("Are you sure you want to restore default quality profiles?"),
|
||||
message: Text("This will remove all your custom profiles and return their default values. This cannot be reverted."),
|
||||
primaryButton: .destructive(Text("Reset")) {
|
||||
QualityProfilesModel.shared.reset()
|
||||
},
|
||||
secondaryButton: .cancel()
|
||||
)
|
||||
)
|
||||
} label: {
|
||||
Text("Restore default profiles...")
|
||||
.foregroundColor(.red)
|
||||
}
|
||||
Spacer()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user