Qt: Setting to show filename in title bar instead of ROM name. (#1807)

* All: Setting to display the file name of the currently loaded ROM instead of the game name in the title bar (closes mgba.io/i/1784)

* Utilize ConfigController getOption method and restructured to not use dynamically allocated memory for the temporary title

* Grab actual path name, use getOption to avoid having to modify the core, update CHANGES file, and moved core declaration to condense code.

* Change CHANGES text

* Qt: Simplify settings UI for PR

Co-authored-by: Vicki Pfau <vi@endrift.com>
This commit is contained in:
Mathew Horner 2020-06-24 01:20:42 -05:00 committed by GitHub
parent dd4619db61
commit 0230e654a3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 36 additions and 16 deletions

View File

@ -36,6 +36,7 @@ Misc:
- Qt: Add hex index to palette view
- Qt: Add transformation matrix info to sprite view
- Qt: Add per-page scrolling to memory view (fixes mgba.io/i/1795)
- Qt: Add setting to display ROM filename in title (closes mgba.io/i/1784)
0.8.2: (2020-06-14)
Emulation fixes:

View File

@ -400,6 +400,7 @@ void SettingsView::updateConfig() {
saveSetting("showFps", m_ui.showFps);
saveSetting("cheatAutoload", m_ui.cheatAutoload);
saveSetting("cheatAutosave", m_ui.cheatAutosave);
saveSetting("showFilename", m_ui.showFilename);
saveSetting("autoload", m_ui.autoload);
saveSetting("autosave", m_ui.autosave);
saveSetting("logToFile", m_ui.logToFile);
@ -574,6 +575,7 @@ void SettingsView::reloadConfig() {
loadSetting("showFps", m_ui.showFps, true);
loadSetting("cheatAutoload", m_ui.cheatAutoload, true);
loadSetting("cheatAutosave", m_ui.cheatAutosave, true);
loadSetting("showFilename", m_ui.showFilename, false);
loadSetting("autoload", m_ui.autoload, true);
loadSetting("autosave", m_ui.autosave, false);
loadSetting("logToFile", m_ui.logToFile);

View File

@ -586,21 +586,21 @@
</property>
</widget>
</item>
<item row="13" column="1">
<item row="14" column="1">
<widget class="QCheckBox" name="useDiscordPresence">
<property name="text">
<string>Enable Discord Rich Presence</string>
</property>
</widget>
</item>
<item row="14" column="0" colspan="2">
<item row="15" column="0" colspan="2">
<widget class="Line" name="line_13">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="15" column="1">
<item row="16" column="1">
<widget class="QCheckBox" name="autosave">
<property name="text">
<string>Automatically save state</string>
@ -610,7 +610,7 @@
</property>
</widget>
</item>
<item row="16" column="1">
<item row="17" column="1">
<widget class="QCheckBox" name="autoload">
<property name="text">
<string>Automatically load state</string>
@ -620,14 +620,14 @@
</property>
</widget>
</item>
<item row="17" column="0" colspan="2">
<item row="18" column="0" colspan="2">
<widget class="Line" name="line_16">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="18" column="1">
<item row="19" column="1">
<widget class="QCheckBox" name="cheatAutosave">
<property name="text">
<string>Automatically save cheats</string>
@ -637,7 +637,7 @@
</property>
</widget>
</item>
<item row="19" column="1">
<item row="20" column="1">
<widget class="QCheckBox" name="cheatAutoload">
<property name="text">
<string>Automatically load cheats</string>
@ -647,7 +647,7 @@
</property>
</widget>
</item>
<item row="12" column="1">
<item row="13" column="1">
<widget class="QCheckBox" name="showOSD">
<property name="text">
<string>Show OSD messages</string>
@ -657,6 +657,16 @@
</property>
</widget>
</item>
<item row="12" column="1">
<widget class="QCheckBox" name="showFilename">
<property name="text">
<string>Show filename instead of ROM name in title bar</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="emulation">

View File

@ -1030,10 +1030,15 @@ void Window::updateTitle(float fps) {
const NoIntroDB* db = GBAApp::app()->gameDB();
NoIntroGame game{};
uint32_t crc32 = 0;
m_controller->thread()->core->checksum(m_controller->thread()->core, &crc32, CHECKSUM_CRC32);
char gameTitle[17] = { '\0' };
mCore* core = m_controller->thread()->core;
core->checksum(m_controller->thread()->core, &crc32, CHECKSUM_CRC32);
QString filePath = windowFilePath();
if (m_config->getOption("showFilename").toInt() && !filePath.isNull()) {
QFileInfo fileInfo(filePath);
title = fileInfo.fileName();
} else {
char gameTitle[17] = { '\0' };
core->getGameTitle(core, gameTitle);
title = gameTitle;
@ -1042,6 +1047,8 @@ void Window::updateTitle(float fps) {
title = QLatin1String(game.name);
}
#endif
}
MultiplayerController* multiplayer = m_controller->multiplayerController();
if (multiplayer && multiplayer->attached() > 1) {
title += tr(" - Player %1 of %2").arg(multiplayer->playerId(m_controller.get()) + 1).arg(multiplayer->attached());