예제 #1
0
파일: ram.cpp 프로젝트: KDE/kde-workspace
void SM::Ram::init()
{
    KGlobal::locale()->insertCatalog("plasma_applet_system-monitor");
    setEngine(dataEngine("systemmonitor"));
    setTitle(i18n("RAM"));

    /* At the time this method is running, not all source may be connected. */
    connect(engine(), SIGNAL(sourceAdded(QString)), this, SLOT(sourceAdded(QString)));
    foreach (const QString& source, engine()->sources()) {
        sourceAdded(source);
    }
예제 #2
0
파일: Albums.cpp 프로젝트: cancamilo/amarok
void Albums::saveConfiguration()
{
    Amarok::config("Albums Applet").writeEntry( "RecentlyAdded", QString::number( m_recentCount ) );
    Amarok::config("Albums Applet").writeEntry( "RightAlignLength", m_rightAlignLength );

    // clear to force an update
    m_albums.clear();

    Plasma::DataEngine::Data data = dataEngine( "amarok-current" )->query( "albums" );
    dataUpdated( QLatin1String("albums"), data );
}
예제 #3
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 );
}
예제 #4
0
PoTD::PoTD(QObject *parent, const QVariantList &args)
    : Plasma::Wallpaper(parent, args)
{
    connect(this, SIGNAL(renderCompleted(QImage)), this, SLOT(wallpaperRendered(QImage)));
    dataEngine(QLatin1String("potd"))->connectSource(QLatin1String("Providers"), this);
    setUsingRenderingCache(false);

    QAction *saveFile = KStandardAction::save(this, SLOT(getSaveFileLocation()), this);
    saveFile->setText(i18n("Save wallpaper image..."));
    saveFile->setShortcut(QKeySequence());
    setContextualActions(QList<QAction *>() << saveFile);
}
예제 #5
0
void Hdd_Activity::init()
{
    KGlobal::locale()->insertCatalog("plasma_applet_system-monitor");
    setEngine(dataEngine("systemmonitor"));
    setTitle(i18n("Disk Activity"), true);

    /* At the time this method is running, not all sources may be connected. */
    connect(engine(), SIGNAL(sourceAdded(QString)), this, SLOT(sourceChanged(QString)));
    connect(engine(), SIGNAL(sourceRemoved(QString)), this, SLOT(sourceChanged(QString)));

    foreach (const QString& source, engine()->sources()) {
        sourceChanged(source);
    }
예제 #6
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);
    }
}
예제 #7
0
void NowPlaying::findPlayer()
{
    QStringList players = dataEngine("nowplaying")->sources();
    kDebug() << "Looking for players.  Possibilities:" << players;
    if (players.isEmpty()) {
        m_state = NoPlayer;
        m_watchingPlayer.clear();
        delete m_controller;
        m_controller = 0;

        emit stateChanged(m_state);
        emit controllerChanged(0);
        update();
    } else {
        m_watchingPlayer = players.first();

        delete m_controller;
        m_controller = dataEngine("nowplaying")->serviceForSource(m_watchingPlayer);
        m_controller->setParent(this);
        emit controllerChanged(m_controller);
        kDebug() << "Installing" << m_watchingPlayer << "as watched player";
        dataEngine("nowplaying")->connectSource(m_watchingPlayer, this, 999);
    }
}
예제 #8
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);
}
예제 #9
0
void ActivityManager::activityAdded(QString id) {
  // skip the Status source
  if (id == "Status")
    return;
  // create a new activity object
  ActivityWidget *activity = new ActivityWidget(extender()->item("Activities"), id);
  // add activity to the list
  m_activities.insert(id, activity);
  // connect activity update signal
  dataEngine("org.kde.activities")->connectSource(id, this);
  // connect activity start/stop signals
  connect(activity, SIGNAL(setCurrent(QString)), this, SLOT(setCurrent(QString)));
  connect(activity, SIGNAL(startActivity(QString)), this, SLOT(start(QString)));
  connect(activity, SIGNAL(stopActivity(QString)), this, SLOT(stop(QString)));
  connect(activity, SIGNAL(addActivity(QString)), this, SLOT(add(QString)));
  connect(activity, SIGNAL(removeActivity(QString)), this, SLOT(remove(QString)));
  connect(activity, SIGNAL(renameActivity(QString,QString)), this, SLOT(setName(QString,QString)));
}
예제 #10
0
파일: Albums.cpp 프로젝트: cancamilo/amarok
void Albums::init()
{
    DEBUG_BLOCK

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

    enableHeader( true );
    setHeaderText( i18n( "Recently Added Albums" ) );

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

    QAction *settingsAction = new QAction( this );
    settingsAction->setIcon( KIcon( "preferences-system" ) );
    settingsAction->setEnabled( true );
    settingsAction->setToolTip( i18n( "Settings" ) );
    addRightHeaderAction( settingsAction );
    connect( settingsAction, SIGNAL(triggered()), this, SLOT(showConfigurationInterface()) );

    QAction *filterAction = new QAction( this );
    filterAction->setIcon( KIcon( "view-filter" ) );
    filterAction->setEnabled( true );
    filterAction->setToolTip( i18n( "Filter Albums" ) );
    m_filterIcon = addLeftHeaderAction( filterAction );
    connect( filterAction, SIGNAL(triggered()), this, SLOT(showFilterBar()) );

    m_albumsView = new AlbumsView( this );
    m_albumsView->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
    if( m_rightAlignLength )
        m_albumsView->setLengthAlignment( Qt::AlignRight );

    QGraphicsLinearLayout *layout = new QGraphicsLinearLayout( Qt::Vertical );
    layout->addItem( m_header );
    layout->addItem( m_albumsView );
    setLayout( layout );

    dataEngine( "amarok-current" )->connectSource( "albums", this );
    connect( CollectionManager::instance(), SIGNAL(collectionDataChanged(Collections::Collection*)),
             this, SLOT(collectionDataChanged(Collections::Collection*)) );

    updateConstraints();
}
예제 #11
0
void ActivityBar::init()
{
    QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(this);
    m_tabBar = new Plasma::TabBar(this);
    layout->addItem(m_tabBar);
    layout->setContentsMargins(0,0,0,0);
    //layout->setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding));

    //This is an awful hack, but I need to keep the old behaviour for plasma-netbook
    //while using the new activity API for plasma-desktop.
    //TODO 4.6 convert netbook to the activity API so we won't need this
    if (qApp->applicationName() == "plasma-desktop") {
        m_engine = dataEngine("org.kde.activities");
        Plasma::DataEngine::Data data = m_engine->query("Status");
        QStringList activities = data["Running"].toStringList();
        //kDebug() << "$$$$$$$$$$$$# sources:" << activities.size();
        foreach (const QString &id, activities) {
            insertActivity(id);
        }
예제 #12
0
void KdeObservatory::init()
{
    m_engine = dataEngine("kdeobservatory");

    m_service = m_engine->serviceForSource("");
    connect(m_service, SIGNAL(engineReady()), SLOT(safeInit()));
    connect(m_service, SIGNAL(engineError(QString,QString)), SLOT(engineError(QString,QString)));

    setPopupIcon(KIcon("kdeobservatory"));

    if (Solid::Networking::status() != Solid::Networking::Connected && Solid::Networking::status() != Solid::Networking::Unknown)
    {
        engineError("fatal", i18n("No active network connection"));
        return;
    }

    Plasma::PopupApplet::setBusy(true);
    m_service->startOperationCall(m_service->operationDescription("allProjectsInfo"));
}
예제 #13
0
void WeatherWallpaper::init(const KConfigGroup & config)
{
    // Connect to weather engine.
    weatherEngine = dataEngine(QLatin1String( "weather" ));

    // Set custom weather options
    m_source = config.readEntry("source");
    m_weatherUpdateTime = config.readEntry("updateWeather", 30);

    m_color = config.readEntry("wallpapercolor", QColor(56, 111, 150));
    m_dir = KStandardDirs::installPath("wallpaper");
    m_usersWallpapers = config.readEntry("userswallpapers", QStringList());
    m_resizeMethod = (ResizeMethod)config.readEntry("wallpaperposition", (int)ScaledResize);

    m_animation = new QPropertyAnimation(this, "fadeValue");
    m_animation->setProperty("easingCurve", QEasingCurve::InQuad);
    m_animation->setProperty("duration", 1000);
    m_animation->setProperty("startValue", 0.0);
    m_animation->setProperty("endValue", 1.0);

    m_weatherMap[QLatin1String( "weather-clear" )] = config.readEntry("clearPaper", QString(m_dir + QLatin1String( "Fields_of_Peace/" )));
    m_weatherMap[QLatin1String( "weather-few-clouds" )] = config.readEntry("partlyCloudyPaper", QString(m_dir + QLatin1String( "Evening/" )));
    m_weatherMap[QLatin1String( "weather-clouds" )] = config.readEntry("cloudyPaper", QString(m_dir + QLatin1String( "Colorado_Farm/" )));
    m_weatherMap[QLatin1String( "weather-many-clouds" )] = config.readEntry("manyCloudsPaper", QString(m_dir + QLatin1String( "Beach_Reflecting_Clouds/" )));
    m_weatherMap[QLatin1String( "weather-showers" )] = config.readEntry("showersPaper", QString(m_dir + QLatin1String( "There_is_Rain_on_the_Table/" )));
    m_weatherMap[QLatin1String( "weather-showers-scattered" )] = config.readEntry("showersScatteredPaper", QString(m_dir + QLatin1String( "There_is_Rain_on_the_Table/" )));
    m_weatherMap[QLatin1String( "weather-rain" )] = config.readEntry("rainPaper", QString(m_dir + QLatin1String( "There_is_Rain_on_the_Table/" )));
    m_weatherMap[QLatin1String( "weather-mist" )] = config.readEntry("mistPaper", QString(m_dir + QLatin1String( "Fresh_Morning/" )));
    m_weatherMap[QLatin1String( "weather-storm" )] = config.readEntry("stormPaper", QString(m_dir + QLatin1String( "Storm/" )));
    m_weatherMap[QLatin1String( "weather-scattered-storms" )] = m_weatherMap[QLatin1String( "weather-storm" )];
    m_weatherMap[QLatin1String( "weather-hail" )] = config.readEntry("hailPaper", QString(m_dir + QLatin1String( "Storm/" )));
    m_weatherMap[QLatin1String( "weather-snow" )] = config.readEntry("snowPaper", QString(m_dir + QLatin1String( "Winter_Track/" )));
    m_weatherMap[QLatin1String( "weather-snow-scattered" )] = config.readEntry("snowScatteredPaper", QString(m_dir + QLatin1String( "Winter_Track/" )));
    m_weatherMap[QLatin1String( "weather-few-clouds-night" )] = config.readEntry("partlyCloudyNightPaper", QString(m_dir + QLatin1String( "JK_Bridge_at_Night/" )));
    m_weatherMap[QLatin1String( "weather-clouds-night" )] = config.readEntry("cloudyNightPaper", QString(m_dir + QLatin1String( "JK_Bridge_at_Night/" )));
    m_weatherMap[QLatin1String( "weather-clear-night" )] = config.readEntry("clearNightPaper", QString(m_dir + QLatin1String( "City_at_Night/" )));
    m_weatherMap[QLatin1String( "weather-freezing-rain" )] = config.readEntry("freezingRainPaper", QString(m_dir + QLatin1String( "Icy_Tree/" )));
    m_weatherMap[QLatin1String( "weather-snow-rain" )] = config.readEntry("snowRainPaper", QString(m_dir + QLatin1String( "Icy_Tree/" )));

    calculateGeometry();
    connectWeatherSource();
}
예제 #14
0
void InfoApplet::init()
{
    // Call the base implementation.
    Context::Applet::init();

    dataEngine( "amarok-info" )->connectSource( "info", this );

    m_webView = new KGraphicsWebView( this );

    QPalette p = m_webView->palette();
    p.setColor( QPalette::Dark, QColor( 255, 255, 255, 0)  );
    p.setColor( QPalette::Window, QColor( 255, 255, 255, 0)  );
    m_webView->setPalette( p );

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

    connect( m_webView->page(), SIGNAL(linkClicked(QUrl)), SLOT(linkClicked(QUrl)) );

    updateConstraints();
}
예제 #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" ) );
}
예제 #16
0
KalziumPlasma::KalziumPlasma(QObject *parent, const QVariantList &args)
    : Plasma::Applet(parent, args),
    m_dialog(0),
    m_font(QFont())
{
    m_theme.setImagePath("widgets/testtube"),
    m_engine = dataEngine("kalzium");

    m_dialog = 0;
    m_label1 = 0;
    m_lineedit = new Plasma::LineEdit(this);
    m_lineedit->setDefaultText(i18n("Enter the atomic number."));
    connect(m_lineedit, SIGNAL(editingFinished()),
            this, SLOT(textChanged()));

    setHasConfigurationInterface(true);
    setAcceptDrops(false);
    setAcceptsHoverEvents(true);
//     setDrawStandardBackground(false);

    resize(385,177);
}
예제 #17
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)));
}
예제 #18
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);
    }
}
예제 #19
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" ) );
        }
    }
}
예제 #20
0
void Clock::clockConfigAccepted()
{
    KConfigGroup cg = config();
    m_showTimezoneString = ui.showTimezoneStringCheckBox->isChecked();
    m_showingTimezone = m_showTimezoneString || shouldDisplayTimezone();
    m_showSecondHand = ui.showSecondHandCheckBox->isChecked();

    if (m_showSecondHand) {
        //We don't need to cache the applet if it update every seconds
        setCacheMode(QGraphicsItem::NoCache);
    } else {
        setCacheMode(QGraphicsItem::DeviceCoordinateCache);
    }

    cg.writeEntry("showSecondHand", m_showSecondHand);
    cg.writeEntry("showTimezoneString", m_showTimezoneString);
    update();

    dataEngine("time")->disconnectSource(currentTimezone(), this);
    connectToEngine();

    constraintsEvent(Plasma::AllConstraints);
    emit configNeedsSaving();
}
예제 #21
0
void GraphicalTimetableLine::init()
{
    if ( !m_svg.hasElement("background") ) {
        setFailedToLaunch( true, i18n("No 'background' element found in the SVG") );
    }

    m_zoomInButton = new Plasma::ToolButton( this );
    m_zoomOutButton = new Plasma::ToolButton( this );
    m_zoomInButton->setIcon( KIcon("zoom-in") );
    m_zoomOutButton->setIcon( KIcon("zoom-out") );
    m_zoomInButton->setZValue( 999999 );
    m_zoomOutButton->setZValue( 999999 );
    connect( m_zoomInButton, SIGNAL(clicked()), this, SLOT(zoomIn()) );
    connect( m_zoomOutButton, SIGNAL(clicked()), this, SLOT(zoomOut()) );

    m_title = new Plasma::Label( this );
    QFont font = Plasma::Theme::defaultTheme()->font( Plasma::Theme::DefaultFont );
    font.setPixelSize( 14 );
    font.setBold( true );
    m_title->setFont( font );
    m_title->setWordWrap( false );
    m_title->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
    m_title->setZValue( 999999 );

    m_courtesy = new Plasma::Label;
    m_courtesy->setAlignment( Qt::AlignVCenter | Qt::AlignRight );
    connect( m_courtesy, SIGNAL(linkActivated(QString)),
                KToolInvocation::self(), SLOT(invokeBrowser(QString)) );
    QLabel *labelInfo = m_courtesy->nativeWidget();
    labelInfo->setOpenExternalLinks( true );
    labelInfo->setWordWrap( true );
    m_courtesy->setText( courtesyText() );
    m_courtesy->setZValue( 999999 );

    m_departureView = new QGraphicsWidget( this );
    m_departureView->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
    m_departureView->translate( 0, -m_title->size().height() - 25 );

    QGraphicsGridLayout *l = new QGraphicsGridLayout( this );
    l->addItem( m_zoomInButton, 0, 0 );
    l->addItem( m_zoomOutButton, 0, 1 );
    l->addItem( m_title, 0, 2 );
    l->addItem( m_departureView, 1, 0, 1, 3 );
    l->addItem( m_courtesy, 2, 0, 1, 3 );

    m_stopSettings.set( ServiceProviderSetting,
                        config().readEntry(QLatin1String("serviceProvider"), QString()) );
    m_stopSettings.set( StopNameSetting,
                        config().readEntry(QLatin1String("stopName"), QString()) );

    m_timelineLength = config().readEntry( QLatin1String("timelineLength"), 10 );
    m_showTimetable = config().readEntry( QLatin1String("showTimetable"), true );
    m_drawTransportLine = config().readEntry( QLatin1String("drawTransportLine"), true );

    QVariantList vehicleTypes = config().readEntry( QLatin1String("vehicleTypes"), QVariantList() );
    if ( vehicleTypes.isEmpty() ) {
        m_vehicleTypes << UnknownVehicleType << Tram << Bus << TrolleyBus << InterurbanTrain
                << Subway << Metro << RegionalTrain << RegionalExpressTrain << InterregionalTrain
                << IntercityTrain << HighSpeedTrain << Ship << Plane << Feet;
    } else {
        foreach ( const QVariant &vehicleType, vehicleTypes ) {
            m_vehicleTypes << static_cast<VehicleType>( vehicleType.toInt() );
        }
    }

    if ( m_stopSettings.stopList().isEmpty() ) {
        setConfigurationRequired( true, i18n("Please select a stop name") );
    } else if ( m_stopSettings.get<QString>(ServiceProviderSetting).isEmpty() ) {
        setConfigurationRequired( true, i18n("Please select a service provider") );
    } else {
        setConfigurationRequired( false );
    }

    if ( !configurationRequired() ) {
        m_sourceName = QString("Departures %1|stop=%2|timeoffset=0")
                    .arg(m_stopSettings.get<QString>(ServiceProviderSetting))
                    .arg(m_stopSettings.stop(0).nameOrId());
        dataEngine("publictransport")->connectSource( m_sourceName,
                this, 60000, Plasma::AlignToMinute );
    }

    createTooltip();
}
예제 #22
0
파일: wicdapplet.cpp 프로젝트: KDE/wicd-kde
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);
}
예제 #23
0
void Clock::changeEngineTimezone(const QString &oldTimezone, const QString &newTimezone)
{
    resetLastTimeSeen();
    dataEngine("time")->disconnectSource(oldTimezone, this);
    dataEngine("time")->connectSource(newTimezone, this, updateInterval(), intervalAlignment());
}
예제 #24
0
void ActivityManager::stop(QString id) {
  // TODO: when activity is stopped, take a screenshot and use that icon
  Plasma::Service *service = dataEngine("org.kde.activities")->serviceForSource(id);
  Plasma::ServiceJob *job = service->startOperationCall(service->operationDescription("stop"));
  connect(job, SIGNAL(finished(KJob*)), service, SLOT(deleteLater()));
}
예제 #25
0
void ActivityManager::start(QString id) {
  Plasma::Service *service = dataEngine("org.kde.activities")->serviceForSource(id);
  Plasma::ServiceJob *job = service->startOperationCall(service->operationDescription("start"));
  connect(job, SIGNAL(finished(KJob*)), service, SLOT(deleteLater()));
}
예제 #26
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();
}
예제 #27
0
void
SimilarArtistsApplet::connectSource( const QString &source )
{
    if( source == QLatin1String("similarArtists") )
        dataEngine( "amarok-similarArtists" )->connectSource( source, this );
}
예제 #28
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" );
}
예제 #29
0
void HWInfo::setSources()
{
    m_cpus = engine()->query("IS Processor")["IS Processor"].toStringList();
    foreach (const QString& id, m_cpus) {
        appendSource(id);
    }
    m_networks = engine()->query("IS NetworkInterface")["IS NetworkInterface"].toStringList();
    foreach (const QString& id, m_networks) {
        appendSource(id);
    }
    m_audios = engine()->query("IS AudioInterface")["IS AudioInterface"].toStringList();
    foreach (const QString& id, m_audios) {
        appendSource(id);
    }
    // TODO: get this from soliddevice
    Plasma::DataEngine* engine = dataEngine("executable");
    QString path = QString::fromLocal8Bit(qgetenv("PATH"))
                 + QString::fromLatin1(":/usr/sbin:/sbin/");
    QString exe = KStandardDirs::findExe( "lspci", path );
    if (exe.isEmpty()) {
       kError()  << "lspci not found in " << path << endl;
    } else {
       QString tmp = exe + " | grep VGA | sed 's/.*: //g'";
       engine->connectSource(tmp, this);
    }
}

void HWInfo::dataUpdated(const QString& source,
                         const Plasma::DataEngine::Data &data)
{
    if (m_audios.contains(source) && !m_audioNames.contains(data["Name"].toString()) &&
예제 #30
0
void Luna::connectToEngine()
{
    Plasma::DataEngine* timeEngine = dataEngine("time");
    timeEngine->connectSource("UTC", this, 360000, Plasma::AlignToHour);
}