From fddb86860f4cc72709d1e83d988adf8b4ba0679a Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Mardelle Date: Thu, 29 Mar 2018 22:31:04 +0200 Subject: [PATCH] Reintroduce url param widget --- src/assets/CMakeLists.txt | 1 + src/assets/model/assetparametermodel.cpp | 2 + src/assets/model/assetparametermodel.hpp | 1 + .../view/widgets/abstractparamwidget.cpp | 5 +- src/assets/view/widgets/urlparamwidget.cpp | 69 +++++++++ src/assets/view/widgets/urlparamwidget.hpp | 58 ++++++++ src/ui/urlval_ui.ui | 137 +++++++++--------- 7 files changed, 201 insertions(+), 72 deletions(-) create mode 100644 src/assets/view/widgets/urlparamwidget.cpp create mode 100644 src/assets/view/widgets/urlparamwidget.hpp diff --git a/src/assets/CMakeLists.txt b/src/assets/CMakeLists.txt index 694e03998..79eed8e3b 100644 --- a/src/assets/CMakeLists.txt +++ b/src/assets/CMakeLists.txt @@ -15,6 +15,7 @@ set(kdenlive_SRCS #assets/view/widgets/animationwidget.cpp assets/view/widgets/boolparamwidget.cpp assets/view/widgets/switchparamwidget.cpp + assets/view/widgets/urlparamwidget.cpp assets/view/widgets/doubleparamwidget.cpp assets/view/widgets/colorwheel.cpp assets/view/widgets/slidewidget.cpp diff --git a/src/assets/model/assetparametermodel.cpp b/src/assets/model/assetparametermodel.cpp index 992535a62..4a8049f24 100644 --- a/src/assets/model/assetparametermodel.cpp +++ b/src/assets/model/assetparametermodel.cpp @@ -276,6 +276,8 @@ QVariant AssetParameterModel::data(const QModelIndex &index, int role) const return parseAttribute(QStringLiteral("decimals"), element); case DefaultRole: return parseAttribute(QStringLiteral("default"), element); + case FilterRole: + return parseAttribute(QStringLiteral("filter"), element); case SuffixRole: return element.attribute(QStringLiteral("suffix")); case OpacityRole: diff --git a/src/assets/model/assetparametermodel.hpp b/src/assets/model/assetparametermodel.hpp index 36c4332e6..6890cc362 100644 --- a/src/assets/model/assetparametermodel.hpp +++ b/src/assets/model/assetparametermodel.hpp @@ -86,6 +86,7 @@ public: ListValuesRole, ListNamesRole, FactorRole, + FilterRole, ScaleRole, OpacityRole, InRole, diff --git a/src/assets/view/widgets/abstractparamwidget.cpp b/src/assets/view/widgets/abstractparamwidget.cpp index a215d78cd..ed9dd0abf 100644 --- a/src/assets/view/widgets/abstractparamwidget.cpp +++ b/src/assets/view/widgets/abstractparamwidget.cpp @@ -31,6 +31,7 @@ #include "positioneditwidget.hpp" #include "coloreditwidget.hpp" #include "slidewidget.hpp" +#include "urlparamwidget.hpp" #include #include @@ -105,6 +106,9 @@ AbstractParamWidget *AbstractParamWidget::construct(const std::shared_ptr. * + ***************************************************************************/ + +#include "urlparamwidget.hpp" +#include "assets/model/assetparametermodel.hpp" + +#include + +UrlParamWidget::UrlParamWidget(std::shared_ptr model, QModelIndex index, QWidget *parent) + : AbstractParamWidget(std::move(model), index, parent) +{ + setupUi(this); + + // setup the comment + QString name = m_model->data(m_index, AssetParameterModel::NameRole).toString(); + QString comment = m_model->data(m_index, AssetParameterModel::CommentRole).toString(); + labelComment->setText(comment); + setToolTip(comment); + labelComment->setHidden(true); + QString filter = m_model->data(m_index, AssetParameterModel::FilterRole).toString(); + if (!filter.isEmpty()) { + urlwidget->setFilter(filter); + } + slotRefresh(); + + // setup the name + label->setText(m_model->data(m_index, Qt::DisplayRole).toString()); + + // set check state + slotRefresh(); + + // emit the signal of the base class when appropriate + connect(this->urlwidget, &KUrlRequester::urlSelected, [this](QUrl url) { + emit valueChanged(m_index, url.toLocalFile(), true); }); +} + +void UrlParamWidget::slotShowComment(bool show) +{ + if (!labelComment->text().isEmpty()) { + labelComment->setVisible(show); + } +} + +void UrlParamWidget::slotRefresh() +{ + urlwidget->setUrl(QUrl::fromLocalFile(m_model->data(m_index, AssetParameterModel::ValueRole).toString())); +} + +void UrlParamWidget::slotSetRange(QPair) +{ +} diff --git a/src/assets/view/widgets/urlparamwidget.hpp b/src/assets/view/widgets/urlparamwidget.hpp new file mode 100644 index 000000000..0187e8785 --- /dev/null +++ b/src/assets/view/widgets/urlparamwidget.hpp @@ -0,0 +1,58 @@ +/*************************************************************************** + * Copyright (C) 2018 by Jean-Baptiste Mardelle * + * This file is part of Kdenlive. See www.kdenlive.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, see . * + ***************************************************************************/ + +#ifndef URLPARAMWIDGET_H +#define URLPARAMWIDGET_H + +#include "abstractparamwidget.hpp" +#include "ui_urlval_ui.h" +#include + +/** @brief This class represents a parameter that requires + the user to choose tick a checkbox + */ +class UrlParamWidget : public AbstractParamWidget, public Ui::Urlval_UI +{ + Q_OBJECT +public: + /** @brief Constructor for the widgetComment + @param name String containing the name of the parameter + @param comment Optional string containing the comment associated to the parameter + @param checked Boolean indicating wether the checkbox should initially be checked + @param parent Parent widget + */ + UrlParamWidget(std::shared_ptr model, QModelIndex index, QWidget *parent); + +public slots: + /** @brief Toggle the comments on or off + */ + void slotShowComment(bool show) override; + + /** @brief refresh the properties to reflect changes in the model + */ + void slotRefresh() override; + + /** @brief update the clip's in/out point + */ + void slotSetRange(QPair) override; +}; + +#endif diff --git a/src/ui/urlval_ui.ui b/src/ui/urlval_ui.ui index 625f4bc59..29e0e287c 100644 --- a/src/ui/urlval_ui.ui +++ b/src/ui/urlval_ui.ui @@ -7,87 +7,82 @@ 0 0 159 - 23 + 60 - - - 0 - - - 0 - - - - - - - - 1 - 0 - - - - TextLabel - - - - - - - - 1 - 0 - - - - - - - - - - - 0 - - - 0 - - - 0 - - - 15 - - - - - QFrame::StyledPanel - - - QFrame::Raised - - - Qt::RichText - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - true - - - - + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + + + 1 + 0 + + + + TextLabel + - + + + + + + 1 + 0 + + + + + + + + + QFrame::NoFrame + + + QFrame::Plain + + + -1 + + + Qt::RichText + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + true + + + + KUrlRequester QFrame
kurlrequester.h
+ 1
-- GitLab