FileList: fix context menu and do not open new file in unkown type

This commit is contained in:
Le Tan 2019-04-26 19:43:44 +08:00
parent de1e6ed3fa
commit b3555cffba
2 changed files with 10 additions and 3 deletions

View File

@ -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<QListWidgetItem *> items = fileList->selectedItems();

View File

@ -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,