From 906ed9db4d75b0841bbe680152b8d1a777060b34 Mon Sep 17 00:00:00 2001 From: Adriano Rezende Date: Fri, 27 Nov 2009 19:49:24 -0300 Subject: HyperUI: Added clock label to main window --- hyperui/mainwindow.cpp | 21 +++++++++++++++++++++ hyperui/mainwindow.h | 5 +++++ hyperui/resource/640x360/hyperui.ini | 1 + hyperui/resource/800x480/hyperui.ini | 1 + 4 files changed, 28 insertions(+) diff --git a/hyperui/mainwindow.cpp b/hyperui/mainwindow.cpp index 4bf104d..5006917 100644 --- a/hyperui/mainwindow.cpp +++ b/hyperui/mainwindow.cpp @@ -69,12 +69,17 @@ MainWindow::MainWindow(QGraphicsItem *parent) QGraphicsSimpleTextItem *phoneLabel = new QGraphicsSimpleTextItem(tr("T-Mobile"), this); + m_hourLabel = new QGraphicsSimpleTextItem(this); + QFont labelFont(Resource::stringValue("default/font-family")); labelFont.setBold(true); labelFont.setPixelSize(Resource::intValue("topbar/font-size")); phoneLabel->setFont(labelFont); phoneLabel->setBrush(QColor(Resource::stringValue("default/font-color"))); + m_hourLabel->setFont(labelFont); + m_hourLabel->setBrush(QColor(Resource::stringValue("default/font-color"))); + QGraphicsPixmapItem *iconBattery = new QGraphicsPixmapItem(Resource::pixmap("topbar_battery.png"), this); @@ -84,12 +89,28 @@ MainWindow::MainWindow(QGraphicsItem *parent) QGraphicsPixmapItem *iconNetwork = new QGraphicsPixmapItem(Resource::pixmap("topbar_network.png"), this); + m_hourLabel->setPos(Resource::value("topbar/hour-label-pos").toPoint()); phoneLabel->setPos(Resource::value("topbar/label-pos").toPoint()); iconNetwork->setPos(Resource::value("topbar/icon-network-pos").toPoint()); icon3G->setPos(Resource::value("topbar/icon-3g-pos").toPoint()); iconBattery->setPos(Resource::value("topbar/icon-battery-pos").toPoint()); + updateTime(); createDummyDailyEvents(); + + // update time each 30 seconds + startTimer(30000); +} + +void MainWindow::timerEvent(QTimerEvent *event) +{ + Q_UNUSED(event); + updateTime(); +} + +void MainWindow::updateTime() +{ + m_hourLabel->setText(QDateTime::currentDateTime().toString("hh:mm")); } void MainWindow::onDragModeIn() diff --git a/hyperui/mainwindow.h b/hyperui/mainwindow.h index e085214..f945e44 100644 --- a/hyperui/mainwindow.h +++ b/hyperui/mainwindow.h @@ -55,12 +55,16 @@ public: void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); +protected: + void timerEvent(QTimerEvent *event); + private slots: void onDragModeIn(); void onDragModeOut(); void onMaximizeFinished(); private: + void updateTime(); void createDummyDailyEvents(); QPixmap m_background; @@ -68,6 +72,7 @@ private: ClockWidget *m_clockWidget; DraggablePreview *m_preview; QGraphicsRectItem *m_overlay; + QGraphicsSimpleTextItem *m_hourLabel; }; #endif diff --git a/hyperui/resource/640x360/hyperui.ini b/hyperui/resource/640x360/hyperui.ini index f1d35e1..d8b8c11 100644 --- a/hyperui/resource/640x360/hyperui.ini +++ b/hyperui/resource/640x360/hyperui.ini @@ -12,6 +12,7 @@ height=640 [topbar] font-size=14 label-pos=@Point(230 5) +hour-label-pos=@Point(10 5) icon-network-pos=@Point(290 5) icon-3g-pos=@Point(310 5) icon-battery-pos=@Point(330 5) diff --git a/hyperui/resource/800x480/hyperui.ini b/hyperui/resource/800x480/hyperui.ini index 555ba15..d10fe73 100644 --- a/hyperui/resource/800x480/hyperui.ini +++ b/hyperui/resource/800x480/hyperui.ini @@ -12,6 +12,7 @@ height=800 [topbar] font-size=16 label-pos=@Point(340 6) +hour-label-pos=@Point(10 6) icon-network-pos=@Point(406 6) icon-3g-pos=@Point(428 6) icon-battery-pos=@Point(450 6) -- cgit v1.2.3