From b102dee4faeef5b713cbba4e4775c88f1f8edf75 Mon Sep 17 00:00:00 2001 From: Dominik Holland Date: Thu, 7 Jun 2018 11:32:01 +0200 Subject: Use the iconTheme config options from applicationmanager MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously a ProxyTheme class was used in the neptunestyleplugin, where a path was returned which was hardcoded to the INSTALL_PREFIX. This doesn't work when neptune is run from the build-folder and wasn't installed previously or when installed from the online installer as the theme directory needed to be known at build-time. The new solution is to use the iconThemeName and iconThemeSearchPaths configuration options of application-manager and get rid of the ProxyTheme completely. This also makes sure neptune3 will compile with QQC2 from the dev branch, which doesn't offer the ProxyTheme anymore. Task-number: QTAUTO-1072 Change-Id: I2d9c4f888c6430613d4a56480b37a364517c44e9 Reviewed-by: Lukáš Tinkl Reviewed-by: Bramastyo Harimukti Santoso --- am-config.yaml | 2 + plugins/styles/neptune/neptune.pro | 2 - plugins/styles/neptune/neptunestyle.cpp | 11 +++- plugins/styles/neptune/neptunestyleplugin.cpp | 7 --- plugins/styles/neptune/neptunestyleplugin.h | 2 - plugins/styles/neptune/neptunetheme.cpp | 74 --------------------------- plugins/styles/neptune/neptunetheme.h | 51 ------------------ 7 files changed, 11 insertions(+), 138 deletions(-) delete mode 100644 plugins/styles/neptune/neptunetheme.cpp delete mode 100644 plugins/styles/neptune/neptunetheme.h diff --git a/am-config.yaml b/am-config.yaml index 55e2cb1f..86d101dd 100644 --- a/am-config.yaml +++ b/am-config.yaml @@ -29,6 +29,8 @@ runtimes: ui: fullscreen: no style: "${CONFIG_PWD}/styles/neptune" + iconThemeName: "neptune" + iconThemeSearchPaths: [ "${CONFIG_PWD}/imports/assets/icons" ] mainQml: "${CONFIG_PWD}/Main.qml" importPaths: [ "${CONFIG_PWD}/imports/shared", "${CONFIG_PWD}/imports/system", "${CONFIG_PWD}/sysui" ] windowIcon: "${CONFIG_PWD}/imports/assets/icons/neptune/sysui/ic-menu-home.png" diff --git a/plugins/styles/neptune/neptune.pro b/plugins/styles/neptune/neptune.pro index 373787b5..a0d57dbf 100644 --- a/plugins/styles/neptune/neptune.pro +++ b/plugins/styles/neptune/neptune.pro @@ -12,7 +12,6 @@ DEFINES += "NEPTUNE_ICONS_PATH=$$clean_path($$INSTALL_PREFIX/neptune3/imports/as SOURCES += \ neptunestyle.cpp \ neptunestyleplugin.cpp \ - neptunetheme.cpp \ qquickiconlabel.cpp \ qquickicon.cpp \ qquickdefaultprogressbar.cpp @@ -20,7 +19,6 @@ SOURCES += \ HEADERS += \ neptunestyle.h \ neptunestyleplugin.h \ - neptunetheme.h \ qquickiconlabel_p.h \ qquickiconlabel_p_p.h \ qquickicon_p.h \ diff --git a/plugins/styles/neptune/neptunestyle.cpp b/plugins/styles/neptune/neptunestyle.cpp index 730cb0b9..24906af8 100644 --- a/plugins/styles/neptune/neptunestyle.cpp +++ b/plugins/styles/neptune/neptunestyle.cpp @@ -34,6 +34,7 @@ #include #include #include +#include #include #include @@ -98,11 +99,17 @@ static ThemeData& neptunestyle_theme_data(NeptuneStyle::Theme theme) class StyleData { public: StyleData() - : font(QGuiApplication::font()) - , fontFactor(1.0) + : fontFactor(1.0) , theme(NeptuneStyle::Light) , scale(1.0) { + const QFont sansFont(QLatin1String("Open Sans")); + + if (QFontInfo(sansFont).family() == QLatin1String("Open Sans")) + font.setFamily(font.family()); + + font.setPixelSize(15); + QGuiApplication::setFont(font); compute(); } StyleData(const StyleData &data) diff --git a/plugins/styles/neptune/neptunestyleplugin.cpp b/plugins/styles/neptune/neptunestyleplugin.cpp index 054455ad..1ed8d4cc 100644 --- a/plugins/styles/neptune/neptunestyleplugin.cpp +++ b/plugins/styles/neptune/neptunestyleplugin.cpp @@ -33,7 +33,6 @@ #include #include "neptunestyle.h" -#include "neptunetheme.h" #include "qquickiconlabel_p.h" #include "qquickdefaultprogressbar_p.h" @@ -60,9 +59,3 @@ QString NeptuneStylePlugin::name() const { return QStringLiteral("neptune"); } - -QQuickProxyTheme *NeptuneStylePlugin::createTheme() const -{ - qCDebug(neptuneStyle) << "Created a NeptuneTheme instance"; - return new NeptuneTheme; -} diff --git a/plugins/styles/neptune/neptunestyleplugin.h b/plugins/styles/neptune/neptunestyleplugin.h index 6e4835c5..26a3f3e0 100644 --- a/plugins/styles/neptune/neptunestyleplugin.h +++ b/plugins/styles/neptune/neptunestyleplugin.h @@ -48,8 +48,6 @@ public: void registerTypes(const char *uri) override; void initializeEngine(QQmlEngine *engine, const char *uri) override; QString name() const override; - QQuickProxyTheme *createTheme() const override; - }; #endif // NEPTUNESTYLEPLUGIN_H diff --git a/plugins/styles/neptune/neptunetheme.cpp b/plugins/styles/neptune/neptunetheme.cpp deleted file mode 100644 index 20a256e4..00000000 --- a/plugins/styles/neptune/neptunetheme.cpp +++ /dev/null @@ -1,74 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 Pelagicore AG -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Neptune 3 IVI UI. -** -** $QT_BEGIN_LICENSE:GPL-QTAS$ -** Commercial License Usage -** Licensees holding valid commercial Qt Automotive Suite 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 https://www.qt.io/terms-conditions. -** For further information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -** SPDX-License-Identifier: GPL-3.0 -** -****************************************************************************/ - -#include "neptunetheme.h" - -#include -#include -#include -#include - -// code to transform a macro into a string literal -#define QUOTE(name) #name -#define STR(macro) QUOTE(macro) - -Q_LOGGING_CATEGORY(neptuneTheme, "neptune.theme") - -NeptuneTheme::NeptuneTheme(QPlatformTheme *theme) -{ - Q_UNUSED(theme) - const QFont font(QLatin1String("Open Sans")); - - if (QFontInfo(font).family() == QLatin1String("Open Sans")) { - const QString family = font.family(); - m_systemFont.setFamily(family); - } - - m_systemFont.setPixelSize(15); -} - -const QFont *NeptuneTheme::font(QPlatformTheme::Font type) const -{ - switch (type) { - default: - return &m_systemFont; - } -} - -QVariant NeptuneTheme::themeHint(QPlatformTheme::ThemeHint hint) const -{ - if (hint == SystemIconThemeName || hint == StyleNames) { - return QStringLiteral("neptune"); - } else if (hint == IconThemeSearchPaths) { - return STR(NEPTUNE_ICONS_PATH); - } - return QQuickProxyTheme::themeHint(hint); -} diff --git a/plugins/styles/neptune/neptunetheme.h b/plugins/styles/neptune/neptunetheme.h deleted file mode 100644 index 0890697d..00000000 --- a/plugins/styles/neptune/neptunetheme.h +++ /dev/null @@ -1,51 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 Pelagicore AG -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Neptune 3 IVI UI. -** -** $QT_BEGIN_LICENSE:GPL-QTAS$ -** Commercial License Usage -** Licensees holding valid commercial Qt Automotive Suite 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 https://www.qt.io/terms-conditions. -** For further information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -** SPDX-License-Identifier: GPL-3.0 -** -****************************************************************************/ - -#ifndef NEPTUNETHEME_H -#define NEPTUNETHEME_H - -#include -#include -#include - - -class NeptuneTheme : public QQuickProxyTheme -{ -public: - NeptuneTheme(QPlatformTheme *theme = nullptr); - - const QFont *font(QPlatformTheme::Font type = SystemFont) const override; - QVariant themeHint(QPlatformTheme::ThemeHint hint) const override; -private: - QFont m_systemFont; -}; - -#endif // NEPTUNETHEME_H -- cgit v1.2.3