Fix dynamic text broken because of missing font & keyword params

Fixes #185
parent aeb55fce
......@@ -38,9 +38,8 @@
<paramlistdisplay>Top,Middle,Bottom</paramlistdisplay>
<name>Vertical Alignment</name>
</parameter>
<parameter type="keywords" name="argument" default="#timecode#">
<parameter type="keywords" name="argument" default="#timecode#" paramlist="#timecode#;#frame#;#filedate#;#localfiledate#;#meta.media.0.stream.frame_rate#;#meta.media.0.codec.name#;#meta.media.0.codec.bit_rate#;#meta.media.width#;#meta.media.height#;#meta.attr.comment.markup#">
<name>Text</name>
<keywords>#timecode#;#frame#;#filedate#;#localfiledate#;#meta.media.0.stream.frame_rate#;#meta.media.0.codec.name#;#meta.media.0.codec.bit_rate#;#meta.media.width#;#meta.media.height#;#meta.attr.comment.markup#</keywords>
<keywordsdisplay>timecode;frame;file date;local file date;source frame rate;source codec;source bit rate;source width;source height;source comment</keywordsdisplay>
<paramlistdisplay>timecode,frame,file date,local file date,source frame rate,source codec,source bit rate,source width,source height,source comment</paramlistdisplay>
</parameter>
</effect>
......@@ -33,6 +33,8 @@ set(kdenlive_SRCS
assets/view/widgets/coloreditwidget.cpp
assets/view/widgets/hideparamwidget.cpp
assets/view/widgets/clickablelabelwidget.cpp
assets/view/widgets/fontparamwidget.cpp
assets/view/widgets/keywordparamwidget.cpp
# curves widget
assets/view/widgets/curves/abstractcurvewidget.h
assets/view/widgets/curves/bezier/beziersplineeditor.cpp
......
......@@ -21,6 +21,8 @@
#include "assets/model/assetparametermodel.hpp"
#include "buttonparamwidget.hpp"
#include "boolparamwidget.hpp"
#include "fontparamwidget.hpp"
#include "keywordparamwidget.hpp"
#include "coloreditwidget.hpp"
#include "curves/bezier/beziersplineeditor.h"
#include "curves/cubic/kis_cubic_curve.h"
......@@ -135,6 +137,14 @@ AbstractParamWidget *AbstractParamWidget::construct(const std::shared_ptr<AssetP
widget = new ClickableLabelParamWidget(model, index, parent);
break;
}
case ParamType::Fontfamily: {
widget = new FontParamWidget(model, index, parent);
break;
}
case ParamType::Keywords: {
widget = new KeywordParamWidget(model, index, parent);
break;
}
case ParamType::Animated:
case ParamType::RestrictedAnim:
// widget = new AnimationWidget(model, index, range, parent);
......@@ -143,8 +153,6 @@ AbstractParamWidget *AbstractParamWidget::construct(const std::shared_ptr<AssetP
// widget = new KeyframeEdit(model, index, parent);
// break;
case ParamType::Addedgeometry:
case ParamType::Keywords:
case ParamType::Fontfamily:
// not reimplemented
widget = new Unsupported(model, index, parent);
static_cast<Unsupported *>(widget)->setText(name);
......
......@@ -28,7 +28,6 @@ BoolParamWidget::BoolParamWidget(std::shared_ptr<AssetParameterModel> model, QMo
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();
setToolTip(comment);
m_labelComment->setText(comment);
......
/***************************************************************************
* Copyright (C) 2016 by Nicolas Carion *
* 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 <http://www.gnu.org/licenses/>. *
***************************************************************************/
#include "fontparamwidget.hpp"
#include "assets/model/assetparametermodel.hpp"
FontParamWidget::FontParamWidget(std::shared_ptr<AssetParameterModel> model, QModelIndex index, QWidget *parent)
: AbstractParamWidget(std::move(model), index, parent)
{
setupUi(this);
// setup the comment
QString comment = m_model->data(m_index, AssetParameterModel::CommentRole).toString();
setToolTip(comment);
// setup the name
labelName->setText(m_model->data(m_index, Qt::DisplayRole).toString());
// set check state
slotRefresh();
// emit the signal of the base class when appropriate
connect(this->fontfamilywidget, &QFontComboBox::currentFontChanged, [this](const QFont &font) { emit valueChanged(m_index, font.family(), true); });
}
void FontParamWidget::slotShowComment(bool show)
{
Q_UNUSED(show);
}
void FontParamWidget::slotRefresh()
{
const QString family = m_model->data(m_index, AssetParameterModel::ValueRole).toString();
fontfamilywidget->setCurrentFont(QFont(family));
}
/***************************************************************************
* Copyright (C) 2016 by Nicolas Carion *
* 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 <http://www.gnu.org/licenses/>. *
***************************************************************************/
#ifndef FONTPARAMWIDGET_H
#define FONTPARAMWIDGET_H
#include "abstractparamwidget.hpp"
#include "ui_fontval_ui.h"
#include <QWidget>
/** @brief This class represents a parameter that requires
the user to choose tick a checkbox
*/
class FontParamWidget : public AbstractParamWidget, public Ui::Fontval_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 whether the checkbox should initially be checked
@param parent Parent widget
*/
FontParamWidget(std::shared_ptr<AssetParameterModel> 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;
};
#endif
/***************************************************************************
* Copyright (C) 2016 by Nicolas Carion *
* 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 <http://www.gnu.org/licenses/>. *
***************************************************************************/
#include "keywordparamwidget.hpp"
#include "assets/model/assetparametermodel.hpp"
KeywordParamWidget::KeywordParamWidget(std::shared_ptr<AssetParameterModel> 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();
setToolTip(comment);
// setup the name
label->setText(m_model->data(m_index, Qt::DisplayRole).toString());
QStringList kwrdValues = m_model->data(m_index, AssetParameterModel::ListValuesRole).toStringList();
QStringList kwrdNames = m_model->data(m_index, AssetParameterModel::ListNamesRole).toStringList();
comboboxwidget->addItems(kwrdNames);
int i = 0;
for (const QString &keywordVal : kwrdValues) {
if (i >= comboboxwidget->count()) {
break;
}
comboboxwidget->setItemData(i, keywordVal);
i++;
}
comboboxwidget->insertItem(0, i18n("<select a keyword>"));
comboboxwidget->setCurrentIndex(0);
// set check state
slotRefresh();
// emit the signal of the base class when appropriate
connect(lineeditwidget, &QLineEdit::editingFinished, [this]() {
emit valueChanged(m_index, lineeditwidget->text(), true);
});
connect(comboboxwidget, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
[this](int ix) {
if (ix > 0) {
QString comboval = comboboxwidget->itemData(ix).toString();
this->lineeditwidget->insert(comboval);
emit valueChanged(m_index, lineeditwidget->text(), true);
comboboxwidget->setCurrentIndex(0);
}
});
}
void KeywordParamWidget::slotShowComment(bool show)
{
Q_UNUSED(show);
}
void KeywordParamWidget::slotRefresh()
{
lineeditwidget->setText(m_model->data(m_index, AssetParameterModel::ValueRole).toString());
}
/***************************************************************************
* Copyright (C) 2016 by Nicolas Carion *
* 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 <http://www.gnu.org/licenses/>. *
***************************************************************************/
#ifndef KEYWORDPARAMWIDGET_H
#define KEYWORDPARAMWIDGET_H
#include "abstractparamwidget.hpp"
#include "ui_keywordval_ui.h"
#include <QWidget>
/** @brief This class represents a parameter that requires
the user to choose tick a checkbox
*/
class KeywordParamWidget : public AbstractParamWidget, public Ui::Keywordval_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 whether the checkbox should initially be checked
@param parent Parent widget
*/
KeywordParamWidget(std::shared_ptr<AssetParameterModel> 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;
};
#endif
......@@ -6,19 +6,28 @@
<rect>
<x>0</x>
<y>0</y>
<width>200</width>
<width>570</width>
<height>60</height>
</rect>
</property>
<layout class="QGridLayout">
<property name="margin">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<property name="spacing">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="name">
<widget class="QLabel" name="labelName">
<property name="text">
<string>TextLabel</string>
</property>
......
......@@ -7,16 +7,31 @@
<x>0</x>
<y>0</y>
<width>194</width>
<height>42</height>
<height>139</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="verticalSpacing">
<property name="leftMargin">
<number>0</number>
</property>
<property name="margin">
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<property name="spacing">
<number>0</number>
</property>
<item row="2" column="0">
<widget class="QComboBox" name="comboboxwidget"/>
</item>
<item row="1" column="0">
<widget class="QLineEdit" name="lineeditwidget"/>
</item>
<item row="0" column="0" colspan="2">
<widget class="QLabel" name="label">
<property name="text">
......@@ -27,26 +42,8 @@
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLineEdit" name="lineeditwidget"/>
</item>
<item row="2" column="0">
<widget class="KComboBox" name="comboboxwidget"/>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>KComboBox</class>
<extends>QComboBox</extends>
<header>kcombobox.h</header>
</customwidget>
<customwidget>
<class>QLineEdit</class>
<extends>QLineEdit</extends>
<header>klineedit.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment