Skip to content

Commit

Permalink
small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Artikash committed Sep 26, 2019
1 parent 268da6e commit 54f60f7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion extensions/extrawindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ class ExtraWindow : public PrettyWindow
ExtraWindow() :
PrettyWindow("Extra Window")
{
ui.display->setTextFormat(Qt::PlainText);
setGeometry(settings.value(WINDOW, geometry()).toRect());

for (auto [name, default, slot] : Array<std::tuple<const char*, bool, void(ExtraWindow::*)(bool)>>{
Expand Down Expand Up @@ -261,9 +262,11 @@ class ExtraWindow : public PrettyWindow
UpdateDictionary();
definitions.clear();
definitionIndex = 0;
std::unordered_set<std::string_view> definitionSet;
for (QByteArray utf8term = term.left(200).toUtf8(); !utf8term.isEmpty(); utf8term.chop(1))
for (auto [it, end] = std::equal_range(dictionary.begin(), dictionary.end(), DictionaryEntry{ utf8term }); it != end; ++it)
definitions.push_back(QStringLiteral("<h3>%1 (%3/%4)</h3>%2").arg(utf8term, it->definition));
if (definitionSet.emplace(it->definition).second)
definitions.push_back(QStringLiteral("<h3>%1 (%3/%4)</h3>%2").arg(utf8term, it->definition));
for (int i = 0; i < definitions.size(); ++i) definitions[i] = definitions[i].arg(i + 1).arg(definitions.size());
ShowDefinition();
}
Expand Down
2 changes: 1 addition & 1 deletion text.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ const char* TOPMOST = u8"Always on top";
const char* DICTIONARY = u8"Dictionary";
const char* DICTIONARY_INSTRUCTIONS = u8R"(This file is used only for the "Dictionary" feature of the Extra Window extension.
It uses a custom format specific to Textractor and is not meant to be written manually.
You should look for a dictionary in this format online (https://artikash.github.io/?dictionary is a good place to start).
You should look for a dictionary in this format online (https://github.com/Artikash/Textractor-Dictionaries/releases is a good place to start).
Alternatively, if you're a programmer, you can write a script to convert a dictionary from another format with the info below.
Once you have a dictionary, to look up some text in Extra Window, select it. All matching definitions will be shown.
Definitions are formatted like this:|TERM|Hola|TERM|hola|TERM|Bonjour|TERM|bonjour|DEFINITION|hello|END|
Expand Down

0 comments on commit 54f60f7

Please sign in to comment.