add pref and shortcut to toggle showing result table header

This commit is contained in:
Jean-Francois Dockes 2021-01-22 10:07:57 +01:00
parent 84815d4aa6
commit 8099951b0f
6 changed files with 40 additions and 3 deletions

View File

@ -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);

View File

@ -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};

View File

@ -605,6 +605,10 @@ void ResTable::init()
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) \

View File

@ -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};
};

View File

@ -202,6 +202,16 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="noResTableHeaderCB">
<property name="text">
<string>Hide result table header.</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="noClearSearchCB">
<property name="text">

View File

@ -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();