Esempio n. 1
0
KeyboardApplet::KeyboardApplet(QObject *parent, const QVariantList &args):
    Plasma::Applet(parent, args),
    xEventNotifier(),
    rules(Rules::readRules(Rules::READ_EXTRAS)),
    keyboardConfig(new KeyboardConfig()),
    layoutsMenu(new LayoutsMenu(*keyboardConfig, *rules, flags))
{
    if( ! X11Helper::xkbSupported(NULL) ) {
        setFailedToLaunch(true, i18n("XKB extension failed to initialize"));
        return;
    }

    m_svg = new Plasma::Svg(this);
    m_svg->setImagePath("widgets/labeltexture");
    m_svg->setContainsMultipleImages(true);
    resize(48,48);

    setHasConfigurationInterface(false);

    setAspectRatioMode(Plasma::KeepAspectRatio);
    //setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum));
    setBackgroundHints(DefaultBackground);
    connect(Plasma::Theme::defaultTheme(), SIGNAL(themeChanged()), this, SLOT(themeChanged()));

    QDBusConnection dbus = QDBusConnection::sessionBus();
    dbus.connect(QString(), KEYBOARD_DBUS_OBJECT_PATH, KEYBOARD_DBUS_SERVICE_NAME, KEYBOARD_DBUS_CONFIG_RELOAD_MESSAGE, this, SLOT(configChanged()));
}
Esempio n. 2
0
void
Bubble::init()
{
    m_svg->resize(geometry().width(), geometry().height());

    m_sensorModel = new QStandardItemModel(this);

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

    m_animator = new QTimer(this);
    m_animator->setInterval(75);
    connect(m_animator, SIGNAL(timeout()), this, SLOT(moveBubbles()));

    m_interpolator = new QTimeLine(m_speed, this);
    connect(m_interpolator, SIGNAL(frameChanged(int)), this, SLOT(interpolateValue()));

    m_engine = dataEngine("systemmonitor");
    if (!m_engine->isValid()) {
        setFailedToLaunch(true,
                           i18nc("@info:status The system monitor data engine could not be found or loaded",
                                  "Could not load the System Monitor data engine."));
    } else {
        connect(m_engine, SIGNAL(sourceAdded(QString)), this, SLOT(connectSensor()));
    }

    configChanged();

    m_bubbleRect = m_svg->elementSize("bubble");
}
Esempio n. 3
0
void Simonoid::init() {
  kDebug() << "Restoring";
  KConfigGroup lconfig = config();
  m_layouttype = ( LayoutType ) lconfig.readEntry ( "LayoutType", ( int ) LayoutTiny);
  m_interval = lconfig.readEntry ( "RefreshInterval", 3 );

  kDebug() << "Restored to: " << m_layouttype << m_interval;
  
  kDebug() << "Init called";
  Plasma::Applet::init();

  if ( m_icon.isNull() ) {
    setFailedToLaunch ( true, i18n ( "Could not load Simon icon." ) );
    exit ( -1 );
  }

  m_meter = new Plasma::Meter;
  m_meter->setVisible ( true );
  m_meter->setMeterType ( Plasma::Meter::BarMeterHorizontal );
//   m_meter->setMaximumWidth ( 32 );
//   m_meter->setSizePolicy ( QSizePolicy::Maximum, QSizePolicy::Expanding );
  m_meter->setMaximum ( 100 );
  m_meter->setValue ( 0 );

  m_lb_status = new Plasma::Label;
  m_lb_status->setText ( i18n ( "Status:" ) );
  m_lb_status_value = new Plasma::Label;
  m_lb_status_value->setText ( "1" );

  m_lb_peak = new Plasma::Label;
  m_lb_peak->setText ( i18n ( "Peak:" ) );
  m_lb_peak_value = new Plasma::Label;
  m_lb_peak_value->setText ( "2" );

  m_simonicon = new Plasma::IconWidget();
//   m_simonicon->setSizePolicy ( QSizePolicy::Expanding, QSizePolicy::Maximum );
  m_simonicon->setIcon ( m_icon );
  m_simonicon->setOrientation ( Qt::Vertical );
  m_simonicon->setDrawBackground ( true );
  //m_simonicon->setMaximumHeight(36);
  m_simonicon->setAcceptDrops ( false );
  

  initLayout ( m_layouttype );
  m_interval = m_interval;

  connect ( &m_checkConnectionTimer, SIGNAL (timeout()), this, SLOT (checkConnection()) );
  m_checkConnectionTimer.start ( 1000*m_interval );

  checkConnection();
  update();
}
Esempio n. 4
0
void Luna::init()
{
    configChanged();
    m_theme = new Plasma::Svg(this);
    m_theme->setImagePath("widgets/luna");
    m_theme->setContainsMultipleImages(true);

    if (!m_theme->isValid()) {
        setFailedToLaunch(true, i18n("The luna SVG file was not found"));
        return;
    }

    Plasma::ToolTipManager::self()->registerWidget(this);

    connectToEngine();
}
void ponycountdownplasma::prepare()
{
    //Parsing JSON
    QJson::Parser parser;
    bool ok;
    m_info = parser.parse(m_dl.downloadedData().toUtf8(), &ok).toMap();
    
    if(!ok)
    {
      setFailedToLaunch(true, i18n("A problem with JSON, try to restart or check your network settings"));
    }
    m_datetime = KSystemTimeZones::local().toZoneTime(m_datetime.fromString(info("time"), Qt::ISODate));
    
    m_tonewep.setFromMSecs(m_datetime.toMSecsSinceEpoch() - QDateTime::currentDateTime().toMSecsSinceEpoch());
    
    update(); 
}
Esempio n. 6
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);
}
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();
}
Esempio n. 8
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);
}