61
61
m_theme->setContentType(Plasma::Svg::SingleImage);
62
62
m_theme->resize(m_pixelSize, m_pixelSize);
65
setCachePaintMode(NoCacheMode);
68
void Clock::connectToEngine()
64
70
Plasma::DataEngine* timeEngine = dataEngine("time");
65
timeEngine->connectSource(m_timezone, this);
66
timeEngine->setProperty("reportSeconds", m_showSecondHand);
67
updated(m_timezone, timeEngine->query(m_timezone));
71
if (m_showSecondHand) {
72
timeEngine->connectSource(m_timezone, this, 500);
74
timeEngine->connectSource(m_timezone, this, 6000, Plasma::AlignToMinute);
71
QSizeF Clock::contentSize() const
78
QSizeF Clock::contentSizeHint() const
76
void Clock::constraintsUpdated()
83
void Clock::constraintsUpdated(Plasma::Constraints constraints)
78
prepareGeometryChange();
79
if (formFactor() == Plasma::Planar ||
80
formFactor() == Plasma::MediaCenter) {
81
m_size = m_theme->size();
83
QFontMetrics fm(QApplication::font());
84
m_size = QSizeF(fm.width("00:00:00") * 1.2, fm.height() * 1.5);
85
if (constraints & Plasma::FormFactorConstraint) {
86
prepareGeometryChange();
87
if (formFactor() == Plasma::Planar ||
88
formFactor() == Plasma::MediaCenter) {
89
m_size = m_theme->size();
91
QFontMetrics fm(QApplication::font());
92
m_size = QSizeF(fm.width("00:00:00") * 1.2, fm.height() * 1.5);
132
140
void Clock::configAccepted()
134
142
KConfigGroup cg = config();
135
m_showTimeString = ui.showTimeStringCheckBox->checkState() == Qt::Checked;
136
m_showSecondHand = ui.showSecondHandCheckBox->checkState() == Qt::Checked;
143
m_showTimeString = ui.showTimeStringCheckBox->isChecked();
144
m_showSecondHand = ui.showSecondHandCheckBox->isChecked();
137
146
cg.writeEntry("showTimeString", m_showTimeString);
138
147
cg.writeEntry("showSecondHand", m_showSecondHand);
139
dataEngine("time")->setProperty("reportSeconds", m_showSecondHand);
140
QGraphicsItem::update();
141
149
cg.writeEntry("size", ui.spinSize->value());
142
150
m_size = QSize(ui.spinSize->value(), ui.spinSize->value());
143
151
m_theme->resize(m_size);
144
152
QStringList tzs = ui.timeZones->selection();
146
154
if (tzs.count() > 0) {
147
155
//TODO: support multiple timezones
148
156
QString tz = tzs.at(0);
149
157
if (tz != m_timezone) {
150
158
dataEngine("time")->disconnectSource(m_timezone, this);
152
dataEngine("time")->connectSource(m_timezone, this);
154
161
} else if (m_timezone != "Local") {
155
162
dataEngine("time")->disconnectSource(m_timezone, this);
156
163
m_timezone = "Local";
157
dataEngine("time")->connectSource(m_timezone, this);
161
dataEngine("time")->connectSource(m_timezone, this);
162
constraintsUpdated();
167
constraintsUpdated(Plasma::AllConstraints);
229
235
m_theme->paint(p, tempRect, "HourHand");
232
// drawHand(p, hours, "SecondHand", 1);
234
239
p->translate(boundSize.width()/2, boundSize.height()/2);
235
240
p->rotate(minutes);