diff --git a/browsingbackends/metadatabackends/abstractmetadatamodel.cpp b/browsingbackends/metadatabackends/abstractmetadatamodel.cpp index 67e3b2d9..85a0def4 100644 --- a/browsingbackends/metadatabackends/abstractmetadatamodel.cpp +++ b/browsingbackends/metadatabackends/abstractmetadatamodel.cpp @@ -1,279 +1,278 @@ /*************************************************************************** * Copyright 2011 Sinny Kumari * * * * 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 . * ***************************************************************************/ #include "abstractmetadatamodel.h" #include #include #include #include #include class AbstractMetadataModel::Private { public: Private() { model = 0; } QAbstractItemModel* model; int labelKey; int iconKey; int urlKey; }; AbstractMetadataModel::AbstractMetadataModel (QObject* parent) : QAbstractItemModel (parent) , d (new Private()) { if (metadataModel()) { setSourceModel(metadataModel()); } setRoleNames(MediaCenter::appendAdditionalMediaRoles(roleNames())); } AbstractMetadataModel::~AbstractMetadataModel() { delete d; } QAbstractItemModel* AbstractMetadataModel::sourceModel() const { return d->model; } void AbstractMetadataModel::setSourceModel (QAbstractItemModel* newSourceModel) { if (sourceModel()) { disconnect (sourceModel(), SIGNAL (columnsAboutToBeInserted (QModelIndex, int, int))); disconnect (sourceModel(), SIGNAL (columnsAboutToBeMoved (QModelIndex, int, int, QModelIndex, int))); disconnect (sourceModel(), SIGNAL (columnsAboutToBeRemoved (QModelIndex, int, int))); disconnect (sourceModel(), SIGNAL (columnsInserted (QModelIndex, int, int))); disconnect (sourceModel(), SIGNAL (columnsMoved (QModelIndex, int, int, QModelIndex, int))); disconnect (sourceModel(), SIGNAL (columnsRemoved (QModelIndex, int, int))); disconnect (sourceModel(), SIGNAL (dataChanged (QModelIndex, QModelIndex))); disconnect (sourceModel(), SIGNAL (headerDataChanged (Qt::Orientation, int, int))); disconnect (sourceModel(), SIGNAL (layoutAboutToBeChanged ())); disconnect (sourceModel(), SIGNAL (layoutChanged ())); disconnect (sourceModel(), SIGNAL (modelAboutToBeReset())); disconnect (sourceModel(), SIGNAL (modelReset ())); disconnect (sourceModel(), SIGNAL (rowsAboutToBeInserted (QModelIndex, int, int))); disconnect (sourceModel(), SIGNAL (rowsAboutToBeMoved (QModelIndex, int, int, QModelIndex, int))); disconnect (sourceModel(), SIGNAL (rowsAboutToBeRemoved (QModelIndex, int, int))); disconnect (sourceModel(), SIGNAL (rowsInserted (QModelIndex, int, int))); disconnect (sourceModel(), SIGNAL (rowsMoved (QModelIndex, int, int, QModelIndex, int))); disconnect (sourceModel(), SIGNAL (rowsRemoved (QModelIndex, int, int))); } d->model = newSourceModel; if (sourceModel()) { connect (sourceModel(), SIGNAL (columnsAboutToBeInserted (QModelIndex, int, int)), SLOT (sourceColumnsAboutToBeInserted (QModelIndex, int, int))); connect (sourceModel(), SIGNAL (columnsAboutToBeMoved (QModelIndex, int, int, QModelIndex, int)), SLOT (sourceColumnsAboutToBeMoved (QModelIndex, int, int, QModelIndex, int))); connect (sourceModel(), SIGNAL (columnsAboutToBeRemoved (QModelIndex, int, int)), SLOT (sourceColumnsAboutToBeRemoved (QModelIndex, int, int))); connect (sourceModel(), SIGNAL (columnsInserted (QModelIndex, int, int)), SLOT (sourceColumnsInserted (QModelIndex, int, int))); connect (sourceModel(), SIGNAL (columnsMoved (QModelIndex, int, int, QModelIndex, int)), SLOT (sourceColumnsMoved (QModelIndex, int, int, QModelIndex, int))); connect (sourceModel(), SIGNAL (columnsRemoved (QModelIndex, int, int)), SLOT (sourceColumnsRemoved (QModelIndex, int, int))); connect (sourceModel(), SIGNAL (dataChanged (QModelIndex, QModelIndex)), SLOT (sourceDataChanged (QModelIndex, QModelIndex))); connect (sourceModel(), SIGNAL (headerDataChanged (Qt::Orientation, int, int)), SLOT (sourceHeaderDataChanged (Qt::Orientation, int, int))); connect (sourceModel(), SIGNAL (layoutAboutToBeChanged ()), SLOT (sourceLayoutAboutToBeChanged ())); connect (sourceModel(), SIGNAL (layoutChanged ()), SLOT (sourceLayoutChanged ())); connect (sourceModel(), SIGNAL (modelAboutToBeReset()), SLOT (sourceModelAboutToBeReset ())); connect (sourceModel(), SIGNAL (modelReset ()), SLOT (sourceModelReset ())); connect (sourceModel(), SIGNAL (rowsAboutToBeInserted (QModelIndex, int, int)), SLOT (sourceRowsAboutToBeInserted (QModelIndex, int, int))); connect (sourceModel(), SIGNAL (rowsAboutToBeMoved (QModelIndex, int, int, QModelIndex, int)), SLOT (sourceRowsAboutToBeMoved (QModelIndex, int, int, QModelIndex, int))); connect (sourceModel(), SIGNAL (rowsAboutToBeRemoved (QModelIndex, int, int)), SLOT (sourceRowsAboutToBeRemoved (QModelIndex, int, int))); connect (sourceModel(), SIGNAL (rowsInserted (QModelIndex, int, int)), SLOT (sourceRowsInserted (QModelIndex, int, int))); connect (sourceModel(), SIGNAL (rowsMoved (QModelIndex, int, int, QModelIndex, int)), SLOT (sourceRowsMoved (QModelIndex, int, int, QModelIndex, int))); connect (sourceModel(), SIGNAL (rowsRemoved (QModelIndex, int, int)), SLOT (sourceRowsRemoved (QModelIndex, int, int))); d->labelKey = metadataModel()->roleNames().key("label"); d->iconKey = metadataModel()->roleNames().key("icon"); d->urlKey = metadataModel()->roleNames().key("url"); } } QVariant AbstractMetadataModel::data (const QModelIndex& index, int role) const { if (!metadataModel()) return QVariant(); switch (role) { case Qt::DisplayRole: return metadataModel()->data(index, d->labelKey); case Qt::DecorationRole: return metadataModel()->data(index, d->iconKey); case MediaCenter::MediaUrlRole: return metadataModel()->data(index, d->urlKey); case MediaCenter::IsExpandableRole: return false; } - return QVariant(); + return metadataModel()->data(index, role); } int AbstractMetadataModel::columnCount (const QModelIndex& parent) const { return 1; } int AbstractMetadataModel::rowCount (const QModelIndex& parent) const { if (!metadataModel()) return 0; return metadataModel()->rowCount(parent); } QModelIndex AbstractMetadataModel::parent (const QModelIndex& child) const { return QModelIndex(); } QModelIndex AbstractMetadataModel::index (int row, int column, const QModelIndex& parent) const { - Q_UNUSED(parent); return metadataModel()->index(row, column, parent); } QAbstractItemModel* AbstractMetadataModel::metadataModel() const { MediaCenter::AbstractBrowsingBackend *backend = static_cast(QObject::parent()); return static_cast(backend->metadataModel()); } void AbstractMetadataModel::sourceColumnsAboutToBeInserted ( const QModelIndex & parent, int start, int end ) { beginInsertColumns(parent, start, end); } void AbstractMetadataModel::sourceColumnsAboutToBeMoved ( const QModelIndex & sourceParent, int sourceStart, int sourceEnd, const QModelIndex & destinationParent, int destinationColumn ) { beginMoveColumns(sourceParent, sourceStart, sourceEnd, destinationParent, destinationColumn); } void AbstractMetadataModel::sourceColumnsAboutToBeRemoved ( const QModelIndex & parent, int start, int end ) { beginRemoveColumns(parent, start, end); } void AbstractMetadataModel::sourceColumnsInserted ( const QModelIndex & parent, int start, int end ) { insertColumns(start, end, parent); } void AbstractMetadataModel::sourceColumnsMoved ( const QModelIndex & sourceParent, int sourceStart, int sourceEnd, const QModelIndex & destinationParent, int destinationColumn ) { endMoveColumns(); } void AbstractMetadataModel::sourceColumnsRemoved ( const QModelIndex & parent, int start, int end ) { removeColumns(start, end, parent); } void AbstractMetadataModel::sourceDataChanged ( const QModelIndex & topLeft, const QModelIndex & bottomRight ) { emit dataChanged(topLeft, bottomRight); } void AbstractMetadataModel::sourceHeaderDataChanged ( Qt::Orientation orientation, int first, int last ) { emit headerDataChanged(orientation, first, last); } void AbstractMetadataModel::sourceLayoutAboutToBeChanged () { emit layoutAboutToBeChanged(); } void AbstractMetadataModel::sourceLayoutChanged () { emit layoutChanged(); } void AbstractMetadataModel::sourceModelAboutToBeReset () { beginResetModel(); } void AbstractMetadataModel::sourceModelReset () { reset(); } void AbstractMetadataModel::sourceRowsAboutToBeInserted ( const QModelIndex & parent, int start, int end ) { beginInsertRows(parent, start, end); } void AbstractMetadataModel::sourceRowsAboutToBeMoved ( const QModelIndex & sourceParent, int sourceStart, int sourceEnd, const QModelIndex & destinationParent, int destinationRow ) { beginMoveRows(sourceParent, sourceStart, sourceEnd, destinationParent, destinationRow); } void AbstractMetadataModel::sourceRowsAboutToBeRemoved ( const QModelIndex & parent, int start, int end ) { beginRemoveRows(parent, start, end); } void AbstractMetadataModel::sourceRowsInserted ( const QModelIndex & parent, int start, int end ) { endInsertRows(); } void AbstractMetadataModel::sourceRowsMoved ( const QModelIndex & sourceParent, int sourceStart, int sourceEnd, const QModelIndex & destinationParent, int destinationRow ) { endMoveRows(); } void AbstractMetadataModel::sourceRowsRemoved ( const QModelIndex & parent, int start, int end ) { removeRows(start, end, parent); } void AbstractMetadataModel::resetMetadataModel() { QDeclarativePropertyMap *map = qobject_cast(metadataModel()->property("extraParameters").value()); metadataModel()->setProperty("resourceType", ""); metadataModel()->setProperty("mimeType", ""); metadataModel()->setProperty("limit", ""); Q_FOREACH(const QString &key, map->keys()) { map->clear(key); } } #include "abstractmetadatamodel.moc" diff --git a/browsingbackends/metadatabackends/metadatapicturebackend/metadatapicturemodel.cpp b/browsingbackends/metadatabackends/metadatapicturebackend/metadatapicturemodel.cpp index 75284d25..4df94c6a 100644 --- a/browsingbackends/metadatabackends/metadatapicturebackend/metadatapicturemodel.cpp +++ b/browsingbackends/metadatabackends/metadatapicturebackend/metadatapicturemodel.cpp @@ -1,65 +1,65 @@ /*************************************************************************** * Copyright 2011 Sinny Kumari * * * * 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 . * ***************************************************************************/ #include "metadatapicturemodel.h" #include #include #include #include MetadataPictureModel::MetadataPictureModel (QObject* parent) : AbstractMetadataModel (parent) { if (metadataModel()) { resetMetadataModel(); metadataModel()->setProperty("resourceType", "nfo:Image"); metadataModel()->setProperty("mimeType", ""); - metadataModel()->setProperty("limit", 500); + metadataModel()->setProperty("limit", 50); } else { kDebug() << "WARNING: Constructor called before metadataModel set :/"; } } MetadataPictureModel::~MetadataPictureModel() { } QVariant MetadataPictureModel::data (const QModelIndex& index, int role) const { if (!metadataModel()) { return QVariant(); } if (role == Qt::DecorationRole) { if (!MetadataPictureModel::data(index, MediaCenter::IsExpandableRole).toBool()) return AbstractMetadataModel::data (index, MediaCenter::MediaUrlRole); } if(role == MediaCenter::MediaTypeRole) { return "image"; } else { return AbstractMetadataModel::data(index, role); } } #include "metadatapicturemodel.moc" diff --git a/browsingbackends/metadatabackends/metadatavideobackend/metadatavideomodel.cpp b/browsingbackends/metadatabackends/metadatavideobackend/metadatavideomodel.cpp index b9a011df..397613c2 100644 --- a/browsingbackends/metadatabackends/metadatavideobackend/metadatavideomodel.cpp +++ b/browsingbackends/metadatabackends/metadatavideobackend/metadatavideomodel.cpp @@ -1,95 +1,76 @@ /*************************************************************************** * Copyright 2011 Sinny Kumari * * * * 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 . * ***************************************************************************/ #include "metadatavideomodel.h" #include "metadatavideothumbnailprovider.h" #include #include -#include +#include +#include #include #include #include class MetadataVideoModel::Private { public: - Private() - : thumbProvider(new MetadataVideoThumbnailProvider(QDeclarativeImageProvider::Pixmap)) { - } - MetadataVideoThumbnailProvider* thumbProvider; + int thumbnailKey; }; MetadataVideoModel::MetadataVideoModel(QObject* parent) : AbstractMetadataModel(parent) , d(new Private()) { if(metadataModel()) { + d->thumbnailKey = metadataModel()->roleNames().key("thumbnail"); resetMetadataModel(); metadataModel()->setProperty("resourceType", "nfo:FileDataObject"); metadataModel()->setProperty("mimeType", "video"); - metadataModel()->setProperty("limit", 500); + metadataModel()->setProperty("limit", 4); } else { kDebug() << "WARNING: Constructor called before metadataModel set :/"; } - - connect(d->thumbProvider, SIGNAL(gotThumbnail(QString)), SLOT(gotThumbnail(QString))); - /*qobject_cast(parent)->declarativeEngine()->addImageProvider(QLatin1String("metadatavideothumb"), - d->thumbProvider);*/ } MetadataVideoModel::~MetadataVideoModel() { delete d; } -void MetadataVideoModel::gotThumbnail(const QString& url) -{ - for(int i = 0; i < rowCount(); ++i) { - if(data(index(i, 0), MediaCenter::MediaUrlRole).toUrl() == QUrl(url)) { - emit dataChanged(index(i, 0), index(i, 0)); - } - } -} - QVariant MetadataVideoModel::data(const QModelIndex& index, int role) const { if(!metadataModel()) { return QVariant(); } switch (role) { case MediaCenter::MediaTypeRole: return "video"; - case Qt::DecorationRole: { - QString url = data(index, MediaCenter::MediaUrlRole).toUrl().toString(); - if (d->thumbProvider->hasThumbnail(url)) { - return QString("image://metadatavideothumb/") + url; - } - d->thumbProvider->loadThumbnail(KUrl(url), QSize(256, 256)); - } + case Qt::DecorationRole: + return AbstractMetadataModel::data(index, d->thumbnailKey); default: return AbstractMetadataModel::data(index, role); } } #include "metadatavideomodel.moc" diff --git a/browsingbackends/metadatabackends/metadatavideobackend/metadatavideomodel.h b/browsingbackends/metadatabackends/metadatavideobackend/metadatavideomodel.h index 89129ac0..c13e1e37 100644 --- a/browsingbackends/metadatabackends/metadatavideobackend/metadatavideomodel.h +++ b/browsingbackends/metadatabackends/metadatavideobackend/metadatavideomodel.h @@ -1,44 +1,41 @@ /*************************************************************************** * Copyright 2011 Sinny Kumari * * * * 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 METADATAVIDEOMODEL_H #define METADATAVIDEOMODEL_H #include #include "../abstractmetadatamodel.h" class MetadataVideoModel : public AbstractMetadataModel { Q_OBJECT public: explicit MetadataVideoModel(QObject* parent = 0); virtual ~MetadataVideoModel(); virtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const; -private slots: - void gotThumbnail(const QString& url); - private: class Private; Private* const d; }; #endif // METADATAVIDEOMODEL_H diff --git a/components/CMakeLists.txt b/components/CMakeLists.txt index 4a884152..c02d270c 100644 --- a/components/CMakeLists.txt +++ b/components/CMakeLists.txt @@ -1,9 +1,7 @@ -add_subdirectory(backendsmodel) - install(FILES qmldir DESTINATION ${IMPORTS_INSTALL_DIR}/org/kde/plasma/mediacentercomponents) install(DIRECTORY mediabrowser DESTINATION ${IMPORTS_INSTALL_DIR}/org/kde/plasma/mediacentercomponents) install(DIRECTORY mediacontroller DESTINATION ${IMPORTS_INSTALL_DIR}/org/kde/plasma/mediacentercomponents) install(DIRECTORY mediainfobar DESTINATION ${IMPORTS_INSTALL_DIR}/org/kde/plasma/mediacentercomponents) install(DIRECTORY mediaplayer DESTINATION ${IMPORTS_INSTALL_DIR}/org/kde/plasma/mediacentercomponents) install(DIRECTORY mediawelcome DESTINATION ${IMPORTS_INSTALL_DIR}/org/kde/plasma/mediacentercomponents) install(DIRECTORY runtimedata DESTINATION ${IMPORTS_INSTALL_DIR}/org/kde/plasma/mediacentercomponents) diff --git a/components/backendsmodel/CMakeLists.txt b/components/backendsmodel/CMakeLists.txt deleted file mode 100644 index 0150e94b..00000000 --- a/components/backendsmodel/CMakeLists.txt +++ /dev/null @@ -1,25 +0,0 @@ -project(backendsmodel) -include(KDE4Defaults) - -include_directories( - ${CMAKE_SOURCE_DIR} - ${CMAKE_BINARY_DIR} - ${KDE4_INCLUDES} -) - -set(backendsmodel_SRCS - backendsmodel.cpp - backendsmodelplugin.cpp -) - -qt4_automoc(${backendsmodel_SRCS}) -kde4_add_library(backendsmodelplugin SHARED ${backendsmodel_SRCS}) - -target_link_libraries(backendsmodelplugin - ${QT_QTCORE_LIBRARY} - ${QT_QTDECLARATIVE_LIBRARY} - ${KDE4_KDECORE_LIBRARY} - mediacenterlibs -) - -install(TARGETS backendsmodelplugin DESTINATION ${IMPORTS_INSTALL_DIR}/org/kde/plasma/mediacentercomponents/backendsmodelplugin/) diff --git a/components/backendsmodel/backendsmodelplugin.cpp b/components/backendsmodel/backendsmodelplugin.cpp deleted file mode 100644 index ba33f028..00000000 --- a/components/backendsmodel/backendsmodelplugin.cpp +++ /dev/null @@ -1,12 +0,0 @@ -#include "backendsmodelplugin.h" - -#include "backendsmodel.h" - -#include - -void BackendsModelPlugin::registerTypes (const char* uri) -{ - qmlRegisterType(uri, 0, 1, "BackendsModel"); -} - -#include "backendsmodelplugin.moc" diff --git a/components/backendsmodel/backendsmodelplugin.h b/components/backendsmodel/backendsmodelplugin.h deleted file mode 100644 index f44700f6..00000000 --- a/components/backendsmodel/backendsmodelplugin.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef BACKENDSMODELPLUGIN_H -#define BACKENDSMODELPLUGIN_H - -#include - -class BackendsModelPlugin : public QDeclarativeExtensionPlugin -{ - Q_OBJECT -public: - virtual void registerTypes (const char* uri); -}; - -Q_EXPORT_PLUGIN2(backendsmodelplugin, BackendsModelPlugin) - -#endif // BACKENDSMODELPLUGIN_H diff --git a/components/mediabrowser/MediaBrowser.qml b/components/mediabrowser/MediaBrowser.qml index ad59f33f..ac307699 100644 --- a/components/mediabrowser/MediaBrowser.qml +++ b/components/mediabrowser/MediaBrowser.qml @@ -1,53 +1,58 @@ /* * Copyright 2011 Sinny Kumari * Copyright 2010 Lukas Appelhans * * 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 QtQuick 1.1 import org.kde.metadatamodels 0.1 as MetadataModels Item { id: mediaBrowser clip: true property QtObject currentBrowsingBackend + signal playRequested(string url) + MetadataModels.MetadataModel { id: metadataModel } GridView { id: mediaBrowserGridView anchors.fill: parent cellWidth: width / 5 cellHeight: width / 6 - delegate: MediaItemDelegate {} + delegate: MediaItemDelegate { + backend: currentBrowsingBackend + onPlayRequested: mediaBrowser.playRequested(url) + } highlight: MediaItemHighlight {} - focus: true + //focus: true highlightFollowsCurrentItem: true flow: GridView.TopToBottom cacheBuffer: width*10 } onCurrentBrowsingBackendChanged: { console.log("INIT'ing " + currentBrowsingBackend) currentBrowsingBackend.metadataModel = metadataModel; currentBrowsingBackend.init(); mediaBrowserGridView.model = (function() { return currentBrowsingBackend.backendModel; }) } } diff --git a/components/mediaplayer/MediaPlayer.qml b/components/mediaplayer/MediaPlayer.qml index 5af28e96..178fb893 100644 --- a/components/mediaplayer/MediaPlayer.qml +++ b/components/mediaplayer/MediaPlayer.qml @@ -1,5 +1,35 @@ import QtQuick 1.1 +import Phonon 1.0 as Phonon -Text { - text: "hello world" +Rectangle { + id: mediaPlayerRootRect + color: "black" + + property alias url: video.source + + Phonon.Media { + id: video + anchors.fill: parent + + Phonon.AudioOutput { + id: audioPlayer + anchors.fill: parent + } + + Phonon.Video { + id: videoPlayer + anchors.fill: parent + } + + onTotalTimeChanged: { + } + + onTimeChanged: { + } + } + + function play() + { + video.play(); + } } diff --git a/components/mediawelcome/MediaWelcome.qml b/components/mediawelcome/MediaWelcome.qml index 5cee49ba..bf351be7 100644 --- a/components/mediawelcome/MediaWelcome.qml +++ b/components/mediawelcome/MediaWelcome.qml @@ -1,77 +1,80 @@ /*************************************************************************** * Copyright 2010 by Alessandro Diaferia * * * * 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 . * ***************************************************************************/ import QtQuick 1.1 import org.kde.qtextracomponents 0.1 as QtExtraComponents PathView { id: view clip: true model: homeModel anchors.fill: parent focus: true preferredHighlightBegin: 0.5 preferredHighlightEnd: 0.5 signal backendSelected(variant selectedBackend) delegate: Component { Item { id: wrapper width: parent.width/3 height: parent.height/3 scale: PathView.iconScale Column { anchors.fill: parent QtExtraComponents.QIconItem { icon: decoration height: wrapper.height width: wrapper.width } Text { text: display font.pointSize: 30 anchors.horizontalCenter: parent.horizontalCenter color: "white" smooth: true style: Text.Raised font.bold: true font.italic: true } } MouseArea { anchors.fill: parent onClicked: view.backendSelected(modelObject) } } } path: Path { startX: 0 startY: 10 PathAttribute { name: "iconScale"; value: 0.1 } PathQuad { x: view.width/2; y: view.height/2; controlX: view.width/4; controlY: view.height/4 } PathAttribute { name: "iconScale"; value: 1 } PathQuad { x: view.width; y: 10; controlX: view.width*3/4; controlY: view.height/4 } PathAttribute { name: "iconScale"; value: 0.1 } } + + Keys.onLeftPressed: decrementCurrentIndex() + Keys.onRightPressed: incrementCurrentIndex() } diff --git a/components/qmldir b/components/qmldir index 646927be..6bf94415 100644 --- a/components/qmldir +++ b/components/qmldir @@ -1,7 +1,6 @@ MediaBrowser 0.1 mediabrowser/MediaBrowser.qml MediaController 0.1 mediacontroller/MediaController.qml MediaInfoBar 0.1 mediainfobar/MediaInfoBar.qml MediaPlayer 0.1 mediaplayer/MediaPlayer.qml MediaWelcome 0.1 mediawelcome/MediaWelcome.qml RuntimeData 0.1 runtimedata/RuntimeData.qml -plugin backendsmodelplugin backendsmodelplugin/ diff --git a/libs/mediacenter/CMakeLists.txt b/libs/mediacenter/CMakeLists.txt index d9efe56d..61380079 100644 --- a/libs/mediacenter/CMakeLists.txt +++ b/libs/mediacenter/CMakeLists.txt @@ -1,41 +1,43 @@ set (mediacenterlibs_SRCS gesturerecognizer.cpp playbackgesture.cpp browsergesture.cpp browser.cpp playbackcontrol.cpp playlist.cpp mediacenter.cpp abstractbrowsingbackend.cpp homeapplet.cpp +backendsmodel.cpp # widgets widgets/navigationtoolbar.cpp widgets/viewitem.cpp ) kde4_add_library(mediacenterlibs SHARED ${mediacenterlibs_SRCS}) target_link_libraries(mediacenterlibs ${KDE4_PLASMA_LIBS} ${KDE4_SOLID_LIBS} ${KDE4_PHONON_LIBS} ${KDE4_NEPOMUK_LIBS} ${TAGLIB_LIBRARIES}) install(TARGETS mediacenterlibs ${INSTALL_TARGETS_DEFAULT_ARGS}) set (mediacenterlibs_HDRS mediacenter.h browser.h playbackcontrol.h playlist.h gesturerecognizer.h playbackgesture.h browsergesture.h abstractbrowsingbackend.h homeapplet.h + backendsmodel.h ) set (mediacenterlibs_WIDGETS_HDRS widgets/navigationtoolbar.h widgets/viewitem.h ) install(FILES ${mediacenterlibs_HDRS} DESTINATION ${INCLUDE_INSTALL_DIR}/mediacenter COMPONENT Devel) install(FILES ${mediacenterlibs_WIDGETS_HDRS} DESTINATION ${INCLUDE_INSTALL_DIR}/mediacenter/widgets COMPONENT Devel) install(FILES data/servicetypes/pmc_browsingbackend.desktop DESTINATION ${SERVICETYPES_INSTALL_DIR}) diff --git a/components/backendsmodel/backendsmodel.cpp b/libs/mediacenter/backendsmodel.cpp similarity index 85% rename from components/backendsmodel/backendsmodel.cpp rename to libs/mediacenter/backendsmodel.cpp index fc8ad5b8..093bc0d3 100644 --- a/components/backendsmodel/backendsmodel.cpp +++ b/libs/mediacenter/backendsmodel.cpp @@ -1,63 +1,62 @@ #include "backendsmodel.h" #include #include -BackendsModel::BackendsModel (QObject* parent) : QAbstractListModel (parent) +BackendsModel::BackendsModel (QDeclarativeEngine* engine, QObject* parent) : QAbstractListModel (parent) { MediaCenter::AbstractBrowsingBackend *backend; KSharedPtr service; KService::List list = MediaCenter::AbstractBrowsingBackend::availableBackends(); for (int i=0; icreateInstance(0, QVariantList() << service->storageId()); - loadBrowsingBackend(backend); + loadBrowsingBackend(backend, engine); } QHash roles = roleNames(); roles[ModelObjectRole] = "modelObject"; setRoleNames(roles); } -bool BackendsModel::loadBrowsingBackend(MediaCenter::AbstractBrowsingBackend *backend) +bool BackendsModel::loadBrowsingBackend(MediaCenter::AbstractBrowsingBackend* backend, QDeclarativeEngine* engine) { if (!backend) { kDebug() << "OUCH! Something's wrong with the backend"; return false; } backend->setParent(this); + backend->setDeclarativeEngine(engine); backends.append(backend); return true; } QVariant BackendsModel::data (const QModelIndex& index, int role) const { if (index.row() >= rowCount()) { return QVariant(); } switch (role) { case Qt::DisplayRole: return backends.at(index.row())->name(); case Qt::DecorationRole: return backends.at(index.row())->icon(); case ModelObjectRole: QVariant ptr; ptr.setValue(qobject_cast(backends.at(index.row()))); return ptr; } return QVariant(); } int BackendsModel::rowCount (const QModelIndex& parent) const { return backends.count(); } #include "backendsmodel.moc" - - diff --git a/components/backendsmodel/backendsmodel.h b/libs/mediacenter/backendsmodel.h similarity index 70% rename from components/backendsmodel/backendsmodel.h rename to libs/mediacenter/backendsmodel.h index 5d061888..824596e2 100644 --- a/components/backendsmodel/backendsmodel.h +++ b/libs/mediacenter/backendsmodel.h @@ -1,27 +1,32 @@ #ifndef BACKENDSMODEL_H #define BACKENDSMODEL_H +#include "mediacenter_export.h" + #include +class QDeclarativeEngine; + namespace MediaCenter { class AbstractBrowsingBackend; } -class BackendsModel : public QAbstractListModel +class MEDIACENTER_EXPORT BackendsModel : public QAbstractListModel { Q_OBJECT public: enum Roles { ModelObjectRole = Qt::UserRole + 1 }; - explicit BackendsModel (QObject* parent = 0); + + BackendsModel (QDeclarativeEngine *engine, QObject* parent = 0); virtual QVariant data (const QModelIndex& index, int role = Qt::DisplayRole) const; virtual int rowCount (const QModelIndex& parent = QModelIndex()) const; private: - bool loadBrowsingBackend(MediaCenter::AbstractBrowsingBackend *backend); + bool loadBrowsingBackend(MediaCenter::AbstractBrowsingBackend *backend, QDeclarativeEngine *engine); QList backends; }; #endif // BACKENDSMODEL_H diff --git a/shells/newshell/CMakeLists.txt b/shells/newshell/CMakeLists.txt index fde8e0a6..619bc937 100644 --- a/shells/newshell/CMakeLists.txt +++ b/shells/newshell/CMakeLists.txt @@ -1,26 +1,27 @@ project (plasma-mediacenter) find_package(KDE4 REQUIRED) include (KDE4Defaults) include_directories(${KDE4_INCLUDES}) set(QT_USE_QTOPENGL TRUE) include(${QT_USE_FILE}) set(plasma-mediacenter_SRCS main.cpp mainwindow.cpp ) kde4_add_executable(plasma-mediacenter-new ${plasma-mediacenter_SRCS}) -target_link_libraries(plasma-mediacenter-new mediacenterlibs +target_link_libraries(plasma-mediacenter-new + mediacenterlibs ${KDE4_KDEUI_LIBS} ${KDE4_PLASMA_LIBS} ${KDE4_KIO_LIBS} ${QT_LIBRARIES} ${QT_QTDECLARATIVE_LIBRARIES} kdeclarative ) install(TARGETS plasma-mediacenter-new ${INSTALL_TARGETS_DEFAULT_ARGS}) install(DIRECTORY package/ DESTINATION ${DATA_INSTALL_DIR}/plasma/packages/org.kde.plasma.mediacenter) install(FILES plasma-mediacenter.desktop DESTINATION ${XDG_APPS_INSTALL_DIR}) diff --git a/shells/newshell/mainwindow.cpp b/shells/newshell/mainwindow.cpp index 45925f83..cc34c1d9 100644 --- a/shells/newshell/mainwindow.cpp +++ b/shells/newshell/mainwindow.cpp @@ -1,73 +1,79 @@ /*************************************************************************** * Copyright 2009 by Alessandro Diaferia * * * * 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 . * ***************************************************************************/ #include "mainwindow.h" +#include + #include #include #include +#include #include #include MainWindow::MainWindow(QWidget *parent) : KMainWindow(parent) { KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); if (args->isSet("fullscreen")) { toggleFullScreen(); } args->clear(); QDeclarativeView *view = new QDeclarativeView(this); QGLWidget *glWidget = new QGLWidget; glWidget->setAutoFillBackground(false); view->setViewport(glWidget); view->setAttribute(Qt::WA_OpaquePaintEvent); view->setAttribute(Qt::WA_NoSystemBackground); view->viewport()->setAttribute(Qt::WA_OpaquePaintEvent); view->viewport()->setAttribute(Qt::WA_NoSystemBackground); view->setResizeMode(QDeclarativeView::SizeRootObjectToView); setCentralWidget(view); m_kdeclarative.setDeclarativeEngine(view->engine()); m_kdeclarative.initialize(); m_kdeclarative.setupBindings(); + BackendsModel *backendsModel = new BackendsModel(view->engine(), this); + view->rootContext()->setContextProperty("backendsModel", backendsModel); + m_structure = Plasma::PackageStructure::load("Plasma/Generic"); Plasma::Package *package = new Plasma::Package(QString(), "org.kde.plasma.mediacenter", m_structure); view->setSource(QUrl(package->filePath("mainscript"))); } void MainWindow::toggleFullScreen() { if (windowState() & Qt::WindowFullScreen) { setWindowState(windowState() & ~Qt::WindowFullScreen); } else { setWindowState(windowState() | Qt::WindowFullScreen); } } MainWindow::~MainWindow() { } diff --git a/shells/newshell/package/contents/ui/mediacenter.qml b/shells/newshell/package/contents/ui/mediacenter.qml index 8d102c8e..c5d7133c 100644 --- a/shells/newshell/package/contents/ui/mediacenter.qml +++ b/shells/newshell/package/contents/ui/mediacenter.qml @@ -1,63 +1,65 @@ import QtQuick 1.1 import org.kde.plasma.mediacentercomponents 0.1 as MediaCenterComponents Rectangle { id: mediaCenterRootItem gradient: Gradient { GradientStop { position: 0.0; color: "lightsteelblue" } GradientStop { position: 1.0; color: "black" } } MediaCenterComponents.MediaPlayer { + id: mediaPlayer anchors.fill: parent z: -1 } - MediaCenterComponents.BackendsModel { - id: backendsModel - } - MediaCenterComponents.RuntimeData { id: runtimeData } MediaCenterComponents.MediaController { id: mediaController height: parent.height*0.1 width: parent.width anchors { left: parent.left; right: parent.left; top: parent.top } } MediaCenterComponents.MediaWelcome { width: parent.width model: backendsModel anchors { left: parent.left; right: parent.right; top: mediaController.top; bottom: mediaInfoBar.top } onBackendSelected: { runtimeData.currentBrowsingBackend = selectedBackend; visible = false } } MediaCenterComponents.MediaBrowser { width: parent.width anchors { left: parent.left; right: parent.right; top: mediaController.top; bottom: mediaInfoBar.top } visible: false currentBrowsingBackend: runtimeData.currentBrowsingBackend onCurrentBrowsingBackendChanged: visible = true + onPlayRequested: { + mediaPlayer.url = url + mediaPlayer.play() + mediaPlayer.z = 2 + } } MediaCenterComponents.MediaInfoBar { id: mediaInfoBar height: parent.height * 0.1 width: parent.width anchors { left: parent.left; right: parent.left; bottom: parent.bottom } } }