Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Qt5 #1

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,13 @@ moc_*
# Auto-generated documentation files
doc/api/*/*


*.dll
*.exp
*.lib
Makefile*
*.manifest
*.Release
*.Debug
*.exe
qrc_*.cpp
4 changes: 3 additions & 1 deletion README
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ To compile and run the demo:
- Create the directory where you want to build the project ("mkdir indigets-build && cd indigets-build")
- Configure with "cmake <path-to-sources>" from the build directory
- Compile with "make"
- Run the demo with the QML Viewer executable ("qmlviewer -I <plugin-build-dir> -I <indigets-dir> <indigets-dir>/demo/examples/demo1.qml")


- Run the demo with the QML Viewer executable ("qmlscene -I <plugin-build-dir> -I <indigets-dir> <indigets-dir>/demo/examples/demo1.qml")
25 changes: 25 additions & 0 deletions demo_gui/demo_gui.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
TEMPLATE = app
CONFIG += c++11

QT += qml quick

SOURCES += src/main.cpp

CONFIG(debug, debug|release) {
TARGET = demo_guid
OBJECTS_DIR = build/debug
MOC_DIR = build/debug
}
else {
TARGET = demo_gui
OBJECTS_DIR = build/release
MOC_DIR = build/release
}

RESOURCES += qml.qrc

# Additional import path used to resolve QML modules in Qt Creator's code model
QML_IMPORT_PATH = ../indigets ./src/qml ../

# Default rules for deployment.
include(deployment.pri)
27 changes: 27 additions & 0 deletions demo_gui/deployment.pri
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
android-no-sdk {
target.path = /data/user/qt
export(target.path)
INSTALLS += target
} else:android {
x86 {
target.path = /libs/x86
} else: armeabi-v7a {
target.path = /libs/armeabi-v7a
} else {
target.path = /libs/armeabi
}
export(target.path)
INSTALLS += target
} else:unix {
isEmpty(target.path) {
qnx {
target.path = /tmp/$${TARGET}/bin
} else {
target.path = /opt/$${TARGET}/bin
}
export(target.path)
}
INSTALLS += target
}

export(INSTALLS)
6 changes: 6 additions & 0 deletions demo_gui/qml.qrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<RCC>
<qresource prefix="/">
<file>qml/main.qml</file>
<file>qml/ValueChanger.qml</file>
</qresource>
</RCC>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import demo 1.0
import Qt 4.7
import indigets 1.0
import QtQuick 2.2

Item {
property QtObject subject
Expand Down
15 changes: 9 additions & 6 deletions demo/examples/demo1.qml → demo_gui/qml/main.qml
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@

import indigets 1.0
import demo 1.0
import Qt 4.7
import QtQuick 2.2

import "../qml"

Rectangle {
id: root
width: 600
height: 400
width: 800
height: 600

gradient: Gradient {
GradientStop { position: 0.0; color: "#ff525252" }
Expand All @@ -25,8 +27,8 @@ Rectangle {

Gauge {
id: mainGauge
width: 400
height: 400
width: 200
height: 200

Marker {
scale: parent.scale
Expand Down Expand Up @@ -346,3 +348,4 @@ Rectangle {
}
}
}

35 changes: 35 additions & 0 deletions demo_gui/src/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@

#include <QGuiApplication>
#include <QQuickView>
#include <QDir>
#include <QQmlEngine>

int main(int argc, char *argv[])
{
QDir dir(QStringLiteral("../libqt/plugins"));
QStringList dirs;

dirs << QCoreApplication::libraryPaths();
dirs << dir.absolutePath();

dirs << QDir::currentPath() + "/plugins";
dirs << QDir::currentPath() ;
dirs << "../";


QCoreApplication::setLibraryPaths(dirs);
QGuiApplication app(argc, argv);

QQuickView view;
for(const auto& path : dirs)
{
view.engine()->addPluginPath(path);
view.engine()->addImportPath(path);
}

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

return app.exec();
}
13 changes: 13 additions & 0 deletions indigets.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@




TEMPLATE = subdirs
CONFIG += ordered
SUBDIRS = src \
demo_gui


OTHER_FILES += \
README

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import indigets 1.0
import QtQuick 1.0
import QtQuick 2.2

Item {
id: button
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import QtQuick 1.0
import QtQuick 2.2

TextInput {
width: 50
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import indigets 1.0
import QtQuick 1.0
import QtQuick 2.2

Item {
id: gauge
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import QtQuick 1.0
import QtQuick 2.2

Text {
width: 50
Expand Down
2 changes: 1 addition & 1 deletion demo/components/Led.qml → indigets/components/Led.qml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import indigets 1.0
import QtQuick 1.0
import QtQuick 2.2

Item {
property bool on: false
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import indigets 1.0
import QtQuick 1.0
import QtQuick 2.2

Pointer {
z: scale.z + 1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import indigets 1.0
import QtQuick 1.0
import QtQuick 2.2

Item {
id: pointer
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import indigets 1.0
import QtQuick 1.0
import QtQuick 2.2

Item {
id: rotator
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import indigets 1.0
import QtQuick 1.0
import QtQuick 2.2

Item {
id: scaler
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import QtQuick 1.0
import QtQuick 2.2

Item {
id: button
Expand Down
2 changes: 1 addition & 1 deletion demo/components/Tank.qml → indigets/components/Tank.qml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import indigets 1.0
import QtQuick 1.0
import QtQuick 2.2

Item {
id: tank
Expand Down
2 changes: 2 additions & 0 deletions demo/qmldir → indigets/qmldir
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
module indigets
plugin indigets
Scaler 1.0 components/Scaler.qml
Rotator 1.0 components/Rotator.qml
Marker 1.0 components/Marker.qml
Expand Down
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
10 changes: 5 additions & 5 deletions src/abstractscale.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
#include "valuemapper.hpp"
#include <QPainter>

AbstractScale::AbstractScale(QDeclarativeItem* parent)
: QDeclarativeItem(parent)
AbstractScale::AbstractScale(QQuickItem* parent)
: QQuickItem(parent)
, m_minimum(0)
, m_maximum(100)
{
Expand Down Expand Up @@ -55,9 +55,9 @@ void AbstractScale::setMapper(ValueMapper* mapper)
}
}

QDeclarativeListProperty<ScaleZone> AbstractScale::zones()
QQmlListProperty<ScaleZone> AbstractScale::zones()
{
return QDeclarativeListProperty<ScaleZone>(this, m_zones);
return QQmlListProperty<ScaleZone>(this, m_zones);
}

int AbstractScale::zoneCount() const
Expand Down Expand Up @@ -110,7 +110,7 @@ double AbstractScale::angleAtValue(double value) const

void AbstractScale::geometryChanged(const QRectF& newGeometry, const QRectF& oldGeometry)
{
QDeclarativeItem::geometryChanged(newGeometry, oldGeometry);
QQuickItem::geometryChanged(newGeometry, oldGeometry);

// Discard the path on geometry change
rebuild();
Expand Down
11 changes: 6 additions & 5 deletions src/abstractscale.hpp
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
#ifndef ABSTRACTSCALE_HPP
#define ABSTRACTSCALE_HPP

#include <QDeclarativeItem>
#include <QQuickItem>
#include <QPainterPath>
#include <QPointer>

class ValueMapper;
class ScaleZone;

class AbstractScale : public QDeclarativeItem
class AbstractScale : public QQuickItem
{
Q_OBJECT
Q_PROPERTY(double minimum READ minimum WRITE setMinimum NOTIFY minimumChanged)
Q_PROPERTY(double maximum READ maximum WRITE setMaximum NOTIFY maximumChanged)
Q_PROPERTY(ValueMapper* mapper READ mapper WRITE setMapper NOTIFY mapperChanged)
Q_PROPERTY(QDeclarativeListProperty<ScaleZone> zones READ zones)
Q_PROPERTY(QQmlListProperty<ScaleZone> zones READ zones)
Q_PROPERTY(const QPainterPath& path READ path NOTIFY pathChanged)

public:
AbstractScale(QDeclarativeItem* parent = 0);
AbstractScale(QQuickItem* parent = 0);

double minimum() const;
void setMinimum(double minimum);
Expand All @@ -28,7 +29,7 @@ class AbstractScale : public QDeclarativeItem
ValueMapper* mapper() const;
void setMapper(ValueMapper* mapper);

QDeclarativeListProperty<ScaleZone> zones();
QQmlListProperty<ScaleZone> zones();
int zoneCount() const;
ScaleZone* zone(int index) const;

Expand Down
2 changes: 1 addition & 1 deletion src/circularscale.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "circularscale.hpp"

CircularScale::CircularScale(QDeclarativeItem* parent)
CircularScale::CircularScale(QQuickItem* parent)
: AbstractScale(parent)
, m_startAngle(215)
, m_spanAngle(250)
Expand Down
2 changes: 1 addition & 1 deletion src/circularscale.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class CircularScale : public AbstractScale
Q_PROPERTY(double spanAngle READ spanAngle WRITE setSpanAngle NOTIFY spanAngleChanged)

public:
CircularScale(QDeclarativeItem* parent = 0);
CircularScale(QQuickItem* parent = 0);

double startAngle() const;
void setStartAngle(double angle);
Expand Down
20 changes: 9 additions & 11 deletions src/ellipse.cpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
#include "ellipse.hpp"
#include <QPainter>

Ellipse::Ellipse(QDeclarativeItem* parent)
: QDeclarativeItem(parent)
Ellipse::Ellipse(QQuickItem* parent)
: QQuickPaintedItem(parent)
, m_borderWidth(0.)
{
// need to disable this flag to draw inside a QDeclarativeItem
setFlag(QGraphicsItem::ItemHasNoContents, false);
//FIXME: diasble flags settings ?
// need to disable this flag to draw inside a QQuickItem
//setFlag(QGraphicsItem::ItemHasNoContents, false);

// need to disable this flag to receive geometry change events (used to discard the path cache)
setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
//setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
}

QColor Ellipse::color() const
Expand Down Expand Up @@ -57,11 +58,8 @@ void Ellipse::setBorderWidth(double width)
}
}

void Ellipse::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
void Ellipse::paint(QPainter* painter)
{
Q_UNUSED(option);
Q_UNUSED(widget);

// Rebuild the path if necessary
if (m_path.isEmpty())
{
Expand All @@ -80,9 +78,9 @@ void Ellipse::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, Q
painter->drawPath(m_path);
}

QVariant Ellipse::itemChange(GraphicsItemChange change, const QVariant& value)
void Ellipse::itemChange(ItemChange change, const ItemChangeData& value)
{
// Discard the path on geometry change
m_path = QPainterPath();
return QDeclarativeItem::itemChange(change, value);
QQuickItem::itemChange(change, value);
}
Loading