first commit
This commit is contained in:
63
widgets/launcherpage.h
Normal file
63
widgets/launcherpage.h
Normal file
@@ -0,0 +1,63 @@
|
||||
#ifndef LAUNCHERPAGE_H
|
||||
#define LAUNCHERPAGE_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QVector>
|
||||
#include <QJsonObject>
|
||||
#include <QMap>
|
||||
#include <QRect>
|
||||
#include "appicon.h"
|
||||
|
||||
struct PageConfig
|
||||
{
|
||||
QString id;
|
||||
QString title;
|
||||
QVector<AppIconData> apps;
|
||||
};
|
||||
|
||||
// 分组信息结构
|
||||
struct GroupInfo
|
||||
{
|
||||
QString groupId;
|
||||
QVector<int> iconIndices; // 该分组包含的图标索引
|
||||
QRect boundingRect; // 分组的边界矩形
|
||||
};
|
||||
|
||||
class LauncherPage : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit LauncherPage(const PageConfig &config, QWidget *parent = nullptr);
|
||||
~LauncherPage();
|
||||
|
||||
QString pageId() const { return m_config.id; }
|
||||
QString pageTitle() const { return m_config.title; }
|
||||
|
||||
signals:
|
||||
void appClicked(const QString &appId);
|
||||
void appLongPressed(const QString &appId);
|
||||
|
||||
protected:
|
||||
void resizeEvent(QResizeEvent *event) override;
|
||||
void paintEvent(QPaintEvent *event) override;
|
||||
|
||||
private:
|
||||
void setupUI();
|
||||
void layoutIcons();
|
||||
void updateGroupRects(const QMap<int, QRect> &iconRects); // 更新分组矩形
|
||||
|
||||
PageConfig m_config;
|
||||
QVector<AppIcon *> m_icons;
|
||||
QMap<QString, GroupInfo> m_groups; // 分组信息
|
||||
|
||||
// 网格布局参数
|
||||
int m_columns;
|
||||
int m_rows;
|
||||
int m_horizontalGap;
|
||||
int m_verticalGap;
|
||||
int m_horizontalPadding;
|
||||
int m_verticalPadding;
|
||||
};
|
||||
|
||||
#endif // LAUNCHERPAGE_H
|
||||
Reference in New Issue
Block a user