added quick screenshot (#6025)
Modified Capture screenshot to save screenshots with a timestamped name in the user directory.
This commit is contained in:
parent
355933218d
commit
19d97e4180
3 changed files with 68 additions and 10 deletions
|
@ -1959,17 +1959,22 @@ void GMainWindow::OnSaveMovie() {
|
|||
|
||||
void GMainWindow::OnCaptureScreenshot() {
|
||||
OnPauseGame();
|
||||
QFileDialog png_dialog(this, tr("Capture Screenshot"), UISettings::values.screenshot_path,
|
||||
tr("PNG Image (*.png)"));
|
||||
png_dialog.setAcceptMode(QFileDialog::AcceptSave);
|
||||
png_dialog.setDefaultSuffix(QStringLiteral("png"));
|
||||
if (png_dialog.exec()) {
|
||||
const QString path = png_dialog.selectedFiles().first();
|
||||
if (!path.isEmpty()) {
|
||||
UISettings::values.screenshot_path = QFileInfo(path).path();
|
||||
render_window->CaptureScreenshot(UISettings::values.screenshot_resolution_factor, path);
|
||||
}
|
||||
QString path = UISettings::values.screenshot_path;
|
||||
if (!FileUtil::IsDirectory(path.toStdString())) {
|
||||
if (!FileUtil::CreateFullPath(path.toStdString())) {
|
||||
QMessageBox::information(this, tr("Invalid Screenshot Directory"),
|
||||
tr("Cannot create specified screenshot directory. Screenshot "
|
||||
"path is set back to its default value."));
|
||||
path = QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::UserDir));
|
||||
path.append(QStringLiteral("screenshots/"));
|
||||
UISettings::values.screenshot_path = path;
|
||||
};
|
||||
}
|
||||
const QString filename = game_title.remove(QRegularExpression(QStringLiteral("[\\/:?\"<>|]")));
|
||||
const QString timestamp =
|
||||
QDateTime::currentDateTime().toString(QStringLiteral("dd.MM.yy_hh.mm.ss.z"));
|
||||
path.append(QStringLiteral("/%1_%2.png").arg(filename).arg(timestamp));
|
||||
render_window->CaptureScreenshot(UISettings::values.screenshot_resolution_factor, path);
|
||||
OnStartGame();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue