diff options
author | Adriano Rezende <adriano.rezende@openbossa.org> | 2009-10-27 11:18:35 -0300 |
---|---|---|
committer | Adriano Rezende <adriano.rezende@openbossa.org> | 2009-10-27 12:40:51 -0300 |
commit | 775e9418abad450a0a069497577489e55680d140 (patch) | |
tree | b4aca2cd117cf6c1c5d6ed0e57977947744e55f8 /hyperui/mainwindow.cpp | |
parent | 2c58484742ae91424254c6a2c02874193011236d (diff) |
Renamed project name from hiperui to hyperui
Diffstat (limited to 'hyperui/mainwindow.cpp')
-rw-r--r-- | hyperui/mainwindow.cpp | 122 |
1 files changed, 122 insertions, 0 deletions
diff --git a/hyperui/mainwindow.cpp b/hyperui/mainwindow.cpp new file mode 100644 index 0000000..4f48fe3 --- /dev/null +++ b/hyperui/mainwindow.cpp @@ -0,0 +1,122 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: openBossa - INdT (renato.chencarek@openbossa.org) +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** the openBossa stream from INdT (renato.chencarek@openbossa.org). +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QDateTime> + +#include "global.h" +#include "mainwindow.h" +#include "pageview.h" +#include "menuview.h" +#include "clockwidget.h" +#include "draggablepreview.h" + +#ifdef Q_OS_SYMBIAN +#include <eikenv.h> +#include <coemain.h> +#include <aknappui.h> +#endif + + +MainWindow::MainWindow(QGraphicsItem *parent) + : QGraphicsWidget(parent) +{ + setFlag(QGraphicsItem::ItemHasNoContents); + + m_clockWidget = new ClockWidget(this); + m_clockWidget->setPos(0, 0); + + // cache the clock into a pixmap to improve drag performance + m_clockWidget->setCacheMode(QGraphicsItem::ItemCoordinateCache); + + const int width = Resource::intValue("window/width"); + const int height = Resource::intValue("window/height"); + + m_mainView = new PageView(); + m_mainView->add(new MenuView()); + m_preview = new DraggablePreview(m_mainView, QSize(width, height), this); + connect(m_preview, SIGNAL(maximizeFinished()), SLOT(onMaximizeFinished())); + + createDummyDailyEvents(); + +#ifdef Q_OS_SYMBIAN + // The line below is necessary, since CAknAppUi object is only + // available in the main loop. + QTimer::singleShot(0, this, SLOT(lockPortraitMode())); +#endif +} + +void MainWindow::onMaximizeFinished() +{ + m_clockWidget->hide(); +} + +void MainWindow::createDummyDailyEvents() +{ + QColor color1("#80A2BF"); + QColor color2("#FF5E74"); + QColor color3("#A05284"); + + const QDate &cd = QDate::currentDate(); + + m_clockWidget->addEvent(QDateTime(cd, QTime(3, 20, 0)), + QDateTime(cd, QTime(4, 30, 0)), color1); + m_clockWidget->addEvent(QDateTime(cd, QTime(4, 34, 0)), + QDateTime(cd, QTime(5, 15, 0)), color1); + m_clockWidget->addEvent(QDateTime(cd, QTime(5, 19, 0)), + QDateTime(cd, QTime(6, 17, 0)), color1); + m_clockWidget->addEvent(QDateTime(cd, QTime(6, 25, 0)), + QDateTime(cd, QTime(6, 53, 0)), color1); + + m_clockWidget->addEvent(QDateTime(cd, QTime(7, 55, 0)), + QDateTime(cd, QTime(8, 45, 0)), color2); + m_clockWidget->addEvent(QDateTime(cd, QTime(9, 25, 0)), + QDateTime(cd, QTime(10, 20, 0)), color2); + + m_clockWidget->addEvent(QDateTime(cd, QTime(6, 40, 0)), + QDateTime(cd, QTime(7, 20, 0)), color3); + m_clockWidget->addEvent(QDateTime(cd, QTime(7, 24, 0)), + QDateTime(cd, QTime(8, 20, 0)), color3); +} + +/*! + Lock the screen in portrait mode. + + \todo Add support to maemo portrait mode. +*/ +#ifdef Q_OS_SYMBIAN +void MainWindow::lockPortraitMode() +{ + CAknAppUi *aknAppUi = dynamic_cast<CAknAppUi *>(CEikonEnv::Static()->AppUi()); + + if (aknAppUi) + aknAppUi->SetOrientationL(CAknAppUi::EAppUiOrientationPortrait); +} +#endif |