add shortcuts

This commit is contained in:
wgh19
2024-06-12 19:17:32 +08:00
parent 70da478044
commit 7c8fabf52c
6 changed files with 39 additions and 9 deletions

View File

@@ -32,6 +32,8 @@ class _Appdata {
LogicalKeyboardKey.enter.keyId,
LogicalKeyboardKey.keyD.keyId,
LogicalKeyboardKey.keyF.keyId,
LogicalKeyboardKey.keyC.keyId,
LogicalKeyboardKey.keyG.keyId,
],
"showOriginalImage": false,
};
@@ -64,7 +66,7 @@ class _Appdata {
final file = File("${App.dataPath}/account.json");
if (file.existsSync()) {
var json = jsonDecode(await file.readAsString());
if(json != null) {
if (json != null) {
account = Account.fromJson(json);
}
}
@@ -73,7 +75,15 @@ class _Appdata {
var json = jsonDecode(await settingsFile.readAsString());
for (var key in json.keys) {
if (json[key] != null) {
settings[key] = json[key];
if (json[key] is List && settings[key] is List) {
for (int i = 0;
i < json[key].length && i < settings[key].length;
i++) {
settings[key][i] = json[key][i];
}
} else {
settings[key] = json[key];
}
}
}
}

View File

@@ -40,12 +40,11 @@ class KeyEventListenerState extends State<KeyEventListener> {
focusNode: focusNode,
autofocus: true,
onKeyEvent: (node, event) {
if (event is! KeyUpEvent) return KeyEventResult.ignored;
if (event is! KeyUpEvent) return KeyEventResult.handled;
if (event.logicalKey == LogicalKeyboardKey.escape) {
if (App.rootNavigatorKey.currentState?.canPop() ?? false) {
App.rootNavigatorKey.currentState?.pop();
}
if (App.mainNavigatorKey?.currentState?.canPop() ?? false) {
} else if (App.mainNavigatorKey?.currentState?.canPop() ?? false) {
App.mainNavigatorKey?.currentState?.pop();
}
return KeyEventResult.handled;

View File

@@ -62,12 +62,19 @@ class HistoryManager {
illust.width,
illust.height
]);
if(length > 1000) {
_db.execute('''
delete from history where id in (
select id from history order by time asc limit 100
)
''');
}
}
List<IllustHistory> getHistories(int page) {
var rows = _db.select('''
select * from history
limit 20 offset ?
select * from history order by time desc
limit 20 offset ?
''', [(page - 1) * 20]);
List<IllustHistory> res = [];
for (var row in rows) {

View File

@@ -319,6 +319,14 @@ class _IllustPageState extends State<IllustPage> {
_bottomBarController.download();
case 6:
_bottomBarController.follow();
case 7:
if (ModalRoute.of(context)?.isCurrent ?? true) {
CommentsPage.show(context, widget.illust.id.toString());
} else {
context.pop();
}
case 8:
openImage(0);
}
}

View File

@@ -592,6 +592,8 @@ class _ShortcutsSettingsState extends State<ShortcutsSettings> {
"Add to favorites",
"Download",
"Follow the artist",
"Show comments",
"Show original image"
];
@override