Changeset View
Changeset View
Standalone View
Standalone View
shell/panelconfigview.cpp
Show First 20 Lines • Show All 100 Lines • ▼ Show 20 Line(s) | 100 | { | |||
---|---|---|---|---|---|
101 | QAction *addWidgetAction = m_containment->actions()->action(QStringLiteral("add widgets")); | 101 | QAction *addWidgetAction = m_containment->actions()->action(QStringLiteral("add widgets")); | ||
102 | if (addWidgetAction) { | 102 | if (addWidgetAction) { | ||
103 | addWidgetAction->trigger(); | 103 | addWidgetAction->trigger(); | ||
104 | } | 104 | } | ||
105 | } | 105 | } | ||
106 | 106 | | |||
107 | void PanelConfigView::addPanelSpacer() | 107 | void PanelConfigView::addPanelSpacer() | ||
108 | { | 108 | { | ||
109 | m_containment->createApplet(QStringLiteral("org.kde.plasma.panelspacer")); | 109 | ShellCorona *c = qobject_cast<ShellCorona *>(m_containment->corona()); | ||
110 | if (!c) { | ||||
111 | return; | ||||
112 | } | ||||
113 | // Add a spacer at the end *except* if there is exactly one spacer already | ||||
114 | // this to trigger the panel centering mode of the spacer in a slightly more discoverable way | ||||
115 | c->evaluateScript(QStringLiteral("panel = panelById(") + QString::number(m_containment->id()) | ||||
davidedmundson: why is this a script? | |||||
so, i need to add the second spacer at first position rather than the last. mart: so, i need to add the second spacer at first position rather than the last.
I don't think i can… | |||||
Seems like Panel could benefit from some sort of...ContinamentLayoutManager? Effectively we're evaluating what RowLayout evaluates by hand here anyway, it seems like the right path forward and worth investing time in. Though it can happen after this patch. davidedmundson: Seems like Panel could benefit from some sort of...ContinamentLayoutManager?
Effectively… | |||||
mart: indeed. | |||||
116 | + QStringLiteral(");" | ||||
117 | "var spacers = panel.widgets(\"org.kde.plasma.panelspacer\");" | ||||
118 | "if (spacers.length === 1) {" | ||||
119 | " panel.addWidget(\"org.kde.plasma.panelspacer\", 0,0,1,1);" | ||||
120 | "} else {" | ||||
121 | " panel.addWidget(\"org.kde.plasma.panelspacer\");" | ||||
122 | "}")); | ||||
110 | } | 123 | } | ||
111 | 124 | | |||
112 | void PanelConfigView::syncGeometry() | 125 | void PanelConfigView::syncGeometry() | ||
113 | { | 126 | { | ||
114 | if (!m_containment || !rootObject()) { | 127 | if (!m_containment || !rootObject()) { | ||
115 | return; | 128 | return; | ||
116 | } | 129 | } | ||
117 | 130 | | |||
▲ Show 20 Lines • Show All 168 Lines • Show Last 20 Lines |
why is this a script?