From 2f61410d6557dbc35bd1e07d7905844305c9364e Mon Sep 17 00:00:00 2001 From: Ivailo Monev Date: Wed, 27 Sep 2023 21:56:54 +0300 Subject: [PATCH] kdeplasma-addons: remove icontasks applet there shall be only one (official) applet for that task Signed-off-by: Ivailo Monev --- kdeplasma-addons/applets/CMakeLists.txt | 1 - .../applets/icontasks/CMakeLists.txt | 52 - .../applets/icontasks/Messages.sh | 3 - kdeplasma-addons/applets/icontasks/README | 106 - .../applets/icontasks/abstracttaskitem.cpp | 1856 ----------------- .../applets/icontasks/abstracttaskitem.h | 291 --- .../applets/icontasks/appearanceconfig.ui | 260 --- .../applets/icontasks/applauncheritem.cpp | 149 -- .../applets/icontasks/applauncheritem.h | 83 - kdeplasma-addons/applets/icontasks/badge.svgz | Bin 4150 -> 0 bytes .../applets/icontasks/behaviourconfig.ui | 207 -- .../applets/icontasks/dbusstatus.cpp | 46 - .../applets/icontasks/dbusstatus.h | 47 - .../applets/icontasks/dropindicators.svgz | Bin 2435 -> 0 bytes .../applets/icontasks/indicators.svgz | Bin 7462 -> 0 bytes .../applets/icontasks/jobmanager.cpp | 197 -- .../applets/icontasks/jobmanager.h | 72 - .../applets/icontasks/launcherseparator.svgz | Bin 2002 -> 0 bytes .../applets/icontasks/mediabuttons.cpp | 364 ---- .../applets/icontasks/mediabuttons.h | 95 - .../applets/icontasks/mediabuttonsrc | 6 - .../org.freedesktop.MediaPlayer.player.xml | 72 - .../org.mpris.MediaPlayer2.Player.xml | 43 - .../icontasks/plasma-applet-icontasks.desktop | 104 - .../applets/icontasks/progress.svgz | Bin 3687 -> 0 bytes .../applets/icontasks/recentdocuments.cpp | 542 ----- .../applets/icontasks/recentdocuments.h | 95 - .../applets/icontasks/taskgroupitem.cpp | 1597 -------------- .../applets/icontasks/taskgroupitem.h | 209 -- .../applets/icontasks/taskitemlayout.cpp | 635 ------ .../applets/icontasks/taskitemlayout.h | 110 - kdeplasma-addons/applets/icontasks/tasks.cpp | 755 ------- kdeplasma-addons/applets/icontasks/tasks.h | 255 --- .../applets/icontasks/tooltips/tooltip.cpp | 541 ----- .../applets/icontasks/tooltips/tooltip_p.h | 86 - .../icontasks/tooltips/tooltipcontent.cpp | 330 --- .../icontasks/tooltips/tooltipcontent.h | 258 --- .../icontasks/tooltips/tooltipmanager.cpp | 566 ----- .../icontasks/tooltips/tooltipmanager.h | 249 --- .../icontasks/tooltips/windowpreview.cpp | 498 ----- .../icontasks/tooltips/windowpreview_p.h | 116 -- .../applets/icontasks/windowtaskitem.cpp | 452 ---- .../applets/icontasks/windowtaskitem.h | 101 - 43 files changed, 11449 deletions(-) delete mode 100644 kdeplasma-addons/applets/icontasks/CMakeLists.txt delete mode 100755 kdeplasma-addons/applets/icontasks/Messages.sh delete mode 100644 kdeplasma-addons/applets/icontasks/README delete mode 100644 kdeplasma-addons/applets/icontasks/abstracttaskitem.cpp delete mode 100644 kdeplasma-addons/applets/icontasks/abstracttaskitem.h delete mode 100644 kdeplasma-addons/applets/icontasks/appearanceconfig.ui delete mode 100644 kdeplasma-addons/applets/icontasks/applauncheritem.cpp delete mode 100644 kdeplasma-addons/applets/icontasks/applauncheritem.h delete mode 100644 kdeplasma-addons/applets/icontasks/badge.svgz delete mode 100644 kdeplasma-addons/applets/icontasks/behaviourconfig.ui delete mode 100644 kdeplasma-addons/applets/icontasks/dbusstatus.cpp delete mode 100644 kdeplasma-addons/applets/icontasks/dbusstatus.h delete mode 100644 kdeplasma-addons/applets/icontasks/dropindicators.svgz delete mode 100644 kdeplasma-addons/applets/icontasks/indicators.svgz delete mode 100644 kdeplasma-addons/applets/icontasks/jobmanager.cpp delete mode 100644 kdeplasma-addons/applets/icontasks/jobmanager.h delete mode 100644 kdeplasma-addons/applets/icontasks/launcherseparator.svgz delete mode 100644 kdeplasma-addons/applets/icontasks/mediabuttons.cpp delete mode 100644 kdeplasma-addons/applets/icontasks/mediabuttons.h delete mode 100644 kdeplasma-addons/applets/icontasks/mediabuttonsrc delete mode 100644 kdeplasma-addons/applets/icontasks/org.freedesktop.MediaPlayer.player.xml delete mode 100644 kdeplasma-addons/applets/icontasks/org.mpris.MediaPlayer2.Player.xml delete mode 100644 kdeplasma-addons/applets/icontasks/plasma-applet-icontasks.desktop delete mode 100644 kdeplasma-addons/applets/icontasks/progress.svgz delete mode 100644 kdeplasma-addons/applets/icontasks/recentdocuments.cpp delete mode 100644 kdeplasma-addons/applets/icontasks/recentdocuments.h delete mode 100644 kdeplasma-addons/applets/icontasks/taskgroupitem.cpp delete mode 100644 kdeplasma-addons/applets/icontasks/taskgroupitem.h delete mode 100644 kdeplasma-addons/applets/icontasks/taskitemlayout.cpp delete mode 100644 kdeplasma-addons/applets/icontasks/taskitemlayout.h delete mode 100644 kdeplasma-addons/applets/icontasks/tasks.cpp delete mode 100644 kdeplasma-addons/applets/icontasks/tasks.h delete mode 100644 kdeplasma-addons/applets/icontasks/tooltips/tooltip.cpp delete mode 100644 kdeplasma-addons/applets/icontasks/tooltips/tooltip_p.h delete mode 100644 kdeplasma-addons/applets/icontasks/tooltips/tooltipcontent.cpp delete mode 100644 kdeplasma-addons/applets/icontasks/tooltips/tooltipcontent.h delete mode 100644 kdeplasma-addons/applets/icontasks/tooltips/tooltipmanager.cpp delete mode 100644 kdeplasma-addons/applets/icontasks/tooltips/tooltipmanager.h delete mode 100644 kdeplasma-addons/applets/icontasks/tooltips/windowpreview.cpp delete mode 100644 kdeplasma-addons/applets/icontasks/tooltips/windowpreview_p.h delete mode 100644 kdeplasma-addons/applets/icontasks/windowtaskitem.cpp delete mode 100644 kdeplasma-addons/applets/icontasks/windowtaskitem.h diff --git a/kdeplasma-addons/applets/CMakeLists.txt b/kdeplasma-addons/applets/CMakeLists.txt index ad305c72..95c18f2c 100644 --- a/kdeplasma-addons/applets/CMakeLists.txt +++ b/kdeplasma-addons/applets/CMakeLists.txt @@ -26,5 +26,4 @@ add_subdirectory(systemloadviewer) if(KDE4WORKSPACE_FOUND) add_subdirectory(binary-clock) add_subdirectory(fuzzy-clock) - add_subdirectory(icontasks) endif() diff --git a/kdeplasma-addons/applets/icontasks/CMakeLists.txt b/kdeplasma-addons/applets/icontasks/CMakeLists.txt deleted file mode 100644 index a1ec7278..00000000 --- a/kdeplasma-addons/applets/icontasks/CMakeLists.txt +++ /dev/null @@ -1,52 +0,0 @@ -set(tasks_SRCS - windowtaskitem.cpp - tasks.cpp - taskitemlayout.cpp - abstracttaskitem.cpp - taskgroupitem.cpp - applauncheritem.cpp - jobmanager.cpp - mediabuttons.cpp - dbusstatus.cpp - recentdocuments.cpp - tooltips/tooltipcontent.cpp - tooltips/tooltip.cpp - tooltips/tooltipmanager.cpp - tooltips/windowpreview.cpp - appearanceconfig.ui - behaviourconfig.ui -) - -qt4_add_dbus_interface(tasks_SRCS org.mpris.MediaPlayer2.Player.xml playerv2interface) - -set_source_files_properties(org.freedesktop.MediaPlayer.player.xml PROPERTIES INCLUDE "dbusstatus.h") -qt4_add_dbus_interface(tasks_SRCS org.freedesktop.MediaPlayer.player.xml playerv1interface) - -kde4_add_plugin(plasma_applet_icontasks ${tasks_SRCS}) - -target_link_libraries(plasma_applet_icontasks - KDE4::kdeui - KDE4::plasma - KDE4::kio - KDE4Workspace::taskmanager - ${X11_X11_LIB} -) - -include_directories(${CMAKE_BINARY_DIR}) - -install( - TARGETS plasma_applet_icontasks - DESTINATION ${KDE4_PLUGIN_INSTALL_DIR} -) -install( - FILES plasma-applet-icontasks.desktop - DESTINATION ${KDE4_SERVICES_INSTALL_DIR} -) -install( - FILES badge.svgz launcherseparator.svgz progress.svgz indicators.svgz dropindicators.svgz - DESTINATION ${KDE4_DATA_INSTALL_DIR}/desktoptheme/default/icontasks/ -) -install( - FILES mediabuttonsrc - DESTINATION ${KDE4_DATA_INSTALL_DIR}/kdeplasma-addons -) diff --git a/kdeplasma-addons/applets/icontasks/Messages.sh b/kdeplasma-addons/applets/icontasks/Messages.sh deleted file mode 100755 index b4a0b036..00000000 --- a/kdeplasma-addons/applets/icontasks/Messages.sh +++ /dev/null @@ -1,3 +0,0 @@ -#! /usr/bin/env bash -$EXTRACTRC *.ui >> rc.cpp -$XGETTEXT */*.cpp *.cpp -o $podir/plasma_applet_icontasks.pot diff --git a/kdeplasma-addons/applets/icontasks/README b/kdeplasma-addons/applets/icontasks/README deleted file mode 100644 index c4711d03..00000000 --- a/kdeplasma-addons/applets/icontasks/README +++ /dev/null @@ -1,106 +0,0 @@ -KDE Plasma Tasks Applet -======================= - -This is a desktop applet for KDE Plasma which provides a view -of the user's running graphical tasks and allows them to -switch between these tasks. - -It is intended as a replacement for the taskbar found in -KDE 3. - -Goals -===== - -This section describes the main goals of the tasks applet from the user's -perspective: - -- Provide a clear, attractive visual depiction of the user's running graphical tasks -- Allow the user to navigate between tasks quickly -- Allow the user to group related tasks so that they can be operated on - as one* - - -1. Task representation - - The information currently available from which a task representation can be - constructed: - - - Window title - - A (typically small) pixmap - - The 'window class' of a window which can in some cases be used - to look up an appropriate icon for that application. - - Notifications about changes to a window's state (eg. raised, - lowered, wants attention) - - This information is fairly limited. In order to provide more interesting - and useful representations in future, additional information will be - required. - - - A reliable source for a scalable icon for the task - - Information about the documents associated with a task - - Information about the people associated with a task - -2. Navigation between tasks - - The tasks applet should try to make it as easy as possible - for the user to perform a 'context switch' between the different - tasks they are performing. - - On a basic level, this means that: - - - The user must be able to identify the task from a small - representation - - Easily activate a task's representation which causes the - corresponding window to be raised and placed at the top - of the screen. - - Note: One of the flaws of KDE 3's Kicker is that task - representations are placed in a 2-task high grid - at one edge of the screen. This means that only half - of the task representations touch the screen edge and as a result - only half of them benefit from the 'infinite size' of a screen - edge with respect to activating it with the mouse. - - In the KDE 3.5.x series there is a bug in Kicker where the - colour of the text for a minimized task is grey, against what - is usually a grey/silverish panel background. This makes the - text difficult to read. - - Navigation between tasks usually occurs for two reasons: - - A) The user decides to switch to a different task of their own - volition. - - Example: Greg has been writing a business letter to a client, - he decides he wishes to take a break for twenty minutes - during which he intends to listen to music and read - the latest news online. - - He therefore wishes to switch away from the word document - and email related to that letter to his music player and - feed reader. - - B) An external interruption - - Example: Paul is watching the latest episode of a TV drama online when - he is alerted by his messaging client that a friend he wants - to talk to has come online. Paul then wishes to switch - away from the TV episode he is watching and start a conversation - with his friend. - -3. Grouping - - This is intended to be the main area of innovation in the KDE Plasma - 'taskbar' versus that found in KDE 3, Gnome, Windows, and Mac OS X. - - Some of these windows are likely to be related to the same logical - activity from the user's point of view. For example, a paper which - the user is writing and the various research material used to - write that paper. - - The idea is to allow the user to easily group these related tasks - so that he can treat them as one. That is, bringing all of them - to the front, closing all of them or layout out the windows within - a group so that they are all visible on screen at the same time - and can be worked with together. - diff --git a/kdeplasma-addons/applets/icontasks/abstracttaskitem.cpp b/kdeplasma-addons/applets/icontasks/abstracttaskitem.cpp deleted file mode 100644 index 998c9a4d..00000000 --- a/kdeplasma-addons/applets/icontasks/abstracttaskitem.cpp +++ /dev/null @@ -1,1856 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2007 by Robert Knight * - * Copyright (C) 2008 by Alexis Ménard * - * Copyright (C) 2008 by Marco Martin * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * - ***************************************************************************/ - -// Own -#include "abstracttaskitem.h" -#include "jobmanager.h" -#include "mediabuttons.h" -#include "recentdocuments.h" - -// Qt -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifdef Q_WS_X11 -#include -#endif - -// KDE -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include -#include -#include -#include -#include "tooltips/tooltipmanager.h" -#include - -#include "taskmanager/task.h" -#include "taskmanager/taskmanager.h" -#include "taskmanager/taskgroup.h" - -#include "tasks.h" -#include "taskgroupitem.h" -#include "applauncheritem.h" - -#include -#include - -struct Tile { - QPixmap left; - QPixmap center; - QPixmap right; -}; - -static QCache colorCache; -static QCache tileCache(50); -static QCache scaledCache(50); -static QPixmap shineCache; - -static QAction theSepAction("Separator", 0L); - -void AbstractTaskItem::clearCaches(int cache) -{ - if (cache & Cache_Bgnd) { - colorCache.clear(); - tileCache.clear(); - shineCache = QPixmap(); - } - - if (cache & Cache_Scale) { - scaledCache.clear(); - } -} - -static QPixmap scaleIcon(const QIcon &icon, const QSize &sz, const QPixmap &pix) -{ - static const int constStep = 4; - QSize s((sz.width() / constStep)*constStep, (sz.height() / constStep)*constStep); - QString key; - key.sprintf("%llx-%x-%x", icon.cacheKey(), s.width(), s.height()); - if (scaledCache.contains(key)) { - return *scaledCache[key]; - } - - QPixmap *scaled = new QPixmap(pix.scaled(s, Qt::KeepAspectRatio, Qt::SmoothTransformation)); - scaledCache.insert(key, scaled); - return *scaled; -} - -static bool hsvLess(const QColor &c1, const QColor &c2) -{ - int h1, s1, v1, h2, s2, v2; - c1.getHsv(&h1, &s1, &v1); - c2.getHsv(&h2, &s2, &v2); - - return - (h1 << 16 | s1 << 8 | v1) < - (h2 << 16 | s2 << 8 | v2); -} - -static bool isNear(const QColor &c1, const QColor &c2) -{ - int h1, s1, v1, h2, s2, v2; - c1.getHsv(&h1, &s1, &v1); - c2.getHsv(&h2, &s2, &v2); - - return - qAbs(h1 - h2) <= 8 && - qAbs(s1 - s2) <= 16 && - qAbs(v1 - v2) <= 32; -} - -static QColor dominantColor(const QIcon &icon) -{ - if (colorCache.contains(icon.cacheKey())) { - return *colorCache[icon.cacheKey()]; - } - - static const QColor constBlackSubstitute(64 , 64 , 64); - static const int constMin = 32; // Min value of r, g, and b - - QImage image(icon.pixmap(32, 32).toImage()); - QVector colors(image.width() * image.height()); - - int count = 0; - - // find the mean color - for (int x = 0; x < image.width(); ++ x) { - for (int y = 0; y < image.height(); ++ y) { - QRgb rgb = image.pixel(x, y); - - // only use non-(total-)transparent colors - if (qAlpha(rgb) != 0) { - QColor color(rgb); - - // only use colors that aren't too grey - if (color.saturation() > 24) { - colors[count] = color; - - ++ count; - } - } - } - } - - if (count == 0) { - colorCache.insert(icon.cacheKey(), new QColor(constBlackSubstitute)); - return *colorCache[icon.cacheKey()]; - } - - colors.resize(count); - qSort(colors.begin(), colors.end(), hsvLess); - - int mid = count / 2; - QColor midColor(colors[mid]); - QColor *begin = colors.data() + mid; - - // find similar colors before the mean: - if (mid != 0) { - -- begin; - - while (begin != colors.data()) { - if (isNear(*(begin - 1), midColor)) { - -- begin; - } else { - break; - } - } - } - - QColor* end = colors.data() + mid; - - // find similar colors after the mean: - while (end != colors.data() + colors.size()) { - if (isNear(*end, midColor)) { - ++ end; - } else { - break; - } - } - - // average of similar colors: - unsigned int r = 0, g = 0, b = 0; - for (QColor* it = begin; it != end; ++ it) { - r += it->red(); - g += it->green(); - b += it->blue(); - } - - int similarCount = std::distance(begin, end); - QColor color(r / similarCount, g / similarCount, b / similarCount); - int h, s, v; - color.getHsv(&h, &s, &v); - - if (v < 196) { - v = 196; - } else if (v > 224) { - v = 224; - } - - if (s < 128) { - s = 128; - } else if (s > 196) { - s = 196; - } - - color.setHsv(h, s, v); - - static const int constStep = 8; - QColor *col = new QColor((color.red() / constStep)*constStep, (color.green() / constStep)*constStep, (color.blue() / constStep)*constStep); - - if (col->red() < constMin && col->green() < constMin && col->blue() < constMin) { - *col = constBlackSubstitute; - } - colorCache.insert(icon.cacheKey(), col); - return *col; -} - -const Tile & coloredBackground(const QColor &color, const QSize &size) -{ - qreal radius = qMin(4.0, size.width() / 4.0); - int sectionWidth = qMax(2, (int)(radius + 1)); - - quint64 key = (((quint64)(sectionWidth & 0xFFFF)) << 48) + - (((quint64)(size.height() & 0xFFFF)) << 32) + - (color.red() << 16) + - (color.blue() << 8) + - (color.green()); - if (tileCache.contains(key)) { - return *tileCache[key]; - } - - QPixmap pix(sectionWidth * 3, size.height()); - pix.fill(Qt::transparent); - QPainter painter(&pix); - QPainterPath path(Plasma::PaintUtils::roundedRectangle(QRectF(0.5, 0.5, pix.width() - 1, pix.height() - 1), radius)); - QLinearGradient grad(QPoint(0, 0), QPoint(0, pix.height())); - QColor col(color); - - col.setAlphaF(0.7); - grad.setColorAt(0, KColorUtils::lighten(col, 0.5)); - grad.setColorAt(1.0, KColorUtils::darken(col, 0.35)); - - painter.setRenderHint(QPainter::Antialiasing, true); - painter.fillPath(path, grad); - -// col.setAlphaF(0.5); - painter.setPen(col); // KColorUtils::lighten(color, 0.2)); - painter.drawPath(path); - painter.end(); - - Tile *tile = new Tile; - tile->left = pix.copy(0, 0, sectionWidth, pix.height()); - tile->center = pix.copy(sectionWidth, 0, sectionWidth, pix.height()); - tile->right = pix.copy(sectionWidth * 2, 0, sectionWidth, pix.height()); - tileCache.insert(key, tile); - return *tile; -} - -const QPixmap & shine(const QSize &sz) -{ - QSize size(sz); - size.setHeight(sz.width() / 2); - - if (shineCache.size() == size) { - return shineCache; - } - - shineCache = QPixmap(size); - shineCache.fill(Qt::transparent); - QPainter painter(&shineCache); - QRadialGradient rad(QPointF(shineCache.width() / 2.0, 0), shineCache.width() / 2.0, QPointF(shineCache.width() / 2.0, 0)); - QColor c(Qt::white); - double alpha(0.6); - - c.setAlphaF(alpha); - rad.setColorAt(0, c); - c.setAlphaF(alpha * 0.625); -// rad.setColorAt(0.5, c); -// c.setAlphaF(alpha*0.125); -// rad.setColorAt(0.75, c); - c.setAlphaF(0); - rad.setColorAt(1, c); - painter.fillRect(QRect(0, 1, shineCache.width(), shineCache.height()), rad); - painter.end(); - - return shineCache; -} - -static QSize rotateFrame(const QSize &sz, bool rot) -{ - return rot ? QSize(sz.height(), sz.width()) : sz; -} - -static const int HOVER_EFFECT_TIMEOUT = 900; - -AbstractTaskItem::AbstractTaskItem(QGraphicsWidget *parent, Tasks *applet) - : QGraphicsWidget(parent), - m_abstractItem(0), - m_applet(applet), - m_flags(0), - m_backgroundFadeAnim(0), - m_alpha(1), - m_backgroundPrefix("normal"), - m_activateTimerId(0), - m_updateGeometryTimerId(0), - m_updateTimerId(0), - m_hoverEffectTimerId(0), - m_attentionTimerId(0), - m_attentionTicks(0), - m_mediaStateTimerId(0), - m_lastViewId(0), -// m_showText(true), - m_layoutAnimationLock(false), - m_firstGeometryUpdate(false), - m_progressSource(IS_None), - m_lastProgress(-1), - m_currentProgress(-1) -{ - m_layoutAnimation = new QPropertyAnimation(this, "animationPos", this); - m_layoutAnimation->setEasingCurve(QEasingCurve::InOutQuad); - m_layoutAnimation->setDuration(250); - - setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); - setAcceptHoverEvents(true); - setAcceptDrops(true); - setFocusPolicy(Qt::StrongFocus); - setFlag(QGraphicsItem::ItemIsFocusable); - - checkSettings(); - connect(applet->itemBackground(), SIGNAL(repaintNeeded()), this, SLOT(syncActiveRect())); - connect(applet, SIGNAL(settingsChanged()), this, SLOT(checkSettings())); - IconTasks::ToolTipManager::self()->registerWidget(this); -} - -QSize AbstractTaskItem::basicPreferredSize() const -{ - QFontMetrics fm(KGlobalSettings::taskbarFont()); - QSize mSize = fm.size(0, "M"); - const int iconsize = KIconLoader::SizeSmall; - - int size = (int)qMin((mSize.width() * 12 + m_applet->itemLeftMargin() + m_applet->itemRightMargin() + iconsize), - qMax(mSize.height(), iconsize) + m_applet->itemTopMargin() + m_applet->itemBottomMargin()); - return QSize(size, size); -} - -void AbstractTaskItem::setPreferredOffscreenSize() -{ - QFontMetrics fm(KGlobalSettings::taskbarFont()); - int textWidth = fm.width(text()); - QSize mSize = fm.size(0, "M"); - int iconsize = KIconLoader::SizeSmall; - - QSizeF s(qMax(qMin(textWidth, 512) + 8, mSize.width() * 12) + m_applet->offscreenLeftMargin() + m_applet->offscreenRightMargin() + iconsize, - qMax(mSize.height(), iconsize) + m_applet->offscreenTopMargin() + m_applet->offscreenBottomMargin()); - setPreferredSize(s); -} - -void AbstractTaskItem::setPreferredOnscreenSize() -{ - setPreferredSize(basicPreferredSize()); -} - -AbstractTaskItem::~AbstractTaskItem() -{ - stopWindowHoverEffect(); - emit destroyed(this); - IconTasks::ToolTipManager::self()->unregisterWidget(this); - - QList timers = QList() << m_activateTimerId - << m_updateGeometryTimerId - << m_updateTimerId - << m_hoverEffectTimerId - << m_attentionTimerId - << m_mediaStateTimerId; - foreach (int t, timers) { - if (t) { - killTimer(t); - } - } -} - -void AbstractTaskItem::checkSettings() -{ - TaskGroupItem *group = qobject_cast(this); - - if (m_applet->showToolTip() && (!group || group->collapsed())) { - clearToolTip(); - } else { - IconTasks::ToolTipManager::self()->unregisterWidget(this); - } -} - -void AbstractTaskItem::updateToolTipMediaState() -{ - IconTasks::ToolTipContent data; - QString key = mediaButtonKey(); - - if (!key.isEmpty()) { - data.setPlayState(MediaButtons::self()->playbackStatus(key, pid())); - } - - data.setAutohide(false); - data.setMediaUpdate(true); - IconTasks::ToolTipManager::self()->setContent(this, data); -} - -void AbstractTaskItem::clearToolTip() -{ - if (m_mediaStateTimerId) { - killTimer(m_mediaStateTimerId); - m_mediaStateTimerId = 0; - } - IconTasks::ToolTipContent data; - data.setInstantPopup(m_applet->instantToolTip()); - - IconTasks::ToolTipManager::self()->setContent(this, data); -} - -void AbstractTaskItem::clearAbstractItem() -{ - m_abstractItem = 0; -} - -QString AbstractTaskItem::text() const -{ - if (m_abstractItem) { - return m_abstractItem->name(); - } else { - kDebug() << "no abstract item?"; - } - - return QString(); -} - -QIcon AbstractTaskItem::icon() const -{ - if (m_abstractItem) { - if (m_applet->launcherIcons() && m_icon.isNull()) { - KUrl launcherUrl(m_abstractItem->launcherUrl()); - if (launcherUrl.isLocalFile() && KDesktopFile::isDesktopFile(launcherUrl.toLocalFile())) { - KDesktopFile f(launcherUrl.toLocalFile()); - if (f.tryExec()) { - m_icon = KIcon(f.readIcon()); - } - } - } - - return m_applet->launcherIcons() && !m_icon.isNull() ? m_icon : m_abstractItem->icon(); - } - - return QIcon(); -} - -void AbstractTaskItem::setTaskFlags(TaskFlags flags) -{ - if ((flags & TaskWantsAttention) && (flags & TaskHasFocus)) { - flags &= ~TaskWantsAttention; - } - - if (((m_flags & TaskWantsAttention) != 0) != ((flags & TaskWantsAttention) != 0)) { - //kDebug() << "task attention state changed" << m_attentionTimerId; - m_flags = flags; - if (flags & TaskWantsAttention) { - m_applet->needsVisualFocus(true); - // start attention getting - if (!m_attentionTimerId) { - m_attentionTimerId = startTimer(500); - } - } else { - m_applet->needsVisualFocus(false); - if (m_attentionTimerId) { - killTimer(m_attentionTimerId); - m_attentionTimerId = 0; - } - } - } - - m_flags = flags; - - QString newBackground; - if (m_flags & TaskIsMinimized) { - newBackground = "minimized"; - } else if (m_flags & TaskHasFocus) { - newBackground = "focus"; - } else { - newBackground = "normal"; - } - - if (newBackground != m_backgroundPrefix) { - fadeBackground(newBackground, 250); - } -} - -void AbstractTaskItem::fadeBackground(const QString &newBackground, int duration) -{ - TaskGroupItem *group = qobject_cast(this); - if (group && !group->collapsed()) { - return; - } - - m_oldBackgroundPrefix = m_backgroundPrefix; - m_backgroundPrefix = newBackground; - - if (m_oldBackgroundPrefix.isEmpty()) { - update(); - } else { - if (!m_backgroundFadeAnim) { - m_backgroundFadeAnim = new QPropertyAnimation(this); - m_backgroundFadeAnim->setDuration(duration); - m_backgroundFadeAnim->setEasingCurve(QEasingCurve::InQuad); - m_backgroundFadeAnim->setPropertyName("backgroundFadeAlpha"); - m_backgroundFadeAnim->setTargetObject(this); - m_backgroundFadeAnim->setStartValue(0); - m_backgroundFadeAnim->setEndValue(1); - } - - m_backgroundFadeAnim->start(); - } -} - -AbstractTaskItem::TaskFlags AbstractTaskItem::taskFlags() const -{ - return m_flags; -} - -void AbstractTaskItem::toolTipAboutToShow() -{ - if (m_applet->showToolTip()) { - updateToolTip(); - connect(IconTasks::ToolTipManager::self(), - SIGNAL(windowPreviewActivated(WId, Qt::MouseButtons, Qt::KeyboardModifiers, QPoint)), - this, SLOT(windowPreviewActivated(WId, Qt::MouseButtons, Qt::KeyboardModifiers, QPoint))); - connect(IconTasks::ToolTipManager::self(), - SIGNAL(windowButtonActivated(WId, Qt::MouseButtons, Qt::KeyboardModifiers, QPoint)), - this, SLOT(controlWindow(WId, Qt::MouseButtons))); - connect(IconTasks::ToolTipManager::self(), - SIGNAL(mediaButtonPressed(int)), this, SLOT(mediaButtonPressed(int))); - } else { - clearToolTip(); - } -} - -void AbstractTaskItem::toolTipHidden() -{ - clearToolTip(); - disconnect(IconTasks::ToolTipManager::self(), - SIGNAL(windowPreviewActivated(WId, Qt::MouseButtons, Qt::KeyboardModifiers, QPoint)), - this, SLOT(windowPreviewActivated(WId, Qt::MouseButtons, Qt::KeyboardModifiers, QPoint))); - disconnect(IconTasks::ToolTipManager::self(), - SIGNAL(windowButtonActivated(WId, Qt::MouseButtons, Qt::KeyboardModifiers, QPoint)), - this, SLOT(controlWindow(WId, Qt::MouseButtons))); - disconnect(IconTasks::ToolTipManager::self(), - SIGNAL(mediaButtonPressed(int)), this, SLOT(mediaButtonPressed(int))); -} - -QString AbstractTaskItem::mediaButtonKey() -{ - KUrl lUrl = launcherUrl(); - QString desktopEntry; - if (lUrl.isValid()) { - desktopEntry = lUrl.fileName().remove(".desktop").toLower(); - } - - if (MediaButtons::self()->isMediaApp(desktopEntry)) { - QString key = windowClass().toLower(); - - if (key.isEmpty()) { - key = desktopEntry; - } - - return key; - } - - return QString(); -} - -void AbstractTaskItem::mediaButtonPressed(int b) -{ - QString key = mediaButtonKey(); - if (!key.isEmpty()) { - switch (b) { - case IconTasks::ToolTipManager::MB_PREV: - MediaButtons::self()->previous(key, pid()); - break; - case IconTasks::ToolTipManager::MB_PLAY_PAUSE: - MediaButtons::self()->playPause(key, pid()); - break; - case IconTasks::ToolTipManager::MB_NEXT: - MediaButtons::self()->next(key, pid()); - break; - default: - break; - } - - // Update the playstate after a timer, to give player time to react... - if (m_mediaStateTimerId) { - killTimer(m_mediaStateTimerId); - m_mediaStateTimerId = 0; - } - m_mediaStateTimerId = startTimer(250); - } -} - -void AbstractTaskItem::windowPreviewActivated(WId id, Qt::MouseButtons buttons, Qt::KeyboardModifiers, const QPoint &pos) -{ - if (buttons & Qt::LeftButton) { - if (parentGroup()) { - AbstractTaskItem *item = parentGroup()->taskItemForWId(id); - if (item) { - IconTasks::ToolTipManager::self()->hide(this); - item->activate(); - } - } - } else if (buttons & Qt::RightButton) { - if (parentGroup()) { - AbstractTaskItem *item = parentGroup()->taskItemForWId(id); - if (item) { - // Onnly show menu if th e hide timer has not already gone off!!! - if (IconTasks::ToolTipManager::self()->stopHideTimer(this)) { - item->showContextMenu(pos, false); - IconTasks::ToolTipManager::self()->startHideTimer(this); - } - } - } - } else if (buttons & Qt::MiddleButton) { - switch (m_applet->middleClick()) { - case Tasks::MC_Close: { - if (parentGroup()) { - AbstractTaskItem *item = parentGroup()->taskItemForWId(id); - if (item) { - item->m_abstractItem->close(); - } - } - break; - } - case Tasks::MC_MoveToCurrentDesktop: { - if (parentGroup()) { - AbstractTaskItem *item = parentGroup()->taskItemForWId(id); - if (item) { - item->toCurrentDesktop(); - } - } - break; - } - default: - break; - } - } -} - -void AbstractTaskItem::controlWindow(WId id, Qt::MouseButtons buttons) -{ - // TODO: More window actions... - if (buttons & Qt::LeftButton) { - if (parentGroup()) { - AbstractTaskItem *item = parentGroup()->taskItemForWId(id); - if (item && item->m_abstractItem) { - IconTasks::ToolTipManager::self()->hide(this); - item->m_abstractItem->close(); - } - } - } -} - -void AbstractTaskItem::middleClick() -{ - if (m_abstractItem) { - switch (m_applet->middleClick()) { - case Tasks::MC_NewInstance: { - KUrl url = m_abstractItem->launcherUrl(); - - if (!url.isEmpty()) { - new KRun(url, 0); - } - break; - } - case Tasks::MC_Close: - m_abstractItem->close(); - break; - case Tasks::MC_MoveToCurrentDesktop: - toCurrentDesktop(); - break; - default: - break; - } - } -} - -void AbstractTaskItem::queueUpdate() -{ - if (m_updateTimerId || m_attentionTimerId) { - return; - } - - if (m_lastUpdate.elapsed() < 100) { - m_updateTimerId = startTimer(100); - return; - } - - publishIconGeometry(); - update(); - m_lastUpdate.restart(); -} - -void AbstractTaskItem::focusInEvent(QFocusEvent *event) -{ - Q_UNUSED(event) - - setTaskFlags(m_flags | TaskHasFocus); - update(); -} - -void AbstractTaskItem::focusOutEvent(QFocusEvent *event) -{ - Q_UNUSED(event) - - setTaskFlags(m_flags & ~TaskHasFocus); - update(); -} - -void AbstractTaskItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event) -{ - Q_UNUSED(event) - fadeBackground("hover", 250); - QGraphicsWidget *w = parentWidget(); - if (w && this != m_applet->rootGroupItem()) { - if (m_hoverEffectTimerId) { - killTimer(m_hoverEffectTimerId); - m_hoverEffectTimerId = 0; - } - - m_hoverEffectTimerId = startTimer(HOVER_EFFECT_TIMEOUT); - } -} - -void AbstractTaskItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) -{ - Q_UNUSED(event) - - stopWindowHoverEffect(); - - QString backgroundPrefix; - if (m_flags & TaskWantsAttention && 0 != m_attentionTimerId) { - backgroundPrefix = "attention"; - } else if (m_flags & TaskIsMinimized) { - backgroundPrefix = "minimized"; - } else if (m_flags & TaskHasFocus) { - backgroundPrefix = "focus"; - } else { - backgroundPrefix = "normal"; - } - - fadeBackground(backgroundPrefix, 150); -} - -void AbstractTaskItem::stopWindowHoverEffect() -{ - if (m_hoverEffectTimerId) { - killTimer(m_hoverEffectTimerId); - m_hoverEffectTimerId = 0; - } - - if (m_lastViewId && m_applet->highlightWindows()) { - Plasma::WindowEffects::highlightWindows(m_lastViewId, QList()); - } -} - -void AbstractTaskItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) -{ - switch (event->button()) { - case Qt::LeftButton: - if (boundingRect().contains(event->pos())) { - activate(); - } - break; - case Qt::MiddleButton: - middleClick(); - break; - default: - break; - } -} - -void AbstractTaskItem::mousePressEvent(QGraphicsSceneMouseEvent *) -{ - update(); -} - -void AbstractTaskItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) -{ - //kDebug(); - if (QPoint(event->screenPos() - event->buttonDownScreenPos(Qt::LeftButton)).manhattanLength() < QApplication::startDragDistance()) { - return; - } //Wait a bit before starting drag - - QMimeData* mimeData = new QMimeData(); - //#ifndef ICON_TASKS_SHOW_DROP_INDICATOR_FOR_MOVE - mimeData->setProperty("icontasks-item-ptr", (qulonglong)this); - //#else - //mimeData->setProperty("icontasks-item-index", m_applet->rootGroupItem()->indexOf(this, false)); - //#endif - setAdditionalMimeData(mimeData); - - if (mimeData->formats().isEmpty()) { - delete mimeData; - return; - } - - QDrag *drag = new QDrag(event->widget()); - drag->setMimeData(mimeData); - //#ifndef ICON_TASKS_SHOW_DROP_INDICATOR_FOR_MOVE - drag->setPixmap(icon().pixmap(KIconLoader::SizeSmall, KIconLoader::SizeSmall)); - //#else - //drag->setPixmap(icon().pixmap(iconSize(m_applet->autoIconScaling() ? boundingRect().adjusted(4, 4, -5, -5) : boundingRect()).width())); - //#endif - drag->exec(); -} - -void AbstractTaskItem::timerEvent(QTimerEvent *event) -{ - if (event->timerId() == m_activateTimerId) { - killTimer(m_activateTimerId); - m_activateTimerId = 0; - if (!isActive()) { - activate(); - } - } else if (event->timerId() == m_updateGeometryTimerId) { - killTimer(m_updateGeometryTimerId); - m_updateGeometryTimerId = 0; - m_firstGeometryUpdate = true; - publishIconGeometry(); - } else if (event->timerId() == m_updateTimerId) { - killTimer(m_updateTimerId); - m_updateTimerId = 0; - update(); - } else if (event->timerId() == m_attentionTimerId) { - ++m_attentionTicks; - if (m_attentionTicks > (Tasks::Style_Plasma == m_applet->style() ? 6 : 9)) { - killTimer(m_attentionTimerId); - m_attentionTimerId = 0; - m_attentionTicks = 0; - } - - if (m_attentionTicks % 2 == 0) { - fadeBackground("attention", Tasks::Style_Plasma == m_applet->style() ? 200 : 300); - } else { - fadeBackground("normal", Tasks::Style_Plasma == m_applet->style() ? 250 : 375); - } - } else if (event->timerId() == m_hoverEffectTimerId) { - killTimer(m_hoverEffectTimerId); - m_hoverEffectTimerId = 0; - if (!isUnderMouse()) { - return; - } - -#ifdef Q_WS_X11 - QList windows; - - if (m_abstractItem && m_abstractItem->itemType() == TaskManager::GroupItemType) { - TaskManager::TaskGroup *group = qobject_cast(m_abstractItem); - - if (group) { - TaskGroupItem *groupItem = qobject_cast(this); - if (groupItem && groupItem->popupDialog()) { - kDebug() << "adding" << groupItem->popupDialog()->winId(); - windows.append(groupItem->popupDialog()->winId()); - } - - foreach (AbstractGroupableItem * item, group->members()) { - if (item->itemType() == TaskManager::TaskItemType) { - TaskManager::TaskItem *taskItem = qobject_cast(item); - if (taskItem && taskItem->task()) { - windows.append(taskItem->task()->window()); - } - } //TODO: if taskgroup, recurse through sub-groups? - } - } - } else { - WindowTaskItem *windowTaskItem = qobject_cast(this); - if (windowTaskItem && windowTaskItem->parent()) { - TaskGroupItem *groupItem = qobject_cast(windowTaskItem->parent()); - if (groupItem && groupItem->popupDialog()) { - windows.append(groupItem->popupDialog()->winId()); - } - } - - TaskManager::TaskItem *taskItem = qobject_cast(m_abstractItem); - if (taskItem && taskItem->task()) { - windows.append(taskItem->task()->window()); - } - } - - stopWindowHoverEffect(); - QGraphicsView *view = m_applet->view(); - if (view && m_applet->highlightWindows()) { - m_lastViewId = view->winId(); - Plasma::WindowEffects::highlightWindows(m_lastViewId, windows); - } -#endif - } else if (event->timerId() == m_mediaStateTimerId) { - killTimer(m_mediaStateTimerId); - m_mediaStateTimerId = 0; - updateToolTipMediaState(); - } else { - QGraphicsWidget::timerEvent(event); - } -} - -bool AbstractTaskItem::isStartupWithTask() const -{ - return busyWidget() && parentGroup() && parentGroup()->matchingItem(m_abstractItem); -} - -bool AbstractTaskItem::isToolTipVisible() const -{ - return IconTasks::ToolTipManager::self()->isVisible(this); -} - -void AbstractTaskItem::updateProgress(int v, InfoSource source) -{ - if (source == m_progressSource || IS_None == m_progressSource) { - m_progressSource = source; - m_currentProgress = v; - if (m_lastProgress != m_currentProgress && (m_currentProgress < 1 || 100 == m_currentProgress || abs(m_currentProgress - m_lastProgress) > 2)) { - queueUpdate(); - } - - if (m_currentProgress < 0) { - m_progressSource = IS_None; - } - } -} - -void AbstractTaskItem::drawProgress(QPainter *painter, const QRectF &rect) -{ - if (rect.width() < 12 || rect.height() < 12) { - return; - } - - m_lastProgress = m_currentProgress; - - double height = qMin(8.0, rect.height() / 4.0); - QRectF border(rect.x(), rect.bottom() - (height + 1), rect.width(), height); - qreal fill = ((border.width() - 1.0) * m_currentProgress) / 100.0; - Plasma::FrameSvg *svg = m_applet->progressBar(); - - svg->setElementPrefix("bar-inactive"); - - if (border.size() != svg->frameSize()) { - m_applet->resizeProgressBar(border.size()); - } - svg->paintFrame(painter, border.topLeft()); - - if (fill > 0.0 && fill < 4.0) { - fill = 4.0; - } - if (fill >= 2.0) { - bool rtl = Qt::RightToLeft == layoutDirection(); - QRectF fillRect(rtl ? border.right() - fill : border.x(), border.y(), fill, border.height()); - svg->setElementPrefix("bar-active"); - - if (fillRect.size() != svg->frameSize()) { - m_applet->resizeProgressBar(fillRect.size()); - } - - svg->paintFrame(painter, fillRect.topLeft()); - } -} - -void AbstractTaskItem::drawBadge(QPainter *painter, const QRectF &bounds, const QString &badge) -{ - static const qreal constMaxPercent = 0.95; - static const int constBlockSize = 4; - - QFont font(KGlobalSettings::taskbarFont()); - font.setItalic(false); - QFontMetrics fm(font); - QRect textRect = fm.boundingRect(badge).adjusted(-4, -2, 4, 2); - int origWidth = textRect.width(); - - // To save lots of re-sizing, adjust width in step of 4 pixels - textRect.setWidth(((textRect.width() / constBlockSize)*constBlockSize) + (textRect.width() % constBlockSize ? constBlockSize : 0)); - - if (textRect.width() > (bounds.width()*constMaxPercent)) { - // Perhaps rounding has made it too big? - textRect.setWidth(origWidth); - if (textRect.width() > (bounds.width()*constMaxPercent)) { - // Try decreasing font size... - font = KGlobalSettings::smallestReadableFont(); - font.setItalic(false); - fm = QFontMetrics(font); - textRect = fm.boundingRect(badge).adjusted(-2, -1, 2, 1); - } - } - - if (textRect.width() <= (bounds.width()*constMaxPercent)) { - QColor txtCol(textColor()); - bool rtl = Qt::RightToLeft == layoutDirection(); - QRectF textRectF(rtl ? bounds.x() : bounds.right() - textRect.width(), - bounds.y() + 1, textRect.width(), textRect.height()); - Plasma::FrameSvg *svg = m_applet->badgeBackground(); - - if (Tasks::Style_Plasma != m_applet->style()) { - textRectF.adjust(rtl ? -1 : 1, -1, rtl ? -1 : 1, -1); - } - - svg->setElementPrefix(txtCol.value() > 160 ? "dark" : "light"); - if (textRectF.size() != svg->frameSize()) { - m_applet->resizeBadgeBackground(textRectF.size()); - } - svg->paintFrame(painter, textRectF.topLeft()); - painter->setFont(font); - painter->setPen(QPen(txtCol, 1.0)); - painter->drawText(textRectF, Qt::AlignCenter, badge); - } -} - -void AbstractTaskItem::drawIndicators(QPainter *painter, const QRectF &bounds) -{ - QString suffix = m_flags & TaskWantsAttention ? "-attention" : m_flags & TaskIsMinimized ? "-minimized" : ""; - QString position; - bool vertical = Plasma::Vertical == m_applet->formFactor(); - qreal dimension = vertical ? bounds.height() : bounds.width(); - qreal size = dimension > 48 ? qMin(24.0, dimension / 4.0) : qMin(12.0, dimension / 2.0); - QSizeF iSize(vertical ? size * 0.75 : size, vertical ? size : size * 0.75); - bool group = qobject_cast(this); - Plasma::Svg *svg = m_applet->indicators(); - - if (iSize != svg->size()) { - svg->resize(iSize); - } - - switch (m_applet->location()) { - case Plasma::TopEdge: - if (group) { - svg->paint(painter, QPointF(bounds.x() + ((bounds.width() - (iSize.width() * 1.5)) / 2.0) + (iSize.width() * 0.5), - bounds.y()), - "down" + suffix); - svg->paint(painter, QPointF(bounds.x() + ((bounds.width() - (iSize.width() * 1.5)) / 2.0), - bounds.y()), - "down" + suffix); - } else { - svg->paint(painter, QPointF(bounds.x() + ((bounds.width() - iSize.width()) / 2.0), - bounds.y()), - "down" + suffix); - } - if (m_flags & TaskHasFocus) { - svg->paint(painter, QPointF(bounds.x() + ((bounds.width() - iSize.width()) / 2.0), - bounds.y() + (bounds.height() - iSize.height())), - "up" + suffix); - } - break; - case Plasma::RightEdge: - if (group) { - svg->paint(painter, QPointF(bounds.x() + (bounds.width() - iSize.width()), - bounds.y() + ((bounds.height() - (iSize.height() * 1.5)) / 2.0) + (iSize.height() * 0.5)), - "left" + suffix); - svg->paint(painter, QPointF(bounds.x() + (bounds.width() - iSize.width()), - bounds.y() + ((bounds.height() - (iSize.height() * 1.5)) / 2.0)), - "left" + suffix); - } else { - svg->paint(painter, QPointF(bounds.x() + (bounds.width() - iSize.width()), - bounds.y() + ((bounds.height() - iSize.height()) / 2.0)), - "left" + suffix); - } - if (m_flags & TaskHasFocus) { - svg->paint(painter, QPointF(bounds.x(), - bounds.y() + ((bounds.height() - iSize.height()) / 2.0)), - "right" + suffix); - } - break; - case Plasma::LeftEdge: - if (group) { - svg->paint(painter, QPointF(bounds.x(), - bounds.y() + ((bounds.height() - (iSize.height() * 1.5)) / 2.0) + (iSize.height() * 0.5)), - "right" + suffix); - svg->paint(painter, QPointF(bounds.x(), - bounds.y() + ((bounds.height() - (iSize.height() * 1.5)) / 2.0)), - "right" + suffix); - } else { - svg->paint(painter, QPointF(bounds.x(), - bounds.y() + ((bounds.height() - iSize.height()) / 2.0)), - "right" + suffix); - } - if (m_flags & TaskHasFocus) { - svg->paint(painter, QPointF(bounds.x() + (bounds.width() - iSize.width()), - bounds.y() + ((bounds.height() - iSize.height()) / 2.0)), - "left" + suffix); - } - break; - default: - case Plasma::BottomEdge: - if (group) { - svg->paint(painter, QPointF(bounds.x() + ((bounds.width() - (iSize.width() * 1.5)) / 2.0) + (iSize.width() * 0.5), - bounds.y() + (bounds.height() - iSize.height())), - "up" + suffix); - svg->paint(painter, QPointF(bounds.x() + ((bounds.width() - (iSize.width() * 1.5)) / 2.0), - bounds.y() + (bounds.height() - iSize.height())), - "up" + suffix); - } else { - svg->paint(painter, QPointF(bounds.x() + ((bounds.width() - iSize.width()) / 2.0), - bounds.y() + (bounds.height() - iSize.height())), - "up" + suffix); - } - if (m_flags & TaskHasFocus) { - svg->paint(painter, QPointF(bounds.x() + ((bounds.width() - iSize.width()) / 2.0), - bounds.y()), - "down" + suffix); - } - } -} - -void AbstractTaskItem::drawColoredBackground(QPainter *painter, const QStyleOptionGraphicsItem *option) -{ - // Do not paint with invalid sizes, the happens when the layout is being initialized - if (!option->rect.isValid()) { - return; - } - - QSize sz = size().toSize() - QSize(4, 4); - const Tile &tile = coloredBackground(dominantColor(icon()), sz); - QPointF pos = size().toSize() == m_activeRect.size().toSize() ? m_activeRect.topLeft() + QPoint(2, 2) : QPointF(2, 2); - - if (!tile.left.isNull()) { - painter->drawPixmap(pos, tile.left); - painter->drawTiledPixmap(pos.x() + tile.left.width(), pos.y(), sz.width() - (tile.left.width() + tile.right.width()), tile.center.height(), tile.center); - painter->drawPixmap((pos.x() + sz.width()) - tile.right.width(), pos.y(), tile.right); - } -} - -void AbstractTaskItem::drawShine(QPainter *painter, const QStyleOptionGraphicsItem *option) -{ - // Do not paint with invalid sizes, the happens when the layout is being initialized - if (!option->rect.isValid()) { - return; - } - - QPixmap pixmap = shine(size().toSize() - QSize(4, 4)); - if (pixmap.size() == (m_activeRect.size().toSize() - QSize(4, 4))) { - painter->drawPixmap(m_activeRect.topLeft() + QPoint(2, 2), pixmap); - } else { - painter->drawPixmap(QPoint(2, 2), pixmap); - } -} - -void AbstractTaskItem::paint(QPainter *painter, - const QStyleOptionGraphicsItem *option, - QWidget *) -{ - if (!m_abstractItem) { - return; - } - - qreal origOpacity = 1.0; - bool fadeBackground = false; - - if (busyWidget()) { - AbstractTaskItem *item = parentGroup()->matchingItem(m_abstractItem); - if (item) { - QRectF iconR = item->iconRect(/*m_applet->autoIconScaling() ? item->boundingRect().adjusted(4,4,-5,-5) : */item->boundingRect(), false); - QPointF pos = item->mapToParent(QPointF(iconR.x(), iconR.y())); - - busyWidget()->setGeometry(QRectF(pos.x(), pos.y(), iconR.width(), iconR.height())); - busyWidget()->show(); - setGeometry(QRectF(-1, -1, 1, 1)); // Hide this item... - return; - } else { - origOpacity = painter->opacity(); - fadeBackground = true; - } - } - - //kDebug() << "painting" << (QObject*)this << text(); - painter->setRenderHint(QPainter::Antialiasing); - QRectF bounds(boundingRect()); - bool showText = bounds.width() > (bounds.height() * 4); // Want text for popup! - - if ((Tasks::Style_Plasma == m_applet->style() || showText) && (m_abstractItem->itemType() != TaskManager::LauncherItemType)) { //Launchers have no frame - // draw background - drawBackground(painter, option); - if (fadeBackground) { - painter->setOpacity(origOpacity * 0.50); - } - } else if (Tasks::Style_IconTasksColored == m_applet->style()) { - if (fadeBackground) { - painter->setOpacity(origOpacity * 0.50); - } - drawColoredBackground(painter, option); - } - - // draw icon and text - drawTask(painter, option, showText); - - if (fadeBackground) { - painter->setOpacity(origOpacity); - } -} - -void AbstractTaskItem::syncActiveRect() -{ - Plasma::FrameSvg *itemBackground = m_applet->itemBackground(); - itemBackground->setElementPrefix("normal"); - - qreal left, top, right, bottom; - itemBackground->getMargins(left, top, right, bottom); - - itemBackground->setElementPrefix("focus"); - qreal activeLeft, activeTop, activeRight, activeBottom; - itemBackground->getMargins(activeLeft, activeTop, activeRight, activeBottom); - - m_activeRect = QRectF(QPointF(0, 0), size()); - m_activeRect.adjust(left - activeLeft, top - activeTop, - -(right - activeRight), -(bottom - activeBottom)); - - itemBackground->setElementPrefix(m_backgroundPrefix); - - queueUpdate(); -} - -void AbstractTaskItem::resizeEvent(QGraphicsSceneResizeEvent *event) -{ - syncActiveRect(); - resizeBackground(event->newSize().toSize()); -} - -void AbstractTaskItem::resizeBackground(const QSize &size) -{ - Plasma::FrameSvg *itemBackground = m_applet->itemBackground(); - bool vertical = Plasma::Vertical == m_applet->formFactor(), - rot = vertical && m_applet->rotate(); - QSize sz = rotateFrame(size, rot) + (vertical ? QSize(2, 2) : QSize(0, 0)); - - itemBackground->setElementPrefix("focus"); - m_applet->resizeItemBackground(sz); - itemBackground->setElementPrefix("normal"); - m_applet->resizeItemBackground(sz); - itemBackground->setElementPrefix("minimized"); - m_applet->resizeItemBackground(sz); - itemBackground->setElementPrefix("attention"); - m_applet->resizeItemBackground(sz); - itemBackground->setElementPrefix("hover"); - m_applet->resizeItemBackground(sz); - - //restore the prefix - itemBackground->setElementPrefix(m_backgroundPrefix); -} - -void AbstractTaskItem::drawBackground(QPainter *painter, const QStyleOptionGraphicsItem *option) -{ - // Do not paint with invalid sizes, the happens when the layout is being initialized - if (!option->rect.isValid()) { - return; - } - - bool rot = Plasma::Vertical == m_applet->formFactor() && m_applet->rotate(); - - /*FIXME -could be done more elegant with caching in tasks in a qhash . - -do not use size() directly because this introduces the blackline syndrome. - -This line is only needed when we have different items in the taskbar because of an expanded group for example. otherwise the resizing in the resizeEvent is sufficient - */ - Plasma::FrameSvg *itemBackground = m_applet->itemBackground(); - QPointF adj = Plasma::LeftEdge == m_applet->location() || Plasma::RightEdge == m_applet->location() - ? QPointF(-1, -1) : QPointF(0, 0); - - if (rot) { - painter->save(); - painter->rotate(-90); - painter->translate(-boundingRect().height(), 0); - } - - if (~option->state & QStyle::State_Sunken && - (!m_backgroundFadeAnim || m_backgroundFadeAnim->state() != QAbstractAnimation::Running)) { - itemBackground->setElementPrefix(m_backgroundPrefix); - //since a single framesvg is shared between all tasks, we could have to resize it even if there wasn't a resizeevent - if (rotateFrame(size().toSize(), rot) != itemBackground->frameSize()) { - resizeBackground(size().toSize()); - } - - if (itemBackground->frameSize() == m_activeRect.size().toSize()) { - itemBackground->paintFrame(painter, m_activeRect.topLeft() + adj); - } else { - itemBackground->paintFrame(painter, adj); - } - //itemBackground->paintFrame(painter, backgroundPosition); - if (rot) painter->restore(); - return; - } - - itemBackground->setElementPrefix(m_oldBackgroundPrefix); - //since a single framesvg is shared between all tasks, we could have to resize it even if there wasn't a resizeevent - if (rotateFrame(size().toSize(), rot) != itemBackground->frameSize()) { - resizeBackground(size().toSize()); - } - - QPixmap oldBackground; - - if (option->state & QStyle::State_Sunken) { - oldBackground = QPixmap(m_activeRect.size().toSize()); - oldBackground.fill(Qt::transparent); - m_alpha = 0.4; - } else { - oldBackground = itemBackground->framePixmap(); - } - - itemBackground->setElementPrefix(m_backgroundPrefix); - //since a single framesvg is shared between all tasks, we could have to resize it even if there wasn't a resizeevent - if (rotateFrame(size().toSize(), rot) != itemBackground->frameSize()) { - resizeBackground(size().toSize()); - } - - QPixmap result = Plasma::PaintUtils::transition(oldBackground, itemBackground->framePixmap(), m_alpha); - - if (result.size() == m_activeRect.size().toSize()) { - painter->drawPixmap(m_activeRect.topLeft() + adj, result); - } else { - painter->drawPixmap(QPoint(0, 0) + adj, result); - } - if (rot) painter->restore(); -} - -void AbstractTaskItem::drawTask(QPainter *painter, const QStyleOptionGraphicsItem *option, bool showText) -{ - Q_UNUSED(option) - - QRectF boundOrig = boundingRect(); - QRectF bounds = boundOrig; - - if (/*(m_abstractItem->itemType() != TaskManager::LauncherItemType) &&*/ showText) { - bounds = bounds.adjusted(m_applet->itemLeftMargin(), m_applet->itemTopMargin(), -m_applet->itemRightMargin(), -m_applet->itemBottomMargin()); - } else { - bounds = bounds.adjusted(4, 4, -5, -5); - } - - WindowTaskItem *window = qobject_cast(this); - QGraphicsWidget *busyWidget; - busyWidget = window ? window->busyWidget() : 0; - - QRectF iconR = iconRect(m_applet->autoIconScaling() ? bounds : boundOrig, showText); - - if (busyWidget) { - QRectF bwR = iconRect(boundOrig, false); - QPointF pos = mapToParent(QPointF(bwR.x(), bwR.y())); - busyWidget->setGeometry(QRectF(pos.x(), pos.y(), bwR.width(), bwR.height())); - busyWidget->show(); - } - - /* - kDebug() << bool(option->state & QStyle::State_MouseOver) << m_backgroundFadeAnim << - (m_backgroundFadeAnim ? m_backgroundFadeAnim->state() : QAbstractAnimation::Stopped);*/ - const bool fadingBg = m_backgroundFadeAnim && m_backgroundFadeAnim->state() == QAbstractAnimation::Running; - QIcon icn(icon()); - QSize iSize = iconR.toRect().size(); - QPixmap result = icn.pixmap(iSize); - - if (!m_applet->autoIconScaling() && result.size() != iSize) { - result = scaleIcon(icn, iconR.toRect().size(), result); - if (result.size() != iSize) { - int xmod = (iSize.width() - result.width()) / 2, - ymod = (iSize.height() - result.height()) / 2; - iconR.adjust(xmod, ymod, -xmod, -ymod); - } - } - - if ((!fadingBg && !(option->state & QStyle::State_MouseOver)) || - (m_oldBackgroundPrefix != "hover" && m_backgroundPrefix != "hover")) { - // QIcon::paint does some alignment work and can lead to funny - // things when icon().size() != iconR.toRect().size() - qreal opacity = painter->opacity(); - if (Tasks::Style_Plasma != m_applet->style()) { - if (m_attentionTimerId) { - painter->setOpacity(0.25 + ((((m_alpha > 0.5 ? m_alpha : 1.0 - m_alpha) - 0.5) / 0.5) * 0.75)); - } -// else if (m_flags & TaskIsMinimized) { -// painter->setOpacity(0.6*painter->opacity()); -// } - } - painter->drawPixmap(iconR.topLeft(), result); - if (Tasks::Style_Plasma != m_applet->style() && (/* (m_flags & TaskIsMinimized) || */m_attentionTimerId)) { - painter->setOpacity(opacity); - } - } else { - KIconEffect *effect = KIconLoader::global()->iconEffect(); - - 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_backgroundPrefix != "hover" ? 1 - m_alpha : m_alpha); - } - } - painter->drawPixmap(iconR.topLeft(), result); - } - - painter->setPen(QPen(textColor(), 1.0)); - - if (m_abstractItem->itemType() != TaskManager::LauncherItemType) { - if (showText) { - QRect rect = textRect(bounds).toRect(); - if (rect.height() > 20) { - rect.adjust(2, 2, -2, -2); // Create a text margin - } - - QFont f(KGlobalSettings::taskbarFont()); - QFontMetrics fm(f); - QString txt = fm.elidedText(text(), Qt::ElideRight, rect.width(), QPalette::WindowText); - QColor txtCol(textColor()); - - painter->setPen(txtCol); - painter->setFont(font()); - if (txtCol.value() < 128 && rect.height() > 4) { - int haloWidth = qMin(rect.width(), fm.width(txt)); - if (haloWidth > 4) { - Plasma::PaintUtils::drawHalo(painter, QRectF(rect.x() + 0.5, rect.y() + 0.5, haloWidth - 1, rect.height() - 1)); - } - } - painter->drawText(rect, txt, QTextOption(Qt::AlignVCenter)); - if (m_flags & TaskWantsAttention && 0 != m_attentionTimerId) { - painter->drawText(rect.adjusted(1, 0, 1, 0), txt, QTextOption(Qt::AlignVCenter)); - } - } - - TaskGroupItem *groupItem = qobject_cast(this); - if (groupItem && Tasks::Style_Plasma == m_applet->style()) { - int iSize = iconR.height() > 28 ? 16 : 8; - QPixmap pix(KIcon("list-add").pixmap(iSize, iSize)); - bool rtl = Qt::RightToLeft == layoutDirection(); - int glow = 1, - x = (rtl ? iconR.left() : (iconR.right() - (pix.width()))) + 2, - y = (iconR.bottom() - (pix.height() + 2)) + 2; - double glowX = (x - glow) + ((pix.width() + (2 * glow)) / 2.0), - glowY = (y - glow) + ((pix.height() + (2 * glow)) / 2.0); - - QRadialGradient gradient(QPointF(glowX, glowY), (pix.width() + (2 * glow)) / 2.0, QPointF(glowX, glowY)); - QColor c(Qt::white); - c.setAlphaF(0.5); - gradient.setColorAt(0, c); - gradient.setColorAt(0.6, c); - c.setAlphaF(0.0); - gradient.setColorAt(1.0, c); - painter->fillRect(QRect(x - glow, y - glow, pix.width() + (2 * glow), pix.height() + (2 * glow)), gradient); - painter->drawPixmap(x, y, pix); - } - } - - if (showText) { - return; - } - - if (Tasks::Style_IconTasksColored == m_applet->style()) { - drawShine(painter, option); - } - - if (busyWidget) { - return; - } - - if (!showText && JobManager::self()->isEnabled() && m_currentProgress >= 0) { - drawProgress(painter, iconR); - } - - if (Tasks::Style_Plasma != m_applet->style() && (m_abstractItem->itemType() != TaskManager::LauncherItemType)) { - drawIndicators(painter, rect()); - } -} - -qreal AbstractTaskItem::backgroundFadeAlpha() const -{ - return m_alpha; -} - -void AbstractTaskItem::setBackgroundFadeAlpha(qreal progress) -{ - m_alpha = progress; - update(); -} - -bool AbstractTaskItem::shouldIgnoreDragEvent(QGraphicsSceneDragDropEvent *event) -{ - bool locked = m_applet->groupManager().launchersLocked(); - - if (event->mimeData()->hasFormat(TaskManager::Task::mimetype()) || - event->mimeData()->hasFormat(TaskManager::Task::groupMimetype()) || - (!locked && event->mimeData()->hasFormat(AppLauncherItem::mimetype()))) { - return true; - } - - if (!locked && event->mimeData()->hasFormat("text/uri-list")) { - // we want to check if we have .desktop files; if so, then we treat it as a possible - // drop for a launcher - const KUrl::List uris = KUrl::List::fromMimeData(event->mimeData()); - if (!uris.isEmpty()) { - foreach (const QUrl & uri, uris) { - KUrl url(uri); - if (!url.isLocalFile()) { - return false; - } - - const QString path = url.toLocalFile(); - - if (QFileInfo(path).isDir()) { - return false; - } - - if (KDesktopFile::isDesktopFile(path)) { - KDesktopFile f(path); - if (f.tryExec()) { - return true; - } - } - } - } - } - - return false; -} - -QList AbstractTaskItem::getAppMenu() -{ - QList appMenu; - bool addedDocs = false; - KUrl lUrl = launcherUrl(); - - if (lUrl.isValid()) { - appMenu = RecentDocuments::self()->get(lUrl.fileName().remove(".desktop")); - addedDocs = true; - } - - return appMenu; -} - -void AbstractTaskItem::registerWithHelpers() -{ - JobManager::self()->registerTask(this); -} - -void AbstractTaskItem::unregisterFromHelpers() -{ - JobManager::self()->unregisterTask(this); -} - -void AbstractTaskItem::dragEnterEvent(QGraphicsSceneDragDropEvent *event) -{ - if (shouldIgnoreDragEvent(event)) { - event->ignore(); - return; - } - - event->accept(); - - if (!m_activateTimerId) { - m_activateTimerId = startTimer(250); - m_oldDragPos = event->pos(); - } -} - -void AbstractTaskItem::dragMoveEvent(QGraphicsSceneDragDropEvent *event) -{ - // restart the timer so that activate() is only called after the mouse - // stops moving - if (m_activateTimerId && event->pos() != m_oldDragPos) { - m_oldDragPos = event->pos(); - killTimer(m_activateTimerId); - m_activateTimerId = startTimer(250); - } -} - -void AbstractTaskItem::dragLeaveEvent(QGraphicsSceneDragDropEvent *event) -{ - Q_UNUSED(event); - - if (m_activateTimerId) { - killTimer(m_activateTimerId); - m_activateTimerId = 0; - } -} - -QRect AbstractTaskItem::iconGeometry() const -{ - if (!scene() || !boundingRect().isValid()) { - return QRect(); - } - - QGraphicsView *parentView = 0; - QGraphicsView *possibleParentView = 0; - // The following was taken from Plasma::Applet, it doesn't make sense to make the item an applet, and this was the easiest way around it. - foreach (QGraphicsView * view, scene()->views()) { - if (view->sceneRect().intersects(sceneBoundingRect()) || - view->sceneRect().contains(scenePos())) { - if (view->isActiveWindow()) { - parentView = view; - break; - } else { - possibleParentView = view; - } - } - } - - if (!parentView) { - parentView = possibleParentView; - - if (!parentView) { - return QRect(); - } - } - - QRect rect = parentView->mapFromScene(mapToScene(boundingRect())).boundingRect().adjusted(0, 0, 1, 1); - rect.moveTopLeft(parentView->mapToGlobal(rect.topLeft())); - return rect; -} - -void AbstractTaskItem::publishIconGeometry() const -{ -} - -void AbstractTaskItem::publishIconGeometry(const QRect &rect) const -{ - Q_UNUSED(rect) -} - -void AbstractTaskItem::setAnimationPos(const QPointF &pos) -{ - m_layoutAnimationLock = true; - setPos(pos); - m_layoutAnimationLock = false; -} - -QPointF AbstractTaskItem::animationPos() const -{ - return pos(); -} - -void AbstractTaskItem::setGeometry(const QRectF& geometry) -{ - if (geometry == QGraphicsWidget::geometry()) { - // Stop layout animiation! Without this a gap in the taskbar can appear when - // a whole task group is closed (e.g. start 2 KCalcs (with a launcher), and - // close via right-click menu). - // Looks like we have a first animation to move item below KCalc group - // down/right by 1 space he we immediately get a setGeometry moving back to - // the start. But because geometry==QGraphicsWidget::geometry, nothing happend. - m_layoutAnimation->stop(); - if (m_updateGeometryTimerId) { - killTimer(m_updateGeometryTimerId); - m_updateGeometryTimerId = 0; - } - return; - } - - QPointF oldPos = pos(); - - if (m_lastGeometryUpdate.elapsed() < 500) { - if (m_updateGeometryTimerId) { - killTimer(m_updateGeometryTimerId); - m_updateGeometryTimerId = 0; - } - - m_updateGeometryTimerId = startTimer(500 - m_lastGeometryUpdate.elapsed()); - } else { - publishIconGeometry(); - m_lastGeometryUpdate.restart(); - } - - //TODO:remove when we will have proper animated layouts - if (m_firstGeometryUpdate && !m_layoutAnimationLock) { - QRectF animStartGeom(oldPos, geometry.size()); - QGraphicsWidget::setGeometry(animStartGeom); - - if (m_layoutAnimation->state() == QAbstractAnimation::Running) { - m_layoutAnimation->stop(); - } - - m_layoutAnimation->setEndValue(geometry.topLeft()); - m_layoutAnimation->start(); - } else { - QGraphicsWidget::setGeometry(geometry); - } -} - -QRectF AbstractTaskItem::iconRect(const QRectF &b, bool showText) -{ - QRectF bounds(b); - const int right = bounds.right(); - - if (showText) { - //leave enough space for the text. useful in vertical panel - bounds.setWidth(qMax(bounds.width() / 3, qMin(minimumSize().height(), bounds.width()))); - - //restore right position if the layout is RTL - if (QApplication::layoutDirection() == Qt::RightToLeft) { - bounds.moveRight(right); - } - } - - m_lastIconSize = iconSize(bounds); - - if (showText) { - return QStyle::alignedRect(QApplication::layoutDirection(), - (showText ? Qt::AlignLeft : Qt::AlignCenter) | Qt::AlignVCenter, - m_lastIconSize, bounds.toRect()); - } else { - return QRectF(bounds.x() + ((bounds.width() - m_lastIconSize.width()) / 2.0), - bounds.y() + ((bounds.height() - m_lastIconSize.height()) / 2.0), - m_lastIconSize.width(), m_lastIconSize.height()); - } -} - -QSize AbstractTaskItem::iconSize(const QRectF &bounds) const -{ - QSize size; - if (m_applet->autoIconScaling()) { - size = icon().actualSize(bounds.size().toSize()); - - static const int constMargin = 2; - - if (size.width() == size.height()) { - if (size.width() > KIconLoader::SizeSmall - constMargin && size.width() < KIconLoader::SizeSmall + constMargin) { - size = QSize(KIconLoader::SizeSmall, KIconLoader::SizeSmall); - } else if (size.width() > KIconLoader::SizeSmallMedium - constMargin && size.width() < KIconLoader::SizeSmallMedium + constMargin) { - size = QSize(KIconLoader::SizeSmallMedium, KIconLoader::SizeSmallMedium); - } else if (size.width() > KIconLoader::SizeMedium - constMargin && size.width() < KIconLoader::SizeMedium + constMargin) { - size = QSize(KIconLoader::SizeMedium, KIconLoader::SizeMedium); - } else if (size.width() > KIconLoader::SizeLarge - constMargin && size.width() < KIconLoader::SizeLarge + constMargin) { - size = QSize(KIconLoader::SizeLarge, KIconLoader::SizeLarge); - } else if (size.width() > KIconLoader::SizeHuge - constMargin && size.width() < KIconLoader::SizeHuge + constMargin) { - size = QSize(KIconLoader::SizeHuge, KIconLoader::SizeHuge); - } - } - } else { - size = bounds.size().toSize(); // - int sz = (qMin(size.width(), size.height()) * m_applet->iconScale()) / 100; - size = QSize(sz, sz); - } - - return size; -} - -QRectF AbstractTaskItem::textRect(const QRectF &bounds) -{ - QSize size(bounds.size().toSize()); - QRectF effectiveBounds(bounds); - - size.rwidth() -= int(iconRect(bounds, true).width()) + qMax(0, IconTextSpacing - 2); - return QStyle::alignedRect(QApplication::layoutDirection(), Qt::AlignRight | Qt::AlignVCenter, size, effectiveBounds.toRect()); -} - -QColor AbstractTaskItem::textColor() const -{ - QColor color; - qreal bias; - Plasma::Theme *theme = Plasma::Theme::defaultTheme(); - - if ((m_oldBackgroundPrefix == "attention" || m_backgroundPrefix == "attention") && - m_applet->itemBackground()->hasElement("hint-attention-button-color")) { - bool animatingBg = m_backgroundFadeAnim && m_backgroundFadeAnim->state() == QAbstractAnimation::Running; - if (animatingBg) { - if (m_oldBackgroundPrefix == "attention") { - bias = 1 - m_alpha; - } else { - bias = m_alpha; - } - - color = KColorUtils::mix(theme->color(Plasma::Theme::TextColor), - theme->color(Plasma::Theme::ButtonTextColor), bias); - } else if (m_backgroundPrefix != "attention") { - color = theme->color(Plasma::Theme::TextColor); - } else { - color = theme->color(Plasma::Theme::ButtonTextColor); - } - } else { - color = theme->color(Plasma::Theme::TextColor); - } - - if (m_flags & TaskIsMinimized) { - color.setAlphaF(0.85); - } - - return color; -} - -bool AbstractTaskItem::isGroupMember(const TaskGroupItem *group) const -{ - if (!m_abstractItem || !group) { - kDebug() << "no task"; - return false; - } - - return m_abstractItem->isGroupMember(group->group()); - -} - -bool AbstractTaskItem::isGrouped() const -{ - if (!m_abstractItem) { - kDebug() << "no item"; - return false; - } - - return m_abstractItem->isGrouped(); -} - -TaskGroupItem * AbstractTaskItem::parentGroup() const -{ - TaskGroupItem *group = qobject_cast(parentWidget()); - - //lucky case: directly in a group - if (group) { - return group; - } - - //in a popup or a popup's popup? - QObject *candidate = parentWidget(); - - while (candidate) { - group = qobject_cast(candidate); - candidate = candidate->parent(); - if (group) { - return group; - } - } - - return 0; -} - -TaskManager::AbstractGroupableItem * AbstractTaskItem::abstractItem() -{ - return m_abstractItem; -} - -#include "moc_abstracttaskitem.cpp" diff --git a/kdeplasma-addons/applets/icontasks/abstracttaskitem.h b/kdeplasma-addons/applets/icontasks/abstracttaskitem.h deleted file mode 100644 index 8418626e..00000000 --- a/kdeplasma-addons/applets/icontasks/abstracttaskitem.h +++ /dev/null @@ -1,291 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2007 by Robert Knight * - * Copyright (C) 2008 by Alexis Ménard * - * Copyright (C) 2008 by Marco Martin * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * - ***************************************************************************/ - - -#ifndef ABSTRACTTASKITEM_H -#define ABSTRACTTASKITEM_H - -// KDE -#include -#include - -// Own -#include "taskmanager/taskgroup.h" - -// Katie -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -// Plasma -#include - -class Tasks; -class TaskGroupItem; -class LayoutWidget; - -/** - * A baseclass for a task - */ -class AbstractTaskItem : public QGraphicsWidget -{ - Q_OBJECT - Q_PROPERTY(QPointF animationPos READ animationPos WRITE setAnimationPos) - Q_PROPERTY(qreal backgroundFadeAlpha READ backgroundFadeAlpha WRITE setBackgroundFadeAlpha) - -public: - enum InfoSource { - IS_None, - IS_Job - }; - - enum Cache { - Cache_Bgnd = 0x01, - Cache_Scale = 0x02, - Cache_All = Cache_Bgnd | Cache_Scale - }; - - static void clearCaches(int cache = Cache_All); - - /** Constructs a new representation for an abstract task. */ - AbstractTaskItem(QGraphicsWidget *parent, Tasks *applet); - - /** Destruct the representation for an abstract task. */ - virtual ~AbstractTaskItem(); - - /** The text changed for this task item. */ - void textChanged(); - - /** Sets the icon for this task item. */ - void setIcon(const QIcon &icon); - - /** - * This enum describes the generic flags which are currently - * set by the task. - */ - enum TaskFlag { - /** - * This flag is set by the task to indicate that it wants - * the user's attention. - */ - TaskWantsAttention = 1, - /** - * Indicates that the task's window has the focus - */ - TaskHasFocus = 2, - /** - * Indicates that the task is iconified - */ - TaskIsMinimized = 4 - }; - Q_DECLARE_FLAGS(TaskFlags, TaskFlag) - - /** Sets the task flags for this item. */ - void setTaskFlags(TaskFlags flags); - - /** Returns the task's current flags. */ - TaskFlags taskFlags() const; - - /** Returns current text for this task. */ - virtual QString text() const; - - /** Returns the current icon for this task. */ - QIcon icon() const; - - virtual void close() = 0; - - /** Tells the window manager the minimized task's geometry. */ - virtual void publishIconGeometry() const; - virtual void publishIconGeometry(const QRect &rect) const; - QRect iconGeometry() const; // helper for above - - /** Overridden from LayoutItem */ - void setGeometry(const QRectF& geometry); - - /** Convenience Functions to get information about Grouping */ - /** Only true if the task is not only member of rootGroup */ - bool isGrouped() const; - bool isGroupMember(const TaskGroupItem *group) const; - TaskGroupItem *parentGroup() const; - - virtual bool isWindowItem() const = 0; - virtual bool isActive() const = 0; - - virtual void setAdditionalMimeData(QMimeData* mimeData) = 0; - - void setLayoutWidget(LayoutWidget* widget); - TaskManager::AbstractGroupableItem * abstractItem(); - - /** Returns the preferred size calculated on base of the fontsize and the iconsize*/ - QSize basicPreferredSize() const; - void setPreferredOffscreenSize(); - void setPreferredOnscreenSize(); - - //TODO: to be removed when we have proper animated layouts - QPointF animationPos() const; - void setAnimationPos(const QPointF &pos); - - virtual QGraphicsWidget *busyWidget() const { - return 0L; - } - bool isStartupWithTask() const; - bool isToolTipVisible() const; - - virtual void showContextMenu(const QPoint &, bool) { } - virtual QString appName() const = 0; - virtual KUrl launcherUrl() const = 0; - virtual QString windowClass() const = 0; - void updateProgress(int v, InfoSource source = IS_Job); - virtual int pid() const { - return 0; - } - virtual void toCurrentDesktop() { } - QString mediaButtonKey(); - -Q_SIGNALS: - void activated(AbstractTaskItem *); - void destroyed(AbstractTaskItem *); - -public Q_SLOTS: - virtual void activate() = 0; - void toolTipAboutToShow(); - void toolTipHidden(); - void mediaButtonPressed(int b); - void windowPreviewActivated(WId id, Qt::MouseButtons buttons, Qt::KeyboardModifiers, const QPoint &pos); - void controlWindow(WId id, Qt::MouseButtons buttons); - -protected: - void middleClick(); - void dragEnterEvent(QGraphicsSceneDragDropEvent *event); - void dragMoveEvent(QGraphicsSceneDragDropEvent *event); - void dragLeaveEvent(QGraphicsSceneDragDropEvent *event); - - // reimplemented - void focusInEvent(QFocusEvent *event); - void focusOutEvent(QFocusEvent *event); - void hoverEnterEvent(QGraphicsSceneHoverEvent *event); - void hoverLeaveEvent(QGraphicsSceneHoverEvent *event); - void mousePressEvent(QGraphicsSceneMouseEvent *event); - void mouseMoveEvent(QGraphicsSceneMouseEvent *event); - void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); - void timerEvent(QTimerEvent *event); - void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); - - void drawProgress(QPainter *painter, const QRectF &rect); - void drawBadge(QPainter *painter, const QRectF &rect, const QString &badge); - void drawIndicators(QPainter *painter, const QRectF &rect); - void drawColoredBackground(QPainter *painter, const QStyleOptionGraphicsItem *option); - void drawShine(QPainter *painter, const QStyleOptionGraphicsItem *option); - - /** Draws the background for the task item. */ - virtual void drawBackground(QPainter *painter, const QStyleOptionGraphicsItem *option); - /** Draws the icon and text which represent the task item. */ - virtual void drawTask(QPainter *painter, const QStyleOptionGraphicsItem *option, bool showText); - - virtual void updateTask(::TaskManager::TaskChanges changes) = 0; // pure virtual function - virtual void updateToolTip() = 0; // pure virtual function - void updateToolTipMediaState(); - void clearToolTip(); - void stopWindowHoverEffect(); - bool shouldIgnoreDragEvent(QGraphicsSceneDragDropEvent *event); - QList getAppMenu(); - void registerWithHelpers(); - void unregisterFromHelpers(); - -protected Q_SLOTS: - /** Event compression **/ - void queueUpdate(); - - qreal backgroundFadeAlpha() const; - void setBackgroundFadeAlpha(qreal progress); - - void syncActiveRect(); - void checkSettings(); - void clearAbstractItem(); - -protected: - // area of item occupied by task's icon - QRectF iconRect(const QRectF &bounds, bool showText = false); - QSize iconSize(const QRectF &bounds) const; - // area of item occupied by task's text - QRectF textRect(const QRectF &bounds); - // start an animation to chnge the task background - void fadeBackground(const QString &newBackground, int duration); - // text color, use this because it could be animated - QColor textColor() const; - void resizeBackground(const QSize &size); - - void resizeEvent(QGraphicsSceneResizeEvent *event); - - TaskManager::AbstractGroupableItem * m_abstractItem; - LayoutWidget *m_layoutWidget; - - Tasks *m_applet; - TaskFlags m_flags; - - // distance (in pixels) between a task's icon and its text - static const int IconTextSpacing = 4; - static const int TaskItemHorizontalMargin = 4; - static const int TaskItemVerticalMargin = 4; - - //TODO: remove when we have animated layouts - QPropertyAnimation *m_layoutAnimation; - QPropertyAnimation *m_backgroundFadeAnim; - - qreal m_alpha; - QString m_oldBackgroundPrefix; - QString m_backgroundPrefix; - -private: - QRectF m_activeRect; - - QElapsedTimer m_lastGeometryUpdate; - QElapsedTimer m_lastUpdate; - QSize m_lastIconSize; - int m_activateTimerId; - int m_updateGeometryTimerId; - int m_updateTimerId; - int m_hoverEffectTimerId; - int m_attentionTimerId; - int m_attentionTicks; - int m_mediaStateTimerId; - - WId m_lastViewId; - - bool m_layoutAnimationLock : 1; - bool m_firstGeometryUpdate : 1; - - mutable QIcon m_icon; - - InfoSource m_progressSource; - int m_lastProgress; - int m_currentProgress; - QPointF m_oldDragPos; -}; - -#endif diff --git a/kdeplasma-addons/applets/icontasks/appearanceconfig.ui b/kdeplasma-addons/applets/icontasks/appearanceconfig.ui deleted file mode 100644 index fb58fd14..00000000 --- a/kdeplasma-addons/applets/icontasks/appearanceconfig.ui +++ /dev/null @@ -1,260 +0,0 @@ - - - appearanceconfig - - - - 0 - 0 - 480 - 283 - - - - - 0 - - - - - Style: - - - - - - - - - - Rotate vertical frames: - - - rotate - - - - - - - <p>Controls whether the frames drawn around taskbar entries should be rotated 90-degrees counter-clockwise when the taskbar is in a vertical panel.</p> - - - - - - - - - - Tooltips: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - toolTips - - - - - - - - - - Window preview size: - - - previewSize - - - - - - - <p>Controls the width of window previews with tooltips.</p> - - - px - - - - - - - - - - Always use launcher icons: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - launcherIcons - - - - - - - <p>Enabling this item forces the icon for a running application to be the same as that used for the launcher. This resolves some oddities where the launcher icon is different from the application icon - as happens with LibreOffice.</p> - - - - - - - - - - Scale icons to: - - - iconScale - - - - - - - <p>Controls the scaling of the taskbar icon. When set to &quot;Automatic&quot;, the taskbar will attempt to determine the optimal size.</p> - - - % - - - 10 - - - - - - - Spacing: - - - spacing - - - - - - - <p>Set the amount of extra spacing between items.</p> - - - px - - - - - - 0 - - - - - - - Maximum rows: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - maxRows - - - - - - - <p>Controls the maximum number of rows (for a horizontal taskbar), or columns (for a vertical taskbar), that will be used.</p> - - - 1 - - - 2 - - - - - - - Sorting: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - sortingStrategy - - - - - - - - 200 - 0 - - - - - - - - Separator: - - - showSeparator - - - - - - - <p>When enabled, and there is only 1 row/column, then a separator will be drawn between the launchers/tasks-with-launchers and non-launcher tasks.</p> - - - - - - - Highlight windows: - - - - - - - - - - - - - - - KIntSpinBox - QSpinBox -
knuminput.h
-
-
- - style - rotate - toolTips - previewSize - launcherIcons - iconScale - spacing - maxRows - sortingStrategy - showSeparator - - -
diff --git a/kdeplasma-addons/applets/icontasks/applauncheritem.cpp b/kdeplasma-addons/applets/icontasks/applauncheritem.cpp deleted file mode 100644 index 144572f7..00000000 --- a/kdeplasma-addons/applets/icontasks/applauncheritem.cpp +++ /dev/null @@ -1,149 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2010 by Anton Kreuzkamp * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * - ***************************************************************************/ - -// Own -#include "applauncheritem.h" -#include "taskgroupitem.h" -#include "jobmanager.h" -#include "mediabuttons.h" - -#include "taskmanager/taskactions.h" -#include "taskmanager/groupmanager.h" - -// Qt -#include -#include - -// KDE -#include - -#include "tooltips/tooltipmanager.h" -#include -#include -#include - -QString AppLauncherItem::mimetype() -{ - return "taskmanager:/launcher"; -} - -AppLauncherItem::AppLauncherItem(QGraphicsWidget* parent, Tasks* applet, TaskManager::LauncherItem* launcher) - : AbstractTaskItem(parent, applet) -{ - m_launcher = launcher; - m_abstractItem = launcher; - registerWithHelpers(); -} - -AppLauncherItem::~AppLauncherItem() -{ - close(false); -} - -void AppLauncherItem::close() -{ - close(true); -} - -void AppLauncherItem::close(bool hide) -{ - unregisterFromHelpers(); - if (hide) { - setVisible(false); - } -} - -QString AppLauncherItem::windowClass() const -{ - return m_applet->groupManager().launcherWmClass(launcherUrl()); -} - -void AppLauncherItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) -{ - if ((event->button() == Qt::LeftButton || (event->button() == Qt::MiddleButton && Tasks::MC_NewInstance == m_applet->middleClick())) && - boundingRect().contains(event->pos())) { - m_launcher->launch(); - } -} - -void AppLauncherItem::contextMenuEvent(QGraphicsSceneContextMenuEvent *e) -{ - if (!m_launcher) { - QGraphicsWidget::contextMenuEvent(e); - return; - } - - QList actionList; - - QAction *configAction = m_applet->action("configure"); - if (configAction && configAction->isEnabled()) { - actionList.append(configAction); - } - - TaskManager::BasicMenu *menu = new TaskManager::BasicMenu(0, m_launcher, &m_applet->groupManager(), actionList, getAppMenu()); - menu->adjustSize(); - - if (m_applet->formFactor() != Plasma::Vertical) { - menu->setMinimumWidth(size().width()); - } - - Q_ASSERT(m_applet->containment()); - Q_ASSERT(m_applet->containment()->corona()); - stopWindowHoverEffect(); - menu->exec(m_applet->containment()->corona()->popupPosition(this, menu->size())); - menu->deleteLater(); -} - - -void AppLauncherItem::updateToolTip() -{ - IconTasks::ToolTipContent data(m_launcher->name(), m_launcher->genericName(), m_launcher->icon()); - data.setInstantPopup(m_applet->instantToolTip()); - QString key = mediaButtonKey(); - if (!key.isEmpty()) { - data.setPlayState(MediaButtons::self()->playbackStatus(key)); - data.setClickable(true); - } - - IconTasks::ToolTipManager::self()->setContent(this, data); -} - -void AppLauncherItem::keyPressEvent(QKeyEvent *event) -{ - if (event->key() == Qt::Key_Return || event->key() == Qt::Key_Enter) { - m_launcher->launch(); - } else { - QGraphicsWidget::keyPressEvent(event); - } -} - -void AppLauncherItem::setAdditionalMimeData(QMimeData* mimeData) -{ - if (m_launcher) { - m_launcher->addMimeData(mimeData); - - // Add our own mimetype, so that AbstractTaskItem knows to ignore drag envets of this type, - // then taskgroup will receive the event, and launchers can be re-ordered!!! - QByteArray data; - mimeData->setData(mimetype(), data); - } -} - -#include "moc_applauncheritem.cpp" - diff --git a/kdeplasma-addons/applets/icontasks/applauncheritem.h b/kdeplasma-addons/applets/icontasks/applauncheritem.h deleted file mode 100644 index 35f521f6..00000000 --- a/kdeplasma-addons/applets/icontasks/applauncheritem.h +++ /dev/null @@ -1,83 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2010 by Anton Kreuzkamp * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * - ***************************************************************************/ - - -#ifndef APPLAUNCHERITEM_H -#define APPLAUNCHERITEM_H - -#include "abstracttaskitem.h" -// Own -#include "taskmanager/taskmanager.h" -#include "taskmanager/launcheritem.h" - -/** - * A launcheritem to quickly launch applications. - */ -class AppLauncherItem : public AbstractTaskItem -{ - Q_OBJECT - -public: - /** Constructs a new representation for a launcher. */ - AppLauncherItem(QGraphicsWidget *parent, Tasks *applet, TaskManager::LauncherItem *launcher); - ~AppLauncherItem(); - - TaskManager::LauncherItem* launcher() { - return m_launcher; - } - - virtual bool isWindowItem() const { - return false; - } - virtual bool isActive() const { - return false; - } - virtual void setAdditionalMimeData(QMimeData* mimeData); - virtual void close(); - virtual void updateTask(TaskManager::TaskChanges) {} - - static QString mimetype(); - - QString appName() const { - return m_launcher->name(); - } - KUrl launcherUrl() const { - return m_launcher->launcherUrl(); - } - QString windowClass() const; - -private: - void close(bool hide); - -public slots: - virtual void activate() {} - -protected: - void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); - void keyPressEvent(QKeyEvent *event); - void contextMenuEvent(QGraphicsSceneContextMenuEvent *event); - void updateToolTip(); - - -private: - TaskManager::LauncherItem *m_launcher; - -}; - -#endif diff --git a/kdeplasma-addons/applets/icontasks/badge.svgz b/kdeplasma-addons/applets/icontasks/badge.svgz deleted file mode 100644 index 8e9edce4a44509053270f485bcd41d69d850b252..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4150 zcmV-65XtW!iwFP!000000PS5{Z{xTXexF~VdR}HwQ|48avhnQ0E?O+mqCj^SeJm7P zaon*bLsllq{Q4eJl0{jvCEK#>@r;867O&#RbK~J5bN}<}a$$W5;`KZV#{**Hffa<4 zXgUvP};t^TKo?;(6W((-EZzN}%;y znE0=#TovB2t}4YCk07ro*{;;x>jI$I`7%1!>>c1=!SAL*o?x$|=Xer4Le0PqgJksU zAHQxg5w@qv)MzG0ztnGONEX~R*nOWSm zi4}X&!Me!He40Fs2ien8FrPgov%=_3ZLU@&j6G8j$g{xi%~I9e_Iw^|2XTF)4CARwnDfb&d)H_bU z%!3zI&S>Uk9!{edl;g-{+ETSdhC9JbZkJg3vta$?L#gqA)@4RO67%Fu&88!`hl%H8 z#b(d*X^=#VAojyapqjVy7nsG+V{K0K@V{V^)aN}!@id4x9g?k#NwkRK@!-9qKUtP~ z#XQ5+pL`HgML_FddrV)WXsO!v($9AGVnu{HsFb;=tW^U9whN|U?wW;*QMl5b2<+_JVdXh{EP@Zxq8h~ za>AiS(x#Dh=&!166fCHx5rvU{i${M^1v(q@(tn*V=U)RDLrT{`*~P2E*wShiXd3@v z5tN4tY%yQYA$coRA)@LEv6%nL2j zW!+dK&48mS2kP`?koZ$S@e4xBQ)E6uP$qZ({`GI4vJUSjle_;!@#nmM%TfjW2M|@` z!Qj&-`F=XN1A)HulTY&{P`1(>e+2=4KPoaxh1HmgM$=~FAk_@D%5*we&Q+z+@5y|z z_)T?^4Ocfg%3k!xi(lr&??(pZ+>dg)(ofUiab1v{dJ;LgDFXK6zsLS`4uZtwl5!6B z1l|n(ehnI}7|J?%Q+%cpk(Q`;@3H>;q?0nS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!` zYiPEDRaK!GcZ`suikht5#&v?xVZog>mMyEbY+09LJ&y8j#L&0bGanqL@vLY#ji1qtqhM2x!t%k;4%s$u3=su?QNRDNW}@-wUG)bxnk!s3|@BQIfj^z4dh?6Krljr!0pFGDw5m(UURiNzXy=G;( zrR3oZnNU($=_`;K+*N;>DCe6S&{IGDynFvy=eF5?&J0HmQfgyI)wQ&!t0=pf0<(jYxx5)=B4Uk{zSvjl+|sKzK5jtRqZ*yq34AIV^>X^)C!IGA`<)C0PX?M{6) zSdWnpoe9wN3aVR*l0aR=Nwi*q928Gs5bKYKiW_yE&{zB0g zM_b5elr{Pu&RdMtK&?WyFCcR~Vpx^mQ(TAgaBNAHhPaO2%$LJsK#b#_*W<=$5e0Iv zL%0_i4bw#ccGiC(!7d2um8M})cF%}x9hm9C3p3}lc5bni@Xc1y^DKouwkO}ho z-aAnNDYaXv*B_FC4h@w57WPbf4qh?VQ*HN53VB#Uf(M?DonzQbz0cD;Ob}!R$>a$n zSUe5l{GO9sjAp)=oK`mi7njpti@5@6jff~`$8RcMjp%-~{sJTVKUOb}sZOQ<0LB*} ArvLx| diff --git a/kdeplasma-addons/applets/icontasks/behaviourconfig.ui b/kdeplasma-addons/applets/icontasks/behaviourconfig.ui deleted file mode 100644 index c4e4d11b..00000000 --- a/kdeplasma-addons/applets/icontasks/behaviourconfig.ui +++ /dev/null @@ -1,207 +0,0 @@ - - - behaviourconfig - - - - 0 - 0 - 341 - 274 - - - - - 0 - - - - - General - - - - - - Show job progress on task icon: - - - showProgress - - - - - - - <p>When enabled, a progressbar will be drawn over the applications icons to represent its overall job progress.</p> - - - - - - - - - - Show control buttons on media player tooltips: - - - mediaButtons - - - - - - - <p>When enabled - previous, play/pause, and next buttons will be shown in the tooltips for media players.</p> - - - - - - - - - - Show recent documents: - - - recentDocuments - - - - - - - <p>Toggles support for listing an application's recent documents in its popup menu.</p> - - - - - - - - - - Group click action: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - groupClick - - - - - - - <p>Configures what should occur when a task group is clicked.</p> - - - - - - - Middle-click action: - - - middleClick - - - - - - - - - - - - - Filters - - - - QFormLayout::ExpandingFieldsGrow - - - - - Only show tasks from the current screen: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - showOnlyCurrentScreen - - - - - - - - - - - - - - Only show tasks from the current desktop: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - showOnlyCurrentDesktop - - - - - - - - - - - - - - Only show tasks from the current activity: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - showOnlyCurrentActivity - - - - - - - - - - - - - - - - - Qt::Vertical - - - - 20 - 2 - - - - - - - - diff --git a/kdeplasma-addons/applets/icontasks/dbusstatus.cpp b/kdeplasma-addons/applets/icontasks/dbusstatus.cpp deleted file mode 100644 index 3dd29bd8..00000000 --- a/kdeplasma-addons/applets/icontasks/dbusstatus.cpp +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Icon Task Manager - * - * Copyright 2011 Craig Drummond - * - * ---- - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#include "dbusstatus.h" - -QDBusArgument& operator<< (QDBusArgument& arg, const DBusStatus& status) -{ - arg.beginStructure(); - arg << status.play; - arg << status.random; - arg << status.repeat; - arg << status.repeat_playlist; - arg.endStructure(); - return arg; -} - -const QDBusArgument& operator>> (const QDBusArgument& arg, DBusStatus& status) -{ - arg.beginStructure(); - arg >> status.play; - arg >> status.random; - arg >> status.repeat; - arg >> status.repeat_playlist; - arg.endStructure(); - return arg; -} diff --git a/kdeplasma-addons/applets/icontasks/dbusstatus.h b/kdeplasma-addons/applets/icontasks/dbusstatus.h deleted file mode 100644 index 4195851b..00000000 --- a/kdeplasma-addons/applets/icontasks/dbusstatus.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Icon Task Manager - * - * Copyright 2011 Craig Drummond - * - * ---- - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef __DBUS_STATUS_H__ -#define __DBUS_STATUS_H__ - -#include -#include - -struct DBusStatus { // From Amarok. - int play; // Playing = 0, Paused = 1, Stopped = 2 - int random; // Linearly = 0, Randomly = 1 - int repeat; // Go_To_Next = 0, Repeat_Current = 1 - int repeat_playlist; // Stop_When_Finished = 0, Never_Give_Up_Playing = 1, Never_Let_You_Down = 42 - - enum MprisPlayState { - Mpris_Playing = 0, - Mpris_Paused = 1, - Mpris_Stopped = 2, - }; -}; - -Q_DECLARE_METATYPE(DBusStatus) -QDBusArgument& operator <<(QDBusArgument& arg, const DBusStatus& status); -const QDBusArgument& operator >>(const QDBusArgument& arg, DBusStatus& status); - -#endif diff --git a/kdeplasma-addons/applets/icontasks/dropindicators.svgz b/kdeplasma-addons/applets/icontasks/dropindicators.svgz deleted file mode 100644 index b6ecac458dd837ae85ce44440ff94ad73a1718cf..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2435 zcmV-}34Hb+iwFP!000000PR~_liD~Ie(zu5bzai7*yv`-B2DIDQnNKrTeXwaK5n^f zLAwG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=gmMfG+{{I7IjCn2x&_k+^z!q^-+%b>AE11;FT@!E0Np)GZ~y=R diff --git a/kdeplasma-addons/applets/icontasks/jobmanager.cpp b/kdeplasma-addons/applets/icontasks/jobmanager.cpp deleted file mode 100644 index 3df507ba..00000000 --- a/kdeplasma-addons/applets/icontasks/jobmanager.cpp +++ /dev/null @@ -1,197 +0,0 @@ -/* - * Icon Task Manager - * - * Copyright 2011 Craig Drummond - * - * ---- - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#include "jobmanager.h" -#include "abstracttaskitem.h" -#include "tasks.h" -#include -#include - -K_GLOBAL_STATIC(JobManager, jobMgr) - -static const char *constEngineName = "applicationjobs"; - -JobManager * JobManager::self() -{ - return jobMgr; -} - -JobManager::JobManager() - : m_engine(0) -{ -} - -JobManager::~JobManager() -{ -} - -void JobManager::setEnabled(bool enabled) -{ - if ((m_engine && !enabled) || (enabled && !m_engine)) { - if (enabled) { - m_engine = Plasma::DataEngineManager::self()->loadEngine(constEngineName); - - if (!m_engine->isValid()) { - Plasma::DataEngineManager::self()->unloadEngine(constEngineName); - m_engine = 0; - return; - } - - connect(m_engine, SIGNAL(sourceAdded(const QString)), this, SLOT(addJob(const QString))); - connect(m_engine, SIGNAL(sourceRemoved(const QString)), this, SLOT(removeJob(const QString))); - m_engine->connectAllSources(this); - } else if (m_engine) { - disconnect(m_engine, SIGNAL(sourceAdded(const QString)), this, SLOT(addJob(const QString))); - disconnect(m_engine, SIGNAL(sourceRemoved(const QString)), this, SLOT(removeJob(const QString))); - - QMap >::Iterator it(m_appJobs.begin()), - end(m_appJobs.end()); - - for (; it != end; ++it) { - foreach (const QString & job, *it) { - m_engine->disconnectSource(job, this); - } - } - - Plasma::DataEngineManager::self()->unloadEngine(constEngineName); - m_appJobs.clear(); - m_jobs.clear(); - m_engine = 0; - } - } -} - -void JobManager::registerTask(AbstractTaskItem *task) -{ - QString appName(task->appName()); - - if (!appName.isEmpty()) { - m_tasks[appName].append(task); - - if (m_appJobs.contains(appName)) { - task->updateProgress(appProgress(appName)); - } - } -} - -void JobManager::unregisterTask(AbstractTaskItem *task) -{ - // Remove each reference to task... - QMap >::Iterator it(m_tasks.begin()), - end(m_tasks.end()); - QStringList emptied; - - for (; it != end; ++it) { - if ((*it).contains(task)) { - (*it).removeAll(task); - if (0 == (*it).count()) { - emptied.append(it.key()); - } - } - } - - foreach (const QString & app, emptied) { - m_tasks.remove(app); - } -} - -void JobManager::addJob(const QString &job) -{ - m_engine->connectSource(job, this); -} - -void JobManager::dataUpdated(const QString &job, const Plasma::DataEngine::Data &data) -{ - QString appName = data["appName"].toString(); - - if (appName.isEmpty()) { - return; - } - - int percentage = data.contains("percentage") ? data["percentage"].toInt() : -1; - - if (m_appJobs.contains(appName)) { - m_appJobs[appName].insert(job); - } - - m_jobs[job] = percentage; - update(appName); -} - -void JobManager::removeJob(const QString &job) -{ - m_jobs.remove(job); - QMap >::Iterator it(m_appJobs.begin()), - end(m_appJobs.end()); - QStringList updated, - emptied; - - for (; it != end; ++it) { - if ((*it).contains(job)) { - (*it).remove(job); - if (0 == (*it).count()) { - emptied.append(it.key()); - } else { - updated.append(it.key()); - } - } - } - - foreach (const QString & app, emptied) { - m_appJobs.remove(app); - update(app); - } - - foreach (const QString & app, updated) { - update(app); - } -} - -int JobManager::appProgress(const QString &app) -{ - int numJobs = 0, - total = 0; - - foreach (const QString & job, m_appJobs[app]) { - int p = m_jobs[job]; - if (-1 != p) { - numJobs++; - total += p; - } - } - - return 0 == numJobs ? -1 : total / numJobs; -} - -void JobManager::update(const QString &app) -{ - if (m_tasks.contains(app)) { - int p = appProgress(app); - - foreach (AbstractTaskItem * item, m_tasks[app]) { - item->updateProgress(p); - } - } -} - -#include "moc_jobmanager.cpp" diff --git a/kdeplasma-addons/applets/icontasks/jobmanager.h b/kdeplasma-addons/applets/icontasks/jobmanager.h deleted file mode 100644 index 700f6d9b..00000000 --- a/kdeplasma-addons/applets/icontasks/jobmanager.h +++ /dev/null @@ -1,72 +0,0 @@ -#ifndef _JOB_MANAGER_H__ -#define _JOB_MANAGER_H__ - -/* - * Icon Task Manager - * - * Copyright 2011 Craig Drummond - * - * ---- - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#include -#include -#include -#include -#include - -class AbstractTaskItem; - -class JobManager : public QObject -{ - Q_OBJECT - -public: - - static JobManager * self(); - - JobManager(); - ~JobManager(); - - void setEnabled(bool enabled); - bool isEnabled() const { - return 0 != m_engine; - } - void registerTask(AbstractTaskItem *task); - void unregisterTask(AbstractTaskItem *task); - -private Q_SLOTS: - - void addJob(const QString &job); - void dataUpdated(const QString &job, const Plasma::DataEngine::Data &data); - void removeJob(const QString &job); - -private: - - int appProgress(const QString &app); - void update(const QString &app); - -private: - - Plasma::DataEngine *m_engine; - QMap > m_appJobs; // Map from appName to list of job names - QMap m_jobs; // Map from job name to job percentage - QMap > m_tasks; -}; - -#endif diff --git a/kdeplasma-addons/applets/icontasks/launcherseparator.svgz b/kdeplasma-addons/applets/icontasks/launcherseparator.svgz deleted file mode 100644 index 0babb5207c4b6c21a542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N-_yD15%V%*6C}IdZy7z%`U>Z12DuxYe@kERX!9PT#ux!F$j=yl49&pK$bc&ZX`zO50V0l}dDtZ8 zhk8SVP65`r3wK@i7ZTW0p4x4Es6t53q9<(PRv<8OId~Fc+v(OzFLhFq|Xkt9N zJ%om9zseBq2X6rW72x65242tpXJRtI5mJChUK@CldC2PtT!e=L&~|SN;5jKCz%p2p zhscm=9&%nL(d#3ci=4rTX8#~W!*HKA49&2K2O}9ajo~RK4+2C^Qj8GvW)6dMZtB77 zXWZ7Kfp6>^`@xNG?YqgA<9QVAS)!hk+aW}=Ml4u-xj$fP>#jijgvOibI)ZB zk#`Jv<9b%a9xXAoBDSkIcFTyhUp8X@bq3N?DH-H=7_!`SR>FI<_Irbb*BCV6B|j$J zTr@yYWXQVGv*|{#GZ5Jb_6DOGAr}(ur8AM!9Jx3jA&rMOXN1ZNaK30p2 z(0hAjBw`zb!FP~Q|LE}b-?YjDGt&%vd^Zu;Ncvj^e~S21~W&mQ0~eJkar z7hs+{M0O16PMP@_H!cdl1cXC8xNbuD>K%1sb&nGsHO`I2k?*OCf9^o4&{d0w`Zm6iz)XXF2W z`drmQf?)h7YX@PhH^i6z31QS~K>x|YR(v9<5wfHN2<@$-%_xTb`n zz#^Mg;~F@CoMyGXdO^O?R=oRe8I87_^Dqg^Fq#hsib_{i)6&e3Gr)QbtMLBaVb=N~ zmp006`6XY)beyo{iE{Qa6P$g|FI$UsDF6o(v__|9NY0#LCqP~gmR*=1ER0;a(QyQ% z*u3V#!a33L#HGfKoWjj^FUGBJDX+i*iIsEhAV3#~fj#=s!@xGK5(X`Z{#78jrvt&h zb|ADKNS+r8Bk$&+Fwy5-C&(k^A_|^!ew;;D?<#wuc^MVVJtnyLBoo|I-OrD5>|Go} z?zubSQMb;cpL_1+(iH&MzRqen-WhJ4;2>nzSK%PK@MJz - * - * ---- - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#include "mediabuttons.h" -#include "dbusstatus.h" -#include "playerv1interface.h" -#include "playerv2interface.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -K_GLOBAL_STATIC(MediaButtons, mediaBtns) - -static const QString constV2Prefix = QLatin1String("org.mpris.MediaPlayer2."); -static const QString constV1Prefix = QLatin1String("org.mpris."); - -static QString playbackStatus(OrgFreedesktopMediaPlayerInterface *iface) -{ - DBusStatus status = iface->GetStatus(); - - switch (status.play) { - case DBusStatus::Mpris_Playing: return "Playing"; - case DBusStatus::Mpris_Paused: return "Paused"; - case DBusStatus::Mpris_Stopped: return "Stopped"; - } - return QString(); -} - -MediaButtons::Interface::~Interface() -{ - if (v1) { - delete v1; - } - if (v2) { - delete v2; - } -} - -void MediaButtons::Interface::next() -{ - if (v2) { - v2->Next(); - } else if (v1) { - v1->Next(); - } -} - -void MediaButtons::Interface::previous() -{ - if (v2) { - v2->Previous(); - } else if (v1) { - v1->Prev(); - } -} - -void MediaButtons::Interface::playPause() -{ - if (v2) { - v2->PlayPause(); - } else if (v1) { - if ("Playing" ==::playbackStatus(v1)) { - v1->Pause(); - } else { - v1->Play(); - } - } -} - -QString MediaButtons::Interface::playbackStatus() -{ - if (v2) { - return v2->playbackStatus(); - } else if (v1) { - return ::playbackStatus(v1); - } - - return QString(); -} - -QString MediaButtons::Interface::service() -{ - if (v2) { - return v2->service(); - } else if (v1) { - return v1->service(); - } - - return QString(); -} - -MediaButtons * MediaButtons::self() -{ - return mediaBtns; -} - -MediaButtons::MediaButtons() - : m_watcher(0) - , m_enabled(false) -{ - qDBusRegisterMetaType(); -} - -void MediaButtons::setEnabled(bool en) -{ - if (en != m_enabled) { - m_enabled = en; - if (m_enabled) { - m_watcher = new QDBusServiceWatcher(this); - m_watcher->setConnection(QDBusConnection::sessionBus()); - m_watcher->setWatchMode(QDBusServiceWatcher::WatchForOwnerChange); - connect(m_watcher, SIGNAL(serviceOwnerChanged(QString, QString, QString)), this, SLOT(serviceOwnerChanged(QString, QString, QString))); - readConfig(); - } else if (m_watcher) { - disconnect(m_watcher, SIGNAL(serviceOwnerChanged(QString, QString, QString)), this, SLOT(serviceOwnerChanged(QString, QString, QString))); - - foreach (Interface * iface, m_interfaces.values()) { - delete iface; - } - m_interfaces.clear(); - - delete m_watcher; - } - } -} - -void MediaButtons::serviceOwnerChanged(const QString &name, const QString &oldOwner, const QString &newOwner) -{ - bool isV2 = name.startsWith(constV2Prefix); - QString n = QString(name).remove(isV2 ? constV2Prefix : constV1Prefix).toLower(); - QMap::iterator it(m_interfaces.find(n)), - end(m_interfaces.end()); - - if (newOwner.isEmpty()) { - if (it != end) { - if ((*it)->isV2() == isV2) { - delete(*it); - m_interfaces.erase(it); - } - } - } else if (oldOwner.isEmpty()) { - if (isV2) { - OrgMprisMediaPlayer2PlayerInterface *iface = new OrgMprisMediaPlayer2PlayerInterface(name, "/org/mpris/MediaPlayer2", QDBusConnection::sessionBus(), this); - if (iface->canControl()) { - if (it != end) { - delete(*it); - m_interfaces.erase(it); - } - m_interfaces.insert(n, new Interface(iface)); - } else { - delete iface; - } - } else if (it == end || !(*it)->isV2()) { - OrgFreedesktopMediaPlayerInterface *iface = new OrgFreedesktopMediaPlayerInterface(name, "/Player", QDBusConnection::sessionBus(), this); - if (it != end) { - delete(*it); - m_interfaces.erase(it); - } - m_interfaces.insert(n, new Interface(iface)); - } - } -} - -void MediaButtons::next(const QString &name, int pid) -{ - if (m_enabled) { - Interface *iface = getInterface(name, pid); - if (iface) { - iface->next(); - } - } -} - -void MediaButtons::previous(const QString &name, int pid) -{ - if (m_enabled) { - Interface *iface = getInterface(name, pid); - if (iface) { - iface->previous(); - } - } -} - -void MediaButtons::playPause(const QString &name, int pid) -{ - if (m_enabled) { - Interface *iface = getInterface(name, pid); - if (iface) { - iface->playPause(); - } - } -} - -QString MediaButtons::playbackStatus(const QString &name, int pid) -{ - if (m_enabled) { - Interface *iface = getInterface(name, pid); - if (iface) { - return iface->playbackStatus(); - } - } - - return QString(); -} - -void MediaButtons::readConfig() -{ - m_aliases.clear(); - m_ignore.clear(); - - QStringList files(KGlobal::dirs()->findAllResources("data", "kdeplasma-addons/mediabuttonsrc")); - - foreach (const QString &file, files) { - KConfig cfg(file); - KConfigGroup ag(&cfg, "Aliases"); - KConfigGroup gen(&cfg, "General"); - - m_ignore += gen.readEntry("Ignore", QStringList()).toSet(); - foreach (const QString &key, ag.keyList()) { - foreach (const QString &alias, ag.readEntry(key, QStringList())) { - m_aliases[alias.toLower()] = key.toLower(); - } - } - } -} - -bool MediaButtons::isMediaApp(const QString &desktopEntry) -{ - if (!m_enabled) { - return false; - } - - QString name = desktopEntry; - if (m_aliases.contains(name)) { - name = m_aliases[name]; - } - - if (m_ignore.contains(name)) { - return false; - } - - MediaButtons::Interface *i = getV2Interface(name); - // qDebug() << Q_FUNC_INFO << desktopEntry << i; - if (i) { - return true; - } - - i = getV1Interface(name); - // qDebug() << Q_FUNC_INFO << desktopEntry << i; - if (i) { - return true; - } - - return false; -} - -MediaButtons::Interface * MediaButtons::getInterface(const QString &name, int pid) -{ - QStringList names; - - if (m_aliases.contains(name)) { - QString alias = m_aliases[name]; - names << alias << alias + "." + QString::number(pid) << alias + "-" + QString::number(pid); - } - names << name << name + "." + QString::number(pid) << name + "-" + QString::number(pid); - - foreach (const QString &n, names) { - if (m_interfaces.contains(n)) { - return m_interfaces[n]; - } - } - - foreach (const QString &n, names) { - MediaButtons::Interface *i = getV2Interface(n); - if (i) { - return i; - } - } - - foreach (const QString &n, names) { - MediaButtons::Interface *i = getV1Interface(n); - if (i) { - return i; - } - } - - return nullptr; -} - -MediaButtons::Interface * MediaButtons::getV2Interface(const QString &name) -{ - QDBusReply reply = QDBusConnection::sessionBus().interface()->isServiceRegistered(constV2Prefix + name); - - if (reply.isValid() && reply.value()) { - serviceOwnerChanged(constV2Prefix + name, QString(), QLatin1String("X")); - if (m_interfaces.contains(name)) { - m_watcher->addWatchedService(constV2Prefix + name); - return m_interfaces[name]; - } - } - - QDBusReply registeredReply = QDBusConnection::sessionBus().interface()->registeredServiceNames(); - if (!registeredReply.isValid()) { - return nullptr; - } - foreach (const QString &value, registeredReply.value()) { - if (value.startsWith(constV2Prefix + name + QLatin1Char('.'))) { - serviceOwnerChanged(value, QString(), QLatin1String("X")); - // qDebug() << Q_FUNC_INFO << value << m_interfaces; - QString unsuffixedName = value.mid(constV2Prefix.size(), value.size() - constV2Prefix.size()); - if (m_interfaces.contains(unsuffixedName)) { - m_watcher->addWatchedService(value); - return m_interfaces[unsuffixedName]; - } - } - } - - return nullptr; -} - -MediaButtons::Interface * MediaButtons::getV1Interface(const QString &name) -{ - QDBusReply reply = QDBusConnection::sessionBus().interface()->isServiceRegistered(constV1Prefix + name); - - if (reply.isValid() && reply.value()) { - serviceOwnerChanged(constV1Prefix + name, QString(), QLatin1String("X")); - if (m_interfaces.contains(name)) { - m_watcher->addWatchedService(constV1Prefix + name); - return m_interfaces[name]; - } - } - - return 0; -} - -#include "moc_mediabuttons.cpp" diff --git a/kdeplasma-addons/applets/icontasks/mediabuttons.h b/kdeplasma-addons/applets/icontasks/mediabuttons.h deleted file mode 100644 index cecd8a6d..00000000 --- a/kdeplasma-addons/applets/icontasks/mediabuttons.h +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Icon Task Manager - * - * Copyright 2011 Craig Drummond - * - * ---- - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef __MEDIABUTTONS_H__ -#define __MEDIABUTTONS_H__ - -#include -#include -#include - -#include -class OrgMprisMediaPlayer2PlayerInterface; -class OrgFreedesktopMediaPlayerInterface; - -class MediaButtons : public QObject -{ - Q_OBJECT - -public: - class Interface - { - public: - Interface(OrgFreedesktopMediaPlayerInterface *o) : v1(o), v2(0) { } - Interface(OrgMprisMediaPlayer2PlayerInterface *t) : v1(0), v2(t) { } - ~Interface(); - - bool isV1() const { - return 0 != v1; - } - bool isV2() const { - return 0 != v2; - } - - void next(); - void previous(); - void playPause(); - QString playbackStatus(); - QString service(); - private: - OrgFreedesktopMediaPlayerInterface *v1; - OrgMprisMediaPlayer2PlayerInterface *v2; - }; - - static MediaButtons * self(); - - MediaButtons(); - - void setEnabled(bool en); - bool isEnabled() const { - return m_enabled; - } - bool isMediaApp(const QString &desktopEntry); - void next(const QString &name, int pid = 0); - void previous(const QString &name, int pid = 0); - void playPause(const QString &name, int pid = 0); - QString playbackStatus(const QString &name, int pid = 0); - -private Q_SLOTS: - void serviceOwnerChanged(const QString &name, const QString &oldOwner, const QString &newOwner); - -private: - void readConfig(); - Interface * getInterface(const QString &name, int pid); - Interface * getV2Interface(const QString &name); - Interface * getV1Interface(const QString &name); - -private: - QDBusServiceWatcher *m_watcher; - QMap m_interfaces; - QMap m_aliases; - QSet m_ignore; - bool m_enabled; -}; - -#endif diff --git a/kdeplasma-addons/applets/icontasks/mediabuttonsrc b/kdeplasma-addons/applets/icontasks/mediabuttonsrc deleted file mode 100644 index 37e7d916..00000000 --- a/kdeplasma-addons/applets/icontasks/mediabuttonsrc +++ /dev/null @@ -1,6 +0,0 @@ -[General] -Ignore=kmix,k3b,ghb,xbmc,flashplayer,audex,kmediafactory,kdenlive,avidemux-qt4,mkvinfo,mkvmergegui,guvcview,pavucontrol,avidemux-qt,devede,kid3 -[Aliases] -amarok=amarok_containers -mpd=qmpdclient,sonata,quimup,qtmpc -dragonplayer=Dragon diff --git a/kdeplasma-addons/applets/icontasks/org.freedesktop.MediaPlayer.player.xml b/kdeplasma-addons/applets/icontasks/org.freedesktop.MediaPlayer.player.xml deleted file mode 100644 index d36a60b4..00000000 --- a/kdeplasma-addons/applets/icontasks/org.freedesktop.MediaPlayer.player.xml +++ /dev/null @@ -1,72 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/kdeplasma-addons/applets/icontasks/org.mpris.MediaPlayer2.Player.xml b/kdeplasma-addons/applets/icontasks/org.mpris.MediaPlayer2.Player.xml deleted file mode 100644 index 711a74e4..00000000 --- a/kdeplasma-addons/applets/icontasks/org.mpris.MediaPlayer2.Player.xml +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/kdeplasma-addons/applets/icontasks/plasma-applet-icontasks.desktop b/kdeplasma-addons/applets/icontasks/plasma-applet-icontasks.desktop deleted file mode 100644 index bb9e0433..00000000 --- a/kdeplasma-addons/applets/icontasks/plasma-applet-icontasks.desktop +++ /dev/null @@ -1,104 +0,0 @@ -[Desktop Entry] -Name=Icon-Only Task Manager -Name[bs]=Icon-Only upravljač zadacima -Name[ca]=Gestor de tasques de només icones -Name[ca@valencia]=Gestor de tasques de només icones -Name[cs]=Ikonový správce úloh -Name[da]=Opgavelinje kun med ikoner -Name[de]=Symbol-Fensterleiste -Name[el]=Διαχειριστής εργασιών με εικονίδια μόνο -Name[en_GB]=Icon-Only Task Manager -Name[es]=Gestor de tareas de solo iconos -Name[et]=Ainult ikoonidega tegumihaldur -Name[fi]=Kuvaketehtävienhallinta -Name[fr]=Gestionnaire de tâches à icônes -Name[gl]=Xestor de tarefas baseado en iconas -Name[hu]=Ikonos feladatkezelő -Name[it]=Gestore attività con sole icone -Name[kk]=Тек таңбашалы тапсырмалар менеджері -Name[km]=តែ​រូបតំណាង​កម្មវិធី​គ្រប់គ្រង​ភារកិច្ច -Name[ko]=아이콘만 있는 작업 관리자 -Name[lt]=Tik ženkliukų užduočių tvarkytuvė -Name[lv]=Tikai ikonu uzdevumu pārvaldnieks -Name[mr]=फक्त-चिन्ह कार्य व्यवस्थापक -Name[nb]=Oppgavebehandler med bare ikoner -Name[nds]="Bloots-Lüttbild"-Opgavenpleger -Name[nl]=Takenbeheer met alleen pictogrammen -Name[pa]=ਕੇਵਲ ਆਈਕਾਨ ਟਾਸਕ ਮੈਨੇਜਰ -Name[pl]=Menadżer zadań tylko z ikonami -Name[pt]=Gestor de Tarefas com Ícones -Name[pt_BR]=Gerenciador de tarefas com ícones -Name[ro]=Gestionar de sarcini bazat pe pictograme -Name[ru]=Панель задач (только значки) -Name[sk]=Správca úloh len s ikonami -Name[sl]=Upravljalnik opravil s samimi ikonami -Name[sr]=менаџер задатака само са иконама -Name[sr@ijekavian]=менаџер задатака само са иконама -Name[sr@ijekavianlatin]=menadžer zadataka samo sa ikonama -Name[sr@latin]=menadžer zadataka samo sa ikonama -Name[sv]=Aktivitetshanterare med bara ikoner -Name[tr]=Sadece-Simge Görev Yöneticisi -Name[uk]=Керування задачами за допомогою піктограм -Name[x-test]=xxIcon-Only Task Managerxx -Name[zh_CN]=图标任务管理器 -Name[zh_TW]=只有圖示的工作管理員 -Comment=Switch between running applications -Comment[ar]=بدِّل بين التطبيقات المفتوحة -Comment[bs]=Prebacujte između programa u radu -Comment[ca]=Commuta entre aplicacions en execució -Comment[ca@valencia]=Commuta entre aplicacions en execució -Comment[cs]=Přepnout mezi běžícími aplikacemi -Comment[da]=Skift mellem kørende programmer -Comment[de]=Zwischen laufenden Programmen wechseln -Comment[el]=Εναλλαγή μεταξύ των εκτελούμενων εφαρμογών -Comment[en_GB]=Switch between running applications -Comment[es]=Cambiar entre las aplicaciones en ejecución -Comment[et]=Lülitumine töötavate rakenduste vahel -Comment[fi]=Vaihda avoinna olevien ohjelmien välillä -Comment[fr]=Basculer entre les applications démarrées -Comment[ga]=Athraigh idir feidhmchláir atá ag rith -Comment[gl]=Manexe os aplicativos que teña abertos. -Comment[hu]=Váltás a futó alkalmazások között -Comment[it]=Passa da un'applicazione in esecuzione all'altra -Comment[kk]=Жегілген қолданбаларды ақтару -Comment[km]=ប្ដូរ​រវាង​កម្មវិធី​ដែល​កំពុង​រត់ -Comment[ko]=실행 중인 프로그램 전환 -Comment[lt]=Persijungti tarp veikiančių programų -Comment[lv]=Pārslēgties starp darbojošām programmām -Comment[mr]=चालू असलेले अनुप्रयोग बदला -Comment[nb]=Bytt mellom kjørende programmer -Comment[nds]=Twischen lopen Programmen wesseln -Comment[nl]=Schakel tussen draaiende programma's -Comment[nn]=Byt mellom program som køyrer -Comment[pa]=ਚੱਲਦੀਆਂ ਐਪਲੀਕੇਸ਼ਨਾਂ ਬਦਲੋ -Comment[pl]=Przełącz pomiędzy działającymi programami -Comment[pt]=Mudar de aplicações em execução -Comment[pt_BR]=Alterna entre os aplicativos em execução -Comment[ro]=Comută printre aplicațiile ce rulează -Comment[ru]=Переключение между запущенными приложениями -Comment[sk]=Prepínať medzi bežiacimi aplikáciami -Comment[sl]=Preklapljajte med zagnanimi programi -Comment[sr]=Пребацивање између покренутих програма -Comment[sr@ijekavian]=Пребацивање између покренутих програма -Comment[sr@ijekavianlatin]=Prebacivanje između pokrenutih programa -Comment[sr@latin]=Prebacivanje između pokrenutih programa -Comment[sv]=Byt mellan program som kör -Comment[tr]=Çalışan uygulamalar arasında geçiş yap -Comment[ug]=ئىجرا بولۇۋاتقان پروگراممىلارنى ئالماشتۇر -Comment[uk]=Перемкніть запущені програми -Comment[x-test]=xxSwitch between running applicationsxx -Comment[zh_CN]=在运行中的应用程序间切换 -Comment[zh_TW]=在執行中的應用程式間切換 -Icon=preferences-desktop-icons -Type=Service -X-KDE-ServiceTypes=Plasma/Applet - -X-KDE-Library=plasma_applet_icontasks -X-KDE-PluginInfo-Author=Craig Drummond -X-KDE-PluginInfo-Email=craig@kde.org -X-KDE-PluginInfo-Name=icontasks -X-KDE-PluginInfo-Version=1.0 -X-KDE-PluginInfo-Category=Windows and Tasks -X-KDE-PluginInfo-Depends= -X-KDE-PluginInfo-License=GPL v2+ -X-KDE-PluginInfo-EnabledByDefault=false diff --git a/kdeplasma-addons/applets/icontasks/progress.svgz b/kdeplasma-addons/applets/icontasks/progress.svgz deleted file mode 100644 index 099c671a2b472529109449feef715cc0a15bbc91..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3687 zcmV-t4w&&DiwFow`fN@B18{P0XL4n8b1rjsX8`S7TW{kw7Ji>!q4m7XU@e;WOD3KI z+oFpCT@={1=;K1MmBby}GGsZI`Sp7!SrRG9w&K`HFs%oJ*d#^reCInCQj{*gdsxha zyEt9XlI3_n5FP~aa*|AE%bW4w_uqaD^&nVh(Q+EilVv;}ER(@^pWj{nBMgJ@(>TiF zX>dQwZiAneU)Gao6$c+~vut%S8r|RDquI6)CF#xRV-SX)-@UtB-`%_mf&j){t}mvO z@nCzwYLm|MhSSL?p2v%LnXN|zk?@8mH6islgVq{(Eu8h$#&PG4{_Cr+}Vl>UBPB$g`-ngDhmeC?!ucAr39+lu~hTg5dZL28u5{?*fDV&^j+tkUEr zjn``ggM9V7NjBMPll?D#$l_(uABf?|lvn51Ax|KW;Gd!7vKrQoIlY_3_qJUj+*PzL zE(?NHbOQ{VC+T?bKH~P@w&E&Dr*T?V$^7G0C4lQJdn|@5DsEE1HJQh0w48vP1b9+a zZD!NhtJ_v2SAWKntgEI1#m=!Ft*dr@8%>k@@qjifzb457iYby*aiW^llZWv@7(@)G zO1CQQXas3&sA<-LE;rVI!_9J*fsw2pT32t<)Haw$k1-&a|7p$rezt^phb0{;6+2p# z4AqM5XkjI3$+xWoK}t|-=2ug$*fl`Q#)M-e%8s2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@DeVd6j_DV29ew0OeQ z*wqSkyLaLU - * - * ---- - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#include "recentdocuments.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - - -#include -#include -#include -#include - -K_GLOBAL_STATIC(RecentDocuments, recentDocs) - -static QLatin1String constXbel("recently-used.xbel"); - -static QList::ConstIterator findUrl(const QList &list, const QString &url) -{ - QList::ConstIterator it(list.constBegin()), - end(list.constEnd()); - for (; it != end; ++it) { - if ((*it)->property("url") == url) { - break; - } - } - return it; -} - -static bool hasUrl(const QList &list, const QString &url) -{ - return list.end() != findUrl(list, url); -} - -static QString dirSyntax(const QString &d) -{ - if (!d.isEmpty()) { - QString ds(d); - - ds.replace("//", "/"); - - int slashPos(ds.lastIndexOf('/')); - - if (slashPos != (((int)ds.length()) - 1)) - ds.append('/'); - - return ds; - } - - return d; -} - -RecentDocuments * RecentDocuments::self() -{ - return recentDocs; -} - -RecentDocuments::RecentDocuments() - : m_enabled(false) - , m_watcher(0) - , m_menu(0) -{ -} - -RecentDocuments::~RecentDocuments() -{ - if (m_menu) { - m_menu->deleteLater(); - } -} - -void RecentDocuments::setEnabled(bool enabled) -{ - if (m_enabled != enabled) { - if (enabled) { - if (m_files.isEmpty()) { - m_files << File(File::Xbel, dirSyntax(KGlobal::dirs()->localxdgdatadir()) + constXbel) - << File(File::Xbel, dirSyntax(QDir::homePath()) + "." + constXbel) - << File(File::Office, dirSyntax(QDir::homePath()) + ".recently-used"); - } - - m_watcher = new KDirWatch(this); - m_watcher->addDir(KRecentDocument::recentDocumentDirectory()); - foreach (File f, m_files) { - m_watcher->addFile(f.path); - } - connect(m_watcher, SIGNAL(dirty(QString)), this, SLOT(readCurrentDocs())); - connect(KSycoca::self(), SIGNAL(databaseChanged(QStringList)), this, SLOT(sycocaChanged(const QStringList &))); - readCurrentDocs(); - } else if (m_enabled) { - disconnect(m_watcher, SIGNAL(dirty(QString)), this, SLOT(readCurrentDocs())); - disconnect(KSycoca::self(), SIGNAL(databaseChanged(QStringList)), this, SLOT(sycocaChanged(const QStringList &))); - delete m_watcher; - m_watcher = 0; - - QMap >::Iterator it(m_docs.begin()), - end(m_docs.end()); - - for (; it != end; ++it) { - foreach (const QAction * act, *it) { - delete act; - } - } - m_docs.clear(); - m_apps.clear(); - } - m_enabled = enabled; - } -} - -QList RecentDocuments::get(const QString &app) -{ - if (m_enabled) { - load(); - if (m_docs.contains(app)) { - if (m_docs[app].count() > 1) { - if (!m_menu) { - m_menu = new TaskManager::ToolTipMenu(0, i18n("Recent Documents")); - } - - QList old=m_menu->actions(); - foreach (QAction * act, old) { - m_menu->removeAction(act); - } - - foreach (QAction * act, m_docs[app]) { - m_menu->addAction(act); - } - - QList acts; - acts.append(m_menu->menuAction()); - return acts; - } - return m_docs[app]; - } - } - return QList(); -} - -void RecentDocuments::added(const QString &path) -{ - if (KDesktopFile::isDesktopFile(path)) { - removed(path); // Remove first! - KDesktopFile df(path); - KConfigGroup de(&df, "Desktop Entry"); - QString url = de.readEntry("URL", QString()); - QString name = KUrl(url).fileName(); - QString app = de.readEntry("X-KDE-LastOpenedWith", QString()); - - if (!name.isEmpty() && !app.isEmpty() && !url.isEmpty() && !hasUrl(m_docs[app], url)) { - QString icon = de.readEntry("Icon", QString()); - QAction *act = icon.isEmpty() ? new QAction(name, this) : new QAction(KIcon(icon), name, this); - act->setToolTip(KUrl(url).prettyUrl()); - act->setProperty("timestamp", (qulonglong)0); - act->setProperty("path", path); - act->setProperty("url", url); - connect(act, SIGNAL(triggered()), SLOT(loadDoc())); - m_docs[app].append(act); - } - } else { - QList::Iterator it(m_files.begin()), - end(m_files.end()); - for (; it != end; ++it) { - if ((*it).path == path) { - (*it).dirty = true; - break; - } - } - } -} - -void RecentDocuments::removed(const QString &path) -{ - if (path.endsWith(".desktop")) { - QMap >::Iterator it(m_docs.begin()), - end(m_docs.end()); - - for (; it != end; ++it) { - foreach (QAction * act, *it) { - if (act->property("path").toString() == path) { - disconnect(act, SIGNAL(triggered()), this, SLOT(loadDoc())); - delete act; - (*it).removeAll(act); - if ((*it).isEmpty()) { - m_docs.erase(it); - } - return; - } - } - } - } else { - QList::Iterator it(m_files.begin()), - end(m_files.end()); - for (; it != end; ++it) { - if ((*it).path == path) { - (*it).dirty = true; - break; - } - } - } -} - -void RecentDocuments::sycocaChanged(const QStringList &types) -{ - if (types.contains("apps") || types.contains("xdgdata-apps")) { - m_apps.clear(); - QList::Iterator it(m_files.begin()), - end(m_files.end()); - for (; it != end; ++it) { - if (File::Xbel == (*it).type) { - (*it).dirty = true; - } - } - } -} - -void RecentDocuments::loadDoc() -{ - QObject *s = sender(); - if (s && qobject_cast(s)) { - QAction *item = static_cast(s); - QString path = item->property("path").toString(); - - if (path.isEmpty()) { - QString exec = item->property("exec").toString(); - KUrl url = KUrl(item->property("url").toString()); - - if (url.isValid() && !exec.isEmpty()) { - KRun::run(exec, KUrl::List() << url, 0, QString(), QString(), "0"); - } - } else { - new KRun(KUrl(path), 0); - } - } -} - -void RecentDocuments::readCurrentDocs() -{ - const QStringList documents = KRecentDocument::recentDocuments(); - foreach (const QString & document, documents) { - added(document); - } -} - -void RecentDocuments::load() -{ - qulonglong now = (qulonglong)QDateTime::currentMSecsSinceEpoch(); - QList::Iterator it(m_files.begin()), - end(m_files.end()); - for (; it != end; ++it) { - if ((*it).dirty) { - if (File::Xbel == (*it).type) { - loadXbel((*it).path, now); - } else if (File::Office == (*it).type) { - loadOffice((*it).path, now); - } - (*it).dirty = false; - } - } -} - -static QString convertMimeType(const QString &mimeType, const KUrl &url) -{ - return mimeType == "text/plain" && url.fileName().endsWith(".csv") - ? QLatin1String("text/csv") : mimeType; -} - -RecentDocuments::App RecentDocuments::officeAppForMimeType(const QString &mimeType) -{ - if (m_apps.contains(mimeType)) { - return m_apps[mimeType]; - } else { - KService::List services = KServiceTypeTrader::self()->query("Application", - QString("exist Exec and (exist ServiceTypes) and ('libreoffice' ~ Exec) and ('%1' in ServiceTypes)").arg(mimeType)); - - if (!services.empty()) { - QString desktopFile = services[0]->entryPath(); - KDesktopFile df(desktopFile); - KConfigGroup grp(&df, "Desktop Entry"); - QString exec = grp.readEntry("Exec", QString()); - - if (!exec.isEmpty()) { - App app(KUrl::fromPath(desktopFile).fileName().remove(".desktop"), exec); - m_apps.insert(mimeType, app); - return app; - } - } - } - - return App(); -} - -RecentDocuments::App RecentDocuments::appForExec(const QString &execString) -{ - if (m_apps.contains(execString)) { - return m_apps[execString]; - } else { - KService::List services = KServiceTypeTrader::self()->query("Application", - QString("exist Exec and ('%1' =~ Exec)").arg(execString)); - if (services.empty()) { - QString execApp = execString; - int space = execApp.indexOf(' '); - if (-1 != space) { - execApp = execApp.left(space); - } - services = KServiceTypeTrader::self()->query("Application", - QString("exist TryExec and ('%1' =~ TryExec)").arg(execApp)); - } - if (!services.empty()) { - QString desktopFile = services[0]->entryPath(); - KDesktopFile df(desktopFile); - KConfigGroup grp(&df, "Desktop Entry"); - QString exec = grp.readEntry("Exec", QString()); - - if (!exec.isEmpty()) { - App app(KUrl::fromPath(desktopFile).fileName().remove(".desktop"), exec); - m_apps.insert(execString, app); - return app; - } - } - } - - return App(); -} - -void RecentDocuments::loadXbel(const QString &path, qulonglong now) -{ - QDomDocument doc("xbel"); - QFile f(path); - - if (f.open(QIODevice::ReadOnly) && doc.setContent(&f)) { - QDomElement root = doc.documentElement(); - if ("xbel" == root.tagName() && root.hasAttribute("version") && "1.0" == root.attribute("version")) { - QDomElement bookmark = root.firstChildElement("bookmark"); - while (!bookmark.isNull()) { - if (bookmark.hasAttribute("href")) { - QDomElement info = bookmark.firstChildElement("info"); - if (!info.isNull()) { - QDomElement metadata = info.firstChildElement("metadata"); - if (!metadata.isNull() && metadata.hasAttribute("owner") && "http://freedesktop.org" == metadata.attribute("owner")) { - QDomElement applications = metadata.firstChildElement("bookmark:applications"); - if (!applications.isNull()) { - QDomElement application = applications.firstChildElement("bookmark:application"); - if (!application.isNull() && application.hasAttribute("exec")) { - KUrl url = bookmark.attribute("href"); - if (url.isValid() && (!url.isLocalFile() || QFile::exists(url.toLocalFile()))) { - QString exec = application.attribute("exec"); - QDomElement mimeType = metadata.firstChildElement("mime:mime-type"); - QString mType; - KMimeType::Ptr mime; - if (!mimeType.isNull() && mimeType.hasAttribute("type")) { - mType = convertMimeType(mimeType.attribute("type"), url); - mime = KMimeType::mimeType(mType); - } - - exec.remove('\''); - - App app = mime && QLatin1String("soffice %u")==exec - ? officeAppForMimeType(mType) - : appForExec(exec); - - if (!app.name.isEmpty()) { - QString name = KUrl(url).fileName(); - - if (!name.isEmpty()) { - bool found = false; - if (!m_docs[app.name].isEmpty()) { - QList::ConstIterator it = findUrl(m_docs[app.name], url.url()); - if (it != m_docs[app.name].constEnd()) { - found = true; - if ((*it)->property("timestamp").toULongLong() > 0) { - (*it)->setProperty("timestamp", now); - } - } - } - if (!found) { - QAction *act = mime - ? new QAction(KIcon(mime->iconName()), name, this) - : new QAction(name, this); - - act->setToolTip(KUrl(url).prettyUrl()); - act->setProperty("timestamp", now); - act->setProperty("url", url.url()); - act->setProperty("exec", app.exec); - act->setProperty("type", (int)File::Xbel); - connect(act, SIGNAL(triggered()), SLOT(loadDoc())); - m_docs[app.name].append(act); - } - } - } - } - } - } - } - } - } - bookmark = bookmark.nextSiblingElement("bookmark"); - } - } - } - - removeOld(now, File::Xbel); -} - -void RecentDocuments::loadOffice(const QString &path, qulonglong now) -{ - QDomDocument doc("RecentFiles"); - QFile f(path); - - if (f.open(QIODevice::ReadOnly) && doc.setContent(&f)) { - QDomElement root = doc.documentElement(); - if ("RecentFiles" == root.tagName()) { - QDomElement recentItem = root.firstChildElement("RecentItem"); - while (!recentItem.isNull()) { - QDomElement groups = recentItem.firstChildElement("Groups"); - if (!groups.isNull()) { - QDomElement group = groups.firstChildElement("Group"); - bool ok = false; - while (!group.isNull()) { - if (group.text() == "openoffice.org") { - ok = true; - break; - } - group = group.nextSiblingElement("Group"); - } - - if (ok) { - QDomElement uri = recentItem.firstChildElement("URI"); - QDomElement mimeType = recentItem.firstChildElement("Mime-Type"); - - if (!uri.isNull() && !mimeType.isNull()) { - KUrl url(uri.text()); - - if (url.isValid() && (!url.isLocalFile() || QFile::exists(url.toLocalFile()))) { - QString mType = convertMimeType(mimeType.text(), url); - App app = officeAppForMimeType(mType); - - if (!app.name.isEmpty() && !app.exec.isEmpty()) { - QString name = KUrl(url).fileName(); - - if (!name.isEmpty()) { - bool found = false; - if (!m_docs[app.name].isEmpty()) { - QList::ConstIterator it = findUrl(m_docs[app.name], url.url()); - if (it != m_docs[app.name].constEnd()) { - found = true; - if ((*it)->property("timestamp").toULongLong() > 0) { - (*it)->setProperty("timestamp", now); - } - } - } - if (!found) { - KMimeType::Ptr mime = KMimeType::mimeType(mType); - QAction *act = mime - ? new QAction(KIcon(mime->iconName()), name, this) - : new QAction(name, this); - - act->setToolTip(KUrl(url).prettyUrl()); - act->setProperty("local", false); - act->setProperty("timestamp", now); - act->setProperty("url", url.url()); - act->setProperty("exec", app.exec); - act->setProperty("type", (int)File::Office); - connect(act, SIGNAL(triggered()), SLOT(loadDoc())); - m_docs[app.name].append(act); - } - } - } - } - } - } - } - recentItem = recentItem.nextSiblingElement("RecentItem"); - } - } - } - - removeOld(now, File::Office); -} - -void RecentDocuments::removeOld(qulonglong now, File::Type type) -{ - QMap >::Iterator it(m_docs.begin()), - end(m_docs.end()); - while (it != end) { - QList old; - - foreach (QAction * act, (*it)) { - qulonglong t = act->property("timestamp").toULongLong(); - if (type==act->property("type").toInt() && t > 0 && t < now) { - old.append(act); - } - } - - foreach (QAction * act, old) { - act->deleteLater(); - (*it).removeAll(act); - } - - if ((*it).isEmpty()) { - QMap >::Iterator cur = it; - it++; - m_docs.erase(cur); - } else { - it++; - } - } -} - -#include "moc_recentdocuments.cpp" diff --git a/kdeplasma-addons/applets/icontasks/recentdocuments.h b/kdeplasma-addons/applets/icontasks/recentdocuments.h deleted file mode 100644 index 4820279a..00000000 --- a/kdeplasma-addons/applets/icontasks/recentdocuments.h +++ /dev/null @@ -1,95 +0,0 @@ -#ifndef __RECENT_DOCUMENTS__ -#define __RECENT_DOCUMENTS__ - -/* - * Icon Task Manager - * - * Copyright 2011 Craig Drummond - * - * ---- - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#include -#include -#include -#include -#include "taskmanager/taskactions.h" - -class KDirWatch; - -class RecentDocuments : public QObject -{ - Q_OBJECT - - struct File { - enum Type { - Xbel, - Office - }; - - File(Type t, const QString &p) : type(t), path(p), dirty(true) { } - Type type; - QString path; - bool dirty; - }; - - struct App { - App(const QString &n = QString(), const QString &e = QString()) : name(n), exec(e) { } - QString name; - QString exec; - }; - -public: - static RecentDocuments * self(); - - RecentDocuments(); - ~RecentDocuments(); - - void setEnabled(bool enabled); - bool isEnabled() const { - return m_enabled; - } - - QList get(const QString &app); - -private Q_SLOTS: - void added(const QString& path); - void removed(const QString& path); - void sycocaChanged(const QStringList &types); - void loadDoc(); - void readCurrentDocs(); - -private: - void load(); - App officeAppForMimeType(const QString &mimeType); - App appForExec(const QString &execString); - void loadXbel(const QString &path, qulonglong now); - void loadOffice(const QString &path, qulonglong now); - void removeOld(qulonglong now, File::Type type); - -private: - - bool m_enabled; - QMap > m_docs; - QMap m_apps; - KDirWatch *m_watcher; - QList m_files; - TaskManager::ToolTipMenu *m_menu; -}; - -#endif diff --git a/kdeplasma-addons/applets/icontasks/taskgroupitem.cpp b/kdeplasma-addons/applets/icontasks/taskgroupitem.cpp deleted file mode 100644 index a413f02b..00000000 --- a/kdeplasma-addons/applets/icontasks/taskgroupitem.cpp +++ /dev/null @@ -1,1597 +0,0 @@ -/*************************************************************************** -* Copyright (C) 2007 by Robert Knight * -* Copyright (C) 2008 by Alexis Ménard * -* * -* This program is free software; you can redistribute it and/or modify * -* it under the terms of the GNU General Public License as published by * -* the Free Software Foundation; either version 2 of the License, or * -* (at your option) any later version. * -* * -* This program is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU General Public License for more details. * -* * -* You should have received a copy of the GNU General Public License * -* along with this program; if not, write to the * -* Free Software Foundation, Inc., * -* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * -***************************************************************************/ - -// Own -#include "taskgroupitem.h" -#include "jobmanager.h" -#include "mediabuttons.h" - -// Qt -#include -#include -#include -#include -#include -#include - -// KDE -#include -#include - -#include "taskmanager/taskactions.h" -#include "taskmanager/taskmanager.h" -#include "taskmanager/taskgroup.h" -#include "taskmanager/abstractgroupingstrategy.h" -#include "taskmanager/taskitem.h" - -#include -#include -#include "tooltips/tooltipmanager.h" -#include -#include -#include -#include - -#include "tasks.h" -#include "taskitemlayout.h" -#include "windowtaskitem.h" -#include "applauncheritem.h" - -class DropIndicator : public QGraphicsWidget -{ -public: - - DropIndicator(QGraphicsItem *parent = 0, Qt::WindowFlags wFlags = 0) - : QGraphicsWidget(parent, wFlags) - , m_size(16) - , m_orientation(Qt::Horizontal) { - m_svg = new Plasma::Svg(); - m_svg->setImagePath("icontasks/dropindicators"); - m_svg->setContainsMultipleImages(true); - m_svg->resize(m_size, m_size); - setOrientation(Qt::Horizontal); - - m_animation = new QPropertyAnimation(this, "pos", this); - m_animation->setEasingCurve(QEasingCurve::InOutQuad); - m_animation->setDuration(50); - } - - ~DropIndicator() { - } - - void setOrientation(Qt::Orientation orientation) { - m_orientation = orientation; - } - - Qt::Orientation orientation() { - return m_orientation; - } - - void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { - Q_UNUSED(option); - Q_UNUSED(widget); - - m_svg->paint(painter, rect().topLeft(), Qt::Horizontal == m_orientation ? "horizontal-dropindicator" : "vertical-dropindicator"); - } - - void setSize(int size) { - int sz = size; - if (sz < 16) { - sz = 16; - } else if (sz > 32) { - sz = 32; - } else { - sz = (sz / 4) * 4; - } - - if (m_size != sz) { - m_size = sz; - m_svg->resize(m_size, m_size); - } - } - - void setPosition(const QRectF &r) { - QPointF newPos = Qt::Horizontal == m_orientation - ? QPointF(r.x() - (m_size / 2.0), r.y() + (r.height() - m_size) / 2.0) - : QPointF(r.x() + (r.width() - m_size) / 2.0, r.y() - (m_size / 2.0)); - - if (isVisible()) { - if (m_animation->state() == QAbstractAnimation::Running) { - m_animation->stop(); - } - - m_animation->setEndValue(newPos); - m_animation->start(); - } else { - setVisible(true); - setPos(newPos); - } - } - -private: - int m_size; - Plasma::Svg *m_svg; - Qt::Orientation m_orientation; - QPropertyAnimation *m_animation; -}; - - -TaskGroupItem::TaskGroupItem(QGraphicsWidget *parent, Tasks *applet) - : AbstractTaskItem(parent, applet), - m_tasksLayout(0), - m_popupMenuTimer(0), - m_lastActivated(-1), - m_activeTaskIndex(0), - m_maximumRows(1), - m_offscreenWidget(0), - m_offscreenLayout(0), - m_collapsed(true), - m_mainLayout(0), - m_popupDialog(0), - m_updateTimer(0), - m_changes(TaskManager::TaskUnchanged), - m_dropIndicator(0) -{ - setAcceptDrops(true); - setFlag(ItemClipsChildrenToShape, true); -} - - -TaskGroupItem::~TaskGroupItem() -{ - if (!m_offscreenLayout && !m_mainLayout) { - // only delete this if we have neither an offscreen layout or a mainlayout - // if we do, then they will delete the layout for us. - delete m_tasksLayout; - } - close(false); -} - -void TaskGroupItem::activate() -{ -} - -void TaskGroupItem::activateOrIconify() -{ - bool includesActive = false; - TaskManager::ItemList items(m_group.data()->members()); - int iconified = 0; - foreach (AbstractGroupableItem * item, items) { - TaskManager::TaskItem *task = qobject_cast(item); - if (task) { - if (task->task()->isMinimized()) { - ++ iconified; - } - - if (task->task()->isActive()) { - includesActive = true; - } - } - } - - if (includesActive && items.size() - iconified > iconified) { - // iconify - foreach (TaskManager::AbstractGroupableItem * item, items) { - TaskManager::TaskItem *task = qobject_cast(item); - if (task) { - task->task()->setIconified(true); - } - } - } else { - // activate - QList winOrder(KWindowSystem::stackingOrder()); - const int winCount = winOrder.size(); - TaskManager::TaskItem* sortedItems[winCount]; - - memset(sortedItems, 0, sizeof(TaskManager::TaskItem*) * winCount); - - foreach (TaskManager::AbstractGroupableItem * item, items) { - TaskManager::TaskItem *task = qobject_cast(item); - if (task) { - int index = winOrder.indexOf(task->task()->window()); - if (index != -1) { - sortedItems[index] = task; - } - } - } - - for (int index = 0; index < winCount; ++ index) { - TaskManager::TaskItem* task = sortedItems[index]; - if (task) { - task->task()->activate(); - } - } - } -} - -void TaskGroupItem::close() -{ - close(true); -} - -void TaskGroupItem::close(bool hide) -{ - //kDebug(); - //close the popup if the group is removed - if (m_popupDialog) { - m_popupDialog->hide(); - disconnect(m_popupDialog, 0, 0, 0); - m_popupDialog->deleteLater(); - m_popupDialog = 0; - } - - if (m_group) { - disconnect(m_group.data(), 0, this, 0); - } - - if (m_updateTimer) { - m_updateTimer->stop(); - } - - if (!isRootGroup()) { - unregisterFromHelpers(); - if (hide) { - setVisible(false); - } - } -} - -bool TaskGroupItem::isRootGroup() const -{ - return m_applet == parentWidget(); -} - -void TaskGroupItem::updateTask(::TaskManager::TaskChanges changes) -{ - if (!m_group || isRootGroup()) { - return; - } - - m_changes |= changes; - - if (!m_updateTimer) { - m_updateTimer = new QTimer(this); - m_updateTimer->setInterval(10); - m_updateTimer->setSingleShot(true); - connect(m_updateTimer, SIGNAL(timeout()), this, SLOT(checkUpdates())); - } - - m_updateTimer->start(); -} - -void TaskGroupItem::checkUpdates() -{ - if (!m_group) { - return; - } - - bool needsUpdate = false; - TaskFlags flags = m_flags; - - if (m_changes & TaskManager::StateChanged) { - if (m_group.data()->isActive()) { - flags |= TaskHasFocus; - if (!(m_flags & TaskHasFocus)) { - emit activated(this); - } - } else { - flags &= ~TaskHasFocus; - } - - if (m_group.data()->isMinimized()) { - flags |= TaskIsMinimized; - } else { - flags &= ~TaskIsMinimized; - } - } - - if (m_changes & TaskManager::AttentionChanged) { - if (m_group.data()->demandsAttention()) { - flags |= TaskWantsAttention; - } else { - flags &= ~TaskWantsAttention; - } - } - - if (flags != m_flags) { - needsUpdate = true; - setTaskFlags(flags); - } - - // basic title and icon - if (m_changes & TaskManager::IconChanged) { - needsUpdate = true; - } - - if (m_changes & TaskManager::NameChanged) { - needsUpdate = true; - } - - if (IconTasks::ToolTipManager::self()->isVisible(this) && - (m_changes & TaskManager::IconChanged || - m_changes & TaskManager::NameChanged || - m_changes & TaskManager::DesktopChanged)) { - updateToolTip(); - } - - m_changes = TaskManager::TaskUnchanged; - if (needsUpdate) { - //redraw - queueUpdate(); - } -} - -void TaskGroupItem::updateToolTip() -{ - if (!m_group) { - return; - } - - QWidget *dialog = m_applet->popupDialog(); - - if (dialog && dialog->isVisible()) { - clearToolTip(); - return; - } - - IconTasks::ToolTipContent data; - - data.setClickable(true); - data.setInstantPopup(m_applet->instantToolTip()); - data.setHighlightWindows(m_applet->highlightWindows()); - data.setVertical(Plasma::Vertical == m_applet->formFactor()); - - QMap map; - - if (m_applet->launcherIcons() && m_icon.isNull()) { - KUrl launcherUrl(m_abstractItem->launcherUrl()); - if (launcherUrl.isLocalFile() && KDesktopFile::isDesktopFile(launcherUrl.toLocalFile())) { - KDesktopFile f(launcherUrl.toLocalFile()); - if (f.tryExec()) { - m_icon = KIcon(f.readIcon()); - } - } - } - - foreach (AbstractGroupableItem * item, m_group.data()->members()) { - TaskManager::TaskItem *taskItem = qobject_cast(item); - if (taskItem && taskItem->task()) { - if (m_icon.isNull()) { - m_icon = item->icon(); - } - map.insertMulti(taskItem->id(), - IconTasks::ToolTipContent::Window(taskItem->task()->window(), - item->name(), - m_icon.pixmap(IconTasks::ToolTipContent::iconSize(), IconTasks::ToolTipContent::iconSize()), - taskItem->task()->demandsAttention(), - !m_applet->groupManager().showOnlyCurrentDesktop() || !taskItem->isOnCurrentDesktop() - ? taskItem->task()->desktop() : 0)); - } - } - - data.setWindowDetailsToPreview(map.values()); - - QString key = mediaButtonKey(); - if (!key.isEmpty()) { - data.setPlayState(MediaButtons::self()->playbackStatus(key)); - } - - IconTasks::ToolTipManager::self()->setContent(this, data); -} - -void TaskGroupItem::reload() -{ - if (!group()) { - return; - } - - QHash itemsToRemove = m_groupMembers; - foreach (AbstractGroupableItem * item, group()->members()) { - if (!item) { - kDebug() << "invalid Item"; - continue; - } - - if (itemsToRemove.contains(item)) { - itemsToRemove.insert(item, 0); - } - itemAdded(item); - - if (item->itemType() == TaskManager::GroupItemType) { - TaskGroupItem *group = qobject_cast(abstractTaskItem(item)); - if (group) { - group->reload(); - } - } - } - - QHashIterator it(itemsToRemove); - while (it.hasNext()) { - it.next(); - if (it.key() && it.value()) { - itemRemoved(it.key()); - } - } -} - -void TaskGroupItem::setGroup(TaskManager::GroupPtr group) -{ - //kDebug(); - if (m_group.data() == group) { - kDebug() << "already have this group!"; - return; - } - - if (m_group) { - disconnect(m_group.data(), 0, this, 0); - } - - m_group = group; - m_abstractItem = group; - - if (m_group) { - connect(m_abstractItem, SIGNAL(destroyed(QObject*)), this, SLOT(clearAbstractItem())); - connect(group, SIGNAL(destroyed(QObject*)), this, SLOT(clearGroup())); - connect(group, SIGNAL(itemRemoved(AbstractGroupableItem*)), this, SLOT(itemRemoved(AbstractGroupableItem*))); - connect(group, SIGNAL(itemAdded(AbstractGroupableItem*)), this, SLOT(itemAdded(AbstractGroupableItem*))); - - //connect(group, SIGNAL(destroyed()), this, SLOT(close())); - - connect(group, SIGNAL(changed(::TaskManager::TaskChanges)), this, SLOT(updateTask(::TaskManager::TaskChanges))); - - connect(group, SIGNAL(itemPositionChanged(AbstractGroupableItem*)), this, SLOT(itemPositionChanged(AbstractGroupableItem*))); - } - - //Add already existing items - reload(); - updateTask(::TaskManager::EverythingChanged); - if (!isRootGroup()) { - registerWithHelpers(); - } - //kDebug() << "Task added, isActive = " << task->isActive(); -} - -TaskManager::GroupPtr TaskGroupItem::group() const -{ - return m_group.data(); -} - -void TaskGroupItem::clearGroup() -{ - //now it's useless -} - -void TaskGroupItem::contextMenuEvent(QGraphicsSceneContextMenuEvent *e) -{ - //kDebug(); - if (!m_group) { - QGraphicsWidget::contextMenuEvent(e); - return; - } - - Q_ASSERT(m_applet); - //we are the master group item - if (isRootGroup()) { - e->ignore(); - return; - } - - QList actionList; - - QAction *a = m_applet->action("configure"); - if (a && a->isEnabled()) { - actionList.append(a); - } - - TaskManager::BasicMenu menu(qobject_cast(this), m_group.data(), &m_applet->groupManager(), actionList, getAppMenu()); - - menu.adjustSize(); - - if (m_applet->formFactor() != Plasma::Vertical) { - menu.setMinimumWidth(size().width()); - } - - Q_ASSERT(m_applet->containment()); - Q_ASSERT(m_applet->containment()->corona()); - stopWindowHoverEffect(); - menu.exec(m_applet->containment()->corona()->popupPosition(this, menu.size())); -} - -QHash TaskGroupItem::members() const -{ - return m_groupMembers; -} - -int TaskGroupItem::count() const -{ - return m_groupMembers.count(); -} - -AbstractTaskItem *TaskGroupItem::createAbstractItem(TaskManager::AbstractGroupableItem *groupableItem) -{ - //kDebug() << "item to create" << groupableItem; - AbstractTaskItem *item = 0; - - if (groupableItem->itemType() == TaskManager::GroupItemType) { - TaskGroupItem *groupItem = new TaskGroupItem(this, m_applet); - groupItem->setGroup(static_cast(groupableItem)); - item = groupItem; - } else if (groupableItem->itemType() == TaskManager::LauncherItemType) { - AppLauncherItem *launcherItem = new AppLauncherItem(this, m_applet, static_cast(groupableItem)); - item = launcherItem; - } else { - TaskManager::TaskItem * taskItem = static_cast(groupableItem); - //if the taskItem is not either a startup o a task, return 0; - if (!taskItem->startup() && !taskItem->task()) { - return item; - } - - WindowTaskItem *windowItem = new WindowTaskItem(this, m_applet); - windowItem->setTask(taskItem); - item = windowItem; - } - - if (m_collapsed) { - item->setPreferredOffscreenSize(); - } - - return item; -} - -void TaskGroupItem::itemAdded(TaskManager::AbstractGroupableItem * groupableItem) -{ - //kDebug(); - if (!m_applet) { - kDebug() << "No applet"; - return; - } - - //returns the corresponding item or creates a new one - AbstractTaskItem *item = m_groupMembers.value(groupableItem); - - if (!item) { - item = createAbstractItem(groupableItem); - - if (item) { - connect(item, SIGNAL(activated(AbstractTaskItem*)), - this, SLOT(updateActive(AbstractTaskItem*))); - - TaskGroupItem *group = qobject_cast(item); - if (group) { - connect(item, SIGNAL(changed()), this, SLOT(relayoutItems())); - } - - if (!isRootGroup()) { - item->setVisible(false); - } - } else { - kDebug() << "invalid Item"; - return; - } - } - - m_groupMembers[groupableItem] = item; - item->setParentItem(this); - - if (m_tasksLayout) { //add to layout either for popup or expanded group - m_tasksLayout->addTaskItem(item); - } else { //collapsed and no layout so far - item->hide(); - QRect rect = iconGeometry(); - item->publishIconGeometry(rect); - } - - if (item->isActive()) { - //kDebug() << "item is Active" ; - m_activeTaskIndex = indexOf(item); - } else if (!m_group || m_group.data()->members().size() == 1) { - m_activeTaskIndex = 0; - } - - if (collapsed()) { - update(); - } -} - -void TaskGroupItem::itemRemoved(TaskManager::AbstractGroupableItem * groupableItem) -{ - //kDebug(); - if (!m_applet) { - kDebug() << "No Applet"; - return; - } - - AbstractTaskItem *item = m_groupMembers.take(groupableItem); - - if (!item) { - kDebug() << "Item not found"; - return; - } - //kDebug() << item->text(); - - disconnect(item, 0, 0, 0); - - if (m_tasksLayout) { - m_tasksLayout->removeTaskItem(item); - - if (m_offscreenWidget) { - m_offscreenWidget->adjustSize(); - } - - if (m_popupDialog && m_popupDialog->isVisible() && - m_applet->containment() && m_applet->containment()->corona()) { - m_popupDialog->move(m_applet->containment()->corona()->popupPosition(this, m_popupDialog->size(), Qt::AlignCenter)); - } - } - - item->close(); - //item->deleteLater(); - QTimer::singleShot(0, item, SLOT(deleteLater())); -} - -bool TaskGroupItem::isWindowItem() const -{ - return false; -} - -bool TaskGroupItem::isActive() const -{ - //kDebug() << "Not Implemented"; - return false; -} - -bool TaskGroupItem::windowPreviewOpen() const -{ - if (KWindowSystem::compositingActive() && isRootGroup()) { - QHashIterator it(m_groupMembers); - - while (it.hasNext()) { - it.next(); - AbstractTaskItem *item = it.value(); - if (!qobject_cast(item) && item->isToolTipVisible()) { - return true; - } - } - } - - return false; -} - -QString TaskGroupItem::appName() const -{ - if (isRootGroup()) { - return text(); - } - - foreach (AbstractTaskItem * member, m_groupMembers) { - QString n(member->appName()); - - if (!n.isEmpty()) { - return n; - } - } - - return QString(); -} - -KUrl TaskGroupItem::launcherUrl() const -{ - if (isRootGroup()) { - return KUrl(); - } - - foreach (AbstractTaskItem * member, m_groupMembers) { - KUrl u(member->launcherUrl()); - - if (u.isValid()) { - return u; - } - } - - return KUrl(); -} - -QString TaskGroupItem::windowClass() const -{ - if (isRootGroup()) { - return QString(); - } - - foreach (AbstractTaskItem * member, m_groupMembers) { - QString c(member->windowClass()); - - if (!c.isEmpty()) { - return c; - } - } - - return QString(); -} - -void TaskGroupItem::mousePressEvent(QGraphicsSceneMouseEvent *event) -{ - if (!m_group) { - return; - } - - event->accept(); -} - -void TaskGroupItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) -{ - if (m_applet->rootGroupItem() == this || !m_group) { - return; - } - - if (event->button() == Qt::LeftButton) { - if (Tasks::GC_MinMax != m_applet->groupClick() || event->modifiers() & Qt::ControlModifier) { - bool usePresentWindows=(event->modifiers()&Qt::ControlModifier || Tasks::GC_PresentWindows == m_applet->groupClick()) && - KWindowSystem::compositingActive() && Plasma::WindowEffects::isEffectAvailable(Plasma::WindowEffects::PresentWindowsGroup); - - if (usePresentWindows) { - QList ids; - foreach (AbstractGroupableItem * groupable, m_group.data()->members()) { - if (groupable->itemType() == TaskManager::GroupItemType) { - //TODO: recurse through sub-groups? - } else { - TaskItem * item = qobject_cast(groupable); - if (item && item->task()) { - ids << item->task()->info().win(); - } - } - } - - Plasma::WindowEffects::presentWindows(m_applet->view()->winId(), ids); - } else { - if (m_popupMenuTimer) { - m_popupMenuTimer->stop(); - } - popupMenu(); - } - } else { - activateOrIconify(); - } - } - - AbstractTaskItem::mouseReleaseEvent(event); -} - -void TaskGroupItem::handleActiveWindowChanged(WId id) -{ - if (!m_popupDialog) { - return; - } - - if (id == m_popupDialog->winId()) { - return; - } - - m_popupDialog->hide(); - - QRect rect = iconGeometry(); - publishIconGeometry(rect); -} - -void TaskGroupItem::popupMenu() -{ - //kDebug(); - if (!m_collapsed) { - return; - } - - if (!m_offscreenWidget) { - foreach (AbstractTaskItem * member, m_groupMembers) { - member->setPreferredOffscreenSize(); - } - - tasksLayout()->invalidate(); - m_tasksLayout->setOrientation(Plasma::Vertical); - m_tasksLayout->setMaximumRows(1); - m_offscreenWidget = new QGraphicsWidget(this); - m_offscreenLayout = new QGraphicsLinearLayout(m_offscreenWidget); - m_offscreenLayout->setContentsMargins(0, 0, 0, 0); //default are 4 on each side - m_offscreenLayout->addItem(tasksLayout()); - m_offscreenWidget->setLayout(m_offscreenLayout); - m_offscreenWidget->adjustSize(); - m_applet->containment()->corona()->addOffscreenWidget(m_offscreenWidget); - m_offscreenLayout->activate(); - } - - if (!m_popupDialog) { - // Initialize popup dialog - m_popupDialog = new Plasma::Dialog(0, Qt::Popup); - KWindowSystem::setType(m_popupDialog->winId(), NET::PopupMenu); - connect(m_popupDialog, SIGNAL(dialogVisible(bool)), this, SLOT(popupVisibilityChanged(bool))); - connect(m_popupDialog, SIGNAL(dialogVisible(bool)), m_applet, SLOT(setPopupDialog(bool))); - connect(KWindowSystem::self(), SIGNAL(activeWindowChanged(WId)), this, SLOT(handleActiveWindowChanged(WId))); - KWindowSystem::setState(m_popupDialog->winId(), NET::SkipTaskbar | NET::SkipPager); - m_popupDialog->setWindowFlags(Qt::Popup | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint); - - int left, top, right, bottom; - m_popupDialog->getContentsMargins(&left, &top, &right, &bottom); - m_offscreenWidget->setMinimumWidth(size().width() - left - right); - m_popupDialog->setGraphicsWidget(m_offscreenWidget); - } - - if (m_popupDialog->isVisible()) { - m_popupDialog->clearFocus(); - if (m_applet->location() != Plasma::Floating) { - m_popupDialog->animatedHide(Plasma::locationToInverseDirection(m_applet->location())); - } else { - m_popupDialog->hide(); - } - } else { - m_tasksLayout->setOrientation(Plasma::Vertical); - m_tasksLayout->setMaximumRows(1); - m_offscreenWidget->layout()->activate(); - - QSizeF sz(m_offscreenWidget->effectiveSizeHint(Qt::PreferredSize)); - foreach (AbstractTaskItem * member, m_groupMembers) { - member->setPreferredOffscreenSize(); - QSizeF m = member->preferredSize(); - if (m.width() > sz.width()) { - sz.setWidth(m.width()); - } - } - - m_offscreenWidget->resize(sz); - m_popupDialog->syncToGraphicsWidget(); - - if (m_applet->containment() && m_applet->containment()->corona()) { - m_popupDialog->move(m_applet->containment()->corona()->popupPosition(this, m_popupDialog->size(), Qt::AlignCenter)); - } - KWindowSystem::setState(m_popupDialog->winId(), NET::SkipTaskbar | NET::SkipPager); - if (m_applet->location() != Plasma::Floating) { - m_popupDialog->animatedShow(Plasma::locationToDirection(m_applet->location())); - } else { - m_popupDialog->show(); - } - - m_popupDialog->raise(); - } -} - -void TaskGroupItem::popupVisibilityChanged(bool visible) -{ - if (!visible) { - QRect rect = iconGeometry(); - publishIconGeometry(rect); - update(); - } -} - -bool TaskGroupItem::focusNextPrevChild(bool next) -{ - return focusSubTask(next, false); -} - -bool TaskGroupItem::focusSubTask(bool next, bool activate) -{ - const int subTasks = totalSubTasks(); - - if (subTasks > 0) { - int index = -1; - - if (subTasks > 1) { - for (int i = 0; i < subTasks; ++i) { - if (selectSubTask(i)->taskFlags() & TaskHasFocus) { - index = i; - break; - } - } - } - - if (next) { - ++index; - - if (index >= subTasks) { - index = 0; - } - } else { - --index; - - if (index < 0) { - index = (subTasks - 1); - } - } - - AbstractTaskItem *taskItem = selectSubTask(index); - - if (taskItem) { - taskItem->setFocus(); - m_activeTaskIndex = index; - } - - if (activate && taskItem) { - stopWindowHoverEffect(); - taskItem->activate(); - } - - return true; - } else { - return false; - } -} - -void TaskGroupItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) -{ - if (isRootGroup()) { - return; - } - - if (QPoint(event->screenPos() - event->buttonDownScreenPos(Qt::LeftButton)).manhattanLength() < QApplication::startDragDistance()) { - return; - } //Wait a bit before starting drag - - //kDebug(); - if (m_popupMenuTimer) { - //kDebug() << "popupTimer stop"; - m_popupMenuTimer->stop(); - } //Wait a bit before starting drag - AbstractTaskItem::mouseMoveEvent(event); -} - -void TaskGroupItem::resizeEvent(QGraphicsSceneResizeEvent *event) -{ - Q_UNUSED(event) - - if (m_offscreenWidget && m_popupDialog) { - int left, top, right, bottom; - m_popupDialog->getContentsMargins(&left, &top, &right, &bottom); - m_offscreenWidget->setMinimumWidth(size().width() - left - right); - } - - AbstractTaskItem::resizeEvent(event); -} - -void TaskGroupItem::expand() -{ - if (!collapsed()) { - //kDebug() << "already expanded"; - return; - } - - if (m_popupDialog) { - m_popupDialog->hide(); - } - - if (m_offscreenLayout) { - m_offscreenLayout->removeItem(tasksLayout()); - } - - if (!m_mainLayout) { //this layout is needed since we can't take a layout directly from a widget without destroying it - m_mainLayout = new QGraphicsLinearLayout(this); - m_mainLayout->setContentsMargins(0, 0, 0, 0); //default are 4 on each side - setLayout(m_mainLayout); - } - - //set it back from the popup settings (always vertical and 1 row) - tasksLayout()->setOrientation(m_applet->formFactor()); - tasksLayout()->setMaximumRows(m_maximumRows); - - m_mainLayout->addItem(tasksLayout()); - - disconnect(m_applet, SIGNAL(constraintsChanged(Plasma::Constraints)), this, SLOT(constraintsChanged(Plasma::Constraints))); - connect(m_applet, SIGNAL(constraintsChanged(Plasma::Constraints)), this, SLOT(constraintsChanged(Plasma::Constraints))); - //connect(m_tasksLayout, SIGNAL(sizeHintChanged(Qt::SizeHint)), this, SLOT(updatePreferredSize())); - m_collapsed = false; - tasksLayout()->layoutItems(); - //kDebug() << tasksLayout()->preferredSize() << preferredSize() << m_groupMembers.count(); - emit changed(); - checkSettings(); - //kDebug() << "expanded"; -} - -void TaskGroupItem::constraintsChanged(Plasma::Constraints constraints) -{ - //kDebug(); - if (constraints & Plasma::SizeConstraint && m_tasksLayout) { - m_tasksLayout->layoutItems(); - } - - if (constraints & Plasma::FormFactorConstraint && m_tasksLayout) { - m_tasksLayout->setOrientation(m_applet->formFactor()); - if (m_dropIndicator) { - m_dropIndicator->setOrientation(Plasma::Vertical == m_applet->formFactor() ? Qt::Vertical : Qt::Horizontal); - } - } -} - -void TaskGroupItem::relayoutItems() -{ - if (m_tasksLayout) { - m_tasksLayout->layoutItems(); - } -} - -TaskItemLayout *TaskGroupItem::tasksLayout() -{ - if (!m_tasksLayout) { - m_tasksLayout = new TaskItemLayout(this, m_applet); - m_tasksLayout->setMaximumRows(m_maximumRows); - m_tasksLayout->setForceRows(false); // m_forceRows); - m_tasksLayout->setOrientation(m_applet->formFactor()); - } - - return m_tasksLayout; -} - -void TaskGroupItem::collapse() -{ - //kDebug() << (int)this; - if (collapsed()) { - //kDebug() << "already collapsed"; - return; - } - - m_mainLayout->removeItem(tasksLayout()); - if (m_offscreenLayout) { - m_offscreenLayout->addItem(tasksLayout()); - } else { - foreach (AbstractTaskItem * member, m_groupMembers) { - scene()->removeItem(member); - } - } - - //kDebug(); - //delete m_tasksLayout; - disconnect(m_applet, SIGNAL(constraintsChanged(Plasma::Constraints)), this, SLOT(constraintsChanged(Plasma::Constraints))); - m_collapsed = true; - updatePreferredSize(); - //kDebug(); - emit changed(); - checkSettings(); -} - -bool TaskGroupItem::collapsed() const -{ - return m_collapsed; -} - -void TaskGroupItem::toCurrentDesktop() -{ - if (!isRootGroup()) { - foreach (AbstractTaskItem * member, m_groupMembers) { - member->toCurrentDesktop(); - } - } -} - -void TaskGroupItem::updatePreferredSize() -{ - if (m_collapsed) { - foreach (AbstractTaskItem * taskItem, m_groupMembers) { - taskItem->setPreferredOffscreenSize(); - } - - //FIXME: copypaste from abstracttaskitem: to be done better with proper sizeHint() - setPreferredSize(basicPreferredSize()); - } else { - foreach (AbstractTaskItem * taskItem, m_groupMembers) { - taskItem->setPreferredOnscreenSize(); - } - - layout()->invalidate(); - setPreferredSize(layout()->preferredSize()); - //kDebug() << "expanded group" << layout()->preferredSize(); - } - - //kDebug() << preferredSize(); - emit sizeHintChanged(Qt::PreferredSize); -} - -AbstractTaskItem *TaskGroupItem::directMember(AbstractTaskItem *item) -{ - Q_ASSERT(item); - Q_ASSERT(m_group); - TaskManager::AbstractGroupableItem * directMember = m_group.data()->directMember(item->abstractItem()); - if (!directMember) { - kDebug() << "Error" << item->abstractItem(); - } - return abstractTaskItem(directMember); -} - -void TaskGroupItem::paint(QPainter *painter, - const QStyleOptionGraphicsItem *option, - QWidget *widget) -{ - if (collapsed()) { - AbstractTaskItem::paint(painter, option, widget); - } -} - -void TaskGroupItem::itemPositionChanged(AbstractGroupableItem * item) -{ - //kDebug(); - if (!m_tasksLayout) { - return; - } - - Q_ASSERT(item); - - AbstractTaskItem *taskItem = abstractTaskItem(item); - - m_tasksLayout->removeTaskItem(taskItem); - - // NOTE: If the grouping strategy is "only when the taskbar is full", - // removing the task from the layout might cause this group to - // split, and so the task might be removed from the group. - // This will cause deleteLater() to be called on taskItem, and - // we are in danger of inserting a pointer that will soon be - // invalid into the layout. So check that the task item is - // still in the group. - taskItem = abstractTaskItem(item); - if (m_group && taskItem) { - m_tasksLayout->insert(m_group.data()->members().indexOf(item), taskItem); - } -} - - -void TaskGroupItem::dragEnterEvent(QGraphicsSceneDragDropEvent *event) -{ - bool shouldIgnore = shouldIgnoreDragEvent(event); - if ((collapsed() && shouldIgnore) || (isRootGroup() && !shouldIgnore)) { - event->ignore(); - //kDebug()<<"Drag enter accepted"; - } else { - event->accept(); - if (!m_popupMenuTimer) { - m_popupMenuTimer = new QTimer(this); - m_popupMenuTimer->setSingleShot(true); - m_popupMenuTimer->setInterval(500); - connect(m_popupMenuTimer, SIGNAL(timeout()), this, SLOT(popupMenu())); - } - m_popupMenuTimer->start(); - } -} - -void TaskGroupItem::dragLeaveEvent(QGraphicsSceneDragDropEvent *) -{ - if (m_popupMenuTimer) { - m_popupMenuTimer->stop(); - } - - if (m_dropIndicator && m_dropIndicator->isVisible()) { - m_dropIndicator->setVisible(false); - } -} - -void TaskGroupItem::dragMoveEvent(QGraphicsSceneDragDropEvent *event) -{ - if (isRootGroup()) { - //#ifndef ICON_TASKS_SHOW_DROP_INDICATOR_FOR_MOVE - int sourceIndex = event->mimeData()->property("icontasks-item-ptr").isValid() - ? m_applet->rootGroupItem()->indexOf((AbstractTaskItem *)(event->mimeData()->property("icontasks-item-ptr").toULongLong()), false) - : -1; - //#else - //int sourceIndex = event->mimeData()->property("icontasks-item-index").isValid() ? event->mimeData()->property("icontasks-item-index").toInt() : -1; - //#endif - bool isDesktopFile = -1 == sourceIndex && event->mimeData()->hasFormat("text/uri-list"); - bool isLauncher = isDesktopFile || (-1 != sourceIndex && sourceIndex < m_applet->groupManager().launcherCount()); - - if (isLauncher && m_applet->groupManager().launchersLocked()) { - return; - } - - if (sourceIndex > -1 || isDesktopFile) { - TaskItemLayout::Insert destIndex = m_tasksLayout->insertionIndexAt(event->pos()); - bool visible = destIndex.index != sourceIndex && destIndex.index >= 0 && (destIndex.geom.x() > 0 || destIndex.geom.y() > 0 || 0 == destIndex.index); - bool moveRight = sourceIndex > -1 && destIndex.index > sourceIndex; - -// qDebug() << event->pos() << sourceIndex << destIndex.index << destIndex.geom; - if (visible && ((isLauncher && destIndex.index - (moveRight ? 1 : 0) < m_applet->groupManager().launcherCount()) || - (!isLauncher && destIndex.index - (moveRight ? 1 : 0) >= m_applet->groupManager().launcherCount()))) { - //#ifndef ICON_TASKS_SHOW_DROP_INDICATOR_FOR_MOVE - if (!isDesktopFile) { - dropEvent(event); - return; - } - //#endif - - if (!m_dropIndicator) { - m_dropIndicator = new DropIndicator(parentItem()); - m_dropIndicator->setOrientation(Plasma::Vertical == m_applet->formFactor() ? Qt::Vertical : Qt::Horizontal); - m_dropIndicator->setVisible(false); - } - - if (!m_dropIndicator->isVisible()) { - m_dropIndicator->setSize((Plasma::Vertical == m_applet->formFactor() ? destIndex.geom.height() : destIndex.geom.width()) / 3.0); - } - - m_dropIndicator->setPosition(QRectF(mapToParent(destIndex.geom.topLeft()), destIndex.geom.size())); - return; - } - } - - if (m_dropIndicator && m_dropIndicator->isVisible()) { - m_dropIndicator->setVisible(false); - } - } -} - -AbstractTaskItem *TaskGroupItem::taskItemForWId(WId id) -{ - QHashIterator it(m_groupMembers); - - while (it.hasNext()) { - it.next(); - AbstractTaskItem *item = it.value(); - TaskGroupItem *group = qobject_cast(item); - - if (group) { - item = group->taskItemForWId(id); - if (item) { - return item; - } - } else { - TaskManager::TaskItem *task = qobject_cast(it.key()); - if (task && task->task() && task->task()->window() == id) { - return item; - } - } - } - - return 0; -} - -static QString agiName(TaskManager::AbstractGroupableItem *i) -{ - if (i->itemType() == TaskManager::TaskItemType && !i->isStartupItem()) { - return static_cast(i)->taskName().toLower(); - } else { - return i->name().toLower(); - } -} - -AbstractTaskItem *TaskGroupItem::matchingItem(TaskManager::AbstractGroupableItem *from) -{ - QHashIterator it(m_groupMembers); - AbstractTaskItem *itm = 0L; - QString n = agiName(from); - KUrl launcherUrl = from->launcherUrl(); - - while (it.hasNext()) { - it.next(); - AbstractGroupableItem *item = it.key(); - AbstractTaskItem *taskItem = it.value(); - QString name = agiName(item); - - if ((name == n || (!launcherUrl.isEmpty() && item->launcherUrl() == launcherUrl)) && - (qobject_cast(taskItem) || !taskItem->busyWidget())) { - itm = taskItem; - } - } - - return itm; -} - -void TaskGroupItem::dropEvent(QGraphicsSceneDragDropEvent *event) -{ - if (m_dropIndicator && m_dropIndicator->isVisible()) { - m_dropIndicator->setVisible(false); - } - - //kDebug() << "TaskItemLayout dropEvent"; - if (event->mimeData()->hasFormat(TaskManager::Task::mimetype()) || - event->mimeData()->hasFormat(TaskManager::Task::groupMimetype())) { - bool ok; - QList ids = TaskManager::Task::idsFromMimeData(event->mimeData(), &ok); - - if (!ok) { - //kDebug() << "FAIL!"; - event->ignore(); - return; - } - - AbstractTaskItem *targetTask = dynamic_cast(scene()->itemAt(mapToScene(event->pos()))); - // kDebug() << "Pos: " << event->pos() << mapToScene(event->pos()) << "item" << scene()->itemAt(mapToScene(event->pos())) << "target Task " << dynamic_cast(targetTask); - - //kDebug() << "got" << ids.count() << "windows"; - foreach (WId id, ids) { - handleDroppedId(id, targetTask, event); - } - - //kDebug() << "TaskItemLayout dropEvent done"; - event->acceptProposedAction(); - } else if (!m_applet->groupManager().launchersLocked() && event->mimeData()->hasFormat("text/uri-list")) { - KUrl::List urls = KUrl::List::fromMimeData(event->mimeData()); - foreach (const KUrl & url, urls) { - const bool exists = m_applet->groupManager().launcherExists(url); - if (exists) { - // it exists; if we are doing manual sorting, make sure it is in the right location if - // it is in this group .. otherwise, we can do nothing. - if (m_applet->groupManager().sortingStrategy() == TaskManager::GroupManager::ManualSorting) { - QHashIterator it(m_groupMembers); - while (it.hasNext()) { - it.next(); - if (it.key()->itemType() == TaskManager::LauncherItemType && - it.key()->launcherUrl() == url) { - layoutTaskItem(it.value(), event->pos()); - break; - } - } - } - } else { - m_applet->groupManager().addLauncher(url, QIcon(), QString(), QString(), QString(), m_tasksLayout->insertionIndexAt(event->pos()).index); - } - } - } else { - event->ignore(); - } -} - -void TaskGroupItem::handleDroppedId(WId id, AbstractTaskItem *, QGraphicsSceneDragDropEvent *event) -{ - AbstractTaskItem *taskItem = m_applet->rootGroupItem()->taskItemForWId(id); - - if (!taskItem) { - //kDebug() << "Invalid TaskItem"; - return; - } - - if (!taskItem->parentGroup()) { - //kDebug() << "group invalid"; - return; - } - - TaskManager::GroupPtr group = taskItem->parentGroup()->group(); - - //kDebug() << id << taskItem->text() << (QObject*)targetTask; - - // kDebug() << "first item: " << dynamic_cast(m_taskItems.first()) << "layout widget" << dynamic_cast(this); - if (m_applet->groupManager().sortingStrategy() == TaskManager::GroupManager::ManualSorting) { - //Move action - if (group == m_group.data()) { //same group - //kDebug() << "Drag within group"; - layoutTaskItem(taskItem, event->pos()); - } else if (m_group) { //task item was dragged outside of group -> group move - AbstractTaskItem *directMember = abstractTaskItem(m_group.data()->directMember(group)); - if (directMember) { - layoutTaskItem(directMember, event->pos()); //we need to get the group right under the receiver group - } - } - } -} - -void TaskGroupItem::layoutTaskItem(AbstractTaskItem* item, const QPointF &pos) -{ - if (!m_tasksLayout || !item->abstractItem()) { - return; - } - - int insertIndex = m_tasksLayout->insertionIndexAt(pos).index; - // kDebug() << "Item inserting at: " << insertIndex << "of: " << numberOfItems(); - m_applet->groupManager().manualSortingRequest(item->abstractItem(), insertIndex); -} - - -void TaskGroupItem::updateActive(AbstractTaskItem *task) -{ - if (!m_tasksLayout) { - return; - } - - m_activeTaskIndex = indexOf(task); -} - -int TaskGroupItem::indexOf(AbstractTaskItem *task, bool descendGroups) -{ - if (!m_group || !task) { - //kDebug() << "Error"; - return -1; - } - - int index = 0; - - foreach (AbstractGroupableItem * item, m_group.data()->members()) { - AbstractTaskItem *taskItem = abstractTaskItem(item); - if (!taskItem) { - continue; - } - - if (task == taskItem) { - if (descendGroups) { - TaskGroupItem *groupItem = qobject_cast(taskItem); - if (groupItem) { - int subIndex = groupItem->indexOf(groupItem->activeSubTask()); - if (subIndex == -1) { - index += groupItem->count(); - } else { - return index + subIndex; - } - } - } - - return index; - } - - if (descendGroups) { - TaskGroupItem *groupItem = qobject_cast(taskItem); - if (groupItem) { - int subIndex = groupItem->indexOf(task); - if (subIndex == -1) { - index += groupItem->count(); - } else { - return index + subIndex; - } - } else { - ++index; - } - } else { - ++index; - } - } - - return -1; -} - -AbstractTaskItem * TaskGroupItem::activeSubTask() -{ - if (!m_group) { - return 0; - } - - foreach (AbstractGroupableItem * item, m_group.data()->members()) { - AbstractTaskItem *taskItem = abstractTaskItem(item); - if (taskItem && taskItem->isActive()) { - TaskGroupItem *groupItem = qobject_cast(taskItem); - if (groupItem) { - return groupItem->activeSubTask(); - } - return taskItem; - } - } - - return 0; -} - -int TaskGroupItem::totalSubTasks() -{ - int count = 0; - - foreach (AbstractGroupableItem * item, group()->members()) { - AbstractTaskItem *taskItem = abstractTaskItem(item); - if (taskItem) { - TaskGroupItem *groupItem = qobject_cast(taskItem); - if (groupItem) { - count += groupItem->count(); - } else if (!qobject_cast(taskItem)) { - count++; - } - } - } - return count; -} - -AbstractTaskItem * TaskGroupItem::selectSubTask(int index) -{ - foreach (AbstractGroupableItem * item, group()->members()) { - AbstractTaskItem *taskItem = abstractTaskItem(item); - if (taskItem) { - TaskGroupItem *groupItem = qobject_cast(taskItem); - if (groupItem) { - if (index < groupItem->count()) { - return groupItem->abstractTaskItem(groupItem->group()->members().at(index)); - } else { - index -= groupItem->count(); - } - } else if (qobject_cast(taskItem)) { - continue; - } else if (index == 0) { - return taskItem; - } else { - --index; - } - } - } - return NULL; -} - -void TaskGroupItem::wheelEvent(QGraphicsSceneWheelEvent *event) -{ - focusSubTask((event->delta() < 0), true); -} - -int TaskGroupItem::maxRows() -{ - return m_maximumRows; -} - -void TaskGroupItem::setMaxRows(int rows) -{ - m_maximumRows = rows; - if (m_tasksLayout) { - m_tasksLayout->setMaximumRows(m_maximumRows); - } -} - -int TaskGroupItem::optimumCapacity() -{ - if (m_tasksLayout) { - return m_tasksLayout->maximumRows() * m_tasksLayout->preferredColumns(); - } - - return 1; -} - -AbstractTaskItem* TaskGroupItem::abstractTaskItem(AbstractGroupableItem * item) -{ - if (!item) { - return 0; - } - - AbstractTaskItem *abstractTaskItem = m_groupMembers.value(item); - if (!abstractTaskItem) { - foreach (AbstractTaskItem * taskItem, m_groupMembers) { - TaskGroupItem *group = qobject_cast(taskItem); - if (group) { - abstractTaskItem = group->abstractTaskItem(item); - if (abstractTaskItem) { - break; - } - } - } - } - - //kDebug() << "item not found"; - return abstractTaskItem; -} - -void TaskGroupItem::setAdditionalMimeData(QMimeData* mimeData) -{ - if (m_group) { - m_group.data()->addMimeData(mimeData); - } -} - -void TaskGroupItem::publishIconGeometry() const -{ - // only do this if we are a collapsed group, with a GroupPtr and members - if (!collapsed() || !m_group || m_groupMembers.isEmpty()) { - return; - } - - QRect rect = iconGeometry(); - publishIconGeometry(rect); -} - -void TaskGroupItem::publishIconGeometry(const QRect &rect) const -{ - foreach (AbstractTaskItem * item, m_groupMembers) { - WindowTaskItem *windowItem = qobject_cast(item); - if (windowItem) { - windowItem->publishIconGeometry(rect); - continue; - } - - TaskGroupItem *groupItem = qobject_cast(item); - if (groupItem) { - groupItem->publishIconGeometry(rect); - } - } -} - -QWidget *TaskGroupItem::popupDialog() const -{ - return m_popupDialog; -} - -#include "moc_taskgroupitem.cpp" - diff --git a/kdeplasma-addons/applets/icontasks/taskgroupitem.h b/kdeplasma-addons/applets/icontasks/taskgroupitem.h deleted file mode 100644 index 9e61c3c5..00000000 --- a/kdeplasma-addons/applets/icontasks/taskgroupitem.h +++ /dev/null @@ -1,209 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2007 by Robert Knight * - * Copyright (C) 2008 by Alexis Ménard * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * - ***************************************************************************/ - - -#ifndef TASKGROUPITEM_H -#define TASKGROUPITEM_H - -#include "abstracttaskitem.h" -#include "windowtaskitem.h" -// Own -#include "taskmanager/taskmanager.h" -#include "tasks.h" -#include -#include - -using TaskManager::TaskGroup; -using TaskManager::GroupPtr; -using TaskManager::TaskItem; -using TaskManager::AbstractGroupableItem; - -class TaskItemLayout; -class DropIndicator; -#include - -namespace Plasma -{ -class Dialog; -} -typedef QMap Order; - -/** - * A task item for a TaskGroup. It can be displayed collapsed as single item or expanded as group. - */ -class TaskGroupItem : public AbstractTaskItem -{ - Q_OBJECT - -public: - /** Constructs a new representation for a taskgroup. */ - TaskGroupItem(QGraphicsWidget *parent, Tasks *applet); - virtual ~TaskGroupItem(); - - /** Sets the group represented by this task. */ - void setGroup(TaskManager::GroupPtr); - - /** Returns the group represented by this task. */ - TaskManager::GroupPtr group() const; - - virtual void close(); - - QHash members() const; - int count() const; - AbstractTaskItem * activeSubTask(); - - virtual bool isWindowItem() const; - virtual bool isActive() const; - bool windowPreviewOpen() const; - QString appName() const; - KUrl launcherUrl() const; - QString windowClass() const; - bool collapsed() const; - virtual void toCurrentDesktop(); - - /** Returns Direct Member group if the passed item is in a subgroup */ - AbstractTaskItem *directMember(AbstractTaskItem *); - - /** Maximum number of Rows the group will have */ - int maxRows(); - void setMaxRows(int); - - TaskItemLayout *tasksLayout(); - - int indexOf(AbstractTaskItem *task, bool descendGroups = true); - - int optimumCapacity(); - - AbstractTaskItem* abstractTaskItem(AbstractGroupableItem *); - - void setAdditionalMimeData(QMimeData* mimeData); - void publishIconGeometry() const; - void publishIconGeometry(const QRect &rect) const; - QWidget *popupDialog() const; - AbstractTaskItem *taskItemForWId(WId id); - AbstractTaskItem *matchingItem(TaskManager::AbstractGroupableItem *from); - -private: - void close(bool hide); - -signals: - /** Emitted when a window is selected for activation, minimization, iconification */ - void groupSelected(TaskGroupItem *); - void sizeHintChanged(Qt::SizeHint); - /** informs the parent group about changes */ - void changed(); - -public slots: - virtual void activate(); - - /** Reload all tasks */ - void reload(); - - void expand(); - void collapse(); - void updatePreferredSize(); - void clearGroup(); - bool isRootGroup() const; - -public slots: - void updateActive(AbstractTaskItem *); - void relayoutItems(); - -protected: - void activateOrIconify(); - void contextMenuEvent(QGraphicsSceneContextMenuEvent *event); - void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); - - void dragEnterEvent(QGraphicsSceneDragDropEvent *event); - void dragLeaveEvent(QGraphicsSceneDragDropEvent *event); - void dragMoveEvent(QGraphicsSceneDragDropEvent *event); - void dropEvent(QGraphicsSceneDragDropEvent *event); - bool focusNextPrevChild(bool next); - - void handleDroppedId(WId id, AbstractTaskItem *targetTask, QGraphicsSceneDragDropEvent *event); - - void mousePressEvent(QGraphicsSceneMouseEvent *event); - void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); - void mouseMoveEvent(QGraphicsSceneMouseEvent *event); - void resizeEvent(QGraphicsSceneResizeEvent *event); - - void updateToolTip(); - -protected slots: - virtual void wheelEvent(QGraphicsSceneWheelEvent *event); - -private Q_SLOTS: - void checkUpdates(); - void constraintsChanged(Plasma::Constraints); - void handleActiveWindowChanged(WId id); - - void updateTask(::TaskManager::TaskChanges changes); - - /** Stay informed about changes in group */ - void itemAdded(AbstractGroupableItem *); - void itemRemoved(AbstractGroupableItem *); - - /** Update to new position*/ - void itemPositionChanged(AbstractGroupableItem *); - - void popupMenu(); - /** force a relayout of all items */ - void popupVisibilityChanged(bool visible); - -private: - AbstractTaskItem* createAbstractItem(AbstractGroupableItem * groupableItem); - TaskGroupItem* createNewGroup(QList members); - WindowTaskItem * createWindowTask(TaskManager::TaskItem* task); - TaskGroupItem * createTaskGroup(GroupPtr); - WindowTaskItem *createStartingTask(TaskManager::TaskItem* task); - - void removeItem(AbstractTaskItem *item); - - void layoutTaskItem(AbstractTaskItem* item, const QPointF &pos); - void setSplitIndex(int position); - - QIcon m_icon; - - int totalSubTasks(); - bool focusSubTask(bool next, bool activate); - AbstractTaskItem * selectSubTask(int index); - - QWeakPointer m_group; - - QHash m_groupMembers; - - TaskItemLayout *m_tasksLayout; - QTimer *m_popupMenuTimer; - QHash m_taskOrder; - int m_lastActivated; - int m_activeTaskIndex; - int m_maximumRows; - QGraphicsWidget *m_offscreenWidget; - QGraphicsLinearLayout *m_offscreenLayout; - bool m_collapsed; - QGraphicsLinearLayout *m_mainLayout; - Plasma::Dialog *m_popupDialog; - QTimer *m_updateTimer; - TaskManager::TaskChanges m_changes; - - DropIndicator *m_dropIndicator; -}; - -#endif diff --git a/kdeplasma-addons/applets/icontasks/taskitemlayout.cpp b/kdeplasma-addons/applets/icontasks/taskitemlayout.cpp deleted file mode 100644 index 0da6a735..00000000 --- a/kdeplasma-addons/applets/icontasks/taskitemlayout.cpp +++ /dev/null @@ -1,635 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2008 by Christian Mollekopf chrigi_1@fastmail.fm * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * - ***************************************************************************/ - -#include "taskitemlayout.h" - -//Taskmanager -#include "taskmanager/taskmanager.h" -#include "taskmanager/abstractgroupableitem.h" -#include "taskmanager/groupmanager.h" - -// Qt -#include -#include - -// KDE -#include - -#include - -#include "windowtaskitem.h" -#include "taskgroupitem.h" - -class LauncherSeparator : public QGraphicsWidget -{ -public: - - LauncherSeparator(QGraphicsItem *parent = 0, Qt::WindowFlags wFlags = 0) - : QGraphicsWidget(parent, wFlags) { - m_svg = new Plasma::Svg(); - m_svg->setImagePath("icontasks/launcherseparator"); - m_svg->setContainsMultipleImages(true); - setOrientation(Qt::Horizontal); - } - - ~LauncherSeparator() { - delete m_svg; - } - - void setOrientation(Qt::Orientation orientation) { - m_orientation = orientation; - - if (m_orientation == Qt::Vertical) { - setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); - } else { - setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding); - } - } - - Qt::Orientation orientation() { - return m_orientation; - } - - void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { - Q_UNUSED(option); - Q_UNUSED(widget); - - if (m_svg) { - if (m_orientation == Qt::Horizontal) { - m_svg->paint(painter, boundingRect(), "horizontal-separator"); - } else { - m_svg->paint(painter, boundingRect(), "vertical-separator"); - } - } - } - - QSizeF sizeHint(Qt::SizeHint which, const QSizeF & constraint) const { - QSizeF hint = QGraphicsWidget::sizeHint(which, constraint); - - if (m_orientation == Qt::Horizontal) { - hint.setWidth(m_svg->elementSize("horizontal-separator").width()); - } else { - hint.setHeight(m_svg->elementSize("vertical-separator").height()); - } - - return hint; - } - -private: - Plasma::Svg *m_svg; - Qt::Orientation m_orientation; -}; - -TaskItemLayout::TaskItemLayout(TaskGroupItem *parent, Tasks *applet) - : QGraphicsGridLayout(0), - m_groupItem(parent), - m_rowSize(1), - m_maxRows(1), - m_forceRows(false), - m_applet(applet), - m_layoutOrientation(Qt::Horizontal), - m_separator(parent->isRootGroup() ? new LauncherSeparator(parent) : 0L) -{ - setContentsMargins(0, 0, 0, 0); - setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); - setMaximumSize(INT_MAX, INT_MAX); - //kDebug(); - foreach (AbstractTaskItem * item, m_groupItem->members()) { - addTaskItem(item); - } - - if (parent->isRootGroup()) { - connect(&m_applet->groupManager(), SIGNAL(launchersChanged()), SLOT(layoutItems())); - } -} - -TaskItemLayout::~TaskItemLayout() -{ -} - -void TaskItemLayout::setOrientation(Plasma::FormFactor orientation) -{ - Qt::Orientation oldOrientation = m_layoutOrientation; - - if (orientation == Plasma::Vertical) { - m_layoutOrientation = Qt::Vertical; - } else { - m_layoutOrientation = Qt::Horizontal; - } - - if (m_separator) { - m_separator->setOrientation(m_layoutOrientation); - } - - if (m_layoutOrientation != oldOrientation) { - layoutItems(); - } -} - -bool TaskItemLayout::separatorVisible() const -{ - return m_separator && m_separator->isVisible(); -} - -void TaskItemLayout::addTaskItem(AbstractTaskItem * item) -{ - //kDebug(); - if (!item) { - return; - } - - if (item->isStartupWithTask()) { - return; - } - - if (m_itemPositions.contains(item)) { - //kDebug() << "already in this layout"; - return; - } - - if (m_groupItem->scene() && !item->scene()) { - //kDebug() << "layout widget got scene"<scene()<< "add item to scene" <scene(); - m_groupItem->scene()->addItem(item); - //kDebug() << "itemScene" << item->scene(); - } - - if (!insert(m_groupItem->indexOf(item, false), item)) { - return; - } - - item->show(); - //kDebug() << "end"; -} - -void TaskItemLayout::removeTaskItem(AbstractTaskItem *item) -{ - if (!remove(item)) { - return; - } - - //kDebug(); - - if (m_groupItem->scene()) { - //kDebug() << "got scene"; - m_groupItem->scene()->removeItem(item); - } else { - kDebug() << "No Scene available"; - } - //kDebug() << "done"; -} - -bool TaskItemLayout::insert(int index, AbstractTaskItem *item) -{ - //kDebug() << item->text() << index; - if (!item) { - kDebug() << "error"; - return false; - } - - int listIndex; - for (listIndex = 0; listIndex < m_itemPositions.size(); listIndex++) { - if (index <= m_groupItem->indexOf(m_itemPositions.at(listIndex), false)) { - break; - } - } - - if (m_itemPositions.removeAll(item) == 0) { - connect(item, SIGNAL(destroyed(AbstractTaskItem*)), this, SLOT(remove(AbstractTaskItem*))); - } - - m_itemPositions.insert(listIndex, item); - - layoutItems(); - return true; -} - -bool TaskItemLayout::remove(AbstractTaskItem* item) -{ - if (!item) { - kDebug() << "null Item"; - layoutItems(); - return false; - } - - disconnect(item, 0, this, 0); - m_itemPositions.removeAll(item); - layoutItems(); - return true; -} - - -/** size including expanded groups*/ -int TaskItemLayout::size() -{ - int groupSize = 0; - - foreach (AbstractTaskItem * item, m_groupItem->members()) { - if (!item->abstractItem()) { - // this item is a startup task or the task no longer exists - kDebug() << "Error, invalid item in groupMembers"; - continue; - } - - if (item->abstractItem()->itemType() == TaskManager::GroupItemType) { - TaskGroupItem *group = qobject_cast(item); - if (!group->collapsed()) { - TaskItemLayout *layout = qobject_cast(group->tasksLayout()); - if (!layout) { - kDebug() << "Error group has no layout"; - continue; - } - - // increase number of items since expanded groups occupy several spaces - groupSize += layout->size(); - continue; - } - } - - ++groupSize; - } - - //kDebug() << "group size" << groupSize; - return groupSize; -} - -//return maximum colums set by the user unless the setting is to high and the items would get unusable -int TaskItemLayout::maximumRows() -{ - int maxRows; - if (m_itemPositions.isEmpty()) { - return 1; - } - - if (m_forceRows) { - return m_maxRows; - } - - // in this case rows are columns, columns are rows... - //TODO basicPreferredSize isn't the optimal source here because it changes because of margins probably - QSizeF itemSize = m_itemPositions.first()->basicPreferredSize(); - if (m_layoutOrientation == Qt::Vertical) { - maxRows = qMin(qMax(1, int(m_groupItem->geometry().width() / itemSize.width())), m_maxRows); - } else { - maxRows = qMin(qMax(1, int(m_groupItem->geometry().height() / itemSize.height())), m_maxRows); - } - - //kDebug() << "maximum rows: " << maxRows << m_maxRows << m_groupItem->geometry().height() << itemSize.height(); - return maxRows; -} - -//returns a reasonable amount of columns -int TaskItemLayout::preferredColumns() -{ - if (m_forceRows) { - m_rowSize = 1; - } else { - if (m_itemPositions.isEmpty()) { - return 1; - } - - //TODO basicPreferredSize isn't the optimal source here because it changes because of margins probably - QSizeF itemSize = m_itemPositions.first()->basicPreferredSize(); - //kDebug() << itemSize.width() << m_groupItem->geometry().width(); - if (m_layoutOrientation == Qt::Vertical) { - m_rowSize = qMax(1, int(m_groupItem->geometry().height() / itemSize.height())); - } else { - //Launchers doesn't need the same space as task- and groupitems on horizontal Layouts so the size needs to be adjusted - qreal horizontalSpace = m_groupItem->geometry().width(); - m_rowSize = qMax(1, int(horizontalSpace / itemSize.width())); - } - } - //kDebug() << "preferred columns: " << qMax(1, m_rowSize); - return qMax(1, m_rowSize); -} - -// -QPair TaskItemLayout::gridLayoutSize() -{ - int groupSize = size(); - //the basic settings - int columns = preferredColumns(); - int maxRows = maximumRows(); - - //check for adjustments on columns because there isnt room enough yet for all of the items - while (ceil(static_cast(groupSize) / static_cast(columns)) > maxRows) { - columns++; // more rows needed than allowed so we add some columns instead - } - //kDebug() << "groupWidth" << columns << maxRows << m_maxRows; - int rows; - if (m_forceRows) { - rows = maxRows; - } else { - rows = ceil(static_cast(groupSize) / static_cast(columns)); //actually needed rows - } - - return QPair(columns, rows); -} - - -void TaskItemLayout::layoutItems() -{ - //kDebug(); - - QPair grid = gridLayoutSize(); - int columns = qMax(grid.first, 1); - - //FIXME: resetting column preferred sizesthey shouldn't be taken into account for inexistent ones but they are, probably upstream issue - for (int i = 0; i < columnCount(); ++i) { - setColumnMaximumWidth(i, 0); - setColumnPreferredWidth(i, 0); - } - - for (int i = 0; i < rowCount(); ++i) { - setRowMaximumHeight(i, 0); - setRowPreferredHeight(i, 0); - } - - //clearLayout - if (m_separator) { - m_separator->setVisible(false); - } - while (count()) { - removeAt(0); - } - - QRectF groupRect(m_groupItem->boundingRect()); - qreal cellSize(qMin(m_applet->launcherIcons() || !m_applet->autoIconScaling() ? qreal(272) : qreal(80), qMin(groupRect.width(), groupRect.height()))); - QSizeF maximumCellSize(cellSize, cellSize); - - setHorizontalSpacing(m_applet->spacing()); - setVerticalSpacing(m_applet->spacing()); - - //go through all items of this layoutwidget and populate the layout with items - int numberOfItems = 0; - foreach (AbstractTaskItem * item, m_itemPositions) { - int row; - int col; - if (m_layoutOrientation == Qt::Vertical) { - row = numberOfItems % columns; - col = numberOfItems / columns; - } else { - row = numberOfItems / columns; - col = numberOfItems % columns; - } - - if (m_separator && 1 == m_maxRows && Tasks::Sep_Never != m_applet->showSeparator() && - TaskManager::GroupManager::ManualSorting == m_applet->groupManager().sortingStrategy() && - m_applet->groupManager().launcherCount() && numberOfItems >= m_applet->groupManager().launcherCount() && - !m_separator->isVisible()) { - - // If a group associated with a launcher is split, then there will be more entries than launchers! - // So, we need to check if this item is associated with a launcher... - if (!(item->abstractItem() && m_applet->groupManager().isItemAssociatedWithLauncher(item->abstractItem()))) { - addItem(m_separator, row, col, 1, 1); - m_separator->setVisible(true); - numberOfItems++; - if (m_layoutOrientation == Qt::Vertical) { - row = numberOfItems % columns; - col = numberOfItems / columns; - } else { - row = numberOfItems / columns; - col = numberOfItems % columns; - } - } - } - //not good if we don't recreate the layout every time - //m_layout->setColumnPreferredWidth(col, columnWidth);//Somehow this line is absolutely crucial - //m_layout->setRowPreferredHeight(row, rowHeight);//Somehow this line is absolutely crucial - - - //FIXME: this is a glorious hack - if (maximumCellSize.isValid()) { - if (m_layoutOrientation == Qt::Vertical) { - setRowMaximumHeight(row, maximumCellSize.height()); - setColumnMaximumWidth(col, QWIDGETSIZE_MAX); - } else { - setColumnMaximumWidth(col, maximumCellSize.width()); - setRowMaximumHeight(row, QWIDGETSIZE_MAX); - } - setRowPreferredHeight(row, maximumCellSize.height()); - setColumnPreferredWidth(col, maximumCellSize.width()); - } - - if (item->abstractItem() && - item->abstractItem()->itemType() == TaskManager::GroupItemType) { - - TaskGroupItem *group = static_cast(item); - if (group->collapsed()) { -// group->unsplitGroup(); - addItem(item, row, col, 1, 1); - numberOfItems++; - } else { - TaskItemLayout *layout = group->tasksLayout(); - if (!layout) { - kDebug() << "group has no valid layout"; - continue; - } - - int groupRowWidth = m_layoutOrientation == Qt::Vertical ? layout->numberOfRows() : layout->numberOfColumns(); - - if ((columns - col) < groupRowWidth) { - //we need to split the group - int splitIndex = columns - col;//number of items in group that are on this row - if (m_layoutOrientation == Qt::Vertical) { - addItem(item, row, col, splitIndex, 1); - } else { - addItem(item, row, col, 1, splitIndex); - } - - } else { - if (m_layoutOrientation == Qt::Vertical) { - addItem(item, row, col, groupRowWidth, 1); - } else { - addItem(item, row, col, 1, groupRowWidth); - } - } - - numberOfItems += groupRowWidth; - } - } else { - addItem(item, row, col, 1, 1); - numberOfItems++; - } - - //kDebug() << "addItem at: " << row << col; - } - - if (m_separator && 1 == m_maxRows && Tasks::Sep_Always == m_applet->showSeparator() && !m_separator->isVisible() && - TaskManager::GroupManager::ManualSorting == m_applet->groupManager().sortingStrategy() && - m_applet->groupManager().launcherCount()) { - if (m_layoutOrientation == Qt::Vertical) { - addItem(m_separator, numberOfItems % columns, numberOfItems / columns, 1, 1); - } else { - addItem(m_separator, numberOfItems / columns, numberOfItems % columns, 1, 1); - } - m_separator->setVisible(true); - } - - updatePreferredSize(); - //m_groupItem->setLayout(m_layout); -} - - -void TaskItemLayout::updatePreferredSize() -{ - //kDebug() << "column count: " << m_layout->columnCount(); - bool haveSep = m_separator && m_separator->isVisible(); - - if (count() > (haveSep ? 1 : 0)) { - bool vertical = m_layoutOrientation == Qt::Vertical; - QSizeF s = itemAt(0)->preferredSize(); - QSizeF sepSize = m_separator && m_separator->isVisible() - ? QSizeF(vertical - ? 0 : m_separator->preferredSize().width(), - vertical - ? m_separator->preferredSize().height() : 0) - : QSizeF(0, 0); - //kDebug() << s << columnCount(); - setPreferredSize((s.width() * (columnCount() - (!vertical && haveSep ? 1 : 0))) + sepSize.width(), - (s.height() * (rowCount() - (vertical && haveSep ? 1 : 0))) + sepSize.height()); - } else { - //Empty taskbar, arbitrary small value - kDebug() << "Empty layout!!!!!!!!!!!!!!!!!!"; - if (m_layoutOrientation == Qt::Vertical) { - setPreferredSize(/*m_layout->preferredSize().width()*/10, 10); //since we recreate the layout we don't have the previous values - } else { - setPreferredSize(10, /*m_layout->preferredSize().height()*/10); - } - } - //kDebug() << "preferred size: " << m_layout->preferredSize(); - m_groupItem->updatePreferredSize(); -} - -void TaskItemLayout::setMaximumRows(int rows) -{ - if (rows != m_maxRows) { - m_maxRows = rows; - layoutItems(); - } -} - -void TaskItemLayout::setForceRows(bool forceRows) -{ - m_forceRows = forceRows; -} - -TaskItemLayout::Insert TaskItemLayout::insertionIndexAt(const QPointF &pos) -{ - Insert insert; - int nRows = numberOfRows(); - int nCols = numberOfColumns(); - int row = nRows; - int col = nCols; - bool vertical = Qt::Vertical == m_layoutOrientation; - - insert.index = -1; - - //if pos is (-1,-1) insert at the end of the panel - if (pos.toPoint() == QPoint(-1, -1)) { - kDebug() << "Error"; - return insert; - } else { - QRectF siblingGeometry; - int border = 1 + (m_applet->spacing() / 2.0); - - //get correct row - for (int i = 0; i < nRows; i++) { - if (vertical) { - siblingGeometry = itemAt(0, i)->geometry();//set geometry of single item - if (pos.x() <= (siblingGeometry.right() + border)) { - row = i; - break; - } - } else { - siblingGeometry = itemAt(i, 0)->geometry();//set geometry of single item - if (pos.y() <= (siblingGeometry.bottom() + border)) { - row = i; - break; - } - } - } - - //and column - for (int i = 0; i < nCols; i++) { - if (vertical) { - siblingGeometry = itemAt(i, 0)->geometry();//set geometry of single item - qreal vertMiddle = (siblingGeometry.top() + siblingGeometry.bottom()) / 2.0; - if (pos.y() < vertMiddle) { - col = i; - break; - } - - } else if (itemAt(0, i)) { - siblingGeometry = itemAt(0, i)->geometry();//set geometry of single item - qreal horizMiddle = (siblingGeometry.left() + siblingGeometry.right()) / 2.0; - if (pos.x() < horizMiddle) { - col = i; - break; - } - } - } - } - - insert.index = row * nCols + col; - - // Calculate geometry - used for drop indicator... - if (nCols > 0 && nRows > 0) { - int rowAdjust = row >= nRows ? 1 : 0; - int colAdjust = col >= nCols ? 1 : 0; - QGraphicsLayoutItem *item = itemAt(vertical ? (col - colAdjust) : (row - rowAdjust), vertical ? (row - rowAdjust) : (col - colAdjust)); - - if (item) { - insert.geom = item->geometry(); - if ((rowAdjust && vertical) || (colAdjust && !vertical)) { - insert.geom.adjust(insert.geom.width(), 0, insert.geom.width(), 0); - } - if ((rowAdjust && !vertical) || (colAdjust && vertical)) { - insert.geom.adjust(0, insert.geom.height(), 0, insert.geom.height()); - } - } - } - - if (separatorVisible() && insert.index > m_applet->groupManager().launcherCount()) { - insert.index--; - } - - //kDebug() << "insert Index" << insertIndex; - return insert; -} - -int TaskItemLayout::numberOfRows() -{ - if (m_layoutOrientation == Qt::Vertical) { - return columnCount(); - } else { - return rowCount(); - } -} - -int TaskItemLayout::numberOfColumns() -{ - if (m_layoutOrientation == Qt::Vertical) { - return rowCount(); - } else { - return columnCount(); - } -} - -#include "moc_taskitemlayout.cpp" - diff --git a/kdeplasma-addons/applets/icontasks/taskitemlayout.h b/kdeplasma-addons/applets/icontasks/taskitemlayout.h deleted file mode 100644 index 64142e1e..00000000 --- a/kdeplasma-addons/applets/icontasks/taskitemlayout.h +++ /dev/null @@ -1,110 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2008 by Christian Mollekopf chrigi_1@fastmail.fm * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * - ***************************************************************************/ - - -#ifndef TASKITEMLAYOUT_H -#define TASKITEMLAYOUT_H - -//Own -#include "tasks.h" - -// Qt -#include -#include - -class TaskGroupItem; -class AbstractTaskItem; -class LauncherSeparator; - -/** - * A Layout for the expanded group - */ -class TaskItemLayout : public QObject, public QGraphicsGridLayout -{ - Q_OBJECT - -public: - struct Insert { - int index; - QRectF geom; - }; - - TaskItemLayout(TaskGroupItem * parent, Tasks *applet); - ~TaskItemLayout(); - /** insert the item on the index in TaskGroupItem::getMemberList */ - void addTaskItem(AbstractTaskItem*); - void removeTaskItem(AbstractTaskItem*); - /** insert the item on a specific index*/ - bool insert(int index, AbstractTaskItem* item); - - /** returns the insert index for a task drop on pos */ - Insert insertionIndexAt(const QPointF &pos); - /** set the maximum number of rows */ - void setMaximumRows(int); - /** force the layout to use maximumRows setting and fill rows before columns */ - void setForceRows(bool); - - /** the size including expanded groups*/ - int size(); - - /** returns columnCount or rowCount depending on m_applet->formFactor() */ - int numberOfRows(); - /** returns columnCount or rowCount depending on m_applet->formFactor()*/ - int numberOfColumns(); - - /** Returns the preferred number of rows based on the user settings but limited by calculation to honor AbstractGroupableItem::basicPreferredSize()*/ - int maximumRows(); - /** Returns the preferred number of columns calculated on base of AbstractGroupableItem::basicPreferredSize()*/ - int preferredColumns(); - - /** Set the layout Orientation, normally set to formFactor of applet*/ - void setOrientation(Plasma::FormFactor orientation); - - bool separatorVisible() const; - -public Q_SLOTS: - /** Populates the actual QGraphicsGridLayout with items*/ - void layoutItems(); -private: - void adjustStretch(); - void updatePreferredSize(); - -private Q_SLOTS: - bool remove(AbstractTaskItem* item); - -private: - TaskGroupItem *m_groupItem; - QList m_itemPositions; - /** Calculates the number of columns and rows for the layoutItems function and returns */ - QPair gridLayoutSize(); - - /** Limit before row is full, more columns are added if maxRows is exeeded*/ - int m_rowSize; - /** How many rows should be used*/ - int m_maxRows; - - bool m_forceRows; - - Tasks *m_applet; - - Qt::Orientation m_layoutOrientation; - LauncherSeparator *m_separator; -}; - -#endif diff --git a/kdeplasma-addons/applets/icontasks/tasks.cpp b/kdeplasma-addons/applets/icontasks/tasks.cpp deleted file mode 100644 index 111db1d1..00000000 --- a/kdeplasma-addons/applets/icontasks/tasks.cpp +++ /dev/null @@ -1,755 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2007 by Robert Knight * - * Copyright (C) 2008 by Alexis Ménard * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * - ***************************************************************************/ - -#include "tooltips/tooltipmanager.h" -// Own -#include "tasks.h" -#include "windowtaskitem.h" -#include "taskgroupitem.h" -#include "jobmanager.h" -#include "mediabuttons.h" -#include "recentdocuments.h" - -//Taskmanager -#include "taskmanager/groupmanager.h" -#include "taskmanager/taskgroup.h" -#include "taskmanager/taskitem.h" - -// KDE -#include -#include -#include - -// Qt -#include -#include -#include -#include -#include -#include - -// Plasma -#include -#include -#include -#include - -static void setCurrentIndex(QComboBox *combo, int val) -{ - for (int i = 0; i < combo->count(); ++i) { - if (combo->itemData(i).toInt() == val) { - combo->setCurrentIndex(i); - break; - } - } -} - -class GroupManager : public TaskManager::GroupManager -{ -public: - GroupManager(Plasma::Applet *applet) - : TaskManager::GroupManager(applet), - m_applet(applet) { - setGroupingStrategy(GroupManager::ProgramGrouping); - setSortingStrategy(GroupManager::ManualSorting); - setShowOnlyCurrentDesktop(true); - setShowOnlyCurrentScreen(false); - setShowOnlyMinimized(false); - setOnlyGroupWhenFull(false); - setSeparateLaunchers(false); - setForceGrouping(true); - readLauncherConfig(); - } - -protected: - KConfigGroup config() const { - return m_applet->config(); - } - -private: - Plasma::Applet *m_applet; -}; - -static const int constMinSpacing = 0; -static const int constMaxSpacing = 50; -static const int constMinIconScale = 49; -static const int constMaxIconScale = 100; - -Tasks::Tasks(QObject* parent, const QVariantList &arguments) - : Plasma::Applet(parent, arguments), - m_toolTips(TT_Instant), - m_highlightWindows(false), - m_launcherIcons(false), - m_groupClick(GC_PresentWindows), - m_rotate(false), - m_style(Style_Plasma), - m_showSeparator(Sep_WhenNeeded), - m_middleClick(MC_NewInstance), - m_spacing(0), - m_iconScale(constMinIconScale), // constMinIconScale==automatic scaling!!! - m_taskItemBackground(0), - m_progressBar(0), - m_badgeBackground(0), - m_indicators(0), - m_leftMargin(0), - m_topMargin(0), - m_rightMargin(0), - m_bottomMargin(0), - m_offscreenLeftMargin(0), - m_offscreenTopMargin(0), - m_offscreenRightMargin(0), - m_offscreenBottomMargin(0), - m_rootGroupItem(0), - m_groupManager(0), - m_lockAct(0), - m_unlockAct(0), - m_refreshAct(0) -{ - KGlobal::locale()->insertCatalog("icontasks"); - setHasConfigurationInterface(true); - setAspectRatioMode(Plasma::IgnoreAspectRatio); - m_screenTimer.setSingleShot(true); - m_screenTimer.setInterval(300); - resize(500, 58); - - setAcceptDrops(true); -} - -Tasks::~Tasks() -{ - JobManager::self()->setEnabled(false); - MediaButtons::self()->setEnabled(false); - RecentDocuments::self()->setEnabled(false); - delete m_rootGroupItem; - delete m_groupManager; - AbstractTaskItem::clearCaches(); -} - -void Tasks::init() -{ - m_groupManager = new GroupManager(this); - Plasma::Containment* appletContainment = containment(); - if (appletContainment) { - m_groupManager->setScreen(appletContainment->screen()); - } - - connect(m_groupManager, SIGNAL(reload()), this, SLOT(reload())); - connect(m_groupManager, SIGNAL(configChanged()), this, SIGNAL(configNeedsSaving())); - - m_rootGroupItem = new TaskGroupItem(this, this); - m_rootGroupItem->expand(); - m_rootGroupItem->setGroup(m_groupManager->rootGroup()); - - connect(m_rootGroupItem, SIGNAL(sizeHintChanged(Qt::SizeHint)), this, SLOT(changeSizeHint(Qt::SizeHint))); - - setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); - setMaximumSize(INT_MAX, INT_MAX); - - layout = new QGraphicsLinearLayout(this); - layout->setContentsMargins(0, 0, 0, 0); - layout->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); - layout->setMaximumSize(INT_MAX, INT_MAX); - layout->setOrientation(Qt::Vertical); - layout->addItem(m_rootGroupItem); - setLayout(layout); - - configChanged(); - if (containment()) { - IconTasks::ToolTipManager::self()->setCorona(containment()->corona()); - } -} - -void Tasks::configChanged() -{ - KConfigGroup cg = config(); - bool changed = false; - - // only update these if they have actually changed, because they make the - // group manager reload its tasks list - const bool showOnlyCurrentDesktop = cg.readEntry("showOnlyCurrentDesktop", m_groupManager->showOnlyCurrentDesktop()); - if (showOnlyCurrentDesktop != m_groupManager->showOnlyCurrentDesktop()) { - m_groupManager->setShowOnlyCurrentDesktop(showOnlyCurrentDesktop); - changed = true; - } - - const bool showOnlyCurrentScreen = cg.readEntry("showOnlyCurrentScreen", m_groupManager->showOnlyCurrentScreen()); - if (showOnlyCurrentScreen != m_groupManager->showOnlyCurrentScreen()) { - m_groupManager->setShowOnlyCurrentScreen(showOnlyCurrentScreen); - changed = true; - } - - TaskManager::GroupManager::TaskSortingStrategy sortingStrategy = - static_cast( - cg.readEntry("sortingStrategy", - static_cast(m_groupManager->sortingStrategy())) - ); - - if (sortingStrategy != m_groupManager->sortingStrategy()) { - m_groupManager->setSortingStrategy(sortingStrategy); - changed = true; - } - - const int maxRows = cg.readEntry("maxRows", m_rootGroupItem->maxRows()); - if (maxRows != m_rootGroupItem->maxRows()) { - m_rootGroupItem->setMaxRows(maxRows); - changed = true; - } - - const bool launcherIcons = cg.readEntry("launcherIcons", m_launcherIcons); - if (launcherIcons != m_launcherIcons) { - m_launcherIcons = launcherIcons; - changed = true; - } - - const GroupClick groupClick = static_cast(cg.readEntry("groupClick", static_cast(m_groupClick))); - if (groupClick != m_groupClick) { - m_groupClick = groupClick; - changed = true; - } - - const bool rotate = cg.readEntry("rotate", m_rotate); - if (rotate != m_rotate) { - m_rotate = rotate; - changed = true; - } - - const Style style = static_cast