From b3555cffbaa0151d73b990833ef22f67ee9aeda0 Mon Sep 17 00:00:00 2001 From: Le Tan Date: Fri, 26 Apr 2019 19:43:44 +0800 Subject: [PATCH] FileList: fix context menu and do not open new file in unkown type --- src/vfilelist.cpp | 4 ++-- src/vmainwindow.cpp | 9 ++++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/vfilelist.cpp b/src/vfilelist.cpp index c0f46071..ba15b8d0 100644 --- a/src/vfilelist.cpp +++ b/src/vfilelist.cpp @@ -659,14 +659,14 @@ void VFileList::contextMenuRequested(QPoint pos) menu.addSeparator(); if (selectedSize == 1) { QAction *openLocationAct = new QAction(VIconUtils::menuIcon(":/resources/icons/open_location.svg"), - tr("&Open Note Location"), + tr("Open Note &Location"), &menu); openLocationAct->setToolTip(tr("Explore the folder containing this note in operating system")); connect(openLocationAct, &QAction::triggered, this, &VFileList::openFileLocation); menu.addAction(openLocationAct); - QAction *copyPathAct = new QAction(tr("Copy File Path"), &menu); + QAction *copyPathAct = new QAction(tr("Copy File &Path"), &menu); connect(copyPathAct, &QAction::triggered, this, [this]() { QList items = fileList->selectedItems(); diff --git a/src/vmainwindow.cpp b/src/vmainwindow.cpp index 0057e89e..e6a97d71 100644 --- a/src/vmainwindow.cpp +++ b/src/vmainwindow.cpp @@ -276,7 +276,14 @@ void VMainWindow::setupUI() connect(m_fileList, &VFileList::fileClicked, m_editArea, &VEditArea::openFile); connect(m_fileList, &VFileList::fileCreated, - m_editArea, &VEditArea::openFile); + m_editArea, [this](VNoteFile *p_file, + OpenFileMode p_mode, + bool p_forceMode) { + if (p_file->getDocType() == DocType::Markdown + || p_file->getDocType() == DocType::Html) { + m_editArea->openFile(p_file, p_mode, p_forceMode); + } + }); connect(m_fileList, &VFileList::fileUpdated, m_editArea, &VEditArea::handleFileUpdated); connect(m_editArea, &VEditArea::tabStatusUpdated,