Skip to content
Snippets Groups Projects
Unverified Commit 4ed2aeae authored by Spotlight's avatar Spotlight
Browse files

Force popover to work

parent 8710aa7d
No related branches found
No related tags found
No related merge requests found
......@@ -17,10 +17,10 @@
4279D5C61F4696EA00558889 /* UploadManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4279D5C51F4696EA00558889 /* UploadManager.swift */; };
4279D5CC1F469B4500558889 /* Config.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4279D5CB1F469B4500558889 /* Config.swift */; };
4279D5D01F46A01D00558889 /* GCPManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4279D5CF1F46A01D00558889 /* GCPManager.swift */; };
42C0AD501FBE5D6D0053C761 /* PopoverMenu.swift in Sources */ = {isa = PBXBuildFile; fileRef = 42C0AD4F1FBE5D6D0053C761 /* PopoverMenu.swift */; };
42C0AD521FBE61A70053C761 /* PopoverMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 42C0AD511FBE61A70053C761 /* PopoverMenu.xib */; };
42D1E8441F4E472300238857 /* SettingsMenu.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 42D1E8431F4E472300238857 /* SettingsMenu.storyboard */; };
42F2C88C1F4A585B00FA3D44 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 42F2C88A1F4A585B00FA3D44 /* MainMenu.xib */; };
42F2C8921F4A5B4C00FA3D44 /* PopoverMenu.swift in Sources */ = {isa = PBXBuildFile; fileRef = 42F2C8901F4A5B4C00FA3D44 /* PopoverMenu.swift */; };
42F2C8931F4A5B4C00FA3D44 /* PopoverMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 42F2C8911F4A5B4C00FA3D44 /* PopoverMenu.xib */; };
91C9E7F18A37EE7A8E2F39F8 /* Pods_ScreenshottrTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C2ACA69BD41F67A4C2DFC71C /* Pods_ScreenshottrTests.framework */; };
A36C9E254518F2FEE5372C9B /* Pods_ScreenshottrUITests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B3E2968AB8A1EEDF1100710F /* Pods_ScreenshottrUITests.framework */; };
/* End PBXBuildFile section */
......@@ -62,10 +62,10 @@
4279D5C51F4696EA00558889 /* UploadManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UploadManager.swift; sourceTree = "<group>"; };
4279D5CB1F469B4500558889 /* Config.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Config.swift; sourceTree = "<group>"; };
4279D5CF1F46A01D00558889 /* GCPManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GCPManager.swift; sourceTree = "<group>"; };
42C0AD4F1FBE5D6D0053C761 /* PopoverMenu.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PopoverMenu.swift; sourceTree = "<group>"; };
42C0AD511FBE61A70053C761 /* PopoverMenu.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = PopoverMenu.xib; sourceTree = "<group>"; };
42D1E8431F4E472300238857 /* SettingsMenu.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = SettingsMenu.storyboard; sourceTree = "<group>"; };
42F2C88B1F4A585B00FA3D44 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/MainMenu.xib; sourceTree = "<group>"; };
42F2C8901F4A5B4C00FA3D44 /* PopoverMenu.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PopoverMenu.swift; sourceTree = "<group>"; };
42F2C8911F4A5B4C00FA3D44 /* PopoverMenu.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = PopoverMenu.xib; sourceTree = "<group>"; };
7A9EE1DAFB01DE50B9F3F2CA /* Pods-Screenshottr.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Screenshottr.release.xcconfig"; path = "Pods/Target Support Files/Pods-Screenshottr/Pods-Screenshottr.release.xcconfig"; sourceTree = "<group>"; };
85B58CFFF6F2C5DBA952F077 /* Pods_Screenshottr.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Screenshottr.framework; sourceTree = BUILT_PRODUCTS_DIR; };
A291B5585B597E748BB362D0 /* Pods-Screenshottr.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Screenshottr.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Screenshottr/Pods-Screenshottr.debug.xcconfig"; sourceTree = "<group>"; };
......@@ -136,9 +136,9 @@
4279D5CF1F46A01D00558889 /* GCPManager.swift */,
4277C2BA1F4F66F7004649DA /* PomfManager.swift */,
42F2C88A1F4A585B00FA3D44 /* MainMenu.xib */,
42F2C8901F4A5B4C00FA3D44 /* PopoverMenu.swift */,
42F2C8911F4A5B4C00FA3D44 /* PopoverMenu.xib */,
42D1E8431F4E472300238857 /* SettingsMenu.storyboard */,
42C0AD4F1FBE5D6D0053C761 /* PopoverMenu.swift */,
42C0AD511FBE61A70053C761 /* PopoverMenu.xib */,
);
path = Screenshottr;
sourceTree = "<group>";
......@@ -310,8 +310,8 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
42C0AD521FBE61A70053C761 /* PopoverMenu.xib in Resources */,
4279D5861F4686AE00558889 /* Assets.xcassets in Resources */,
42F2C8931F4A5B4C00FA3D44 /* PopoverMenu.xib in Resources */,
42D1E8441F4E472300238857 /* SettingsMenu.storyboard in Resources */,
42F2C88C1F4A585B00FA3D44 /* MainMenu.xib in Resources */,
);
......@@ -499,10 +499,10 @@
buildActionMask = 2147483647;
files = (
4279D5C61F4696EA00558889 /* UploadManager.swift in Sources */,
42C0AD501FBE5D6D0053C761 /* PopoverMenu.swift in Sources */,
4279D5D01F46A01D00558889 /* GCPManager.swift in Sources */,
4279D5841F4686AE00558889 /* AppDelegate.swift in Sources */,
4279D5CC1F469B4500558889 /* Config.swift in Sources */,
42F2C8921F4A5B4C00FA3D44 /* PopoverMenu.swift in Sources */,
4277C2BB1F4F66F8004649DA /* PomfManager.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
......
......@@ -13,32 +13,16 @@ import SKQueue
class AppDelegate: NSObject, NSApplicationDelegate {
let statusItem = NSStatusBar.system().statusItem(withLength: NSVariableStatusItemLength)
// let viewController = PopoverMenu(nibName: "PopoverMenu",
// bundle: Bundle.main)!
let popover = NSPopover()
let viewController = PopoverMenu(nibName: "PopoverMenu",
bundle: Bundle.main)!
func applicationDidFinishLaunching(_ aNotification: Notification) {
// Insert code here to initialize your application
statusItem.image = NSImage(named: "status_icon")
let statusMenu = NSMenu()
statusItem.action = #selector(togglePopover)
let settingsItem = NSMenuItem()
settingsItem.action = #selector(openDialog)
settingsItem.title = "Settings"
statusMenu.addItem(settingsItem)
let uploadItem = NSMenuItem()
uploadItem.action = #selector(AppDelegate.openDialog)
uploadItem.title = "Upload File"
statusMenu.addItem(uploadItem)
// Seperator + quit
statusMenu.addItem(NSMenuItem.separator())
let quitItem = NSMenuItem()
quitItem.action = #selector(AppDelegate.quitApplication)
quitItem.title = "Quit"
statusMenu.addItem(quitItem)
statusItem.menu = statusMenu
popover.contentViewController = viewController
popover.behavior = .transient
// Set up file watching
let queue = SKQueue(delegate: UploadReceiver())
......@@ -49,46 +33,23 @@ class AppDelegate: NSObject, NSApplicationDelegate {
NSApplication.shared().terminate(self)
}
func openDialog() {
// popover.contentViewController = viewController
// if popover.isShown {
// closePopover(sender: sender)
// } else {
// showPopover(sender: sender)
// }
// Open panel otherwise
let dialog = NSOpenPanel();
dialog.title = "Choose a file to upload.";
dialog.showsResizeIndicator = true;
dialog.showsHiddenFiles = false;
dialog.canChooseDirectories = false;
dialog.canCreateDirectories = false;
dialog.allowsMultipleSelection = false;
if (dialog.runModal() == NSModalResponseOK) {
let result = dialog.url // Pathname of the file
if (result != nil) {
let path = result!.path
UploadManager().uploadFile(path: path, type: .GoogleCloudPlatform, fromQueue: false)
}
func togglePopover(sender: AnyObject?) {
if popover.isShown {
closePopover(sender: sender)
} else {
// User clicked on "Cancel"
return
showPopover(sender: sender)
}
}
// func showPopover(sender: AnyObject?) {
// if let button = statusItem.button {
// popover.show(relativeTo: button.bounds, of: button, preferredEdge: NSRectEdge.minY)
// }
// }
//
// func closePopover(sender: AnyObject?) {
// popover.performClose(sender)
// }
func showPopover(sender: AnyObject?) {
if let button = statusItem.button {
popover.show(relativeTo: button.bounds, of: button, preferredEdge: NSRectEdge.minY)
}
}
func closePopover(sender: AnyObject?) {
popover.performClose(sender)
}
func applicationWillTerminate(_ aNotification: Notification) {
......
......@@ -2,19 +2,66 @@
// PopoverMenu.swift
// Screenshottr
//
// Created by Spotlight on 8/20/17.
// Created by Spotlight on 11/16/17.
// Copyright © 2017 JOS Computing. All rights reserved.
//
import Cocoa
class PopoverMenu: NSViewController {
let settingsMenu = NSMenu()
@IBOutlet var recentScreenshotsList: NSTreeController!
override func viewDidLoad() {
super.viewDidLoad()
// Do view setup here.
// recentScreenshotsList.add("test")
let settingsItem = NSMenuItem()
settingsItem.action = #selector(openDialog)
settingsItem.title = "Settings"
settingsMenu.addItem(settingsItem)
let uploadItem = NSMenuItem()
uploadItem.action = #selector(openDialog)
uploadItem.title = "Upload File"
settingsMenu.addItem(uploadItem)
// Seperator + quit
settingsMenu.addItem(NSMenuItem.separator())
let quitItem = NSMenuItem()
quitItem.action = #selector(AppDelegate.quitApplication)
quitItem.title = "Quit"
settingsMenu.addItem(quitItem)
}
func openDialog(sender: Any) {
let dialog = NSOpenPanel();
dialog.title = "Choose a file to upload.";
dialog.showsResizeIndicator = true;
dialog.showsHiddenFiles = false;
dialog.canChooseDirectories = false;
dialog.canCreateDirectories = false;
dialog.allowsMultipleSelection = false;
if (dialog.runModal() == NSModalResponseOK) {
let result = dialog.url // Pathname of the file
if (result != nil) {
let path = result!.path
UploadManager().uploadFile(path: path, type: .GoogleCloudPlatform, fromQueue: false)
}
} else {
// User clicked on "Cancel"
return
}
}
@IBAction func toggleGearMenu(_ sender: Any) {
if let event = NSApplication.shared().currentEvent {
NSMenu.popUpContextMenu(settingsMenu, with: event, for: sender as! NSView)
}
}
@IBAction func uploadFileClicked(_ sender: Any) {
openDialog(sender: sender as Any)
}
}
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="11762" systemVersion="15G1611" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="11762" systemVersion="15G17023" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="11762"/>
......@@ -8,7 +8,6 @@
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="PopoverMenu" customModule="Screenshottr" customModuleProvider="target">
<connections>
<outlet property="recentScreenshotsList" destination="OHK-bq-nof" id="kUs-dz-qIO"/>
<outlet property="view" destination="Hz6-mo-xeY" id="0bl-1N-x8E"/>
</connections>
</customObject>
......@@ -25,16 +24,14 @@
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="uploadFileClicked:" target="-2" id="jft-g4-t1c"/>
</connections>
</button>
<imageView fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="bmI-0E-hvv">
<rect key="frame" x="235" y="5" width="25" height="25"/>
<autoresizingMask key="autoresizingMask"/>
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" animates="YES" imageScaling="proportionallyDown" image="NSActionTemplate" id="EZB-Pp-65R"/>
</imageView>
<popUpButton verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="W5e-Go-9Z7">
<rect key="frame" x="18" y="256" width="230" height="26"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<popUpButtonCell key="cell" type="push" title="Item 1" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" state="on" borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2" selectedItem="TFj-Tx-XUc" id="Hhq-RT-1sX">
<popUpButtonCell key="cell" type="push" title="Item 1" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" state="on" borderStyle="border" imageScaling="proportionallyDown" inset="2" selectedItem="TFj-Tx-XUc" id="Hhq-RT-1sX">
<behavior key="behavior" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="menu"/>
<menu key="menu" id="t4g-3M-PQD">
......@@ -76,25 +73,8 @@
<tableCellView id="0mr-ml-YnE">
<rect key="frame" x="1" y="1" width="220" height="17"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="H2v-JE-qk5">
<rect key="frame" x="0.0" y="0.0" width="220" height="17"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" title="Table View Cell" id="AsO-iN-MTs">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
</subviews>
<connections>
<outlet property="textField" destination="H2v-JE-qk5" id="iT9-Tx-gvc"/>
</connections>
</tableCellView>
</prototypeCellViews>
<connections>
<binding destination="OHK-bq-nof" name="value" keyPath="arrangedObjects.name" id="KJh-3j-CAF"/>
</connections>
</tableColumn>
</tableColumns>
</outlineView>
......@@ -110,14 +90,20 @@
<autoresizingMask key="autoresizingMask"/>
</scroller>
</scrollView>
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="ZlR-St-Ru0">
<rect key="frame" x="237" y="7" 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"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="toggleGearMenu:" target="-2" id="FKD-T9-7Xw"/>
</connections>
</button>
</subviews>
<point key="canvasLocation" x="31.5" y="182"/>
</customView>
<treeController childrenKeyPath="child" id="OHK-bq-nof">
<connections>
<outlet property="content" destination="zp9-Ey-lcc" id="uaM-wg-jEN"/>
</connections>
</treeController>
</objects>
<resources>
<image name="NSActionTemplate" width="14" height="14"/>
......
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