Skip to content

Commit

Permalink
Initial commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
mireq committed Jan 16, 2014
0 parents commit d5a94ed
Show file tree
Hide file tree
Showing 25 changed files with 684 additions and 0 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Miroslav Bendík <[email protected]>
27 changes: 27 additions & 0 deletions COPYING
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Copyright (c) 2014, Miroslav Bendík and various contributors (see AUTHORS)
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

The views and conclusions contained in the software and documentation are those
of the authors and should not be interpreted as representing official policies,
either expressed or implied, of the FreeBSD Project.

4 changes: 4 additions & 0 deletions examples/examples.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
TEMPLATE = subdirs
SUBDIRS = \
keyboardview \
textedit \
6 changes: 6 additions & 0 deletions examples/keyboardview/keyboardview.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
TEMPLATE = app
QT += gui quick
include($$PWD/../../src/components.pri)
SOURCES += \
main.cpp
RESOURCES = resources.qrc
25 changes: 25 additions & 0 deletions examples/keyboardview/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include <QGuiApplication>
#include <QQuickView>
#include <QUrl>
#include "../../src/KeyboardItem.h"
#include "../../src/ModeItem.h"
#include "../../src/ButtonItem.h"
#include "../../src/LayoutItem.h"

int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);

qmlRegisterType<KeyboardItem>("QuickKeyboard", 1, 0, "Keyboard");
qmlRegisterType<ModeItem>("QuickKeyboard", 1, 0, "Mode");
qmlRegisterType<ButtonItem>("QuickKeyboard", 1, 0, "Button");
qmlRegisterType<LayoutItemAttached>();
qmlRegisterType<LayoutItem>("QuickKeyboard", 1, 0, "Layout");

QQuickView view;
view.setResizeMode(QQuickView::SizeRootObjectToView);
view.setSource(QUrl("qrc:/keyboard.qml"));
view.show();

return app.exec();
}
6 changes: 6 additions & 0 deletions examples/keyboardview/resources.qrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<!DOCTYPE RCC><RCC version="1.0">
<qresource prefix="/">
<file alias="keyboard.qml">../../qml/keyboard.qml</file>
<file alias="Btn.qml">../../qml/Btn.qml</file>
</qresource>
</RCC>
17 changes: 17 additions & 0 deletions examples/textedit/example.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import QtQuick 2.0

Rectangle {
width: 800; height: 600
color: "white"

Rectangle {
anchors.fill: input
color: "#eee"
border { width: 1; color: "gray" }
}

TextEdit {
id: input
anchors { top: parent.top; left: parent.left; right: parent.right; margins: 10 }
}
}
13 changes: 13 additions & 0 deletions examples/textedit/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include <QGuiApplication>
#include <QQuickView>
#include <QUrl>

int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
app.addLibraryPath(app.applicationDirPath() + "/../../");
QQuickView view;
view.setSource(QUrl("qrc:/example.qml"));
view.show();
return app.exec();
}
5 changes: 5 additions & 0 deletions examples/textedit/resources.qrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<!DOCTYPE RCC><RCC version="1.0">
<qresource prefix="/">
<file>example.qml</file>
</qresource>
</RCC>
5 changes: 5 additions & 0 deletions examples/textedit/textedit.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
TEMPLATE = app
QT += gui quick
SOURCES = \
main.cpp
RESOURCES = resources.qrc
17 changes: 17 additions & 0 deletions qml/Btn.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import QtQuick 2.0
import QuickKeyboard 1.0

Button {
property int row
property int col
Layout.row: row
Layout.col: col
Layout.colSpan: 2
Layout.rowSpan: 2
width: 50
height: 50
Rectangle {
color: "green"
anchors.fill: parent
}
}
14 changes: 14 additions & 0 deletions qml/keyboard.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import QtQuick 2.0
import QuickKeyboard 1.0

Keyboard {
width: 200; height: 100
Mode {
id: standard
anchors.fill: parent
Btn{ col: 0; row: 0; label: "A"; symbols: ["A"] }
Btn{ col: 3; row: 3; label: "B"; symbols: ["B"] }
Btn{ col: 5; row: 5; label: "C"; symbols: ["C"] }
}
mode: standard
}
4 changes: 4 additions & 0 deletions quickkeyboard.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
TEMPLATE = subdirs
SUBDIRS = \
examples \
src
27 changes: 27 additions & 0 deletions src/BaseLayoutItem.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#include "ButtonItem.h"
#include "BaseLayoutItem.h"

BaseLayoutItem::BaseLayoutItem(QQuickItem *parent):
QQuickItem(parent)
{
}

BaseLayoutItem::~BaseLayoutItem()
{
}

