mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-04-29 15:03:09 +00:00
homescreens/folio: Do not initialize shared_ptr with a QObject parent
This MR ensures that delegates created with make_shared do not also get initialized with a QObject parent. Some of the classes used the same constructor parameter for HomeScreen and used it as a parent simultaneously. This was refactored so that they are separated.
This commit is contained in:
parent
0fe7879afa
commit
ecefc446a6
12 changed files with 68 additions and 68 deletions
|
|
@ -130,8 +130,8 @@ void ApplicationListModel::load()
|
||||||
|
|
||||||
// Append new elements
|
// Append new elements
|
||||||
for (const KService::Ptr &service : toInsert) {
|
for (const KService::Ptr &service : toInsert) {
|
||||||
FolioApplication::Ptr app = std::make_shared<FolioApplication>(m_homeScreen, service);
|
FolioApplication::Ptr app = std::make_shared<FolioApplication>(service);
|
||||||
FolioDelegate::Ptr delegate = std::make_shared<FolioDelegate>(app, m_homeScreen);
|
FolioDelegate::Ptr delegate = std::make_shared<FolioDelegate>(app);
|
||||||
|
|
||||||
beginInsertRows({}, m_delegates.size(), m_delegates.size());
|
beginInsertRows({}, m_delegates.size(), m_delegates.size());
|
||||||
m_delegates.append(delegate);
|
m_delegates.append(delegate);
|
||||||
|
|
|
||||||
|
|
@ -505,8 +505,8 @@ void DragState::onDelegateDragFromAppDrawerStarted(QString storageId)
|
||||||
{
|
{
|
||||||
// fetch delegate at start position
|
// fetch delegate at start position
|
||||||
if (KService::Ptr service = KService::serviceByStorageId(storageId)) {
|
if (KService::Ptr service = KService::serviceByStorageId(storageId)) {
|
||||||
FolioApplication::Ptr app = std::make_shared<FolioApplication>(m_homeScreen, service);
|
FolioApplication::Ptr app = std::make_shared<FolioApplication>(service);
|
||||||
setDropDelegate(std::make_shared<FolioDelegate>(app, m_homeScreen));
|
setDropDelegate(std::make_shared<FolioDelegate>(app));
|
||||||
} else {
|
} else {
|
||||||
setDropDelegate(nullptr);
|
setDropDelegate(nullptr);
|
||||||
}
|
}
|
||||||
|
|
@ -531,7 +531,7 @@ void DragState::onDelegateDragFromWidgetListStarted(QString appletPluginId)
|
||||||
// default widget has dimensions of 1x1, and id of -1
|
// default widget has dimensions of 1x1, and id of -1
|
||||||
m_createdAppletPluginId = appletPluginId;
|
m_createdAppletPluginId = appletPluginId;
|
||||||
FolioWidget::Ptr widget = std::make_shared<FolioWidget>(m_homeScreen, -1, 1, 1);
|
FolioWidget::Ptr widget = std::make_shared<FolioWidget>(m_homeScreen, -1, 1, 1);
|
||||||
setDropDelegate(std::make_shared<FolioDelegate>(widget, m_homeScreen));
|
setDropDelegate(std::make_shared<FolioDelegate>(widget));
|
||||||
|
|
||||||
// set start location
|
// set start location
|
||||||
m_startPosition->setLocation(DelegateDragPosition::WidgetList);
|
m_startPosition->setLocation(DelegateDragPosition::WidgetList);
|
||||||
|
|
@ -857,7 +857,7 @@ bool DragState::createDropPositionDelegate()
|
||||||
FolioApplicationFolder::Ptr folder = std::make_shared<FolioApplicationFolder>(m_homeScreen, DEFAULT_FOLDER_NAME);
|
FolioApplicationFolder::Ptr folder = std::make_shared<FolioApplicationFolder>(m_homeScreen, DEFAULT_FOLDER_NAME);
|
||||||
folder->addDelegate(m_dropDelegate, 0);
|
folder->addDelegate(m_dropDelegate, 0);
|
||||||
folder->addDelegate(existingDelegate, 0);
|
folder->addDelegate(existingDelegate, 0);
|
||||||
FolioDelegate::Ptr folderDelegate = std::make_shared<FolioDelegate>(folder, m_homeScreen);
|
FolioDelegate::Ptr folderDelegate = std::make_shared<FolioDelegate>(folder);
|
||||||
|
|
||||||
m_homeScreen->favouritesModel()->removeEntry(m_candidateDropPosition->favouritesPosition());
|
m_homeScreen->favouritesModel()->removeEntry(m_candidateDropPosition->favouritesPosition());
|
||||||
m_homeScreen->favouritesModel()->addEntry(m_candidateDropPosition->favouritesPosition(), folderDelegate);
|
m_homeScreen->favouritesModel()->addEntry(m_candidateDropPosition->favouritesPosition(), folderDelegate);
|
||||||
|
|
|
||||||
|
|
@ -196,7 +196,7 @@ void FavouritesModel::setGhostEntry(int row)
|
||||||
|
|
||||||
// if it doesn't, add a new empty delegate
|
// if it doesn't, add a new empty delegate
|
||||||
if (!found) {
|
if (!found) {
|
||||||
FolioDelegate::Ptr ghost = std::make_shared<FolioDelegate>(m_homeScreen);
|
FolioDelegate::Ptr ghost = std::make_shared<FolioDelegate>();
|
||||||
addEntry(row, ghost);
|
addEntry(row, ghost);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
#include <KNotificationJobUiDelegate>
|
#include <KNotificationJobUiDelegate>
|
||||||
|
|
||||||
FolioApplication::FolioApplication(HomeScreen *parent, KService::Ptr service)
|
FolioApplication::FolioApplication(KService::Ptr service, QObject *parent)
|
||||||
: QObject{parent}
|
: QObject{parent}
|
||||||
, m_running{false}
|
, m_running{false}
|
||||||
, m_name{service->name()}
|
, m_name{service->name()}
|
||||||
|
|
@ -39,11 +39,11 @@ FolioApplication::FolioApplication(HomeScreen *parent, KService::Ptr service)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
FolioApplication::Ptr FolioApplication::fromJson(QJsonObject &obj, HomeScreen *parent)
|
FolioApplication::Ptr FolioApplication::fromJson(QJsonObject &obj)
|
||||||
{
|
{
|
||||||
QString storageId = obj[QStringLiteral("storageId")].toString();
|
QString storageId = obj[QStringLiteral("storageId")].toString();
|
||||||
if (KService::Ptr service = KService::serviceByStorageId(storageId)) {
|
if (KService::Ptr service = KService::serviceByStorageId(storageId)) {
|
||||||
return std::make_shared<FolioApplication>(parent, service);
|
return std::make_shared<FolioApplication>(service);
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -34,9 +34,9 @@ class FolioApplication : public QObject, public std::enable_shared_from_this<Fol
|
||||||
public:
|
public:
|
||||||
typedef std::shared_ptr<FolioApplication> Ptr;
|
typedef std::shared_ptr<FolioApplication> Ptr;
|
||||||
|
|
||||||
FolioApplication(HomeScreen *parent = nullptr, KService::Ptr service = QExplicitlySharedDataPointer<KService>{nullptr});
|
FolioApplication(KService::Ptr service = QExplicitlySharedDataPointer<KService>{nullptr}, QObject *parent = nullptr);
|
||||||
|
|
||||||
static FolioApplication::Ptr fromJson(QJsonObject &obj, HomeScreen *parent); // may return nullptr
|
static FolioApplication::Ptr fromJson(QJsonObject &obj); // may return nullptr
|
||||||
QJsonObject toJson() const;
|
QJsonObject toJson() const;
|
||||||
|
|
||||||
bool running() const;
|
bool running() const;
|
||||||
|
|
|
||||||
|
|
@ -7,25 +7,25 @@
|
||||||
#include <QJsonArray>
|
#include <QJsonArray>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
FolioApplicationFolder::FolioApplicationFolder(HomeScreen *parent, QString name)
|
FolioApplicationFolder::FolioApplicationFolder(HomeScreen *homeScreen, QString name, QObject *parent)
|
||||||
: QObject{parent}
|
: QObject{parent}
|
||||||
, m_homeScreen{parent}
|
, m_homeScreen{homeScreen}
|
||||||
, m_name{name}
|
, m_name{name}
|
||||||
, m_applicationFolderModel{new ApplicationFolderModel{this}}
|
, m_applicationFolderModel{new ApplicationFolderModel{this}}
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
FolioApplicationFolder::Ptr FolioApplicationFolder::fromJson(QJsonObject &obj, HomeScreen *parent)
|
FolioApplicationFolder::Ptr FolioApplicationFolder::fromJson(QJsonObject &obj, HomeScreen *homeScreen)
|
||||||
{
|
{
|
||||||
QString name = obj[QStringLiteral("name")].toString();
|
QString name = obj[QStringLiteral("name")].toString();
|
||||||
QList<FolioApplication::Ptr> apps;
|
QList<FolioApplication::Ptr> apps;
|
||||||
for (auto storageId : obj[QStringLiteral("apps")].toArray()) {
|
for (auto storageId : obj[QStringLiteral("apps")].toArray()) {
|
||||||
if (KService::Ptr service = KService::serviceByStorageId(storageId.toString())) {
|
if (KService::Ptr service = KService::serviceByStorageId(storageId.toString())) {
|
||||||
apps.append(std::make_shared<FolioApplication>(parent, service));
|
apps.append(std::make_shared<FolioApplication>(service));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FolioApplicationFolder::Ptr folder = std::make_shared<FolioApplicationFolder>(parent, name);
|
FolioApplicationFolder::Ptr folder = std::make_shared<FolioApplicationFolder>(homeScreen, name);
|
||||||
folder->setApplications(apps);
|
folder->setApplications(apps);
|
||||||
return folder;
|
return folder;
|
||||||
}
|
}
|
||||||
|
|
@ -339,7 +339,7 @@ void ApplicationFolderModel::setGhostEntry(int index)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ghost) {
|
if (!ghost) {
|
||||||
ghost = std::make_shared<FolioDelegate>(m_folder->m_homeScreen);
|
ghost = std::make_shared<FolioDelegate>();
|
||||||
}
|
}
|
||||||
|
|
||||||
// add empty delegate at new position
|
// add empty delegate at new position
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ class FolioApplicationFolder : public QObject, public std::enable_shared_from_th
|
||||||
public:
|
public:
|
||||||
typedef std::shared_ptr<FolioApplicationFolder> Ptr;
|
typedef std::shared_ptr<FolioApplicationFolder> Ptr;
|
||||||
|
|
||||||
FolioApplicationFolder(HomeScreen *parent = nullptr, QString name = QString{});
|
FolioApplicationFolder(HomeScreen *homeScreen = nullptr, QString name = QString{}, QObject *parent = nullptr);
|
||||||
|
|
||||||
static std::shared_ptr<FolioApplicationFolder> fromJson(QJsonObject &obj, HomeScreen *parent);
|
static std::shared_ptr<FolioApplicationFolder> fromJson(QJsonObject &obj, HomeScreen *parent);
|
||||||
QJsonObject toJson() const;
|
QJsonObject toJson() const;
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
#include "foliodelegate.h"
|
#include "foliodelegate.h"
|
||||||
#include "homescreenstate.h"
|
#include "homescreenstate.h"
|
||||||
|
|
||||||
FolioDelegate::FolioDelegate(HomeScreen *parent)
|
FolioDelegate::FolioDelegate(QObject *parent)
|
||||||
: QObject{parent}
|
: QObject{parent}
|
||||||
, m_type{FolioDelegate::None}
|
, m_type{FolioDelegate::None}
|
||||||
, m_application{nullptr}
|
, m_application{nullptr}
|
||||||
|
|
@ -13,7 +13,7 @@ FolioDelegate::FolioDelegate(HomeScreen *parent)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
FolioDelegate::FolioDelegate(FolioApplication::Ptr application, HomeScreen *parent)
|
FolioDelegate::FolioDelegate(FolioApplication::Ptr application, QObject *parent)
|
||||||
: QObject{parent}
|
: QObject{parent}
|
||||||
, m_type{FolioDelegate::Application}
|
, m_type{FolioDelegate::Application}
|
||||||
, m_application{application}
|
, m_application{application}
|
||||||
|
|
@ -22,7 +22,7 @@ FolioDelegate::FolioDelegate(FolioApplication::Ptr application, HomeScreen *pare
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
FolioDelegate::FolioDelegate(FolioApplicationFolder::Ptr folder, HomeScreen *parent)
|
FolioDelegate::FolioDelegate(FolioApplicationFolder::Ptr folder, QObject *parent)
|
||||||
: QObject{parent}
|
: QObject{parent}
|
||||||
, m_type{FolioDelegate::Folder}
|
, m_type{FolioDelegate::Folder}
|
||||||
, m_application{nullptr}
|
, m_application{nullptr}
|
||||||
|
|
@ -31,7 +31,7 @@ FolioDelegate::FolioDelegate(FolioApplicationFolder::Ptr folder, HomeScreen *par
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
FolioDelegate::FolioDelegate(FolioWidget::Ptr widget, HomeScreen *parent)
|
FolioDelegate::FolioDelegate(FolioWidget::Ptr widget, QObject *parent)
|
||||||
: QObject{parent}
|
: QObject{parent}
|
||||||
, m_type{FolioDelegate::Widget}
|
, m_type{FolioDelegate::Widget}
|
||||||
, m_application{nullptr}
|
, m_application{nullptr}
|
||||||
|
|
@ -40,34 +40,34 @@ FolioDelegate::FolioDelegate(FolioWidget::Ptr widget, HomeScreen *parent)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
FolioDelegate::Ptr FolioDelegate::fromJson(QJsonObject &obj, HomeScreen *parent)
|
FolioDelegate::Ptr FolioDelegate::fromJson(QJsonObject &obj, HomeScreen *homeScreen)
|
||||||
{
|
{
|
||||||
const QString type = obj[QStringLiteral("type")].toString();
|
const QString type = obj[QStringLiteral("type")].toString();
|
||||||
if (type == "application") {
|
if (type == "application") {
|
||||||
// read application
|
// read application
|
||||||
FolioApplication::Ptr app = FolioApplication::fromJson(obj, parent);
|
FolioApplication::Ptr app = FolioApplication::fromJson(obj);
|
||||||
|
|
||||||
if (app) {
|
if (app) {
|
||||||
return std::make_shared<FolioDelegate>(app, parent);
|
return std::make_shared<FolioDelegate>(app);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (type == "folder") {
|
} else if (type == "folder") {
|
||||||
// read folder
|
// read folder
|
||||||
FolioApplicationFolder::Ptr folder = FolioApplicationFolder::fromJson(obj, parent);
|
FolioApplicationFolder::Ptr folder = FolioApplicationFolder::fromJson(obj, homeScreen);
|
||||||
|
|
||||||
if (folder) {
|
if (folder) {
|
||||||
return std::make_shared<FolioDelegate>(folder, parent);
|
return std::make_shared<FolioDelegate>(folder);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (type == "widget") {
|
} else if (type == "widget") {
|
||||||
// read widget
|
// read widget
|
||||||
FolioWidget::Ptr widget = FolioWidget::fromJson(obj, parent);
|
FolioWidget::Ptr widget = FolioWidget::fromJson(obj, homeScreen);
|
||||||
|
|
||||||
if (widget) {
|
if (widget) {
|
||||||
return std::make_shared<FolioDelegate>(widget, parent);
|
return std::make_shared<FolioDelegate>(widget);
|
||||||
}
|
}
|
||||||
} else if (type == "none") {
|
} else if (type == "none") {
|
||||||
return std::make_shared<FolioDelegate>(parent);
|
return std::make_shared<FolioDelegate>();
|
||||||
}
|
}
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
@ -128,45 +128,45 @@ FolioWidget *FolioDelegate::widgetRaw()
|
||||||
return m_widget.get();
|
return m_widget.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
FolioPageDelegate::FolioPageDelegate(int row, int column, HomeScreen *parent)
|
FolioPageDelegate::FolioPageDelegate(int row, int column, HomeScreen *homeScreen, QObject *parent)
|
||||||
: FolioDelegate{parent}
|
: FolioDelegate{parent}
|
||||||
, m_homeScreen{parent}
|
, m_homeScreen{homeScreen}
|
||||||
, m_row{row}
|
, m_row{row}
|
||||||
, m_column{column}
|
, m_column{column}
|
||||||
{
|
{
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
FolioPageDelegate::FolioPageDelegate(int row, int column, FolioApplication::Ptr application, HomeScreen *parent)
|
FolioPageDelegate::FolioPageDelegate(int row, int column, FolioApplication::Ptr application, HomeScreen *homeScreen, QObject *parent)
|
||||||
: FolioDelegate{application, parent}
|
: FolioDelegate{application, parent}
|
||||||
, m_homeScreen{parent}
|
, m_homeScreen{homeScreen}
|
||||||
, m_row{row}
|
, m_row{row}
|
||||||
, m_column{column}
|
, m_column{column}
|
||||||
{
|
{
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
FolioPageDelegate::FolioPageDelegate(int row, int column, FolioApplicationFolder::Ptr folder, HomeScreen *parent)
|
FolioPageDelegate::FolioPageDelegate(int row, int column, FolioApplicationFolder::Ptr folder, HomeScreen *homeScreen, QObject *parent)
|
||||||
: FolioDelegate{folder, parent}
|
: FolioDelegate{folder, parent}
|
||||||
, m_homeScreen{parent}
|
, m_homeScreen{homeScreen}
|
||||||
, m_row{row}
|
, m_row{row}
|
||||||
, m_column{column}
|
, m_column{column}
|
||||||
{
|
{
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
FolioPageDelegate::FolioPageDelegate(int row, int column, FolioWidget::Ptr widget, HomeScreen *parent)
|
FolioPageDelegate::FolioPageDelegate(int row, int column, FolioWidget::Ptr widget, HomeScreen *homeScreen, QObject *parent)
|
||||||
: FolioDelegate{widget, parent}
|
: FolioDelegate{widget, parent}
|
||||||
, m_homeScreen{parent}
|
, m_homeScreen{homeScreen}
|
||||||
, m_row{row}
|
, m_row{row}
|
||||||
, m_column{column}
|
, m_column{column}
|
||||||
{
|
{
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
FolioPageDelegate::FolioPageDelegate(int row, int column, FolioDelegate::Ptr delegate, HomeScreen *parent)
|
FolioPageDelegate::FolioPageDelegate(int row, int column, FolioDelegate::Ptr delegate, HomeScreen *homeScreen, QObject *parent)
|
||||||
: FolioDelegate{parent}
|
: FolioDelegate{parent}
|
||||||
, m_homeScreen{parent}
|
, m_homeScreen{homeScreen}
|
||||||
, m_row{row}
|
, m_row{row}
|
||||||
, m_column{column}
|
, m_column{column}
|
||||||
{
|
{
|
||||||
|
|
@ -234,9 +234,9 @@ void FolioPageDelegate::init()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
FolioPageDelegate::Ptr FolioPageDelegate::fromJson(QJsonObject &obj, HomeScreen *parent)
|
FolioPageDelegate::Ptr FolioPageDelegate::fromJson(QJsonObject &obj, HomeScreen *homeScreen)
|
||||||
{
|
{
|
||||||
FolioDelegate::Ptr fd = FolioDelegate::fromJson(obj, parent);
|
FolioDelegate::Ptr fd = FolioDelegate::fromJson(obj, homeScreen);
|
||||||
|
|
||||||
if (!fd) {
|
if (!fd) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
@ -245,10 +245,10 @@ FolioPageDelegate::Ptr FolioPageDelegate::fromJson(QJsonObject &obj, HomeScreen
|
||||||
int realRow = obj[QStringLiteral("row")].toInt();
|
int realRow = obj[QStringLiteral("row")].toInt();
|
||||||
int realColumn = obj[QStringLiteral("column")].toInt();
|
int realColumn = obj[QStringLiteral("column")].toInt();
|
||||||
|
|
||||||
int row = getTranslatedTopLeftRow(parent, realRow, realColumn, fd);
|
int row = getTranslatedTopLeftRow(homeScreen, realRow, realColumn, fd);
|
||||||
int column = getTranslatedTopLeftColumn(parent, realRow, realColumn, fd);
|
int column = getTranslatedTopLeftColumn(homeScreen, realRow, realColumn, fd);
|
||||||
|
|
||||||
FolioPageDelegate::Ptr delegate = std::make_shared<FolioPageDelegate>(row, column, fd, parent);
|
FolioPageDelegate::Ptr delegate = std::make_shared<FolioPageDelegate>(row, column, fd, homeScreen);
|
||||||
fd->deleteLater();
|
fd->deleteLater();
|
||||||
|
|
||||||
return delegate;
|
return delegate;
|
||||||
|
|
|
||||||
|
|
@ -34,12 +34,12 @@ public:
|
||||||
};
|
};
|
||||||
Q_ENUM(Type)
|
Q_ENUM(Type)
|
||||||
|
|
||||||
FolioDelegate(HomeScreen *parent);
|
FolioDelegate(QObject *parent = nullptr);
|
||||||
FolioDelegate(std::shared_ptr<FolioApplication> application, HomeScreen *parent);
|
FolioDelegate(std::shared_ptr<FolioApplication> application, QObject *parent = nullptr);
|
||||||
FolioDelegate(std::shared_ptr<FolioApplicationFolder> folder, HomeScreen *parent);
|
FolioDelegate(std::shared_ptr<FolioApplicationFolder> folder, QObject *parent = nullptr);
|
||||||
FolioDelegate(std::shared_ptr<FolioWidget> widget, HomeScreen *parent);
|
FolioDelegate(std::shared_ptr<FolioWidget> widget, QObject *parent = nullptr);
|
||||||
|
|
||||||
static std::shared_ptr<FolioDelegate> fromJson(QJsonObject &obj, HomeScreen *parent);
|
static std::shared_ptr<FolioDelegate> fromJson(QJsonObject &obj, HomeScreen *homeScreen);
|
||||||
|
|
||||||
virtual QJsonObject toJson() const;
|
virtual QJsonObject toJson() const;
|
||||||
|
|
||||||
|
|
@ -71,13 +71,13 @@ class FolioPageDelegate : public FolioDelegate
|
||||||
public:
|
public:
|
||||||
typedef std::shared_ptr<FolioPageDelegate> Ptr;
|
typedef std::shared_ptr<FolioPageDelegate> Ptr;
|
||||||
|
|
||||||
FolioPageDelegate(int row = 0, int column = 0, HomeScreen *parent = nullptr);
|
FolioPageDelegate(int row = 0, int column = 0, HomeScreen *homeScreen = nullptr, QObject *parent = nullptr);
|
||||||
FolioPageDelegate(int row, int column, std::shared_ptr<FolioApplication> application, HomeScreen *parent);
|
FolioPageDelegate(int row, int column, std::shared_ptr<FolioApplication> application, HomeScreen *homeScreen, QObject *parent = nullptr);
|
||||||
FolioPageDelegate(int row, int column, std::shared_ptr<FolioApplicationFolder> folder, HomeScreen *parent);
|
FolioPageDelegate(int row, int column, std::shared_ptr<FolioApplicationFolder> folder, HomeScreen *homeScreen, QObject *parent = nullptr);
|
||||||
FolioPageDelegate(int row, int column, std::shared_ptr<FolioWidget> widget, HomeScreen *parent);
|
FolioPageDelegate(int row, int column, std::shared_ptr<FolioWidget> widget, HomeScreen *homeScreen, QObject *parent = nullptr);
|
||||||
FolioPageDelegate(int row, int column, std::shared_ptr<FolioDelegate> delegate, HomeScreen *parent);
|
FolioPageDelegate(int row, int column, std::shared_ptr<FolioDelegate> delegate, HomeScreen *homeScreen, QObject *parent = nullptr);
|
||||||
|
|
||||||
static std::shared_ptr<FolioPageDelegate> fromJson(QJsonObject &obj, HomeScreen *parent);
|
static std::shared_ptr<FolioPageDelegate> fromJson(QJsonObject &obj, HomeScreen *homeScreen);
|
||||||
static int getTranslatedTopLeftRow(HomeScreen *homeScreen, int realRow, int realColumn, std::shared_ptr<FolioDelegate> fd);
|
static int getTranslatedTopLeftRow(HomeScreen *homeScreen, int realRow, int realColumn, std::shared_ptr<FolioDelegate> fd);
|
||||||
static int getTranslatedTopLeftColumn(HomeScreen *homeScreen, int realRow, int realColumn, std::shared_ptr<FolioDelegate> fd);
|
static int getTranslatedTopLeftColumn(HomeScreen *homeScreen, int realRow, int realColumn, std::shared_ptr<FolioDelegate> fd);
|
||||||
static int getTranslatedRow(HomeScreen *homeScreen, int realRow, int realColumn);
|
static int getTranslatedRow(HomeScreen *homeScreen, int realRow, int realColumn);
|
||||||
|
|
|
||||||
|
|
@ -5,9 +5,9 @@
|
||||||
#include "homescreenstate.h"
|
#include "homescreenstate.h"
|
||||||
#include "widgetsmanager.h"
|
#include "widgetsmanager.h"
|
||||||
|
|
||||||
FolioWidget::FolioWidget(HomeScreen *parent, int id, int realGridWidth, int realGridHeight)
|
FolioWidget::FolioWidget(HomeScreen *homeScreen, int id, int realGridWidth, int realGridHeight, QObject *parent)
|
||||||
: QObject{parent}
|
: QObject{parent}
|
||||||
, m_homeScreen{parent}
|
, m_homeScreen{homeScreen}
|
||||||
, m_id{id}
|
, m_id{id}
|
||||||
, m_realGridWidth{realGridWidth}
|
, m_realGridWidth{realGridWidth}
|
||||||
, m_realGridHeight{realGridHeight}
|
, m_realGridHeight{realGridHeight}
|
||||||
|
|
@ -21,9 +21,9 @@ FolioWidget::FolioWidget(HomeScreen *parent, int id, int realGridWidth, int real
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
FolioWidget::FolioWidget(HomeScreen *parent, Plasma::Applet *applet, int realGridWidth, int realGridHeight)
|
FolioWidget::FolioWidget(HomeScreen *homeScreen, Plasma::Applet *applet, int realGridWidth, int realGridHeight, QObject *parent)
|
||||||
: QObject{parent}
|
: QObject{parent}
|
||||||
, m_homeScreen{parent}
|
, m_homeScreen{homeScreen}
|
||||||
, m_id{applet ? static_cast<int>(applet->id()) : -1}
|
, m_id{applet ? static_cast<int>(applet->id()) : -1}
|
||||||
, m_realGridWidth{realGridWidth}
|
, m_realGridWidth{realGridWidth}
|
||||||
, m_realGridHeight{realGridHeight}
|
, m_realGridHeight{realGridHeight}
|
||||||
|
|
@ -51,12 +51,12 @@ void FolioWidget::init()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
FolioWidget::Ptr FolioWidget::fromJson(QJsonObject &obj, HomeScreen *parent)
|
FolioWidget::Ptr FolioWidget::fromJson(QJsonObject &obj, HomeScreen *homeScreen)
|
||||||
{
|
{
|
||||||
int id = obj[QStringLiteral("id")].toInt();
|
int id = obj[QStringLiteral("id")].toInt();
|
||||||
int gridWidth = obj[QStringLiteral("gridWidth")].toInt();
|
int gridWidth = obj[QStringLiteral("gridWidth")].toInt();
|
||||||
int gridHeight = obj[QStringLiteral("gridHeight")].toInt();
|
int gridHeight = obj[QStringLiteral("gridHeight")].toInt();
|
||||||
return std::make_shared<FolioWidget>(parent, id, gridWidth, gridHeight);
|
return std::make_shared<FolioWidget>(homeScreen, id, gridWidth, gridHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
QJsonObject FolioWidget::toJson() const
|
QJsonObject FolioWidget::toJson() const
|
||||||
|
|
|
||||||
|
|
@ -34,10 +34,10 @@ class FolioWidget : public QObject, public std::enable_shared_from_this<FolioWid
|
||||||
public:
|
public:
|
||||||
typedef std::shared_ptr<FolioWidget> Ptr;
|
typedef std::shared_ptr<FolioWidget> Ptr;
|
||||||
|
|
||||||
FolioWidget(HomeScreen *parent = nullptr, int id = -1, int gridWidth = 0, int gridHeight = 0);
|
FolioWidget(HomeScreen *homeScreen = nullptr, int id = -1, int gridWidth = 0, int gridHeight = 0, QObject *parent = nullptr);
|
||||||
FolioWidget(HomeScreen *parent, Plasma::Applet *applet, int gridWidth, int gridHeight);
|
FolioWidget(HomeScreen *homeScreen, Plasma::Applet *applet, int gridWidth, int gridHeight, QObject *parent = nullptr);
|
||||||
|
|
||||||
static std::shared_ptr<FolioWidget> fromJson(QJsonObject &obj, HomeScreen *parent);
|
static std::shared_ptr<FolioWidget> fromJson(QJsonObject &obj, HomeScreen *homeScreen);
|
||||||
QJsonObject toJson() const;
|
QJsonObject toJson() const;
|
||||||
|
|
||||||
int id() const;
|
int id() const;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue