1
/***********************************************************************
3
* Copyright (C) 2010 Innocent De Marchi <tangram.peces@gmail.com>
5
* This program is free software: you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation, either version 3 of the License, or
8
* (at your option) any later version.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program. If not, see <http://www.gnu.org/licenses/>.
18
***********************************************************************/
25
Rellotge::Rellotge(QWidget * parent , Qt::WindowFlags)
28
rellotgeQTimer = new QTimer();
29
connect(rellotgeQTimer, SIGNAL(timeout()), this, SLOT(actualitzaRellotge()));
30
p_rellotgeEnMarxa=false;
36
void Rellotge::actualitzaRellotge(){
46
setText(retornaTemps());
49
void Rellotge::iniciaRellotge(){
50
p_rellotgeEnMarxa= true;
51
setText(retornaTemps());
52
rellotgeQTimer->start(1000);
55
void Rellotge::aturaRellotge(){
56
rellotgeQTimer->stop();
57
p_rellotgeEnMarxa=false;
58
setText(retornaTemps());
62
void Rellotge::estableixTemps(QString temps){
63
QStringList list1 = temps.split(":");
64
hores=list1.at(0).toInt();
65
minuts=list1.at(1).toInt();
66
segons=list1.at(2).toInt();
67
setText(retornaTemps());
71
QString Rellotge::retornaTemps(int tipus){
73
QString sHores,sMinuts,sSegons;
76
sHores= QString("0%1:").arg(hores);
78
else sHores= QString("%1:").arg(hores);
81
sMinuts= QString("0%1:").arg(minuts);
83
else sMinuts= QString("%1:").arg(minuts);
86
sSegons= QString("0%1").arg(segons);
88
else sSegons= QString("%1").arg(segons);
91
if(rellotgeQTimer->isActive()){
92
return QString("<h1><font color=red>%1%2%3</font></h1>").arg(sHores,sMinuts,sSegons);
95
return QString("<h1><font color=blue>%1%2%3</font></h1>").arg(sHores,sMinuts,sSegons);
99
return QString("%1%2%3").arg(sHores,sMinuts,sSegons);
103
bool Rellotge::rellotgeEnMarxa(){
104
return p_rellotgeEnMarxa;