Browse Source

add elapsed time to the image name

Add elapsed time to the image name when inserting an image.

Signed-off-by: Le Tan <[email protected]>
Le Tan 9 năm trước cách đây
mục cha
commit
de8b54afa7
1 tập tin đã thay đổi với 4 bổ sung0 xóa
  1. 4 0
      src/utils/vutils.cpp

+ 4 - 0
src/utils/vutils.cpp

@@ -9,6 +9,7 @@
 #include <QMimeData>
 #include <QJsonObject>
 #include <QJsonDocument>
+#include <QDateTime>
 
 VUtils::VUtils()
 {
@@ -71,6 +72,9 @@ QString VUtils::generateImageFileName(const QString &path, const QString &title,
     QString baseName(title.toLower());
     baseName.replace(regExp, "_");
     baseName.prepend('_');
+
+    // Add current time to make the name be most likely unique
+    baseName = baseName + '_' + QString::number(QDateTime::currentDateTime().toTime_t());
     QString imageName = baseName + "." + format.toLower();
     QString filePath = QDir(path).filePath(imageName);
     int index = 1;