diff --git a/.DS_Store b/.DS_Store index 460f90099a3061137ffce657c135e70ea814b905..03e5283108dec403316b84b08663f92109f4ac7a 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/Screenshottr/AppDelegate.swift b/Screenshottr/AppDelegate.swift index 487abe911bc33a108fab393c315c95b263997d15..81c1d3f746aaa9a04f67a6696c7aebc6a6eba73b 100644 --- a/Screenshottr/AppDelegate.swift +++ b/Screenshottr/AppDelegate.swift @@ -13,8 +13,7 @@ import SKQueue class AppDelegate: NSObject, NSApplicationDelegate { let statusItem = NSStatusBar.system.statusItem(withLength: NSStatusItem.variableLength) let popover = NSPopover() - let viewController = PopoverMenu(nibName: "PopoverMenu", - bundle: Bundle.main) + let viewController = PopoverMenu(nibName: "PopoverMenu", bundle: Bundle.main) let statusIcon = NSImage(named: "status_icon") var spinnerView = NSView() let spinner = NSProgressIndicator() diff --git a/Screenshottr/DropView.swift b/Screenshottr/DropView.swift index f764af1ff49dc267d6701add670512d52f6eef46..cdeb0f16c6276cd7606641192cc441146e335d6d 100644 --- a/Screenshottr/DropView.swift +++ b/Screenshottr/DropView.swift @@ -8,38 +8,28 @@ import Cocoa -class DropView: NSImageView { - @IBOutlet var uploadImage: DropView! - @IBOutlet var textLabel: NSTextField! - - var filePath: String? +class DropView: NSView { + @IBOutlet weak var textLabel: NSTextField! //FIXME: Value is Nil despite outlet existing. https://stackoverflow.com/questions/58314461/outlet-definition-is-nil-despite-outlet-existing + var filePath: String? required init?(coder: NSCoder) { super.init(coder: coder) - isEditable = false + //isEditable = false wantsLayer = true registerForDraggedTypes([NSPasteboard.PasteboardType.URL, NSPasteboard.PasteboardType.fileURL]) } override func draggingEntered(_: NSDraggingInfo) -> NSDragOperation { - textLabel.stringValue = "*notices your file* owo what's this?" + //textLabel.stringValue = "*notices your file* owo what's this?" return .copy } override func draggingEnded(_: NSDraggingInfo) { - textLabel.stringValue = "Drag and Drop to Upload" - image = NSImage(named: "upload") - /* - * For anybody in the future: The reason we change the image is because, for some reason, the - * image view in PopoverMenu will not connect to the outlet, meaning I cannot mark it as un-editable. - * No matter how hard I try it is an editable image view. - * If you, future person, find a solution, please email me. My email will be on https://github.com/broman - * But I am currently reachable at ryan@broman.dev - */ + //textLabel.stringValue = "Drag and Drop to Upload" } override func draggingExited(_: NSDraggingInfo?) { - textLabel.stringValue = "Drag and Drop to Upload" + //textLabel.stringValue = "Drag and Drop to Upload" } override func performDragOperation(_ sender: NSDraggingInfo) -> Bool { diff --git a/Screenshottr/DropViewController.swift b/Screenshottr/DropViewController.swift new file mode 100644 index 0000000000000000000000000000000000000000..af7000730d5a190ff79e2f2b9e75eb2f654b3d10 --- /dev/null +++ b/Screenshottr/DropViewController.swift @@ -0,0 +1,13 @@ +// +// DropViewController.swift +// Screenshottr +// +// Created by Ryan Broman on 26/09/19. +// Copyright © 2019 JOS Computing. All rights reserved. +// + +import Cocoa + +class DropViewController { + @IBOutlet weak var uploaderImage: DropView! +} diff --git a/Screenshottr/PopoverMenu.swift b/Screenshottr/PopoverMenu.swift index 8e230d1d667271b06cf0fec8706043720ad7abaa..4533ba77c87d76b72a010206823a0afde6da7399 100644 --- a/Screenshottr/PopoverMenu.swift +++ b/Screenshottr/PopoverMenu.swift @@ -9,11 +9,14 @@ import Cocoa class PopoverMenu: NSViewController { - let settingsMenu = NSMenu() + @IBOutlet weak var uploadButton: NSButton! + + let settingsMenu = NSMenu() override func viewDidLoad() { super.viewDidLoad() // Do view setup here. + uploadButton.isHighlighted = false let settingsItem = NSMenuItem() settingsItem.action = #selector(presentSettingsDialog) settingsItem.title = "Settings" diff --git a/Screenshottr/PopoverMenu.xib b/Screenshottr/PopoverMenu.xib index 1ca9b7a9e4f32c5258a84e0d679d27675d0c18fb..0eb81179bb11f845e941ed8dfbdbfef5c77e0e9f 100644 --- a/Screenshottr/PopoverMenu.xib +++ b/Screenshottr/PopoverMenu.xib @@ -7,13 +7,14 @@ <objects> <customObject id="-2" userLabel="File's Owner" customClass="PopoverMenu" customModule="Screenshottr" customModuleProvider="target"> <connections> + <outlet property="uploadButton" destination="jrN-oy-XGI" id="wjX-1I-3Py"/> <outlet property="view" destination="Hz6-mo-xeY" id="0bl-1N-x8E"/> </connections> </customObject> <customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/> <customObject id="-3" userLabel="Application" customClass="DropView"> <connections> - <outlet property="uploadImage" destination="687-0U-0uf" id="lti-id-9I9"/> + <outlet property="textLabel" destination="fj4-kJ-fXa" id="Fz7-VA-xTL"/> </connections> </customObject> <customView id="Hz6-mo-xeY"> @@ -21,7 +22,7 @@ <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/> <subviews> <button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="jrN-oy-XGI"> - <rect key="frame" x="78" y="13" width="108" height="32"/> + <rect key="frame" x="72" y="6" width="120" height="43"/> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/> <buttonCell key="cell" type="push" title="Upload File" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="7jj-A4-JC3"> <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/> @@ -31,8 +32,28 @@ <action selector="uploadFileClicked:" target="-2" id="jft-g4-t1c"/> </connections> </button> + <imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="2jg-Ct-0t0"> + <rect key="frame" x="20" y="49" width="225" height="215"/> + <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/> + <imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyDown" image="upload" id="SQf-YI-nXZ"/> + </imageView> + <customView fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="MI0-Tw-K0l" customClass="DropView" customModule="Screenshottr" customModuleProvider="target"> + <rect key="frame" x="20" y="49" width="225" height="215"/> + <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/> + <subviews> + <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="fj4-kJ-fXa"> + <rect key="frame" x="-2" y="20" width="229" height="17"/> + <autoresizingMask key="autoresizingMask"/> + <textFieldCell key="cell" lineBreakMode="clipping" alignment="center" title="Drag and Drop to Upload" id="dcJ-qF-u2q"> + <font key="font" metaFont="system"/> + <color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/> + <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/> + </textFieldCell> + </textField> + </subviews> + </customView> <button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="ZlR-St-Ru0"> - <rect key="frame" x="237" y="20" width="21" height="21"/> + <rect key="frame" x="224" y="20" width="21" height="21"/> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/> <buttonCell key="cell" type="square" bezelStyle="shadowlessSquare" image="NSActionTemplate" imagePosition="only" alignment="center" refusesFirstResponder="YES" imageScaling="proportionallyDown" inset="2" id="uPe-bE-h5R"> <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/> @@ -42,23 +63,6 @@ <action selector="toggleGearMenu:" target="-2" id="FKD-T9-7Xw"/> </connections> </button> - <imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="687-0U-0uf" customClass="DropView" customModule="Screenshottr" customModuleProvider="target"> - <rect key="frame" x="20" y="49" width="225" height="215"/> - <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/> - <imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyDown" image="upload" id="DPA-2I-1fC"/> - <connections> - <outlet property="textLabel" destination="r6E-aY-KOH" id="nQx-7n-fKo"/> - </connections> - </imageView> - <textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="r6E-aY-KOH"> - <rect key="frame" x="5" y="95" width="254" height="23"/> - <autoresizingMask key="autoresizingMask"/> - <textFieldCell key="cell" lineBreakMode="truncatingTail" selectable="YES" alignment="center" title="Drag and Drop to Upload" usesSingleLineMode="YES" id="IqH-JI-SBr"> - <font key="font" metaFont="system"/> - <color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/> - <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/> - </textFieldCell> - </textField> </subviews> <point key="canvasLocation" x="-17.5" y="62"/> </customView> diff --git a/Screenshottr/UploadManager.swift b/Screenshottr/UploadManager.swift index 6a663215c5ba03093bfb38d97e3b530247c6357c..a9bad596ec7efe75ae0fd99971212b85e2f97c29 100644 --- a/Screenshottr/UploadManager.swift +++ b/Screenshottr/UploadManager.swift @@ -24,7 +24,7 @@ class UploadManager: NSObject { defaults.set(true, forKey: uploadingKey) // This could probably be done better // oh well lol - // sleep(2) + sleep(2) //prevents race condiiton on legacy Mac OS let fileManager = FileManager.default do { // Grab contents by predicate, convert to array, loop through array with paths