예제 #1
0
파일: keyboard.cpp 프로젝트: BGmot/Qt
void Keyboard::handleInfo(QVariant const& properties)
{
    bool ok = false;
    QVariantHash items = properties.toHash();
    QString newSize = items[QString::fromLatin1("size")].toString();
    QVariantHash locale = items[QString::fromLatin1("locale")].toHash();

    int intSize = newSize.toInt(&ok);

    if (!locale.isEmpty())
    {
        QString languageId = locale[QString::fromLatin1("languageId")].toString();
        QString countryId = locale[QString::fromLatin1("countryId")].toString();

        if (!languageId.isEmpty())
            mLanguageId = languageId;

        if (!countryId.isEmpty())
            mCountryId = countryId;
    }

    if (ok && intSize != mKeyboardHeight) {
        mKeyboardHeight = intSize;
        emit notifyHeightChanged(mKeyboardHeight);
    }

#ifdef PPS_KEYBOARD_DEBUG
    qDebug() << "Keyboard: height:" << mKeyboardHeight << " languageId:" << mLanguageId
             << " countryId:" << mCountryId;
#endif

}
예제 #2
0
	QVariantHash JPersonTuneConverter::convertFrom(const QSharedPointer<Jreen::Payload> &entity) const
	{
		Jreen::Tune *tune = Jreen::se_cast<Jreen::Tune*>(entity.data());
		Q_ASSERT(tune);
		QVariantHash data;
		QString description;

		ADD_TEXT_TAG(artist);
		ADD_TAG(length, > -1, QString::number);
		ADD_TAG(rating, > -1, QString::number);
		ADD_TEXT_TAG(source);
		ADD_TEXT_TAG(title);
		ADD_TEXT_TAG(track);
		ADD_TAG(uri, .isValid(), uriToStringHelper);

		if (!data.isEmpty()) {
			data.insert(QLatin1String("id"), "tune");
			data.insert(QLatin1String("title"), QT_TRANSLATE_NOOP("Tune", "Now listening").toString());
			data.insert(QLatin1String("description"), description);
			data.insert(QLatin1String("icon"),
						qVariantFromValue(qutim_sdk_0_3::ExtensionIcon("user-status-listening_to_music")));
			data.insert(QLatin1String("showInTooltip"), true);
			data.insert(QLatin1String("priorityInTooltip"), 70);
		}

		return data;
	}
