explicit NoPrefixes()
     : KPackage::Package(new KPackage::PackageStructure)
 {
     setContentsPrefixPaths(QStringList());
     addDirectoryDefinition("bin", QStringLiteral("bin"), QStringLiteral("bin"));
     addFileDefinition("MultiplePaths", QStringLiteral("first"), QStringLiteral("Description proper"));
     addFileDefinition("MultiplePaths", QStringLiteral("second"), QStringLiteral("Description proper"));
     setPath(QStringLiteral("/"));
 }
void WebAppletPackage::pathChanged()
{
    KDesktopFile config(path() + "/metadata.desktop");
    KConfigGroup cg = config.desktopGroup();
    QString mainScript = cg.readEntry("X-Plasma-MainScript", QString());
    if (!mainScript.isEmpty()) {
        addFileDefinition("mainscript", mainScript, i18n("Main Script File"));
        setRequired("mainscript", true);
    }
}
WebAppletPackage::WebAppletPackage(QObject *parent, QVariantList args)
    : Plasma::PackageStructure(parent, "Web")
{
    Q_UNUSED(args)
    // copy the main applet structure
    Plasma::PackageStructure::operator=(*Plasma::Applet::packageStructure());
    addFileDefinition("mainscript", "code/main.html", i18n("Main Script File"));
    setRequired("mainscript", true);

    // For Webapplet::init()
    addDirectoryDefinition("html", "code/", i18n("Root HTML directory"));
}
Exemple #4
0
bool Bundle::parsePlist(const QString &loc)
{
    QFile f(loc);
    if (!f.open(QIODevice::ReadOnly)) {
        qWarning("Couldn't open info file: '%s'", qPrintable(loc));
        return false;
    }

    QMap<QString, QString> infoMap;
    QString str = f.readAll();
    QXmlStreamReader reader(str);
    while (!reader.atEnd()) {
        reader.readNext();
        // do processing
        if (reader.isStartElement()) {
            //qDebug() << reader.name().toString();
            if (reader.name() == "key") {
                QString key, value;
                reader.readNext();
                if (reader.isCharacters()) {
                    QString str = reader.text().toString();
                    str = str.trimmed();
                    if (!str.isEmpty())
                        key = str;
                }
                if (key.isEmpty())
                    continue;
                while (!reader.isStartElement())
                    reader.readNext();
                if (reader.name() != "string" &&
                    reader.name() != "integer") {
                    qDebug()<<"Unrecognized val "<<reader.name().toString()
                            <<" for key "<<key;
                    continue;
                }
                reader.readNext();
                if (reader.isCharacters()) {
                    QString str = reader.text().toString();
                    str = str.trimmed();
                    if (!str.isEmpty())
                        value = str;
                }
                //qDebug()<<"key = "<<key<<", value = "<<value;
                infoMap.insert(key, value);
            }
        }
    }

    QMap<QString, QString>::const_iterator itr;
    for (itr = infoMap.constBegin(); itr != infoMap.constEnd(); ++itr) {
        kDebug() << itr.key() << itr.value();
        if (itr.key() == QLatin1String("CFBundleIdentifier")) {
            m_bundleId = itr.value();
        } else if (itr.key() == QLatin1String("CFBundleName")) {
            m_description = itr.value();
        } else if (itr.key() == QLatin1String("CFBundleDisplayName")) {
            m_name = itr.value();
        } else if (itr.key() == QLatin1String("CFBundleVersion")) {
            m_version = itr.value();
        } else if (itr.key() == QLatin1String("CloseBoxInsetX")) {

        } else if (itr.key() == QLatin1String("CloseBoxInsetY")) {

        } else if (itr.key() == QLatin1String("Height")) {
            m_height = itr.value().toInt();
        } else if (itr.key() == QLatin1String("Width")) {
            m_width = itr.value().toInt();
        } else if (itr.key() == QLatin1String("MainHTML")) {
            m_htmlLocation = QString("%1%2").arg(path()).arg(itr.value());
            addFileDefinition("mainscript", itr.value(), i18n("Main Webpage"));
        } else {
            qDebug()<<"Unrecognized key = "<<itr.key();
        }
    }
    m_iconLocation = QString("%1Icon.png").arg(path());
    kDebug() << path();
    addDirectoryDefinition("root", "/", i18n("Root HTML directory"));

    //qDebug()<<"name = "<<m_name;
    //qDebug()<<"id   = "<<m_bundleId;
    //qDebug()<<"html = "<<m_htmlLocation;
    //qDebug()<<"icon = "<<m_iconLocation;

    return !m_bundleId.isEmpty();
}