1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

Make screenshot names use ~ISO 8601 (timestamp) instead of random string

Now screenshots will be saved as: `qTox-Screenshot_yyyy-MM-dd HH-mm-ss.zzz`

Since miliseconds are used, it shouldn't cause filename conflicts when
saving screenshots.

Change should make it easier for users to navigate through screenshots
chronologically.
This commit is contained in:
Zetok Zalbavar 2015-10-04 10:08:55 +01:00
parent 2ec716cb54
commit a13969b9ba
No known key found for this signature in database
GPG Key ID: C953D3880212068A

View File

@ -904,8 +904,18 @@ void ChatForm::doScreenshot()
}
void ChatForm::onScreenshotTaken(const QPixmap &pixmap) {
QTemporaryFile file(Settings::getInstance().getSettingsDirPath()+"screenshots"+QDir::separator()+"qTox-Screenshot-XXXXXXXX.png");
if (!file.open())
// use ~ISO 8601 for screenshot timestamp, considering FS limitations
// https://en.wikipedia.org/wiki/ISO_8601
// Windows has to be supported, thus filename can't have `:` in it :/
// Format should be: `qTox_Screenshot_yyyy-MM-dd HH-mm-ss.zzz.png`
QString filepath = QString("%1screenshots%2qTox_Screenshot_%3.png")
.arg(Settings::getInstance().getSettingsDirPath())
.arg(QDir::separator())
.arg(QDateTime::currentDateTime().toString("yyyy-MM-dd HH-mm-ss.zzz"));
QFile file(filepath);
if (!file.open(QFile::ReadWrite))
{
QMessageBox::warning(this,
tr("Failed to open temporary file", "Temporary file for screenshot"),
@ -913,8 +923,6 @@ void ChatForm::onScreenshotTaken(const QPixmap &pixmap) {
return;
}
file.setAutoRemove(false);
pixmap.save(&file, "PNG");
long long filesize = file.size();