mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-06 06:19:52 +08:00
add shortcuts for tab navigation in ViewSplit
This commit is contained in:
parent
79abddd802
commit
1f3b00ee44
@ -1 +1 @@
|
|||||||
Subproject commit 5e02a011cb7e4979e897c0670fe8ac8f1060feb4
|
Subproject commit 32678afe91f4ad15acb4f4d24d92e1fa61bb1df7
|
@ -38,6 +38,18 @@ namespace vnotex
|
|||||||
Quit,
|
Quit,
|
||||||
FlashPage,
|
FlashPage,
|
||||||
QuickAccess,
|
QuickAccess,
|
||||||
|
ActivateTab1,
|
||||||
|
ActivateTab2,
|
||||||
|
ActivateTab3,
|
||||||
|
ActivateTab4,
|
||||||
|
ActivateTab5,
|
||||||
|
ActivateTab6,
|
||||||
|
ActivateTab7,
|
||||||
|
ActivateTab8,
|
||||||
|
ActivateTab9,
|
||||||
|
AlternateTab,
|
||||||
|
ActivateNextTab,
|
||||||
|
ActivatePreviousTab,
|
||||||
MaxShortcut
|
MaxShortcut
|
||||||
};
|
};
|
||||||
Q_ENUM(Shortcut)
|
Q_ENUM(Shortcut)
|
||||||
@ -70,6 +82,8 @@ namespace vnotex
|
|||||||
void setRecoverLastSessionOnStartEnabled(bool p_enabled);
|
void setRecoverLastSessionOnStartEnabled(bool p_enabled);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
friend class MainConfig;
|
||||||
|
|
||||||
void loadShortcuts(const QJsonObject &p_app, const QJsonObject &p_user);
|
void loadShortcuts(const QJsonObject &p_app, const QJsonObject &p_user);
|
||||||
|
|
||||||
void loadNoteManagement(const QJsonObject &p_app, const QJsonObject &p_user);
|
void loadNoteManagement(const QJsonObject &p_app, const QJsonObject &p_user);
|
||||||
|
@ -117,4 +117,10 @@ QString MainConfig::getVersion(const QJsonObject &p_jobj)
|
|||||||
void MainConfig::doVersionSpecificOverride()
|
void MainConfig::doVersionSpecificOverride()
|
||||||
{
|
{
|
||||||
// In a new version, we may want to change one value by force.
|
// In a new version, we may want to change one value by force.
|
||||||
|
m_coreConfig->m_shortcuts[CoreConfig::Shortcut::NavigationDock] = "Ctrl+G, A";
|
||||||
|
m_coreConfig->m_shortcuts[CoreConfig::Shortcut::OutlineDock] = "Ctrl+G, U";
|
||||||
|
m_coreConfig->m_shortcuts[CoreConfig::Shortcut::SearchDock] = "Ctrl+G, S";
|
||||||
|
m_coreConfig->m_shortcuts[CoreConfig::Shortcut::LocationListDock] = "Ctrl+G, L";
|
||||||
|
m_coreConfig->m_shortcuts[CoreConfig::Shortcut::NewWorkspace] = "Ctrl+G, M";
|
||||||
|
m_coreConfig->writeToSettings();
|
||||||
}
|
}
|
||||||
|
@ -15,10 +15,10 @@
|
|||||||
"Settings" : "Ctrl+Alt+P",
|
"Settings" : "Ctrl+Alt+P",
|
||||||
"NewNote" : "Ctrl+Alt+N",
|
"NewNote" : "Ctrl+Alt+N",
|
||||||
"CloseTab" : "Ctrl+G, X",
|
"CloseTab" : "Ctrl+G, X",
|
||||||
"NavigationDock" : "Ctrl+G, 1",
|
"NavigationDock" : "Ctrl+G, A",
|
||||||
"OutlineDock" : "Ctrl+G, 2",
|
"OutlineDock" : "Ctrl+G, U",
|
||||||
"SearchDock" : "Ctrl+G, 3",
|
"SearchDock" : "Ctrl+G, S",
|
||||||
"LocationListDock" : "Ctrl+G, 4",
|
"LocationListDock" : "Ctrl+G, L",
|
||||||
"Search" : "Ctrl+Alt+F",
|
"Search" : "Ctrl+Alt+F",
|
||||||
"NavigationMode" : "Ctrl+G, W",
|
"NavigationMode" : "Ctrl+G, W",
|
||||||
"LocateNode" : "Ctrl+G, D",
|
"LocateNode" : "Ctrl+G, D",
|
||||||
@ -27,11 +27,23 @@
|
|||||||
"MaximizeSplit" : "Ctrl+G, Shift+\\",
|
"MaximizeSplit" : "Ctrl+G, Shift+\\",
|
||||||
"DistributeSplits" : "Ctrl+G, =",
|
"DistributeSplits" : "Ctrl+G, =",
|
||||||
"RemoveSplitAndWorkspace" : "Ctrl+G, R",
|
"RemoveSplitAndWorkspace" : "Ctrl+G, R",
|
||||||
"NewWorkspace" : "Ctrl+G, N",
|
"NewWorkspace" : "Ctrl+G, M",
|
||||||
"Export" : "Ctrl+G, T",
|
"Export" : "Ctrl+G, T",
|
||||||
"Quit" : "Ctrl+Q",
|
"Quit" : "Ctrl+Q",
|
||||||
"FlashPage" : "Ctrl+Alt+L",
|
"FlashPage" : "Ctrl+Alt+L",
|
||||||
"QuickAccess" : "Ctrl+Alt+I"
|
"QuickAccess" : "Ctrl+Alt+I",
|
||||||
|
"ActivateTab1" : "Ctrl+G, 1",
|
||||||
|
"ActivateTab2" : "Ctrl+G, 2",
|
||||||
|
"ActivateTab3" : "Ctrl+G, 3",
|
||||||
|
"ActivateTab4" : "Ctrl+G, 4",
|
||||||
|
"ActivateTab5" : "Ctrl+G, 5",
|
||||||
|
"ActivateTab6" : "Ctrl+G, 6",
|
||||||
|
"ActivateTab7" : "Ctrl+G, 7",
|
||||||
|
"ActivateTab8" : "Ctrl+G, 8",
|
||||||
|
"ActivateTab9" : "Ctrl+G, 9",
|
||||||
|
"AlternateTab" : "Ctrl+G, 0",
|
||||||
|
"ActivateNextTab" : "Ctrl+G, N",
|
||||||
|
"ActivatePreviousTab" : "Ctrl+G, P"
|
||||||
},
|
},
|
||||||
"toolbar_icon_size" : 16,
|
"toolbar_icon_size" : 16,
|
||||||
"note_management" : {
|
"note_management" : {
|
||||||
|
@ -103,6 +103,9 @@ void ViewSplit::focusCurrentViewWindow()
|
|||||||
} else {
|
} else {
|
||||||
setFocus();
|
setFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_lastViewWindow = m_currentViewWindow;
|
||||||
|
m_currentViewWindow = win;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ViewSplit::setupCornerWidget()
|
void ViewSplit::setupCornerWidget()
|
||||||
@ -407,7 +410,7 @@ void ViewSplit::updateWindowList(QMenu *p_menu)
|
|||||||
int cnt = getViewWindowCount();
|
int cnt = getViewWindowCount();
|
||||||
if (cnt == 0) {
|
if (cnt == 0) {
|
||||||
// Add a dummy entry.
|
// Add a dummy entry.
|
||||||
auto act = p_menu->addAction(tr("No window to show here"));
|
auto act = p_menu->addAction(tr("No Window To Show"));
|
||||||
act->setEnabled(false);
|
act->setEnabled(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -742,6 +745,136 @@ void ViewSplit::setupShortcuts()
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ActivateTab1.
|
||||||
|
{
|
||||||
|
auto shortcut = WidgetUtils::createShortcut(coreConfig.getShortcut(CoreConfig::ActivateTab1), this, Qt::WidgetWithChildrenShortcut);
|
||||||
|
if (shortcut) {
|
||||||
|
connect(shortcut, &QShortcut::activated,
|
||||||
|
this, [this]() {
|
||||||
|
setCurrentViewWindow(0);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ActivateTab2.
|
||||||
|
{
|
||||||
|
auto shortcut = WidgetUtils::createShortcut(coreConfig.getShortcut(CoreConfig::ActivateTab2), this, Qt::WidgetWithChildrenShortcut);
|
||||||
|
if (shortcut) {
|
||||||
|
connect(shortcut, &QShortcut::activated,
|
||||||
|
this, [this]() {
|
||||||
|
setCurrentViewWindow(1);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ActivateTab3.
|
||||||
|
{
|
||||||
|
auto shortcut = WidgetUtils::createShortcut(coreConfig.getShortcut(CoreConfig::ActivateTab3), this, Qt::WidgetWithChildrenShortcut);
|
||||||
|
if (shortcut) {
|
||||||
|
connect(shortcut, &QShortcut::activated,
|
||||||
|
this, [this]() {
|
||||||
|
setCurrentViewWindow(2);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ActivateTab4.
|
||||||
|
{
|
||||||
|
auto shortcut = WidgetUtils::createShortcut(coreConfig.getShortcut(CoreConfig::ActivateTab4), this, Qt::WidgetWithChildrenShortcut);
|
||||||
|
if (shortcut) {
|
||||||
|
connect(shortcut, &QShortcut::activated,
|
||||||
|
this, [this]() {
|
||||||
|
setCurrentViewWindow(3);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ActivateTab5.
|
||||||
|
{
|
||||||
|
auto shortcut = WidgetUtils::createShortcut(coreConfig.getShortcut(CoreConfig::ActivateTab5), this, Qt::WidgetWithChildrenShortcut);
|
||||||
|
if (shortcut) {
|
||||||
|
connect(shortcut, &QShortcut::activated,
|
||||||
|
this, [this]() {
|
||||||
|
setCurrentViewWindow(4);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ActivateTab6.
|
||||||
|
{
|
||||||
|
auto shortcut = WidgetUtils::createShortcut(coreConfig.getShortcut(CoreConfig::ActivateTab6), this, Qt::WidgetWithChildrenShortcut);
|
||||||
|
if (shortcut) {
|
||||||
|
connect(shortcut, &QShortcut::activated,
|
||||||
|
this, [this]() {
|
||||||
|
setCurrentViewWindow(5);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ActivateTab7.
|
||||||
|
{
|
||||||
|
auto shortcut = WidgetUtils::createShortcut(coreConfig.getShortcut(CoreConfig::ActivateTab7), this, Qt::WidgetWithChildrenShortcut);
|
||||||
|
if (shortcut) {
|
||||||
|
connect(shortcut, &QShortcut::activated,
|
||||||
|
this, [this]() {
|
||||||
|
setCurrentViewWindow(6);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ActivateTab8.
|
||||||
|
{
|
||||||
|
auto shortcut = WidgetUtils::createShortcut(coreConfig.getShortcut(CoreConfig::ActivateTab8), this, Qt::WidgetWithChildrenShortcut);
|
||||||
|
if (shortcut) {
|
||||||
|
connect(shortcut, &QShortcut::activated,
|
||||||
|
this, [this]() {
|
||||||
|
setCurrentViewWindow(7);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ActivateTab9.
|
||||||
|
{
|
||||||
|
auto shortcut = WidgetUtils::createShortcut(coreConfig.getShortcut(CoreConfig::ActivateTab9), this, Qt::WidgetWithChildrenShortcut);
|
||||||
|
if (shortcut) {
|
||||||
|
connect(shortcut, &QShortcut::activated,
|
||||||
|
this, [this]() {
|
||||||
|
setCurrentViewWindow(8);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// AlternateTab.
|
||||||
|
{
|
||||||
|
auto shortcut = WidgetUtils::createShortcut(coreConfig.getShortcut(CoreConfig::AlternateTab), this, Qt::WidgetWithChildrenShortcut);
|
||||||
|
if (shortcut) {
|
||||||
|
connect(shortcut, &QShortcut::activated,
|
||||||
|
this, &ViewSplit::alternateTab);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ActivateNextTab.
|
||||||
|
{
|
||||||
|
auto shortcut = WidgetUtils::createShortcut(coreConfig.getShortcut(CoreConfig::ActivateNextTab), this, Qt::WidgetWithChildrenShortcut);
|
||||||
|
if (shortcut) {
|
||||||
|
connect(shortcut, &QShortcut::activated,
|
||||||
|
this, [this]() {
|
||||||
|
activateNextTab(false);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ActivatePreviousTab.
|
||||||
|
{
|
||||||
|
auto shortcut = WidgetUtils::createShortcut(coreConfig.getShortcut(CoreConfig::ActivatePreviousTab), this, Qt::WidgetWithChildrenShortcut);
|
||||||
|
if (shortcut) {
|
||||||
|
connect(shortcut, &QShortcut::activated,
|
||||||
|
this, [this]() {
|
||||||
|
activateNextTab(true);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ViewSplit::focus()
|
void ViewSplit::focus()
|
||||||
@ -759,3 +892,40 @@ void ViewSplit::setCurrentViewWindow(int p_idx)
|
|||||||
auto win = getViewWindow(p_idx);
|
auto win = getViewWindow(p_idx);
|
||||||
setCurrentViewWindow(win);
|
setCurrentViewWindow(win);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ViewSplit::alternateTab()
|
||||||
|
{
|
||||||
|
if (!m_lastViewWindow) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// It is fine even when m_lastViewWindow is a wild pointer. The implementation will just
|
||||||
|
// compare its value without dereferencing it.
|
||||||
|
if (-1 != indexOf(m_lastViewWindow)) {
|
||||||
|
setCurrentViewWindow(m_lastViewWindow);
|
||||||
|
} else {
|
||||||
|
m_lastViewWindow = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ViewSplit::activateNextTab(bool p_backward)
|
||||||
|
{
|
||||||
|
int idx = currentIndex();
|
||||||
|
if (idx == -1 || count() == 1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (p_backward) {
|
||||||
|
--idx;
|
||||||
|
if (idx < 0) {
|
||||||
|
idx = count() - 1;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
++idx;
|
||||||
|
if (idx >= count()) {
|
||||||
|
idx = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
setCurrentViewWindow(idx);
|
||||||
|
}
|
||||||
|
@ -129,6 +129,10 @@ namespace vnotex
|
|||||||
|
|
||||||
void focusCurrentViewWindow();
|
void focusCurrentViewWindow();
|
||||||
|
|
||||||
|
void alternateTab();
|
||||||
|
|
||||||
|
void activateNextTab(bool p_backward);
|
||||||
|
|
||||||
ID m_id = 0;
|
ID m_id = 0;
|
||||||
|
|
||||||
const QVector<QSharedPointer<ViewWorkspace>> &m_allWorkspaces;
|
const QVector<QSharedPointer<ViewWorkspace>> &m_allWorkspaces;
|
||||||
@ -143,6 +147,10 @@ namespace vnotex
|
|||||||
|
|
||||||
QActionGroup *m_workspaceActionGroup = nullptr;
|
QActionGroup *m_workspaceActionGroup = nullptr;
|
||||||
|
|
||||||
|
// Used for AlternateTab.
|
||||||
|
ViewWindow *m_currentViewWindow = nullptr;
|
||||||
|
ViewWindow *m_lastViewWindow = nullptr;
|
||||||
|
|
||||||
static QIcon s_windowListIcon;
|
static QIcon s_windowListIcon;
|
||||||
|
|
||||||
static QIcon s_windowListActiveIcon;
|
static QIcon s_windowListActiveIcon;
|
||||||
|
@ -180,14 +180,11 @@ void ViewWindow::detachFromBuffer(bool p_quiet)
|
|||||||
|
|
||||||
QIcon ViewWindow::getIcon() const
|
QIcon ViewWindow::getIcon() const
|
||||||
{
|
{
|
||||||
/*
|
|
||||||
if (m_buffer) {
|
if (m_buffer) {
|
||||||
return m_buffer->isModified() ? s_modifiedIcon : s_savedIcon;
|
return m_buffer->isModified() ? s_modifiedIcon : s_savedIcon;
|
||||||
} else {
|
} else {
|
||||||
return s_savedIcon;
|
return s_savedIcon;
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
return QIcon();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ViewWindow::getName() const
|
QString ViewWindow::getName() const
|
||||||
|
Loading…
x
Reference in New Issue
Block a user