Leertasten-Shortcut zur Bild-Auswahl
This commit is contained in:
parent
b5f062e4b6
commit
43ea6556cb
@ -16,6 +16,7 @@
|
|||||||
EC13307124DDB3F4008063CF /* FinderHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC13307024DDB3F4008063CF /* FinderHelper.swift */; };
|
EC13307124DDB3F4008063CF /* FinderHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC13307024DDB3F4008063CF /* FinderHelper.swift */; };
|
||||||
EC13307424DF2B2D008063CF /* YapsFileCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC13307324DF2B2D008063CF /* YapsFileCell.swift */; };
|
EC13307424DF2B2D008063CF /* YapsFileCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC13307324DF2B2D008063CF /* YapsFileCell.swift */; };
|
||||||
ECF5A75824E070710010A11D /* RawFileExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = ECF5A75724E070710010A11D /* RawFileExtensions.swift */; };
|
ECF5A75824E070710010A11D /* RawFileExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = ECF5A75724E070710010A11D /* RawFileExtensions.swift */; };
|
||||||
|
ECF5A76024E41AAC0010A11D /* Shared.swift in Sources */ = {isa = PBXBuildFile; fileRef = ECF5A75F24E41AAC0010A11D /* Shared.swift */; };
|
||||||
/* End PBXBuildFile section */
|
/* End PBXBuildFile section */
|
||||||
|
|
||||||
/* Begin PBXFileReference section */
|
/* Begin PBXFileReference section */
|
||||||
@ -31,6 +32,7 @@
|
|||||||
EC13307024DDB3F4008063CF /* FinderHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FinderHelper.swift; sourceTree = "<group>"; };
|
EC13307024DDB3F4008063CF /* FinderHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FinderHelper.swift; sourceTree = "<group>"; };
|
||||||
EC13307324DF2B2D008063CF /* YapsFileCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YapsFileCell.swift; sourceTree = "<group>"; };
|
EC13307324DF2B2D008063CF /* YapsFileCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YapsFileCell.swift; sourceTree = "<group>"; };
|
||||||
ECF5A75724E070710010A11D /* RawFileExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RawFileExtensions.swift; sourceTree = "<group>"; };
|
ECF5A75724E070710010A11D /* RawFileExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RawFileExtensions.swift; sourceTree = "<group>"; };
|
||||||
|
ECF5A75F24E41AAC0010A11D /* Shared.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Shared.swift; sourceTree = "<group>"; };
|
||||||
/* End PBXFileReference section */
|
/* End PBXFileReference section */
|
||||||
|
|
||||||
/* Begin PBXFrameworksBuildPhase section */
|
/* Begin PBXFrameworksBuildPhase section */
|
||||||
@ -73,6 +75,7 @@
|
|||||||
EC13306724DAE92E008063CF /* YAPS.entitlements */,
|
EC13306724DAE92E008063CF /* YAPS.entitlements */,
|
||||||
EC13306024DAE92E008063CF /* Preview Content */,
|
EC13306024DAE92E008063CF /* Preview Content */,
|
||||||
EC13307024DDB3F4008063CF /* FinderHelper.swift */,
|
EC13307024DDB3F4008063CF /* FinderHelper.swift */,
|
||||||
|
ECF5A75F24E41AAC0010A11D /* Shared.swift */,
|
||||||
);
|
);
|
||||||
path = YAPS;
|
path = YAPS;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
@ -173,6 +176,7 @@
|
|||||||
isa = PBXSourcesBuildPhase;
|
isa = PBXSourcesBuildPhase;
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
|
ECF5A76024E41AAC0010A11D /* Shared.swift in Sources */,
|
||||||
EC13305D24DAE92D008063CF /* ContentView.swift in Sources */,
|
EC13305D24DAE92D008063CF /* ContentView.swift in Sources */,
|
||||||
EC13307124DDB3F4008063CF /* FinderHelper.swift in Sources */,
|
EC13307124DDB3F4008063CF /* FinderHelper.swift in Sources */,
|
||||||
ECF5A75824E070710010A11D /* RawFileExtensions.swift in Sources */,
|
ECF5A75824E070710010A11D /* RawFileExtensions.swift in Sources */,
|
||||||
|
|||||||
@ -34,6 +34,26 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
|||||||
// Insert code here to tear down your application
|
// Insert code here to tear down your application
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
@IBAction func zoomIn(_ sender: Any) {
|
||||||
|
//scrollView.magnification += 0.25
|
||||||
|
}
|
||||||
|
|
||||||
|
@IBAction func zoomOut(_ sender: Any) {
|
||||||
|
scrollView.magnification -= 0.25
|
||||||
|
}
|
||||||
|
|
||||||
|
@IBAction func zoomToFit(_ sender: Any) {
|
||||||
|
scrollView.magnify(toFit: imageView.frame)
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
@IBAction func getIt(_ sender: Any) {
|
||||||
|
if !Shared.shared.destinationDefined {
|
||||||
|
Shared.shared.destination = FinderHelper.shared.selectFolder(modalTitle: "Choose destination folder.")
|
||||||
|
Shared.shared.destinationDefined = true
|
||||||
|
}
|
||||||
|
FinderHelper.shared.iLikeThisImage(yapsFile: Shared.shared.currentFile, destination: Shared.shared.destination)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="14814" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
|
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="16096" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14814"/>
|
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="16096"/>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<scenes>
|
<scenes>
|
||||||
<!--Application-->
|
<!--Application-->
|
||||||
@ -630,6 +630,19 @@
|
|||||||
</items>
|
</items>
|
||||||
</menu>
|
</menu>
|
||||||
</menuItem>
|
</menuItem>
|
||||||
|
<menuItem title="Action" id="GjW-e6-GKW">
|
||||||
|
<modifierMask key="keyEquivalentModifierMask"/>
|
||||||
|
<menu key="submenu" title="Action" id="G8d-ZB-3Wx">
|
||||||
|
<items>
|
||||||
|
<menuItem title="Get It" keyEquivalent=" " id="ZNf-qX-HIL">
|
||||||
|
<modifierMask key="keyEquivalentModifierMask"/>
|
||||||
|
<connections>
|
||||||
|
<action selector="getIt:" target="Voe-Tx-rLC" id="fzn-Y1-JAr"/>
|
||||||
|
</connections>
|
||||||
|
</menuItem>
|
||||||
|
</items>
|
||||||
|
</menu>
|
||||||
|
</menuItem>
|
||||||
<menuItem title="Window" id="aUF-d1-5bR">
|
<menuItem title="Window" id="aUF-d1-5bR">
|
||||||
<modifierMask key="keyEquivalentModifierMask"/>
|
<modifierMask key="keyEquivalentModifierMask"/>
|
||||||
<menu key="submenu" title="Window" systemMenu="window" id="Td7-aD-5lo">
|
<menu key="submenu" title="Window" systemMenu="window" id="Td7-aD-5lo">
|
||||||
@ -673,7 +686,7 @@
|
|||||||
<outlet property="delegate" destination="Voe-Tx-rLC" id="PrD-fu-P6m"/>
|
<outlet property="delegate" destination="Voe-Tx-rLC" id="PrD-fu-P6m"/>
|
||||||
</connections>
|
</connections>
|
||||||
</application>
|
</application>
|
||||||
<customObject id="Voe-Tx-rLC" customClass="AppDelegate" customModuleProvider="target"/>
|
<customObject id="Voe-Tx-rLC" customClass="AppDelegate" customModule="YAPS" customModuleProvider="target"/>
|
||||||
<customObject id="YLy-65-1bz" customClass="NSFontManager"/>
|
<customObject id="YLy-65-1bz" customClass="NSFontManager"/>
|
||||||
<customObject id="Ady-hI-5gd" userLabel="First Responder" customClass="NSResponder" sceneMemberID="firstResponder"/>
|
<customObject id="Ady-hI-5gd" userLabel="First Responder" customClass="NSResponder" sceneMemberID="firstResponder"/>
|
||||||
</objects>
|
</objects>
|
||||||
|
|||||||
@ -10,13 +10,7 @@ import SwiftUI
|
|||||||
|
|
||||||
struct ContentView: View {
|
struct ContentView: View {
|
||||||
@State var fileList = [YapsFile]()
|
@State var fileList = [YapsFile]()
|
||||||
@State var tabbedFile: YapsFile = YapsFile(name: "EMPTY", file: .init(fileURLWithPath: "Y"))
|
|
||||||
@State var previewImg = Image("placeholder-image")
|
@State var previewImg = Image("placeholder-image")
|
||||||
@State var destinationDefined: Bool = false
|
|
||||||
@State var destinationURL: URL = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0]
|
|
||||||
|
|
||||||
let finderHelper: FinderHelper = FinderHelper()
|
|
||||||
|
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
VStack {
|
VStack {
|
||||||
@ -24,7 +18,7 @@ struct ContentView: View {
|
|||||||
VStack(alignment: .leading) {
|
VStack(alignment: .leading) {
|
||||||
HStack {
|
HStack {
|
||||||
Button(action: {
|
Button(action: {
|
||||||
let files = self.finderHelper.askForFolderAndGetFiles()
|
let files = FinderHelper.shared.askForFolderAndGetFiles()
|
||||||
|
|
||||||
if files.count > 0 {
|
if files.count > 0 {
|
||||||
self.fileList.removeAll()
|
self.fileList.removeAll()
|
||||||
@ -35,11 +29,11 @@ struct ContentView: View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Button(action: {
|
Button(action: {
|
||||||
if !self.destinationDefined {
|
if !Shared.shared.destinationDefined {
|
||||||
self.destinationURL = self.finderHelper.selectFolder(modalTitle: "Choose destination folder.")
|
Shared.shared.destination = FinderHelper.shared.selectFolder(modalTitle: "Choose destination folder.")
|
||||||
self.destinationDefined = true
|
Shared.shared.destinationDefined = true
|
||||||
}
|
}
|
||||||
self.finderHelper.iLikeThisImage(yapsFile: self.tabbedFile, destination: self.destinationURL)
|
FinderHelper.shared.iLikeThisImage(yapsFile: Shared.shared.currentFile, destination: Shared.shared.destination)
|
||||||
}) {
|
}) {
|
||||||
Text("Get It!")
|
Text("Get It!")
|
||||||
}
|
}
|
||||||
@ -57,10 +51,10 @@ struct ContentView: View {
|
|||||||
|
|
||||||
print("pressed \(yapsFile.name)")
|
print("pressed \(yapsFile.name)")
|
||||||
|
|
||||||
self.previewImg = FinderHelper().getImageByURL(source: selectedImageURL)
|
self.previewImg = FinderHelper.shared.getImageByURL(source: selectedImageURL)
|
||||||
.resizable()
|
.resizable()
|
||||||
|
|
||||||
self.tabbedFile = yapsFile
|
Shared.shared.currentFile = yapsFile
|
||||||
})
|
})
|
||||||
.onMoveCommand { (direction) in
|
.onMoveCommand { (direction) in
|
||||||
print("direction: \(direction)")
|
print("direction: \(direction)")
|
||||||
@ -79,7 +73,7 @@ struct ContentView: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Text("\(self.tabbedFile.file.absoluteString)")
|
Text("\(Shared.shared.currentFile.file.absoluteString)")
|
||||||
.multilineTextAlignment(.leading)
|
.multilineTextAlignment(.leading)
|
||||||
.lineLimit(1)
|
.lineLimit(1)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,6 +10,9 @@ import Foundation
|
|||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
class FinderHelper {
|
class FinderHelper {
|
||||||
|
static let shared = FinderHelper()
|
||||||
|
|
||||||
|
private init() { }
|
||||||
|
|
||||||
func selectFolder(modalTitle: String) -> URL {
|
func selectFolder(modalTitle: String) -> URL {
|
||||||
let dialog = NSOpenPanel();
|
let dialog = NSOpenPanel();
|
||||||
|
|||||||
18
YAPS/YAPS/Shared.swift
Normal file
18
YAPS/YAPS/Shared.swift
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
//
|
||||||
|
// Shared.swift
|
||||||
|
// YAPS
|
||||||
|
//
|
||||||
|
// Created by Gerrit Linnemann on 12.08.20.
|
||||||
|
// Copyright © 2020 Adawim UG (haftungsbeschränkt). All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
class Shared: ObservableObject {
|
||||||
|
static let shared = Shared()
|
||||||
|
var currentFile: YapsFile = YapsFile(name: "EMPTY", file: .init(fileURLWithPath: "Y"))
|
||||||
|
var destination: URL = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0]
|
||||||
|
var destinationDefined: Bool = false
|
||||||
|
|
||||||
|
private init() { }
|
||||||
|
}
|
||||||
@ -18,7 +18,7 @@ struct YapsFileCell: View {
|
|||||||
|
|
||||||
HStack {
|
HStack {
|
||||||
// Icon
|
// Icon
|
||||||
FinderHelper().getImageByFiletype(file: yapsFile.file).resizable().frame(width: 20, height: 20)
|
FinderHelper.shared.getImageByFiletype(file: yapsFile.file).resizable().frame(width: 20, height: 20)
|
||||||
|
|
||||||
// Text
|
// Text
|
||||||
Text(yapsFile.name)
|
Text(yapsFile.name)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user