Filter on internal effects

By default internal effects are excluded from the list, but by
checking the option in the config menu, they get included in the
list.

REVIEW: 116755
This commit is contained in:
Martin Gräßlin 2014-03-13 19:50:17 +01:00
parent 24626b8cb0
commit 7166bdad61
3 changed files with 39 additions and 27 deletions

View file

@ -133,6 +133,8 @@ QVariant EffectModel::data(const QModelIndex &index, int role) const
return m_effectsList.at(index.row()).supported; return m_effectsList.at(index.row()).supported;
case ExclusiveRole: case ExclusiveRole:
return m_effectsList.at(index.row()).exclusiveGroup; return m_effectsList.at(index.row()).exclusiveGroup;
case InternalRole:
return m_effectsList.at(index.row()).internal;
default: default:
return QVariant(); return QVariant();
} }
@ -199,6 +201,7 @@ void EffectModel::loadEffects()
effect.video = service->property(QStringLiteral("X-KWin-Video-Url"), QVariant::Url).toUrl(); effect.video = service->property(QStringLiteral("X-KWin-Video-Url"), QVariant::Url).toUrl();
effect.supported = true; effect.supported = true;
effect.exclusiveGroup = service->property(QStringLiteral("X-KWin-Exclusive-Category"), QVariant::String).toString(); effect.exclusiveGroup = service->property(QStringLiteral("X-KWin-Exclusive-Category"), QVariant::String).toString();
effect.internal = service->property(QStringLiteral("X-KWin-Internal"), QVariant::Bool).toBool();
m_effectsList << effect; m_effectsList << effect;
} }
@ -329,9 +332,12 @@ void EffectModel::defaults()
EffectFilterModel::EffectFilterModel(QObject *parent) EffectFilterModel::EffectFilterModel(QObject *parent)
: QSortFilterProxyModel(parent) : QSortFilterProxyModel(parent)
, m_effectModel(new EffectModel(this)) , m_effectModel(new EffectModel(this))
, m_supported(true) , m_filterOutUnsupported(true)
, m_filterOutInternal(true)
{ {
setSourceModel(m_effectModel); setSourceModel(m_effectModel);
connect(this, &EffectFilterModel::filterOutUnsupportedChanged, this, &EffectFilterModel::invalidateFilter);
connect(this, &EffectFilterModel::filterOutInternalChanged, this, &EffectFilterModel::invalidateFilter);
} }
const QString &EffectFilterModel::filter() const const QString &EffectFilterModel::filter() const
@ -350,17 +356,6 @@ void EffectFilterModel::setFilter(const QString &filter)
invalidateFilter(); invalidateFilter();
} }
void EffectFilterModel::setFilterOnSupported(bool supported)
{
if (m_supported == supported) {
return;
}
m_supported = supported;
emit filterOnSupportedChanged();
invalidateFilter();
}
bool EffectFilterModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const bool EffectFilterModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const
{ {
if (!m_effectModel) { if (!m_effectModel) {
@ -372,9 +367,14 @@ bool EffectFilterModel::filterAcceptsRow(int source_row, const QModelIndex &sour
return false; return false;
} }
if (m_supported) { if (m_filterOutUnsupported) {
bool supported = index.data(EffectModel::SupportedRole).toBool(); if (!index.data(EffectModel::SupportedRole).toBool()) {
if (!supported) { return false;
}
}
if (m_filterOutInternal) {
if (index.data(EffectModel::InternalRole).toBool()) {
return false; return false;
} }
} }

View file

@ -48,6 +48,7 @@ struct EffectData {
QUrl video; QUrl video;
bool supported; bool supported;
QString exclusiveGroup; QString exclusiveGroup;
bool internal;
}; };
class EffectModel : public QAbstractItemModel class EffectModel : public QAbstractItemModel
@ -69,7 +70,8 @@ public:
WindowManagementRole, WindowManagementRole,
VideoRole, VideoRole,
SupportedRole, SupportedRole,
ExclusiveRole ExclusiveRole,
InternalRole
}; };
explicit EffectModel(QObject *parent = 0); explicit EffectModel(QObject *parent = 0);
@ -131,7 +133,12 @@ class EffectFilterModel : public QSortFilterProxyModel
* If @c true not supported effects are excluded, if @c false no restriction on supported. * If @c true not supported effects are excluded, if @c false no restriction on supported.
* Default value is @c true. * Default value is @c true.
**/ **/
Q_PROPERTY(bool filterOnSupported READ isFilterOnSupported WRITE setFilterOnSupported NOTIFY filterOnSupportedChanged) Q_PROPERTY(bool filterOutUnsupported MEMBER m_filterOutUnsupported NOTIFY filterOutUnsupportedChanged)
/**
* If @c true internal effects are excluded, if @c false no restriction on internal.
* Default value is @c true.
**/
Q_PROPERTY(bool filterOutInternal MEMBER m_filterOutInternal NOTIFY filterOutInternalChanged)
Q_PROPERTY(QColor backgroundActiveColor READ backgroundActiveColor CONSTANT); Q_PROPERTY(QColor backgroundActiveColor READ backgroundActiveColor CONSTANT);
Q_PROPERTY(QColor backgroundNormalColor READ backgroundNormalColor CONSTANT); Q_PROPERTY(QColor backgroundNormalColor READ backgroundNormalColor CONSTANT);
Q_PROPERTY(QColor backgroundAlternateColor READ backgroundAlternateColor CONSTANT); Q_PROPERTY(QColor backgroundAlternateColor READ backgroundAlternateColor CONSTANT);
@ -154,11 +161,6 @@ public:
return color; return color;
} }
void setFilterOnSupported(bool supported);
bool isFilterOnSupported() const {
return m_supported;
}
void defaults(); void defaults();
public Q_SLOTS: public Q_SLOTS:
@ -170,12 +172,14 @@ protected:
Q_SIGNALS: Q_SIGNALS:
void effectModelChanged(); void effectModelChanged();
void filterChanged(); void filterChanged();
void filterOnSupportedChanged(); void filterOutUnsupportedChanged();
void filterOutInternalChanged();
private: private:
EffectModel *m_effectModel; EffectModel *m_effectModel;
QString m_filter; QString m_filter;
bool m_supported; bool m_filterOutUnsupported;
bool m_filterOutInternal;
}; };
} }
} }

View file

@ -80,11 +80,19 @@ Item {
tooltip: "Configure filter" tooltip: "Configure filter"
menu: Menu { menu: Menu {
MenuItem { MenuItem {
text: i18n("Filter only on Desktop Effects supported by the Compositor") text: i18n("Exclude Desktop Effects not supported by the Compositor")
checkable: true checkable: true
checked: searchModel.filterOnSupported checked: searchModel.filterOutUnsupported
onTriggered: { onTriggered: {
searchModel.filterOnSupported = !searchModel.filterOnSupported; searchModel.filterOutUnsupported = !searchModel.filterOutUnsupported;
}
}
MenuItem {
text: i18n("Exclude internal Desktop Effects")
checkable: true
checked: searchModel.filterOutInternal
onTriggered: {
searchModel.filterOutInternal = !searchModel.filterOutInternal
} }
} }
} }