Font
(cherry picked from commit 050925ccac957dea3d4e138babdd7aa93925dffc)
This commit is contained in:
parent
9b8759284b
commit
9f14dc661e
@ -457,8 +457,10 @@ QGraphicsSystem *QApplicationPrivate::graphics_system = 0; // default graphics s
|
|||||||
QString QApplicationPrivate::graphics_system_name; // graphics system id - for delayed initialization
|
QString QApplicationPrivate::graphics_system_name; // graphics system id - for delayed initialization
|
||||||
bool QApplicationPrivate::runtime_graphics_system = false;
|
bool QApplicationPrivate::runtime_graphics_system = false;
|
||||||
|
|
||||||
|
#ifndef Q_WS_QPA
|
||||||
Q_GLOBAL_STATIC(QMutex, applicationFontMutex)
|
Q_GLOBAL_STATIC(QMutex, applicationFontMutex)
|
||||||
QFont *QApplicationPrivate::app_font = 0; // default application font
|
QFont *QApplicationPrivate::app_font = 0; // default application font
|
||||||
|
#endif
|
||||||
QFont *QApplicationPrivate::sys_font = 0; // default system font
|
QFont *QApplicationPrivate::sys_font = 0; // default system font
|
||||||
QFont *QApplicationPrivate::set_font = 0; // default font set by programmer
|
QFont *QApplicationPrivate::set_font = 0; // default font set by programmer
|
||||||
|
|
||||||
@ -1146,11 +1148,14 @@ QApplication::~QApplication()
|
|||||||
QApplicationPrivate::set_pal = 0;
|
QApplicationPrivate::set_pal = 0;
|
||||||
app_palettes()->clear();
|
app_palettes()->clear();
|
||||||
|
|
||||||
|
#ifndef Q_WS_QPA
|
||||||
{
|
{
|
||||||
QMutexLocker locker(applicationFontMutex());
|
QMutexLocker locker(applicationFontMutex());
|
||||||
delete QApplicationPrivate::app_font;
|
delete QApplicationPrivate::app_font;
|
||||||
QApplicationPrivate::app_font = 0;
|
QApplicationPrivate::app_font = 0;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
delete QApplicationPrivate::sys_font;
|
delete QApplicationPrivate::sys_font;
|
||||||
QApplicationPrivate::sys_font = 0;
|
QApplicationPrivate::sys_font = 0;
|
||||||
delete QApplicationPrivate::set_font;
|
delete QApplicationPrivate::set_font;
|
||||||
@ -1940,10 +1945,14 @@ void QApplicationPrivate::setSystemPalette(const QPalette &pal)
|
|||||||
*/
|
*/
|
||||||
QFont QApplication::font()
|
QFont QApplication::font()
|
||||||
{
|
{
|
||||||
|
#ifndef Q_WS_QPA
|
||||||
QMutexLocker locker(applicationFontMutex());
|
QMutexLocker locker(applicationFontMutex());
|
||||||
if (!QApplicationPrivate::app_font)
|
if (!QApplicationPrivate::app_font)
|
||||||
QApplicationPrivate::app_font = new QFont(QLatin1String("Helvetica"));
|
QApplicationPrivate::app_font = new QFont(QLatin1String("Helvetica"));
|
||||||
return *QApplicationPrivate::app_font;
|
return *QApplicationPrivate::app_font;
|
||||||
|
#else
|
||||||
|
return QGuiApplication::font();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@ -2022,11 +2031,15 @@ void QApplication::setFont(const QFont &font, const char *className)
|
|||||||
bool all = false;
|
bool all = false;
|
||||||
FontHash *hash = app_fonts();
|
FontHash *hash = app_fonts();
|
||||||
if (!className) {
|
if (!className) {
|
||||||
|
#ifndef Q_WS_QPA
|
||||||
QMutexLocker locker(applicationFontMutex());
|
QMutexLocker locker(applicationFontMutex());
|
||||||
if (!QApplicationPrivate::app_font)
|
if (!QApplicationPrivate::app_font)
|
||||||
QApplicationPrivate::app_font = new QFont(font);
|
QApplicationPrivate::app_font = new QFont(font);
|
||||||
else
|
else
|
||||||
*QApplicationPrivate::app_font = font;
|
*QApplicationPrivate::app_font = font;
|
||||||
|
#else
|
||||||
|
QGuiApplication::setFont(font);
|
||||||
|
#endif
|
||||||
if (hash && hash->size()) {
|
if (hash && hash->size()) {
|
||||||
all = true;
|
all = true;
|
||||||
hash->clear();
|
hash->clear();
|
||||||
|
@ -432,7 +432,9 @@ public:
|
|||||||
static bool runtime_graphics_system;
|
static bool runtime_graphics_system;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
#ifndef Q_WS_QPA
|
||||||
static QFont *app_font; // private for a reason! Always use QApplication::font() instead!
|
static QFont *app_font; // private for a reason! Always use QApplication::font() instead!
|
||||||
|
#endif
|
||||||
public:
|
public:
|
||||||
static QFont *sys_font;
|
static QFont *sys_font;
|
||||||
static QFont *set_font;
|
static QFont *set_font;
|
||||||
|
@ -47,6 +47,7 @@
|
|||||||
|
|
||||||
#include <QtCore/private/qcoreapplication_p.h>
|
#include <QtCore/private/qcoreapplication_p.h>
|
||||||
#include <QtCore/private/qabstracteventdispatcher_p.h>
|
#include <QtCore/private/qabstracteventdispatcher_p.h>
|
||||||
|
#include <QtCore/qmutex.h>
|
||||||
#include <QtDebug>
|
#include <QtDebug>
|
||||||
|
|
||||||
#include <QtGui/QPlatformIntegration>
|
#include <QtGui/QPlatformIntegration>
|
||||||
@ -92,6 +93,9 @@ QGuiApplicationPrivate *QGuiApplicationPrivate::self = 0;
|
|||||||
QClipboard *QGuiApplicationPrivate::qt_clipboard = 0;
|
QClipboard *QGuiApplicationPrivate::qt_clipboard = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Q_GLOBAL_STATIC(QMutex, applicationFontMutex)
|
||||||
|
QFont *QGuiApplicationPrivate::app_font = 0;
|
||||||
|
|
||||||
QGuiApplication::QGuiApplication(int &argc, char **argv, int flags)
|
QGuiApplication::QGuiApplication(int &argc, char **argv, int flags)
|
||||||
: QCoreApplication(*new QGuiApplicationPrivate(argc, argv, flags))
|
: QCoreApplication(*new QGuiApplicationPrivate(argc, argv, flags))
|
||||||
{
|
{
|
||||||
@ -738,5 +742,21 @@ QClipboard * QGuiApplication::clipboard()
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
QFont QGuiApplication::font()
|
||||||
|
{
|
||||||
|
QMutexLocker locker(applicationFontMutex());
|
||||||
|
if (!QGuiApplicationPrivate::app_font)
|
||||||
|
QGuiApplicationPrivate::app_font = new QFont(QLatin1String("Helvetica"));
|
||||||
|
return *QGuiApplicationPrivate::app_font;
|
||||||
|
}
|
||||||
|
|
||||||
|
void QGuiApplication::setFont(const QFont &font)
|
||||||
|
{
|
||||||
|
QMutexLocker locker(applicationFontMutex());
|
||||||
|
if (!QGuiApplicationPrivate::app_font)
|
||||||
|
QGuiApplicationPrivate::app_font = new QFont(font);
|
||||||
|
else
|
||||||
|
*QGuiApplicationPrivate::app_font = font;
|
||||||
|
}
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
@ -72,14 +72,11 @@ public:
|
|||||||
static void setOverrideCursor(const QCursor &);
|
static void setOverrideCursor(const QCursor &);
|
||||||
static void changeOverrideCursor(const QCursor &);
|
static void changeOverrideCursor(const QCursor &);
|
||||||
static void restoreOverrideCursor();
|
static void restoreOverrideCursor();
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static QFont font();
|
static QFont font();
|
||||||
static QFont font(const QWidget*);
|
static void setFont(const QFont &);
|
||||||
static QFont font(const char *className);
|
|
||||||
static void setFont(const QFont &, const char* className = 0);
|
|
||||||
static QFontMetrics fontMetrics();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef QT_NO_CLIPBOARD
|
#ifndef QT_NO_CLIPBOARD
|
||||||
static QClipboard *clipboard();
|
static QClipboard *clipboard();
|
||||||
|
@ -117,6 +117,8 @@ public:
|
|||||||
#ifndef QT_NO_CLIPBOARD
|
#ifndef QT_NO_CLIPBOARD
|
||||||
static QClipboard *qt_clipboard;
|
static QClipboard *qt_clipboard;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static QFont *app_font;
|
||||||
private:
|
private:
|
||||||
void init();
|
void init();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user