Skip to content
This repository was archived by the owner on May 11, 2025. It is now read-only.

Commit 674f4bd

Browse files
committed
Add more settings and view fixes
1 parent 31ace8e commit 674f4bd

12 files changed

Lines changed: 295 additions & 311 deletions

File tree

Whisky.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
6EFDF6662AAE303300EF622F /* Icons.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 6EFDF6652AAE303300EF622F /* Icons.xcassets */; };
5353
8C2AEFC82AED79B700CB568F /* WhiskyKit in Frameworks */ = {isa = PBXBuildFile; productRef = 8C2AEFC72AED79B700CB568F /* WhiskyKit */; };
5454
8C2AEFCA2AED79CD00CB568F /* WhiskyKit in Frameworks */ = {isa = PBXBuildFile; productRef = 8C2AEFC92AED79CD00CB568F /* WhiskyKit */; };
55+
8C73E1342AF472FC00B6FB45 /* ProgramMenuView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8C73E1332AF472FC00B6FB45 /* ProgramMenuView.swift */; };
5556
8CB681E52AED7C6F0018D319 /* WhiskyKit in Resources */ = {isa = PBXBuildFile; fileRef = 8CB681E42AED7C6F0018D319 /* WhiskyKit */; };
5657
8CB681E72AED7CD00018D319 /* WhiskyKit in Frameworks */ = {isa = PBXBuildFile; productRef = 8CB681E62AED7CD00018D319 /* WhiskyKit */; };
5758
AB66A8642A4195B10006D238 /* Rosetta2.swift in Sources */ = {isa = PBXBuildFile; fileRef = AB66A8632A4195B10006D238 /* Rosetta2.swift */; };
@@ -147,6 +148,7 @@
147148
6EFDF6522AAE2DA800EF622F /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
148149
6EFDF6532AAE2DA800EF622F /* WhiskyThumbnail.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = WhiskyThumbnail.entitlements; sourceTree = "<group>"; };
149150
6EFDF6652AAE303300EF622F /* Icons.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Icons.xcassets; sourceTree = "<group>"; };
151+
8C73E1332AF472FC00B6FB45 /* ProgramMenuView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProgramMenuView.swift; sourceTree = "<group>"; };
150152
8CB681E42AED7C6F0018D319 /* WhiskyKit */ = {isa = PBXFileReference; lastKnownFileType = wrapper; path = WhiskyKit; sourceTree = "<group>"; };
151153
AB66A8632A4195B10006D238 /* Rosetta2.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Rosetta2.swift; sourceTree = "<group>"; };
152154
EEA5A2452A31DD65008274AE /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
@@ -211,6 +213,7 @@
211213
6E355E5929D782B2002D83BE /* ProgramsView.swift */,
212214
6E355E5D29D7D85D002D83BE /* ProgramView.swift */,
213215
6E17B6482AF4118F00831173 /* EnvironmentArgView.swift */,
216+
8C73E1332AF472FC00B6FB45 /* ProgramMenuView.swift */,
214217
);
215218
path = Programs;
216219
sourceTree = "<group>";
@@ -580,6 +583,7 @@
580583
6E17B6462AF3FDC100831173 /* PinsView.swift in Sources */,
581584
6E064B1429DD331F00D9A2D2 /* SparkleView.swift in Sources */,
582585
6E40495629CCA19C006E3F1B /* WhiskyApp.swift in Sources */,
586+
8C73E1342AF472FC00B6FB45 /* ProgramMenuView.swift in Sources */,
583587
6E50D98329CD6066008C39F6 /* BottleVM.swift in Sources */,
584588
6E6915452A3265BB0085BBB7 /* Logger.swift in Sources */,
585589
6E49E0212AECB7DB00009CAC /* SettingsView.swift in Sources */,

Whisky/Localizable.xcstrings

