summaryrefslogtreecommitdiff
path: root/src/citra_qt/main.cpp
diff options
context:
space:
mode:
authorGravatar bunnei2016-04-10 20:21:34 -0400
committerGravatar bunnei2016-04-10 20:21:34 -0400
commita1b81469a3a72f0a6550075e2a693e31dab31ea9 (patch)
tree196b2ae1191198f1c47af2c33a145931c853c915 /src/citra_qt/main.cpp
parentMerge pull request #1653 from mailwl/blx-lr (diff)
parentAdd more stuff to configure. (diff)
downloadyuzu-a1b81469a3a72f0a6550075e2a693e31dab31ea9.tar.gz
yuzu-a1b81469a3a72f0a6550075e2a693e31dab31ea9.tar.xz
yuzu-a1b81469a3a72f0a6550075e2a693e31dab31ea9.zip
Merge pull request #1368 from LittleWhite-tb/configure-widget
Implementation for a configure widget
Diffstat (limited to 'src/citra_qt/main.cpp')
-rw-r--r--src/citra_qt/main.cpp163
1 files changed, 51 insertions, 112 deletions
diff --git a/src/citra_qt/main.cpp b/src/citra_qt/main.cpp
index ca0ae6f7b..23eb28259 100644
--- a/src/citra_qt/main.cpp
+++ b/src/citra_qt/main.cpp
@@ -14,9 +14,11 @@
14 14
15#include "citra_qt/bootmanager.h" 15#include "citra_qt/bootmanager.h"
16#include "citra_qt/config.h" 16#include "citra_qt/config.h"
17#include "citra_qt/configure_dialog.h"
17#include "citra_qt/game_list.h" 18#include "citra_qt/game_list.h"
18#include "citra_qt/hotkeys.h" 19#include "citra_qt/hotkeys.h"
19#include "citra_qt/main.h" 20#include "citra_qt/main.h"
21#include "citra_qt/ui_settings.h"
20 22
21// Debugger 23// Debugger
22#include "citra_qt/debugger/callstack.h" 24#include "citra_qt/debugger/callstack.h"
@@ -50,12 +52,10 @@
50 52
51#include "video_core/video_core.h" 53#include "video_core/video_core.h"
52 54
53GMainWindow::GMainWindow() : emu_thread(nullptr) 55GMainWindow::GMainWindow() : config(new Config()), emu_thread(nullptr)
54{ 56{
55 Pica::g_debug_context = Pica::DebugContext::Construct(); 57 Pica::g_debug_context = Pica::DebugContext::Construct();
56 58
57 Config config;
58
59 ui.setupUi(this); 59 ui.setupUi(this);
60 statusBar()->hide(); 60 statusBar()->hide();
61 61
@@ -133,33 +133,21 @@ GMainWindow::GMainWindow() : emu_thread(nullptr)
133 setGeometry(x, y, w, h); 133 setGeometry(x, y, w, h);
134 134
135 // Restore UI state 135 // Restore UI state
136 QSettings settings; 136 restoreGeometry(UISettings::values.geometry);
137 137 restoreState(UISettings::values.state);
138 settings.beginGroup("UILayout"); 138 render_window->restoreGeometry(UISettings::values.renderwindow_geometry);
139 restoreGeometry(settings.value("geometry").toByteArray()); 139 microProfileDialog->restoreGeometry(UISettings::values.microprofile_geometry);
140 restoreState(settings.value("state").toByteArray()); 140 microProfileDialog->setVisible(UISettings::values.microprofile_visible);
141 render_window->restoreGeometry(settings.value("geometryRenderWindow").toByteArray());
142 microProfileDialog->restoreGeometry(settings.value("microProfileDialogGeometry").toByteArray());
143 microProfileDialog->setVisible(settings.value("microProfileDialogVisible").toBool());
144 settings.endGroup();
145
146 game_list->LoadInterfaceLayout(settings);
147 141
148 ui.action_Use_Gdbstub->setChecked(Settings::values.use_gdbstub); 142 game_list->LoadInterfaceLayout();
149 SetGdbstubEnabled(ui.action_Use_Gdbstub->isChecked());
150 143
144 GDBStub::ToggleServer(Settings::values.use_gdbstub);
151 GDBStub::SetServerPort(static_cast<u32>(Settings::values.gdbstub_port)); 145 GDBStub::SetServerPort(static_cast<u32>(Settings::values.gdbstub_port));
152 146
153 ui.action_Use_Hardware_Renderer->setChecked(Settings::values.use_hw_renderer); 147 ui.action_Single_Window_Mode->setChecked(UISettings::values.single_window_mode);
154 SetHardwareRendererEnabled(ui.action_Use_Hardware_Renderer->isChecked());
155
156 ui.action_Use_Shader_JIT->setChecked(Settings::values.use_shader_jit);
157 SetShaderJITEnabled(ui.action_Use_Shader_JIT->isChecked());
158
159 ui.action_Single_Window_Mode->setChecked(settings.value("singleWindowMode", true).toBool());
160 ToggleWindowMode(); 148 ToggleWindowMode();
161 149
162 ui.actionDisplay_widget_title_bars->setChecked(settings.value("displayTitleBars", true).toBool()); 150 ui.actionDisplay_widget_title_bars->setChecked(UISettings::values.display_titlebar);
163 OnDisplayTitleBars(ui.actionDisplay_widget_title_bars->isChecked()); 151 OnDisplayTitleBars(ui.actionDisplay_widget_title_bars->isChecked());
164 152
165 // Prepare actions for recent files 153 // Prepare actions for recent files
@@ -172,21 +160,16 @@ GMainWindow::GMainWindow() : emu_thread(nullptr)
172 } 160 }
173 UpdateRecentFiles(); 161 UpdateRecentFiles();
174 162
175 confirm_before_closing = settings.value("confirmClose", true).toBool();
176
177 // Setup connections 163 // Setup connections
178 connect(game_list, SIGNAL(GameChosen(QString)), this, SLOT(OnGameListLoadFile(QString))); 164 connect(game_list, SIGNAL(GameChosen(QString)), this, SLOT(OnGameListLoadFile(QString)), Qt::DirectConnection);
179 connect(ui.action_Load_File, SIGNAL(triggered()), this, SLOT(OnMenuLoadFile())); 165 connect(ui.action_Configure, SIGNAL(triggered()), this, SLOT(OnConfigure()));
166 connect(ui.action_Load_File, SIGNAL(triggered()), this, SLOT(OnMenuLoadFile()),Qt::DirectConnection);
180 connect(ui.action_Load_Symbol_Map, SIGNAL(triggered()), this, SLOT(OnMenuLoadSymbolMap())); 167 connect(ui.action_Load_Symbol_Map, SIGNAL(triggered()), this, SLOT(OnMenuLoadSymbolMap()));
181 connect(ui.action_Select_Game_List_Root, SIGNAL(triggered()), this, SLOT(OnMenuSelectGameListRoot())); 168 connect(ui.action_Select_Game_List_Root, SIGNAL(triggered()), this, SLOT(OnMenuSelectGameListRoot()));
182 connect(ui.action_Start, SIGNAL(triggered()), this, SLOT(OnStartGame())); 169 connect(ui.action_Start, SIGNAL(triggered()), this, SLOT(OnStartGame()));
183 connect(ui.action_Pause, SIGNAL(triggered()), this, SLOT(OnPauseGame())); 170 connect(ui.action_Pause, SIGNAL(triggered()), this, SLOT(OnPauseGame()));
184 connect(ui.action_Stop, SIGNAL(triggered()), this, SLOT(OnStopGame())); 171 connect(ui.action_Stop, SIGNAL(triggered()), this, SLOT(OnStopGame()));
185 connect(ui.action_Use_Hardware_Renderer, SIGNAL(triggered(bool)), this, SLOT(SetHardwareRendererEnabled(bool)));
186 connect(ui.action_Use_Shader_JIT, SIGNAL(triggered(bool)), this, SLOT(SetShaderJITEnabled(bool)));
187 connect(ui.action_Use_Gdbstub, SIGNAL(triggered(bool)), this, SLOT(SetGdbstubEnabled(bool)));
188 connect(ui.action_Single_Window_Mode, SIGNAL(triggered(bool)), this, SLOT(ToggleWindowMode())); 172 connect(ui.action_Single_Window_Mode, SIGNAL(triggered(bool)), this, SLOT(ToggleWindowMode()));
189 connect(ui.action_Hotkeys, SIGNAL(triggered()), this, SLOT(OnOpenHotkeysDialog()));
190 173
191 connect(this, SIGNAL(EmulationStarting(EmuThread*)), disasmWidget, SLOT(OnEmulationStarting(EmuThread*))); 174 connect(this, SIGNAL(EmulationStarting(EmuThread*)), disasmWidget, SLOT(OnEmulationStarting(EmuThread*)));
192 connect(this, SIGNAL(EmulationStopping()), disasmWidget, SLOT(OnEmulationStopping())); 175 connect(this, SIGNAL(EmulationStopping()), disasmWidget, SLOT(OnEmulationStopping()));
@@ -201,7 +184,7 @@ GMainWindow::GMainWindow() : emu_thread(nullptr)
201 // Setup hotkeys 184 // Setup hotkeys
202 RegisterHotkey("Main Window", "Load File", QKeySequence::Open); 185 RegisterHotkey("Main Window", "Load File", QKeySequence::Open);
203 RegisterHotkey("Main Window", "Start Emulation"); 186 RegisterHotkey("Main Window", "Start Emulation");
204 LoadHotkeys(settings); 187 LoadHotkeys();
205 188
206 connect(GetHotkey("Main Window", "Load File", this), SIGNAL(activated()), this, SLOT(OnMenuLoadFile())); 189 connect(GetHotkey("Main Window", "Load File", this), SIGNAL(activated()), this, SLOT(OnMenuLoadFile()));
207 connect(GetHotkey("Main Window", "Start Emulation", this), SIGNAL(activated()), this, SLOT(OnStartGame())); 190 connect(GetHotkey("Main Window", "Start Emulation", this), SIGNAL(activated()), this, SLOT(OnStartGame()));
@@ -211,7 +194,7 @@ GMainWindow::GMainWindow() : emu_thread(nullptr)
211 194
212 show(); 195 show();
213 196
214 game_list->PopulateAsync(settings.value("gameListRootDir", ".").toString(), settings.value("gameListDeepScan", false).toBool()); 197 game_list->PopulateAsync(UISettings::values.gamedir, UISettings::values.gamedir_deepscan);
215 198
216 QStringList args = QApplication::arguments(); 199 QStringList args = QApplication::arguments();
217 if (args.length() >= 2) { 200 if (args.length() >= 2) {
@@ -375,32 +358,24 @@ void GMainWindow::ShutdownGame() {
375 emulation_running = false; 358 emulation_running = false;
376} 359}
377 360
378void GMainWindow::StoreRecentFile(const std::string& filename) 361void GMainWindow::StoreRecentFile(const std::string& filename) {
379{ 362 UISettings::values.recent_files.prepend(QString::fromStdString(filename));
380 QSettings settings; 363 UISettings::values.recent_files.removeDuplicates();
381 QStringList recent_files = settings.value("recentFiles").toStringList(); 364 while (UISettings::values.recent_files.size() > max_recent_files_item) {
382 recent_files.prepend(QString::fromStdString(filename)); 365 UISettings::values.recent_files.removeLast();
383 recent_files.removeDuplicates();
384 while (recent_files.size() > max_recent_files_item) {
385 recent_files.removeLast();
386 } 366 }
387 367
388 settings.setValue("recentFiles", recent_files);
389
390 UpdateRecentFiles(); 368 UpdateRecentFiles();
391} 369}
392 370
393void GMainWindow::UpdateRecentFiles() { 371void GMainWindow::UpdateRecentFiles() {
394 QSettings settings; 372 unsigned int num_recent_files = std::min(UISettings::values.recent_files.size(), static_cast<int>(max_recent_files_item));
395 QStringList recent_files = settings.value("recentFiles").toStringList();
396
397 unsigned int num_recent_files = std::min(recent_files.size(), static_cast<int>(max_recent_files_item));
398 373
399 for (unsigned int i = 0; i < num_recent_files; i++) { 374 for (unsigned int i = 0; i < num_recent_files; i++) {
400 QString text = QString("&%1. %2").arg(i + 1).arg(QFileInfo(recent_files[i]).fileName()); 375 QString text = QString("&%1. %2").arg(i + 1).arg(QFileInfo(UISettings::values.recent_files[i]).fileName());
401 actions_recent_files[i]->setText(text); 376 actions_recent_files[i]->setText(text);
402 actions_recent_files[i]->setData(recent_files[i]); 377 actions_recent_files[i]->setData(UISettings::values.recent_files[i]);
403 actions_recent_files[i]->setToolTip(recent_files[i]); 378 actions_recent_files[i]->setToolTip(UISettings::values.recent_files[i]);
404 actions_recent_files[i]->setVisible(true); 379 actions_recent_files[i]->setVisible(true);
405 } 380 }
406 381
@@ -421,36 +396,28 @@ void GMainWindow::OnGameListLoadFile(QString game_path) {
421} 396}
422 397
423void GMainWindow::OnMenuLoadFile() { 398void GMainWindow::OnMenuLoadFile() {
424 QSettings settings; 399 QString filename = QFileDialog::getOpenFileName(this, tr("Load File"), UISettings::values.roms_path, tr("3DS executable (*.3ds *.3dsx *.elf *.axf *.cci *.cxi)"));
425 QString rom_path = settings.value("romsPath", QString()).toString();
426
427 QString filename = QFileDialog::getOpenFileName(this, tr("Load File"), rom_path, tr("3DS executable (*.3ds *.3dsx *.elf *.axf *.cci *.cxi)"));
428 if (!filename.isEmpty()) { 400 if (!filename.isEmpty()) {
429 settings.setValue("romsPath", QFileInfo(filename).path()); 401 UISettings::values.roms_path = QFileInfo(filename).path();
430 402
431 BootGame(filename.toStdString()); 403 BootGame(filename.toStdString());
432 } 404 }
433} 405}
434 406
435void GMainWindow::OnMenuLoadSymbolMap() { 407void GMainWindow::OnMenuLoadSymbolMap() {
436 QSettings settings; 408 QString filename = QFileDialog::getOpenFileName(this, tr("Load Symbol Map"), UISettings::values.symbols_path, tr("Symbol map (*)"));
437 QString symbol_path = settings.value("symbolsPath", QString()).toString();
438
439 QString filename = QFileDialog::getOpenFileName(this, tr("Load Symbol Map"), symbol_path, tr("Symbol map (*)"));
440 if (!filename.isEmpty()) { 409 if (!filename.isEmpty()) {
441 settings.setValue("symbolsPath", QFileInfo(filename).path()); 410 UISettings::values.symbols_path = QFileInfo(filename).path();
442 411
443 LoadSymbolMap(filename.toStdString()); 412 LoadSymbolMap(filename.toStdString());
444 } 413 }
445} 414}
446 415
447void GMainWindow::OnMenuSelectGameListRoot() { 416void GMainWindow::OnMenuSelectGameListRoot() {
448 QSettings settings;
449
450 QString dir_path = QFileDialog::getExistingDirectory(this, tr("Select Directory")); 417 QString dir_path = QFileDialog::getExistingDirectory(this, tr("Select Directory"));
451 if (!dir_path.isEmpty()) { 418 if (!dir_path.isEmpty()) {
452 settings.setValue("gameListRootDir", dir_path); 419 UISettings::values.gamedir = dir_path;
453 game_list->PopulateAsync(dir_path, settings.value("gameListDeepScan").toBool()); 420 game_list->PopulateAsync(dir_path, UISettings::values.gamedir_deepscan);
454 } 421 }
455} 422}
456 423
@@ -466,10 +433,7 @@ void GMainWindow::OnMenuRecentFile() {
466 // Display an error message and remove the file from the list. 433 // Display an error message and remove the file from the list.
467 QMessageBox::information(this, tr("File not found"), tr("File \"%1\" not found").arg(filename)); 434 QMessageBox::information(this, tr("File not found"), tr("File \"%1\" not found").arg(filename));
468 435
469 QSettings settings; 436 UISettings::values.recent_files.removeOne(filename);
470 QStringList recent_files = settings.value("recentFiles").toStringList();
471 recent_files.removeOne(filename);
472 settings.setValue("recentFiles", recent_files);
473 UpdateRecentFiles(); 437 UpdateRecentFiles();
474 } 438 }
475} 439}
@@ -496,31 +460,6 @@ void GMainWindow::OnStopGame() {
496 ShutdownGame(); 460 ShutdownGame();
497} 461}
498 462
499void GMainWindow::OnOpenHotkeysDialog() {
500 GHotkeysDialog dialog(this);
501 dialog.exec();
502}
503
504void GMainWindow::SetHardwareRendererEnabled(bool enabled) {
505 VideoCore::g_hw_renderer_enabled = enabled;
506
507 Config config;
508 Settings::values.use_hw_renderer = enabled;
509 config.Save();
510}
511
512void GMainWindow::SetGdbstubEnabled(bool enabled) {
513 GDBStub::ToggleServer(enabled);
514}
515
516void GMainWindow::SetShaderJITEnabled(bool enabled) {
517 VideoCore::g_shader_jit_enabled = enabled;
518
519 Config config;
520 Settings::values.use_shader_jit = enabled;
521 config.Save();
522}
523
524void GMainWindow::ToggleWindowMode() { 463void GMainWindow::ToggleWindowMode() {
525 if (ui.action_Single_Window_Mode->isChecked()) { 464 if (ui.action_Single_Window_Mode->isChecked()) {
526 // Render in the main window... 465 // Render in the main window...
@@ -547,11 +486,17 @@ void GMainWindow::ToggleWindowMode() {
547} 486}
548 487
549void GMainWindow::OnConfigure() { 488void GMainWindow::OnConfigure() {
550 //GControllerConfigDialog* dialog = new GControllerConfigDialog(controller_ports, this); 489 ConfigureDialog configureDialog(this);
490 auto result = configureDialog.exec();
491 if (result == QDialog::Accepted)
492 {
493 configureDialog.applyConfiguration();
494 config->Save();
495 }
551} 496}
552 497
553bool GMainWindow::ConfirmClose() { 498bool GMainWindow::ConfirmClose() {
554 if (emu_thread == nullptr || !confirm_before_closing) 499 if (emu_thread == nullptr || !UISettings::values.confirm_before_closing)
555 return true; 500 return true;
556 501
557 auto answer = QMessageBox::question(this, tr("Citra"), 502 auto answer = QMessageBox::question(this, tr("Citra"),
@@ -566,23 +511,18 @@ void GMainWindow::closeEvent(QCloseEvent* event) {
566 return; 511 return;
567 } 512 }
568 513
569 // Save window layout 514 UISettings::values.geometry = saveGeometry();
570 QSettings settings(QSettings::IniFormat, QSettings::UserScope, "Citra team", "Citra"); 515 UISettings::values.state = saveState();
516 UISettings::values.renderwindow_geometry = render_window->saveGeometry();
517 UISettings::values.microprofile_geometry = microProfileDialog->saveGeometry();
518 UISettings::values.microprofile_visible = microProfileDialog->isVisible();
571 519
572 settings.beginGroup("UILayout"); 520 UISettings::values.single_window_mode = ui.action_Single_Window_Mode->isChecked();
573 settings.setValue("geometry", saveGeometry()); 521 UISettings::values.display_titlebar = ui.actionDisplay_widget_title_bars->isChecked();
574 settings.setValue("state", saveState()); 522 UISettings::values.first_start = false;
575 settings.setValue("geometryRenderWindow", render_window->saveGeometry());
576 settings.setValue("microProfileDialogGeometry", microProfileDialog->saveGeometry());
577 settings.setValue("microProfileDialogVisible", microProfileDialog->isVisible());
578 settings.endGroup();
579 523
580 settings.setValue("singleWindowMode", ui.action_Single_Window_Mode->isChecked()); 524 game_list->SaveInterfaceLayout();
581 settings.setValue("displayTitleBars", ui.actionDisplay_widget_title_bars->isChecked()); 525 SaveHotkeys();
582 settings.setValue("firstStart", false);
583 settings.setValue("confirmClose", confirm_before_closing);
584 game_list->SaveInterfaceLayout(settings);
585 SaveHotkeys(settings);
586 526
587 // Shutdown session if the emu thread is active... 527 // Shutdown session if the emu thread is active...
588 if (emu_thread != nullptr) 528 if (emu_thread != nullptr)
@@ -607,7 +547,6 @@ int main(int argc, char* argv[]) {
607 }); 547 });
608 548
609 // Init settings params 549 // Init settings params
610 QSettings::setDefaultFormat(QSettings::IniFormat);
611 QCoreApplication::setOrganizationName("Citra team"); 550 QCoreApplication::setOrganizationName("Citra team");
612 QCoreApplication::setApplicationName("Citra"); 551 QCoreApplication::setApplicationName("Citra");
613 552