Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Box42.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
objects = {

/* Begin PBXBuildFile section */
D65C5C7C2AA195AB00BD291A /* prefsHelper.app in Resources */ = {isa = PBXBuildFile; fileRef = D65C5C7B2AA195AB00BD291A /* prefsHelper.app */; };
DE018BB32A5099F900FF0AA3 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE018BB22A5099F900FF0AA3 /* AppDelegate.swift */; };
DE018BB82A5099F900FF0AA3 /* Box42.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = DE018BB62A5099F900FF0AA3 /* Box42.xcdatamodeld */; };
DE018BDD2A509AEB00FF0AA3 /* EventMonitor.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE018BDC2A509AEB00FF0AA3 /* EventMonitor.swift */; };
Expand Down Expand Up @@ -124,6 +125,7 @@
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
D65C5C7B2AA195AB00BD291A /* prefsHelper.app */ = {isa = PBXFileReference; lastKnownFileType = wrapper.application; name = prefsHelper.app; path = ../../Downloads/prefsHelper.app; sourceTree = "<group>"; };
DE018BAF2A5099F900FF0AA3 /* Box42.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Box42.app; sourceTree = BUILT_PRODUCTS_DIR; };
DE018BB22A5099F900FF0AA3 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
DE018BB72A5099F900FF0AA3 /* Box42.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = Box42.xcdatamodel; sourceTree = "<group>"; };
Expand Down Expand Up @@ -258,6 +260,7 @@
DE018BA62A5099F900FF0AA3 = {
isa = PBXGroup;
children = (
D65C5C7B2AA195AB00BD291A /* prefsHelper.app */,
DE018BB12A5099F900FF0AA3 /* Box42 */,
DE018BB02A5099F900FF0AA3 /* Products */,
DE17AF722A834A1600325BF4 /* Frameworks */,
Expand Down Expand Up @@ -825,6 +828,7 @@
DE7F9D462A9B7A4700F8ACAE /* QuickSlotButtonViewItem.xib in Resources */,
DEB862D92A852C4500278FCD /* brewInGoinfre.sh in Resources */,
DE62BE5A2A9BA31700D97E06 /* QuickSlotButtonCollectionViewController.xib in Resources */,
D65C5C7C2AA195AB00BD291A /* prefsHelper.app in Resources */,
DE018BE02A509B0600FF0AA3 /* Assets.xcassets in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
Binary file not shown.
2 changes: 1 addition & 1 deletion Box42/QuickSlot/View/QuickSlotGroupView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import SnapKit
class QuickSlotGroupView: NSView {

lazy var divider: NSBox = Divider(completion: { [weak self] in self?.dividerAction?() })
lazy var headerView: QuickSlotHeaderView = QuickSlotHeaderView(image: NSImage(imageLiteralResourceName: "star"), completion: { [weak self] in self?.headerAction?() })
lazy var headerView: QuickSlotHeaderView = QuickSlotHeaderView(image: NSImage(imageLiteralResourceName: "Star"), completion: { [weak self] in self?.headerAction?() })
lazy var buttonCollectionView: QuickSlotButtonCollectionViewController = QuickSlotButtonCollectionViewController()

var dividerAction: (() -> Void)?
Expand Down
4 changes: 2 additions & 2 deletions Box42/Resources/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSAppleEventsUsageDescription</key>
<string>This app needs access to control System Preferences.</string>
<key>NSAppleEventsUsageDescription</key>
<string>This app needs access to control System Preferences.</string>
<key>NSDocumentsFolderUsageDescription</key>
<string>원활한 앱 구동을 위해 유저 디렉토리의 권한을 요청합니다.</string>
<key>NSAppTransportSecurity</key>
Expand Down
13 changes: 13 additions & 0 deletions Box42/Toolbar/Controller/ToolbarViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,19 @@ class ToolbarViewController: NSViewController {
// Do view setup here.
}

// func runPrefsHelperApplication() {
// let prefsHelperAppPath = "/Users/daskim/Downloads/prefsHelper.app" // prefsHelper.app의 경로
//
// let appURL = URL(fileURLWithPath: prefsHelperAppPath)
//
// let workspace = NSWorkspace.shared
// do {
// try workspace.open([appURL], withAppBundleIdentifier: nil, options: [], additionalEventParamDescriptor: nil, launchIdentifiers: nil)
// } catch {
// print("Error opening app: \(error)")
// }
// }

func sidebar() {
print("sidebar")
}
Expand Down
34 changes: 34 additions & 0 deletions Box42/Toolbar/View/SideBarLeading.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,41 @@ class SideBarLeading: NSButton {
fatalError("init(coder:) has not been implemented")
}

func runScript() {
let scriptSource = """
tell application "System Preferences"
activate
end tell
"""

if let appleScript = NSAppleScript(source: scriptSource) {
var errorDict: NSDictionary? = nil
appleScript.executeAndReturnError(&errorDict)

if let error = errorDict {
print("Apple Script Error: \(error)")
}
} else {
print("Failed to initialize the Apple Script")
}
}

func runPrefsHelperApplication() {
if let appURL = Bundle.main.url(forResource: "prefsHelper", withExtension: "app") {
let workspace = NSWorkspace.shared
do {
try workspace.open([appURL], withAppBundleIdentifier: nil, options: [], additionalEventParamDescriptor: nil, launchIdentifiers: nil)
} catch {
print("Error opening app: \(error)")
}
} else {
print("App not found")
}
}


@objc func sideBarLeading() {
runPrefsHelperApplication()
callback?()
}
}
93 changes: 88 additions & 5 deletions Box42/View/BoxContentsViewGroup.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,105 @@
import WebKit
import SnapKit

class BoxContentsViewGroup: NSView {
var webVC: WebViewController?
class BoxContentsViewGroup: NSView, WKUIDelegate {
// var webVC: WebViewController?
var preferencesVC = PreferencesViewController()
var scriptsVC = ScriptsViewController()

var webView: WKWebView!
static let shared = BoxContentsViewGroup()

init() {
super.init(frame: .zero)
webVC = WebViewController(nibName: nil, bundle: nil)
// webVC = WebViewController(nibName: nil, bundle: nil)
self.wantsLayer = true
self.layer?.cornerRadius = 20
self.layer?.masksToBounds = true
self.addSubview(webVC!.view)
webVC?.view.snp.makeConstraints { make in

// self.addSubview(webVC!.view)
// webVC?.view.snp.makeConstraints { make in
// make.edges.equalTo(self)
// }

let webConfiguration = WKWebViewConfiguration()
webView = WKWebView(frame: .zero, configuration: webConfiguration)
webView.uiDelegate = self
WebViewManager.shared.hostingWebView = webView
self.addSubview(webView)
webView.snp.makeConstraints { make in
make.edges.equalTo(self)
}

if let url = URL(string: "https://www.42box.kr") {
let request = URLRequest(url: url)
webView.load(request)
}

NotificationCenter.default.addObserver(self, selector:
#selector(goBack), name:
Notification.Name("goBack"), object:nil)

NotificationCenter.default.addObserver(self, selector:
#selector(goForward), name:
Notification.Name("goForward"), object:nil)

NotificationCenter.default.addObserver(self, selector:
#selector(reload), name:
Notification.Name("reload"), object:nil)
}

deinit {
// view controller가 해제될 때 observer도 제거합니다.
NotificationCenter.default.removeObserver(self)
}

@objc func goBack() {
if webView.canGoBack {
webView.goBack()
}
}

@objc func goForward() {
if webView.canGoForward {
webView.goForward()
}
}

@objc func reload() {
webView.reload()
}

func webView(_ webView: WKWebView,
createWebViewWith configuration: WKWebViewConfiguration,
for navigationAction: WKNavigationAction,
windowFeatures: WKWindowFeatures) -> WKWebView? {

if navigationAction.targetFrame == nil {
if let url = navigationAction.request.url {
if navigationAction.navigationType == .linkActivated {
webView.load(URLRequest(url: url))
return nil
}
}
}
return nil
}

func webView(_ webView: WKWebView, runOpenPanelWith parameters: WKOpenPanelParameters, initiatedByFrame frame: WKFrameInfo, completionHandler: @escaping ([URL]?) -> Void) {
let openPanel = NSOpenPanel()
openPanel.canChooseFiles = true
openPanel.allowsMultipleSelection = parameters.allowsMultipleSelection
openPanel.level = .popUpMenu

openPanel.begin { (result) in
if result == .OK {
completionHandler(openPanel.urls)
} else {
completionHandler(nil)
}
}
}


required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
Expand Down