Aaron J. Seigo 写道: > On Thursday 23 July 2009, 潘卫平(Peter Pan) wrote: >> Taht will cover the icon and looks mussy. >> I prefer to let it over the text. > > hm.. ok, how about on the right side of the button then, where the # of > windows usually appears when there are several windows grouped? > > also as for this: > > + QRectF rect = parentGroup()->tasksLayout()->contentsRect(); > + int rowCount = parentGroup()->tasksLayout()->rowCount(); > + qreal height = rect.height() / rowCount; > + QSizeF size(height, height); > > it should be able to just position it relative to the task button itself, > something like this which would make it consistent with the group number > drawing as well: > > Plasma::FrameSvg *itemBackground = m_applet->itemBackground(); > QSizeF busySize(itemBackground->elementSize(expanderElement())); > QRectF animationRect(QPointF(size().width() - busySize.width(), (size.height() > - busySize.height()) / 2), busySize); > > even with this code, however, if the size of the button changes while the app > is launching the busy widget will no longer be in the right place. > > so ... either the positioning code should be put into a separate method and be > called from both startStartupAnimation and resizeEvent or a layout should be > used to manage that for us. a layout is probably overkill in this situation, > though. > > > > ------------------------------------------------------------------------ > > _______________________________________________ > Plasma-devel mailing list > Plasma-devel@kde.org > https://mail.kde.org/mailman/listinfo/plasma-devel
Fisrt, I prefer to use Plasma::BusyWidget, consistent with others. Second, I prefer to replace icon when the app is starting up, like firefox when it is opening a new website. Third, I set the BusyWidgest's geometry in AbstractTaskItem::drawTask(), so it can get the proper geometry. Best regards! -- 潘卫平(Peter Pan)
Index: abstracttaskitem.cpp =================================================================== --- abstracttaskitem.cpp (版本 1004126) +++ abstracttaskitem.cpp (工作副本) @@ -586,26 +586,34 @@ QRectF bounds = boundingRect().adjusted(m_applet->itemLeftMargin(), m_applet->itemTopMargin(), -m_applet->itemRightMargin(), -m_applet->itemBottomMargin()); - if ((!m_animId && ~option->state & QStyle::State_MouseOver) || - (m_oldBackgroundPrefix != "hover" && m_backgroundPrefix != "hover")) { - m_icon.paint(painter, iconRect(bounds).toRect()); + WindowTaskItem *window = qobject_cast<WindowTaskItem *>(this); + QGraphicsWidget *busyWidget; + busyWidget = window ? window->busyWidget() : 0; + + if (busyWidget) { + busyWidget->setGeometry(iconRect(bounds)); + busyWidget->show(); } else { - KIconEffect *effect = KIconLoader::global()->iconEffect(); - QPixmap result = m_icon.pixmap(iconRect(bounds).toRect().size()); + if ((!m_animId && ~option->state & QStyle::State_MouseOver) + ||(m_oldBackgroundPrefix != "hover" && m_backgroundPrefix != "hover")) { + m_icon.paint(painter, iconRect(bounds).toRect()); + } else { + KIconEffect *effect = KIconLoader::global()->iconEffect(); + QPixmap result = m_icon.pixmap(iconRect(bounds).toRect().size()); - if (effect->hasEffect(KIconLoader::Desktop, KIconLoader::ActiveState)) { - if (qFuzzyCompare(qreal(1.0), m_alpha)) { - result = effect->apply(result, KIconLoader::Desktop, KIconLoader::ActiveState); - } else { - result = Plasma::PaintUtils::transition( - result, - effect->apply(result, KIconLoader::Desktop, - KIconLoader::ActiveState), m_fadeIn?m_alpha:1-m_alpha); + if (effect->hasEffect(KIconLoader::Desktop, KIconLoader::ActiveState)) { + if (qFuzzyCompare(qreal(1.0), m_alpha)) { + result = effect->apply(result, KIconLoader::Desktop, KIconLoader::ActiveState); + } else { + result = Plasma::PaintUtils::transition(result, + effect->apply(result, KIconLoader::Desktop, + KIconLoader::ActiveState), m_fadeIn?m_alpha:1-m_alpha); + } } + painter->drawPixmap(iconRect(bounds).topLeft(), result); } - painter->drawPixmap(iconRect(bounds).topLeft(), result); } - + painter->setPen(QPen(textColor(), 1.0)); QRect rect = textRect(bounds).toRect(); Index: windowtaskitem.cpp =================================================================== --- windowtaskitem.cpp (版本 1004126) +++ windowtaskitem.cpp (工作副本) @@ -60,7 +60,8 @@ WindowTaskItem::WindowTaskItem(QGraphicsWidget *parent, Tasks *applet) : AbstractTaskItem(parent, applet), - m_task(0) + m_task(0), + m_busyWidget(0) { } @@ -239,6 +240,11 @@ connect(task, SIGNAL(gotTaskPointer()), this, SLOT(gotTaskPointer())); setText(task->startup()->text()); setIcon(KIcon(task->startup()->icon())); + + if (!m_busyWidget) { + m_busyWidget = new Plasma::BusyWidget(this); + m_busyWidget->hide(); + } } void WindowTaskItem::gotTaskPointer() @@ -246,6 +252,9 @@ //kDebug(); TaskManager::TaskItem *item = qobject_cast<TaskManager::TaskItem*>(sender()); if (item) { + delete m_busyWidget; + m_busyWidget = 0; + setWindowTask(item); } } @@ -342,5 +351,10 @@ } } +QGraphicsWidget *WindowTaskItem::busyWidget() const +{ + return m_busyWidget; +} + #include "windowtaskitem.moc" Index: windowtaskitem.h =================================================================== --- windowtaskitem.h (版本 1004126) +++ windowtaskitem.h (工作副本) @@ -22,6 +22,7 @@ #ifndef WINDOWTASKITEM_H #define WINDOWTASKITEM_H +#include <Plasma/BusyWidget> #include "abstracttaskitem.h" // Own #include <taskmanager/taskmanager.h> @@ -54,6 +55,7 @@ virtual bool isWindowItem() const; virtual bool isActive() const; virtual void setAdditionalMimeData(QMimeData* mimeData); + QGraphicsWidget *busyWidget() const; signals: /** Emitted when a window is selected for activation, minimization, iconification */ @@ -80,6 +82,7 @@ void setWindowTask(TaskManager::TaskItem* taskItem); TaskManager::TaskItem *m_task; + Plasma::BusyWidget *m_busyWidget; }; #endif Index: tasks.cpp =================================================================== --- tasks.cpp (版本 1004126) +++ tasks.cpp (工作副本) @@ -399,6 +399,7 @@ void Tasks::setPopupDialog(bool status) { + Q_UNUSED(status) QWidget *widget = qobject_cast<QWidget *>(sender()); if (widget->isVisible()) {
_______________________________________________ Plasma-devel mailing list Plasma-devel@kde.org https://mail.kde.org/mailman/listinfo/plasma-devel