Skip to content

Commit

Permalink
Merge pull request #169 from mumu-lhl/switch-show-not-found-words
Browse files Browse the repository at this point in the history
feat: add option to switch show not found words
  • Loading branch information
mumu-lhl authored Feb 7, 2025
2 parents fb47435 + 4624fa4 commit 2c018c1
Show file tree
Hide file tree
Showing 17 changed files with 227 additions and 93 deletions.
6 changes: 6 additions & 0 deletions lib/database/dictionary.dart
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ class DictionaryDatabase extends _$DictionaryDatabase {
..limit(20))
.get();
}

Future<bool> wordExist(String word) async {
final result =
await (select(dictionary)..where((u) => u.key.isValue(word))).get();
return result.isNotEmpty;
}
}

@TableIndex(name: "idx_data", columns: {#key})
Expand Down
3 changes: 3 additions & 0 deletions lib/dictionary.dart
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,9 @@ class Mdict {

final alias = await dictionaryListDao.getAlias(id);
title = alias ?? reader.header["Title"] ?? basename(path);
if (title.isEmpty) {
title = basename(path);
}

if (Platform.isWindows) {
await _startServer();
Expand Down
3 changes: 2 additions & 1 deletion lib/l10n/app_de.arb
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,6 @@
"notification": "Benachrichtigung",
"moreOptionsButton": "Mehr Optionen Schaltfläche",
"titleAlias": "Titel Alias",
"skipTaggedWord": "Markiertes Wort überspringen"
"skipTaggedWord": "Markiertes Wort überspringen",
"showNotFoundWord": "Nicht gefundene Wörter anzeigen"
}
4 changes: 3 additions & 1 deletion lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -123,5 +123,7 @@
"titleAlias": "Title Alias",
"@titleAlias": {},
"skipTaggedWord": "Skip Tagged Word",
"@skipTaggedWord": {}
"@skipTaggedWord": {},
"showNotFoundWord": "Show Not Found Word",
"@showNotFoundWord": {}
}
3 changes: 2 additions & 1 deletion lib/l10n/app_fa.arb
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,6 @@
"notification": "اعلان",
"moreOptionsButton": "دکمه گزینه‌های بیشتر",
"titleAlias": "عنوان مستعار",
"skipTaggedWord": "رد شدن از کلمه تگ شده"
"skipTaggedWord": "رد شدن از کلمه تگ شده",
"showNotFoundWord": "نمایش کلمات پیدا نشده"
}
3 changes: 2 additions & 1 deletion lib/l10n/app_nb.arb
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,6 @@
"notification": "Varsling",
"moreOptionsButton": "Flere alternativer-knapp",
"titleAlias": "Tittel Alias",
"skipTaggedWord": "Hopp over merket ord"
"skipTaggedWord": "Hopp over merket ord",
"showNotFoundWord": "Vis ord som ikke ble funnet"
}
3 changes: 2 additions & 1 deletion lib/l10n/app_ru.arb
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,6 @@
"notification": "Уведомление",
"moreOptionsButton": "Кнопка дополнительных параметров",
"titleAlias": "Псевдоним заголовка",
"skipTaggedWord": "Пропускать помеченное слово"
"skipTaggedWord": "Пропускать помеченное слово",
"showNotFoundWord": "Показывать ненайденные слова"
}
3 changes: 2 additions & 1 deletion lib/l10n/app_sc.arb
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,6 @@
"notification": "Notìfica",
"moreOptionsButton": "Butone de àteras optziones",
"titleAlias": "Alias de tìtulu",
"skipTaggedWord": "Iscarta sa প্যারau প্যারau ডে প্যারau"
"skipTaggedWord": "Iscarta sa প্যারau প্যারau ডে প্যারau",
"showNotFoundWord": "Mustra sas paràulas non atzapadas"
}
3 changes: 2 additions & 1 deletion lib/l10n/app_ta.arb
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,6 @@
"notification": "அறிவிப்பு",
"moreOptionsButton": "மேலும் விருப்பங்கள் பொத்தான்",
"titleAlias": "தலைப்பு மாற்றுப்பெயர்",
"skipTaggedWord": "குறிச்சொல்லிடப்பட்ட வார்த்தையைத் தவிர்க்கவும்"
"skipTaggedWord": "குறிச்சொல்லிடப்பட்ட வார்த்தையைத் தவிர்க்கவும்",
"showNotFoundWord": "காணப்படாத வார்த்தைகளைக் காட்டு"
}
3 changes: 2 additions & 1 deletion lib/l10n/app_zh.arb
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,6 @@
"notification": "通知",
"moreOptionsButton": "更多选项按钮",
"titleAlias": "标题别名",
"skipTaggedWord": "跳过有标签的单词"
"skipTaggedWord": "跳过有标签的单词",
"showNotFoundWord": "显示未找到的单词"
}
3 changes: 2 additions & 1 deletion lib/l10n/app_zh_HK.arb
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,6 @@
"notification": "通知",
"moreOptionsButton": "更多選項按鈕",
"titleAlias": "標題別名",
"skipTaggedWord": "跳過有標籤的字詞"
"skipTaggedWord": "跳過有標籤的字詞",
"showNotFoundWord": "顯示未找到的字詞"
}
3 changes: 2 additions & 1 deletion lib/l10n/app_zh_TW.arb
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,6 @@
"notification": "通知",
"moreOptionsButton": "更多選項按鈕",
"titleAlias": "標題別名",
"skipTaggedWord": "跳過有標籤的字詞"
"skipTaggedWord": "跳過有標籤的字詞",
"showNotFoundWord": "顯示未找到的字詞"
}
1 change: 1 addition & 0 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ void main() async {
"notification",
"showMoreOptionsButton",
"skipTaggedWord",
"showNotFound",
}));

