TDE 0.1.0
 
Loading...
Searching...
No Matches
applist.hpp
Go to the documentation of this file.
1
12#pragma once
13
14#include <qgridlayout.h>
15#include <qstackedwidget.h>
16#include <qwidget.h>
17
18#include "tde/app/info.hpp"
19#include "tde/common.hpp"
20#include "tde/settings.hpp"
22
23namespace tde::widgets {
24
29class TDE_PUBLIC AppListCard : public QWidget
30{
31 Q_OBJECT
32
33private:
34 QSize _grid_size;
35
36public:
43 AppListCard(const QSize& grid_size, QWidget* parent = nullptr);
44 ~AppListCard() override = default;
45
51 void add_app(const app::Info& app);
52
58 [[nodiscard]] TDE_INLINE auto app_count() const { return layout()->count(); }
59
65 [[nodiscard]] TDE_INLINE auto app_size() const
66 {
67 return _grid_size.width() * _grid_size.height();
68 }
69
75 [[nodiscard]] TDE_INLINE auto is_full() const
76 {
77 return app_count() >= app_size();
78 }
79
80signals:
86 void request_launch_app(const app::Info& app);
87};
88
93class TDE_PUBLIC AppList : public QWidget
94{
95 Q_OBJECT
96
97private:
98 QSize _grid_size;
99 QList<AppListCard*> _cards;
100 QStackedWidget* _stack;
101 RadioSelector* _selector;
102
103public:
110 AppList(const DesktopSettings& settings, QWidget* parent = nullptr);
111 ~AppList() override = default;
112
113private:
118 void _init();
119
124 void _init_ui();
125
130 void _create_card();
131
136 void _clear_cards();
137
138signals:
145
146public slots:
152 void on_apps_changed(const QList<app::Info>& apps);
153
154private slots:
160 void on_selected(int index);
161};
162
163}
Desktop settings.
Definition settings.hpp:27
Application list card.
Definition applist.hpp:30
TDE_INLINE auto app_size() const
Returns the size of the app grid.
Definition applist.hpp:65
TDE_INLINE auto is_full() const
Checks if the card is full.
Definition applist.hpp:75
void request_launch_app(const app::Info &app)
Emitted when the app is requested to be launched.
TDE_INLINE auto app_count() const
Returns the number of apps in the card.
Definition applist.hpp:58
Application list widget, which is a group of AppListCard.
Definition applist.hpp:94
void request_launch_app(const app::Info &app)
Emitted when the app is requested to be launched.
Group of radio buttons used for selecting an item.
Definition radioselector.hpp:26
Some utility macros.
Application information.
AppListCard selector.
Desktop settings.
Application information.
Definition info.hpp:23