all repos — mgba @ e2b964a8be5efb850368c52ee08c785eba26c6d7

mGBA Game Boy Advance Emulator

Qt: Show version info in window title
Jeffrey Pfau jeffrey@endrift.com
Fri, 15 May 2015 09:11:12 -0700
commit

e2b964a8be5efb850368c52ee08c785eba26c6d7

parent

47d945bf75c4a43307698393a57b015d7373e716

3 files changed, 32 insertions(+), 13 deletions(-)

jump to
M CHANGESCHANGES

@@ -33,6 +33,7 @@ - GBA: Add status log level

- GBA Thread: Add functionality for running callbacks on the GBA thread - Qt: Fast forward (held) option moved from Other to Emulation menu - All: Add --help flag for command line programs + - Qt: Show version info in window title 0.2.1: (2015-05-13) Bugfixes:
M src/platform/qt/Window.cppsrc/platform/qt/Window.cpp

@@ -62,12 +62,12 @@ , m_mruMenu(nullptr)

, m_shortcutController(new ShortcutController(this)) , m_playerId(playerId) { - setWindowTitle(projectName); setFocusPolicy(Qt::StrongFocus); setAcceptDrops(true); m_controller = new GameController(this); m_controller->setInputController(&m_inputController); m_controller->setOverrides(m_config->overrides()); + updateTitle(); QGLFormat format(QGLFormat(QGL::Rgba | QGL::DoubleBuffer)); format.setSwapInterval(1);

@@ -506,7 +506,7 @@ foreach (QAction* action, m_gameActions) {

action->setDisabled(false); } appendMRU(context->fname); - setWindowTitle(tr("%1 - %2").arg(projectName).arg(title)); + updateTitle(); attachWidget(m_display); #ifndef Q_OS_MAC

@@ -523,7 +523,7 @@ void Window::gameStopped() {

foreach (QAction* action, m_gameActions) { action->setDisabled(true); } - setWindowTitle(projectName); + updateTitle(); detachWidget(m_display); m_screenWidget->setLockAspectRatio(m_logo.width(), m_logo.height()); m_screenWidget->setPixmap(m_logo);

@@ -568,22 +568,38 @@ }

} void Window::showFPS() { - char gameTitle[13] = { '\0' }; - GBAGetGameTitle(m_controller->thread()->gba, gameTitle); - - QString title(gameTitle); - std::shared_ptr<MultiplayerController> multiplayer = m_controller->multiplayerController(); - if (multiplayer && multiplayer->attached() > 1) { - title += tr(" - Player %1 of %2").arg(m_playerId + 1).arg(multiplayer->attached()); - } if (m_frameList.isEmpty()) { - setWindowTitle(tr("%1 - %2").arg(projectName).arg(title)); + updateTitle(); return; } qint64 interval = m_frameList.first().msecsTo(m_frameList.last()); float fps = (m_frameList.count() - 1) * 10000.f / interval; fps = round(fps) / 10.f; - setWindowTitle(tr("%1 - %2 (%3 fps)").arg(projectName).arg(title).arg(fps)); + updateTitle(fps); +} + +void Window::updateTitle(float fps) { + QString title; + + m_controller->threadInterrupt(); + if (m_controller->isLoaded()) { + char gameTitle[13] = { '\0' }; + GBAGetGameTitle(m_controller->thread()->gba, gameTitle); + + title = (gameTitle); + } + std::shared_ptr<MultiplayerController> multiplayer = m_controller->multiplayerController(); + if (multiplayer && multiplayer->attached() > 1) { + title += tr(" - Player %1 of %2").arg(m_playerId + 1).arg(multiplayer->attached()); + } + m_controller->threadContinue(); + if (title.isNull()) { + setWindowTitle(tr("%1 - %2").arg(projectName).arg(projectVersion)); + } else if (isnan(fps)) { + setWindowTitle(tr("%1 - %2 - %3").arg(projectName).arg(title).arg(projectVersion)); + } else { + setWindowTitle(tr("%1 - %2 (%3 fps) - %4").arg(projectName).arg(title).arg(fps).arg(projectVersion)); + } } void Window::openStateWindow(LoadSave ls) {
M src/platform/qt/Window.hsrc/platform/qt/Window.h

@@ -133,6 +133,8 @@

QAction* addControlledAction(QMenu* menu, QAction* action, const QString& name); QAction* addHiddenAction(QMenu* menu, QAction* action, const QString& name); + void updateTitle(float fps = NAN); + GameController* m_controller; Display* m_display; QList<QAction*> m_gameActions;