From 8603409defdfd4379a0d16510a97d29353d52b75 Mon Sep 17 00:00:00 2001 From: Jean-Francois Dockes Date: Sat, 10 Apr 2021 15:26:00 +0200 Subject: [PATCH] GUI: preferences: separate tab for result table preferences. Add option to disable showing meta while hovering. Show doc text on ctrl+... if this is the default for a mouse click (no Shift) --- src/qtgui/guiutils.cpp | 1 + src/qtgui/guiutils.h | 1 + src/qtgui/rclm_wins.cpp | 2 +- src/qtgui/restable.cpp | 42 +++++++---- src/qtgui/uiprefs.ui | 152 ++++++++++++++++++++++++---------------- src/qtgui/uiprefs_w.cpp | 2 + 6 files changed, 124 insertions(+), 76 deletions(-) diff --git a/src/qtgui/guiutils.cpp b/src/qtgui/guiutils.cpp index 9e000af3..2debd53e 100644 --- a/src/qtgui/guiutils.cpp +++ b/src/qtgui/guiutils.cpp @@ -307,6 +307,7 @@ void rwSettings(bool writing) SETTING_RW(prefs.noMenuBar, "/Recoll/prefs/noMenuBar", Bool, false); SETTING_RW(prefs.noSSTypCMB, "/Recoll/prefs/noSSTypCMB", Bool, false); SETTING_RW(prefs.resTableTextNoShift, "/Recoll/prefs/resTableTextNoShift", Bool, false); + SETTING_RW(prefs.resTableNoHoverMeta, "/Recoll/prefs/resTableNoHoverMeta", Bool, false); SETTING_RW(prefs.noResTableHeader, "/Recoll/prefs/noResTableHeader", Bool, false); SETTING_RW(prefs.showResTableVHeader, "/Recoll/prefs/showResTableVHeader", Bool, false); SETTING_RW(prefs.noResTableRowJumpSC, "/Recoll/prefs/noResTableRowJumpSC", Bool, false); diff --git a/src/qtgui/guiutils.h b/src/qtgui/guiutils.h index 0c914906..24849e7f 100644 --- a/src/qtgui/guiutils.h +++ b/src/qtgui/guiutils.h @@ -153,6 +153,7 @@ public: bool noMenuBar{false}; bool noSSTypCMB{false}; bool resTableTextNoShift{false}; + bool resTableNoHoverMeta{false}; bool noResTableHeader{false}; bool showResTableVHeader{false}; bool noResTableRowJumpSC{false}; diff --git a/src/qtgui/rclm_wins.cpp b/src/qtgui/rclm_wins.cpp index a75d4d61..7c8a551b 100644 --- a/src/qtgui/rclm_wins.cpp +++ b/src/qtgui/rclm_wins.cpp @@ -326,7 +326,7 @@ void RclMain::showUIPrefs() void RclMain::showExtIdxDialog() { showUIPrefs(); - uiprefs->tabWidget->setCurrentIndex(4); + uiprefs->tabWidget->setCurrentIndex(5); } void RclMain::showAboutDialog() diff --git a/src/qtgui/restable.cpp b/src/qtgui/restable.cpp index 4aee183a..8fa1678e 100644 --- a/src/qtgui/restable.cpp +++ b/src/qtgui/restable.cpp @@ -706,14 +706,14 @@ void ResTable::onNewShortcuts() auto sc = new QShortcut(QKeySequence(qs2utf8s(qs).c_str()), this); m_rowlinks.push_back(new SCData(this, setrow, i)); m_rowsc.push_back(sc); - connect(sc, SIGNAL(activated()),m_rowlinks.back(),SLOT(activate())); + connect(sc, SIGNAL(activated()), m_rowlinks.back(), SLOT(activate())); if (i > 9) continue; qs = QString("Ctrl+%1").arg(i); sc = new QShortcut(QKeySequence(qs2utf8s(qs).c_str()), this); m_rowsc.push_back(sc); m_rowlinks.push_back(new SCData(this, setrow, i)); - connect(sc, SIGNAL(activated()),m_rowlinks.back(),SLOT(activate())); + connect(sc, SIGNAL(activated()), m_rowlinks.back(), SLOT(activate())); } } SETSHORTCUT(this, "restable:704", tr("Result Table"), @@ -891,8 +891,10 @@ void ResTable::saveColState() void ResTable::onTableView_currentChanged(const QModelIndex& index) { + bool hasselection = tableView->selectionModel()->hasSelection(); LOGDEB2("ResTable::onTableView_currentChanged(" << index.row() << ", " << - index.column() << ") from kbd " << m_rowchangefromkbd << "\n"); + index.column() << ") from kbd " << m_rowchangefromkbd << " hasselection " << + hasselection << "\n"); if (!m_model || !m_model->getDocSource()) return; @@ -901,18 +903,30 @@ void ResTable::onTableView_currentChanged(const QModelIndex& index) m_detail->init(); m_detaildocnum = index.row(); m_detaildoc = doc; - bool isShift = (QApplication::keyboardModifiers() & Qt::ShiftModifier) && - !m_rowchangefromkbd; - bool showtext = isShift ^ prefs.resTableTextNoShift; - if (tableView->selectionModel()->hasSelection() && showtext) { - m_rowchangefromkbd = false; - bool loadok = rcldb->getDocRawText(m_detaildoc); - if (loadok) { - m_detail->setPlainText(u8s2qs(m_detaildoc.text)); + bool isShift = (QApplication::keyboardModifiers() & Qt::ShiftModifier); + bool showtext{false}; + bool showmeta{false}; + if (m_rowchangefromkbd) { + // Ctrl+... jump to row. Show text/meta as for simple click + if (hasselection) { + // When getting here from ctrl+... we get called twice, once with row 0 + // and no selection, once with the actual row and selection. Only + // reset fromkbd and set showtext in the second case. + m_rowchangefromkbd = false; + showtext = prefs.resTableTextNoShift; } - } else { - m_pager->displaySingleDoc(theconfig, m_detaildocnum, m_detaildoc, - m_model->m_hdata); + } else { + // Mouse click. Show text or meta depending on shift key. Never show text when hovering + // (no selection). + showtext = hasselection && (isShift ^ prefs.resTableTextNoShift); + } + if (!showtext) { + showmeta = hasselection || !prefs.resTableNoHoverMeta; + } + if (showtext && rcldb->getDocRawText(m_detaildoc)) { + m_detail->setPlainText(u8s2qs(m_detaildoc.text)); + } else if (showmeta) { + m_pager->displaySingleDoc(theconfig, m_detaildocnum, m_detaildoc, m_model->m_hdata); } emit(detailDocChanged(doc, m_model->getDocSource())); } else { diff --git a/src/qtgui/uiprefs.ui b/src/qtgui/uiprefs.ui index 4d62ad3b..447aeb68 100644 --- a/src/qtgui/uiprefs.ui +++ b/src/qtgui/uiprefs.ui @@ -22,7 +22,7 @@ 0 - + User interface @@ -258,61 +258,6 @@ - - - - - - To display document text instead of metadata in result table detail area, use: - - - - - - - left mouse click - - - - - - - Shift+click - - - - - - - - - Hide result table header. - - - false - - - - - - - Show result table row headers. - - - false - - - - - - - Disable the Ctrl+[0-9]/Shift+[a-z] shortcuts for jumping to table rows. - - - false - - - @@ -628,7 +573,7 @@ - + Shortcuts @@ -673,7 +618,7 @@ - + Result List @@ -988,7 +933,92 @@ - + + + Result Table + + + + + + Hide result table header. + + + false + + + + + + + Show result table row headers. + + + false + + + + + + + Disable the Ctrl+[0-9]/Shift+[a-z] shortcuts for jumping to table rows. + + + false + + + + + + + + + To display document text instead of metadata in result table detail area, use: + + + + + + + left mouse click + + + + + + + Shift+click + + + + + + + + + Do not display metadata when hovering over rows. + + + false + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + Search parameters @@ -1386,7 +1416,7 @@ May be slow for big documents. - + External Indexes @@ -1492,7 +1522,7 @@ May be slow for big documents. - + Misc diff --git a/src/qtgui/uiprefs_w.cpp b/src/qtgui/uiprefs_w.cpp index 10310119..16507180 100644 --- a/src/qtgui/uiprefs_w.cpp +++ b/src/qtgui/uiprefs_w.cpp @@ -159,6 +159,7 @@ void UIPrefsDialog::setFromPrefs() noSSTypCMBCB->setChecked(prefs.noSSTypCMB); restabShowTxtNoShiftRB->setChecked(prefs.resTableTextNoShift); restabShowTxtShiftRB->setChecked(!prefs.resTableTextNoShift); + resTableNoHoverMetaCB->setChecked(prefs.resTableNoHoverMeta); noResTableHeaderCB->setChecked(prefs.noResTableHeader); showResTableVHeaderCB->setChecked(prefs.showResTableVHeader); noRowJumpShortcutsCB->setChecked(prefs.noResTableRowJumpSC); @@ -437,6 +438,7 @@ void UIPrefsDialog::accept() m_mainWindow->setupMenus(); prefs.noSSTypCMB = noSSTypCMBCB->isChecked(); prefs.resTableTextNoShift = restabShowTxtNoShiftRB->isChecked(); + prefs.resTableNoHoverMeta = resTableNoHoverMetaCB->isChecked(); prefs.noResTableHeader = noResTableHeaderCB->isChecked(); prefs.showResTableVHeader = showResTableVHeaderCB->isChecked(); prefs.noResTableRowJumpSC = noRowJumpShortcutsCB->isChecked();