Merged scratch/mart/plasma-components into subtree plasma/declarativeimports.
This commit is contained in:
parent
4037ced032
commit
cde1151099
65
declarativeimports/plasmacomponents/BusyWidget.qml
Normal file
65
declarativeimports/plasmacomponents/BusyWidget.qml
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2010 by Artur Duque de Souza <asouzakde.org>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Library General Public License as
|
||||||
|
* published by the Free Software Foundation; either version 2, 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 Library 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import Qt 4.7
|
||||||
|
import org.kde.plasma.core 0.1 as PlasmaCore
|
||||||
|
|
||||||
|
Item {
|
||||||
|
id: root
|
||||||
|
width: 100; height: 100
|
||||||
|
|
||||||
|
property bool running: true
|
||||||
|
property string label: ""
|
||||||
|
|
||||||
|
PlasmaCore.Theme {
|
||||||
|
id: theme
|
||||||
|
}
|
||||||
|
|
||||||
|
PlasmaCore.SvgItem {
|
||||||
|
id: widget
|
||||||
|
width: root.width
|
||||||
|
height: root.height
|
||||||
|
anchors.horizontalCenter: root.horizontalCenter
|
||||||
|
smooth: true
|
||||||
|
svg: PlasmaCore.Svg { imagePath: ("widgets/busywidget") }
|
||||||
|
|
||||||
|
RotationAnimation on rotation {
|
||||||
|
from: 0
|
||||||
|
to: 360
|
||||||
|
target: widget
|
||||||
|
duration: 1500
|
||||||
|
running: root.running
|
||||||
|
loops: Animation.Infinite
|
||||||
|
}
|
||||||
|
|
||||||
|
// if you need to do anything while repainting
|
||||||
|
// do it inside this slot
|
||||||
|
function update() {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Text {
|
||||||
|
id: label
|
||||||
|
text: root.label
|
||||||
|
color: theme.textColor
|
||||||
|
anchors.verticalCenter: root.verticalCenter
|
||||||
|
anchors.horizontalCenter: root.horizontalCenter
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
76
declarativeimports/plasmacomponents/FlashingLabel.qml
Normal file
76
declarativeimports/plasmacomponents/FlashingLabel.qml
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2010 by Anselmo Lacerda Silveira de Melo <anselmolsm@gmail.com>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Library General Public License as
|
||||||
|
* published by the Free Software Foundation; either version 2, 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 Library 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import Qt 4.7
|
||||||
|
import org.kde.plasma.core 0.1 as PlasmaCore
|
||||||
|
|
||||||
|
Item {
|
||||||
|
id: root
|
||||||
|
width: 200
|
||||||
|
height: 100
|
||||||
|
|
||||||
|
//API
|
||||||
|
property bool autohide: false
|
||||||
|
//### get font from theme when available
|
||||||
|
//### deal with QFont stuff in a proper way
|
||||||
|
property string font: "Arial"
|
||||||
|
property string color: theme.textColor
|
||||||
|
property int duration: 3000
|
||||||
|
|
||||||
|
/*### actually the FlashingLabel in C++ doesn't have
|
||||||
|
this as part of its API, either text or pixmap is
|
||||||
|
set only when flash is called.*/
|
||||||
|
property string text: ""
|
||||||
|
|
||||||
|
//###
|
||||||
|
PlasmaCore.Theme {
|
||||||
|
id: theme
|
||||||
|
}
|
||||||
|
|
||||||
|
Text {
|
||||||
|
id: label
|
||||||
|
text: root.text
|
||||||
|
color: root.color
|
||||||
|
font.family: root.font
|
||||||
|
horizontalAlignment: Text.AlignHCenter
|
||||||
|
verticalAlignment: Text.AlignVCenter
|
||||||
|
anchors.verticalCenter: root.verticalCenter
|
||||||
|
anchors.horizontalCenter: root.horizontalCenter
|
||||||
|
}
|
||||||
|
|
||||||
|
PropertyAnimation {
|
||||||
|
id: fade
|
||||||
|
target: label;
|
||||||
|
property: "opacity";
|
||||||
|
duration: root.duration;
|
||||||
|
to: 0
|
||||||
|
}
|
||||||
|
|
||||||
|
function flash(text, duration, alignment) {
|
||||||
|
if (text)
|
||||||
|
root.text = text
|
||||||
|
if (duration)
|
||||||
|
root.duration = duration
|
||||||
|
if (alignment)
|
||||||
|
label.horizontalAlignment = alignment
|
||||||
|
fade.start()
|
||||||
|
}
|
||||||
|
|
||||||
|
//###TODO: flash pixmap
|
||||||
|
}
|
47
declarativeimports/plasmacomponents/Frame.qml
Normal file
47
declarativeimports/plasmacomponents/Frame.qml
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010 Marco Martin <notmart@gmail.com>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Library General Public License as
|
||||||
|
* published by the Free Software Foundation; either version 2, 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 Library 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.
|
||||||
|
*/
|
||||||
|
import Qt 4.7
|
||||||
|
import org.kde.plasma.core 0.1 as PlasmaCore
|
||||||
|
|
||||||
|
PlasmaCore.FrameSvgItem {
|
||||||
|
id : background
|
||||||
|
imagePath: "widgets/frame"
|
||||||
|
prefix: "plain"
|
||||||
|
|
||||||
|
width: childrenRect.width
|
||||||
|
height: childrenRect.height
|
||||||
|
|
||||||
|
property alias padding: paddingRectangle;
|
||||||
|
signal clicked;
|
||||||
|
|
||||||
|
Item {
|
||||||
|
id: paddingRectangle
|
||||||
|
anchors.fill: parent
|
||||||
|
anchors.leftMargin: background.margins.left
|
||||||
|
anchors.topMargin: background.margins.top
|
||||||
|
anchors.rightMargin: background.margins.right
|
||||||
|
anchors.bottomMargin: background.margins.bottom
|
||||||
|
}
|
||||||
|
|
||||||
|
MouseArea {
|
||||||
|
id: itemMouse
|
||||||
|
anchors.fill: background
|
||||||
|
onClicked: background.clicked()
|
||||||
|
}
|
||||||
|
}
|
97
declarativeimports/plasmacomponents/IconWidget.qml
Normal file
97
declarativeimports/plasmacomponents/IconWidget.qml
Normal file
@ -0,0 +1,97 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2010 by Artur Duque de Souza <asouzakde.org>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Library General Public License as
|
||||||
|
* published by the Free Software Foundation; either version 2, 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 Library 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import Qt 4.7
|
||||||
|
import org.kde.plasma.core 0.1 as PlasmaCore
|
||||||
|
|
||||||
|
Item {
|
||||||
|
id: root
|
||||||
|
width: 100; height: 100
|
||||||
|
|
||||||
|
property string text: ""
|
||||||
|
property string infoText: ""
|
||||||
|
|
||||||
|
property string svg: ""
|
||||||
|
property string icon: ""
|
||||||
|
|
||||||
|
property bool drawBackground: true
|
||||||
|
property int numDisplayLines: 1
|
||||||
|
//property QColor textBackgroundColor: ""
|
||||||
|
|
||||||
|
signal pressed(bool down)
|
||||||
|
signal clicked()
|
||||||
|
signal doubleClicked()
|
||||||
|
signal activated()
|
||||||
|
signal changed()
|
||||||
|
|
||||||
|
PlasmaCore.Theme {
|
||||||
|
id: theme
|
||||||
|
}
|
||||||
|
|
||||||
|
PlasmaCore.FrameSvgItem {
|
||||||
|
id: background
|
||||||
|
visible: root.drawBackground
|
||||||
|
anchors.fill: root
|
||||||
|
|
||||||
|
imagePath: "widgets/viewitem"
|
||||||
|
prefix: mainMouseArea.pressed == true ? "selected" : "hover"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
PlasmaCore.SvgItem {
|
||||||
|
id: svg
|
||||||
|
visible: root.svg != ""
|
||||||
|
width: root.width - label.height
|
||||||
|
height: root.height - label.height
|
||||||
|
anchors.horizontalCenter: root.horizontalCenter
|
||||||
|
svg: PlasmaCore.Svg { imagePath: root.svg }
|
||||||
|
|
||||||
|
// if you need to do anything while repainting
|
||||||
|
// do it inside this slot
|
||||||
|
function update() {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Image {
|
||||||
|
id: icon
|
||||||
|
visible: root.icon != ""
|
||||||
|
width: root.width - label.height
|
||||||
|
height: root.height - label.height
|
||||||
|
}
|
||||||
|
|
||||||
|
Text {
|
||||||
|
id: label
|
||||||
|
text: root.text
|
||||||
|
color: theme.textColor
|
||||||
|
anchors.top: icon.bottom
|
||||||
|
anchors.horizontalCenter: root.horizontalCenter
|
||||||
|
}
|
||||||
|
|
||||||
|
MouseArea {
|
||||||
|
id: mainMouseArea
|
||||||
|
hoverEnabled: true
|
||||||
|
anchors.fill: parent
|
||||||
|
|
||||||
|
onEntered: {
|
||||||
|
}
|
||||||
|
|
||||||
|
onExited: {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
95
declarativeimports/plasmacomponents/PushButton.qml
Normal file
95
declarativeimports/plasmacomponents/PushButton.qml
Normal file
@ -0,0 +1,95 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2010 by Marco Martin <mart@kde.org>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Library General Public License as
|
||||||
|
* published by the Free Software Foundation; either version 2, 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 Library 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import Qt 4.7
|
||||||
|
import org.kde.plasma.core 0.1 as PlasmaCore
|
||||||
|
|
||||||
|
Item {
|
||||||
|
width: 50
|
||||||
|
height:20
|
||||||
|
|
||||||
|
property string text
|
||||||
|
signal clicked
|
||||||
|
|
||||||
|
id: button
|
||||||
|
PlasmaCore.FrameSvgItem {
|
||||||
|
id: hover
|
||||||
|
anchors.fill: parent
|
||||||
|
opacity: 0
|
||||||
|
anchors.leftMargin: -margins.left
|
||||||
|
anchors.topMargin: -margins.top
|
||||||
|
anchors.rightMargin: -margins.right
|
||||||
|
anchors.bottomMargin: -margins.bottom
|
||||||
|
imagePath: "widgets/button"
|
||||||
|
prefix: "hover"
|
||||||
|
Behavior on opacity {
|
||||||
|
PropertyAnimation { duration: 250 }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
PlasmaCore.FrameSvgItem {
|
||||||
|
id: shadow
|
||||||
|
anchors.fill: parent
|
||||||
|
anchors.leftMargin: -margins.left
|
||||||
|
anchors.topMargin: -margins.top
|
||||||
|
anchors.rightMargin: -margins.right
|
||||||
|
anchors.bottomMargin: -margins.bottom
|
||||||
|
imagePath: "widgets/button"
|
||||||
|
prefix: "shadow"
|
||||||
|
Behavior on opacity {
|
||||||
|
PropertyAnimation { duration: 250 }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
PlasmaCore.FrameSvgItem {
|
||||||
|
id: surface
|
||||||
|
anchors.fill: parent
|
||||||
|
imagePath: "widgets/button"
|
||||||
|
prefix: "normal"
|
||||||
|
}
|
||||||
|
|
||||||
|
Text {
|
||||||
|
text: button.text
|
||||||
|
anchors.fill: parent
|
||||||
|
horizontalAlignment: Text.AlignHCenter
|
||||||
|
verticalAlignment: Text.AlignVCenter
|
||||||
|
}
|
||||||
|
|
||||||
|
MouseArea {
|
||||||
|
anchors.fill: parent
|
||||||
|
hoverEnabled: true
|
||||||
|
|
||||||
|
onPressed: {
|
||||||
|
surface.prefix = "pressed"
|
||||||
|
}
|
||||||
|
onReleased: {
|
||||||
|
surface.prefix = "normal"
|
||||||
|
button.clicked()
|
||||||
|
}
|
||||||
|
onEntered: {
|
||||||
|
shadow.opacity = 0
|
||||||
|
hover.opacity = 1
|
||||||
|
}
|
||||||
|
onExited: {
|
||||||
|
shadow.opacity = 1
|
||||||
|
hover.opacity = 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
107
declarativeimports/plasmacomponents/ScrollBar.qml
Normal file
107
declarativeimports/plasmacomponents/ScrollBar.qml
Normal file
@ -0,0 +1,107 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2010 by Marco Martin <mart@kde.org>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Library General Public License as
|
||||||
|
* published by the Free Software Foundation; either version 2, 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 Library 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import Qt 4.7
|
||||||
|
import org.kde.plasma.core 0.1 as PlasmaCore
|
||||||
|
|
||||||
|
|
||||||
|
PlasmaCore.FrameSvgItem {
|
||||||
|
id: scrollBar
|
||||||
|
width: orientation==Qt.Horizontal?200:22
|
||||||
|
height: orientation==Qt.Horizontal?22:200
|
||||||
|
|
||||||
|
property int minimum: 0
|
||||||
|
property int maximum: 100
|
||||||
|
property int value: 0
|
||||||
|
property string orientation: Qt.Horizontal
|
||||||
|
|
||||||
|
onValueChanged: {
|
||||||
|
if (drag.state != "dragging") {
|
||||||
|
if (orientation == Qt.Horizontal) {
|
||||||
|
drag.x = (value/(maximum-minimum))*(scrollBar.width - drag.width)
|
||||||
|
} else {
|
||||||
|
drag.y = (value/(maximum-minimum))*(scrollBar.height - drag.height)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
imagePath: "widgets/scrollbar"
|
||||||
|
prefix: orientation==Qt.Horizontal?"background-horizontal":"background-vertical"
|
||||||
|
|
||||||
|
PlasmaCore.FrameSvgItem {
|
||||||
|
id: drag
|
||||||
|
anchors.top: orientation==Qt.Horizontal?parent.top:null
|
||||||
|
anchors.bottom: orientation==Qt.Horizontal?parent.bottom:null
|
||||||
|
anchors.left: orientation==Qt.Horizontal?null:parent.left
|
||||||
|
anchors.right: orientation==Qt.Horizontal?null:parent.right
|
||||||
|
state: "normal"
|
||||||
|
width: (orientation == Qt.Horizontal)?Math.max(12, (parent.width*1/(scrollBar.maximum-scrollBar.minimum))):0
|
||||||
|
height: (orientation != Qt.Horizontal)?Math.max(12, (parent.height*1/(scrollBar.maximum-scrollBar.minimum))):0
|
||||||
|
x: 0
|
||||||
|
y: 0
|
||||||
|
onXChanged: {
|
||||||
|
if (orientation == Qt.Horizontal && state == "dragging") {
|
||||||
|
value = (maximum - minimum)*(x/(scrollBar.width-width))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
onYChanged: {
|
||||||
|
if (orientation != Qt.Horizontal && state == "dragging") {
|
||||||
|
value = (maximum - minimum)*(x/(scrollBar.height-height))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Behavior on x {
|
||||||
|
NumberAnimation {
|
||||||
|
duration: 200
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Behavior on y {
|
||||||
|
NumberAnimation {
|
||||||
|
duration: 200
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
imagePath: "widgets/scrollbar"
|
||||||
|
prefix: "slider"
|
||||||
|
MouseArea {
|
||||||
|
anchors.fill: parent
|
||||||
|
hoverEnabled: true
|
||||||
|
|
||||||
|
drag.target: parent;
|
||||||
|
drag.axis: orientation == Qt.Horizontal?"XAxis":"YAxis"
|
||||||
|
drag.minimumX: 0;
|
||||||
|
drag.maximumX: scrollBar.width-drag.width;
|
||||||
|
drag.minimumY: 0;
|
||||||
|
drag.maximumY: scrollBar.height-drag.height;
|
||||||
|
|
||||||
|
onEntered: drag.prefix = "mouseover-slider"
|
||||||
|
onExited: drag.prefix = "slider"
|
||||||
|
onPressed: {
|
||||||
|
drag.prefix = "sunken-slider"
|
||||||
|
drag.state = "dragging"
|
||||||
|
}
|
||||||
|
onReleased: {
|
||||||
|
containsMouse?drag.prefix = "mouseover-slider":drag.prefix = "slider"
|
||||||
|
drag.state = "normal"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
79
declarativeimports/plasmacomponents/ToolButton.qml
Normal file
79
declarativeimports/plasmacomponents/ToolButton.qml
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2010 by Marco Martin <mart@kde.org>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Library General Public License as
|
||||||
|
* published by the Free Software Foundation; either version 2, 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 Library 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import Qt 4.7
|
||||||
|
import org.kde.plasma.core 0.1 as PlasmaCore
|
||||||
|
|
||||||
|
Item {
|
||||||
|
width: 50
|
||||||
|
height:20
|
||||||
|
|
||||||
|
property string text
|
||||||
|
property bool down: false
|
||||||
|
signal clicked
|
||||||
|
|
||||||
|
id: button
|
||||||
|
|
||||||
|
PlasmaCore.FrameSvgItem {
|
||||||
|
id: surface
|
||||||
|
anchors.fill: parent
|
||||||
|
imagePath: "widgets/button"
|
||||||
|
prefix: down?"pressed":"normal"
|
||||||
|
opacity: down?1:0
|
||||||
|
Behavior on opacity {
|
||||||
|
PropertyAnimation { duration: 250 }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Text {
|
||||||
|
text: button.text
|
||||||
|
anchors.fill: parent
|
||||||
|
horizontalAlignment: Text.AlignHCenter
|
||||||
|
verticalAlignment: Text.AlignVCenter
|
||||||
|
}
|
||||||
|
|
||||||
|
MouseArea {
|
||||||
|
anchors.fill: parent
|
||||||
|
hoverEnabled: true
|
||||||
|
|
||||||
|
onPressed: {
|
||||||
|
if (!down) {
|
||||||
|
surface.prefix = "pressed"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
onReleased: {
|
||||||
|
if (!down) {
|
||||||
|
surface.prefix = "normal"
|
||||||
|
}
|
||||||
|
button.clicked()
|
||||||
|
}
|
||||||
|
onEntered: {
|
||||||
|
if (!down) {
|
||||||
|
surface.opacity = 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
onExited: {
|
||||||
|
if (!down) {
|
||||||
|
surface.opacity = 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
7
declarativeimports/plasmacomponents/qmldir
Normal file
7
declarativeimports/plasmacomponents/qmldir
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
BusyWidget 0.1 BusyWidget.qml
|
||||||
|
FlashingLabel 0.1 FlashingLabel.qml
|
||||||
|
Frame 0.1 Frame.qml
|
||||||
|
IconWidget 0.1 IconWidget.qml
|
||||||
|
PushButton 0.1 PushButton.qml
|
||||||
|
ScrollBar 0.1 ScrollBar.qml
|
||||||
|
ToolButton 0.1 ToolButton.qml
|
26
declarativeimports/qtextracomponents/CMakeLists.txt
Normal file
26
declarativeimports/qtextracomponents/CMakeLists.txt
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
project(qtextracomponents)
|
||||||
|
|
||||||
|
include(KDE4Defaults)
|
||||||
|
|
||||||
|
set(qtextracomponents_SRCS
|
||||||
|
qtextracomponentsplugin.cpp
|
||||||
|
qpixmapitem.cpp
|
||||||
|
qimageitem.cpp
|
||||||
|
qiconitem.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
INCLUDE_DIRECTORIES(
|
||||||
|
${CMAKE_SOURCE_DIR}
|
||||||
|
${CMAKE_BINARY_DIR}
|
||||||
|
${KDE4_INCLUDES}
|
||||||
|
)
|
||||||
|
|
||||||
|
qt4_automoc(${qtextracomponents_SRCS})
|
||||||
|
|
||||||
|
|
||||||
|
add_library(qtextracomponentsplugin SHARED ${qtextracomponents_SRCS})
|
||||||
|
target_link_libraries(qtextracomponentsplugin ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTDECLARATIVE_LIBRARY})
|
||||||
|
|
||||||
|
install(TARGETS qtextracomponentsplugin DESTINATION ${IMPORTS_INSTALL_DIR}/org/kde/qtextracomponents)
|
||||||
|
|
||||||
|
install(FILES qmldir DESTINATION ${IMPORTS_INSTALL_DIR}/org/kde/qtextracomponents)
|
82
declarativeimports/qtextracomponents/qiconitem.cpp
Normal file
82
declarativeimports/qtextracomponents/qiconitem.cpp
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2011 Marco Martin <mart@kde.org>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Library General Public License as
|
||||||
|
* published by the Free Software Foundation; either version 2, 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 Library 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 "qiconitem.h"
|
||||||
|
|
||||||
|
#include <QtGui/QPainter>
|
||||||
|
|
||||||
|
|
||||||
|
QIconItem::QIconItem(QDeclarativeItem *parent)
|
||||||
|
: QDeclarativeItem(parent),
|
||||||
|
m_smooth(false)
|
||||||
|
{
|
||||||
|
setFlag(QGraphicsItem::ItemHasNoContents, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QIconItem::~QIconItem()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void QIconItem::setIcon(const QIcon &icon)
|
||||||
|
{
|
||||||
|
m_icon = icon;
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
QIcon QIconItem::icon() const
|
||||||
|
{
|
||||||
|
return m_icon;
|
||||||
|
}
|
||||||
|
|
||||||
|
void QIconItem::setSmooth(const bool smooth)
|
||||||
|
{
|
||||||
|
if (smooth == m_smooth) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
m_smooth = smooth;
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool QIconItem::smooth() const
|
||||||
|
{
|
||||||
|
return m_smooth;
|
||||||
|
}
|
||||||
|
|
||||||
|
void QIconItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||||
|
{
|
||||||
|
Q_UNUSED(option);
|
||||||
|
Q_UNUSED(widget);
|
||||||
|
|
||||||
|
if (m_icon.isNull()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//do without painter save, faster and the support can be compiled out
|
||||||
|
const bool wasAntiAlias = painter->testRenderHint(QPainter::Antialiasing);
|
||||||
|
const bool wasSmoothTransform = painter->testRenderHint(QPainter::SmoothPixmapTransform);
|
||||||
|
painter->setRenderHint(QPainter::Antialiasing, m_smooth);
|
||||||
|
painter->setRenderHint(QPainter::SmoothPixmapTransform, m_smooth);
|
||||||
|
|
||||||
|
m_icon.paint(painter, boundingRect().toRect());
|
||||||
|
painter->setRenderHint(QPainter::Antialiasing, wasAntiAlias);
|
||||||
|
painter->setRenderHint(QPainter::SmoothPixmapTransform, wasSmoothTransform);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#include "qiconitem.moc"
|
49
declarativeimports/qtextracomponents/qiconitem.h
Normal file
49
declarativeimports/qtextracomponents/qiconitem.h
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* Copyright 2011 Marco Martin <mart@kde.org> *
|
||||||
|
* *
|
||||||
|
* 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 QICONITEM_H
|
||||||
|
#define QICONITEM_H
|
||||||
|
|
||||||
|
#include <QDeclarativeItem>
|
||||||
|
#include <QPixmap>
|
||||||
|
|
||||||
|
class QIconItem : public QDeclarativeItem
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
Q_PROPERTY(QIcon icon READ icon WRITE setIcon)
|
||||||
|
Q_PROPERTY(bool smooth READ smooth WRITE setSmooth)
|
||||||
|
|
||||||
|
public:
|
||||||
|
QIconItem(QDeclarativeItem *parent=0);
|
||||||
|
~QIconItem();
|
||||||
|
|
||||||
|
void setIcon(const QIcon &icon);
|
||||||
|
QIcon icon() const;
|
||||||
|
|
||||||
|
void setSmooth(const bool smooth);
|
||||||
|
bool smooth() const;
|
||||||
|
|
||||||
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||||
|
|
||||||
|
private:
|
||||||
|
QIcon m_icon;
|
||||||
|
bool m_smooth;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
94
declarativeimports/qtextracomponents/qimageitem.cpp
Normal file
94
declarativeimports/qtextracomponents/qimageitem.cpp
Normal file
@ -0,0 +1,94 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2011 Marco Martin <mart@kde.org>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Library General Public License as
|
||||||
|
* published by the Free Software Foundation; either version 2, 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 Library 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 "qimageitem.h"
|
||||||
|
|
||||||
|
#include <QtGui/QPainter>
|
||||||
|
|
||||||
|
|
||||||
|
QImageItem::QImageItem(QDeclarativeItem *parent)
|
||||||
|
: QDeclarativeItem(parent),
|
||||||
|
m_smooth(false)
|
||||||
|
{
|
||||||
|
setFlag(QGraphicsItem::ItemHasNoContents, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QImageItem::~QImageItem()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void QImageItem::setImage(const QImage &image)
|
||||||
|
{
|
||||||
|
m_image = image;
|
||||||
|
update();
|
||||||
|
emit nativeWidthChanged();
|
||||||
|
emit nativeHeightChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
QImage QImageItem::image() const
|
||||||
|
{
|
||||||
|
return m_image;
|
||||||
|
}
|
||||||
|
|
||||||
|
void QImageItem::setSmooth(const bool smooth)
|
||||||
|
{
|
||||||
|
if (smooth == m_smooth) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
m_smooth = smooth;
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool QImageItem::smooth() const
|
||||||
|
{
|
||||||
|
return m_smooth;
|
||||||
|
}
|
||||||
|
|
||||||
|
int QImageItem::nativeWidth() const
|
||||||
|
{
|
||||||
|
return m_image.size().width();
|
||||||
|
}
|
||||||
|
|
||||||
|
int QImageItem::nativeHeight() const
|
||||||
|
{
|
||||||
|
return m_image.size().height();
|
||||||
|
}
|
||||||
|
|
||||||
|
void QImageItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||||
|
{
|
||||||
|
Q_UNUSED(option);
|
||||||
|
Q_UNUSED(widget);
|
||||||
|
|
||||||
|
if (m_image.isNull()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//do without painter save, faster and the support can be compiled out
|
||||||
|
const bool wasAntiAlias = painter->testRenderHint(QPainter::Antialiasing);
|
||||||
|
const bool wasSmoothTransform = painter->testRenderHint(QPainter::SmoothPixmapTransform);
|
||||||
|
painter->setRenderHint(QPainter::Antialiasing, m_smooth);
|
||||||
|
painter->setRenderHint(QPainter::SmoothPixmapTransform, m_smooth);
|
||||||
|
|
||||||
|
painter->drawImage(boundingRect(), m_image, m_image.rect());
|
||||||
|
painter->setRenderHint(QPainter::Antialiasing, wasAntiAlias);
|
||||||
|
painter->setRenderHint(QPainter::SmoothPixmapTransform, wasSmoothTransform);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#include "qimageitem.moc"
|
58
declarativeimports/qtextracomponents/qimageitem.h
Normal file
58
declarativeimports/qtextracomponents/qimageitem.h
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* Copyright 2011 Marco Martin <mart@kde.org> *
|
||||||
|
* *
|
||||||
|
* 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 QIMAGEITEM_H
|
||||||
|
#define QIMAGEITEM_H
|
||||||
|
|
||||||
|
#include <QDeclarativeItem>
|
||||||
|
#include <QImage>
|
||||||
|
|
||||||
|
class QImageItem : public QDeclarativeItem
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
Q_PROPERTY(QImage image READ image WRITE setImage)
|
||||||
|
Q_PROPERTY(bool smooth READ smooth WRITE setSmooth)
|
||||||
|
Q_PROPERTY(int nativeWidth READ nativeWidth NOTIFY nativeWidthChanged)
|
||||||
|
Q_PROPERTY(int nativeHeight READ nativeHeight NOTIFY nativeHeightChanged)
|
||||||
|
|
||||||
|
public:
|
||||||
|
QImageItem(QDeclarativeItem *parent=0);
|
||||||
|
~QImageItem();
|
||||||
|
|
||||||
|
void setImage(const QImage &image);
|
||||||
|
QImage image() const;
|
||||||
|
|
||||||
|
void setSmooth(const bool smooth);
|
||||||
|
bool smooth() const;
|
||||||
|
|
||||||
|
int nativeWidth() const;
|
||||||
|
int nativeHeight() const;
|
||||||
|
|
||||||
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||||
|
|
||||||
|
Q_SIGNALS:
|
||||||
|
void nativeWidthChanged();
|
||||||
|
void nativeHeightChanged();
|
||||||
|
|
||||||
|
private:
|
||||||
|
QImage m_image;
|
||||||
|
bool m_smooth;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
3
declarativeimports/qtextracomponents/qmldir
Normal file
3
declarativeimports/qtextracomponents/qmldir
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
plugin qtextracomponentsplugin
|
||||||
|
|
||||||
|
|
94
declarativeimports/qtextracomponents/qpixmapitem.cpp
Normal file
94
declarativeimports/qtextracomponents/qpixmapitem.cpp
Normal file
@ -0,0 +1,94 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2011 Marco Martin <mart@kde.org>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Library General Public License as
|
||||||
|
* published by the Free Software Foundation; either version 2, 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 Library 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 "qpixmapitem.h"
|
||||||
|
|
||||||
|
#include <QtGui/QPainter>
|
||||||
|
|
||||||
|
|
||||||
|
QPixmapItem::QPixmapItem(QDeclarativeItem *parent)
|
||||||
|
: QDeclarativeItem(parent),
|
||||||
|
m_smooth(false)
|
||||||
|
{
|
||||||
|
setFlag(QGraphicsItem::ItemHasNoContents, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QPixmapItem::~QPixmapItem()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void QPixmapItem::setPixmap(const QPixmap &pixmap)
|
||||||
|
{
|
||||||
|
m_pixmap = pixmap;
|
||||||
|
update();
|
||||||
|
emit nativeWidthChanged();
|
||||||
|
emit nativeHeightChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
QPixmap QPixmapItem::pixmap() const
|
||||||
|
{
|
||||||
|
return m_pixmap;
|
||||||
|
}
|
||||||
|
|
||||||
|
void QPixmapItem::setSmooth(const bool smooth)
|
||||||
|
{
|
||||||
|
if (smooth == m_smooth) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
m_smooth = smooth;
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool QPixmapItem::smooth() const
|
||||||
|
{
|
||||||
|
return m_smooth;
|
||||||
|
}
|
||||||
|
|
||||||
|
int QPixmapItem::nativeWidth() const
|
||||||
|
{
|
||||||
|
return m_pixmap.size().width();
|
||||||
|
}
|
||||||
|
|
||||||
|
int QPixmapItem::nativeHeight() const
|
||||||
|
{
|
||||||
|
return m_pixmap.size().height();
|
||||||
|
}
|
||||||
|
|
||||||
|
void QPixmapItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||||
|
{
|
||||||
|
Q_UNUSED(option);
|
||||||
|
Q_UNUSED(widget);
|
||||||
|
|
||||||
|
if (m_pixmap.isNull()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//do without painter save, faster and the support can be compiled out
|
||||||
|
const bool wasAntiAlias = painter->testRenderHint(QPainter::Antialiasing);
|
||||||
|
const bool wasSmoothTransform = painter->testRenderHint(QPainter::SmoothPixmapTransform);
|
||||||
|
painter->setRenderHint(QPainter::Antialiasing, m_smooth);
|
||||||
|
painter->setRenderHint(QPainter::SmoothPixmapTransform, m_smooth);
|
||||||
|
|
||||||
|
painter->drawPixmap(boundingRect(), m_pixmap, m_pixmap.rect());
|
||||||
|
painter->setRenderHint(QPainter::Antialiasing, wasAntiAlias);
|
||||||
|
painter->setRenderHint(QPainter::SmoothPixmapTransform, wasSmoothTransform);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#include "qpixmapitem.moc"
|
58
declarativeimports/qtextracomponents/qpixmapitem.h
Normal file
58
declarativeimports/qtextracomponents/qpixmapitem.h
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* Copyright 2011 Marco Martin <mart@kde.org> *
|
||||||
|
* *
|
||||||
|
* 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 QPIXMAPITEM_H
|
||||||
|
#define QPIXMAPITEM_H
|
||||||
|
|
||||||
|
#include <QDeclarativeItem>
|
||||||
|
#include <QPixmap>
|
||||||
|
|
||||||
|
class QPixmapItem : public QDeclarativeItem
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
Q_PROPERTY(QPixmap pixmap READ pixmap WRITE setPixmap)
|
||||||
|
Q_PROPERTY(bool smooth READ smooth WRITE setSmooth)
|
||||||
|
Q_PROPERTY(int nativeWidth READ nativeWidth NOTIFY nativeWidthChanged)
|
||||||
|
Q_PROPERTY(int nativeHeight READ nativeHeight NOTIFY nativeHeightChanged)
|
||||||
|
|
||||||
|
public:
|
||||||
|
QPixmapItem(QDeclarativeItem *parent=0);
|
||||||
|
~QPixmapItem();
|
||||||
|
|
||||||
|
void setPixmap(const QPixmap &pixmap);
|
||||||
|
QPixmap pixmap() const;
|
||||||
|
|
||||||
|
void setSmooth(const bool smooth);
|
||||||
|
bool smooth() const;
|
||||||
|
|
||||||
|
int nativeWidth() const;
|
||||||
|
int nativeHeight() const;
|
||||||
|
|
||||||
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||||
|
|
||||||
|
Q_SIGNALS:
|
||||||
|
void nativeWidthChanged();
|
||||||
|
void nativeHeightChanged();
|
||||||
|
|
||||||
|
private:
|
||||||
|
QPixmap m_pixmap;
|
||||||
|
bool m_smooth;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
@ -0,0 +1,41 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2009 by Alan Alpert <alan.alpert@nokia.com>
|
||||||
|
* Copyright 2010 by Ménard Alexis <menard@kde.org>
|
||||||
|
* Copyright 2010 by Marco Martin <mart@kde.org>
|
||||||
|
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Library General Public License as
|
||||||
|
* published by the Free Software Foundation; either version 2, 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 Library 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 "qtextracomponentsplugin.h"
|
||||||
|
|
||||||
|
#include <QtDeclarative/qdeclarative.h>
|
||||||
|
|
||||||
|
#include "qpixmapitem.h"
|
||||||
|
#include "qimageitem.h"
|
||||||
|
#include "qiconitem.h"
|
||||||
|
|
||||||
|
void QtExtraComponentsPlugin::registerTypes(const char *uri)
|
||||||
|
{
|
||||||
|
Q_ASSERT(uri == QLatin1String("org.kde.qtextracomponents"));
|
||||||
|
|
||||||
|
qmlRegisterType<QPixmapItem>(uri, 0, 1, "QPixmapItem");
|
||||||
|
qmlRegisterType<QImageItem>(uri, 0, 1, "QImageItem");
|
||||||
|
qmlRegisterType<QIconItem>(uri, 0, 1, "QIconItem");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#include "qtextracomponentsplugin.moc"
|
||||||
|
|
@ -0,0 +1,38 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2009 by Alan Alpert <alan.alpert@nokia.com>
|
||||||
|
* Copyright 2010 by Ménard Alexis <menard@kde.org>
|
||||||
|
* Copyright 2011 by Marco Martin <mart@kde.org>
|
||||||
|
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Library General Public License as
|
||||||
|
* published by the Free Software Foundation; either version 2, 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 Library 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 QTEXTRACOMPONENTSPLUGIN_H
|
||||||
|
#define QTEXTRACOMPONENTSPLUGIN_H
|
||||||
|
|
||||||
|
#include <QDeclarativeExtensionPlugin>
|
||||||
|
|
||||||
|
|
||||||
|
class QtExtraComponentsPlugin : public QDeclarativeExtensionPlugin
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
void registerTypes(const char *uri);
|
||||||
|
};
|
||||||
|
|
||||||
|
Q_EXPORT_PLUGIN2(qtextracomponentsplugin, QtExtraComponentsPlugin);
|
||||||
|
|
||||||
|
#endif
|
29
declarativeimports/test/CMakeLists.txt
Normal file
29
declarativeimports/test/CMakeLists.txt
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
project(components_test)
|
||||||
|
|
||||||
|
find_package(KDE4 REQUIRED)
|
||||||
|
|
||||||
|
include(KDE4Defaults)
|
||||||
|
|
||||||
|
add_definitions (${QT_DEFINITIONS} ${KDE4_DEFINITIONS})
|
||||||
|
|
||||||
|
include_directories(
|
||||||
|
${CMAKE_SOURCE_DIR}
|
||||||
|
${CMAKE_BINARY_DIR}
|
||||||
|
${KDE4_INCLUDES}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
set(components_test_TEST_SRCS
|
||||||
|
test.cpp)
|
||||||
|
|
||||||
|
kde4_add_executable(components_test ${components_test_TEST_SRCS})
|
||||||
|
|
||||||
|
target_link_libraries(components_test kdeclarative ${KDE4_KDECORE_LIBS} ${QT_QTDECLARATIVE_LIBRARY})
|
||||||
|
|
||||||
|
## install
|
||||||
|
|
||||||
|
|
||||||
|
install(TARGETS components_test EXPORT kdelibsLibraryTargets ${INSTALL_TARGETS_DEFAULT_ARGS})
|
||||||
|
|
||||||
|
|
||||||
|
install(FILES "gallery.qml" DESTINATION ${CMAKE_BINARY_DIR}/widgets/components)
|
79
declarativeimports/test/gallery.qml
Normal file
79
declarativeimports/test/gallery.qml
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2010 by Anselmo Lacerda Silveira de Melo <anselmolsm@gmail.com>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Library General Public License as
|
||||||
|
* published by the Free Software Foundation; either version 2, 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 Library 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import Qt 4.7
|
||||||
|
import org.kde.plasma.components 0.1 as PlasmaComponents
|
||||||
|
import org.kde.plasma.core 0.1 as PlasmaCore
|
||||||
|
import org.kde.qtextracomponents 0.1 as QtExtraComponents
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
id: test
|
||||||
|
width: 400
|
||||||
|
height: 500
|
||||||
|
color: "tomato"
|
||||||
|
|
||||||
|
Column {
|
||||||
|
x: 10
|
||||||
|
anchors.fill: parent
|
||||||
|
spacing: 5
|
||||||
|
|
||||||
|
PlasmaComponents.FlashingLabel {
|
||||||
|
id: label
|
||||||
|
font: "Times"
|
||||||
|
}
|
||||||
|
|
||||||
|
Row {
|
||||||
|
id: busyRow
|
||||||
|
|
||||||
|
Repeater {
|
||||||
|
model: 8
|
||||||
|
PlasmaComponents.BusyWidget {
|
||||||
|
width: 50
|
||||||
|
height: 50
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
PlasmaComponents.PushButton {
|
||||||
|
text: "Ok"
|
||||||
|
onClicked: {print("Clicked!"); scrollBar.value=35}
|
||||||
|
}
|
||||||
|
PlasmaComponents.ScrollBar {
|
||||||
|
id: scrollBar
|
||||||
|
}
|
||||||
|
PlasmaComponents.ScrollBar {
|
||||||
|
id: scrollBarV
|
||||||
|
orientation: Qt.Vertical
|
||||||
|
}
|
||||||
|
QtExtraComponents.QPixmapItem {
|
||||||
|
width:200
|
||||||
|
height:100
|
||||||
|
id: pixmapTest
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
PlasmaCore.Svg {
|
||||||
|
id: svgTest
|
||||||
|
imagePath: "widgets/clock"
|
||||||
|
}
|
||||||
|
Component.onCompleted: {
|
||||||
|
label.flash("I am a FlashingLabel!!!");
|
||||||
|
pixmapTest.pixmap = svgTest.pixmap();
|
||||||
|
}
|
||||||
|
}
|
55
declarativeimports/test/test.cpp
Normal file
55
declarativeimports/test/test.cpp
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2011 Marco Martin <mart@gmail.com>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Library General Public License as
|
||||||
|
* published by the Free Software Foundation; either version 2, 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 Library 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 <QApplication>
|
||||||
|
#include <QDeclarativeView>
|
||||||
|
#include <QDeclarativeContext>
|
||||||
|
#include <QScriptEngine>
|
||||||
|
|
||||||
|
#include <kdeclarative.h>
|
||||||
|
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
QApplication app(argc, argv);
|
||||||
|
|
||||||
|
QDeclarativeView view;
|
||||||
|
QDeclarativeContext *context = view.rootContext();
|
||||||
|
context->setContextProperty("backgroundColor",
|
||||||
|
QColor(Qt::yellow));
|
||||||
|
|
||||||
|
KDeclarative kdeclarative;
|
||||||
|
kdeclarative.setDeclarativeEngine(view.engine());
|
||||||
|
kdeclarative.initialize();
|
||||||
|
//binds things like kconfig and icons
|
||||||
|
kdeclarative.setupBindings();
|
||||||
|
|
||||||
|
//If all gone well, the QScriptEngine has been extracted
|
||||||
|
QScriptEngine *scriptEngine = kdeclarative.scriptEngine();
|
||||||
|
Q_ASSERT(scriptEngine);
|
||||||
|
|
||||||
|
QScriptValue global = scriptEngine->globalObject();
|
||||||
|
|
||||||
|
view.setSource(QUrl::fromLocalFile("gallery.qml"));
|
||||||
|
view.show();
|
||||||
|
|
||||||
|
return app.exec();
|
||||||
|
}
|
||||||
|
|
||||||
|
#include "testobject_p.moc"
|
49
declarativeimports/test/testobject_p.h
Normal file
49
declarativeimports/test/testobject_p.h
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2011 Marco Martin <mart@gmail.com>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Library General Public License as
|
||||||
|
* published by the Free Software Foundation; either version 2, 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 Library 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 TESTOBJECT_P_H
|
||||||
|
#define TESTOBJECT_P_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
|
class TestObject : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
Q_PROPERTY(QString prop READ prop WRITE setProp NOTIFY propChanged)
|
||||||
|
|
||||||
|
public:
|
||||||
|
void setProp(const QString &prop)
|
||||||
|
{
|
||||||
|
m_prop = prop;
|
||||||
|
emit propChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString prop() const
|
||||||
|
{
|
||||||
|
return m_prop;
|
||||||
|
}
|
||||||
|
|
||||||
|
Q_SIGNALS:
|
||||||
|
void propChanged();
|
||||||
|
|
||||||
|
private:
|
||||||
|
QString m_prop;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
Loading…
Reference in New Issue
Block a user