Revert "Revert "BasicPlasmoidHeading component""
This reverts commit 3a3b78c14683cb46e9e1f9f23e0e8186c78000cd.
This commit is contained in:
parent
3a3b78c146
commit
8b7b4f74c6
@ -246,6 +246,9 @@ void QMenuProxy::addMenuItem(QMenuItem *item, QMenuItem *before)
|
|||||||
m_menu->addAction(item->action());
|
m_menu->addAction(item->action());
|
||||||
m_items << item;
|
m_items << item;
|
||||||
}
|
}
|
||||||
|
connect(item, &QMenuItem::destroyed, this, [this, item]() {
|
||||||
|
removeMenuItem(item);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void QMenuProxy::addSection(const QString &text)
|
void QMenuProxy::addSection(const QString &text)
|
||||||
|
@ -50,6 +50,7 @@ void QMenuItem::setAction(QAction *a)
|
|||||||
|
|
||||||
connect(this, &QQuickItem::visibleChanged, this, &QMenuItem::updateAction);
|
connect(this, &QQuickItem::visibleChanged, this, &QMenuItem::updateAction);
|
||||||
connect(this, &QQuickItem::enabledChanged, this, &QMenuItem::updateAction);
|
connect(this, &QQuickItem::enabledChanged, this, &QMenuItem::updateAction);
|
||||||
|
connect(this, &QObject::destroyed, this, &QMenuItem::deleteLater);
|
||||||
|
|
||||||
emit actionChanged();
|
emit actionChanged();
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,130 @@
|
|||||||
|
/*
|
||||||
|
SPDX-FileCopyrightText: 2020 Marco Martin <mart@kde.org>
|
||||||
|
|
||||||
|
SPDX-License-Identifier: LGPL-2.0-or-later
|
||||||
|
*/
|
||||||
|
|
||||||
|
import QtQuick 2.12
|
||||||
|
import QtQuick.Layouts 1.12
|
||||||
|
|
||||||
|
import org.kde.plasma.core 2.0 as PlasmaCore
|
||||||
|
import org.kde.plasma.components 2.0 as PC2
|
||||||
|
import org.kde.plasma.components 3.0 as PlasmaComponents
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A standard basic header for plasmoids which has title, a config button and
|
||||||
|
* a popup menu with all extra plasmoid actions.
|
||||||
|
* By default, it will be invisible when the plamsoid is in the system tray, as it provides a replacement header with the same features
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @inherit PlasmoidHeading
|
||||||
|
*/
|
||||||
|
PlasmoidHeading {
|
||||||
|
/**
|
||||||
|
* extraControls: list<QtObject>
|
||||||
|
* any extra control and button that may be inserted in the heading
|
||||||
|
*/
|
||||||
|
default property alias extraControls: extraControlsLayout.data
|
||||||
|
|
||||||
|
visible: !(plasmoid.containmentDisplayHints & PlasmaCore.Types.ContainmentDrawsPlasmoidHeading)
|
||||||
|
|
||||||
|
contentItem: RowLayout {
|
||||||
|
Heading {
|
||||||
|
elide: Text.ElideRight
|
||||||
|
wrapMode: Text.NoWrap
|
||||||
|
Layout.fillWidth: true
|
||||||
|
visible: (plasmoid.containmentDisplayHints & PlasmaCore.Types.ContainmentDrawsPlasmoidHeading)
|
||||||
|
level: 1
|
||||||
|
text: plasmoid.title
|
||||||
|
}
|
||||||
|
RowLayout {
|
||||||
|
id: extraControlsLayout
|
||||||
|
visible: children.length > 0
|
||||||
|
Layout.fillHeight: true
|
||||||
|
}
|
||||||
|
PlasmaComponents.ToolButton {
|
||||||
|
id: actionsButton
|
||||||
|
visible: visibleActions > 0 && !(plasmoid.containmentDisplayHints & PlasmaCore.Types.ContainmentDrawsPlasmoidHeading)
|
||||||
|
checked: configMenu.status !== PC2.DialogStatus.Closed
|
||||||
|
property int visibleActions: 0
|
||||||
|
property QtObject singleAction
|
||||||
|
|
||||||
|
Component.onCompleted: updateVisibleActions()
|
||||||
|
function updateVisibleActions() {
|
||||||
|
let newSingleAction = null;
|
||||||
|
let newVisibleActions = 0;
|
||||||
|
for (let i in plasmoid.contextualActions) {
|
||||||
|
let action = plasmoid.contextualActions[i];
|
||||||
|
if (action.visible && action !== plasmoid.action("configure")) {
|
||||||
|
newVisibleActions++;
|
||||||
|
newSingleAction = action;
|
||||||
|
action.changed.connect(() => {updateVisibleActions()});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (newVisibleActions > 1) {
|
||||||
|
newSingleAction = null;
|
||||||
|
}
|
||||||
|
visibleActions = newVisibleActions;
|
||||||
|
singleAction = newSingleAction;
|
||||||
|
}
|
||||||
|
Connections {
|
||||||
|
target: plasmoid
|
||||||
|
function onContextualActionsChanged() {updateVisibleActions();}
|
||||||
|
}
|
||||||
|
icon.name: "application-menu"
|
||||||
|
checkable: visibleActions > 1
|
||||||
|
contentItem.opacity: visibleActions > 1
|
||||||
|
// NOTE: it needs an IconItem because QtQuickControls2 buttons cannot load QIcons as their icon
|
||||||
|
PlasmaCore.IconItem {
|
||||||
|
parent: actionsButton
|
||||||
|
anchors.centerIn: parent
|
||||||
|
active: actionsButton.hovered
|
||||||
|
implicitWidth: PlasmaCore.Units.iconSizes.smallMedium
|
||||||
|
implicitHeight: implicitWidth
|
||||||
|
source: actionsButton.singleAction !== null ? actionsButton.singleAction.icon : ""
|
||||||
|
visible: actionsButton.singleAction
|
||||||
|
}
|
||||||
|
onToggled: {
|
||||||
|
if (checked) {
|
||||||
|
configMenu.openRelative();
|
||||||
|
} else {
|
||||||
|
configMenu.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
onClicked: {
|
||||||
|
if (singleAction) {
|
||||||
|
singleAction.trigger();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
PlasmaComponents.ToolTip {
|
||||||
|
text: actionsButton.singleAction ? actionsButton.singleAction.text : i18n("More actions")
|
||||||
|
}
|
||||||
|
PC2.Menu {
|
||||||
|
id: configMenu
|
||||||
|
visualParent: actionsButton
|
||||||
|
placement: PlasmaCore.Types.BottomPosedLeftAlignedPopup
|
||||||
|
}
|
||||||
|
|
||||||
|
Instantiator {
|
||||||
|
model: plasmoid.contextualActions
|
||||||
|
delegate: PC2.MenuItem {
|
||||||
|
id: menuItem
|
||||||
|
action: modelData
|
||||||
|
}
|
||||||
|
onObjectAdded: {
|
||||||
|
if (object !== plasmoid.action("configure")) {
|
||||||
|
configMenu.addMenuItem(object);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
PlasmaComponents.ToolButton {
|
||||||
|
icon.name: "configure"
|
||||||
|
visible: plasmoid && plasmoid.action("configure") && !(plasmoid.containmentDisplayHints & PlasmaCore.Types.ContainmentDrawsPlasmoidHeading)
|
||||||
|
PlasmaComponents.ToolTip {
|
||||||
|
text: parent.visible ? plasmoid.action("configure").text : ""
|
||||||
|
}
|
||||||
|
onClicked: plasmoid.action("configure").trigger();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -13,6 +13,7 @@ ScrollArea 2.0 ScrollArea.qml
|
|||||||
Title 2.0 Title.qml
|
Title 2.0 Title.qml
|
||||||
DescriptiveLabel 2.0 DescriptiveLabel.qml
|
DescriptiveLabel 2.0 DescriptiveLabel.qml
|
||||||
PlasmoidHeading 2.0 PlasmoidHeading.qml
|
PlasmoidHeading 2.0 PlasmoidHeading.qml
|
||||||
|
BasicPlasmoidHeading 2.0 BasicPlasmoidHeading.qml
|
||||||
|
|
||||||
ActivateAnimation 2.0 animations/ActivateAnimation.qml
|
ActivateAnimation 2.0 animations/ActivateAnimation.qml
|
||||||
AppearAnimation 2.0 animations/AppearAnimation.qml
|
AppearAnimation 2.0 animations/AppearAnimation.qml
|
||||||
|
@ -704,6 +704,13 @@ Types::FormFactor Applet::formFactor() const
|
|||||||
return c ? c->d->formFactor : Plasma::Types::Planar;
|
return c ? c->d->formFactor : Plasma::Types::Planar;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Types::ContainmentDisplayHints Applet::containmentDisplayHints() const
|
||||||
|
{
|
||||||
|
Containment *c = containment();
|
||||||
|
|
||||||
|
return c ? c->d->containmentDisplayHints : Plasma::Types::NoContainmentDisplayHint;
|
||||||
|
}
|
||||||
|
|
||||||
Containment *Applet::containment() const
|
Containment *Applet::containment() const
|
||||||
{
|
{
|
||||||
Containment *c = qobject_cast<Containment *>(const_cast<Applet *>(this));
|
Containment *c = qobject_cast<Containment *>(const_cast<Applet *>(this));
|
||||||
|
@ -58,6 +58,7 @@ class PLASMA_EXPORT Applet : public QObject
|
|||||||
Q_PROPERTY(Plasma::Types::ImmutabilityType immutability READ immutability WRITE setImmutability NOTIFY immutabilityChanged)
|
Q_PROPERTY(Plasma::Types::ImmutabilityType immutability READ immutability WRITE setImmutability NOTIFY immutabilityChanged)
|
||||||
Q_PROPERTY(Plasma::Types::FormFactor formFactor READ formFactor NOTIFY formFactorChanged)
|
Q_PROPERTY(Plasma::Types::FormFactor formFactor READ formFactor NOTIFY formFactorChanged)
|
||||||
Q_PROPERTY(Plasma::Types::Location location READ location NOTIFY locationChanged)
|
Q_PROPERTY(Plasma::Types::Location location READ location NOTIFY locationChanged)
|
||||||
|
Q_PROPERTY(Plasma::Types::ContainmentDisplayHints containmentDisplayHints READ containmentDisplayHints NOTIFY containmentDisplayHintsChanged)
|
||||||
Q_PROPERTY(QString title READ title WRITE setTitle NOTIFY titleChanged FINAL)
|
Q_PROPERTY(QString title READ title WRITE setTitle NOTIFY titleChanged FINAL)
|
||||||
Q_PROPERTY(QString icon READ icon WRITE setIcon NOTIFY iconChanged FINAL)
|
Q_PROPERTY(QString icon READ icon WRITE setIcon NOTIFY iconChanged FINAL)
|
||||||
Q_PROPERTY(bool busy READ isBusy WRITE setBusy NOTIFY busyChanged FINAL)
|
Q_PROPERTY(bool busy READ isBusy WRITE setBusy NOTIFY busyChanged FINAL)
|
||||||
@ -175,6 +176,12 @@ public:
|
|||||||
*/
|
*/
|
||||||
Types::Location location() const;
|
Types::Location location() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Display hints that come from the containment that suggest the applet how to look and behave.
|
||||||
|
* @since 5.77
|
||||||
|
*/
|
||||||
|
Types::ContainmentDisplayHints containmentDisplayHints() const;
|
||||||
|
|
||||||
//CONFIGURATION
|
//CONFIGURATION
|
||||||
/**
|
/**
|
||||||
* Returns the KConfigGroup to access the applets configuration.
|
* Returns the KConfigGroup to access the applets configuration.
|
||||||
@ -582,6 +589,8 @@ Q_SIGNALS:
|
|||||||
*/
|
*/
|
||||||
void locationChanged(Plasma::Types::Location location);
|
void locationChanged(Plasma::Types::Location location);
|
||||||
|
|
||||||
|
void containmentDisplayHintsChanged(Plasma::Types::ContainmentDisplayHints hints);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Emitted when setConfigurationRequired was called
|
* Emitted when setConfigurationRequired was called
|
||||||
* @see setConfigurationRequired
|
* @see setConfigurationRequired
|
||||||
|
@ -343,6 +343,16 @@ void Containment::setFormFactor(Types::FormFactor formFactor)
|
|||||||
emit formFactorChanged(formFactor);
|
emit formFactorChanged(formFactor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Containment::setContainmentDisplayHints(Types::ContainmentDisplayHints hints)
|
||||||
|
{
|
||||||
|
if (d->containmentDisplayHints == hints) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
d->containmentDisplayHints = hints;
|
||||||
|
emit containmentDisplayHintsChanged(hints);
|
||||||
|
}
|
||||||
|
|
||||||
void Containment::setLocation(Types::Location location)
|
void Containment::setLocation(Types::Location location)
|
||||||
{
|
{
|
||||||
if (d->location == location) {
|
if (d->location == location) {
|
||||||
|
@ -286,6 +286,14 @@ public Q_SLOTS:
|
|||||||
*/
|
*/
|
||||||
void setFormFactor(Plasma::Types::FormFactor formFactor);
|
void setFormFactor(Plasma::Types::FormFactor formFactor);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set Display hints that come from the containment that suggest the applet how to look and behave.
|
||||||
|
*
|
||||||
|
* @param hints the new hints, as bitwise OR
|
||||||
|
* @since 5.77
|
||||||
|
*/
|
||||||
|
void setContainmentDisplayHints(Plasma::Types::ContainmentDisplayHints hints);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the type of this containment.
|
* Sets the type of this containment.
|
||||||
*/
|
*/
|
||||||
|
@ -86,6 +86,20 @@ public:
|
|||||||
};
|
};
|
||||||
Q_ENUM(FormFactor)
|
Q_ENUM(FormFactor)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display hints that come from the containment that suggest the applet how to look and behave.
|
||||||
|
* @since 5.77
|
||||||
|
*/
|
||||||
|
enum ContainmentDisplayHint {
|
||||||
|
NoContainmentDisplayHint = 0,
|
||||||
|
ContainmentDrawsPlasmoidHeading = 1, /**< The containment will draw an titlebar-looking header for the applets, so the applets shouldn't attempt to paint a similar thing **/
|
||||||
|
ContainmentForcesSquarePlasmoids = 2, /**< The containment will force every plasmoid to be constrained in a square icon (An example is the System Tray)**/
|
||||||
|
DesktopFullyCovered = 4 /**< The desktop area for the contaiment's screen is not visible at all, for instance a window has been maximized on top of it */
|
||||||
|
};
|
||||||
|
Q_ENUM(ContainmentDisplayHint)
|
||||||
|
Q_DECLARE_FLAGS(ContainmentDisplayHints, ContainmentDisplayHint)
|
||||||
|
Q_FLAG(ContainmentDisplayHints)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This enumeration describes the type of the Containment.
|
* This enumeration describes the type of the Containment.
|
||||||
* DesktopContainments represent main containments that will own a screen in a mutually exclusive fashion,
|
* DesktopContainments represent main containments that will own a screen in a mutually exclusive fashion,
|
||||||
@ -95,6 +109,7 @@ public:
|
|||||||
NoContainmentType = -1, /**< @internal */
|
NoContainmentType = -1, /**< @internal */
|
||||||
DesktopContainment = 0, /**< A desktop containment */
|
DesktopContainment = 0, /**< A desktop containment */
|
||||||
PanelContainment, /**< A desktop panel */
|
PanelContainment, /**< A desktop panel */
|
||||||
|
|
||||||
CustomContainment = 127, /**< A containment that is neither a desktop nor a panel
|
CustomContainment = 127, /**< A containment that is neither a desktop nor a panel
|
||||||
but something application specific */
|
but something application specific */
|
||||||
CustomPanelContainment = 128, /**< A customized desktop panel */
|
CustomPanelContainment = 128, /**< A customized desktop panel */
|
||||||
@ -307,6 +322,7 @@ PLASMA_EXPORT Types::Direction locationToDirection(Types::Location location);
|
|||||||
**/
|
**/
|
||||||
PLASMA_EXPORT Types::Direction locationToInverseDirection(Types::Location location);
|
PLASMA_EXPORT Types::Direction locationToInverseDirection(Types::Location location);
|
||||||
|
|
||||||
|
Q_DECLARE_OPERATORS_FOR_FLAGS(Types::ContainmentDisplayHints)
|
||||||
Q_DECLARE_OPERATORS_FOR_FLAGS(Types::Constraints)
|
Q_DECLARE_OPERATORS_FOR_FLAGS(Types::Constraints)
|
||||||
Q_DECLARE_OPERATORS_FOR_FLAGS(Types::Flip)
|
Q_DECLARE_OPERATORS_FOR_FLAGS(Types::Flip)
|
||||||
Q_DECLARE_OPERATORS_FOR_FLAGS(Types::ComponentTypes)
|
Q_DECLARE_OPERATORS_FOR_FLAGS(Types::ComponentTypes)
|
||||||
|
@ -69,6 +69,8 @@ public:
|
|||||||
Containment *q;
|
Containment *q;
|
||||||
Types::FormFactor formFactor;
|
Types::FormFactor formFactor;
|
||||||
Types::Location location;
|
Types::Location location;
|
||||||
|
Types::ContainmentDisplayHints containmentDisplayHints = Types::NoContainmentDisplayHint;
|
||||||
|
|
||||||
QList<Applet *> applets;
|
QList<Applet *> applets;
|
||||||
//Applets still considered not ready
|
//Applets still considered not ready
|
||||||
QSet <Applet *> loadingApplets;
|
QSet <Applet *> loadingApplets;
|
||||||
|
@ -98,6 +98,8 @@ AppletInterface::AppletInterface(DeclarativeAppletScript *script, const QVariant
|
|||||||
|
|
||||||
connect(applet(), &Plasma::Applet::activated,
|
connect(applet(), &Plasma::Applet::activated,
|
||||||
this, &AppletInterface::activated);
|
this, &AppletInterface::activated);
|
||||||
|
connect(applet(), &Plasma::Applet::containmentDisplayHintsChanged,
|
||||||
|
this, &AppletInterface::containmentDisplayHintsChanged);
|
||||||
|
|
||||||
connect(appletScript(), &DeclarativeAppletScript::formFactorChanged,
|
connect(appletScript(), &DeclarativeAppletScript::formFactorChanged,
|
||||||
this, &AppletInterface::formFactorChanged);
|
this, &AppletInterface::formFactorChanged);
|
||||||
@ -232,6 +234,11 @@ Plasma::Types::Location AppletInterface::location() const
|
|||||||
return applet()->location();
|
return applet()->location();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Plasma::Types::ContainmentDisplayHints AppletInterface::containmentDisplayHints() const
|
||||||
|
{
|
||||||
|
return applet()->containmentDisplayHints();
|
||||||
|
}
|
||||||
|
|
||||||
QString AppletInterface::currentActivity() const
|
QString AppletInterface::currentActivity() const
|
||||||
{
|
{
|
||||||
if (applet()->containment()) {
|
if (applet()->containment()) {
|
||||||
|
@ -112,6 +112,12 @@ class AppletInterface : public PlasmaQuick::AppletQuickItem
|
|||||||
*/
|
*/
|
||||||
Q_PROPERTY(Plasma::Types::FormFactor formFactor READ formFactor NOTIFY formFactorChanged)
|
Q_PROPERTY(Plasma::Types::FormFactor formFactor READ formFactor NOTIFY formFactorChanged)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Type of the containment we're in
|
||||||
|
* @since 5.77
|
||||||
|
*/
|
||||||
|
Q_PROPERTY(Plasma::Types::ContainmentDisplayHints containmentDisplayHints READ containmentDisplayHints NOTIFY containmentDisplayHintsChanged)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Location for the plasmoid
|
* Location for the plasmoid
|
||||||
*/
|
*/
|
||||||
@ -375,6 +381,8 @@ public:
|
|||||||
|
|
||||||
Plasma::Types::Location location() const;
|
Plasma::Types::Location location() const;
|
||||||
|
|
||||||
|
Plasma::Types::ContainmentDisplayHints containmentDisplayHints() const;
|
||||||
|
|
||||||
QString currentActivity() const;
|
QString currentActivity() const;
|
||||||
|
|
||||||
QObject *configuration() const;
|
QObject *configuration() const;
|
||||||
@ -458,6 +466,7 @@ Q_SIGNALS:
|
|||||||
void toolTipItemChanged();
|
void toolTipItemChanged();
|
||||||
void formFactorChanged();
|
void formFactorChanged();
|
||||||
void locationChanged();
|
void locationChanged();
|
||||||
|
void containmentDisplayHintsChanged();
|
||||||
void contextChanged();
|
void contextChanged();
|
||||||
void immutabilityChanged();
|
void immutabilityChanged();
|
||||||
void statusChanged();
|
void statusChanged();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user