Skip to content

Commit

Permalink
Use placeholder text to display when lookups failed
Browse files Browse the repository at this point in the history
  • Loading branch information
1over137 committed Mar 23, 2024
1 parent 69ff4c0 commit 4e8441f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
4 changes: 0 additions & 4 deletions vocabsieve/ui/main_window_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,6 @@ def initWidgets(self) -> None:
"allow_editing",
True,
type=bool)))
self.definition.setPlaceholderText(
f'Look up a word by double clicking it or by selecting it, then pressing {MOD}+D.\nUse Shift-{MOD}+D to look up the word without lemmatization.')
self.definition2.setPlaceholderText(
f'Look up a word by double clicking it or by selecting it, then pressing {MOD}+D.\nUse Shift-{MOD}+D to look up the word without lemmatization.')

self.image_viewer = QLabel("<center><b>&lt;No image&gt;</center>")
self.image_viewer.setScaledContents(True)
Expand Down
10 changes: 10 additions & 0 deletions vocabsieve/ui/multi_definition_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
from loguru import logger
from typing import Optional
import time
from ..global_names import MOD


DEFAULT_PLACEHOLDER_TEXT = f"Look up a word by double clicking it or by selecting it, then pressing {MOD}+D.\nUse Shift-{MOD}+D to look up the word without lemmatization."
NEXT_DEFINITION_SCROLL_COUNT_TRANSITION_THRESHOLD = 3


Expand Down Expand Up @@ -120,6 +123,11 @@ def wheelEvent(self, event):

def setSourceGroup(self, sources: list[DictionarySource]):
self.sources = sources
if not self.sources:
self.setPlaceholderText(
"Hint: No sources are set, so no lookups can be performed. Go to Configure -> Sources to add some sources.")
else:
self.setPlaceholderText(DEFAULT_PLACEHOLDER_TEXT)

def lookup(self, word: str, no_lemma: bool, rules: list[tuple[str, str]]):
self.reset()
Expand Down Expand Up @@ -171,6 +179,8 @@ def populateDefinitions(self):
self.word_widget.setText(self.current_target)
self.setPlaceholderText("No definitions found for \"" + self.current_target
+ "\". You can still type in a definition manually to add to Anki.")
else:
self.setPlaceholderText(DEFAULT_PLACEHOLDER_TEXT)
self.currentIndex = 0
self.updateIndex()

Expand Down

0 comments on commit 4e8441f

Please sign in to comment.