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

List:       kde-commits
Subject:    =?utf-8?q?=5Bkde-workspace=5D_plasma/generic/tools=3A_Small_Plas?=
From:       Kevin Ottens <ervin () kde ! org>
Date:       2011-04-30 10:27:53
Message-ID: 20110430102753.E6092A60A4 () git ! kde ! org
[Download RAW message or body]

Git commit 142a8680464e06f7d258714a9e1bf1d986839515 by Kevin Ottens.
Committed on 30/04/2011 at 12:25.
Pushed by ervin into branch 'master'.

Small Plasma Remote Widgets browser

QML based small Plasma Remote Widgets browser allowing you to see
all the computers exposing those, and the actual content. Also allows
to add such remote widgets to your current activity just by clicking on
them.

M  +1    -0    plasma/generic/tools/CMakeLists.txt     
A  +12   -0    plasma/generic/tools/remote-widgets-browser/CMakeLists.txt         \
[License: UNKNOWN]  * A  +3    -0    \
plasma/generic/tools/remote-widgets-browser/Messages.sh         [License: UNKNOWN]  * \
A  +87   -0    plasma/generic/tools/remote-widgets-browser/main.cpp         [License: \
GPL (v2/3)] A  +109  -0    plasma/generic/tools/remote-widgets-browser/main.qml       \
[License: UNKNOWN]  * A  +59   -0    \
plasma/generic/tools/remote-widgets-browser/plasmafiltermodel.cpp         [License: \
GPL (v2/3)] A  +43   -0    \
plasma/generic/tools/remote-widgets-browser/plasmafiltermodel.h         [License: GPL \
(v2/3)] A  +5    -0    plasma/generic/tools/remote-widgets-browser/resources.qrc      \
[License: UNKNOWN]  *

The files marked with a * at the end have a non valid license. Please read: \
http://techbase.kde.org/Policies/Licensing_Policy and use the headers which are \
listed at that page.


http://commits.kde.org/kde-workspace/142a8680464e06f7d258714a9e1bf1d986839515

diff --git a/plasma/generic/tools/CMakeLists.txt \
b/plasma/generic/tools/CMakeLists.txt index b6f8a99..aa628a8 100644
--- a/plasma/generic/tools/CMakeLists.txt
+++ b/plasma/generic/tools/CMakeLists.txt
@@ -1,3 +1,4 @@
 add_subdirectory(engineexplorer)
 add_subdirectory(plasmoidviewer)
+add_subdirectory(remote-widgets-browser)
 add_subdirectory(wallpaperviewer)
