2
/***************************************************************************
3
* Copyright (C) 2007-2008 by Riccardo Iaconelli <riccardo@kde.org> *
4
* Copyright (C) 2007-2008 by Sebastian Kuegler <sebas@kde.org> *
6
* This program is free software; you can redistribute it and/or modify *
7
* it under the terms of the GNU General Public License as published by *
8
* the Free Software Foundation; either version 2 of the License, or *
9
* (at your option) any later version. *
11
* This program is distributed in the hope that it will be useful, *
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14
* GNU General Public License for more details. *
16
* You should have received a copy of the GNU General Public License *
17
* along with this program; if not, write to the *
18
* Free Software Foundation, Inc., *
19
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
20
***************************************************************************/
23
class ClockApplet < Plasma::Applet
24
attr_accessor :currentTimezone
26
slots :configAccepted,
27
'showCalendar(QGraphicsSceneMouseEvent *)',
28
'currentTimezone=(QString)'
30
def initialize(parent, args)
33
@currentTimezone = "Local"
35
@calendarUi = Ui::Calendar.new
36
@timezonesUi = Ui::TimezonesConfig.new
37
@clicked = Qt::Point.new
41
def updateToolTipContent()
44
def createConfigurationInterface(parent)
45
createClockConfigurationInterface(parent)
47
widget = Qt::Widget.new
48
@timezonesUi.setupUi(widget)
50
parent.addPage(widget, KDE.i18n("Time Zones"), icon())
52
@timezonesUi.localTimeZone.checked = localTimezone?
53
@timezonesUi.timeZones.setSelected(@currentTimezone, true)
54
@timezonesUi.timeZones.enabled = !localTimezone?
56
parent.buttons = KDE::Dialog::Ok | KDE::Dialog::Cancel | KDE::Dialog::Apply
57
connect(parent, SIGNAL(:applyClicked), self, SLOT(:configAccepted))
58
connect(parent, SIGNAL(:okClicked), self, SLOT(:configAccepted))
61
def createClockConfigurationInterface(parent)
64
def clockConfigAccepted()
70
@timeZones = @timezonesUi.timeZones.selection()
71
cg.writeEntry("timeZones", @timeZones)
73
newTimezone = localTimezone()
75
if !@timezonesUi.localTimeZone.checked? && !@timeZones.empty?
76
newTimezone = @timeZones[0]
79
changeEngineTimezone(@currentTimezone, newTimezone)
81
@currentTimezone = newTimezone
82
cg.writeEntry("currentTimezone", newTimezone)
86
constraintsEvent(Plasma::SizeConstraint)
88
emit configNeedsSaving
91
def changeEngineTimezone(oldTimezone, newTimezone)
94
def mousePressEvent(event)
95
if event.buttons == Qt::LeftButton
96
@clicked = scenePos.toPoint
104
def mouseReleaseEvent(event)
105
if (@clicked - scenePos.toPoint).manhattanLength <
106
KDE::GlobalSettings.dndEventDelay()
111
def showCalendar(event)
113
@calendar = Plasma::Dialog.new
114
@calendarUi.setupUi(@calendar)
115
@calendar.setWindowFlags(Qt::Popup)
119
if @calendar.visible?
122
data = dataEngine("time").query(@currentTimezone)
123
@calendarUi.kdatepicker.date = data["Date"].toDate
124
@calendar.move(popupPosition(@calendar.sizeHint))
130
return @currentTimezone == localTimezone()