screensaver/screensaverplugins/snsrbigclockscreensaverplugin/snsrclockwidgets/src/snsroledclockwidget.cpp
changeset 69 87476091b3f5
parent 62 341166945d65
equal deleted inserted replaced
67:474929a40a0f 69:87476091b3f5
     1 /*
     1 /*
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2009 - 2010 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
   129         createPrimitives();
   129         createPrimitives();
   130     }
   130     }
   131     Q_ASSERT( mClockHourHand && mClockMinuteHand /*&& mClockDateLabel */);
   131     Q_ASSERT( mClockHourHand && mClockMinuteHand /*&& mClockDateLabel */);
   132     
   132     
   133     // Calculate angles for clock hands.
   133     // Calculate angles for clock hands.
       
   134     // Use granularity of one minute so that minute hand is always exactly
       
   135     // on some minute and not between minutes. OLED clock is not updated more
       
   136     // frequently than once per minute and using finer granularity would cause
       
   137     // the minute hand to be always between even minutes.
   134     QTime time = QTime::currentTime();
   138     QTime time = QTime::currentTime();
   135     qreal s = 6 * time.second();
   139     qreal m = 6 * time.minute();
   136     qreal m = 6 * (time.minute() + s/360);
       
   137     qreal h = 30 * ((time.hour() % 12) + m/360);
   140     qreal h = 30 * ((time.hour() % 12) + m/360);
   138     
   141     
   139     int x = mClockHourHand->preferredSize().width()/2;
   142     int x = mClockHourHand->preferredSize().width()/2;
   140     int y = mClockHourHand->preferredSize().height()/2;
   143     int y = mClockHourHand->preferredSize().height()/2;
   141     mClockHourHand->setTransform(QTransform().translate(x, y).rotate(h).translate(-x, -y));
   144     mClockHourHand->setTransform(QTransform().translate(x, y).rotate(h).translate(-x, -y));