summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdriano Rezende <adriano.rezende@openbossa.org>2009-11-17 12:44:41 -0300
committerAdriano Rezende <adriano.rezende@openbossa.org>2009-11-17 13:43:23 -0300
commitf503aa16629e3163b3d50d08444b68c04d961340 (patch)
tree123ada7426513f4e00874e569f3fbdd63d1cc808
parenta1ab255d5e5c93652998c4e6085094d5bdcfea14 (diff)
HyperUI: Changed source code to use Resource from shared
Signed-off-by: Adriano Rezende <adriano.rezende@openbossa.org>
-rw-r--r--hyperui/clockwidget.cpp2
-rw-r--r--hyperui/draggablepreview.cpp2
-rw-r--r--hyperui/global.cpp75
-rw-r--r--hyperui/global.h55
-rw-r--r--hyperui/hyperui.pro9
-rw-r--r--hyperui/main.cpp5
-rw-r--r--hyperui/mainwindow.cpp2
-rw-r--r--hyperui/menuview.cpp2
-rw-r--r--hyperui/pagemenu.cpp2
-rw-r--r--hyperui/pageview.cpp2
-rw-r--r--hyperui/phoneview.cpp19
11 files changed, 28 insertions, 147 deletions
diff --git a/hyperui/clockwidget.cpp b/hyperui/clockwidget.cpp
index f6c2283..3f0be2f 100644
--- a/hyperui/clockwidget.cpp
+++ b/hyperui/clockwidget.cpp
@@ -33,7 +33,7 @@
#include <QDateTime>
#include <QRadialGradient>
-#include "global.h"
+#include "resource.h"
#include "clockwidget.h"
diff --git a/hyperui/draggablepreview.cpp b/hyperui/draggablepreview.cpp
index e59197b..e2b5109 100644
--- a/hyperui/draggablepreview.cpp
+++ b/hyperui/draggablepreview.cpp
@@ -36,7 +36,7 @@
#include <QParallelAnimationGroup>
#include <QGraphicsSceneMouseEvent>
-#include "global.h"
+#include "resource.h"
#include "draggablepreview.h"
diff --git a/hyperui/global.cpp b/hyperui/global.cpp
deleted file mode 100644
index dd2a9db..0000000
--- a/hyperui/global.cpp
+++ /dev/null
@@ -1,75 +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 <QSettings>
-
-#include "global.h"
-
-
-QPixmap Resource::pixmap(const QString &path)
-{
- return QPixmap(QString(":/images/%1").arg(path));
-}
-
-QVariant Resource::value(const QString &key, const QVariant &value)
-{
- static QSettings settings(":hyperui.ini", QSettings::IniFormat);
-
- if (settings.contains(key))
- return settings.value(key, value);
- else {
- qWarning("Resource: key '%s' not found", key.toLatin1().data());
- return QVariant();
- }
-}
-
-int Resource::intValue(const QString &key, int value)
-{
- return Resource::value(key, value).toInt();
-}
-
-double Resource::doubleValue(const QString &key, double value)
-{
- return Resource::value(key, value).toDouble();
-}
-
-QString Resource::stringValue(const QString &key, const QString &value)
-{
- return Resource::value(key, value).toString();
-}
-
-QFont Resource::buttonFont()
-{
- QFont font(Resource::stringValue("default/font-family"));
- font.setBold(true);
- font.setPixelSize(Resource::intValue("button/font-size"));
- return font;
-}
diff --git a/hyperui/global.h b/hyperui/global.h
deleted file mode 100644
index a36b487..0000000
--- a/hyperui/global.h
+++ /dev/null
@@ -1,55 +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 GLOBAL_H
-#define GLOBAL_H
-
-#include <QFont>
-#include <QString>
-#include <QPixmap>
-#include <QVariant>
-
-
-class Resource
-{
-public:
- static QPixmap pixmap(const QString &path);
-
- static QFont buttonFont();
-
- static QVariant value(const QString &key, const QVariant &value = QVariant());
-
- static int intValue(const QString &key, int value = 0);
- static double doubleValue(const QString &key, double value = 0);
- static QString stringValue(const QString &key, const QString &value = QString());
-};
-
-#endif
diff --git a/hyperui/hyperui.pro b/hyperui/hyperui.pro
index 56b6579..63a21c6 100644
--- a/hyperui/hyperui.pro
+++ b/hyperui/hyperui.pro
@@ -16,7 +16,6 @@ symbian {
}
HEADERS += mainwindow.h \
- global.h \
pagemenu.h \
view.h \
pageview.h \
@@ -25,12 +24,11 @@ HEADERS += mainwindow.h \
draggablepreview.h \
clockwidget.h \
../shared/button.h \
- ../shared/label.h
-
+ ../shared/label.h \
+ ../shared/resource.h
SOURCES += main.cpp \
mainwindow.cpp \
- global.cpp \
pagemenu.cpp \
view.cpp \
pageview.cpp \
@@ -39,7 +37,8 @@ SOURCES += main.cpp \
draggablepreview.cpp \
clockwidget.cpp \
../shared/button.cpp \
- ../shared/label.cpp
+ ../shared/label.cpp \
+ ../shared/resource.cpp
isEmpty(RESOLUTION) {
RESOLUTION = "800x480"
diff --git a/hyperui/main.cpp b/hyperui/main.cpp
index 0cf9ea4..afeb479 100644
--- a/hyperui/main.cpp
+++ b/hyperui/main.cpp
@@ -33,7 +33,7 @@
#include <QGraphicsScene>
#include <QGraphicsView>
-#include "global.h"
+#include "resource.h"
#include "mainwindow.h"
@@ -43,6 +43,9 @@ int main(int argc, char **argv)
QApplication::setGraphicsSystem("raster");
#endif
+ Resource::setIniFile(":/hyperui.ini");
+ Resource::setPixmapPrefix(":/images/");
+
QApplication app(argc, argv);
const int width = Resource::intValue("window/width");
diff --git a/hyperui/mainwindow.cpp b/hyperui/mainwindow.cpp
index 80f6687..e759003 100644
--- a/hyperui/mainwindow.cpp
+++ b/hyperui/mainwindow.cpp
@@ -33,7 +33,7 @@
#include <QPainter>
#include <QGraphicsRectItem>
-#include "global.h"
+#include "resource.h"
#include "mainwindow.h"
#include "pageview.h"
#include "menuview.h"
diff --git a/hyperui/menuview.cpp b/hyperui/menuview.cpp
index 21e27c5..789f77f 100644
--- a/hyperui/menuview.cpp
+++ b/hyperui/menuview.cpp
@@ -29,7 +29,7 @@
**
****************************************************************************/
-#include "global.h"
+#include "resource.h"
#include "button.h"
#include "menuview.h"
#include "phoneview.h"
diff --git a/hyperui/pagemenu.cpp b/hyperui/pagemenu.cpp
index 578ec72..432b25e 100644
--- a/hyperui/pagemenu.cpp
+++ b/hyperui/pagemenu.cpp
@@ -32,7 +32,7 @@
#include <QPainter>
#include <QFontMetrics>
-#include "global.h"
+#include "resource.h"
#include "pagemenu.h"
diff --git a/hyperui/pageview.cpp b/hyperui/pageview.cpp
index cfa8bf8..5470ae9 100644
--- a/hyperui/pageview.cpp
+++ b/hyperui/pageview.cpp
@@ -36,7 +36,7 @@
#include <QParallelAnimationGroup>
#include <QGraphicsSceneResizeEvent>
-#include "global.h"
+#include "resource.h"
#include "view.h"
#include "button.h"
#include "pagemenu.h"
diff --git a/hyperui/phoneview.cpp b/hyperui/phoneview.cpp
index 6a88456..bc2585d 100644
--- a/hyperui/phoneview.cpp
+++ b/hyperui/phoneview.cpp
@@ -39,12 +39,21 @@
#include <QGraphicsGridLayout>
#include <QSequentialAnimationGroup>
-#include "global.h"
+#include "resource.h"
#include "label.h"
#include "button.h"
#include "phoneview.h"
+static QFont resourceButtonFont()
+{
+ QFont font(Resource::stringValue("default/font-family"));
+ font.setBold(true);
+ font.setPixelSize(Resource::intValue("button/font-size"));
+ return font;
+}
+
+
class Overlay : public QObject,
public QGraphicsRectItem
{
@@ -123,7 +132,7 @@ void DialerWidget::addButton(const QString &label, int row, int col,
Button *button = new Button(Resource::pixmap(normalPath),
Resource::pixmap(pressedPath));
button->setText(label);
- button->setFont(Resource::buttonFont());
+ button->setFont(resourceButtonFont());
connect(button, SIGNAL(clicked()), SLOT(onButtonClicked()));
@@ -421,7 +430,7 @@ PhoneView::PhoneView(QGraphicsItem *parent)
m_contactsButton = new Button(Resource::pixmap("dialer_bt_contacts.png"), this);
m_contactsButton->setPos(contactsButtonPos);
- m_contactsButton->setFont(Resource::buttonFont());
+ m_contactsButton->setFont(resourceButtonFont());
m_overlay = new Overlay(this);
m_overlay->setBrush(Qt::black);
@@ -431,13 +440,13 @@ PhoneView::PhoneView(QGraphicsItem *parent)
Resource::pixmap("dialer_bt_call_over.png"), this);
m_callButton->setText(tr("CALL"));
m_callButton->setPos(callButtonPos);
- m_callButton->setFont(Resource::buttonFont());
+ m_callButton->setFont(resourceButtonFont());
m_endCallButton = new Button(Resource::pixmap("dialer_bt_endcall.png"),
Resource::pixmap("dialer_bt_endcall_over.png"), this);
m_endCallButton->setText(tr("END CALL"));
m_endCallButton->setPos(callButtonPos);
- m_endCallButton->setFont(Resource::buttonFont());
+ m_endCallButton->setFont(resourceButtonFont());
m_board = new CallBoard(this);
m_board->setPos(dialerBackPos);