rework widget explorer models as component

This commit is contained in:
Marco Martin 2013-10-29 20:55:00 +01:00
parent 3b6c2c82e3
commit d0fd982933
5 changed files with 36 additions and 3 deletions

View File

@ -23,7 +23,7 @@ import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.extras 2.0 as PlasmaExtras
import org.kde.qtextracomponents 2.0
import QtQuick.Window 2.1
import org.kde.plasma.private.shell 2.0
Item {
id: main
@ -39,6 +39,11 @@ Item {
property Item getWidgetsButton
property Item categoryButton
WidgetExplorer {
id:widgetExplorer
desktopView: desktop
}
PlasmaComponents.ContextMenu {
id: categoriesDialog
visualParent: main.categoryButton

View File

@ -21,6 +21,8 @@ import QtQuick 2.0
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.components 2.0 as PlasmaComponents
import "../activitymanager"
import "../explorer"
Rectangle {
id: root
@ -39,7 +41,7 @@ Rectangle {
explorerObject.close();
sidePanelStack.state = "closed";
} else {
sidePanelStack.push(explorerObject);
sidePanelStack.push(Qt.resolvedUrl("../explorer/WidgetExplorer.qml"));
explorerObject.closed.connect(function(){sidePanelStack.state = "closed";});
sidePanelStack.state = "widgetExplorer";
}

View File

@ -92,6 +92,9 @@ ShellCorona::ShellCorona(QObject *parent)
{
d->desktopDefaultsConfig = KConfigGroup(KSharedConfig::openConfig(package().filePath("defaults")), "Desktop");
qmlRegisterType<WidgetExplorer>("org.kde.plasma.private.shell", 2, 0, "WidgetExplorer");
qmlRegisterType<DesktopView>();
connect(&d->appConfigSyncTimer, &QTimer::timeout,
this, &ShellCorona::syncAppConfig);

View File

@ -37,6 +37,7 @@
#include <Plasma/PackageStructure>
#include <qstandardpaths.h>
#include "desktopview.h"
#include "kcategorizeditemsviewmodels_p.h"
#include "plasmaappletitemmodel_p.h"
@ -63,7 +64,8 @@ public:
containment(0),
itemModel(w),
filterModel(w),
qmlObject(new QmlObject(w))
qmlObject(new QmlObject(w)),
desktopView(0)
{
}
@ -98,6 +100,7 @@ public:
PlasmaAppletItemModel itemModel;
KCategorizedItemsViewModels::DefaultFilterModel filterModel;
DefaultItemFilterProxyModel filterItemModel;
DesktopView *desktopView;
QmlObject *qmlObject;
};
@ -338,6 +341,20 @@ Qt::Orientation WidgetExplorer::orientation() const
return d->orientation;
}
DesktopView *WidgetExplorer::desktopView()
{
return d->desktopView;
}
void WidgetExplorer::setDesktopView(DesktopView *view)
{qWarning()<<"AAAAAAAAAAAAAAAAAAAAAAA"<<view;
d->desktopView = view;
if (view) {
setContainment(view->containment());
}
emit desktopViewChanged();
}
void WidgetExplorer::populateWidgetList(const QString &app)
{
d->application = app;

View File

@ -34,6 +34,7 @@ namespace Plasma {
class Applet;
}
class WidgetExplorerPrivate;
class DesktopView;
//We need to access the separator property that is not exported by QAction
class WidgetAction : public QAction
@ -85,6 +86,8 @@ class WidgetExplorer : public QQuickItem
*/
Q_PROPERTY(Qt::Orientation orientation READ orientation NOTIFY orientationChanged)
Q_PROPERTY(DesktopView *desktopView READ desktopView WRITE setDesktopView NOTIFY desktopViewChanged)
public:
explicit WidgetExplorer(QQuickItem *parent = 0);
~WidgetExplorer();
@ -134,6 +137,8 @@ public:
Qt::Orientation orientation() const;
DesktopView *desktopView();
void setDesktopView(DesktopView *view);
QObject *widgetsModel() const;
QObject *filterModel() const;
@ -155,6 +160,7 @@ Q_SIGNALS:
void widgetsMenuActionsChanged();
void extraActionsChanged();
void closed();
void desktopViewChanged();
public Q_SLOTS:
/**