mirror of
				https://github.com/PabloMK7/citra.git
				synced 2025-10-30 21:30: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
 | // Licensed under GPLv2 or any later version
 | ||||||
| // Refer to the license.txt file included.
 | // Refer to the license.txt file included.
 | ||||||
| 
 | 
 | ||||||
|  | #include <QDesktopServices> | ||||||
|  | #include <QFileDialog> | ||||||
| #include <QMessageBox> | #include <QMessageBox> | ||||||
|  | #include <QUrl> | ||||||
| #include "citra_qt/configuration/configure_general.h" | #include "citra_qt/configuration/configure_general.h" | ||||||
| #include "citra_qt/uisettings.h" | #include "citra_qt/uisettings.h" | ||||||
| #include "core/core.h" | #include "core/core.h" | ||||||
|  | @ -56,6 +59,15 @@ ConfigureGeneral::ConfigureGeneral(QWidget* parent) | ||||||
|                     .rightJustified(tr("unthrottled").size())); |                     .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; | ConfigureGeneral::~ConfigureGeneral() = default; | ||||||
|  | @ -101,6 +113,16 @@ void ConfigureGeneral::SetConfiguration() { | ||||||
|                 .arg(SliderToSettings(ui->frame_limit_alternate->value())) |                 .arg(SliderToSettings(ui->frame_limit_alternate->value())) | ||||||
|                 .rightJustified(tr("unthrottled").size())); |                 .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() { | void ConfigureGeneral::ResetDefaults() { | ||||||
|  | @ -124,6 +146,8 @@ void ConfigureGeneral::ApplyConfiguration() { | ||||||
|     UISettings::values.check_for_update_on_start = ui->toggle_update_check->isChecked(); |     UISettings::values.check_for_update_on_start = ui->toggle_update_check->isChecked(); | ||||||
|     UISettings::values.update_on_close = ui->toggle_auto_update->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; |     Settings::values.region_value = ui->region_combobox->currentIndex() - 1; | ||||||
| 
 | 
 | ||||||
|     if (ui->frame_limit->value() == ui->frame_limit->maximum()) { |     if (ui->frame_limit->value() == ui->frame_limit->maximum()) { | ||||||
|  |  | ||||||
|  | @ -213,6 +213,33 @@ | ||||||
|        </layout> |        </layout> | ||||||
|       </widget> |       </widget> | ||||||
|      </item> |      </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"> |      <item alignment="Qt::AlignRight"> | ||||||
|       <widget class="QPushButton" name="button_reset_defaults"> |       <widget class="QPushButton" name="button_reset_defaults"> | ||||||
|        <property name="text"> |        <property name="text"> | ||||||
|  | @ -247,6 +274,8 @@ | ||||||
|   <tabstop>frame_limit</tabstop> |   <tabstop>frame_limit</tabstop> | ||||||
|   <tabstop>toggle_alternate_speed</tabstop> |   <tabstop>toggle_alternate_speed</tabstop> | ||||||
|   <tabstop>frame_limit_alternate</tabstop> |   <tabstop>frame_limit_alternate</tabstop> | ||||||
|  |   <tabstop>screenshot_dir_path</tabstop> | ||||||
|  |   <tabstop>change_screenshot_dir</tabstop> | ||||||
|   <tabstop>button_reset_defaults</tabstop> |   <tabstop>button_reset_defaults</tabstop> | ||||||
|  </tabstops> |  </tabstops> | ||||||
|  <resources/> |  <resources/> | ||||||
|  |  | ||||||
|  | @ -1959,17 +1959,22 @@ void GMainWindow::OnSaveMovie() { | ||||||
| 
 | 
 | ||||||
| void GMainWindow::OnCaptureScreenshot() { | void GMainWindow::OnCaptureScreenshot() { | ||||||
|     OnPauseGame(); |     OnPauseGame(); | ||||||
|     QFileDialog png_dialog(this, tr("Capture Screenshot"), UISettings::values.screenshot_path, |     QString path = UISettings::values.screenshot_path; | ||||||
|                            tr("PNG Image (*.png)")); |     if (!FileUtil::IsDirectory(path.toStdString())) { | ||||||
|     png_dialog.setAcceptMode(QFileDialog::AcceptSave); |         if (!FileUtil::CreateFullPath(path.toStdString())) { | ||||||
|     png_dialog.setDefaultSuffix(QStringLiteral("png")); |             QMessageBox::information(this, tr("Invalid Screenshot Directory"), | ||||||
|     if (png_dialog.exec()) { |                                      tr("Cannot create specified screenshot directory. Screenshot " | ||||||
|         const QString path = png_dialog.selectedFiles().first(); |                                         "path is set back to its default value.")); | ||||||
|         if (!path.isEmpty()) { |             path = QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::UserDir)); | ||||||
|             UISettings::values.screenshot_path = QFileInfo(path).path(); |             path.append(QStringLiteral("screenshots/")); | ||||||
|             render_window->CaptureScreenshot(UISettings::values.screenshot_resolution_factor, path); |             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(); |     OnStartGame(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue