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.
This commit is contained in:
Le Tan 2021-01-13 21:46:25 +08:00
parent 9e20f1b0a6
commit 9d76d1f06b
2 changed files with 17 additions and 8 deletions

View File

@ -86,18 +86,27 @@ void BufferMgr::open(const QString &p_filePath, const QSharedPointer<FileOpenPar
return; return;
} }
{ QFileInfo finfo(p_filePath);
QFileInfo info(p_filePath); if (!finfo.exists()) {
if (!info.exists() || info.isDir()) { qWarning() << QString("failed to open file %1 that does not exist").arg(p_filePath);
qWarning() << QString("failed to open file %1 exists:%2 isDir:%3").arg(p_filePath).arg(info.exists()).arg(info.isDir()); return;
return;
}
} }
// Check if it is an internal node or not. // Check if it is an internal node or not.
auto node = loadNodeByPath(p_filePath); auto node = loadNodeByPath(p_filePath);
if (node) { 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; return;
} }

View File

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