[C3SL-git] Mobile Application Suite branch, master, updated. 51f93473563c51b919e59845bb3f80f60a2cc742
smartphones-commits at linuxtogo.org
smartphones-commits at linuxtogo.org
Sun Jul 17 21:18:41 CEST 2011
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Mobile Application Suite".
The branch, master has been updated
via 51f93473563c51b919e59845bb3f80f60a2cc742 (commit)
via 53c88967e0e256aedeb74933badda153ff43b443 (commit)
from e60524a248eb57ab3ef4a721f7db06dea2728d25 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 51f93473563c51b919e59845bb3f80f60a2cc742
Author: Simon Busch <morphis at gravedo.de>
Date: Sun Jul 17 21:18:01 2011 +0200
aurora-components: adjust button component api and implement font measuring
commit 53c88967e0e256aedeb74933badda153ff43b443
Author: Simon Busch <morphis at gravedo.de>
Date: Sun Jul 17 21:17:12 2011 +0200
aurora-components: add a qml tools component to the context for things like font measuring
-----------------------------------------------------------------------
Summary of changes:
aurora-components/components/Button.qml | 27 ++++++++++++++++---
aurora-components/plugins/kernel/Makefile.am | 2 +
aurora-components/plugins/kernel/plugin.cpp | 4 +++
aurora-components/plugins/kernel/plugin.h | 3 ++
.../plugins/kernel/qmltools.cpp | 22 ++++++++++------
.../plugins/kernel/qmltools.h | 15 ++++++-----
6 files changed, 53 insertions(+), 20 deletions(-)
copy aurora/plugins/kernel/systemcontroller.cpp => aurora-components/plugins/kernel/qmltools.cpp (70%)
copy aurora/plugins/kernel/systemcontroller.h => aurora-components/plugins/kernel/qmltools.h (74%)
Changes between commits e60524..51f934
diff --git a/aurora-components/components/Button.qml b/aurora-components/components/Button.qml
index 889a865..59b504d 100644
--- a/aurora-components/components/Button.qml
+++ b/aurora-components/components/Button.qml
@@ -27,8 +27,18 @@ Item {
// public API
//
+ // common public API
+ // see: http://bugreports.qt.nokia.com/browse/QTCOMPONENTS-200
+
property alias text: label.text
+ property alias font: label.font
+
property bool enabled: true
+ property bool checked: false
+ property bool checkable: false
+ property bool pressed: ( stateGroup.state == "pressed" && mouseArea.containsMouse )
+
+ property string iconSource: ""
signal clicked
@@ -36,9 +46,6 @@ Item {
// private
//
- property bool pressed: false
- property bool checked: false
-
Theme { id: theme }
QtObject {
@@ -78,15 +85,25 @@ Item {
Item {
id: content
+
clip: true
- anchors.fill: parent
+ width: Math.min(label.textWidth, component.width)
+ height: label.height
+ anchors.centerIn: parent
+
Text {
id: label
+
anchors.centerIn: parent
elide: Text.ElideRight
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignHCenter
+ height: text ? qmlTools.fontHeight(font) : 0
+
+ property int textWidth: text ? qmlTools.textWidth(text, font) : 0
+
font { family: theme.fontFamily; pixelSize: theme.fontSizeLarge }
+
color: {
if (!component.enabled)
return theme.colorDisabledLight;
@@ -123,8 +140,8 @@ Item {
}
MouseArea {
+ id: mouseArea
anchors.fill: parent
-
onPressed: stateGroup.state = "pressed"
onReleased: stateGroup.state = ""
onCanceled: stateGroup.state = "canceled";
diff --git a/aurora-components/plugins/kernel/Makefile.am b/aurora-components/plugins/kernel/Makefile.am
index 8b750ee..ff31426 100644
--- a/aurora-components/plugins/kernel/Makefile.am
+++ b/aurora-components/plugins/kernel/Makefile.am
@@ -30,6 +30,7 @@ libaurora_kernel_la_SOURCES = \
plugin.cpp \
saverestorestate.cpp \
themeimageprovider.cpp \
+ qmltools.cpp \
$(NULL)
nodist_libaurora_kernel_la_SOURCES = \
@@ -38,6 +39,7 @@ nodist_libaurora_kernel_la_SOURCES = \
moc_plugin.cpp \
moc_saverestorestate.cpp \
moc_themeimageprovider.cpp \
+ moc_qmltools.cpp \
$(NULL)
libaurora_kernel_la_LIBADD = \
diff --git a/aurora-components/plugins/kernel/plugin.cpp b/aurora-components/plugins/kernel/plugin.cpp
index cd6b6fe..e0d00ad 100644
--- a/aurora-components/plugins/kernel/plugin.cpp
+++ b/aurora-components/plugins/kernel/plugin.cpp
@@ -22,6 +22,7 @@
#include "mouseactivitynotifier.h"
#include "themeimageprovider.h"
#include "localtime.h"
+#include "qmltools.h"
AuroraKernelPlugin::AuroraKernelPlugin(QObject *parent)
: QDeclarativeExtensionPlugin(parent)
@@ -39,6 +40,9 @@ void AuroraKernelPlugin::initializeEngine(QDeclarativeEngine *engine, const char
{
Q_UNUSED(uri);
engine->addImageProvider("theme", new ThemeImageProvider);
+
+ QDeclarativeContext *context = engine->rootContext();
+ context->setContextProperty("qmlTools", &this->qmlTools);
}
Q_EXPORT_PLUGIN2(aurora-kernel, AuroraKernelPlugin);
diff --git a/aurora-components/plugins/kernel/plugin.h b/aurora-components/plugins/kernel/plugin.h
index 825fc6a..9b99324 100644
--- a/aurora-components/plugins/kernel/plugin.h
+++ b/aurora-components/plugins/kernel/plugin.h
@@ -20,10 +20,13 @@
#define PLUGIN_H_
#include <QDeclarativeExtensionPlugin>
+#include "qmltools.h"
class AuroraKernelPlugin : public QDeclarativeExtensionPlugin
{
Q_OBJECT
+private:
+ QmlTools qmlTools;
public:
AuroraKernelPlugin(QObject *parent = 0);
diff --git a/aurora-components/plugins/kernel/qmltools.cpp b/aurora-components/plugins/kernel/qmltools.cpp
new file mode 100644
index 0000000..7fc659b
--- /dev/null
+++ b/aurora-components/plugins/kernel/qmltools.cpp
@@ -0,0 +1,39 @@
+/*
+ * (C) 2011 Simon Busch <morphis at gravedo.de>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <QFont>
+#include <QFontMetrics>
+
+#include "qmltools.h"
+
+QmlTools::QmlTools(QObject *parent)
+ : QObject(parent)
+{
+}
+
+int QmlTools::textWidth(const QString& text, const QFont& font)
+{
+ QFontMetrics metrics(font);
+ return metrics.width(text);
+}
+
+int QmlTools::fontHeight(const QFont& font)
+{
+ QFontMetrics metrics(font);
+ return metrics.height();
+}
diff --git a/aurora-components/plugins/kernel/qmltools.h b/aurora-components/plugins/kernel/qmltools.h
new file mode 100644
index 0000000..3a1f179
--- /dev/null
+++ b/aurora-components/plugins/kernel/qmltools.h
@@ -0,0 +1,35 @@
+/*
+ * (C) 2011 Simon Busch <morphis at gravedo.de>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef QMLTOOLS_H_
+#define QMLTOOLS_H_
+
+#include <QObject>
+#include <QFont>
+
+class QmlTools : public QObject
+{
+ Q_OBJECT
+public:
+ explicit QmlTools(QObject *parent = 0);
+
+ Q_INVOKABLE int textWidth(const QString &text, const QFont& font);
+ Q_INVOKABLE int fontHeight(const QFont& font);
+};
+
+#endif // QMLTOOLS_H_
hooks/post-receive
--
Mobile Application Suite
More information about the smartphones-commits
mailing list