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 {
|
||||
model: KWinComponents.ClientFilterModel {
|
||||
desktop: KWinComponents.Workspace.currentDesktop
|
||||
desktop: KWinComponents.Workspace.currentVirtualDesktop
|
||||
screenName: targetScreen.name
|
||||
clientModel: stackModel
|
||||
windowType: KWinComponents.ClientFilterModel.Dock
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include "clientmodel.h"
|
||||
#include "abstract_client.h"
|
||||
#include "screens.h"
|
||||
#include "virtualdesktops.h"
|
||||
#include "workspace.h"
|
||||
|
||||
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) {
|
||||
m_desktop = desktop;
|
||||
|
@ -159,11 +160,7 @@ void ClientFilterModel::setDesktop(int desktop)
|
|||
|
||||
void ClientFilterModel::resetDesktop()
|
||||
{
|
||||
if (m_desktop.has_value()) {
|
||||
m_desktop.reset();
|
||||
Q_EMIT desktopChanged();
|
||||
invalidateFilter();
|
||||
}
|
||||
setDesktop(nullptr);
|
||||
}
|
||||
|
||||
QString ClientFilterModel::filter() const
|
||||
|
@ -253,8 +250,8 @@ bool ClientFilterModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourc
|
|||
}
|
||||
}
|
||||
|
||||
if (m_desktop.has_value()) {
|
||||
if (!client->isOnDesktop(*m_desktop)) {
|
||||
if (m_desktop) {
|
||||
if (!client->isOnDesktop(m_desktop)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <QAbstractListModel>
|
||||
#include <QPointer>
|
||||
#include <QSortFilterProxyModel>
|
||||
|
||||
#include <optional>
|
||||
|
@ -14,6 +15,7 @@
|
|||
namespace KWin
|
||||
{
|
||||
class AbstractClient;
|
||||
class VirtualDesktop;
|
||||
|
||||
namespace ScriptingModels::V3
|
||||
{
|
||||
|
@ -51,7 +53,7 @@ class ClientFilterModel : public QSortFilterProxyModel
|
|||
Q_OBJECT
|
||||
Q_PROPERTY(ClientModel *clientModel READ clientModel WRITE setClientModel NOTIFY clientModelChanged)
|
||||
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 screenName READ screenName WRITE setScreenName RESET resetScreenName NOTIFY screenNameChanged)
|
||||
Q_PROPERTY(WindowTypes windowType READ windowType WRITE setWindowType RESET resetWindowType NOTIFY windowTypeChanged)
|
||||
|
@ -77,8 +79,8 @@ public:
|
|||
void setActivity(const QString &activity);
|
||||
void resetActivity();
|
||||
|
||||
int desktop() const;
|
||||
void setDesktop(int desktop);
|
||||
VirtualDesktop *desktop() const;
|
||||
void setDesktop(VirtualDesktop *desktop);
|
||||
void resetDesktop();
|
||||
|
||||
QString filter() const;
|
||||
|
@ -108,7 +110,7 @@ private:
|
|||
|
||||
ClientModel *m_clientModel = nullptr;
|
||||
std::optional<QString> m_activity;
|
||||
std::optional<int> m_desktop;
|
||||
QPointer<VirtualDesktop> m_desktop;
|
||||
QString m_filter;
|
||||
std::optional<QString> m_screenName;
|
||||
std::optional<WindowTypes> m_windowType;
|
||||
|
|
Loading…
Reference in a new issue