Commit 0865f2f9 authored by Julius Künzel's avatar Julius Künzel 💬
Browse files

[AssetLists] Remove workaround for (fixed) Qt bug

https://bugreports.qt.io/browse/QTBUG-57714 is fixed since Qt 5.9.0, we
require 5.15.2 since a while so we can remove workaround
parent f0b95f07
Pipeline #249029 passed with stage
in 5 minutes and 33 seconds
......@@ -62,9 +62,12 @@ bool AssetListWidget::isFavorite(const QModelIndex &index) const
return m_model->isFavorite(m_proxyModel->mapToSource(index));
}
void AssetListWidget::setFavorite(const QModelIndex &index, bool favorite, bool isEffect)
void AssetListWidget::setFavorite(const QModelIndex &index, bool favorite)
{
m_model->setFavorite(m_proxyModel->mapToSource(index), favorite, isEffect);
m_model->setFavorite(m_proxyModel->mapToSource(index), favorite, isEffect());
emit m_proxyModel->dataChanged(index, index, QVector<int>());
m_proxyModel->reloadFilterOnFavorite();
emit reloadFavorites();
}
void AssetListWidget::deleteCustomEffect(const QModelIndex &index)
......@@ -72,9 +75,9 @@ void AssetListWidget::deleteCustomEffect(const QModelIndex &index)
m_model->deleteEffect(m_proxyModel->mapToSource(index));
}
QString AssetListWidget::getDescription(bool isEffect, const QModelIndex &index) const
QString AssetListWidget::getDescription(const QModelIndex &index) const
{
return m_model->getDescription(isEffect, m_proxyModel->mapToSource(index));
return m_model->getDescription(isEffect(), m_proxyModel->mapToSource(index));
}
void AssetListWidget::setFilterName(const QString &pattern)
......@@ -104,3 +107,14 @@ void AssetListWidget::activate(const QModelIndex &ix)
const QString assetId = m_model->data(m_proxyModel->mapToSource(ix), AssetTreeModel::IdRole).toString();
emit activateAsset(getMimeData(assetId));
}
bool AssetListWidget::showDescription() const
{
return KdenliveSettings::showeffectinfo();
}
void AssetListWidget::setShowDescription(bool show)
{
KdenliveSettings::setShoweffectinfo(show);
emit showDescriptionChanged();
}
......@@ -21,38 +21,49 @@ class AssetListWidget : public QQuickWidget
Q_OBJECT
/** @brief Should the descriptive info box be displayed
*/
Q_PROPERTY(bool showDescription READ showDescription WRITE setShowDescription NOTIFY showDescriptionChanged)
public:
AssetListWidget(QWidget *parent = Q_NULLPTR);
~AssetListWidget() override;
virtual bool isEffect() const = 0;
/** @brief Returns the name of the asset given its model index */
QString getName(const QModelIndex &index) const;
Q_INVOKABLE QString getName(const QModelIndex &index) const;
/** @brief Returns true if this effect belongs to favorites */
bool isFavorite(const QModelIndex &index) const;
Q_INVOKABLE bool isFavorite(const QModelIndex &index) const;
/** @brief Sets whether this effect belongs to favorites */
void setFavorite(const QModelIndex &index, bool favorite = true, bool isEffect = true);
Q_INVOKABLE void setFavorite(const QModelIndex &index, bool favorite = true);
/** @brief Delete a custom effect */
void deleteCustomEffect(const QModelIndex &index);
virtual void reloadCustomEffectIx(const QModelIndex &index) = 0;
virtual void editCustomAsset(const QModelIndex &index) = 0;
Q_INVOKABLE void deleteCustomEffect(const QModelIndex &index);
Q_INVOKABLE virtual void reloadCustomEffectIx(const QModelIndex &index) = 0;
Q_INVOKABLE virtual void editCustomAsset(const QModelIndex &index) = 0;
/** @brief Returns the description of the asset given its model index */
QString getDescription(bool isEffect, const QModelIndex &index) const;
Q_INVOKABLE QString getDescription(const QModelIndex &index) const;
/** @brief Sets the pattern against which the assets' names are filtered */
void setFilterName(const QString &pattern);
Q_INVOKABLE void setFilterName(const QString &pattern);
Q_INVOKABLE virtual void setFilterType(const QString &type) = 0;
/** @brief Return mime type used for drag and drop. It can be kdenlive/effect,
kdenlive/composition or kdenlive/transition*/
virtual QString getMimeType(const QString &assetId) const = 0;
* kdenlive/composition or kdenlive/transition
*/
Q_INVOKABLE virtual QString getMimeType(const QString &assetId) const = 0;
virtual bool isAudio(const QString &assetId) const = 0;
QVariantMap getMimeData(const QString &assetId) const;
Q_INVOKABLE QVariantMap getMimeData(const QString &assetId) const;
void activate(const QModelIndex &ix);
Q_INVOKABLE void activate(const QModelIndex &ix);
/** @brief Should the descriptive info box be displayed
*/
bool showDescription() const;
void setShowDescription(bool show);
/** @brief Rebuild the view by resetting the source. Is there a better way? */
void reset();
......@@ -66,4 +77,6 @@ protected:
signals:
void activateAsset(const QVariantMap data);
void showDescriptionChanged();
void reloadFavorites();
};
......@@ -355,7 +355,7 @@ Rectangle {
text: i18n("Edit Info")
visible: isEffectList && assetContextMenu.isCustom
onTriggered: {
assetlist.editCustomEffectInfo(sel.currentIndex)
assetlist.editCustomAsset(sel.currentIndex)
}
}
MenuItem {
......
......@@ -36,8 +36,8 @@ EffectListWidget::EffectListWidget(QWidget *parent)
m_proxyModel->setSourceModel(m_model.get());
m_proxyModel->setSortRole(EffectTreeModel::NameRole);
m_proxyModel->sort(0, Qt::AscendingOrder);
m_proxy = new EffectListWidgetProxy(this);
rootContext()->setContextProperty("assetlist", m_proxy);
rootContext()->setContextProperty("assetlist", this);
rootContext()->setContextProperty("assetListModel", m_proxyModel.get());
rootContext()->setContextProperty("isEffectList", true);
m_assetIconProvider = new AssetIconProvider(true);
......@@ -47,13 +47,6 @@ EffectListWidget::EffectListWidget(QWidget *parent)
setFilterType("");
}
void EffectListWidget::updateFavorite(const QModelIndex &index)
{
emit m_proxyModel->dataChanged(index, index, QVector<int>());
m_proxyModel->reloadFilterOnFavorite();
emit reloadFavorites();
}
EffectListWidget::~EffectListWidget() {}
void EffectListWidget::setFilterType(const QString &type)
......@@ -104,7 +97,7 @@ void EffectListWidget::editCustomAsset(const QModelIndex &index)
QDialog dialog(this);
QFormLayout form(&dialog);
QString currentName = getName(index);
QString desc = getDescription(true, index);
QString desc = getDescription(index);
// Strip effect Name
if (desc.contains(QLatin1Char('('))) {
desc = desc.section(QLatin1Char('('), 0, -2).simplified();
......
......@@ -24,67 +24,19 @@ class EffectListWidget : public AssetListWidget
public:
EffectListWidget(QWidget *parent = Q_NULLPTR);
~EffectListWidget() override;
void setFilterType(const QString &type);
bool isEffect() const override { return true; }
void setFilterType(const QString &type) override;
bool isAudio(const QString &assetId) const override;
/** @brief Return mime type used for drag and drop. It will be kdenlive/effect*/
QString getMimeType(const QString &assetId) const override;
void updateFavorite(const QModelIndex &index);
void reloadEffectMenu(QMenu *effectsMenu, KActionCategory *effectActions);
void reloadCustomEffectIx(const QModelIndex &index) override;
void editCustomAsset(const QModelIndex &index) override;
void exportCustomEffect(const QModelIndex &index);
Q_INVOKABLE void exportCustomEffect(const QModelIndex &index);
public slots:
void reloadCustomEffect(const QString &path);
private:
EffectListWidgetProxy *m_proxy;
signals:
void reloadFavorites();
};
// TODO we use Qt 5.15 now where this is fixed
// see https://bugreports.qt.io/browse/QTBUG-57714, don't expose a QWidget as a context property
class EffectListWidgetProxy : public QObject
{
Q_OBJECT
Q_PROPERTY(bool showDescription READ showDescription WRITE setShowDescription NOTIFY showDescriptionChanged)
public:
EffectListWidgetProxy(EffectListWidget *parent)
: QObject(parent)
, q(parent)
{
}
Q_INVOKABLE QString getName(const QModelIndex &index) const { return q->getName(index); }
Q_INVOKABLE bool isFavorite(const QModelIndex &index) const { return q->isFavorite(index); }
Q_INVOKABLE void reloadCustomEffectIx(const QModelIndex &index) const { q->reloadCustomEffectIx(index); }
Q_INVOKABLE void setFavorite(const QModelIndex &index, bool favorite) const
{
q->setFavorite(index, favorite, true);
q->updateFavorite(index);
}
Q_INVOKABLE void deleteCustomEffect(const QModelIndex &index) { q->deleteCustomEffect(index); }
Q_INVOKABLE QString getDescription(const QModelIndex &index) const { return q->getDescription(true, index); }
Q_INVOKABLE void editCustomEffectInfo(const QModelIndex &index) { q->editCustomAsset(index); }
Q_INVOKABLE void exportCustomEffect(const QModelIndex &index) { q->exportCustomEffect(index); }
Q_INVOKABLE QVariantMap getMimeData(const QString &assetId) const { return q->getMimeData(assetId); }
Q_INVOKABLE void activate(const QModelIndex &ix) { q->activate(ix); }
Q_INVOKABLE void setFilterType(const QString &type) { q->setFilterType(type); }
Q_INVOKABLE void setFilterName(const QString &pattern) { q->setFilterName(pattern); }
Q_INVOKABLE QString getMimeType(const QString &assetId) const { return q->getMimeType(assetId); }
bool showDescription() const { return KdenliveSettings::showeffectinfo(); }
void setShowDescription(bool show)
{
KdenliveSettings::setShoweffectinfo(show);
emit showDescriptionChanged();
}
signals:
void showDescriptionChanged();
private:
EffectListWidget *q; // NOLINT
};
......@@ -26,8 +26,7 @@ TransitionListWidget::TransitionListWidget(QWidget *parent)
m_proxyModel->setSortRole(AssetTreeModel::NameRole);
m_proxyModel->sort(0, Qt::AscendingOrder);
m_proxy = new TransitionListWidgetProxy(this);
rootContext()->setContextProperty("assetlist", m_proxy);
rootContext()->setContextProperty("assetlist", this);
rootContext()->setContextProperty("assetListModel", m_proxyModel.get());
rootContext()->setContextProperty("isEffectList", false);
m_assetIconProvider = new AssetIconProvider(false);
......@@ -48,13 +47,6 @@ QString TransitionListWidget::getMimeType(const QString &assetId) const
return QStringLiteral("kdenlive/composition");
}
void TransitionListWidget::updateFavorite(const QModelIndex &index)
{
emit m_proxyModel->dataChanged(index, index, QVector<int>());
m_proxyModel->reloadFilterOnFavorite();
emit reloadFavorites();
}
void TransitionListWidget::setFilterType(const QString &type)
{
if (type == "favorites") {
......
......@@ -21,61 +21,13 @@ class TransitionListWidget : public AssetListWidget
public:
TransitionListWidget(QWidget *parent = Q_NULLPTR);
~TransitionListWidget() override;
void setFilterType(const QString &type);
bool isEffect() const override { return false; }
void setFilterType(const QString &type) override;
bool isAudio(const QString &assetId) const override;
/** @brief Return mime type used for drag and drop. It will be kdenlive/composition
or kdenlive/transition*/
QString getMimeType(const QString &assetId) const override;
void updateFavorite(const QModelIndex &index);
void refreshLumas();
void reloadCustomEffectIx(const QModelIndex &path) override;
void editCustomAsset(const QModelIndex &index) override;
private:
TransitionListWidgetProxy *m_proxy;
signals:
void reloadFavorites();
};
// see https://bugreports.qt.io/browse/QTBUG-57714, don't expose a QWidget as a context property
class TransitionListWidgetProxy : public QObject
{
Q_OBJECT
Q_PROPERTY(bool showDescription READ showDescription WRITE setShowDescription NOTIFY showDescriptionChanged)
public:
TransitionListWidgetProxy(TransitionListWidget *parent)
: QObject(parent)
, q(parent)
{
}
Q_INVOKABLE QString getName(const QModelIndex &index) const { return q->getName(index); }
Q_INVOKABLE bool isFavorite(const QModelIndex &index) const { return q->isFavorite(index); }
Q_INVOKABLE void reloadCustomEffectIx(const QModelIndex &index) const { q->reloadCustomEffectIx(index); }
Q_INVOKABLE void setFavorite(const QModelIndex &index, bool favorite) const
{
q->setFavorite(index, favorite, false);
q->updateFavorite(index);
}
Q_INVOKABLE void setFilterType(const QString &type) { q->setFilterType(type); }
Q_INVOKABLE QString getDescription(const QModelIndex &index) const { return q->getDescription(false, index); }
Q_INVOKABLE QVariantMap getMimeData(const QString &assetId) const { return q->getMimeData(assetId); }
Q_INVOKABLE void activate(const QModelIndex &ix) { q->activate(ix); }
Q_INVOKABLE void setFilterName(const QString &pattern) { q->setFilterName(pattern); }
Q_INVOKABLE QString getMimeType(const QString &assetId) const { return q->getMimeType(assetId); }
Q_INVOKABLE void refreshLumas() { q->refreshLumas(); }
bool showDescription() const { return KdenliveSettings::showeffectinfo(); }
void setShowDescription(bool show)
{
KdenliveSettings::setShoweffectinfo(show);
emit showDescriptionChanged();
}
signals:
void showDescriptionChanged();
private:
TransitionListWidget *q; // NOLINT
};
Supports Markdown
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