fix: optimize memory

main
reionwong 4 years ago
parent 081cd78dc2
commit eabeace283

@ -79,12 +79,12 @@ Item {
// color: FishUI.Theme.darkMode ? "#4D4D4D" : "#FFFFFF" // color: FishUI.Theme.darkMode ? "#4D4D4D" : "#FFFFFF"
// opacity: windowHelper.compositing ? FishUI.Theme.darkMode ? 0.5 : 0.7 : 1.0 // opacity: windowHelper.compositing ? FishUI.Theme.darkMode ? 0.5 : 0.7 : 1.0
Behavior on color { // Behavior on color {
ColorAnimation { // ColorAnimation {
duration: 100 // duration: 100
easing.type: Easing.Linear // easing.type: Easing.Linear
} // }
} // }
} }
FishUI.WindowHelper { FishUI.WindowHelper {

@ -22,22 +22,29 @@
#include <QApplication> #include <QApplication>
#include <QDebug> #include <QDebug>
#include <QPixmap> #include <QPixmap>
#include <QPixmapCache>
#include <QScreen> #include <QScreen>
#include <QRgb> #include <QRgb>
BackgroundHelper::BackgroundHelper(QObject *parent) BackgroundHelper::BackgroundHelper(QObject *parent)
: QObject(parent) : QObject(parent)
, m_statusBarHeight(25 / qApp->devicePixelRatio()) , m_statusBarHeight(25 / qApp->devicePixelRatio())
, m_type(0)
{ {
} }
void BackgroundHelper::setColor(QColor c) void BackgroundHelper::setColor(QColor c)
{ {
m_color = c;
m_type = 1;
emit newColor(c, c.lightness()); emit newColor(c, c.lightness());
} }
void BackgroundHelper::setBackgound(const QString &fileName) void BackgroundHelper::setBackgound(const QString &fileName)
{ {
m_wallpaper = fileName;
m_type = 0;
QImage img(fileName); QImage img(fileName);
QSize screenSize = qApp->primaryScreen()->geometry().size(); QSize screenSize = qApp->primaryScreen()->geometry().size();
@ -68,4 +75,21 @@ void BackgroundHelper::setBackgound(const QString &fileName)
QColor c = QColor(sumR, sumG, sumB); QColor c = QColor(sumR, sumG, sumB);
emit newColor(c, c.lightness()); emit newColor(c, c.lightness());
// clear cache.
QPixmapCache::clear();
}
void BackgroundHelper::onChanged()
{
switch (m_type) {
case 0:
setBackgound(m_wallpaper);
break;
case 1:
setColor(m_color);
break;
default:
break;
}
} }

@ -33,11 +33,17 @@ public:
Q_INVOKABLE void setColor(QColor c); Q_INVOKABLE void setColor(QColor c);
Q_INVOKABLE void setBackgound(const QString &fileName); Q_INVOKABLE void setBackgound(const QString &fileName);
private slots:
void onChanged();
signals: signals:
void newColor(QColor color, int lightness); void newColor(QColor color, int lightness);
private: private:
int m_statusBarHeight; int m_statusBarHeight;
int m_type;
QColor m_color;
QString m_wallpaper;
}; };
#endif // BACKGROUNDHELPER_H #endif // BACKGROUNDHELPER_H

@ -273,6 +273,7 @@ void StatusNotifierItemSource::refreshCallback(QDBusPendingCallWatcher *call)
m_iconName = id; m_iconName = id;
} }
m_appId = id; m_appId = id;
// qDebug() << m_appId;
// Reion: For icon theme path // Reion: For icon theme path
QString iconThemePath = properties[QStringLiteral("IconThemePath")].toString(); QString iconThemePath = properties[QStringLiteral("IconThemePath")].toString();

@ -27,7 +27,9 @@
static QStringList noColorOverlayList = { static QStringList noColorOverlayList = {
"netease-cloud-music", "netease-cloud-music",
"chrome_status_icon_1" "chrome_status_icon_1",
"35682", // obs studio
"lark_status_icon_1"
}; };
SystemTrayModel::SystemTrayModel(QObject *parent) SystemTrayModel::SystemTrayModel(QObject *parent)

Loading…
Cancel
Save