From kde-commits Mon Nov 01 13:32:08 2010 From: =?utf-8?q?Ivan=20=C4=8Cuki=C4=87?= Date: Mon, 01 Nov 2010 13:32:08 +0000 To: kde-commits Subject: KDE/kdebase/workspace Message-Id: <20101101133208.98F03AC89B () svn ! kde ! org> X-MARC-Message: https://marc.info/?l=kde-commits&m=128861837414552 SVN commit 1191933 by ivan: - marking current activity - using tasks theme for items in plasmagenericshell M +27 -3 libs/plasmagenericshell/abstracticon.cpp M +4 -0 libs/plasmagenericshell/abstracticon.h M +2 -0 plasma/desktop/shell/activity.h M +2 -0 plasma/desktop/shell/activitymanager/activityicon.cpp M +1 -0 plasma/desktop/shell/activitymanager/activityicon.h --- trunk/KDE/kdebase/workspace/libs/plasmagenericshell/abstracticon.cpp #1191932:1191933 @@ -1,6 +1,7 @@ /* * Copyright (C) 2009 by Ana CecĂ­lia Martins * Copyright (C) 2010 by Chani Armitage + * Copyright (C) 2010 by Ivan Cukic * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library/Lesser General Public License @@ -49,7 +50,8 @@ setCacheMode(DeviceCoordinateCache); setAcceptHoverEvents(true); m_background = new Plasma::FrameSvg(this); - m_background->setImagePath("widgets/background"); + m_background->setImagePath("widgets/tasks"); + m_background->setElementPrefix("normal"); } AbstractIcon::~AbstractIcon() @@ -129,12 +131,14 @@ QMimeData *data = mimeData(); if (data && !data->formats().isEmpty()) { } + update(); } void AbstractIcon::hoverLeaveEvent(QGraphicsSceneHoverEvent *) { m_hovered = false; emit hoverLeave(this); + update(); } void AbstractIcon::mouseMoveEvent(QGraphicsSceneMouseEvent *event) @@ -188,8 +192,11 @@ void AbstractIcon::setSelected(bool selected) { + if (m_selected != selected) { m_selected = selected; + update(); } +} bool AbstractIcon::isSelected() const { @@ -213,10 +220,27 @@ void AbstractIcon::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { - Q_UNUSED(option) - Q_UNUSED(widget) + paintBackground(painter, option, widget); + paintForeground(painter, option, widget); +} +void AbstractIcon::paintBackground(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) +{ + if (m_selected) { + qDebug() << "SELECTED!!!"; + m_background->setElementPrefix("focus"); + } else if (m_hovered) { + qDebug() << "HOVERED!!!"; + m_background->setElementPrefix("hover"); + } else { + m_background->setElementPrefix("normal"); + } + m_background->paintFrame(painter, option->rect, option->rect); +} + +void AbstractIcon::paintForeground(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) +{ const QRectF rect = contentsRect(); const int width = rect.width(); const int height = rect.height(); --- trunk/KDE/kdebase/workspace/libs/plasmagenericshell/abstracticon.h #1191932:1191933 @@ -41,7 +41,10 @@ bool isSelected() const; void setSelected(bool selected); + void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); + void paintForeground(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); + void paintBackground(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); QString name() const; @@ -52,6 +55,7 @@ * return the background image */ virtual QPixmap pixmap(const QSize &size) = 0; + /** * return the mime data for d&d */ --- trunk/KDE/kdebase/workspace/plasma/desktop/shell/activity.h #1191932:1191933 @@ -99,10 +99,12 @@ public slots: void setName(const QString &name); void setIcon(const QString &icon); + /** * delete the activity forever */ void destroy(); + /** * make this activity the current activity */ --- trunk/KDE/kdebase/workspace/plasma/desktop/shell/activitymanager/activityicon.cpp #1191932:1191933 @@ -366,6 +366,8 @@ return; } + setSelected(m_activity->isActive()); + AbstractIcon::paint(painter, option, widget); } --- trunk/KDE/kdebase/workspace/plasma/desktop/shell/activitymanager/activityicon.h #1191932:1191933 @@ -70,6 +70,7 @@ ActivityActionWidget * m_buttonConfigure; bool m_closable : 1; + bool m_active : 1; Activity *m_activity; QWeakPointer < ActivityControls > m_inlineWidget;