mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-08-02 01:34:46 +00:00
redesign widget explorer as suggested by the VDG
This commit is contained in:
parent
bab5d7d9e2
commit
d3b41afc02
2 changed files with 269 additions and 197 deletions
|
|
@ -31,29 +31,47 @@ Item {
|
||||||
|
|
||||||
readonly property string pluginName: model.pluginName
|
readonly property string pluginName: model.pluginName
|
||||||
|
|
||||||
width: list.width
|
width: list.cellWidth
|
||||||
height: iconContainer.height + units.largeSpacing
|
height: list.cellHeight
|
||||||
|
|
||||||
|
|
||||||
RowLayout {
|
|
||||||
|
ColumnLayout {
|
||||||
|
id: mainLayout
|
||||||
|
spacing: units.smallSpacing
|
||||||
anchors {
|
anchors {
|
||||||
fill: parent
|
left: parent.left
|
||||||
margins: units.smallSpacing
|
right: parent.right
|
||||||
|
//bottom: parent.bottom
|
||||||
|
margins: units.smallSpacing * 2
|
||||||
rightMargin: units.smallSpacing * 2 // don't cram the text to the border too much
|
rightMargin: units.smallSpacing * 2 // don't cram the text to the border too much
|
||||||
|
verticalCenter: parent.verticalCenter
|
||||||
}
|
}
|
||||||
spacing: units.largeSpacing
|
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
id: iconContainer
|
id: iconContainer
|
||||||
width: units.iconSizes.huge
|
width: units.iconSizes.enormous
|
||||||
height: width
|
height: width
|
||||||
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
|
|
||||||
QIconItem {
|
Item {
|
||||||
id: iconWidget
|
id: iconWidget
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
icon: model.decoration
|
QIconItem {
|
||||||
|
anchors.fill: parent
|
||||||
|
icon: model.decoration
|
||||||
|
visible: model.screenshot == ""
|
||||||
|
}
|
||||||
|
Image {
|
||||||
|
width: units.iconSizes.enormous
|
||||||
|
height: width
|
||||||
|
anchors.fill: parent
|
||||||
|
fillMode: Image.PreserveAspectFit
|
||||||
|
source: model.screenshot
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
id: badgeMask
|
id: badgeMask
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|
@ -82,7 +100,6 @@ Item {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
horizontalAlignment: Text.AlignHCenter
|
horizontalAlignment: Text.AlignHCenter
|
||||||
verticalAlignment: Text.AlignVCenter
|
verticalAlignment: Text.AlignVCenter
|
||||||
color: theme.backgroundColor
|
|
||||||
text: running
|
text: running
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -114,31 +131,27 @@ Item {
|
||||||
"
|
"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
PlasmaExtras.Heading {
|
||||||
ColumnLayout {
|
id: heading
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
spacing: units.smallSpacing
|
level: 4
|
||||||
|
text: model.name
|
||||||
PlasmaExtras.Heading {
|
elide: Text.ElideRight
|
||||||
id: heading
|
wrapMode: Text.WordWrap
|
||||||
Layout.fillWidth: true
|
maximumLineCount: 2
|
||||||
level: 4
|
lineHeight: 0.95
|
||||||
text: model.name
|
horizontalAlignment: Text.AlignHCenter
|
||||||
elide: Text.ElideRight
|
}
|
||||||
wrapMode: Text.WordWrap
|
PlasmaComponents.Label {
|
||||||
maximumLineCount: 2
|
Layout.fillWidth: true
|
||||||
lineHeight: 0.95
|
// otherwise causes binding loop due to the way the Plasma sets the height
|
||||||
}
|
height: implicitHeight
|
||||||
PlasmaComponents.Label {
|
text: model.description
|
||||||
Layout.fillWidth: true
|
font.pointSize: theme.smallestFont.pointSize
|
||||||
// otherwise causes binding loop due to the way the Plasma sets the height
|
wrapMode: Text.WordWrap
|
||||||
height: implicitHeight
|
elide: Text.ElideRight
|
||||||
text: model.description
|
maximumLineCount: heading.lineCount === 1 ? 3 : 2
|
||||||
font.pointSize: theme.smallestFont.pointSize
|
horizontalAlignment: Text.AlignHCenter
|
||||||
wrapMode: Text.WordWrap
|
|
||||||
elide: Text.ElideRight
|
|
||||||
maximumLineCount: heading.lineCount === 1 ? 3 : 2
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -148,7 +161,10 @@ Item {
|
||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
onClicked: {
|
onClicked: {
|
||||||
widgetExplorer.addApplet(pluginName);
|
widgetExplorer.addApplet(pluginName);
|
||||||
main.closed();
|
main.closed()
|
||||||
}
|
}
|
||||||
|
onEntered: list.currentIndex = index
|
||||||
|
onExited: list.currentIndex = -1
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -32,193 +32,249 @@ import QtQuick.Layouts 1.1
|
||||||
import org.kde.plasma.private.shell 2.0
|
import org.kde.plasma.private.shell 2.0
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
id: main
|
id: root
|
||||||
|
color: Qt.rgba(0, 0, 0, main.opacity * 0.8)
|
||||||
color: theme.backgroundColor
|
|
||||||
|
|
||||||
property alias containment: widgetExplorer.containment
|
|
||||||
|
|
||||||
//external drop events can cause a raise event causing us to lose focus and
|
|
||||||
//therefore get deleted whilst we are still in a drag exec()
|
|
||||||
//this is a clue to the owning dialog that hideOnWindowDeactivate should be deleted
|
|
||||||
//See https://bugs.kde.org/show_bug.cgi?id=332733
|
|
||||||
property bool preventWindowHide: false
|
|
||||||
|
|
||||||
property Item getWidgetsButton
|
|
||||||
property Item categoryButton
|
|
||||||
|
|
||||||
signal closed()
|
signal closed()
|
||||||
|
|
||||||
function addCurrentApplet() {
|
MouseArea {
|
||||||
var pluginName = list.currentItem ? list.currentItem.pluginName : ""
|
|
||||||
if (pluginName) {
|
|
||||||
widgetExplorer.addApplet(pluginName)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
WidgetExplorer {
|
|
||||||
id: widgetExplorer
|
|
||||||
//view: desktop
|
|
||||||
onShouldClose: main.closed();
|
|
||||||
}
|
|
||||||
MobileComponents.SplitDrawer {
|
|
||||||
visible: true
|
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
drawer: PlasmaExtras.ScrollArea {
|
onClicked: removeAnim.running = true;
|
||||||
ListView {
|
}
|
||||||
model: widgetExplorer.filterModel
|
|
||||||
delegate: PlasmaComponents.ListItem {
|
NumberAnimation {
|
||||||
enabled: true
|
id: openAnim
|
||||||
visible: !model.separator
|
running: true
|
||||||
height: model.separator ? 0 : implicitHeight
|
target: main
|
||||||
PlasmaComponents.Label {
|
properties: "x"
|
||||||
text: model.display
|
duration: units.longDuration
|
||||||
}
|
easing.type: Easing.InOutQuad
|
||||||
onClicked: {
|
to: 0
|
||||||
list.contentX = 0
|
}
|
||||||
list.contentY = 0
|
SequentialAnimation {
|
||||||
heading.text = model.display
|
id: removeAnim
|
||||||
widgetExplorer.widgetsModel.filterQuery = model.filterData
|
NumberAnimation {
|
||||||
widgetExplorer.widgetsModel.filterType = model.filterType
|
target: main
|
||||||
}
|
properties: "x"
|
||||||
}
|
duration: units.longDuration
|
||||||
|
easing.type: Easing.InOutQuad
|
||||||
|
to: -main.width
|
||||||
|
}
|
||||||
|
ScriptAction {
|
||||||
|
script: root.closed();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Rectangle {
|
||||||
|
id: main
|
||||||
|
|
||||||
|
x: -width
|
||||||
|
width: parent.width - parent.width/6
|
||||||
|
height: parent.height
|
||||||
|
color: theme.backgroundColor
|
||||||
|
|
||||||
|
opacity: 1 - Math.abs(x / (width/2))
|
||||||
|
property alias containment: widgetExplorer.containment
|
||||||
|
|
||||||
|
//external drop events can cause a raise event causing us to lose focus and
|
||||||
|
//therefore get deleted whilst we are still in a drag exec()
|
||||||
|
//this is a clue to the owning dialog that hideOnWindowDeactivate should be deleted
|
||||||
|
//See https://bugs.kde.org/show_bug.cgi?id=332733
|
||||||
|
property bool preventWindowHide: false
|
||||||
|
|
||||||
|
property Item getWidgetsButton
|
||||||
|
property Item categoryButton
|
||||||
|
|
||||||
|
|
||||||
|
function addCurrentApplet() {
|
||||||
|
var pluginName = list.currentItem ? list.currentItem.pluginName : ""
|
||||||
|
if (pluginName) {
|
||||||
|
widgetExplorer.addApplet(pluginName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ColumnLayout {
|
|
||||||
GridLayout {
|
|
||||||
id: topBar
|
|
||||||
anchors {
|
|
||||||
top: parent.top
|
|
||||||
left: parent.left
|
|
||||||
right: parent.right
|
|
||||||
topMargin: 0
|
|
||||||
leftMargin: units.smallSpacing
|
|
||||||
}
|
|
||||||
columns: 2
|
|
||||||
|
|
||||||
PlasmaExtras.Title {
|
|
||||||
id: heading
|
|
||||||
text: i18nd("plasma_shell_org.kde.plasma.desktop", "Widgets")
|
|
||||||
Layout.fillWidth: true
|
|
||||||
}
|
|
||||||
|
|
||||||
PlasmaComponents.ToolButton {
|
WidgetExplorer {
|
||||||
id: closeButton
|
id: widgetExplorer
|
||||||
anchors {
|
//view: desktop
|
||||||
right: parent.right
|
onShouldClose: removeAnim.running = true;
|
||||||
verticalCenter: heading.verticalCenter
|
}
|
||||||
}
|
MobileComponents.SplitDrawer {
|
||||||
iconSource: "window-close"
|
visible: true
|
||||||
onClicked: main.closed()
|
anchors.fill: parent
|
||||||
}
|
drawer: PlasmaExtras.ScrollArea {
|
||||||
|
|
||||||
PlasmaComponents.TextField {
|
|
||||||
id: searchInput
|
|
||||||
clearButtonShown: true
|
|
||||||
placeholderText: i18nd("plasma_shell_org.kde.plasma.desktop", "Search...")
|
|
||||||
onTextChanged: {
|
|
||||||
list.positionViewAtBeginning()
|
|
||||||
list.currentIndex = -1
|
|
||||||
widgetExplorer.widgetsModel.searchTerm = text
|
|
||||||
}
|
|
||||||
|
|
||||||
Component.onCompleted: forceActiveFocus()
|
|
||||||
Layout.columnSpan: 2
|
|
||||||
Layout.fillWidth: true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
PlasmaExtras.ScrollArea {
|
|
||||||
anchors {
|
|
||||||
top: topBar.bottom
|
|
||||||
left: parent.left
|
|
||||||
right: parent.right
|
|
||||||
bottom: bottomBar.top
|
|
||||||
topMargin: units.smallSpacing
|
|
||||||
leftMargin: units.smallSpacing
|
|
||||||
bottomMargin: units.smallSpacing
|
|
||||||
}
|
|
||||||
ListView {
|
ListView {
|
||||||
id: list
|
model: widgetExplorer.filterModel
|
||||||
|
delegate: PlasmaComponents.ListItem {
|
||||||
model: widgetExplorer.widgetsModel
|
enabled: true
|
||||||
activeFocusOnTab: true
|
visible: !model.separator
|
||||||
currentIndex: -1
|
height: model.separator ? 0 : implicitHeight
|
||||||
keyNavigationWraps: true
|
PlasmaComponents.Label {
|
||||||
|
text: model.display
|
||||||
delegate: AppletDelegate {}
|
|
||||||
|
|
||||||
//slide in to view from the left
|
|
||||||
add: Transition {
|
|
||||||
NumberAnimation {
|
|
||||||
properties: "x"
|
|
||||||
from: -list.width
|
|
||||||
to: 0
|
|
||||||
duration: units.shortDuration * 3
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
onClicked: {
|
||||||
|
list.contentX = 0
|
||||||
//slide out of view to the right
|
list.contentY = 0
|
||||||
remove: Transition {
|
heading.text = model.display
|
||||||
NumberAnimation {
|
widgetExplorer.widgetsModel.filterQuery = model.filterData
|
||||||
properties: "x"
|
widgetExplorer.widgetsModel.filterType = model.filterType
|
||||||
to: list.width
|
|
||||||
duration: units.shortDuration * 3
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//if we are adding other items into the view use the same animation as normal adding
|
|
||||||
//this makes everything slide in together
|
|
||||||
//if we make it move everything ends up weird
|
|
||||||
addDisplaced: list.add
|
|
||||||
|
|
||||||
//moved due to filtering
|
|
||||||
displaced: Transition {
|
|
||||||
NumberAnimation {
|
|
||||||
properties: "y"
|
|
||||||
duration: units.shortDuration * 3
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
MouseArea {
|
||||||
Column {
|
anchors.fill: parent
|
||||||
id: bottomBar
|
drag.filterChildren: true
|
||||||
anchors {
|
drag.target: main
|
||||||
left: parent.left
|
drag.axis: Drag.XAxis
|
||||||
right: parent.right
|
drag.maximumX: 0
|
||||||
bottom: parent.bottom
|
onReleased: {
|
||||||
leftMargin: units.smallSpacing
|
if (main.x < -main.width/2) {
|
||||||
rightMargin: units.smallSpacing
|
removeAnim.running = true;
|
||||||
bottomMargin: units.smallSpacing
|
} else {
|
||||||
|
openAnim.running = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
ColumnLayout {
|
||||||
|
anchors.fill: parent
|
||||||
|
GridLayout {
|
||||||
|
id: topBar
|
||||||
|
anchors {
|
||||||
|
top: parent.top
|
||||||
|
left: parent.left
|
||||||
|
right: parent.right
|
||||||
|
topMargin: 0
|
||||||
|
leftMargin: units.smallSpacing
|
||||||
|
}
|
||||||
|
columns: 2
|
||||||
|
|
||||||
spacing: units.smallSpacing
|
PlasmaExtras.Title {
|
||||||
|
id: heading
|
||||||
|
text: i18nd("plasma_shell_org.kde.plasma.desktop", "Widgets")
|
||||||
|
Layout.fillWidth: true
|
||||||
|
}
|
||||||
|
|
||||||
Repeater {
|
PlasmaComponents.ToolButton {
|
||||||
model: widgetExplorer.extraActions.length
|
id: closeButton
|
||||||
PlasmaComponents.Button {
|
anchors {
|
||||||
|
right: parent.right
|
||||||
|
verticalCenter: heading.verticalCenter
|
||||||
|
}
|
||||||
|
iconSource: "window-close"
|
||||||
|
onClicked: removeAnim.running = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
PlasmaComponents.TextField {
|
||||||
|
id: searchInput
|
||||||
|
clearButtonShown: true
|
||||||
|
placeholderText: i18nd("plasma_shell_org.kde.plasma.desktop", "Search...")
|
||||||
|
onTextChanged: {
|
||||||
|
list.positionViewAtBeginning()
|
||||||
|
list.currentIndex = -1
|
||||||
|
widgetExplorer.widgetsModel.searchTerm = text
|
||||||
|
}
|
||||||
|
|
||||||
|
Component.onCompleted: forceActiveFocus()
|
||||||
|
Layout.columnSpan: 2
|
||||||
|
Layout.fillWidth: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
PlasmaExtras.ScrollArea {
|
||||||
|
anchors {
|
||||||
|
top: topBar.bottom
|
||||||
|
left: parent.left
|
||||||
|
right: parent.right
|
||||||
|
bottom: bottomBar.top
|
||||||
|
topMargin: units.smallSpacing
|
||||||
|
leftMargin: units.smallSpacing
|
||||||
|
bottomMargin: units.smallSpacing
|
||||||
|
}
|
||||||
|
GridView {
|
||||||
|
id: list
|
||||||
|
|
||||||
|
model: widgetExplorer.widgetsModel
|
||||||
|
activeFocusOnTab: true
|
||||||
|
currentIndex: -1
|
||||||
|
keyNavigationWraps: true
|
||||||
|
cellWidth: units.iconSizes.enormous + units.smallSpacing * 2
|
||||||
|
cellHeight: cellWidth + units.gridUnit * 4 + units.smallSpacing * 2
|
||||||
|
|
||||||
|
|
||||||
|
delegate: AppletDelegate {}
|
||||||
|
|
||||||
|
//slide in to view from the left
|
||||||
|
add: Transition {
|
||||||
|
NumberAnimation {
|
||||||
|
properties: "x"
|
||||||
|
from: -list.width
|
||||||
|
to: 0
|
||||||
|
duration: units.shortDuration * 3
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//slide out of view to the right
|
||||||
|
remove: Transition {
|
||||||
|
NumberAnimation {
|
||||||
|
properties: "x"
|
||||||
|
to: list.width
|
||||||
|
duration: units.shortDuration * 3
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//if we are adding other items into the view use the same animation as normal adding
|
||||||
|
//this makes everything slide in together
|
||||||
|
//if we make it move everything ends up weird
|
||||||
|
addDisplaced: list.add
|
||||||
|
|
||||||
|
//moved due to filtering
|
||||||
|
displaced: Transition {
|
||||||
|
NumberAnimation {
|
||||||
|
properties: "y"
|
||||||
|
duration: units.shortDuration * 3
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Column {
|
||||||
|
id: bottomBar
|
||||||
anchors {
|
anchors {
|
||||||
left: parent.left
|
left: parent.left
|
||||||
right: parent.right
|
right: parent.right
|
||||||
|
bottom: parent.bottom
|
||||||
|
leftMargin: units.smallSpacing
|
||||||
|
rightMargin: units.smallSpacing
|
||||||
|
bottomMargin: units.smallSpacing
|
||||||
}
|
}
|
||||||
iconSource: widgetExplorer.extraActions[modelData].icon
|
|
||||||
text: widgetExplorer.extraActions[modelData].text
|
spacing: units.smallSpacing
|
||||||
onClicked: {
|
|
||||||
widgetExplorer.extraActions[modelData].trigger()
|
Repeater {
|
||||||
|
model: widgetExplorer.extraActions.length
|
||||||
|
PlasmaComponents.Button {
|
||||||
|
anchors {
|
||||||
|
left: parent.left
|
||||||
|
right: parent.right
|
||||||
|
}
|
||||||
|
iconSource: widgetExplorer.extraActions[modelData].icon
|
||||||
|
text: widgetExplorer.extraActions[modelData].text
|
||||||
|
onClicked: {
|
||||||
|
widgetExplorer.extraActions[modelData].trigger()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Component.onCompleted: {
|
||||||
}
|
main.getWidgetsButton = getWidgetsButton
|
||||||
Component.onCompleted: {
|
main.categoryButton = categoryButton
|
||||||
main.getWidgetsButton = getWidgetsButton
|
}
|
||||||
main.categoryButton = categoryButton
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue