Merge pull request #3804 from zhaowenlan1779/titlebar

citra-qt: Improve Title Bar display
This commit is contained in:
James Rowe 2018-06-19 19:41:12 -06:00 committed by GitHub
commit f18b8e3998
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 46 additions and 14 deletions

View File

@ -100,8 +100,8 @@ EmuWindow_SDL2::EmuWindow_SDL2(bool fullscreen) {
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 0); SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 0);
std::string window_title = Common::StringFromFormat("Citra %s| %s-%s ", Common::g_build_name, std::string window_title = Common::StringFromFormat(
Common::g_scm_branch, Common::g_scm_desc); "Citra %s| %s-%s ", Common::g_build_fullname, Common::g_scm_branch, Common::g_scm_desc);
render_window = render_window =
SDL_CreateWindow(window_title.c_str(), SDL_CreateWindow(window_title.c_str(),
SDL_WINDOWPOS_UNDEFINED, // x position SDL_WINDOWPOS_UNDEFINED, // x position
@ -134,8 +134,8 @@ EmuWindow_SDL2::EmuWindow_SDL2(bool fullscreen) {
OnMinimalClientAreaChangeRequest(GetActiveConfig().min_client_area_size); OnMinimalClientAreaChangeRequest(GetActiveConfig().min_client_area_size);
SDL_PumpEvents(); SDL_PumpEvents();
SDL_GL_SetSwapInterval(Settings::values.use_vsync); SDL_GL_SetSwapInterval(Settings::values.use_vsync);
NGLOG_INFO(Frontend, "Citra Version: {} | {}-{}", Common::g_build_name, Common::g_scm_branch, NGLOG_INFO(Frontend, "Citra Version: {} | {}-{}", Common::g_build_fullname,
Common::g_scm_desc); Common::g_scm_branch, Common::g_scm_desc);
DoneCurrent(); DoneCurrent();
} }

View File

@ -13,7 +13,7 @@ AboutDialog::AboutDialog(QWidget* parent)
ui->setupUi(this); ui->setupUi(this);
ui->labelLogo->setPixmap(QIcon::fromTheme("citra").pixmap(200)); ui->labelLogo->setPixmap(QIcon::fromTheme("citra").pixmap(200));
ui->labelBuildInfo->setText( ui->labelBuildInfo->setText(
ui->labelBuildInfo->text().arg(Common::g_build_name, Common::g_scm_branch, ui->labelBuildInfo->text().arg(Common::g_build_fullname, Common::g_scm_branch,
Common::g_scm_desc, QString(Common::g_build_date).left(10))); Common::g_scm_desc, QString(Common::g_build_date).left(10)));
} }

View File

