コード例 #1
0
void FdoSelectionManagerPrivate::createNotification(WId winId)
{
    if (!tasks.contains(winId)) {
        kDebug() << "message request from unknown task" << winId;
        return;
    }

    MessageRequest &request = messageRequests[winId];
    Task *task = tasks[winId];

    QString message = QString::fromUtf8(request.message);
    message = QTextDocument(message).toHtml();

    if (!notificationsEngine) {
        notificationsEngine = Plasma::DataEngineManager::self()->loadEngine("notifications");
    }
    //FIXME: who is the source in this case?
    Plasma::Service *service = notificationsEngine->serviceForSource("notification");
    KConfigGroup op = service->operationDescription("createNotification");

    if (op.isValid()) {
        op.writeEntry("appName", task->name());
        //FIXME: find a way to pass icons trough here
        op.writeEntry("appIcon", task->name());

        //op.writeEntry("summary", task->name());
        op.writeEntry("body", message);
        op.writeEntry("timeout", (int)request.timeout);
        KJob *job = service->startOperationCall(op);
        QObject::connect(job, SIGNAL(finished(KJob*)), service, SLOT(deleteLater()));
    } else {
        delete service;
        kDebug() << "invalid operation";
    }
}
コード例 #2
0
ファイル: metalistviewwidget.cpp プロジェクト: gkiagia/qtwine
void MetaListViewWidget::initialize(QAbstractItemModel *model, const KConfigGroup & group)
{
    m_listView->setModel(model);

    if ( group.isValid() ) {
        setMetaBarPosition( readEntry(group, "metaBarPosition", Right) );
        setListViewMode( readEntry(group, "listViewMode", QListView::ListMode) );
        m_splitter->restoreState( group.readEntry("splitterState", QByteArray()) );
        m_configGroup = group;
    } else {
        setMetaBarPosition(Right);
        setListViewMode(QListView::ListMode);
    }

    //### Disabled feature; this should not be user-configurable. depends on the model.
    setMultipleSelectionEnabled(false);

    QItemSelectionModel *selModel = m_listView->selectionModel();
    connect(selModel, SIGNAL(selectionChanged(QItemSelection, QItemSelection )),
        SIGNAL(selectionChanged(QItemSelection)) );

    connect(m_listView, SIGNAL(customContextMenuRequested(QPoint)),
        SLOT(slotContextMenuRequested(QPoint)) );

    loadGlobalPreferences();
    connect(qtwineApp, SIGNAL(preferencesChanged()), this, SLOT(loadGlobalPreferences()) );
}
コード例 #3
0
ファイル: suspendsession.cpp プロジェクト: KDE/powerdevil
bool SuspendSession::loadAction(const KConfigGroup& config)
{
    if (config.isValid() && config.hasKey("idleTime") && config.hasKey("suspendType")) {
        // Add the idle timeout
        m_idleTime = config.readEntry<int>("idleTime", 0);
        if (m_idleTime) {
            registerIdleTimeout(m_idleTime - 5000);
            registerIdleTimeout(m_idleTime);
        }
        m_autoType = config.readEntry<uint>("suspendType", 0);
    }

    return true;
}
コード例 #4
0
QMap<QString, QVariant> Service::parametersFromDescription(const KConfigGroup &description)
{
    QMap<QString, QVariant> params;

    if (!d->config || !description.isValid()) {
        return params;
    }

    const QString op = description.name();
    foreach (const QString &key, description.keyList()) {
        KConfigSkeletonItem *item = d->config->findItem(op, key);
        if (item) {
            params.insert(key, description.readEntry(key, item->property()));
        }
    }

    return params;
}
コード例 #5
0
void PlasmoidProtocol::init()
{
    //this should never happen
    if (m_containment) {
        return;
    }

    Host* h = qobject_cast<Host*>(parent());
    QQuickItem* rootItem = h->rootItem();
    if (rootItem) {
        m_systrayApplet = rootItem->property("_plasma_applet").value<Plasma::Applet*>();
    }

    if (!m_systrayApplet) {
        qWarning() << "Don't have a parent applet, Can't initialize the Plasmoid protocol!!!";
        return;
    }

    int containmentId = 0;

    KConfigGroup cg = m_systrayApplet->config();
    cg = KConfigGroup(&cg, "Containments");
    if (cg.isValid() && cg.groupList().size()) {
        containmentId = cg.groupList().first().toInt();
    }

    m_containment = new Plasma::Containment(m_systrayApplet, QStringLiteral("null"), containmentId);
    m_containment->setImmutability(Plasma::Types::Mutable);
    m_containment->setFormFactor(Plasma::Types::Horizontal);
    m_containment->setLocation(m_systrayApplet->location());
    m_containment->setContainmentActions(QStringLiteral("RightButton;NoModifier"), QStringLiteral("org.kde.contextmenu"));
    m_containment->init();
    emit m_systrayApplet->containment()->corona()->containmentAdded(m_containment);

    connect(m_systrayApplet, &Plasma::Applet::locationChanged, this, [=]() {
        m_containment->setLocation(m_systrayApplet->location());
    });

    m_systrayApplet->setProperty("containment", QVariant::fromValue(m_containment));

    restorePlasmoids();
}
コード例 #6
0
ファイル: kgtheme.cpp プロジェクト: alasin/libkdegames
bool KgTheme::readFromDesktopFile(const QString& path_)
{
    if (path_.isEmpty())
    {
        qCDebug(GAMES_LIB) << "Refusing to load theme with no name";
        return false;
    }
    //legacy support: relative paths are resolved with KStandardDirs/appdata
    QString path(path_);
    if (QFileInfo(path).isRelative())
    {
        path = QStandardPaths::locate(QStandardPaths::DataLocation, path);
        if (path.isEmpty())
        {
            qCDebug(GAMES_LIB) << "Could not find theme description" << path;
            return false;
        }
    }
    //default group name
    if (Private::s_configGroupNames.isEmpty())
    {
        Private::s_configGroupNames << QLatin1String("KGameTheme");
    }
    //open file, look for a known config group
    KConfig config(path, KConfig::SimpleConfig);
    KConfigGroup group;
    foreach (const QString& groupName, Private::s_configGroupNames)
    {
        if (config.hasGroup(groupName))
        {
            group = config.group(groupName);
        }
    }
    if (!group.isValid())
    {
        qCDebug(GAMES_LIB) << "Could not read theme description at" << path;
        return false;
    }
    //check format version
    if (group.readEntry("VersionFormat", 1) > 1)
    {
        qCDebug(GAMES_LIB) << "Format of theme description too new at" << path;
        return false;
    }

    //resolve paths
    const QFileInfo fi(path);
    const QDir dir = fi.dir();
    QString graphicsPath = group.readEntry("FileName", QString());
    if (!graphicsPath.isEmpty() && QFileInfo(graphicsPath).isRelative())
        graphicsPath = dir.absoluteFilePath(graphicsPath);
    QString previewPath = group.readEntry("Preview", QString());
    if (!previewPath.isEmpty() && QFileInfo(previewPath).isRelative())
        previewPath = dir.absoluteFilePath(previewPath);
    //create theme
    setName(group.readEntry("Name", QString()));
    setDescription(group.readEntry("Description", QString()));
    setAuthor(group.readEntry("Author", QString()));
    setAuthorEmail(group.readEntry("AuthorEmail", QString()));
    setGraphicsPath(graphicsPath);
    setPreviewPath(previewPath);
    setCustomData(group.entryMap());
    //store modification date of this file in private property (KGameRenderer
    //wants to clear its cache also if the theme description changes)
    setProperty("_k_themeDescTimestamp", fi.lastModified().toTime_t());
    return true;
}