From f080b932f67d0b0f8201dc0a67d7070b2f6d4533 Mon Sep 17 00:00:00 2001 From: chanhihi Date: Thu, 31 Aug 2023 04:56:00 +0900 Subject: [PATCH 1/2] =?UTF-8?q?feat:=20storage=20view=EB=A5=BC=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80=ED=95=A9=EB=8B=88=EB=8B=A4.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Box42.xcodeproj/project.pbxproj | 4 + .../View/PreferencesTableView.swift | 16 ++- Box42/Preferences/View/StorageView.swift | 112 ++++++++++++++++++ 3 files changed, 128 insertions(+), 4 deletions(-) create mode 100644 Box42/Preferences/View/StorageView.swift diff --git a/Box42.xcodeproj/project.pbxproj b/Box42.xcodeproj/project.pbxproj index cf1c784..f62f3d7 100644 --- a/Box42.xcodeproj/project.pbxproj +++ b/Box42.xcodeproj/project.pbxproj @@ -97,6 +97,7 @@ DE9457312A9FB01400B0B768 /* PreferencesTableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE9457302A9FB01400B0B768 /* PreferencesTableView.swift */; }; DE9457342A9FB1D300B0B768 /* RequestAccessView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE9457332A9FB1D300B0B768 /* RequestAccessView.swift */; }; DE9457372A9FC0A800B0B768 /* SecurityScopedResourceAccess.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE9457362A9FC0A800B0B768 /* SecurityScopedResourceAccess.swift */; }; + DE94573D2A9FD33400B0B768 /* StorageView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE94573C2A9FD33400B0B768 /* StorageView.swift */; }; DE97CA692A9A6364001073DE /* PixelConversion+CGFloat.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE97CA682A9A6364001073DE /* PixelConversion+CGFloat.swift */; }; DE97CA792A9A6F6A001073DE /* QuickSlotHeaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE97CA782A9A6F6A001073DE /* QuickSlotHeaderView.swift */; }; DE97CA7C2A9A7199001073DE /* QuickSlotGroupView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE97CA7B2A9A7199001073DE /* QuickSlotGroupView.swift */; }; @@ -207,6 +208,7 @@ DE9457302A9FB01400B0B768 /* PreferencesTableView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PreferencesTableView.swift; sourceTree = ""; }; DE9457332A9FB1D300B0B768 /* RequestAccessView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RequestAccessView.swift; sourceTree = ""; }; DE9457362A9FC0A800B0B768 /* SecurityScopedResourceAccess.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SecurityScopedResourceAccess.swift; sourceTree = ""; }; + DE94573C2A9FD33400B0B768 /* StorageView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StorageView.swift; sourceTree = ""; }; DE97CA682A9A6364001073DE /* PixelConversion+CGFloat.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "PixelConversion+CGFloat.swift"; sourceTree = ""; }; DE97CA6E2A9A6EFC001073DE /* QuickSlotViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QuickSlotViewModel.swift; sourceTree = ""; }; DE97CA712A9A6F0D001073DE /* QuickSlotButtonModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QuickSlotButtonModel.swift; sourceTree = ""; }; @@ -525,6 +527,7 @@ DE78862C2A9D1ADE00FE21DD /* PreferencesCell.swift */, DE9457302A9FB01400B0B768 /* PreferencesTableView.swift */, DE9457332A9FB1D300B0B768 /* RequestAccessView.swift */, + DE94573C2A9FD33400B0B768 /* StorageView.swift */, ); path = View; sourceTree = ""; @@ -853,6 +856,7 @@ DE97CA862A9A7404001073DE /* QuickSlotViewModel.swift in Sources */, DE3FF3762A978AB8009C88EF /* WindowCloseButton.swift in Sources */, DE9457092A9E69D100B0B768 /* ScriptDescriptionsLabel.swift in Sources */, + DE94573D2A9FD33400B0B768 /* StorageView.swift in Sources */, DE9457282A9F6E4400B0B768 /* GetUserMeScripts.swift in Sources */, DE77BBD22A9E0AE8006CC98B /* WebViewUI.swift in Sources */, DE3FF3772A978AB8009C88EF /* WindowMinimizeButton.swift in Sources */, diff --git a/Box42/Preferences/View/PreferencesTableView.swift b/Box42/Preferences/View/PreferencesTableView.swift index e4b862a..2c0ec06 100644 --- a/Box42/Preferences/View/PreferencesTableView.swift +++ b/Box42/Preferences/View/PreferencesTableView.swift @@ -9,15 +9,18 @@ import AppKit import SnapKit import Combine -enum PreferencesCellList: Int, CaseIterable { - case requestAccessView = 1 - case cpu = 2 - case my = 3 +enum PreferencesCellList: CaseIterable { + case requestAccessView + case storage + case cpu + case my var height: CGFloat { switch self { case .requestAccessView: return 100.0 + case .storage: + return 300.0 case .cpu: return 40.0 case .my: @@ -28,6 +31,7 @@ enum PreferencesCellList: Int, CaseIterable { class PreferencesTableView: NSTableView { let requestAccessView = RequestAccessView() + let storageView = StorageView() func setup() { self.delegate = self @@ -37,6 +41,8 @@ class PreferencesTableView: NSTableView { column1.width = 100.0 column1.title = "Preferences" self.addTableColumn(column1) + + self.selectionHighlightStyle = .none } } @@ -48,6 +54,8 @@ extension PreferencesTableView: NSTableViewDelegate, NSTableViewDataSource { switch allCases[row] { case .requestAccessView: return requestAccessView + case .storage: + return StorageView() case .cpu: // Return the view for the CPU cell return NSView() // Placeholder diff --git a/Box42/Preferences/View/StorageView.swift b/Box42/Preferences/View/StorageView.swift new file mode 100644 index 0000000..77650b6 --- /dev/null +++ b/Box42/Preferences/View/StorageView.swift @@ -0,0 +1,112 @@ +// +// StorageView.swift +// Box42 +// +// Created by Chanhee Kim on 8/31/23. +// +import AppKit +import SnapKit + +class StorageView: NSView { + + var currentStorageTextField: NSTextField = NSTextField() + var remainingStorageTextField: NSTextField = NSTextField() + var totalStorageTextField: NSTextField = NSTextField() + var thresholdTextField: NSTextField = NSTextField() + var intervalTextField: NSTextField = NSTextField() + var executeScriptButton: NSButton = NSButton() + + override init(frame frameRect: NSRect) { + super.init(frame: frameRect) + + // Add subviews + addSubview(currentStorageTextField) + addSubview(remainingStorageTextField) + addSubview(totalStorageTextField) + addSubview(thresholdTextField) + addSubview(intervalTextField) + addSubview(executeScriptButton) + + // Initialize UI elements + initTextFields() + initButton() + + // Set constraints + setConstraints() + } + + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + func initTextFields() { + // Initialize textfields + currentStorageTextField.stringValue = "Current Storage: ?? GB" + remainingStorageTextField.stringValue = "Remaining Storage: ?? GB" + totalStorageTextField.stringValue = "Total Storage: ?? GB" + thresholdTextField.placeholderString = "Enter threshold (%)" + intervalTextField.placeholderString = "Enter interval (seconds)" + + [currentStorageTextField, remainingStorageTextField, totalStorageTextField, thresholdTextField, intervalTextField].forEach { textField in + textField.isEditable = false + textField.isBordered = false + textField.backgroundColor = NSColor.clear + } + + intervalTextField.isEditable = true + thresholdTextField.isEditable = true + } + + func initButton() { + executeScriptButton.title = "Run Script" + executeScriptButton.target = self + executeScriptButton.action = #selector(runScript(_:)) + } + + func setConstraints() { + // Use SnapKit to set constraints + currentStorageTextField.snp.makeConstraints { make in + make.top.leading.equalToSuperview().offset(20) + } + + remainingStorageTextField.snp.makeConstraints { make in + make.top.equalTo(currentStorageTextField.snp.bottom).offset(10) + make.leading.equalToSuperview().offset(20) + } + + totalStorageTextField.snp.makeConstraints { make in + make.top.equalTo(remainingStorageTextField.snp.bottom).offset(10) + make.leading.equalToSuperview().offset(20) + } + + thresholdTextField.snp.makeConstraints { make in + make.top.equalTo(totalStorageTextField.snp.bottom).offset(10) + make.leading.equalToSuperview().offset(20) + make.height.equalTo(30) + make.width.equalTo(100) + } + + intervalTextField.snp.makeConstraints { make in + make.top.equalTo(thresholdTextField.snp.bottom).offset(10) + make.leading.equalToSuperview().offset(20) + make.height.equalTo(30) + make.width.equalTo(100) + } + + executeScriptButton.snp.makeConstraints { make in + make.top.equalTo(intervalTextField.snp.bottom).offset(20) + make.leading.equalToSuperview().offset(20) + } + } + + @objc func runScript(_ sender: NSButton) { + // Logic to run script + } + + // Update storage information + func updateStorageInfo(current: String, remaining: String, total: String) { + currentStorageTextField.stringValue = "Current Storage: \(current) GB" + remainingStorageTextField.stringValue = "Remaining Storage: \(remaining) GB" + totalStorageTextField.stringValue = "Total Storage: \(total) GB" + } +} From 0b138330bd212d0a816f508e124f403e0ca06c77 Mon Sep 17 00:00:00 2001 From: chanhihi Date: Thu, 31 Aug 2023 04:57:41 +0900 Subject: [PATCH 2/2] =?UTF-8?q?chore:=20=ED=8C=8C=EC=9D=BC=EA=B5=AC?= =?UTF-8?q?=EC=A1=B0=EB=A5=BC=20=EB=B3=80=EA=B2=BD=ED=95=A9=EB=8B=88?= =?UTF-8?q?=EB=8B=A4.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Box42.xcodeproj/project.pbxproj | 24 +++++++++++++++---- ...yDown+BoxBaseContainerViewController.swift | 4 ++++ .../{ => Funtion}/RequestAccessView.swift | 0 .../View/{ => Funtion}/StorageView.swift | 0 .../View/{ => Table}/PreferencesCell.swift | 0 .../{ => Table}/PreferencesTableView.swift | 0 6 files changed, 24 insertions(+), 4 deletions(-) rename Box42/Preferences/View/{ => Funtion}/RequestAccessView.swift (100%) rename Box42/Preferences/View/{ => Funtion}/StorageView.swift (100%) rename Box42/Preferences/View/{ => Table}/PreferencesCell.swift (100%) rename Box42/Preferences/View/{ => Table}/PreferencesTableView.swift (100%) diff --git a/Box42.xcodeproj/project.pbxproj b/Box42.xcodeproj/project.pbxproj index f62f3d7..f2eb8dd 100644 --- a/Box42.xcodeproj/project.pbxproj +++ b/Box42.xcodeproj/project.pbxproj @@ -524,10 +524,8 @@ DE78862B2A9D1A9E00FE21DD /* View */ = { isa = PBXGroup; children = ( - DE78862C2A9D1ADE00FE21DD /* PreferencesCell.swift */, - DE9457302A9FB01400B0B768 /* PreferencesTableView.swift */, - DE9457332A9FB1D300B0B768 /* RequestAccessView.swift */, - DE94573C2A9FD33400B0B768 /* StorageView.swift */, + DE9457412A9FD69800B0B768 /* Table */, + DE94573F2A9FD68C00B0B768 /* Funtion */, ); path = View; sourceTree = ""; @@ -592,6 +590,24 @@ path = Table; sourceTree = ""; }; + DE94573F2A9FD68C00B0B768 /* Funtion */ = { + isa = PBXGroup; + children = ( + DE9457332A9FB1D300B0B768 /* RequestAccessView.swift */, + DE94573C2A9FD33400B0B768 /* StorageView.swift */, + ); + path = Funtion; + sourceTree = ""; + }; + DE9457412A9FD69800B0B768 /* Table */ = { + isa = PBXGroup; + children = ( + DE78862C2A9D1ADE00FE21DD /* PreferencesCell.swift */, + DE9457302A9FB01400B0B768 /* PreferencesTableView.swift */, + ); + path = Table; + sourceTree = ""; + }; DE98E8382A98D48700F8744A /* QuickSlot */ = { isa = PBXGroup; children = ( diff --git a/Box42/Main/keyDown+BoxBaseContainerViewController.swift b/Box42/Main/keyDown+BoxBaseContainerViewController.swift index f16fcfc..f73306a 100644 --- a/Box42/Main/keyDown+BoxBaseContainerViewController.swift +++ b/Box42/Main/keyDown+BoxBaseContainerViewController.swift @@ -22,6 +22,10 @@ extension BoxBaseContainerViewController { StorageConfig.shared.setPeriod(.period1s) } + if event.modifierFlags.contains(.command) && event.keyCode == 15 { + print("Cmd + R pressed, reloading...") + WebViewManager.shared.hostingWebView?.reload() + } if event.keyCode == 53 { // Escape 키의 keyCode는 53입니다. print("escape") diff --git a/Box42/Preferences/View/RequestAccessView.swift b/Box42/Preferences/View/Funtion/RequestAccessView.swift similarity index 100% rename from Box42/Preferences/View/RequestAccessView.swift rename to Box42/Preferences/View/Funtion/RequestAccessView.swift diff --git a/Box42/Preferences/View/StorageView.swift b/Box42/Preferences/View/Funtion/StorageView.swift similarity index 100% rename from Box42/Preferences/View/StorageView.swift rename to Box42/Preferences/View/Funtion/StorageView.swift diff --git a/Box42/Preferences/View/PreferencesCell.swift b/Box42/Preferences/View/Table/PreferencesCell.swift similarity index 100% rename from Box42/Preferences/View/PreferencesCell.swift rename to Box42/Preferences/View/Table/PreferencesCell.swift diff --git a/Box42/Preferences/View/PreferencesTableView.swift b/Box42/Preferences/View/Table/PreferencesTableView.swift similarity index 100% rename from Box42/Preferences/View/PreferencesTableView.swift rename to Box42/Preferences/View/Table/PreferencesTableView.swift