diff options
author | Adriano Rezende <adriano.rezende@openbossa.org> | 2009-11-05 14:10:41 -0300 |
---|---|---|
committer | Adriano Rezende <adriano.rezende@openbossa.org> | 2009-11-16 10:34:52 -0300 |
commit | 0579478a9e3b4d71070342fba52a5b99403375df (patch) | |
tree | 57c9e07eb68c96043e862e905ee5560d4c0a2346 | |
parent | 143e69f7586a234ce35f09681fa401f034647241 (diff) |
HyperUI: Moved DialerWidget code to phone view
-rw-r--r-- | hyperui/dialerwidget.cpp | 161 | ||||
-rw-r--r-- | hyperui/dialerwidget.h | 73 | ||||
-rw-r--r-- | hyperui/hyperui.pro | 2 | ||||
-rw-r--r-- | hyperui/phoneview.cpp | 78 |
4 files changed, 77 insertions, 237 deletions
diff --git a/hyperui/dialerwidget.cpp b/hyperui/dialerwidget.cpp deleted file mode 100644 index 99291c9..0000000 --- a/hyperui/dialerwidget.cpp +++ /dev/null @@ -1,161 +0,0 @@ -/**************************************************************************** -** -** 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 <QGraphicsGridLayout> -#include <QGraphicsPixmapItem> - -#include "global.h" -#include "dialerwidget.h" -#include "button.h" - -#define MAX_ROWS 4 -#define MAX_COLUMNS 3 - - -DialerWidget::DialerWidget(QGraphicsItem *parent) - : QGraphicsWidget(parent) -{ - QGraphicsPixmapItem *background = - new QGraphicsPixmapItem(Resource::pixmap("dialer/background.png"), this); - background->setPos(0, 0); - background->setShapeMode(QGraphicsPixmapItem::BoundingRectShape); - - const int margin = Resource::intValue("dialer-widget/margin"); - const int spacing = Resource::intValue("dialer-widget/spacing"); - - m_layout = new QGraphicsGridLayout(); - m_layout->setSpacing(spacing); - m_layout->setContentsMargins(margin, margin, margin, margin); - - addButton("1", 0, 0, SLOT(oneClicked())); - addButton("2", 0, 1, SLOT(twoClicked())); - addButton("3", 0, 2, SLOT(threeClicked())); - addButton("4", 1, 0, SLOT(fourClicked())); - addButton("5", 1, 1, SLOT(fiveClicked())); - addButton("6", 1, 2, SLOT(sixClicked())); - addButton("7", 2, 0, SLOT(sevenClicked())); - addButton("8", 2, 1, SLOT(eightClicked())); - addButton("9", 2, 2, SLOT(nineClicked())); - addButton("*", 3, 0, SLOT(starClicked())); - addButton("0", 3, 1, SLOT(zeroClicked())); - addButton("#", 3, 2, SLOT(hashClicked())); - - setLayout(m_layout); -} - -void DialerWidget::addButton(const QString &label, int row, int col, const char *slot) -{ - QPixmap normalPixmap; - QPixmap pressedPixmap; - - if (row == 0 && col == 0) { - normalPixmap = Resource::pixmap("dialer/top_left_key.png"); - pressedPixmap = Resource::pixmap("dialer/top_left_key_pressed.png"); - } else if (row == 0 && col == MAX_COLUMNS - 1) { - normalPixmap = Resource::pixmap("dialer/top_right_key.png"); - pressedPixmap = Resource::pixmap("dialer/top_right_key_pressed.png"); - } else if (row == MAX_ROWS - 1 && col == 0) { - normalPixmap = Resource::pixmap("dialer/bottom_left_key.png"); - pressedPixmap = Resource::pixmap("dialer/bottom_left_key_pressed.png"); - } else if (row == MAX_ROWS - 1 && col == MAX_COLUMNS - 1) { - normalPixmap = Resource::pixmap("dialer/bottom_right_key.png"); - pressedPixmap = Resource::pixmap("dialer/bottom_right_key_pressed.png"); - } else { - normalPixmap = Resource::pixmap("dialer/middle_key.png"); - pressedPixmap = Resource::pixmap("dialer/middle_key_pressed.png"); - } - - Button *button = new Button(normalPixmap, pressedPixmap); - button->setText(label); - connect(button, SIGNAL(clicked()), slot); - - m_layout->addItem(button, row, col); -} - -void DialerWidget::oneClicked() -{ - emit buttonClicked("1"); -} - -void DialerWidget::twoClicked() -{ - emit buttonClicked("2"); -} - -void DialerWidget::threeClicked() -{ - emit buttonClicked("3"); -} - -void DialerWidget::fourClicked() -{ - emit buttonClicked("4"); -} - -void DialerWidget::fiveClicked() -{ - emit buttonClicked("5"); -} - -void DialerWidget::sixClicked() -{ - emit buttonClicked("6"); -} - -void DialerWidget::sevenClicked() -{ - emit buttonClicked("7"); -} - -void DialerWidget::eightClicked() -{ - emit buttonClicked("8"); -} - -void DialerWidget::nineClicked() -{ - emit buttonClicked("9"); -} - -void DialerWidget::starClicked() -{ - emit buttonClicked("*"); -} - -void DialerWidget::zeroClicked() -{ - emit buttonClicked("0"); -} - -void DialerWidget::hashClicked() -{ - emit buttonClicked("#"); -} diff --git a/hyperui/dialerwidget.h b/hyperui/dialerwidget.h deleted file mode 100644 index a237668..0000000 --- a/hyperui/dialerwidget.h +++ /dev/null @@ -1,73 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -#ifndef DIALERWIDGET_H -#define DIALERWIDGET_H - -#include <QGraphicsWidget> - -QT_BEGIN_NAMESPACE -class QGraphicsGridLayout; -QT_END_NAMESPACE - - -class DialerWidget : public QGraphicsWidget -{ - Q_OBJECT - -public: - DialerWidget(QGraphicsItem *parent = 0); - -signals: - void buttonClicked(const QString &value); - -protected: - void addButton(const QString &label, int row, int col, const char *slot); - -private slots: - void oneClicked(); - void twoClicked(); - void threeClicked(); - void fourClicked(); - void fiveClicked(); - void sixClicked(); - void sevenClicked(); - void eightClicked(); - void nineClicked(); - void starClicked(); - void zeroClicked(); - void hashClicked(); - -private: - QGraphicsGridLayout *m_layout; -}; - -#endif diff --git a/hyperui/hyperui.pro b/hyperui/hyperui.pro index 24a18e8..d47c511 100644 --- a/hyperui/hyperui.pro +++ b/hyperui/hyperui.pro @@ -23,7 +23,6 @@ HEADERS += mainwindow.h \ pageview.h \ menuview.h \ phoneview.h \ - dialerwidget.h \ label.h \ draggablepreview.h \ clockwidget.h @@ -37,7 +36,6 @@ SOURCES += main.cpp \ pageview.cpp \ menuview.cpp \ phoneview.cpp \ - dialerwidget.cpp \ label.cpp \ draggablepreview.cpp \ clockwidget.cpp diff --git a/hyperui/phoneview.cpp b/hyperui/phoneview.cpp index 50927e6..3664949 100644 --- a/hyperui/phoneview.cpp +++ b/hyperui/phoneview.cpp @@ -36,13 +36,13 @@ #include <QGraphicsPixmapItem> #include <QGraphicsLinearLayout> #include <QPropertyAnimation> +#include <QGraphicsGridLayout> #include <QSequentialAnimationGroup> #include "global.h" #include "label.h" #include "button.h" #include "phoneview.h" -#include "dialerwidget.h" class Overlay : public QObject, @@ -61,6 +61,82 @@ protected: }; +class DialerWidget : public QGraphicsWidget +{ + Q_OBJECT + +public: + DialerWidget(QGraphicsItem *parent = 0); + +signals: + void buttonClicked(const QString &value); + +protected: + void addButton(const QString &label, int row, int col, + const QString &imagePrefix); + +private slots: + void onButtonClicked(); + +private: + QGraphicsGridLayout *m_layout; +}; + + +DialerWidget::DialerWidget(QGraphicsItem *parent) + : QGraphicsWidget(parent) +{ + QGraphicsPixmapItem *background = + new QGraphicsPixmapItem(Resource::pixmap("dialer/background.png"), this); + background->setPos(0, 0); + background->setShapeMode(QGraphicsPixmapItem::BoundingRectShape); + + const int margin = Resource::intValue("dialer-widget/margin"); + const int spacing = Resource::intValue("dialer-widget/spacing"); + + m_layout = new QGraphicsGridLayout(); + m_layout->setSpacing(spacing); + m_layout->setContentsMargins(margin, margin, margin, margin); + + addButton("1", 0, 0, "dialer/top_left_key"); + addButton("2", 0, 1, "dialer/middle_key"); + addButton("3", 0, 2, "dialer/top_right_key"); + addButton("4", 1, 0, "dialer/middle_key"); + addButton("5", 1, 1, "dialer/middle_key"); + addButton("6", 1, 2, "dialer/middle_key"); + addButton("7", 2, 0, "dialer/middle_key"); + addButton("8", 2, 1, "dialer/middle_key"); + addButton("9", 2, 2, "dialer/middle_key"); + addButton("*", 3, 0, "dialer/bottom_left_key"); + addButton("0", 3, 1, "dialer/middle_key"); + addButton("#", 3, 2, "dialer/bottom_right_key"); + + setLayout(m_layout); +} + +void DialerWidget::addButton(const QString &label, int row, int col, + const QString &imagePrefix) +{ + const QString &normalPath = QString("%1.png").arg(imagePrefix); + const QString &pressedPath = QString("%1_pressed.png").arg(imagePrefix); + + Button *button = new Button(Resource::pixmap(normalPath), + Resource::pixmap(pressedPath)); + button->setText(label); + connect(button, SIGNAL(clicked()), SLOT(onButtonClicked())); + + m_layout->addItem(button, row, col); +} + +void DialerWidget::onButtonClicked() +{ + Button *button = dynamic_cast<Button *>(sender()); + + if (button) + emit buttonClicked(button->text()); +} + + class CallBoard : public QGraphicsWidget { Q_OBJECT |