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

Merge remote-tracking branch 'zetok/screenshotname'

This commit is contained in:
agilob 2015-10-05 19:48:55 +01:00
commit eaf44c45d5
No known key found for this signature in database
GPG Key ID: 296F0B764741106C

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();