Skip to content

Commit

Permalink
Fix hit limit settings having no effect
Browse files Browse the repository at this point in the history
In qolibri 1.x, book and total hit limits were set via spinboxes on the
toolbar. 185b647 removed these, and
with them any way to set the limits. The ones in the options set the
maximum limits for the toolbar and no longer had any effect (other than
confusing users).

This change rewires the book and total limit settings in the options to
the actual limits, rather than their obsolete maxima.

Fixes #61
  • Loading branch information
mvf committed Jul 7, 2024
1 parent 1be1759 commit 047fea3
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 27 deletions.
16 changes: 8 additions & 8 deletions src/configure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ const bool highlightMatch_Def = true;
const bool beepSound_Def = true;
const bool serverMode_Def = false;
const bool convertFullwidth_Def = true;
const int maxLimitBookHit_Def = 15000;
const int maxLimitTotalHit_Def = 15000;
const int limitBookHit_Def = 15000;
const int limitTotalHit_Def = 15000;
const int historyMax_Def = 500;
const int limitBrowserChar_Def = 1000000;
const int limitMenuHit_Def = 1000;
Expand Down Expand Up @@ -73,8 +73,8 @@ void Configure::load()
limitMenuHit = conf.value("limit_menu", limitMenuHit_Def).toInt();
indentOffset = conf.value("indent_offset", indentOffset_Def).toInt();
portNo = conf.value("port_no", portNo_Def).toInt();
maxLimitBookHit = conf.value("limt_book", maxLimitBookHit_Def).toInt();
maxLimitTotalHit = conf.value("limit_total", maxLimitTotalHit_Def).toInt();
limitBookHit = conf.value("limt_book", limitBookHit_Def).toInt();
limitTotalHit = conf.value("limit_total", limitTotalHit_Def).toInt();
browserFont.fromString(conf.value("browser_font", qApp->font()).toString());
dictionarySearchPath = conf.value("dictionary_search_path", QDir::homePath()).toString();

Expand Down Expand Up @@ -115,8 +115,8 @@ void Configure::save()
conf.setValue("userdef_url", userDefUrl);
conf.setValue("limit_char", limitBrowserChar);
conf.setValue("limit_menu", limitMenuHit);
conf.setValue("limt_book", maxLimitBookHit);
conf.setValue("limit_total", maxLimitTotalHit);
conf.setValue("limt_book", limitBookHit);
conf.setValue("limit_total", limitTotalHit);
conf.setValue("indent_offset", indentOffset);
conf.setValue("port_no", portNo);
conf.setValue("browser_font", browserFont.toString());
Expand Down Expand Up @@ -144,8 +144,8 @@ void Configure::setDefault()
limitMenuHit = limitMenuHit_Def;
indentOffset = indentOffset_Def;
portNo = portNo_Def;
maxLimitBookHit = maxLimitBookHit_Def;
maxLimitTotalHit = maxLimitTotalHit_Def;
limitBookHit = limitBookHit_Def;
limitTotalHit = limitTotalHit_Def;
browserFont = qApp->font();
}

