Skip to content
Snippets Groups Projects
Verified Commit 57ca3e7f authored by Spotlight Deveaux's avatar Spotlight Deveaux :fox:
Browse files

Test settings view

parent aedfcf10
No related branches found
No related tags found
1 merge request!1Add settings menu, add drag and drop functionality
......@@ -34,8 +34,8 @@ class PopoverMenu: NSViewController {
}
@objc func presentSettingsDialog(sender: Any) {
let mwc: SettingsView! = SettingsView(windowNibName: "SettingsView")
mwc.window!.orderFront(self)
Bundle.main.loadNibNamed("SettingsView", owner: self, topLevelObjects: nil)
AppDelegate().closePopover(sender: self)
}
@objc func openDialog(sender: Any) {
......
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="11762" systemVersion="15G17023" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="14313.13.2" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="11762"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14313.13.2"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
......@@ -14,11 +14,11 @@
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
<customView id="Hz6-mo-xeY">
<rect key="frame" x="0.0" y="0.0" width="265" height="300"/>
<rect key="frame" x="0.0" y="0.0" width="265" height="284"/>
<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="0.0" width="108" height="32"/>
<rect key="frame" x="78" y="13" width="108" height="32"/>
<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"/>
......@@ -28,23 +28,8 @@
<action selector="uploadFileClicked:" target="-2" id="jft-g4-t1c"/>
</connections>
</button>
<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="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">
<items>
<menuItem title="Item 1" state="on" id="TFj-Tx-XUc"/>
<menuItem title="Item 2" id="cQz-hv-8Nx"/>
<menuItem title="Item 3" id="VrR-jj-eNs"/>
</items>
</menu>
</popUpButtonCell>
</popUpButton>
<scrollView wantsLayer="YES" fixedFrame="YES" autohidesScrollers="YES" horizontalLineScroll="26" horizontalPageScroll="10" verticalLineScroll="26" verticalPageScroll="10" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="T2C-QO-xfc">
<rect key="frame" x="20" y="48" width="225" height="203"/>
<rect key="frame" x="20" y="61" width="225" height="203"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<clipView key="contentView" ambiguous="YES" drawsBackground="NO" id="l7O-qP-Abw">
<rect key="frame" x="1" y="1" width="223" height="201"/>
......@@ -81,17 +66,17 @@
</subviews>
<nil key="backgroundColor"/>
</clipView>
<scroller key="horizontalScroller" hidden="YES" verticalHuggingPriority="750" horizontal="YES" id="gIO-dw-hsa">
<scroller key="horizontalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" horizontal="YES" id="gIO-dw-hsa">
<rect key="frame" x="1" y="-15" width="0.0" height="16"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
<scroller key="verticalScroller" hidden="YES" verticalHuggingPriority="750" doubleValue="1" horizontal="NO" id="x3Q-hc-R7z">
<scroller key="verticalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" doubleValue="1" horizontal="NO" id="x3Q-hc-R7z">
<rect key="frame" x="-15" y="1" width="16" height="0.0"/>
<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"/>
<rect key="frame" x="237" 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"/>
......@@ -102,7 +87,7 @@
</connections>
</button>
</subviews>
<point key="canvasLocation" x="31.5" y="182"/>
<point key="canvasLocation" x="31.5" y="161"/>
</customView>
</objects>
<resources>
......
......@@ -8,13 +8,49 @@
import Cocoa
class SettingsView: NSWindowController {
class SettingsView: NSView {
@IBOutlet weak var apiURL: NSTextField!
@IBOutlet weak var apiEndDomain: NSTextField!
@IBOutlet weak var owoToken: NSTextField!
@IBOutlet weak var owoTokenDescription: NSTextField!
@IBOutlet weak var serviceSelection: NSPopUpButton!
override func windowDidLoad() {
super.windowDidLoad()
let owoBetaAPIURL = "https://api.awau.moe/upload/pomf?key="
let standard = UserDefaults.standard
// Load defaults
func viewWillMove(_ currentWindow: NSWindow?) {
currentWindow!.makeKeyAndOrderFront(self)
owoToken.stringValue = standard.string(forKey: "owoToken") ?? ""
apiURL.stringValue = standard.string(forKey: "pomfUploadPath") ?? ""
apiEndDomain.stringValue = standard.string(forKey: "pomfBaseDomain") ?? ""
serviceSelection.selectItem(at: standard.integer(forKey: "selectedService"))
}
@IBAction func saveData(_ sender: Any) {
if serviceSelection.selectedItem?.title == "OwO Beta" || owoToken.stringValue != "" {
let url = "\(owoBetaAPIURL)\(owoToken.stringValue)"
standard.set(url, forKey: "pomfUploadPath")
} else {
standard.set("pomfUploadPath", forKey: apiURL.stringValue)
}
// Implement this method to handle any initialization after your window controller's window has been loaded from its nib file.
print("testing")
standard.set(apiEndDomain.stringValue, forKey: "pomfBaseDomain")
standard.set(owoToken.stringValue, forKey: "owoToken")
standard.set(serviceSelection.indexOfSelectedItem, forKey: "selectedService")
}
@IBAction func serviceTypeUpdated(_ sender: Any) {
if serviceSelection.selectedItem?.title != "OwO Beta" {
owoToken.isHidden = true
owoTokenDescription.isHidden = true
} else {
owoToken.isHidden = false
owoTokenDescription.isHidden = false
}
}
@IBAction func owoTokenUpdated(_ sender: Any) {
apiURL.stringValue = "\(owoBetaAPIURL)\(owoToken.stringValue)"
}
}
......@@ -9,15 +9,134 @@
<customObject id="-2" userLabel="File's Owner"/>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
<window title="Window" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" animationBehavior="default" id="QvC-M9-y7g">
<window title="Preferences" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" animationBehavior="default" id="QvC-M9-y7g">
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
<rect key="contentRect" x="196" y="240" width="480" height="270"/>
<rect key="contentRect" x="196" y="240" width="410" height="478"/>
<rect key="screenRect" x="0.0" y="0.0" width="1920" height="1177"/>
<view key="contentView" wantsLayer="YES" id="EiT-Mj-1SZ">
<rect key="frame" x="0.0" y="0.0" width="480" height="270"/>
<view key="contentView" wantsLayer="YES" id="EiT-Mj-1SZ" customClass="SettingsView" customModule="Screenshottr" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="410" height="478"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Xpq-5o-CoS">
<rect key="frame" x="18" y="441" width="134" height="17"/>
<autoresizingMask key="autoresizingMask"/>
<textFieldCell key="cell" lineBreakMode="clipping" title="Pomf host provider" id="Isv-ak-kUD">
<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>
<popUpButton verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="kln-Mi-C4C">
<rect key="frame" x="236" y="436" width="157" height="25"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<popUpButtonCell key="cell" type="push" title="OwO Beta" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" state="on" borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2" selectedItem="8gh-CX-7g9" id="fVv-Zu-mEE">
<behavior key="behavior" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="menu"/>
<menu key="menu" id="8WX-6i-1Wd">
<items>
<menuItem title="OwO Beta" state="on" id="8gh-CX-7g9">
<modifierMask key="keyEquivalentModifierMask"/>
</menuItem>
<menuItem title="Other" id="KlD-pC-Vw9">
<modifierMask key="keyEquivalentModifierMask"/>
</menuItem>
</items>
</menu>
</popUpButtonCell>
<connections>
<action selector="serviceTypeUpdated:" target="EiT-Mj-1SZ" id="678-Oh-mHx"/>
</connections>
</popUpButton>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="mgV-Pf-QGe">
<rect key="frame" x="18" y="358" width="134" height="17"/>
<autoresizingMask key="autoresizingMask"/>
<textFieldCell key="cell" lineBreakMode="clipping" title="API URL" id="5hH-cA-LDe">
<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>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="8NS-Fk-YRu">
<rect key="frame" x="18" y="297" width="134" height="17"/>
<autoresizingMask key="autoresizingMask"/>
<textFieldCell key="cell" lineBreakMode="clipping" title="API End Domain" id="pLF-Zp-jMn">
<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>
<textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="qF5-nX-Pz8">
<rect key="frame" x="20" y="328" width="370" height="22"/>
<autoresizingMask key="autoresizingMask"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" continuous="YES" sendsActionOnEndEditing="YES" borderStyle="bezel" drawsBackground="YES" id="qBj-EN-HPh">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="uKy-PG-R3s">
<rect key="frame" x="20" y="267" width="370" height="22"/>
<autoresizingMask key="autoresizingMask"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" borderStyle="bezel" drawsBackground="YES" id="xX3-Lm-O6v">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="avt-xf-4ZB">
<rect key="frame" x="20" y="175" width="370" height="22"/>
<autoresizingMask key="autoresizingMask"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" borderStyle="bezel" drawsBackground="YES" id="DKN-gW-zJK">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
<connections>
<action selector="owoTokenUpdated:" target="EiT-Mj-1SZ" id="1Wc-dZ-8N9"/>
</connections>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="N76-l6-il7">
<rect key="frame" x="18" y="205" width="274" height="17"/>
<autoresizingMask key="autoresizingMask"/>
<textFieldCell key="cell" lineBreakMode="clipping" title="OwO beta token - will update API URL above" id="stG-8f-QrQ">
<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>
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="eG2-Uz-PWc">
<rect key="frame" x="321" y="13" width="70" height="32"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="push" title="Save" bezelStyle="rounded" alignment="center" state="on" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="Sbb-sj-6Dr">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="saveData:" target="EiT-Mj-1SZ" id="rOI-th-hhD"/>
</connections>
</button>
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="IyY-Hw-jSo">
<rect key="frame" x="246" y="13" width="75" height="32"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="push" title="Close" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="HFk-qx-eaJ">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="performClose:" target="QvC-M9-y7g" id="e3t-a4-0VU"/>
</connections>
</button>
</subviews>
<connections>
<outlet property="apiEndDomain" destination="uKy-PG-R3s" id="53E-RA-Rwb"/>
<outlet property="apiURL" destination="qF5-nX-Pz8" id="thI-Gp-m30"/>
<outlet property="owoToken" destination="avt-xf-4ZB" id="nw1-mn-fmF"/>
<outlet property="owoTokenDescription" destination="N76-l6-il7" id="EXJ-y4-e0d"/>
<outlet property="serviceSelection" destination="kln-Mi-C4C" id="2bS-lE-yCF"/>
</connections>
</view>
<point key="canvasLocation" x="174" y="251"/>
</window>
</objects>
</document>
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