diff options
| author | 2019-05-09 01:41:33 -0400 | |
|---|---|---|
| committer | 2019-05-09 01:46:01 -0400 | |
| commit | d9559448690bdffef0f9930a25f064d5f3c59e12 (patch) | |
| tree | 3f6f045b9cb4f6a45b30ba952f53acadafcece68 | |
| parent | yuzu/about_dialog: Specify string conversions explicitly (diff) | |
| download | yuzu-d9559448690bdffef0f9930a25f064d5f3c59e12.tar.gz yuzu-d9559448690bdffef0f9930a25f064d5f3c59e12.tar.xz yuzu-d9559448690bdffef0f9930a25f064d5f3c59e12.zip | |
yuzu/main: Move window title updating logic to its own function
For similar reasons to the previous change, we move this to a single
function, so we don't need to duplicate the conversion logic in several
places within main.cpp.
| -rw-r--r-- | src/yuzu/main.cpp | 25 | ||||
| -rw-r--r-- | src/yuzu/main.h | 1 |
2 files changed, 19 insertions, 7 deletions
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index e33e3aaaf..a59abf6e8 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp | |||
| @@ -198,11 +198,11 @@ GMainWindow::GMainWindow() | |||
| 198 | 198 | ||
| 199 | ConnectMenuEvents(); | 199 | ConnectMenuEvents(); |
| 200 | ConnectWidgetEvents(); | 200 | ConnectWidgetEvents(); |
| 201 | |||
| 201 | LOG_INFO(Frontend, "yuzu Version: {} | {}-{}", Common::g_build_fullname, Common::g_scm_branch, | 202 | LOG_INFO(Frontend, "yuzu Version: {} | {}-{}", Common::g_build_fullname, Common::g_scm_branch, |
| 202 | Common::g_scm_desc); | 203 | Common::g_scm_desc); |
| 204 | UpdateWindowTitle(); | ||
| 203 | 205 | ||
| 204 | setWindowTitle(QString("yuzu %1| %2-%3") | ||
| 205 | .arg(Common::g_build_fullname, Common::g_scm_branch, Common::g_scm_desc)); | ||
| 206 | show(); | 206 | show(); |
| 207 | 207 | ||
| 208 | Core::System::GetInstance().SetContentProvider( | 208 | Core::System::GetInstance().SetContentProvider( |
| @@ -936,9 +936,7 @@ void GMainWindow::BootGame(const QString& filename) { | |||
| 936 | title_name = FileUtil::GetFilename(filename.toStdString()); | 936 | title_name = FileUtil::GetFilename(filename.toStdString()); |
| 937 | } | 937 | } |
| 938 | 938 | ||
| 939 | setWindowTitle(QString("yuzu %1| %4 | %2-%3") | 939 | UpdateWindowTitle(QString::fromStdString(title_name)); |
| 940 | .arg(Common::g_build_fullname, Common::g_scm_branch, Common::g_scm_desc, | ||
| 941 | QString::fromStdString(title_name))); | ||
| 942 | 940 | ||
| 943 | loading_screen->Prepare(Core::System::GetInstance().GetAppLoader()); | 941 | loading_screen->Prepare(Core::System::GetInstance().GetAppLoader()); |
| 944 | loading_screen->show(); | 942 | loading_screen->show(); |
| @@ -979,8 +977,8 @@ void GMainWindow::ShutdownGame() { | |||
| 979 | loading_screen->Clear(); | 977 | loading_screen->Clear(); |
| 980 | game_list->show(); | 978 | game_list->show(); |
| 981 | game_list->setFilterFocus(); | 979 | game_list->setFilterFocus(); |
| 982 | setWindowTitle(QString("yuzu %1| %2-%3") | 980 | |
| 983 | .arg(Common::g_build_fullname, Common::g_scm_branch, Common::g_scm_desc)); | 981 | UpdateWindowTitle(); |
| 984 | 982 | ||
| 985 | // Disable status bar updates | 983 | // Disable status bar updates |
| 986 | status_bar_update_timer.stop(); | 984 | status_bar_update_timer.stop(); |
| @@ -1767,6 +1765,19 @@ void GMainWindow::OnCaptureScreenshot() { | |||
| 1767 | OnStartGame(); | 1765 | OnStartGame(); |
| 1768 | } | 1766 | } |
| 1769 | 1767 | ||
| 1768 | void GMainWindow::UpdateWindowTitle(const QString& title_name) { | ||
| 1769 | const QString full_name = QString::fromUtf8(Common::g_build_fullname); | ||
| 1770 | const QString branch_name = QString::fromUtf8(Common::g_scm_branch); | ||
| 1771 | const QString description = QString::fromUtf8(Common::g_scm_desc); | ||
| 1772 | |||
| 1773 | if (title_name.isEmpty()) { | ||
| 1774 | setWindowTitle(QStringLiteral("yuzu %1| %2-%3").arg(full_name, branch_name, description)); | ||
| 1775 | } else { | ||
| 1776 | setWindowTitle(QStringLiteral("yuzu %1| %4 | %2-%3") | ||
| 1777 | .arg(full_name, branch_name, description, title_name)); | ||
| 1778 | } | ||
| 1779 | } | ||
| 1780 | |||
| 1770 | void GMainWindow::UpdateStatusBar() { | 1781 | void GMainWindow::UpdateStatusBar() { |
| 1771 | if (emu_thread == nullptr) { | 1782 | if (emu_thread == nullptr) { |
| 1772 | status_bar_update_timer.stop(); | 1783 | status_bar_update_timer.stop(); |
diff --git a/src/yuzu/main.h b/src/yuzu/main.h index fb2a193cb..7bf82e665 100644 --- a/src/yuzu/main.h +++ b/src/yuzu/main.h | |||
| @@ -209,6 +209,7 @@ private slots: | |||
| 209 | 209 | ||
| 210 | private: | 210 | private: |
| 211 | std::optional<u64> SelectRomFSDumpTarget(const FileSys::ContentProvider&, u64 program_id); | 211 | std::optional<u64> SelectRomFSDumpTarget(const FileSys::ContentProvider&, u64 program_id); |
| 212 | void UpdateWindowTitle(const QString& title_name = {}); | ||
| 212 | void UpdateStatusBar(); | 213 | void UpdateStatusBar(); |
| 213 | 214 | ||
| 214 | Ui::MainWindow ui; | 215 | Ui::MainWindow ui; |