Lines changed: 50 additions & 118 deletions
Original file line numberDiff line numberDiff line change
@@ -945,6 +945,16 @@
945945
}
946946
}
947947
},
948+
"button.pin" : {
949+
"localizations" : {
950+
"en" : {
951+
"stringUnit" : {
952+
"state" : "translated",
953+
"value" : "Pin"
954+
}
955+
}
956+
}
957+
},
948958
"button.refresh" : {
949959
"localizations" : {
950960
"da" : {
@@ -2125,6 +2135,16 @@
21252135
}
21262136
}
21272137
},
2138+
"button.unpin" : {
2139+
"localizations" : {
2140+
"en" : {
2141+
"stringUnit" : {
2142+
"state" : "translated",
2143+
"value" : "Unpin"
2144+
}
2145+
}
2146+
}
2147+
},
21282148
"button.winetricks" : {
21292149
"localizations" : {
21302150
"da" : {
@@ -8262,124 +8282,6 @@
82628282
}
82638283
}
82648284
},
8265-
"pin.unpin" : {
8266-
"localizations" : {
8267-
"da" : {
8268-
"stringUnit" : {
8269-
"state" : "translated",
8270-
"value" : "Unpin Program"
8271-
}
8272-
},
8273-
"de" : {
8274-
"stringUnit" : {
8275-
"state" : "translated",
8276-
"value" : "Programm lösen"
8277-
}
8278-
},
8279-
"en" : {
8280-
"stringUnit" : {
8281-
"state" : "translated",
8282-
"value" : "Unpin Program"
8283-
}
8284-
},
8285-
"es" : {
8286-
"stringUnit" : {
8287-
"state" : "translated",
8288-
"value" : "Unpin Program"
8289-
}
8290-
},
8291-
"fi" : {
8292-
"stringUnit" : {
8293-
"state" : "translated",
8294-
"value" : "Poista ohjelman kiinnitys"
8295-
}
8296-
},
8297-
"fr" : {
8298-
"stringUnit" : {
8299-
"state" : "translated",
8300-
"value" : "Unpin Program"
8301-
}
8302-
},
8303-
"it" : {
8304-
"stringUnit" : {
8305-
"state" : "translated",
8306-
"value" : "Sblocca Programma"
8307-
}
8308-
},
8309-
"ja" : {
8310-
"stringUnit" : {
8311-
"state" : "translated",
8312-
"value" : "ピン留めを解除"
8313-
}
8314-
},
8315-
"ko" : {
8316-
"stringUnit" : {
8317-
"state" : "translated",
8318-
"value" : "프로그램 고정 해제"
8319-
}
8320-
},
8321-
"nl" : {
8322-
"stringUnit" : {
8323-
"state" : "translated",
8324-
"value" : "Pin verwijderen"
8325-
}
8326-
},
8327-
"pl" : {
8328-
"stringUnit" : {
8329-
"state" : "translated",
8330-
"value" : "Odepnij program"
8331-
}
8332-
},
8333-
"pt-BR" : {
8334-
"stringUnit" : {
8335-
"state" : "translated",
8336-
"value" : "Desafixar programa"
8337-
}
8338-
},
8339-
"pt-PT" : {
8340-
"stringUnit" : {
8341-
"state" : "translated",
8342-
"value" : "Unpin Program"
8343-
}
8344-
},
8345-
"ru" : {
8346-
"stringUnit" : {
8347-
"state" : "translated",
8348-
"value" : "Открепить программу"
8349-
}
8350-
},
8351-
"tr" : {
8352-
"stringUnit" : {
8353-
"state" : "translated",
8354-
"value" : "Sabitlenmiş Programı Kaldır"
8355-
}
8356-
},
8357-
"uk" : {
8358-
"stringUnit" : {
8359-
"state" : "translated",
8360-
"value" : "Відкріпити програму"
8361-
}
8362-
},
8363-
"vi" : {
8364-
"stringUnit" : {
8365-
"state" : "translated",
8366-
"value" : "Unpin Program"
8367-
}
8368-
},
8369-
"zh-Hans" : {
8370-
"stringUnit" : {
8371-
"state" : "translated",
8372-
"value" : "取消固定此应用"
8373-
}
8374-
},
8375-
"zh-Hant" : {
8376-
"stringUnit" : {
8377-
"state" : "translated",
8378-
"value" : "取消程式釘選"
8379-
}
8380-
}
8381-
}
8382-
},
83838285
"program.add.blocklist" : {
83848286
"localizations" : {
83858287
"da" : {
@@ -8498,6 +8400,16 @@
84988400
}
84998401
}
85008402
},
8403+
"program.add.selected.blocklist" : {
8404+
"localizations" : {
8405+
"en" : {
8406+
"stringUnit" : {
8407+
"state" : "translated",
8408+
"value" : "Add Selected to Blocklist"
8409+
}
8410+
}
8411+
}
8412+
},
85018413
"program.args" : {
85028414
"localizations" : {
85038415
"da" : {
@@ -9088,6 +9000,26 @@
90889000
}
90899001
}
90909002
},
9003+
"program.remove.selected.blocklist" : {
9004+
"localizations" : {
9005+
"en" : {
9006+
"stringUnit" : {
9007+
"state" : "translated",
9008+
"value" : "Remove Selected from Blocklist"
9009+
}
9010+
}
9011+
}
9012+
},
9013+
"program.settings" : {
9014+
"localizations" : {
9015+
"en" : {
9016+
"stringUnit" : {
9017+
"state" : "translated",
9018+
"value" : "Settings"
9019+
}
9020+
}
9021+
}
9022+
},
90919023
"program.title" : {
90929024
"localizations" : {
90939025
"da" : {

Whisky/Models/Program.swift

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -90,18 +90,4 @@ extension Program {
9090
}
9191
}
9292
}
93-
94-
func togglePinned() -> Bool {
95-
if pinned {
96-
bottle.settings.pins.removeAll(where: { $0.url == url })
97-
pinned = false
98-
} else {
99-
bottle.settings.pins.append(PinnedProgram(name: name
100-
.replacingOccurrences(of: ".exe", with: ""),
101-
url: url))
102-
pinned = true
103-
}
104-
105-
return pinned
106-
}
10793
}

