From 8d28f263aa14cc450085c9df3623a483b6021c56 Mon Sep 17 00:00:00 2001 From: Jan-Arve Saether Date: Tue, 27 Mar 2012 07:09:22 +0200 Subject: Fix IAccessible2 for Windows, enable MSAA/IAccessible for MinGW. Commit 5e9089135bfe7db7d7a43c9ee4d4c24ab8f6458d had some problems: * It left out the cast to IServiceProvider in the refactoring of QueryInterface. This broke IAccessible2. * It also failed to enable the codepath for MinGW inside wrap(), which effectively caused MSAA for MinGW to be disabled. It also adds an autotest to the bridge (finally). It is simple, but it should help avoiding committing stuff that completely breaks the bridge. Change-Id: I459d89c3bdb93e54ddea85872b50fc1dba0fe4a0 Reviewed-by: Friedemann Kleint --- src/plugins/platforms/windows/accessible/iaccessible2.cpp | 4 +++- src/plugins/platforms/windows/accessible/qwindowsaccessibility.cpp | 4 ---- 2 files changed, 3 insertions(+), 5 deletions(-) (limited to 'src/plugins/platforms/windows') diff --git a/src/plugins/platforms/windows/accessible/iaccessible2.cpp b/src/plugins/platforms/windows/accessible/iaccessible2.cpp index c3d5c543cf..be680e7d48 100644 --- a/src/plugins/platforms/windows/accessible/iaccessible2.cpp +++ b/src/plugins/platforms/windows/accessible/iaccessible2.cpp @@ -169,7 +169,9 @@ HRESULT STDMETHODCALLTYPE QWindowsIA2Accessible::QueryInterface(REFIID id, LPVOI { HRESULT hr = QWindowsMsaaAccessible::QueryInterface(id, iface); if (!SUCCEEDED(hr)) { - if (id == IID_IAccessible2) { + if (id == IID_IServiceProvider) { + *iface = (IServiceProvider*)this; + } else if (id == IID_IAccessible2) { *iface = (IAccessible2*)this; } else if (id == IID_IAccessibleAction) { if (accessible->actionInterface()) diff --git a/src/plugins/platforms/windows/accessible/qwindowsaccessibility.cpp b/src/plugins/platforms/windows/accessible/qwindowsaccessibility.cpp index bd928399c8..0672a86dd9 100644 --- a/src/plugins/platforms/windows/accessible/qwindowsaccessibility.cpp +++ b/src/plugins/platforms/windows/accessible/qwindowsaccessibility.cpp @@ -232,9 +232,6 @@ QWindow *QWindowsAccessibility::windowHelper(const QAccessibleInterface *iface) */ IAccessible *QWindowsAccessibility::wrap(QAccessibleInterface *acc) { -#ifdef Q_CC_MINGW - return 0; -#else if (!acc) return 0; #ifdef Q_CC_MINGW @@ -245,7 +242,6 @@ IAccessible *QWindowsAccessibility::wrap(QAccessibleInterface *acc) IAccessible *iacc = 0; wacc->QueryInterface(IID_IAccessible, (void**)&iacc); return iacc; -#endif } /*! -- cgit v1.2.3 From 4f92f9b7251addef556b25e8ab88e00acfaf61b0 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 27 Mar 2012 08:30:47 +0200 Subject: Introduce FontSmoothingGamma as a platform style hint. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Allocate gamma tables on the heap in a thread-safe way, use font smoothing returned by the style hints of the platform to calculate them. - Improve font rendering on Windows. Change-Id: I8cd39b51cf03cbd642474c02b9076814baecd597 Reviewed-by: Samuel Rødal --- .../platforms/windows/qwindowsfontdatabase.cpp | 28 ++++++++++++---------- .../platforms/windows/qwindowsfontdatabase.h | 2 ++ .../platforms/windows/qwindowsintegration.cpp | 2 ++ 3 files changed, 20 insertions(+), 12 deletions(-) (limited to 'src/plugins/platforms/windows') diff --git a/src/plugins/platforms/windows/qwindowsfontdatabase.cpp b/src/plugins/platforms/windows/qwindowsfontdatabase.cpp index e0be731b53..7d0bd53e8b 100644 --- a/src/plugins/platforms/windows/qwindowsfontdatabase.cpp +++ b/src/plugins/platforms/windows/qwindowsfontdatabase.cpp @@ -68,8 +68,10 @@ QT_BEGIN_NAMESPACE */ QWindowsFontEngineData::QWindowsFontEngineData() + : clearTypeEnabled(false) + , fontSmoothingGamma(QWindowsFontDatabase::fontSmoothingGamma()) #if !defined(QT_NO_DIRECTWRITE) - : directWriteFactory(0) + , directWriteFactory(0) , directWriteGdiInterop(0) #endif { @@ -78,17 +80,6 @@ QWindowsFontEngineData::QWindowsFontEngineData() if (SystemParametersInfo(SPI_GETFONTSMOOTHINGTYPE, 0, &result, 0)) clearTypeEnabled = (result == FE_FONTSMOOTHINGCLEARTYPE); - int winSmooth; - if (SystemParametersInfo(0x200C /* SPI_GETFONTSMOOTHINGCONTRAST */, 0, &winSmooth, 0)) { - fontSmoothingGamma = winSmooth / qreal(1000.0); - } else { - fontSmoothingGamma = 1.0; - } - - // Safeguard ourselves against corrupt registry values... - if (fontSmoothingGamma > 5 || fontSmoothingGamma < 1) - fontSmoothingGamma = qreal(1.4); - const qreal gray_gamma = 2.31; for (int i=0; i<256; ++i) pow_gamma[i] = uint(qRound(qPow(i / qreal(255.), gray_gamma) * 2047)); @@ -110,6 +101,19 @@ QWindowsFontEngineData::~QWindowsFontEngineData() #endif } +qreal QWindowsFontDatabase::fontSmoothingGamma() +{ + int winSmooth; + qreal result = 1; + if (SystemParametersInfo(0x200C /* SPI_GETFONTSMOOTHINGCONTRAST */, 0, &winSmooth, 0)) + result = qreal(winSmooth) / qreal(1000.0); + + // Safeguard ourselves against corrupt registry values... + if (result > 5 || result < 1) + result = qreal(1.4); + return result; +} + #if !defined(QT_NO_DIRECTWRITE) static inline bool initDirectWrite(QWindowsFontEngineData *d) { diff --git a/src/plugins/platforms/windows/qwindowsfontdatabase.h b/src/plugins/platforms/windows/qwindowsfontdatabase.h index f8f2a1eb85..774a203a55 100644 --- a/src/plugins/platforms/windows/qwindowsfontdatabase.h +++ b/src/plugins/platforms/windows/qwindowsfontdatabase.h @@ -96,6 +96,8 @@ public: static HFONT systemFont(); static QFont LOGFONT_to_QFont(const LOGFONT& lf, int verticalDPI = 0); + static qreal fontSmoothingGamma(); + private: void populate(const QString &family = QString()); QSharedPointer m_fontEngineData; diff --git a/src/plugins/platforms/windows/qwindowsintegration.cpp b/src/plugins/platforms/windows/qwindowsintegration.cpp index ee58a19ca9..fa63d77dd7 100644 --- a/src/plugins/platforms/windows/qwindowsintegration.cpp +++ b/src/plugins/platforms/windows/qwindowsintegration.cpp @@ -317,6 +317,8 @@ QVariant QWindowsIntegration::styleHint(QPlatformIntegration::StyleHint hint) co case QPlatformIntegration::KeyboardInputInterval: case QPlatformIntegration::ShowIsFullScreen: break; // Not implemented + case QPlatformIntegration::FontSmoothingGamma: + return QVariant(QWindowsFontDatabase::fontSmoothingGamma()); } return QPlatformIntegration::styleHint(hint); } -- cgit v1.2.3 From 4f1820e3a77b3fdda32a1b935502b187e73059cf Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Fri, 23 Mar 2012 14:17:23 +0200 Subject: Implement application font loading for Windows For FreeType Windows font database, use the application font loading implementation of the parent class. For native Windows font database, the implementation was adapted from Qt 4.8. Also fixed a bug in font database population, where old data was not destroyed before population, resulting in fonts not getting properly repopulated when a new font was added. Task-number: QTBUG-24193 Task-number: QTBUG-24195 Task-number: QTBUG-24196 Change-Id: Ie224a87baf7500b9867aaafa807f62dd4503dee8 Reviewed-by: Friedemann Kleint --- .../platforms/windows/qwindowsfontdatabase.cpp | 173 +++++++++++++++++++-- .../platforms/windows/qwindowsfontdatabase.h | 8 + .../platforms/windows/qwindowsfontdatabase_ft.cpp | 23 +-- .../platforms/windows/qwindowsfontdatabase_ft.h | 1 - 4 files changed, 177 insertions(+), 28 deletions(-) (limited to 'src/plugins/platforms/windows') diff --git a/src/plugins/platforms/windows/qwindowsfontdatabase.cpp b/src/plugins/platforms/windows/qwindowsfontdatabase.cpp index 7d0bd53e8b..c1c25dd686 100644 --- a/src/plugins/platforms/windows/qwindowsfontdatabase.cpp +++ b/src/plugins/platforms/windows/qwindowsfontdatabase.cpp @@ -51,6 +51,7 @@ #include #include +#include #include @@ -618,14 +619,14 @@ static int CALLBACK storeFont(ENUMLOGFONTEX* f, NEWTEXTMETRICEX *textmetric, void QWindowsFontDatabase::populateFontDatabase() { - if (m_families.isEmpty()) { - QPlatformFontDatabase::populateFontDatabase(); - populate(); // Called multiple times. - // Work around EnumFontFamiliesEx() not listing the system font, see below. - const QString sysFontFamily = QGuiApplication::font().family(); - if (!m_families.contains(sysFontFamily)) - populate(sysFontFamily); - } + m_families.clear(); + removeApplicationFonts(); + QPlatformFontDatabase::populateFontDatabase(); + populate(); // Called multiple times. + // Work around EnumFontFamiliesEx() not listing the system font, see below. + const QString sysFontFamily = QGuiApplication::font().family(); + if (!m_families.contains(sysFontFamily)) + populate(sysFontFamily); } /*! @@ -669,6 +670,7 @@ QWindowsFontDatabase::QWindowsFontDatabase() : QWindowsFontDatabase::~QWindowsFontDatabase() { + removeApplicationFonts(); } QFontEngine * QWindowsFontDatabase::fontEngine(const QFontDef &fontDef, @@ -702,11 +704,160 @@ QStringList QWindowsFontDatabase::fallbacksForFamily(const QString family, const return result; } +static QList getTrueTypeFontOffsets(const uchar *fontData) +{ + QList offsets; + const quint32 headerTag = *reinterpret_cast(fontData); + if (headerTag != MAKE_TAG('t', 't', 'c', 'f')) { + if (headerTag != MAKE_TAG(0, 1, 0, 0) + && headerTag != MAKE_TAG('O', 'T', 'T', 'O') + && headerTag != MAKE_TAG('t', 'r', 'u', 'e') + && headerTag != MAKE_TAG('t', 'y', 'p', '1')) + return offsets; + offsets << 0; + return offsets; + } + const quint32 numFonts = qFromBigEndian(fontData + 8); + for (uint i = 0; i < numFonts; ++i) { + offsets << qFromBigEndian(fontData + 12 + i * 4); + } + return offsets; +} + +static void getFontTable(const uchar *fileBegin, const uchar *data, quint32 tag, const uchar **table, quint32 *length) +{ + const quint16 numTables = qFromBigEndian(data + 4); + for (uint i = 0; i < numTables; ++i) { + const quint32 offset = 12 + 16 * i; + if (*reinterpret_cast(data + offset) == tag) { + *table = fileBegin + qFromBigEndian(data + offset + 8); + *length = qFromBigEndian(data + offset + 12); + return; + } + } + *table = 0; + *length = 0; + return; +} + +static void getFamiliesAndSignatures(const QByteArray &fontData, + QStringList *families, + QVector *signatures) +{ + const uchar *data = reinterpret_cast(fontData.constData()); + + QList offsets = getTrueTypeFontOffsets(data); + if (offsets.isEmpty()) + return; + + for (int i = 0; i < offsets.count(); ++i) { + const uchar *font = data + offsets.at(i); + const uchar *table; + quint32 length; + getFontTable(data, font, MAKE_TAG('n', 'a', 'm', 'e'), &table, &length); + if (!table) + continue; + QString name = getEnglishName(table, length); + if (name.isEmpty()) + continue; + + families->append(name); + + if (signatures) { + FONTSIGNATURE signature; + getFontTable(data, font, MAKE_TAG('O', 'S', '/', '2'), &table, &length); + if (table && length >= 86) { + // Offsets taken from OS/2 table in the TrueType spec + signature.fsUsb[0] = qFromBigEndian(table + 42); + signature.fsUsb[1] = qFromBigEndian(table + 46); + signature.fsUsb[2] = qFromBigEndian(table + 50); + signature.fsUsb[3] = qFromBigEndian(table + 54); + + signature.fsCsb[0] = qFromBigEndian(table + 78); + signature.fsCsb[1] = qFromBigEndian(table + 82); + } else { + memset(&signature, 0, sizeof(signature)); + } + signatures->append(signature); + } + } +} + QStringList QWindowsFontDatabase::addApplicationFont(const QByteArray &fontData, const QString &fileName) { - const QStringList result = QPlatformFontDatabase::addApplicationFont(fontData, fileName); - Q_UNIMPLEMENTED(); - return result; + WinApplicationFont font; + font.fileName = fileName; + QVector signatures; + QStringList families; + + if (!fontData.isEmpty()) { + getFamiliesAndSignatures(fontData, &families, &signatures); + if (families.isEmpty()) + return families; + + DWORD dummy = 0; + font.handle = AddFontMemResourceEx((void *)fontData.constData(), fontData.size(), 0, + &dummy); + if (font.handle == 0) + return QStringList(); + + // Memory fonts won't show up in enumeration, so do add them the hard way. + for (int j = 0; j < families.count(); ++j) { + const QString familyName = families.at(j); + HDC hdc = GetDC(0); + LOGFONT lf; + memset(&lf, 0, sizeof(LOGFONT)); + memcpy(lf.lfFaceName, familyName.utf16(), sizeof(wchar_t) * qMin(LF_FACESIZE, familyName.size())); + lf.lfCharSet = DEFAULT_CHARSET; + HFONT hfont = CreateFontIndirect(&lf); + HGDIOBJ oldobj = SelectObject(hdc, hfont); + + TEXTMETRIC textMetrics; + GetTextMetrics(hdc, &textMetrics); + + addFontToDatabase(familyName, QString(), &textMetrics, &signatures.at(j), + TRUETYPE_FONTTYPE); + + SelectObject(hdc, oldobj); + DeleteObject(hfont); + ReleaseDC(0, hdc); + } + } else { + QFile f(fileName); + if (!f.open(QIODevice::ReadOnly)) + return families; + QByteArray data = f.readAll(); + f.close(); + + getFamiliesAndSignatures(data, &families, 0); + if (families.isEmpty()) + return families; + + if (AddFontResourceExW((wchar_t*)fileName.utf16(), FR_PRIVATE, 0) == 0) + return QStringList(); + + font.handle = 0; + + // Fonts based on files are added via populate, as they will show up in font enumeration. + for (int j = 0; j < families.count(); ++j) + populate(families.at(j)); + } + + m_applicationFonts << font; + + return families; +} + +void QWindowsFontDatabase::removeApplicationFonts() +{ + foreach (const WinApplicationFont &font, m_applicationFonts) { + if (font.handle) { + RemoveFontMemResourceEx(font.handle); + } else { + RemoveFontResourceExW((LPCWSTR)font.fileName.utf16(), FR_PRIVATE, 0); + } + } + m_applicationFonts.clear(); } void QWindowsFontDatabase::releaseHandle(void *handle) diff --git a/src/plugins/platforms/windows/qwindowsfontdatabase.h b/src/plugins/platforms/windows/qwindowsfontdatabase.h index 774a203a55..2fa615253e 100644 --- a/src/plugins/platforms/windows/qwindowsfontdatabase.h +++ b/src/plugins/platforms/windows/qwindowsfontdatabase.h @@ -100,8 +100,16 @@ public: private: void populate(const QString &family = QString()); + void removeApplicationFonts(); QSharedPointer m_fontEngineData; QSet m_families; + + struct WinApplicationFont { + HANDLE handle; + QString fileName; + }; + + QList m_applicationFonts; }; QT_END_NAMESPACE diff --git a/src/plugins/platforms/windows/qwindowsfontdatabase_ft.cpp b/src/plugins/platforms/windows/qwindowsfontdatabase_ft.cpp index f90a880cd3..500a1eeccb 100644 --- a/src/plugins/platforms/windows/qwindowsfontdatabase_ft.cpp +++ b/src/plugins/platforms/windows/qwindowsfontdatabase_ft.cpp @@ -273,14 +273,13 @@ static int CALLBACK storeFont(ENUMLOGFONTEX* f, NEWTEXTMETRICEX *textmetric, void QWindowsFontDatabaseFT::populateFontDatabase() { - if (m_families.isEmpty()) { - QPlatformFontDatabase::populateFontDatabase(); - populate(); // Called multiple times. - // Work around EnumFontFamiliesEx() not listing the system font, see below. - const QString sysFontFamily = QGuiApplication::font().family(); - if (!m_families.contains(sysFontFamily)) - populate(sysFontFamily); - } + m_families.clear(); + QPlatformFontDatabase::populateFontDatabase(); + populate(); // Called multiple times. + // Work around EnumFontFamiliesEx() not listing the system font, see below. + const QString sysFontFamily = QGuiApplication::font().family(); + if (!m_families.contains(sysFontFamily)) + populate(sysFontFamily); } /*! @@ -426,14 +425,6 @@ QStringList QWindowsFontDatabaseFT::fallbacksForFamily(const QString family, con << script << result << m_families; return result; } - -QStringList QWindowsFontDatabaseFT::addApplicationFont(const QByteArray &fontData, const QString &fileName) -{ - const QStringList result = QPlatformFontDatabase::addApplicationFont(fontData, fileName); - Q_UNIMPLEMENTED(); - return result; -} - QString QWindowsFontDatabaseFT::fontDir() const { const QString result = QLatin1String(qgetenv("windir")) + QLatin1String("/Fonts");//QPlatformFontDatabase::fontDir(); diff --git a/src/plugins/platforms/windows/qwindowsfontdatabase_ft.h b/src/plugins/platforms/windows/qwindowsfontdatabase_ft.h index 24810c9202..bb55b68251 100644 --- a/src/plugins/platforms/windows/qwindowsfontdatabase_ft.h +++ b/src/plugins/platforms/windows/qwindowsfontdatabase_ft.h @@ -56,7 +56,6 @@ public: QFontEngine *fontEngine(const QByteArray &fontData, qreal pixelSize, QFont::HintingPreference hintingPreference); QStringList fallbacksForFamily(const QString family, const QFont::Style &style, const QFont::StyleHint &styleHint, const QUnicodeTables::Script &script) const; - QStringList addApplicationFont(const QByteArray &fontData, const QString &fileName); virtual QString fontDir() const; virtual QFont defaultFont() const; -- cgit v1.2.3 From 1e8f2ae34b8412c23e1c579440e3bb4e376b5664 Mon Sep 17 00:00:00 2001 From: Pekka Vuorela Date: Thu, 29 Mar 2012 16:22:54 +0300 Subject: Adapt windows input context to QGuiApplication::focusObject() Change-Id: I8c18814d705b456d3285d7a5f2e1e0849af99b70 Reviewed-by: Friedemann Kleint --- src/plugins/platforms/windows/qwindowsinputcontext.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/plugins/platforms/windows') diff --git a/src/plugins/platforms/windows/qwindowsinputcontext.cpp b/src/plugins/platforms/windows/qwindowsinputcontext.cpp index ae5053210e..03a76258f4 100644 --- a/src/plugins/platforms/windows/qwindowsinputcontext.cpp +++ b/src/plugins/platforms/windows/qwindowsinputcontext.cpp @@ -184,7 +184,7 @@ void QWindowsInputContext::reset() QPlatformInputContext::reset(); if (!m_compositionContext.hwnd) return; - QObject *fo = qApp->inputMethod()->inputItem(); + QObject *fo = qApp->focusObject(); if (QWindowsContext::verboseInputMethods) qDebug() << __FUNCTION__<< fo; if (!fo) @@ -329,11 +329,11 @@ static inline QTextFormat standardFormat(StandardFormat format) bool QWindowsInputContext::startComposition(HWND hwnd) { - const QObject *fo = qApp->inputMethod()->inputItem(); + const QObject *fo = qApp->focusObject(); if (!fo) return false; // This should always match the object. - QWindow *window = qApp->inputMethod()->inputWindow(); + QWindow *window = qApp->focusWindow(); if (!window) return false; if (QWindowsContext::verboseInputMethods) @@ -397,7 +397,7 @@ static inline QList bool QWindowsInputContext::composition(HWND hwnd, LPARAM lParamIn) { - QObject *fo = qApp->inputMethod()->inputItem(); + QObject *fo = qApp->focusObject(); const int lParam = int(lParamIn); if (QWindowsContext::verboseInputMethods) qDebug() << '>' << __FUNCTION__ << fo << debugComposition(lParam) @@ -459,7 +459,7 @@ bool QWindowsInputContext::endComposition(HWND hwnd) // against that. if (m_endCompositionRecursionGuard || m_compositionContext.hwnd != hwnd) return false; - QObject *fo = qApp->inputMethod()->inputItem(); + QObject *fo = qApp->focusObject(); if (!fo) return false; @@ -537,7 +537,7 @@ bool QWindowsInputContext::handleIME_Request(WPARAM wParam, int QWindowsInputContext::reconvertString(RECONVERTSTRING *reconv) { - QObject *fo = qApp->inputMethod()->inputItem(); + QObject *fo = qApp->focusObject(); if (!fo) return false; -- cgit v1.2.3 From 108e708e7068bcd402c7f3202e76ab2c2ebd9a68 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Fri, 30 Mar 2012 14:51:42 +0300 Subject: Windows: Improve Freetype font database registry check for fonts Some non-scalable fonts like "Courier" list some numbers after the font name in Windows registry, e.g. "Courier 10,12,15". These are not part of the font name and therefore confused the algorithm looking for font files. Improved the algorithm to ignore this kind of number list. Single numbers are still expected to be part of the font name. Task-number: QTBUG-24970 Change-Id: I3fe45b798f44bee962e5b3aa748fc4717f723353 Reviewed-by: Friedemann Kleint Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/plugins/platforms/windows/qwindowsfontdatabase_ft.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/plugins/platforms/windows') diff --git a/src/plugins/platforms/windows/qwindowsfontdatabase_ft.cpp b/src/plugins/platforms/windows/qwindowsfontdatabase_ft.cpp index 500a1eeccb..e84f0c7630 100644 --- a/src/plugins/platforms/windows/qwindowsfontdatabase_ft.cpp +++ b/src/plugins/platforms/windows/qwindowsfontdatabase_ft.cpp @@ -195,9 +195,11 @@ static bool addFontToDatabase(QString familyName, const QString &scriptName, const QStringList allKeys = fontRegistry.allKeys(); allFonts.reserve(allKeys.size()); const QString trueType = QStringLiteral("(TrueType)"); + const QRegExp sizeListMatch(QStringLiteral("\\s(\\d+,)+\\d+")); foreach (const QString &key, allKeys) { QString realKey = key; realKey.remove(trueType); + realKey.remove(sizeListMatch); QStringList fonts; const QStringList fontNames = realKey.trimmed().split(QLatin1Char('&')); foreach (const QString &fontName, fontNames) -- cgit v1.2.3 From 95d411578d44693059c05ccbec586aab4363092a Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 3 Apr 2012 14:11:17 +0200 Subject: WindowsXP: Fix Item view alternate color being black. The theme palette needs to be initialized by the standard palette. Change-Id: I91c2ac9aea122e6ed9c09c96b35dfe0ef18a3ca0 Reviewed-by: Friedemann Kleint --- src/plugins/platforms/windows/qwindowstheme.cpp | 38 +++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 3 deletions(-) (limited to 'src/plugins/platforms/windows') diff --git a/src/plugins/platforms/windows/qwindowstheme.cpp b/src/plugins/platforms/windows/qwindowstheme.cpp index f3a9d91d00..513bebbc8b 100644 --- a/src/plugins/platforms/windows/qwindowstheme.cpp +++ b/src/plugins/platforms/windows/qwindowstheme.cpp @@ -68,12 +68,27 @@ static inline QTextStream& operator<<(QTextStream &str, const QColor &c) return str; } +static inline void paletteRoleToString(const QPalette &palette, + const QPalette::ColorRole role, + QTextStream &str) +{ + str << "Role: "; + str.setFieldWidth(2); + str.setPadChar(QLatin1Char('0')); + str << role; + str.setFieldWidth(0); + str << " Active: " << palette.color(QPalette::Active, role) + << " Disabled: " << palette.color(QPalette::Disabled, role) + << " Inactive: " << palette.color(QPalette::Inactive, role) + << '\n'; +} + static inline QString paletteToString(const QPalette &palette) { QString result; QTextStream str(&result); - str << "text=" << palette.color(QPalette::WindowText) - << " background=" << palette.color(QPalette::Window); + for (int r = 0; r < QPalette::NColorRoles; ++r) + paletteRoleToString(palette, static_cast(r), str); return result; } @@ -105,9 +120,26 @@ static inline QColor getSysColor(int index) return qColorToCOLORREF(GetSysColor(index)); } +// from QStyle::standardPalette +static inline QPalette standardPalette() +{ + QColor backgroundColor(0xd4, 0xd0, 0xc8); // win 2000 grey + QColor lightColor(backgroundColor.lighter()); + QColor darkColor(backgroundColor.darker()); + const QBrush darkBrush(darkColor); + QColor midColor(Qt::gray); + QPalette palette(Qt::black, backgroundColor, lightColor, darkColor, + midColor, Qt::black, Qt::white); + palette.setBrush(QPalette::Disabled, QPalette::WindowText, darkBrush); + palette.setBrush(QPalette::Disabled, QPalette::Text, darkBrush); + palette.setBrush(QPalette::Disabled, QPalette::ButtonText, darkBrush); + palette.setBrush(QPalette::Disabled, QPalette::Base, QBrush(backgroundColor)); + return palette; +} + static inline QPalette systemPalette() { - QPalette result; + QPalette result = standardPalette(); result.setColor(QPalette::WindowText, getSysColor(COLOR_WINDOWTEXT)); result.setColor(QPalette::Button, getSysColor(COLOR_BTNFACE)); result.setColor(QPalette::Light, getSysColor(COLOR_BTNHIGHLIGHT)); -- cgit v1.2.3 From 246c16e0007473874e0407ca067c0b031c17852f Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 4 Apr 2012 11:55:24 +0200 Subject: Windows: Fix menu color for Windows, WindowsXP. Typo in palette. Change-Id: I8b4c23ef7f75ff3aa3351f15e4af0767a3ccd083 Reviewed-by: Friedemann Kleint --- src/plugins/platforms/windows/qwindowstheme.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/plugins/platforms/windows') diff --git a/src/plugins/platforms/windows/qwindowstheme.cpp b/src/plugins/platforms/windows/qwindowstheme.cpp index 513bebbc8b..000311a807 100644 --- a/src/plugins/platforms/windows/qwindowstheme.cpp +++ b/src/plugins/platforms/windows/qwindowstheme.cpp @@ -215,7 +215,7 @@ static inline QPalette toolTipPalette(const QPalette &systemPalette) static inline QPalette menuPalette(const QPalette &systemPalette) { QPalette result(systemPalette); - const QColor menuColor(getSysColor(COLOR_INFOBK)); + const QColor menuColor(getSysColor(COLOR_MENU)); const QColor menuTextColor(getSysColor(COLOR_MENUTEXT)); const QColor disabled(getSysColor(COLOR_GRAYTEXT)); const bool isFlat = booleanSystemParametersInfo(SPI_GETFLATMENU, false); -- cgit v1.2.3 From 76ae64abb54581a9bae27745d28aaf4dfb23a00c Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 27 Mar 2012 17:05:53 +0200 Subject: Windows: Use native font engine by default. Turn around the meaning of the command line parameter. The FreeType engine can now be activated by passing freetype. Change-Id: I9da6cd4a127603f9cfb91f0ce8450088c0883faa Reviewed-by: Miikka Heikkinen Reviewed-by: Friedemann Kleint --- src/plugins/platforms/windows/qwindowsintegration.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/plugins/platforms/windows') diff --git a/src/plugins/platforms/windows/qwindowsintegration.cpp b/src/plugins/platforms/windows/qwindowsintegration.cpp index fa63d77dd7..47d6a2f11a 100644 --- a/src/plugins/platforms/windows/qwindowsintegration.cpp +++ b/src/plugins/platforms/windows/qwindowsintegration.cpp @@ -283,10 +283,11 @@ QPlatformFontDatabase *QWindowsIntegration::fontDatabase() const { if (!d->m_fontDatabase) { #ifndef QT_NO_FREETYPE - if (d->m_nativeInterface.property("fontengine").toString() == QLatin1String("native")) - d->m_fontDatabase = new QWindowsFontDatabase(); - else + const QVariant argument = d->m_nativeInterface.property("fontengine"); + if (argument.isValid() && argument.toString() == QLatin1String("freetype")) d->m_fontDatabase = new QWindowsFontDatabaseFT(); + else + d->m_fontDatabase = new QWindowsFontDatabase(); #else d->m_fontDatabase = new QWindowsFontDatabase(); #endif -- cgit v1.2.3