void BaseLayoutItem::addButton(ButtonItem *button)
{
m_buttons.append(button);
}

void BaseLayoutItem::clearButtons()
{
m_buttons.clear();
}

const QList<ButtonItem *> &BaseLayoutItem::buttons() const
{
return m_buttons;
}

26 changes: 26 additions & 0 deletions src/BaseLayoutItem.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#ifndef BASELAYOUTITEM_H_ZHXO0UI7
#define BASELAYOUTITEM_H_ZHXO0UI7

#include <QQuickItem>
#include <QList>
class ButtonItem;

class BaseLayoutItem: public QQuickItem
{
Q_OBJECT
public:
explicit BaseLayoutItem(QQuickItem *parent = 0);
~BaseLayoutItem();

virtual void addButton(ButtonItem *button);
virtual void clearButtons();

protected:
const QList<ButtonItem *> &buttons() const;

private:
QList<ButtonItem *> m_buttons;
}; /* ----- end of class BaseLayoutItem ----- */

#endif /* end of include guard: BASELAYOUTITEM_H_ZHXO0UI7 */

17 changes: 17 additions & 0 deletions src/ButtonItem.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include "ButtonItem.h"

ButtonItem::ButtonItem(QQuickItem *parent):
QQuickItem(parent),
m_pressed(false),
m_modifier(false),
m_col(0),
m_row(0),
m_colSpan(1),
m_rowSpan(1)
{
}

ButtonItem::~ButtonItem()
{
}

47 changes: 47 additions & 0 deletions src/ButtonItem.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#ifndef BUTTONITEM_H_VNF1QLCU
#define BUTTONITEM_H_VNF1QLCU

#include <QQuickItem>
#include <QStringList>

class ButtonItem: public QQuickItem
{
Q_OBJECT
Q_PROPERTY(bool pressed MEMBER m_pressed NOTIFY pressedChanged DESIGNABLE false)
Q_PROPERTY(bool modifier MEMBER m_modifier NOTIFY modifierChanged DESIGNABLE false)
Q_PROPERTY(QString label MEMBER m_label NOTIFY labelChanged)
Q_PROPERTY(QStringList symbols MEMBER m_symbols NOTIFY symbolsChanged)

// position
Q_PROPERTY(int col MEMBER m_col NOTIFY colChanged)
Q_PROPERTY(int row MEMBER m_row NOTIFY rowChanged)
Q_PROPERTY(int colSpan MEMBER m_colSpan NOTIFY colSpanChanged)
Q_PROPERTY(int rowSpan MEMBER m_rowSpan NOTIFY rowSpanChanged)
public:
explicit ButtonItem(QQuickItem *parent = 0);
~ButtonItem();

signals:
void pressedChanged(bool is_pressed);
void modifierChanged(bool is_modifier);
void labelChanged(const QString &label);
void symbolsChanged(const QStringList &symbols);

void colChanged(int col);
void rowChanged(int row);
void colSpanChanged(int colSpan);
void rowSpanChanged(int rowSpan);

private:
bool m_pressed;
bool m_modifier;
QString m_label;
QStringList m_symbols;
int m_col;
int m_row;
int m_colSpan;
int m_rowSpan;
}; /* ----- end of class ButtonItem ----- */

#endif /* end of include guard: BUTTONITEM_H_VNF1QLCU */

22 changes: 22 additions & 0 deletions src/KeyboardItem.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include "KeyboardItem.h"

KeyboardItem::KeyboardItem(QQuickItem *parent):
QQuickItem(parent),
m_mode(0)
{
}

KeyboardItem::~KeyboardItem()
{
}

void KeyboardItem::setMode(ModeItem *mode)
{
if (m_mode == mode) {
return;
}

m_mode = mode;
emit modeChanged(m_mode);
}

26 changes: 26 additions & 0 deletions src/KeyboardItem.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#ifndef KEYBOARDITEM_H_PT4SCIAV
#define KEYBOARDITEM_H_PT4SCIAV

#include <QQuickItem>
#include <QList>
#include "ModeItem.h"

class KeyboardItem: public QQuickItem
{
Q_OBJECT
Q_PROPERTY(ModeItem* mode MEMBER m_mode WRITE setMode NOTIFY modeChanged DESIGNABLE false)
public:
explicit KeyboardItem(QQuickItem *parent = 0);
~KeyboardItem();

void setMode(ModeItem *mode);

signals:
void modeChanged(ModeItem *mode);

private:
ModeItem *m_mode;
}; /* ----- end of class KeyboardItem ----- */

#endif /* end of include guard: KEYBOARDITEM_H_PT4SCIAV */

Loading

0 comments on commit d5a94ed

Please sign in to comment.