mirror of https://github.com/cutefishos/launcher
Fix too much memory for wallpaper
parent
fcb9330996
commit
e90f775e30
@ -0,0 +1,59 @@
|
||||
import QtQuick 2.12
|
||||
import QtQuick.Layouts 1.12
|
||||
import QtQuick.Controls 2.12
|
||||
import MeuiKit 1.0 as Meui
|
||||
|
||||
ListView {
|
||||
id: control
|
||||
|
||||
focus: true
|
||||
snapMode: ListView.SnapToItem
|
||||
maximumFlickVelocity: 9000
|
||||
highlightMoveDuration: 100
|
||||
|
||||
preferredHighlightBegin: 0
|
||||
preferredHighlightEnd: 0
|
||||
highlightRangeMode: ListView.StrictlyEnforceRange
|
||||
highlightFollowsCurrentItem: true
|
||||
cacheBuffer: control.width * control.count
|
||||
clip: true
|
||||
|
||||
displaced: Transition {
|
||||
SpringAnimation {
|
||||
property: "y"
|
||||
spring: 3
|
||||
damping: 0.1
|
||||
epsilon: 0.25
|
||||
duration: 1000
|
||||
}
|
||||
}
|
||||
|
||||
Component {
|
||||
id: listDelegate
|
||||
|
||||
Flow {
|
||||
id: launcherGrid
|
||||
width: control.width
|
||||
height: control.height
|
||||
|
||||
move: Transition {
|
||||
NumberAnimation {
|
||||
duration: 200
|
||||
easing.type: Easing.InOutQuad
|
||||
properties: "x,y"
|
||||
}
|
||||
}
|
||||
|
||||
Repeater {
|
||||
id: repeaterHandle
|
||||
|
||||
delegate: DropArea {
|
||||
id: delegate
|
||||
width: control.width / 6
|
||||
height: control.height / 4
|
||||
opacity: 1
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
#include "modelmanager.h"
|
||||
|
||||
ModelManager::ModelManager(QObject *parent) : QObject(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
int ModelManager::count() const
|
||||
{
|
||||
return m_appList.count();
|
||||
}
|
||||
@ -0,0 +1,25 @@
|
||||
#ifndef MODELMANAGER_H
|
||||
#define MODELMANAGER_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
struct ApplicationData {
|
||||
QString name;
|
||||
QString icon;
|
||||
QStringList args;
|
||||
};
|
||||
|
||||
class ModelManager : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ModelManager(QObject *parent = nullptr);
|
||||
|
||||
int count() const;
|
||||
|
||||
private:
|
||||
QList<ApplicationData> m_appList;
|
||||
};
|
||||
|
||||
#endif // MODELMANAGER_H
|
||||
@ -1,34 +0,0 @@
|
||||
#include "wallpaper.h"
|
||||
|
||||
Wallpaper::Wallpaper(QObject *parent)
|
||||
: QObject(parent)
|
||||
, m_interface("org.cutefish.Settings",
|
||||
"/Theme", "org.cutefish.Theme",
|
||||
QDBusConnection::sessionBus(), this)
|
||||
{
|
||||
if (m_interface.isValid()) {
|
||||
connect(&m_interface, SIGNAL(wallpaperChanged(QString)), this, SLOT(onWallpaperChanged(QString)));
|
||||
connect(&m_interface, SIGNAL(darkModeDimsWallpaerChanged()), this, SIGNAL(dimsWallpaperChanged()));
|
||||
|
||||
m_wallpaper = m_interface.property("wallpaper").toString();
|
||||
emit wallpaperChanged();
|
||||
}
|
||||
}
|
||||
|
||||
QString Wallpaper::wallpaper() const
|
||||
{
|
||||
return m_wallpaper;
|
||||
}
|
||||
|
||||
bool Wallpaper::dimsWallpaper() const
|
||||
{
|
||||
return m_interface.property("darkModeDimsWallpaer").toBool();
|
||||
}
|
||||
|
||||
void Wallpaper::onWallpaperChanged(QString path)
|
||||
{
|
||||
if (path != m_wallpaper) {
|
||||
m_wallpaper = path;
|
||||
emit wallpaperChanged();
|
||||
}
|
||||
}
|
||||
@ -1,32 +0,0 @@
|
||||
#ifndef WALLPAPER_H
|
||||
#define WALLPAPER_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QDBusInterface>
|
||||
#include <QProcess>
|
||||
|
||||
class Wallpaper : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QString wallpaper READ wallpaper NOTIFY wallpaperChanged)
|
||||
Q_PROPERTY(bool dimsWallpaper READ dimsWallpaper NOTIFY dimsWallpaperChanged)
|
||||
|
||||
public:
|
||||
explicit Wallpaper(QObject *parent = nullptr);
|
||||
|
||||
QString wallpaper() const;
|
||||
bool dimsWallpaper() const;
|
||||
|
||||
signals:
|
||||
void wallpaperChanged();
|
||||
void dimsWallpaperChanged();
|
||||
|
||||
private slots:
|
||||
void onWallpaperChanged(QString);
|
||||
|
||||
private:
|
||||
QDBusInterface m_interface;
|
||||
QString m_wallpaper;
|
||||
};
|
||||
|
||||
#endif // WALLPAPER_H
|
||||
@ -0,0 +1,50 @@
|
||||
#include "wallpaperitem.h"
|
||||
#include <QPainter>
|
||||
#include <QPixmapCache>
|
||||
|
||||
WallpaperItem::WallpaperItem(QQuickItem *parent)
|
||||
: QQuickPaintedItem(parent)
|
||||
, m_interface("org.cutefish.Settings",
|
||||
"/Theme", "org.cutefish.Theme",
|
||||
QDBusConnection::sessionBus(), this)
|
||||
{
|
||||
if (m_interface.isValid()) {
|
||||
connect(&m_interface, SIGNAL(wallpaperChanged(QString)), this, SLOT(onWallpaperChanged(QString)));
|
||||
m_wallpaper = m_interface.property("wallpaper").toString();
|
||||
loadWallpaperPixmap();
|
||||
}
|
||||
}
|
||||
|
||||
void WallpaperItem::paint(QPainter *painter)
|
||||
{
|
||||
painter->drawPixmap(QRect(0, 0, width(), height()), m_pixmap);
|
||||
}
|
||||
|
||||
void WallpaperItem::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
|
||||
{
|
||||
Q_UNUSED(newGeometry);
|
||||
Q_UNUSED(oldGeometry);
|
||||
|
||||
loadWallpaperPixmap();
|
||||
}
|
||||
|
||||
void WallpaperItem::loadWallpaperPixmap()
|
||||
{
|
||||
// Clear cache.
|
||||
m_pixmap = QPixmap();
|
||||
QPixmapCache::clear();
|
||||
|
||||
if (m_wallpaper.isEmpty())
|
||||
return;
|
||||
|
||||
m_pixmap = QPixmap(m_wallpaper).scaled(QSize(width(), height()),
|
||||
Qt::KeepAspectRatioByExpanding);
|
||||
|
||||
QQuickPaintedItem::update();
|
||||
}
|
||||
|
||||
void WallpaperItem::onWallpaperChanged(QString wallpaper)
|
||||
{
|
||||
m_wallpaper = wallpaper;
|
||||
loadWallpaperPixmap();
|
||||
}
|
||||
@ -0,0 +1,30 @@
|
||||
#ifndef WALLPAPERITEM_H
|
||||
#define WALLPAPERITEM_H
|
||||
|
||||
#include <QQuickPaintedItem>
|
||||
#include <QDBusInterface>
|
||||
#include <QPixmap>
|
||||
|
||||
class WallpaperItem : public QQuickPaintedItem
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit WallpaperItem(QQuickItem *parent = nullptr);
|
||||
|
||||
void paint(QPainter *painter) override;
|
||||
void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) override;
|
||||
|
||||
private:
|
||||
void loadWallpaperPixmap();
|
||||
|
||||
private slots:
|
||||
void onWallpaperChanged(QString wallpaper);
|
||||
|
||||
private:
|
||||
QPixmap m_pixmap;
|
||||
QDBusInterface m_interface;
|
||||
QString m_wallpaper;
|
||||
};
|
||||
|
||||
#endif // WALLPAPERITEM_H
|
||||
Loading…
Reference in New Issue