Remove swipe on table feature

This commit is contained in:
1024jp 2023-12-22 17:40:28 +09:00
parent 010790b85a
commit 45bad587f8
13 changed files with 3 additions and 83 deletions

View File

@ -5,6 +5,7 @@
### Improvements
- [trivial] Deprecate the feature for themes/syntaxes settings to delete a setting by swiping on the setting name in the Settings.
- [non-AppStore ver.] Update Sparkle from 2.5.1 to 2.6.0.

View File

@ -337,37 +337,6 @@ final class AppearancePaneController: NSViewController, NSMenuItemValidation, NS
}
func tableView(_ tableView: NSTableView, rowActionsForRow row: Int, edge: NSTableView.RowActionEdge) -> [NSTableViewRowAction] {
guard edge == .trailing else { return [] }
// get swiped theme
let themeName = self.themeNames[row]
// do nothing on undeletable theme
guard
let state = ThemeManager.shared.state(of: themeName),
state.isCustomized
else { return [] }
if state.isRestorable {
return [NSTableViewRowAction(style: .regular,
title: String(localized: "Restore"),
handler: { [weak self] (_, _) in
self?.restoreTheme(name: themeName)
// finish swiped mode anyway
tableView.rowActionsVisible = false
})]
} else {
return [NSTableViewRowAction(style: .destructive,
title: String(localized: "Delete"),
handler: { [weak self] (_, _) in
self?.deleteTheme(name: themeName)
})]
}
}
// NSTextFieldDelegate
/// A theme name was edited.
@ -650,13 +619,7 @@ final class AppearancePaneController: NSViewController, NSMenuItemValidation, NS
let window = self.view.window!
Task {
let returnCode = await alert.beginSheetModal(for: window)
guard returnCode == .alertSecondButtonReturn else { // cancelled
// flush swipe action for in case if this deletion was invoked by swiping the theme name
self.themeTableView?.rowActionsVisible = false
return
}
guard await alert.beginSheetModal(for: window) == .alertSecondButtonReturn else { return }
do {
try ThemeManager.shared.removeSetting(name: name)

View File

@ -189,36 +189,6 @@ final class FormatPaneController: NSViewController, NSMenuItemValidation, NSTabl
}
/// Sets actions on swiping syntax name.
func tableView(_ tableView: NSTableView, rowActionsForRow row: Int, edge: NSTableView.RowActionEdge) -> [NSTableViewRowAction] {
guard edge == .trailing else { return [] }
// get swiped syntax
let syntaxName = self.syntaxNames[row]
// do nothing on undeletable syntax
guard let state = SyntaxManager.shared.state(of: syntaxName), state.isCustomized else { return [] }
if state.isBundled {
return [NSTableViewRowAction(style: .regular,
title: String(localized: "Restore"),
handler: { [weak self] (_, _) in
self?.restoreSyntax(name: syntaxName)
// finish swiped mode anyway
tableView.rowActionsVisible = false
})]
} else {
return [NSTableViewRowAction(style: .destructive,
title: String(localized: "Delete"),
handler: { [weak self] (_, _) in
self?.deleteSyntax(name: syntaxName)
})]
}
}
/// Validates when dragged items come to tableView.
func tableView(_ tableView: NSTableView, validateDrop info: any NSDraggingInfo, proposedRow row: Int, proposedDropOperation dropOperation: NSTableView.DropOperation) -> NSDragOperation {
@ -563,11 +533,7 @@ final class FormatPaneController: NSViewController, NSMenuItemValidation, NSTabl
let window = self.view.window!
Task {
guard await alert.beginSheetModal(for: window) == .alertSecondButtonReturn else { // cancelled
// flush swipe action for in case if this deletion was invoked by swiping the syntax name
self.syntaxTableView?.rowActionsVisible = false
return
}
guard await alert.beginSheetModal(for: window) == .alertSecondButtonReturn else { return }
do {
try SyntaxManager.shared.removeSetting(name: name)

View File

@ -31,7 +31,6 @@
"Start" = "Start";
"Restore Defaults" = "Standard wiederherstellen";
"Delete" = "Löschen";
"Restore" = "Wiederherstellen";
// words with symbols

View File

@ -31,7 +31,6 @@
"Start" = "Start";
"Restore Defaults" = "Restore Defaults";
"Delete" = "Delete";
"Restore" = "Restore";
// words with symbols

View File

@ -31,7 +31,6 @@
"Start" = "Iniciar";
"Restore Defaults" = "Restaurar valores por omisión";
"Delete" = "Eliminar";
"Restore" = "Restaurar";
// words with symbols

View File

@ -31,7 +31,6 @@
"Start" = "Démarrer";
"Restore Defaults" = "Réglages par défaut";
"Delete" = "Supprimer";
"Restore" = "Restaurer";
// words with symbols

View File

@ -31,7 +31,6 @@
"Start" = "Inizio";
"Restore Defaults" = "Ripristina default";
"Delete" = "Elimina";
"Restore" = "Ripristina";
// words with symbols

View File

@ -31,7 +31,6 @@
"Start" = "開始";
"Restore Defaults" = "デフォルトに戻す";
"Delete" = "削除";
"Restore" = "元に戻す";
// words with symbols

View File

@ -31,7 +31,6 @@
"Start" = "Iniciar";
"Restore Defaults" = "Restaurar Padrões";
"Delete" = "Apagar";
"Restore" = "Restaurar";
// words with symbols

View File

@ -31,7 +31,6 @@
"Start" = "Başlangıç";
"Restore Defaults" = "Saptanmışlara Dön";
"Delete" = "Sil";
"Restore" = "Geri Yükle";
// words with symbols

View File

@ -31,7 +31,6 @@
"Start" = "开始";
"Restore Defaults" = "恢复默认";
"Delete" = "删除";
"Restore" = "还原";
// words with symbols

View File

@ -31,7 +31,6 @@
"Start" = "開始";
"Restore Defaults" = "回復預設值";
"Delete" = "刪除";
"Restore" = "還原";
// words with symbols