4 changes: 2 additions & 2 deletions src/configure.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ class Configure
bool beepSound;
bool serverMode;
bool convertFullwidth;
int maxLimitBookHit;
int maxLimitTotalHit;
int limitBookHit;
int limitTotalHit;
int historyMax;
int limitBrowserChar;
int limitMenuHit;
Expand Down
14 changes: 9 additions & 5 deletions src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1128,17 +1128,21 @@ void MainWindow::clearCache()
void MainWindow::setConfig()
{
OptionDialog dlg(this);
auto *const cow = ClipboardOptionsWidget::maybeCreate(this);
auto *const cow = ClipboardOptionsWidget::maybeCreate(&dlg);
if (cow) {
cow->setMode(watchClipboardMode);
cow->setRaiseWindowEnabled(watchClipboardRaiseWindow);
cow->setSelectionDelay(watchClipboardSelectionDelay);
dlg.insertTab(1, cow, tr("Clipboard"));
}
if (dlg.exec() == QDialog::Accepted && cow) {
watchClipboardMode = cow->mode();
watchClipboardRaiseWindow = cow->isRaiseWindowEnabled();
watchClipboardSelectionDelay = cow->selectionDelay();
if (dlg.exec() == QDialog::Accepted) {
model->setLimitBook(CONF->limitBookHit);
model->setLimitTotal(CONF->limitTotalHit);
if (cow) {
watchClipboardMode = cow->mode();
watchClipboardRaiseWindow = cow->isRaiseWindowEnabled();
watchClipboardSelectionDelay = cow->selectionDelay();
}
}
}

Expand Down
5 changes: 3 additions & 2 deletions src/model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

#include "model.h"
#include "settings.h"
#include "configure.h"

Model::Model()
: bookMode(ModeDictionary)
Expand Down Expand Up @@ -336,8 +337,8 @@ SearchMethod Model::readMethodSetting(const QSettings &set)
ExactWordSearch).toInt();
m.logic = (NarrowingLogic)set.value("narrowing_logic",
LogicAND).toInt();
m.limitBook = set.value("limit_book", 100).toInt();
m.limitTotal = set.value("limit_total", 1000).toInt();
m.limitBook = set.value("limit_book", CONF->limitBookHit).toInt();
m.limitTotal = set.value("limit_total", CONF->limitTotalHit).toInt();

return m;
}
Expand Down
8 changes: 4 additions & 4 deletions src/optiondialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ void OptionDialog::reset()
userDefUrlEdit->setText(d->userDefUrl);
limitCharBox->setValue(d->limitBrowserChar);
limitMenuBox->setValue(d->limitMenuHit);
limitMaxBookBox->setValue(d->maxLimitBookHit);
limitMaxTotalBox->setValue(d->maxLimitTotalHit);
limitBookBox->setValue(d->limitBookHit);
limitTotalBox->setValue(d->limitTotalHit);
}

void OptionDialog::accept()
Expand All @@ -81,6 +81,6 @@ void OptionDialog::accept()
d->userDefUrl = userDefUrlEdit->text();
d->limitBrowserChar = limitCharBox->value();
d->limitMenuHit = limitMenuBox->value();
d->maxLimitBookHit = limitMaxBookBox->value();
d->maxLimitTotalHit = limitMaxTotalBox->value();
d->limitBookHit = limitBookBox->value();
d->limitTotalHit = limitTotalBox->value();
}
8 changes: 4 additions & 4 deletions src/optiondialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@
</widget>
</item>
<item row="2" column="1">
<widget class="QSpinBox" name="limitMaxBookBox">
<widget class="QSpinBox" name="limitBookBox">
<property name="minimum">
<number>1000</number>
</property>
Expand All @@ -273,7 +273,7 @@
</widget>
</item>
<item row="3" column="1">
<widget class="QSpinBox" name="limitMaxTotalBox">
<widget class="QSpinBox" name="limitTotalBox">
<property name="minimum">
<number>1000</number>
</property>
Expand Down Expand Up @@ -326,8 +326,8 @@
<tabstop>userDefUrlEdit</tabstop>
<tabstop>limitCharBox</tabstop>
<tabstop>limitMenuBox</tabstop>
<tabstop>limitMaxBookBox</tabstop>
<tabstop>limitMaxTotalBox</tabstop>
<tabstop>limitBookBox</tabstop>
<tabstop>limitTotalBox</tabstop>
</tabstops>
<resources/>
<connections>
Expand Down
4 changes: 2 additions & 2 deletions translations/qolibri_ja_JP.ts
Original file line number Diff line number Diff line change
Expand Up @@ -798,12 +798,12 @@ Search Method: %2</source>
<message>
<location filename="optiondialog.ui" line="223"/>
<source>Limit of hits per book</source>
<translation>最大検索数の限度(辞書)</translation>
<translation>最大検索数(辞書)</translation>
</message>
<message>
<location filename="optiondialog.ui" line="243"/>
<source>Limit of total hits</source>
<translation>最大検索数の限度 (全体)</translation>
<translation>最大検索数(全体)</translation>
</message>
<message>
<location filename="optiondialog.ui" line="263"/>
Expand Down

0 comments on commit 047fea3

Please sign in to comment.