GUI code: added some marker comment to ease semi-automate adding a pref variable

This commit is contained in:
Jean-Francois Dockes 2022-03-09 20:43:40 +01:00
parent f201f5ee1b
commit 53b8b7e237
4 changed files with 50 additions and 48 deletions

View File

@ -289,6 +289,8 @@ void rwSettings(bool writing)
SETTING_RW(prefs.showTrayIcon, "/Recoll/prefs/showTrayIcon", Bool, false); SETTING_RW(prefs.showTrayIcon, "/Recoll/prefs/showTrayIcon", Bool, false);
SETTING_RW(prefs.closeToTray, "/Recoll/prefs/closeToTray", Bool, false); SETTING_RW(prefs.closeToTray, "/Recoll/prefs/closeToTray", Bool, false);
SETTING_RW(prefs.trayMessages, "/Recoll/prefs/trayMessages", Bool, false); SETTING_RW(prefs.trayMessages, "/Recoll/prefs/trayMessages", Bool, false);
/*INSERTHERE*/
// See qxtconfirmationmessage. Needs to be -1 for the dialog to show. // See qxtconfirmationmessage. Needs to be -1 for the dialog to show.
SETTING_RW(prefs.showTempFileWarning, "Recoll/prefs/showTempFileWarning", Int, -1); SETTING_RW(prefs.showTempFileWarning, "Recoll/prefs/showTempFileWarning", Int, -1);

View File

@ -161,7 +161,8 @@ public:
bool showTrayIcon{false}; bool showTrayIcon{false};
bool closeToTray{false}; bool closeToTray{false};
bool trayMessages{false}; bool trayMessages{false};
/*INSERTHERE*/
// See widgets/qxtconfirmationmessage. // See widgets/qxtconfirmationmessage.
// Values -1/positive. -1 will trigger the dialog. // Values -1/positive. -1 will trigger the dialog.
int showTempFileWarning{-1}; int showTempFileWarning{-1};

View File

@ -1572,33 +1572,29 @@ May be slow for big documents.</string>
<attribute name="title"> <attribute name="title">
<string>Misc</string> <string>Misc</string>
</attribute> </attribute>
<layout class="QVBoxLayout" name="verticalLayout_3"> <layout class="QVBoxLayout" name="verticalLayout_2">
<item> <item>
<layout class="QVBoxLayout" name="verticalLayout_2"> <widget class="QCheckBox" name="anchorTamilHackCB">
<item> <property name="toolTip">
<widget class="QCheckBox" name="anchorTamilHackCB"> <string>The bug causes a strange circle characters to be displayed inside highlighted Tamil words. The workaround inserts an additional space character which appears to fix the problem.</string>
<property name="toolTip"> </property>
<string>The bug causes a strange circle characters to be displayed inside highlighted Tamil words. The workaround inserts an additional space character which appears to fix the problem.</string> <property name="text">
</property> <string>Work around Tamil QTBUG-78923 by inserting space before anchor text</string>
<property name="text"> </property>
<string>Work around Tamil QTBUG-78923 by inserting space before anchor text</string> </widget>
</property> </item>
</widget> <item>
</item> <spacer name="verticalSpacer_2">
<item> <property name="orientation">
<spacer name="verticalSpacer_2"> <enum>Qt::Vertical</enum>
<property name="orientation"> </property>
<enum>Qt::Vertical</enum> <property name="sizeHint" stdset="0">
</property> <size>
<property name="sizeHint" stdset="0"> <width>20</width>
<size> <height>40</height>
<width>20</width> </size>
<height>40</height> </property>
</size> </spacer>
</property>
</spacer>
</item>
</layout>
</item> </item>
</layout> </layout>
</widget> </widget>
@ -1665,7 +1661,7 @@ May be slow for big documents.</string>
<resources/> <resources/>
<connections/> <connections/>
<buttongroups> <buttongroups>
<buttongroup name="buttonGroup"/>
<buttongroup name="buttonGroup_2"/> <buttongroup name="buttonGroup_2"/>
<buttongroup name="buttonGroup"/>
</buttongroups> </buttongroups>
</ui> </ui>

