From 2ad9e69a9f9231b5f65a53036ae60bb0abc93609 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Tue, 5 Aug 2014 12:58:47 +0200 Subject: GTK file dialog: pre-fill the filename if given to a Save dialog The docs for gtk_file_chooser_set_filename explain that if a file is new, we should call gtk_file_chooser_set_current_name instead. (But in that case it is necessary to set the directory separately.) Qt doesn't make a distinction between a save dialog for saving a new file vs. a dialog for re-saving an existing file, so it seems this is the better way to do it all the time, since a save dialog would most often be used for saving a new file. Task-number: QTBUG-40573 Change-Id: I285e898fafc54ae39f09d564ca431a279a8f8919 Reviewed-by: J-P Nurmi --- src/plugins/platformthemes/gtk2/qgtk2dialoghelpers.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/plugins') diff --git a/src/plugins/platformthemes/gtk2/qgtk2dialoghelpers.cpp b/src/plugins/platformthemes/gtk2/qgtk2dialoghelpers.cpp index f85fe0839f..506c29c9cf 100644 --- a/src/plugins/platformthemes/gtk2/qgtk2dialoghelpers.cpp +++ b/src/plugins/platformthemes/gtk2/qgtk2dialoghelpers.cpp @@ -308,7 +308,13 @@ QUrl QGtk2FileDialogHelper::directory() const void QGtk2FileDialogHelper::selectFile(const QUrl &filename) { GtkDialog *gtkDialog = d->gtkDialog(); - gtk_file_chooser_select_filename(GTK_FILE_CHOOSER(gtkDialog), filename.toLocalFile().toUtf8()); + if (options()->acceptMode() == QFileDialogOptions::AcceptSave) { + QFileInfo fi(filename.toLocalFile()); + gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(gtkDialog), fi.path().toUtf8()); + gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(gtkDialog), fi.fileName().toUtf8()); + } else { + gtk_file_chooser_select_filename(GTK_FILE_CHOOSER(gtkDialog), filename.toLocalFile().toUtf8()); + } } QList QGtk2FileDialogHelper::selectedFiles() const -- cgit v1.2.3 From 4946ed049608251cf750a6250b4c94cda1c2e707 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Str=C3=B8mme?= Date: Tue, 5 Aug 2014 19:37:47 +0200 Subject: Android: Fix QAndroidPlatformServices::openUrl(). Return true only if an activity was found for the intent. Task-number: QTBUG-34716 Change-Id: I764caf1e8afa3b17b2d71f52873c17e5d834a956 Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/plugins/platforms/android/qandroidplatformservices.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/android/qandroidplatformservices.cpp b/src/plugins/platforms/android/qandroidplatformservices.cpp index 9c21abe39b..1f2f58f838 100644 --- a/src/plugins/platforms/android/qandroidplatformservices.cpp +++ b/src/plugins/platforms/android/qandroidplatformservices.cpp @@ -54,11 +54,10 @@ QAndroidPlatformServices::QAndroidPlatformServices() bool QAndroidPlatformServices::openUrl(const QUrl &url) { QJNIObjectPrivate urlString = QJNIObjectPrivate::fromString(url.toString()); - QJNIObjectPrivate::callStaticMethod(QtAndroid::applicationClass(), - "openURL", - "(Ljava/lang/String;)V", - urlString.object()); - return true; + return QJNIObjectPrivate::callStaticMethod(QtAndroid::applicationClass(), + "openURL", + "(Ljava/lang/String;)Z", + urlString.object()); } bool QAndroidPlatformServices::openDocument(const QUrl &url) -- cgit v1.2.3 From 1671dacb521e92986ff2d274d009e3e60a026045 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Str=C3=B8mme?= Date: Tue, 5 Aug 2014 19:43:23 +0200 Subject: Android: Remove native views when their window is destroyd. destroySurface() was not removing the native view as they are not in the m_surfaces map. Task-number: QTBUG-40159 Change-Id: Ib5457e0bd34141654fa47883f5e125d894b0bd05 Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/plugins/platforms/android/androidjnimain.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/android/androidjnimain.cpp b/src/plugins/platforms/android/androidjnimain.cpp index 3e3e169df9..e7e0375adf 100644 --- a/src/plugins/platforms/android/androidjnimain.cpp +++ b/src/plugins/platforms/android/androidjnimain.cpp @@ -413,10 +413,9 @@ namespace QtAndroid { QMutexLocker lock(&m_surfacesMutex); const auto &it = m_surfaces.find(surfaceId); - if (it == m_surfaces.end()) - return; + if (it != m_surfaces.end()) + m_surfaces.remove(surfaceId); - m_surfaces.remove(surfaceId); QJNIEnvironmentPrivate env; if (!env) return; -- cgit v1.2.3 From 8306dee38f4e315399a465b028819b0777746c55 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Wed, 6 Aug 2014 13:40:46 +0200 Subject: Windows: Fix stored family name of fallback fonts When we create fallback fonts, we copy the fontdef of the main font, but we need to update the family name to match reality, otherwise a QRawFont created with the font engine will have the wrong family name. This is already done in the default implementation of loadEngine(), but was missing from the Windows implementation. One large consequence of this was that when the distance field renderer cloned the font engine (to change its size), it would clone it with the wrong family name. When it later painted its glyph indexes, they would of course refer to the wrong font (the fallback) so random characters would appear. [ChangeLog][Windows] Fixed using QRawFont with fallback fonts, e.g. in the case of text rendering in Qt Quick. Task-number: QTBUG-39172 Change-Id: Ic8fcd9dfc20ec7aadf0b47d4a80417f401f355fd Reviewed-by: Konstantin Ritt --- src/plugins/platforms/windows/qwindowsfontengine.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/plugins') diff --git a/src/plugins/platforms/windows/qwindowsfontengine.cpp b/src/plugins/platforms/windows/qwindowsfontengine.cpp index 6f97c8584b..4efedb7bc7 100644 --- a/src/plugins/platforms/windows/qwindowsfontengine.cpp +++ b/src/plugins/platforms/windows/qwindowsfontengine.cpp @@ -1350,6 +1350,7 @@ void QWindowsMultiFontEngine::loadEngine(int at) fontEngine->fontDef.pixelSize, data); fedw->fontDef = fontDef; + fedw->fontDef.family = fam; fedw->ref.ref(); engines[at] = fedw; @@ -1375,6 +1376,7 @@ void QWindowsMultiFontEngine::loadEngine(int at) engines[at] = new QWindowsFontEngine(fam, hfont, stockFont, lf, data); engines[at]->ref.ref(); engines[at]->fontDef = fontDef; + engines[at]->fontDef.family = fam; qCDebug(lcQpaFonts) << __FUNCTION__ << at << fam; // TODO: increase cost in QFontCache for the font engine loaded here -- cgit v1.2.3 From 909d3f5c733dde02074a737a5f1dbe3e51dbef32 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Wed, 2 Jul 2014 13:18:50 +0200 Subject: Font Database: Add support for private, system UI font families MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We introduce QPlatformFontDatabase::isPrivateFontFamily() to allow testing for private, system UI font families. Both QFontComboBox and QFontDialog need to filter out those private font families which, by definition, should be hidden from the end user. (The textedit example had to be updated to fix the issue where the default font would be private. In 5.4, we will be adding an equivalent, public API in QFontDatabase, and a better solution for the textedit example and QTexEdit in general). In particular, on OS X and iOS, private fonts are used for the system UI font. Those have their font family name prefixed by a dot. QCoreTextFontDatabase knows about this, and makes sure those are tested positive as private font families. In order to have a cleaner layer separation, we moved the QPA theme font resolution from the platform theme classes into QCoreTextFontDatabase for both Cocoa and iOS QPA plugins. In both cases, we use CoreText's CTFontCreateUIFontForLanguage(), that nicely maps to the HITheme API we were using so far on Mac. That means one HITheme dependency less. We also cache the font descriptors we get for these font for each time QCTFD::populateFamilies() gets called. (While not common, this currently happens in auto-tests, like tst_QFontDatabase, and could happen in actual applications -- specially when adding and removing application fonts.) Change-Id: Ic6f0b60f9f597afee1a43596a669742dc546b97f Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/cocoa/qcocoasystemsettings.h | 1 - .../platforms/cocoa/qcocoasystemsettings.mm | 44 ---------------------- src/plugins/platforms/cocoa/qcocoatheme.mm | 7 ++++ src/plugins/platforms/ios/qiostheme.mm | 19 +++------- 4 files changed, 13 insertions(+), 58 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/cocoa/qcocoasystemsettings.h b/src/plugins/platforms/cocoa/qcocoasystemsettings.h index 9ce301f7e7..3861da6230 100644 --- a/src/plugins/platforms/cocoa/qcocoasystemsettings.h +++ b/src/plugins/platforms/cocoa/qcocoasystemsettings.h @@ -50,7 +50,6 @@ QT_BEGIN_NAMESPACE QPalette * qt_mac_createSystemPalette(); QHash qt_mac_createRolePalettes(); -QHash qt_mac_createRoleFonts(); QT_END_NAMESPACE diff --git a/src/plugins/platforms/cocoa/qcocoasystemsettings.mm b/src/plugins/platforms/cocoa/qcocoasystemsettings.mm index f18be8b69c..67fa66ad63 100644 --- a/src/plugins/platforms/cocoa/qcocoasystemsettings.mm +++ b/src/plugins/platforms/cocoa/qcocoasystemsettings.mm @@ -230,48 +230,4 @@ QHash qt_mac_createRolePalettes() return palettes; } -QFont *qt_mac_qfontForThemeFont(ThemeFontID themeID) -{ - CTFontUIFontType ctID = HIThemeGetUIFontType(themeID); - QCFType ctfont = CTFontCreateUIFontForLanguage(ctID, 0, 0); - QString familyName = QCFString(CTFontCopyFamilyName(ctfont)); - QCFType dict = CTFontCopyTraits(ctfont); - CFNumberRef num = static_cast(CFDictionaryGetValue(dict, kCTFontWeightTrait)); - float fW; - CFNumberGetValue(num, kCFNumberFloat32Type, &fW); - QFont::Weight wght = fW > 0. ? QFont::Bold : QFont::Normal; - num = static_cast(CFDictionaryGetValue(dict, kCTFontSlantTrait)); - CFNumberGetValue(num, kCFNumberFloatType, &fW); - bool italic = (fW != 0.0); - return new QFont(familyName, CTFontGetSize(ctfont), wght, italic); -} - -QHash qt_mac_createRoleFonts() -{ - QHash fonts; - - fonts.insert(QPlatformTheme::SystemFont, qt_mac_qfontForThemeFont(kThemeApplicationFont)); - fonts.insert(QPlatformTheme::PushButtonFont, qt_mac_qfontForThemeFont(kThemePushButtonFont)); - fonts.insert(QPlatformTheme::ListViewFont, qt_mac_qfontForThemeFont(kThemeViewsFont)); - fonts.insert(QPlatformTheme::ListBoxFont, qt_mac_qfontForThemeFont(kThemeViewsFont)); - fonts.insert(QPlatformTheme::TitleBarFont, qt_mac_qfontForThemeFont(kThemeWindowTitleFont)); - fonts.insert(QPlatformTheme::MenuFont, qt_mac_qfontForThemeFont(kThemeMenuItemFont)); - fonts.insert(QPlatformTheme::MenuBarFont, qt_mac_qfontForThemeFont(kThemeMenuItemFont)); - fonts.insert(QPlatformTheme::ComboMenuItemFont, qt_mac_qfontForThemeFont(kThemeSystemFont)); - fonts.insert(QPlatformTheme::HeaderViewFont, qt_mac_qfontForThemeFont(kThemeSmallSystemFont)); - fonts.insert(QPlatformTheme::TipLabelFont, qt_mac_qfontForThemeFont(kThemeSmallSystemFont)); - fonts.insert(QPlatformTheme::LabelFont, qt_mac_qfontForThemeFont(kThemeSystemFont)); - fonts.insert(QPlatformTheme::ToolButtonFont, qt_mac_qfontForThemeFont(kThemeSmallSystemFont)); - fonts.insert(QPlatformTheme::MenuItemFont, qt_mac_qfontForThemeFont(kThemeMenuItemFont)); - fonts.insert(QPlatformTheme::ComboLineEditFont, qt_mac_qfontForThemeFont(kThemeViewsFont)); - fonts.insert(QPlatformTheme::SmallFont, qt_mac_qfontForThemeFont(kThemeSmallSystemFont)); - fonts.insert(QPlatformTheme::MiniFont, qt_mac_qfontForThemeFont(kThemeMiniSystemFont)); - - QFont* fixedFont = new QFont(QStringLiteral("Monaco"), fonts[QPlatformTheme::SystemFont]->pointSize()); - fixedFont->setStyleHint(QFont::TypeWriter); - fonts.insert(QPlatformTheme::FixedFont, fixedFont); - - return fonts; -} - QT_END_NAMESPACE diff --git a/src/plugins/platforms/cocoa/qcocoatheme.mm b/src/plugins/platforms/cocoa/qcocoatheme.mm index dce1671800..ae42fee82c 100644 --- a/src/plugins/platforms/cocoa/qcocoatheme.mm +++ b/src/plugins/platforms/cocoa/qcocoatheme.mm @@ -60,6 +60,7 @@ #include #include #include +#include #include #include @@ -134,6 +135,12 @@ const QPalette *QCocoaTheme::palette(Palette type) const return 0; } +QHash qt_mac_createRoleFonts() +{ + QCoreTextFontDatabase *ctfd = static_cast(QGuiApplicationPrivate::platformIntegration()->fontDatabase()); + return ctfd->themeFonts(); +} + const QFont *QCocoaTheme::font(Font type) const { if (m_fonts.isEmpty()) { diff --git a/src/plugins/platforms/ios/qiostheme.mm b/src/plugins/platforms/ios/qiostheme.mm index e7093185aa..e51e97bd5a 100644 --- a/src/plugins/platforms/ios/qiostheme.mm +++ b/src/plugins/platforms/ios/qiostheme.mm @@ -46,6 +46,10 @@ #include +#include +#include +#include + #include #include @@ -75,19 +79,8 @@ QVariant QIOSTheme::themeHint(ThemeHint hint) const const QFont *QIOSTheme::font(Font type) const { if (m_fonts.isEmpty()) { - // The real system font on iOS is '.Helvetica Neue UI', as returned by both [UIFont systemFontOfSize] - // and CTFontCreateUIFontForLanguage(kCTFontSystemFontType, ...), but this font is not included when - // populating the available fonts in QCoreTextFontDatabase::populateFontDatabase(), since the font - // is internal to iOS and not supposed to be used by applications. We could potentially add this - // font to the font-database, but it would then show up when enumerating user fonts from Qt - // applications since we don't have a flag in Qt to mark a font as a private system font. - // For now we hard-code the font to Helvetica, which should be very close to the actual - // system font. - QLatin1String systemFontFamilyName("Helvetica"); - m_fonts.insert(QPlatformTheme::SystemFont, new QFont(systemFontFamilyName, [UIFont systemFontSize])); - m_fonts.insert(QPlatformTheme::SmallFont, new QFont(systemFontFamilyName, [UIFont smallSystemFontSize])); - m_fonts.insert(QPlatformTheme::LabelFont, new QFont(systemFontFamilyName, [UIFont labelFontSize])); - m_fonts.insert(QPlatformTheme::PushButtonFont, new QFont(systemFontFamilyName, [UIFont buttonFontSize])); + QCoreTextFontDatabase *ctfd = static_cast(QGuiApplicationPrivate::platformIntegration()->fontDatabase()); + m_fonts = ctfd->themeFonts(); } return m_fonts.value(type, 0); -- cgit v1.2.3