[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-panel-devel
Subject:    RssNOW QML
From:       Giorgos Tsiapaliwkas <terietor () gmail ! com>
Date:       2011-11-16 15:52:26
Message-ID: CAODYyLbK09mD7yxXmw1H2m_0XNwQLhKVZxsPQLZ+kJ20+4kL2g () mail ! gmail ! com
[Download RAW message or body]

Hello,

yesterday thanks to notmart i ported the rssnow plasmoid to plasma components.
But as far as i am concerned the rss plasmoid is missing of two features.

1.Is the ability to add more rss with drag&drop.I didn't get into that yet.
2.When someone clicks the left/right arrow it was supposed that the
Timer component would reset its counting.
But this doesn't work.

I have added some code which is supposed to do the work but it doesn't.

I have added a "console.log("terietor hello");" in the lines which was
supposed to be executed but they never print the message.

thanks in advance

P.S.:the attachments are all the code that the plasmoids is being consist of.
P.S.2:the plasmoid is in the declarative-plasmoids repository
-- 
Giorgos Tsiapaliwkas (terietor)
KDE Developer

terietor.gr

["ListItem.qml" (text/x-qml)]

/*
 *   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 Library 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 QtQuick 1.1
import org.kde.plasma.core 0.1 as PlasmaCore

PlasmaCore.FrameSvgItem {
    id : background
    imagePath: "widgets/frame"
    prefix: "plain"

    width: entryList.width
    height: entryList.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()
    }
}

["ListItemEntry.qml" (text/x-qml)]

/*
 *   Copyright 2010 Marco Martin <notmart@gmail.com>
 *   Copyright 2010 Lukas Appelhans <l.appelhans@gmx.de>
 *
 *   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 Library 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 QtQuick 1.1
import org.kde.plasma.core 0.1 as PlasmaCore

ListItem {
    id: listItem
    property string text;
    property string iconFile;
    property string feedUrl;
    signal clicked;

    Row {
        id : delegateLayout
        width: entryList.width
        height: 50
        spacing: 5
        anchors.left: listItem.padding.left
        anchors.right: listItem.padding.right
        anchors.top: listItem.padding.top

        Image {
            id: image
            source: iconFile
            height: parent.height
            width: parent.height / 2
            anchors.horizontalCenter: width / 2
            anchors.verticalCenter: height / 2
            fillMode: Image.PreserveAspectFit
            smooth:true
            opacity: 0.8
        }
        Text {
            id: title
            clip:true
            width: delegateLayout.width - rightArrow.width - image.width - parent.spacing * 2
            height: delegateLayout.height
            color: theme.textColor
            textFormat: Text.RichText
            text: listItem.text
            wrapMode: Text.Wrap
        }
        /*Text {
            color: theme.textColor
            width: delegateLayout.width
            horizontalAlignment: Text.AlignRight
            text: '<em><small>'+listItem.date+'</em></small>&nbsp;'
        }*/
        Column {
            id: column
            spacing: 5
            PlasmaCore.SvgItem {
                id: leftArrow
                width: 20
                height: 20
                elementId: "left"
                opacity: 0

                Behavior on opacity { PropertyAnimation {} }
                svg: PlasmaCore.Svg {
                    imagePath: "rssnow/left"
                }
                MouseArea {
                    id: leftMouse
                    anchors.fill: leftArrow
                    onClicked: {
                        listItem.clicked()
                        console.log("terietor hello");
                    }
                }
            }
            PlasmaCore.SvgItem {
                id: rightArrow
                width: 20
                height: 20
                elementId: "right"
                opacity: 0

                Behavior on opacity { PropertyAnimation {} }
                svg: PlasmaCore.Svg {
                    imagePath: "rssnow/right"
                }
                MouseArea {
                    id: rightMouse
                    anchors.fill: rightArrow
                    onClicked: {
                        listItem.clicked()
                        console.log("terietor hello");
                    }
                }
            }
        }
    }
    MouseArea {
        anchors.fill: parent
        hoverEnabled: true

        onClicked: {
            if (mouse.x < delegateLayout.width && mouse.x > (delegateLayout.width - leftArrow.width)) {
                if (mouse.y > leftArrow.height) {
                    if (entryList.currentIndex == (entryList.count - 1))
                        entryList.currentIndex = 0
                    else
                        entryList.currentIndex = entryList.currentIndex + 1
                } else
                    if (entryList.currentIndex == 0)
                        entryList.currentIndex = (entryList.count - 1)
                    else
                        entryList.currentIndex = entryList.currentIndex - 1
            } else {
                plasmoid.openUrl(feedUrl)
            }
        }
        onPositionChanged: {
            if (mouse.x < delegateLayout.width && mouse.x > (delegateLayout.width - leftArrow.width)) {
                if (mouse.y > rightArrow.y && mouse.y < (rightArrow.y + rightArrow.height)) {
                    rightArrow.opacity = 0.2
                    leftArrow.opacity = 1
                } else if (mouse.y > leftArrow.y && mouse.y < (leftArrow.y + leftArrow.height)) {
                    leftArrow.opacity = 0.2
                    rightArrow.opacity = 1
                } else {
                    rightArrow.opacity = 1
                    leftArrow.opacity = 1
                }
            } else {
                rightArrow.opacity = 1
                leftArrow.opacity = 1
            }
        }
        onEntered: {
            rightArrow.opacity = 1
            leftArrow.opacity = 1
        }
        onExited: {
            rightArrow.opacity = 0
            leftArrow.opacity = 0
        }
    }
}


