diff --git a/src/resources/vnote.ini b/src/resources/vnote.ini index 9b124100..baf7dafd 100644 --- a/src/resources/vnote.ini +++ b/src/resources/vnote.ini @@ -233,6 +233,9 @@ note_list_view_order=0 ; 1 - 6 outline_expanded_level=6 +; [optional] Prefix of the name of inserted images +image_name_prefix= + [export] ; Path of the wkhtmltopdf tool wkhtmltopdf=wkhtmltopdf diff --git a/src/utils/vutils.cpp b/src/utils/vutils.cpp index eb76757d..519f3116 100644 --- a/src/utils/vutils.cpp +++ b/src/utils/vutils.cpp @@ -151,13 +151,16 @@ QString VUtils::generateImageFileName(const QString &path, // Constrain the length of the name. baseName.truncate(10); + baseName.prepend(g_config->getImageNamePrefix()); + if (!baseName.isEmpty()) { - baseName.prepend('_'); + baseName.append('_'); } // Add current time and random number to make the name be most likely unique - baseName = baseName + '_' + QString::number(QDateTime::currentDateTime().toTime_t()); - baseName = baseName + '_' + QString::number(qrand()); + baseName += QString::number(QDateTime::currentDateTime().toTime_t()) + + '_' + + QString::number(qrand()); QDir dir(path); QString imageName = baseName + "." + format.toLower(); diff --git a/src/vconfigmanager.cpp b/src/vconfigmanager.cpp index 99bf63a8..20e00c6c 100644 --- a/src/vconfigmanager.cpp +++ b/src/vconfigmanager.cpp @@ -303,6 +303,9 @@ void VConfigManager::initialize() m_outlineExpandedLevel = getConfigFromSettings("global", "outline_expanded_level").toInt(); + + m_imageNamePrefix = getConfigFromSettings("global", + "image_name_prefix").toString(); } void VConfigManager::initSettings() diff --git a/src/vconfigmanager.h b/src/vconfigmanager.h index 4aa4c34c..5bb4761d 100644 --- a/src/vconfigmanager.h +++ b/src/vconfigmanager.h @@ -520,6 +520,8 @@ public: int getOutlineExpandedLevel() const; void setOutlineExpandedLevel(int p_level); + const QString &getImageNamePrefix() const; + private: // Look up a config from user and default settings. QVariant getConfigFromSettings(const QString §ion, const QString &key) const; @@ -936,6 +938,9 @@ private: // Expanded level of outline. int m_outlineExpandedLevel; + // Prefix of the name of inserted images. + QString m_imageNamePrefix; + // The name of the config file in each directory. static const QString c_dirConfigFile; @@ -2444,4 +2449,9 @@ inline void VConfigManager::setOutlineExpandedLevel(int p_level) m_outlineExpandedLevel = p_level; setConfigToSettings("global", "outline_expanded_level", m_outlineExpandedLevel); } + +inline const QString &VConfigManager::getImageNamePrefix() const +{ + return m_imageNamePrefix; +} #endif // VCONFIGMANAGER_H diff --git a/src/vwebview.cpp b/src/vwebview.cpp index 29da582d..6b0f10b6 100644 --- a/src/vwebview.cpp +++ b/src/vwebview.cpp @@ -42,7 +42,7 @@ VWebView::VWebView(VFile *p_file, QWidget *p_parent) void VWebView::contextMenuEvent(QContextMenuEvent *p_event) { if (m_inPreview) { - QWebEngineView(p_event); + QWebEngineView::contextMenuEvent(p_event); return; }