Add a client property to ThumbnailItem
Makes it a little bit easier to use a ThumbnailItem for a Client. E.g. ThumbnailItem { client: model.client } instead of mapping the windowIds, which is rather uncomfty.
This commit is contained in:
parent
15b84c54f8
commit
6351472d28
2 changed files with 36 additions and 0 deletions
|
@ -36,6 +36,7 @@ namespace KWin
|
|||
ThumbnailItem::ThumbnailItem(QDeclarativeItem* parent)
|
||||
: QDeclarativeItem(parent)
|
||||
, m_wId(0)
|
||||
, m_client(NULL)
|
||||
, m_clip(true)
|
||||
, m_parent(QWeakPointer<EffectWindowImpl>())
|
||||
, m_parentWindow(0)
|
||||
|
@ -108,10 +109,33 @@ void ThumbnailItem::findParentEffectWindow()
|
|||
|
||||
void ThumbnailItem::setWId(qulonglong wId)
|
||||
{
|
||||
if (m_wId == wId) {
|
||||
return;
|
||||
}
|
||||
m_wId = wId;
|
||||
if (m_wId != 0) {
|
||||
setClient(Workspace::self()->findClient(WindowMatchPredicate(m_wId)));
|
||||
} else if (m_client) {
|
||||
m_client = NULL;
|
||||
emit clientChanged();
|
||||
}
|
||||
emit wIdChanged(wId);
|
||||
}
|
||||
|
||||
void ThumbnailItem::setClient(Client *client)
|
||||
{
|
||||
if (m_client == client) {
|
||||
return;
|
||||
}
|
||||
m_client = client;
|
||||
if (m_client) {
|
||||
setWId(m_client->window());
|
||||
} else {
|
||||
setWId(0);
|
||||
}
|
||||
emit clientChanged();
|
||||
}
|
||||
|
||||
void ThumbnailItem::setClip(bool clip)
|
||||
{
|
||||
m_clip = clip;
|
||||
|
|
|
@ -27,6 +27,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
namespace KWin
|
||||
{
|
||||
|
||||
class Client;
|
||||
class EffectWindow;
|
||||
class EffectWindowImpl;
|
||||
|
||||
|
@ -38,6 +39,7 @@ class ThumbnailItem : public QDeclarativeItem
|
|||
Q_PROPERTY(qulonglong parentWindow READ parentWindow WRITE setParentWindow)
|
||||
Q_PROPERTY(qreal brightness READ brightness WRITE setBrightness NOTIFY brightnessChanged)
|
||||
Q_PROPERTY(qreal saturation READ saturation WRITE setSaturation NOTIFY saturationChanged)
|
||||
Q_PROPERTY(KWin::Client *client READ client WRITE setClient NOTIFY clientChanged)
|
||||
public:
|
||||
explicit ThumbnailItem(QDeclarativeItem *parent = 0);
|
||||
virtual ~ThumbnailItem();
|
||||
|
@ -57,6 +59,8 @@ public:
|
|||
void setParentWindow(qulonglong parentWindow);
|
||||
qreal brightness() const;
|
||||
qreal saturation() const;
|
||||
Client *client() const;
|
||||
void setClient(Client *client);
|
||||
|
||||
public Q_SLOTS:
|
||||
void setBrightness(qreal brightness);
|
||||
|
@ -67,6 +71,7 @@ Q_SIGNALS:
|
|||
void clipChanged(bool clipped);
|
||||
void brightnessChanged();
|
||||
void saturationChanged();
|
||||
void clientChanged();
|
||||
private Q_SLOTS:
|
||||
void init();
|
||||
void effectWindowAdded();
|
||||
|
@ -75,6 +80,7 @@ private Q_SLOTS:
|
|||
private:
|
||||
void findParentEffectWindow();
|
||||
qulonglong m_wId;
|
||||
Client *m_client;
|
||||
bool m_clip;
|
||||
QWeakPointer<EffectWindowImpl> m_parent;
|
||||
qulonglong m_parentWindow;
|
||||
|
@ -94,6 +100,12 @@ qreal ThumbnailItem::saturation() const
|
|||
return m_saturation;
|
||||
}
|
||||
|
||||
inline
|
||||
Client *ThumbnailItem::client() const
|
||||
{
|
||||
return m_client;
|
||||
}
|
||||
|
||||
} // KWin
|
||||
|
||||
#endif // KWIN_THUMBNAILITEM_H
|
||||
|
|
Loading…
Reference in a new issue