diff --git a/CMakeLists.txt b/CMakeLists.txt index a491ed9..bee03dd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,9 +23,10 @@ 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 diff --git a/debian/control b/debian/control index 48c1564..feb37d1 100644 --- a/debian/control +++ b/debian/control @@ -24,6 +24,7 @@ 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 diff --git a/qml.qrc b/qml.qrc index f6d1235..9030bef 100755 --- a/qml.qrc +++ b/qml.qrc @@ -4,5 +4,6 @@ qml/LauncherGridDelegate.qml qml/PageView.qml qml/LauncherGridView.qml + qml/AppView.qml diff --git a/qml/AppView.qml b/qml/AppView.qml new file mode 100644 index 0000000..b511489 --- /dev/null +++ b/qml/AppView.qml @@ -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 + } + } + } + } +} diff --git a/qml/LauncherGridDelegate.qml b/qml/LauncherGridDelegate.qml index 2122cbc..83d88db 100755 --- a/qml/LauncherGridDelegate.qml +++ b/qml/LauncherGridDelegate.qml @@ -69,11 +69,9 @@ Item { } } - Menu { + Meui.TopLevelMenu { id: _itemMenu - modal: true - MenuItem { text: qsTr("Open") onTriggered: launcherModel.launch(model.appId) diff --git a/qml/main.qml b/qml/main.qml index b1e606b..46901b7 100755 --- a/qml/main.qml +++ b/qml/main.qml @@ -13,19 +13,9 @@ Item { property real horizontalSpacing: root.width * 0.01 property real verticalSpacing: root.height * 0.01 - Wallpaper { - id: backend - } - - Image { + WallpaperItem { id: wallpaper anchors.fill: parent - source: "file://" + backend.wallpaper - sourceSize: Qt.size(width, height) - fillMode: Image.PreserveAspectCrop - clip: true - cache: true - smooth: false } FastBlur { @@ -39,7 +29,7 @@ Item { anchors.fill: parent source: wallpaperBlur color: "#000000" - opacity: 0.6 + opacity: 0.5 visible: true } diff --git a/src/main.cpp b/src/main.cpp index fa6e6e8..d598280 100755 --- a/src/main.cpp +++ b/src/main.cpp @@ -25,7 +25,7 @@ #include "launcheritem.h" #include "launchermodel.h" #include "pagemodel.h" -#include "wallpaper.h" +#include "wallpaperitem.h" #include "iconitem.h" #include @@ -45,7 +45,7 @@ int main(int argc, char *argv[]) qmlRegisterUncreatableType(uri, 1, 0, "LauncherItem", "cannot init application"); qmlRegisterType(uri, 1, 0, "LauncherModel"); qmlRegisterType(uri, 1, 0, "PageModel"); - qmlRegisterType(uri, 1, 0, "Wallpaper"); + qmlRegisterType(uri, 1, 0, "WallpaperItem"); qmlRegisterType(uri, 1, 0, "IconItem"); QApplication app(argc, argv); diff --git a/src/modelmanager.cpp b/src/modelmanager.cpp new file mode 100644 index 0000000..b8fc80c --- /dev/null +++ b/src/modelmanager.cpp @@ -0,0 +1,11 @@ +#include "modelmanager.h" + +ModelManager::ModelManager(QObject *parent) : QObject(parent) +{ + +} + +int ModelManager::count() const +{ + return m_appList.count(); +} diff --git a/src/modelmanager.h b/src/modelmanager.h new file mode 100644 index 0000000..28ca925 --- /dev/null +++ b/src/modelmanager.h @@ -0,0 +1,25 @@ +#ifndef MODELMANAGER_H +#define MODELMANAGER_H + +#include + +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 m_appList; +}; + +#endif // MODELMANAGER_H diff --git a/src/wallpaper.cpp b/src/wallpaper.cpp deleted file mode 100644 index cb391af..0000000 --- a/src/wallpaper.cpp +++ /dev/null @@ -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(); - } -} diff --git a/src/wallpaper.h b/src/wallpaper.h deleted file mode 100644 index 7d316ab..0000000 --- a/src/wallpaper.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef WALLPAPER_H -#define WALLPAPER_H - -#include -#include -#include - -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 diff --git a/src/wallpaperitem.cpp b/src/wallpaperitem.cpp new file mode 100644 index 0000000..167e6a1 --- /dev/null +++ b/src/wallpaperitem.cpp @@ -0,0 +1,50 @@ +#include "wallpaperitem.h" +#include +#include + +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(); +} diff --git a/src/wallpaperitem.h b/src/wallpaperitem.h new file mode 100644 index 0000000..63c7ac3 --- /dev/null +++ b/src/wallpaperitem.h @@ -0,0 +1,30 @@ +#ifndef WALLPAPERITEM_H +#define WALLPAPERITEM_H + +#include +#include +#include + +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