mirror of https://github.com/PCSX2/pcsx2.git
Qt: Make status bar less confusing
This commit is contained in:
parent
dcb17243f8
commit
a2afbd3080
|
@ -851,15 +851,12 @@ void Host::OnGameChanged(const std::string& disc_path, const std::string& game_s
|
|||
|
||||
void EmuThread::updatePerformanceMetrics(bool force)
|
||||
{
|
||||
QString fps_stat, gs_stat;
|
||||
bool changed = force;
|
||||
|
||||
if (m_verbose_status && VMManager::HasValidVM())
|
||||
{
|
||||
std::string gs_stat_str;
|
||||
GSgetTitleStats(gs_stat_str);
|
||||
changed = true;
|
||||
|
||||
QString gs_stat;
|
||||
if (THREAD_VU1)
|
||||
{
|
||||
gs_stat =
|
||||
|
@ -876,8 +873,11 @@ void EmuThread::updatePerformanceMetrics(bool force)
|
|||
.arg(PerformanceMetrics::GetCPUThreadUsage(), 0, 'f', 0)
|
||||
.arg(PerformanceMetrics::GetGSThreadUsage(), 0, 'f', 0);
|
||||
}
|
||||
|
||||
QMetaObject::invokeMethod(g_main_window->getStatusVerboseWidget(), "setText", Qt::QueuedConnection, Q_ARG(const QString&, gs_stat));
|
||||
}
|
||||
|
||||
const GSRendererType renderer = GSConfig.Renderer;
|
||||
const float speed = std::round(PerformanceMetrics::GetSpeed());
|
||||
const float gfps = std::round(PerformanceMetrics::GetInternalFPS());
|
||||
const float vfps = std::round(PerformanceMetrics::GetFPS());
|
||||
|
@ -886,41 +886,56 @@ void EmuThread::updatePerformanceMetrics(bool force)
|
|||
|
||||
if (iwidth != m_last_internal_width || iheight != m_last_internal_height ||
|
||||
speed != m_last_speed || gfps != m_last_game_fps || vfps != m_last_video_fps ||
|
||||
changed)
|
||||
renderer != m_last_renderer || force)
|
||||
{
|
||||
m_last_internal_width = iwidth;
|
||||
m_last_internal_height = iheight;
|
||||
m_last_speed = speed;
|
||||
m_last_game_fps = gfps;
|
||||
m_last_video_fps = vfps;
|
||||
changed = true;
|
||||
|
||||
if (iwidth == 0 && iheight == 0)
|
||||
{
|
||||
// if we don't have width/height yet, we're not going to have fps either.
|
||||
// and we'll probably be <100% due to compiling. so just leave it blank for now.
|
||||
}
|
||||
else if (PerformanceMetrics::IsInternalFPSValid())
|
||||
{
|
||||
fps_stat = QStringLiteral("%1x%2 | G: %3 | V: %4 | %5%")
|
||||
.arg(iwidth)
|
||||
.arg(iheight)
|
||||
.arg(gfps, 0, 'f', 0)
|
||||
.arg(vfps, 0, 'f', 0)
|
||||
.arg(speed, 0, 'f', 0);
|
||||
QString blank;
|
||||
QMetaObject::invokeMethod(g_main_window->getStatusRendererWidget(), "setText", Qt::QueuedConnection, Q_ARG(const QString&, blank));
|
||||
QMetaObject::invokeMethod(g_main_window->getStatusResolutionWidget(), "setText", Qt::QueuedConnection, Q_ARG(const QString&, blank));
|
||||
QMetaObject::invokeMethod(g_main_window->getStatusFPSWidget(), "setText", Qt::QueuedConnection, Q_ARG(const QString&, blank));
|
||||
QMetaObject::invokeMethod(g_main_window->getStatusVPSWidget(), "setText", Qt::QueuedConnection, Q_ARG(const QString&, blank));
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
fps_stat = QStringLiteral("%1x%2 | V: %3 | %4%")
|
||||
.arg(iwidth)
|
||||
.arg(iheight)
|
||||
.arg(vfps, 0, 'f', 0)
|
||||
.arg(speed, 0, 'f', 0);
|
||||
if (renderer != m_last_renderer || force)
|
||||
{
|
||||
QMetaObject::invokeMethod(g_main_window->getStatusRendererWidget(), "setText", Qt::QueuedConnection,
|
||||
Q_ARG(const QString&, QString::fromUtf8(Pcsx2Config::GSOptions::GetRendererName(renderer))));
|
||||
m_last_renderer = renderer;
|
||||
}
|
||||
if (iwidth != m_last_internal_width || iheight != m_last_internal_height || force)
|
||||
{
|
||||
QMetaObject::invokeMethod(g_main_window->getStatusResolutionWidget(), "setText", Qt::QueuedConnection,
|
||||
Q_ARG(const QString&, tr("%1x%2")
|
||||
.arg(iwidth)
|
||||
.arg(iheight)));
|
||||
m_last_internal_width = iwidth;
|
||||
m_last_internal_height = iheight;
|
||||
}
|
||||
|
||||
if (gfps != m_last_game_fps || force)
|
||||
{
|
||||
QMetaObject::invokeMethod(g_main_window->getStatusFPSWidget(), "setText", Qt::QueuedConnection,
|
||||
Q_ARG(const QString&, tr("Game: %1 FPS")
|
||||
.arg(gfps, 0, 'f', 0)));
|
||||
m_last_game_fps = gfps;
|
||||
}
|
||||
|
||||
if (speed != m_last_speed || vfps != m_last_video_fps || force)
|
||||
{
|
||||
QMetaObject::invokeMethod(g_main_window->getStatusVPSWidget(), "setText", Qt::QueuedConnection,
|
||||
Q_ARG(const QString&, tr("Video: %1 FPS (%2%)")
|
||||
.arg(vfps, 0, 'f', 0)
|
||||
.arg(speed, 0, 'f', 0)));
|
||||
m_last_speed = speed;
|
||||
m_last_video_fps = vfps;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (changed)
|
||||
emit onPerformanceMetricsUpdated(fps_stat, gs_stat);
|
||||
}
|
||||
|
||||
void Host::OnPerformanceMetricsUpdated()
|
||||
|
|
|
@ -110,9 +110,6 @@ Q_SIGNALS:
|
|||
/// Provided by the host; called when the running executable changes.
|
||||
void onGameChanged(const QString& path, const QString& serial, const QString& name, quint32 crc);
|
||||
|
||||
/// Called when performance metrics are changed, approx. once a second.
|
||||
void onPerformanceMetricsUpdated(const QString& fps_stats, const QString& gs_stats);
|
||||
|
||||
void onInputDevicesEnumerated(const QList<QPair<QString, QString>>& devices);
|
||||
void onInputDeviceConnected(const QString& identifier, const QString& device_name);
|
||||
void onInputDeviceDisconnected(const QString& identifier);
|
||||
|
@ -173,6 +170,7 @@ private:
|
|||
float m_last_video_fps = 0.0f;
|
||||
int m_last_internal_width = 0;
|
||||
int m_last_internal_height = 0;
|
||||
GSRendererType m_last_renderer = GSRendererType::Null;
|
||||
};
|
||||
|
||||
extern EmuThread* g_emu_thread;
|
||||
|
|
|
@ -179,16 +179,29 @@ void MainWindow::setupAdditionalUi()
|
|||
m_status_progress_widget->setFixedSize(140, 16);
|
||||
m_status_progress_widget->hide();
|
||||
|
||||
m_status_gs_widget = new QLabel(m_ui.statusBar);
|
||||
m_status_gs_widget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
||||
m_status_gs_widget->setFixedHeight(16);
|
||||
m_status_gs_widget->hide();
|
||||
m_status_verbose_widget = new QLabel(m_ui.statusBar);
|
||||
m_status_verbose_widget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
||||
m_status_verbose_widget->setFixedHeight(16);
|
||||
m_status_verbose_widget->hide();
|
||||
|
||||
m_status_renderer_widget = new QLabel(m_ui.statusBar);
|
||||
m_status_renderer_widget->setFixedHeight(16);
|
||||
m_status_renderer_widget->setFixedSize(65, 16);
|
||||
m_status_renderer_widget->hide();
|
||||
|
||||
m_status_resolution_widget = new QLabel(m_ui.statusBar);
|
||||
m_status_resolution_widget->setFixedHeight(16);
|
||||
m_status_resolution_widget->setFixedSize(70, 16);
|
||||
m_status_resolution_widget->hide();
|
||||
|
||||
m_status_fps_widget = new QLabel(m_ui.statusBar);
|
||||
m_status_fps_widget->setAlignment(Qt::AlignRight);
|
||||
m_status_fps_widget->setFixedHeight(16);
|
||||
m_status_fps_widget->setFixedSize(85, 16);
|
||||
m_status_fps_widget->hide();
|
||||
|
||||
m_status_vps_widget = new QLabel(m_ui.statusBar);
|
||||
m_status_vps_widget->setFixedSize(125, 16);
|
||||
m_status_vps_widget->hide();
|
||||
|
||||
for (u32 scale = 0; scale <= 10; scale++)
|
||||
{
|
||||
QAction* action = m_ui.menuWindowSize->addAction((scale == 0) ? tr("Internal Resolution") : tr("%1x Scale").arg(scale));
|
||||
|
@ -319,7 +332,6 @@ void MainWindow::connectVMThreadSignals(EmuThread* thread)
|
|||
connect(thread, &EmuThread::onVMResumed, this, &MainWindow::onVMResumed);
|
||||
connect(thread, &EmuThread::onVMStopped, this, &MainWindow::onVMStopped);
|
||||
connect(thread, &EmuThread::onGameChanged, this, &MainWindow::onGameChanged);
|
||||
connect(thread, &EmuThread::onPerformanceMetricsUpdated, this, &MainWindow::onPerformanceMetricsUpdated);
|
||||
|
||||
connect(m_ui.actionReset, &QAction::triggered, thread, &EmuThread::resetVM);
|
||||
connect(m_ui.actionPause, &QAction::toggled, thread, &EmuThread::setVMPaused);
|
||||
|
@ -721,8 +733,11 @@ void MainWindow::updateStatusBarWidgetVisibility()
|
|||
}
|
||||
};
|
||||
|
||||
Update(m_status_gs_widget, s_vm_valid && !s_vm_paused, 1);
|
||||
Update(m_status_verbose_widget, s_vm_valid, 1);
|
||||
Update(m_status_renderer_widget, s_vm_valid, 0);
|
||||
Update(m_status_resolution_widget, s_vm_valid, 0);
|
||||
Update(m_status_fps_widget, s_vm_valid, 0);
|
||||
Update(m_status_vps_widget, s_vm_valid, 0);
|
||||
}
|
||||
|
||||
void MainWindow::updateWindowTitle()
|
||||
|
@ -1449,7 +1464,8 @@ void MainWindow::onVMPaused()
|
|||
s_vm_paused = true;
|
||||
updateWindowTitle();
|
||||
updateStatusBarWidgetVisibility();
|
||||
m_status_fps_widget->setText(tr("Paused"));
|
||||
m_last_fps_status = m_status_verbose_widget->text();
|
||||
m_status_verbose_widget->setText(tr("Paused"));
|
||||
if (m_display_widget)
|
||||
{
|
||||
m_display_widget->updateRelativeMode(false);
|
||||
|
@ -1469,7 +1485,8 @@ void MainWindow::onVMResumed()
|
|||
m_was_disc_change_request = false;
|
||||
updateWindowTitle();
|
||||
updateStatusBarWidgetVisibility();
|
||||
m_status_fps_widget->setText(m_last_fps_status);
|
||||
m_status_verbose_widget->setText(m_last_fps_status);
|
||||
m_last_fps_status = QString();
|
||||
if (m_display_widget)
|
||||
{
|
||||
m_display_widget->updateRelativeMode(true);
|
||||
|
@ -1509,13 +1526,6 @@ void MainWindow::onGameChanged(const QString& path, const QString& serial, const
|
|||
updateSaveStateMenus(path, serial, crc);
|
||||
}
|
||||
|
||||
void MainWindow::onPerformanceMetricsUpdated(const QString& fps_stat, const QString& gs_stat)
|
||||
{
|
||||
m_last_fps_status = fps_stat;
|
||||
m_status_fps_widget->setText(m_last_fps_status);
|
||||
m_status_gs_widget->setText(gs_stat);
|
||||
}
|
||||
|
||||
void MainWindow::showEvent(QShowEvent* event)
|
||||
{
|
||||
QMainWindow::showEvent(event);
|
||||
|
|
|
@ -86,6 +86,13 @@ public:
|
|||
/// Locks the VM by pausing it, while a popup dialog is displayed.
|
||||
VMLock pauseAndLockVM();
|
||||
|
||||
/// Accessors for the status bar widgets, updated by the emulation thread.
|
||||
__fi QLabel* getStatusVerboseWidget() const { return m_status_verbose_widget; }
|
||||
__fi QLabel* getStatusRendererWidget() const { return m_status_renderer_widget; }
|
||||
__fi QLabel* getStatusResolutionWidget() const { return m_status_resolution_widget; }
|
||||
__fi QLabel* getStatusFPSWidget() const { return m_status_fps_widget; }
|
||||
__fi QLabel* getStatusVPSWidget() const { return m_status_vps_widget; }
|
||||
|
||||
public Q_SLOTS:
|
||||
void checkForUpdates(bool display_message);
|
||||
void refreshGameList(bool invalidate_cache);
|
||||
|
@ -156,7 +163,6 @@ private Q_SLOTS:
|
|||
void onVMStopped();
|
||||
|
||||
void onGameChanged(const QString& path, const QString& serial, const QString& name, quint32 crc);
|
||||
void onPerformanceMetricsUpdated(const QString& fps_stat, const QString& gs_stat);
|
||||
|
||||
void recreate();
|
||||
|
||||
|
@ -234,8 +240,11 @@ private:
|
|||
AutoUpdaterDialog* m_auto_updater_dialog = nullptr;
|
||||
|
||||
QProgressBar* m_status_progress_widget = nullptr;
|
||||
QLabel* m_status_gs_widget = nullptr;
|
||||
QLabel* m_status_verbose_widget = nullptr;
|
||||
QLabel* m_status_renderer_widget = nullptr;
|
||||
QLabel* m_status_fps_widget = nullptr;
|
||||
QLabel* m_status_vps_widget = nullptr;
|
||||
QLabel* m_status_resolution_widget = nullptr;
|
||||
|
||||
QString m_current_disc_path;
|
||||
QString m_current_game_serial;
|
||||
|
|
Loading…
Reference in New Issue