Просмотр исходного кода

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

Le Tan 6 лет назад
Родитель
Сommit
b3555cffba
2 измененных файлов с 10 добавлено и 3 удалено
  1. 2 2
      src/vfilelist.cpp
  2. 8 1
      src/vmainwindow.cpp

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

+ 8 - 1
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,