From 8099951b0f3111fedcfec41bfbba1a2c0e9918a7 Mon Sep 17 00:00:00 2001 From: Jean-Francois Dockes Date: Fri, 22 Jan 2021 10:07:57 +0100 Subject: [PATCH] add pref and shortcut to toggle showing result table header --- src/qtgui/guiutils.cpp | 2 ++ src/qtgui/guiutils.h | 1 + src/qtgui/restable.cpp | 26 +++++++++++++++++++++++--- src/qtgui/restable.h | 2 ++ src/qtgui/uiprefs.ui | 10 ++++++++++ src/qtgui/uiprefs_w.cpp | 2 ++ 6 files changed, 40 insertions(+), 3 deletions(-) diff --git a/src/qtgui/guiutils.cpp b/src/qtgui/guiutils.cpp index 7745b0c7..9272f765 100644 --- a/src/qtgui/guiutils.cpp +++ b/src/qtgui/guiutils.cpp @@ -298,6 +298,8 @@ void rwSettings(bool writing) SETTING_RW(prefs.noStatusBar, "/Recoll/prefs/noStatusBar", Bool, false); SETTING_RW(prefs.noMenuBar, "/Recoll/prefs/noMenuBar", Bool, false); SETTING_RW(prefs.noSSTypCMB, "/Recoll/prefs/noSSTypCMB", Bool, false); + SETTING_RW(prefs.noResTableHeader, "/Recoll/prefs/noResTableHeader", + Bool, false); SETTING_RW(prefs.showTrayIcon, "/Recoll/prefs/showTrayIcon", Bool, false); SETTING_RW(prefs.closeToTray, "/Recoll/prefs/closeToTray", Bool, false); SETTING_RW(prefs.trayMessages, "/Recoll/prefs/trayMessages", Bool, false); diff --git a/src/qtgui/guiutils.h b/src/qtgui/guiutils.h index 26dce1d2..e329e9b8 100644 --- a/src/qtgui/guiutils.h +++ b/src/qtgui/guiutils.h @@ -145,6 +145,7 @@ public: bool noStatusBar{false}; bool noMenuBar{false}; bool noSSTypCMB{false}; + bool noResTableHeader{false}; bool showTrayIcon{false}; bool closeToTray{false}; bool trayMessages{false}; diff --git a/src/qtgui/restable.cpp b/src/qtgui/restable.cpp index 772a3fc8..acc3a8bc 100644 --- a/src/qtgui/restable.cpp +++ b/src/qtgui/restable.cpp @@ -604,6 +604,10 @@ void ResTable::init() new QShortcut(QKeySequence("Ctrl+7"), this, SLOT(setCurrentRow7())); new QShortcut(QKeySequence("Ctrl+8"), this, SLOT(setCurrentRow8())); new QShortcut(QKeySequence("Ctrl+9"), this, SLOT(setCurrentRow9())); + + QShortcut *sc = new QShortcut(QKeySequence(Qt::Key_Escape), this); + connect(sc, SIGNAL(activated()), + tableView->selectionModel(), SLOT(clear())); connect(tableView, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(createPopupMenu(const QPoint&))); @@ -636,11 +640,11 @@ void ResTable::init() #else header->setMovable(true); #endif - + if (prefs.noResTableHeader) { + header->hide(); + } setDefRowHeight(); - QShortcut *sc = new QShortcut(QKeySequence(Qt::Key_Escape), this); - connect(sc, SIGNAL(activated()), tableView->selectionModel(), SLOT(clear())); connect(tableView->selectionModel(), SIGNAL(currentChanged(const QModelIndex&, const QModelIndex &)), this, SLOT(onTableView_currentChanged(const QModelIndex&))); @@ -682,6 +686,8 @@ void ResTable::onNewShortcuts() "Ctrl+D", m_previewsc, menuPreview); SETSHORTCUT(this, tr("Result Table"), tr("Show Snippets"), "Ctrl+E", m_showsnipssc, menuShowSnippets); + SETSHORTCUT(this, tr("Result Table"), tr("Show Header"), + "Ctrl+H", m_showheadersc, toggleHeader); } bool ResTable::eventFilter(QObject* obj, QEvent* event) @@ -731,11 +737,25 @@ void ResTable::setRclMain(RclMain *m, bool ismain) m_rclmain, SLOT(showSnippets(Rcl::Doc))); } +void ResTable::toggleHeader() +{ + if (tableView->horizontalHeader()->isVisible()) { + tableView->horizontalHeader()->hide(); + } else { + tableView->horizontalHeader()->show(); + } +} + void ResTable::onUiPrefsChanged() { if (m_detail) { m_detail->init(); } + if (prefs.noResTableHeader) { + tableView->horizontalHeader()->hide(); + } else { + tableView->horizontalHeader()->show(); + } } #define SETCURRENTROW(INDEX) \ diff --git a/src/qtgui/restable.h b/src/qtgui/restable.h index fe4c7889..ff8a21ad 100644 --- a/src/qtgui/restable.h +++ b/src/qtgui/restable.h @@ -177,6 +177,7 @@ public slots: virtual void setCurrentRow7(); virtual void setCurrentRow8(); virtual void setCurrentRow9(); + virtual void toggleHeader(); signals: void docPreviewClicked(int, Rcl::Doc, int); @@ -211,6 +212,7 @@ private: QShortcut *m_openquitsc{nullptr}; QShortcut *m_previewsc{nullptr}; QShortcut *m_showsnipssc{nullptr}; + QShortcut *m_showheadersc{nullptr}; }; diff --git a/src/qtgui/uiprefs.ui b/src/qtgui/uiprefs.ui index efc737fa..11588e4c 100644 --- a/src/qtgui/uiprefs.ui +++ b/src/qtgui/uiprefs.ui @@ -202,6 +202,16 @@ + + + + Hide result table header. + + + false + + + diff --git a/src/qtgui/uiprefs_w.cpp b/src/qtgui/uiprefs_w.cpp index 76146160..1e4ef7f8 100644 --- a/src/qtgui/uiprefs_w.cpp +++ b/src/qtgui/uiprefs_w.cpp @@ -152,6 +152,7 @@ void UIPrefsDialog::setFromPrefs() noStatusBarCB->setChecked(prefs.noStatusBar); noMenuBarCB->setChecked(prefs.noMenuBar); noSSTypCMBCB->setChecked(prefs.noSSTypCMB); + noResTableHeaderCB->setChecked(prefs.noResTableHeader); showTrayIconCB->setChecked(prefs.showTrayIcon); if (!prefs.showTrayIcon) { prefs.closeToTray = false; @@ -406,6 +407,7 @@ void UIPrefsDialog::accept() prefs.noMenuBar = noMenuBarCB->isChecked(); m_mainWindow->setupMenus(); prefs.noSSTypCMB = noSSTypCMBCB->isChecked(); + prefs.noResTableHeader = noResTableHeaderCB->isChecked(); prefs.noStatusBar = noStatusBarCB->isChecked(); m_mainWindow->setupStatusBar(); prefs.noClearSearch = noClearSearchCB->isChecked();