Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion ishare/Capture/ImageCapture.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,11 @@ func captureScreen(type: CaptureType, display: Int = 1) async {
if copyToClipboard {
let pasteboard = NSPasteboard.general
pasteboard.clearContents()
pasteboard.setString(fileURL.absoluteString, forType: .fileURL)
if Defaults[.copyImageToClipboard], let image = NSImage(contentsOf: fileURL) {
pasteboard.writeObjects([image])
} else {
pasteboard.setString(fileURL.absoluteString, forType: .fileURL)
}
}

if openInFinder {
Expand Down
8 changes: 5 additions & 3 deletions ishare/Http/Custom.swift
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,11 @@ private func handleResponse(
let historyItem = HistoryItem(fileUrl: fileUrl.absoluteString, deletionUrl: deletionUrl)
addToUploadHistory(historyItem)

let pasteboard = NSPasteboard.general
pasteboard.clearContents()
pasteboard.setString(fileUrl.absoluteString, forType: .string)
if !Defaults[.copyImageToClipboard] {
let pasteboard = NSPasteboard.general
pasteboard.clearContents()
pasteboard.setString(fileUrl.absoluteString, forType: .string)
}
callback?(nil, fileUrl)
} else {
callback?(CustomUploadError.responseParsing, nil)
Expand Down
8 changes: 5 additions & 3 deletions ishare/Http/Imgur.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,11 @@ import SwiftyJSON
if let link = json["data"]["link"].string {
print("Image uploaded successfully. Link: \(link)")

let pasteboard = NSPasteboard.general
pasteboard.clearContents()
pasteboard.setString(link, forType: .string)
if !Defaults[.copyImageToClipboard] {
let pasteboard = NSPasteboard.general
pasteboard.clearContents()
pasteboard.setString(link, forType: .string)
}

let historyItem = HistoryItem(fileUrl: link)
addToUploadHistory(historyItem)
Expand Down
1 change: 1 addition & 0 deletions ishare/Util/Constants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ extension KeyboardShortcuts.Name {
extension Defaults.Keys {
static let showMainMenu = Key<Bool>("showMainMenu", default: false, iCloud: true)
static let copyToClipboard = Key<Bool>("copyToClipboard", default: true, iCloud: true)
static let copyImageToClipboard = Key<Bool>("copyImageToClipboard", default: false, iCloud: true)
static let openInFinder = Key<Bool>("openInFinder", default: false, iCloud: true)
static let saveToDisk = Key<Bool>("saveToDisk", default: true, iCloud: true)
static let uploadMedia = Key<Bool>("uploadMedia", default: false, iCloud: true)
Expand Down
2 changes: 2 additions & 0 deletions ishare/Views/SettingsMenuView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ struct GeneralSettingsView: View {
@Default(.toastTimeout) var toastTimeout
@Default(.aussieMode) var aussieMode
@Default(.uploadHistory) var uploadHistory
@Default(.copyImageToClipboard) var copyImageToClipboard

let appImage = NSImage(named: "AppIcon") ?? AppIcon

Expand Down Expand Up @@ -145,6 +146,7 @@ struct GeneralSettingsView: View {
Text("Launch at login".localized())
}
Toggle("Land down under".localized(), isOn: $aussieMode)
Toggle("Copy image to clipboard instead of URL".localized(), isOn: $copyImageToClipboard)
}

VStack(alignment: .leading) {
Expand Down