mirror of
https://github.com/KDE/latte-dock.git
synced 2025-02-02 21:47:22 +03:00
Latte::Quick use layout popUpMargin
--this way we can support three different popup styles. Plasma/AllBorders/Far From Edge
This commit is contained in:
parent
99382184ff
commit
940bee9408
@ -92,6 +92,8 @@ void Effects::init()
|
||||
|
||||
connect(this, &Effects::backgroundAllCornersChanged, this, &Effects::updateEnabledBorders);
|
||||
|
||||
connect(this, &Effects::popUpMarginChanged, this, &Effects::onPopUpMarginChanged);
|
||||
|
||||
connect(m_view, &Latte::View::alignmentChanged, this, &Effects::updateEnabledBorders);
|
||||
connect(m_view, &Latte::View::maxLengthChanged, this, &Effects::updateEnabledBorders);
|
||||
connect(m_view, &Latte::View::offsetChanged, this, &Effects::updateEnabledBorders);
|
||||
@ -100,6 +102,7 @@ void Effects::init()
|
||||
connect(this, &Effects::drawShadowsChanged, this, &Effects::updateShadows);
|
||||
connect(m_view, &Latte::View::behaveAsPlasmaPanelChanged, this, &Effects::updateShadows);
|
||||
connect(m_view, &Latte::View::configWindowGeometryChanged, this, &Effects::updateMask);
|
||||
connect(m_view, &Latte::View::layoutChanged, this, &Effects::onPopUpMarginChanged);
|
||||
|
||||
connect(&m_theme, &Plasma::Theme::themeChanged, this, [&]() {
|
||||
auto background = m_background;
|
||||
@ -277,6 +280,11 @@ void Effects::setInnerShadow(int shadow)
|
||||
emit innerShadowChanged();
|
||||
}
|
||||
|
||||
int Effects::popUpMargin() const
|
||||
{
|
||||
return m_view->layout() ? m_view->layout()->popUpMargin() : -1/*default*/;
|
||||
}
|
||||
|
||||
QRect Effects::rect() const
|
||||
{
|
||||
return m_rect;
|
||||
@ -350,6 +358,11 @@ void Effects::setAppletsLayoutGeometry(const QRect &geom)
|
||||
emit appletsLayoutGeometryChanged();
|
||||
}
|
||||
|
||||
void Effects::onPopUpMarginChanged()
|
||||
{
|
||||
m_view->setProperty("_applets_popup_margin", QVariant(popUpMargin()));
|
||||
}
|
||||
|
||||
void Effects::forceMaskRedraw()
|
||||
{
|
||||
if (m_background) {
|
||||
|
@ -57,6 +57,8 @@ class Effects: public QObject
|
||||
Q_PROPERTY(int backgroundRadius READ backgroundRadius WRITE setBackgroundRadius NOTIFY backgroundRadiusChanged)
|
||||
Q_PROPERTY(float backgroundOpacity READ backgroundOpacity WRITE setBackgroundOpacity NOTIFY backgroundOpacityChanged)
|
||||
|
||||
Q_PROPERTY(int popUpMargin READ popUpMargin NOTIFY popUpMarginChanged)
|
||||
|
||||
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)
|
||||
@ -95,6 +97,8 @@ public:
|
||||
int backgroundRadius();
|
||||
void setBackgroundRadius(const int &radius);
|
||||
|
||||
int popUpMargin() const;
|
||||
|
||||
float backgroundOpacity() const;
|
||||
void setBackgroundOpacity(float opacity);
|
||||
|
||||
@ -140,6 +144,7 @@ signals:
|
||||
void maskChanged();
|
||||
void innerShadowChanged();
|
||||
void inputMaskChanged();
|
||||
void popUpMarginChanged();
|
||||
void rectChanged();
|
||||
|
||||
void subtractedMaskRegionsChanged();
|
||||
@ -148,6 +153,8 @@ signals:
|
||||
private slots:
|
||||
void init();
|
||||
|
||||
void onPopUpMarginChanged();
|
||||
|
||||
void updateBackgroundContrastValues();
|
||||
void updateBackgroundCorners();
|
||||
|
||||
|
@ -1195,6 +1195,7 @@ void View::setLayout(Layout::GenericLayout *layout)
|
||||
}
|
||||
|
||||
connectionsLayout << connect(m_positioner, &Latte::ViewPart::Positioner::edgeChanged, m_layout, &Layout::GenericLayout::viewEdgeChanged);
|
||||
connectionsLayout << connect(m_layout, &Layout::GenericLayout::popUpMarginChanged, m_effects, &Latte::ViewPart::Effects::popUpMarginChanged);
|
||||
|
||||
//! Sometimes the activity isnt completely ready, by adding a delay
|
||||
//! we try to catch up
|
||||
|
@ -74,16 +74,34 @@ QRect Dialog::appletsLayoutGeometryFromContainment() const
|
||||
return geom.isValid() ? geom.toRect() : QRect();
|
||||
}
|
||||
|
||||
int Dialog::appletsPopUpMargin() const
|
||||
{
|
||||
QVariant margin = visualParent() && visualParent()->window() ? visualParent()->window()->property("_applets_popup_margin") : QVariant();
|
||||
return margin.isValid() ? margin.toInt() : -1;
|
||||
}
|
||||
|
||||
void Dialog::updatePopUpEnabledBorders()
|
||||
{
|
||||
QRect appletslayoutgeometry = appletsLayoutGeometryFromContainment();
|
||||
int appletspopupmargin = appletsPopUpMargin();
|
||||
|
||||
//! Plasma Scenario
|
||||
bool hideEdgeBorder = isRespectingAppletsLayoutGeometry() && !appletslayoutgeometry.isEmpty() && appletspopupmargin==-1;
|
||||
|
||||
if (hideEdgeBorder) {
|
||||
setLocation(m_edge);
|
||||
} else {
|
||||
setLocation(Plasma::Types::Floating);
|
||||
}
|
||||
}
|
||||
|
||||
void Dialog::adjustGeometry(const QRect &geom)
|
||||
{
|
||||
if (location() != Plasma::Types::Floating) {
|
||||
PlasmaQuick::Dialog::adjustGeometry(geom);
|
||||
return;
|
||||
}
|
||||
|
||||
auto visualparent = visualParent();
|
||||
|
||||
if (visualparent && visualparent->window() && visualparent->window()->screen()) {
|
||||
updatePopUpEnabledBorders();
|
||||
|
||||
QPointF parenttopleftf = visualparent->mapToGlobal(QPointF(0, 0));
|
||||
QPoint parenttopleft = parenttopleftf.toPoint();
|
||||
QScreen *screen = visualparent->window()->screen();
|
||||
@ -98,14 +116,16 @@ void Dialog::adjustGeometry(const QRect &geom)
|
||||
x = parenttopleft.x() + (visualparent->width()/2) - (geom.width()/2);
|
||||
}
|
||||
|
||||
int popupmargin = qMax(0, appletsPopUpMargin());
|
||||
|
||||
if (m_edge == Plasma::Types::LeftEdge) {
|
||||
x = parenttopleft.x() + visualparent->width() - 1;
|
||||
x = parenttopleft.x() + visualparent->width() - 1 + popupmargin;
|
||||
} else if (m_edge == Plasma::Types::RightEdge) {
|
||||
x = parenttopleft.x() - geom.width() + 1;
|
||||
x = parenttopleft.x() - geom.width() + 1 - popupmargin;
|
||||
} else if (m_edge == Plasma::Types::TopEdge) {
|
||||
y = parenttopleft.y() + visualparent->height() - 1;
|
||||
y = parenttopleft.y() + visualparent->height() - 1 + popupmargin;
|
||||
} else { // bottom case
|
||||
y = parenttopleft.y() - geom.height() + 1;
|
||||
y = parenttopleft.y() - geom.height() + 1 - popupmargin;
|
||||
}
|
||||
|
||||
x = qBound(screengeometry.x(), x, screengeometry.right()-1);
|
||||
|
@ -57,11 +57,14 @@ protected:
|
||||
|
||||
private slots:
|
||||
void setContainsMouse(bool contains);
|
||||
void updatePopUpEnabledBorders();
|
||||
|
||||
private:
|
||||
bool isRespectingAppletsLayoutGeometry() const;
|
||||
QRect appletsLayoutGeometryFromContainment() const;
|
||||
|
||||
int appletsPopUpMargin() const;
|
||||
|
||||
private:
|
||||
bool m_containsMouse{false};
|
||||
|
||||
|
@ -158,7 +158,7 @@ PlasmaCore.ToolTipArea {
|
||||
flags: Qt.WindowStaysOnTopHint
|
||||
visible: plasmoid.expanded && fullRepresentation
|
||||
visualParent: compactRepresentationVisualParent ? compactRepresentationVisualParent : (compactRepresentation ? compactRepresentation : null)
|
||||
location: PlasmaCore.Types.Floating //plasmoid.location
|
||||
// location: PlasmaCore.Types.Floating //plasmoid.location
|
||||
edge: plasmoid.location /*this way dialog borders are not updated and it is used only for adjusting dialog position*/
|
||||
hideOnWindowDeactivate: plasmoid.hideOnWindowDeactivate
|
||||
backgroundHints: (plasmoid.containmentDisplayHints & PlasmaCore.Types.DesktopFullyCovered) ? PlasmaCore.Dialog.SolidBackground : PlasmaCore.Dialog.StandardBackground
|
||||
|
Loading…
x
Reference in New Issue
Block a user