mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 13:59:52 +08:00
Return to select on macOS
This commit is contained in:
parent
03e9982980
commit
78a6602ad4
@ -62,7 +62,7 @@ void VNewFileDialog::setupUI(const QString &p_title,
|
||||
templateBtn->setToolTip(tr("Manage Templates"));
|
||||
templateBtn->setProperty("FlatBtn", true);
|
||||
connect(templateBtn, &QPushButton::clicked,
|
||||
this, [this]() {
|
||||
this, []() {
|
||||
QUrl url = QUrl::fromLocalFile(g_config->getTemplateConfigFolder());
|
||||
QDesktopServices::openUrl(url);
|
||||
});
|
||||
@ -86,7 +86,7 @@ void VNewFileDialog::setupUI(const QString &p_title,
|
||||
m_insertTitleCB->setToolTip(tr("Insert note name into the new note as a title"));
|
||||
m_insertTitleCB->setChecked(g_config->getInsertTitleFromNoteName());
|
||||
connect(m_insertTitleCB, &QCheckBox::stateChanged,
|
||||
this, [this](int p_state) {
|
||||
this, [](int p_state) {
|
||||
g_config->setInsertTitleFromNoteName(p_state == Qt::Checked);
|
||||
});
|
||||
|
||||
|
@ -92,6 +92,19 @@ void VSelectDialog::keyPressEvent(QKeyEvent *p_event)
|
||||
return;
|
||||
}
|
||||
|
||||
// On Mac OS X, it is `Command+O` to activate an item, instead of Return.
|
||||
#if defined(Q_OS_MACOS) || defined(Q_OS_MAC)
|
||||
int key = p_event->key();
|
||||
if (key == Qt::Key_Return || key == Qt::Key_Enter) {
|
||||
p_event->accept();
|
||||
if (auto item = m_list->currentItem()) {
|
||||
selectionChosen(item);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
QDialog::keyPressEvent(p_event);
|
||||
}
|
||||
|
||||
|
@ -346,7 +346,7 @@ void VDirectoryTree::contextMenuRequested(QPoint pos)
|
||||
VUtils::fixTextWithShortcut(newNoteAct, "NewNote");
|
||||
newNoteAct->setToolTip(tr("Create a note in selected folder"));
|
||||
connect(newNoteAct, &QAction::triggered,
|
||||
this, [this]() {
|
||||
this, []() {
|
||||
g_mainWin->getFileList()->newFile();
|
||||
});
|
||||
|
||||
|
@ -411,7 +411,7 @@ void VMdEditor::contextMenuEvent(QContextMenuEvent *p_event)
|
||||
toggleLivePreviewAct->setToolTip(tr("Toggle live preview panel for graphs"));
|
||||
VUtils::fixTextWithCaptainShortcut(toggleLivePreviewAct, "LivePreview");
|
||||
connect(toggleLivePreviewAct, &QAction::triggered,
|
||||
this, [this, mdtab]() {
|
||||
this, [mdtab]() {
|
||||
mdtab->toggleLivePreview();
|
||||
});
|
||||
|
||||
@ -1477,14 +1477,14 @@ void VMdEditor::initLinkAndPreviewMenu(QAction *p_before, QMenu *p_menu, const Q
|
||||
|
||||
QAction *viewImageAct = new QAction(tr("View Image"), p_menu);
|
||||
connect(viewImageAct, &QAction::triggered,
|
||||
this, [this, imgPath]() {
|
||||
this, [imgPath]() {
|
||||
QDesktopServices::openUrl(VUtils::pathToUrl(imgPath));
|
||||
});
|
||||
p_menu->insertAction(p_before, viewImageAct);
|
||||
|
||||
QAction *copyImageLinkAct = new QAction(tr("Copy Image URL"), p_menu);
|
||||
connect(copyImageLinkAct, &QAction::triggered,
|
||||
this, [this, imgPath]() {
|
||||
this, [imgPath]() {
|
||||
QClipboard *clipboard = QApplication::clipboard();
|
||||
VClipboardUtils::setLinkToClipboard(clipboard,
|
||||
imgPath,
|
||||
@ -1495,7 +1495,7 @@ void VMdEditor::initLinkAndPreviewMenu(QAction *p_before, QMenu *p_menu, const Q
|
||||
if (isLocalFile) {
|
||||
QAction *copyImagePathAct = new QAction(tr("Copy Image Path"), p_menu);
|
||||
connect(copyImagePathAct, &QAction::triggered,
|
||||
this, [this, imgPath]() {
|
||||
this, [imgPath]() {
|
||||
QClipboard *clipboard = QApplication::clipboard();
|
||||
QMimeData *data = new QMimeData();
|
||||
data->setText(imgPath);
|
||||
@ -1552,14 +1552,14 @@ void VMdEditor::initLinkAndPreviewMenu(QAction *p_before, QMenu *p_menu, const Q
|
||||
|
||||
QAction *viewLinkAct = new QAction(tr("View Link"), p_menu);
|
||||
connect(viewLinkAct, &QAction::triggered,
|
||||
this, [this, linkUrl]() {
|
||||
this, [linkUrl]() {
|
||||
QDesktopServices::openUrl(VUtils::pathToUrl(linkUrl));
|
||||
});
|
||||
p_menu->insertAction(p_before, viewLinkAct);
|
||||
|
||||
QAction *copyLinkAct = new QAction(tr("Copy Link URL"), p_menu);
|
||||
connect(copyLinkAct, &QAction::triggered,
|
||||
this, [this, linkUrl]() {
|
||||
this, [linkUrl]() {
|
||||
QClipboard *clipboard = QApplication::clipboard();
|
||||
VClipboardUtils::setLinkToClipboard(clipboard,
|
||||
linkUrl,
|
||||
@ -1570,7 +1570,7 @@ void VMdEditor::initLinkAndPreviewMenu(QAction *p_before, QMenu *p_menu, const Q
|
||||
if (isLocalFile) {
|
||||
QAction *copyLinkPathAct = new QAction(tr("Copy Link Path"), p_menu);
|
||||
connect(copyLinkPathAct, &QAction::triggered,
|
||||
this, [this, linkUrl]() {
|
||||
this, [linkUrl]() {
|
||||
QClipboard *clipboard = QApplication::clipboard();
|
||||
QMimeData *data = new QMimeData();
|
||||
data->setText(linkUrl);
|
||||
|
@ -1085,7 +1085,7 @@ void VMdTab::applySnippet()
|
||||
QWidgetAction *act = new QWidgetAction(&menu);
|
||||
act->setDefaultWidget(sel);
|
||||
connect(sel, &VInsertSelector::accepted,
|
||||
this, [this, &menu]() {
|
||||
this, [&menu]() {
|
||||
QKeyEvent *escEvent = new QKeyEvent(QEvent::KeyPress, Qt::Key_Escape,
|
||||
Qt::NoModifier);
|
||||
QCoreApplication::postEvent(&menu, escEvent);
|
||||
|
@ -472,7 +472,7 @@ void VWebView::initPreviewTunnelMenu(QAction *p_before, QMenu *p_menu)
|
||||
}
|
||||
|
||||
connect(ag, &QActionGroup::triggered,
|
||||
this, [this](QAction *p_act) {
|
||||
this, [](QAction *p_act) {
|
||||
int data = p_act->data().toInt();
|
||||
g_config->setSmartLivePreview(data);
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user