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:
parent
2ec716cb54
commit
a13969b9ba
|
@ -904,8 +904,18 @@ void ChatForm::doScreenshot()
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatForm::onScreenshotTaken(const QPixmap &pixmap) {
|
void ChatForm::onScreenshotTaken(const QPixmap &pixmap) {
|
||||||
QTemporaryFile file(Settings::getInstance().getSettingsDirPath()+"screenshots"+QDir::separator()+"qTox-Screenshot-XXXXXXXX.png");
|
// use ~ISO 8601 for screenshot timestamp, considering FS limitations
|
||||||
if (!file.open())
|
// 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,
|
QMessageBox::warning(this,
|
||||||
tr("Failed to open temporary file", "Temporary file for screenshot"),
|
tr("Failed to open temporary file", "Temporary file for screenshot"),
|
||||||
|
@ -913,8 +923,6 @@ void ChatForm::onScreenshotTaken(const QPixmap &pixmap) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
file.setAutoRemove(false);
|
|
||||||
|
|
||||||
pixmap.save(&file, "PNG");
|
pixmap.save(&file, "PNG");
|
||||||
|
|
||||||
long long filesize = file.size();
|
long long filesize = file.size();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user