<commit_before>/*
 *   Copyright 2009 by <NAME> <<EMAIL>>
 *   Copyright 2010 by <NAME> <<EMAIL>>
 *   Copyright 2010 by <NAME> <<EMAIL>>

 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU Library General Public License as
 *   published by the Free Software Foundation; either version 2, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU Library General Public License for more details
 *
 *   You should have received a copy of the GNU Library General Public
 *   License along with this program; if not, write to the
 *   Free Software Foundation, Inc.,
 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */

#include "kirigamiplugin.h"

#include <QQmlEngine>
#include <QQmlContext>
#include <QQuickItem>

QString KirigamiPlugin::componentPath(const QString &fileName) const
{
    QString candidate;
    QString candidatePath;

    foreach (const QString &style, m_stylesFallbackChain) {
        candidate = QStringLiteral("styles/") + style + QLatin1Char('/') + fileName;
        if (QFile::exists(resolveFilePath(candidate))) {
            return resolveFileUrl(candidate);
        }
    }

    return resolveFileUrl(fileName);
}


void KirigamiPlugin::registerTypes(const char *uri)
{
    Q_ASSERT(uri == QLatin1String("org.kde.kirigami"));

    const QString style = QString::fromLatin1(qgetenv("QT_QUICK_CONTROLS_STYLE"));

    if (style.isEmpty() && QFile::exists(resolveFilePath(QStringLiteral("/styles/Desktop")))) {
        m_stylesFallbackChain.prepend(QStringLiteral("Desktop"));
    }

    if (!style.isEmpty() && QFile::exists(resolveFilePath(QStringLiteral("/styles/") + style))) {
        m_stylesFallbackChain.prepend(style);
    }
    //At this point the fallback chain will be selected->Desktop->Fallback


    //TODO: in this plugin it will end up something similar to
    //PlasmaCore's ColorScope?
qWarning()<<"FFF"<<componentPath(QStringLiteral("Theme.qml"));<commit_msg>don't default on desktop on android and ios<commit_after>/*
 *   Copyright 2009 by <NAME> <<EMAIL>>
 *   Copyright 2010 by <NAME> <<EMAIL>>
 *   Copyright 2010 by <NAME> <<EMAIL>>

 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU Library General Public License as
 *   published by the Free Software Foundation; either version 2, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU Library General Public License for more details
 *
 *   You should have received a copy of the GNU Library General Public
 *   License along with this program; if not, write to the
 *   Free Software Foundation, Inc.,
 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */

#include "kirigamiplugin.h"

#include <QQmlEngine>
#include <QQmlContext>
#include <QQuickItem>

QString KirigamiPlugin::componentPath(const QString &fileName) const
{
    QString candidate;
    QString candidatePath;

    foreach (const QString &style, m_stylesFallbackChain) {
        candidate = QStringLiteral("styles/") + style + QLatin1Char('/') + fileName;
        if (QFile::exists(resolveFilePath(candidate))) {
            return resolveFileUrl(candidate);
        }
    }

    return resolveFileUrl(fileName);
}


void KirigamiPlugin::registerTypes(const char *uri)
{
    Q_ASSERT(uri == QLatin1String("org.kde.kirigami"));

    const QString style = QString::fromLatin1(qgetenv("QT_QUICK_CONTROLS_STYLE"));

#if !defined(Q_OS_ANDROID) && !defined(Q_OS_IOS)
    if (style.isEmpty() && QFile::exists(resolveFilePath(QStringLiteral("/styles/Desktop")))) {
        m_stylesFallbackChain.prepend(QStringLiteral("Desktop"));
    }
#endif

    if (!style.isEmpty() && QFile::exists(resolveFilePath(QStringLiteral("/styles/") + style))) {
        m_stylesFallbackChain.prepend(style);
    }
    //At this point the fallback chain will be selected->Desktop->Fallback


    //TODO: in this plugin it will end up something similar to
    //PlasmaCore's ColorScope?

{'fraction_non_alphanumeric': 0.10551504102096627, 'fraction_numerical': 0.012306289881494986, 'mean_word_length': 3.8984375, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3706059', 'n_tokens_mistral': 1308, 'n_tokens_neox': 1244, 'n_words': 417}