aboutsummaryrefslogtreecommitdiffstats
path: root/src/imports/controls
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@theqtcompany.com>2015-11-26 14:00:17 +0100
committerJ-P Nurmi <jpnurmi@theqtcompany.com>2015-11-26 17:28:22 +0000
commit3208d08f6210c68ad8c48f2e3515ac1a7672a48b (patch)
treed6d7a87aeb07277910f0f39aa5929ca0f44e1d35 /src/imports/controls
parentf556f3ea80ebc41cb6a49560e83965c8889b8974 (diff)
Rename QQuickFileSelector to QQuickStyleSelector
Also moved to QtLabsControls lib. Change-Id: I8ed1256da2b9aa63db4ca3b51a0ace3ba730e542 Reviewed-by: J-P Nurmi <jpnurmi@theqtcompany.com>
Diffstat (limited to 'src/imports/controls')
-rw-r--r--src/imports/controls/controls.pri3
-rw-r--r--src/imports/controls/controls.pro2
-rw-r--r--src/imports/controls/qquickfileselector.cpp234
-rw-r--r--src/imports/controls/qquickfileselector_p.h79
-rw-r--r--src/imports/controls/qquickfileselector_p_p.h79
-rw-r--r--src/imports/controls/qtlabscontrolsplugin.cpp4
6 files changed, 3 insertions, 398 deletions
diff --git a/src/imports/controls/controls.pri b/src/imports/controls/controls.pri
index 530ca6f4..fa493508 100644
--- a/src/imports/controls/controls.pri
+++ b/src/imports/controls/controls.pri
@@ -29,12 +29,9 @@ QML_FILES = \
Tumbler.qml
HEADERS += \
- $$PWD/qquickfileselector_p.h \
- $$PWD/qquickfileselector_p_p.h \
$$PWD/qquickthemedata_p.h \
$$PWD/qquicktheme_p.h
SOURCES += \
- $$PWD/qquickfileselector.cpp \
$$PWD/qquicktheme.cpp \
$$PWD/qquickthemedata.cpp
diff --git a/src/imports/controls/controls.pro b/src/imports/controls/controls.pro
index 5057675f..786a5724 100644
--- a/src/imports/controls/controls.pro
+++ b/src/imports/controls/controls.pro
@@ -3,7 +3,7 @@ TARGETPATH = Qt/labs/controls
IMPORT_VERSION = 1.0
QT += qml quick
-QT_PRIVATE += core-private gui-private qml-private quick-private labstemplates-private
+QT_PRIVATE += core-private gui-private qml-private quick-private labstemplates-private labscontrols-private
DEFINES += QT_NO_CAST_TO_ASCII QT_NO_CAST_FROM_ASCII
diff --git a/src/imports/controls/qquickfileselector.cpp b/src/imports/controls/qquickfileselector.cpp
deleted file mode 100644
index bc09df9f..00000000
--- a/src/imports/controls/qquickfileselector.cpp
+++ /dev/null
@@ -1,234 +0,0 @@
-/***************************************************************************
-**
-** Copyright (C) 2013 BlackBerry Limited. All rights reserved.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the Qt Labs Controls module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL21$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** As a special exception, The Qt Company gives you certain additional
-** rights. These rights are described in The Qt Company LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qquickfileselector_p.h"
-#include "qquickfileselector_p_p.h"
-
-#include <QtCore/QFile>
-#include <QtCore/QDir>
-#include <QtCore/QMutex>
-#include <QtCore/QMutexLocker>
-#include <QtCore/QUrl>
-#include <QtCore/QFileInfo>
-#include <QtCore/QLocale>
-#include <QtCore/QDebug>
-
-QT_BEGIN_NAMESPACE
-
-//Environment variable to allow tooling full control of file selectors
-static const char env_override[] = "QT_LABS_CONTROLS_NO_STYLE";
-
-Q_GLOBAL_STATIC(QQuickFileSelectorSharedData, sharedData);
-static QBasicMutex sharedDataMutex;
-
-QQuickFileSelectorPrivate::QQuickFileSelectorPrivate()
- : QObjectPrivate()
-{
-}
-
-QQuickFileSelector::QQuickFileSelector(QObject *parent)
- : QObject(*(new QQuickFileSelectorPrivate()), parent)
-{
-}
-
-QQuickFileSelector::~QQuickFileSelector()
-{
-}
-
-QString QQuickFileSelector::select(const QString &filePath) const
-{
- Q_D(const QQuickFileSelector);
- return select(QUrl(d->baseUrl.toString() + filePath)).toString();
-}
-
-static bool isLocalScheme(const QString &file)
-{
- bool local = file == QStringLiteral("qrc");
-#ifdef Q_OS_ANDROID
- local |= file == QStringLiteral("assets");
-#endif
- return local;
-}
-
-QUrl QQuickFileSelector::select(const QUrl &filePath) const
-{
- Q_D(const QQuickFileSelector);
- if (!isLocalScheme(filePath.scheme()) && !filePath.isLocalFile())
- return filePath;
- QUrl ret(filePath);
- if (isLocalScheme(filePath.scheme())) {
- QString equivalentPath = QLatin1Char(':') + filePath.path();
- QString selectedPath = d->select(equivalentPath);
- ret.setPath(selectedPath.remove(0, 1));
- } else {
- ret = QUrl::fromLocalFile(d->select(ret.toLocalFile()));
- }
- return ret;
-}
-
-static QString selectionHelper(const QString &path, const QString &fileName, const QStringList &selectors)
-{
- /* selectionHelper does a depth-first search of possible selected files. Because there is strict
- selector ordering in the API, we can stop checking as soon as we find the file in a directory
- which does not contain any other valid selector directories.
- */
- Q_ASSERT(path.isEmpty() || path.endsWith(QLatin1Char('/')));
-
- foreach (const QString &s, selectors) {
- QString prospectiveBase = path + s + QLatin1Char('/');
- QStringList remainingSelectors = selectors;
- remainingSelectors.removeAll(s);
- if (!QDir(prospectiveBase).exists())
- continue;
- QString prospectiveFile = selectionHelper(prospectiveBase, fileName, remainingSelectors);
- if (!prospectiveFile.isEmpty())
- return prospectiveFile;
- }
-
- // If we reach here there were no successful files found at a lower level in this branch, so we
- // should check this level as a potential result.
- if (!QFile::exists(path + fileName))
- return QString();
- return path + fileName;
-}
-
-QString QQuickFileSelectorPrivate::select(const QString &filePath) const
-{
- Q_Q(const QQuickFileSelector);
- QFileInfo fi(filePath);
- // If file doesn't exist, don't select
- if (!fi.exists())
- return filePath;
-
- QString ret = selectionHelper(fi.path().isEmpty() ? QString() : fi.path() + QLatin1Char('/'),
- fi.fileName(), q->allSelectors());
-
- if (!ret.isEmpty())
- return ret;
- return filePath;
-}
-
-QString QQuickFileSelector::style() const
-{
- Q_D(const QQuickFileSelector);
- return d->style;
-}
-
-void QQuickFileSelector::setStyle(const QString &s)
-{
- Q_D(QQuickFileSelector);
- d->style = s;
-}
-
-QStringList QQuickFileSelector::allSelectors() const
-{
- Q_D(const QQuickFileSelector);
- QMutexLocker locker(&sharedDataMutex);
- QQuickFileSelectorPrivate::updateSelectors();
- return QStringList(d->style) + sharedData->staticSelectors;
-}
-
-void QQuickFileSelector::setBaseUrl(const QUrl &base)
-{
- Q_D(QQuickFileSelector);
- if (d->baseUrl != base)
- d->baseUrl = base;
-}
-
-QUrl QQuickFileSelector::baseUrl() const
-{
- Q_D(const QQuickFileSelector);
- return d->baseUrl;
-}
-
-void QQuickFileSelectorPrivate::updateSelectors()
-{
- if (!sharedData->staticSelectors.isEmpty())
- return; //Already loaded
-
- QLatin1Char pathSep(',');
- QStringList envSelectors = QString::fromLatin1(qgetenv("QT_LABS_CONTROLS_STYLE"))
- .split(pathSep, QString::SkipEmptyParts);
- if (envSelectors.count())
- sharedData->staticSelectors << envSelectors;
-
- if (!qEnvironmentVariableIsEmpty(env_override))
- return;
-
- sharedData->staticSelectors << sharedData->preloadedStatics; //Potential for static selectors from other modules
-
- // TODO: Update on locale changed?
- sharedData->staticSelectors << QLocale().name();
-
- sharedData->staticSelectors << platformSelectors();
-}
-
-QStringList QQuickFileSelectorPrivate::platformSelectors()
-{
- // similar, but not identical to QSysInfo::osType
- QStringList ret;
-#if defined(Q_OS_WIN)
- // can't fall back to QSysInfo because we need both "winphone" and "winrt" for the Windows Phone case
- ret << QStringLiteral("windows");
- ret << QSysInfo::kernelType(); // "wince" and "winnt"
-# if defined(Q_OS_WINRT)
- ret << QStringLiteral("winrt");
-# if defined(Q_OS_WINPHONE)
- ret << QStringLiteral("winphone");
-# endif
-# endif
-#elif defined(Q_OS_UNIX)
- ret << QStringLiteral("unix");
-# if !defined(Q_OS_ANDROID) && !defined(Q_OS_BLACKBERRY)
- // we don't want "linux" for Android or "qnx" for Blackberry here
- ret << QSysInfo::kernelType();
-# ifdef Q_OS_MAC
- ret << QStringLiteral("mac"); // compatibility, since kernelType() is "darwin"
-# endif
-# endif
- QString productName = QSysInfo::productType();
- if (productName != QLatin1String("unknown"))
- ret << productName; // "opensuse", "fedora", "osx", "ios", "blackberry", "android"
-#endif
- return ret;
-}
-
-void QQuickFileSelectorPrivate::addStatics(const QStringList &statics)
-{
- QMutexLocker locker(&sharedDataMutex);
- sharedData->preloadedStatics << statics;
-}
-
-QT_END_NAMESPACE
-
-#include "moc_qquickfileselector_p.cpp"
diff --git a/src/imports/controls/qquickfileselector_p.h b/src/imports/controls/qquickfileselector_p.h
deleted file mode 100644
index ed1cd7d5..00000000
--- a/src/imports/controls/qquickfileselector_p.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/***************************************************************************
-**
-** Copyright (C) 2013 BlackBerry Limited. All rights reserved.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the Qt Labs Controls module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL21$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** As a special exception, The Qt Company gives you certain additional
-** rights. These rights are described in The Qt Company LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QFILESELECTOR_H
-#define QFILESELECTOR_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QtCore/QObject>
-#include <QtCore/QStringList>
-
-QT_BEGIN_NAMESPACE
-
-class QQuickFileSelectorPrivate;
-class QQuickFileSelector : public QObject
-{
- Q_OBJECT
-public:
- explicit QQuickFileSelector(QObject *parent = Q_NULLPTR);
- ~QQuickFileSelector();
-
- QString select(const QString &filePath) const;
-
- QString style() const;
- void setStyle(const QString &s);
-
- QStringList allSelectors() const;
-
- void setBaseUrl(const QUrl &base);
- QUrl baseUrl() const;
-
-private:
- QUrl select(const QUrl &filePath) const;
-
- Q_DECLARE_PRIVATE(QQuickFileSelector)
-};
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/imports/controls/qquickfileselector_p_p.h b/src/imports/controls/qquickfileselector_p_p.h
deleted file mode 100644
index eb849554..00000000
--- a/src/imports/controls/qquickfileselector_p_p.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/***************************************************************************
-**
-** Copyright (C) 2013 BlackBerry Limited. All rights reserved.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the Qt Labs Controls module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL21$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** As a special exception, The Qt Company gives you certain additional
-** rights. These rights are described in The Qt Company LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QFILESELECTOR_P_H
-#define QFILESELECTOR_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QtCore/QString>
-#include <QtCore/QUrl>
-#include <private/qobject_p.h>
-
-#include "qquickfileselector_p.h"
-
-QT_BEGIN_NAMESPACE
-
-struct QQuickFileSelectorSharedData //Not QSharedData because currently is just a global store
-{
- QStringList staticSelectors;
- QStringList preloadedStatics;
-};
-
-class QQuickFileSelectorPrivate : QObjectPrivate //Exported for use in other modules (like QtGui)
-{
- Q_DECLARE_PUBLIC(QQuickFileSelector)
-public:
- static void updateSelectors();
- static QStringList platformSelectors();
- static void addStatics(const QStringList &); //For loading GUI statics from other Qt modules
- QQuickFileSelectorPrivate();
- QString select(const QString &filePath) const;
-
- QString style;
- QUrl baseUrl;
-};
-
-QT_END_NAMESPACE
-
-#endif
-
diff --git a/src/imports/controls/qtlabscontrolsplugin.cpp b/src/imports/controls/qtlabscontrolsplugin.cpp
index 20f1750e..8c65abc5 100644
--- a/src/imports/controls/qtlabscontrolsplugin.cpp
+++ b/src/imports/controls/qtlabscontrolsplugin.cpp
@@ -40,9 +40,9 @@
#include <QtGui/private/qguiapplication_p.h>
#include <QtLabsTemplates/private/qquickbuttongroup_p.h>
+#include <QtLabsControls/private/qquickstyleselector_p.h>
#include "qquicktheme_p.h"
-#include "qquickfileselector_p.h"
void initResources()
{
@@ -71,7 +71,7 @@ void QtLabsControlsPlugin::registerTypes(const char *uri)
QString styleOverride = QGuiApplicationPrivate::styleOverride;
// TODO: read the style from application manifest file
- QQuickFileSelector selector;
+ QQuickStyleSelector selector;
selector.setBaseUrl(baseUrl());
if (!styleOverride.isEmpty())