fixes for FastLayoutManager.insertAtCoordinates

--consider start and end layouts only when the alignment
is set to Justify
work/spdx
Michail Vourlakos 4 years ago
parent b6f43057ce
commit 5295dc9ae9

@ -87,6 +87,9 @@ set(CORETYPESHEADER "LIBCORETYPES_H")
configure_file(declarativeimports/coretypes.h.in declarativeimports/core/types.h)
set(CORETYPESHEADER "APPCORETYPES_H")
configure_file(declarativeimports/coretypes.h.in app/coretypes.h)
set(CORETYPESHEADER "LATTEGENERALCONTAINMENTTYPES_H")
configure_file(declarativeimports/coretypes.h.in containment/plugin/lattetypes.h)
# subdirectories
add_subdirectory(declarativeimports)

@ -4,6 +4,7 @@ configure_file(metadata.desktop.cmake ${CMAKE_CURRENT_SOURCE_DIR}/package/metada
plasma_install_package(package org.kde.latte.containment)
set(containment_SRCS
plugin/lattetypes.h
plugin/types.cpp
plugin/layoutmanager.cpp
plugin/lattecontainmentplugin.cpp

@ -20,7 +20,10 @@
#include "layoutmanager.h"
//! Plasma
// local
#include <plugin/lattetypes.h>
// Plasma
#include <Plasma>
const int CHILDFOUNDID = 11;
@ -138,6 +141,7 @@ void LayoutManager::insertBefore(QQuickItem *hoveredItem, QQuickItem *item)
item->setParentItem(hoveredItem->parentItem());
item->stackBefore(hoveredItem);
}
void LayoutManager::insertAfter(QQuickItem *hoveredItem, QQuickItem *item)
@ -220,13 +224,11 @@ bool LayoutManager::insertAtLayoutCoordinates(QQuickItem *layout, QQuickItem *it
}
}
item->setParentItem(layout);
if ((vertical && y < (hovered->y() + hovered->height()/2)) ||
(horizontal && x < hovered->x() + hovered->width()/2)) {
item->stackBefore(hovered);
insertBefore(hovered, item);
} else {
item->stackAfter(hovered);
insertAfter(hovered, item);
}
return true;
@ -234,14 +236,22 @@ bool LayoutManager::insertAtLayoutCoordinates(QQuickItem *layout, QQuickItem *it
void LayoutManager::insertAtCoordinates(QQuickItem *item, const int &x, const int &y)
{
if (!m_configuration) {
return;
}
Latte::Types::Alignment alignment = static_cast<Latte::Types::Alignment>((*m_configuration)["alignment"].toInt());
bool result{false};
QPointF startPos = m_startLayout->mapFromItem(m_rootItem, QPointF(x, y));
result = insertAtLayoutCoordinates(m_startLayout, item, startPos.x(), startPos.y());
if (alignment == Latte::Types::Justify) {
QPointF startPos = m_startLayout->mapFromItem(m_rootItem, QPointF(x, y));
result = insertAtLayoutCoordinates(m_startLayout, item, startPos.x(), startPos.y());
if (!result) {
QPointF endPos = m_endLayout->mapFromItem(m_rootItem, QPointF(x, y));
result = insertAtLayoutCoordinates(m_endLayout, item, endPos.x(), endPos.y());
if (!result) {
QPointF endPos = m_endLayout->mapFromItem(m_rootItem, QPointF(x, y));
result = insertAtLayoutCoordinates(m_endLayout, item, endPos.x(), endPos.y());
}
}
if (!result) {

Loading…
Cancel
Save