Very early KDE 6 release.

This commit is contained in:
wackyideas 2024-08-09 03:20:25 +02:00
parent 7cc4ccabbc
commit 686046d4f7
6272 changed files with 140920 additions and 529657 deletions

View file

@ -0,0 +1,204 @@
/*
SPDX-FileCopyrightText: 2014 Marco Martin <mart@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
import QtQuick 2.15
import QtQuick.Controls 2.5 as QQC2
import QtQuick.Layouts 1.1
import QtQuick.Window 2.1
import org.kde.plasma.core as PlasmaCore
import org.kde.plasma.components 3.0 as PlasmaComponents3
import org.kde.plasma.extras 2.0 as PlasmaExtras
import org.kde.plasma.plasmoid
import org.kde.kirigami 2.20 as Kirigami
import org.kde.plasma.private.shell 2.0
PlasmaCore.Dialog {
id: dialog
visualParent: alternativesHelper.applet
location: alternativesHelper.applet.Plasmoid.location
hideOnWindowDeactivate: true
backgroundHints: (alternativesHelper.applet.Plasmoid.containmentDisplayHints & PlasmaCore.Types.ContainmentPrefersOpaqueBackground) ? PlasmaCore.Dialog.SolidBackground : PlasmaCore.Dialog.StandardBackground
Component.onCompleted: {
flags = flags | Qt.WindowStaysOnTopHint;
dialog.show();
}
ColumnLayout {
id: root
signal configurationChanged
Layout.minimumWidth: Kirigami.Units.gridUnit * 20
Layout.minimumHeight: Math.min(Screen.height - Kirigami.Units.gridUnit * 10, implicitHeight)
LayoutMirroring.enabled: Qt.application.layoutDirection === Qt.RightToLeft
LayoutMirroring.childrenInherit: true
property string currentPlugin: ""
Shortcut {
sequence: "Escape"
onActivated: dialog.close()
}
Shortcut {
sequence: "Return"
onActivated: root.savePluginAndClose()
}
Shortcut {
sequence: "Enter"
onActivated: root.savePluginAndClose()
}
WidgetExplorer {
id: widgetExplorer
provides: alternativesHelper.appletProvides
}
PlasmaExtras.PlasmoidHeading {
Kirigami.Heading {
id: heading
text: i18nd("plasma_shell_org.kde.plasma.desktop", "Alternative Widgets")
textFormat: Text.PlainText
}
}
// This timer checks with a short delay whether a new item in the list has been hovered by the cursor.
// If not, then the cursor has left the view and thus no item should be selected.
Timer {
id: resetCurrentIndex
property string oldPlugin
interval: 100
onTriggered: {
if (root.currentPlugin === oldPlugin) {
mainList.currentIndex = -1
root.currentPlugin = ""
}
}
}
function savePluginAndClose() {
alternativesHelper.loadAlternative(currentPlugin);
dialog.close();
}
PlasmaComponents3.ScrollView {
Layout.fillWidth: true
Layout.fillHeight: true
Layout.preferredHeight: mainList.contentHeight
focus: true
ListView {
id: mainList
focus: dialog.visible
model: widgetExplorer.widgetsModel
boundsBehavior: Flickable.StopAtBounds
highlight: PlasmaExtras.Highlight {
pressed: mainList.currentItem && mainList.currentItem.pressed
}
highlightMoveDuration : 0
highlightResizeDuration: 0
height: contentHeight+Kirigami.Units.smallSpacing
delegate: PlasmaComponents3.ItemDelegate {
id: listItem
implicitHeight: contentLayout.implicitHeight + Kirigami.Units.smallSpacing * 2
width: ListView.view.width
onHoveredChanged: {
if (hovered) {
resetCurrentIndex.stop()
mainList.currentIndex = index
} else {
resetCurrentIndex.oldPlugin = model.pluginName
resetCurrentIndex.restart()
}
}
Connections {
target: mainList
function onCurrentIndexChanged() {
if (mainList.currentIndex === index) {
root.currentPlugin = model.pluginName
}
}
}
onClicked: root.savePluginAndClose()
Component.onCompleted: {
if (model.pluginName === alternativesHelper.currentPlugin) {
root.currentPlugin = model.pluginName
setAsCurrent.restart()
}
}
// we don't want to select any entry by default
// this cannot be set in Component.onCompleted
Timer {
id: setAsCurrent
interval: 100
onTriggered: {
mainList.currentIndex = index
}
}
contentItem: RowLayout {
id: contentLayout
spacing: Kirigami.Units.largeSpacing
Kirigami.Icon {
implicitWidth: Kirigami.Units.iconSizes.huge
implicitHeight: Kirigami.Units.iconSizes.huge
source: model.decoration
}
ColumnLayout {
id: labelLayout
readonly property color textColor: listItem.pressed ? Kirigami.Theme.highlightedTextColor : Kirigami.Theme.textColor
Layout.fillHeight: true
Layout.fillWidth: true
spacing: 0 // The labels bring their own bottom margins
Kirigami.Heading {
level: 4
Layout.fillWidth: true
text: model.name
textFormat: Text.PlainText
elide: Text.ElideRight
type: model.pluginName === alternativesHelper.currentPlugin ? PlasmaExtras.Heading.Type.Primary : PlasmaExtras.Heading.Type.Normal
color: labelLayout.textColor
}
PlasmaComponents3.Label {
Layout.fillWidth: true
text: model.description
textFormat: Text.PlainText
font.pointSize: Kirigami.Theme.smallFont.pointSize
font.family: Kirigami.Theme.smallFont.family
font.bold: model.pluginName === alternativesHelper.currentPlugin
opacity: 0.6
maximumLineCount: 2
wrapMode: Text.WordWrap
elide: Text.ElideRight
color: labelLayout.textColor
}
}
}
}
}
}
}
}

View file

@ -0,0 +1,247 @@
/*
SPDX-FileCopyrightText: 2011 Marco Martin <mart@kde.org>
SPDX-FileCopyrightText: 2015 Kai Uwe Broulik <kde@privat.broulik.de>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
import QtQuick 2.15
import QtQuick.Layouts 1.1
import org.kde.plasma.components 3.0 as PlasmaComponents
import org.kde.plasma.core as PlasmaCore
import org.kde.kwindowsystem
import org.kde.kirigami 2.20 as Kirigami
import org.kde.graphicaleffects as KGraphicalEffects
Item {
id: delegate
readonly property string pluginName: model.pluginName
readonly property bool pendingUninstall: pendingUninstallTimer.applets.indexOf(pluginName) > -1
readonly property bool pressed: tapHandler.pressed
width: list.cellWidth
height: list.cellHeight
HoverHandler {
id: hoverHandler
onHoveredChanged: if (hovered) delegate.GridView.view.currentIndex = index
}
TapHandler {
id: tapHandler
enabled: !delegate.pendingUninstall && model.isSupported
onTapped: widgetExplorer.addApplet(delegate.pluginName)
}
PlasmaCore.ToolTipArea {
anchors.fill: parent
visible: !model.isSupported
mainText: i18n("Unsupported Widget")
subText: model.unsupportedMessage
}
// Avoid repositioning delegate item after dragFinished
Item {
anchors.fill: parent
enabled: model.isSupported
Drag.dragType: Drag.Automatic
Drag.supportedActions: Qt.MoveAction | Qt.LinkAction
Drag.mimeData: {
"text/x-plasmoidservicename" : delegate.pluginName,
}
Drag.onDragStarted: {
KWindowSystem.showingDesktop = true;
main.draggingWidget = true;
}
Drag.onDragFinished: {
main.draggingWidget = false;
}
DragHandler {
id: dragHandler
enabled: !delegate.pendingUninstall && model.isSupported
onActiveChanged: if (active) {
iconContainer.grabToImage(function(result) {
if (!dragHandler.active) {
return;
}
parent.Drag.imageSource = result.url;
parent.Drag.active = dragHandler.active;
}, Qt.size(Kirigami.Units.iconSizes.huge, Kirigami.Units.iconSizes.huge));
} else {
parent.Drag.active = false;
parent.Drag.imageSource = "";
}
}
}
ColumnLayout {
id: mainLayout
readonly property color textColor: tapHandler.pressed ? Kirigami.Theme.highlightedTextColor : Kirigami.Theme.textColor
spacing: Kirigami.Units.smallSpacing
anchors {
left: parent.left
right: parent.right
//bottom: parent.bottom
margins: Kirigami.Units.smallSpacing * 2
rightMargin: Kirigami.Units.smallSpacing * 2 // don't cram the text to the border too much
top: parent.top
}
Item {
id: iconContainer
width: Kirigami.Units.iconSizes.enormous
height: width
Layout.alignment: Qt.AlignHCenter
opacity: delegate.pendingUninstall ? 0.6 : 1
Behavior on opacity {
OpacityAnimator {
duration: Kirigami.Units.longDuration
easing.type: Easing.InOutQuad
}
}
Item {
id: iconWidget
anchors.fill: parent
Kirigami.Icon {
anchors.fill: parent
source: model.decoration
visible: model.screenshot === ""
selected: tapHandler.pressed
enabled: model.isSupported
}
Image {
width: Kirigami.Units.iconSizes.enormous
height: width
anchors.fill: parent
fillMode: Image.PreserveAspectFit
source: model.screenshot
}
}
Item {
id: badgeMask
anchors.fill: parent
Rectangle {
x: Math.round(-Kirigami.Units.smallSpacing * 1.5 / 2)
y: x
width: runningBadge.width + Math.round(Kirigami.Units.smallSpacing * 1.5)
height: width
radius: height
visible: running && delegate.GridView.isCurrentItem
}
}
KGraphicalEffects.BadgeEffect {
anchors.fill: parent
source: ShaderEffectSource {
sourceItem: iconWidget
hideSource: true
live: false
}
mask: ShaderEffectSource {
id: maskShaderSource
sourceItem: badgeMask
hideSource: true
live: false
}
}
Rectangle {
id: runningBadge
width: height
height: Math.round(Kirigami.Units.iconSizes.sizeForLabels * 1.3)
radius: height
color: Kirigami.Theme.highlightColor
visible: running && delegate.GridView.isCurrentItem
onVisibleChanged: maskShaderSource.scheduleUpdate()
PlasmaComponents.Label {
id: countLabel
anchors.fill: parent
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
text: running
textFormat: Text.PlainText
}
}
PlasmaComponents.ToolButton {
id: uninstallButton
anchors {
top: parent.top
right: parent.right
}
icon.name: delegate.pendingUninstall ? "edit-undo" : "edit-delete"
// we don't really "undo" anything but we'll pretend to the user that we do
PlasmaComponents.ToolTip.delay: Kirigami.Units.toolTipDelay
PlasmaComponents.ToolTip.visible: hovered
PlasmaComponents.ToolTip.text: delegate.pendingUninstall ? i18nd("plasma_shell_org.kde.plasma.desktop", "Undo uninstall")
: i18nd("plasma_shell_org.kde.plasma.desktop", "Uninstall widget")
flat: false
visible: model.local && delegate.GridView.isCurrentItem && !dragHandler.active
onHoveredChanged: {
if (hovered) {
// hovering the uninstall button triggers onExited of the main mousearea
delegate.GridView.view.currentIndex = index
}
}
onClicked: {
var pending = pendingUninstallTimer.applets
if (delegate.pendingUninstall) {
var index = pending.indexOf(pluginName)
if (index > -1) {
pending.splice(index, 1)
}
} else {
pending.push(pluginName)
}
pendingUninstallTimer.applets = pending
if (pending.length) {
pendingUninstallTimer.restart()
} else {
pendingUninstallTimer.stop()
}
}
}
}
Kirigami.Heading {
id: heading
Layout.fillWidth: true
level: 4
text: model.name
textFormat: Text.PlainText
elide: Text.ElideRight
wrapMode: Text.WordWrap
maximumLineCount: 2
lineHeight: 0.95
horizontalAlignment: Text.AlignHCenter
color: mainLayout.textColor
}
PlasmaComponents.Label {
Layout.fillWidth: true
// otherwise causes binding loop due to the way the Plasma sets the height
height: implicitHeight
text: model.description
textFormat: Text.PlainText
font: Kirigami.Theme.smallFont
wrapMode: Text.WordWrap
elide: Text.ElideRight
maximumLineCount: heading.lineCount === 1 ? 3 : 2
horizontalAlignment: Text.AlignHCenter
color: mainLayout.textColor
}
}
}

View file

@ -0,0 +1,142 @@
/*
SPDX-FileCopyrightText: 2011 Marco Martin <mart@kde.org>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
import QtQuick 2.1
import QtQuick.Layouts 1.0 as Layouts
import org.kde.plasma.components 3.0 as PlasmaComponents
import org.kde.kirigami 2.20 as Kirigami
MouseArea {
id: main
hoverEnabled: true
onEntered: toolTipHideTimer.running = false
onExited: toolTipHideTimer.running = true
width: Kirigami.Units.iconSizes.sizeForLabels * 35
height: Kirigami.Units.iconSizes.sizeForLabels * 16
property variant icon
property string title
property string description
property string author
property string email
property string license
property string pluginName
property bool local
onClicked: tooltipDialog.visible = false
Connections {
target: tooltipDialog
function onAppletDelegateChanged() {
if (!tooltipDialog.appletDelegate) {
return
}
icon = tooltipDialog.appletDelegate.icon
title = tooltipDialog.appletDelegate.title
description = tooltipDialog.appletDelegate.description
author = tooltipDialog.appletDelegate.author
email = tooltipDialog.appletDelegate.email
license = tooltipDialog.appletDelegate.license
pluginName = tooltipDialog.appletDelegate.pluginName
local = tooltipDialog.appletDelegate.local
}
}
Kirigami.Icon {
id: tooltipIconWidget
anchors {
left: parent.left
top: parent.top
margins: 8
}
width: Kirigami.Units.iconSizes.huge
height: width
source: main.icon
}
Column {
id: nameColumn
spacing: 8
anchors {
left: tooltipIconWidget.right
margins: 8
top: parent.top
right: parent.right
}
Kirigami.Heading {
text: title
level: 2
anchors.left: parent.left
anchors.right: parent.right
height: paintedHeight
textFormat: Text.PlainText
wrapMode: Text.Wrap
}
PlasmaComponents.Label {
text: description
textFormat: Text.PlainText
anchors.left: parent.left
anchors.right: parent.right
wrapMode: Text.Wrap
}
}
Layouts.GridLayout {
columns: 2
anchors {
top: (nameColumn.height > tooltipIconWidget.height) ? nameColumn.bottom : tooltipIconWidget.bottom
topMargin: 16
horizontalCenter: parent.horizontalCenter
}
PlasmaComponents.Label {
text: i18nd("plasma_shell_org.kde.plasma.desktop", "License:")
textFormat: Text.PlainText
Layouts.Layout.alignment: Qt.AlignVCenter|Qt.AlignRight
}
PlasmaComponents.Label {
id: licenseText
text: license
textFormat: Text.PlainText
wrapMode: Text.Wrap
}
PlasmaComponents.Label {
text: i18nd("plasma_shell_org.kde.plasma.desktop", "Author:")
textFormat: Text.PlainText
Layouts.Layout.alignment: Qt.AlignVCenter|Qt.AlignRight
}
PlasmaComponents.Label {
text: author
textFormat: Text.PlainText
wrapMode: Text.Wrap
}
PlasmaComponents.Label {
text: i18nd("plasma_shell_org.kde.plasma.desktop", "Email:")
textFormat: Text.PlainText
Layouts.Layout.alignment: Qt.AlignVCenter|Qt.AlignRight
}
PlasmaComponents.Label {
text: email
textFormat: Text.PlainText
}
}
PlasmaComponents.Button {
id: uninstallButton
anchors {
horizontalCenter: parent.horizontalCenter
bottom: parent.bottom
}
opacity: local ? 1 : 0
Behavior on opacity {
NumberAnimation { duration: Kirigami.Units.longDuration }
}
iconSource: "application-exit"
text: i18nd("plasma_shell_org.kde.plasma.desktop", "Uninstall")
onClicked: {
widgetExplorer.uninstall(pluginName)
tooltipDialog.visible = false
}
}
}

View file

@ -0,0 +1,309 @@
/*
SPDX-FileCopyrightText: 2011 Marco Martin <mart@kde.org>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
import QtQuick 2.7
import QtQuick.Controls 2.5 as QQC2
import org.kde.plasma.components 3.0 as PC3
import org.kde.plasma.core as PlasmaCore
import org.kde.plasma.extras 2.0 as PlasmaExtras
import org.kde.kquickcontrolsaddons 2.0
import org.kde.kwindowsystem 1.0
import org.kde.kirigami 2.20 as Kirigami
import QtQuick.Window 2.1
import QtQuick.Layouts 1.1
import org.kde.plasma.private.shell 2.0
PC3.Page {
id: main
width: Math.max(heading.paintedWidth, Kirigami.Units.iconSizes.enormous * 3 + Kirigami.Units.smallSpacing * 4 + Kirigami.Units.gridUnit * 2)
height: 800//Screen.height
opacity: draggingWidget ? 0.3 : 1
property QtObject containment
property PlasmaCore.Dialog sidePanel
//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: draggingWidget || categoriesDialog.status !== PlasmaExtras.Menu.Closed
|| getWidgetsDialog.status !== PlasmaExtras.Menu.Closed
// We might've lost focus during the widget drag and drop or whilst using
// the "get widgets" dialog; however we prevented the sidebar to hide.
// This might get the sidebar stuck, since we only hide when losing focus.
// To avoid this we reclaim focus as soon as the drag and drop is done,
// or the get widgets window is closed.
onPreventWindowHideChanged: {
if (!preventWindowHide && !sidePanel.active) {
sidePanel.requestActivate()
}
}
property bool outputOnly: draggingWidget
property Item categoryButton
property bool draggingWidget: false
signal closed()
onVisibleChanged: {
if (!visible) {
KWindowSystem.showingDesktop = false
}
}
Component.onCompleted: {
if (!root.widgetExplorer) {
root.widgetExplorer = widgetExplorerComponent.createObject(root)
}
root.widgetExplorer.containment = main.containment
}
Component.onDestruction: {
if (pendingUninstallTimer.running) {
// we're not being destroyed so at least reset the filters
widgetExplorer.widgetsModel.filterQuery = ""
widgetExplorer.widgetsModel.filterType = ""
widgetExplorer.widgetsModel.searchTerm = ""
} else {
root.widgetExplorer.destroy()
root.widgetExplorer = null
}
}
function addCurrentApplet() {
var pluginName = list.currentItem ? list.currentItem.pluginName : ""
if (pluginName) {
widgetExplorer.addApplet(pluginName)
}
}
QQC2.Action {
shortcut: "Escape"
onTriggered: {
if (searchInput.length > 0) {
searchInput.text = ""
} else {
main.closed()
}
}
}
QQC2.Action {
shortcut: "Enter"
onTriggered: addCurrentApplet()
}
QQC2.Action {
shortcut: "Return"
onTriggered: addCurrentApplet()
}
Component {
id: widgetExplorerComponent
WidgetExplorer {
//view: desktop
onShouldClose: main.closed();
}
}
PlasmaExtras.ModelContextMenu {
id: categoriesDialog
visualParent: categoryButton
// model set on first invocation
onClicked: {
list.contentX = 0
list.contentY = 0
categoryButton.text = (model.filterData ? model.display : i18nd("plasma_shell_org.kde.plasma.desktop", "All Widgets"))
widgetExplorer.widgetsModel.filterQuery = model.filterData
widgetExplorer.widgetsModel.filterType = model.filterType
}
}
PlasmaExtras.ModelContextMenu {
id: getWidgetsDialog
visualParent: getWidgetsButton
placement: PlasmaExtras.Menu.TopPosedLeftAlignedPopup
// model set on first invocation
onClicked: model.trigger()
}
header: PlasmaExtras.PlasmoidHeading {
ColumnLayout {
id: header
anchors.fill: parent
spacing: Kirigami.Units.smallSpacing
RowLayout {
spacing: Kirigami.Units.smallSpacing
Kirigami.Heading {
id: heading
level: 1
text: i18nd("plasma_shell_org.kde.plasma.desktop", "Widgets")
textFormat: Text.PlainText
elide: Text.ElideRight
Layout.fillWidth: true
}
PC3.ToolButton {
id: getWidgetsButton
icon.name: "get-hot-new-stuff"
text: i18nd("plasma_shell_org.kde.plasma.desktop", "Get New Widgets…")
KeyNavigation.right: closeButton
KeyNavigation.down: searchInput
onClicked: {
getWidgetsDialog.model = widgetExplorer.widgetsMenuActions
getWidgetsDialog.openRelative()
}
}
PC3.ToolButton {
id: closeButton
icon.name: "window-close"
KeyNavigation.down: categoryButton
onClicked: main.closed()
}
}
RowLayout {
spacing: Kirigami.Units.smallSpacing
PlasmaExtras.SearchField {
id: searchInput
Layout.fillWidth: true
KeyNavigation.down: list
KeyNavigation.right: categoryButton
onTextChanged: {
list.positionViewAtBeginning()
list.currentIndex = -1
widgetExplorer.widgetsModel.searchTerm = text
}
Component.onCompleted: if (!Kirigami.InputMethod.willShowOnActive) { forceActiveFocus() }
}
PC3.ToolButton {
id: categoryButton
text: i18nd("plasma_shell_org.kde.plasma.desktop", "All Widgets")
icon.name: "view-filter"
KeyNavigation.down: list
onClicked: {
categoriesDialog.model = widgetExplorer.filterModel
categoriesDialog.open(0, categoryButton.height)
}
PC3.ToolTip {
text: i18nd("plasma_shell_org.kde.plasma.desktop", "Categories")
}
}
}
}
}
footer: PlasmaExtras.PlasmoidHeading {
position: PC3.ToolBar.Footer
visible: pendingUninstallTimer.applets.length > 0
contentItem: PC3.Button {
text: i18ndp("plasma_shell_org.kde.plasma.desktop", "Confirm Removal Of One Widget", "Confirm Removal Of %1 Widgets", pendingUninstallTimer.applets.length)
onClicked: pendingUninstallTimer.uninstall()
}
}
Timer {
id: setModelTimer
interval: 20
running: true
onTriggered: list.model = widgetExplorer.widgetsModel
}
PC3.ScrollView {
anchors.fill: parent
anchors.rightMargin: - main.sidePanel.margins.right
// hide the flickering by fading in nicely
opacity: setModelTimer.running ? 0 : 1
Behavior on opacity {
OpacityAnimator {
duration: Kirigami.Units.longDuration
easing.type: Easing.InOutQuad
}
}
GridView {
id: list
// model set delayed by Timer above
activeFocusOnTab: true
cellWidth: Math.floor(width / 3)
cellHeight: cellWidth + Kirigami.Units.gridUnit * 4 + Kirigami.Units.smallSpacing * 2
delegate: AppletDelegate {}
highlight: PlasmaExtras.Highlight {
pressed: list.currentItem && list.currentItem.pressed
}
highlightMoveDuration: 0
//highlightResizeDuration: 0
//slide in to view from the left
add: Transition {
NumberAnimation {
properties: "x"
from: -list.width
duration: Kirigami.Units.shortDuration
}
}
//slide out of view to the right
remove: Transition {
NumberAnimation {
properties: "x"
to: list.width
duration: Kirigami.Units.shortDuration
}
}
//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: "x,y"
duration: Kirigami.Units.shortDuration
}
}
KeyNavigation.up: searchInput
}
}
PlasmaExtras.PlaceholderMessage {
anchors.centerIn: parent
width: parent.width - (Kirigami.Units.gridUnit * 4)
iconName: "edit-none"
text: searchInput.text.length > 0 ? i18nd("plasma_shell_org.kde.plasma.desktop", "No widgets matched the search terms") : i18nd("plasma_shell_org.kde.plasma.desktop", "No widgets available")
visible: list.count == 0 && !setModelTimer.running
}
}