allow customization of default search text
https://forums.ankiweb.net/t/whats-the-default-search-when-browsing-now-also-how-do-i-choose-to-browse-current-deck/8922
This commit is contained in:
parent
d85f978b72
commit
114eec6585
@ -36,3 +36,5 @@ preferences-user-interface-size = User interface size
|
||||
preferences-when-adding-default-to-current-deck = When adding, default to current deck
|
||||
preferences-you-can-restore-backups-via-fileswitch = You can restore backups via File>Switch Profile.
|
||||
preferences-legacy-timezone-handling = Legacy timezone handling (buggy, but required for AnkiDroid <= 2.14)
|
||||
preferences-default-search-text = Default search text
|
||||
preferences-default-search-text-example = eg. 'deck:current '
|
||||
|
@ -333,10 +333,16 @@ class Browser(QMainWindow):
|
||||
self.onSearchActivated()
|
||||
|
||||
def _default_search(self, card: Optional[Card] = None) -> None:
|
||||
search = self.col.build_search_string(SearchNode(deck="current"))
|
||||
default = self.col.get_config_string(Config.String.DEFAULT_SEARCH_TEXT)
|
||||
if default.strip():
|
||||
search = default
|
||||
prompt = default
|
||||
else:
|
||||
search = self.col.build_search_string(SearchNode(deck="current"))
|
||||
prompt = ""
|
||||
if card is not None:
|
||||
search = gui_hooks.default_search(search, card)
|
||||
self.search_for(search, "")
|
||||
self.search_for(search, prompt)
|
||||
|
||||
def onReset(self) -> None:
|
||||
self.sidebar.refresh()
|
||||
|
@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>640</width>
|
||||
<height>419</height>
|
||||
<height>480</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@ -114,6 +114,20 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="search_text_label">
|
||||
<property name="text">
|
||||
<string>preferences_default_search_text</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="default_search_text">
|
||||
<property name="placeholderText">
|
||||
<string>preferences_default_search_text_example</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<item>
|
||||
@ -603,6 +617,7 @@
|
||||
<tabstop>nightMode</tabstop>
|
||||
<tabstop>useCurrent</tabstop>
|
||||
<tabstop>recording_driver</tabstop>
|
||||
<tabstop>default_search_text</tabstop>
|
||||
<tabstop>uiScale</tabstop>
|
||||
<tabstop>showEstimates</tabstop>
|
||||
<tabstop>showProgress</tabstop>
|
||||
|
@ -82,6 +82,7 @@ class Preferences(QDialog):
|
||||
)
|
||||
form.paste_strips_formatting.setChecked(editing.paste_strips_formatting)
|
||||
form.pastePNG.setChecked(editing.paste_images_as_png)
|
||||
form.default_search_text.setText(editing.default_search_text)
|
||||
|
||||
def update_collection(self) -> None:
|
||||
form = self.form
|
||||
@ -104,6 +105,7 @@ class Preferences(QDialog):
|
||||
editing.adding_defaults_to_current_deck = not form.useCurrent.currentIndex()
|
||||
editing.paste_images_as_png = self.form.pastePNG.isChecked()
|
||||
editing.paste_strips_formatting = self.form.paste_strips_formatting.isChecked()
|
||||
editing.default_search_text = self.form.default_search_text.text()
|
||||
|
||||
self.mw.col.set_preferences(self.prefs)
|
||||
self.mw.apply_collection_options()
|
||||
|
@ -1213,6 +1213,7 @@ message Preferences {
|
||||
bool adding_defaults_to_current_deck = 1;
|
||||
bool paste_images_as_png = 2;
|
||||
bool paste_strips_formatting = 3;
|
||||
string default_search_text = 4;
|
||||
}
|
||||
|
||||
Scheduling scheduling = 1;
|
||||
@ -1468,6 +1469,7 @@ message Config {
|
||||
enum Key {
|
||||
SET_DUE_BROWSER = 0;
|
||||
SET_DUE_REVIEWER = 1;
|
||||
DEFAULT_SEARCH_TEXT = 2;
|
||||
}
|
||||
Key key = 1;
|
||||
}
|
||||
|
@ -42,6 +42,7 @@ impl From<StringKeyProto> for StringKey {
|
||||
match k {
|
||||
StringKeyProto::SetDueBrowser => StringKey::SetDueBrowser,
|
||||
StringKeyProto::SetDueReviewer => StringKey::SetDueReviewer,
|
||||
StringKeyProto::DefaultSearchText => StringKey::DefaultSearchText,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ use crate::prelude::*;
|
||||
pub enum StringKey {
|
||||
SetDueBrowser,
|
||||
SetDueReviewer,
|
||||
DefaultSearchText,
|
||||
}
|
||||
|
||||
impl Collection {
|
||||
@ -17,7 +18,7 @@ impl Collection {
|
||||
let default = match key {
|
||||
StringKey::SetDueBrowser => "0",
|
||||
StringKey::SetDueReviewer => "1",
|
||||
// other => "",
|
||||
_other => "",
|
||||
};
|
||||
self.get_config_optional(key)
|
||||
.unwrap_or_else(|| default.to_string())
|
||||
|
@ -7,7 +7,7 @@ use crate::{
|
||||
Preferences,
|
||||
},
|
||||
collection::Collection,
|
||||
config::BoolKey,
|
||||
config::{BoolKey, StringKey},
|
||||
error::Result,
|
||||
prelude::*,
|
||||
scheduler::timing::local_minutes_west_for_stamp,
|
||||
@ -131,6 +131,7 @@ impl Collection {
|
||||
.get_config_bool(BoolKey::AddingDefaultsToCurrentDeck),
|
||||
paste_images_as_png: self.get_config_bool(BoolKey::PasteImagesAsPng),
|
||||
paste_strips_formatting: self.get_config_bool(BoolKey::PasteStripsFormatting),
|
||||
default_search_text: self.get_config_string(StringKey::DefaultSearchText),
|
||||
})
|
||||
}
|
||||
|
||||
@ -142,6 +143,7 @@ impl Collection {
|
||||
)?;
|
||||
self.set_config_bool_inner(BoolKey::PasteImagesAsPng, s.paste_images_as_png)?;
|
||||
self.set_config_bool_inner(BoolKey::PasteStripsFormatting, s.paste_strips_formatting)?;
|
||||
self.set_config_string_inner(StringKey::DefaultSearchText, &s.default_search_text)?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user