position latte panels pop ups really nice

--expose appletsLayoutGeometry through Latte::View
dynamic properties and allog LattQuick::Dialogs to
use it in order to be positioned nicely
work/spdx
Michail Vourlakos 4 years ago
parent 1e487a4b1c
commit f5fb12e8da

@ -333,6 +333,23 @@ void Effects::setInputMask(QRect area)
emit inputMaskChanged();
}
QRect Effects::appletsLayoutGeometry() const
{
return m_appletsLayoutGeometry;
}
void Effects::setAppletsLayoutGeometry(const QRect &geom)
{
if (m_appletsLayoutGeometry == geom) {
return;
}
m_appletsLayoutGeometry = geom;
m_view->setProperty("_applets_layout_geometry", QVariant(m_appletsLayoutGeometry));
emit appletsLayoutGeometryChanged();
}
void Effects::forceMaskRedraw()
{
if (m_background) {

@ -60,6 +60,7 @@ class Effects: public QObject
Q_PROPERTY(QRect mask READ mask WRITE setMask NOTIFY maskChanged)
Q_PROPERTY(QRect rect READ rect WRITE setRect NOTIFY rectChanged)
Q_PROPERTY(QRect inputMask READ inputMask WRITE setInputMask NOTIFY inputMaskChanged)
Q_PROPERTY(QRect appletsLayoutGeometry READ appletsLayoutGeometry WRITE setAppletsLayoutGeometry NOTIFY appletsLayoutGeometryChanged)
Q_PROPERTY(Plasma::FrameSvg::EnabledBorders enabledBorders READ enabledBorders NOTIFY enabledBordersChanged)
@ -106,6 +107,9 @@ public:
QRect rect() const;
void setRect(QRect area);
QRect appletsLayoutGeometry() const;
void setAppletsLayoutGeometry(const QRect &geom);
Plasma::FrameSvg::EnabledBorders enabledBorders() const;
public slots:
@ -123,6 +127,7 @@ public slots:
signals:
void animationsBlockedChanged();
void appletsLayoutGeometryChanged();
void backgroundAllCornersChanged();
void backgroundCornersMaskChanged();
void backgroundOpacityChanged();
@ -179,6 +184,7 @@ private:
QRect m_rect;
QRect m_mask;
QRect m_inputMask;
QRect m_appletsLayoutGeometry;
QPointer<Latte::View> m_view;
QPointer<Latte::Corona> m_corona;

@ -284,6 +284,37 @@ Item{
value: background.shadows.headThickness
}
Binding{
target: latteView && latteView.effects ? latteView.effects : null
property:"appletsLayoutGeometry"
when: latteView && latteView.effects && manager.inNormalState
value: {
if (root.behaveAsPlasmaPanel
|| (!parabolic.isEnabled && root.userShowPanelBackground && plasmoid.configuration.panelSize===100)) {
if (myView.alignment === LatteCore.Types.Justify) {
if (root.isHorizontal) {
return Qt.rect(layoutsContainer.x + layoutsContainer.backgroundTailLength,
layoutsContainer.y,
layoutsContainer.width - layoutsContainer.backgroundShadowHeadLength - layoutsContainer.backgroundTailLength,
layoutsContainer.height);
} else {
return Qt.rect(layoutsContainer.x,
layoutsContainer.y + layoutsContainer.backgroundTailLength,
layoutsContainer.width,
layoutsContainer.height - layoutsContainer.backgroundShadowHeadLength - layoutsContainer.backgroundTailLength);
}
} else {
return Qt.rect(layoutsContainer.mainLayout.x,
layoutsContainer.mainLayout.y,
layoutsContainer.mainLayout.width,
layoutsContainer.mainLayout.height)
}
}
return Qt.rect(-1, -1, 0, 0);
}
}
//! View::Positioner bindings
Binding{
target: latteView && latteView.positioner ? latteView.positioner : null

@ -54,6 +54,7 @@ Ability.MyViewPrivate {
lastUsedActivity: view && view.layout ? view.layout.lastUsedActivity : ""
appletsLayoutGeometry: view && view.effects ? view.effects.appletsLayoutGeometry : Qt.rect(0, 0, -1, -1)
screenGeometry: view ? view.screenGeometry : plasmoid.screenGeometry
containmentActions: isReady ? view.containmentActions : []

@ -53,6 +53,7 @@ Item {
property string lastUsedActivity: ""
property rect appletsLayoutGeometry: Qt.rect(-1, -1, 0, 0)
property rect screenGeometry: Qt.rect(0, 0, 1600, 1080)
property var containmentActions: []

@ -61,6 +61,7 @@ AbilityDefinition.MyView {
readonly property alias lastUsedActivity: apis.lastUsedActivity
readonly property alias appletsLayoutGeometry: apis.appletsLayoutGeometry
readonly property alias screenGeometry: apis.screenGeometry
readonly property alias containmentActions: apis.containmentActions

@ -62,6 +62,17 @@ void Dialog::setEdge(const Plasma::Types::Location &edge)
emit edgeChanged();
}
bool Dialog::isRespectingAppletsLayoutGeometry() const
{
//! As it appears plasma applets popups are defining their popups to Normal window.
return (type() == Dialog::Normal || type() == Dialog::PopupMenu);
}
QRect Dialog::appletsLayoutGeometryFromContainment() const
{
QVariant geom = visualParent() && visualParent()->window() ? visualParent()->window()->property("_applets_layout_geometry") : QVariant();
return geom.isValid() ? geom.toRect() : QRect();
}
void Dialog::adjustGeometry(const QRect &geom)
{
@ -100,6 +111,28 @@ void Dialog::adjustGeometry(const QRect &geom)
x = qBound(screengeometry.x(), x, screengeometry.right()-1);
y = qBound(screengeometry.y(), y, screengeometry.bottom()-1);
QRect appletslayoutgeometry = appletsLayoutGeometryFromContainment();
if (isRespectingAppletsLayoutGeometry() && !appletslayoutgeometry.isEmpty()) {
QPoint appletsglobaltopleft = visualparent->window()->mapToGlobal(appletslayoutgeometry.topLeft());
QRect appletsglobalgeometry(appletsglobaltopleft.x(), appletsglobaltopleft.y(), appletslayoutgeometry.width(), appletslayoutgeometry.height());
if (m_edge == Plasma::Types::LeftEdge || m_edge == Plasma::Types::RightEdge) {
int bottomy = appletsglobalgeometry.bottom()-geom.height();
if (appletsglobalgeometry.height() >= geom.height()) {
y = qBound(appletsglobalgeometry.y(), y, bottomy + 1);
}
} else {
int rightx = appletsglobalgeometry.right()-geom.width();
if (appletsglobalgeometry.width() >= geom.width()) {
x = qBound(appletsglobalgeometry.x(), x, rightx + 1);
}
}
}
QRect repositionedrect(x, y, geom.width(), geom.height());
setGeometry(repositionedrect);
return;

@ -35,9 +35,7 @@ class Dialog : public PlasmaQuick::Dialog {
Q_OBJECT
Q_PROPERTY (bool containsMouse READ containsMouse NOTIFY containsMouseChanged)
/**
* Plasma Location of the dialog window. Useful if this dialog is a popup for a panel
*/
//! it is used instead of location property in order to not break borders drawing
Q_PROPERTY(Plasma::Types::Location edge READ edge WRITE setEdge NOTIFY edgeChanged)
public:
@ -60,6 +58,10 @@ protected:
private slots:
void setContainsMouse(bool contains);
private:
bool isRespectingAppletsLayoutGeometry() const;
QRect appletsLayoutGeometryFromContainment() const;
private:
bool m_containsMouse{false};

@ -890,7 +890,9 @@ Item {
target: icList
property int maxThickness: (appletAbilities.parabolic.isHovered || windowPreviewIsShown || appletAbilities.animations.hasThicknessAnimation) ?
property int maxThickness: ((appletAbilities.parabolic.isEnabled && appletAbilities.parabolic.isHovered)
|| (appletAbilities.parabolic.isEnabled && windowPreviewIsShown)
|| appletAbilities.animations.hasThicknessAnimation) ?
appletAbilities.metrics.mask.thickness.maxZoomedForItems : // dont clip bouncing tasks when zoom=1
appletAbilities.metrics.mask.thickness.normalForItems

Loading…
Cancel
Save