@ -137,8 +137,8 @@ GMainWindow::GMainWindow() : config(new Config()), emu_thread(nullptr) {
ConnectWidgetEvents(); ConnectWidgetEvents();
SetupUIStrings(); SetupUIStrings();
NGLOG_INFO(Frontend, "Citra Version: {} | {}-{}", Common::g_build_name, Common::g_scm_branch, NGLOG_INFO(Frontend, "Citra Version: {} | {}-{}", Common::g_build_fullname,
Common::g_scm_desc); Common::g_scm_branch, Common::g_scm_desc);
show(); show();
@ -606,6 +606,10 @@ bool GMainWindow::LoadROM(const QString& filename) {
Core::System& system{Core::System::GetInstance()}; Core::System& system{Core::System::GetInstance()};
const Core::System::ResultStatus result{system.Load(render_window, filename.toStdString())}; const Core::System::ResultStatus result{system.Load(render_window, filename.toStdString())};
std::string title;
system.GetAppLoader().ReadTitle(title);
game_title = QString::fromStdString(title);
SetupUIStrings();
if (result != Core::System::ResultStatus::Success) { if (result != Core::System::ResultStatus::Success) {
switch (result) { switch (result) {
@ -755,6 +759,9 @@ void GMainWindow::ShutdownGame() {
if (defer_update_prompt) { if (defer_update_prompt) {
ShowUpdatePrompt(); ShowUpdatePrompt();
} }
game_title.clear();
SetupUIStrings();
} }
void GMainWindow::StoreRecentFile(const QString& filename) { void GMainWindow::StoreRecentFile(const QString& filename) {
@ -1407,8 +1414,11 @@ void GMainWindow::OnLanguageChanged(const QString& locale) {
} }
void GMainWindow::SetupUIStrings() { void GMainWindow::SetupUIStrings() {
setWindowTitle( if (game_title.isEmpty()) {
tr("Citra %1| %2-%3").arg(Common::g_build_name, Common::g_scm_branch, Common::g_scm_desc)); setWindowTitle(tr("Citra %1").arg(Common::g_build_fullname));
} else {
setWindowTitle(tr("Citra %1| %2").arg(Common::g_build_fullname, game_title));
}
} }
void GMainWindow::SyncMenuUISettings() { void GMainWindow::SyncMenuUISettings() {

View File

@ -202,6 +202,8 @@ private:
// Whether emulation is currently running in Citra. // Whether emulation is currently running in Citra.
bool emulation_running = false; bool emulation_running = false;
std::unique_ptr<EmuThread> emu_thread; std::unique_ptr<EmuThread> emu_thread;
// The title of the game currently running
QString game_title;
// Debugger panes // Debugger panes
ProfilerWidget* profilerWidget; ProfilerWidget* profilerWidget;

View File

@ -1,13 +1,16 @@
# Generate cpp with Git revision from template # Generate cpp with Git revision from template
# Also if this is a CI build, add the build name (ie: Nightly, Bleeding Edge) to the scm_rev file as well # Also if this is a CI build, add the build name (ie: Nightly, Canary) to the scm_rev file as well
set(REPO_NAME "") set(REPO_NAME "")
set(BUILD_VERSION "0")
if ($ENV{CI}) if ($ENV{CI})
if ($ENV{TRAVIS}) if ($ENV{TRAVIS})
set(BUILD_REPOSITORY $ENV{TRAVIS_REPO_SLUG}) set(BUILD_REPOSITORY $ENV{TRAVIS_REPO_SLUG})
set(BUILD_TAG $ENV{TRAVIS_TAG})
elseif($ENV{APPVEYOR}) elseif($ENV{APPVEYOR})
set(BUILD_REPOSITORY $ENV{APPVEYOR_REPO_NAME}) set(BUILD_REPOSITORY $ENV{APPVEYOR_REPO_NAME})
set(BUILD_TAG $ENV{APPVEYOR_REPO_TAG_NAME})
endif() endif()
# regex capture the string nightly or bleeding-edge into CMAKE_MATCH_1 # regex capture the string nightly or canary into CMAKE_MATCH_1
string(REGEX MATCH "citra-emu/citra-?(.*)" OUTVAR ${BUILD_REPOSITORY}) string(REGEX MATCH "citra-emu/citra-?(.*)" OUTVAR ${BUILD_REPOSITORY})
if (${CMAKE_MATCH_COUNT} GREATER 0) if (${CMAKE_MATCH_COUNT} GREATER 0)
# capitalize the first letter of each word in the repo name. # capitalize the first letter of each word in the repo name.
@ -16,10 +19,21 @@ if ($ENV{CI})
string(SUBSTRING ${WORD} 0 1 FIRST_LETTER) string(SUBSTRING ${WORD} 0 1 FIRST_LETTER)
string(SUBSTRING ${WORD} 1 -1 REMAINDER) string(SUBSTRING ${WORD} 1 -1 REMAINDER)
string(TOUPPER ${FIRST_LETTER} FIRST_LETTER) string(TOUPPER ${FIRST_LETTER} FIRST_LETTER)
# this leaves a trailing space on the last word, but we actually want that
# because of how it's styled in the title bar.
set(REPO_NAME "${REPO_NAME}${FIRST_LETTER}${REMAINDER}") set(REPO_NAME "${REPO_NAME}${FIRST_LETTER}${REMAINDER}")
endforeach() endforeach()
if (BUILD_TAG)
string(REGEX MATCH "${CMAKE_MATCH_1}-([0-9]+)" OUTVAR ${BUILD_TAG})
if (${CMAKE_MATCH_COUNT} GREATER 0)
set(BUILD_VERSION ${CMAKE_MATCH_1})
endif()
if (BUILD_VERSION)
# This leaves a trailing space on the last word, but we actually want that
# because of how it's styled in the title bar.
set(BUILD_FULLNAME "${REPO_NAME} #${BUILD_VERSION} ")
else()
set(BUILD_FULLNAME "")
endif()
endif()
endif() endif()
endif() endif()
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/scm_rev.cpp.in" "${CMAKE_CURRENT_SOURCE_DIR}/scm_rev.cpp" @ONLY) configure_file("${CMAKE_CURRENT_SOURCE_DIR}/scm_rev.cpp.in" "${CMAKE_CURRENT_SOURCE_DIR}/scm_rev.cpp" @ONLY)

View File

@ -9,6 +9,8 @@
#define GIT_DESC "@GIT_DESC@" #define GIT_DESC "@GIT_DESC@"
#define BUILD_NAME "@REPO_NAME@" #define BUILD_NAME "@REPO_NAME@"
#define BUILD_DATE "@BUILD_DATE@" #define BUILD_DATE "@BUILD_DATE@"
#define BUILD_VERSION "@BUILD_VERSION@"
#define BUILD_FULLNAME "@BUILD_FULLNAME@"
namespace Common { namespace Common {
@ -17,6 +19,8 @@ const char g_scm_branch[] = GIT_BRANCH;
const char g_scm_desc[] = GIT_DESC; const char g_scm_desc[] = GIT_DESC;
const char g_build_name[] = BUILD_NAME; const char g_build_name[] = BUILD_NAME;
const char g_build_date[] = BUILD_DATE; const char g_build_date[] = BUILD_DATE;
const char g_build_fullname[] = BUILD_FULLNAME;
const char g_build_version[] = BUILD_VERSION;
} // namespace } // namespace

View File

@ -11,5 +11,7 @@ extern const char g_scm_branch[];
extern const char g_scm_desc[]; extern const char g_scm_desc[];
extern const char g_build_name[]; extern const char g_build_name[];
extern const char g_build_date[]; extern const char g_build_date[];
extern const char g_build_fullname[];
extern const char g_build_version[];
} // namespace Common } // namespace Common