diff options
| author | 2020-07-06 23:30:49 -0400 | |
|---|---|---|
| committer | 2020-07-20 23:03:55 -0400 | |
| commit | a723ed31fd4c5b3dbad5f2ad53a6d1556db15569 (patch) | |
| tree | ca77b2c42d671df2ee7b1e0dda40ebd22383db54 /src | |
| parent | configuration: Setup UI to config screenshot path and saving (diff) | |
| download | yuzu-a723ed31fd4c5b3dbad5f2ad53a6d1556db15569.tar.gz yuzu-a723ed31fd4c5b3dbad5f2ad53a6d1556db15569.tar.xz yuzu-a723ed31fd4c5b3dbad5f2ad53a6d1556db15569.zip | |
main: rewrite (save as) screenshot saving
This picks a default directory and file name. If on Windows and save-as screenshot saving is enabled, it asks the user, first defaulting to the default screenshot path, and with a default filename in the format `[title_id]_[year-mt-dy_hr-mn-sc-msc].png`. Otherwise, or on Linux for now, it simply saves a file in that directory with that file name.
Diffstat (limited to '')
| -rw-r--r-- | src/yuzu/main.cpp | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index 31a635176..c6bf5214e 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp | |||
| @@ -2153,17 +2153,26 @@ void GMainWindow::OnToggleFilterBar() { | |||
| 2153 | 2153 | ||
| 2154 | void GMainWindow::OnCaptureScreenshot() { | 2154 | void GMainWindow::OnCaptureScreenshot() { |
| 2155 | OnPauseGame(); | 2155 | OnPauseGame(); |
| 2156 | QFileDialog png_dialog(this, tr("Capture Screenshot"), UISettings::values.screenshot_path, | 2156 | |
| 2157 | tr("PNG Image (*.png)")); | 2157 | const u64 title_id = Core::System::GetInstance().CurrentProcess()->GetTitleID(); |
| 2158 | png_dialog.setAcceptMode(QFileDialog::AcceptSave); | 2158 | const auto screenshot_path = FileUtil::GetUserPath(FileUtil::UserPath::ScreenshotsDir); |
| 2159 | png_dialog.setDefaultSuffix(QStringLiteral("png")); | 2159 | const auto date = QDateTime::currentDateTime() |
| 2160 | if (png_dialog.exec()) { | 2160 | .toString(QStringLiteral("yyyy-MM-dd_hh-mm-ss-zzz")) |
| 2161 | const QString path = png_dialog.selectedFiles().first(); | 2161 | .toStdString(); |
| 2162 | if (!path.isEmpty()) { | 2162 | QString filename = QString::fromStdString(screenshot_path + fmt::format("{:016X}", title_id) + |
| 2163 | UISettings::values.screenshot_path = QFileInfo(path).path(); | 2163 | "_" + date + ".png"); |
| 2164 | render_window->CaptureScreenshot(UISettings::values.screenshot_resolution_factor, path); | 2164 | |
| 2165 | #ifdef _WIN32 | ||
| 2166 | if (UISettings::values.enable_screenshot_save_as) { | ||
| 2167 | filename = QFileDialog::getSaveFileName(this, tr("Capture Screenshot"), filename, | ||
| 2168 | tr("PNG Image (*.png)")); | ||
| 2169 | if (filename.isEmpty()) { | ||
| 2170 | OnStartGame(); | ||
| 2171 | return; | ||
| 2165 | } | 2172 | } |
| 2166 | } | 2173 | } |
| 2174 | #endif | ||
| 2175 | render_window->CaptureScreenshot(UISettings::values.screenshot_resolution_factor, filename); | ||
| 2167 | OnStartGame(); | 2176 | OnStartGame(); |
| 2168 | } | 2177 | } |
| 2169 | 2178 | ||