diff --git a/qml/StatusNotifierItem.qml b/qml/StatusNotifierItem.qml deleted file mode 100644 index af62393..0000000 --- a/qml/StatusNotifierItem.qml +++ /dev/null @@ -1,9 +0,0 @@ -import QtQuick 2.12 - -Loader { - sourceComponent: _item - - Component { - id: _item - } -} diff --git a/qml/main.qml b/qml/main.qml index 09dac29..fd939a4 100644 --- a/qml/main.qml +++ b/qml/main.qml @@ -6,7 +6,6 @@ import QtGraphicalEffects 1.0 import Cyber.NetworkManagement 1.0 as NM import Cutefish.Dock 1.0 import MeuiKit 1.0 as Meui -import org.kde.plasma.core 2.0 as PlasmaCore Item { id: root @@ -70,10 +69,17 @@ Item { color: Meui.Theme.backgroundColor opacity: Meui.Theme.darkMode ? 0.3 : 0.5 + Behavior on opacity { + NumberAnimation { + duration: 200 + easing.type: Easing.Linear + } + } + Behavior on color { ColorAnimation { duration: 200 - easing.type: Easing.InOutQuad + easing.type: Easing.Linear } } } diff --git a/resources.qrc b/resources.qrc index 4360cf5..754c47a 100644 --- a/resources.qrc +++ b/resources.qrc @@ -102,6 +102,5 @@ svg/light/dark-mode.svg svg/dark/dark-mode.svg svg/dark/bluetooth-symbolic.svg - qml/StatusNotifierItem.qml diff --git a/src/iconitem.cpp b/src/iconitem.cpp index e0b2116..b86b263 100644 --- a/src/iconitem.cpp +++ b/src/iconitem.cpp @@ -152,16 +152,20 @@ public: explicit SvgSource(const QString &sourceString, IconItem *iconItem) : IconItemSource(iconItem) { + m_reader.setFileName(sourceString); + } + bool isValid() const override { + return m_reader.canRead(); } const QSize size() const override { - return size(); + return QSize(); } QPixmap pixmap(const QSize &size) override { - Q_UNUSED(size); - return QPixmap(); + m_reader.setScaledSize(size * devicePixelRatio()); + return QPixmap::fromImage(m_reader.read()); } private: @@ -169,6 +173,7 @@ private: return window() ? window()->devicePixelRatio() : qApp->devicePixelRatio(); } + QImageReader m_reader; QString m_svgIconName; }; @@ -177,7 +182,6 @@ IconItem::IconItem(QQuickItem *parent) , m_iconItemSource(new NullSource(this)) , m_active(false) , m_animated(false) - , m_usesPlasmaTheme(false) , m_roundToIconSize(true) , m_textureChanged(false) , m_sizeChanged(false) @@ -226,7 +230,10 @@ void IconItem::setSource(const QVariant &source) m_iconItemSource.reset(new QImageSource(imageIcon, this)); } } else { - // m_iconItemSource.reset(new SvgSource(sourceString, this)); +// if (sourceString.startsWith("qrc:/")) +// m_iconItemSource.reset(new SvgSource(sourceString.remove(0, 3), this)); +// else if (sourceString.startsWith(":/")) +// m_iconItemSource.reset(new SvgSource(sourceString, this)); if (!m_iconItemSource->isValid()) { // if we started with a QIcon use that. @@ -388,7 +395,6 @@ void IconItem::loadPixmap() return; } - const qreal devicePixelRatio = window() ? window()->devicePixelRatio() : qApp->devicePixelRatio(); int size = qMin(qRound(width()), qRound(height())); QPixmap result; @@ -399,7 +405,9 @@ void IconItem::loadPixmap() } if (m_iconItemSource->isValid()) { - result = m_iconItemSource->pixmap(QSize(size * devicePixelRatio, size * devicePixelRatio)); + result = m_iconItemSource->pixmap(QSize(size * qApp->devicePixelRatio(), + size * qApp->devicePixelRatio())); + result.setDevicePixelRatio(qApp->devicePixelRatio()); } else { m_iconPixmap = QPixmap(); update(); diff --git a/src/iconitem.h b/src/iconitem.h index 89a2cd3..f8454f8 100644 --- a/src/iconitem.h +++ b/src/iconitem.h @@ -62,7 +62,6 @@ signals: void activeChanged(); void sourceChanged(); void animatedChanged(); - void usesPlasmaThemeChanged(); void roundToIconSizeChanged(); void validChanged(); void colorGroupChanged(); @@ -83,7 +82,6 @@ private: bool m_active; bool m_animated; - bool m_usesPlasmaTheme; bool m_roundToIconSize; bool m_textureChanged;