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 */; };
|
||||
EC13307424DF2B2D008063CF /* YapsFileCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC13307324DF2B2D008063CF /* YapsFileCell.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 */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
@ -31,6 +32,7 @@
|
||||
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>"; };
|
||||
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 */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
@ -73,6 +75,7 @@
|
||||
EC13306724DAE92E008063CF /* YAPS.entitlements */,
|
||||
EC13306024DAE92E008063CF /* Preview Content */,
|
||||
EC13307024DDB3F4008063CF /* FinderHelper.swift */,
|
||||
ECF5A75F24E41AAC0010A11D /* Shared.swift */,
|
||||
);
|
||||
path = YAPS;
|
||||
sourceTree = "<group>";
|
||||
@ -173,6 +176,7 @@
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
ECF5A76024E41AAC0010A11D /* Shared.swift in Sources */,
|
||||
EC13305D24DAE92D008063CF /* ContentView.swift in Sources */,
|
||||
EC13307124DDB3F4008063CF /* FinderHelper.swift in Sources */,
|
||||
ECF5A75824E070710010A11D /* RawFileExtensions.swift in Sources */,
|
||||
|
||||
@ -34,6 +34,26 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
||||
// 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"?>
|
||||
<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>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14814"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="16096"/>
|
||||
</dependencies>
|
||||
<scenes>
|
||||
<!--Application-->
|
||||
@ -630,6 +630,19 @@
|
||||
</items>
|
||||
</menu>
|
||||
</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">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<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"/>
|
||||
</connections>
|
||||
</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="Ady-hI-5gd" userLabel="First Responder" customClass="NSResponder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
|
||||
@ -10,13 +10,7 @@ import SwiftUI
|
||||
|
||||
struct ContentView: View {
|
||||
@State var fileList = [YapsFile]()
|
||||
@State var tabbedFile: YapsFile = YapsFile(name: "EMPTY", file: .init(fileURLWithPath: "Y"))
|
||||
@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 {
|
||||
VStack {
|
||||
@ -24,7 +18,7 @@ struct ContentView: View {
|
||||
VStack(alignment: .leading) {
|
||||
HStack {
|
||||
Button(action: {
|
||||
let files = self.finderHelper.askForFolderAndGetFiles()
|
||||
let files = FinderHelper.shared.askForFolderAndGetFiles()
|
||||
|
||||
if files.count > 0 {
|
||||
self.fileList.removeAll()
|
||||
@ -35,11 +29,11 @@ struct ContentView: View {
|
||||
}
|
||||
|
||||
Button(action: {
|
||||
if !self.destinationDefined {
|
||||
self.destinationURL = self.finderHelper.selectFolder(modalTitle: "Choose destination folder.")
|
||||
self.destinationDefined = true
|
||||
if !Shared.shared.destinationDefined {
|
||||
Shared.shared.destination = FinderHelper.shared.selectFolder(modalTitle: "Choose destination folder.")
|
||||
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!")
|
||||
}
|
||||
@ -57,10 +51,10 @@ struct ContentView: View {
|
||||
|
||||
print("pressed \(yapsFile.name)")
|
||||
|
||||
self.previewImg = FinderHelper().getImageByURL(source: selectedImageURL)
|
||||
self.previewImg = FinderHelper.shared.getImageByURL(source: selectedImageURL)
|
||||
.resizable()
|
||||
|
||||
self.tabbedFile = yapsFile
|
||||
Shared.shared.currentFile = yapsFile
|
||||
})
|
||||
.onMoveCommand { (direction) in
|
||||
print("direction: \(direction)")
|
||||
@ -79,7 +73,7 @@ struct ContentView: View {
|
||||
}
|
||||
}
|
||||
|
||||
Text("\(self.tabbedFile.file.absoluteString)")
|
||||
Text("\(Shared.shared.currentFile.file.absoluteString)")
|
||||
.multilineTextAlignment(.leading)
|
||||
.lineLimit(1)
|
||||
}
|
||||
|
||||
@ -10,6 +10,9 @@ import Foundation
|
||||
import SwiftUI
|
||||
|
||||
class FinderHelper {
|
||||
static let shared = FinderHelper()
|
||||
|
||||
private init() { }
|
||||
|
||||
func selectFolder(modalTitle: String) -> URL {
|
||||
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 {
|
||||
// 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(yapsFile.name)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user