diff --git a/plasma/generic/tools/remote-widgets-browser/CMakeLists.txt \
b/plasma/generic/tools/remote-widgets-browser/CMakeLists.txt new file mode 100644
index 0000000..02f69f9
--- /dev/null
+++ b/plasma/generic/tools/remote-widgets-browser/CMakeLists.txt
@@ -0,0 +1,12 @@
+set(remote_widgets_browser_SRCS
+    main.cpp
+    plasmafiltermodel.cpp
+)
+
+qt4_add_resources(remote_widgets_browser_SRCS resources.qrc)
+
+kde4_add_executable(remote-widgets-browser ${remote_widgets_browser_SRCS})
+target_link_libraries(remote-widgets-browser ${KDE4_PLASMA_LIBS} ${KDE4_KIO_LIBS} \
kdeclarative) +
+install(TARGETS remote-widgets-browser ${INSTALL_TARGETS_DEFAULT_ARGS})
+
diff --git a/plasma/generic/tools/remote-widgets-browser/Messages.sh \
b/plasma/generic/tools/remote-widgets-browser/Messages.sh new file mode 100755
index 0000000..a37d4f1
--- /dev/null
+++ b/plasma/generic/tools/remote-widgets-browser/Messages.sh
@@ -0,0 +1,3 @@
+#! /usr/bin/env bash
+$XGETTEXT *.cpp *.h -o $podir/remote-widgets-browser.pot
+
diff --git a/plasma/generic/tools/remote-widgets-browser/main.cpp \
b/plasma/generic/tools/remote-widgets-browser/main.cpp new file mode 100644
index 0000000..e4bf890
--- /dev/null
+++ b/plasma/generic/tools/remote-widgets-browser/main.cpp
@@ -0,0 +1,87 @@
+/* Copyright 2011 Kevin Ottens <ervin@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) version 3 or any later version
+   accepted by the membership of KDE e.V. (or its successor approved
+   by the membership of KDE e.V.), which shall act as a proxy
+   defined in Section 14 of version 3 of the license.
+
+   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 <KApplication>
+#include <KAboutData>
+#include <KCmdLineArgs>
+#include <kdeclarative.h>
+#include <KDirLister>
+#include <KDirModel>
+#include <KLocale>
+#include <KStandardDirs>
+
+#include <QtDeclarative/QDeclarativeContext>
+#include <QtDeclarative/QDeclarativeEngine>
+#include <QtDeclarative/QDeclarativeView>
+#include <QtGui/QSortFilterProxyModel>
+
+#include "plasmafiltermodel.h"
+
+static const char description[] = I18N_NOOP("Explore the Plasma Widgets shared on \
the network"); +static const char version[] = "0.1";
+
+int main(int argc, char **argv)
+{
+    KAboutData aboutData("remote-widgets-browser", 0, ki18n("Plasma Remote Widgets \
Browser"), +                         version, ki18n(description), \
KAboutData::License_GPL, +                         ki18n("(c) 2011 The KDE Team"));
+    aboutData.addAuthor(ki18n("Kevin Ottens"),
+                        ki18n( "Author" ),
+                        "ervin@kde.org");
+    aboutData.setProgramIconName("plasma");
+
+    KCmdLineArgs::init(argc, argv, &aboutData);
+
+    KApplication app;
+
+    QDeclarativeView *view = new QDeclarativeView;
+
+    KDirModel *model = new KDirModel(view);
+    KDirLister *lister = new KDirLister(view);
+    QSortFilterProxyModel *sorter = new QSortFilterProxyModel(view);
+    PlasmaFilterModel *filter = new PlasmaFilterModel(view);
+
+    lister->openUrl(KUrl("network:/"), KDirLister::Keep);
+    model->setDirLister(lister);
+    sorter->setSourceModel(model);
+    filter->setSourceModel(sorter);
+
+    sorter->setDynamicSortFilter(true);
+    sorter->sort(0);
+
+    KDeclarative kdeclarative;
+    kdeclarative.setDeclarativeEngine(view->engine());
+    kdeclarative.initialize();
+    //binds things like kconfig and icons
+    kdeclarative.setupBindings();
+
+    view->setResizeMode(QDeclarativeView::SizeRootObjectToView);
+
+    foreach (const QString &importPath, KGlobal::dirs()->findDirs("module", \
"imports")) { +        view->engine()->addImportPath(importPath);
+    }
+
+    view->rootContext()->setContextProperty("plasmaModel", filter);
+    view->setSource(QUrl("qrc:/main.qml"));
+    view->show();
+
+    return app.exec();
+}
diff --git a/plasma/generic/tools/remote-widgets-browser/main.qml \
b/plasma/generic/tools/remote-widgets-browser/main.qml new file mode 100644
index 0000000..b130aac
--- /dev/null
+++ b/plasma/generic/tools/remote-widgets-browser/main.qml
@@ -0,0 +1,109 @@
+import QtQuick 1.0
+import org.kde.qtextracomponents 0.1
+import org.kde.plasma.graphicswidgets 0.1
+
+Rectangle {
+    id: page
+    width: 500; height: 500
+    color: "white"
+
+    Component {
+        id: appDelegate
+
+        Item {
+            width: 200; height: 100
+
+            Rectangle {
+                id: background
+                width: parent.width - 2
+                height: parent.height
+                anchors.centerIn: parent
+                radius: 5
+                color: "lightsteelblue"
+                opacity: 0
+                Behavior on opacity {
+                    NumberAnimation {
+                        duration: 200
+                        easing.type: Easing.InOutCubic
+                    }
+                }
+            }
+            QIconItem {
+                id: iconItem
+                width: 64; height: 64
+                y: 10; anchors.horizontalCenter: parent.horizontalCenter
+                icon: decoration
+            }
+            Text {
+                anchors { top: iconItem.bottom; horizontalCenter: \
parent.horizontalCenter } +                text: display
+                width: parent.width - 8
+                elide: Text.ElideRight
+                horizontalAlignment: Text.AlignHCenter
+            }
+            MouseArea {
+                anchors.fill: parent
+                hoverEnabled: true
+                onClicked: {
+                    var point = mapToItem(gridView, mouse.x, mouse.y)
+                    var index = gridView.indexAt(point.x, point.y)
+                    gridView.currentIndex = index
+
+                    var modelIndex = filterModel.modelIndex(index)
+                    if (hasModelChildren) {
+                        filterModel.rootIndex = modelIndex
+                    } else {
+                        plasmaModel.runIndex(modelIndex)
+                    }
+                }
+                onEntered: background.opacity = 0.5
+                onExited: background.opacity = 0
+            }
+        }
+    }
+
+    Component {
+        id: appHighlight
+        Rectangle {
+            radius: 5
+            border.color: "black"
+            border.width: 2
+        }
+    }
+
+    Component {
+        id: backBar
+
+        Rectangle {
+            height: backButton.height + 8
+            width: parent.width
+            color: "transparent"
+
+            PushButton {
+                id: backButton
+                anchors.verticalCenter: parent.verticalCenter
+                x: 4
+                text: i18n("Back")
+                onClicked: {
+                    filterModel.rootIndex = filterModel.parentModelIndex
+                }
+            }
+        }
+    }
+
+    VisualDataModel {
+        id: filterModel
+        model: plasmaModel
+        delegate: appDelegate
+    }
+
+    GridView {
+        id: gridView
+        anchors.fill: parent
+        cellWidth: 206; cellHeight: 106
+        header: backBar
+        highlight: appHighlight
+        focus: true
+        model: filterModel
+    }
+}
diff --git a/plasma/generic/tools/remote-widgets-browser/plasmafiltermodel.cpp \
b/plasma/generic/tools/remote-widgets-browser/plasmafiltermodel.cpp new file mode \
100644 index 0000000..e6637a1
--- /dev/null
+++ b/plasma/generic/tools/remote-widgets-browser/plasmafiltermodel.cpp
@@ -0,0 +1,59 @@
+/* Copyright 2011 Kevin Ottens <ervin@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) version 3 or any later version
+   accepted by the membership of KDE e.V. (or its successor approved
+   by the membership of KDE e.V.), which shall act as a proxy
+   defined in Section 14 of version 3 of the license.
+
+   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 "plasmafiltermodel.h"
+
+#include <KDirModel>
+#include <KRun>
+
+PlasmaFilterModel::PlasmaFilterModel(QObject *parent)
+    : KRecursiveFilterProxyModel(parent)
+{
+    setDynamicSortFilter(true);
+}
+
+PlasmaFilterModel::~PlasmaFilterModel()
+{
+}
+
+bool PlasmaFilterModel::filterAcceptsColumn(int sourceColumn, const QModelIndex&) \
const +{
+    return sourceColumn==0;
+}
+
+bool PlasmaFilterModel::acceptRow(int sourceRow, const QModelIndex &sourceParent) \
const +{
+    QModelIndex sourceChild = sourceModel()->index(sourceRow, 0, sourceParent);
+
+    if (sourceModel()->canFetchMore(sourceChild)) {
+        sourceModel()->fetchMore(sourceChild);
+    }
+
+    KFileItem file = sourceChild.data(KDirModel::FileItemRole).value<KFileItem>();
+    return file.targetUrl().protocol()=="plasma";
+}
+
+void PlasmaFilterModel::runIndex(const QModelIndex &index)
+{
+    KFileItem file = index.data(KDirModel::FileItemRole).value<KFileItem>();
+    new KRun(file.targetUrl(), 0);
+}
+
diff --git a/plasma/generic/tools/remote-widgets-browser/plasmafiltermodel.h \
b/plasma/generic/tools/remote-widgets-browser/plasmafiltermodel.h new file mode \
100644 index 0000000..1cb930a
--- /dev/null
+++ b/plasma/generic/tools/remote-widgets-browser/plasmafiltermodel.h
@@ -0,0 +1,43 @@
+/* Copyright 2011 Kevin Ottens <ervin@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) version 3 or any later version
+   accepted by the membership of KDE e.V. (or its successor approved
+   by the membership of KDE e.V.), which shall act as a proxy
+   defined in Section 14 of version 3 of the license.
+
+   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 PLASMAFILTERMODEL_H
+#define PLASMAFILTERMODEL_H
+
+#include <krecursivefilterproxymodel.h>
+
+class PlasmaFilterModel : public KRecursiveFilterProxyModel
+{
+    Q_OBJECT
+
+public:
+    PlasmaFilterModel(QObject *parent = 0);
+    virtual ~PlasmaFilterModel();
+
+    virtual bool filterAcceptsColumn(int sourceColumn, const QModelIndex \
&sourceParent) const; +    virtual bool acceptRow(int sourceRow, const QModelIndex \
&sourceParent) const; +
+public slots:
+    void runIndex(const QModelIndex &index);
+};
+
+#endif
+
diff --git a/plasma/generic/tools/remote-widgets-browser/resources.qrc \
b/plasma/generic/tools/remote-widgets-browser/resources.qrc new file mode 100644
index 0000000..6b2d0a7
--- /dev/null
+++ b/plasma/generic/tools/remote-widgets-browser/resources.qrc
@@ -0,0 +1,5 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource>
+    <file>main.qml</file>
+</qresource>
+</RCC>


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

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