From 047fea3321688df81ff302da0dd1c266221a703b Mon Sep 17 00:00:00 2001 From: Matthias von Faber Date: Sun, 7 Jul 2024 17:15:58 +0200 Subject: [PATCH] Fix hit limit settings having no effect In qolibri 1.x, book and total hit limits were set via spinboxes on the toolbar. 185b6472bdc55a5ca49c52bf98b70a3b595257c6 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 --- src/configure.cpp | 16 ++++++++-------- src/configure.h | 4 ++-- src/mainwindow.cpp | 14 +++++++++----- src/model.cpp | 5 +++-- src/optiondialog.cpp | 8 ++++---- src/optiondialog.ui | 8 ++++---- translations/qolibri_ja_JP.ts | 4 ++-- 7 files changed, 32 insertions(+), 27 deletions(-) diff --git a/src/configure.cpp b/src/configure.cpp index 2f5ce6b..2c10f0f 100644 --- a/src/configure.cpp +++ b/src/configure.cpp @@ -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; @@ -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(); @@ -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()); @@ -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(); } diff --git a/src/configure.h b/src/configure.h index 3f765ab..6c72f86 100644 --- a/src/configure.h +++ b/src/configure.h @@ -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; diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 8955bdb..3984284 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -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(); + } } } diff --git a/src/model.cpp b/src/model.cpp index 3f3eb9b..fa27708 100644 --- a/src/model.cpp +++ b/src/model.cpp @@ -20,6 +20,7 @@ #include "model.h" #include "settings.h" +#include "configure.h" Model::Model() : bookMode(ModeDictionary) @@ -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; } diff --git a/src/optiondialog.cpp b/src/optiondialog.cpp index 07269a6..4eaee9a 100644 --- a/src/optiondialog.cpp +++ b/src/optiondialog.cpp @@ -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() @@ -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(); } diff --git a/src/optiondialog.ui b/src/optiondialog.ui index 98595de..626aa9a 100644 --- a/src/optiondialog.ui +++ b/src/optiondialog.ui @@ -253,7 +253,7 @@ - + 1000 @@ -273,7 +273,7 @@ - + 1000 @@ -326,8 +326,8 @@ userDefUrlEdit limitCharBox limitMenuBox - limitMaxBookBox - limitMaxTotalBox + limitBookBox + limitTotalBox diff --git a/translations/qolibri_ja_JP.ts b/translations/qolibri_ja_JP.ts index 6fd0ecf..2b3d179 100644 --- a/translations/qolibri_ja_JP.ts +++ b/translations/qolibri_ja_JP.ts @@ -798,12 +798,12 @@ Search Method: %2 Limit of hits per book - 最大検索数の限度(辞書) + 最大検索数(辞書) Limit of total hits - 最大検索数の限度 (全体) + 最大検索数(全体)