Commit 3e09df00 authored by Fabian Vogt's avatar Fabian Vogt
Browse files

Revert "panel: refactor code to be more declarative"

It broke the layout on the first startup when there's no appletsrc yet.
This reverts commit b678f2d7.

CCMAIL: uhhadd@gmail.com
parent 74e95a2a
......@@ -173,6 +173,7 @@ function checkLastSpacer() {
LayoutManager.lastSpacer = lastSpacer;
LayoutManager.marginHighlights = [];
LayoutManager.restore();
containmentSizeSyncTimer.restart();
plasmoid.action("configure").visible = Qt.binding(function() {
return !plasmoid.immutable;
......@@ -211,6 +212,7 @@ function checkLastSpacer() {
event.accept(event.proposedAction);
root.fixedWidth = 0;
root.fixedHeight = 0;
containmentSizeSyncTimer.restart();
}
......@@ -225,6 +227,8 @@ function checkLastSpacer() {
}
Plasmoid.onUserConfiguringChanged: {
containmentSizeSyncTimer.restart();
if (plasmoid.immutable) {
if (dragOverlay) {
dragOverlay.destroy();
......@@ -253,7 +257,11 @@ function checkLastSpacer() {
}
}
Plasmoid.onFormFactorChanged: containmentSizeSyncTimer.restart();
Containment.onEditModeChanged: containmentSizeSyncTimer.restart();
onToolBoxChanged: {
containmentSizeSyncTimer.restart();
if (startupTimer.running) {
startupTimer.restart();
}
......@@ -485,10 +493,26 @@ function checkLastSpacer() {
rowSpacing: PlasmaCore.Units.smallSpacing
columnSpacing: PlasmaCore.Units.smallSpacing
anchors.fill: parent
anchors.rightMargin: (isHorizontal && toolBox && plasmoid.editMode) ? toolBox.width : 0
anchors.bottomMargin: (!isHorizontal && toolBox && plasmoid.editMode) ? toolBox.height : 0
Layout.preferredWidth: {
var width = 0;
for (var i = 0, length = currentLayout.children.length; i < length; ++i) {
var item = currentLayout.children[i];
if (item.Layout) {
width += Math.max(item.Layout.minimumWidth, item.Layout.preferredWidth);
}
}
return width;
}
Layout.preferredHeight: {
var height = 0;
for (var i = 0, length = currentLayout.children.length; i < length; ++i) {
var item = currentLayout.children[i];
if (item.Layout) {
height += Math.max(item.Layout.minimumHeight, item.Layout.preferredHeight);
}
}
return height;
}
rows: 1
columns: 1
//when horizontal layout top-to-bottom, this way it will obey our limit of one row and actually lay out left to right
......@@ -497,16 +521,31 @@ function checkLastSpacer() {
}
onWidthChanged: {
containmentSizeSyncTimer.restart()
if (startupTimer.running) {
startupTimer.restart();
}
}
onHeightChanged: {
containmentSizeSyncTimer.restart()
if (startupTimer.running) {
startupTimer.restart();
}
}
Timer {
id: containmentSizeSyncTimer
interval: 150
onTriggered: {
dndSpacer.parent = root;
currentLayout.x = (isHorizontal && toolBox && Qt.application.layoutDirection === Qt.RightToLeft && plasmoid.editMode) ? toolBox.width : 0;
currentLayout.y = 0
currentLayout.width = root.width - (isHorizontal && toolBox && plasmoid.editMode ? toolBox.width : 0)
currentLayout.height = root.height - (!isHorizontal && toolBox && plasmoid.editMode ? toolBox.height : 0)
currentLayout.isLayoutHorizontal = isHorizontal
}
}
//FIXME: I don't see other ways at the moment a way to see when the UI is REALLY ready
Timer {
id: startupTimer
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment