Optimize background color animation
This commit is contained in:
parent
360764be8d
commit
e77d1f0f2a
5 changed files with 23 additions and 21 deletions
|
@ -1,9 +0,0 @@
|
||||||
import QtQuick 2.12
|
|
||||||
|
|
||||||
Loader {
|
|
||||||
sourceComponent: _item
|
|
||||||
|
|
||||||
Component {
|
|
||||||
id: _item
|
|
||||||
}
|
|
||||||
}
|
|
10
qml/main.qml
10
qml/main.qml
|
@ -6,7 +6,6 @@ import QtGraphicalEffects 1.0
|
||||||
import Cyber.NetworkManagement 1.0 as NM
|
import Cyber.NetworkManagement 1.0 as NM
|
||||||
import Cutefish.Dock 1.0
|
import Cutefish.Dock 1.0
|
||||||
import MeuiKit 1.0 as Meui
|
import MeuiKit 1.0 as Meui
|
||||||
import org.kde.plasma.core 2.0 as PlasmaCore
|
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
id: root
|
id: root
|
||||||
|
@ -70,10 +69,17 @@ Item {
|
||||||
color: Meui.Theme.backgroundColor
|
color: Meui.Theme.backgroundColor
|
||||||
opacity: Meui.Theme.darkMode ? 0.3 : 0.5
|
opacity: Meui.Theme.darkMode ? 0.3 : 0.5
|
||||||
|
|
||||||
|
Behavior on opacity {
|
||||||
|
NumberAnimation {
|
||||||
|
duration: 200
|
||||||
|
easing.type: Easing.Linear
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Behavior on color {
|
Behavior on color {
|
||||||
ColorAnimation {
|
ColorAnimation {
|
||||||
duration: 200
|
duration: 200
|
||||||
easing.type: Easing.InOutQuad
|
easing.type: Easing.Linear
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -102,6 +102,5 @@
|
||||||
<file>svg/light/dark-mode.svg</file>
|
<file>svg/light/dark-mode.svg</file>
|
||||||
<file>svg/dark/dark-mode.svg</file>
|
<file>svg/dark/dark-mode.svg</file>
|
||||||
<file>svg/dark/bluetooth-symbolic.svg</file>
|
<file>svg/dark/bluetooth-symbolic.svg</file>
|
||||||
<file>qml/StatusNotifierItem.qml</file>
|
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
|
|
@ -152,16 +152,20 @@ public:
|
||||||
explicit SvgSource(const QString &sourceString, IconItem *iconItem)
|
explicit SvgSource(const QString &sourceString, IconItem *iconItem)
|
||||||
: IconItemSource(iconItem)
|
: IconItemSource(iconItem)
|
||||||
{
|
{
|
||||||
|
m_reader.setFileName(sourceString);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isValid() const override {
|
||||||
|
return m_reader.canRead();
|
||||||
}
|
}
|
||||||
|
|
||||||
const QSize size() const override {
|
const QSize size() const override {
|
||||||
return size();
|
return QSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
QPixmap pixmap(const QSize &size) override {
|
QPixmap pixmap(const QSize &size) override {
|
||||||
Q_UNUSED(size);
|
m_reader.setScaledSize(size * devicePixelRatio());
|
||||||
return QPixmap();
|
return QPixmap::fromImage(m_reader.read());
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -169,6 +173,7 @@ private:
|
||||||
return window() ? window()->devicePixelRatio() : qApp->devicePixelRatio();
|
return window() ? window()->devicePixelRatio() : qApp->devicePixelRatio();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QImageReader m_reader;
|
||||||
QString m_svgIconName;
|
QString m_svgIconName;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -177,7 +182,6 @@ IconItem::IconItem(QQuickItem *parent)
|
||||||
, m_iconItemSource(new NullSource(this))
|
, m_iconItemSource(new NullSource(this))
|
||||||
, m_active(false)
|
, m_active(false)
|
||||||
, m_animated(false)
|
, m_animated(false)
|
||||||
, m_usesPlasmaTheme(false)
|
|
||||||
, m_roundToIconSize(true)
|
, m_roundToIconSize(true)
|
||||||
, m_textureChanged(false)
|
, m_textureChanged(false)
|
||||||
, m_sizeChanged(false)
|
, m_sizeChanged(false)
|
||||||
|
@ -226,7 +230,10 @@ void IconItem::setSource(const QVariant &source)
|
||||||
m_iconItemSource.reset(new QImageSource(imageIcon, this));
|
m_iconItemSource.reset(new QImageSource(imageIcon, this));
|
||||||
}
|
}
|
||||||
} else {
|
} 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 (!m_iconItemSource->isValid()) {
|
||||||
// if we started with a QIcon use that.
|
// if we started with a QIcon use that.
|
||||||
|
@ -388,7 +395,6 @@ void IconItem::loadPixmap()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const qreal devicePixelRatio = window() ? window()->devicePixelRatio() : qApp->devicePixelRatio();
|
|
||||||
int size = qMin(qRound(width()), qRound(height()));
|
int size = qMin(qRound(width()), qRound(height()));
|
||||||
QPixmap result;
|
QPixmap result;
|
||||||
|
|
||||||
|
@ -399,7 +405,9 @@ void IconItem::loadPixmap()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_iconItemSource->isValid()) {
|
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 {
|
} else {
|
||||||
m_iconPixmap = QPixmap();
|
m_iconPixmap = QPixmap();
|
||||||
update();
|
update();
|
||||||
|
|
|
@ -62,7 +62,6 @@ signals:
|
||||||
void activeChanged();
|
void activeChanged();
|
||||||
void sourceChanged();
|
void sourceChanged();
|
||||||
void animatedChanged();
|
void animatedChanged();
|
||||||
void usesPlasmaThemeChanged();
|
|
||||||
void roundToIconSizeChanged();
|
void roundToIconSizeChanged();
|
||||||
void validChanged();
|
void validChanged();
|
||||||
void colorGroupChanged();
|
void colorGroupChanged();
|
||||||
|
@ -83,7 +82,6 @@ private:
|
||||||
|
|
||||||
bool m_active;
|
bool m_active;
|
||||||
bool m_animated;
|
bool m_animated;
|
||||||
bool m_usesPlasmaTheme;
|
|
||||||
bool m_roundToIconSize;
|
bool m_roundToIconSize;
|
||||||
|
|
||||||
bool m_textureChanged;
|
bool m_textureChanged;
|
||||||
|
|
Loading…
Reference in a new issue