Skip to content
Snippets Groups Projects
Commit d95d1c1c authored by broman's avatar broman :speech_balloon:
Browse files

Merge branch 'test-settings-view' into 'master'

Test settings view

See merge request !2
parents f4e7f9b4 95ef2d5c
No related branches found
No related tags found
1 merge request!2Test settings view
No preview for this file type
...@@ -13,8 +13,7 @@ import SKQueue ...@@ -13,8 +13,7 @@ import SKQueue
class AppDelegate: NSObject, NSApplicationDelegate { class AppDelegate: NSObject, NSApplicationDelegate {
let statusItem = NSStatusBar.system.statusItem(withLength: NSStatusItem.variableLength) let statusItem = NSStatusBar.system.statusItem(withLength: NSStatusItem.variableLength)
let popover = NSPopover() let popover = NSPopover()
let viewController = PopoverMenu(nibName: "PopoverMenu", let viewController = PopoverMenu(nibName: "PopoverMenu", bundle: Bundle.main)
bundle: Bundle.main)
let statusIcon = NSImage(named: "status_icon") let statusIcon = NSImage(named: "status_icon")
var spinnerView = NSView() var spinnerView = NSView()
let spinner = NSProgressIndicator() let spinner = NSProgressIndicator()
......
...@@ -8,38 +8,28 @@ ...@@ -8,38 +8,28 @@
import Cocoa import Cocoa
class DropView: NSImageView { class DropView: NSView {
@IBOutlet var uploadImage: DropView! @IBOutlet weak var textLabel: NSTextField! //FIXME: Value is Nil despite outlet existing. https://stackoverflow.com/questions/58314461/outlet-definition-is-nil-despite-outlet-existing
@IBOutlet var textLabel: NSTextField! var filePath: String?
var filePath: String?
required init?(coder: NSCoder) { required init?(coder: NSCoder) {
super.init(coder: coder) super.init(coder: coder)
isEditable = false //isEditable = false
wantsLayer = true wantsLayer = true
registerForDraggedTypes([NSPasteboard.PasteboardType.URL, NSPasteboard.PasteboardType.fileURL]) registerForDraggedTypes([NSPasteboard.PasteboardType.URL, NSPasteboard.PasteboardType.fileURL])
} }
override func draggingEntered(_: NSDraggingInfo) -> NSDragOperation { 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 return .copy
} }
override func draggingEnded(_: NSDraggingInfo) { override func draggingEnded(_: NSDraggingInfo) {
textLabel.stringValue = "Drag and Drop to Upload" //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
*/
} }
override func draggingExited(_: NSDraggingInfo?) { override func draggingExited(_: NSDraggingInfo?) {
textLabel.stringValue = "Drag and Drop to Upload" //textLabel.stringValue = "Drag and Drop to Upload"
} }
override func performDragOperation(_ sender: NSDraggingInfo) -> Bool { override func performDragOperation(_ sender: NSDraggingInfo) -> Bool {
......
//
// 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!
}
...@@ -9,11 +9,14 @@ ...@@ -9,11 +9,14 @@
import Cocoa import Cocoa
class PopoverMenu: NSViewController { class PopoverMenu: NSViewController {
let settingsMenu = NSMenu() @IBOutlet weak var uploadButton: NSButton!
let settingsMenu = NSMenu()
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
// Do view setup here. // Do view setup here.
uploadButton.isHighlighted = false
let settingsItem = NSMenuItem() let settingsItem = NSMenuItem()
settingsItem.action = #selector(presentSettingsDialog) settingsItem.action = #selector(presentSettingsDialog)
settingsItem.title = "Settings" settingsItem.title = "Settings"
......
...@@ -7,13 +7,14 @@ ...@@ -7,13 +7,14 @@
<objects> <objects>
<customObject id="-2" userLabel="File's Owner" customClass="PopoverMenu" customModule="Screenshottr" customModuleProvider="target"> <customObject id="-2" userLabel="File's Owner" customClass="PopoverMenu" customModule="Screenshottr" customModuleProvider="target">
<connections> <connections>
<outlet property="uploadButton" destination="jrN-oy-XGI" id="wjX-1I-3Py"/>
<outlet property="view" destination="Hz6-mo-xeY" id="0bl-1N-x8E"/> <outlet property="view" destination="Hz6-mo-xeY" id="0bl-1N-x8E"/>
</connections> </connections>
</customObject> </customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/> <customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application" customClass="DropView"> <customObject id="-3" userLabel="Application" customClass="DropView">
<connections> <connections>
<outlet property="uploadImage" destination="687-0U-0uf" id="lti-id-9I9"/> <outlet property="textLabel" destination="fj4-kJ-fXa" id="Fz7-VA-xTL"/>
</connections> </connections>
</customObject> </customObject>
<customView id="Hz6-mo-xeY"> <customView id="Hz6-mo-xeY">
...@@ -21,7 +22,7 @@ ...@@ -21,7 +22,7 @@
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<subviews> <subviews>
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="jrN-oy-XGI"> <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"/> <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"> <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"/> <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
...@@ -31,8 +32,28 @@ ...@@ -31,8 +32,28 @@
<action selector="uploadFileClicked:" target="-2" id="jft-g4-t1c"/> <action selector="uploadFileClicked:" target="-2" id="jft-g4-t1c"/>
</connections> </connections>
</button> </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"> <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"/> <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"> <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"/> <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
...@@ -42,23 +63,6 @@ ...@@ -42,23 +63,6 @@
<action selector="toggleGearMenu:" target="-2" id="FKD-T9-7Xw"/> <action selector="toggleGearMenu:" target="-2" id="FKD-T9-7Xw"/>
</connections> </connections>
</button> </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> </subviews>
<point key="canvasLocation" x="-17.5" y="62"/> <point key="canvasLocation" x="-17.5" y="62"/>
</customView> </customView>
......
...@@ -24,7 +24,7 @@ class UploadManager: NSObject { ...@@ -24,7 +24,7 @@ class UploadManager: NSObject {
defaults.set(true, forKey: uploadingKey) defaults.set(true, forKey: uploadingKey)
// This could probably be done better // This could probably be done better
// oh well lol // oh well lol
// sleep(2) sleep(2) //prevents race condiiton on legacy Mac OS
let fileManager = FileManager.default let fileManager = FileManager.default
do { do {
// Grab contents by predicate, convert to array, loop through array with paths // Grab contents by predicate, convert to array, loop through array with paths
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment