var panel = new Panel
var panelScreen = panel.screen
var freeEdges = {"top": true, "bottom": true, "left": true, "right": true}

for (i = 0; i < panelIds.length; ++i) {
    var tmpPanel = panelById(panelIds[i])
    if (tmpPanel.screen == panelScreen) {
        // Ignore the new panel
        if (tmpPanel.id != panel.id) {
            freeEdges[tmpPanel.location] = false;
        }
    }
}

if (freeEdges["bottom"] == true) {
    panel.location = "bottom";
} else if (freeEdges["left"] == true) {
    panel.location = "left";
} else if (freeEdges["right"] == true) {
    panel.location = "right";
} else if (freeEdges["top"] == true) {
    panel.location = "top";
} else {
    // There is no free edge, so leave the default value
    panel.location = "bottom";
}

panel.lengthMode = "fit"
panel.hiding = "dodgewindows"
panel.height = gridUnit * 3.5

var spacer1 = panel.addWidget("org.kde.plasma.panelspacer")
spacer1.writeConfig("expanding", "false")
spacer1.writeConfig("length", "10")

var kickerdash = panel.addWidget("org.kde.plasma.kickerdash")
kickerdash.writeConfig("customButtonImage", "app-launcher")
kickerdash.writeConfig("useCustomButtonImage", "true")

var taskmanager = panel.addWidget("org.kde.plasma.icontasks")
var launcherlist = [ "applications:org.kde.dolphin.desktop", "preferred://browser", "applications:patchance.desktop", "applications:ardour.desktop", "applications:com.obsproject.Studio.desktop", "applications:org.kde.krita.desktop", "applications:gimp.desktop", "applications:org.kde.kdenlive.desktop", "applications:org.kde.digikam.desktop", "applications:org.darktable.darktable.desktop",  "applications:org.kde.discover.desktop", "applications:systemsettings.desktop" ]
taskmanager.writeConfig("launchers", launcherlist)

panel.addWidget("org.kde.plasma.trash")

var spacer2 = panel.addWidget("org.kde.plasma.panelspacer")
spacer2.writeConfig("expanding", "false")
spacer2.writeConfig("length", "10")
