shortcuts updated

This commit is contained in:
Zira project 2020-12-28 15:51:30 +05:00
parent 61f9c9da78
commit 327347ab02
3 changed files with 24 additions and 3 deletions

View File

@ -370,6 +370,11 @@ Editor::Editor(QWidget * parent):
shortcutContextMenu->setContext(Qt::WidgetShortcut);
connect(shortcutContextMenu, SIGNAL(activated()), this, SLOT(contextMenu()));
QString shortcutGoToStr = QString::fromStdString(Settings::get("shortcut_goto"));
QShortcut * shortcutGoTo = new QShortcut(QKeySequence(shortcutGoToStr), this);
shortcutGoTo->setContext(Qt::WidgetShortcut);
connect(shortcutGoTo, SIGNAL(activated()), this, SLOT(gotoLineRequest()));
// order matters
// annotation
lineAnnotation = new Annotation(this);
@ -2355,9 +2360,15 @@ bool Editor::onKeyPress(QKeyEvent *e)
return false;
}
// hide popup
if (code == Qt::Key_Escape && completePopup->isVisible()) {
hideCompletePopup();
return false;
if (code == Qt::Key_Escape) {
if (completePopup->isVisible()) {
hideCompletePopup();
return false;
}
if (search->isVisible()) {
closeSearch();
return false;
}
}
// switch tooltip page
if ((code == Qt::Key_Down || code == Qt::Key_Up) && tooltipLabel.isVisible() && tooltipSavedList.size()>1 && tooltipSavedPageOffset >= 0 && tooltipSavedPageOffset < tooltipSavedList.size()) {
@ -6427,6 +6438,7 @@ void Editor::updateMarksAndMapArea()
void Editor::findToggle()
{
QTextCursor curs = textCursor();
/*
if (!search->isVisible() || curs.hasSelection()) {
if (curs.hasSelection()) {
searchString = curs.selectedText();
@ -6437,6 +6449,13 @@ void Editor::findToggle()
} else {
closeSearch();
}
*/
if (curs.hasSelection()) {
searchString = curs.selectedText();
static_cast<Search *>(search)->setFindEditText(searchString);
}
showSearch();
highlightExtras();
}
void Editor::showSearch()

View File

@ -110,6 +110,7 @@ void Settings::initData()
{"shortcut_delete_line", "Ctrl+Shift+D"},
{"shortcut_context_menu", "F2"},
{"shortcut_focus_tree", "Alt+Down"},
{"shortcut_goto", "Ctrl+G"},
{"shortcut_open_file", "Ctrl+O"},
{"shortcut_open_project", "Ctrl+Shift+O"},
{"shortcut_new_file", "Ctrl+N"},

View File

@ -65,6 +65,7 @@ std::vector<std::pair<std::string, std::string>> ShortcutsDialog::getShortcutNam
{"shortcut_multiselect", "Multi-Selection"},
{"shortcut_help", "Context help"},
{"shortcut_quick_access", "Quick Access"},
{"shortcut_goto", "Go to line"},
{"shortcut_duplicate_line", "Duplicate line"},
{"shortcut_delete_line", "Delete line"},
{"shortcut_context_menu", "Context menu"},