mirror of
				https://github.com/PabloMK7/citra.git
				synced 2025-10-31 05:40:04 +00:00 
			
		
		
		
	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
				
			
		|  | @ -2,7 +2,10 @@ | |||
| // Licensed under GPLv2 or any later version
 | ||||
| // Refer to the license.txt file included.
 | ||||
| 
 | ||||
| #include <QDesktopServices> | ||||
| #include <QFileDialog> | ||||
| #include <QMessageBox> | ||||
| #include <QUrl> | ||||
| #include "citra_qt/configuration/configure_general.h" | ||||
| #include "citra_qt/uisettings.h" | ||||
| #include "core/core.h" | ||||
|  | @ -56,6 +59,15 @@ ConfigureGeneral::ConfigureGeneral(QWidget* parent) | |||
|                     .rightJustified(tr("unthrottled").size())); | ||||
|         } | ||||
|     }); | ||||
| 
 | ||||
|     connect(ui->change_screenshot_dir, &QToolButton::clicked, this, [this] { | ||||
|         const QString dir_path = QFileDialog::getExistingDirectory( | ||||
|             this, tr("Select Screenshot Directory"), ui->screenshot_dir_path->text(), | ||||
|             QFileDialog::ShowDirsOnly); | ||||
|         if (!dir_path.isEmpty()) { | ||||
|             ui->screenshot_dir_path->setText(dir_path); | ||||
|         } | ||||
|     }); | ||||
| } | ||||
| 
 | ||||
| ConfigureGeneral::~ConfigureGeneral() = default; | ||||
|  | @ -101,6 +113,16 @@ void ConfigureGeneral::SetConfiguration() { | |||
|                 .arg(SliderToSettings(ui->frame_limit_alternate->value())) | ||||
|                 .rightJustified(tr("unthrottled").size())); | ||||
|     } | ||||
| 
 | ||||
|     QString screenshot_path = UISettings::values.screenshot_path; | ||||
|     if (screenshot_path.isEmpty()) { | ||||
|         screenshot_path = | ||||
|             QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::UserDir)); | ||||
|         screenshot_path.append(QStringLiteral("screenshots/")); | ||||
|         FileUtil::CreateFullPath(screenshot_path.toStdString()); | ||||
|         UISettings::values.screenshot_path = screenshot_path; | ||||
|     } | ||||
|     ui->screenshot_dir_path->setText(screenshot_path); | ||||
| } | ||||
| 
 | ||||
| void ConfigureGeneral::ResetDefaults() { | ||||
|  | @ -124,6 +146,8 @@ void ConfigureGeneral::ApplyConfiguration() { | |||
|     UISettings::values.check_for_update_on_start = ui->toggle_update_check->isChecked(); | ||||
|     UISettings::values.update_on_close = ui->toggle_auto_update->isChecked(); | ||||
| 
 | ||||
|     UISettings::values.screenshot_path = ui->screenshot_dir_path->text(); | ||||
| 
 | ||||
|     Settings::values.region_value = ui->region_combobox->currentIndex() - 1; | ||||
| 
 | ||||
|     if (ui->frame_limit->value() == ui->frame_limit->maximum()) { | ||||
|  |  | |||
|  | @ -213,6 +213,33 @@ | |||
|        </layout> | ||||
|       </widget> | ||||
|      </item> | ||||
|      <item> | ||||
|       <widget class="QGroupBox" name="screenshot_group"> | ||||
|        <property name="title"> | ||||
|         <string>Screenshots</string> | ||||
|        </property> | ||||
|        <layout class="QHBoxLayout" name="horizontalLayout_2"> | ||||
|         <item> | ||||
|          <widget class="QLabel" name="label_2"> | ||||
|           <property name="text"> | ||||
|            <string>Save Screenshots To</string> | ||||
|           </property> | ||||
|          </widget> | ||||
|         </item> | ||||
|         <item> | ||||
|          <widget class="QLineEdit" name="screenshot_dir_path"> | ||||
|          </widget> | ||||
|         </item> | ||||
|         <item> | ||||
|          <widget class="QToolButton" name="change_screenshot_dir"> | ||||
|           <property name="text"> | ||||
|            <string>...</string> | ||||
|           </property> | ||||
|          </widget> | ||||
|         </item> | ||||
|        </layout> | ||||
|       </widget> | ||||
|      </item> | ||||
|      <item alignment="Qt::AlignRight"> | ||||
|       <widget class="QPushButton" name="button_reset_defaults"> | ||||
|        <property name="text"> | ||||
|  | @ -247,6 +274,8 @@ | |||
|   <tabstop>frame_limit</tabstop> | ||||
|   <tabstop>toggle_alternate_speed</tabstop> | ||||
|   <tabstop>frame_limit_alternate</tabstop> | ||||
|   <tabstop>screenshot_dir_path</tabstop> | ||||
|   <tabstop>change_screenshot_dir</tabstop> | ||||
|   <tabstop>button_reset_defaults</tabstop> | ||||
|  </tabstops> | ||||
|  <resources/> | ||||
|  |  | |||
|  | @ -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