Add MPV logs export

This commit is contained in:
Arkadiusz Fal
2022-07-07 00:08:38 +02:00
parent e0a862fb36
commit 36363628d4
5 changed files with 61 additions and 5 deletions

View File

@@ -6,6 +6,12 @@ struct AdvancedSettings: View {
@Default(.showMPVPlaybackStats) private var showMPVPlaybackStats
@Default(.mpvCacheSecs) private var mpvCacheSecs
@Default(.mpvCachePauseWait) private var mpvCachePauseWait
@Default(.mpvEnableLogging) private var mpvEnableLogging
@EnvironmentObject<PlayerModel> private var player
@State private var presentingShareSheet = false
@State private var filesToShare = [MPVClient.logFile]
var body: some View {
VStack(alignment: .leading) {
@@ -17,6 +23,10 @@ struct AdvancedSettings: View {
advancedSettings
}
#if os(iOS)
.sheet(isPresented: $presentingShareSheet) {
ShareSheet(activityItems: filesToShare)
.id("logs-\(filesToShare.count)")
}
.listStyle(.insetGrouped)
#endif
#endif
@@ -27,9 +37,29 @@ struct AdvancedSettings: View {
.navigationTitle("Advanced")
}
var logButton: some View {
Button {
#if os(macOS)
NSWorkspace.shared.selectFile(MPVClient.logFile.path, inFileViewerRootedAtPath: YatteeApp.logsDirectory.path)
#else
presentingShareSheet = true
#endif
} label: {
#if os(macOS)
let labelText = "Open logs in Finder"
#else
let labelText = "Share Logs..."
#endif
Text(labelText)
}
}
@ViewBuilder var advancedSettings: some View {
Section(header: SettingsHeader(text: "MPV"), footer: mpvFooter) {
showMPVPlaybackStatsToggle
#if !os(tvOS)
mpvEnableLoggingToggle
#endif
HStack {
Text("cache-secs")
@@ -44,6 +74,10 @@ struct AdvancedSettings: View {
TextField("cache-pause-wait", text: $mpvCachePauseWait)
}
.multilineTextAlignment(.trailing)
if mpvEnableLogging {
logButton
}
}
Section(header: manifestHeader) {
@@ -85,6 +119,10 @@ struct AdvancedSettings: View {
Toggle("Show playback statistics", isOn: $showMPVPlaybackStats)
}
var mpvEnableLoggingToggle: some View {
Toggle("Enable logging", isOn: $mpvEnableLogging)
}
#if os(macOS)
private func onHover(_ inside: Bool) {
if inside {

View File

@@ -226,7 +226,7 @@ struct SettingsView: View {
case .locations:
return 480
case .advanced:
return 300
return 320
case .help:
return 600
}