Revert "Fix too much memory for wallpaper"

This reverts commit e90f775e30.
pull/4/head
cutefishd 5 years ago
parent e90f775e30
commit 15b251bd79

@ -23,10 +23,9 @@ set(SRCS
src/main.cpp
src/pagemodel.cpp
src/ucunits.cpp
src/wallpaper.cpp
src/listmodelmanager.cpp
src/iconitem.cpp
src/wallpaperitem.cpp
src/modelmanager.cpp
)
set(RESOURCES

1
debian/control vendored

@ -24,7 +24,6 @@ Depends: qml-module-qtquick-controls2,
qml-module-qtqml,
qml-module-qtquick-window2,
qml-module-qtquick-shapes,
qml-module-qtquick-dialogs,
${misc:Depends},
${shlibs:Depends}
Description: CutefishOS Launcher

@ -4,6 +4,5 @@
<file>qml/LauncherGridDelegate.qml</file>
<file>qml/PageView.qml</file>
<file>qml/LauncherGridView.qml</file>
<file>qml/AppView.qml</file>
</qresource>
</RCC>

@ -1,59 +0,0 @@
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
}
}
}
}
}

@ -69,9 +69,11 @@ Item {
}
}
Meui.TopLevelMenu {
Menu {
id: _itemMenu
modal: true
MenuItem {
text: qsTr("Open")
onTriggered: launcherModel.launch(model.appId)

@ -13,9 +13,19 @@ Item {
property real horizontalSpacing: root.width * 0.01
property real verticalSpacing: root.height * 0.01
WallpaperItem {
Wallpaper {
id: backend
}
Image {
id: wallpaper
anchors.fill: parent
source: "file://" + backend.wallpaper
sourceSize: Qt.size(width, height)
fillMode: Image.PreserveAspectCrop
clip: true
cache: true
smooth: false
}
FastBlur {
@ -29,7 +39,7 @@ Item {
anchors.fill: parent
source: wallpaperBlur
color: "#000000"
opacity: 0.5
opacity: 0.6
visible: true
}

@ -25,7 +25,7 @@
#include "launcheritem.h"
#include "launchermodel.h"
#include "pagemodel.h"
#include "wallpaperitem.h"
#include "wallpaper.h"
#include "iconitem.h"
#include <QDebug>
@ -45,7 +45,7 @@ int main(int argc, char *argv[])
qmlRegisterUncreatableType<LauncherItem>(uri, 1, 0, "LauncherItem", "cannot init application");
qmlRegisterType<LauncherModel>(uri, 1, 0, "LauncherModel");
qmlRegisterType<PageModel>(uri, 1, 0, "PageModel");
qmlRegisterType<WallpaperItem>(uri, 1, 0, "WallpaperItem");
qmlRegisterType<Wallpaper>(uri, 1, 0, "Wallpaper");
qmlRegisterType<IconItem>(uri, 1, 0, "IconItem");
QApplication app(argc, argv);

@ -1,11 +0,0 @@
#include "modelmanager.h"
ModelManager::ModelManager(QObject *parent) : QObject(parent)
{
}
int ModelManager::count() const
{
return m_appList.count();
}

@ -1,25 +0,0 @@
#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

@ -0,0 +1,34 @@
#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();
}
}

@ -0,0 +1,32 @@
#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

@ -1,50 +0,0 @@
#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();
}

@ -1,30 +0,0 @@
#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…
Cancel
Save