diff options
Diffstat (limited to 'src/yuzu/main.cpp')
-rw-r--r-- | src/yuzu/main.cpp | 42 |
1 files changed, 36 insertions, 6 deletions
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index 2d82df739..d6bb18d24 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp @@ -675,6 +675,24 @@ void GMainWindow::RestoreUIState() { Debugger::ToggleConsole(); } +void GMainWindow::OnAppFocusStateChanged(Qt::ApplicationState state) { + if (!UISettings::values.pause_when_in_background) { + return; + } + if (state != Qt::ApplicationHidden && state != Qt::ApplicationInactive && + state != Qt::ApplicationActive) { + LOG_DEBUG(Frontend, "ApplicationState unusual flag: {} ", state); + } + if (ui.action_Pause->isEnabled() && + (state & (Qt::ApplicationHidden | Qt::ApplicationInactive))) { + auto_paused = true; + OnPauseGame(); + } else if (ui.action_Start->isEnabled() && auto_paused && state == Qt::ApplicationActive) { + auto_paused = false; + OnStartGame(); + } +} + void GMainWindow::ConnectWidgetEvents() { connect(game_list, &GameList::GameChosen, this, &GMainWindow::OnGameListLoadFile); connect(game_list, &GameList::OpenDirectory, this, &GMainWindow::OnGameListOpenDirectory); @@ -1889,15 +1907,24 @@ void GMainWindow::OnCaptureScreenshot() { } void GMainWindow::UpdateWindowTitle(const QString& title_name) { - const QString full_name = QString::fromUtf8(Common::g_build_fullname); - const QString branch_name = QString::fromUtf8(Common::g_scm_branch); - const QString description = QString::fromUtf8(Common::g_scm_desc); + const auto full_name = std::string(Common::g_build_fullname); + const auto branch_name = std::string(Common::g_scm_branch); + const auto description = std::string(Common::g_scm_desc); + const auto build_id = std::string(Common::g_build_id); + + const auto date = + QDateTime::currentDateTime().toString(QStringLiteral("yyyy-MM-dd")).toStdString(); if (title_name.isEmpty()) { - setWindowTitle(QStringLiteral("yuzu %1| %2-%3").arg(full_name, branch_name, description)); + const auto fmt = std::string(Common::g_title_bar_format_idle); + setWindowTitle(QString::fromStdString(fmt::format(fmt.empty() ? "yuzu {0}| {1}-{2}" : fmt, + full_name, branch_name, description, + std::string{}, date, build_id))); } else { - setWindowTitle(QStringLiteral("yuzu %1| %4 | %2-%3") - .arg(full_name, branch_name, description, title_name)); + const auto fmt = std::string(Common::g_title_bar_format_running); + setWindowTitle(QString::fromStdString( + fmt::format(fmt.empty() ? "yuzu {0}| {3} | {1}-{2}" : fmt, full_name, branch_name, + description, title_name.toStdString(), date, build_id))); } } @@ -2311,6 +2338,9 @@ int main(int argc, char* argv[]) { // After settings have been loaded by GMainWindow, apply the filter main_window.show(); + QObject::connect(&app, &QGuiApplication::applicationStateChanged, &main_window, + &GMainWindow::OnAppFocusStateChanged); + Settings::LogSettings(); int result = app.exec(); |