diff --git a/CHANGELOG.md b/CHANGELOG.md index 0f075b2..c848247 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,18 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p - Refactor application. +## [0.6.0] - 2021-08-02 + +### Changed + +- Changed the activity property of some menu items according to the rule: + - if no object was copied, then the menu items "Paste link to here" an "Move it here and replace with a link" are not active; + - if at least one object was not copied, then the menu items "Paste link to here" an "Move it here and replace with a link" are inactive; + +### Added + +- Added cleaning clipboard after inserting links; + ## [0.5.0] - 2021-08-02 ### Added diff --git a/README.md b/README.md index 41f93e3..203c4f5 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ The Quick Symlink is a `Finder extension` which provides a `contextual menu item` for the symbolic links creation on macOS. -[![status](https://img.shields.io/badge/status-active-active?style=flat-square)](BADGES_GUIDE.md#status) [![version](https://img.shields.io/badge/version-0.5.0-informational?style=flat-square)](BADGES_GUIDE.md#version) [![oss lifecycle](https://img.shields.io/badge/oss_lifecycle-active-important?style=flat-square)](BADGES_GUIDE.md#oss-lifecycle) [![maintenance](https://img.shields.io/badge/maintenance-yes-informational?style=flat-square)](BADGES_GUIDE.md#maintenance) [![last release](https://img.shields.io/badge/last_release-August_02,_2021-informational?style=flat-square)](BADGES_GUIDE.md#release-date) [![last commit](https://img.shields.io/badge/last_commit-August_02,_2021-informational?style=flat-square)](BADGES_GUIDE.md#commit-date) +[![status](https://img.shields.io/badge/status-active-active?style=flat-square)](BADGES_GUIDE.md#status) [![version](https://img.shields.io/badge/version-0.6.0-informational?style=flat-square)](BADGES_GUIDE.md#version) [![oss lifecycle](https://img.shields.io/badge/oss_lifecycle-active-important?style=flat-square)](BADGES_GUIDE.md#oss-lifecycle) [![maintenance](https://img.shields.io/badge/maintenance-yes-informational?style=flat-square)](BADGES_GUIDE.md#maintenance) [![last release](https://img.shields.io/badge/last_release-August_07,_2021-informational?style=flat-square)](BADGES_GUIDE.md#release-date) [![last commit](https://img.shields.io/badge/last_commit-August_07,_2021-informational?style=flat-square)](BADGES_GUIDE.md#commit-date) [![license](https://img.shields.io/badge/license-MIT-informational?style=flat-square)](LICENSE) [![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-v2.0%20adopted-ff69b4.svg?style=flat-square)](CODE_OF_CONDUCT.md) @@ -140,33 +140,32 @@ https://github.com/ololx/quick-symlink.git ### Using This tool allows to: -* Create symlinks in the current directory -* Create symlinks in another directory -* Replace objects with symbolic links - -#### Creating symlinks in the current directory - -1. Select folders or files for which a symbolic link is needed. -2. Call the contextual menu by the right-clicking on selected. -3. Select menu item `Quick Symlink --> Create symlink for`. - -#### Creating symlinks in another directory - -1. Select folders or files for which a symbolic link is needed. -2. Call the contextual menu by the right-clicking on selected. -3. Select menu item `Quick Symlink --> Copy path from here`. -4. Go to a destination folder. -5. Call the contextual menu by right-clicking on the filder. -6. Select menu item `Quick Symlink --> Paste to here`. +
+ Create symlinks in the current directory +1. Select folders or files for which a symbolic link is needed.
+2. Call the contextual menu by the right-clicking on selected.
+3. Select menu item `Quick Symlink --> Create symlink for`.
+
-#### Replacing objects with symbolic links +
+ Create symlinks in another directory +1. Select folders or files for which a symbolic link is needed.
+2. Call the contextual menu by the right-clicking on selected.
+3. Select menu item `Quick Symlink --> Copy path from here`.
+4. Go to a destination folder.
+5. Call the contextual menu by right-clicking on the filder.
+6. Select menu item `Quick Symlink --> Paste to here`.
+
-1. Select folders or files for which a symbolic link is needed. -2. Call the contextual menu by the right-clicking on selected. -3. Select menu item `Quick Symlink --> Copy to clipboard`. -4. Go to a destination folder. -5. Call the contextual menu by right-clicking on the filder. -6. Select menu item `Quick Symlink --> Move it here and replace with a link`. +
+ Replace objects with symbolic links +1. Select folders or files for which a symbolic link is needed.
+2. Call the contextual menu by the right-clicking on selected.
+3. Select menu item `Quick Symlink --> Copy to clipboard`.
+4. Go to a destination folder.
+5. Call the contextual menu by right-clicking on the filder.
+6. Select menu item `Quick Symlink --> Move it here and replace with a link`.
+
## 🛠 Built With diff --git a/commons/CopyPathAction.swift b/commons/CopyPathAction.swift index 2c804e5..7cbcb0e 100644 --- a/commons/CopyPathAction.swift +++ b/commons/CopyPathAction.swift @@ -34,7 +34,7 @@ public class CopyPathAction: QuickSymlinkAction { paths.removeLast(); //Copy path list to clipboard - let pasteboard = NSPasteboard.general; + let pasteboard = NSPasteboard.init(name: NSPasteboard.Name.init(rawValue: "qs")); pasteboard.declareTypes([NSPasteboard.PasteboardType.string], owner: nil); pasteboard.setString(paths, forType: NSPasteboard.PasteboardType.string); } diff --git a/commons/PasteLinkAction.swift b/commons/PasteLinkAction.swift index 40104e3..b174aa1 100644 --- a/commons/PasteLinkAction.swift +++ b/commons/PasteLinkAction.swift @@ -25,10 +25,12 @@ public class PasteLinkAction: QuickSymlinkAction { return; } - let pathsFromClipboard = NSPasteboard.general.string(forType: NSPasteboard.PasteboardType.string) ?? ""; + let pasteboard = NSPasteboard.init(name: NSPasteboard.Name.init(rawValue: "qs")); + let pathsFromClipboard = pasteboard.string(forType: NSPasteboard.PasteboardType.string) ?? ""; if pathsFromClipboard.isEmpty { return; } + pasteboard.clearContents(); let paths = pathsFromClipboard.components(separatedBy: ";"); for path in paths { diff --git a/commons/ReplaceWithLinkAction.swift b/commons/ReplaceWithLinkAction.swift index 5098e96..07c988f 100644 --- a/commons/ReplaceWithLinkAction.swift +++ b/commons/ReplaceWithLinkAction.swift @@ -25,10 +25,12 @@ public class ReplaceWithLinkAction: QuickSymlinkAction { return; } - let pathsFromClipboard = NSPasteboard.general.string(forType: NSPasteboard.PasteboardType.string) ?? ""; + let pasteboard = NSPasteboard.init(name: NSPasteboard.Name.init(rawValue: "qs")); + let pathsFromClipboard = pasteboard.string(forType: NSPasteboard.PasteboardType.string) ?? ""; if pathsFromClipboard.isEmpty { return; } + pasteboard.clearContents(); let paths = pathsFromClipboard.components(separatedBy: ";"); for path in paths { diff --git a/quick-symlink-extension/FinderSync.swift b/quick-symlink-extension/FinderSync.swift index 33780b9..5b6626d 100644 --- a/quick-symlink-extension/FinderSync.swift +++ b/quick-symlink-extension/FinderSync.swift @@ -40,8 +40,6 @@ class FinderSync: FIFinderSync { finderSync.directoryURLs.insert(volumeURL); } } - - //FIFinderSyncController.default().directoryURLs = [self.myFolderURL]; } // MARK: - Primary Finder Sync protocol methods @@ -80,21 +78,31 @@ class FinderSync: FIFinderSync { action: #selector(createSymlink(_:)), keyEquivalent: "" ); + quickSymlinkMenu.addItem( withTitle: NSLocalizedString("COPY_PATH_ACTION_NAME", comment: ""), action: #selector(copyPathToClipboard(_:)), keyEquivalent: "" ); - quickSymlinkMenu.addItem( - withTitle: NSLocalizedString("PASTE_LINK_ACTION_NAME", comment: ""), + + let pastleSymlinkFromClipboardMenuItem = NSMenuItem.init( + title: NSLocalizedString("PASTE_LINK_ACTION_NAME", comment: ""), action: #selector(pastleSymlinkFromClipboard(_:)), keyEquivalent: "" ); - quickSymlinkMenu.addItem( - withTitle: NSLocalizedString("REPLACE_WITH_LINK_ACTION_NAME", comment: ""), + quickSymlinkMenu.addItem(pastleSymlinkFromClipboardMenuItem); + + let replaceFileWithSymlinkFromClipboardMenuItem = NSMenuItem.init( + title: NSLocalizedString("REPLACE_WITH_LINK_ACTION_NAME", comment: ""), action: #selector(replaceFileWithSymlinkFromClipboard(_:)), keyEquivalent: "" ); + quickSymlinkMenu.addItem(replaceFileWithSymlinkFromClipboardMenuItem); + + if (NSPasteboard.init(name: NSPasteboard.Name.init(rawValue: "qs")).string(forType: NSPasteboard.PasteboardType.string) ?? "").isEmpty { + pastleSymlinkFromClipboardMenuItem.isEnabled = false; + replaceFileWithSymlinkFromClipboardMenuItem.isEnabled = false; + } if menuKind.rawValue == 3 { return quickSymlinkMenu;