raDIYo 0.4
swclockcontrol.cpp
1/***************************************************************************
2
3 source::worx raDIYo
4 Copyright © 2020-2022 c.holzheuer
5 c.holzheuer@sourceworx.org
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
11
12***************************************************************************/
13
14
15#include <QDebug>
16#include <QPainter>
17#include <QKeyEvent>
18#include <QTime>
19#include <QAction>
20
21#include <swclockcontrol.h>
22
23SWClockControl::SWClockControl( SWRaDIYoMainWidget* parent )
24: SWAbstractControl( parent )
25{
26 setupUi( this );
27
28 //--
29
30 _flipHour->setTransition( SWFlipDigit::Flip );
31 _flipMinute->setTransition( SWFlipDigit::Flip );
32 _flipSecond->setTransition( SWFlipDigit::Flip );
33
34 _flipHour->show();
35 _flipMinute->show();
36 _flipSecond->show();
37
38 QPalette pal = palette();
39 pal.setColor( QPalette::Window, Qt::black );
40 setPalette( pal );
41
42 _ticker.start( 1000, this );
43 QTime t = QTime::currentTime();
44 _flipHour->setNumber( t.hour() );
45 _flipMinute->setNumber( t.minute() );
46
47 updateTime();
48
49}
50
51
52SWClockControl::~SWClockControl()
53{
54
55}
56
57/*
58bool SWClockControl::onDialClicked()
59{
60 qDebug() << "alarm onClick";
61}
62
63bool SWClockControl::onDialValueChanged( int value )
64{
65 qDebug() << "alarm on ValueChanged: " << value;
66}
67*/
68
69void SWClockControl::loadSettings()
70{
71
72}
73
74
75void SWClockControl::saveSettings()
76{
77
78}
79
80
81void SWClockControl::updateTime()
82{
83 QTime now = QTime::currentTime();
84 _flipHour->flipTo( now.hour() );
85 _flipMinute->flipTo( now.minute() );
86 _flipSecond->flipTo( now.second() );
87
88
89}
90
91
92void SWClockControl::switchTransition( int delta )
93{
94 int i = ( _flipHour->transition() + delta + 3) % 3;
95 _flipHour->setTransition( (SWFlipDigit::SWFlipMode) i );
96 _flipMinute->setTransition( (SWFlipDigit::SWFlipMode) i );
97 updateTime();
98}
99
100
101/*
102void SWClockControl::resizeEvent(QResizeEvent*)
103{
104 int digitsWidth = width() / 3;
105 int digitsHeight = digitsWidth * 1.2;
106
107 int y = (double) (height() - digitsHeight) / 1.8;
108
109 _flipHour->resize( digitsWidth, digitsHeight );
110 _flipHour->move( 0, y );
111
112 _flipMinute->resize( digitsWidth, digitsHeight );
113 _flipMinute->move( width() / 3, y );
114
115 _flipSecond->resize( digitsWidth, digitsHeight );
116 _flipSecond->move( width() /3 * 2, y );
117}
118*/
119
120void SWClockControl::timerEvent( QTimerEvent* event )
121{
122 Q_UNUSED( event )
123 updateTime();
124}
125
126
127
128
129void SWClockControl::chooseSlide()
130{
131 _flipHour->setTransition( SWFlipDigit::Slide );
132 _flipMinute->setTransition( SWFlipDigit::Slide );
133 _flipSecond->setTransition( SWFlipDigit::Slide );
134 updateTime();
135}
136
137
138void SWClockControl::chooseFlip()
139{
140 _flipHour->setTransition( SWFlipDigit::Flip );
141 _flipMinute->setTransition( SWFlipDigit::Flip );
142 _flipSecond->setTransition( SWFlipDigit::Flip );
143 updateTime();
144}
145
146void SWClockControl::chooseRotate()
147{
148 _flipHour->setTransition( SWFlipDigit::Rotate );
149 _flipMinute->setTransition( SWFlipDigit::Rotate );
150 _flipSecond->setTransition( SWFlipDigit::Rotate );
151 updateTime();
152}
153
154
155