Simplify main window title bar removing common suffixes

On Apple Silicon we can hide "-arm64", and on PCs we can hide "-x64".
For Intel chips on Mac we'll show "(x64)" suffix, and on PCs we'll
show "(x86)" for 32-bit version.
This commit is contained in:
David Capello 2023-11-26 22:13:08 -03:00
parent 700217c413
commit 7e331d95e2

View File

@ -57,6 +57,8 @@
#include "app/util/clipboard.h"
#include "base/exception.h"
#include "base/fs.h"
#include "base/platform.h"
#include "base/replace_string.h"
#include "base/split_string.h"
#include "doc/sprite.h"
#include "fmt/format.h"
@ -762,9 +764,35 @@ void App::showBackupNotification(bool state)
void App::updateDisplayTitleBar()
{
std::string defaultTitle = fmt::format("{} v{}", get_app_name(), get_app_version());
static std::string defaultTitle;
std::string title;
if (defaultTitle.empty()) {
defaultTitle = fmt::format("{} v{}", get_app_name(), get_app_version());
#if LAF_MACOS
// On macOS we remove the "-arm64" suffix for Apple Silicon as it
// will be the most common platform from now on.
if constexpr (base::Platform::arch == base::Platform::Arch::arm64) {
base::replace_string(defaultTitle, "-arm64", "");
}
else if constexpr (base::Platform::arch == base::Platform::Arch::x64) {
base::replace_string(defaultTitle, "-x64", "");
defaultTitle += " (x64)";
}
#else
// On PC (Windows/Linux) we try to remove "-x64" suffix as it's
// the most common platform.
if constexpr (base::Platform::arch == base::Platform::Arch::x64) {
base::replace_string(defaultTitle, "-x64", "");
}
else if constexpr (base::Platform::arch == base::Platform::Arch::x86) {
base::replace_string(defaultTitle, "-x86", "");
defaultTitle += " (x86)";
}
#endif
}
DocView* docView = UIContext::instance()->activeView();
if (docView) {
// Prepend the document's filename.