Exemple #1
0
void Clock::clockConfigChanged()
{
    KConfigGroup cg = config();
    m_showTimezone = cg.readEntry("showTimezone", !isLocalTimezone());

    kDebug() << "showTimezone:" << m_showTimezone;

    if (cg.hasKey("showDate")) {    //legacy config entry as of 2011-1-4
        m_dateStyle = cg.readEntry("showDate", false) ? 2 : 0; //short date : no date
        cg.deleteEntry("showDate");
    }
    else {
        m_dateStyle = cg.readEntry("dateStyle", 0);
    }

    if (cg.hasKey("showYear")) {   //legacy config entry as of 2011-1-4
        if( m_dateStyle ) {
            m_dateStyle = cg.readEntry("showYear", false) ? 2 : 1; //short date : compact date
        }
        cg.deleteEntry("showYear");
    }

    m_showSeconds = cg.readEntry("showSeconds", false);
    if (m_showSeconds) {
        //We don't need to cache the applet if it update every seconds
        setCacheMode(QGraphicsItem::NoCache);
    } else {
        setCacheMode(QGraphicsItem::DeviceCoordinateCache);
    }

    QFont f = cg.readEntry("plainClockFont", m_plainClockFont);
    m_isDefaultFont = f == m_plainClockFont;
    m_plainClockFont = f;

    m_useCustomColor = cg.readEntry("useCustomColor", m_useCustomColor);
    m_plainClockColor = cg.readEntry("plainClockColor", m_plainClockColor);
    m_useCustomShadowColor = cg.readEntry("useCustomShadowColor", m_useCustomShadowColor);
    m_plainClockShadowColor = cg.readEntry("plainClockShadowColor", m_plainClockShadowColor);
    m_drawShadow = cg.readEntry("plainClockDrawShadow", m_drawShadow);

    updateColors();

    if (m_useCustomColor) {
        m_pixmap = QPixmap();
        delete m_svg;
        m_svg = 0;
    }

    const QFontMetricsF metrics(KGlobalSettings::smallestReadableFont());
    const QString timeString = KGlobal::locale()->formatTime(QTime(23, 59), m_showSeconds);
    setMinimumSize(metrics.size(Qt::TextSingleLine, timeString));

    if (isUserConfiguring()) {
        updateSize();
    }
}
void DateTimeGroup::configChanged()
{
	
	KConfigGroup cg = config();

	if (isUserConfiguring()) {
		configAccepted();
	}
	m_natoOperation = cg.readEntry("natoOperation", m_natoOperation);
	m_local= cg.readEntry("localTime", m_local);

	QFont f = cg.readEntry("plainDateTimeGroupFont", m_plainDateTimeGroupFont);
	m_isDefaultFont = f == m_plainDateTimeGroupFont;
	m_plainDateTimeGroupFont = f;
	
	m_useCustomColor = cg.readEntry("useCustomColor", m_useCustomColor);
	m_plainDateTimeGroupColor = cg.readEntry("plainDateTimeGroupColor", m_plainDateTimeGroupColor);
	m_useCustomShadowColor = cg.readEntry("useCustomShadowColor", m_useCustomShadowColor);
	m_plainDateTimeGroupShadowColor = cg.readEntry("plainDateTimeGroupShadowColor", m_plainDateTimeGroupShadowColor);
	
	m_drawShadow = cg.readEntry("plainDateTimeGroupDrawShadow", m_drawShadow);
	m_rounded=cg.readEntry("rounded",m_rounded);
	m_format=cg.readEntry("format",m_format);
	
	m_showSeconds=m_format==2;
	if (m_showSeconds) {
		//We don't need to cache the applet if it update every seconds
		setCacheMode(QGraphicsItem::NoCache);
	} else {
		setCacheMode(QGraphicsItem::DeviceCoordinateCache);
	}
	
	m_sAfterDay =cg.readEntry("sAfterDay", m_sAfterDay);
	m_sAfterHour = cg.readEntry("sAfterHour", m_sAfterHour);
	m_sAfterMinute = cg.readEntry("sAfterMinute", m_sAfterMinute);
	
	m_sAfterSecond = cg.readEntry("sAfterSecond", m_sAfterSecond);
	m_sAfterTimeZone = cg.readEntry("sAfterTimeZone", m_sAfterTimeZone);
	m_sAfterMonth = cg.readEntry("sAfterMonth", m_sAfterMonth);
	
	updateColors();
	
	if (m_useCustomColor) {
		m_pixmap = QPixmap();
		delete m_svg;
		m_svg = 0;
	}
	
	const QFontMetricsF metrics(KGlobalSettings::smallestReadableFont());
	setMinimumSize(metrics.size(Qt::TextSingleLine, dtg));
	updateSize();
}