예제 #3
0
QVariantHash Tools::initDefaultStyleHash()
{
    static QVariantHash hash;
    if (!hash.isEmpty())
        return hash;
    hash.insert("alignment-baseline", "auto");
    hash.insert("baseline-shift", "baseline");
    hash.insert("block-progression", "tb");
    hash.insert("clip", "auto");
    hash.insert("clip-path", "none");
    hash.insert("clip-rule", "nonzero");
    hash.insert("direction", "ltr");
    hash.insert("display", "inline");
    hash.insert("dominant-baseline", "auto");
    hash.insert("enable-background", "accumulate");
    hash.insert("fill-opacity", 1.0);
    hash.insert("fill-rule", "nonzero");
    hash.insert("filter", "none");
    hash.insert("flood-color", "black");
    hash.insert("font-size-adjust", "none");
    hash.insert("font-size", "medium");
    hash.insert("font-stretch", "normal");
    hash.insert("font-style", "normal");
    hash.insert("font-variant", "normal");
    hash.insert("font-weight", "normal");
    hash.insert("glyph-orientation-horizontal", "0deg");
    hash.insert("glyph-orientation-vertical", "auto");
    hash.insert("kerning", "auto");
    hash.insert("letter-spacing", "normal");
    hash.insert("marker-start", "none");
    hash.insert("marker-mid", "none");
    hash.insert("marker-end", "none");
    hash.insert("mask", "none");
    hash.insert("opacity", 1.0);
    hash.insert("overflow", "visible");
    hash.insert("pointer-events", "visiblePainted");
    hash.insert("stop-opacity", 1.0);
    hash.insert("stroke-dasharray", "none");
    hash.insert("stroke-dashoffset", 0);
    hash.insert("stroke-linecap", "butt");
    hash.insert("stroke-linejoin", "miter");
    hash.insert("stroke-miterlimit", 4.0);
    hash.insert("stroke", "none");
    hash.insert("stroke-opacity", 1.0);
    hash.insert("stroke-width", 1.0);
    hash.insert("text-anchor", "start");
    hash.insert("text-decoration", "none");
    hash.insert("visibility", "visible");
    hash.insert("word-spacing", "normal");
    hash.insert("writing-mode", "lr-tb");
    return hash;
}
예제 #4
0
void AVDecoder::setOptions(const QVariantHash &dict)
{
    DPTR_D(AVDecoder);
    d.options = dict;
    if (d.dict) {
        av_dict_free(&d.dict);
        d.dict = 0; //aready 0 in av_free
    }
    if (dict.isEmpty())
        return;
    QVariantHash avcodec_dict(dict);
    if (dict.contains("avcodec"))
        avcodec_dict = dict.value("avcodec").toHash();
    // workaround for VideoDecoderFFmpeg. now it does not call av_opt_set_xxx, so set here in dict
    if (dict.contains("FFmpeg"))
        avcodec_dict.unite(dict.value("FFmpeg").toHash());
    QHashIterator<QString, QVariant> i(avcodec_dict);
    while (i.hasNext()) {
        i.next();
        switch (i.value().type()) {
        case QVariant::Hash: // for example "vaapi": {...}
            continue;
        case QVariant::Bool:
            // QVariant.toByteArray(): "true" or "false", can not recognized by avcodec
            av_dict_set(&d.dict, i.key().toLower().toUtf8().constData(), QByteArray::number(i.value().toBool()), 0);
            break;
        default:
            // avcodec key and value are in lower case
            av_dict_set(&d.dict, i.key().toLower().toUtf8().constData(), i.value().toByteArray().toLower().constData(), 0);
            break;
        }
        qDebug("avcodec option: %s=>%s", i.key().toUtf8().constData(), i.value().toByteArray().constData());
    }
    if (name() == "avcodec")
        return;
    QVariantHash property_dict(dict.value(name()).toHash());
    if (property_dict.isEmpty())
        property_dict = dict.value(name().toLower()).toHash();
    if (property_dict.isEmpty())
        return;
    i = QHashIterator<QString, QVariant>(property_dict);
    while (i.hasNext()) {
        i.next();
        if (i.value().type() == QVariant::Hash) // for example "vaapi": {...}
            continue;
        setProperty(i.key().toUtf8().constData(), i.value());
        qDebug("decoder property: %s=>%s", i.key().toUtf8().constData(), i.value().toByteArray().constData());
    }
}
예제 #5
0
QVariantHash Asterisk::originate(QString channel,
                                 QString exten,
                                 QString context,
                                 uint priority,
                                 QString application,
                                 QString data,
                                 uint timeout,
                                 QString callerId,
                                 QVariantHash variables,
                                 QString account,
                                 bool earlyMedia,
                                 bool async,
                                 QStringList codecs)
{
    QVariantHash headers;
    headers["Channel"] = channel;
    headers["EarlyMedia"] = earlyMedia;
    headers["Async"] = async;

    insertNotEmpty(&headers, "Timeout", timeout);
    insertNotEmpty(&headers, "CallerID", callerId);
    insertNotEmpty(&headers, "Account", account);
    insertNotEmpty(&headers, "Codecs", codecs.join(","));

    if (!exten.isEmpty() && !context.isEmpty() && priority > 0) {
        headers["Exten"] = exten;
        headers["Context"] = context;
        headers["Priority"] = priority;
    }

    if (!application.isEmpty()) {
        headers["Application"] = application;

        insertNotEmpty(&headers, "Data", data);
    }

    if (!variables.isEmpty()) {
        QHashIterator<QString, QVariant> variable(variables);
        while (variable.hasNext()) {
            variable.next();

            headers.insertMulti("Variable", QString("%1=%2").arg(variable.key(), encodeValue(variable.value())));
        }
    }

    return sendPacket("Originate", headers);
}
예제 #6
0
void AVDecoder::setOptions(const QVariantHash &dict)
{
    DPTR_D(AVDecoder);
    d.options = dict;
    // if dict is empty, can not return here, default options will be set for AVCodecContext
    // apply to AVCodecContext
    d.applyOptionsForContext();
    /* set AVDecoder meta properties.
     * we do not check whether the property exists thus we can set dynamic properties.
     */
    if (dict.isEmpty())
        return;
    if (name() == "avcodec")
        return;
    QVariant opt;
    if (dict.contains(name()))
        opt = dict.value(name());
    else if (dict.contains(name().toLower()))
        opt = dict.value(name().toLower());
    else
        return; // TODO: set property if no name() key found?
    if (opt.type() == QVariant::Hash) {
        QVariantHash property_dict(opt.toHash());
        if (property_dict.isEmpty())
            return;
        QHashIterator<QString, QVariant> i(property_dict);
        while (i.hasNext()) {
            i.next();
            if (i.value().type() == QVariant::Hash) // for example "vaapi": {...}
                continue;
            setProperty(i.key().toUtf8().constData(), i.value());
            qDebug("decoder meta property: %s=>%s", i.key().toUtf8().constData(), i.value().toByteArray().constData());
        }
    } else if (opt.type() == QVariant::Map) {
        QVariantMap property_dict(opt.toMap());
        if (property_dict.isEmpty())
            return;
        QMapIterator<QString, QVariant> i(property_dict);
        while (i.hasNext()) {
            i.next();
            if (i.value().type() == QVariant::Map) // for example "vaapi": {...}
                continue;
            setProperty(i.key().toUtf8().constData(), i.value());
            qDebug("decoder meta property: %s=>%s", i.key().toUtf8().constData(), i.value().toByteArray().constData());
        }
    }
}
예제 #7
0
void FSTReader::writeVariant(QBuffer& buffer, QVariantHash::const_iterator& it) {
    QByteArray key = it.key().toUtf8() + " = ";
    QVariantHash hashValue = it.value().toHash();
    if (hashValue.isEmpty()) {
        buffer.write(key + it.value().toByteArray() + "\n");
        return;
    }
    for (QVariantHash::const_iterator second = hashValue.constBegin(); second != hashValue.constEnd(); second++) {
        QByteArray extendedKey = key + second.key().toUtf8();
        QVariantList listValue = second.value().toList();
        if (listValue.isEmpty()) {
            buffer.write(extendedKey + " = " + second.value().toByteArray() + "\n");
            continue;
        }
        buffer.write(extendedKey);
        for (QVariantList::const_iterator third = listValue.constBegin(); third != listValue.constEnd(); third++) {
            buffer.write(" = " + third->toByteArray());
        }
        buffer.write("\n");
    }
}
예제 #8
0
void AVDecoder::setOptions(const QVariantHash &dict)
{
    DPTR_D(AVDecoder);
    d.options = dict;
    // if dict is empty, can not return here, default options will be set for AVCodecContext
    // apply to AVCodecContext
    d.applyOptionsForContext();
    /* set AVDecoder meta properties.
     * we do not check whether the property exists thus we can set dynamic properties.
     */
    if (dict.isEmpty())
        return;
    if (name() == "avcodec")
        return;
    QVariant opt(dict);
    if (dict.contains(name()))
        opt = dict.value(name());
    else if (dict.contains(name().toLower()))
        opt = dict.value(name().toLower());
    Internal::setOptionsForQObject(opt, this);
}
예제 #9
0
void Statistics::load()
{
    // Temp code. Versions v3.1.4 and v3.1.5 saved the data in the qbittorrent.ini file.
    // This code reads the data from there, writes it to the new file, and removes the keys
    // from the old file. This code should be removed after some time has passed.
    // e.g. When we reach v3.3.0
    // Don't forget to remove:
    // 1. Preferences::getStats()
    // 2. Preferences::removeStats()
    // 3. #include "core/preferences.h"
    Preferences* const pref = Preferences::instance();
    QIniSettings s("qBittorrent", "qBittorrent-data");
    QVariantHash v = pref->getStats();

    // Let's test if the qbittorrent.ini holds the key
    if (!v.isEmpty()) {
        m_dirty = true;

        // If the user has used qbt > 3.1.5 and then reinstalled/used
        // qbt < 3.1.6, there will be stats in qbittorrent-data.ini too
        // so we need to merge those 2.
        if (s.contains("Stats/AllStats")) {
            QVariantHash tmp = s.value("Stats/AllStats").toHash();
            v["AlltimeDL"] = v["AlltimeDL"].toULongLong() + tmp["AlltimeDL"].toULongLong();
            v["AlltimeUL"] = v["AlltimeUL"].toULongLong() + tmp["AlltimeUL"].toULongLong();
        }
    }
    else {
        v = s.value("Stats/AllStats").toHash();
    }

    m_alltimeDL = v["AlltimeDL"].toULongLong();
    m_alltimeUL = v["AlltimeUL"].toULongLong();

    if (m_dirty) {
        save();
        pref->removeStats();
    }
}
PageChoosePrinters::PageChoosePrinters(const QVariantHash &args, QWidget *parent) :
    GenericPage(parent),
    ui(new Ui::PageChoosePrinters)
{
    ui->setupUi(this);

    // setup default options
    setWindowTitle(i18nc("@title:window", "Select a Printer to Add"));
    // loads the standard key icon
    QPixmap pixmap;
    pixmap = KIconLoader::global()->loadIcon("printer",
                                             KIconLoader::NoGroup,
                                             KIconLoader::SizeEnormous, // a not so huge icon
                                             KIconLoader::DefaultState);
    QPixmap icon(pixmap);
    QPainter painter(&icon);

    pixmap = KIconLoader::global()->loadIcon("preferences-other",
                                             KIconLoader::NoGroup,
                                             KIconLoader::SizeLarge, // a not so huge icon
                                             KIconLoader::DefaultState);
    // the emblem icon to size 32
    int overlaySize = KIconLoader::SizeLarge;
    QPoint startPoint;
    // bottom right corner
    startPoint = QPoint(KIconLoader::SizeEnormous - overlaySize - 2,
                        KIconLoader::SizeEnormous - overlaySize - 2);
    painter.drawPixmap(startPoint, pixmap);
    ui->printerL->setPixmap(icon);

    connect(ui->membersLV, SIGNAL(changed(bool)),
            this, SIGNAL(allowProceed(bool)));

    if (!args.isEmpty()) {
        setValues(args);
    }
}
예제 #11
0
// system-config-printer --setup-printer='file:/tmp/printout' --devid='MFG:Ricoh;MDL:Aficio SP C820DN'
PageDestinations::PageDestinations(const QVariantHash &args, QWidget *parent) :
    GenericPage(parent),
    ui(new Ui::PageDestinations),
    m_chooseLpd(new ChooseLpd(this)),
    m_chooseSamba(new ChooseSamba(this)),
    m_chooseSerial(new ChooseSerial(this)),
    m_chooseSocket(new ChooseSocket(this)),
    m_chooseUri(new ChooseUri(this)),
    m_chooseLabel(new QLabel(this))
{
    ui->setupUi(this);
    setAttribute(Qt::WA_DeleteOnClose);

    ui->stackedWidget->addWidget(m_chooseLpd);
    connect(m_chooseLpd, SIGNAL(allowProceed(bool)), SIGNAL(allowProceed(bool)));

    ui->stackedWidget->addWidget(m_chooseSamba);
    connect(m_chooseSamba, SIGNAL(allowProceed(bool)), SIGNAL(allowProceed(bool)));

    ui->stackedWidget->addWidget(m_chooseSerial);
    connect(m_chooseSerial, SIGNAL(allowProceed(bool)), SIGNAL(allowProceed(bool)));

    ui->stackedWidget->addWidget(m_chooseSocket);
    connect(m_chooseSocket, SIGNAL(allowProceed(bool)), SIGNAL(allowProceed(bool)));

    ui->stackedWidget->addWidget(m_chooseUri);
    connect(m_chooseUri, SIGNAL(allowProceed(bool)), SIGNAL(allowProceed(bool)));

    m_chooseLabel->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
    ui->stackedWidget->addWidget(m_chooseLabel);

    // Hide the message widget
    ui->messageWidget->setMessageType(KMessageWidget::Error);
    ui->messageWidget->hide();

    // setup default options
    setWindowTitle(i18nc("@title:window", "Select a Printer to Add"));
    m_model = new DevicesModel(this);
    ui->devicesTV->setModel(m_model);
    ui->devicesTV->setItemDelegate(new NoSelectionRectDelegate(this));
    connect(ui->devicesTV->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
            this, SLOT(deviceChanged()));
    connect(m_model, SIGNAL(errorMessage(QString)), ui->messageWidget, SLOT(setText(QString)));
    connect(m_model, SIGNAL(errorMessage(QString)), ui->messageWidget, SLOT(animatedShow()));

    // Expand when a parent is added
    connect(m_model, SIGNAL(parentAdded(QModelIndex)),
            ui->devicesTV, SLOT(expand(QModelIndex)));

    // Update the view when the device URI combo box changed
    connect(ui->connectionsCB, SIGNAL(currentIndexChanged(int)),
            this, SLOT(deviceUriChanged()));
    ui->connectionsGB->setVisible(false);

    // Setup the busy cursor
    working();
    connect(m_model, SIGNAL(loaded()), this, SLOT(notWorking()));

    if (!args.isEmpty()) {
        // set our args
        setValues(args);
    }
}
예제 #12
0
QByteArray ViewEmail::render(Context *c) const
{
    Q_D(const ViewEmail);

    QVariantHash email = c->stash(d->stashKey).toHash();
    if (email.isEmpty()) {
        c->error(QStringLiteral("Cannot render template, template name or template stash key not defined"));
        return QByteArray();
    }

    MimeMessage message;

    QVariant value;
    value = email.value(QStringLiteral("to"));
    if (value.type() == QVariant::String && !value.toString().isEmpty()) {
        message.addTo(value.toString());
    }

    value = email.value(QStringLiteral("cc"));
    if (value.type() == QVariant::String && !value.toString().isEmpty()) {
        message.addCc(value.toString());
    }

    value = email.value(QStringLiteral("from"));
    if (value.type() == QVariant::String && !value.toString().isEmpty()) {
        message.setSender(value.toString());
    }

    value = email.value(QStringLiteral("subject"));
    if (value.type() == QVariant::String && !value.toString().isEmpty()) {
        message.setSubject(value.toString());
    }

    QVariant body = email.value(QStringLiteral("body"));
    QVariant parts = email.value(QStringLiteral("parts"));
    if (body.isNull() && parts.isNull()) {
        c->error(QStringLiteral("Can't send email without parts or body, check stash"));
        return QByteArray();
    }

    if (!parts.isNull()) {
        const QVariantList partsVariant = parts.toList();
        Q_FOREACH (const QVariant &part, partsVariant) {
            MimePart *mime = part.value<MimePart*>();
            if (mime) {
                message.addPart(mime);
            } else {
                qCCritical(CUTELYST_VIEW_EMAIL) << "Failed to cast MimePart";
            }
        }

        auto contentTypeIt = email.constFind(QStringLiteral("content_type"));
        if (contentTypeIt != email.constEnd()
                && !contentTypeIt.value().isNull()
                && !contentTypeIt.value().toString().isEmpty()) {
            const QByteArray contentType = contentTypeIt.value().toString().toLatin1();
            qCDebug(CUTELYST_VIEW_EMAIL) << "Using specified content_type" << contentType;
            message.getContent().setContentType(contentType);
        } else if (!d->defaultContentType.isEmpty()) {
            qCDebug(CUTELYST_VIEW_EMAIL) << "Using default content_type" << d->defaultContentType;
            message.getContent().setContentType(d->defaultContentType);
        }
    } else {
예제 #13
0
파일: AVDecoder.cpp 프로젝트: Taliens/QtAV
void AVDecoder::setOptions(const QVariantHash &dict)
{
    DPTR_D(AVDecoder);
    d.options = dict;
    if (d.dict) {
        av_dict_free(&d.dict);
        d.dict = 0; //aready 0 in av_free
    }
    if (dict.isEmpty())
        return;
    // TODO: use QVariantMap only
    QVariant opt;
    if (dict.contains("avcodec"))
        opt = dict.value("avcodec");
    if (opt.type() == QVariant::Hash) {
        QVariantHash avcodec_dict = opt.toHash();
        // workaround for VideoDecoderFFmpeg. now it does not call av_opt_set_xxx, so set here in dict
        // TODO: wrong if opt is empty
        //if (dict.contains("FFmpeg"))
        //    avcodec_dict.unite(dict.value("FFmpeg").toHash());
        QHashIterator<QString, QVariant> i(avcodec_dict);
        while (i.hasNext()) {
            i.next();
            const QByteArray key(i.key().toLower().toUtf8());
            switch (i.value().type()) {
            case QVariant::Hash: // for example "vaapi": {...}
                continue;
            case QVariant::Bool:
            case QVariant::Int: {
                // QVariant.toByteArray(): "true" or "false", can not recognized by avcodec
                av_dict_set(&d.dict, key.constData(), QByteArray::number(i.value().toInt()).constData(), 0);
                if (d.codec_ctx)
                    av_opt_set_int(d.codec_ctx, key.constData(), i.value().toInt(), 0);
            }
                break;
            case QVariant::ULongLong:
            case QVariant::LongLong: {
                av_dict_set(&d.dict, key.constData(), QByteArray::number(i.value().toLongLong()).constData(), 0);
                if (d.codec_ctx)
                    av_opt_set_int(d.codec_ctx, key.constData(), i.value().toLongLong(), 0);
            }
                break;
            default:
                // avcodec key and value are in lower case
                av_dict_set(&d.dict, i.key().toLower().toUtf8().constData(), i.value().toByteArray().toLower().constData(), 0);
                break;
            }
            qDebug("avcodec option: %s=>%s", i.key().toUtf8().constData(), i.value().toByteArray().constData());
        }
    } else if (opt.type() == QVariant::Map) {
        QVariantMap avcodec_dict = opt.toMap();
        // workaround for VideoDecoderFFmpeg. now it does not call av_opt_set_xxx, so set here in dict
        //if (dict.contains("FFmpeg"))
        //    avcodec_dict.unite(dict.value("FFmpeg").toMap());
        QMapIterator<QString, QVariant> i(avcodec_dict);
        while (i.hasNext()) {
            i.next();
            const QByteArray key(i.key().toLower().toUtf8());
            switch (i.value().type()) {
            case QVariant::Map: // for example "vaapi": {...}
                continue;
            case QVariant::Bool:
            case QVariant::UInt:
            case QVariant::Int: {
                // QVariant.toByteArray(): "true" or "false", can not recognized by avcodec
                av_dict_set(&d.dict, key.constData(), QByteArray::number(i.value().toInt()), 0);
                if (d.codec_ctx)
                    av_opt_set_int(d.codec_ctx, key.constData(), i.value().toInt(), 0);
            }
                break;
            case QVariant::ULongLong:
            case QVariant::LongLong: {
                av_dict_set(&d.dict, key.constData(), QByteArray::number(i.value().toLongLong()).constData(), 0);
                if (d.codec_ctx)
                    av_opt_set_int(d.codec_ctx, key.constData(), i.value().toLongLong(), 0);
            }
                break;
            default:
                // avcodec key and value are in lower case
                av_dict_set(&d.dict, i.key().toLower().toUtf8().constData(), i.value().toByteArray().toLower().constData(), 0);
                break;
            }
            qDebug("avcodec option: %s=>%s", i.key().toUtf8().constData(), i.value().toByteArray().constData());
        }
    }
    if (name() == "avcodec")
        return;
    if (dict.contains(name()))
        opt = dict.value(name());
    else if (dict.contains(name().toLower()))
        opt = dict.value(name().toLower());
    else
        return;
    if (opt.type() == QVariant::Hash) {
        QVariantHash property_dict(opt.toHash());
        if (property_dict.isEmpty())
            return;
        QHashIterator<QString, QVariant> i(property_dict);
        while (i.hasNext()) {
            i.next();
            if (i.value().type() == QVariant::Hash) // for example "vaapi": {...}
                continue;
            setProperty(i.key().toUtf8().constData(), i.value());
            qDebug("decoder property: %s=>%s", i.key().toUtf8().constData(), i.value().toByteArray().constData());
        }
    } else if (opt.type() == QVariant::Map) {
        QVariantMap property_dict(opt.toMap());
        if (property_dict.isEmpty())
            return;
        QMapIterator<QString, QVariant> i(property_dict);
        while (i.hasNext()) {
            i.next();
            if (i.value().type() == QVariant::Map) // for example "vaapi": {...}
                continue;
            setProperty(i.key().toUtf8().constData(), i.value());
            qDebug("decoder property: %s=>%s", i.key().toUtf8().constData(), i.value().toByteArray().constData());
        }
    }

}