From: Nicolas C. <nu...@kd...> - 2017-03-23 18:41:01
|
Git commit 8157a140197d6444db4940878bdcbeb31981b57f by Nicolas Carion. Committed on 23/03/2017 at 18:16. Pushed by alcinos into branch 'refactoring_timeline'. Split widget for transitions apart M +1 -0 src/assets/assetlist/view/qmltypes/asseticonprovider.cpp M +7 -1 src/assets/model/assetparametermodel.cpp M +13 -10 src/assets/model/assetparametermodel.hpp M +14 -27 src/assets/view/assetparameterview.cpp M +5 -4 src/assets/view/assetparameterview.hpp C +4 -2 src/assets/view/qml/AssetView.qml [from: src/assets/view/qml/assetView.qml - 093% similarity] M +1 -1 src/mainwindow.cpp M +1 -0 src/transitions/CMakeLists.txt M +1 -1 src/transitions/transitionsrepository.cpp R +14 -8 src/transitions/view/qml/transitionView.qml [from: src/assets/view/qml/assetView.qml - 083% similarity] C +13 -11 src/transitions/view/transitionparameterview.cpp [from: src/assets/view/assetparameterview.cpp - 080% similarity] C +6 -6 src/transitions/view/transitionparameterview.hpp [from: src/assets/view/assetparameterview.hpp - 086% similarity] M +2 -1 src/uiresources.qrc https://commits.kde.org/kdenlive/8157a140197d6444db4940878bdcbeb31981b57f diff --git a/src/assets/assetlist/view/qmltypes/asseticonprovider.cpp b/src/assets/assetlist/view/qmltypes/asseticonprovider.cpp index 04653ffa5..0c6758f6c 100644 --- a/src/assets/assetlist/view/qmltypes/asseticonprovider.cpp +++ b/src/assets/assetlist/view/qmltypes/asseticonprovider.cpp @@ -69,6 +69,7 @@ QImage AssetIconProvider::requestImage(const QString &id, QSize *size, const QSi QImage AssetIconProvider::makeIcon(const QString &effectId, const QString &effectName, const QSize& size) { + Q_UNUSED(size); QPixmap pix(30,30); if (effectName.isEmpty()) { pix.fill(Qt::red); diff --git a/src/assets/model/assetparametermodel.cpp b/src/assets/model/assetparametermodel.cpp index 9bfee03fe..09214f043 100644 --- a/src/assets/model/assetparametermodel.cpp +++ b/src/assets/model/assetparametermodel.cpp @@ -27,9 +27,10 @@ #include "profiles/profilemodel.hpp" -AssetParameterModel::AssetParameterModel(Mlt::Properties *asset, const QDomElement &assetXml, QObject *parent) +AssetParameterModel::AssetParameterModel(Mlt::Properties *asset, const QDomElement &assetXml, const QString& assetId, QObject *parent) : QAbstractListModel(parent) , m_xml(assetXml) + , m_assetId(assetId) , m_asset(asset) { Q_ASSERT(asset->is_valid()); @@ -227,3 +228,8 @@ double AssetParameterModel::parseDoubleAttribute(const QString& attribute, const } return -1; } + +QString AssetParameterModel::getId() const +{ + return m_assetId; +} diff --git a/src/assets/model/assetparametermodel.hpp b/src/assets/model/assetparametermodel.hpp index b98858b39..bdadda5be 100644 --- a/src/assets/model/assetparametermodel.hpp +++ b/src/assets/model/assetparametermodel.hpp @@ -63,7 +63,7 @@ class AssetParameterModel : public QAbstractListModel Q_OBJECT public: - explicit AssetParameterModel(Mlt::Properties *asset, const QDomElement &assetXml, QObject *parent = nullptr); + explicit AssetParameterModel(Mlt::Properties *asset, const QDomElement &assetXml, const QString &assetId, QObject *parent = nullptr); virtual ~AssetParameterModel(); enum { NameRole = Qt::UserRole + 1, @@ -76,15 +76,8 @@ public: DecimalsRole }; - /* @brief Helper function to retrieve the type of a parameter given the string corresponding to it*/ - static ParamType paramTypeFromStr(const QString & type); - - /* @brief Helper function to get a double attribute from a dom element, given its name. - The function additionally parses following keywords: - - %width and %height that are replaced with profile's height and width. - If keywords are found, mathematical operations are supported. For example "%width -1" is a valid value. - */ - static double parseDoubleAttribute(const QString& attribute, const QDomElement& element); + /* @brief Returns the id of the asset represented by this object */ + QString getId() const; /* @brief Set the parameter with given name to the given value @param store: if this is true, then the value is also stored in m_params @@ -96,6 +89,15 @@ public: int rowCount(const QModelIndex &parent = QModelIndex()) const override; protected: + /* @brief Helper function to retrieve the type of a parameter given the string corresponding to it*/ + static ParamType paramTypeFromStr(const QString & type); + + /* @brief Helper function to get a double attribute from a dom element, given its name. + The function additionally parses following keywords: + - %width and %height that are replaced with profile's height and width. + If keywords are found, mathematical operations are supported. For example "%width -1" is a valid value. + */ + static double parseDoubleAttribute(const QString& attribute, const QDomElement& element); struct ParamRow{ ParamType type; @@ -104,6 +106,7 @@ protected: }; QDomElement m_xml; + QString m_assetId; std::unordered_map<QString, ParamRow > m_params; //Store all parameters by name QVector<QString> m_rows; // We store the params name in order of parsing diff --git a/src/assets/view/assetparameterview.cpp b/src/assets/view/assetparameterview.cpp index 65c82c671..4cbda792b 100644 --- a/src/assets/view/assetparameterview.cpp +++ b/src/assets/view/assetparameterview.cpp @@ -20,39 +20,26 @@ ***************************************************************************/ #include "assetparameterview.hpp" -#include "../model/assetparametermodel.hpp" -#include <QString> -#include <QDebug> -#include <QPushButton> - -#include <KDeclarative/KDeclarative> -#include <QQmlContext> - -#include <QStringListModel> +#include "transitions/view/transitionparameterview.hpp" +#include <QDebug> AssetParameterView::AssetParameterView(QWidget *parent) - : QQuickWidget(parent) + : QWidget(parent) { - KDeclarative::KDeclarative kdeclarative; - kdeclarative.setDeclarativeEngine(engine()); - kdeclarative.setupBindings(); - - setResizeMode(QQuickWidget::SizeRootObjectToView); - setSource(QUrl(QStringLiteral("qrc:/qml/assetView.qml"))); - setFocusPolicy(Qt::StrongFocus); - - // Set void model for the moment - QStringListModel *model = new QStringListModel(); - QStringList list; - list << "a" << "b" << "c"<<"s"<<"w"; - model->setStringList(list); - rootContext()->setContextProperty("paramModel", model); + m_transitionProperties = new TransitionParameterView(this); + m_transitionProperties->setVisible(false); } -void AssetParameterView::setModel(std::shared_ptr<AssetParameterModel> model) +void AssetParameterView::showTransitionParams(std::shared_ptr<AssetParameterModel> model) { - m_model = model; - rootContext()->setContextProperty("paramModel", model.get()); + m_transitionProperties->setVisible(true); + m_transitionProperties->setModel(model); + qDebug() <<"=====================================================================" + << "current size "<<m_transitionProperties->size() << size() + << m_transitionProperties->sizeHint(); + + //This is a hack, TODO fix it + m_transitionProperties->resize(QSize(400,400)); } diff --git a/src/assets/view/assetparameterview.hpp b/src/assets/view/assetparameterview.hpp index c67c3cb65..b3cbff495 100644 --- a/src/assets/view/assetparameterview.hpp +++ b/src/assets/view/assetparameterview.hpp @@ -29,17 +29,18 @@ */ -class AssetParameterView : public QQuickWidget +class TransitionParameterView; +class AssetParameterView : public QWidget { Q_OBJECT public: AssetParameterView(QWidget *parent = nullptr); - /* @brief Set the current model to be displayed */ - void setModel(std::shared_ptr<AssetParameterModel> model); + /* @brief Set the current transition to be displayed */ + void showTransitionParams(std::shared_ptr<AssetParameterModel> model); protected: - std::shared_ptr<AssetParameterModel> m_model; + TransitionParameterView* m_transitionProperties; }; #endif diff --git a/src/assets/view/qml/assetView.qml b/src/assets/view/qml/AssetView.qml similarity index 93% copy from src/assets/view/qml/assetView.qml copy to src/assets/view/qml/AssetView.qml index 09e5d581a..138781885 100644 --- a/src/assets/view/qml/assetView.qml +++ b/src/assets/view/qml/AssetView.qml @@ -28,10 +28,12 @@ import QtQml.Models 2.2 Rectangle { id: assetRoot + property var assetModel SystemPalette { id: activePalette } - color: activePalette.window + color: "blue"//activePalette.window + Label {text: "auieuaeuaieuaieuae"} ListView { anchors.fill: parent id: listView @@ -39,7 +41,7 @@ Rectangle { text: display } - model: paramModel + model: assetModel } } diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 2ef1df632..c109b8d72 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -339,7 +339,7 @@ void MainWindow::init(const QString &MltPath, const QUrl &Url, const QString &cl std::shared_ptr<AssetParameterModel> model = TransitionsRepository::get()->getTransition(QStringLiteral("composite")); AssetParameterView * propertiesWidget = new AssetParameterView(this); - propertiesWidget->setModel(model); + propertiesWidget->showTransitionParams(model); qDebug() << "===================================================== creating listview" << model->rowCount(); diff --git a/src/transitions/CMakeLists.txt b/src/transitions/CMakeLists.txt index ccbe39624..0728e83f4 100644 --- a/src/transitions/CMakeLists.txt +++ b/src/transitions/CMakeLists.txt @@ -3,5 +3,6 @@ set(kdenlive_SRCS transitions/transitionsrepository.cpp transitions/transitionlist/view/transitionlistwidget.cpp transitions/transitionlist/model/transitiontreemodel.cpp + transitions/view/transitionparameterview.cpp PARENT_SCOPE) diff --git a/src/transitions/transitionsrepository.cpp b/src/transitions/transitionsrepository.cpp index 33c416033..9a4253a10 100644 --- a/src/transitions/transitionsrepository.cpp +++ b/src/transitions/transitionsrepository.cpp @@ -135,5 +135,5 @@ std::shared_ptr<AssetParameterModel> TransitionsRepository::getTransition(const NULL ); - return std::make_shared<AssetParameterModel>(transition, getXml(transitionId)); + return std::make_shared<AssetParameterModel>(transition, getXml(transitionId), transitionId); } diff --git a/src/assets/view/qml/assetView.qml b/src/transitions/view/qml/transitionView.qml similarity index 83% rename from src/assets/view/qml/assetView.qml rename to src/transitions/view/qml/transitionView.qml index 09e5d581a..c542807fc 100644 --- a/src/assets/view/qml/assetView.qml +++ b/src/transitions/view/qml/transitionView.qml @@ -27,19 +27,25 @@ import QtQuick.Layouts 1.3 import QtQml.Models 2.2 Rectangle { - id: assetRoot + id: transitionRoot SystemPalette { id: activePalette } - color: activePalette.window + color: "red"//activePalette.window - - ListView { + ColumnLayout { anchors.fill: parent - id: listView - delegate: Label{ - text: display + + Label { + Layout.fillWidth:true + text: i18n("Properties of transition ") + transitionName + } + AssetView { + Layout.fillWidth:true + Layout.fillHeight:true + id: assetView + assetModel: paramModel } - model: paramModel } + } diff --git a/src/assets/view/assetparameterview.cpp b/src/transitions/view/transitionparameterview.cpp similarity index 80% copy from src/assets/view/assetparameterview.cpp copy to src/transitions/view/transitionparameterview.cpp index 65c82c671..6ad6de117 100644 --- a/src/assets/view/assetparameterview.cpp +++ b/src/transitions/view/transitionparameterview.cpp @@ -19,40 +19,42 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. * ***************************************************************************/ -#include "assetparameterview.hpp" -#include "../model/assetparametermodel.hpp" -#include <QString> -#include <QDebug> -#include <QPushButton> +#include "transitionparameterview.hpp" +#include "transitions/transitionsrepository.hpp" #include <KDeclarative/KDeclarative> #include <QQmlContext> #include <QStringListModel> -AssetParameterView::AssetParameterView(QWidget *parent) +TransitionParameterView::TransitionParameterView(QWidget *parent) : QQuickWidget(parent) { KDeclarative::KDeclarative kdeclarative; kdeclarative.setDeclarativeEngine(engine()); kdeclarative.setupBindings(); - setResizeMode(QQuickWidget::SizeRootObjectToView); - setSource(QUrl(QStringLiteral("qrc:/qml/assetView.qml"))); - setFocusPolicy(Qt::StrongFocus); - // Set void model for the moment QStringListModel *model = new QStringListModel(); QStringList list; list << "a" << "b" << "c"<<"s"<<"w"; model->setStringList(list); rootContext()->setContextProperty("paramModel", model); + rootContext()->setContextProperty("transitionName", ""); + + setResizeMode(QQuickWidget::SizeRootObjectToView); + setSource(QUrl(QStringLiteral("qrc:/qml/transitionView.qml"))); + setFocusPolicy(Qt::StrongFocus); + } -void AssetParameterView::setModel(std::shared_ptr<AssetParameterModel> model) +void TransitionParameterView::setModel(std::shared_ptr<AssetParameterModel> model) { m_model = model; rootContext()->setContextProperty("paramModel", model.get()); + QString transitionId = model->getId(); + QString name = TransitionsRepository::get()->getName(transitionId); + rootContext()->setContextProperty("transitionName", name); } diff --git a/src/assets/view/assetparameterview.hpp b/src/transitions/view/transitionparameterview.hpp similarity index 86% copy from src/assets/view/assetparameterview.hpp copy to src/transitions/view/transitionparameterview.hpp index c67c3cb65..1c3088b4c 100644 --- a/src/assets/view/assetparameterview.hpp +++ b/src/transitions/view/transitionparameterview.hpp @@ -19,22 +19,22 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. * ***************************************************************************/ -#ifndef ASSETPARAMETERVIEW_H -#define ASSETPARAMETERVIEW_H +#ifndef TRANSITIONPARAMETERVIEW_H +#define TRANSITIONPARAMETERVIEW_H #include <QQuickWidget> -#include "../model/assetparametermodel.hpp" +#include "assets/model/assetparametermodel.hpp" -/* @brief This class is the view for a list of parameters. +/* @brief This class is the view of the properties of a transition */ -class AssetParameterView : public QQuickWidget +class TransitionParameterView : public QQuickWidget { Q_OBJECT public: - AssetParameterView(QWidget *parent = nullptr); + TransitionParameterView(QWidget *parent = nullptr); /* @brief Set the current model to be displayed */ void setModel(std::shared_ptr<AssetParameterModel> model); diff --git a/src/uiresources.qrc b/src/uiresources.qrc index 3d73e1ed3..42a0bb331 100644 --- a/src/uiresources.qrc +++ b/src/uiresources.qrc @@ -22,6 +22,7 @@ <file alias="CornerSelectionShadow.qml">timeline2/view/qml/CornerSelectionShadow.qml</file> <file alias="Timeline.js">timeline2/view/qml/Timeline.js</file> <file alias="assetList.qml">assets/assetlist/view/qml/assetList.qml</file> - <file alias="assetView.qml">assets/view/qml/assetView.qml</file> + <file alias="AssetView.qml">assets/view/qml/AssetView.qml</file> + <file alias="transitionView.qml">transitions/view/qml/transitionView.qml</file> </qresource> </RCC> |