mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 05:49:53 +08:00
SessionConfig: add external media default path
This commit is contained in:
parent
82ec6beeb5
commit
17af3b8dc0
@ -243,6 +243,7 @@ bool BufferMgr::openWithExternalProgram(const QString &p_filePath, const QString
|
|||||||
|
|
||||||
if (auto pro = ConfigMgr::getInst().getSessionConfig().findExternalProgram(p_name)) {
|
if (auto pro = ConfigMgr::getInst().getSessionConfig().findExternalProgram(p_name)) {
|
||||||
const auto command = pro->fetchCommand(p_filePath);
|
const auto command = pro->fetchCommand(p_filePath);
|
||||||
|
qDebug() << "external program" << command;
|
||||||
if (!command.isEmpty()) {
|
if (!command.isEmpty()) {
|
||||||
ProcessUtils::startDetached(command);
|
ProcessUtils::startDetached(command);
|
||||||
}
|
}
|
||||||
|
@ -131,6 +131,11 @@ void SessionConfig::loadCore(const QJsonObject &p_session)
|
|||||||
m_flashPage = readString(coreObj, QStringLiteral("flash_page"));
|
m_flashPage = readString(coreObj, QStringLiteral("flash_page"));
|
||||||
|
|
||||||
m_quickAccessFiles = readStringList(coreObj, QStringLiteral("quick_access"));
|
m_quickAccessFiles = readStringList(coreObj, QStringLiteral("quick_access"));
|
||||||
|
|
||||||
|
m_externalMediaDefaultPath = readString(coreObj, QStringLiteral("external_media_default_path"));
|
||||||
|
if (m_externalMediaDefaultPath.isEmpty()) {
|
||||||
|
m_externalMediaDefaultPath = QDir::homePath();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QJsonObject SessionConfig::saveCore() const
|
QJsonObject SessionConfig::saveCore() const
|
||||||
@ -145,6 +150,7 @@ QJsonObject SessionConfig::saveCore() const
|
|||||||
}
|
}
|
||||||
coreObj[QStringLiteral("flash_page")] = m_flashPage;
|
coreObj[QStringLiteral("flash_page")] = m_flashPage;
|
||||||
writeStringList(coreObj, QStringLiteral("quick_access"), m_quickAccessFiles);
|
writeStringList(coreObj, QStringLiteral("quick_access"), m_quickAccessFiles);
|
||||||
|
coreObj[QStringLiteral("external_media_default_path")] = m_externalMediaDefaultPath;
|
||||||
return coreObj;
|
return coreObj;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -160,6 +166,16 @@ void SessionConfig::setNewNotebookDefaultRootFolderPath(const QString &p_path)
|
|||||||
this);
|
this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const QString &SessionConfig::getExternalMediaDefaultPath() const
|
||||||
|
{
|
||||||
|
return m_externalMediaDefaultPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SessionConfig::setExternalMediaDefaultPath(const QString &p_path)
|
||||||
|
{
|
||||||
|
updateConfig(m_externalMediaDefaultPath, p_path, this);
|
||||||
|
}
|
||||||
|
|
||||||
const QVector<SessionConfig::NotebookItem> &SessionConfig::getNotebooks() const
|
const QVector<SessionConfig::NotebookItem> &SessionConfig::getNotebooks() const
|
||||||
{
|
{
|
||||||
return m_notebooks;
|
return m_notebooks;
|
||||||
|
@ -85,6 +85,9 @@ namespace vnotex
|
|||||||
const QString &getNewNotebookDefaultRootFolderPath() const;
|
const QString &getNewNotebookDefaultRootFolderPath() const;
|
||||||
void setNewNotebookDefaultRootFolderPath(const QString &p_path);
|
void setNewNotebookDefaultRootFolderPath(const QString &p_path);
|
||||||
|
|
||||||
|
const QString &getExternalMediaDefaultPath() const;
|
||||||
|
void setExternalMediaDefaultPath(const QString &p_path);
|
||||||
|
|
||||||
const QString &getCurrentNotebookRootFolderPath() const;
|
const QString &getCurrentNotebookRootFolderPath() const;
|
||||||
void setCurrentNotebookRootFolderPath(const QString &p_path);
|
void setCurrentNotebookRootFolderPath(const QString &p_path);
|
||||||
|
|
||||||
@ -206,6 +209,9 @@ namespace vnotex
|
|||||||
QVector<ExternalProgram> m_externalPrograms;
|
QVector<ExternalProgram> m_externalPrograms;
|
||||||
|
|
||||||
QVector<HistoryItem> m_history;
|
QVector<HistoryItem> m_history;
|
||||||
|
|
||||||
|
// Default folder path to open for external media like images and files.
|
||||||
|
QString m_externalMediaDefaultPath;;
|
||||||
};
|
};
|
||||||
} // ns vnotex
|
} // ns vnotex
|
||||||
|
|
||||||
|
@ -22,6 +22,8 @@
|
|||||||
#include "messageboxhelper.h"
|
#include "messageboxhelper.h"
|
||||||
#include "fileopenparameters.h"
|
#include "fileopenparameters.h"
|
||||||
#include <core/exception.h>
|
#include <core/exception.h>
|
||||||
|
#include <core/sessionconfig.h>
|
||||||
|
#include <core/configmgr.h>
|
||||||
|
|
||||||
using namespace vnotex;
|
using namespace vnotex;
|
||||||
|
|
||||||
@ -63,13 +65,15 @@ void AttachmentPopup::setupUI()
|
|||||||
// Get dest folder path before other dialogs.
|
// Get dest folder path before other dialogs.
|
||||||
const auto destFolderPath = getDestFolderPath();
|
const auto destFolderPath = getDestFolderPath();
|
||||||
|
|
||||||
static QString lastDirPath = QDir::homePath();
|
auto &sessionConfig = ConfigMgr::getInst().getSessionConfig();
|
||||||
auto files = QFileDialog::getOpenFileNames(this, tr("Select Files As Attachments"), lastDirPath);
|
auto files = QFileDialog::getOpenFileNames(this,
|
||||||
|
tr("Select Files As Attachments"),
|
||||||
|
sessionConfig.getExternalMediaDefaultPath());
|
||||||
if (files.isEmpty()) {
|
if (files.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
lastDirPath = QFileInfo(files[0]).path();
|
sessionConfig.setExternalMediaDefaultPath(QFileInfo(files[0]).path());
|
||||||
|
|
||||||
addAttachments(destFolderPath, files);
|
addAttachments(destFolderPath, files);
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,8 @@
|
|||||||
#include <widgets/lineedit.h>
|
#include <widgets/lineedit.h>
|
||||||
#include <utils/fileutils.h>
|
#include <utils/fileutils.h>
|
||||||
#include <utils/pathutils.h>
|
#include <utils/pathutils.h>
|
||||||
|
#include <core/sessionconfig.h>
|
||||||
|
#include <core/configmgr.h>
|
||||||
|
|
||||||
using namespace vnotex;
|
using namespace vnotex;
|
||||||
|
|
||||||
@ -224,15 +226,17 @@ void ImageInsertDialog::checkInput()
|
|||||||
|
|
||||||
void ImageInsertDialog::browseFile()
|
void ImageInsertDialog::browseFile()
|
||||||
{
|
{
|
||||||
QString bpath(QDir::homePath());
|
auto &sessionConfig = ConfigMgr::getInst().getSessionConfig();
|
||||||
QString filePath = QFileDialog::getOpenFileName(this,
|
QString filePath = QFileDialog::getOpenFileName(this,
|
||||||
tr("Select Image To Insert"),
|
tr("Select Image To Insert"),
|
||||||
bpath,
|
sessionConfig.getExternalMediaDefaultPath(),
|
||||||
tr("Images (*.png *.xpm *.jpg *.bmp *.gif *.svg *.webp);;All (*.*)"));
|
tr("Images (*.png *.xpm *.jpg *.bmp *.gif *.svg *.webp);;All (*.*)"));
|
||||||
if (filePath.isEmpty()) {
|
if (filePath.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sessionConfig.setExternalMediaDefaultPath(filePath);
|
||||||
|
|
||||||
m_source = Source::LocalFile;
|
m_source = Source::LocalFile;
|
||||||
|
|
||||||
setImagePath(filePath);
|
setImagePath(filePath);
|
||||||
|
@ -533,6 +533,7 @@ QGroupBox *MarkdownEditorPage::setupGeneralGroup()
|
|||||||
{
|
{
|
||||||
m_plantUmlWebServiceLineEdit = WidgetsFactory::createLineEdit(box);
|
m_plantUmlWebServiceLineEdit = WidgetsFactory::createLineEdit(box);
|
||||||
m_plantUmlWebServiceLineEdit->setToolTip(tr("Override the Web service used to render PlantUml graphs"));
|
m_plantUmlWebServiceLineEdit->setToolTip(tr("Override the Web service used to render PlantUml graphs"));
|
||||||
|
m_plantUmlWebServiceLineEdit->setPlaceholderText(tr("Empty to use default one"));
|
||||||
|
|
||||||
const QString label(tr("Override PlantUml Web service:"));
|
const QString label(tr("Override PlantUml Web service:"));
|
||||||
layout->addRow(label, m_plantUmlWebServiceLineEdit);
|
layout->addRow(label, m_plantUmlWebServiceLineEdit);
|
||||||
@ -603,6 +604,7 @@ QGroupBox *MarkdownEditorPage::setupGeneralGroup()
|
|||||||
{
|
{
|
||||||
m_mathJaxScriptLineEdit = WidgetsFactory::createLineEdit(box);
|
m_mathJaxScriptLineEdit = WidgetsFactory::createLineEdit(box);
|
||||||
m_mathJaxScriptLineEdit->setToolTip(tr("Override the MathJax script used to render math formulas"));
|
m_mathJaxScriptLineEdit->setToolTip(tr("Override the MathJax script used to render math formulas"));
|
||||||
|
m_mathJaxScriptLineEdit->setPlaceholderText(tr("Empty to use default one"));
|
||||||
|
|
||||||
const QString label(tr("Override MathJax script:"));
|
const QString label(tr("Override MathJax script:"));
|
||||||
layout->addRow(label, m_mathJaxScriptLineEdit);
|
layout->addRow(label, m_mathJaxScriptLineEdit);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user