Skip to content

Commit

Permalink
reset current page, single group and item (#142)
Browse files Browse the repository at this point in the history
  • Loading branch information
eagleoflqj authored Jun 4, 2024
1 parent 7ffac00 commit a146f8e
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 11 deletions.
Binary file modified assets/zh-Hans.lproj/Localizable.strings
Binary file not shown.
22 changes: 12 additions & 10 deletions src/config/navigationsplit.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,19 @@ struct ListConfigView: View {
buildView(config: config).padding([.leading, .trailing])
}
}.padding([.top], 1)
footer(
reset: {
// Reset only current page.
viewModel.selectedConfig?.resetToDefault()
},
apply: {
// Save all pages.
Fcitx.setConfig("fcitx://\(path)", viewModel.config?.encodeValue())
},
close: {
FcitxInputController.controllers[key]?.window?.performClose(_: nil)
})
}
footer(
reset: {
viewModel.config?.resetToDefault()
},
apply: {
Fcitx.setConfig("fcitx://\(path)", viewModel.config?.encodeValue())
},
close: {
FcitxInputController.controllers[key]?.window?.performClose(_: nil)
})
}
}

Expand Down
16 changes: 16 additions & 0 deletions src/config/optionviews.swift
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,14 @@ struct GroupOptionView: OptionView {
subLabel
.font(.title3)
.gridCellColumns(2)
.help(NSLocalizedString("Right click to reset this group.", comment: ""))
.contextMenu {
Button {
child.resetToDefault()
} label: {
Text("Reset to default")
}
}
}
GridRow {
GroupBox {
Expand All @@ -509,6 +517,14 @@ struct GroupOptionView: OptionView {
GridRow {
subLabel
.frame(minWidth: 100, maxWidth: 300, alignment: .trailing)
.help(NSLocalizedString("Right click to reset this item.", comment: ""))
.contextMenu {
Button {
child.resetToDefault()
} label: {
Text("Reset to default")
}
}
AnyView(subView)
}
}
Expand Down
10 changes: 9 additions & 1 deletion src/config/ui.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,15 @@ func footer(reset: @escaping () -> Void, apply: @escaping () -> Void, close: @es
Button {
reset()
} label: {
Text("Reset to default")
Text("Reset to default").tooltip(
NSLocalizedString(
"Reset current page. To reset a single item/group, right click on its label.", comment: ""
))
}
Button {
close()
} label: {
Text("Cancel")
}
Spacer()
Button {
Expand Down

0 comments on commit a146f8e

Please sign in to comment.