示例#1
0
void IconApplet::dropEvent(QGraphicsSceneDragDropEvent *event)
{
    if (!KUrl::List::canDecode(event->mimeData())) {
        return;
    }

    KUrl::List urls = KUrl::List::fromMimeData(event->mimeData());
    if (urls.isEmpty()) {
        return;
    }

    event->accept();

    if (m_url.isEmpty()) {
        setUrl(urls.first());
        //TODO: why we don't call updateConstraints()?
        constraintsEvent(Plasma::FormFactorConstraint);
        return;
    } else if (m_service) {
        KRun::run(*m_service, urls, 0);
        return;
    }

    KMimeType::Ptr mimetype = KMimeType::findByUrl(m_url);

    if (m_url.isLocalFile() &&
        ((mimetype && (mimetype->is("application/x-executable") ||
                       mimetype->is("application/x-shellscript"))) ||
          KDesktopFile::isDesktopFile(m_url.toLocalFile()))) {

        if (KDesktopFile::isDesktopFile(m_url.toLocalFile())) {
            //Extract the command from the Desktop file
            KService service(m_url.toLocalFile());
            KRun::run(service, urls, 0);
            return;
        }

        // Just exec the local executable
        QString params;
        foreach (const KUrl &url, urls) {
            if (url.isLocalFile()) {
                params += ' ' + KShell::quoteArg(url.toLocalFile());
            } else {
                params += ' ' + KShell::quoteArg(url.prettyUrl());
            }
        }

        QString commandStr = KShell::quoteArg(m_url.path());
        KRun::runCommand(commandStr + ' ' + params, 0);
    } else if (mimetype && mimetype->is("inode/directory")) {
示例#2
0
void SongkickApplet::init()
{
    // Call the base implementation.
    Context::Applet::init();

    QColor highlight = PaletteHandler::highlightColor().darker( 300 );

    m_titleLabel = new QGraphicsSimpleTextItem( i18n("Concerts"), this );
    QFont bigger = m_titleLabel->font();
    bigger.setPointSize( bigger.pointSize() + 2 );
    m_titleLabel->setFont( bigger );
    m_titleLabel->setZValue( m_titleLabel->zValue() + 100 );
    m_titleLabel->setDrawBackground( true );

    QAction* reloadAction = new QAction( i18n("Reload Songkick"), this );
    reloadAction->setIcon( KIcon( "view-refresh" ) );
    reloadAction->setVisible( true );
    reloadAction->setEnabled( true );
    m_reloadIcon = addAction( reloadAction );

    connect( m_reloadIcon, SIGNAL(clicked()), dataEngine( "amarok-songkick" ), SLOT(update()) );

    m_songkickProxy = new QGraphicsProxyWidget( this );
    m_songkick = new QTextBrowser;
    m_songkick->setAttribute( Qt::WA_NoSystemBackground );
    m_songkick->setReadOnly( true );
    m_songkick->setOpenExternalLinks( true );
    m_songkick->setTextInteractionFlags( Qt::TextBrowserInteraction | Qt::TextSelectableByKeyboard );
    m_songkickProxy->setWidget( m_songkick );
    QPalette pal;
    QBrush brush(  PaletteHandler::highlightColor().lighter( 170 ) );
    brush.setStyle( Qt::SolidPattern );
    pal.setBrush( QPalette::Active, QPalette::Base, brush );
    pal.setBrush( QPalette::Inactive, QPalette::Base, brush );
    pal.setBrush( QPalette::Disabled, QPalette::Base, brush );
    pal.setBrush( QPalette::Window, brush );
    m_songkick->setPalette( pal );
    m_songkickProxy->setPalette( pal );
    m_songkick->setStyleSheet( QString( "QTextBrowser { background-color: %1; border-width: 0px; border-radius: 0px; color: %2; }" )
                                    .arg( PaletteHandler::highlightColor().lighter( 150 ).name() )
                                    .arg( PaletteHandler::highlightColor().darker( 400 ).name() ) );

    connect( dataEngine( "amarok-songkick" ), SIGNAL(sourceAdded(QString)), this, SLOT(connectSource(QString)) );
    connect( The::paletteHandler(), SIGNAL(newPalette(QPalette)), SLOT(paletteChanged(QPalette)) );

    constraintsEvent();
    connectSource( "ontour" );
    connectSource( "dates" );
}
示例#3
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;
}
示例#4
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();
}
示例#5
0
void Clock::clockConfigAccepted()
{
    KConfigGroup cg = config();

    m_showTimezone = ui.showTimeZone->isChecked();
    cg.writeEntry("showTimezone", m_showTimezone);

    if (m_isDefaultFont && ui.plainClockFont->currentFont() != m_plainClockFont) {
        m_isDefaultFont = false;
    }
    m_plainClockFont = ui.plainClockFont->currentFont();

    //We need this to happen before we disconnect/reconnect sources to ensure
    //that the update interval is set properly.
    if (m_showSeconds != ui.secondsCheckbox->isChecked()) {
        m_showSeconds = !m_showSeconds;
        cg.writeEntry("showSeconds", m_showSeconds);

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

        changeEngineTimezone(currentTimezone(), currentTimezone());
    }

    m_dateStyle = ui.dateStyle->currentIndex();
    cg.writeEntry("dateStyle", m_dateStyle);

    m_showSeconds = ui.secondsCheckbox->checkState() == Qt::Checked;
    cg.writeEntry("showSeconds", m_showSeconds);

    m_useCustomColor = ui.useCustomColor->isChecked();
    cg.writeEntry("useCustomColor", m_useCustomColor);
    if (m_useCustomColor) {
        m_plainClockColor = ui.plainClockColor->color();
        cg.writeEntry("plainClockColor", m_plainClockColor);
        m_pixmap = QPixmap();
        delete m_svg;
        m_svg = 0;
    } else {
        m_plainClockColor = Plasma::Theme::defaultTheme()->color(Plasma::Theme::TextColor);
    }

    m_useCustomShadowColor = ui.useCustomShadowColor->isChecked();
    cg.writeEntry("useCustomShadowColor", m_useCustomShadowColor);
    if (m_useCustomShadowColor) {
        m_plainClockShadowColor = ui.plainClockShadowColor->color();
        cg.writeEntry("plainClockShadowColor", m_plainClockShadowColor);
    } else {
        m_plainClockShadowColor = Plasma::Theme::defaultTheme()->color(Plasma::Theme::BackgroundColor);
    }
    m_drawShadow = ui.drawShadow->isChecked();
    cg.writeEntry("plainClockDrawShadow", m_drawShadow);

    m_plainClockFont.setBold(ui.plainClockFontBold->checkState() == Qt::Checked);
    m_plainClockFont.setItalic(ui.plainClockFontItalic->checkState() == Qt::Checked);
    cg.writeEntry("plainClockFont", m_plainClockFont);

    constraintsEvent(Plasma::SizeConstraint);
    generatePixmap();
    update();
    emit sizeHintChanged(Qt::PreferredSize);
    emit configNeedsSaving();
}
示例#6
0
void Clock::resetSize()
{
    // Called when the size of the applet may change externally, such as on
    // font size changes
    constraintsEvent(Plasma::SizeConstraint);
}
示例#7
0
void DateTimeGroup::configAccepted()
{
	bool m_formatChanged;
	KConfigGroup cg = config();
	
	if (m_isDefaultFont && ui.plainDateTimeGroupFont->currentFont() != m_plainDateTimeGroupFont) {
		m_isDefaultFont = false;
	}
	
	m_plainDateTimeGroupFont = ui.plainDateTimeGroupFont->currentFont();
	
	if(m_sAfterDay!=ui.sAfterDay->isChecked()){
		m_sAfterDay = !m_sAfterDay;
		cg.writeEntry("sAfterDay", m_sAfterDay);
		m_formatChanged=true;
	}
	if(m_sAfterHour!=ui.sAfterHour->isChecked()){
		m_sAfterHour = !m_sAfterHour;
		cg.writeEntry("sAfterHour", m_sAfterHour);
		m_formatChanged=true;
	}
	
	if(m_sAfterMinute!=ui.sAfterMinute->isChecked()){
		m_sAfterMinute =!m_sAfterMinute;
		cg.writeEntry("sAfterMinute", m_sAfterMinute);	
		m_formatChanged=true;
	}
	
	if(m_sAfterSecond!=ui.sAfterSecond->isChecked()){
		m_sAfterSecond =!m_sAfterSecond;
		cg.writeEntry("sAfterSecond", m_sAfterSecond);
		m_formatChanged=true;
	}
	
	if(m_sAfterTimeZone!=ui.sAfterTimeZone->isChecked()){
		m_sAfterTimeZone = !m_sAfterTimeZone;
		cg.writeEntry("sAfterTimeZone", m_sAfterTimeZone);
		m_formatChanged=true;
	}
	
	if(m_sAfterMonth!=ui.sAfterMonth->isChecked()){
		m_sAfterMonth = !m_sAfterMonth;
		cg.writeEntry("sAfterMonth", m_sAfterMonth);
		m_formatChanged=true;
	}
	if(m_rounded!=timezonesUi.fullLetters->isChecked()){
		m_rounded = !m_rounded;
		cg.writeEntry("rounded", m_rounded);
		m_formatChanged=true;
	}
	
	if(m_natoOperation!= ui.natoOperation->isChecked()){
		m_natoOperation=!m_natoOperation;
		cg.writeEntry("natoOperation", m_natoOperation);
		tzBefNatoOp=cg.readEntry("currentTimezone");
		changeEngineTimezone( (m_natoOperation?"UTC":tzBefNatoOp)); 
	}

	if(m_local!= ui.localTime->isChecked()){
		m_local=!m_local;
		cg.writeEntry("localTime", m_local);
		tzBefNatoOp=m_natoOperation?"UTC":cg.readEntry("currentTimezone");
		changeEngineTimezone( (m_local?"Local":tzBefNatoOp)); 
	}
	if (timezonesUi.timeZones->selection()!=curtz && !m_local && !m_natoOperation) {
		changeEngineTimezone(timezonesUi.timeZones->selection());
		cg.writeEntry("currentTimezone", timezonesUi.timeZones->selection());
	}
	if(ui.shortFormat->isChecked()&&m_format!=1){
		int oldm_format=m_format;
		m_format=1;
		m_formatChanged=false;
		if(oldm_format==0)
			setDtg(dataEngine("datetimegroup")->query(currentTimezone()));
	}
	else if(ui.longFormat->isChecked()&&m_format!=2){
		m_format=2;
	}
	else if(ui.stanFormat->isChecked()&&m_format!=0){
		int oldm_format=m_format;
		m_format=0;
		m_formatChanged=false;
		if(oldm_format==1)
			setDtg(dataEngine("datetimegroup")->query(currentTimezone()));
	}
	
	cg.writeEntry("format",m_format);
	if (m_showSeconds != (m_format==2)) {
		m_showSeconds = !m_showSeconds;
		
		if (m_showSeconds) {
			//We don't need to cache the applet if it update every second
			setCacheMode(QGraphicsItem::NoCache);
		} else {
			setCacheMode(QGraphicsItem::DeviceCoordinateCache);
		}
		
		changeEngineTimezone(currentTimezone());
	}
	if(m_formatChanged)
		setDtg(dataEngine("datetimegroup")->query(currentTimezone()));
		
	m_useCustomColor = ui.useCustomColor->isChecked();
	cg.writeEntry("useCustomColor", m_useCustomColor);
	if (m_useCustomColor) {
		m_plainDateTimeGroupColor = ui.plainDateTimeGroupColor->color();
		cg.writeEntry("plainDateTimeGroupColor", m_plainDateTimeGroupColor);
		m_pixmap = QPixmap();
		delete m_svg;
		m_svg = 0;
	} else {
		m_plainDateTimeGroupColor = Plasma::Theme::defaultTheme()->color(Plasma::Theme::TextColor);
	}
	
	m_useCustomShadowColor = ui.useCustomShadowColor->isChecked();
	cg.writeEntry("useCustomShadowColor", m_useCustomShadowColor);
	if (m_useCustomShadowColor) {
		m_plainDateTimeGroupShadowColor = ui.plainDateTimeGroupShadowColor->color();
		cg.writeEntry("plainDateTimeGroupShadowColor", m_plainDateTimeGroupShadowColor);
	} else {
		m_plainDateTimeGroupShadowColor = Plasma::Theme::defaultTheme()->color(Plasma::Theme::BackgroundColor);
	}
	m_drawShadow = ui.drawShadow->isChecked();
	cg.writeEntry("plainDateTimeGroupDrawShadow", m_drawShadow);
	
	m_plainDateTimeGroupFont.setBold(ui.plainDateTimeGroupFontBold->checkState() == Qt::Checked);
	m_plainDateTimeGroupFont.setItalic(ui.plainDateTimeGroupFontItalic->checkState() == Qt::Checked);
	cg.writeEntry("plainDateTimeGroupFont", m_plainDateTimeGroupFont);
	
	constraintsEvent(Plasma::SizeConstraint);
	generatePixmap();
	update();
	
	emit sizeHintChanged(Qt::PreferredSize);
	emit configNeedsSaving();
}
示例#8
0
void DateTimeGroup::resetSize()
{
	constraintsEvent(Plasma::SizeConstraint);
}