From: Claudio Cambra Date: Mon, 4 Mar 2024 12:42:52 +0000 (+0800) Subject: Use ShareController in ShareOptionsView X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~12^2~7^2~46^2~89 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=fea4e8855e72847e8ced644215014783273edbad;p=nextcloud-desktop.git Use ShareController in ShareOptionsView Signed-off-by: Claudio Cambra --- diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.swift index ca197bb30..d0f75a13c 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.swift @@ -21,19 +21,42 @@ class ShareOptionsView: NSView { @IBOutlet private weak var saveButton: NSButton! @IBOutlet private weak var deleteButton: NSButton! - var share: NKShare? { + var controller: ShareController? { didSet { - guard let share = share else { return } - labelTextField.stringValue = share.label - uploadEditPermissionCheckbox.state = share.canEdit ? .on : .off - hideDownloadCheckbox.state = share.hideDownload ? .on : .off - passwordProtectCheckbox.state = share.password.isEmpty ? .off : .on - passwordSecureField.isHidden = passwordProtectCheckbox.state == .off - expirationDateCheckbox.state = share.expirationDate == nil ? .off : .on - expirationDatePicker.isHidden = expirationDateCheckbox.state == .off - noteForRecipientCheckbox.state = share.note.isEmpty ? .off : .on - noteTextField.isHidden = noteForRecipientCheckbox.state == .off - deleteButton.isEnabled = share.canDelete + update() + + } + } + + private func update() { + guard let share = controller?.share else { + reset() + saveButton.isEnabled = false + deleteButton.isEnabled = false + return } + labelTextField.stringValue = share.label + uploadEditPermissionCheckbox.state = share.canEdit ? .on : .off + hideDownloadCheckbox.state = share.hideDownload ? .on : .off + passwordProtectCheckbox.state = share.password.isEmpty ? .off : .on + passwordSecureField.isHidden = passwordProtectCheckbox.state == .off + expirationDateCheckbox.state = share.expirationDate == nil ? .off : .on + expirationDatePicker.isHidden = expirationDateCheckbox.state == .off + noteForRecipientCheckbox.state = share.note.isEmpty ? .off : .on + noteTextField.isHidden = noteForRecipientCheckbox.state == .off + deleteButton.isEnabled = share.canDelete + saveButton.isEnabled = true + } + + func reset() { + labelTextField.stringValue = "" + uploadEditPermissionCheckbox.state = .off + hideDownloadCheckbox.state = .off + passwordProtectCheckbox.state = .off + passwordSecureField.isHidden = true + expirationDateCheckbox.state = .off + expirationDatePicker.isHidden = true + noteForRecipientCheckbox.state = .off + noteTextField.isHidden = true } }