Skip to content

Commit

Permalink
feat: Settings window and placeholder for the serial port details (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
jbmorley authored Jun 21, 2024
1 parent b104c47 commit c110be3
Show file tree
Hide file tree
Showing 11 changed files with 214 additions and 9 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@
[submodule "dependencies/plptools"]
path = dependencies/plptools
url = [email protected]:jbmorley/plptools.git
[submodule "dependencies/interact"]
path = dependencies/interact
url = https://github.com/inseven/interact.git
53 changes: 49 additions & 4 deletions PsiMac.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
objects = {

/* Begin PBXBuildFile section */
D8184C472C253C59008FA79B /* ApplicationModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8184C462C253C59008FA79B /* ApplicationModel.swift */; };
D8184C4B2C253D73008FA79B /* SettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8184C4A2C253D73008FA79B /* SettingsView.swift */; };
D84964DA2C1BFCB600405656 /* PsiMacApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = D84964D92C1BFCB600405656 /* PsiMacApp.swift */; };
D84964DC2C1BFCB600405656 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D84964DB2C1BFCB600405656 /* ContentView.swift */; };
D84964DE2C1BFCB700405656 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = D84964DD2C1BFCB700405656 /* Assets.xcassets */; };
Expand Down Expand Up @@ -45,6 +47,9 @@
D8C080782C1D7C58003128AB /* DriveListResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8C080772C1D7C58003128AB /* DriveListResponse.swift */; };
D8C0807A2C1D7D8D003128AB /* PsiMacError.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8C080792C1D7D8D003128AB /* PsiMacError.swift */; };
D8C0807C2C1D7E79003128AB /* MachineTypeResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8C0807B2C1D7E79003128AB /* MachineTypeResponse.swift */; };
D8D3E79D2C25407E003E696D /* URL.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8D3E79C2C25407E003E696D /* URL.swift */; };
D8D3E79F2C2540D9003E696D /* Interact in Frameworks */ = {isa = PBXBuildFile; productRef = D8D3E79E2C2540D9003E696D /* Interact */; };
D8D3E7A12C25410E003E696D /* MainMenu.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8D3E7A02C25410E003E696D /* MainMenu.swift */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand All @@ -65,6 +70,8 @@
/* End PBXContainerItemProxy section */

