Changeset View
Changeset View
Standalone View
Standalone View
src/qt/guiutil.cpp
Show First 20 Lines • Show All 59 Lines • ▼ Show 20 Lines | |||||
#if QT_VERSION >= 0x50200 | #if QT_VERSION >= 0x50200 | ||||
#include <QFontDatabase> | #include <QFontDatabase> | ||||
#endif | #endif | ||||
#if defined(Q_OS_MAC) | #if defined(Q_OS_MAC) | ||||
// These Mac includes must be done in the global namespace | // These Mac includes must be done in the global namespace | ||||
#include <CoreFoundation/CoreFoundation.h> | #include <CoreFoundation/CoreFoundation.h> | ||||
#include <CoreServices/CoreServices.h> | #include <CoreServices/CoreServices.h> | ||||
extern double NSAppKitVersionNumber; | |||||
#if !defined(NSAppKitVersionNumber10_8) | |||||
#define NSAppKitVersionNumber10_8 1187 | |||||
#endif | |||||
#if !defined(NSAppKitVersionNumber10_9) | |||||
#define NSAppKitVersionNumber10_9 1265 | |||||
#endif | |||||
#endif | #endif | ||||
namespace GUIUtil { | namespace GUIUtil { | ||||
QString dateTimeStr(const QDateTime &date) { | QString dateTimeStr(const QDateTime &date) { | ||||
return date.date().toString(Qt::SystemLocaleShortDate) + QString(" ") + | return date.date().toString(Qt::SystemLocaleShortDate) + QString(" ") + | ||||
date.toString("hh:mm"); | date.toString("hh:mm"); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 317 Lines • ▼ Show 20 Lines | bool openBitcoinConf() { | ||||
configFile.close(); | configFile.close(); | ||||
/* Open bitcoin.conf with the associated application */ | /* Open bitcoin.conf with the associated application */ | ||||
return QDesktopServices::openUrl( | return QDesktopServices::openUrl( | ||||
QUrl::fromLocalFile(boostPathToQString(pathConfig))); | QUrl::fromLocalFile(boostPathToQString(pathConfig))); | ||||
} | } | ||||
void SubstituteFonts(const QString &language) { | |||||
#if defined(Q_OS_MAC) | |||||
// Background: | |||||
// OSX's default font changed in 10.9 and Qt is unable to find it with its | |||||
// usual fallback methods when building against the 10.7 sdk or lower. | |||||
// The 10.8 SDK added a function to let it find the correct fallback font. | |||||
// If this fallback is not properly loaded, some characters may fail to | |||||
// render correctly. | |||||
// | |||||
// The same thing happened with 10.10. .Helvetica Neue DeskInterface is now | |||||
// default. | |||||
// | |||||
// Solution: If building with the 10.7 SDK or lower and the user's platform | |||||
// is 10.9 or higher at runtime, substitute the correct font. This needs to | |||||
// happen before the QApplication is created. | |||||
#if defined(MAC_OS_X_VERSION_MAX_ALLOWED) && \ | |||||
MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_8 | |||||
if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_8) { | |||||
if (floor(NSAppKitVersionNumber) <= NSAppKitVersionNumber10_9) { | |||||
/* On a 10.9 - 10.9.x system */ | |||||
QFont::insertSubstitution(".Lucida Grande UI", "Lucida Grande"); | |||||
} else { | |||||
/* 10.10 or later system */ | |||||
if (language == "zh_CN" || language == "zh_TW" || | |||||
language == "zh_HK") { | |||||
// traditional or simplified Chinese | |||||
QFont::insertSubstitution(".Helvetica Neue DeskInterface", | |||||
"Heiti SC"); | |||||
} else if (language == "ja") { | |||||
// Japanese | |||||
QFont::insertSubstitution(".Helvetica Neue DeskInterface", | |||||
"Songti SC"); | |||||
} else { | |||||
QFont::insertSubstitution(".Helvetica Neue DeskInterface", | |||||
"Lucida Grande"); | |||||
} | |||||
} | |||||
} | |||||
#endif | |||||
#endif | |||||
} | |||||
ToolTipToRichTextFilter::ToolTipToRichTextFilter(int _size_threshold, | ToolTipToRichTextFilter::ToolTipToRichTextFilter(int _size_threshold, | ||||
QObject *parent) | QObject *parent) | ||||
: QObject(parent), size_threshold(_size_threshold) {} | : QObject(parent), size_threshold(_size_threshold) {} | ||||
bool ToolTipToRichTextFilter::eventFilter(QObject *obj, QEvent *evt) { | bool ToolTipToRichTextFilter::eventFilter(QObject *obj, QEvent *evt) { | ||||
if (evt->type() == QEvent::ToolTipChange) { | if (evt->type() == QEvent::ToolTipChange) { | ||||
QWidget *widget = static_cast<QWidget *>(obj); | QWidget *widget = static_cast<QWidget *>(obj); | ||||
QString tooltip = widget->toolTip(); | QString tooltip = widget->toolTip(); | ||||
▲ Show 20 Lines • Show All 543 Lines • Show Last 20 Lines |