//mapFromItem ( Item item, real x, real y )
["main.qml" (text/x-qml)]

/*
*   Copyright 2010 Marco Martin <notmart@gmail.com>
*   Copyright 2010 Lukas Appelhans <l.appelhans@gmx.de>
*
*   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 Library 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 QtQuick 1.1
import org.kde.plasma.core 0.1 as PlasmaCore

Item {
    id: mainWindow

    property string source
    property variant individualSources
    property int scrollInterval
    property int minimumHeight: 200
    property int minimumWidth: 200

    Component.onCompleted: {
        plasmoid.addEventListener('ConfigChanged', configChanged);
        plasmoid.busy = true
    }

    function configChanged()
    {
        source = plasmoid.readConfig("feeds")
        scrollInterval = plasmoid.readConfig("interval")
        var sourceString = new String(source)
        print("Configuration changed: " + source);
        feedSource.connectedSources = source

        individualSources = String(source).split(" ")
        repeater.model = individualSources.length
    }

    PlasmaCore.DataSource {
        id: feedSource
        engine: "rss"
        interval: 50000
        onDataChanged: {
            plasmoid.busy = false
        }
    }

    PlasmaCore.Theme {
        id: theme
    }

    Column {
        PlasmaCore.SvgItem {
            id: svgItem
            width: naturalSize.width / 1.5
            height: naturalSize.height / 1.5
            elementId: "RSSNOW"
            svg: PlasmaCore.Svg {
                id: headersvg
                imagePath: "rssnow/rssnow"
            }
        }

        Repeater {
            id: repeater

            ListView {
                id: entryList
                spacing: 5;
                snapMode: ListView.SnapToItem
                orientation: ListView.Horizontal
                width: mainWindow.width
                height: 50
                clip: true
                highlightMoveDuration: 300
                property int listIndex: index
                model: PlasmaCore.SortFilterModel {
                    filterRole: "feed_url"
                    filterRegExp: individualSources[listIndex]
                    sourceModel: PlasmaCore.DataModel {
                        dataSource: feedSource
                        keyRoleFilter: "items"
                    }
                }
                delegate: ListItemEntry {
                    id: listEntry
                    text: title//+individualSources[listIndex]
                    iconFile: icon
                    feedUrl: link
                    onClicked: {
                        flickTimer.restart();
                        console.log("terietor hello");
                    }
                }

                onFlickEnded: {
                    currentIndex = contentX / contentWidth * count
                }
                Timer {
                    id: flickTimer
                    interval: scrollInterval * 1000
                    running: true
                    repeat: true
                    onTriggered: {
                        if (entryList.currentIndex == (entryList.count - 1)) {
                            entryList.currentIndex = 0
                        } else {
                            entryList.currentIndex = entryList.currentIndex + 1
                        }
                    }
                }
            }
        }
    }
}


_______________________________________________
Plasma-devel mailing list
Plasma-devel@kde.org
https://mail.kde.org/mailman/listinfo/plasma-devel


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic