mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 13:59:52 +08:00
refine FindAndReplace widget activation logics
This commit is contained in:
parent
1f3b00ee44
commit
f80fe2629a
@ -50,6 +50,7 @@ namespace vnotex
|
||||
AlternateTab,
|
||||
ActivateNextTab,
|
||||
ActivatePreviousTab,
|
||||
FocusContentArea,
|
||||
MaxShortcut
|
||||
};
|
||||
Q_ENUM(Shortcut)
|
||||
|
@ -43,7 +43,8 @@
|
||||
"ActivateTab9" : "Ctrl+G, 9",
|
||||
"AlternateTab" : "Ctrl+G, 0",
|
||||
"ActivateNextTab" : "Ctrl+G, N",
|
||||
"ActivatePreviousTab" : "Ctrl+G, P"
|
||||
"ActivatePreviousTab" : "Ctrl+G, P",
|
||||
"FocusContentArea" : "Ctrl+G, Y"
|
||||
},
|
||||
"toolbar_icon_size" : 16,
|
||||
"note_management" : {
|
||||
|
@ -59,6 +59,7 @@ void FindAndReplaceWidget::setupUI()
|
||||
titleLayout->addWidget(closeBtn);
|
||||
|
||||
auto closeAct = new QAction(IconUtils::fetchIcon(iconFile), QString(), closeBtn);
|
||||
closeAct->setToolTip(tr("Close"));
|
||||
closeBtn->setDefaultAction(closeAct);
|
||||
connect(closeAct, &QAction::triggered,
|
||||
this, &FindAndReplaceWidget::close);
|
||||
@ -77,6 +78,8 @@ void FindAndReplaceWidget::setupUI()
|
||||
connect(m_findLineEdit, &QLineEdit::textChanged,
|
||||
m_findTextTimer, QOverload<>::of(&QTimer::start));
|
||||
|
||||
setFocusProxy(m_findLineEdit);
|
||||
|
||||
auto findNextBtn = new QPushButton(tr("Find &Next"), this);
|
||||
findNextBtn->setDefault(true);
|
||||
connect(findNextBtn, &QPushButton::clicked,
|
||||
|
@ -813,6 +813,22 @@ void ViewArea::setupShortcuts()
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// FocusContentArea.
|
||||
{
|
||||
auto shortcut = WidgetUtils::createShortcut(coreConfig.getShortcut(CoreConfig::FocusContentArea), this);
|
||||
if (shortcut) {
|
||||
connect(shortcut, &QShortcut::activated,
|
||||
this, [this]() {
|
||||
auto win = getCurrentViewWindow();
|
||||
if (win) {
|
||||
win->setFocus();
|
||||
} else {
|
||||
setFocus();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool ViewArea::close(Node *p_node, bool p_force)
|
||||
|
@ -409,10 +409,15 @@ QAction *ViewWindow::addAction(QToolBar *p_toolBar, ViewWindowToolBarHelper::Act
|
||||
connect(act, &QAction::triggered,
|
||||
this, [this]() {
|
||||
if (findAndReplaceWidgetVisible()) {
|
||||
const auto focusWidget = QApplication::focusWidget();
|
||||
if (m_findAndReplace == focusWidget || m_findAndReplace->isAncestorOf(focusWidget)) {
|
||||
hideFindAndReplaceWidget();
|
||||
} else {
|
||||
showFindAndReplaceWidget();
|
||||
}
|
||||
} else {
|
||||
showFindAndReplaceWidget();
|
||||
}
|
||||
});
|
||||
break;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user