/* Begin PBXFileReference section */
D8184C462C253C59008FA79B /* ApplicationModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ApplicationModel.swift; sourceTree = "<group>"; };
D8184C4A2C253D73008FA79B /* SettingsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsView.swift; sourceTree = "<group>"; };
D84964D62C1BFCB600405656 /* PsiMac.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = PsiMac.app; sourceTree = BUILT_PRODUCTS_DIR; };
D84964D92C1BFCB600405656 /* PsiMacApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PsiMacApp.swift; sourceTree = "<group>"; };
D84964DB2C1BFCB600405656 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -130,6 +137,8 @@
D8C080772C1D7C58003128AB /* DriveListResponse.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DriveListResponse.swift; sourceTree = "<group>"; };
D8C080792C1D7D8D003128AB /* PsiMacError.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PsiMacError.swift; sourceTree = "<group>"; };
D8C0807B2C1D7E79003128AB /* MachineTypeResponse.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MachineTypeResponse.swift; sourceTree = "<group>"; };
D8D3E79C2C25407E003E696D /* URL.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = URL.swift; sourceTree = "<group>"; };
D8D3E7A02C25410E003E696D /* MainMenu.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainMenu.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand All @@ -139,6 +148,7 @@
files = (
D84965352C1C30E500405656 /* DataStream in Frameworks */,
D84965062C1BFF1F00405656 /* Socket in Frameworks */,
D8D3E79F2C2540D9003E696D /* Interact in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -159,6 +169,25 @@
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
D8184C482C253C6F008FA79B /* Model */ = {
isa = PBXGroup;
children = (
D8184C462C253C59008FA79B /* ApplicationModel.swift */,
D8AD8B512C2378780063A613 /* Server.swift */,
);
path = Model;
sourceTree = "<group>";
};
D8184C492C253D62008FA79B /* Views */ = {
isa = PBXGroup;
children = (
D84964DB2C1BFCB600405656 /* ContentView.swift */,
D8D3E7A02C25410E003E696D /* MainMenu.swift */,
D8184C4A2C253D73008FA79B /* SettingsView.swift */,
);
path = Views;
sourceTree = "<group>";
};
D84964CD2C1BFCB600405656 = {
isa = PBXGroup;
children = (
Expand All @@ -183,21 +212,21 @@
D84964D82C1BFCB600405656 /* PsiMac */ = {
isa = PBXGroup;
children = (
D8AD8B532C2379A10063A613 /* Info.plist */,
D84964E22C1BFCB700405656 /* PsiMac.entitlements */,
D876E6142C22C2F6004A6881 /* PsiMacRelease.entitlements */,
D876E5D72C22B623004A6881 /* PsiMac-Bridging-Header.h */,
D84964DB2C1BFCB600405656 /* ContentView.swift */,
D8AD8B532C2379A10063A613 /* Info.plist */,
D84965392C1D077100405656 /* MachineType.swift */,
D84964D92C1BFCB600405656 /* PsiMacApp.swift */,
D8C080792C1D7D8D003128AB /* PsiMacError.swift */,
D8AD8B512C2378780063A613 /* Server.swift */,
D84964DD2C1BFCB700405656 /* Assets.xcassets */,
D849653D2C1D07AD00405656 /* Extensions */,
D84965362C1D06CA00405656 /* Messages */,
D8184C482C253C6F008FA79B /* Model */,
D8AD8B502C2377F60063A613 /* plptools */,
D84964DF2C1BFCB700405656 /* Preview Content */,
D8C080712C1D7C07003128AB /* Servers */,
D8184C492C253D62008FA79B /* Views */,
);
path = PsiMac;
sourceTree = "<group>";
Expand Down Expand Up @@ -250,9 +279,10 @@
D849653D2C1D07AD00405656 /* Extensions */ = {
isa = PBXGroup;
children = (
D849653E2C1D07B500405656 /* Socket.swift */,
D84965422C1D08AB00405656 /* DataReadStream.swift */,
D84965442C1D08C900405656 /* Packetable.swift */,
D849653E2C1D07B500405656 /* Socket.swift */,
D8D3E79C2C25407E003E696D /* URL.swift */,
);
path = Extensions;
sourceTree = "<group>";
Expand Down Expand Up @@ -345,6 +375,7 @@
packageProductDependencies = (
D84965052C1BFF1F00405656 /* Socket */,
D84965342C1C30E500405656 /* DataStream */,
D8D3E79E2C2540D9003E696D /* Interact */,
);
productName = PsiMac;
productReference = D84964D62C1BFCB600405656 /* PsiMac.app */;
Expand Down Expand Up @@ -422,6 +453,7 @@
packageReferences = (
D84965042C1BFF1F00405656 /* XCRemoteSwiftPackageReference "BlueSocket" */,
D84965322C1C30DB00405656 /* XCLocalSwiftPackageReference "dependencies/DataStream" */,
D8D3E79B2C25405A003E696D /* XCLocalSwiftPackageReference "dependencies/interact" */,
);
productRefGroup = D84964D72C1BFCB600405656 /* Products */;
projectDirPath = "";
Expand Down Expand Up @@ -472,6 +504,7 @@
D84965382C1D075400405656 /* MachineInfoResponse.swift in Sources */,
D84965452C1D08C900405656 /* Packetable.swift in Sources */,
D8C080702C1D7BE1003128AB /* OwnerInfoResponse.swift in Sources */,
D8D3E79D2C25407E003E696D /* URL.swift in Sources */,
D8C0807A2C1D7D8D003128AB /* PsiMacError.swift in Sources */,
D876E6022C22B7D5004A6881 /* linkchan.cc in Sources */,
D8C080762C1D7C43003128AB /* RPCS.swift in Sources */,
Expand All @@ -486,12 +519,15 @@
D876E60B2C22B88A004A6881 /* log.cc in Sources */,
D876E5F42C22B7C8004A6881 /* channel.cc in Sources */,
D849653A2C1D077100405656 /* MachineType.swift in Sources */,
D8184C4B2C253D73008FA79B /* SettingsView.swift in Sources */,
D8C0807C2C1D7E79003128AB /* MachineTypeResponse.swift in Sources */,
D8184C472C253C59008FA79B /* ApplicationModel.swift in Sources */,
D876E5F52C22B7C8004A6881 /* link.cc in Sources */,
D849653F2C1D07B500405656 /* Socket.swift in Sources */,
D8C080782C1D7C58003128AB /* DriveListResponse.swift in Sources */,
D876E6122C22BD96004A6881 /* main.cc in Sources */,
D876E5E82C22B76B004A6881 /* bufferstore.cc in Sources */,
D8D3E7A12C25410E003E696D /* MainMenu.swift in Sources */,
D876E6042C22B7D5004A6881 /* packet.cc in Sources */,
D876E5EE2C22B78B004A6881 /* iowatch.cc in Sources */,
D84964DC2C1BFCB600405656 /* ContentView.swift in Sources */,
Expand Down Expand Up @@ -837,6 +873,10 @@
isa = XCLocalSwiftPackageReference;
relativePath = dependencies/DataStream;
};
D8D3E79B2C25405A003E696D /* XCLocalSwiftPackageReference "dependencies/interact" */ = {
isa = XCLocalSwiftPackageReference;
relativePath = dependencies/interact;
};
/* End XCLocalSwiftPackageReference section */

/* Begin XCRemoteSwiftPackageReference section */
Expand All @@ -861,6 +901,11 @@
package = D84965322C1C30DB00405656 /* XCLocalSwiftPackageReference "dependencies/DataStream" */;
productName = DataStream;
};
D8D3E79E2C2540D9003E696D /* Interact */ = {
isa = XCSwiftPackageProductDependency;
package = D8D3E79B2C25405A003E696D /* XCLocalSwiftPackageReference "dependencies/interact" */;
productName = Interact;
};
/* End XCSwiftPackageProductDependency section */
};
rootObject = D84964CE2C1BFCB600405656 /* Project object */;
Expand Down
25 changes: 25 additions & 0 deletions PsiMac/Extensions/URL.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// PsiMac -- Psion connectivity for macOS
//
// Copyright (C) 2024 Jason Morley
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

import Foundation

extension URL {

static let settings = URL(string: "x-reconnect://settings")!

}
13 changes: 13 additions & 0 deletions PsiMac/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,19 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Viewer</string>
<key>CFBundleURLName</key>
<string>uk.co.jbmorley.reconnect.types.url</string>
<key>CFBundleURLSchemes</key>
<array>
<string>x-reconnect</string>
</array>
</dict>
</array>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
</dict>
Expand Down
42 changes: 42 additions & 0 deletions PsiMac/Model/ApplicationModel.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// PsiMac -- Psion connectivity for macOS
//
// Copyright (C) 2024 Jason Morley
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

import SwiftUI

import Interact

@Observable
class ApplicationModel {

enum SettingsKey: String {
case device
}

@MainActor var device: String {
didSet {
keyedDefaults.set(device, forKey: .device)
}
}

private let keyedDefaults = KeyedDefaults<SettingsKey>()

@MainActor init() {
device = keyedDefaults.string(forKey: .device, default: "")
}

}
4 changes: 2 additions & 2 deletions PsiMac/Server.swift → PsiMac/Model/Server.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ class Server {
}
}