View File

@ -118,7 +118,7 @@ void UIPrefsDialog::setFromPrefs()
} else { } else {
ssearchTypCMB->setCurrentIndex(prefs.ssearchTyp); ssearchTypCMB->setCurrentIndex(prefs.ssearchTyp);
} }
switch (prefs.filterCtlStyle) { switch (prefs.filterCtlStyle) {
case PrefsPack::FCS_MN: case PrefsPack::FCS_MN:
filterMN_RB->setChecked(1); filterMN_RB->setChecked(1);
@ -135,7 +135,7 @@ void UIPrefsDialog::setFromPrefs()
ssNoCompleteCB->setChecked(prefs.ssearchNoComplete); ssNoCompleteCB->setChecked(prefs.ssearchNoComplete);
ssSearchOnCompleteCB->setChecked(prefs.ssearchStartOnComplete); ssSearchOnCompleteCB->setChecked(prefs.ssearchStartOnComplete);
ssSearchOnCompleteCB->setEnabled(!prefs.ssearchNoComplete); ssSearchOnCompleteCB->setEnabled(!prefs.ssearchNoComplete);
syntlenSB->setValue(prefs.syntAbsLen); syntlenSB->setValue(prefs.syntAbsLen);
syntctxSB->setValue(prefs.syntAbsCtx); syntctxSB->setValue(prefs.syntAbsCtx);
@ -163,7 +163,8 @@ void UIPrefsDialog::setFromPrefs()
trayMessagesCB->setEnabled(showTrayIconCB->checkState()); trayMessagesCB->setEnabled(showTrayIconCB->checkState());
closeToTrayCB->setChecked(prefs.closeToTray); closeToTrayCB->setChecked(prefs.closeToTray);
trayMessagesCB->setChecked(prefs.trayMessages); trayMessagesCB->setChecked(prefs.trayMessages);
/*INSERTHERE_LOAD*/
// See qxtconfirmationmessage. Needs to be -1 for the dialog to show. // See qxtconfirmationmessage. Needs to be -1 for the dialog to show.
showTempFileWarningCB->setChecked(prefs.showTempFileWarning == -1); showTempFileWarningCB->setChecked(prefs.showTempFileWarning == -1);
anchorTamilHackCB->setChecked(settings.value("anchorSpcHack", 0).toBool()); anchorTamilHackCB->setChecked(settings.value("anchorSpcHack", 0).toBool());
@ -189,7 +190,7 @@ void UIPrefsDialog::setFromPrefs()
qtermStyleCMB->addItem("color: red;background: yellow"); qtermStyleCMB->addItem("color: red;background: yellow");
qtermStyleCMB->addItem( qtermStyleCMB->addItem(
"color: #dddddd; background: black; font-weight: bold"); "color: #dddddd; background: black; font-weight: bold");
} }
// Abstract snippet separator string // Abstract snippet separator string
abssepLE->setText(prefs.abssep); abssepLE->setText(prefs.abssep);
dateformatLE->setText(u8s2qs(prefs.reslistdateformat)); dateformatLE->setText(u8s2qs(prefs.reslistdateformat));
@ -228,15 +229,15 @@ void UIPrefsDialog::setFromPrefs()
stemLangCMB->addItem(g_stringAllStem); stemLangCMB->addItem(g_stringAllStem);
vector<string> langs; vector<string> langs;
if (!getStemLangs(langs)) { if (!getStemLangs(langs)) {
QMessageBox::warning(0, "Recoll", QMessageBox::warning(0, "Recoll",
tr("error retrieving stemming languages")); tr("error retrieving stemming languages"));
} }
int cur = prefs.queryStemLang == "" ? 0 : 1; int cur = prefs.queryStemLang == "" ? 0 : 1;
for (vector<string>::const_iterator it = langs.begin(); for (vector<string>::const_iterator it = langs.begin();
it != langs.end(); it++) { it != langs.end(); it++) {
stemLangCMB-> stemLangCMB->
addItem(QString::fromUtf8(it->c_str(), it->length())); addItem(QString::fromUtf8(it->c_str(), it->length()));
if (cur == 0 && !strcmp((const char*)prefs.queryStemLang.toUtf8(), if (cur == 0 && !strcmp((const char*)prefs.queryStemLang.toUtf8(),
it->c_str())) { it->c_str())) {
cur = stemLangCMB->count(); cur = stemLangCMB->count();
} }
@ -268,14 +269,14 @@ void UIPrefsDialog::setFromPrefs()
// Initialize the extra indexes listboxes // Initialize the extra indexes listboxes
idxLV->clear(); idxLV->clear();
for (const auto& dbdir : prefs.allExtraDbs) { for (const auto& dbdir : prefs.allExtraDbs) {
QListWidgetItem *item = QListWidgetItem *item =
new QListWidgetItem(path2qs(dbdir), idxLV); new QListWidgetItem(path2qs(dbdir), idxLV);
if (item) if (item)
item->setCheckState(Qt::Unchecked); item->setCheckState(Qt::Unchecked);
} }
for (const auto& dbdir : prefs.activeExtraDbs) { for (const auto& dbdir : prefs.activeExtraDbs) {
auto items = auto items =
idxLV->findItems(path2qs(dbdir), idxLV->findItems(path2qs(dbdir),
Qt::MatchFixedString|Qt::MatchCaseSensitive); Qt::MatchFixedString|Qt::MatchCaseSensitive);
for (auto& entry : items) { for (auto& entry : items) {
entry->setCheckState(Qt::Checked); entry->setCheckState(Qt::Checked);
@ -414,7 +415,7 @@ void UIPrefsDialog::accept()
prefs.ssearchAutoPhrase = autoPhraseCB->isChecked(); prefs.ssearchAutoPhrase = autoPhraseCB->isChecked();
prefs.ssearchAutoPhraseThreshPC = autoPThreshSB->value(); prefs.ssearchAutoPhraseThreshPC = autoPThreshSB->value();
prefs.queryBuildAbstract = buildAbsCB->isChecked(); prefs.queryBuildAbstract = buildAbsCB->isChecked();
prefs.queryReplaceAbstract = buildAbsCB->isChecked() && prefs.queryReplaceAbstract = buildAbsCB->isChecked() &&
replAbsCB->isChecked(); replAbsCB->isChecked();
prefs.startWithAdvSearchOpen = initStartAdvCB->isChecked(); prefs.startWithAdvSearchOpen = initStartAdvCB->isChecked();
@ -438,6 +439,8 @@ void UIPrefsDialog::accept()
m_mainWindow->enableTrayIcon(prefs.showTrayIcon); m_mainWindow->enableTrayIcon(prefs.showTrayIcon);
prefs.closeToTray = closeToTrayCB->isChecked(); prefs.closeToTray = closeToTrayCB->isChecked();
prefs.trayMessages = trayMessagesCB->isChecked(); prefs.trayMessages = trayMessagesCB->isChecked();
/*INSERTHERE_ACCEPT*/
// -1 is the qxtconf... predefined value to show the dialog // -1 is the qxtconf... predefined value to show the dialog
prefs.showTempFileWarning = showTempFileWarningCB->isChecked() ? -1 : 1; prefs.showTempFileWarning = showTempFileWarningCB->isChecked() ? -1 : 1;
settings.setValue("anchorSpcHack", anchorTamilHackCB->isChecked()); settings.setValue("anchorSpcHack", anchorTamilHackCB->isChecked());
@ -460,7 +463,7 @@ void UIPrefsDialog::accept()
prefs.synFileEnable = synFileCB->isChecked(); prefs.synFileEnable = synFileCB->isChecked();
prefs.synFile = synFile; prefs.synFile = synFile;
prefs.allExtraDbs.clear(); prefs.allExtraDbs.clear();
prefs.activeExtraDbs.clear(); prefs.activeExtraDbs.clear();
for (int i = 0; i < idxLV->count(); i++) { for (int i = 0; i < idxLV->count(); i++) {
@ -475,7 +478,7 @@ void UIPrefsDialog::accept()
rwSettings(true); rwSettings(true);
storeShortcuts(); storeShortcuts();
string reason; string reason;
maybeOpenDb(reason, true); maybeOpenDb(reason, true);
emit uiprefsDone(); emit uiprefsDone();
@ -642,7 +645,7 @@ void UIPrefsDialog::showViewAction(const QString& mt)
void UIPrefsDialog::extradDbSelectChanged() void UIPrefsDialog::extradDbSelectChanged()
{ {
if (idxLV->selectedItems().size() <= 1) if (idxLV->selectedItems().size() <= 1)
ptransPB->setEnabled(true); ptransPB->setEnabled(true);
else else
ptransPB->setEnabled(false); ptransPB->setEnabled(false);
@ -698,7 +701,7 @@ void UIPrefsDialog::unacAllExtraDbPB_clicked()
void UIPrefsDialog::delExtraDbPB_clicked() void UIPrefsDialog::delExtraDbPB_clicked()
{ {
QList<QListWidgetItem *> items = idxLV->selectedItems(); QList<QListWidgetItem *> items = idxLV->selectedItems();
for (QList<QListWidgetItem *>::iterator it = items.begin(); for (QList<QListWidgetItem *>::iterator it = items.begin();
it != items.end(); it++) { it != items.end(); it++) {
delete *it; delete *it;
} }
@ -714,14 +717,14 @@ void UIPrefsDialog::on_showTrayIconCB_clicked()
trayMessagesCB->setEnabled(showTrayIconCB->checkState()); trayMessagesCB->setEnabled(showTrayIconCB->checkState());
} }
/** /**
* Browse to add another index. * Browse to add another index.
* We do a textual comparison to check for duplicates, except for * We do a textual comparison to check for duplicates, except for
* the main db for which we check inode numbers. * the main db for which we check inode numbers.
*/ */
void UIPrefsDialog::addExtraDbPB_clicked() void UIPrefsDialog::addExtraDbPB_clicked()
{ {
QString input = myGetFileName(true, QString input = myGetFileName(true,
tr("Select recoll config directory or " tr("Select recoll config directory or "
"xapian index directory " "xapian index directory "
"(e.g.: /home/me/.recoll or " "(e.g.: /home/me/.recoll or "
@ -743,7 +746,7 @@ void UIPrefsDialog::addExtraDbPB_clicked()
} }
} }
LOGDEB("ExtraDbDial: got: [" << (dbdir) << "]\n" ); LOGDEB("ExtraDbDial: got: [" << (dbdir) << "]\n");
bool stripped; bool stripped;
if (!Rcl::Db::testDbDir(dbdir, &stripped)) { if (!Rcl::Db::testDbDir(dbdir, &stripped)) {
QMessageBox::warning(0, "Recoll", tr("The selected directory does not " QMessageBox::warning(0, "Recoll", tr("The selected directory does not "
@ -751,7 +754,7 @@ void UIPrefsDialog::addExtraDbPB_clicked()
return; return;
} }
if (o_index_stripchars != stripped) { if (o_index_stripchars != stripped) {
QMessageBox::warning(0, "Recoll", QMessageBox::warning(0, "Recoll",
tr("Cant add index with different case/diacritics" tr("Cant add index with different case/diacritics"
" stripping option")); " stripping option"));
return; return;