Whisky/Views/Bottle/BottleView.swift

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -26,27 +26,23 @@ enum BottleStage {
2626
}
2727

2828
struct BottleView: View {
29-
@Binding var bottle: Bottle
29+
@ObservedObject var bottle: Bottle
3030
@State private var path = NavigationPath()
3131
@State var programLoading: Bool = false
32-
@State var pins: [PinnedProgram] = []
33-
// We don't actually care about the value
34-
// This just provides a way to trigger a refresh
35-
@State var loadStartMenu: Bool = false
3632
@State var showWinetricksSheet: Bool = false
3733

3834
private let gridLayout = [GridItem(.adaptive(minimum: 100, maximum: .infinity))]
3935

4036
var body: some View {
4137
NavigationStack(path: $path) {
4238
ScrollView {
43-
if pins.count > 0 {
39+
let pinnedPrograms = bottle.programs.pinned
40+
if pinnedPrograms.count > 0 {
4441
LazyVGrid(columns: gridLayout, alignment: .center) {
45-
ForEach(pins, id: \.url) { pin in
46-
PinsView(bottle: bottle,
47-
pin: pin,
48-
loadStartMenu: $loadStartMenu,
49-
path: $path)
42+
ForEach(bottle.settings.pins, id: \.url) { pin in
43+
PinsView(
44+
bottle: bottle, pin: pin, path: $path
45+
)
5046
}
5147
}
5248
.padding()
@@ -72,12 +68,6 @@ struct BottleView: View {
7268
}
7369
}
7470
.formStyle(.grouped)
75-
.onAppear {
76-
updateStartMenu()
77-
}
78-
.onChange(of: loadStartMenu) {
79-
updateStartMenu()
80-
}
8171
}
8272
.bottomBar {
8373
HStack {
@@ -130,19 +120,27 @@ struct BottleView: View {
130120
}
131121
.padding()
132122
}
123+
.onAppear {
124+
updateStartMenu()
125+
}
133126
.disabled(!bottle.isActive)
134127
.navigationTitle(bottle.settings.name)
135128
.sheet(isPresented: $showWinetricksSheet) {
136129
WinetricksView(bottle: bottle)
137130
}
131+
.onChange(of: bottle.settings, { oldValue, newValue in
132+
guard oldValue != newValue else { return }
133+
// Trigger a reload
134+
BottleVM.shared.bottles = BottleVM.shared.bottles
135+
})
138136
.navigationDestination(for: BottleStage.self) { stage in
139137
switch stage {
140138
case .config:
141-
ConfigView(bottle: $bottle)
139+
ConfigView(bottle: bottle)
142140
case .programs:
143-
ProgramsView(bottle: bottle,
144-
reloadStartMenu: $loadStartMenu,
145-
path: $path)
141+
ProgramsView(
142+
bottle: bottle, path: $path
143+
)
146144
}
147145
}
148146
.navigationDestination(for: Program.self) { program in
@@ -151,7 +149,7 @@ struct BottleView: View {
151149
}
152150
}
153151

154-
func updateStartMenu() {
152+
private func updateStartMenu() {
155153
bottle.programs = bottle.updateInstalledPrograms()
156154
let startMenuPrograms = bottle.getStartMenuPrograms()
157155
for startMenuProgram in startMenuPrograms {
@@ -166,8 +164,6 @@ struct BottleView: View {
166164
}
167165
}
168166
}
169-
170-
pins = bottle.settings.pins
171167
}
172168
}
173169

0 commit comments

Comments
 (0)