GUI: add pref to disable the row jump shortcuts
This commit is contained in:
parent
31f6793495
commit
5e69bea014
@ -302,6 +302,8 @@ void rwSettings(bool writing)
|
||||
Bool, false);
|
||||
SETTING_RW(prefs.showResTableVHeader, "/Recoll/prefs/showResTableVHeader",
|
||||
Bool, false);
|
||||
SETTING_RW(prefs.noResTableRowJumpSC, "/Recoll/prefs/noResTableRowJumpSC",
|
||||
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);
|
||||
|
||||
@ -147,6 +147,7 @@ public:
|
||||
bool noSSTypCMB{false};
|
||||
bool noResTableHeader{false};
|
||||
bool showResTableVHeader{false};
|
||||
bool noResTableRowJumpSC{false};
|
||||
bool showTrayIcon{false};
|
||||
bool closeToTray{false};
|
||||
bool trayMessages{false};
|
||||
|
||||
@ -595,28 +595,12 @@ void ResTable::init()
|
||||
tableView->setSelectionBehavior(QAbstractItemView::SelectRows);
|
||||
tableView->setItemDelegate(new ResTableDelegate(this));
|
||||
tableView->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
tableView->setAlternatingRowColors(true);
|
||||
|
||||
onNewShortcuts();
|
||||
connect(&SCBase::scBase(), SIGNAL(shortcutsChanged()),
|
||||
this, SLOT(onNewShortcuts()));
|
||||
|
||||
// Set "go to row" accelerator shortcuts. letter or digit for 0-9,
|
||||
// then letter up to 25
|
||||
std::function<void(int)> setrow =
|
||||
std::bind(&ResTable::setCurrentRow, this, std::placeholders::_1);
|
||||
for (int i = 0; i <= 25; i++) {
|
||||
if (i <= 9) {
|
||||
auto qs = QString("Ctrl+%1").arg(i);
|
||||
auto sc = new QShortcut(QKeySequence(qs2utf8s(qs).c_str()), this);
|
||||
auto lnk = new SCData(this, setrow, i);
|
||||
connect(sc, SIGNAL(activated()), lnk, SLOT(activate()));
|
||||
}
|
||||
auto qs = QString("Ctrl+Shift+%1").arg(char('a'+i));
|
||||
auto sc = new QShortcut(QKeySequence(qs2utf8s(qs).c_str()), this);
|
||||
auto lnk = new SCData(this, setrow, i);
|
||||
connect(sc, SIGNAL(activated()), lnk, SLOT(activate()));
|
||||
}
|
||||
|
||||
auto sc = new QShortcut(QKeySequence(Qt::Key_Escape), this);
|
||||
connect(sc, SIGNAL(activated()),
|
||||
tableView->selectionModel(), SLOT(clear()));
|
||||
@ -688,6 +672,35 @@ void ResTable::init()
|
||||
|
||||
void ResTable::onNewShortcuts()
|
||||
{
|
||||
if (prefs.noResTableRowJumpSC) {
|
||||
for (auto& lnk : m_rowlinks) {
|
||||
delete lnk;
|
||||
}
|
||||
m_rowlinks.clear();
|
||||
for (auto& sc : m_rowsc) {
|
||||
delete sc;
|
||||
}
|
||||
m_rowsc.clear();
|
||||
} else if (m_rowlinks.empty()) {
|
||||
// Set "go to row" accelerator shortcuts. letter or digit for 0-9,
|
||||
// then letter up to 25
|
||||
std::function<void(int)> setrow =
|
||||
std::bind(&ResTable::setCurrentRow, this, std::placeholders::_1);
|
||||
for (int i = 0; i <= 25; i++) {
|
||||
auto qs = QString("Ctrl+Shift+%1").arg(char('a'+i));
|
||||
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()));
|
||||
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()));
|
||||
}
|
||||
}
|
||||
SETSHORTCUT(this, tr("Result Table"), tr("Open current result document"),
|
||||
"Ctrl+O", m_opensc, menuEdit);
|
||||
SETSHORTCUT(this, tr("Result Table"), tr("Open current result and quit"),
|
||||
|
||||
@ -115,6 +115,23 @@ class QUrl;
|
||||
class RclMain;
|
||||
class QShortcut;
|
||||
|
||||
// This is an intermediary object to help setting up multiple similar
|
||||
// shortcuts with different data (e.g. Ctrl+1, Ctrl+2 etc.). Maybe
|
||||
// there is another way, but this one works.
|
||||
class SCData : public QObject {
|
||||
Q_OBJECT;
|
||||
public:
|
||||
SCData(QObject* parent, std::function<void (int)> cb, int row)
|
||||
: QObject(parent), m_cb(cb), m_row(row) {}
|
||||
public slots:
|
||||
virtual void activate() {
|
||||
m_cb(m_row);
|
||||
}
|
||||
private:
|
||||
std::function<void (int)> m_cb;
|
||||
int m_row;
|
||||
};
|
||||
|
||||
class ResTable : public QWidget, public Ui::ResTable
|
||||
{
|
||||
Q_OBJECT;
|
||||
@ -209,23 +226,9 @@ private:
|
||||
QShortcut *m_showheadersc{nullptr};
|
||||
QShortcut *m_showvheadersc{nullptr};
|
||||
QShortcut *m_copycurtextsc{nullptr};
|
||||
std::vector<SCData*> m_rowlinks;
|
||||
std::vector<QShortcut *> m_rowsc;
|
||||
};
|
||||
|
||||
// This is an intermediary object to help setting up multiple similar
|
||||
// shortcuts with different data (e.g. Ctrl+1, Ctrl+2 etc.). Maybe
|
||||
// there is another way, but this one works.
|
||||
class SCData : public QObject {
|
||||
Q_OBJECT;
|
||||
public:
|
||||
SCData(QObject* parent, std::function<void (int)> cb, int row)
|
||||
: QObject(parent), m_cb(cb), m_row(row) {}
|
||||
public slots:
|
||||
virtual void activate() {
|
||||
m_cb(m_row);
|
||||
}
|
||||
private:
|
||||
std::function<void (int)> m_cb;
|
||||
int m_row;
|
||||
};
|
||||
|
||||
|
||||
#endif /* _RESTABLE_H_INCLUDED_ */
|
||||
|
||||
@ -248,6 +248,16 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="noRowJumpShortcutsCB">
|
||||
<property name="text">
|
||||
<string>Disable the Ctrl+[0-9]/[a-z] shortcuts for jumping to table rows.</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="noClearSearchCB">
|
||||
<property name="text">
|
||||
|
||||
@ -156,6 +156,7 @@ void UIPrefsDialog::setFromPrefs()
|
||||
noSSTypCMBCB->setChecked(prefs.noSSTypCMB);
|
||||
noResTableHeaderCB->setChecked(prefs.noResTableHeader);
|
||||
showResTableVHeaderCB->setChecked(prefs.showResTableVHeader);
|
||||
noRowJumpShortcutsCB->setChecked(prefs.noResTableRowJumpSC);
|
||||
showTrayIconCB->setChecked(prefs.showTrayIcon);
|
||||
if (!prefs.showTrayIcon) {
|
||||
prefs.closeToTray = false;
|
||||
@ -427,6 +428,7 @@ void UIPrefsDialog::accept()
|
||||
prefs.noSSTypCMB = noSSTypCMBCB->isChecked();
|
||||
prefs.noResTableHeader = noResTableHeaderCB->isChecked();
|
||||
prefs.showResTableVHeader = showResTableVHeaderCB->isChecked();
|
||||
prefs.noResTableRowJumpSC = noRowJumpShortcutsCB->isChecked();
|
||||
prefs.noStatusBar = noStatusBarCB->isChecked();
|
||||
m_mainWindow->setupStatusBar();
|
||||
prefs.noClearSearch = noClearSearchCB->isChecked();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user