Compositions can now also be defined as favorites

parent fc2822fa
......@@ -73,8 +73,7 @@ bool AssetListWidget::isFavorite(const QModelIndex &index) const
void AssetListWidget::setFavorite(const QModelIndex &index, bool favorite)
{
return m_model->setFavorite(m_proxyModel->mapToSource(index), favorite);
m_model->setFavorite(m_proxyModel->mapToSource(index), favorite);
}
QString AssetListWidget::getDescription(const QModelIndex &index) const
......
......@@ -122,6 +122,16 @@ Rectangle {
assetlist.setFilterType("custom")
}
}
ToolButton {
id: showFavorites
iconName: "favorite"
checkable:true
exclusiveGroup: filterGroup
tooltip: i18n('Show favorite items')
onClicked: {
assetlist.setFilterType("favorites")
}
}
Rectangle {
//This is a spacer
Layout.fillHeight: false
......@@ -229,7 +239,7 @@ Rectangle {
anchors.right: parent ? parent.right : undefined
property bool isItem : styleData.value != "root" && styleData.value != ""
property string mimeType : isItem ? assetlist.getMimeType(styleData.value) : ""
height: text.implicitHeight + 8
height: assetText.implicitHeight + 8
color: "transparent"
Drag.active: isItem ? dragArea.drag.active : false
......@@ -250,11 +260,6 @@ Rectangle {
id: assetThumb
visible: assetDelegate.isItem
property bool isFavorite: model.favorite
onIsFavoriteChanged: {
// ''
//cache = false
//source = 'image://asseticon/' + styleData.value
}
height: parent.height
width: height
source: 'image://asseticon/' + styleData.value
......@@ -314,8 +319,6 @@ Rectangle {
property url thumbSource
onTriggered: {
assetlist.setFavorite(sel.currentIndex, !assetContextMenu.isItemFavorite)
// Force thumb reload
}
}
}
......
......@@ -42,6 +42,9 @@ bool EffectFilter::filterType(const std::shared_ptr<TreeItem> &item) const
if (!m_type_enabled) {
return true;
}
if (m_type_value == EffectType::Favorites) {
return item->dataColumn(AssetTreeModel::favCol).toBool();
}
auto itemType = item->dataColumn(AssetTreeModel::typeCol).value<EffectType>();
return itemType == m_type_value;
}
......
......@@ -66,6 +66,8 @@ void EffectListWidget::setFilterType(const QString &type)
static_cast<EffectFilter *>(m_proxyModel.get())->setFilterType(true, EffectType::Audio);
} else if (type == "custom") {
static_cast<EffectFilter *>(m_proxyModel.get())->setFilterType(true, EffectType::Custom);
} else if (type == "favorites") {
static_cast<EffectFilter *>(m_proxyModel.get())->setFilterType(true, EffectType::Favorites);
} else {
static_cast<EffectFilter *>(m_proxyModel.get())->setFilterType(false, EffectType::Video);
}
......
......@@ -35,7 +35,7 @@
* Note that this class is a Singleton
*/
enum class EffectType { Video, Audio, Custom };
enum class EffectType { Video, Audio, Custom, Favorites};
Q_DECLARE_METATYPE(EffectType)
class EffectsRepository : public AbstractAssetsRepository<EffectType>
......
......@@ -66,7 +66,7 @@ std::shared_ptr<TransitionTreeModel> TransitionTreeModel::construct(bool flat, Q
// we create the data list corresponding to this transition
QList<QVariant> data;
bool isFav = KdenliveSettings::favorite_effects().contains(transition.first);
bool isFav = KdenliveSettings::favorite_transitions().contains(transition.first);
qDebug() << transition.second << transition.first << "in " << targetCategory->dataColumn(0).toString();
data << transition.second << transition.first << QVariant::fromValue(type) << isFav;
......
......@@ -20,6 +20,7 @@
***************************************************************************/
#include "transitionlistwidget.hpp"
#include "effects/effectlist/model/effectfilter.hpp"
#include "../model/transitiontreemodel.hpp"
#include "assets/assetlist/model/assetfilter.hpp"
#include "transitions/transitionsrepository.hpp"
......@@ -32,7 +33,7 @@ TransitionListWidget::TransitionListWidget(QWidget *parent)
m_model = TransitionTreeModel::construct(false, this);
m_proxyModel.reset(new AssetFilter(this));
m_proxyModel.reset(new EffectFilter(this));
m_proxyModel->setSourceModel(m_model.get());
m_proxyModel->setSortRole(AssetTreeModel::NameRole);
m_proxyModel->sort(0, Qt::AscendingOrder);
......@@ -59,3 +60,17 @@ QString TransitionListWidget::getMimeType(const QString &assetId) const
}
return QStringLiteral("kdenlive/transition");
}
void TransitionListWidget::updateFavorite(const QModelIndex &index)
{
m_proxyModel->dataChanged(index, index, QVector<int>());
}
void TransitionListWidget::setFilterType(const QString &type)
{
if (type == "favorites") {
static_cast<EffectFilter *>(m_proxyModel.get())->setFilterType(true, EffectType::Favorites);
} else {
static_cast<EffectFilter *>(m_proxyModel.get())->setFilterType(false, EffectType::Video);
}
}
......@@ -37,15 +37,15 @@ class TransitionListWidget : public AssetListWidget
public:
TransitionListWidget(QWidget *parent = Q_NULLPTR);
~TransitionListWidget();
void setFilterType(const QString &type);
/*@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);
private:
TransitionListWidgetProxy *m_proxy;
signals:
void reloadBasket();
};
// see https://bugreports.qt.io/browse/QTBUG-57714, don't expose a QWidget as a context property
......@@ -61,7 +61,8 @@ public:
}
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 setFavorite(const QModelIndex &index, bool favorite) const { q->setFavorite(index, favorite); q->reloadBasket();}
Q_INVOKABLE void setFavorite(const QModelIndex &index, bool favorite) const { q->setFavorite(index, favorite); q->updateFavorite(index); }
Q_INVOKABLE void setFilterType(const QString &type) { q->setFilterType(type); }
Q_INVOKABLE QString getDescription(const QModelIndex &index) const { return q->getDescription(index); }
Q_INVOKABLE QVariantMap getMimeData(const QString &assetId) const { return q->getMimeData(assetId); }
......
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