Ejemplo n.º 1
0
void
TabsApplet::saveSettings()
{
    DEBUG_BLOCK
    KConfigGroup config = Amarok::config("Tabs Applet");

    bool fetchGuitar = ui_Settings.cbFetchGuitar->isChecked();
    bool fetchBass = ui_Settings.cbFetchBass->isChecked();

    // check if any setting has changed
    bool forceUpdate = false;
    if( m_fetchGuitar != fetchGuitar || m_fetchBass != fetchBass )
        forceUpdate = true;

    if( forceUpdate )
    {
        m_fetchGuitar = fetchGuitar;
        m_fetchBass = fetchBass;

        config.writeEntry( "FetchGuitar", m_fetchGuitar );
        config.writeEntry( "FetchBass", m_fetchBass );

        Plasma::DataEngine *engine = dataEngine( "amarok-tabs" );
        engine->setProperty( "fetchGuitarTabs", m_fetchGuitar );
        engine->setProperty( "fetchBassTabs", m_fetchBass );
        engine->query( QLatin1String( "tabs:forceUpdate" ) );
    }
}
Ejemplo n.º 2
0
void WebBrowser::urlChanged(const QUrl &url)
{
    //ask for a favicon
    Plasma::DataEngine *engine = dataEngine( "favicons" );
    if (engine) {
        //engine->disconnectSource( url.toString(), this );
        engine->connectSource( url.toString(), this );

        engine->query( url.toString() );
    }

    m_url = KUrl(url);

    if (m_bookmarkModel->match(m_bookmarkModel->index(0,0), BookmarkItem::UrlRole, m_url.prettyUrl()).isEmpty()) {
        m_addBookmark->setAction(m_addBookmarkAction);
    } else {
        m_addBookmark->setAction(m_removeBookmarkAction);
    }

    m_nativeHistoryCombo->addToHistory(m_url.prettyUrl());
    m_nativeHistoryCombo->setCurrentIndex(0);

    m_go->setAction(m_reloadAction);

    KConfigGroup cg = config();
    saveState(cg);

    m_back->setEnabled(m_browser->page()->history()->canGoBack());
    m_forward->setEnabled(m_browser->page()->history()->canGoForward());
    setAssociatedApplicationUrls(KUrl(url));
}
Ejemplo n.º 3
0
void ClockApplet::updateTipContent()
{
    Plasma::ToolTipContent tipData;

    QString subText("<table>");
    QList<Plasma::DataEngine::Data> tzs;
    Plasma::DataEngine *engine = dataEngine("time");
    Plasma::DataEngine::Data data = engine->query("Local");
    const QDate localDate = data["Date"].toDate();
    const QString localTz = data["Timezone"].toString();
    tzs.append(data);
    bool highlightLocal = false;

    const bool hasEvents = d->calendarWidget ? d->calendarWidget->dateHasDetails(localDate) : false;
    tipData.setMainText(hasEvents ? i18n("Current Time and Events") : i18n("Current Time"));

    foreach (const QString &tz, d->selectedTimezones) {
        if (tz != "UTC") {
            highlightLocal = true;
        }

        data = engine->query(tz);
        tzs.append(data);
    }

    qSort(tzs.begin(), tzs.end(), sortTzByData);
    QDate currentDate;
    foreach (const Plasma::DataEngine::Data &data, tzs) {
        bool shouldHighlight = highlightLocal && (data["Timezone"].toString() == localTz);
        currentDate = d->addTzToTipText(subText, data, currentDate, shouldHighlight);
    }
Ejemplo n.º 4
0
/**
 * Loads an ion plugin given a plugin name found via KService.
 */
Plasma::DataEngine *WeatherEngine::loadIon(const QString& plugName)
{
    KPluginInfo foundPlugin;

    foreach(const KPluginInfo &info, Plasma::DataEngineManager::listEngineInfo("weatherengine")) {
        if (info.pluginName() == plugName) {
            foundPlugin = info;
            break;
        }
    }

    if (!foundPlugin.isValid()) {
        return NULL;
    }

    // Load the Ion plugin, store it into a QMap to handle multiple ions.
    Plasma::DataEngine *ion = Plasma::DataEngineManager::self()->loadEngine(foundPlugin.pluginName());
    ion->setObjectName(plugName);
    connect(ion, SIGNAL(sourceAdded(QString)), this, SLOT(newIonSource(QString)));
    connect(ion, SIGNAL(forceUpdate(IonInterface*,QString)), this, SLOT(forceUpdate(IonInterface*,QString)));

    m_ions << plugName;

    return ion;
}
Ejemplo n.º 5
0
void ControlWidget::DisconnectSource()
{
    Plasma::DataEngine* engine = m_parent->getDataEngine();
    if (engine && engine->isValid())
    {
        Logger::Log(DEBUG, "Disconnecting source %s", m_unit.address());
        engine->disconnectSource(m_unit.address(), this);
    }
}
Ejemplo n.º 6
0
void
PhotosApplet::init()
{
    DEBUG_BLOCK

    // Call the base implementation.
    Context::Applet::init();

    // Create label
    enableHeader( true );
    setHeaderText( i18n( "Photos" ) );

    // Set the collapse size
    setCollapseHeight( m_header->height() );
    setCollapseOffHeight( 220 );
    setMaximumHeight( 220 );
    setMinimumHeight( collapseHeight() );
    setPreferredHeight( collapseHeight() );

    // Icon
    QAction* settingsAction = new QAction( this );
    settingsAction->setIcon( KIcon( "preferences-system" ) );
    settingsAction->setVisible( true );
    settingsAction->setEnabled( true );
    settingsAction->setText( i18n( "Settings" ) );
    m_settingsIcon = addRightHeaderAction( settingsAction );
    connect( m_settingsIcon, SIGNAL( clicked() ), this, SLOT( showConfigurationInterface() ) );

    m_widget = new PhotosScrollWidget( this );
    m_widget->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
    m_widget->setContentsMargins( 0, 0, 0, 0 );
    connect( m_widget, SIGNAL(photoAdded()), SLOT(photoAdded()) );

    QGraphicsLinearLayout *layout = new QGraphicsLinearLayout( Qt::Vertical, this );
    layout->addItem( m_header );
    layout->addItem( m_widget );

    // Read config and inform the engine.
    KConfigGroup config = Amarok::config("Photos Applet");
    m_nbPhotos = config.readEntry( "NbPhotos", "10" ).toInt();
    m_Animation = config.readEntry( "Animation", "Fading" );
    m_KeyWords = config.readEntry( "KeyWords", QStringList() );

    if( m_Animation == i18nc( "animation type", "Automatic" ) )
        m_widget->setMode( 0 );
    else if( m_Animation == i18n( "Interactive" ) )
        m_widget->setMode( 1 );
    else // fading
        m_widget->setMode( 2 );

    Plasma::DataEngine *engine = dataEngine( "amarok-photos" );
    engine->setProperty( "fetchSize", m_nbPhotos );
    engine->setProperty( "keywords", m_KeyWords );
    engine->connectSource( "photos", this );
}
Ejemplo n.º 7
0
/**
 * \brief Initialization
 *
 * Initializes the TabsApplet with default parameters
 */
void
TabsApplet::init()
{
    // applet base initialization
    Context::Applet::init();

    // create the header label
    enableHeader( true );
    setHeaderText( i18nc( "Guitar tablature", "Tabs" ) );

    // creates the tab view
    m_tabsView = new TabsView( this );

    // Set the collapse size
    setCollapseOffHeight( -1 );
    setCollapseHeight( m_header->height() );
    setMinimumHeight( collapseHeight() );
    setPreferredHeight( collapseHeight() );

    // create the reload icon
    QAction* reloadAction = new QAction( this );
    reloadAction->setIcon( KIcon( "view-refresh" ) );
    reloadAction->setVisible( true );
    reloadAction->setEnabled( true );
    reloadAction->setText( i18nc( "Guitar tablature", "Reload tabs" ) );
    m_reloadIcon = addLeftHeaderAction( reloadAction );
    m_reloadIcon.data()->setEnabled( false );
    connect( m_reloadIcon.data(), SIGNAL(clicked()), this, SLOT(reloadTabs()) );

    // create the settings icon
    QAction* settingsAction = new QAction( this );
    settingsAction->setIcon( KIcon( "preferences-system" ) );
    settingsAction->setEnabled( true );
    settingsAction->setText( i18n( "Settings" ) );
    QWeakPointer<Plasma::IconWidget> settingsIcon = addRightHeaderAction( settingsAction );
    connect( settingsIcon.data(), SIGNAL(clicked()), this, SLOT(showConfigurationInterface()) );

    m_layout = new QGraphicsLinearLayout( Qt::Vertical );
    m_layout->addItem( m_header );
    m_layout->addItem( m_tabsView );
    setLayout( m_layout );

    // read configuration data and update the engine.
    KConfigGroup config = Amarok::config("Tabs Applet");
    m_fetchGuitar = config.readEntry( "FetchGuitar", true );
    m_fetchBass = config.readEntry( "FetchBass", true );

    Plasma::DataEngine *engine = dataEngine( "amarok-tabs" );
    engine->setProperty( "fetchGuitarTabs", m_fetchGuitar );
    engine->setProperty( "fetchBassTabs", m_fetchBass );
    engine->connectSource( "tabs", this );

    updateInterface( InitState );
}
Ejemplo n.º 8
0
bool Hdd::addVisualization(const QString& source)
{
    Plasma::Meter *w;
    Plasma::DataEngine *engine = dataEngine("soliddevice");
    Plasma::DataEngine::Data data;

    if (!engine) {
        return false;
    }
    if (!isValidDevice(source, &data)) {
        // do not try to show hard drives and swap partitions.
        return false;
    }
    QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(Qt::Horizontal);
    layout->setContentsMargins(3, 3, 3, 3);
    layout->setSpacing(5);

    w = new Plasma::Meter(this);
    w->setMeterType(Plasma::Meter::BarMeterHorizontal);
    if (mode() != SM::Applet::Panel) {
        MonitorIcon *icon = new MonitorIcon(this);
        m_icons.insert(source, icon);
        icon->setImage("drive-harddisk");
        if (data["Accessible"].toBool()) {
            QStringList overlays;
            overlays << QString("emblem-mounted");
            icon->setOverlays(overlays);
        }
        layout->addItem(icon);
    } else {
        w->setSvg("system-monitor/hdd_panel");
    }
    w->setLabel(0, hddTitle(source, data));
    w->setLabelAlignment(0, Qt::AlignVCenter | Qt::AlignLeft);
    w->setLabelAlignment(1, Qt::AlignVCenter | Qt::AlignRight);
    w->setLabelAlignment(2, Qt::AlignVCenter | Qt::AlignCenter);
    w->setMaximum(data["Size"].toULongLong() / (1024 * 1024));
    applyTheme(w);
    appendVisualization(source, w);
    layout->addItem(w);
    mainLayout()->addItem(layout);
    dataUpdated(source, data);
    setPreferredItemHeight(layout->preferredSize().height());

    QString disk = data["Parent UDI"].toString();

    m_diskMap[disk] << w;
    if (!connectedSources().contains(disk)) {
        data = engine->query(disk);
        dataUpdated(disk, data);
        connectSource(disk);
    }
    return true;
}
Ejemplo n.º 9
0
void Clock::connectToEngine()
{
    resetLastTimeSeen();

    Plasma::DataEngine* timeEngine = dataEngine("time");
    timeEngine->disconnectSource(m_oldTimezone, this);
    m_oldTimezone = currentTimezone();

    if (m_showSecondHand) {
        timeEngine->connectSource(currentTimezone(), this, 500);
    } else {
        timeEngine->connectSource(currentTimezone(), this, 6000, Plasma::AlignToMinute);
    }
}
Ejemplo n.º 10
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";
    }
}
Ejemplo n.º 11
0
void Clock::changeEngineTimezone(const QString &oldTimezone, const QString &newTimezone)
{
    dataEngine("time")->disconnectSource(oldTimezone, this);
    Plasma::DataEngine* timeEngine = dataEngine("time");

    if (m_showSecondHand) {
        timeEngine->connectSource(newTimezone, this, 500);
    } else {
        timeEngine->connectSource(newTimezone, this, 6000, Plasma::AlignToMinute);
    }

    if (m_showingTimezone != (m_showTimezoneString || shouldDisplayTimezone())) {
        m_showingTimezone = !m_showingTimezone;
        constraintsEvent(Plasma::SizeConstraint);
    }
    m_repaintCache = RepaintAll;
}
Ejemplo n.º 12
0
void PoTD::dataUpdated(const QString &source, const Plasma::DataEngine::Data &data)
{
    if (source == QLatin1String("Providers")) {
        m_providers = data;
        if (!m_provider.isEmpty() && !m_providers.contains(m_provider)) {
            Plasma::DataEngine *engine = dataEngine(QLatin1String("potd"));
            engine->disconnectSource(m_provider, this);
            m_provider = DEFAULT_PROVIDER;
            engine->connectSource(m_provider, this);
        }
    } else if (source == m_provider) {
        QImage image = data["Image"].value<QImage>();
        render(image, boundingRect().size().toSize(), MaxpectResize);
    } else {
        dataEngine(QLatin1String("potd"))->disconnectSource(source, this);
    }
}
Ejemplo n.º 13
0
void RtdScheduleApplet::init()
{
    QString sourceName = QLatin1String("NextStops [B/BF/BX-E:Broadway - 16th St (University of Colorado)"
                                       ",DASH-E:Broadway - 16th St (University of Colorado)"
                                       ",204-S:Broadway - 16th St (University of Colorado)"
                                       ",AB-E:Broadway - 16th St (University of Colorado)"
                                       "] 4");

// NextStops [B/BF/BX-E:Broadway - 16th St (University of Colorado),DASH-E:Broadway - 16th St (University of Colorado),204-S:Broadway - 16th St (University of Colorado),AB-E:Broadway - 16th St (University of Colorado)] 4 TEXT
    Plasma::DataEngine *de = dataEngine("rtddenver");
    if (!de->isValid()) {
        setFailedToLaunch(true, i18n("Cannot connect to RTD Denver data engine"));
        return;
    }

    setBusy(true);
    de->connectSource(sourceName, this, 60*1000, Plasma::AlignToMinute);
}
Ejemplo n.º 14
0
void ControlWidget::ConnectSource()
{
    Plasma::DataEngine* engine = m_parent->getDataEngine();
    if (engine && engine->isValid())
    {
        Logger::Log(DEBUG, "Connecting source %s", m_unit.address());
        engine->connectSource(m_unit.address(), this, 0);

        m_serviceUnit = engine->serviceForSource(m_unit.address());
        if (!m_serviceUnit)
            Logger::Log(ERROR, "Connecting source %s: Null Service", m_unit.address());
    }
    else
    {
        Logger::Log(ERROR, "Connecting source %s: Null Data Engine", m_unit.address());
        m_serviceUnit = 0;
    }
}
Ejemplo n.º 15
0
void
PhotosApplet::saveSettings()
{
    DEBUG_BLOCK
    KConfigGroup config = Amarok::config("Photos Applet");

    m_nbPhotos = ui_Settings.photosSpinBox->value();
    m_Animation = ui_Settings.animationComboBox->currentText();
    m_KeyWords = ui_Settings.additionalkeywordsLineEdit->text().split(", ");
    config.writeEntry( "NbPhotos", m_nbPhotos );
    config.writeEntry( "Animation", m_Animation );
    config.writeEntry( "KeyWords", m_KeyWords );

    m_widget->setMode( ui_Settings.animationComboBox->currentIndex() );
    m_widget->clear();

    Plasma::DataEngine *engine = dataEngine( "amarok-photos" );
    engine->setProperty( "fetchSize", m_nbPhotos );
    engine->setProperty( "keywords", m_KeyWords );
    engine->query( QLatin1String( "photos:forceUpdate" ) );
}
Ejemplo n.º 16
0
void ActivityManager::init() {
  Plasma::ToolTipManager::self()->registerWidget(this);
  extender()->setEmptyExtenderMessage(i18n("No Activities..."));
  // don't grow too much height
  extender()->setMaximumHeight(300);
  if (extender()->item("Activities") == 0) {
    // create the item
    Plasma::ExtenderItem *item = new Plasma::ExtenderItem(extender());
    // initialize the item
    initExtenderItem(item);
    // set item name and title
    item->setName("Activities");
    item->setTitle("Activities");
  }
  // connect data sources
  Plasma::DataEngine *engine = dataEngine("org.kde.activities");
  foreach (const QString source, engine->sources())
    activityAdded(source);
  // activity addition and removal
  connect(engine, SIGNAL(sourceAdded(QString)), this, SLOT(activityAdded(QString)));
  connect(engine, SIGNAL(sourceRemoved(QString)), this, SLOT(activityRemoved(QString)));
}
Ejemplo n.º 17
0
void PoTD::paint(QPainter *painter, const QRectF& exposedRect)
{
    if (m_image.isNull()) {
        painter->fillRect(exposedRect, QBrush(Qt::black));
        const QString provider = m_providers.isEmpty() || m_provider.isEmpty() ? QString()
                                                                               : m_providers.value(m_provider).toString();
        const QString text = provider.isEmpty() ? i18n("Loading the picture of the day...")
                                                : i18n("Loading the picture of the day from %1...", provider);
        QRect textRect = painter->fontMetrics().boundingRect(text);
        textRect.moveCenter(boundingRect().center().toPoint());
        painter->setPen(Qt::white);
        painter->drawText(textRect.topLeft(), text);
    } else {
        if (m_image.size() != boundingRect().size().toSize()) {
            Plasma::DataEngine *engine = dataEngine(QLatin1String("potd"));
            // refresh the data which will trigger a re-render
            engine->disconnectSource(m_provider, this);
            engine->connectSource(m_provider, this);
        }
        painter->drawImage(exposedRect, m_image, exposedRect);
    }
}
Ejemplo n.º 18
0
void
TabsApplet::reloadTabs()
{
    DEBUG_BLOCK
    KDialog reloadDialog;
    QWidget *reloadWidget = new QWidget( &reloadDialog );

    Ui::ReloadEditDialog *reloadUI = new Ui::ReloadEditDialog();
    reloadUI->setupUi( reloadWidget );

    reloadDialog.setCaption( i18nc( "Guitar tablature", "Reload Tabs" ) );
    reloadDialog.setButtons( KDialog::Ok|KDialog::Cancel );
    reloadDialog.setDefaultButton( KDialog::Ok );
    reloadDialog.setMainWidget( reloadWidget );

    // query engine for current artist and title
    Plasma::DataEngine *engine = dataEngine( "amarok-tabs" );
    QString artistName = engine->property( "artistName" ).toString();
    QString titleName = engine->property( "titleName" ).toString();

    // update ui
    reloadUI->artistLineEdit->setText( artistName );
    reloadUI->titleLineEdit->setText( titleName );

    if( reloadDialog.exec() == KDialog::Accepted )
    {
        QString newArtist = reloadUI->artistLineEdit->text();
        QString newTitle = reloadUI->titleLineEdit->text();
        if ( newArtist != artistName || newTitle != titleName )
        {
            engine->setProperty( "artistName", newArtist );
            engine->setProperty( "titleName", newTitle );
            engine->query( QLatin1String( "tabs:forceUpdateSpecificTitleArtist" ) );
        }
    }
}
Ejemplo n.º 19
0
void
SimilarArtistsApplet::init()
{
    DEBUG_BLOCK

    // Call the base implementation.
    Context::Applet::init();

    enableHeader( true );
    setHeaderText( i18n( "Similar Artists" ) );

    QAction* backwardAction = new QAction( this );
    backwardAction->setIcon( KIcon( "go-previous" ) );
    backwardAction->setEnabled( false );
    backwardAction->setText( i18n( "Back" ) );
    m_backwardIcon = addLeftHeaderAction( backwardAction );
    connect( m_backwardIcon, SIGNAL(clicked()), this, SLOT(goBackward()) );

    QAction* forwardAction = new QAction( this );
    forwardAction->setIcon( KIcon( "go-next" ) );
    forwardAction->setEnabled( false );
    forwardAction->setText( i18n( "Forward" ) );
    m_forwardIcon = addLeftHeaderAction( forwardAction );
    connect( m_forwardIcon, SIGNAL(clicked()), this, SLOT(goForward()) );

    QAction *currentAction = new QAction( this );
    currentAction->setIcon( KIcon( "filename-artist-amarok" ) );
    currentAction->setEnabled( true );
    currentAction->setText( i18n( "Show Similar Artists for Currently Playing Track" ) );
    m_currentArtistIcon = addRightHeaderAction( currentAction );
    connect( m_currentArtistIcon, SIGNAL(clicked()), this, SLOT(queryForCurrentTrack()) );

    QAction* settingsAction = new QAction( this );
    settingsAction->setIcon( KIcon( "preferences-system" ) );
    settingsAction->setEnabled( true );
    settingsAction->setText( i18n( "Settings" ) );
    m_settingsIcon = addRightHeaderAction( settingsAction );
    connect( m_settingsIcon, SIGNAL(clicked()), this, SLOT(configure()) );

    setCollapseOffHeight( -1 );
    setCollapseHeight( m_header->height() );
    setMinimumHeight( collapseHeight() );
    setPreferredHeight( collapseHeight() );

    // create a scrollarea
    m_scroll = new ArtistsListWidget( this );
    m_scroll->hide();
    connect( m_scroll, SIGNAL(showSimilarArtists(QString)), SLOT(showSimilarArtists(QString)) );
    connect( m_scroll, SIGNAL(showBio(QString)), SLOT(showArtistBio(QString)) );

    m_layout = new QGraphicsLinearLayout( Qt::Vertical, this );
    m_layout->addItem( m_header );
    m_layout->addItem( m_scroll );
    setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );

    // Read config and inform the engine.
    KConfigGroup config = Amarok::config( "SimilarArtists Applet" );
    m_maxArtists = config.readEntry( "maxArtists", "5" ).toInt();

    Plasma::DataEngine *engine = dataEngine( "amarok-similarArtists" );
    connect( engine, SIGNAL(sourceAdded(QString)), SLOT(connectSource(QString)) );
    engine->setProperty( "maximumArtists", m_maxArtists );
    engine->query( "similarArtists" );
}
Ejemplo n.º 20
0
void WicdApplet::init()
{
    m_theme->resize(contentsRect().size());
    
    Plasma::ToolTipManager::self()->registerWidget(this);

    //load dataengine
    Plasma::DataEngine *engine = dataEngine("wicd");
    if (!engine->isValid()) {
        setFailedToLaunch(true, i18n("Unable to load the Wicd data engine."));
        return;
    }
    
    setupActions();
    
    //build the popup dialog
    QGraphicsWidget *appletDialog = new QGraphicsWidget(this);
    m_dialoglayout = new QGraphicsLinearLayout(Qt::Vertical);
    
    //Network list
    m_scrollWidget = new Plasma::ScrollWidget(appletDialog);
    m_scrollWidget->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    m_scrollWidget->setFlag(QGraphicsItem::ItemClipsChildrenToShape);
    m_scrollWidget->setMaximumHeight(400);

    m_networkView = new NetworkView(m_scrollWidget);
    m_scrollWidget->setWidget(m_networkView);

    m_busyWidget = new Plasma::BusyWidget(m_scrollWidget);
    m_busyWidget->hide();

    m_dialoglayout->addItem(m_scrollWidget);
    
    //Separator
    m_dialoglayout->addItem(new Plasma::Separator(appletDialog));
    
    //Bottom bar
    QGraphicsLinearLayout* bottombarLayout = new QGraphicsLinearLayout(Qt::Horizontal);
    
    m_messageBox = new Plasma::Label(appletDialog);
    m_messageBox->setWordWrap(false);
    bottombarLayout->addItem(m_messageBox);
    
    bottombarLayout->addStretch();
    
    m_abortButton = new Plasma::ToolButton(appletDialog);
    m_abortButton->setIcon(KIcon("dialog-cancel"));
    m_abortButton->nativeWidget()->setToolTip(i18n("Abort"));
    connect(m_abortButton, SIGNAL(clicked()), this, SLOT(cancelConnect()));
    bottombarLayout->addItem(m_abortButton);
    
    Plasma::ToolButton *reloadButton = new Plasma::ToolButton(appletDialog);
    reloadButton->nativeWidget()->setToolTip(i18n("Reload"));
    reloadButton->setAction(action("reload"));
    bottombarLayout->addItem(reloadButton);
    
    m_dialoglayout->addItem(bottombarLayout);
    
    appletDialog->setLayout(m_dialoglayout);
    setGraphicsWidget(appletDialog);

    setHasConfigurationInterface(true);
    
    // read config
    configChanged();

    connect(Plasma::Theme::defaultTheme(), SIGNAL(themeChanged()), SLOT(updateColors()));


    //prevent notification on startup
    m_status.State = 10;
    m_isScanning = false;
    //connect dataengine
    m_wicdService = engine->serviceForSource("");
    engine->connectSource("status", this);
    engine->connectSource("daemon", this);
}
Ejemplo n.º 21
0
void SwitchWindow::makeMenu()
{
    m_menu->clear();
    Plasma::DataEngine *tasks = dataEngine("tasks");
    if (!tasks->isValid()) {
        return;
    }

    QMultiHash<int, QAction*> desktops;

    //make all the window actions
    foreach (const QString &source, tasks->sources()) {
        Plasma::DataEngine::Data window = tasks->query(source);
        if (window.value("startup").toBool()) {
            //kDebug() << "skipped fake task" << source;
            continue;
        }
        if (!window.value("onCurrentActivity").toBool()) {
            continue;
        }

        QString name = window.value("visibleNameWithState").toString();
        if (name.isEmpty()) {
            kDebug() << "failed source" << source;
            continue;
        }

        QAction *action = new QAction(name, m_menu);
        action->setIcon(window.value("icon").value<QIcon>());
        action->setData(source);
        desktops.insert(window.value("desktop").toInt(), action);
    }

    //sort into menu
    if (m_mode == CurrentDesktop) {
        int currentDesktop = KWindowSystem::currentDesktop();
        m_menu->addTitle(i18n("Windows"));
        m_menu->addActions(desktops.values(currentDesktop));
        m_menu->addActions(desktops.values(-1));
    } else {
        int numDesktops = KWindowSystem::numberOfDesktops();
        if (m_mode == AllFlat) {
            for (int i = 1; i <= numDesktops; ++i) {
                if (desktops.contains(i)) {
                    QString name = KWindowSystem::desktopName(i);
                    name = QString("%1: %2").arg(i).arg(name);
                    m_menu->addTitle(name);
                    m_menu->addActions(desktops.values(i));
                }
            }
            if (desktops.contains(-1)) {
                m_menu->addTitle(i18n("All Desktops"));
                m_menu->addActions(desktops.values(-1));
            }
        } else { //submenus
            for (int i = 1; i <= numDesktops; ++i) {
                if (desktops.contains(i)) {
                        QString name = KWindowSystem::desktopName(i);
                        name = QString("%1: %2").arg(i).arg(name);
                        KMenu *subMenu = new KMenu(name, m_menu);
                        subMenu->addActions(desktops.values(i));
                        m_menu->addMenu(subMenu);
                }
            }
            if (desktops.contains(-1)) {
                KMenu *subMenu = new KMenu(i18n("All Desktops"), m_menu);
                subMenu->addActions(desktops.values(-1));
                m_menu->addMenu(subMenu);
            }
        }
    }

    m_menu->adjustSize();
}
Ejemplo n.º 22
0
void Luna::connectToEngine()
{
    Plasma::DataEngine* timeEngine = dataEngine("time");
    timeEngine->connectSource("UTC", this, 360000, Plasma::AlignToHour);
}