Widgetexplorer - wiring up
- add explorer subdirectory to shellpackge, add widgetexplorer filedefinition - hook up containment added with a connection to showing the widget explorer - memory management for widget explorer: create on demand, delete after close: Maybe we want to cache it? For now, go for reduced memory consumption rather than quick opening, and see how slow this might react. - add QQuickView for widget explorer in desktopcorona With this patch, I can open a widget explorer window from the QML containment. Of course, the widget explorer is just a pink window right now.
This commit is contained in:
parent
bbb1f590b3
commit
94d14ac5da
@ -22,6 +22,8 @@
|
||||
#include <QApplication>
|
||||
#include <QDebug>
|
||||
#include <QDesktopWidget>
|
||||
#include <QQuickView>
|
||||
|
||||
#include <Plasma/Package>
|
||||
|
||||
#include "panelview.h"
|
||||
@ -33,7 +35,8 @@ static const QString s_panelTemplatesPath("plasma-layout-templates/panels/*");
|
||||
|
||||
DesktopCorona::DesktopCorona(QObject *parent)
|
||||
: Plasma::Corona(parent),
|
||||
m_desktopWidget(QApplication::desktop())
|
||||
m_desktopWidget(QApplication::desktop()),
|
||||
m_widgetExplorer(0)
|
||||
{
|
||||
m_desktopDefaultsConfig = KConfigGroup(KSharedConfig::openConfig(package().filePath("defaults")), "Desktop");
|
||||
|
||||
@ -43,6 +46,7 @@ DesktopCorona::DesktopCorona(QObject *parent)
|
||||
this, SLOT(screenCountChanged(int)));
|
||||
connect(m_desktopWidget, SIGNAL(workAreaResized(int)),
|
||||
this, SLOT(workAreaResized(int)));
|
||||
connect(this, &DesktopCorona::containmentAdded, this, &DesktopCorona::handleContainmentAdded);
|
||||
|
||||
connect(this, SIGNAL(screenOwnerChanged(int, int, Plasma::Containment *)),
|
||||
this, SLOT(updateScreenOwner(int, int, Plasma::Containment *)));
|
||||
@ -256,6 +260,39 @@ void DesktopCorona::updateScreenOwner(int wasScreen, int isScreen, Plasma::Conta
|
||||
}
|
||||
}
|
||||
|
||||
void DesktopCorona::handleContainmentAdded(Plasma::Containment* c)
|
||||
{
|
||||
connect(c, &Plasma::Containment::showAddWidgetsInterface, this, &DesktopCorona::showWidgetExplorer);
|
||||
}
|
||||
|
||||
void DesktopCorona::showWidgetExplorer()
|
||||
{
|
||||
if (!m_widgetExplorer) {
|
||||
m_widgetExplorer = new QQuickView;
|
||||
QString expqml = package().filePath("widgetexplorer");
|
||||
qDebug() << "Script to load for WidgetExplorer: " << expqml;
|
||||
m_widgetExplorer->setSource(QUrl::fromLocalFile(expqml));
|
||||
connect(m_widgetExplorer, &QQuickView::statusChanged, this, &DesktopCorona::widgetExplorerStatusChanged);
|
||||
connect(m_widgetExplorer, &QQuickView::visibleChanged, this, &DesktopCorona::widgetExplorerClosed);
|
||||
}
|
||||
m_widgetExplorer->show();
|
||||
}
|
||||
|
||||
void DesktopCorona::widgetExplorerClosed(bool visible)
|
||||
{
|
||||
if (!visible) {
|
||||
m_widgetExplorer->deleteLater();
|
||||
m_widgetExplorer = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void DesktopCorona::widgetExplorerStatusChanged()
|
||||
{
|
||||
foreach (QQmlError e, m_widgetExplorer->errors()) {
|
||||
qWarning() << "Error in WidgetExplorer: " << e.toString();
|
||||
}
|
||||
}
|
||||
|
||||
void DesktopCorona::printScriptError(const QString &error)
|
||||
{
|
||||
qWarning() << error;
|
||||
|
@ -24,6 +24,7 @@ class * Free Software Foundation, Inc.,
|
||||
#include "plasma/corona.h"
|
||||
|
||||
class QDesktopWidget;
|
||||
class QQuickView;
|
||||
class PanelView;
|
||||
class View;
|
||||
|
||||
@ -81,9 +82,16 @@ protected Q_SLOTS:
|
||||
void printScriptError(const QString &error);
|
||||
void printScriptMessage(const QString &message);
|
||||
|
||||
private Q_SLOTS:
|
||||
void handleContainmentAdded(Plasma::Containment *c);
|
||||
void showWidgetExplorer();
|
||||
void widgetExplorerClosed(bool visible);
|
||||
void widgetExplorerStatusChanged();
|
||||
|
||||
private:
|
||||
QDesktopWidget *m_desktopWidget;
|
||||
QList <View *> m_views;
|
||||
QQuickView *m_widgetExplorer;
|
||||
QHash<Plasma::Containment *, PanelView *> m_panelViews;
|
||||
KConfigGroup m_desktopDefaultsConfig;
|
||||
};
|
||||
|
@ -31,6 +31,7 @@ void ShellPackageStructure::initPackage(Plasma::Package *package)
|
||||
//Directories
|
||||
package->addDirectoryDefinition("components", "components", i18n("UI components"));
|
||||
package->addDirectoryDefinition("views", "views", i18n("User interface for the views that will show containments"));
|
||||
package->addDirectoryDefinition("explorer", "explorer", i18n("Explorer UI for adding widgets"));
|
||||
|
||||
package->setMimeTypes("components", QStringList() << "text/x-qml");
|
||||
package->setMimeTypes("views", QStringList() << "text/x-qml");
|
||||
@ -46,7 +47,7 @@ void ShellPackageStructure::initPackage(Plasma::Package *package)
|
||||
package->addFileDefinition("compactapplet", "components/CompactApplet.qml", i18n("QML component that shows an applet in a popup"));
|
||||
package->addFileDefinition("configurationui", "components/Configuration.qml", i18n("QML component for the configuratuion dialog"));
|
||||
package->addFileDefinition("defaultcompactrepresentation", "components/DefaultCompactRepresentation.qml", i18n("Compact representation of an applet when collapsed in a popup, for instance as an icon. applets can override this component."));
|
||||
package->addFileDefinition("widgetexplorer", "components/WidgetExplorer.qml", i18n("Widgets explorer UI"));
|
||||
package->addFileDefinition("widgetexplorer", "explorer/WidgetExplorer.qml", i18n("Widgets explorer UI"));
|
||||
package->addFileDefinition("panelconfigurationui", "components/PanelConfiguration.qml", i18n("Panel configuration UI"));
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user