make widgetexplorer show up

it lists widgets, allows to add them now.

Categories and download new widgets are disabled for now.

It seems PlasmaComponents.MenuItem is broken (it inherits its API from QAction,
but in QtQuick, it has to be a QQuickItem to be accepted as Delegate.
This might need glue-api. :/)
This commit is contained in:
Sebastian Kügler 2013-03-26 01:55:17 +01:00
parent 9684d17e9a
commit 243e8d23e3
4 changed files with 50 additions and 31 deletions

View File

@ -33,10 +33,17 @@ PlasmaCore.FrameSvgItem {
property string description: model.description property string description: model.description
property string author: model.author property string author: model.author
property string email: model.email property string email: model.email
property string license: model.license //property string license: model.license
property string license: "GPL" // FIXME
property string pluginName: model.pluginName property string pluginName: model.pluginName
property bool local: model.local property bool local: model.local
function i18n(inp) { // FIXME: HACK!
return inp;
}
ListView.onRemove: SequentialAnimation { ListView.onRemove: SequentialAnimation {
PropertyAction { PropertyAction {
target: background target: background

View File

@ -25,8 +25,10 @@ import org.kde.qtextracomponents 2.0
Item { Item {
id: main id: main
width: 400
height: 800
//this is used to perfectly align the filter field and delegates //this is used to perfectly align the filter field and delegates
property int cellWidth: theme.defaultFont.mSize.width * 20 property int cellWidth: theme.defaultFont.pixelSize * 20
property int minimumWidth: cellWidth + ( property int minimumWidth: cellWidth + (
widgetExplorer.orientation == Qt.Horizontal widgetExplorer.orientation == Qt.Horizontal
@ -38,6 +40,12 @@ Item {
property Item getWidgetsButton property Item getWidgetsButton
property Item categoryButton property Item categoryButton
function i18n(inp) { // FIXME: HACK!
return inp;
}
PlasmaComponents.ContextMenu { PlasmaComponents.ContextMenu {
id: categoriesDialog id: categoriesDialog
visualParent: main.categoryButton visualParent: main.categoryButton
@ -45,22 +53,22 @@ Item {
Repeater { Repeater {
parent: categoriesDialog parent: categoriesDialog
model: widgetExplorer.filterModel model: widgetExplorer.filterModel
delegate: PlasmaComponents.MenuItem { // delegate: PlasmaComponents.MenuItem {
text: display // text: display
separator: model["separator"] // separator: model["separator"]
onClicked: { // onClicked: {
list.contentX = 0 // list.contentX = 0
list.contentY = 0 // list.contentY = 0
var item = widgetExplorer.filterModel.get(index) // var item = widgetExplorer.filterModel.get(index)
//
widgetExplorer.widgetsModel.filterType = item.filterType // widgetExplorer.widgetsModel.filterType = item.filterType
widgetExplorer.widgetsModel.filterQuery = item.filterData // widgetExplorer.widgetsModel.filterQuery = item.filterData
main.categoryButton.text = item.display // main.categoryButton.text = item.display
} // }
Component.onCompleted: { // Component.onCompleted: {
parent = categoriesDialog // parent = categoriesDialog
} // }
} // }
} }
PlasmaComponents.ContextMenu { PlasmaComponents.ContextMenu {
@ -70,15 +78,15 @@ Item {
Repeater { Repeater {
parent: getWidgetsDialog parent: getWidgetsDialog
model: widgetExplorer.widgetsMenuActions model: widgetExplorer.widgetsMenuActions
delegate: PlasmaComponents.MenuItem { // delegate: PlasmaComponents.MenuItem {
icon: modelData.icon // icon: modelData.icon
text: modelData.text // text: modelData.text
separator: modelData.separator // separator: modelData.separator
onClicked: modelData.trigger() // onClicked: modelData.trigger()
Component.onCompleted: { // Component.onCompleted: {
parent = getWidgetsDialog // parent = getWidgetsDialog
} // }
} // }
} }
PlasmaCore.Dialog { PlasmaCore.Dialog {
@ -283,7 +291,7 @@ Item {
id: list id: list
property int delegateWidth: (widgetExplorer.orientation == Qt.Horizontal) ? (list.width / Math.floor(list.width / cellWidth)) : list.width property int delegateWidth: (widgetExplorer.orientation == Qt.Horizontal) ? (list.width / Math.floor(list.width / cellWidth)) : list.width
property int delegateHeight: theme.defaultFont.mSize.height * 7 - 4 property int delegateHeight: theme.defaultFont.pixelSize * 7 - 4
anchors.fill: parent anchors.fill: parent
@ -313,7 +321,8 @@ Item {
id: bottomBar id: bottomBar
sourceComponent: (widgetExplorer.orientation == Qt.Horizontal) ? undefined : verticalBottomBarComponent sourceComponent: (widgetExplorer.orientation == Qt.Horizontal) ? undefined : verticalBottomBarComponent
height: item.height //height: item.height
height: 48 // FIXME
anchors { anchors {
left: parent.left left: parent.left
right: parent.right right: parent.right

View File

@ -358,7 +358,7 @@ WidgetExplorer::WidgetExplorer(QObject *parent)
:QObject(parent), :QObject(parent),
d(new WidgetExplorerPrivate(this)) d(new WidgetExplorerPrivate(this))
{ {
d->init(Plasma::BottomEdge); d->init(Plasma::LeftEdge);
} }
WidgetExplorer::~WidgetExplorer() WidgetExplorer::~WidgetExplorer()

View File

@ -39,11 +39,14 @@ class WidgetExplorerPrivate;
class WidgetAction : public QAction class WidgetAction : public QAction
{ {
Q_OBJECT Q_OBJECT
Q_PROPERTY(bool separator READ isSeparator WRITE setSeparator) Q_PROPERTY(bool separator READ isSeparator WRITE setSeparator NOTIFY separatorChanged)
public: public:
WidgetAction(QObject *parent = 0); WidgetAction(QObject *parent = 0);
WidgetAction(const QIcon &icon, const QString &text, QObject *parent); WidgetAction(const QIcon &icon, const QString &text, QObject *parent);
Q_SIGNALS:
void separatorChanged();
}; };
class WidgetExplorer : public QObject class WidgetExplorer : public QObject