scripting: Make ClientFilterModel take VirtualDesktop
This commit is contained in:
parent
5419e3df4a
commit
1eb0c09292
3 changed files with 14 additions and 15 deletions
|
@ -89,7 +89,7 @@ FocusScope {
|
||||||
|
|
||||||
Repeater {
|
Repeater {
|
||||||
model: KWinComponents.ClientFilterModel {
|
model: KWinComponents.ClientFilterModel {
|
||||||
desktop: KWinComponents.Workspace.currentDesktop
|
desktop: KWinComponents.Workspace.currentVirtualDesktop
|
||||||
screenName: targetScreen.name
|
screenName: targetScreen.name
|
||||||
clientModel: stackModel
|
clientModel: stackModel
|
||||||
windowType: KWinComponents.ClientFilterModel.Dock
|
windowType: KWinComponents.ClientFilterModel.Dock
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#include "clientmodel.h"
|
#include "clientmodel.h"
|
||||||
#include "abstract_client.h"
|
#include "abstract_client.h"
|
||||||
#include "screens.h"
|
#include "screens.h"
|
||||||
|
#include "virtualdesktops.h"
|
||||||
#include "workspace.h"
|
#include "workspace.h"
|
||||||
|
|
||||||
namespace KWin::ScriptingModels::V3
|
namespace KWin::ScriptingModels::V3
|
||||||
|
@ -143,12 +144,12 @@ void ClientFilterModel::resetActivity()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int ClientFilterModel::desktop() const
|
VirtualDesktop *ClientFilterModel::desktop() const
|
||||||
{
|
{
|
||||||
return m_desktop.value_or(0);
|
return m_desktop;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClientFilterModel::setDesktop(int desktop)
|
void ClientFilterModel::setDesktop(VirtualDesktop *desktop)
|
||||||
{
|
{
|
||||||
if (m_desktop != desktop) {
|
if (m_desktop != desktop) {
|
||||||
m_desktop = desktop;
|
m_desktop = desktop;
|
||||||
|
@ -159,11 +160,7 @@ void ClientFilterModel::setDesktop(int desktop)
|
||||||
|
|
||||||
void ClientFilterModel::resetDesktop()
|
void ClientFilterModel::resetDesktop()
|
||||||
{
|
{
|
||||||
if (m_desktop.has_value()) {
|
setDesktop(nullptr);
|
||||||
m_desktop.reset();
|
|
||||||
Q_EMIT desktopChanged();
|
|
||||||
invalidateFilter();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ClientFilterModel::filter() const
|
QString ClientFilterModel::filter() const
|
||||||
|
@ -253,8 +250,8 @@ bool ClientFilterModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourc
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_desktop.has_value()) {
|
if (m_desktop) {
|
||||||
if (!client->isOnDesktop(*m_desktop)) {
|
if (!client->isOnDesktop(m_desktop)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QAbstractListModel>
|
#include <QAbstractListModel>
|
||||||
|
#include <QPointer>
|
||||||
#include <QSortFilterProxyModel>
|
#include <QSortFilterProxyModel>
|
||||||
|
|
||||||
#include <optional>
|
#include <optional>
|
||||||
|
@ -14,6 +15,7 @@
|
||||||
namespace KWin
|
namespace KWin
|
||||||
{
|
{
|
||||||
class AbstractClient;
|
class AbstractClient;
|
||||||
|
class VirtualDesktop;
|
||||||
|
|
||||||
namespace ScriptingModels::V3
|
namespace ScriptingModels::V3
|
||||||
{
|
{
|
||||||
|
@ -51,7 +53,7 @@ class ClientFilterModel : public QSortFilterProxyModel
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(ClientModel *clientModel READ clientModel WRITE setClientModel NOTIFY clientModelChanged)
|
Q_PROPERTY(ClientModel *clientModel READ clientModel WRITE setClientModel NOTIFY clientModelChanged)
|
||||||
Q_PROPERTY(QString activity READ activity WRITE setActivity RESET resetActivity NOTIFY activityChanged)
|
Q_PROPERTY(QString activity READ activity WRITE setActivity RESET resetActivity NOTIFY activityChanged)
|
||||||
Q_PROPERTY(int desktop READ desktop WRITE setDesktop RESET resetDesktop NOTIFY desktopChanged)
|
Q_PROPERTY(KWin::VirtualDesktop *desktop READ desktop WRITE setDesktop RESET resetDesktop NOTIFY desktopChanged)
|
||||||
Q_PROPERTY(QString filter READ filter WRITE setFilter NOTIFY filterChanged)
|
Q_PROPERTY(QString filter READ filter WRITE setFilter NOTIFY filterChanged)
|
||||||
Q_PROPERTY(QString screenName READ screenName WRITE setScreenName RESET resetScreenName NOTIFY screenNameChanged)
|
Q_PROPERTY(QString screenName READ screenName WRITE setScreenName RESET resetScreenName NOTIFY screenNameChanged)
|
||||||
Q_PROPERTY(WindowTypes windowType READ windowType WRITE setWindowType RESET resetWindowType NOTIFY windowTypeChanged)
|
Q_PROPERTY(WindowTypes windowType READ windowType WRITE setWindowType RESET resetWindowType NOTIFY windowTypeChanged)
|
||||||
|
@ -77,8 +79,8 @@ public:
|
||||||
void setActivity(const QString &activity);
|
void setActivity(const QString &activity);
|
||||||
void resetActivity();
|
void resetActivity();
|
||||||
|
|
||||||
int desktop() const;
|
VirtualDesktop *desktop() const;
|
||||||
void setDesktop(int desktop);
|
void setDesktop(VirtualDesktop *desktop);
|
||||||
void resetDesktop();
|
void resetDesktop();
|
||||||
|
|
||||||
QString filter() const;
|
QString filter() const;
|
||||||
|
@ -108,7 +110,7 @@ private:
|
||||||
|
|
||||||
ClientModel *m_clientModel = nullptr;
|
ClientModel *m_clientModel = nullptr;
|
||||||
std::optional<QString> m_activity;
|
std::optional<QString> m_activity;
|
||||||
std::optional<int> m_desktop;
|
QPointer<VirtualDesktop> m_desktop;
|
||||||
QString m_filter;
|
QString m_filter;
|
||||||
std::optional<QString> m_screenName;
|
std::optional<QString> m_screenName;
|
||||||
std::optional<WindowTypes> m_windowType;
|
std::optional<WindowTypes> m_windowType;
|
||||||
|
|
Loading…
Reference in a new issue