let device = "/dev/tty.usbserial-AL00AYCG"
// let device = "/dev/tty.usbserial-A91MGK6M"
// let device = "/dev/tty.usbserial-AL00AYCG"
let device = "/dev/tty.usbserial-A91MGK6M"

// let log: UInt16 = 1 | 2 | 4 | 8 | 18 | 32 | 64
let log: UInt16 = 0
Expand Down
18 changes: 15 additions & 3 deletions PsiMac/PsiMacApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,22 @@

import SwiftUI

import Interact

@main
struct PsiMacApp: App {

@State var server = Server()
@State var applicationModel: ApplicationModel

init() {
self.applicationModel = ApplicationModel()
}

var body: some Scene {

MenuBarExtra {
Button("Connect") {

}
MainMenu()
} label: {
if server.isConnected {
Image("Connected")
Expand All @@ -37,5 +42,12 @@ struct PsiMacApp: App {
}
}

Window("Settings", id: "settings") {
SettingsView()
}
.environment(applicationModel)
.handlesExternalEvents(matching: [.settings])

}

}
File renamed without changes.
31 changes: 31 additions & 0 deletions PsiMac/Views/MainMenu.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// PsiMac -- Psion connectivity for macOS
//
// Copyright (C) 2024 Jason Morley
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

import SwiftUI

struct MainMenu: View {

@Environment(\.openURL) private var openURL

var body: some View {
Button("Settings") {
openURL(.settings)
}
}

}
33 changes: 33 additions & 0 deletions PsiMac/Views/SettingsView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// PsiMac -- Psion connectivity for macOS
//
// Copyright (C) 2024 Jason Morley
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

import SwiftUI

struct SettingsView: View {

@Environment(ApplicationModel.self) var applicationModel

var body: some View {
@Bindable var applicationModel = applicationModel
Form {
TextField("Serial Device", text: $applicationModel.device)
}
.formStyle(.grouped)
}

}
1 change: 1 addition & 0 deletions dependencies/interact
Submodule interact added at 42d74d

0 comments on commit c110be3

Please sign in to comment.