57 /*! |
58 /*! |
58 Sets the clock type; |
59 Sets the clock type; |
59 */ |
60 */ |
60 void ClockWidget::setClockType(const ClockType &type) |
61 void ClockWidget::setClockType(const ClockType &type) |
61 { |
62 { |
62 if (type == ClockTypeDigital) { |
63 if (type == ClockTypeAnalog) { |
63 mClockType = ClockTypeDigital; |
64 if(type != mClockType){ |
|
65 mClockType = ClockTypeAnalog; |
|
66 updateClockWidget(); |
|
67 } |
64 } else { |
68 } else { |
65 mClockType = ClockTypeAnalog; |
69 if(type != mClockType){ |
|
70 mClockType = ClockTypeDigital; |
|
71 updateClockWidget(); |
|
72 } |
66 } |
73 } |
67 } |
74 } |
68 |
75 |
69 /*! |
76 /*! |
70 Updates the clock time with every second |
77 Updates the clock time with every second |
71 */ |
78 */ |
72 void ClockWidget::updateTime() |
79 void ClockWidget::updateTime() |
73 { |
80 { |
74 if (mClockType == ClockTypeAnalog) { |
81 if (mClockType == ClockTypeAnalog) { |
75 mAnalogClock->tick(); |
82 mAnalogClock->tick(); |
|
83 } else { |
|
84 mDigitalClock->updatePrimitives(); |
76 } |
85 } |
77 } |
86 } |
78 |
87 |
79 /*! |
88 /*! |
80 Constructs the clockwidget based upon its type. |
89 Constructs the clockwidget based upon its type. |
81 */ |
90 */ |
82 void ClockWidget::loadClockWidget() |
91 void ClockWidget::loadClockWidget() |
83 { |
92 { |
|
93 mLayout = new QGraphicsLinearLayout(Qt::Vertical); |
|
94 mLayout->setContentsMargins(0,0,0,0); |
|
95 |
84 if (mClockType == ClockTypeAnalog) { |
96 if (mClockType == ClockTypeAnalog) { |
85 mAnalogClock = new AnalogClockWidget(this); |
97 mAnalogClock = new AnalogClockWidget(this); |
86 mLayout = new QGraphicsLinearLayout(Qt::Vertical); |
98 mLayout->addItem(mAnalogClock); |
87 mLayout->setContentsMargins(0,0,0,0); |
99 } else { |
|
100 bool useAmPm = false; |
|
101 mDigitalClock = new DigitalClockWidget(useAmPm, this); |
|
102 mLayout->addItem(mDigitalClock); |
|
103 } |
|
104 setLayout(mLayout); |
|
105 } |
|
106 |
|
107 /*! |
|
108 Constructs the clockwidget based upon its type. |
|
109 */ |
|
110 void ClockWidget::updateClockWidget() |
|
111 { |
|
112 if (mClockType == ClockTypeAnalog) { |
|
113 mLayout->removeItem(mDigitalClock); |
|
114 delete mDigitalClock; |
|
115 if (!mAnalogClock) { |
|
116 mAnalogClock = new AnalogClockWidget(this); |
|
117 } |
88 mLayout->addItem(mAnalogClock); |
118 mLayout->addItem(mAnalogClock); |
89 setLayout(mLayout); |
119 } else { |
|
120 mLayout->removeItem(mAnalogClock); |
|
121 delete mAnalogClock; |
|
122 if(!mDigitalClock){ |
|
123 bool useAmPm = false; // find out this fronm the settings utility |
|
124 mDigitalClock = new DigitalClockWidget(useAmPm, this); |
|
125 } |
|
126 mLayout->addItem(mDigitalClock); |
|
127 } |
|
128 } |
|
129 |
|
130 ClockWidget::TimeFormat ClockWidget::timeFormat() const |
|
131 { |
|
132 return mTimeFormat; |
|
133 } |
|
134 |
|
135 void ClockWidget::setTimeFormat(const TimeFormat &timeFormat) |
|
136 { |
|
137 if(mDigitalClock){ |
|
138 mTimeFormat = timeFormat; |
|
139 if (timeFormat == ClockWidget::TimeFormat12Hrs) { |
|
140 mDigitalClock->setAmPm(true); |
|
141 } else { |
|
142 mDigitalClock->setAmPm(false); |
|
143 } |
90 } |
144 } |
91 } |
145 } |
92 |
|
93 // End of file --Don't remove this. |
146 // End of file --Don't remove this. |