2014-01-28 22:55:02 +01:00
|
|
|
/*
|
2020-08-13 21:08:54 +02:00
|
|
|
SPDX-FileCopyrightText: 2014 Marco Martin <mart@kde.org>
|
|
|
|
|
|
|
|
SPDX-License-Identifier: LGPL-2.0-or-later
|
|
|
|
*/
|
2014-01-28 22:55:02 +01:00
|
|
|
|
2014-02-05 18:00:05 +01:00
|
|
|
#ifndef APPLETQUICKITEM_H
|
|
|
|
#define APPLETQUICKITEM_H
|
2014-01-28 22:55:02 +01:00
|
|
|
|
|
|
|
#include <QQmlComponent>
|
2014-02-05 12:51:31 +01:00
|
|
|
#include <QQmlEngine>
|
2021-03-05 19:15:32 +01:00
|
|
|
#include <QQuickItem>
|
2014-01-28 22:55:02 +01:00
|
|
|
#include <QTimer>
|
|
|
|
|
2014-02-05 12:51:31 +01:00
|
|
|
#include <Plasma/Package>
|
2014-01-28 22:55:02 +01:00
|
|
|
|
2016-03-17 13:33:19 +01:00
|
|
|
#include <plasmaquick/plasmaquick_export.h>
|
2014-01-28 22:55:02 +01:00
|
|
|
|
2014-02-20 11:19:50 +01:00
|
|
|
//
|
|
|
|
// W A R N I N G
|
|
|
|
// -------------
|
|
|
|
//
|
|
|
|
// This file is not part of the public Plasma API. It exists purely as an
|
|
|
|
// implementation detail. This header file may change from version to
|
|
|
|
// version without notice, or even be removed.
|
|
|
|
//
|
|
|
|
// We mean it.
|
|
|
|
//
|
|
|
|
|
2014-04-26 01:45:47 +02:00
|
|
|
namespace Plasma
|
|
|
|
{
|
|
|
|
class Applet;
|
2014-01-28 22:55:02 +01:00
|
|
|
}
|
|
|
|
|
2014-04-26 01:45:47 +02:00
|
|
|
namespace KDeclarative
|
|
|
|
{
|
|
|
|
class QmlObject;
|
2014-01-28 22:55:02 +01:00
|
|
|
}
|
|
|
|
|
2014-04-26 01:45:47 +02:00
|
|
|
namespace PlasmaQuick
|
|
|
|
{
|
2014-02-05 18:00:05 +01:00
|
|
|
class AppletQuickItemPrivate;
|
|
|
|
|
2014-02-05 17:23:52 +01:00
|
|
|
class PLASMAQUICK_EXPORT AppletQuickItem : public QQuickItem
|
2014-01-28 22:55:02 +01:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
Q_PROPERTY(int switchWidth READ switchWidth WRITE setSwitchWidth NOTIFY switchWidthChanged)
|
|
|
|
Q_PROPERTY(int switchHeight READ switchHeight WRITE setSwitchHeight NOTIFY switchHeightChanged)
|
|
|
|
|
|
|
|
Q_PROPERTY(QQmlComponent *compactRepresentation READ compactRepresentation WRITE setCompactRepresentation NOTIFY compactRepresentationChanged)
|
2014-05-27 16:56:26 +02:00
|
|
|
Q_PROPERTY(QQuickItem *compactRepresentationItem READ compactRepresentationItem NOTIFY compactRepresentationItemChanged)
|
2014-01-28 22:55:02 +01:00
|
|
|
|
|
|
|
Q_PROPERTY(QQmlComponent *fullRepresentation READ fullRepresentation WRITE setFullRepresentation NOTIFY fullRepresentationChanged)
|
2014-05-27 16:56:26 +02:00
|
|
|
Q_PROPERTY(QQuickItem *fullRepresentationItem READ fullRepresentationItem NOTIFY fullRepresentationItemChanged)
|
2014-01-28 22:55:02 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* this is supposed to be either one between compactRepresentation or fullRepresentation
|
|
|
|
*/
|
|
|
|
Q_PROPERTY(QQmlComponent *preferredRepresentation READ preferredRepresentation WRITE setPreferredRepresentation NOTIFY preferredRepresentationChanged)
|
|
|
|
|
2014-01-29 17:09:43 +01:00
|
|
|
/**
|
|
|
|
* True when the applet is showing its full representation. either as the main only view, or in a popup.
|
|
|
|
* Setting it will open or close the popup if the plasmoid is iconified, however it won't have effect if the applet is open
|
|
|
|
*/
|
|
|
|
Q_PROPERTY(bool expanded WRITE setExpanded READ isExpanded NOTIFY expandedChanged)
|
|
|
|
|
2016-10-19 18:51:15 +02:00
|
|
|
/**
|
|
|
|
* True when the applet wants the activation signal act in toggle mode, i.e. while being expanded
|
2018-10-22 20:05:29 +02:00
|
|
|
* the signal shrinks the applet to its not expanded state instead of reexpanding it.
|
2016-10-19 18:51:15 +02:00
|
|
|
*/
|
|
|
|
Q_PROPERTY(bool activationTogglesExpanded WRITE setActivationTogglesExpanded READ isActivationTogglesExpanded NOTIFY activationTogglesExpandedChanged)
|
|
|
|
|
2014-05-09 13:12:38 +02:00
|
|
|
/**
|
|
|
|
* the applet root QML item: sometimes is the same as fullRepresentationItem
|
|
|
|
* if a fullrepresentation was not declared explicitly
|
|
|
|
*/
|
|
|
|
Q_PROPERTY(QObject *rootItem READ rootItem CONSTANT)
|
|
|
|
|
2014-01-28 22:55:02 +01:00
|
|
|
public:
|
2017-12-13 07:35:58 +01:00
|
|
|
AppletQuickItem(Plasma::Applet *applet, QQuickItem *parent = nullptr);
|
2018-05-23 08:05:31 +02:00
|
|
|
~AppletQuickItem() override;
|
2014-01-28 22:55:02 +01:00
|
|
|
|
2021-03-05 19:15:32 +01:00
|
|
|
////API NOT SUPPOSED TO BE USED BY QML
|
2014-02-05 12:51:31 +01:00
|
|
|
Plasma::Applet *applet() const;
|
2014-01-28 22:55:02 +01:00
|
|
|
|
2021-03-05 19:15:32 +01:00
|
|
|
// Make the constructor lighter and delay the actual instantiation of the qml in the applet
|
2014-02-05 13:51:41 +01:00
|
|
|
virtual void init();
|
|
|
|
|
2019-10-15 20:23:31 +02:00
|
|
|
#if PLASMAQUICK_ENABLE_DEPRECATED_SINCE(5, 36)
|
|
|
|
PLASMAQUICK_DEPRECATED_VERSION(5, 36, "No longer use")
|
|
|
|
Plasma::Package appletPackage() const;
|
|
|
|
PLASMAQUICK_DEPRECATED_VERSION(5, 36, "No longer use")
|
|
|
|
void setAppletPackage(const Plasma::Package &package);
|
|
|
|
|
|
|
|
PLASMAQUICK_DEPRECATED_VERSION(5, 36, "No longer use")
|
|
|
|
Plasma::Package coronaPackage() const;
|
|
|
|
PLASMAQUICK_DEPRECATED_VERSION(5, 36, "No longer use")
|
|
|
|
void setCoronaPackage(const Plasma::Package &package);
|
|
|
|
#endif
|
2014-02-05 13:51:41 +01:00
|
|
|
|
2014-05-27 16:56:26 +02:00
|
|
|
QQuickItem *compactRepresentationItem();
|
|
|
|
QQuickItem *fullRepresentationItem();
|
2014-05-09 13:12:38 +02:00
|
|
|
QObject *rootItem();
|
2016-03-16 12:32:25 +01:00
|
|
|
QObject *testItem();
|
2014-02-05 13:51:41 +01:00
|
|
|
|
2021-03-05 19:15:32 +01:00
|
|
|
////PROPERTY ACCESSORS
|
2014-01-28 22:55:02 +01:00
|
|
|
int switchWidth() const;
|
|
|
|
void setSwitchWidth(int width);
|
|
|
|
|
|
|
|
int switchHeight() const;
|
|
|
|
void setSwitchHeight(int width);
|
|
|
|
|
|
|
|
QQmlComponent *compactRepresentation();
|
|
|
|
void setCompactRepresentation(QQmlComponent *component);
|
|
|
|
|
|
|
|
QQmlComponent *fullRepresentation();
|
|
|
|
void setFullRepresentation(QQmlComponent *component);
|
|
|
|
|
|
|
|
QQmlComponent *preferredRepresentation();
|
|
|
|
void setPreferredRepresentation(QQmlComponent *component);
|
|
|
|
|
2014-02-05 13:51:41 +01:00
|
|
|
bool isExpanded() const;
|
|
|
|
void setExpanded(bool expanded);
|
2014-01-29 16:20:39 +01:00
|
|
|
|
2016-10-19 18:51:15 +02:00
|
|
|
bool isActivationTogglesExpanded() const;
|
|
|
|
void setActivationTogglesExpanded(bool activationTogglesExpanded);
|
|
|
|
|
2021-03-05 19:15:32 +01:00
|
|
|
////NEEDED BY QML TO CREATE ATTACHED PROPERTIES
|
2014-02-05 17:23:52 +01:00
|
|
|
static AppletQuickItem *qmlAttachedProperties(QObject *object);
|
2014-01-29 16:20:39 +01:00
|
|
|
|
2014-01-28 22:55:02 +01:00
|
|
|
Q_SIGNALS:
|
2021-03-05 19:15:32 +01:00
|
|
|
// Property signals
|
2014-01-28 22:55:02 +01:00
|
|
|
void switchWidthChanged(int width);
|
|
|
|
void switchHeightChanged(int height);
|
|
|
|
|
2014-02-05 13:51:41 +01:00
|
|
|
void expandedChanged(bool expanded);
|
2016-10-19 18:51:15 +02:00
|
|
|
void activationTogglesExpandedChanged(bool activationTogglesExpanded);
|
2014-02-05 13:51:41 +01:00
|
|
|
|
2014-01-28 22:55:02 +01:00
|
|
|
void compactRepresentationChanged(QQmlComponent *compactRepresentation);
|
|
|
|
void fullRepresentationChanged(QQmlComponent *fullRepresentation);
|
|
|
|
void preferredRepresentationChanged(QQmlComponent *preferredRepresentation);
|
|
|
|
|
|
|
|
void compactRepresentationItemChanged(QObject *compactRepresentationItem);
|
|
|
|
void fullRepresentationItemChanged(QObject *fullRepresentationItem);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
KDeclarative::QmlObject *qmlObject();
|
2014-02-05 16:23:57 +01:00
|
|
|
|
2021-03-05 19:15:32 +01:00
|
|
|
// Reimplementation
|
2018-05-23 08:05:31 +02:00
|
|
|
void childEvent(QChildEvent *event) override;
|
|
|
|
void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) override;
|
|
|
|
void itemChange(ItemChange change, const ItemChangeData &value) override;
|
2014-01-28 22:55:02 +01:00
|
|
|
|
|
|
|
private:
|
2014-02-05 14:54:22 +01:00
|
|
|
AppletQuickItemPrivate *const d;
|
2014-02-05 16:02:28 +01:00
|
|
|
|
|
|
|
Q_PRIVATE_SLOT(d, void minimumWidthChanged())
|
2014-02-05 16:23:57 +01:00
|
|
|
Q_PRIVATE_SLOT(d, void minimumHeightChanged())
|
|
|
|
Q_PRIVATE_SLOT(d, void preferredWidthChanged())
|
|
|
|
Q_PRIVATE_SLOT(d, void preferredHeightChanged())
|
|
|
|
Q_PRIVATE_SLOT(d, void maximumWidthChanged())
|
|
|
|
Q_PRIVATE_SLOT(d, void maximumHeightChanged())
|
|
|
|
Q_PRIVATE_SLOT(d, void fillWidthChanged())
|
|
|
|
Q_PRIVATE_SLOT(d, void fillHeightChanged())
|
2014-01-28 22:55:02 +01:00
|
|
|
};
|
|
|
|
|
2014-02-19 19:37:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
QML_DECLARE_TYPEINFO(PlasmaQuick::AppletQuickItem, QML_HAS_ATTACHED_PROPERTIES)
|
|
|
|
|
2014-01-28 22:55:02 +01:00
|
|
|
#endif
|