87 lines
2.5 KiB
Swift
87 lines
2.5 KiB
Swift
//
|
|
// AppDelegate.swift
|
|
// YAPS
|
|
//
|
|
// Created by Gerrit Linnemann on 05.08.20.
|
|
// Copyright © 2020 Adawim UG (haftungsbeschränkt). All rights reserved.
|
|
//
|
|
|
|
import Cocoa
|
|
import SwiftUI
|
|
|
|
@NSApplicationMain
|
|
class AppDelegate: NSObject, NSApplicationDelegate {
|
|
|
|
@ObservedObject var observedFileList: ObservableArray<YapsFile> = Shared.shared.fileList
|
|
var window: NSWindow!
|
|
|
|
|
|
func applicationDidFinishLaunching(_ aNotification: Notification) {
|
|
// Create the SwiftUI view that provides the window contents.
|
|
let contentView = ContentView()
|
|
|
|
// Toolbar **needs** a delegate
|
|
NSToolbar.yapsToolbar.delegate = self
|
|
|
|
// Create the window and set the content view.
|
|
window = NSWindow(
|
|
contentRect: NSRect(x: 0, y: 0, width: 480, height: 300),
|
|
styleMask: [.titled, .closable, .miniaturizable, .resizable, .fullSizeContentView],
|
|
backing: .buffered, defer: false)
|
|
window.toolbar = .yapsToolbar
|
|
window.center()
|
|
window.setFrameAutosaveName("YAPS Main Window")
|
|
window.contentView = NSHostingView(rootView: contentView)
|
|
window.makeKeyAndOrderFront(nil)
|
|
}
|
|
|
|
func applicationWillTerminate(_ aNotification: Notification) {
|
|
// 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 openFolder(_ sender: Any) {
|
|
self.observedFileList.array.removeAll()
|
|
self.observedFileList.array.append(contentsOf: FinderHelper.shared.askForFolderAndGetFiles())
|
|
}
|
|
|
|
@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)
|
|
}
|
|
|
|
@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)
|
|
}
|
|
}
|
|
|
|
struct AppDelegate_Previews: PreviewProvider {
|
|
static var previews: some View {
|
|
/*@START_MENU_TOKEN@*/Text("Hello, World!")/*@END_MENU_TOKEN@*/
|
|
}
|
|
}
|