From 6e62a72c72abc5ad6e241541208a36378d448853 Mon Sep 17 00:00:00 2001 From: Jens Bache-Wiig Date: Tue, 28 May 2013 10:19:30 +0200 Subject: Improved size calculation of GroupBox This adds some pixel tweaks on mac, adds minimum size to fit the label and fixes dpi scaling on Windows Change-Id: I4c43ba4a7815be87356336a9dafc1a217437940b Reviewed-by: Gabriel de Dietrich --- src/private/qquickcontrolsettings.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/private/qquickcontrolsettings.cpp') diff --git a/src/private/qquickcontrolsettings.cpp b/src/private/qquickcontrolsettings.cpp index 44db49c2..e2daa17f 100644 --- a/src/private/qquickcontrolsettings.cpp +++ b/src/private/qquickcontrolsettings.cpp @@ -133,4 +133,15 @@ QString QQuickControlSettings::styleFilePath() const return m_path + QLatin1Char('/') + m_name; } +extern Q_GUI_EXPORT int qt_defaultDpiX(); + +qreal QQuickControlSettings::dpiScaleFactor() const +{ +#ifndef Q_OS_MAC + return (qreal(qt_defaultDpiX()) / 96.0); +#endif + return 1.0; +} + + QT_END_NAMESPACE -- cgit v1.2.1 From 41e13d3746c8b7b5cd550091c63fd8ab066422cf Mon Sep 17 00:00:00 2001 From: Caroline Chao Date: Tue, 11 Jun 2013 09:13:44 +0200 Subject: Add qml/js files in resource files To make deployment of Qt Quick Controls based applications easier. Task-number: QTBUG-31565 Change-Id: I0b8af2864ef0dc9121eed3189ced64712bdb3d20 Reviewed-by: Friedemann Kleint Reviewed-by: Jens Bache-Wiig --- src/private/qquickcontrolsettings.cpp | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'src/private/qquickcontrolsettings.cpp') diff --git a/src/private/qquickcontrolsettings.cpp b/src/private/qquickcontrolsettings.cpp index e2daa17f..d2853982 100644 --- a/src/private/qquickcontrolsettings.cpp +++ b/src/private/qquickcontrolsettings.cpp @@ -63,18 +63,24 @@ static QString styleImportName() return QFileInfo(name).fileName(); } -static QString styleImportPath(QQmlEngine *engine, const QString &styleName) +static QString styleImportPath(QQmlEngine *engine, const QString &styleName, bool &fromResources) { QString path = qgetenv("QT_QUICK_CONTROLS_STYLE"); QFileInfo info(path); if (info.isRelative()) { + bool found = false; foreach (const QString &import, engine->importPathList()) { QDir dir(import + QLatin1String("/QtQuick/Controls/Styles")); if (dir.exists(styleName)) { + found = true; path = dir.absolutePath(); break; } } + if (!found) { + fromResources = true; + path = "qrc:"; + } } else { path = info.absolutePath(); } @@ -83,23 +89,27 @@ static QString styleImportPath(QQmlEngine *engine, const QString &styleName) QQuickControlSettings::QQuickControlSettings(QQmlEngine *engine) { + m_fromResources = false; m_name = styleImportName(); - m_path = styleImportPath(engine, m_name); + m_path = styleImportPath(engine, m_name, m_fromResources); - if (!QFile::exists(styleFilePath())) { + if (!m_fromResources && !QFile::exists(styleFilePath())) { QString unknownStyle = m_name; m_name = defaultStyleName(); - m_path = styleImportPath(engine, m_name); - qWarning() << "WARNING: Cannot find style" << unknownStyle << "- fallback:" << styleFilePath(); + m_path = styleImportPath(engine, m_name, m_fromResources); + qWarning() << "WARNING: Cannot find style" << unknownStyle << " locally - fallback:" << styleFilePath(); } connect(this, SIGNAL(styleNameChanged()), SIGNAL(styleChanged())); connect(this, SIGNAL(stylePathChanged()), SIGNAL(styleChanged())); } -QUrl QQuickControlSettings::style() const +QString QQuickControlSettings::style() const { - return QUrl::fromLocalFile(styleFilePath()); + if (m_fromResources) + return styleFilePath(); + else + return QUrl::fromLocalFile(styleFilePath()).toString(); } QString QQuickControlSettings::styleName() const -- cgit v1.2.1 From 03c7e64ef5f3dfd10d61fd2473fb9f09b124c6e6 Mon Sep 17 00:00:00 2001 From: Caroline Chao Date: Fri, 14 Jun 2013 15:01:34 +0200 Subject: Revert "Add qml/js files in resource files" We need to investigate more this solution. Deployment issue for Qt Quick Controls will be a known limitation in 5.1.0. This reverts commit 41e13d3746c8b7b5cd550091c63fd8ab066422cf. Change-Id: I501be7494bdbdfbb799d31c612d0c20e7f87ffc7 Reviewed-by: Friedemann Kleint Reviewed-by: Jens Bache-Wiig Reviewed-by: Liang Qi --- src/private/qquickcontrolsettings.cpp | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) (limited to 'src/private/qquickcontrolsettings.cpp') diff --git a/src/private/qquickcontrolsettings.cpp b/src/private/qquickcontrolsettings.cpp index d2853982..e2daa17f 100644 --- a/src/private/qquickcontrolsettings.cpp +++ b/src/private/qquickcontrolsettings.cpp @@ -63,24 +63,18 @@ static QString styleImportName() return QFileInfo(name).fileName(); } -static QString styleImportPath(QQmlEngine *engine, const QString &styleName, bool &fromResources) +static QString styleImportPath(QQmlEngine *engine, const QString &styleName) { QString path = qgetenv("QT_QUICK_CONTROLS_STYLE"); QFileInfo info(path); if (info.isRelative()) { - bool found = false; foreach (const QString &import, engine->importPathList()) { QDir dir(import + QLatin1String("/QtQuick/Controls/Styles")); if (dir.exists(styleName)) { - found = true; path = dir.absolutePath(); break; } } - if (!found) { - fromResources = true; - path = "qrc:"; - } } else { path = info.absolutePath(); } @@ -89,27 +83,23 @@ static QString styleImportPath(QQmlEngine *engine, const QString &styleName, boo QQuickControlSettings::QQuickControlSettings(QQmlEngine *engine) { - m_fromResources = false; m_name = styleImportName(); - m_path = styleImportPath(engine, m_name, m_fromResources); + m_path = styleImportPath(engine, m_name); - if (!m_fromResources && !QFile::exists(styleFilePath())) { + if (!QFile::exists(styleFilePath())) { QString unknownStyle = m_name; m_name = defaultStyleName(); - m_path = styleImportPath(engine, m_name, m_fromResources); - qWarning() << "WARNING: Cannot find style" << unknownStyle << " locally - fallback:" << styleFilePath(); + m_path = styleImportPath(engine, m_name); + qWarning() << "WARNING: Cannot find style" << unknownStyle << "- fallback:" << styleFilePath(); } connect(this, SIGNAL(styleNameChanged()), SIGNAL(styleChanged())); connect(this, SIGNAL(stylePathChanged()), SIGNAL(styleChanged())); } -QString QQuickControlSettings::style() const +QUrl QQuickControlSettings::style() const { - if (m_fromResources) - return styleFilePath(); - else - return QUrl::fromLocalFile(styleFilePath()).toString(); + return QUrl::fromLocalFile(styleFilePath()); } QString QQuickControlSettings::styleName() const -- cgit v1.2.1