KWin
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
switcheritem.h
Go to the documentation of this file.
1/*
2 KWin - the KDE window manager
3 This file is part of the KDE project.
4
5 SPDX-FileCopyrightText: 2013 Martin Gräßlin <mgraesslin@kde.org>
6
7 SPDX-License-Identifier: GPL-2.0-or-later
8*/
9#pragma once
10
11#include <QObject>
12#include <QRect>
13
14class QAbstractItemModel;
15
16namespace KWin
17{
18namespace TabBox
19{
20
21class SwitcherItem : public QObject
22{
23 Q_OBJECT
24 Q_PROPERTY(QAbstractItemModel *model READ model NOTIFY modelChanged)
25 Q_PROPERTY(QRect screenGeometry READ screenGeometry NOTIFY screenGeometryChanged)
26 Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged)
27 Q_PROPERTY(bool allDesktops READ isAllDesktops NOTIFY allDesktopsChanged)
28 Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentIndexChanged)
30 Q_PROPERTY(bool compositing READ compositing NOTIFY compositingChanged)
32
36 Q_PROPERTY(QObject *item READ item WRITE setItem NOTIFY itemChanged)
37
38 Q_CLASSINFO("DefaultProperty", "item")
39public:
40 SwitcherItem(QObject *parent = nullptr);
41 ~SwitcherItem() override;
42
43 QAbstractItemModel *model() const;
44 QRect screenGeometry() const;
45 bool isVisible() const;
46 bool isAllDesktops() const;
47 int currentIndex() const;
48 void setCurrentIndex(int index);
49 QObject *item() const;
50 void setItem(QObject *item);
51 bool noModifierGrab() const
52 {
53 return m_noModifierGrab;
54 }
56 bool automaticallyHide() const;
57
58 // for usage from outside
59 void setModel(QAbstractItemModel *model);
60 void setAllDesktops(bool all);
61 void setVisible(bool visible);
62 void setNoModifierGrab(bool set);
63 void setAutomaticallyHide(bool value);
64
65Q_SIGNALS:
67 void currentIndexChanged(int index);
75
78
79private:
80 QAbstractItemModel *m_model;
81 QObject *m_item;
82 bool m_visible;
83 bool m_allDesktops;
84 int m_currentIndex;
85 QMetaObject::Connection m_selectedIndexConnection;
86 bool m_noModifierGrab = false;
87 bool m_automaticallyHide = true;
88};
89
90inline QAbstractItemModel *SwitcherItem::model() const
91{
92 return m_model;
93}
94
95inline bool SwitcherItem::isVisible() const
96{
97 return m_visible;
98}
99
100inline bool SwitcherItem::isAllDesktops() const
101{
102 return m_allDesktops;
103}
104
105inline int SwitcherItem::currentIndex() const
106{
107 return m_currentIndex;
108}
109
110inline QObject *SwitcherItem::item() const
111{
112 return m_item;
113}
114
115} // TabBox
116} // KWin
QAbstractItemModel * model
void setAutomaticallyHide(bool value)
void currentIndexChanged(int index)
void setVisible(bool visible)
void setNoModifierGrab(bool set)
void setItem(QObject *item)
void setModel(QAbstractItemModel *model)