fix #356,expose offset in the dockview

--this patch updates borders correctly based
also on the offset variable
--fixes the calculations for offset and panel
background positioning
pull/1/head
Michail Vourlakos 8 years ago
parent 7162b7eef6
commit 510974c3ff

@ -166,6 +166,7 @@ void DockView::init()
});
connect(this, &DockView::drawShadowsChanged, this, &DockView::syncGeometry);
connect(this, &DockView::maxLengthChanged, this, &DockView::syncGeometry);
connect(this, &DockView::offsetChanged, this, &DockView::syncGeometry);
connect(this, &DockView::alignmentChanged, this, &DockView::updateEnabledBorders);
connect(this, &DockView::dockWinBehaviorChanged, this, &DockView::saveConfig);
connect(this, &DockView::onPrimaryChanged, this, &DockView::saveConfig);
@ -949,6 +950,21 @@ QRect DockView::screenGeometry() const
return QRect();
}
int DockView::offset() const
{
return m_offset;
}
void DockView::setOffset(int offset)
{
if (m_offset == offset) {
return;
}
m_offset = offset;
emit offsetChanged();
}
int DockView::shadow() const
{
return m_shadow;
@ -1505,11 +1521,11 @@ void DockView::updateEnabledBorders()
borders &= ~Plasma::FrameSvg::BottomBorder;
}
if (m_alignment == Dock::Top && !m_forceDrawCenteredBorders) {
if (m_alignment == Dock::Top && !m_forceDrawCenteredBorders && m_offset == 0) {
borders &= ~Plasma::FrameSvg::TopBorder;
}
if (m_alignment == Dock::Bottom && !m_forceDrawCenteredBorders) {
if (m_alignment == Dock::Bottom && !m_forceDrawCenteredBorders && m_offset == 0) {
borders &= ~Plasma::FrameSvg::BottomBorder;
}
}
@ -1520,11 +1536,11 @@ void DockView::updateEnabledBorders()
borders &= ~Plasma::FrameSvg::RightBorder;
}
if (m_alignment == Dock::Left) {
if (m_alignment == Dock::Left && m_offset == 0) {
borders &= ~Plasma::FrameSvg::LeftBorder;
}
if (m_alignment == Dock::Right) {
if (m_alignment == Dock::Right && m_offset == 0) {
borders &= ~Plasma::FrameSvg::RightBorder;
}
}

@ -58,6 +58,7 @@ class DockView : public PlasmaQuick::ContainmentView {
Q_PROPERTY(int height READ height NOTIFY heightChanged)
Q_PROPERTY(int maxThickness READ maxThickness WRITE setMaxThickness NOTIFY maxThicknessChanged)
Q_PROPERTY(int normalThickness READ normalThickness WRITE setNormalThickness NOTIFY normalThicknessChanged)
Q_PROPERTY(int offset READ offset WRITE setOffset NOTIFY offsetChanged)
Q_PROPERTY(int shadow READ shadow WRITE setShadow NOTIFY shadowChanged)
Q_PROPERTY(QString currentScreen READ currentScreen NOTIFY currentScreenChanged)
@ -112,6 +113,9 @@ public:
int normalThickness() const;
void setNormalThickness(int thickness);
int offset() const;
void setOffset(int offset);
int shadow() const;
void setShadow(int shadow);
@ -189,6 +193,7 @@ signals:
void maxLengthChanged();
void maxThicknessChanged();
void normalThicknessChanged();
void offsetChanged();
void onPrimaryChanged();
void visibilityChanged();
void maskAreaChanged();
@ -227,6 +232,7 @@ private:
bool m_onPrimary{true};
int m_maxThickness{24};
int m_normalThickness{24};
int m_offset{0};
int m_shadow{0};
float m_maxLength{1};

@ -65,7 +65,8 @@ Item{
property int spacing: {
if (!Latte.WindowSystem.compositingActive) {
return 0;
} else if (root.panelAlignment === Latte.Dock.Center || plasmoid.configuration.panelPosition === Latte.Dock.Justify) {
} else if (root.panelAlignment === Latte.Dock.Center || plasmoid.configuration.panelPosition === Latte.Dock.Justify
|| root.offset!==0) {
return root.panelEdgeSpacing/2;
} else {
return root.panelEdgeSpacing/4;
@ -128,9 +129,9 @@ Item{
if (root.drawShadowsExternal || !Latte.WindowSystem.compositingActive) {
return 0;
} else {
if (root.panelAlignment === Latte.Dock.Left)
if (root.panelAlignment === Latte.Dock.Left && root.offset===0)
return margins.right;
else if (root.panelAlignment === Latte.Dock.Right)
else if (root.panelAlignment === Latte.Dock.Right && root.offset===0)
return margins.left;
else
return margins.left+margins.right;
@ -141,9 +142,9 @@ Item{
if (root.drawShadowsExternal || !Latte.WindowSystem.compositingActive) {
return 0;
} else {
if (root.panelAlignment === Latte.Dock.Top)
if (root.panelAlignment === Latte.Dock.Top && root.offset===0)
return margins.bottom;
else if (root.panelAlignment === Latte.Dock.Bottom)
else if (root.panelAlignment === Latte.Dock.Bottom && root.offset===0)
return margins.top;
else
return margins.top + margins.bottom;

@ -103,6 +103,14 @@ Item{
value: plasmoid.configuration.maxLength/100
}
Binding{
target: dock
property: "offset"
when: dock
value: plasmoid.configuration.offset
}
Binding{
target: dock
property: "alignment"

@ -110,8 +110,21 @@ DragDrop.DropArea {
property int totalPanelEdgeSpacing: 0 //this is set by PanelBox
//FIXME: this is not needed any more probably
property int previousAllTasks: -1 //is used to forbit updateAutomaticIconSize when hovering
property int offset: root.isHorizontal ? width * (plasmoid.configuration.offset/100)
: height * (plasmoid.configuration.offset/100)
property int offset: {
if (drawShadowsExternal) {
return 0;
}
if (root.isHorizontal) {
return width * (plasmoid.configuration.offset/100);
} else {
height * (plasmoid.configuration.offset/100)
}
}
//center the layout correctly when the user uses an offset
property int offsetFixed: (offset===0 || panelAlignment === Latte.Dock.Center || plasmoid.configuration.panelPosition === Latte.Dock.Justify)?
offset : offset+panelMarginLength/2+totalPanelEdgeSpacing/2
property int realSize: iconSize + iconMargin
property int realPanelSize: 0
@ -280,7 +293,7 @@ DragDrop.DropArea {
}
PropertyChanges{
target: mainLayout; horizontalItemAlignment: Grid.AlignLeft; verticalItemAlignment: Grid.AlignVCenter;
anchors.leftMargin: 0; anchors.rightMargin:0; anchors.topMargin:root.offset; anchors.bottomMargin:0;
anchors.leftMargin: 0; anchors.rightMargin:0; anchors.topMargin:root.offsetFixed; anchors.bottomMargin:0;
anchors.horizontalCenterOffset: 0; anchors.verticalCenterOffset: 0;
}
},
@ -294,7 +307,7 @@ DragDrop.DropArea {
}
PropertyChanges{
target: mainLayout; horizontalItemAlignment: Grid.AlignLeft; verticalItemAlignment: Grid.AlignVCenter;
anchors.leftMargin: 0; anchors.rightMargin:0; anchors.topMargin:0; anchors.bottomMargin:root.offset;
anchors.leftMargin: 0; anchors.rightMargin:0; anchors.topMargin:0; anchors.bottomMargin:root.offsetFixed;
anchors.horizontalCenterOffset: 0; anchors.verticalCenterOffset: 0;
}
},
@ -323,7 +336,7 @@ DragDrop.DropArea {
}
PropertyChanges{
target: mainLayout; horizontalItemAlignment: Grid.AlignRight; verticalItemAlignment: Grid.AlignVCenter;
anchors.leftMargin: 0; anchors.rightMargin:0; anchors.topMargin:root.offset; anchors.bottomMargin:0;
anchors.leftMargin: 0; anchors.rightMargin:0; anchors.topMargin:root.offsetFixed; anchors.bottomMargin:0;
anchors.horizontalCenterOffset: 0; anchors.verticalCenterOffset: 0;
}
},
@ -337,7 +350,7 @@ DragDrop.DropArea {
}
PropertyChanges{
target: mainLayout; horizontalItemAlignment: Grid.AlignRight; verticalItemAlignment: Grid.AlignVCenter;
anchors.leftMargin: 0; anchors.rightMargin:0; anchors.topMargin:0; anchors.bottomMargin:root.offset;
anchors.leftMargin: 0; anchors.rightMargin:0; anchors.topMargin:0; anchors.bottomMargin:root.offsetFixed;
anchors.horizontalCenterOffset: 0; anchors.verticalCenterOffset: 0;
}
},
@ -366,7 +379,7 @@ DragDrop.DropArea {
}
PropertyChanges{
target: mainLayout; horizontalItemAlignment: Grid.AlignHCenter; verticalItemAlignment: Grid.AlignBottom
anchors.leftMargin: root.offset; anchors.rightMargin:0; anchors.topMargin:0; anchors.bottomMargin:0;
anchors.leftMargin: root.offsetFixed; anchors.rightMargin:0; anchors.topMargin:0; anchors.bottomMargin:0;
anchors.horizontalCenterOffset: 0; anchors.verticalCenterOffset: 0;
}
},
@ -380,7 +393,7 @@ DragDrop.DropArea {
}
PropertyChanges{
target: mainLayout; horizontalItemAlignment: Grid.AlignHCenter; verticalItemAlignment: Grid.AlignBottom
anchors.leftMargin: 0; anchors.rightMargin:root.offset; anchors.topMargin:0; anchors.bottomMargin:0;
anchors.leftMargin: 0; anchors.rightMargin:root.offsetFixed; anchors.topMargin:0; anchors.bottomMargin:0;
anchors.horizontalCenterOffset: 0; anchors.verticalCenterOffset: 0;
}
},
@ -409,7 +422,7 @@ DragDrop.DropArea {
}
PropertyChanges{
target: mainLayout; horizontalItemAlignment: Grid.AlignHCenter; verticalItemAlignment: Grid.AlignTop
anchors.leftMargin: root.offset; anchors.rightMargin:0; anchors.topMargin:0; anchors.bottomMargin:0;
anchors.leftMargin: root.offsetFixed; anchors.rightMargin:0; anchors.topMargin:0; anchors.bottomMargin:0;
anchors.horizontalCenterOffset: 0; anchors.verticalCenterOffset: 0;
}
},
@ -423,7 +436,7 @@ DragDrop.DropArea {
}
PropertyChanges{
target: mainLayout; horizontalItemAlignment: Grid.AlignHCenter; verticalItemAlignment: Grid.AlignTop
anchors.leftMargin: 0; anchors.rightMargin:root.offset; anchors.topMargin:0; anchors.bottomMargin:0;
anchors.leftMargin: 0; anchors.rightMargin:root.offsetFixed; anchors.topMargin:0; anchors.bottomMargin:0;
anchors.horizontalCenterOffset: 0; anchors.verticalCenterOffset: 0;
}
}

Loading…
Cancel
Save