diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/citra_qt/main.cpp | 95 | ||||
| -rw-r--r-- | src/citra_qt/main.h | 7 | ||||
| -rw-r--r-- | src/citra_qt/main.ui | 7 |
3 files changed, 91 insertions, 18 deletions
diff --git a/src/citra_qt/main.cpp b/src/citra_qt/main.cpp index 6b030c178..6e50de2ec 100644 --- a/src/citra_qt/main.cpp +++ b/src/citra_qt/main.cpp | |||
| @@ -7,6 +7,7 @@ | |||
| 7 | #include <QtGui> | 7 | #include <QtGui> |
| 8 | #include <QDesktopWidget> | 8 | #include <QDesktopWidget> |
| 9 | #include <QFileDialog> | 9 | #include <QFileDialog> |
| 10 | #include <QMessageBox> | ||
| 10 | #include "qhexedit.h" | 11 | #include "qhexedit.h" |
| 11 | #include "main.h" | 12 | #include "main.h" |
| 12 | 13 | ||
| @@ -137,6 +138,16 @@ GMainWindow::GMainWindow() : emu_thread(nullptr) | |||
| 137 | ui.actionDisplay_widget_title_bars->setChecked(settings.value("displayTitleBars", true).toBool()); | 138 | ui.actionDisplay_widget_title_bars->setChecked(settings.value("displayTitleBars", true).toBool()); |
| 138 | OnDisplayTitleBars(ui.actionDisplay_widget_title_bars->isChecked()); | 139 | OnDisplayTitleBars(ui.actionDisplay_widget_title_bars->isChecked()); |
| 139 | 140 | ||
| 141 | // Prepare actions for recent files | ||
| 142 | for (int i = 0; i < max_recent_files_item; ++i) { | ||
| 143 | actions_recent_files[i] = new QAction(this); | ||
| 144 | actions_recent_files[i]->setVisible(false); | ||
| 145 | connect(actions_recent_files[i], SIGNAL(triggered()), this, SLOT(OnMenuRecentFile())); | ||
| 146 | |||
| 147 | ui.menu_recent_files->addAction(actions_recent_files[i]); | ||
| 148 | } | ||
| 149 | UpdateRecentFiles(); | ||
| 150 | |||
| 140 | // Setup connections | 151 | // Setup connections |
| 141 | connect(ui.action_Load_File, SIGNAL(triggered()), this, SLOT(OnMenuLoadFile())); | 152 | connect(ui.action_Load_File, SIGNAL(triggered()), this, SLOT(OnMenuLoadFile())); |
| 142 | connect(ui.action_Load_Symbol_Map, SIGNAL(triggered()), this, SLOT(OnMenuLoadSymbolMap())); | 153 | connect(ui.action_Load_Symbol_Map, SIGNAL(triggered()), this, SLOT(OnMenuLoadSymbolMap())); |
| @@ -209,6 +220,10 @@ void GMainWindow::OnDisplayTitleBars(bool show) | |||
| 209 | void GMainWindow::BootGame(const std::string& filename) { | 220 | void GMainWindow::BootGame(const std::string& filename) { |
| 210 | LOG_INFO(Frontend, "Citra starting...\n"); | 221 | LOG_INFO(Frontend, "Citra starting...\n"); |
| 211 | 222 | ||
| 223 | // Shutdown previous session if the emu thread is still active... | ||
| 224 | if (emu_thread != nullptr) | ||
| 225 | ShutdownGame(); | ||
| 226 | |||
| 212 | // Initialize the core emulation | 227 | // Initialize the core emulation |
| 213 | System::Init(render_window); | 228 | System::Init(render_window); |
| 214 | 229 | ||
| @@ -268,18 +283,43 @@ void GMainWindow::ShutdownGame() { | |||
| 268 | render_window->hide(); | 283 | render_window->hide(); |
| 269 | } | 284 | } |
| 270 | 285 | ||
| 271 | void GMainWindow::OnMenuLoadFile() | 286 | void GMainWindow::UpdateRecentFiles() { |
| 272 | { | 287 | QSettings settings; |
| 288 | QStringList recent_files = settings.value("recentFiles").toStringList(); | ||
| 289 | |||
| 290 | unsigned int num_recent_files = std::min(recent_files.size(), static_cast<int>(max_recent_files_item)); | ||
| 291 | |||
| 292 | for (unsigned int i = 0; i < num_recent_files; i++) { | ||
| 293 | QString text = QString("&%1. %2").arg(i + 1).arg(QFileInfo(recent_files[i]).fileName()); | ||
| 294 | actions_recent_files[i]->setText(text); | ||
| 295 | actions_recent_files[i]->setData(recent_files[i]); | ||
| 296 | actions_recent_files[i]->setVisible(true); | ||
| 297 | } | ||
| 298 | |||
| 299 | for (int j = num_recent_files; j < max_recent_files_item; ++j) { | ||
| 300 | actions_recent_files[j]->setVisible(false); | ||
| 301 | } | ||
| 302 | |||
| 303 | // Grey out the recent files menu if the list is empty | ||
| 304 | if (num_recent_files == 0) { | ||
| 305 | ui.menu_recent_files->setEnabled(false); | ||
| 306 | } else { | ||
| 307 | ui.menu_recent_files->setEnabled(true); | ||
| 308 | } | ||
| 309 | } | ||
| 310 | |||
| 311 | void GMainWindow::OnMenuLoadFile() { | ||
| 273 | QSettings settings; | 312 | QSettings settings; |
| 274 | QString rom_path = settings.value("romsPath", QString()).toString(); | 313 | QString rom_path = settings.value("romsPath", QString()).toString(); |
| 275 | 314 | ||
| 276 | QString filename = QFileDialog::getOpenFileName(this, tr("Load File"), rom_path, tr("3DS executable (*.3ds *.3dsx *.elf *.axf *.cci *.cxi)")); | 315 | QString filename = QFileDialog::getOpenFileName(this, tr("Load File"), rom_path, tr("3DS executable (*.3ds *.3dsx *.elf *.axf *.cci *.cxi)")); |
| 277 | if (filename.size()) { | 316 | if (filename.size()) { |
| 278 | settings.setValue("romsPath", QFileInfo(filename).path()); | 317 | settings.setValue("romsPath", QFileInfo(filename).path()); |
| 279 | 318 | // Update recent files list | |
| 280 | // Shutdown previous session if the emu thread is still active... | 319 | QStringList recent_files = settings.value("recentFiles").toStringList(); |
| 281 | if (emu_thread != nullptr) | 320 | recent_files.prepend(filename); |
| 282 | ShutdownGame(); | 321 | settings.setValue("recentFiles", recent_files); |
| 322 | UpdateRecentFiles(); // Update UI | ||
| 283 | 323 | ||
| 284 | BootGame(filename.toLatin1().data()); | 324 | BootGame(filename.toLatin1().data()); |
| 285 | } | 325 | } |
| @@ -297,8 +337,32 @@ void GMainWindow::OnMenuLoadSymbolMap() { | |||
| 297 | } | 337 | } |
| 298 | } | 338 | } |
| 299 | 339 | ||
| 300 | void GMainWindow::OnStartGame() | 340 | void GMainWindow::OnMenuRecentFile() { |
| 301 | { | 341 | QAction* action = qobject_cast<QAction*>(sender()); |
| 342 | assert(action); | ||
| 343 | |||
| 344 | QString filename = action->data().toString(); | ||
| 345 | QFileInfo file_info(filename); | ||
| 346 | if (file_info.exists()) { | ||
| 347 | BootGame(filename.toLatin1().data()); | ||
| 348 | } else { | ||
| 349 | // Display an error message and remove the file from the list. | ||
| 350 | QMessageBox::information(this, tr("File not found"), tr("File \"%1\" not found").arg(filename)); | ||
| 351 | |||
| 352 | QSettings settings; | ||
| 353 | QStringList recent_files = settings.value("recentFiles").toStringList(); | ||
| 354 | recent_files.removeOne(filename); | ||
| 355 | settings.setValue("recentFiles", recent_files); | ||
| 356 | |||
| 357 | action->setVisible(false); | ||
| 358 | // Grey out the recent files menu if the list is empty | ||
| 359 | if (ui.menu_recent_files->isEmpty()) { | ||
| 360 | ui.menu_recent_files->setEnabled(false); | ||
| 361 | } | ||
| 362 | } | ||
| 363 | } | ||
| 364 | |||
| 365 | void GMainWindow::OnStartGame() { | ||
| 302 | emu_thread->SetRunning(true); | 366 | emu_thread->SetRunning(true); |
| 303 | 367 | ||
| 304 | ui.action_Start->setEnabled(false); | 368 | ui.action_Start->setEnabled(false); |
| @@ -308,8 +372,7 @@ void GMainWindow::OnStartGame() | |||
| 308 | ui.action_Stop->setEnabled(true); | 372 | ui.action_Stop->setEnabled(true); |
| 309 | } | 373 | } |
| 310 | 374 | ||
| 311 | void GMainWindow::OnPauseGame() | 375 | void GMainWindow::OnPauseGame() { |
| 312 | { | ||
| 313 | emu_thread->SetRunning(false); | 376 | emu_thread->SetRunning(false); |
| 314 | 377 | ||
| 315 | ui.action_Start->setEnabled(true); | 378 | ui.action_Start->setEnabled(true); |
| @@ -321,8 +384,7 @@ void GMainWindow::OnStopGame() { | |||
| 321 | ShutdownGame(); | 384 | ShutdownGame(); |
| 322 | } | 385 | } |
| 323 | 386 | ||
| 324 | void GMainWindow::OnOpenHotkeysDialog() | 387 | void GMainWindow::OnOpenHotkeysDialog() { |
| 325 | { | ||
| 326 | GHotkeysDialog dialog(this); | 388 | GHotkeysDialog dialog(this); |
| 327 | dialog.exec(); | 389 | dialog.exec(); |
| 328 | } | 390 | } |
| @@ -350,13 +412,11 @@ void GMainWindow::ToggleWindowMode() { | |||
| 350 | } | 412 | } |
| 351 | } | 413 | } |
| 352 | 414 | ||
| 353 | void GMainWindow::OnConfigure() | 415 | void GMainWindow::OnConfigure() { |
| 354 | { | ||
| 355 | //GControllerConfigDialog* dialog = new GControllerConfigDialog(controller_ports, this); | 416 | //GControllerConfigDialog* dialog = new GControllerConfigDialog(controller_ports, this); |
| 356 | } | 417 | } |
| 357 | 418 | ||
| 358 | void GMainWindow::closeEvent(QCloseEvent* event) | 419 | void GMainWindow::closeEvent(QCloseEvent* event) { |
| 359 | { | ||
| 360 | // Save window layout | 420 | // Save window layout |
| 361 | QSettings settings(QSettings::IniFormat, QSettings::UserScope, "Citra team", "Citra"); | 421 | QSettings settings(QSettings::IniFormat, QSettings::UserScope, "Citra team", "Citra"); |
| 362 | settings.setValue("geometry", saveGeometry()); | 422 | settings.setValue("geometry", saveGeometry()); |
| @@ -380,8 +440,7 @@ void GMainWindow::closeEvent(QCloseEvent* event) | |||
| 380 | #undef main | 440 | #undef main |
| 381 | #endif | 441 | #endif |
| 382 | 442 | ||
| 383 | int main(int argc, char* argv[]) | 443 | int main(int argc, char* argv[]) { |
| 384 | { | ||
| 385 | Log::Filter log_filter(Log::Level::Info); | 444 | Log::Filter log_filter(Log::Level::Info); |
| 386 | Log::SetFilter(&log_filter); | 445 | Log::SetFilter(&log_filter); |
| 387 | 446 | ||
diff --git a/src/citra_qt/main.h b/src/citra_qt/main.h index 9fe9e0c9c..215e7c87d 100644 --- a/src/citra_qt/main.h +++ b/src/citra_qt/main.h | |||
| @@ -24,6 +24,8 @@ class GMainWindow : public QMainWindow | |||
| 24 | { | 24 | { |
| 25 | Q_OBJECT | 25 | Q_OBJECT |
| 26 | 26 | ||
| 27 | static const int max_recent_files_item = 10; ///< Max number of recently loaded items to keep track | ||
| 28 | |||
| 27 | // TODO: Make use of this! | 29 | // TODO: Make use of this! |
| 28 | enum { | 30 | enum { |
| 29 | UI_IDLE, | 31 | UI_IDLE, |
| @@ -58,6 +60,8 @@ private: | |||
| 58 | void BootGame(const std::string& filename); | 60 | void BootGame(const std::string& filename); |
| 59 | void ShutdownGame(); | 61 | void ShutdownGame(); |
| 60 | 62 | ||
| 63 | void UpdateRecentFiles(); | ||
| 64 | |||
| 61 | void closeEvent(QCloseEvent* event) override; | 65 | void closeEvent(QCloseEvent* event) override; |
| 62 | 66 | ||
| 63 | private slots: | 67 | private slots: |
| @@ -66,6 +70,7 @@ private slots: | |||
| 66 | void OnStopGame(); | 70 | void OnStopGame(); |
| 67 | void OnMenuLoadFile(); | 71 | void OnMenuLoadFile(); |
| 68 | void OnMenuLoadSymbolMap(); | 72 | void OnMenuLoadSymbolMap(); |
| 73 | void OnMenuRecentFile(); | ||
| 69 | void OnOpenHotkeysDialog(); | 74 | void OnOpenHotkeysDialog(); |
| 70 | void OnConfigure(); | 75 | void OnConfigure(); |
| 71 | void OnDisplayTitleBars(bool); | 76 | void OnDisplayTitleBars(bool); |
| @@ -85,6 +90,8 @@ private: | |||
| 85 | CallstackWidget* callstackWidget; | 90 | CallstackWidget* callstackWidget; |
| 86 | GPUCommandStreamWidget* graphicsWidget; | 91 | GPUCommandStreamWidget* graphicsWidget; |
| 87 | GPUCommandListWidget* graphicsCommandsWidget; | 92 | GPUCommandListWidget* graphicsCommandsWidget; |
| 93 | |||
| 94 | QAction* actions_recent_files[max_recent_files_item]; | ||
| 88 | }; | 95 | }; |
| 89 | 96 | ||
| 90 | #endif // _CITRA_QT_MAIN_HXX_ | 97 | #endif // _CITRA_QT_MAIN_HXX_ |
diff --git a/src/citra_qt/main.ui b/src/citra_qt/main.ui index 9a809ee6c..ba293d0bb 100644 --- a/src/citra_qt/main.ui +++ b/src/citra_qt/main.ui | |||
| @@ -52,9 +52,16 @@ | |||
| 52 | <property name="title"> | 52 | <property name="title"> |
| 53 | <string>&File</string> | 53 | <string>&File</string> |
| 54 | </property> | 54 | </property> |
| 55 | <widget class="QMenu" name="menu_recent_files"> | ||
| 56 | <property name="title"> | ||
| 57 | <string>Recent Files</string> | ||
| 58 | </property> | ||
| 59 | </widget> | ||
| 55 | <addaction name="action_Load_File"/> | 60 | <addaction name="action_Load_File"/> |
| 56 | <addaction name="action_Load_Symbol_Map"/> | 61 | <addaction name="action_Load_Symbol_Map"/> |
| 57 | <addaction name="separator"/> | 62 | <addaction name="separator"/> |
| 63 | <addaction name="menu_recent_files"/> | ||
| 64 | <addaction name="separator"/> | ||
| 58 | <addaction name="action_Exit"/> | 65 | <addaction name="action_Exit"/> |
| 59 | </widget> | 66 | </widget> |
| 60 | <widget class="QMenu" name="menu_Emulation"> | 67 | <widget class="QMenu" name="menu_Emulation"> |