123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241 |
- /**
- * Copyright © 2010 Digia Plc
- * Copyright © 2010 Nokia Corporation
- *
- * All rights reserved.
- *
- * Nokia and Nokia Connecting People are registered trademarks of
- * Nokia Corporation.
- * Java and all Java-based marks are trademarks or registered
- * trademarks of
- * Sun Microsystems, Inc. Other product and company names
- * mentioned herein may be
- * trademarks or trade names of their respective owners.
- *
- *
- * Subject to the conditions below, you may, without charge:
- *
- * · Use, copy, modify and/or merge copies of this software and
- * associated documentation files (the "Software")
- *
- * · Publish, distribute, sub-licence and/or sell new software
- * derived from or incorporating the Software.
- *
- *
- * This file, unmodified, shall be included with all copies or
- * substantial portions
- * of the Software that are distributed in source code form.
- *
- * The Software cannot constitute the primary value of any new
- * software derived
- * from or incorporating the Software.
- *
- * Any person dealing with the Software shall not misrepresent
- * the source of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
- * KIND, EXPRESS OR IMPLIED,
- * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A
- * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT
- * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- * WHETHER IN AN ACTION
- * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
- import Qt 4.7
- import "../colibri/javascripts/functions.js" as Functions
- import "javascript/timer.js" as ClockTimer
- import "../colibri"
- Rectangle {
- id: structure;
- property CLStyle style : CLStyle{}
- property real roundness : style.roundness
- property alias hours : textHours.text
- property alias minutes : textMinutes.text
- property int fontSize : 25
- property string selected: "hours"
- property color textColorSelected: "red"
- property color textColor: style.textColor
- property bool pastClockTimesDisabled: false;
- property bool isCurrentDate: true;
- property int minuteInterval: 5
- function addMinute() {
- minutes = ClockTimer.formatTwoDigits(ClockTimer.parseIntClever(minutes) + minuteInterval);
- if (minutes > 59) minutes = "00"
- if (isCurrentDate && getCurrentHour() >= ClockTimer.parseIntClever(hours)
- && getCurrentMinute() > ClockTimer.parseIntClever(minutes) )
- minutes = ClockTimer.formatTwoDigits( getCurrentMinute() );
- }
- /**
- *
- */
- function decreaseMinute() {
- minutes = ClockTimer.formatTwoDigits(ClockTimer.parseIntClever(minutes) - minuteInterval);
- if (minutes == "0-5" || ClockTimer.parseIntClever(minutes) < 0 ||
- isCurrentDate && ( isCurrentDate && getCurrentHour() >= ClockTimer.parseIntClever(hours)
- && ClockTimer.parseIntClever(minutes) < getCurrentMinute() )) {
- var tempMin = (60 - minuteInterval);
- minutes = ClockTimer.formatTwoDigits( tempMin );
- }
- if (isCurrentDate && getCurrentHour() >= ClockTimer.parseIntClever(hours)
- && getCurrentMinute() > ClockTimer.parseIntClever(minutes) )
- minutes = ClockTimer.formatTwoDigits( getCurrentMinute() );
- }
- function addHour() {
- if (hours == 23) hours = "00"
- else hours = ClockTimer.formatTwoDigits(ClockTimer.parseIntClever(hours) + 1);
- if (isCurrentDate && getCurrentHour() > ClockTimer.parseIntClever(hours) ) hours = ClockTimer.formatTwoDigits( getCurrentHour() );
- if (isCurrentDate && getCurrentHour() >= ClockTimer.parseIntClever(hours) && getCurrentMinute() > ClockTimer.parseIntClever(minutes) ) minutes = ClockTimer.formatTwoDigits( getCurrentMinute() );
- if (minutes == "60" ) {
- minutes = "00";
- addHour();
- }
- }
- function decreaseHour() {
- if (hours == 0 || ( isCurrentDate && ClockTimer.parseIntClever(hours) == getCurrentHour() )) hours = "23"
- else hours = ClockTimer.formatTwoDigits(ClockTimer.parseIntClever(hours) - 1);
- if (isCurrentDate && getCurrentHour() > ClockTimer.parseIntClever(hours) )
- hours = ClockTimer.formatTwoDigits( getCurrentHour() );
- if (isCurrentDate && getCurrentHour() >= ClockTimer.parseIntClever(hours)
- && getCurrentMinute() > ClockTimer.parseIntClever(minutes) )
- minutes = ClockTimer.formatTwoDigits( getCurrentMinute() );
- if (minutes == "60" ) {
- minutes = "00";
- addHour();
- }
- }
- function getCurrentHour() {
- var today = new Date();
- return today.getHours();
- }
- function getCurrentMinute() {
- var today = new Date();
- var theMinutes = today.getMinutes();
- theMinutes = ( (theMinutes % structure.minuteInterval) == 0 ) ? theMinutes : ((Math.floor(theMinutes/structure.minuteInterval)*structure.minuteInterval)+structure.minuteInterval);
- if (theMinutes<10) return "0"+theMinutes
- return theMinutes;
- }
- function checkTheTime() {
- if (getCurrentHour() >= ClockTimer.parseIntClever(hours) && getCurrentMinute() > ClockTimer.parseIntClever(minutes) ) minutes = ClockTimer.formatTwoDigits( getCurrentMinute() );
- if (getCurrentHour() > ClockTimer.parseIntClever(hours) ) hours = ClockTimer.formatTwoDigits( getCurrentHour() );
- if (minutes == "60" ) {
- minutes = "00";
- addHour();
- }
- }
- onMinuteIntervalChanged: {
- if (minuteInterval < 1 || minuteInterval > 30 ) minuteInterval = 1;
- if (((60/minuteInterval)%1) != 0 ) minuteInterval = 1;
- }
- width: 120
- height: 70
- radius: Functions.countRadius(roundness,width,height,0,1);
- smooth: true
- Timer {
- id: checkPastTime
- running: isCurrentDate
- interval: 500
- triggeredOnStart: isCurrentDate
- onTriggered: checkTheTime()
- repeat: true
- }
- Row {
- anchors.verticalCenter: parent.verticalCenter
- Text {
- id: textHours
- text: getCurrentHour()
- font.pointSize: 0.001 + fontSize
- color: textColorSelected
- width: structure.width*0.3
- anchors.verticalCenter: parent.verticalCenter
- MouseArea {
- id: mouseAreaHours
- anchors.fill: parent
- onClicked: {
- textHours.color = textColorSelected
- textMinutes.color = textColor
- }
- hoverEnabled: true;
- }
- }
- Text {
- text: ":"
- font.pointSize: 0.001 + fontSize
- color: textColor
- width: structure.width*0.1
- anchors.verticalCenter: parent.verticalCenter
- }
- Text {
- id: textMinutes
- text: getCurrentMinute()
- font.pointSize: 0.001 + fontSize
- color: textColor
- width: structure.width*0.3
- anchors.verticalCenter: parent.verticalCenter
- MouseArea {
- id: mouseAreaMinutes
- anchors.fill: parent
- onClicked: {
- textMinutes.color = textColorSelected
- textHours.color = textColor
- }
- hoverEnabled: true;
- }
- }
- Column {
- CLButton{
- id: buttonUp
- style: structure.style
- text: ""
- backgroundImage: Image {source: "../colibri/images/arrow_up_50x50.png"; scale: structure.height*0.006; smooth: structure.smooth}
- width: structure.width*0.3
- fontSize: 0.00001 + structure.fontSize*0.5
- height: structure.height/2
- smooth: structure.smooth
- onClicked: {
- if (textHours.color == textColorSelected) addHour()
- else addMinute()
- }
- }
- CLButton{
- id: buttonDown
- style: structure.style
- text: ""
- backgroundImage: Image {source: "../colibri/images/arrow_down_50x50.png"; scale: structure.height*0.006; smooth: structure.smooth}
- width: structure.width*0.3
- fontSize: 0.00001 + structure.fontSize*0.5
- height: structure.height/2
- smooth: structure.smooth
- onClicked: {
- if (textHours.color == textColorSelected) decreaseHour()
- else decreaseMinute()
- }
- }
- }
- }
- }
|