get rid of WidgetExplorerView
The widget explorer window is done by a Dialog, allowing for more flexibility in shell packages
This commit is contained in:
parent
2f042a51f6
commit
876ade83a0
@ -100,6 +100,7 @@ void DialogProxy::setMainItem(QQuickItem *mainItem)
|
||||
if (mainItem->metaObject()->indexOfSignal("heightChanged")) {
|
||||
connect(mainItem, SIGNAL(heightChanged()), m_syncTimer, SLOT(start()));
|
||||
}
|
||||
syncToMainItemSize();
|
||||
}
|
||||
|
||||
//if this is called in Compenent.onCompleted we have to wait a loop the item is added to a scene
|
||||
@ -354,7 +355,7 @@ void DialogProxy::syncToMainItemSize()
|
||||
|
||||
void DialogProxy::setAttribute(int attribute, bool on)
|
||||
{
|
||||
setAttribute((Qt::WidgetAttribute)attribute, on);
|
||||
//setAttribute((Qt::WidgetAttribute)attribute, on);
|
||||
|
||||
if (attribute == Qt::WA_X11NetWmWindowTypeDock) {
|
||||
KWindowSystem::setOnAllDesktops(winId(), true);
|
||||
|
@ -39,7 +39,6 @@ set(widgetexplorer_SRC
|
||||
widgetexplorer/kcategorizeditemsviewmodels.cpp
|
||||
widgetexplorer/plasmaappletitemmodel.cpp
|
||||
widgetexplorer/widgetexplorer.cpp
|
||||
widgetexplorer/widgetexplorerview.cpp
|
||||
)
|
||||
|
||||
add_executable(plasma-shell
|
||||
|
@ -22,161 +22,228 @@ import org.kde.plasma.components 2.0 as PlasmaComponents
|
||||
import org.kde.plasma.core 2.0 as PlasmaCore
|
||||
import org.kde.qtextracomponents 2.0
|
||||
|
||||
Item {
|
||||
id: main
|
||||
PlasmaCore.Dialog {
|
||||
id: dialog
|
||||
location: PlasmaCore.Types.LeftEdge
|
||||
|
||||
width: 240
|
||||
height: 800
|
||||
//this is used to perfectly align the filter field and delegates
|
||||
property int cellWidth: theme.defaultFont.pixelSize * 20
|
||||
Component.onCompleted: dialog.visible = true;
|
||||
mainItem: Item {
|
||||
id: main
|
||||
|
||||
PlasmaCore.FrameSvgItem {
|
||||
imagePath: "dialogs/background"
|
||||
anchors.fill: parent
|
||||
anchors.margins: margins
|
||||
//color: "orange"
|
||||
//opacity: 0.3
|
||||
}
|
||||
width: 240
|
||||
height: 800
|
||||
//this is used to perfectly align the filter field and delegates
|
||||
property int cellWidth: theme.defaultFont.pixelSize * 20
|
||||
|
||||
property int minimumWidth: cellWidth + (
|
||||
widgetExplorer.orientation == Qt.Horizontal
|
||||
? 0
|
||||
: (scrollBar.width + 4 * 2) // 4 * 2 == left and right margins
|
||||
)
|
||||
property int minimumHeight: topBar.height + list.delegateHeight + (widgetExplorer.orientation == Qt.Horizontal ? scrollBar.height : 0) + 4
|
||||
property int minimumWidth: cellWidth + (
|
||||
widgetExplorer.orientation == Qt.Horizontal
|
||||
? 0
|
||||
: (scrollBar.width + 4 * 2) // 4 * 2 == left and right margins
|
||||
)
|
||||
property int minimumHeight: 800//topBar.height + list.delegateHeight + (widgetExplorer.orientation == Qt.Horizontal ? scrollBar.height : 0) + 4
|
||||
|
||||
property Item getWidgetsButton
|
||||
property Item categoryButton
|
||||
property Item getWidgetsButton
|
||||
property Item categoryButton
|
||||
|
||||
PlasmaComponents.ContextMenu {
|
||||
id: categoriesDialog
|
||||
visualParent: main.categoryButton
|
||||
}
|
||||
Repeater {
|
||||
parent: categoriesDialog
|
||||
model: widgetExplorer.filterModel
|
||||
delegate: PlasmaComponents.MenuItem {
|
||||
text: display
|
||||
separator: model["separator"] != undefined ? model["separator"] : false
|
||||
onClicked: {
|
||||
list.contentX = 0
|
||||
list.contentY = 0
|
||||
main.categoryButton.text = display
|
||||
widgetExplorer.widgetsModel.filterQuery = model["filterData"]
|
||||
widgetExplorer.widgetsModel.filterType = model["filterType"]
|
||||
PlasmaComponents.ContextMenu {
|
||||
id: categoriesDialog
|
||||
visualParent: main.categoryButton
|
||||
}
|
||||
Repeater {
|
||||
parent: categoriesDialog
|
||||
model: widgetExplorer.filterModel
|
||||
delegate: Item {
|
||||
PlasmaComponents.MenuItem {
|
||||
text: display
|
||||
separator: model["separator"] != undefined ? model["separator"] : false
|
||||
onClicked: {
|
||||
list.contentX = 0
|
||||
list.contentY = 0
|
||||
main.categoryButton.text = display
|
||||
widgetExplorer.widgetsModel.filterQuery = model["filterData"]
|
||||
widgetExplorer.widgetsModel.filterType = model["filterType"]
|
||||
}
|
||||
Component.onCompleted: {
|
||||
parent = categoriesDialog
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PlasmaComponents.ContextMenu {
|
||||
id: getWidgetsDialog
|
||||
visualParent: main.getWidgetsButton
|
||||
}
|
||||
Repeater {
|
||||
parent: getWidgetsDialog
|
||||
model: widgetExplorer.widgetsMenuActions
|
||||
delegate: Item {
|
||||
PlasmaComponents.MenuItem {
|
||||
icon: modelData.icon
|
||||
text: modelData.text
|
||||
separator: modelData.separator
|
||||
onClicked: modelData.trigger()
|
||||
Component.onCompleted: {
|
||||
parent = getWidgetsDialog
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PlasmaCore.Dialog {
|
||||
id: tooltipDialog
|
||||
property Item appletDelegate
|
||||
|
||||
Component.onCompleted: {
|
||||
parent = categoriesDialog
|
||||
tooltipDialog.setAttribute(Qt.WA_X11NetWmWindowTypeToolTip, true)
|
||||
tooltipDialog.windowFlags = Qt.Window|Qt.WindowStaysOnTopHint|Qt.X11BypassWindowManagerHint
|
||||
}
|
||||
|
||||
onAppletDelegateChanged: {
|
||||
if (!appletDelegate) {
|
||||
toolTipHideTimer.restart()
|
||||
toolTipShowTimer.running = false
|
||||
} else if (tooltipDialog.visible) {
|
||||
var point = main.tooltipPosition()
|
||||
tooltipDialog.x = point.x
|
||||
tooltipDialog.y = point.y
|
||||
} else {
|
||||
toolTipShowTimer.restart()
|
||||
toolTipHideTimer.running = false
|
||||
}
|
||||
}
|
||||
mainItem: Tooltip { id: tooltipWidget }
|
||||
Behavior on x {
|
||||
enabled: widgetExplorer.orientation == Qt.Horizontal
|
||||
NumberAnimation { duration: 250 }
|
||||
}
|
||||
Behavior on y {
|
||||
enabled: widgetExplorer.orientation == Qt.Vertical
|
||||
NumberAnimation { duration: 250 }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PlasmaComponents.ContextMenu {
|
||||
id: getWidgetsDialog
|
||||
visualParent: main.getWidgetsButton
|
||||
}
|
||||
Repeater {
|
||||
parent: getWidgetsDialog
|
||||
model: widgetExplorer.widgetsMenuActions
|
||||
delegate: PlasmaComponents.MenuItem {
|
||||
icon: modelData.icon
|
||||
text: modelData.text
|
||||
separator: modelData.separator
|
||||
onClicked: modelData.trigger()
|
||||
Component.onCompleted: {
|
||||
parent = getWidgetsDialog
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PlasmaCore.Dialog {
|
||||
id: tooltipDialog
|
||||
property Item appletDelegate
|
||||
|
||||
Component.onCompleted: {
|
||||
tooltipDialog.setAttribute(Qt.WA_X11NetWmWindowTypeToolTip, true)
|
||||
tooltipDialog.windowFlags = Qt.Window|Qt.WindowStaysOnTopHint|Qt.X11BypassWindowManagerHint
|
||||
}
|
||||
|
||||
onAppletDelegateChanged: {
|
||||
if (!appletDelegate) {
|
||||
toolTipHideTimer.restart()
|
||||
toolTipShowTimer.running = false
|
||||
} else if (tooltipDialog.visible) {
|
||||
Timer {
|
||||
id: toolTipShowTimer
|
||||
interval: 500
|
||||
repeat: false
|
||||
onTriggered: {
|
||||
var point = main.tooltipPosition()
|
||||
tooltipDialog.x = point.x
|
||||
tooltipDialog.y = point.y
|
||||
} else {
|
||||
toolTipShowTimer.restart()
|
||||
toolTipHideTimer.running = false
|
||||
tooltipDialog.visible = true
|
||||
}
|
||||
}
|
||||
mainItem: Tooltip { id: tooltipWidget }
|
||||
Behavior on x {
|
||||
enabled: widgetExplorer.orientation == Qt.Horizontal
|
||||
NumberAnimation { duration: 250 }
|
||||
Timer {
|
||||
id: toolTipHideTimer
|
||||
interval: 1000
|
||||
repeat: false
|
||||
onTriggered: tooltipDialog.visible = false
|
||||
}
|
||||
Behavior on y {
|
||||
enabled: widgetExplorer.orientation == Qt.Vertical
|
||||
NumberAnimation { duration: 250 }
|
||||
function tooltipPosition() {
|
||||
return widgetExplorer.tooltipPosition(tooltipDialog.appletDelegate, tooltipDialog.width, tooltipDialog.height);
|
||||
}
|
||||
}
|
||||
Timer {
|
||||
id: toolTipShowTimer
|
||||
interval: 500
|
||||
repeat: false
|
||||
onTriggered: {
|
||||
var point = main.tooltipPosition()
|
||||
tooltipDialog.x = point.x
|
||||
tooltipDialog.y = point.y
|
||||
tooltipDialog.visible = true
|
||||
}
|
||||
}
|
||||
Timer {
|
||||
id: toolTipHideTimer
|
||||
interval: 1000
|
||||
repeat: false
|
||||
onTriggered: tooltipDialog.visible = false
|
||||
}
|
||||
function tooltipPosition() {
|
||||
return widgetExplorer.tooltipPosition(tooltipDialog.appletDelegate, tooltipDialog.width, tooltipDialog.height);
|
||||
}
|
||||
|
||||
Loader {
|
||||
id: topBar
|
||||
property Item categoryButton
|
||||
Loader {
|
||||
id: topBar
|
||||
property Item categoryButton
|
||||
|
||||
sourceComponent: (widgetExplorer.orientation == Qt.Horizontal) ? horizontalTopBarComponent : verticalTopBarComponent
|
||||
height: item.height + 2
|
||||
anchors {
|
||||
top: parent.top
|
||||
left: parent.left
|
||||
right: parent.right
|
||||
|
||||
topMargin: widgetExplorer.orientation == Qt.Horizontal ? 4 : 0
|
||||
leftMargin: 4
|
||||
}
|
||||
}
|
||||
|
||||
Component {
|
||||
id: horizontalTopBarComponent
|
||||
|
||||
Item {
|
||||
sourceComponent: (widgetExplorer.orientation == Qt.Horizontal) ? horizontalTopBarComponent : verticalTopBarComponent
|
||||
height: item.height + 2
|
||||
anchors {
|
||||
top: parent.top
|
||||
left: parent.left
|
||||
right: parent.right
|
||||
|
||||
topMargin: widgetExplorer.orientation == Qt.Horizontal ? 4 : 0
|
||||
leftMargin: 4
|
||||
}
|
||||
height: filterField.height
|
||||
Row {
|
||||
spacing: 5
|
||||
}
|
||||
|
||||
Component {
|
||||
id: horizontalTopBarComponent
|
||||
|
||||
Item {
|
||||
anchors {
|
||||
top: parent.top
|
||||
left: parent.left
|
||||
leftMargin: 2
|
||||
right: parent.right
|
||||
}
|
||||
height: filterField.height
|
||||
Row {
|
||||
spacing: 5
|
||||
anchors {
|
||||
left: parent.left
|
||||
leftMargin: 2
|
||||
}
|
||||
PlasmaComponents.TextField {
|
||||
id: filterField
|
||||
width: list.width / Math.floor(list.width / cellWidth) - 4
|
||||
clearButtonShown: true
|
||||
placeholderText: i18n("Enter search term...")
|
||||
onTextChanged: {
|
||||
list.contentX = 0
|
||||
list.contentY = 0
|
||||
widgetExplorer.widgetsModel.searchTerm = text
|
||||
}
|
||||
Component.onCompleted: forceActiveFocus()
|
||||
}
|
||||
PlasmaComponents.Button {
|
||||
id: categoryButton
|
||||
text: i18n("Categories")
|
||||
onClicked: categoriesDialog.open(0, categoryButton.height)
|
||||
}
|
||||
}
|
||||
Row {
|
||||
anchors.right: parent.right
|
||||
spacing: 5
|
||||
PlasmaComponents.Button {
|
||||
id: getWidgetsButton
|
||||
iconSource: "get-hot-new-stuff"
|
||||
text: i18n("Get new widgets")
|
||||
onClicked: getWidgetsDialog.open()
|
||||
}
|
||||
|
||||
Repeater {
|
||||
model: widgetExplorer.extraActions.length
|
||||
PlasmaComponents.Button {
|
||||
iconSource: widgetExplorer.extraActions[modelData].icon
|
||||
text: widgetExplorer.extraActions[modelData].text
|
||||
onClicked: {
|
||||
widgetExplorer.extraActions[modelData].trigger()
|
||||
}
|
||||
}
|
||||
}
|
||||
PlasmaComponents.ToolButton {
|
||||
iconSource: "window-close"
|
||||
onClicked: widgetExplorer.close()
|
||||
}
|
||||
}
|
||||
Component.onCompleted: {
|
||||
main.getWidgetsButton = getWidgetsButton
|
||||
main.categoryButton = categoryButton
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Component {
|
||||
id: verticalTopBarComponent
|
||||
|
||||
Column {
|
||||
anchors.top: parent.top
|
||||
anchors.left:parent.left
|
||||
anchors.right: parent.right
|
||||
spacing: 4
|
||||
|
||||
PlasmaComponents.ToolButton {
|
||||
anchors.right: parent.right
|
||||
iconSource: "window-close"
|
||||
onClicked: widgetExplorer.close()
|
||||
}
|
||||
PlasmaComponents.TextField {
|
||||
id: filterField
|
||||
width: list.width / Math.floor(list.width / cellWidth) - 4
|
||||
anchors {
|
||||
left: parent.left
|
||||
right: parent.right
|
||||
}
|
||||
clearButtonShown: true
|
||||
placeholderText: i18n("Enter search term...")
|
||||
onTextChanged: {
|
||||
@ -187,15 +254,100 @@ Item {
|
||||
Component.onCompleted: forceActiveFocus()
|
||||
}
|
||||
PlasmaComponents.Button {
|
||||
anchors {
|
||||
left: parent.left
|
||||
right: parent.right
|
||||
}
|
||||
id: categoryButton
|
||||
text: i18n("Categories")
|
||||
onClicked: categoriesDialog.open(0, categoryButton.height)
|
||||
}
|
||||
Component.onCompleted: {
|
||||
main.categoryButton = categoryButton
|
||||
}
|
||||
}
|
||||
Row {
|
||||
anchors.right: parent.right
|
||||
spacing: 5
|
||||
}
|
||||
|
||||
MouseEventListener {
|
||||
id: listParent
|
||||
anchors {
|
||||
top: topBar.bottom
|
||||
left: parent.left
|
||||
right: widgetExplorer.orientation == Qt.Horizontal
|
||||
? parent.right
|
||||
: (scrollBar.visible ? scrollBar.left : parent.right)
|
||||
bottom: widgetExplorer.orientation == Qt.Horizontal ? scrollBar.top : bottomBar.top
|
||||
leftMargin: 4
|
||||
bottomMargin: 4
|
||||
}
|
||||
onWheelMoved: {
|
||||
//use this only if the wheel orientation is vertical and the list orientation is horizontal, otherwise will be the list itself managing the wheel
|
||||
if (wheel.orientation == Qt.Vertical && list.orientation == ListView.Horizontal) {
|
||||
var delta = wheel.delta > 0 ? 20 : -20
|
||||
list.contentX = Math.min(Math.max(0, list.contentWidth - list.width),
|
||||
Math.max(0, list.contentX - delta))
|
||||
}
|
||||
}
|
||||
ListView {
|
||||
id: list
|
||||
|
||||
property int delegateWidth: (widgetExplorer.orientation == Qt.Horizontal) ? (list.width / Math.floor(list.width / cellWidth)) : list.width
|
||||
property int delegateHeight: theme.defaultFont.pixelSize * 7 - 4
|
||||
|
||||
anchors.fill: parent
|
||||
|
||||
orientation: widgetExplorer.orientation == Qt.Horizontal ? ListView.Horizontal : ListView.Vertical
|
||||
snapMode: ListView.SnapToItem
|
||||
model: widgetExplorer.widgetsModel
|
||||
|
||||
clip: widgetExplorer.orientation == Qt.Vertical
|
||||
|
||||
delegate: AppletDelegate {}
|
||||
}
|
||||
|
||||
}
|
||||
PlasmaComponents.ScrollBar {
|
||||
id: scrollBar
|
||||
orientation: widgetExplorer.orientation == Qt.Horizontal ? ListView.Horizontal : ListView.Vertical
|
||||
anchors {
|
||||
top: widgetExplorer.orientation == Qt.Horizontal ? undefined : listParent.top
|
||||
bottom: widgetExplorer.orientation == Qt.Horizontal ? parent.bottom : bottomBar.top
|
||||
left: widgetExplorer.orientation == Qt.Horizontal ? parent.left : undefined
|
||||
right: parent.right
|
||||
}
|
||||
flickableItem: list
|
||||
}
|
||||
|
||||
Loader {
|
||||
id: bottomBar
|
||||
|
||||
sourceComponent: (widgetExplorer.orientation == Qt.Horizontal) ? undefined : verticalBottomBarComponent
|
||||
//height: item.height
|
||||
height: 48 // FIXME
|
||||
anchors {
|
||||
left: parent.left
|
||||
right: parent.right
|
||||
bottom: parent.bottom
|
||||
leftMargin: 4
|
||||
}
|
||||
}
|
||||
|
||||
Component {
|
||||
id: verticalBottomBarComponent
|
||||
Column {
|
||||
anchors {
|
||||
left: parent.left
|
||||
right: parent.right
|
||||
bottom: parent.bottom
|
||||
}
|
||||
|
||||
spacing: 4
|
||||
|
||||
PlasmaComponents.Button {
|
||||
anchors {
|
||||
left: parent.left
|
||||
right: parent.right
|
||||
}
|
||||
id: getWidgetsButton
|
||||
iconSource: "get-hot-new-stuff"
|
||||
text: i18n("Get new widgets")
|
||||
@ -205,6 +357,10 @@ Item {
|
||||
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: {
|
||||
@ -212,165 +368,11 @@ Item {
|
||||
}
|
||||
}
|
||||
}
|
||||
PlasmaComponents.ToolButton {
|
||||
iconSource: "window-close"
|
||||
onClicked: widgetExplorer.closeClicked()
|
||||
|
||||
Component.onCompleted: {
|
||||
main.getWidgetsButton = getWidgetsButton
|
||||
}
|
||||
}
|
||||
Component.onCompleted: {
|
||||
main.getWidgetsButton = getWidgetsButton
|
||||
main.categoryButton = categoryButton
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Component {
|
||||
id: verticalTopBarComponent
|
||||
|
||||
Column {
|
||||
anchors.top: parent.top
|
||||
anchors.left:parent.left
|
||||
anchors.right: parent.right
|
||||
spacing: 4
|
||||
|
||||
PlasmaComponents.ToolButton {
|
||||
anchors.right: parent.right
|
||||
iconSource: "window-close"
|
||||
onClicked: widgetExplorer.closeClicked()
|
||||
}
|
||||
PlasmaComponents.TextField {
|
||||
anchors {
|
||||
left: parent.left
|
||||
right: parent.right
|
||||
}
|
||||
clearButtonShown: true
|
||||
placeholderText: i18n("Enter search term...")
|
||||
onTextChanged: {
|
||||
list.contentX = 0
|
||||
list.contentY = 0
|
||||
widgetExplorer.widgetsModel.searchTerm = text
|
||||
}
|
||||
Component.onCompleted: forceActiveFocus()
|
||||
}
|
||||
PlasmaComponents.Button {
|
||||
anchors {
|
||||
left: parent.left
|
||||
right: parent.right
|
||||
}
|
||||
id: categoryButton
|
||||
text: i18n("Categories")
|
||||
onClicked: categoriesDialog.open(0, categoryButton.height)
|
||||
}
|
||||
Component.onCompleted: {
|
||||
main.categoryButton = categoryButton
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MouseEventListener {
|
||||
id: listParent
|
||||
anchors {
|
||||
top: topBar.bottom
|
||||
left: parent.left
|
||||
right: widgetExplorer.orientation == Qt.Horizontal
|
||||
? parent.right
|
||||
: (scrollBar.visible ? scrollBar.left : parent.right)
|
||||
bottom: widgetExplorer.orientation == Qt.Horizontal ? scrollBar.top : bottomBar.top
|
||||
leftMargin: 4
|
||||
bottomMargin: 4
|
||||
}
|
||||
onWheelMoved: {
|
||||
//use this only if the wheel orientation is vertical and the list orientation is horizontal, otherwise will be the list itself managing the wheel
|
||||
if (wheel.orientation == Qt.Vertical && list.orientation == ListView.Horizontal) {
|
||||
var delta = wheel.delta > 0 ? 20 : -20
|
||||
list.contentX = Math.min(Math.max(0, list.contentWidth - list.width),
|
||||
Math.max(0, list.contentX - delta))
|
||||
}
|
||||
}
|
||||
ListView {
|
||||
id: list
|
||||
|
||||
property int delegateWidth: (widgetExplorer.orientation == Qt.Horizontal) ? (list.width / Math.floor(list.width / cellWidth)) : list.width
|
||||
property int delegateHeight: theme.defaultFont.pixelSize * 7 - 4
|
||||
|
||||
anchors.fill: parent
|
||||
|
||||
orientation: widgetExplorer.orientation == Qt.Horizontal ? ListView.Horizontal : ListView.Vertical
|
||||
snapMode: ListView.SnapToItem
|
||||
model: widgetExplorer.widgetsModel
|
||||
|
||||
clip: widgetExplorer.orientation == Qt.Vertical
|
||||
|
||||
delegate: AppletDelegate {}
|
||||
}
|
||||
|
||||
}
|
||||
PlasmaComponents.ScrollBar {
|
||||
id: scrollBar
|
||||
orientation: widgetExplorer.orientation == Qt.Horizontal ? ListView.Horizontal : ListView.Vertical
|
||||
anchors {
|
||||
top: widgetExplorer.orientation == Qt.Horizontal ? undefined : listParent.top
|
||||
bottom: widgetExplorer.orientation == Qt.Horizontal ? parent.bottom : bottomBar.top
|
||||
left: widgetExplorer.orientation == Qt.Horizontal ? parent.left : undefined
|
||||
right: parent.right
|
||||
}
|
||||
flickableItem: list
|
||||
}
|
||||
|
||||
Loader {
|
||||
id: bottomBar
|
||||
|
||||
sourceComponent: (widgetExplorer.orientation == Qt.Horizontal) ? undefined : verticalBottomBarComponent
|
||||
//height: item.height
|
||||
height: 48 // FIXME
|
||||
anchors {
|
||||
left: parent.left
|
||||
right: parent.right
|
||||
bottom: parent.bottom
|
||||
leftMargin: 4
|
||||
}
|
||||
}
|
||||
|
||||
Component {
|
||||
id: verticalBottomBarComponent
|
||||
Column {
|
||||
anchors {
|
||||
left: parent.left
|
||||
right: parent.right
|
||||
bottom: parent.bottom
|
||||
}
|
||||
|
||||
spacing: 4
|
||||
|
||||
PlasmaComponents.Button {
|
||||
anchors {
|
||||
left: parent.left
|
||||
right: parent.right
|
||||
}
|
||||
id: getWidgetsButton
|
||||
iconSource: "get-hot-new-stuff"
|
||||
text: i18n("Get new widgets")
|
||||
onClicked: getWidgetsDialog.open()
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,6 @@
|
||||
*/
|
||||
|
||||
import QtQuick 2.0
|
||||
//import org.kde.plasma 2.0
|
||||
|
||||
import org.kde.plasma.core 2.0 as PlasmaCore
|
||||
|
||||
|
@ -35,14 +35,14 @@
|
||||
#include "desktopview.h"
|
||||
#include "panelview.h"
|
||||
#include "scripting/desktopscriptengine.h"
|
||||
#include "widgetexplorer/widgetexplorerview.h"
|
||||
#include "widgetexplorer/widgetexplorer.h"
|
||||
#include "configview.h"
|
||||
|
||||
class ShellCorona::Private {
|
||||
public:
|
||||
Private()
|
||||
: desktopWidget(QApplication::desktop()),
|
||||
widgetExplorerView(nullptr)
|
||||
widgetExplorer(nullptr)
|
||||
{
|
||||
appConfigSyncTimer.setSingleShot(true);
|
||||
// constant controlling how long between requesting a configuration sync
|
||||
@ -53,7 +53,7 @@ public:
|
||||
QString shell;
|
||||
QDesktopWidget * desktopWidget;
|
||||
QList <DesktopView *> views;
|
||||
WidgetExplorerView * widgetExplorerView;
|
||||
QPointer<WidgetExplorer> widgetExplorer;
|
||||
QHash <Plasma::Containment *, PanelView *> panelViews;
|
||||
KConfigGroup desktopDefaultsConfig;
|
||||
WorkspaceScripting::DesktopScriptEngine * scriptEngine;
|
||||
@ -404,23 +404,22 @@ void ShellCorona::handleContainmentAdded(Plasma::Containment* c)
|
||||
|
||||
void ShellCorona::showWidgetExplorer()
|
||||
{
|
||||
if (!d->widgetExplorerView) {
|
||||
if (!d->widgetExplorer) {
|
||||
|
||||
QString expqml = package().filePath("widgetexplorer");
|
||||
qDebug() << "Script to load for WidgetExplorer: " << expqml;
|
||||
d->widgetExplorerView = new WidgetExplorerView(expqml);
|
||||
d->widgetExplorerView->init();
|
||||
d->widgetExplorer = new WidgetExplorer();
|
||||
d->widgetExplorer.data()->setSource(QUrl::fromLocalFile(expqml));
|
||||
}
|
||||
Plasma::Containment *c = 0;
|
||||
c = dynamic_cast<Plasma::Containment*>(sender());
|
||||
if (c) {
|
||||
qDebug() << "Found containment.";
|
||||
d->widgetExplorerView->setContainment(c);
|
||||
d->widgetExplorer.data()->setContainment(c);
|
||||
} else {
|
||||
// FIXME: try harder to find a suitable containment?
|
||||
qWarning() << "containment not set, don't know where to add the applet.";
|
||||
}
|
||||
d->widgetExplorerView->show();
|
||||
}
|
||||
|
||||
void ShellCorona::syncAppConfig()
|
||||
|
@ -21,8 +21,12 @@
|
||||
|
||||
#include "widgetexplorer.h"
|
||||
|
||||
#include <QQmlEngine>
|
||||
#include <QQmlContext>
|
||||
|
||||
#include <klocalizedstring.h>
|
||||
#include <kservicetypetrader.h>
|
||||
#include <kdeclarative/qmlobject.h>
|
||||
|
||||
#include <Plasma/Applet>
|
||||
#include <Plasma/Corona>
|
||||
@ -56,7 +60,8 @@ public:
|
||||
: q(w),
|
||||
containment(0),
|
||||
itemModel(w),
|
||||
filterModel(w)
|
||||
filterModel(w),
|
||||
qmlObject(new QmlObject(w))
|
||||
{
|
||||
}
|
||||
|
||||
@ -94,9 +99,7 @@ public:
|
||||
KCategorizedItemsViewModels::DefaultFilterModel filterModel;
|
||||
DefaultItemFilterProxyModel filterItemModel;
|
||||
|
||||
// Plasma::DeclarativeWidget *declarativeWidget;
|
||||
|
||||
// QGraphicsLinearLayout *mainLayout;
|
||||
QmlObject *qmlObject;
|
||||
};
|
||||
|
||||
void WidgetExplorerPrivate::initFilters()
|
||||
@ -374,6 +377,7 @@ WidgetExplorer::WidgetExplorer(Plasma::Types::Location loc, QObject *parent)
|
||||
d(new WidgetExplorerPrivate(this))
|
||||
{
|
||||
d->init(loc);
|
||||
populateWidgetList();
|
||||
}
|
||||
|
||||
WidgetExplorer::WidgetExplorer(QObject *parent)
|
||||
@ -381,6 +385,7 @@ WidgetExplorer::WidgetExplorer(QObject *parent)
|
||||
d(new WidgetExplorerPrivate(this))
|
||||
{
|
||||
d->init(Plasma::Types::LeftEdge);
|
||||
populateWidgetList();
|
||||
}
|
||||
|
||||
WidgetExplorer::~WidgetExplorer()
|
||||
@ -419,6 +424,19 @@ QString WidgetExplorer::application()
|
||||
return d->application;
|
||||
}
|
||||
|
||||
void WidgetExplorer::setSource(const QUrl &source)
|
||||
{
|
||||
d->qmlObject->setInitializationDelayed(true);
|
||||
d->qmlObject->setSource(source);
|
||||
d->qmlObject->engine()->rootContext()->setContextProperty("widgetExplorer", this);
|
||||
d->qmlObject->completeInitialization();
|
||||
}
|
||||
|
||||
QUrl WidgetExplorer::source() const
|
||||
{
|
||||
return d->qmlObject->source();
|
||||
}
|
||||
|
||||
void WidgetExplorer::setContainment(Plasma::Containment *containment)
|
||||
{
|
||||
if (d->containment != containment) {
|
||||
@ -481,7 +499,7 @@ void WidgetExplorer::addApplet(const QString &pluginName)
|
||||
void WidgetExplorer::immutabilityChanged(Plasma::Types::ImmutabilityType type)
|
||||
{
|
||||
if (type != Plasma::Types::Mutable) {
|
||||
emit closeClicked();
|
||||
close();
|
||||
}
|
||||
}
|
||||
|
||||
@ -600,6 +618,12 @@ void WidgetExplorer::uninstall(const QString &pluginName)
|
||||
}
|
||||
}
|
||||
|
||||
void WidgetExplorer::close()
|
||||
{
|
||||
//d->qmlObject->engine()->rootContext()->setContextProperty("widgetExplorer", 0);
|
||||
deleteLater();
|
||||
}
|
||||
|
||||
/*
|
||||
QPoint WidgetExplorer::tooltipPosition(QGraphicsObject *item, int tipWidth, int tipHeight)
|
||||
{
|
||||
|
@ -108,6 +108,18 @@ public:
|
||||
|
||||
QString application();
|
||||
|
||||
/**
|
||||
* Sets the path of the QML file to parse and execute
|
||||
*
|
||||
* @param path the absolute path of a QML file
|
||||
*/
|
||||
void setSource(const QUrl &source);
|
||||
|
||||
/**
|
||||
* @return the absolute path of the current QML file
|
||||
*/
|
||||
QUrl source() const;
|
||||
|
||||
/**
|
||||
* Populates the widget list for the given application. This must be called
|
||||
* before the widget explorer will be usable as the widget list will remain
|
||||
@ -149,6 +161,7 @@ public:
|
||||
|
||||
Q_INVOKABLE void uninstall(const QString &pluginName);
|
||||
|
||||
Q_INVOKABLE void close();
|
||||
//Q_INVOKABLE QPoint tooltipPosition(QGraphicsObject *item, int tipWidth, int tipHeight);
|
||||
|
||||
Q_SIGNALS:
|
||||
|
@ -1,96 +0,0 @@
|
||||
/*
|
||||
* Copyright 2013 Sebastian Kügler <sebas@kde.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "widgetexplorerview.h"
|
||||
|
||||
#include <QQmlContext>
|
||||
#include <QQmlError>
|
||||
#include <QQuickItem>
|
||||
|
||||
#include <klocalizedstring.h>
|
||||
#include <kwindowsystem.h>
|
||||
#include <kwindoweffects.h>
|
||||
|
||||
#include <Plasma/Containment>
|
||||
|
||||
WidgetExplorerView::WidgetExplorerView(const QString &qmlPath, QWindow *parent)
|
||||
: QQuickView(parent),
|
||||
m_containment(0),
|
||||
m_widgetExplorer(0),
|
||||
m_qmlPath(qmlPath)
|
||||
{
|
||||
QSurfaceFormat format;
|
||||
format.setAlphaBufferSize(8);
|
||||
setFormat(format);
|
||||
setClearBeforeRendering(true);
|
||||
setColor(QColor(Qt::transparent));
|
||||
setFlags(Qt::FramelessWindowHint);
|
||||
//KWindowSystem::setType(winId(), NET::Dock);
|
||||
|
||||
//TODO: how to take the shape from the framesvg?
|
||||
KWindowEffects::enableBlurBehind(winId(), true);
|
||||
|
||||
// connect(this, &View::locationChanged,
|
||||
// this, &WidgetExplorerView::positionPanel);
|
||||
}
|
||||
|
||||
WidgetExplorerView::~WidgetExplorerView()
|
||||
{
|
||||
}
|
||||
|
||||
void WidgetExplorerView::init()
|
||||
{
|
||||
qDebug() << "Loading WidgetExplorer: " << m_qmlPath;
|
||||
|
||||
m_widgetExplorer = new WidgetExplorer(this);
|
||||
m_widgetExplorer->populateWidgetList();
|
||||
m_widgetExplorer->setContainment(m_containment);
|
||||
|
||||
rootContext()->setContextProperty("widgetExplorer", m_widgetExplorer);
|
||||
setTitle(i18n("Add Widgets"));
|
||||
setColor(Qt::transparent);
|
||||
setResizeMode(QQuickView::SizeRootObjectToView);
|
||||
setSource(QUrl::fromLocalFile(m_qmlPath));
|
||||
|
||||
connect(m_widgetExplorer, &WidgetExplorer::closeClicked, this, &QQuickView::close);
|
||||
connect(this, &QQuickView::statusChanged, this, &WidgetExplorerView::widgetExplorerStatusChanged);
|
||||
connect(this, &QQuickView::visibleChanged, this, &WidgetExplorerView::widgetExplorerClosed);
|
||||
}
|
||||
|
||||
|
||||
void WidgetExplorerView::setContainment(Plasma::Containment* c)
|
||||
{
|
||||
m_containment = c;
|
||||
m_widgetExplorer->setContainment(c);
|
||||
}
|
||||
|
||||
|
||||
void WidgetExplorerView::widgetExplorerClosed(bool visible)
|
||||
{
|
||||
if (!visible) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void WidgetExplorerView::widgetExplorerStatusChanged()
|
||||
{
|
||||
foreach (QQmlError e, errors()) {
|
||||
qWarning() << "Error in WidgetExplorer: " << e.toString();
|
||||
}
|
||||
}
|
||||
|
@ -1,51 +0,0 @@
|
||||
/*
|
||||
* Copyright 2013 Sebastian Kügler <sebas@kde.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef WIDGETEXPLORERVIEW_H
|
||||
#define WIDGETEXPLORERVIEW_H
|
||||
|
||||
#include <QQuickView>
|
||||
#include "widgetexplorer.h"
|
||||
|
||||
namespace Plasma {
|
||||
class Containment;
|
||||
}
|
||||
|
||||
|
||||
class WidgetExplorerView : public QQuickView
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit WidgetExplorerView(const QString &qmlPath, QWindow *parent = 0);
|
||||
virtual ~WidgetExplorerView();
|
||||
|
||||
virtual void init();
|
||||
void setContainment(Plasma::Containment* c);
|
||||
|
||||
private Q_SLOTS:
|
||||
void widgetExplorerClosed(bool visible);
|
||||
void widgetExplorerStatusChanged();
|
||||
|
||||
private:
|
||||
Plasma::Containment* m_containment;
|
||||
WidgetExplorer* m_widgetExplorer;
|
||||
QString m_qmlPath;
|
||||
};
|
||||
|
||||
#endif // WIDGETEXPLORERVIEW_H
|
Loading…
Reference in New Issue
Block a user