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); } }
void DateTimeGroup::changeEngineTimezone(const QString &newTimezone) { resetLastTimeSeen(); dataEngine("datetimegroup")->disconnectSource(currentTimezone(), this); dataEngine("datetimegroup")->connectSource(newTimezone, this, updateInterval(), intervalAlignment()); curtz=newTimezone; }
void Clock::init() { ClockApplet::init(); dataEngine("time")->connectSource(currentTimezone(), this, updateInterval(), intervalAlignment()); connect(Plasma::Theme::defaultTheme(), SIGNAL(themeChanged()), this, SLOT(updateColors())); connect(KGlobalSettings::self(), SIGNAL(appearanceChanged()), SLOT(resetSize())); connect(KGlobalSettings::self(), SIGNAL(settingsChanged(int)), SLOT(updateClock(int))); }
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(); }
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(); }
void Clock::init() { ClockApplet::init(); m_oldTimezone = currentTimezone(); configChanged(); }
DateTimeInfo::DateTimeInfo() { cDate = currentDate(); cTime = currentTime(); cTimezone = currentTimezone(); }
void DateTimeGroup::init(){ configChanged(); dataEngine("datetimegroup")->connectSource(currentTimezone(), this, updateInterval(), intervalAlignment() ); connect(Plasma::Theme::defaultTheme(), SIGNAL(themeChanged()), this, SLOT(updateColors())); connect(KGlobalSettings::self(), SIGNAL(appearanceChanged()), SLOT(resetSize())); }
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(); }