mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 05:49:53 +08:00
config: add [global]/image_name_prefix for inserted images
This commit is contained in:
parent
40424b7931
commit
59efed94f3
@ -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
|
||||
|
@ -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();
|
||||
|
@ -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()
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user