feat(m1): 应用骨架、传送门面板与暂存区
- CMake 构建(Qt6 + dtk2widget + LayerShellQt) - 单实例 / --daemon / --show - DBlur 双栏面板:传送门 + 暂存区,layer-shell 定位,不抢焦点 - 暂存区模型:文件/文字/图片、去重、JSON 持久化、文件消失清理 - 列表委托:复选框、缩略图、名称、hover 关闭按钮 - 全选 / 反选 / 删除选中 - 应用图标(多尺寸 hicolor)与 desktop 入口 - 方案更新:确认 layer-shell + 遮挡自动隐藏
This commit is contained in:
@@ -0,0 +1,76 @@
|
||||
// SPDX-FileCopyrightText: 2026 GXDE OS Team
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QAbstractListModel>
|
||||
#include <QFileIconProvider>
|
||||
#include <QHash>
|
||||
#include <QIcon>
|
||||
#include <QTimer>
|
||||
|
||||
#include "stagingitem.h"
|
||||
|
||||
class QMimeData;
|
||||
|
||||
/**
|
||||
* Model backing the staging area.
|
||||
*
|
||||
* Entries are persisted as JSON in the application data directory and entries
|
||||
* whose backing file disappeared are pruned periodically.
|
||||
*/
|
||||
class StagingModel : public QAbstractListModel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum Roles {
|
||||
TypeRole = Qt::UserRole + 1,
|
||||
IdRole,
|
||||
NameRole,
|
||||
UriRole,
|
||||
TextRole,
|
||||
CheckedRole,
|
||||
ExistsRole,
|
||||
IconRole,
|
||||
};
|
||||
|
||||
explicit StagingModel(QObject *parent = nullptr);
|
||||
~StagingModel() override;
|
||||
|
||||
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
||||
bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()) override;
|
||||
Qt::ItemFlags flags(const QModelIndex &index) const override;
|
||||
|
||||
void addMimeData(const QMimeData *mimeData, int *addedRow = nullptr);
|
||||
void addFiles(const QStringList &localPaths, int *addedRow = nullptr);
|
||||
void addText(const QString &text, int *addedRow = nullptr);
|
||||
void addImage(const QImage &image, int *addedRow = nullptr);
|
||||
|
||||
void setChecked(int row, bool checked);
|
||||
void clearAll();
|
||||
|
||||
const StagingItem *itemAt(int row) const;
|
||||
bool isEmpty() const { return m_items.isEmpty(); }
|
||||
int count() const { return m_items.size(); }
|
||||
|
||||
void load();
|
||||
void save() const;
|
||||
|
||||
signals:
|
||||
void countChanged();
|
||||
void itemAdded(int row);
|
||||
|
||||
private:
|
||||
void insertItem(const StagingItem &item, int *addedRow);
|
||||
QIcon iconFor(const StagingItem &item) const;
|
||||
QString imageCacheDir() const;
|
||||
void pruneMissing();
|
||||
|
||||
QList<StagingItem> m_items;
|
||||
QTimer m_pruneTimer;
|
||||
mutable QHash<QString, QIcon> m_iconCache;
|
||||
mutable QFileIconProvider m_iconProvider;
|
||||
QString m_storePath;
|
||||
};
|
||||
Reference in New Issue
Block a user