int? groupId = prefs.getInt("currentDictionaryGroupId");
Expand Down
25 changes: 25 additions & 0 deletions lib/pages/main/settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ class SettingsScreen extends StatelessWidget {
const SearchbarLocationSelector(),
const DrawerIconSwitch(),
const MoreOptionsButtonSwitch(),
const NotFoundSwitch(),
const Divider(),
const AutoExport(),
const Export(),
Expand Down Expand Up @@ -358,6 +359,13 @@ class MoreOptionsButtonSwitch extends StatefulWidget {
_MoreOptionsButtonSwitchState();
}

class NotFoundSwitch extends StatefulWidget {
const NotFoundSwitch({super.key});

@override
State<NotFoundSwitch> createState() => _NotFoundSwitchState();
}

class _MoreOptionsButtonSwitchState extends State<MoreOptionsButtonSwitch> {
@override
Widget build(BuildContext context) {
Expand All @@ -376,6 +384,23 @@ class _MoreOptionsButtonSwitchState extends State<MoreOptionsButtonSwitch> {
}
}

class _NotFoundSwitchState extends State<NotFoundSwitch> {
@override
Widget build(BuildContext context) {
return SwitchListTile(
title: Text(AppLocalizations.of(context)!.showNotFoundWord),
value: settings.showNotFound,
onChanged: (value) async {
await prefs.setBool("showNotFound", value);
setState(() {
settings.showNotFound = value;
});
},
secondary: const Icon(Icons.book),
);
}
}

class _LanguageSelectorState extends State<LanguageSelector> {
@override
Widget build(BuildContext context) {
Expand Down
5 changes: 4 additions & 1 deletion lib/pages/manage_dictionaries/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,10 @@ class _ManageDictionariesState extends State<ManageDictionaries> {
);
},
child: CheckboxListTile(
title: Text(dictManager.dicts[dictionary.id]!.title),
title: Text(dictionary.alias ??
(dictManager.contain(dictionary.id)
? dictManager.dicts[dictionary.id]!.title
: basename(dictionary.path))),
value: dictManager.contain(dictionary.id),
secondary: ReorderableDragStartListener(
index: index,
Expand Down
Loading

0 comments on commit 2c018c1

Please sign in to comment.