Browse Source

support opening link to folder in read mode

If it is a folder node, then locate to it. Otherwise, open it in the
file browser of OS.
Le Tan 4 years ago
parent
commit
9d76d1f06b
2 changed files with 17 additions and 8 deletions
  1. 16 7
      src/core/buffermgr.cpp
  2. 1 1
      src/core/configmgr.cpp

+ 16 - 7
src/core/buffermgr.cpp

@@ -86,18 +86,27 @@ void BufferMgr::open(const QString &p_filePath, const QSharedPointer<FileOpenPar
         return;
     }
 
-    {
-        QFileInfo info(p_filePath);
-        if (!info.exists() || info.isDir()) {
-            qWarning() << QString("failed to open file %1 exists:%2 isDir:%3").arg(p_filePath).arg(info.exists()).arg(info.isDir());
-            return;
-        }
+    QFileInfo finfo(p_filePath);
+    if (!finfo.exists()) {
+        qWarning() << QString("failed to open file %1 that does not exist").arg(p_filePath);
+        return;
     }
 
     // Check if it is an internal node or not.
     auto node = loadNodeByPath(p_filePath);
     if (node) {
-        open(node.data(), p_paras);
+        if (node->getType() == Node::File) {
+            open(node.data(), p_paras);
+            return;
+        } else {
+            // Folder node. Currently just locate to it.
+            emit VNoteX::getInst().locateNodeRequested(node.data());
+            return;
+        }
+    }
+
+    if (finfo.isDir()) {
+        WidgetUtils::openUrlByDesktop(QUrl::fromLocalFile(p_filePath));
         return;
     }
 

+ 1 - 1
src/core/configmgr.cpp

@@ -24,7 +24,7 @@
 using namespace vnotex;
 
 #ifndef QT_NO_DEBUG
-#define VX_DEBUG_WEB
+// #define VX_DEBUG_WEB
 #endif
 
 const QString ConfigMgr::c_orgName = "VNote";