diff --git a/applets/taskmanager/CMakeLists.txt b/applets/taskmanager/CMakeLists.txt
--- a/applets/taskmanager/CMakeLists.txt
+++ b/applets/taskmanager/CMakeLists.txt
@@ -6,7 +6,6 @@
plugin/backend.cpp
plugin/draghelper.cpp
plugin/taskmanagerplugin.cpp
- plugin/textlabel.cpp
plugin/smartlaunchers/smartlauncherbackend.cpp
plugin/smartlaunchers/smartlauncheritem.cpp
@@ -22,7 +21,6 @@
Qt5::DBus
Qt5::Qml
Qt5::Quick
- Qt5::Widgets
KF5::Activities
KF5::ActivitiesStats
KF5::I18n
diff --git a/applets/taskmanager/package/contents/config/main.xml b/applets/taskmanager/package/contents/config/main.xml
--- a/applets/taskmanager/package/contents/config/main.xml
+++ b/applets/taskmanager/package/contents/config/main.xml
@@ -70,9 +70,6 @@
true
-
- false
-
diff --git a/applets/taskmanager/package/contents/ui/CppTextLabel.qml b/applets/taskmanager/package/contents/ui/CppTextLabel.qml
deleted file mode 100644
--- a/applets/taskmanager/package/contents/ui/CppTextLabel.qml
+++ /dev/null
@@ -1,30 +0,0 @@
-/***************************************************************************
- * Copyright (C) 2016 by Eike Hein *
- * *
- * 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 . *
- ***************************************************************************/
-
-import QtQuick 2.0
-
-import org.kde.plasma.private.taskmanager 0.1 as TaskManagerApplet
-
-TaskManagerApplet.TextLabel {
- anchors.fill: parent
-
- text: model.display
- color: theme.textColor
- elide: !inPopup
-}
diff --git a/applets/taskmanager/package/contents/ui/QmlTextLabel.qml b/applets/taskmanager/package/contents/ui/QmlTextLabel.qml
deleted file mode 100644
--- a/applets/taskmanager/package/contents/ui/QmlTextLabel.qml
+++ /dev/null
@@ -1,32 +0,0 @@
-/***************************************************************************
- * Copyright (C) 2016 by Eike Hein *
- * *
- * 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 . *
- ***************************************************************************/
-
-import QtQuick 2.0
-
-import org.kde.plasma.components 2.0 as PlasmaComponents
-
-PlasmaComponents.Label {
- anchors.fill: parent
-
- text: model.display
- wrapMode: Text.Wrap
- elide: Text.ElideRight
- textFormat: Text.PlainText
- verticalAlignment: Text.AlignVCenter
-}
diff --git a/applets/taskmanager/package/contents/ui/Task.qml b/applets/taskmanager/package/contents/ui/Task.qml
--- a/applets/taskmanager/package/contents/ui/Task.qml
+++ b/applets/taskmanager/package/contents/ui/Task.qml
@@ -44,7 +44,7 @@
property int itemIndex: index
property bool inPopup: false
property bool isWindow: model.IsWindow === true
- property alias textWidth: label.implicitTextWidth
+ property alias textWidth: label.implicitWidth
property bool pressed: false
property int pressX: -1
property int pressY: -1
@@ -391,10 +391,11 @@
}
}
- Loader {
+ PlasmaComponents.Label {
id: label
- property int implicitTextWidth: label.item ? label.item.implicitWidth : 0
+ visible: (inPopup || !iconsOnly && model.IsLauncher !== true
+ && (parent.width - iconBox.height - units.smallSpacing) >= (theme.mSize(theme.defaultFont).width * 7))
anchors {
fill: parent
@@ -404,13 +405,11 @@
bottomMargin: taskFrame.margins.bottom
}
- visible: (inPopup || !iconsOnly && model.IsLauncher !== true
- && (parent.width - iconBox.height - units.smallSpacing) >= (theme.mSize(theme.defaultFont).width * 7))
-
- active: inPopup || !iconsOnly
- asynchronous: true
-
- source: plasmoid.configuration.experimentalQmlTextLabel ? "QmlTextLabel.qml" : "CppTextLabel.qml"
+ text: model.display
+ wrapMode: Text.Wrap
+ elide: Text.ElideRight
+ textFormat: Text.PlainText
+ verticalAlignment: Text.AlignVCenter
}
states: [
diff --git a/applets/taskmanager/plugin/blur.cpp b/applets/taskmanager/plugin/blur.cpp
deleted file mode 100644
--- a/applets/taskmanager/plugin/blur.cpp
+++ /dev/null
@@ -1,154 +0,0 @@
-#ifndef BLUR_CPP
-#define BLUR_CPP
-
-/*
- * Copyright 2007 Jani Huhtanen
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library General Public License version 2 as
- * published by the Free Software Foundation
- *
- * 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 Library 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
-
-// Exponential blur, Jani Huhtanen, 2006
-//
-template
-static inline void blurinner(unsigned char *bptr, int &zR, int &zG, int &zB, int &zA, int alpha);
-
-template
-static inline void blurrow(QImage &im, int line, int alpha);
-
-template
-static inline void blurcol(QImage &im, int col, int alpha);
-
-/*
-* expblur(QImage &img, int radius)
-*
-* In-place blur of image 'img' with kernel
-* of approximate radius 'radius'.
-*
-* Blurs with two sided exponential impulse
-* response.
-*
-* aprec = precision of alpha parameter
-* in fixed-point format 0.aprec
-*
-* zprec = precision of state parameters
-* zR,zG,zB and zA in fp format 8.zprec
-*/
-template
-void expblur(QImage &img, int radius)
-{
- if (radius < 1) {
- return;
- }
-
- img = img.convertToFormat(QImage::Format_ARGB32_Premultiplied);
-
- /* Calculate the alpha such that 90% of
- the kernel is within the radius.
- (Kernel extends to infinity)
- */
- int alpha = (int)((1 << aprec) * (1.0f - std::exp(-2.3f / (radius + 1.f))));
-
- int height = img.height();
- int width = img.width();
- for (int row=0; row(img, row, alpha);
- }
-
- for (int col=0; col(img, col, alpha);
- }
- return;
-}
-
-template
-static inline void blurinner(unsigned char *bptr, int &zR, int &zG, int &zB, int &zA, int alpha)
-{
- int R, G, B, A;
- R = *bptr;
- G = *(bptr + 1);
- B = *(bptr + 2);
- A = *(bptr + 3);
-
- zR += (alpha * ((R << zprec) - zR)) >> aprec;
- zG += (alpha * ((G << zprec) - zG)) >> aprec;
- zB += (alpha * ((B << zprec) - zB)) >> aprec;
- zA += (alpha * ((A << zprec) - zA)) >> aprec;
-
- *bptr = zR >> zprec;
- *(bptr+1) = zG >> zprec;
- *(bptr+2) = zB >> zprec;
- *(bptr+3) = zA >> zprec;
-}
-
-template
-static inline void blurrow(QImage &im, int line, int alpha)
-{
- int zR, zG, zB, zA;
-
- QRgb *ptr = (QRgb *)im.scanLine(line);
- int width = im.width();
-
- zR = *((unsigned char *)ptr ) << zprec;
- zG = *((unsigned char *)ptr + 1) << zprec;
- zB = *((unsigned char *)ptr + 2) << zprec;
- zA = *((unsigned char *)ptr + 3) << zprec;
-
- for (int index=1; index((unsigned char *)&ptr[index],zR,zG,zB,zA,alpha);
- }
- for (int index=width-2; index>=0; index--) {
- blurinner((unsigned char *)&ptr[index],zR,zG,zB,zA,alpha);
- }
-}
-
-template
-static inline void blurcol(QImage &im, int col, int alpha)
-{
- int zR, zG, zB, zA;
-
- QRgb *ptr = (QRgb *)im.bits();
- ptr += col;
- int height = im.height();
- int width = im.width();
-
- zR = *((unsigned char *)ptr ) << zprec;
- zG = *((unsigned char *)ptr + 1) << zprec;
- zB = *((unsigned char *)ptr + 2) << zprec;
- zA = *((unsigned char *)ptr + 3) << zprec;
-
- for (int index=width; index<(height-1)*width; index+=width) {
- blurinner((unsigned char *)&ptr[index], zR, zG, zB, zA, alpha);
- }
-
- for (int index=(height-2)*width; index>=0; index-=width) {
- blurinner((unsigned char *)&ptr[index], zR, zG, zB, zA, alpha);
- }
-}
-
-template
-inline const T &qClamp(const T &x, const T &low, const T &high)
-{
- if (x < low) {
- return low;
- } else if (x > high) {
- return high;
- } else {
- return x;
- }
-}
-
-#endif
diff --git a/applets/taskmanager/plugin/taskmanagerplugin.cpp b/applets/taskmanager/plugin/taskmanagerplugin.cpp
--- a/applets/taskmanager/plugin/taskmanagerplugin.cpp
+++ b/applets/taskmanager/plugin/taskmanagerplugin.cpp
@@ -38,7 +38,6 @@
#include "taskmanagerplugin.h"
#include "backend.h"
#include "draghelper.h"
-#include "textlabel.h"
#include "smartlaunchers/smartlauncheritem.h"
@@ -50,7 +49,6 @@
Q_ASSERT(uri == QLatin1String("org.kde.plasma.private.taskmanager"));
qmlRegisterType(uri, 0, 1, "Backend");
qmlRegisterType(uri, 0, 1, "DragHelper");
- qmlRegisterType(uri, 0, 1, "TextLabel");
qmlRegisterType(uri, 0, 1, "SmartLauncherItem");
}
diff --git a/applets/taskmanager/plugin/textlabel.h b/applets/taskmanager/plugin/textlabel.h
deleted file mode 100644
--- a/applets/taskmanager/plugin/textlabel.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/***************************************************************************
- * Copyright (C) 2007 by Robert Knight *
- * Copyright (C) 2008 by Alexis Ménard *
- * Copyright (C) 2008 by Marco Martin *
- * Copyright (C) 2012-2013 by Eike Hein *
- * *
- * 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 TEXTLABEL_H
-#define TEXTLABEL_H
-
-#include
-#include
-#include
-#include
-#include
-
-class TextLabel : public QQuickPaintedItem
-{
- Q_OBJECT
-
- Q_PROPERTY(bool enabled READ enabled WRITE setEnabled)
- Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged)
- Q_PROPERTY(QColor color READ color WRITE setColor)
- Q_PROPERTY(bool elide READ elide WRITE setElide)
-
- public:
- TextLabel(QQuickItem *parent = 0);
- ~TextLabel();
-
- bool enabled() const;
- void setEnabled(bool enabled);
-
- QString text() const;
- void setText(const QString& text);
-
- QColor color() const;
- void setColor(const QColor& color);
-
- bool elide() const;
- void setElide(bool elide);
-
- void paint(QPainter *painter);
-
- Q_SIGNALS:
- void textChanged(const QString& text);
-
- protected:
- void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry);
-
- private:
- void updateImplicitSize();
- QColor textColor() const;
- QTextOption textOption() const;;
- void layoutText(QTextLayout &layout, const QString &text, const QSize &constraints);
- void drawTextLayout(QPainter *painter, const QTextLayout &layout, const QRect &rect);
-
- bool m_enabled;
- QString m_text;
- QColor m_color;
- bool m_elide;
- QTextLayout m_layout;
- QPixmap m_cachedShadow;
-};
-
-#endif
diff --git a/applets/taskmanager/plugin/textlabel.cpp b/applets/taskmanager/plugin/textlabel.cpp
deleted file mode 100644
--- a/applets/taskmanager/plugin/textlabel.cpp
+++ /dev/null
@@ -1,278 +0,0 @@
-/***************************************************************************
- * Copyright (C) 2007 Jani Huhtanen *
- * Copyright (C) 2007 by Robert Knight *
- * Copyright (C) 2008 by Alexis Ménard *
- * Copyright (C) 2008 by Marco Martin *
- * Copyright (C) 2012-2013 by Eike Hein *
- * *
- * 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 "textlabel.h"
-#include "blur.cpp"
-
-#include
-#include
-#include
-
-TextLabel::TextLabel(QQuickItem* parent) : QQuickPaintedItem(parent),
- m_enabled(true),
- m_elide(false)
-{
-}
-
-TextLabel::~TextLabel()
-{
-}
-
-bool TextLabel::enabled() const
-{
- return m_enabled;
-}
-
-void TextLabel::setEnabled(bool enabled)
-{
- if (enabled != m_enabled) {
- m_enabled = enabled;
- update();
- }
-}
-
-QString TextLabel::text() const
-{
- return m_text;
-}
-
-void TextLabel::setText(const QString& text)
-{
- if (text != m_text)
- {
- m_text = text;
- m_cachedShadow = QPixmap();
- updateImplicitSize();
- update();
- emit textChanged(text);
- }
-}
-
-QColor TextLabel::color() const
-{
- return m_color;
-}
-
-void TextLabel::setColor(const QColor& color)
-{
- if (color != m_color)
- {
- m_color = color;
- m_cachedShadow = QPixmap();
- update();
- }
-}
-
-
-bool TextLabel::elide() const
-{
- return m_elide;
-}
-
-void TextLabel::setElide(bool elide)
-{
- m_elide = elide;
-
- updateImplicitSize();
-}
-
-void TextLabel::updateImplicitSize()
-{
- if (m_elide) {
- setImplicitWidth(0);
- setImplicitHeight(0);
- } else {
- QFontMetrics fm(QFontDatabase::systemFont(QFontDatabase::GeneralFont));
-
- setImplicitWidth(fm.width(m_text));
- setImplicitHeight(fm.height());
- }
-}
-
-void TextLabel::geometryChanged(const QRectF& newGeometry, const QRectF& oldGeometry)
-{
- if (newGeometry.size() != oldGeometry.size()) {
- m_cachedShadow = QPixmap();
- }
-}
-
-QColor TextLabel::textColor() const
-{
- QColor color(m_color);
-
- if (!m_enabled) {
- color.setAlphaF(0.5);
- }
-
- return color;
-}
-
-QTextOption TextLabel::textOption() const
-{
- Qt::LayoutDirection direction = QApplication::layoutDirection();
- Qt::Alignment alignment = QStyle::visualAlignment(direction, Qt::AlignLeft | Qt::AlignVCenter);
-
- QTextOption option;
- option.setTextDirection(direction);
- option.setAlignment(alignment);
-
- return option;
-}
-
-void TextLabel::layoutText(QTextLayout &layout, const QString &text, const QSize &constraints)
-{
- QFontMetrics metrics(layout.font());
- int leading = metrics.leading();
- int height = 0;
- int maxWidth = constraints.width();
- int widthUsed = 0;
- int lineSpacing = metrics.lineSpacing();
- QTextLine line;
-
- layout.setText(text);
-
- layout.beginLayout();
- while ((line = layout.createLine()).isValid()) {
- height += leading;
-
- // Make the last line that will fit infinitely long.
- // drawTextLayout() will handle this by fading the line out
- // if it won't fit in the constraints.
- if (height + 2 * lineSpacing > constraints.height()) {
- line.setPosition(QPoint(0, height));
- break;
- }
-
- line.setLineWidth(maxWidth);
- line.setPosition(QPoint(0, height));
-
- height += int(line.height());
- widthUsed = int(qMax(qreal(widthUsed), line.naturalTextWidth()));
- }
- layout.endLayout();
-}
-
-void TextLabel::drawTextLayout(QPainter *painter, const QTextLayout &layout, const QRect &rect)
-{
- if (rect.width() < 1 || rect.height() < 1) {
- return;
- }
-
- QPixmap pixmap(rect.size());
- pixmap.fill(Qt::transparent);
-
- QPainter p(&pixmap);
- p.setPen(painter->pen());
-
- // Create the alpha gradient for the fade out effect
- QLinearGradient alphaGradient(0, 0, 1, 0);
- alphaGradient.setCoordinateMode(QGradient::ObjectBoundingMode);
- if (layout.textOption().textDirection() == Qt::LeftToRight) {
- alphaGradient.setColorAt(0, QColor(0, 0, 0, 255));
- alphaGradient.setColorAt(1, QColor(0, 0, 0, 0));
- } else {
- alphaGradient.setColorAt(0, QColor(0, 0, 0, 0));
- alphaGradient.setColorAt(1, QColor(0, 0, 0, 255));
- }
-
- QFontMetrics fm(layout.font());
- int textHeight = layout.lineCount() * fm.lineSpacing();
-
- QPointF position(0, (rect.height() - textHeight) / 2);
- QList fadeRects;
- int fadeWidth = 30;
-
- // Draw each line in the layout
- for (int i = 0; i < layout.lineCount(); i++) {
- QTextLine line = layout.lineAt(i);
- line.draw(&p, position);
-
- // Add a fade out rect to the list if the line is too long
- if (line.naturalTextWidth() > rect.width())
- {
- int x = int(qMin(line.naturalTextWidth(), (qreal)pixmap.width())) - fadeWidth;
- int y = int(line.position().y() + position.y());
- QRect r = QStyle::visualRect(layout.textOption().textDirection(), pixmap.rect(),
- QRect(x, y, fadeWidth, int(line.height())));
- fadeRects.append(r);
- }
- }
-
- // Reduce the alpha in each fade out rect using the alpha gradient
- if (!fadeRects.isEmpty()) {
- p.setCompositionMode(QPainter::CompositionMode_DestinationIn);
- foreach (const QRect &rect, fadeRects) {
- p.fillRect(rect, alphaGradient);
- }
- }
-
- p.end();
-
-
- QColor shadowColor;
- if (qGray(textColor().rgb()) > 192) {
- shadowColor = Qt::black;
- } else {
- shadowColor = Qt::white;
- }
-
- if (m_cachedShadow.isNull()) {
- QImage shadow = pixmap.toImage();
- expblur<16, 7>(shadow, 1);
- QPainter p(&shadow);
- p.setCompositionMode(QPainter::CompositionMode_SourceIn);
- p.fillRect(shadow.rect(), shadowColor);
- p.end();
- m_cachedShadow = QPixmap(shadow.size());
- m_cachedShadow.fill(Qt::transparent);
- QPainter buffPainter(&m_cachedShadow);
- buffPainter.drawImage(QPoint(0,0), shadow);
- }
-
- if (shadowColor == Qt::white) {
- painter->drawPixmap(rect.topLeft(), m_cachedShadow);
- } else {
- painter->drawPixmap(rect.topLeft() + QPoint(1, 2), m_cachedShadow);
- }
- painter->drawPixmap(rect.topLeft(), pixmap);
-}
-
-void TextLabel::paint(QPainter* painter)
-{
- painter->setPen(QPen(textColor(), 1.0));
-
- if (QFontDatabase::systemFont(QFontDatabase::GeneralFont) != m_layout.font()) {
- m_cachedShadow = QPixmap();
- }
-
- QFont font = QFontDatabase::systemFont(QFontDatabase::GeneralFont);
- QFontMetrics fm(QFontDatabase::systemFont(QFontDatabase::GeneralFont));
- if (fm.tightBoundingRect(QLatin1String("M")).height() > boundingRect().toRect().height()) {
- font.setPixelSize(boundingRect().toRect().height());
- }
- m_layout.setFont(font);
- m_layout.setTextOption(textOption());
-
- layoutText(m_layout, text(), boundingRect().toRect().size());
- drawTextLayout(painter, m_layout, boundingRect().toRect());
-}