Merge branch 'master' into plasma/declarative
Conflicts: plasma/declarativeimports/core/CMakeLists.txt plasma/declarativeimports/core/corebindingsplugin.cpp plasma/declarativeimports/plasmacomponents/BusyIndicator.qml plasma/declarativeimports/plasmacomponents/ScrollBar.qml plasma/declarativeimports/plasmacomponents/qmldir
This commit is contained in:
commit
e5b43a7357
@ -1,4 +1,5 @@
|
|||||||
add_subdirectory(core)
|
add_subdirectory(core)
|
||||||
|
add_subdirectory(draganddrop)
|
||||||
add_subdirectory(graphicslayouts)
|
add_subdirectory(graphicslayouts)
|
||||||
add_subdirectory(graphicswidgets)
|
add_subdirectory(graphicswidgets)
|
||||||
add_subdirectory(qtextracomponents)
|
add_subdirectory(qtextracomponents)
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
project(corebindings)
|
project(corebindings)
|
||||||
|
|
||||||
set(corebindings_SRCS
|
set(corebindings_SRCS
|
||||||
|
declarativeitemcontainer.cpp
|
||||||
corebindingsplugin.cpp
|
corebindingsplugin.cpp
|
||||||
dataengineconsumer.cpp
|
dataengineconsumer.cpp
|
||||||
theme.cpp
|
theme.cpp
|
||||||
@ -10,6 +11,7 @@ set(corebindings_SRCS
|
|||||||
framesvgitem.cpp
|
framesvgitem.cpp
|
||||||
dialog.cpp
|
dialog.cpp
|
||||||
qrangemodel.cpp
|
qrangemodel.cpp
|
||||||
|
tooltip.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
INCLUDE_DIRECTORIES(
|
INCLUDE_DIRECTORIES(
|
||||||
|
@ -33,6 +33,7 @@
|
|||||||
#include "theme_p.h"
|
#include "theme_p.h"
|
||||||
#include "dialog.h"
|
#include "dialog.h"
|
||||||
#include "qrangemodel.h"
|
#include "qrangemodel.h"
|
||||||
|
#include "tooltip.h"
|
||||||
|
|
||||||
void CoreBindingsPlugin::registerTypes(const char *uri)
|
void CoreBindingsPlugin::registerTypes(const char *uri)
|
||||||
{
|
{
|
||||||
@ -51,9 +52,12 @@ void CoreBindingsPlugin::registerTypes(const char *uri)
|
|||||||
|
|
||||||
qmlRegisterType<DialogProxy>(uri, 0, 1, "Dialog");
|
qmlRegisterType<DialogProxy>(uri, 0, 1, "Dialog");
|
||||||
qmlRegisterType<Plasma::QRangeModel>(uri, 0, 1, "RangeModel");
|
qmlRegisterType<Plasma::QRangeModel>(uri, 0, 1, "RangeModel");
|
||||||
|
qmlRegisterType<ToolTipProxy>(uri, 0, 1, "ToolTip");
|
||||||
|
|
||||||
qmlRegisterInterface<Plasma::Service>("Service");
|
qmlRegisterInterface<Plasma::Service>("Service");
|
||||||
qRegisterMetaType<Plasma::Service*>("Service");
|
qRegisterMetaType<Plasma::Service*>("Service");
|
||||||
|
qmlRegisterInterface<Plasma::ServiceJob>("ServiceJob");
|
||||||
|
qRegisterMetaType<Plasma::ServiceJob*>("ServiceJob");
|
||||||
|
|
||||||
/*qmlRegisterInterface<Plasma::DataSource>("DataSource");
|
/*qmlRegisterInterface<Plasma::DataSource>("DataSource");
|
||||||
qRegisterMetaType<Plasma::DataSource*>("DataSource");*/
|
qRegisterMetaType<Plasma::DataSource*>("DataSource");*/
|
||||||
|
@ -26,8 +26,6 @@
|
|||||||
|
|
||||||
#include <Plasma/Service>
|
#include <Plasma/Service>
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(Plasma::Service*)
|
|
||||||
|
|
||||||
class CoreBindingsPlugin : public QDeclarativeExtensionPlugin
|
class CoreBindingsPlugin : public QDeclarativeExtensionPlugin
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -106,6 +106,8 @@ DataEngine *DataEngineConsumer::dataEngine(const QString &name)
|
|||||||
|
|
||||||
DataEngine *DataEngineConsumer::remoteDataEngine(const KUrl &location, const QString &name)
|
DataEngine *DataEngineConsumer::remoteDataEngine(const KUrl &location, const QString &name)
|
||||||
{
|
{
|
||||||
|
Q_UNUSED(location);
|
||||||
|
Q_UNUSED(name);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,10 +83,11 @@ void SortFilterModel::setModel(QObject *source)
|
|||||||
void SortFilterModel::setFilterRegExp(const QString &exp)
|
void SortFilterModel::setFilterRegExp(const QString &exp)
|
||||||
{
|
{
|
||||||
//FIXME: this delaying of the reset signal seems to make the views behave a bit better, i.e. less holes and avoids some crashes, in theory shouldn't be necessary
|
//FIXME: this delaying of the reset signal seems to make the views behave a bit better, i.e. less holes and avoids some crashes, in theory shouldn't be necessary
|
||||||
|
beginResetModel();
|
||||||
blockSignals(true);
|
blockSignals(true);
|
||||||
QSortFilterProxyModel::setFilterRegExp(QRegExp(exp, Qt::CaseInsensitive));
|
QSortFilterProxyModel::setFilterRegExp(QRegExp(exp, Qt::CaseInsensitive));
|
||||||
blockSignals(false);
|
blockSignals(false);
|
||||||
reset();
|
endResetModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString SortFilterModel::filterRegExp() const
|
QString SortFilterModel::filterRegExp() const
|
||||||
@ -190,6 +191,7 @@ void DataModel::dataUpdated(const QString &sourceName, const Plasma::DataEngine:
|
|||||||
(m_sourceFilter.isEmpty() || (sourceRegExp.isValid() && sourceRegExp.exactMatch(i.key())))) {
|
(m_sourceFilter.isEmpty() || (sourceRegExp.isValid() && sourceRegExp.exactMatch(i.key())))) {
|
||||||
Plasma::DataEngine::Data data = value.value<Plasma::DataEngine::Data>();
|
Plasma::DataEngine::Data data = value.value<Plasma::DataEngine::Data>();
|
||||||
data["DataEngineSource"] = i.key();
|
data["DataEngineSource"] = i.key();
|
||||||
|
|
||||||
list.append(data);
|
list.append(data);
|
||||||
}
|
}
|
||||||
++i;
|
++i;
|
||||||
@ -253,26 +255,30 @@ QString DataModel::keyRoleFilter() const
|
|||||||
|
|
||||||
void DataModel::setItems(const QString &sourceName, const QVariantList &list)
|
void DataModel::setItems(const QString &sourceName, const QVariantList &list)
|
||||||
{
|
{
|
||||||
emit modelAboutToBeReset();
|
beginResetModel();
|
||||||
|
|
||||||
//convert to vector, so data() will be O(1)
|
//convert to vector, so data() will be O(1)
|
||||||
m_items[sourceName] = list.toVector();
|
m_items[sourceName] = list.toVector();
|
||||||
|
|
||||||
if (!list.isEmpty()) {
|
if (!list.isEmpty()) {
|
||||||
if (list.first().canConvert<QVariantHash>()) {
|
if (list.first().canConvert<QVariantHash>()) {
|
||||||
foreach (const QString& roleName, list.first().value<QVariantHash>().keys()) {
|
foreach (const QVariant &item, list) {
|
||||||
if (!m_roleIds.contains(roleName)) {
|
foreach (const QString& roleName, item.value<QVariantHash>().keys()) {
|
||||||
++m_maxRoleId;
|
if (!m_roleIds.contains(roleName)) {
|
||||||
m_roleNames[m_maxRoleId] = roleName.toLatin1();
|
++m_maxRoleId;
|
||||||
m_roleIds[roleName] = m_maxRoleId;
|
m_roleNames[m_maxRoleId] = roleName.toLatin1();
|
||||||
|
m_roleIds[roleName] = m_maxRoleId;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
foreach (const QString& roleName, list.first().value<QVariantMap>().keys()) {
|
foreach (const QVariant &item, list) {
|
||||||
if (!m_roleIds.contains(roleName)) {
|
foreach (const QString& roleName, item.value<QVariantMap>().keys()) {
|
||||||
++m_maxRoleId;
|
if (!m_roleIds.contains(roleName)) {
|
||||||
m_roleNames[m_maxRoleId] = roleName.toLatin1();
|
++m_maxRoleId;
|
||||||
m_roleIds[roleName] = m_maxRoleId;
|
m_roleNames[m_maxRoleId] = roleName.toLatin1();
|
||||||
|
m_roleIds[roleName] = m_maxRoleId;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -284,16 +290,32 @@ void DataModel::setItems(const QString &sourceName, const QVariantList &list)
|
|||||||
|
|
||||||
//make the declarative view reload everything,
|
//make the declarative view reload everything,
|
||||||
//would be nice an incremental update but is not possible
|
//would be nice an incremental update but is not possible
|
||||||
emit modelReset();
|
endResetModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataModel::removeSource(const QString &sourceName)
|
void DataModel::removeSource(const QString &sourceName)
|
||||||
{
|
{
|
||||||
//FIXME: this could be way more efficient by not resetting the whole model
|
//FIXME: this could be way more efficient by not resetting the whole model
|
||||||
//FIXME: find a way to remove only the proper things also in the case where sources are items
|
//FIXME: find a way to remove only the proper things also in the case where sources are items
|
||||||
emit modelAboutToBeReset();
|
|
||||||
m_items.remove(sourceName);
|
//source name as key of the map
|
||||||
emit modelReset();
|
if (!m_keyRoleFilter.isEmpty()) {
|
||||||
|
if (m_items.contains(sourceName)) {
|
||||||
|
beginResetModel();
|
||||||
|
m_items.remove(sourceName);
|
||||||
|
endResetModel();
|
||||||
|
}
|
||||||
|
//source name in the map, linear scan
|
||||||
|
} else {
|
||||||
|
for (int i = 0; i < m_items.value(QString()).count(); ++i) {
|
||||||
|
if (m_items.value(QString())[i].value<QVariantHash>().value("DataEngineSource") == sourceName) {
|
||||||
|
beginResetModel();
|
||||||
|
m_items[QString()].remove(i);
|
||||||
|
endResetModel();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant DataModel::data(const QModelIndex &index, int role) const
|
QVariant DataModel::data(const QModelIndex &index, int role) const
|
||||||
|
@ -130,8 +130,6 @@ protected:
|
|||||||
inline int countItems() const;
|
inline int countItems() const;
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void modelAboutToBeReset();
|
|
||||||
void modelReset();
|
|
||||||
void countChanged();
|
void countChanged();
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
|
@ -32,7 +32,7 @@ namespace Plasma
|
|||||||
{
|
{
|
||||||
DataSource::DataSource(QObject* parent)
|
DataSource::DataSource(QObject* parent)
|
||||||
: QObject(parent),
|
: QObject(parent),
|
||||||
m_interval(1000),
|
m_interval(0),
|
||||||
m_dataEngine(0)
|
m_dataEngine(0)
|
||||||
{
|
{
|
||||||
setObjectName("DataSource");
|
setObjectName("DataSource");
|
||||||
@ -193,6 +193,10 @@ Plasma::Service *DataSource::serviceForSource(const QString &source)
|
|||||||
|
|
||||||
void DataSource::connectSource(const QString &source)
|
void DataSource::connectSource(const QString &source)
|
||||||
{
|
{
|
||||||
|
if (m_connectedSources.contains(source)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
m_newSources.append(source);
|
m_newSources.append(source);
|
||||||
m_connectedSources.append(source);
|
m_connectedSources.append(source);
|
||||||
m_changes |= SourcesChanged;
|
m_changes |= SourcesChanged;
|
||||||
|
@ -55,12 +55,13 @@ public:
|
|||||||
DataSource(QObject* parent=0);
|
DataSource(QObject* parent=0);
|
||||||
|
|
||||||
Q_PROPERTY(bool valid READ valid)
|
Q_PROPERTY(bool valid READ valid)
|
||||||
bool valid() const {return m_dataEngine != 0;}
|
bool valid() const {return m_dataEngine && m_dataEngine->isValid();}
|
||||||
|
|
||||||
Q_PROPERTY(int interval READ interval WRITE setInterval NOTIFY intervalChanged)
|
Q_PROPERTY(int interval READ interval WRITE setInterval NOTIFY intervalChanged)
|
||||||
int interval() const {return m_interval;}
|
int interval() const {return m_interval;}
|
||||||
void setInterval(const int interval);
|
void setInterval(const int interval);
|
||||||
|
|
||||||
|
Q_PROPERTY(QString dataEngine READ engine WRITE setEngine NOTIFY engineChanged)
|
||||||
Q_PROPERTY(QString engine READ engine WRITE setEngine NOTIFY engineChanged)
|
Q_PROPERTY(QString engine READ engine WRITE setEngine NOTIFY engineChanged)
|
||||||
QString engine() const {return m_engine;}
|
QString engine() const {return m_engine;}
|
||||||
void setEngine(const QString &e);
|
void setEngine(const QString &e);
|
||||||
|
84
declarativeimports/core/declarativeitemcontainer.cpp
Normal file
84
declarativeimports/core/declarativeitemcontainer.cpp
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* Copyright 2011 Marco Martin <mart@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 "declarativeitemcontainer_p.h"
|
||||||
|
|
||||||
|
#include <KDebug>
|
||||||
|
|
||||||
|
DeclarativeItemContainer::DeclarativeItemContainer(QGraphicsItem *parent)
|
||||||
|
: QGraphicsWidget(parent)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
DeclarativeItemContainer::~DeclarativeItemContainer()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void DeclarativeItemContainer::setDeclarativeItem(QDeclarativeItem *item, bool reparent)
|
||||||
|
{
|
||||||
|
if (m_declarativeItem) {
|
||||||
|
disconnect(m_declarativeItem.data(), 0, this, 0);
|
||||||
|
}
|
||||||
|
m_declarativeItem = item;
|
||||||
|
if (reparent) {
|
||||||
|
static_cast<QGraphicsItem *>(item)->setParentItem(this);
|
||||||
|
}
|
||||||
|
setMinimumWidth(item->implicitWidth());
|
||||||
|
setMinimumHeight(item->implicitHeight());
|
||||||
|
resize(item->width(), item->height());
|
||||||
|
connect(m_declarativeItem.data(), SIGNAL(widthChanged()), this, SLOT(widthChanged()));
|
||||||
|
connect(m_declarativeItem.data(), SIGNAL(heightChanged()), this, SLOT(heightChanged()));
|
||||||
|
}
|
||||||
|
|
||||||
|
QDeclarativeItem *DeclarativeItemContainer::declarativeItem() const
|
||||||
|
{
|
||||||
|
return m_declarativeItem.data();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DeclarativeItemContainer::resizeEvent(QGraphicsSceneResizeEvent *event)
|
||||||
|
{
|
||||||
|
if (m_declarativeItem) {
|
||||||
|
m_declarativeItem.data()->setProperty("width", event->newSize().width());
|
||||||
|
m_declarativeItem.data()->setProperty("height", event->newSize().height());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DeclarativeItemContainer::widthChanged()
|
||||||
|
{
|
||||||
|
if (!m_declarativeItem) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QSizeF newSize(size());
|
||||||
|
newSize.setWidth(m_declarativeItem.data()->width());
|
||||||
|
resize(newSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DeclarativeItemContainer::heightChanged()
|
||||||
|
{
|
||||||
|
if (!m_declarativeItem) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QSizeF newSize(size());
|
||||||
|
newSize.setHeight(m_declarativeItem.data()->height());
|
||||||
|
resize(newSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
#include "declarativeitemcontainer_p.moc"
|
51
declarativeimports/core/declarativeitemcontainer_p.h
Normal file
51
declarativeimports/core/declarativeitemcontainer_p.h
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* Copyright 2011 Marco Martin <mart@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 DECLARATIVEITEMCONTAINER_P
|
||||||
|
#define DECLARATIVEITEMCONTAINER_P
|
||||||
|
|
||||||
|
#include <QDeclarativeItem>
|
||||||
|
#include <QGraphicsObject>
|
||||||
|
#include <QGraphicsWidget>
|
||||||
|
#include <QGraphicsSceneResizeEvent>
|
||||||
|
|
||||||
|
|
||||||
|
class DeclarativeItemContainer : public QGraphicsWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
DeclarativeItemContainer(QGraphicsItem *parent = 0);
|
||||||
|
~DeclarativeItemContainer();
|
||||||
|
|
||||||
|
void setDeclarativeItem(QDeclarativeItem *item, bool reparent = true);
|
||||||
|
QDeclarativeItem *declarativeItem() const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void resizeEvent(QGraphicsSceneResizeEvent *event);
|
||||||
|
|
||||||
|
protected Q_SLOTS:
|
||||||
|
void widthChanged();
|
||||||
|
void heightChanged();
|
||||||
|
|
||||||
|
private:
|
||||||
|
QWeakPointer<QDeclarativeItem> m_declarativeItem;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
@ -18,69 +18,78 @@
|
|||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
#include "dialog.h"
|
#include "dialog.h"
|
||||||
|
#include "declarativeitemcontainer_p.h"
|
||||||
|
|
||||||
#include <QDeclarativeItem>
|
#include <QDeclarativeItem>
|
||||||
#include <QGraphicsObject>
|
#include <QGraphicsObject>
|
||||||
#include <QGraphicsWidget>
|
#include <QGraphicsWidget>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
#include <QLayout>
|
||||||
|
|
||||||
#include <Plasma/Corona>
|
#include <Plasma/Corona>
|
||||||
#include <Plasma/Dialog>
|
#include <Plasma/Dialog>
|
||||||
|
#include <Plasma/WindowEffects>
|
||||||
|
|
||||||
class DeclarativeItemContainer : public QGraphicsWidget
|
|
||||||
|
DialogMargins::DialogMargins(Plasma::Dialog *dialog, QObject *parent)
|
||||||
|
: QObject(parent),
|
||||||
|
m_dialog(dialog)
|
||||||
{
|
{
|
||||||
public:
|
checkMargins();
|
||||||
DeclarativeItemContainer(QGraphicsItem *parent = 0)
|
}
|
||||||
: QGraphicsWidget(parent)
|
|
||||||
{}
|
|
||||||
|
|
||||||
~DeclarativeItemContainer()
|
void DialogMargins::checkMargins()
|
||||||
{}
|
{
|
||||||
|
int left, top, right, bottom;
|
||||||
|
m_dialog->getContentsMargins(&left, &top, &right, &bottom);
|
||||||
|
|
||||||
void setDeclarativeItem(QDeclarativeItem *item)
|
if (left != m_left) {
|
||||||
{
|
m_left = left;
|
||||||
if (m_declarativeItem) {
|
emit leftChanged();
|
||||||
m_declarativeItem.data()->removeSceneEventFilter(this);
|
|
||||||
}
|
|
||||||
m_declarativeItem = item;
|
|
||||||
static_cast<QGraphicsItem *>(item)->setParentItem(this);
|
|
||||||
setMinimumWidth(item->implicitWidth());
|
|
||||||
setMinimumHeight(item->implicitHeight());
|
|
||||||
resize(item->width(), item->height());
|
|
||||||
item->installSceneEventFilter(this);
|
|
||||||
}
|
}
|
||||||
|
if (top != m_top) {
|
||||||
QDeclarativeItem *declarativeItem() const
|
m_top = top;
|
||||||
{
|
emit topChanged();
|
||||||
return m_declarativeItem.data();
|
|
||||||
}
|
}
|
||||||
|
if (right != m_right) {
|
||||||
protected:
|
m_right = right;
|
||||||
void resizeEvent(QGraphicsSceneResizeEvent *event)
|
emit rightChanged();
|
||||||
{
|
|
||||||
if (m_declarativeItem) {
|
|
||||||
m_declarativeItem.data()->setProperty("width", event->newSize().width());
|
|
||||||
m_declarativeItem.data()->setProperty("height", event->newSize().height());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
if (bottom != m_bottom) {
|
||||||
bool sceneEventFilter(QGraphicsItem *watched, QEvent *event)
|
m_bottom = bottom;
|
||||||
{
|
emit bottomChanged();
|
||||||
if (event->type() == QEvent::GraphicsSceneResize) {
|
|
||||||
resize(watched->boundingRect().size());
|
|
||||||
}
|
|
||||||
|
|
||||||
return QGraphicsWidget::sceneEventFilter(watched, event);
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
int DialogMargins::left() const
|
||||||
QWeakPointer<QDeclarativeItem> m_declarativeItem;
|
{
|
||||||
};
|
return m_left;
|
||||||
|
}
|
||||||
|
|
||||||
|
int DialogMargins::top() const
|
||||||
|
{
|
||||||
|
return m_top;
|
||||||
|
}
|
||||||
|
|
||||||
|
int DialogMargins::right() const
|
||||||
|
{
|
||||||
|
return m_right;
|
||||||
|
}
|
||||||
|
|
||||||
|
int DialogMargins::bottom() const
|
||||||
|
{
|
||||||
|
return m_bottom;
|
||||||
|
}
|
||||||
|
|
||||||
DialogProxy::DialogProxy(QObject *parent)
|
DialogProxy::DialogProxy(QObject *parent)
|
||||||
: QObject(parent)
|
: QObject(parent),
|
||||||
|
m_declarativeItemContainer(0),
|
||||||
|
m_activeWindow(false),
|
||||||
|
m_location(Plasma::Floating)
|
||||||
{
|
{
|
||||||
m_dialog = new Plasma::Dialog();
|
m_dialog = new Plasma::Dialog();
|
||||||
|
m_margins = new DialogMargins(m_dialog, this);
|
||||||
|
m_dialog->installEventFilter(this);
|
||||||
m_flags = m_dialog->windowFlags();
|
m_flags = m_dialog->windowFlags();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -92,18 +101,22 @@ DialogProxy::~DialogProxy()
|
|||||||
|
|
||||||
QGraphicsObject *DialogProxy::mainItem() const
|
QGraphicsObject *DialogProxy::mainItem() const
|
||||||
{
|
{
|
||||||
return m_dialog->graphicsWidget();
|
return m_mainItem.data();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DialogProxy::setMainItem(QGraphicsObject *mainItem)
|
void DialogProxy::setMainItem(QGraphicsObject *mainItem)
|
||||||
{
|
{
|
||||||
if (m_mainItem.data() != mainItem) {
|
if (m_mainItem.data() != mainItem) {
|
||||||
if (m_mainItem) {
|
if (m_mainItem) {
|
||||||
m_mainItem.data()->setParent(mainItem->parent());
|
m_mainItem.data()->setParent(mainItem ? mainItem->parent() : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_mainItem = mainItem;
|
m_mainItem = mainItem;
|
||||||
mainItem->setParentItem(0);
|
|
||||||
mainItem->setParent(this);
|
if (mainItem) {
|
||||||
|
mainItem->setParentItem(0);
|
||||||
|
mainItem->setParent(this);
|
||||||
|
}
|
||||||
|
|
||||||
//if this is called in Compenent.onCompleted we have to wait a loop the item is added to a scene
|
//if this is called in Compenent.onCompleted we have to wait a loop the item is added to a scene
|
||||||
QTimer::singleShot(0, this, SLOT(syncMainItem()));
|
QTimer::singleShot(0, this, SLOT(syncMainItem()));
|
||||||
@ -125,19 +138,27 @@ void DialogProxy::syncMainItem()
|
|||||||
QGraphicsObject *qo = qobject_cast<QGraphicsObject *>(parent);
|
QGraphicsObject *qo = qobject_cast<QGraphicsObject *>(parent);
|
||||||
if (qo) {
|
if (qo) {
|
||||||
scene = qo->scene();
|
scene = qo->scene();
|
||||||
scene->addItem(m_mainItem.data());
|
if (scene) {
|
||||||
break;
|
scene->addItem(m_mainItem.data());
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!scene) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
//the parent of the qobject never changed, only the parentitem, so put it back what it was
|
//the parent of the qobject never changed, only the parentitem, so put it back what it was
|
||||||
m_mainItem.data()->setParentItem(qobject_cast<QGraphicsObject *>(m_mainItem.data()->parent()));
|
m_mainItem.data()->setParentItem(qobject_cast<QGraphicsObject *>(m_mainItem.data()->parent()));
|
||||||
|
|
||||||
QGraphicsWidget *widget = qobject_cast<QGraphicsWidget *>(m_mainItem.data());
|
QGraphicsWidget *widget = qobject_cast<QGraphicsWidget *>(m_mainItem.data());
|
||||||
if (widget) {
|
if (widget) {
|
||||||
m_declarativeItemContainer->deleteLater();
|
if (m_declarativeItemContainer) {
|
||||||
m_declarativeItemContainer = 0;
|
m_declarativeItemContainer->deleteLater();
|
||||||
|
m_declarativeItemContainer = 0;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
QDeclarativeItem *di = qobject_cast<QDeclarativeItem *>(m_mainItem.data());
|
QDeclarativeItem *di = qobject_cast<QDeclarativeItem *>(m_mainItem.data());
|
||||||
if (di) {
|
if (di) {
|
||||||
@ -163,17 +184,20 @@ void DialogProxy::setVisible(const bool visible)
|
|||||||
m_dialog->setVisible(visible);
|
m_dialog->setVisible(visible);
|
||||||
if (visible) {
|
if (visible) {
|
||||||
m_dialog->setWindowFlags(m_flags);
|
m_dialog->setWindowFlags(m_flags);
|
||||||
|
m_dialog->setVisible(visible);
|
||||||
m_dialog->raise();
|
m_dialog->raise();
|
||||||
}
|
}
|
||||||
emit visibleChanged();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QPoint DialogProxy::popupPosition(QGraphicsObject *item) const
|
QPoint DialogProxy::popupPosition(QGraphicsObject *item, int alignment) const
|
||||||
{
|
{
|
||||||
|
if (!item) {
|
||||||
|
return QPoint();
|
||||||
|
}
|
||||||
Plasma::Corona *corona = qobject_cast<Plasma::Corona *>(item->scene());
|
Plasma::Corona *corona = qobject_cast<Plasma::Corona *>(item->scene());
|
||||||
if (corona) {
|
if (corona) {
|
||||||
return corona->popupPosition(item, m_dialog->size());
|
return corona->popupPosition(item, m_dialog->size(), (Qt::AlignmentFlag)alignment);
|
||||||
} else {
|
} else {
|
||||||
return QPoint();
|
return QPoint();
|
||||||
}
|
}
|
||||||
@ -200,6 +224,21 @@ void DialogProxy::setY(int y)
|
|||||||
m_dialog->move(m_dialog->pos().x(), y);
|
m_dialog->move(m_dialog->pos().x(), y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int DialogProxy::width() const
|
||||||
|
{
|
||||||
|
return m_dialog->size().width();
|
||||||
|
}
|
||||||
|
|
||||||
|
int DialogProxy::height() const
|
||||||
|
{
|
||||||
|
return m_dialog->size().height();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DialogProxy::isActiveWindow() const
|
||||||
|
{
|
||||||
|
return m_activeWindow;
|
||||||
|
}
|
||||||
|
|
||||||
int DialogProxy::windowFlags() const
|
int DialogProxy::windowFlags() const
|
||||||
{
|
{
|
||||||
return (int)m_dialog->windowFlags();
|
return (int)m_dialog->windowFlags();
|
||||||
@ -211,10 +250,59 @@ void DialogProxy::setWindowFlags(const int flags)
|
|||||||
m_dialog->setWindowFlags((Qt::WindowFlags)flags);
|
m_dialog->setWindowFlags((Qt::WindowFlags)flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int DialogProxy::location() const
|
||||||
|
{
|
||||||
|
return (int)m_location;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DialogProxy::setLocation(int location)
|
||||||
|
{
|
||||||
|
if (m_location == location) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
m_location = (Plasma::Location)location;
|
||||||
|
emit locationChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QObject *DialogProxy::margins() const
|
||||||
|
{
|
||||||
|
return m_margins;
|
||||||
|
}
|
||||||
|
|
||||||
bool DialogProxy::eventFilter(QObject *watched, QEvent *event)
|
bool DialogProxy::eventFilter(QObject *watched, QEvent *event)
|
||||||
{
|
{
|
||||||
if (watched == m_dialog && event->type() == QEvent::Move) {
|
if (watched == m_dialog && event->type() == QEvent::Move) {
|
||||||
emit positionChanged();
|
QMoveEvent *me = static_cast<QMoveEvent *>(event);
|
||||||
|
if (me->oldPos().x() != me->pos().x()) {
|
||||||
|
emit xChanged();
|
||||||
|
}
|
||||||
|
if (me->oldPos().y() != me->pos().y()) {
|
||||||
|
emit yChanged();
|
||||||
|
}
|
||||||
|
if ((me->oldPos().x() != me->pos().x()) || (me->oldPos().y() != me->pos().y())) {
|
||||||
|
m_margins->checkMargins();
|
||||||
|
}
|
||||||
|
} else if (watched == m_dialog && event->type() == QEvent::Resize) {
|
||||||
|
QResizeEvent *re = static_cast<QResizeEvent *>(event);
|
||||||
|
if (re->oldSize().width() != re->size().width()) {
|
||||||
|
emit widthChanged();
|
||||||
|
}
|
||||||
|
if (re->oldSize().height() != re->size().height()) {
|
||||||
|
emit heightChanged();
|
||||||
|
}
|
||||||
|
} else if (watched == m_dialog && event->type() == QEvent::Show) {
|
||||||
|
Plasma::WindowEffects::slideWindow(m_dialog, m_location);
|
||||||
|
emit visibleChanged();
|
||||||
|
} else if (watched == m_dialog && event->type() == QEvent::Hide) {
|
||||||
|
Plasma::WindowEffects::slideWindow(m_dialog, m_location);
|
||||||
|
emit visibleChanged();
|
||||||
|
} else if (watched == m_dialog && event->type() == QEvent::WindowActivate) {
|
||||||
|
m_activeWindow = true;
|
||||||
|
emit activeWindowChanged();
|
||||||
|
} else if (watched == m_dialog && event->type() == QEvent::WindowDeactivate) {
|
||||||
|
m_activeWindow = false;
|
||||||
|
emit activeWindowChanged();
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,8 @@
|
|||||||
#include <QWeakPointer>
|
#include <QWeakPointer>
|
||||||
#include <QPoint>
|
#include <QPoint>
|
||||||
|
|
||||||
|
#include <Plasma/Plasma>
|
||||||
|
|
||||||
class QGraphicsObject;
|
class QGraphicsObject;
|
||||||
|
|
||||||
namespace Plasma
|
namespace Plasma
|
||||||
@ -32,15 +34,56 @@ namespace Plasma
|
|||||||
|
|
||||||
class DeclarativeItemContainer;
|
class DeclarativeItemContainer;
|
||||||
|
|
||||||
|
class DialogMargins : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
Q_PROPERTY(int left READ left NOTIFY leftChanged)
|
||||||
|
Q_PROPERTY(int top READ top NOTIFY topChanged)
|
||||||
|
Q_PROPERTY(int right READ right NOTIFY rightChanged)
|
||||||
|
Q_PROPERTY(int bottom READ bottom NOTIFY bottomChanged)
|
||||||
|
|
||||||
|
public:
|
||||||
|
DialogMargins(Plasma::Dialog *dialog, QObject *parent = 0);
|
||||||
|
|
||||||
|
int left() const;
|
||||||
|
int top() const;
|
||||||
|
int right() const;
|
||||||
|
int bottom() const;
|
||||||
|
|
||||||
|
Q_SIGNALS:
|
||||||
|
void leftChanged();
|
||||||
|
void rightChanged();
|
||||||
|
void topChanged();
|
||||||
|
void bottomChanged();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void checkMargins();
|
||||||
|
|
||||||
|
private:
|
||||||
|
int m_left;
|
||||||
|
int m_top;
|
||||||
|
int m_right;
|
||||||
|
int m_bottom;
|
||||||
|
Plasma::Dialog *m_dialog;
|
||||||
|
friend class DialogProxy;
|
||||||
|
};
|
||||||
|
|
||||||
class DialogProxy : public QObject
|
class DialogProxy : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
Q_PROPERTY(QGraphicsObject *mainItem READ mainItem WRITE setMainItem NOTIFY mainItemChanged)
|
Q_PROPERTY(QGraphicsObject *mainItem READ mainItem WRITE setMainItem NOTIFY mainItemChanged)
|
||||||
Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged)
|
Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged)
|
||||||
Q_PROPERTY(int x READ x WRITE setX NOTIFY positionChanged)
|
Q_PROPERTY(int x READ x WRITE setX NOTIFY xChanged)
|
||||||
Q_PROPERTY(int y READ y WRITE setY NOTIFY positionChanged)
|
Q_PROPERTY(int y READ y WRITE setY NOTIFY yChanged)
|
||||||
|
//to set the size try to force doing so from the inner item
|
||||||
|
Q_PROPERTY(int width READ width NOTIFY widthChanged)
|
||||||
|
Q_PROPERTY(int height READ height NOTIFY heightChanged)
|
||||||
Q_PROPERTY(int windowFlags READ windowFlags WRITE setWindowFlags)
|
Q_PROPERTY(int windowFlags READ windowFlags WRITE setWindowFlags)
|
||||||
|
Q_PROPERTY(QObject *margins READ margins CONSTANT)
|
||||||
|
Q_PROPERTY(bool activeWindow READ isActiveWindow NOTIFY activeWindowChanged)
|
||||||
|
Q_PROPERTY(int location READ location WRITE setLocation NOTIFY locationChanged)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum WidgetAttribute {
|
enum WidgetAttribute {
|
||||||
@ -62,18 +105,34 @@ public:
|
|||||||
int y() const;
|
int y() const;
|
||||||
void setY(int y);
|
void setY(int y);
|
||||||
|
|
||||||
|
int width() const;
|
||||||
|
int height() const;
|
||||||
|
|
||||||
|
bool isActiveWindow() const;
|
||||||
|
|
||||||
//FIXME: passing an int is ugly
|
//FIXME: passing an int is ugly
|
||||||
int windowFlags() const;
|
int windowFlags() const;
|
||||||
void setWindowFlags(const int);
|
void setWindowFlags(const int);
|
||||||
|
|
||||||
Q_INVOKABLE QPoint popupPosition(QGraphicsObject *item) const;
|
int location() const;
|
||||||
|
void setLocation(int location);
|
||||||
|
|
||||||
|
QObject *margins() const;
|
||||||
|
|
||||||
|
//FIXME: alignment should be Qt::AlignmentFlag
|
||||||
|
Q_INVOKABLE QPoint popupPosition(QGraphicsObject *item, int alignment=Qt::AlignLeft) const;
|
||||||
//FIXME:: Qt::WidgetAttribute should be already
|
//FIXME:: Qt::WidgetAttribute should be already
|
||||||
Q_INVOKABLE void setAttribute(int attribute, bool on);
|
Q_INVOKABLE void setAttribute(int attribute, bool on);
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void mainItemChanged();
|
void mainItemChanged();
|
||||||
void visibleChanged();
|
void visibleChanged();
|
||||||
void positionChanged();
|
void xChanged();
|
||||||
|
void yChanged();
|
||||||
|
void widthChanged();
|
||||||
|
void heightChanged();
|
||||||
|
void activeWindowChanged();
|
||||||
|
void locationChanged();
|
||||||
|
|
||||||
protected Q_SLOTS:
|
protected Q_SLOTS:
|
||||||
void syncMainItem();
|
void syncMainItem();
|
||||||
@ -86,6 +145,9 @@ private:
|
|||||||
Qt::WindowFlags m_flags;
|
Qt::WindowFlags m_flags;
|
||||||
DeclarativeItemContainer *m_declarativeItemContainer;
|
DeclarativeItemContainer *m_declarativeItemContainer;
|
||||||
QWeakPointer<QGraphicsObject> m_mainItem;
|
QWeakPointer<QGraphicsObject> m_mainItem;
|
||||||
|
DialogMargins *m_margins;
|
||||||
|
bool m_activeWindow;
|
||||||
|
Plasma::Location m_location;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -69,9 +69,11 @@ void SvgItem::setSvg(Plasma::Svg *svg)
|
|||||||
disconnect(m_svg.data(), 0, this, 0);
|
disconnect(m_svg.data(), 0, this, 0);
|
||||||
}
|
}
|
||||||
m_svg = svg;
|
m_svg = svg;
|
||||||
connect(svg, SIGNAL(repaintNeeded()), this, SLOT(updateNeeded()));
|
if (svg) {
|
||||||
connect(svg, SIGNAL(repaintNeeded()), this, SIGNAL(naturalSizeChanged()));
|
connect(svg, SIGNAL(repaintNeeded()), this, SLOT(updateNeeded()));
|
||||||
connect(svg, SIGNAL(sizeChanged()), this, SIGNAL(naturalSizeChanged()));
|
connect(svg, SIGNAL(repaintNeeded()), this, SIGNAL(naturalSizeChanged()));
|
||||||
|
connect(svg, SIGNAL(sizeChanged()), this, SIGNAL(naturalSizeChanged()));
|
||||||
|
}
|
||||||
emit naturalSizeChanged();
|
emit naturalSizeChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,6 +31,36 @@ ThemeProxy::~ThemeProxy()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString ThemeProxy::themeName() const
|
||||||
|
{
|
||||||
|
return Plasma::Theme::defaultTheme()->themeName();
|
||||||
|
}
|
||||||
|
|
||||||
|
QFont ThemeProxy::font() const
|
||||||
|
{
|
||||||
|
return Plasma::Theme::defaultTheme()->font(Plasma::Theme::DefaultFont);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ThemeProxy::windowTranslucencyEnabled() const
|
||||||
|
{
|
||||||
|
return Plasma::Theme::defaultTheme()->windowTranslucencyEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
|
KUrl ThemeProxy::homepage() const
|
||||||
|
{
|
||||||
|
return Plasma::Theme::defaultTheme()->homepage();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ThemeProxy::useGlobalSettings() const
|
||||||
|
{
|
||||||
|
return Plasma::Theme::defaultTheme()->useGlobalSettings();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString ThemeProxy::wallpaperPath() const
|
||||||
|
{
|
||||||
|
return Plasma::Theme::defaultTheme()->wallpaperPath();
|
||||||
|
}
|
||||||
|
|
||||||
QColor ThemeProxy::textColor() const
|
QColor ThemeProxy::textColor() const
|
||||||
{
|
{
|
||||||
return Plasma::Theme::defaultTheme()->color(Plasma::Theme::TextColor);
|
return Plasma::Theme::defaultTheme()->color(Plasma::Theme::TextColor);
|
||||||
@ -96,6 +126,11 @@ QColor ThemeProxy::viewFocusColor() const
|
|||||||
return Plasma::Theme::defaultTheme()->color(Plasma::Theme::ViewFocusColor);
|
return Plasma::Theme::defaultTheme()->color(Plasma::Theme::ViewFocusColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString ThemeProxy::styleSheet() const
|
||||||
|
{
|
||||||
|
return Plasma::Theme::defaultTheme()->styleSheet(QString());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#include "theme_p.moc"
|
#include "theme_p.moc"
|
||||||
|
|
||||||
|
@ -21,12 +21,22 @@
|
|||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
|
#include <KUrl>
|
||||||
|
#include <QFont>
|
||||||
#include <QColor>
|
#include <QColor>
|
||||||
|
|
||||||
class ThemeProxy : public QObject
|
class ThemeProxy : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
Q_PROPERTY(QString themeName READ themeName NOTIFY themeChanged)
|
||||||
|
Q_PROPERTY(QFont font READ font NOTIFY themeChanged)
|
||||||
|
Q_PROPERTY(bool windowTranslucentEnabled READ windowTranslucencyEnabled NOTIFY themeChanged)
|
||||||
|
Q_PROPERTY(KUrl homepage READ homepage NOTIFY themeChanged)
|
||||||
|
Q_PROPERTY(bool useGlobalSettings READ useGlobalSettings NOTIFY themeChanged)
|
||||||
|
Q_PROPERTY(QString wallpaperPath READ wallpaperPath NOTIFY themeChanged)
|
||||||
|
|
||||||
|
// colors
|
||||||
Q_PROPERTY(QColor textColor READ textColor NOTIFY themeChanged)
|
Q_PROPERTY(QColor textColor READ textColor NOTIFY themeChanged)
|
||||||
Q_PROPERTY(QColor highlightColor READ highlightColor NOTIFY themeChanged)
|
Q_PROPERTY(QColor highlightColor READ highlightColor NOTIFY themeChanged)
|
||||||
Q_PROPERTY(QColor backgroundColor READ backgroundColor NOTIFY themeChanged)
|
Q_PROPERTY(QColor backgroundColor READ backgroundColor NOTIFY themeChanged)
|
||||||
@ -41,11 +51,19 @@ class ThemeProxy : public QObject
|
|||||||
Q_PROPERTY(QColor viewBackgroundColor READ viewBackgroundColor NOTIFY themeChanged)
|
Q_PROPERTY(QColor viewBackgroundColor READ viewBackgroundColor NOTIFY themeChanged)
|
||||||
Q_PROPERTY(QColor viewHoverColor READ viewHoverColor NOTIFY themeChanged)
|
Q_PROPERTY(QColor viewHoverColor READ viewHoverColor NOTIFY themeChanged)
|
||||||
Q_PROPERTY(QColor viewFocusColor READ viewFocusColor NOTIFY themeChanged)
|
Q_PROPERTY(QColor viewFocusColor READ viewFocusColor NOTIFY themeChanged)
|
||||||
|
Q_PROPERTY(QString styleSheet READ styleSheet NOTIFY themeChanged)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ThemeProxy(QObject *parent = 0);
|
ThemeProxy(QObject *parent = 0);
|
||||||
~ThemeProxy();
|
~ThemeProxy();
|
||||||
|
|
||||||
|
QString themeName() const;
|
||||||
|
QFont font() const;
|
||||||
|
bool windowTranslucencyEnabled() const;
|
||||||
|
KUrl homepage() const;
|
||||||
|
bool useGlobalSettings() const;
|
||||||
|
QString wallpaperPath() const;
|
||||||
|
|
||||||
QColor textColor() const;
|
QColor textColor() const;
|
||||||
QColor highlightColor() const;
|
QColor highlightColor() const;
|
||||||
QColor backgroundColor() const;
|
QColor backgroundColor() const;
|
||||||
@ -59,6 +77,7 @@ public:
|
|||||||
QColor viewBackgroundColor() const;
|
QColor viewBackgroundColor() const;
|
||||||
QColor viewHoverColor() const;
|
QColor viewHoverColor() const;
|
||||||
QColor viewFocusColor() const;
|
QColor viewFocusColor() const;
|
||||||
|
QString styleSheet() const;
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void themeChanged();
|
void themeChanged();
|
||||||
|
168
declarativeimports/core/tooltip.cpp
Normal file
168
declarativeimports/core/tooltip.cpp
Normal file
@ -0,0 +1,168 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* Copyright 2011 Marco Martin <mart@kde.org> *
|
||||||
|
* Copyright 2011 Artur Duque de Souza <asouza@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 "tooltip.h"
|
||||||
|
#include "declarativeitemcontainer_p.h"
|
||||||
|
|
||||||
|
#include <QDeclarativeItem>
|
||||||
|
#include <QGraphicsObject>
|
||||||
|
#include <QGraphicsWidget>
|
||||||
|
#include <QGraphicsScene>
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QTimer>
|
||||||
|
|
||||||
|
#include <KIcon>
|
||||||
|
#include <KIconLoader>
|
||||||
|
#include <Plasma/ToolTipContent>
|
||||||
|
#include <Plasma/ToolTipManager>
|
||||||
|
|
||||||
|
|
||||||
|
ToolTipProxy::ToolTipProxy(QObject *parent)
|
||||||
|
: QObject(parent), m_mainText(""), m_subText(""), m_widget(0)
|
||||||
|
{
|
||||||
|
connect(this, SIGNAL(targetChanged()), this, SLOT(updateToolTip()));
|
||||||
|
connect(this, SIGNAL(mainTextChanged()), this, SLOT(updateToolTip()));
|
||||||
|
connect(this, SIGNAL(subTextChanged()), this, SLOT(updateToolTip()));
|
||||||
|
connect(this, SIGNAL(imageChanged()), this, SLOT(updateToolTip()));
|
||||||
|
}
|
||||||
|
|
||||||
|
ToolTipProxy::~ToolTipProxy()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
QGraphicsObject *ToolTipProxy::target() const
|
||||||
|
{
|
||||||
|
return m_target.data();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ToolTipProxy::setTarget(QGraphicsObject *target)
|
||||||
|
{
|
||||||
|
if (m_target.data() != target) {
|
||||||
|
m_target = target;
|
||||||
|
|
||||||
|
m_widget = qobject_cast<QGraphicsWidget*>(m_target.data());
|
||||||
|
if (!m_widget) {
|
||||||
|
// if this is called in Compenent.onCompleted we have to
|
||||||
|
// wait a loop for the item to be added to a scene
|
||||||
|
QTimer::singleShot(0, this, SLOT(syncTarget()));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
emit targetChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ToolTipProxy::syncTarget()
|
||||||
|
{
|
||||||
|
// find the scene
|
||||||
|
QGraphicsScene *scene = m_target.data()->scene();
|
||||||
|
if (!scene) {
|
||||||
|
QObject *parent = m_target.data();
|
||||||
|
while ((parent = parent->parent())) {
|
||||||
|
QGraphicsObject *qo = qobject_cast<QGraphicsObject*>(parent);
|
||||||
|
if (qo) {
|
||||||
|
scene = qo->scene();
|
||||||
|
scene->addItem(m_target.data());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(m_target.data());
|
||||||
|
if (!item) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!m_declarativeItemContainer) {
|
||||||
|
m_declarativeItemContainer = QWeakPointer<DeclarativeItemContainer>(new DeclarativeItemContainer());
|
||||||
|
m_declarativeItemContainer.data()->setObjectName("DIContainer");
|
||||||
|
scene->addItem(m_declarativeItemContainer.data());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_declarativeItemContainer) {
|
||||||
|
m_target.data()->setObjectName("Original Item");
|
||||||
|
m_declarativeItemContainer.data()->setDeclarativeItem(item, false);
|
||||||
|
m_declarativeItemContainer.data()->setAcceptHoverEvents(true);
|
||||||
|
m_declarativeItemContainer.data()->setParentItem(m_target.data());
|
||||||
|
m_widget = m_declarativeItemContainer.data();
|
||||||
|
emit targetChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QString ToolTipProxy::mainText() const
|
||||||
|
{
|
||||||
|
return m_mainText;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ToolTipProxy::setMainText(const QString &text)
|
||||||
|
{
|
||||||
|
if (text == m_mainText) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_mainText = text;
|
||||||
|
emit mainTextChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString ToolTipProxy::subText() const
|
||||||
|
{
|
||||||
|
return m_subText;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ToolTipProxy::setSubText(const QString &text)
|
||||||
|
{
|
||||||
|
if (text == m_subText) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_subText = text;
|
||||||
|
emit subTextChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
// ###TODO: SHOULD BE PIXMAP OR QICON??
|
||||||
|
QString ToolTipProxy::image() const
|
||||||
|
{
|
||||||
|
return m_image;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ToolTipProxy::setImage(const QString &name)
|
||||||
|
{
|
||||||
|
if (name == m_image) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_image = name;
|
||||||
|
emit imageChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ToolTipProxy::updateToolTip()
|
||||||
|
{
|
||||||
|
if (!m_widget) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Plasma::ToolTipContent data;
|
||||||
|
data.setMainText(m_mainText);
|
||||||
|
data.setSubText(m_subText);
|
||||||
|
data.setImage(KIcon(m_image).pixmap(IconSize(KIconLoader::Desktop)));
|
||||||
|
Plasma::ToolTipManager::self()->setContent(m_widget, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
#include "tooltip.moc"
|
||||||
|
|
76
declarativeimports/core/tooltip.h
Normal file
76
declarativeimports/core/tooltip.h
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* Copyright 2011 Marco Martin <mart@kde.org> *
|
||||||
|
* Copyright 2011 Artur Duque de Souza <asouza@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 TOOLTIP_PROXY_P
|
||||||
|
#define TOOLTIP_PROXY_P
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <QWeakPointer>
|
||||||
|
|
||||||
|
class QGraphicsObject;
|
||||||
|
class QGraphicsWidget;
|
||||||
|
class DeclarativeItemContainer;
|
||||||
|
|
||||||
|
class ToolTipProxy : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
Q_PROPERTY(QGraphicsObject *target READ target WRITE setTarget NOTIFY targetChanged)
|
||||||
|
Q_PROPERTY(QString mainText READ mainText WRITE setMainText NOTIFY mainTextChanged)
|
||||||
|
Q_PROPERTY(QString subText READ subText WRITE setSubText NOTIFY subTextChanged)
|
||||||
|
Q_PROPERTY(QString image READ image WRITE setImage NOTIFY imageChanged)
|
||||||
|
|
||||||
|
public:
|
||||||
|
ToolTipProxy(QObject *parent = 0);
|
||||||
|
~ToolTipProxy();
|
||||||
|
|
||||||
|
QGraphicsObject *target() const;
|
||||||
|
void setTarget(QGraphicsObject *target);
|
||||||
|
|
||||||
|
QString mainText() const;
|
||||||
|
void setMainText(const QString &text);
|
||||||
|
|
||||||
|
QString subText() const;
|
||||||
|
void setSubText(const QString &text);
|
||||||
|
|
||||||
|
// SHOULD BE PIXMAP OR QICON
|
||||||
|
QString image() const;
|
||||||
|
void setImage(const QString &name);
|
||||||
|
|
||||||
|
Q_SIGNALS:
|
||||||
|
void targetChanged();
|
||||||
|
void mainTextChanged();
|
||||||
|
void subTextChanged();
|
||||||
|
void imageChanged();
|
||||||
|
|
||||||
|
protected Q_SLOTS:
|
||||||
|
void syncTarget();
|
||||||
|
void updateToolTip();
|
||||||
|
|
||||||
|
private:
|
||||||
|
QString m_mainText;
|
||||||
|
QString m_subText;
|
||||||
|
QString m_image;
|
||||||
|
QGraphicsWidget *m_widget;
|
||||||
|
QWeakPointer<DeclarativeItemContainer> m_declarativeItemContainer;
|
||||||
|
QWeakPointer<QGraphicsObject> m_target;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
27
declarativeimports/draganddrop/CMakeLists.txt
Normal file
27
declarativeimports/draganddrop/CMakeLists.txt
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
project(draganddrop)
|
||||||
|
|
||||||
|
include(KDE4Defaults)
|
||||||
|
|
||||||
|
set(declarativedragdrop_SRCS
|
||||||
|
draganddropplugin.cpp
|
||||||
|
DeclarativeDragArea.cpp
|
||||||
|
DeclarativeDragDropEvent.cpp
|
||||||
|
DeclarativeDropArea.cpp
|
||||||
|
DeclarativeMimeData.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
INCLUDE_DIRECTORIES(
|
||||||
|
${CMAKE_SOURCE_DIR}
|
||||||
|
${CMAKE_BINARY_DIR}
|
||||||
|
${KDE4_INCLUDES}
|
||||||
|
)
|
||||||
|
|
||||||
|
qt4_automoc(${declarativedragdrop_SRCS})
|
||||||
|
|
||||||
|
|
||||||
|
kde4_add_library(dragdropplugin SHARED ${declarativedragdrop_SRCS})
|
||||||
|
target_link_libraries(dragdropplugin ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTDECLARATIVE_LIBRARY})
|
||||||
|
|
||||||
|
install(TARGETS dragdropplugin DESTINATION ${IMPORTS_INSTALL_DIR}/org/kde/draganddrop)
|
||||||
|
|
||||||
|
install(FILES qmldir DESTINATION ${IMPORTS_INSTALL_DIR}/org/kde/draganddrop)
|
186
declarativeimports/draganddrop/DeclarativeDragArea.cpp
Normal file
186
declarativeimports/draganddrop/DeclarativeDragArea.cpp
Normal file
@ -0,0 +1,186 @@
|
|||||||
|
/*
|
||||||
|
Copyright (C) 2010 by BetterInbox <contact@betterinbox.com>
|
||||||
|
Original author: Gregory Schlomoff <greg@betterinbox.com>
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "DeclarativeDragArea.h"
|
||||||
|
#include "DeclarativeMimeData.h"
|
||||||
|
|
||||||
|
#include <QDrag>
|
||||||
|
#include <QMimeData>
|
||||||
|
#include <QGraphicsSceneMouseEvent>
|
||||||
|
#include <QApplication>
|
||||||
|
#include <QGraphicsScene>
|
||||||
|
#include <QGraphicsView>
|
||||||
|
|
||||||
|
/*!
|
||||||
|
A DragArea is used to make an item draggable.
|
||||||
|
*/
|
||||||
|
|
||||||
|
DeclarativeDragArea::DeclarativeDragArea(QDeclarativeItem *parent)
|
||||||
|
: QDeclarativeItem(parent),
|
||||||
|
m_delegate(0),
|
||||||
|
m_source(0),
|
||||||
|
m_target(0),
|
||||||
|
m_enabled(true),
|
||||||
|
m_supportedActions(Qt::MoveAction),
|
||||||
|
m_defaultAction(Qt::MoveAction),
|
||||||
|
m_data(new DeclarativeMimeData()) // m_data is owned by us, and we shouldn't pass it to Qt directly as it will automatically delete it after the drag and drop.
|
||||||
|
{
|
||||||
|
setAcceptedMouseButtons(Qt::LeftButton);
|
||||||
|
}
|
||||||
|
|
||||||
|
DeclarativeDragArea::~DeclarativeDragArea()
|
||||||
|
{
|
||||||
|
if (m_data) {
|
||||||
|
delete m_data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
The delegate is the item that will be displayed next to the mouse cursor during the drag and drop operation.
|
||||||
|
It usually consists of a large, semi-transparent icon representing the data being dragged.
|
||||||
|
*/
|
||||||
|
QDeclarativeComponent* DeclarativeDragArea::delegate() const
|
||||||
|
{
|
||||||
|
return m_delegate;
|
||||||
|
}
|
||||||
|
void DeclarativeDragArea::setDelegate(QDeclarativeComponent *delegate)
|
||||||
|
{
|
||||||
|
if (m_delegate != delegate) {
|
||||||
|
m_delegate = delegate;
|
||||||
|
emit delegateChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void DeclarativeDragArea::resetDelegate()
|
||||||
|
{
|
||||||
|
setDelegate(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
The QML element that is the source of this drag and drop operation. This can be defined to any item, and will
|
||||||
|
be available to the DropArea as event.data.source
|
||||||
|
*/
|
||||||
|
QDeclarativeItem* DeclarativeDragArea::source() const
|
||||||
|
{
|
||||||
|
return m_source;
|
||||||
|
}
|
||||||
|
void DeclarativeDragArea::setSource(QDeclarativeItem* source)
|
||||||
|
{
|
||||||
|
if (m_source != source) {
|
||||||
|
m_source = source;
|
||||||
|
emit sourceChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void DeclarativeDragArea::resetSource()
|
||||||
|
{
|
||||||
|
setSource(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// target
|
||||||
|
QDeclarativeItem* DeclarativeDragArea::target() const
|
||||||
|
{
|
||||||
|
//TODO: implement me
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// data
|
||||||
|
DeclarativeMimeData* DeclarativeDragArea::data() const
|
||||||
|
{
|
||||||
|
return m_data;
|
||||||
|
}
|
||||||
|
|
||||||
|
// enabled
|
||||||
|
bool DeclarativeDragArea::isEnabled() const
|
||||||
|
{
|
||||||
|
return m_enabled;
|
||||||
|
}
|
||||||
|
void DeclarativeDragArea::setEnabled(bool enabled)
|
||||||
|
{
|
||||||
|
if (enabled != m_enabled) {
|
||||||
|
m_enabled = enabled;
|
||||||
|
emit enabledChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// supported actions
|
||||||
|
Qt::DropActions DeclarativeDragArea::supportedActions() const
|
||||||
|
{
|
||||||
|
return m_supportedActions;
|
||||||
|
}
|
||||||
|
void DeclarativeDragArea::setSupportedActions(Qt::DropActions actions)
|
||||||
|
{
|
||||||
|
if (actions != m_supportedActions) {
|
||||||
|
m_supportedActions = actions;
|
||||||
|
emit supportedActionsChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// default action
|
||||||
|
Qt::DropAction DeclarativeDragArea::defaultAction() const
|
||||||
|
{
|
||||||
|
return m_defaultAction;
|
||||||
|
}
|
||||||
|
void DeclarativeDragArea::setDefaultAction(Qt::DropAction action)
|
||||||
|
{
|
||||||
|
if (action != m_defaultAction) {
|
||||||
|
m_defaultAction = action;
|
||||||
|
emit defaultActionChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DeclarativeDragArea::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
||||||
|
{
|
||||||
|
if ( !m_enabled
|
||||||
|
|| QLineF(event->screenPos(), event->buttonDownScreenPos(Qt::LeftButton)).length()
|
||||||
|
< QApplication::startDragDistance()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDrag *drag = new QDrag(event->widget());
|
||||||
|
DeclarativeMimeData* dataCopy = new DeclarativeMimeData(m_data); //Qt will take ownership of this copy and delete it.
|
||||||
|
drag->setMimeData(dataCopy);
|
||||||
|
|
||||||
|
if (m_delegate) {
|
||||||
|
|
||||||
|
// Render the delegate to a Pixmap
|
||||||
|
|
||||||
|
QDeclarativeItem* item = qobject_cast<QDeclarativeItem *>(m_delegate->create());
|
||||||
|
|
||||||
|
QGraphicsScene scene;
|
||||||
|
scene.addItem(item);
|
||||||
|
|
||||||
|
QPixmap pixmap(scene.sceneRect().width(), scene.sceneRect().height());
|
||||||
|
pixmap.fill(Qt::transparent);
|
||||||
|
|
||||||
|
QPainter painter(&pixmap);
|
||||||
|
painter.setRenderHint(QPainter::Antialiasing);
|
||||||
|
scene.render(&painter);
|
||||||
|
|
||||||
|
drag->setPixmap(pixmap);
|
||||||
|
drag->setHotSpot(QPoint(0, 0)); // TODO: Make a property for that
|
||||||
|
}
|
||||||
|
|
||||||
|
//setCursor(Qt::OpenHandCursor); //TODO? Make a property for the cursor
|
||||||
|
|
||||||
|
Qt::DropAction action = drag->exec(m_supportedActions, m_defaultAction);
|
||||||
|
emit drop(action);
|
||||||
|
}
|
95
declarativeimports/draganddrop/DeclarativeDragArea.h
Normal file
95
declarativeimports/draganddrop/DeclarativeDragArea.h
Normal file
@ -0,0 +1,95 @@
|
|||||||
|
/*
|
||||||
|
Copyright (C) 2010 by BetterInbox <contact@betterinbox.com>
|
||||||
|
Original author: Gregory Schlomoff <greg@betterinbox.com>
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef DECLARATIVEDRAGAREA_H
|
||||||
|
#define DECLARATIVEDRAGAREA_H
|
||||||
|
|
||||||
|
#include <QDeclarativeItem>
|
||||||
|
|
||||||
|
class QDeclarativeComponent;
|
||||||
|
class DeclarativeMimeData;
|
||||||
|
|
||||||
|
class DeclarativeDragArea : public QDeclarativeItem
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
Q_PROPERTY(QDeclarativeComponent* delegate READ delegate WRITE setDelegate NOTIFY delegateChanged RESET resetDelegate)
|
||||||
|
Q_PROPERTY(QDeclarativeItem* source READ source WRITE setSource NOTIFY sourceChanged RESET resetSource)
|
||||||
|
Q_PROPERTY(QDeclarativeItem* target READ source NOTIFY targetChanged)
|
||||||
|
Q_PROPERTY(DeclarativeMimeData* data READ data CONSTANT)
|
||||||
|
Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged) //TODO: Should call setAcceptDrops()
|
||||||
|
Q_PROPERTY(Qt::DropActions supportedActions READ supportedActions WRITE setSupportedActions NOTIFY supportedActionsChanged)
|
||||||
|
Q_PROPERTY(Qt::DropAction defaultAction READ defaultAction WRITE setDefaultAction NOTIFY defaultActionChanged)
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
DeclarativeDragArea(QDeclarativeItem *parent=0);
|
||||||
|
~DeclarativeDragArea();
|
||||||
|
|
||||||
|
QDeclarativeComponent *delegate() const;
|
||||||
|
void setDelegate(QDeclarativeComponent* delegate);
|
||||||
|
void resetDelegate();
|
||||||
|
|
||||||
|
QDeclarativeItem* target() const;
|
||||||
|
QDeclarativeItem* source() const;
|
||||||
|
void setSource(QDeclarativeItem* source);
|
||||||
|
void resetSource();
|
||||||
|
|
||||||
|
bool isEnabled() const;
|
||||||
|
void setEnabled(bool enabled);
|
||||||
|
|
||||||
|
//supported actions
|
||||||
|
Qt::DropActions supportedActions() const;
|
||||||
|
void setSupportedActions(Qt::DropActions actions);
|
||||||
|
|
||||||
|
//default action
|
||||||
|
Qt::DropAction defaultAction() const;
|
||||||
|
void setDefaultAction(Qt::DropAction action);
|
||||||
|
|
||||||
|
DeclarativeMimeData* data() const;
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void delegateChanged();
|
||||||
|
void sourceChanged();
|
||||||
|
void targetChanged();
|
||||||
|
void dataChanged();
|
||||||
|
void enabledChanged();
|
||||||
|
void drop(int action);
|
||||||
|
void supportedActionsChanged();
|
||||||
|
void defaultActionChanged();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
|
||||||
|
void mousePressEvent(QGraphicsSceneMouseEvent *) {}
|
||||||
|
void mouseReleaseEvent(QGraphicsSceneMouseEvent *) {}
|
||||||
|
|
||||||
|
private:
|
||||||
|
QDeclarativeComponent* m_delegate;
|
||||||
|
QDeclarativeItem* m_source;
|
||||||
|
QDeclarativeItem* m_target;
|
||||||
|
bool m_enabled;
|
||||||
|
Qt::DropActions m_supportedActions;
|
||||||
|
Qt::DropAction m_defaultAction;
|
||||||
|
DeclarativeMimeData* const m_data;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // DECLARATIVEDRAGAREA_H
|
42
declarativeimports/draganddrop/DeclarativeDragDropEvent.cpp
Normal file
42
declarativeimports/draganddrop/DeclarativeDragDropEvent.cpp
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
/*
|
||||||
|
Copyright (C) 2010 by BetterInbox <contact@betterinbox.com>
|
||||||
|
Original author: Gregory Schlomoff <greg@betterinbox.com>
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "DeclarativeDragDropEvent.h"
|
||||||
|
|
||||||
|
DeclarativeDragDropEvent::DeclarativeDragDropEvent(QGraphicsSceneDragDropEvent* e, QObject* parent) :
|
||||||
|
QObject(parent),
|
||||||
|
m_x(e->pos().x()),
|
||||||
|
m_y(e->pos().y()),
|
||||||
|
m_buttons(e->buttons()),
|
||||||
|
m_modifiers(e->modifiers()),
|
||||||
|
m_data(e->mimeData()),
|
||||||
|
m_event(e)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void DeclarativeDragDropEvent::accept(int action)
|
||||||
|
{
|
||||||
|
m_event->setDropAction( (Qt::DropAction) action );
|
||||||
|
m_event->accept();
|
||||||
|
}
|
66
declarativeimports/draganddrop/DeclarativeDragDropEvent.h
Normal file
66
declarativeimports/draganddrop/DeclarativeDragDropEvent.h
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
/*
|
||||||
|
Copyright (C) 2010 by BetterInbox <contact@betterinbox.com>
|
||||||
|
Original author: Gregory Schlomoff <greg@betterinbox.com>
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef DECLARATIVEDRAGDROPEVENT_H
|
||||||
|
#define DECLARATIVEDRAGDROPEVENT_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <QGraphicsSceneDragDropEvent>
|
||||||
|
#include "DeclarativeMimeData.h"
|
||||||
|
|
||||||
|
class DeclarativeDragDropEvent : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
Q_PROPERTY(int x READ x)
|
||||||
|
Q_PROPERTY(int y READ y)
|
||||||
|
Q_PROPERTY(int buttons READ buttons)
|
||||||
|
Q_PROPERTY(int modifiers READ modifiers)
|
||||||
|
Q_PROPERTY(DeclarativeMimeData* data READ data)
|
||||||
|
Q_PROPERTY(Qt::DropActions possibleActions READ possibleActions)
|
||||||
|
Q_PROPERTY(Qt::DropAction proposedAction READ proposedAction)
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
DeclarativeDragDropEvent(QGraphicsSceneDragDropEvent* e, QObject* parent = 0);
|
||||||
|
|
||||||
|
int x() const { return m_x; }
|
||||||
|
int y() const { return m_y; }
|
||||||
|
int buttons() const { return m_buttons; }
|
||||||
|
int modifiers() const { return m_modifiers; }
|
||||||
|
DeclarativeMimeData* data() { return &m_data; }
|
||||||
|
Qt::DropAction proposedAction() const { return m_event->proposedAction(); }
|
||||||
|
Qt::DropActions possibleActions() const { return m_event->possibleActions(); }
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void accept(int action);
|
||||||
|
|
||||||
|
private:
|
||||||
|
int m_x;
|
||||||
|
int m_y;
|
||||||
|
Qt::MouseButtons m_buttons;
|
||||||
|
Qt::KeyboardModifiers m_modifiers;
|
||||||
|
DeclarativeMimeData m_data;
|
||||||
|
QGraphicsSceneDragDropEvent* m_event;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // DECLARATIVEDRAGDROPEVENT_H
|
68
declarativeimports/draganddrop/DeclarativeDropArea.cpp
Normal file
68
declarativeimports/draganddrop/DeclarativeDropArea.cpp
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
/*
|
||||||
|
Copyright (C) 2010 by BetterInbox <contact@betterinbox.com>
|
||||||
|
Original author: Gregory Schlomoff <greg@betterinbox.com>
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "DeclarativeDropArea.h"
|
||||||
|
#include "DeclarativeDragDropEvent.h"
|
||||||
|
|
||||||
|
#include <QGraphicsSceneDragDropEvent>
|
||||||
|
#include <QMimeData>
|
||||||
|
|
||||||
|
DeclarativeDropArea::DeclarativeDropArea(QDeclarativeItem *parent)
|
||||||
|
: QDeclarativeItem(parent),
|
||||||
|
m_enabled(true)
|
||||||
|
{
|
||||||
|
setAcceptDrops(m_enabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DeclarativeDropArea::dragEnterEvent(QGraphicsSceneDragDropEvent *event) {
|
||||||
|
DeclarativeDragDropEvent dde(event, this);
|
||||||
|
emit dragEnter(&dde);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DeclarativeDropArea::dragLeaveEvent(QGraphicsSceneDragDropEvent *event)
|
||||||
|
{
|
||||||
|
DeclarativeDragDropEvent dde(event, this);
|
||||||
|
emit dragLeave(&dde);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DeclarativeDropArea::dropEvent(QGraphicsSceneDragDropEvent *event)
|
||||||
|
{
|
||||||
|
DeclarativeDragDropEvent dde(event, this);
|
||||||
|
emit drop(&dde);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DeclarativeDropArea::isEnabled() const
|
||||||
|
{
|
||||||
|
return m_enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DeclarativeDropArea::setEnabled(bool enabled)
|
||||||
|
{
|
||||||
|
if (enabled == m_enabled) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_enabled = enabled;
|
||||||
|
setAcceptDrops(m_enabled);
|
||||||
|
emit enabledChanged();
|
||||||
|
}
|
57
declarativeimports/draganddrop/DeclarativeDropArea.h
Normal file
57
declarativeimports/draganddrop/DeclarativeDropArea.h
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
/*
|
||||||
|
Copyright (C) 2010 by BetterInbox <contact@betterinbox.com>
|
||||||
|
Original author: Gregory Schlomoff <greg@betterinbox.com>
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef DECLARATIVEDROPAREA_H
|
||||||
|
#define DECLARATIVEDROPAREA_H
|
||||||
|
|
||||||
|
#include <QDeclarativeItem>
|
||||||
|
|
||||||
|
class DeclarativeDragDropEvent;
|
||||||
|
|
||||||
|
class DeclarativeDropArea : public QDeclarativeItem
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged)
|
||||||
|
|
||||||
|
public:
|
||||||
|
DeclarativeDropArea(QDeclarativeItem *parent=0);
|
||||||
|
bool isEnabled() const;
|
||||||
|
void setEnabled(bool enabled);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void dragEnter(DeclarativeDragDropEvent* event);
|
||||||
|
void dragLeave(DeclarativeDragDropEvent* event);
|
||||||
|
void drop(DeclarativeDragDropEvent* event);
|
||||||
|
void enabledChanged();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void dragEnterEvent(QGraphicsSceneDragDropEvent *event);
|
||||||
|
void dragLeaveEvent(QGraphicsSceneDragDropEvent *event);
|
||||||
|
void dropEvent(QGraphicsSceneDragDropEvent *event);
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool m_enabled;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
121
declarativeimports/draganddrop/DeclarativeMimeData.cpp
Normal file
121
declarativeimports/draganddrop/DeclarativeMimeData.cpp
Normal file
@ -0,0 +1,121 @@
|
|||||||
|
/*
|
||||||
|
Copyright (C) 2010 by BetterInbox <contact@betterinbox.com>
|
||||||
|
Original author: Gregory Schlomoff <greg@betterinbox.com>
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "DeclarativeMimeData.h"
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\qmlclass MimeData DeclarativeMimeData
|
||||||
|
|
||||||
|
This is a wrapper class around QMimeData, with a few extensions to provide better support for in-qml drag & drops.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\internal
|
||||||
|
\class DeclarativeMimeData
|
||||||
|
|
||||||
|
Creates a new DeclarativeMimeData by cloning the QMimeData passed as parameter.
|
||||||
|
This is useful for two reasons :
|
||||||
|
- In DragArea, we want to clone our "working copy" of the DeclarativeMimeData instance, as Qt will automatically
|
||||||
|
delete it after the drag and drop operation.
|
||||||
|
- In the drop events, the QMimeData is const, and we have troubles passing const to QML. So we clone it to
|
||||||
|
remove the "constness"
|
||||||
|
|
||||||
|
This method will try to cast the QMimeData to DeclarativeMimeData, and will clone our extensions to QMimeData as well
|
||||||
|
*/
|
||||||
|
DeclarativeMimeData::DeclarativeMimeData(const QMimeData* copy)
|
||||||
|
: QMimeData(),
|
||||||
|
m_source(0)
|
||||||
|
{
|
||||||
|
// Copy the standard MIME data
|
||||||
|
foreach(QString format, copy->formats()) {
|
||||||
|
this->setData(format, copy->data(format));
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the object we are copying actually is a DeclarativeMimeData, copy our extended properties as well
|
||||||
|
const DeclarativeMimeData* declarativeMimeData = qobject_cast<const DeclarativeMimeData*>(copy);
|
||||||
|
if (declarativeMimeData) {
|
||||||
|
this->setSource(declarativeMimeData->source());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\qmlproperty url MimeData::url
|
||||||
|
|
||||||
|
Returns the first URL from the urls property of QMimeData
|
||||||
|
TODO: We should use QDeclarativeListProperty<QUrls> to return the whole list instead of only the first element.
|
||||||
|
*/
|
||||||
|
QUrl DeclarativeMimeData::url() const
|
||||||
|
{
|
||||||
|
if ( this->hasUrls() && !this->urls().isEmpty()) {
|
||||||
|
return urls().first();
|
||||||
|
}
|
||||||
|
return QUrl();
|
||||||
|
}
|
||||||
|
void DeclarativeMimeData::setUrl(const QUrl &url)
|
||||||
|
{
|
||||||
|
if (this->url() == url)
|
||||||
|
return;
|
||||||
|
|
||||||
|
QList<QUrl> urlList;
|
||||||
|
urlList.append(url);
|
||||||
|
setUrls(urlList);
|
||||||
|
emit urlChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
// color
|
||||||
|
QColor DeclarativeMimeData::color() const
|
||||||
|
{
|
||||||
|
if ( this->hasColor()) {
|
||||||
|
return qvariant_cast<QColor>(this->colorData());
|
||||||
|
}
|
||||||
|
return QColor();
|
||||||
|
}
|
||||||
|
void DeclarativeMimeData::setColor(const QColor &color)
|
||||||
|
{
|
||||||
|
if (this->color() != color) {
|
||||||
|
this->setColorData(color);
|
||||||
|
emit colorChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\qmlproperty item MimeData::source
|
||||||
|
|
||||||
|
Setting source to any existing qml item will enable the receiver of the drag and drop operation to know in which item
|
||||||
|
the operation originated.
|
||||||
|
|
||||||
|
In the case of inter-application drag and drop operations, the source will not be available, and will be 0.
|
||||||
|
Be sure to test it in your QML code, before using it, or it will generate errors in the console.
|
||||||
|
*/
|
||||||
|
QDeclarativeItem* DeclarativeMimeData::source() const
|
||||||
|
{
|
||||||
|
return m_source;
|
||||||
|
}
|
||||||
|
void DeclarativeMimeData::setSource(QDeclarativeItem* source)
|
||||||
|
{
|
||||||
|
if (m_source != source) {
|
||||||
|
m_source = source;
|
||||||
|
emit sourceChanged();
|
||||||
|
}
|
||||||
|
}
|
75
declarativeimports/draganddrop/DeclarativeMimeData.h
Normal file
75
declarativeimports/draganddrop/DeclarativeMimeData.h
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
/*
|
||||||
|
Copyright (C) 2010 by BetterInbox <contact@betterinbox.com>
|
||||||
|
Original author: Gregory Schlomoff <greg@betterinbox.com>
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef DECLARATIVEMIMEDATA_H
|
||||||
|
#define DECLARATIVEMIMEDATA_H
|
||||||
|
|
||||||
|
#include <QMimeData>
|
||||||
|
#include <QColor>
|
||||||
|
#include <QUrl>
|
||||||
|
#include <QDeclarativeItem>
|
||||||
|
|
||||||
|
class DeclarativeMimeData : public QMimeData
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged)
|
||||||
|
Q_PROPERTY(QString html READ html WRITE setHtml NOTIFY htmlChanged)
|
||||||
|
Q_PROPERTY(QUrl url READ url WRITE setUrl NOTIFY urlChanged) //TODO: use QDeclarativeListProperty<QUrls> to return the whole list instead of only the first url
|
||||||
|
Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
|
||||||
|
Q_PROPERTY(QDeclarativeItem* source READ source WRITE setSource NOTIFY sourceChanged)
|
||||||
|
//TODO: Image property
|
||||||
|
|
||||||
|
public:
|
||||||
|
DeclarativeMimeData() : QMimeData() {}
|
||||||
|
DeclarativeMimeData(const QMimeData* copy);
|
||||||
|
|
||||||
|
QUrl url() const;
|
||||||
|
void setUrl(const QUrl &url);
|
||||||
|
|
||||||
|
QColor color() const;
|
||||||
|
void setColor(const QColor &color);
|
||||||
|
|
||||||
|
QDeclarativeItem* source() const;
|
||||||
|
void setSource(QDeclarativeItem* source);
|
||||||
|
|
||||||
|
/*
|
||||||
|
QString text() const; //TODO: Reimplement this to issue the onChanged signals
|
||||||
|
void setText(const QString &text);
|
||||||
|
QString html() const;
|
||||||
|
void setHtml(const QString &html);
|
||||||
|
*/
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void textChanged(); //FIXME not being used
|
||||||
|
void htmlChanged(); //FIXME not being used
|
||||||
|
void urlChanged();
|
||||||
|
void colorChanged();
|
||||||
|
void sourceChanged();
|
||||||
|
|
||||||
|
private:
|
||||||
|
QDeclarativeItem* m_source;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // DECLARATIVEMIMEDATA_H
|
43
declarativeimports/draganddrop/draganddropplugin.cpp
Normal file
43
declarativeimports/draganddrop/draganddropplugin.cpp
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2011 by Marco Martin <mart@kde.org>
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "draganddropplugin.h"
|
||||||
|
|
||||||
|
#include <QtDeclarative/qdeclarative.h>
|
||||||
|
|
||||||
|
#include "DeclarativeDragArea.h"
|
||||||
|
#include "DeclarativeDragDropEvent.h"
|
||||||
|
#include "DeclarativeDropArea.h"
|
||||||
|
#include "DeclarativeMimeData.h"
|
||||||
|
|
||||||
|
void DragAndDropPlugin::registerTypes(const char *uri)
|
||||||
|
{
|
||||||
|
Q_ASSERT(uri == QLatin1String("org.kde.draganddrop"));
|
||||||
|
|
||||||
|
qmlRegisterType<DeclarativeDropArea>(uri, 1, 0, "DropArea");
|
||||||
|
qmlRegisterType<DeclarativeDragArea>(uri, 1, 0, "DragArea");
|
||||||
|
qmlRegisterUncreatableType<DeclarativeMimeData>(uri, 1, 0, "MimeData", "MimeData cannot be created from QML.");
|
||||||
|
qmlRegisterUncreatableType<DeclarativeDragDropEvent>(uri, 1, 0, "DragDropEvent", "DragDropEvent cannot be created from QML.");
|
||||||
|
}
|
||||||
|
|
||||||
|
Q_EXPORT_PLUGIN2(draganddropplugin, DragAndDropPlugin)
|
||||||
|
|
36
declarativeimports/draganddrop/draganddropplugin.h
Normal file
36
declarativeimports/draganddrop/draganddropplugin.h
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2011 by Marco Martin <mart@kde.org>
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef DRAGANDDROPPLUGIN_H
|
||||||
|
#define DRAGANDDROPPLUGIN_H
|
||||||
|
|
||||||
|
#include <QDeclarativeExtensionPlugin>
|
||||||
|
|
||||||
|
class DragAndDropPlugin : public QDeclarativeExtensionPlugin
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
void registerTypes(const char *uri);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
2
declarativeimports/draganddrop/qmldir
Normal file
2
declarativeimports/draganddrop/qmldir
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
plugin draganddropplugin
|
||||||
|
|
@ -1,76 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2010 by Anselmo Lacerda Silveira de Melo <anselmolsm@gmail.com>
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Library General Public License as
|
|
||||||
* published by the Free Software Foundation; either version 2, 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 Library 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import Qt 4.7
|
|
||||||
import org.kde.plasma.core 0.1 as PlasmaCore
|
|
||||||
|
|
||||||
Item {
|
|
||||||
id: root
|
|
||||||
width: 200
|
|
||||||
height: 100
|
|
||||||
|
|
||||||
//API
|
|
||||||
property bool autohide: false
|
|
||||||
//### get font from theme when available
|
|
||||||
//### deal with QFont stuff in a proper way
|
|
||||||
property string font: "Arial"
|
|
||||||
property string color: theme.textColor
|
|
||||||
property int duration: 3000
|
|
||||||
|
|
||||||
/*### actually the FlashingLabel in C++ doesn't have
|
|
||||||
this as part of its API, either text or pixmap is
|
|
||||||
set only when flash is called.*/
|
|
||||||
property string text: ""
|
|
||||||
|
|
||||||
//###
|
|
||||||
PlasmaCore.Theme {
|
|
||||||
id: theme
|
|
||||||
}
|
|
||||||
|
|
||||||
Text {
|
|
||||||
id: label
|
|
||||||
text: root.text
|
|
||||||
color: root.color
|
|
||||||
font.family: root.font
|
|
||||||
horizontalAlignment: Text.AlignHCenter
|
|
||||||
verticalAlignment: Text.AlignVCenter
|
|
||||||
anchors.verticalCenter: root.verticalCenter
|
|
||||||
anchors.horizontalCenter: root.horizontalCenter
|
|
||||||
}
|
|
||||||
|
|
||||||
PropertyAnimation {
|
|
||||||
id: fade
|
|
||||||
target: label;
|
|
||||||
property: "opacity";
|
|
||||||
duration: root.duration;
|
|
||||||
to: 0
|
|
||||||
}
|
|
||||||
|
|
||||||
function flash(text, duration, alignment) {
|
|
||||||
if (text)
|
|
||||||
root.text = text
|
|
||||||
if (duration)
|
|
||||||
root.duration = duration
|
|
||||||
if (alignment)
|
|
||||||
label.horizontalAlignment = alignment
|
|
||||||
fade.start()
|
|
||||||
}
|
|
||||||
|
|
||||||
//###TODO: flash pixmap
|
|
||||||
}
|
|
@ -1,47 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010 Marco Martin <notmart@gmail.com>
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Library General Public License as
|
|
||||||
* published by the Free Software Foundation; either version 2, 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 Library 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.
|
|
||||||
*/
|
|
||||||
import Qt 4.7
|
|
||||||
import org.kde.plasma.core 0.1 as PlasmaCore
|
|
||||||
|
|
||||||
PlasmaCore.FrameSvgItem {
|
|
||||||
id : background
|
|
||||||
imagePath: "widgets/frame"
|
|
||||||
prefix: "plain"
|
|
||||||
|
|
||||||
width: childrenRect.width
|
|
||||||
height: childrenRect.height
|
|
||||||
|
|
||||||
property alias padding: paddingRectangle;
|
|
||||||
signal clicked;
|
|
||||||
|
|
||||||
Item {
|
|
||||||
id: paddingRectangle
|
|
||||||
anchors.fill: parent
|
|
||||||
anchors.leftMargin: background.margins.left
|
|
||||||
anchors.topMargin: background.margins.top
|
|
||||||
anchors.rightMargin: background.margins.right
|
|
||||||
anchors.bottomMargin: background.margins.bottom
|
|
||||||
}
|
|
||||||
|
|
||||||
MouseArea {
|
|
||||||
id: itemMouse
|
|
||||||
anchors.fill: background
|
|
||||||
onClicked: background.clicked()
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,97 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2010 by Artur Duque de Souza <asouzakde.org>
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Library General Public License as
|
|
||||||
* published by the Free Software Foundation; either version 2, 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 Library 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import Qt 4.7
|
|
||||||
import org.kde.plasma.core 0.1 as PlasmaCore
|
|
||||||
|
|
||||||
Item {
|
|
||||||
id: root
|
|
||||||
width: 100; height: 100
|
|
||||||
|
|
||||||
property string text: ""
|
|
||||||
property string infoText: ""
|
|
||||||
|
|
||||||
property string svg: ""
|
|
||||||
property string icon: ""
|
|
||||||
|
|
||||||
property bool drawBackground: true
|
|
||||||
property int numDisplayLines: 1
|
|
||||||
//property QColor textBackgroundColor: ""
|
|
||||||
|
|
||||||
signal pressed(bool down)
|
|
||||||
signal clicked()
|
|
||||||
signal doubleClicked()
|
|
||||||
signal activated()
|
|
||||||
signal changed()
|
|
||||||
|
|
||||||
PlasmaCore.Theme {
|
|
||||||
id: theme
|
|
||||||
}
|
|
||||||
|
|
||||||
PlasmaCore.FrameSvgItem {
|
|
||||||
id: background
|
|
||||||
visible: root.drawBackground
|
|
||||||
anchors.fill: root
|
|
||||||
|
|
||||||
imagePath: "widgets/viewitem"
|
|
||||||
prefix: mainMouseArea.pressed == true ? "selected" : "hover"
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
PlasmaCore.SvgItem {
|
|
||||||
id: svg
|
|
||||||
visible: root.svg != ""
|
|
||||||
width: root.width - label.height
|
|
||||||
height: root.height - label.height
|
|
||||||
anchors.horizontalCenter: root.horizontalCenter
|
|
||||||
svg: PlasmaCore.Svg { imagePath: root.svg }
|
|
||||||
|
|
||||||
// if you need to do anything while repainting
|
|
||||||
// do it inside this slot
|
|
||||||
function update() {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Image {
|
|
||||||
id: icon
|
|
||||||
visible: root.icon != ""
|
|
||||||
width: root.width - label.height
|
|
||||||
height: root.height - label.height
|
|
||||||
}
|
|
||||||
|
|
||||||
Text {
|
|
||||||
id: label
|
|
||||||
text: root.text
|
|
||||||
color: theme.textColor
|
|
||||||
anchors.top: icon.bottom
|
|
||||||
anchors.horizontalCenter: root.horizontalCenter
|
|
||||||
}
|
|
||||||
|
|
||||||
MouseArea {
|
|
||||||
id: mainMouseArea
|
|
||||||
hoverEnabled: true
|
|
||||||
anchors.fill: parent
|
|
||||||
|
|
||||||
onEntered: {
|
|
||||||
}
|
|
||||||
|
|
||||||
onExited: {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,95 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2010 by Marco Martin <mart@kde.org>
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Library General Public License as
|
|
||||||
* published by the Free Software Foundation; either version 2, 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 Library 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import Qt 4.7
|
|
||||||
import org.kde.plasma.core 0.1 as PlasmaCore
|
|
||||||
|
|
||||||
Item {
|
|
||||||
width: 50
|
|
||||||
height:20
|
|
||||||
|
|
||||||
property string text
|
|
||||||
signal clicked
|
|
||||||
|
|
||||||
id: button
|
|
||||||
PlasmaCore.FrameSvgItem {
|
|
||||||
id: hover
|
|
||||||
anchors.fill: parent
|
|
||||||
opacity: 0
|
|
||||||
anchors.leftMargin: -margins.left
|
|
||||||
anchors.topMargin: -margins.top
|
|
||||||
anchors.rightMargin: -margins.right
|
|
||||||
anchors.bottomMargin: -margins.bottom
|
|
||||||
imagePath: "widgets/button"
|
|
||||||
prefix: "hover"
|
|
||||||
Behavior on opacity {
|
|
||||||
PropertyAnimation { duration: 250 }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
PlasmaCore.FrameSvgItem {
|
|
||||||
id: shadow
|
|
||||||
anchors.fill: parent
|
|
||||||
anchors.leftMargin: -margins.left
|
|
||||||
anchors.topMargin: -margins.top
|
|
||||||
anchors.rightMargin: -margins.right
|
|
||||||
anchors.bottomMargin: -margins.bottom
|
|
||||||
imagePath: "widgets/button"
|
|
||||||
prefix: "shadow"
|
|
||||||
Behavior on opacity {
|
|
||||||
PropertyAnimation { duration: 250 }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
PlasmaCore.FrameSvgItem {
|
|
||||||
id: surface
|
|
||||||
anchors.fill: parent
|
|
||||||
imagePath: "widgets/button"
|
|
||||||
prefix: "normal"
|
|
||||||
}
|
|
||||||
|
|
||||||
Text {
|
|
||||||
text: button.text
|
|
||||||
anchors.fill: parent
|
|
||||||
horizontalAlignment: Text.AlignHCenter
|
|
||||||
verticalAlignment: Text.AlignVCenter
|
|
||||||
}
|
|
||||||
|
|
||||||
MouseArea {
|
|
||||||
anchors.fill: parent
|
|
||||||
hoverEnabled: true
|
|
||||||
|
|
||||||
onPressed: {
|
|
||||||
surface.prefix = "pressed"
|
|
||||||
}
|
|
||||||
onReleased: {
|
|
||||||
surface.prefix = "normal"
|
|
||||||
button.clicked()
|
|
||||||
}
|
|
||||||
onEntered: {
|
|
||||||
shadow.opacity = 0
|
|
||||||
hover.opacity = 1
|
|
||||||
}
|
|
||||||
onExited: {
|
|
||||||
shadow.opacity = 1
|
|
||||||
hover.opacity = 0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,79 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2010 by Marco Martin <mart@kde.org>
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Library General Public License as
|
|
||||||
* published by the Free Software Foundation; either version 2, 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 Library 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import Qt 4.7
|
|
||||||
import org.kde.plasma.core 0.1 as PlasmaCore
|
|
||||||
|
|
||||||
Item {
|
|
||||||
width: 50
|
|
||||||
height:20
|
|
||||||
|
|
||||||
property string text
|
|
||||||
property bool down: false
|
|
||||||
signal clicked
|
|
||||||
|
|
||||||
id: button
|
|
||||||
|
|
||||||
PlasmaCore.FrameSvgItem {
|
|
||||||
id: surface
|
|
||||||
anchors.fill: parent
|
|
||||||
imagePath: "widgets/button"
|
|
||||||
prefix: down?"pressed":"normal"
|
|
||||||
opacity: down?1:0
|
|
||||||
Behavior on opacity {
|
|
||||||
PropertyAnimation { duration: 250 }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Text {
|
|
||||||
text: button.text
|
|
||||||
anchors.fill: parent
|
|
||||||
horizontalAlignment: Text.AlignHCenter
|
|
||||||
verticalAlignment: Text.AlignVCenter
|
|
||||||
}
|
|
||||||
|
|
||||||
MouseArea {
|
|
||||||
anchors.fill: parent
|
|
||||||
hoverEnabled: true
|
|
||||||
|
|
||||||
onPressed: {
|
|
||||||
if (!down) {
|
|
||||||
surface.prefix = "pressed"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
onReleased: {
|
|
||||||
if (!down) {
|
|
||||||
surface.prefix = "normal"
|
|
||||||
}
|
|
||||||
button.clicked()
|
|
||||||
}
|
|
||||||
onEntered: {
|
|
||||||
if (!down) {
|
|
||||||
surface.opacity = 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
onExited: {
|
|
||||||
if (!down) {
|
|
||||||
surface.opacity = 0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -73,7 +73,7 @@ void QIconItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
|||||||
painter->setRenderHint(QPainter::Antialiasing, m_smooth);
|
painter->setRenderHint(QPainter::Antialiasing, m_smooth);
|
||||||
painter->setRenderHint(QPainter::SmoothPixmapTransform, m_smooth);
|
painter->setRenderHint(QPainter::SmoothPixmapTransform, m_smooth);
|
||||||
|
|
||||||
m_icon.paint(painter, boundingRect().toRect());
|
m_icon.paint(painter, boundingRect().toRect(), Qt::AlignCenter, isEnabled()?QIcon::Normal:QIcon::Disabled);
|
||||||
painter->setRenderHint(QPainter::Antialiasing, wasAntiAlias);
|
painter->setRenderHint(QPainter::Antialiasing, wasAntiAlias);
|
||||||
painter->setRenderHint(QPainter::SmoothPixmapTransform, wasSmoothTransform);
|
painter->setRenderHint(QPainter::SmoothPixmapTransform, wasSmoothTransform);
|
||||||
}
|
}
|
||||||
|
@ -1,29 +0,0 @@
|
|||||||
project(components_test)
|
|
||||||
|
|
||||||
find_package(KDE4 REQUIRED)
|
|
||||||
|
|
||||||
include(KDE4Defaults)
|
|
||||||
|
|
||||||
add_definitions (${QT_DEFINITIONS} ${KDE4_DEFINITIONS})
|
|
||||||
|
|
||||||
include_directories(
|
|
||||||
${CMAKE_SOURCE_DIR}
|
|
||||||
${CMAKE_BINARY_DIR}
|
|
||||||
${KDE4_INCLUDES}
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
set(components_test_TEST_SRCS
|
|
||||||
test.cpp)
|
|
||||||
|
|
||||||
kde4_add_executable(components_test ${components_test_TEST_SRCS})
|
|
||||||
|
|
||||||
target_link_libraries(components_test kdeclarative ${KDE4_KDECORE_LIBS} ${QT_QTDECLARATIVE_LIBRARY})
|
|
||||||
|
|
||||||
## install
|
|
||||||
|
|
||||||
|
|
||||||
install(TARGETS components_test EXPORT kdelibsLibraryTargets ${INSTALL_TARGETS_DEFAULT_ARGS})
|
|
||||||
|
|
||||||
|
|
||||||
install(FILES "gallery.qml" DESTINATION ${CMAKE_BINARY_DIR}/widgets/components)
|
|
@ -1,79 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2010 by Anselmo Lacerda Silveira de Melo <anselmolsm@gmail.com>
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Library General Public License as
|
|
||||||
* published by the Free Software Foundation; either version 2, 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 Library 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import Qt 4.7
|
|
||||||
import org.kde.plasma.components 0.1 as PlasmaComponents
|
|
||||||
import org.kde.plasma.core 0.1 as PlasmaCore
|
|
||||||
import org.kde.qtextracomponents 0.1 as QtExtraComponents
|
|
||||||
|
|
||||||
Rectangle {
|
|
||||||
id: test
|
|
||||||
width: 400
|
|
||||||
height: 500
|
|
||||||
color: "tomato"
|
|
||||||
|
|
||||||
Column {
|
|
||||||
x: 10
|
|
||||||
anchors.fill: parent
|
|
||||||
spacing: 5
|
|
||||||
|
|
||||||
PlasmaComponents.FlashingLabel {
|
|
||||||
id: label
|
|
||||||
font: "Times"
|
|
||||||
}
|
|
||||||
|
|
||||||
Row {
|
|
||||||
id: busyRow
|
|
||||||
|
|
||||||
Repeater {
|
|
||||||
model: 8
|
|
||||||
PlasmaComponents.BusyWidget {
|
|
||||||
width: 50
|
|
||||||
height: 50
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
PlasmaComponents.PushButton {
|
|
||||||
text: "Ok"
|
|
||||||
onClicked: {print("Clicked!"); scrollBar.value=35}
|
|
||||||
}
|
|
||||||
PlasmaComponents.ScrollBar {
|
|
||||||
id: scrollBar
|
|
||||||
}
|
|
||||||
PlasmaComponents.ScrollBar {
|
|
||||||
id: scrollBarV
|
|
||||||
orientation: Qt.Vertical
|
|
||||||
}
|
|
||||||
QtExtraComponents.QPixmapItem {
|
|
||||||
width:200
|
|
||||||
height:100
|
|
||||||
id: pixmapTest
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
PlasmaCore.Svg {
|
|
||||||
id: svgTest
|
|
||||||
imagePath: "widgets/clock"
|
|
||||||
}
|
|
||||||
Component.onCompleted: {
|
|
||||||
label.flash("I am a FlashingLabel!!!");
|
|
||||||
pixmapTest.pixmap = svgTest.pixmap();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,55 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2011 Marco Martin <mart@gmail.com>
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Library General Public License as
|
|
||||||
* published by the Free Software Foundation; either version 2, 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 Library 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 <QApplication>
|
|
||||||
#include <QDeclarativeView>
|
|
||||||
#include <QDeclarativeContext>
|
|
||||||
#include <QScriptEngine>
|
|
||||||
|
|
||||||
#include <kdeclarative.h>
|
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
|
||||||
{
|
|
||||||
QApplication app(argc, argv);
|
|
||||||
|
|
||||||
QDeclarativeView view;
|
|
||||||
QDeclarativeContext *context = view.rootContext();
|
|
||||||
context->setContextProperty("backgroundColor",
|
|
||||||
QColor(Qt::yellow));
|
|
||||||
|
|
||||||
KDeclarative kdeclarative;
|
|
||||||
kdeclarative.setDeclarativeEngine(view.engine());
|
|
||||||
kdeclarative.initialize();
|
|
||||||
//binds things like kconfig and icons
|
|
||||||
kdeclarative.setupBindings();
|
|
||||||
|
|
||||||
//If all gone well, the QScriptEngine has been extracted
|
|
||||||
QScriptEngine *scriptEngine = kdeclarative.scriptEngine();
|
|
||||||
Q_ASSERT(scriptEngine);
|
|
||||||
|
|
||||||
QScriptValue global = scriptEngine->globalObject();
|
|
||||||
|
|
||||||
view.setSource(QUrl::fromLocalFile("gallery.qml"));
|
|
||||||
view.show();
|
|
||||||
|
|
||||||
return app.exec();
|
|
||||||
}
|
|
||||||
|
|
||||||
#include "testobject_p.moc"
|
|
@ -1,49 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2011 Marco Martin <mart@gmail.com>
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Library General Public License as
|
|
||||||
* published by the Free Software Foundation; either version 2, 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 Library 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 TESTOBJECT_P_H
|
|
||||||
#define TESTOBJECT_P_H
|
|
||||||
|
|
||||||
#include <QObject>
|
|
||||||
|
|
||||||
class TestObject : public QObject
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
Q_PROPERTY(QString prop READ prop WRITE setProp NOTIFY propChanged)
|
|
||||||
|
|
||||||
public:
|
|
||||||
void setProp(const QString &prop)
|
|
||||||
{
|
|
||||||
m_prop = prop;
|
|
||||||
emit propChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
QString prop() const
|
|
||||||
{
|
|
||||||
return m_prop;
|
|
||||||
}
|
|
||||||
|
|
||||||
Q_SIGNALS:
|
|
||||||
void propChanged();
|
|
||||||
|
|
||||||
private:
|
|
||||||
QString m_prop;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,6 +1,8 @@
|
|||||||
[Desktop Entry]
|
[Desktop Entry]
|
||||||
Name=plasma-kpart
|
Name=plasma-kpart
|
||||||
Name[ast]=plasma-kpart
|
Name[ast]=plasma-kpart
|
||||||
|
Name[bg]=plasma-kpart
|
||||||
|
Name[bs]=plasma-kpart
|
||||||
Name[ca]=plasma-kpart
|
Name[ca]=plasma-kpart
|
||||||
Name[ca@valencia]=plasma-kpart
|
Name[ca@valencia]=plasma-kpart
|
||||||
Name[cs]=plasma-kpart
|
Name[cs]=plasma-kpart
|
||||||
@ -29,6 +31,7 @@ Name[lt]=plasma-kpart
|
|||||||
Name[nb]=plasma-kpart
|
Name[nb]=plasma-kpart
|
||||||
Name[nds]=Kpart för Plasma
|
Name[nds]=Kpart för Plasma
|
||||||
Name[nl]=plasma-kpart
|
Name[nl]=plasma-kpart
|
||||||
|
Name[nn]=plasma-kpart
|
||||||
Name[pa]=plasma-kpart
|
Name[pa]=plasma-kpart
|
||||||
Name[pl]=plasma-kpart
|
Name[pl]=plasma-kpart
|
||||||
Name[pt]=plasma-kpart
|
Name[pt]=plasma-kpart
|
||||||
@ -44,6 +47,7 @@ Name[sr@latin]=plasma-kpart
|
|||||||
Name[sv]=Plasma-delprogram
|
Name[sv]=Plasma-delprogram
|
||||||
Name[th]=plasma-kpart
|
Name[th]=plasma-kpart
|
||||||
Name[tr]=plasma-kpart
|
Name[tr]=plasma-kpart
|
||||||
|
Name[ug]=plasma-kpart
|
||||||
Name[uk]=plasma-kpart
|
Name[uk]=plasma-kpart
|
||||||
Name[wa]=plasma-kpårt
|
Name[wa]=plasma-kpårt
|
||||||
Name[x-test]=xxplasma-kpartxx
|
Name[x-test]=xxplasma-kpartxx
|
||||||
|
@ -22,8 +22,15 @@
|
|||||||
|
|
||||||
#include "plasmakpart.h"
|
#include "plasmakpart.h"
|
||||||
|
|
||||||
#include "plasmakpartcorona.h"
|
#include <QCheckBox>
|
||||||
#include "plasmakpartview.h"
|
#include <QFile>
|
||||||
|
#include <QHash>
|
||||||
|
#include <QGraphicsProxyWidget>
|
||||||
|
#include <QGraphicsLinearLayout>
|
||||||
|
#include <QTimer>
|
||||||
|
|
||||||
|
#include <KDebug>
|
||||||
|
#include <KStandardDirs>
|
||||||
|
|
||||||
#include <Plasma/Containment>
|
#include <Plasma/Containment>
|
||||||
#include <Plasma/Theme>
|
#include <Plasma/Theme>
|
||||||
@ -31,13 +38,8 @@
|
|||||||
#include <Plasma/Wallpaper>
|
#include <Plasma/Wallpaper>
|
||||||
#include <plasma/pluginloader.h>
|
#include <plasma/pluginloader.h>
|
||||||
|
|
||||||
#include <KDebug>
|
#include "plasmakpartcorona.h"
|
||||||
#include <KStandardDirs>
|
#include "plasmakpartview.h"
|
||||||
|
|
||||||
#include <QCheckBox>
|
|
||||||
#include <QHash>
|
|
||||||
#include <QGraphicsProxyWidget>
|
|
||||||
#include <QGraphicsLinearLayout>
|
|
||||||
|
|
||||||
K_PLUGIN_FACTORY(plasmaKPartFactory, registerPlugin<PlasmaKPart>();)
|
K_PLUGIN_FACTORY(plasmaKPartFactory, registerPlugin<PlasmaKPart>();)
|
||||||
K_EXPORT_PLUGIN(plasmaKPartFactory("plasma-kpart","plasma-kpart") )
|
K_EXPORT_PLUGIN(plasmaKPartFactory("plasma-kpart","plasma-kpart") )
|
||||||
@ -45,8 +47,7 @@ K_EXPORT_PLUGIN(plasmaKPartFactory("plasma-kpart","plasma-kpart") )
|
|||||||
PlasmaKPart::PlasmaKPart(QWidget *parentWidget, QObject *parent, const QVariantList &args)
|
PlasmaKPart::PlasmaKPart(QWidget *parentWidget, QObject *parent, const QVariantList &args)
|
||||||
: KParts::ReadOnlyPart(parent),
|
: KParts::ReadOnlyPart(parent),
|
||||||
m_corona(0),
|
m_corona(0),
|
||||||
m_view(new PlasmaKPartView(0, 1, parentWidget)),
|
m_view(new PlasmaKPartView(0, 1))
|
||||||
m_service(0)
|
|
||||||
{
|
{
|
||||||
setComponentData(plasmaKPartFactory::componentData());
|
setComponentData(plasmaKPartFactory::componentData());
|
||||||
|
|
||||||
@ -66,16 +67,24 @@ PlasmaKPart::PlasmaKPart(QWidget *parentWidget, QObject *parent, const QVariantL
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.length() > 1) {
|
setAutoDeletePart(false);
|
||||||
m_category = args.at(1).value<QString>();
|
QTimer::singleShot(0, this, SLOT(initCorona()));
|
||||||
}
|
|
||||||
|
|
||||||
// this line initializes the corona.
|
|
||||||
corona();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PlasmaKPart::~PlasmaKPart()
|
PlasmaKPart::~PlasmaKPart()
|
||||||
{
|
{
|
||||||
|
delete m_view;
|
||||||
|
m_view = 0;
|
||||||
|
|
||||||
|
if (!m_configFile.isEmpty()) {
|
||||||
|
m_corona->saveLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
delete m_corona;
|
||||||
|
m_corona = 0;
|
||||||
|
|
||||||
|
//TODO: This manual sync() should not be necessary?
|
||||||
|
syncConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlasmaKPart::setThemeDefaults()
|
void PlasmaKPart::setThemeDefaults()
|
||||||
@ -90,62 +99,35 @@ void PlasmaKPart::setThemeDefaults()
|
|||||||
Plasma::Theme::defaultTheme()->setFont(cg.readEntry("desktopFont", QFont("Sans") ));
|
Plasma::Theme::defaultTheme()->setFont(cg.readEntry("desktopFont", QFont("Sans") ));
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlasmaKPart::cleanup()
|
|
||||||
{
|
|
||||||
if (m_corona) {
|
|
||||||
m_corona->saveLayout();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!m_view->containment()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// save the mapping of Views to Containments at the moment
|
|
||||||
// of application exit so we can restore that when we start again.
|
|
||||||
KConfigGroup viewIds(KGlobal::config(), "ViewIds");
|
|
||||||
viewIds.deleteGroup();
|
|
||||||
viewIds.writeEntry(QString::number(m_view->containment()->id()), 1);
|
|
||||||
|
|
||||||
delete m_view;
|
|
||||||
m_view = 0;
|
|
||||||
|
|
||||||
delete m_corona;
|
|
||||||
m_corona = 0;
|
|
||||||
|
|
||||||
//TODO: This manual sync() should not be necessary?
|
|
||||||
syncConfig();
|
|
||||||
}
|
|
||||||
|
|
||||||
void PlasmaKPart::syncConfig()
|
void PlasmaKPart::syncConfig()
|
||||||
{
|
{
|
||||||
KGlobal::config()->sync();
|
KGlobal::config()->sync();
|
||||||
}
|
}
|
||||||
|
|
||||||
PlasmaKPartCorona* PlasmaKPart::corona()
|
void PlasmaKPart::initCorona()
|
||||||
{
|
{
|
||||||
if (!m_corona) {
|
if (m_corona) {
|
||||||
m_corona = new PlasmaKPartCorona(this);
|
return;
|
||||||
connect(m_corona, SIGNAL(containmentAdded(Plasma::Containment*)), this, SLOT(createView(Plasma::Containment*)));
|
|
||||||
connect(m_corona, SIGNAL(configSynced()), this, SLOT(syncConfig()));
|
|
||||||
|
|
||||||
m_corona->setItemIndexMethod(QGraphicsScene::NoIndex);
|
|
||||||
m_corona->initializeLayout();
|
|
||||||
|
|
||||||
m_view->show();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_corona = new PlasmaKPartCorona(this);
|
||||||
|
connect(m_corona, SIGNAL(containmentAdded(Plasma::Containment*)), this, SLOT(createView(Plasma::Containment*)));
|
||||||
|
connect(m_corona, SIGNAL(configSynced()), this, SLOT(syncConfig()));
|
||||||
|
|
||||||
|
m_corona->setItemIndexMethod(QGraphicsScene::NoIndex);
|
||||||
|
m_corona->initializeLayout(m_configFile);
|
||||||
|
|
||||||
|
m_view->show();
|
||||||
|
}
|
||||||
|
|
||||||
|
PlasmaKPartCorona* PlasmaKPart::corona() const
|
||||||
|
{
|
||||||
return m_corona;
|
return m_corona;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlasmaKPart::createView(Plasma::Containment *containment)
|
void PlasmaKPart::createView(Plasma::Containment *containment)
|
||||||
{
|
{
|
||||||
KConfigGroup viewIds(KGlobal::config(), "ViewIds");
|
|
||||||
int id = viewIds.readEntry(QString::number(containment->id()), 1);
|
|
||||||
|
|
||||||
kDebug() << "new containment" << (QObject*)containment << containment->id()<<"view id"<<id;
|
|
||||||
|
|
||||||
m_view->setContainment(containment);
|
m_view->setContainment(containment);
|
||||||
emit viewCreated();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlasmaKPart::addApplet(const QString& name, const QVariantList& args, const QRectF& geometry )
|
void PlasmaKPart::addApplet(const QString& name, const QVariantList& args, const QRectF& geometry )
|
||||||
@ -153,29 +135,27 @@ void PlasmaKPart::addApplet(const QString& name, const QVariantList& args, const
|
|||||||
containment()->addApplet(name, args, geometry);
|
containment()->addApplet(name, args, geometry);
|
||||||
}
|
}
|
||||||
|
|
||||||
Plasma::Applet::List PlasmaKPart::listActiveApplets( )
|
Plasma::Applet::List PlasmaKPart::listActiveApplets() const
|
||||||
{
|
{
|
||||||
return containment()->applets();
|
return containment()->applets();
|
||||||
}
|
}
|
||||||
|
|
||||||
Plasma::Containment* PlasmaKPart::containment()
|
QString PlasmaKPart::configFile() const
|
||||||
|
{
|
||||||
|
return m_configFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PlasmaKPart::setConfigFile(const QString &file)
|
||||||
|
{
|
||||||
|
m_configFile = file;
|
||||||
|
if (m_corona && QFile::exists(m_configFile)) {
|
||||||
|
m_corona->initializeLayout(m_configFile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Plasma::Containment* PlasmaKPart::containment() const
|
||||||
{
|
{
|
||||||
return corona()->containments().first();
|
return corona()->containments().first();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PlasmaKPart::setPluginLoader(Plasma::PluginLoader *loader)
|
|
||||||
{
|
|
||||||
if (Plasma::PluginLoader::pluginLoader()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
Plasma::PluginLoader::setPluginLoader(loader);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString PlasmaKPart::category()
|
|
||||||
{
|
|
||||||
return m_category;
|
|
||||||
}
|
|
||||||
|
|
||||||
#include "plasmakpart.moc"
|
#include "plasmakpart.moc"
|
||||||
|
@ -35,7 +35,6 @@ namespace Plasma
|
|||||||
}
|
}
|
||||||
|
|
||||||
#include <KDE/KParts/Part>
|
#include <KDE/KParts/Part>
|
||||||
#include <KDE/KService>
|
|
||||||
|
|
||||||
#include <QtCore/QHash>
|
#include <QtCore/QHash>
|
||||||
class QVariant;
|
class QVariant;
|
||||||
@ -45,16 +44,33 @@ class PlasmaKPart : public KParts::ReadOnlyPart
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(Plasma::Applet::List activeApplets READ listActiveApplets)
|
Q_PROPERTY(Plasma::Applet::List activeApplets READ listActiveApplets)
|
||||||
|
Q_PROPERTY(QString configFile READ configFile WRITE setConfigFile)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
/**
|
||||||
|
* The default constructor.
|
||||||
|
* The args may contain a pointer to a Plasma::PluginLoader as the first parameter.
|
||||||
|
* Note that only one Plasma::PluginLoader can be active at a time, and that the
|
||||||
|
* prefered mechanism for registering the plugin loader is via
|
||||||
|
* Plasma::PluginLoader::setPluginLoader
|
||||||
|
*/
|
||||||
PlasmaKPart(QWidget *parentWidget, QObject *parent, const QVariantList &args);
|
PlasmaKPart(QWidget *parentWidget, QObject *parent, const QVariantList &args);
|
||||||
~PlasmaKPart();
|
~PlasmaKPart();
|
||||||
|
|
||||||
void notifyStartup(bool completed);
|
void notifyStartup(bool completed);
|
||||||
|
|
||||||
PlasmaKPartCorona *corona();
|
PlasmaKPartCorona *corona() const;
|
||||||
Plasma::Containment *containment();
|
Plasma::Containment *containment() const;
|
||||||
QString category();
|
|
||||||
|
/**
|
||||||
|
* Returns a list of active applets in the containment.
|
||||||
|
*
|
||||||
|
* @return A list of the containment's Applets
|
||||||
|
**/
|
||||||
|
Plasma::Applet::List listActiveApplets() const;
|
||||||
|
|
||||||
|
QString configFile() const;
|
||||||
|
void setConfigFile(const QString &file);
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
/**
|
/**
|
||||||
@ -66,40 +82,8 @@ public Q_SLOTS:
|
|||||||
**/
|
**/
|
||||||
void addApplet(const QString &pluginName, const QVariantList &args = QVariantList(), const QRectF &dimensions = QRectF());
|
void addApplet(const QString &pluginName, const QVariantList &args = QVariantList(), const QRectF &dimensions = QRectF());
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the application-specific plugin loader. This allows
|
|
||||||
* applications which need to add internal applets (such
|
|
||||||
* as existing QWidget-based dashboard plugins), services or
|
|
||||||
* data engines to the Plasma dashboard. The preferred way to
|
|
||||||
* set this loader is by passing it to the KPart wrapped in a
|
|
||||||
* QVariant in the @p args parameter of the KPart constructor.
|
|
||||||
* This method is provided for applications which cannot set
|
|
||||||
* the loader in this method.
|
|
||||||
* The method will return false if Plasma already has a
|
|
||||||
* PluginLoader in memory, and will return true if the PluginLoader
|
|
||||||
* is successfully set.
|
|
||||||
*
|
|
||||||
* @param loader The loader which you want Plasma to query for
|
|
||||||
* new Applets, Data Engines and Services.
|
|
||||||
* @return True if the loader was successfully set, false otherwise
|
|
||||||
* (If Plasma already has a PluginLoader in memory)
|
|
||||||
*
|
|
||||||
* @short Set application-specific plugin loader
|
|
||||||
**/
|
|
||||||
bool setPluginLoader(Plasma::PluginLoader *loader);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a list of active applets in the containment.
|
|
||||||
*
|
|
||||||
* @return A list of the containment's Applets
|
|
||||||
**/
|
|
||||||
Plasma::Applet::List listActiveApplets();
|
|
||||||
|
|
||||||
Q_SIGNALS:
|
|
||||||
void viewCreated();
|
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void cleanup();
|
void initCorona();
|
||||||
void syncConfig();
|
void syncConfig();
|
||||||
void createView(Plasma::Containment* containment);
|
void createView(Plasma::Containment* containment);
|
||||||
void setThemeDefaults();
|
void setThemeDefaults();
|
||||||
@ -107,10 +91,9 @@ private Q_SLOTS:
|
|||||||
private:
|
private:
|
||||||
PlasmaKPartCorona* m_corona;
|
PlasmaKPartCorona* m_corona;
|
||||||
PlasmaKPartView* m_view;
|
PlasmaKPartView* m_view;
|
||||||
QString m_category;
|
|
||||||
KService::Ptr m_service;
|
|
||||||
QHash<QString,Plasma::Applet*>* m_appletList;
|
QHash<QString,Plasma::Applet*>* m_appletList;
|
||||||
QVBoxLayout* m_configLayout;
|
QVBoxLayout* m_configLayout;
|
||||||
|
QString m_configFile;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // multiple inclusion guard
|
#endif // multiple inclusion guard
|
||||||
|
@ -33,11 +33,6 @@
|
|||||||
|
|
||||||
PlasmaKPartCorona::PlasmaKPartCorona(QObject *parent)
|
PlasmaKPartCorona::PlasmaKPartCorona(QObject *parent)
|
||||||
: Plasma::Corona(parent)
|
: Plasma::Corona(parent)
|
||||||
{
|
|
||||||
init();
|
|
||||||
}
|
|
||||||
|
|
||||||
void PlasmaKPartCorona::init()
|
|
||||||
{
|
{
|
||||||
enableAction("Lock Widgets", false);
|
enableAction("Lock Widgets", false);
|
||||||
enableAction("Shortcut Settings", false);
|
enableAction("Shortcut Settings", false);
|
||||||
@ -47,7 +42,6 @@ void PlasmaKPartCorona::init()
|
|||||||
void PlasmaKPartCorona::loadDefaultLayout()
|
void PlasmaKPartCorona::loadDefaultLayout()
|
||||||
{
|
{
|
||||||
// used to force a save into the config file
|
// used to force a save into the config file
|
||||||
KConfigGroup invalidConfig;
|
|
||||||
Plasma::Containment *c = addContainment(QString());
|
Plasma::Containment *c = addContainment(QString());
|
||||||
|
|
||||||
if (!c) {
|
if (!c) {
|
||||||
@ -85,15 +79,4 @@ void PlasmaKPartCorona::printScriptMessage(const QString &error)
|
|||||||
kDebug() << "Startup script: " << error;
|
kDebug() << "Startup script: " << error;
|
||||||
}
|
}
|
||||||
|
|
||||||
Plasma::Containment* PlasmaKPartCorona::containment()
|
|
||||||
{
|
|
||||||
// We only have one containment, so just try and return the first one
|
|
||||||
QList<Plasma::Containment*> list = containments();
|
|
||||||
if (!list.isEmpty()) {
|
|
||||||
return list.first();
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#include "plasmakpartcorona.moc"
|
#include "plasmakpartcorona.moc"
|
||||||
|
@ -38,13 +38,9 @@ Q_OBJECT
|
|||||||
public:
|
public:
|
||||||
PlasmaKPartCorona(QObject* parent);
|
PlasmaKPartCorona(QObject* parent);
|
||||||
|
|
||||||
Plasma::Containment *containment();
|
protected:
|
||||||
|
|
||||||
void loadDefaultLayout();
|
void loadDefaultLayout();
|
||||||
|
|
||||||
private:
|
|
||||||
void evaluateScripts(const QStringList &scripts);
|
void evaluateScripts(const QStringList &scripts);
|
||||||
void init();
|
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void printScriptError(const QString &error);
|
void printScriptError(const QString &error);
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
Name=Save remote widgets' policies
|
Name=Save remote widgets' policies
|
||||||
Name[ar]=احفظ سياسات الودجات البعيدة
|
Name[ar]=احفظ سياسات الودجات البعيدة
|
||||||
Name[ast]=Guardáu de polítiques d'elementos gráficos remotos
|
Name[ast]=Guardáu de polítiques d'elementos gráficos remotos
|
||||||
|
Name[bg]=Запазване на правилата на отдалечените джаджи
|
||||||
|
Name[bs]=Sačuvaj smjernice za udaljene grafičke kontrole
|
||||||
Name[ca]=Desa les polítiques d'estris remots
|
Name[ca]=Desa les polítiques d'estris remots
|
||||||
Name[ca@valencia]=Alça les polítiques d'estris remots
|
Name[ca@valencia]=Alça les polítiques d'estris remots
|
||||||
Name[cs]=Uložit zásady vzdálených widgetů
|
Name[cs]=Uložit zásady vzdálených widgetů
|
||||||
@ -13,13 +15,14 @@ Name[es]=Guardado de políticas de elementos gráficos remotos
|
|||||||
Name[et]=Välisvidinate reeglite salvestamine
|
Name[et]=Välisvidinate reeglite salvestamine
|
||||||
Name[eu]=Gorde urruneko trepeten politikak
|
Name[eu]=Gorde urruneko trepeten politikak
|
||||||
Name[fi]=Tallenna etäkäyttöliittymäkomponenttien menettelytavat
|
Name[fi]=Tallenna etäkäyttöliittymäkomponenttien menettelytavat
|
||||||
Name[fr]=Enregistrer la stratégie des gadgets distants
|
Name[fr]=Enregistrer la politique des composants graphiques distants
|
||||||
Name[ga]=Sábháil polasaithe um giuirléidí cianda
|
Name[ga]=Sábháil polasaithe um giuirléidí cianda
|
||||||
Name[he]=שמירת מדיניות של ווידג׳טים מרוחקים
|
Name[he]=שמירת מדיניות של ווידג׳טים מרוחקים
|
||||||
Name[hr]=Spremi pravila za udaljene widgete
|
Name[hr]=Spremi pravila za udaljene widgete
|
||||||
Name[hu]=Távoli widgetek irányelveinek mentése
|
Name[hu]=Távoli widgetek irányelveinek mentése
|
||||||
Name[ia]=Il salva le politicas del widgets remote
|
Name[ia]=Il salva le politicas del widgets remote
|
||||||
Name[id]=Simpan kebijakan widget jarak jauh
|
Name[id]=Simpan kebijakan widget jarak jauh
|
||||||
|
Name[is]=Vista stefnur varðandi fjartengdar græjur
|
||||||
Name[it]=Salva le linee guida degli oggetti remoti
|
Name[it]=Salva le linee guida degli oggetti remoti
|
||||||
Name[ja]=リモートウィジェットポリシーを保存
|
Name[ja]=リモートウィジェットポリシーを保存
|
||||||
Name[kk]=Қашықтағы виджеттер ережелерін сақтау
|
Name[kk]=Қашықтағы виджеттер ережелерін сақтау
|
||||||
@ -48,6 +51,7 @@ Name[sr@latin]=Sačuvaj smernice za udaljene vidžete
|
|||||||
Name[sv]=Spara policy för grafiska fjärrkomponenter
|
Name[sv]=Spara policy för grafiska fjärrkomponenter
|
||||||
Name[th]=บันทึกกฎของวิดเจ็ตระยะไกล
|
Name[th]=บันทึกกฎของวิดเจ็ตระยะไกล
|
||||||
Name[tr]=Uzak programcık politikalarını kaydet
|
Name[tr]=Uzak programcık politikalarını kaydet
|
||||||
|
Name[ug]=يىراقتىكى ۋىجېتلارنى ساقلاش تەدبىرى
|
||||||
Name[uk]=Зберегти правила для віддалених віджетів
|
Name[uk]=Зберегти правила для віддалених віджетів
|
||||||
Name[x-test]=xxSave remote widgets' policiesxx
|
Name[x-test]=xxSave remote widgets' policiesxx
|
||||||
Name[zh_CN]=保存远程部件的策略
|
Name[zh_CN]=保存远程部件的策略
|
||||||
@ -55,6 +59,8 @@ Name[zh_TW]=儲存遠端元件政策
|
|||||||
Description=Prevents the system from saving remote plasma widgets' policies
|
Description=Prevents the system from saving remote plasma widgets' policies
|
||||||
Description[ar]=يمنع النظام من حفظ سياسات ودجات بلازما البعيدة
|
Description[ar]=يمنع النظام من حفظ سياسات ودجات بلازما البعيدة
|
||||||
Description[ast]=Impide que'l sistema guarde polítiques d'elementos gráficos Plasma remotos
|
Description[ast]=Impide que'l sistema guarde polítiques d'elementos gráficos Plasma remotos
|
||||||
|
Description[bg]=Забраняване запазването на правилата на отдалечените джаджи
|
||||||
|
Description[bs]=Sprečava sistem da sačuva smjernice udaljenih plazma grafičkih kontrola
|
||||||
Description[ca]=Evita al sistema de desar polítiques d'estris remots del plasma
|
Description[ca]=Evita al sistema de desar polítiques d'estris remots del plasma
|
||||||
Description[ca@valencia]=Evita al sistema d'alçar polítiques d'estris remots del plasma
|
Description[ca@valencia]=Evita al sistema d'alçar polítiques d'estris remots del plasma
|
||||||
Description[cs]=Zabrání systému ukládat zásady vzdálených widgetů plasmy
|
Description[cs]=Zabrání systému ukládat zásady vzdálených widgetů plasmy
|
||||||
@ -66,13 +72,14 @@ Description[es]=Impide que el sistema guarde políticas de elementos gráficos P
|
|||||||
Description[et]=Takistab süsteemil salvestamast Plasma välisvidinate reegleid
|
Description[et]=Takistab süsteemil salvestamast Plasma välisvidinate reegleid
|
||||||
Description[eu]=Sistemak urruneko plasma trepeten politikak gorde ditzan galarazten du
|
Description[eu]=Sistemak urruneko plasma trepeten politikak gorde ditzan galarazten du
|
||||||
Description[fi]=Estää järjestelmää tallentamasta etäplasmakäyttöliittymäkomponenttien menettelytapoja
|
Description[fi]=Estää järjestelmää tallentamasta etäplasmakäyttöliittymäkomponenttien menettelytapoja
|
||||||
Description[fr]=Empêche le système d'enregistrer la stratégie des gadgets distant
|
Description[fr]=Empêche le système d'enregistrer la politique des composants graphiques distants
|
||||||
Description[ga]=Ná lig don chóras polasaithe um giuirléidí cianda plasma a shábháil
|
Description[ga]=Ná lig don chóras polasaithe um giuirléidí cianda plasma a shábháil
|
||||||
Description[he]=מונע מהמערכת מלשמור מדיניות של ווידג׳טים מרוחקים
|
Description[he]=מונע מהמערכת מלשמור מדיניות של ווידג׳טים מרוחקים
|
||||||
Description[hr]=Brani sustavu spremanje pravila za udaljene widgete Plasme
|
Description[hr]=Brani sustavu spremanje pravila za udaljene widgete Plasme
|
||||||
Description[hu]=Megakadályozza a rendszert a távoli widgetek irányelveinek mentésében
|
Description[hu]=Megakadályozza a rendszert a távoli widgetek irányelveinek mentésében
|
||||||
Description[ia]=Il preveni le systema ab salvar le politicas del widgets (elementos graphic) remote de plasma
|
Description[ia]=Il preveni le systema ab salvar le politicas del widgets (elementos graphic) remote de plasma
|
||||||
Description[id]=Mencegah sistem dari menyimpan kebijakan widget jarak jauh plasma
|
Description[id]=Mencegah sistem dari menyimpan kebijakan widget jarak jauh plasma
|
||||||
|
Description[is]=Kemur í veg fyrir að kerfið geti vistað stefnur varðandi fjartengdar græjur
|
||||||
Description[it]=Impedisce al sistema di salvare le linee guida degli oggetti remoti di Plasma
|
Description[it]=Impedisce al sistema di salvare le linee guida degli oggetti remoti di Plasma
|
||||||
Description[ja]=システムがリモート Plasma ウィジェットポリシー保存するのを防ぎます
|
Description[ja]=システムがリモート Plasma ウィジェットポリシー保存するのを防ぎます
|
||||||
Description[kk]=Қашықтағы Plasma виджеттер ережелерін жүйеде сақтауын болдырмау
|
Description[kk]=Қашықтағы Plasma виджеттер ережелерін жүйеде сақтауын болдырмау
|
||||||
@ -99,6 +106,7 @@ Description[sr@latin]=Sprečava sistem da sačuva smernice udaljenih plasma vid
|
|||||||
Description[sv]=Förhindrar systemet från att spara policy för Plasma grafiska fjärrkomponenter
|
Description[sv]=Förhindrar systemet från att spara policy för Plasma grafiska fjärrkomponenter
|
||||||
Description[th]=ป้องกันระบบจากการบันทึกกฎของวิดเจ็ตของพลาสมาจากทางไกล
|
Description[th]=ป้องกันระบบจากการบันทึกกฎของวิดเจ็ตของพลาสมาจากทางไกล
|
||||||
Description[tr]=Sistemin uzak plasma programcık politikalarını kaydetmesini engelle
|
Description[tr]=Sistemin uzak plasma programcık politikalarını kaydetmesini engelle
|
||||||
|
Description[ug]=سىستېما يىراقتىكى پلازما ۋىجېتلىرىنىڭ تەدبىرىنى ساقلاشنى چەكلەيدۇ
|
||||||
Description[uk]=Заборонити системі зберігати правила для віддалених віджетів Плазми
|
Description[uk]=Заборонити системі зберігати правила для віддалених віджетів Плазми
|
||||||
Description[x-test]=xxPrevents the system from saving remote plasma widgets' policiesxx
|
Description[x-test]=xxPrevents the system from saving remote plasma widgets' policiesxx
|
||||||
Description[zh_CN]=禁止系统保存远程 Plasma 部件的策略
|
Description[zh_CN]=禁止系统保存远程 Plasma 部件的策略
|
||||||
|
@ -8,8 +8,10 @@ if(KDE_PLATFORM_FEATURE_BINARY_COMPATIBLE_FEATURE_REDUCTION)
|
|||||||
endif(KDE_PLATFORM_FEATURE_BINARY_COMPATIBLE_FEATURE_REDUCTION)
|
endif(KDE_PLATFORM_FEATURE_BINARY_COMPATIBLE_FEATURE_REDUCTION)
|
||||||
|
|
||||||
set(simple_javascript_engine_SRCS
|
set(simple_javascript_engine_SRCS
|
||||||
|
common/extension_launchapp.cpp
|
||||||
|
common/extension_io.cpp
|
||||||
|
common/guiscriptenv.cpp
|
||||||
common/javascriptaddonpackagestructure.cpp
|
common/javascriptaddonpackagestructure.cpp
|
||||||
common/jsscriptenv.cpp
|
|
||||||
plasmoid/abstractjsappletscript.cpp
|
plasmoid/abstractjsappletscript.cpp
|
||||||
plasmoid/appletauthorization.cpp
|
plasmoid/appletauthorization.cpp
|
||||||
plasmoid/jsappletinterface.cpp
|
plasmoid/jsappletinterface.cpp
|
||||||
@ -62,6 +64,8 @@ install(FILES data/plasma-scriptengine-applet-simple-javascript.desktop DESTINAT
|
|||||||
# RUNNER
|
# RUNNER
|
||||||
|
|
||||||
set(javascript_runner_engine_SRCS
|
set(javascript_runner_engine_SRCS
|
||||||
|
common/extension_launchapp.cpp
|
||||||
|
common/extension_io.cpp
|
||||||
common/javascriptaddonpackagestructure.cpp
|
common/javascriptaddonpackagestructure.cpp
|
||||||
common/scriptenv.cpp
|
common/scriptenv.cpp
|
||||||
runner/javascriptrunner.cpp
|
runner/javascriptrunner.cpp
|
||||||
@ -83,6 +87,8 @@ install(FILES data/plasma-scriptengine-runner-javascript.desktop DESTINATION ${S
|
|||||||
# DATAENGINE
|
# DATAENGINE
|
||||||
|
|
||||||
set(javascript_dataengine_engine_SRCS
|
set(javascript_dataengine_engine_SRCS
|
||||||
|
common/extension_launchapp.cpp
|
||||||
|
common/extension_io.cpp
|
||||||
common/javascriptaddonpackagestructure.cpp
|
common/javascriptaddonpackagestructure.cpp
|
||||||
common/scriptenv.cpp
|
common/scriptenv.cpp
|
||||||
dataengine/javascriptdataengine.cpp
|
dataengine/javascriptdataengine.cpp
|
||||||
@ -119,6 +125,8 @@ install(FILES data/plasma-javascriptaddon.desktop DESTINATION ${SERVICETYPES_INS
|
|||||||
|
|
||||||
#DECLARATIVE APPLET
|
#DECLARATIVE APPLET
|
||||||
set(declarative_appletscript_SRCS
|
set(declarative_appletscript_SRCS
|
||||||
|
common/extension_launchapp.cpp
|
||||||
|
common/extension_io.cpp
|
||||||
common/javascriptaddonpackagestructure.cpp
|
common/javascriptaddonpackagestructure.cpp
|
||||||
common/declarativescriptenv.cpp
|
common/declarativescriptenv.cpp
|
||||||
declarative/packageaccessmanager.cpp
|
declarative/packageaccessmanager.cpp
|
||||||
|
142
scriptengines/javascript/common/extension_io.cpp
Normal file
142
scriptengines/javascript/common/extension_io.cpp
Normal file
@ -0,0 +1,142 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2011 Aaron Seigo <aseigo@kde.org>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Library General Public License as
|
||||||
|
* published by the Free Software Foundation; either version 2, 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 Library 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 "scriptenv.h"
|
||||||
|
|
||||||
|
#include <QDir>
|
||||||
|
|
||||||
|
#include <KGlobalSettings>
|
||||||
|
#include <KIO/Job>
|
||||||
|
#include <KRun>
|
||||||
|
#include <KStandardDirs>
|
||||||
|
|
||||||
|
QScriptValue ScriptEnv::openUrl(QScriptContext *context, QScriptEngine *engine)
|
||||||
|
{
|
||||||
|
Q_UNUSED(engine)
|
||||||
|
if (context->argumentCount() == 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
QScriptValue v = context->argument(0);
|
||||||
|
KUrl url = v.isString() ? KUrl(v.toString()) : qscriptvalue_cast<KUrl>(v);
|
||||||
|
|
||||||
|
if (!url.isValid()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
ScriptEnv *env = ScriptEnv::findScriptEnv(engine);
|
||||||
|
if (!env) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(env->m_allowedUrls & AppLaunching) &&
|
||||||
|
!((env->m_allowedUrls & HttpUrls) && (url.protocol() == "http" || url.protocol() == "https"))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
new KRun(url, 0);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO these should throw an exception
|
||||||
|
QScriptValue ScriptEnv::getUrl(QScriptContext *context, QScriptEngine *engine)
|
||||||
|
{
|
||||||
|
if (context->argumentCount() == 0) {
|
||||||
|
return engine->undefinedValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
QScriptValue v = context->argument(0);
|
||||||
|
KUrl url = v.isString() ? KUrl(v.toString()) : qscriptvalue_cast<KUrl>(v);
|
||||||
|
|
||||||
|
if (!url.isValid()) {
|
||||||
|
return engine->undefinedValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
ScriptEnv *env = ScriptEnv::findScriptEnv(engine);
|
||||||
|
if (!env) {
|
||||||
|
//kDebug() << "findScriptEnv failed";
|
||||||
|
return engine->undefinedValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (url.isLocalFile()) {
|
||||||
|
if (!(env->m_allowedUrls & LocalUrls)) {
|
||||||
|
return engine->undefinedValue();
|
||||||
|
}
|
||||||
|
} else if (!(env->m_allowedUrls & NetworkUrls) &&
|
||||||
|
!((env->m_allowedUrls & HttpUrls) && (url.protocol() == "http" || url.protocol() == "https"))) {
|
||||||
|
return engine->undefinedValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
KIO::Job *job = KIO::get(url, KIO::NoReload, KIO::HideProgressInfo);
|
||||||
|
return engine->newQObject(job);
|
||||||
|
}
|
||||||
|
|
||||||
|
QScriptValue ScriptEnv::userDataPath(QScriptContext *context, QScriptEngine *engine)
|
||||||
|
{
|
||||||
|
Q_UNUSED(engine)
|
||||||
|
if (context->argumentCount() == 0) {
|
||||||
|
return QDir::homePath();
|
||||||
|
}
|
||||||
|
|
||||||
|
const QString type = context->argument(0).toString();
|
||||||
|
if (type.isEmpty()) {
|
||||||
|
return QDir::homePath();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (context->argumentCount() > 1) {
|
||||||
|
const QString filename = context->argument(1).toString();
|
||||||
|
return KStandardDirs::locateLocal(type.toLatin1(), filename);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (type.compare("desktop", Qt::CaseInsensitive) == 0) {
|
||||||
|
return KGlobalSettings::desktopPath();
|
||||||
|
} else if (type.compare("autostart", Qt::CaseInsensitive) == 0) {
|
||||||
|
return KGlobalSettings::autostartPath();
|
||||||
|
} else if (type.compare("documents", Qt::CaseInsensitive) == 0) {
|
||||||
|
return KGlobalSettings::documentPath();
|
||||||
|
} else if (type.compare("music", Qt::CaseInsensitive) == 0) {
|
||||||
|
return KGlobalSettings::musicPath();
|
||||||
|
} else if (type.compare("video", Qt::CaseInsensitive) == 0) {
|
||||||
|
return KGlobalSettings::videosPath();
|
||||||
|
} else if (type.compare("downloads", Qt::CaseInsensitive) == 0) {
|
||||||
|
return KGlobalSettings::downloadPath();
|
||||||
|
} else if (type.compare("pictures", Qt::CaseInsensitive) == 0) {
|
||||||
|
return KGlobalSettings::picturesPath();
|
||||||
|
}
|
||||||
|
|
||||||
|
return QString();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ScriptEnv::registerGetUrl(QScriptValue &obj)
|
||||||
|
{
|
||||||
|
QScriptValue get = obj.property("getUrl");
|
||||||
|
if (!get.isValid()) {
|
||||||
|
obj.setProperty("getUrl", m_engine->newFunction(ScriptEnv::getUrl));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ScriptEnv::registerOpenUrl(QScriptValue &obj)
|
||||||
|
{
|
||||||
|
QScriptValue value = obj.property("openUrl");
|
||||||
|
if (!value.isValid()) {
|
||||||
|
obj.setProperty("openUrl", m_engine->newFunction(ScriptEnv::openUrl));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
253
scriptengines/javascript/common/extension_launchapp.cpp
Normal file
253
scriptengines/javascript/common/extension_launchapp.cpp
Normal file
@ -0,0 +1,253 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2011 Aaron Seigo <aseigo@kde.org>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Library General Public License as
|
||||||
|
* published by the Free Software Foundation; either version 2, 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 Library 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 "scriptenv.h"
|
||||||
|
|
||||||
|
#include <KEMailSettings>
|
||||||
|
#include <KMimeTypeTrader>
|
||||||
|
#include <KStandardDirs>
|
||||||
|
#include <KRun>
|
||||||
|
#include <KServiceTypeTrader>
|
||||||
|
#include <KShell>
|
||||||
|
|
||||||
|
QScriptValue ScriptEnv::runApplication(QScriptContext *context, QScriptEngine *engine)
|
||||||
|
{
|
||||||
|
Q_UNUSED(engine)
|
||||||
|
if (context->argumentCount() == 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
KUrl::List urls;
|
||||||
|
if (context->argumentCount() > 1) {
|
||||||
|
urls = qscriptvalue_cast<KUrl::List>(context->argument(1));
|
||||||
|
}
|
||||||
|
|
||||||
|
const QString app = context->argument(0).toString();
|
||||||
|
|
||||||
|
const QString exec = KGlobal::dirs()->findExe(app);
|
||||||
|
if (!exec.isEmpty()) {
|
||||||
|
return KRun::run(exec, urls, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
KService::Ptr service = KService::serviceByStorageId(app);
|
||||||
|
if (service) {
|
||||||
|
return KRun::run(*service, urls, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
QScriptValue ScriptEnv::runCommand(QScriptContext *context, QScriptEngine *engine)
|
||||||
|
{
|
||||||
|
Q_UNUSED(engine);
|
||||||
|
|
||||||
|
if (context->argumentCount() == 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QString exec = KGlobal::dirs()->findExe(context->argument(0).toString());
|
||||||
|
if (!exec.isEmpty()) {
|
||||||
|
QString args;
|
||||||
|
if (context->argumentCount() > 1) {
|
||||||
|
const QStringList argList = qscriptvalue_cast<QStringList>(context->argument(1));
|
||||||
|
if (!argList.isEmpty()) {
|
||||||
|
args = ' ' + KShell::joinArgs(argList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return KRun::runCommand(exec + args, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
QScriptValue ScriptEnv::applicationExists(QScriptContext *context, QScriptEngine *engine)
|
||||||
|
{
|
||||||
|
Q_UNUSED(engine)
|
||||||
|
if (context->argumentCount() == 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QString application = context->argument(0).toString();
|
||||||
|
if (application.isEmpty()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// first, check for it in $PATH
|
||||||
|
if (!KStandardDirs::findExe(application).isEmpty()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (KService::serviceByStorageId(application)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (application.contains("'")) {
|
||||||
|
// apostrophes just screw up the trader lookups below, so check for it
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// next, consult ksycoca for an app by that name
|
||||||
|
if (!KServiceTypeTrader::self()->query("Application", QString("Name =~ '%1'").arg(application)).isEmpty()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// next, consult ksycoca for an app by that generic name
|
||||||
|
if (!KServiceTypeTrader::self()->query("Application", QString("GenericName =~ '%1'").arg(application)).isEmpty()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
QScriptValue ScriptEnv::defaultApplication(QScriptContext *context, QScriptEngine *engine)
|
||||||
|
{
|
||||||
|
Q_UNUSED(engine)
|
||||||
|
if (context->argumentCount() == 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QString application = context->argument(0).toString();
|
||||||
|
if (application.isEmpty()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const bool storageId = context->argumentCount() < 2 ? false : context->argument(1).toBool();
|
||||||
|
|
||||||
|
// FIXME: there are some pretty horrible hacks below, in the sense that they assume a very
|
||||||
|
// specific implementation system. there is much room for improvement here. see
|
||||||
|
// kdebase-runtime/kcontrol/componentchooser/ for all the gory details ;)
|
||||||
|
if (application.compare("mailer", Qt::CaseInsensitive) == 0) {
|
||||||
|
KEMailSettings settings;
|
||||||
|
|
||||||
|
// in KToolInvocation, the default is kmail; but let's be friendlier :)
|
||||||
|
QString command = settings.getSetting(KEMailSettings::ClientProgram);
|
||||||
|
if (command.isEmpty()) {
|
||||||
|
if (KService::Ptr kontact = KService::serviceByStorageId("kontact")) {
|
||||||
|
return storageId ? kontact->storageId() : kontact->exec();
|
||||||
|
} else if (KService::Ptr kmail = KService::serviceByStorageId("kmail")) {
|
||||||
|
return storageId ? kmail->storageId() : kmail->exec();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!command.isEmpty()) {
|
||||||
|
if (settings.getSetting(KEMailSettings::ClientTerminal) == "true") {
|
||||||
|
KConfigGroup confGroup(KGlobal::config(), "General");
|
||||||
|
const QString preferredTerminal = confGroup.readPathEntry("TerminalApplication",
|
||||||
|
QString::fromLatin1("konsole"));
|
||||||
|
command = preferredTerminal + QString::fromLatin1(" -e ") + command;
|
||||||
|
}
|
||||||
|
|
||||||
|
return command;
|
||||||
|
}
|
||||||
|
} else if (application.compare("browser", Qt::CaseInsensitive) == 0) {
|
||||||
|
KConfigGroup config(KGlobal::config(), "General");
|
||||||
|
QString browserApp = config.readPathEntry("BrowserApplication", QString());
|
||||||
|
if (browserApp.isEmpty()) {
|
||||||
|
const KService::Ptr htmlApp = KMimeTypeTrader::self()->preferredService(QLatin1String("text/html"));
|
||||||
|
if (htmlApp) {
|
||||||
|
browserApp = storageId ? htmlApp->storageId() : htmlApp->exec();
|
||||||
|
}
|
||||||
|
} else if (browserApp.startsWith('!')) {
|
||||||
|
browserApp = browserApp.mid(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return browserApp;
|
||||||
|
} else if (application.compare("terminal", Qt::CaseInsensitive) == 0) {
|
||||||
|
KConfigGroup confGroup(KGlobal::config(), "General");
|
||||||
|
return confGroup.readPathEntry("TerminalApplication", QString::fromLatin1("konsole"));
|
||||||
|
} else if (application.compare("filemanager", Qt::CaseInsensitive) == 0) {
|
||||||
|
KService::Ptr service = KMimeTypeTrader::self()->preferredService("inode/directory");
|
||||||
|
if (service) {
|
||||||
|
return storageId ? service->storageId() : service->exec();
|
||||||
|
}
|
||||||
|
} else if (application.compare("windowmanager", Qt::CaseInsensitive) == 0) {
|
||||||
|
KConfig cfg("ksmserverrc", KConfig::NoGlobals);
|
||||||
|
KConfigGroup confGroup(&cfg, "General");
|
||||||
|
return confGroup.readEntry("windowManager", QString::fromLatin1("konsole"));
|
||||||
|
} else if (KService::Ptr service = KMimeTypeTrader::self()->preferredService(application)) {
|
||||||
|
return storageId ? service->storageId() : service->exec();
|
||||||
|
} else {
|
||||||
|
// try the files in share/apps/kcm_componentchooser/
|
||||||
|
const QStringList services = KGlobal::dirs()->findAllResources("data","kcm_componentchooser/*.desktop", KStandardDirs::NoDuplicates);
|
||||||
|
//kDebug() << "ok, trying in" << services.count();
|
||||||
|
foreach (const QString &service, services) {
|
||||||
|
KConfig config(service, KConfig::SimpleConfig);
|
||||||
|
KConfigGroup cg = config.group(QByteArray());
|
||||||
|
const QString type = cg.readEntry("valueName", QString());
|
||||||
|
//kDebug() << " checking" << service << type << application;
|
||||||
|
if (type.compare(application, Qt::CaseInsensitive) == 0) {
|
||||||
|
KConfig store(cg.readPathEntry("storeInFile", "null"));
|
||||||
|
KConfigGroup storeCg(&store, cg.readEntry("valueSection", QString()));
|
||||||
|
const QString exec = storeCg.readPathEntry(cg.readEntry("valueName", "kcm_componenchooser_null"),
|
||||||
|
cg.readEntry("defaultImplementation", QString()));
|
||||||
|
if (!exec.isEmpty()) {
|
||||||
|
return exec;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
QScriptValue ScriptEnv::applicationPath(QScriptContext *context, QScriptEngine *engine)
|
||||||
|
{
|
||||||
|
Q_UNUSED(engine)
|
||||||
|
if (context->argumentCount() == 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QString application = context->argument(0).toString();
|
||||||
|
if (application.isEmpty()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// first, check for it in $PATH
|
||||||
|
const QString path = KStandardDirs::findExe(application);
|
||||||
|
if (!path.isEmpty()) {
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (KService::Ptr service = KService::serviceByStorageId(application)) {
|
||||||
|
return KStandardDirs::locate("apps", service->entryPath());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (application.contains("'")) {
|
||||||
|
// apostrophes just screw up the trader lookups below, so check for it
|
||||||
|
return QString();
|
||||||
|
}
|
||||||
|
|
||||||
|
// next, consult ksycoca for an app by that name
|
||||||
|
KService::List offers = KServiceTypeTrader::self()->query("Application", QString("Name =~ '%1'").arg(application));
|
||||||
|
if (offers.isEmpty()) {
|
||||||
|
// next, consult ksycoca for an app by that generic name
|
||||||
|
offers = KServiceTypeTrader::self()->query("Application", QString("GenericName =~ '%1'").arg(application));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!offers.isEmpty()) {
|
||||||
|
KService::Ptr offer = offers.first();
|
||||||
|
return KStandardDirs::locate("apps", offer->entryPath());
|
||||||
|
}
|
||||||
|
|
||||||
|
return QString();
|
||||||
|
}
|
||||||
|
|
@ -153,134 +153,6 @@ bool ScriptEnv::checkForErrors(bool fatal)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
QScriptValue ScriptEnv::runApplication(QScriptContext *context, QScriptEngine *engine)
|
|
||||||
{
|
|
||||||
Q_UNUSED(engine)
|
|
||||||
if (context->argumentCount() == 0) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
KUrl::List urls;
|
|
||||||
if (context->argumentCount() > 1) {
|
|
||||||
urls = qscriptvalue_cast<KUrl::List>(context->argument(1));
|
|
||||||
}
|
|
||||||
|
|
||||||
const QString app = context->argument(0).toString();
|
|
||||||
|
|
||||||
const QString exec = KGlobal::dirs()->findExe(app);
|
|
||||||
if (!exec.isEmpty()) {
|
|
||||||
return KRun::run(exec, urls, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
KService::Ptr service = KService::serviceByStorageId(app);
|
|
||||||
if (service) {
|
|
||||||
return KRun::run(*service, urls, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
QScriptValue ScriptEnv::runCommand(QScriptContext *context, QScriptEngine *engine)
|
|
||||||
{
|
|
||||||
Q_UNUSED(engine);
|
|
||||||
|
|
||||||
if (context->argumentCount() == 0) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
const QString exec = KGlobal::dirs()->findExe(context->argument(0).toString());
|
|
||||||
if (!exec.isEmpty()) {
|
|
||||||
QString args;
|
|
||||||
if (context->argumentCount() > 1) {
|
|
||||||
const QStringList argList = qscriptvalue_cast<QStringList>(context->argument(1));
|
|
||||||
if (!argList.isEmpty()) {
|
|
||||||
args = ' ' + KShell::joinArgs(argList);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return KRun::runCommand(exec + args, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
QScriptValue ScriptEnv::openUrl(QScriptContext *context, QScriptEngine *engine)
|
|
||||||
{
|
|
||||||
Q_UNUSED(engine)
|
|
||||||
if (context->argumentCount() == 0) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
QScriptValue v = context->argument(0);
|
|
||||||
KUrl url = v.isString() ? KUrl(v.toString()) : qscriptvalue_cast<KUrl>(v);
|
|
||||||
|
|
||||||
if (!url.isValid()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
ScriptEnv *env = ScriptEnv::findScriptEnv(engine);
|
|
||||||
if (!env) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(env->m_allowedUrls & AppLaunching) &&
|
|
||||||
!((env->m_allowedUrls & HttpUrls) && (url.protocol() == "http" || url.protocol() == "https"))) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
new KRun(url, 0);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO these should throw an exception
|
|
||||||
QScriptValue ScriptEnv::getUrl(QScriptContext *context, QScriptEngine *engine)
|
|
||||||
{
|
|
||||||
if (context->argumentCount() == 0) {
|
|
||||||
return engine->undefinedValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
QScriptValue v = context->argument(0);
|
|
||||||
KUrl url = v.isString() ? KUrl(v.toString()) : qscriptvalue_cast<KUrl>(v);
|
|
||||||
|
|
||||||
if (!url.isValid()) {
|
|
||||||
return engine->undefinedValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
ScriptEnv *env = ScriptEnv::findScriptEnv(engine);
|
|
||||||
if (!env) {
|
|
||||||
//kDebug() << "findScriptEnv failed";
|
|
||||||
return engine->undefinedValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (url.isLocalFile()) {
|
|
||||||
if (!(env->m_allowedUrls & LocalUrls)) {
|
|
||||||
return engine->undefinedValue();
|
|
||||||
}
|
|
||||||
} else if (!(env->m_allowedUrls & NetworkUrls) &&
|
|
||||||
!((env->m_allowedUrls & HttpUrls) && (url.protocol() == "http" || url.protocol() == "https"))) {
|
|
||||||
return engine->undefinedValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
KIO::Job *job = KIO::get(url, KIO::NoReload, KIO::HideProgressInfo);
|
|
||||||
return engine->newQObject(job);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ScriptEnv::registerGetUrl(QScriptValue &obj)
|
|
||||||
{
|
|
||||||
QScriptValue get = obj.property("getUrl");
|
|
||||||
if (!get.isValid()) {
|
|
||||||
obj.setProperty("getUrl", m_engine->newFunction(ScriptEnv::getUrl));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ScriptEnv::registerOpenUrl(QScriptValue &obj)
|
|
||||||
{
|
|
||||||
QScriptValue value = obj.property("openUrl");
|
|
||||||
if (!value.isValid()) {
|
|
||||||
obj.setProperty("openUrl", m_engine->newFunction(ScriptEnv::openUrl));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ScriptEnv::importBuiltinExtension(const QString &extension, QScriptValue &obj)
|
bool ScriptEnv::importBuiltinExtension(const QString &extension, QScriptValue &obj)
|
||||||
{
|
{
|
||||||
kDebug() << extension;
|
kDebug() << extension;
|
||||||
@ -307,6 +179,8 @@ bool ScriptEnv::importBuiltinExtension(const QString &extension, QScriptValue &o
|
|||||||
} else if ("localio" == extension) {
|
} else if ("localio" == extension) {
|
||||||
m_allowedUrls |= LocalUrls;
|
m_allowedUrls |= LocalUrls;
|
||||||
registerGetUrl(obj);
|
registerGetUrl(obj);
|
||||||
|
obj.setProperty("userDataPath", m_engine->newFunction(ScriptEnv::userDataPath));
|
||||||
|
obj.setProperty("runCommand", m_engine->newFunction(ScriptEnv::runCommand));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,8 +82,12 @@ private:
|
|||||||
static QScriptValue print(QScriptContext *context, QScriptEngine *engine);
|
static QScriptValue print(QScriptContext *context, QScriptEngine *engine);
|
||||||
static QScriptValue runApplication(QScriptContext *context, QScriptEngine *engine);
|
static QScriptValue runApplication(QScriptContext *context, QScriptEngine *engine);
|
||||||
static QScriptValue runCommand(QScriptContext *context, QScriptEngine *engine);
|
static QScriptValue runCommand(QScriptContext *context, QScriptEngine *engine);
|
||||||
|
static QScriptValue defaultApplication(QScriptContext *context, QScriptEngine *engine);
|
||||||
|
static QScriptValue applicationPath(QScriptContext *context, QScriptEngine *engine);
|
||||||
|
static QScriptValue applicationExists(QScriptContext *context, QScriptEngine *engine);
|
||||||
static QScriptValue openUrl(QScriptContext *context, QScriptEngine *engine);
|
static QScriptValue openUrl(QScriptContext *context, QScriptEngine *engine);
|
||||||
static QScriptValue getUrl(QScriptContext *context, QScriptEngine *engine);
|
static QScriptValue getUrl(QScriptContext *context, QScriptEngine *engine);
|
||||||
|
static QScriptValue userDataPath(QScriptContext *context, QScriptEngine *engine);
|
||||||
static QScriptValue listAddons(QScriptContext *context, QScriptEngine *engine);
|
static QScriptValue listAddons(QScriptContext *context, QScriptEngine *engine);
|
||||||
static QScriptValue loadAddon(QScriptContext *context, QScriptEngine *engine);
|
static QScriptValue loadAddon(QScriptContext *context, QScriptEngine *engine);
|
||||||
static QScriptValue registerAddon(QScriptContext *context, QScriptEngine *engine);
|
static QScriptValue registerAddon(QScriptContext *context, QScriptEngine *engine);
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
Name=Plasma JavaScript Addon
|
Name=Plasma JavaScript Addon
|
||||||
Name[ast]=Complementu de JavaScript pa Plasma
|
Name[ast]=Complementu de JavaScript pa Plasma
|
||||||
Name[bg]=Добавка за JavaScript на Plasma
|
Name[bg]=Добавка за JavaScript на Plasma
|
||||||
|
Name[bs]=Plazma javaskriptni dodatak
|
||||||
Name[ca]=Complement del JavaScript pel Plasma
|
Name[ca]=Complement del JavaScript pel Plasma
|
||||||
Name[ca@valencia]=Complement del JavaScript pel Plasma
|
Name[ca@valencia]=Complement del JavaScript pel Plasma
|
||||||
Name[cs]=Doplněk Plasmy JavaScript
|
Name[cs]=Doplněk Plasmy JavaScript
|
||||||
@ -12,12 +13,14 @@ Name[en_GB]=Plasma JavaScript Addon
|
|||||||
Name[es]=Complemento de JavaScript para Plasma
|
Name[es]=Complemento de JavaScript para Plasma
|
||||||
Name[et]=Plasma JavaScripti lisa
|
Name[et]=Plasma JavaScripti lisa
|
||||||
Name[eu]=Plasma JavaScript gehigarria
|
Name[eu]=Plasma JavaScript gehigarria
|
||||||
|
Name[fi]=Plasma JavaScript -lisäosa
|
||||||
Name[fr]=Module complémentaire Javascript de Plasma
|
Name[fr]=Module complémentaire Javascript de Plasma
|
||||||
Name[he]=תוסף עבור JavaScript של Plasma
|
Name[he]=תוסף עבור JavaScript של Plasma
|
||||||
Name[hi]=प्लाज़मा जावा-स्क्रिप्ट एडोन
|
Name[hi]=प्लाज़मा जावा-स्क्रिप्ट एडोन
|
||||||
Name[hr]=Dodatak JavaScripta Plasmi
|
Name[hr]=Dodatak JavaScripta Plasmi
|
||||||
Name[hu]=Plazma JavaScript-bővítmény
|
Name[hu]=Plazma JavaScript-bővítmény
|
||||||
Name[ia]=Plasma JavaScript Addon
|
Name[ia]=Plasma JavaScript Addon
|
||||||
|
Name[is]=Plasma JavaScript viðbót
|
||||||
Name[it]=Aggiunta per Java e JavaScript
|
Name[it]=Aggiunta per Java e JavaScript
|
||||||
Name[ja]=Plasma JavaScript アドオン
|
Name[ja]=Plasma JavaScript アドオン
|
||||||
Name[kk]=Plasma JavaScript қосымшасы
|
Name[kk]=Plasma JavaScript қосымшасы
|
||||||
@ -34,6 +37,7 @@ Name[pl]=Dodatek dla JavaScript
|
|||||||
Name[pt]=Extensão de JavaScript do Plasma
|
Name[pt]=Extensão de JavaScript do Plasma
|
||||||
Name[pt_BR]=Complementos de JavaScript do Plasma
|
Name[pt_BR]=Complementos de JavaScript do Plasma
|
||||||
Name[ro]=Supliment JavaScript Plasma
|
Name[ro]=Supliment JavaScript Plasma
|
||||||
|
Name[ru]=Расширение Plasma, использующее JavaScript
|
||||||
Name[sk]=Doplnok JavaScript pre plasmu
|
Name[sk]=Doplnok JavaScript pre plasmu
|
||||||
Name[sl]=Dodatek za JavaScript za Plasmo
|
Name[sl]=Dodatek za JavaScript za Plasmo
|
||||||
Name[sr]=Плазма јаваскриптни додатак
|
Name[sr]=Плазма јаваскриптни додатак
|
||||||
@ -44,8 +48,11 @@ Name[sv]=Plasma Javaskript-tillägg
|
|||||||
Name[tg]=Иловаҳои Plasma JavaScript
|
Name[tg]=Иловаҳои Plasma JavaScript
|
||||||
Name[th]=ส่วนเสริมจาวาและจาวาสคริปต์สำหรับพลาสมาส่วนเสริมจาวาและจาวาสคริปต์สำหรับ
|
Name[th]=ส่วนเสริมจาวาและจาวาสคริปต์สำหรับพลาสมาส่วนเสริมจาวาและจาวาสคริปต์สำหรับ
|
||||||
Name[tr]=Plasma JavaScript Eklentisi
|
Name[tr]=Plasma JavaScript Eklentisi
|
||||||
|
Name[ug]=Plasma JavaScript قوشۇلما
|
||||||
Name[uk]=Додаток JavaScript до Плазми
|
Name[uk]=Додаток JavaScript до Плазми
|
||||||
|
Name[wa]=Pacaedje di rawete Plasma JavaScript
|
||||||
Name[x-test]=xxPlasma JavaScript Addonxx
|
Name[x-test]=xxPlasma JavaScript Addonxx
|
||||||
|
Name[zh_CN]=Plasma JavaScript 附加插件
|
||||||
Name[zh_TW]=Plasma JavaScript Addon
|
Name[zh_TW]=Plasma JavaScript Addon
|
||||||
Type=ServiceType
|
Type=ServiceType
|
||||||
X-KDE-ServiceType=Plasma/JavascriptAddon
|
X-KDE-ServiceType=Plasma/JavascriptAddon
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
[Desktop Entry]
|
[Desktop Entry]
|
||||||
Name=Javascript Addon
|
Name=Javascript Addon
|
||||||
Name[ast]=Complementu de JavaScript
|
Name[ast]=Complementu de JavaScript
|
||||||
Name[bg]=Добавка за JavaScript
|
Name[bg]=Добавка за Javascript
|
||||||
|
Name[bs]=Javaskriptni dodatak
|
||||||
Name[ca]=Complement del Javascript
|
Name[ca]=Complement del Javascript
|
||||||
Name[ca@valencia]=Complement del Javascript
|
Name[ca@valencia]=Complement del Javascript
|
||||||
Name[cs]=Doplněk JavaScript
|
Name[cs]=Doplněk JavaScript
|
||||||
@ -12,6 +13,7 @@ Name[en_GB]=Javascript Addon
|
|||||||
Name[es]=Complemento de JavaScript
|
Name[es]=Complemento de JavaScript
|
||||||
Name[et]=JavaScripti lisa
|
Name[et]=JavaScripti lisa
|
||||||
Name[eu]=Javascript gehigarria
|
Name[eu]=Javascript gehigarria
|
||||||
|
Name[fi]=Javascript-lisäosa
|
||||||
Name[fr]=Module complémentaire Javascript
|
Name[fr]=Module complémentaire Javascript
|
||||||
Name[he]=תוסף JavaScript
|
Name[he]=תוסף JavaScript
|
||||||
Name[hi]=जावास्क्रिप्ट एडोन
|
Name[hi]=जावास्क्रिप्ट एडोन
|
||||||
@ -35,6 +37,7 @@ Name[pl]=Dodatek dla JavaScript
|
|||||||
Name[pt]=Extensão de JavaScript
|
Name[pt]=Extensão de JavaScript
|
||||||
Name[pt_BR]=Complementos de JavaScript
|
Name[pt_BR]=Complementos de JavaScript
|
||||||
Name[ro]=Supliment Javascript
|
Name[ro]=Supliment Javascript
|
||||||
|
Name[ru]=Дополнение, использующее JavaScript
|
||||||
Name[sk]=Doplnok JavaScript
|
Name[sk]=Doplnok JavaScript
|
||||||
Name[sl]=Dodatek za JavaScript
|
Name[sl]=Dodatek za JavaScript
|
||||||
Name[sr]=Јаваскриптни додатак
|
Name[sr]=Јаваскриптни додатак
|
||||||
@ -44,12 +47,16 @@ Name[sr@latin]=JavaScript dodatak
|
|||||||
Name[sv]=Javaskript-tillägg
|
Name[sv]=Javaskript-tillägg
|
||||||
Name[th]=ส่วนเสริมจาวาสคริปต์
|
Name[th]=ส่วนเสริมจาวาสคริปต์
|
||||||
Name[tr]=Javascript Eklentisi
|
Name[tr]=Javascript Eklentisi
|
||||||
|
Name[ug]=Javascript قوشۇلما
|
||||||
Name[uk]=Додаток JavaScript
|
Name[uk]=Додаток JavaScript
|
||||||
|
Name[wa]=Pacaedje di rawete Javascript
|
||||||
Name[x-test]=xxJavascript Addonxx
|
Name[x-test]=xxJavascript Addonxx
|
||||||
|
Name[zh_CN]=Javascript 插件
|
||||||
Name[zh_TW]=Javascript Addon
|
Name[zh_TW]=Javascript Addon
|
||||||
Comment=Addons for Javascript Plasma plugins
|
Comment=Addons for Javascript Plasma plugins
|
||||||
Comment[ast]=Amestaos pa complementos de JavaScript pa Plasma
|
Comment[ast]=Amestaos pa complementos de JavaScript pa Plasma
|
||||||
Comment[bg]=Добавки за приставките за Javascript на Plasma
|
Comment[bg]=Добавки за приставките за Javascript на Plasma
|
||||||
|
Comment[bs]=Dodaci za javaskriptne plazma priključke
|
||||||
Comment[ca]=Complements pels connectors Javascript del Plasma
|
Comment[ca]=Complements pels connectors Javascript del Plasma
|
||||||
Comment[ca@valencia]=Complements pels connectors Javascript del Plasma
|
Comment[ca@valencia]=Complements pels connectors Javascript del Plasma
|
||||||
Comment[cs]=Doplňky pro javascriptové zásuvné moduly plasmy
|
Comment[cs]=Doplňky pro javascriptové zásuvné moduly plasmy
|
||||||
@ -60,11 +67,13 @@ Comment[en_GB]=Addons for Javascript Plasma plugins
|
|||||||
Comment[es]=Añadidos para complementos de JavaScript para Plasma
|
Comment[es]=Añadidos para complementos de JavaScript para Plasma
|
||||||
Comment[et]=JavaScripti Plasma pluginate lisad
|
Comment[et]=JavaScripti Plasma pluginate lisad
|
||||||
Comment[eu]=Javascript Plasma pluginentzako gehigarriak
|
Comment[eu]=Javascript Plasma pluginentzako gehigarriak
|
||||||
|
Comment[fi]=Lisäosia JavaScript Plasma -liitännäisille
|
||||||
Comment[fr]=Module complémentaire pour les modules externes en Javascript de Plasma
|
Comment[fr]=Module complémentaire pour les modules externes en Javascript de Plasma
|
||||||
Comment[he]=תוספים לתוספי JavaScript של Plasma
|
Comment[he]=תוספים לתוספי JavaScript של Plasma
|
||||||
Comment[hr]=Dodaci za priključke za Javascript Plasma
|
Comment[hr]=Dodaci za priključke za Javascript Plasma
|
||||||
Comment[hu]=Bővítmények JavaScript Plazma-modulokhoz
|
Comment[hu]=Bővítmények JavaScript Plazma-modulokhoz
|
||||||
Comment[ia]=Addons (elementos adjuncte) pro plugins de Plasma de javascript
|
Comment[ia]=Addons (elementos adjuncte) pro plugins de Plasma de javascript
|
||||||
|
Comment[is]=Viðbætur fyrir Plasma JavaScript íforrit
|
||||||
Comment[it]=Aggiunte per le estensioni JavaScript di Plasma
|
Comment[it]=Aggiunte per le estensioni JavaScript di Plasma
|
||||||
Comment[ja]=JavaScript Plasma プラグイン用のアドオン
|
Comment[ja]=JavaScript Plasma プラグイン用のアドオン
|
||||||
Comment[kk]=Javascript Plasma плагиніне қосымшасы
|
Comment[kk]=Javascript Plasma плагиніне қосымшасы
|
||||||
@ -80,7 +89,7 @@ Comment[pl]=Dodatki dla wtyczek Plazmy w JavaScript
|
|||||||
Comment[pt]=Extras para os 'plugins' do Plasma em JavaScript
|
Comment[pt]=Extras para os 'plugins' do Plasma em JavaScript
|
||||||
Comment[pt_BR]=Complementos para os plug-ins do Plasma em JavaScript
|
Comment[pt_BR]=Complementos para os plug-ins do Plasma em JavaScript
|
||||||
Comment[ro]=Suplimente pentru module JavaScript Plasma
|
Comment[ro]=Suplimente pentru module JavaScript Plasma
|
||||||
Comment[ru]=Модули, обеспечивающие поддержку JavaScript в расширениях Plasma
|
Comment[ru]=Модули поддержки дополнений Plasma, использующих JavaScript
|
||||||
Comment[sk]=Doplnky pre Javascriptové moduly plasmy
|
Comment[sk]=Doplnky pre Javascriptové moduly plasmy
|
||||||
Comment[sl]=Dodatki za vstavke JavaScript za Plasmo
|
Comment[sl]=Dodatki za vstavke JavaScript za Plasmo
|
||||||
Comment[sr]=Додаци за јаваскриптне плазма прикључке
|
Comment[sr]=Додаци за јаваскриптне плазма прикључке
|
||||||
@ -90,9 +99,11 @@ Comment[sr@latin]=Dodaci za JavaScript plasma priključke
|
|||||||
Comment[sv]=Tillägg för Javascript Plasma-insticksprogram
|
Comment[sv]=Tillägg för Javascript Plasma-insticksprogram
|
||||||
Comment[th]=ส่วนขยายสำหรับส่วนเสริมพลาสมาที่เป็นจาวาสคริปต์
|
Comment[th]=ส่วนขยายสำหรับส่วนเสริมพลาสมาที่เป็นจาวาสคริปต์
|
||||||
Comment[tr]=Javascript Plasma eklentileri için ek araçlar
|
Comment[tr]=Javascript Plasma eklentileri için ek araçlar
|
||||||
|
Comment[ug]=Javascript Plasma قىستۇرمىسى ئۈچۈن قوشۇلما
|
||||||
Comment[uk]=Додатки для використання Javascript у Плазмі
|
Comment[uk]=Додатки для використання Javascript у Плазмі
|
||||||
Comment[wa]=Pacaedjes di rawete po les tchôkes-divins Plasma Javascript
|
Comment[wa]=Pacaedjes di rawete po les tchôkes-divins Plasma Javascript
|
||||||
Comment[x-test]=xxAddons for Javascript Plasma pluginsxx
|
Comment[x-test]=xxAddons for Javascript Plasma pluginsxx
|
||||||
|
Comment[zh_CN]=Javascript Plasma 插件的附件组件
|
||||||
Comment[zh_TW]=Javascript Plasma 外掛程式的 Addon
|
Comment[zh_TW]=Javascript Plasma 外掛程式的 Addon
|
||||||
Type=Service
|
Type=Service
|
||||||
X-KDE-ServiceTypes=Plasma/PackageStructure
|
X-KDE-ServiceTypes=Plasma/PackageStructure
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
[Desktop Entry]
|
[Desktop Entry]
|
||||||
Name=Declarative widget
|
Name=Declarative widget
|
||||||
Name[ast]=Elementu gráficu declarativu
|
Name[ast]=Elementu gráficu declarativu
|
||||||
|
Name[bg]=Декларативна джаджа
|
||||||
|
Name[bs]=Deklarativna grafička kontrola
|
||||||
Name[ca]=Estri declaratiu
|
Name[ca]=Estri declaratiu
|
||||||
Name[ca@valencia]=Estri declaratiu
|
Name[ca@valencia]=Estri declaratiu
|
||||||
Name[cs]=Deklarativní widget
|
Name[cs]=Deklarativní widget
|
||||||
@ -11,11 +13,12 @@ Name[en_GB]=Declarative widget
|
|||||||
Name[es]=Elemento gráfico declarativo
|
Name[es]=Elemento gráfico declarativo
|
||||||
Name[et]=Deklaratiivne vidin
|
Name[et]=Deklaratiivne vidin
|
||||||
Name[eu]=Trepeta ezagutarazlea
|
Name[eu]=Trepeta ezagutarazlea
|
||||||
Name[fr]=Élément graphique « Declarative »
|
Name[fr]=Composant graphique « Declarative »
|
||||||
Name[he]=ווידג׳ט מוצהר
|
Name[he]=ווידג׳ט מוצהר
|
||||||
Name[hr]=Deklarativni widget
|
Name[hr]=Deklarativni widget
|
||||||
Name[hu]=Deklaratív widget
|
Name[hu]=Deklaratív widget
|
||||||
Name[ia]=Widget declarative
|
Name[ia]=Widget declarative
|
||||||
|
Name[is]=Skilgreiningagræja
|
||||||
Name[it]=Oggetto dichiarativo
|
Name[it]=Oggetto dichiarativo
|
||||||
Name[kk]=Мәлімдеме виджеті
|
Name[kk]=Мәлімдеме виджеті
|
||||||
Name[km]=ធាតុក្រាហ្វិកដែលប្រកាស
|
Name[km]=ធាតុក្រាហ្វិកដែលប្រកាស
|
||||||
@ -24,6 +27,8 @@ Name[lt]=Deklaratyvus valdiklis
|
|||||||
Name[nb]=Deklarativt skjermelement
|
Name[nb]=Deklarativt skjermelement
|
||||||
Name[nds]=Stüerelement för Verkloren
|
Name[nds]=Stüerelement för Verkloren
|
||||||
Name[nl]=Widget voor declaratie
|
Name[nl]=Widget voor declaratie
|
||||||
|
Name[nn]=Deklarativt skjermelement
|
||||||
|
Name[pl]=Deklaratywny element interfejsu
|
||||||
Name[pt]=Item declarativo
|
Name[pt]=Item declarativo
|
||||||
Name[pt_BR]=Widget declarativo
|
Name[pt_BR]=Widget declarativo
|
||||||
Name[ro]=Control declarativ
|
Name[ro]=Control declarativ
|
||||||
@ -36,12 +41,16 @@ Name[sr@ijekavianlatin]=Deklarativni vidžet
|
|||||||
Name[sr@latin]=Deklarativni vidžet
|
Name[sr@latin]=Deklarativni vidžet
|
||||||
Name[sv]=Deklarativ grafisk komponent
|
Name[sv]=Deklarativ grafisk komponent
|
||||||
Name[tr]=Bildirim parçacığı
|
Name[tr]=Bildirim parçacığı
|
||||||
|
Name[ug]=ئېنىقلىما ۋىجېت
|
||||||
Name[uk]=Декларативний віджет
|
Name[uk]=Декларативний віджет
|
||||||
Name[wa]=Ahesse di gåyotaedje
|
Name[wa]=Ahesse di gåyotaedje
|
||||||
Name[x-test]=xxDeclarative widgetxx
|
Name[x-test]=xxDeclarative widgetxx
|
||||||
|
Name[zh_CN]=描述部件
|
||||||
Name[zh_TW]=宣告元件
|
Name[zh_TW]=宣告元件
|
||||||
Comment=Native Plasma widget written in QML and JavaScript
|
Comment=Native Plasma widget written in QML and JavaScript
|
||||||
Comment[ast]=Elementu gráficu nativu de Plasma escritu en QML y JavaScript
|
Comment[ast]=Elementu gráficu nativu de Plasma escritu en QML y JavaScript
|
||||||
|
Comment[bg]=Оригинална джаджа за Plasma, написана наQML и JavaScript
|
||||||
|
Comment[bs]=Samosvojni plazma grafičkih kontrola napisana u QML‑u i javaskriptu
|
||||||
Comment[ca]=Estri nadiu del Plasma escrit en QML i JavaScript
|
Comment[ca]=Estri nadiu del Plasma escrit en QML i JavaScript
|
||||||
Comment[ca@valencia]=Estri nadiu del Plasma escrit en QML i JavaScript
|
Comment[ca@valencia]=Estri nadiu del Plasma escrit en QML i JavaScript
|
||||||
Comment[cs]=Nativní Plasma widget napsaný v QML a JavaScriptu
|
Comment[cs]=Nativní Plasma widget napsaný v QML a JavaScriptu
|
||||||
@ -53,11 +62,12 @@ Comment[es]=Elemento gráfico nativo de Plasma escrito en QML y JavaScript
|
|||||||
Comment[et]=QML-is ja JavaScriptis kirjutatud Plasma vidin
|
Comment[et]=QML-is ja JavaScriptis kirjutatud Plasma vidin
|
||||||
Comment[eu]=Plasma jatorrizko trepeta QML eta JavaScript-en idatzia
|
Comment[eu]=Plasma jatorrizko trepeta QML eta JavaScript-en idatzia
|
||||||
Comment[fi]=Natiivi, QML-pohjainen Plasma-sovelma
|
Comment[fi]=Natiivi, QML-pohjainen Plasma-sovelma
|
||||||
Comment[fr]=Plasmoïde natif Plasma écrit en QML et JavaScript
|
Comment[fr]=Composant graphique natif de Plasma écrit en QML et JavaScript
|
||||||
Comment[he]=ווידג׳טים של Plasma הנכתבים ב־QML וב־JavaScript
|
Comment[he]=ווידג׳טים של Plasma הנכתבים ב־QML וב־JavaScript
|
||||||
Comment[hr]=Izvorni Plasma widget napisan u QML-u i JavaScriptu
|
Comment[hr]=Izvorni Plasma widget napisan u QML-u i JavaScriptu
|
||||||
Comment[hu]=QML-ben és JavaScriptben írt natív Plazma-widget
|
Comment[hu]=QML-ben és JavaScriptben írt natív Plazma-widget
|
||||||
Comment[ia]=Widget native de Plasma scribite in QLM e JavaScript
|
Comment[ia]=Widget native de Plasma scribite in QLM e JavaScript
|
||||||
|
Comment[is]=Upprunabundin Plasma græja skrifuð í QML og JavaScript
|
||||||
Comment[it]=Oggetto nativo di Plasma scritto in QML e JavaScript
|
Comment[it]=Oggetto nativo di Plasma scritto in QML e JavaScript
|
||||||
Comment[ja]=QML と JavaScript で書かれた Plasma のネイティブウィジェット
|
Comment[ja]=QML と JavaScript で書かれた Plasma のネイティブウィジェット
|
||||||
Comment[kk]=QML мен JavaScript-те жазылған Plasma тума виджеті
|
Comment[kk]=QML мен JavaScript-те жазылған Plasma тума виджеті
|
||||||
@ -68,6 +78,7 @@ Comment[lt]=Nuosavas Plasma valdiklis parašytas QML ir JavaScript kalba
|
|||||||
Comment[nb]=Plasmaelement for dette systemet, skrevet i QML og JavaScript
|
Comment[nb]=Plasmaelement for dette systemet, skrevet i QML og JavaScript
|
||||||
Comment[nds]=En orginaal Plasmaelement, schreven in QML un JavaScript
|
Comment[nds]=En orginaal Plasmaelement, schreven in QML un JavaScript
|
||||||
Comment[nl]=Hier thuishorend Plasma-widget geschreven in QML en JavaScript
|
Comment[nl]=Hier thuishorend Plasma-widget geschreven in QML en JavaScript
|
||||||
|
Comment[nn]=Plasma-element skriven i QML og JavaScript
|
||||||
Comment[pa]=QML ਤੇ ਜਾਵਾ-ਸਕ੍ਰਿਪਟ ਵਿੱਚ ਲਿਖੇ ਨੇਟਿਵ ਪਲਾਜ਼ਮਾ ਵਿਦਜੈੱਟ
|
Comment[pa]=QML ਤੇ ਜਾਵਾ-ਸਕ੍ਰਿਪਟ ਵਿੱਚ ਲਿਖੇ ਨੇਟਿਵ ਪਲਾਜ਼ਮਾ ਵਿਦਜੈੱਟ
|
||||||
Comment[pl]=Element interfejsu Plazmy napisany w QML lub JavaScript
|
Comment[pl]=Element interfejsu Plazmy napisany w QML lub JavaScript
|
||||||
Comment[pt]=Elemento nativo do Plasma feito em QML e JavaScript
|
Comment[pt]=Elemento nativo do Plasma feito em QML e JavaScript
|
||||||
@ -83,8 +94,10 @@ Comment[sr@latin]=Samosvojni plasma vidžet napisan u QML‑u i JavaScriptu
|
|||||||
Comment[sv]=Inbyggd grafisk Plasma-komponent skriven i QML och Javascript
|
Comment[sv]=Inbyggd grafisk Plasma-komponent skriven i QML och Javascript
|
||||||
Comment[th]=วิดเจ็ตพลาสมาแบบดั้งเดิมที่เขียนด้วย QML และจาวาสคริปต์
|
Comment[th]=วิดเจ็ตพลาสมาแบบดั้งเดิมที่เขียนด้วย QML และจาวาสคริปต์
|
||||||
Comment[tr]=JavaScript ve QML ile yazılmış gerçek Plasma gereci
|
Comment[tr]=JavaScript ve QML ile yazılmış gerçek Plasma gereci
|
||||||
|
Comment[ug]=QML ۋە JavaScript بىلەن يېزىلغان ئەسلى Plasma ۋىجېتى
|
||||||
Comment[uk]=Віджет Плазми, написаний на QML та JavaScript
|
Comment[uk]=Віджет Плазми, написаний на QML та JavaScript
|
||||||
Comment[x-test]=xxNative Plasma widget written in QML and JavaScriptxx
|
Comment[x-test]=xxNative Plasma widget written in QML and JavaScriptxx
|
||||||
|
Comment[zh_CN]=使用 QML 和 JavaScript 编写的原生 Plasma 部件
|
||||||
Comment[zh_TW]=用 QML 與 JavaScript 寫的原始 Plasma 元件
|
Comment[zh_TW]=用 QML 與 JavaScript 寫的原始 Plasma 元件
|
||||||
Type=Service
|
Type=Service
|
||||||
Icon=text-x-script
|
Icon=text-x-script
|
||||||
|
@ -5,6 +5,7 @@ Name[ast]=Elementu gráficu JavaScript
|
|||||||
Name[be@latin]=Widžet „JavaScript”
|
Name[be@latin]=Widžet „JavaScript”
|
||||||
Name[bg]=Джаджа JavaScript
|
Name[bg]=Джаджа JavaScript
|
||||||
Name[bn_IN]=JavaScript Widget
|
Name[bn_IN]=JavaScript Widget
|
||||||
|
Name[bs]=Javascript grafička kontrola
|
||||||
Name[ca]=Estri del JavaScript
|
Name[ca]=Estri del JavaScript
|
||||||
Name[ca@valencia]=Estri del JavaScript
|
Name[ca@valencia]=Estri del JavaScript
|
||||||
Name[cs]=JavaScript Widget
|
Name[cs]=JavaScript Widget
|
||||||
@ -18,7 +19,7 @@ Name[es]=Elemento gráfico JavaScript
|
|||||||
Name[et]=JavaScripti vidin
|
Name[et]=JavaScripti vidin
|
||||||
Name[eu]=JavaScript trepeta
|
Name[eu]=JavaScript trepeta
|
||||||
Name[fi]=JavaScript-sovelma
|
Name[fi]=JavaScript-sovelma
|
||||||
Name[fr]=Plasmoïde JavaScript
|
Name[fr]=Composant graphique JavaScript
|
||||||
Name[fy]=JavaSkript Widget
|
Name[fy]=JavaSkript Widget
|
||||||
Name[ga]=Giuirléid JavaScript
|
Name[ga]=Giuirléid JavaScript
|
||||||
Name[gl]=Widget de JavaScript
|
Name[gl]=Widget de JavaScript
|
||||||
@ -66,6 +67,7 @@ Name[te]=జావాస్క్రిప్ట్ విడ్జ్
|
|||||||
Name[tg]=Видҷети JavaScript
|
Name[tg]=Видҷети JavaScript
|
||||||
Name[th]=วิดเจ็ตภาษาจาวาสคริปต์
|
Name[th]=วิดเจ็ตภาษาจาวาสคริปต์
|
||||||
Name[tr]=JavaScript Programcığı
|
Name[tr]=JavaScript Programcığı
|
||||||
|
Name[ug]=JavaScript ۋىجېتى
|
||||||
Name[uk]=Віджет JavaScript
|
Name[uk]=Віджет JavaScript
|
||||||
Name[wa]=Ahesse JavaScript
|
Name[wa]=Ahesse JavaScript
|
||||||
Name[x-test]=xxJavaScript Widgetxx
|
Name[x-test]=xxJavaScript Widgetxx
|
||||||
@ -76,6 +78,7 @@ Comment[ar]=ودجة بلازما أصلية كتبت بجافا سكربت
|
|||||||
Comment[ast]=Elementu gráficu nativu de Plasma escritu en JavaScript
|
Comment[ast]=Elementu gráficu nativu de Plasma escritu en JavaScript
|
||||||
Comment[be@latin]=Widžet systemy „Plasma”, napisany ŭ movie „JavaScript”
|
Comment[be@latin]=Widžet systemy „Plasma”, napisany ŭ movie „JavaScript”
|
||||||
Comment[bg]=Оригинална джаджа за Plasma, написана с JavaScript
|
Comment[bg]=Оригинална джаджа за Plasma, написана с JavaScript
|
||||||
|
Comment[bs]=Samosvojni plazma grafička kontrola napisana u javaskriptu
|
||||||
Comment[ca]=Estri nadiu del Plasma escrit en JavaScript
|
Comment[ca]=Estri nadiu del Plasma escrit en JavaScript
|
||||||
Comment[ca@valencia]=Estri nadiu del Plasma escrit en JavaScript
|
Comment[ca@valencia]=Estri nadiu del Plasma escrit en JavaScript
|
||||||
Comment[cs]=Nativní Plasma widget napsaný v JavaScriptu
|
Comment[cs]=Nativní Plasma widget napsaný v JavaScriptu
|
||||||
@ -89,7 +92,7 @@ Comment[es]=Elemento gráfico nativo de Plasma escrito en JavaScript
|
|||||||
Comment[et]=JavaScriptis kirjutatud Plasma vidin
|
Comment[et]=JavaScriptis kirjutatud Plasma vidin
|
||||||
Comment[eu]=Plasma jatorrizko trepeta JavaScript-en idatzia
|
Comment[eu]=Plasma jatorrizko trepeta JavaScript-en idatzia
|
||||||
Comment[fi]=Natiivi, JavaScript-pohjainen Plasma-sovelma
|
Comment[fi]=Natiivi, JavaScript-pohjainen Plasma-sovelma
|
||||||
Comment[fr]=Plasmoïde natif Plasma écrit en JavaScript
|
Comment[fr]=Composant graphique natif de Plasma écrit en JavaScript
|
||||||
Comment[fy]=Plasma widget skreaun yn JavaSkript
|
Comment[fy]=Plasma widget skreaun yn JavaSkript
|
||||||
Comment[ga]=Giuirléid dhúchasach Plasma, scríofa i JavaScript
|
Comment[ga]=Giuirléid dhúchasach Plasma, scríofa i JavaScript
|
||||||
Comment[gl]=Widget nativo de Plasma escrito en JavaScript
|
Comment[gl]=Widget nativo de Plasma escrito en JavaScript
|
||||||
@ -136,6 +139,7 @@ Comment[te]=జావాస్క్రిప్ట్లో వ్రా
|
|||||||
Comment[tg]=Модуль Plasma, написанный на языке JavaScript
|
Comment[tg]=Модуль Plasma, написанный на языке JavaScript
|
||||||
Comment[th]=วิดเจ็ตพลาสมาที่ถูกเขียนด้วยจาวาสคริปต์
|
Comment[th]=วิดเจ็ตพลาสมาที่ถูกเขียนด้วยจาวาสคริปต์
|
||||||
Comment[tr]=JavaScript ile yazılmış gerçek Plasma gereci
|
Comment[tr]=JavaScript ile yazılmış gerçek Plasma gereci
|
||||||
|
Comment[ug]=JavaScript بىلەن يېزىلغان ئەسلى Plasma ۋىجېتى
|
||||||
Comment[uk]=Віджет Плазми, написаний на JavaScript
|
Comment[uk]=Віджет Плазми, написаний на JavaScript
|
||||||
Comment[wa]=Ahesse askepieye po Plasma eyet scrîte e JavaScript
|
Comment[wa]=Ahesse askepieye po Plasma eyet scrîte e JavaScript
|
||||||
Comment[x-test]=xxNative Plasma widget written in JavaScriptxx
|
Comment[x-test]=xxNative Plasma widget written in JavaScriptxx
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
Name=JavaScript DataEngine
|
Name=JavaScript DataEngine
|
||||||
Name[ar]=مشغل جافا سكربت
|
Name[ar]=مشغل جافا سكربت
|
||||||
Name[ast]=Motor de datos JavaScript
|
Name[ast]=Motor de datos JavaScript
|
||||||
|
Name[bg]=Ядро за данни на JavaScript
|
||||||
|
Name[bs]=Javascript pogon podataka
|
||||||
Name[ca]=Motor de dades de JavaScript
|
Name[ca]=Motor de dades de JavaScript
|
||||||
Name[ca@valencia]=Motor de dades de JavaScript
|
Name[ca@valencia]=Motor de dades de JavaScript
|
||||||
Name[cs]=Datový nástroj JavaScript
|
Name[cs]=Datový nástroj JavaScript
|
||||||
@ -15,7 +17,7 @@ Name[es]=Motor de datos JavaScript
|
|||||||
Name[et]=JavaScripti andmemootor
|
Name[et]=JavaScripti andmemootor
|
||||||
Name[eu]=JavaScript datu-motorea
|
Name[eu]=JavaScript datu-motorea
|
||||||
Name[fi]=JavaScript-datakone
|
Name[fi]=JavaScript-datakone
|
||||||
Name[fr]=Moteur de donnée JavaScript
|
Name[fr]=Moteur de données JavaScript
|
||||||
Name[fy]=JavaSkript gegevens motor
|
Name[fy]=JavaSkript gegevens motor
|
||||||
Name[ga]=Inneall Sonraí JavaScript
|
Name[ga]=Inneall Sonraí JavaScript
|
||||||
Name[gl]=Motor de datos de JavaScript
|
Name[gl]=Motor de datos de JavaScript
|
||||||
@ -56,7 +58,9 @@ Name[sv]=Javascript-datagränssnitt
|
|||||||
Name[tg]=Иҷрогари JavaScript
|
Name[tg]=Иҷрогари JavaScript
|
||||||
Name[th]=กลไกข้อมูลของจาวาสคริปต์
|
Name[th]=กลไกข้อมูลของจาวาสคริปต์
|
||||||
Name[tr]=JavaScript Veri Motoru
|
Name[tr]=JavaScript Veri Motoru
|
||||||
|
Name[ug]=JavaScript سانلىق مەلۇمات ماتورى
|
||||||
Name[uk]=Рушій даних JavaScript
|
Name[uk]=Рушій даних JavaScript
|
||||||
|
Name[wa]=Moteur di dnêyes JavaScript
|
||||||
Name[x-test]=xxJavaScript DataEnginexx
|
Name[x-test]=xxJavaScript DataEnginexx
|
||||||
Name[zh_CN]=JavaScript 数据引擎
|
Name[zh_CN]=JavaScript 数据引擎
|
||||||
Name[zh_TW]=JavaScript 資料引擎
|
Name[zh_TW]=JavaScript 資料引擎
|
||||||
|
@ -5,6 +5,7 @@ Name[ast]=Motor de javascript
|
|||||||
Name[be@latin]=Uklučeńnie „JavaScript”
|
Name[be@latin]=Uklučeńnie „JavaScript”
|
||||||
Name[bg]=Изпълнение на JavaScript
|
Name[bg]=Изпълнение на JavaScript
|
||||||
Name[bn_IN]=JavaScript Runner
|
Name[bn_IN]=JavaScript Runner
|
||||||
|
Name[bs]=Javascript izvođač
|
||||||
Name[ca]=Executor de JavaScript
|
Name[ca]=Executor de JavaScript
|
||||||
Name[ca@valencia]=Executor de JavaScript
|
Name[ca@valencia]=Executor de JavaScript
|
||||||
Name[cs]=Spouštěč JavaScriptu
|
Name[cs]=Spouštěč JavaScriptu
|
||||||
@ -17,7 +18,7 @@ Name[eo]=Ĝavaskripta ruligilo
|
|||||||
Name[es]=Motor de javascript
|
Name[es]=Motor de javascript
|
||||||
Name[et]=JavaScripti käivitaja
|
Name[et]=JavaScripti käivitaja
|
||||||
Name[eu]=JavaScript abiarazlea
|
Name[eu]=JavaScript abiarazlea
|
||||||
Name[fi]=JavaScript-suorittaja
|
Name[fi]=JavaScript-suoritusohjelma
|
||||||
Name[fr]=Lanceur JavaScript
|
Name[fr]=Lanceur JavaScript
|
||||||
Name[fy]=JavaSkript rinner
|
Name[fy]=JavaSkript rinner
|
||||||
Name[ga]=Feidhmitheoir JavaScript
|
Name[ga]=Feidhmitheoir JavaScript
|
||||||
@ -67,6 +68,7 @@ Name[te]=జావాస్క్రిప్ట్ నడుపునది
|
|||||||
Name[tg]=Иҷрогари JavaScript
|
Name[tg]=Иҷрогари JavaScript
|
||||||
Name[th]=ตัวประมวลผลจาวาสคริปต์
|
Name[th]=ตัวประมวลผลจาวาสคริปต์
|
||||||
Name[tr]=JavaScript Çalıştırıcı
|
Name[tr]=JavaScript Çalıştırıcı
|
||||||
|
Name[ug]=JavaScript ئىجراچىسى
|
||||||
Name[uk]=Механізм запуску JavaScript
|
Name[uk]=Механізм запуску JavaScript
|
||||||
Name[wa]=Enondeu JavaScript
|
Name[wa]=Enondeu JavaScript
|
||||||
Name[x-test]=xxJavaScript Runnerxx
|
Name[x-test]=xxJavaScript Runnerxx
|
||||||
@ -78,6 +80,7 @@ Comment[ast]=Motor de javascript
|
|||||||
Comment[be@latin]=Uklučeńnie „JavaScript”.
|
Comment[be@latin]=Uklučeńnie „JavaScript”.
|
||||||
Comment[bg]=Изпълнение на JavaScript
|
Comment[bg]=Изпълнение на JavaScript
|
||||||
Comment[bn_IN]=JavaScript Runner
|
Comment[bn_IN]=JavaScript Runner
|
||||||
|
Comment[bs]=Javascript izvođač
|
||||||
Comment[ca]=Executor de JavaScript
|
Comment[ca]=Executor de JavaScript
|
||||||
Comment[ca@valencia]=Executor de JavaScript
|
Comment[ca@valencia]=Executor de JavaScript
|
||||||
Comment[cs]=Spouštěč JavaScriptu
|
Comment[cs]=Spouštěč JavaScriptu
|
||||||
@ -90,7 +93,7 @@ Comment[eo]=Ĝavaskripta ruligilo
|
|||||||
Comment[es]=Motor de javascript
|
Comment[es]=Motor de javascript
|
||||||
Comment[et]=JavaScripti käivitaja
|
Comment[et]=JavaScripti käivitaja
|
||||||
Comment[eu]=JavaScript abiarazlea
|
Comment[eu]=JavaScript abiarazlea
|
||||||
Comment[fi]=JavaScript-suorittaja
|
Comment[fi]=JavaScript-suoritusohjelma
|
||||||
Comment[fr]=Lanceur JavaScript
|
Comment[fr]=Lanceur JavaScript
|
||||||
Comment[fy]=JavaSkript rinner
|
Comment[fy]=JavaSkript rinner
|
||||||
Comment[ga]=Feidhmitheoir JavaScript
|
Comment[ga]=Feidhmitheoir JavaScript
|
||||||
@ -140,7 +143,9 @@ Comment[te]=జావాస్క్రిప్ట్ నడుపునద
|
|||||||
Comment[tg]=Иҷрогари JavaScript
|
Comment[tg]=Иҷрогари JavaScript
|
||||||
Comment[th]=ตัวประมวลผลจาวาสคริปต์
|
Comment[th]=ตัวประมวลผลจาวาสคริปต์
|
||||||
Comment[tr]=JavaScript Çalıştırıcı
|
Comment[tr]=JavaScript Çalıştırıcı
|
||||||
|
Comment[ug]=JavaScript ئىجراچىسى
|
||||||
Comment[uk]=Механізм запуску JavaScript
|
Comment[uk]=Механізм запуску JavaScript
|
||||||
|
Comment[wa]=Enondeu JavaScript
|
||||||
Comment[x-test]=xxJavaScript Runnerxx
|
Comment[x-test]=xxJavaScript Runnerxx
|
||||||
Comment[zh_CN]=JavaScript 运行器
|
Comment[zh_CN]=JavaScript 运行器
|
||||||
Comment[zh_TW]=JavaScript 執行器
|
Comment[zh_TW]=JavaScript 執行器
|
||||||
|
@ -39,6 +39,8 @@ public:
|
|||||||
|
|
||||||
qint64 readData(char *data, qint64 maxSize)
|
qint64 readData(char *data, qint64 maxSize)
|
||||||
{
|
{
|
||||||
|
Q_UNUSED(data);
|
||||||
|
Q_UNUSED(maxSize);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,13 +81,18 @@ bool DeclarativeAppletScript::init()
|
|||||||
{
|
{
|
||||||
m_declarativeWidget = new Plasma::DeclarativeWidget(applet());
|
m_declarativeWidget = new Plasma::DeclarativeWidget(applet());
|
||||||
m_declarativeWidget->setInitializationDelayed(true);
|
m_declarativeWidget->setInitializationDelayed(true);
|
||||||
|
KGlobal::locale()->insertCatalog(description().pluginName());
|
||||||
|
|
||||||
//make possible to import extensions from the package
|
//make possible to import extensions from the package
|
||||||
//FIXME: probably to be removed, would make possible to use native code from within the package :/
|
//FIXME: probably to be removed, would make possible to use native code from within the package :/
|
||||||
//m_declarativeWidget->engine()->addImportPath(package()->path()+"/contents/imports");
|
//m_declarativeWidget->engine()->addImportPath(package()->path()+"/contents/imports");
|
||||||
|
|
||||||
//use our own custom network access manager that will access Plasma packages and to manage security (i.e. deny access to remote stuff when the proper extension isn't enabled
|
//use our own custom network access manager that will access Plasma packages and to manage security (i.e. deny access to remote stuff when the proper extension isn't enabled
|
||||||
m_declarativeWidget->engine()->setNetworkAccessManagerFactory(new PackageAccessManagerFactory(package(), &m_auth));
|
QDeclarativeEngine *engine = m_declarativeWidget->engine();
|
||||||
|
QDeclarativeNetworkAccessManagerFactory *factory = engine->networkAccessManagerFactory();
|
||||||
|
engine->setNetworkAccessManagerFactory(0);
|
||||||
|
delete factory;
|
||||||
|
engine->setNetworkAccessManagerFactory(new PackageAccessManagerFactory(package(), &m_auth));
|
||||||
|
|
||||||
m_declarativeWidget->setQmlPath(mainScript());
|
m_declarativeWidget->setQmlPath(mainScript());
|
||||||
|
|
||||||
@ -135,6 +140,9 @@ bool DeclarativeAppletScript::init()
|
|||||||
|
|
||||||
void DeclarativeAppletScript::collectGarbage()
|
void DeclarativeAppletScript::collectGarbage()
|
||||||
{
|
{
|
||||||
|
if (!m_engine) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
m_engine->collectGarbage();
|
m_engine->collectGarbage();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -195,6 +203,9 @@ QScriptValue DeclarativeAppletScript::newPlasmaSvg(QScriptContext *context, QScr
|
|||||||
|
|
||||||
QScriptValue DeclarativeAppletScript::variantToScriptValue(QVariant var)
|
QScriptValue DeclarativeAppletScript::variantToScriptValue(QVariant var)
|
||||||
{
|
{
|
||||||
|
if (!m_engine) {
|
||||||
|
return QScriptValue();
|
||||||
|
}
|
||||||
return m_engine->newVariant(var);
|
return m_engine->newVariant(var);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -268,6 +279,18 @@ QGraphicsWidget *DeclarativeAppletScript::extractParent(QScriptContext *context,
|
|||||||
return parent;
|
return parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DeclarativeAppletScript::callPlasmoidFunction(const QString &functionName, const QScriptValueList &args, ScriptEnv *env)
|
||||||
|
{
|
||||||
|
if (!m_env) {
|
||||||
|
m_env = ScriptEnv::findScriptEnv(m_engine);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (env) {
|
||||||
|
QScriptValue func = m_self.property(functionName);
|
||||||
|
m_env->callFunction(func, args, m_self);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void DeclarativeAppletScript::constraintsEvent(Plasma::Constraints constraints)
|
void DeclarativeAppletScript::constraintsEvent(Plasma::Constraints constraints)
|
||||||
{
|
{
|
||||||
if (constraints & Plasma::FormFactorConstraint) {
|
if (constraints & Plasma::FormFactorConstraint) {
|
||||||
@ -297,6 +320,9 @@ void DeclarativeAppletScript::popupEvent(bool popped)
|
|||||||
|
|
||||||
void DeclarativeAppletScript::dataUpdated(const QString &name, const Plasma::DataEngine::Data &data)
|
void DeclarativeAppletScript::dataUpdated(const QString &name, const Plasma::DataEngine::Data &data)
|
||||||
{
|
{
|
||||||
|
if (!m_engine) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
QScriptValueList args;
|
QScriptValueList args;
|
||||||
args << m_engine->toScriptValue(name) << m_engine->toScriptValue(data);
|
args << m_engine->toScriptValue(name) << m_engine->toScriptValue(data);
|
||||||
|
|
||||||
@ -308,6 +334,9 @@ void DeclarativeAppletScript::extenderItemRestored(Plasma::ExtenderItem* item)
|
|||||||
if (!m_env) {
|
if (!m_env) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (!m_engine) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
QScriptValueList args;
|
QScriptValueList args;
|
||||||
args << m_engine->newQObject(item, QScriptEngine::AutoOwnership, QScriptEngine::PreferExistingWrapperObject);
|
args << m_engine->newQObject(item, QScriptEngine::AutoOwnership, QScriptEngine::PreferExistingWrapperObject);
|
||||||
@ -331,7 +360,9 @@ void DeclarativeAppletScript::executeAction(const QString &name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
const QString func("action_" + name);
|
const QString func("action_" + name);
|
||||||
m_env->callEventListeners(func);
|
if (!m_env->callEventListeners(func)) {
|
||||||
|
callPlasmoidFunction(func, QScriptValueList(), m_env);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DeclarativeAppletScript::include(const QString &path)
|
bool DeclarativeAppletScript::include(const QString &path)
|
||||||
@ -347,6 +378,10 @@ ScriptEnv *DeclarativeAppletScript::scriptEnv()
|
|||||||
void DeclarativeAppletScript::setupObjects()
|
void DeclarativeAppletScript::setupObjects()
|
||||||
{
|
{
|
||||||
m_engine = m_declarativeWidget->scriptEngine();
|
m_engine = m_declarativeWidget->scriptEngine();
|
||||||
|
if (!m_engine) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
connect(m_engine, SIGNAL(signalHandlerException(const QScriptValue &)),
|
connect(m_engine, SIGNAL(signalHandlerException(const QScriptValue &)),
|
||||||
this, SLOT(signalHandlerException(const QScriptValue &)));
|
this, SLOT(signalHandlerException(const QScriptValue &)));
|
||||||
|
|
||||||
@ -393,7 +428,6 @@ void DeclarativeAppletScript::setupObjects()
|
|||||||
}
|
}
|
||||||
|
|
||||||
registerSimpleAppletMetaTypes(m_engine);
|
registerSimpleAppletMetaTypes(m_engine);
|
||||||
registerDataEngineMetaTypes(m_engine);
|
|
||||||
QTimer::singleShot(0, this, SLOT(configChanged()));
|
QTimer::singleShot(0, this, SLOT(configChanged()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -456,6 +490,11 @@ QScriptValue DeclarativeAppletScript::loadService(QScriptContext *context, QScri
|
|||||||
return engine->newQObject(service, QScriptEngine::AutoOwnership);
|
return engine->newQObject(service, QScriptEngine::AutoOwnership);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QList<QAction*> DeclarativeAppletScript::contextualActions()
|
||||||
|
{
|
||||||
|
return m_interface->contextualActions();
|
||||||
|
}
|
||||||
|
|
||||||
QScriptEngine *DeclarativeAppletScript::engine() const
|
QScriptEngine *DeclarativeAppletScript::engine() const
|
||||||
{
|
{
|
||||||
return m_engine;
|
return m_engine;
|
||||||
|
@ -49,7 +49,7 @@ public:
|
|||||||
|
|
||||||
QString filePath(const QString &type, const QString &file) const;
|
QString filePath(const QString &type, const QString &file) const;
|
||||||
|
|
||||||
void executeAction(const QString &name);
|
QList<QAction*> contextualActions();
|
||||||
|
|
||||||
void constraintsEvent(Plasma::Constraints constraints);
|
void constraintsEvent(Plasma::Constraints constraints);
|
||||||
|
|
||||||
@ -70,6 +70,7 @@ public:
|
|||||||
static QScriptValue loadService(QScriptContext *context, QScriptEngine *engine);
|
static QScriptValue loadService(QScriptContext *context, QScriptEngine *engine);
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
|
void executeAction(const QString &name);
|
||||||
void dataUpdated(const QString &name, const Plasma::DataEngine::Data &data);
|
void dataUpdated(const QString &name, const Plasma::DataEngine::Data &data);
|
||||||
void signalHandlerException(const QScriptValue &exception);
|
void signalHandlerException(const QScriptValue &exception);
|
||||||
void popupEvent(bool popped);
|
void popupEvent(bool popped);
|
||||||
@ -92,6 +93,7 @@ Q_SIGNALS:
|
|||||||
void contextChanged();
|
void contextChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void callPlasmoidFunction(const QString &functionName, const QScriptValueList &args, ScriptEnv *env);
|
||||||
Plasma::DeclarativeWidget *m_declarativeWidget;
|
Plasma::DeclarativeWidget *m_declarativeWidget;
|
||||||
AppletInterface *m_interface;
|
AppletInterface *m_interface;
|
||||||
EngineAccess *m_engineAccess;
|
EngineAccess *m_engineAccess;
|
||||||
|
@ -309,6 +309,7 @@ bool SimpleJavaScriptApplet::init()
|
|||||||
this, SLOT(extenderItemRestored(Plasma::ExtenderItem*)));
|
this, SLOT(extenderItemRestored(Plasma::ExtenderItem*)));
|
||||||
connect(applet(), SIGNAL(activate()),
|
connect(applet(), SIGNAL(activate()),
|
||||||
this, SLOT(activate()));
|
this, SLOT(activate()));
|
||||||
|
KGlobal::locale()->insertCatalog(description().pluginName());
|
||||||
setupObjects();
|
setupObjects();
|
||||||
|
|
||||||
AppletAuthorization auth(this);
|
AppletAuthorization auth(this);
|
||||||
|
@ -54,13 +54,19 @@ void serviceJobFromQScriptValue(const QScriptValue &scriptValue, ServiceJobPtr &
|
|||||||
serviceJob = static_cast<Plasma::ServiceJob *>(obj);
|
serviceJob = static_cast<Plasma::ServiceJob *>(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
typedef QMap< QString, QString > StringStringMap;
|
||||||
|
Q_DECLARE_METATYPE(StringStringMap)
|
||||||
|
|
||||||
void registerDataEngineMetaTypes(QScriptEngine *engine)
|
void registerDataEngineMetaTypes(QScriptEngine *engine)
|
||||||
{
|
{
|
||||||
qRegisterMetaType<Plasma::DataEngine::Data>("Plasma::DataEngine::Data");
|
qRegisterMetaType<Plasma::DataEngine::Data>("Plasma::DataEngine::Data");
|
||||||
qRegisterMetaType<Plasma::DataEngine::Data>("DataEngine::Data");
|
qRegisterMetaType<Plasma::DataEngine::Data>("DataEngine::Data");
|
||||||
qScriptRegisterMapMetaType<Plasma::DataEngine::Data>(engine);
|
qScriptRegisterVariantMapMetaType<Plasma::DataEngine::Data>(engine);
|
||||||
|
qScriptRegisterMapMetaType<StringStringMap>(engine);
|
||||||
qScriptRegisterMetaType<Plasma::Service *>(engine, qScriptValueFromService, serviceFromQScriptValue);
|
qScriptRegisterMetaType<Plasma::Service *>(engine, qScriptValueFromService, serviceFromQScriptValue);
|
||||||
qScriptRegisterMetaType<Plasma::DataEngine *>(engine, qScriptValueFromDataEngine, dataEngineFromQScriptValue);
|
qScriptRegisterMetaType<Plasma::DataEngine *>(engine, qScriptValueFromDataEngine, dataEngineFromQScriptValue);
|
||||||
qScriptRegisterMetaType<Plasma::ServiceJob *>(engine, qScriptValueFromServiceJob, serviceJobFromQScriptValue);
|
qScriptRegisterMetaType<Plasma::ServiceJob *>(engine, qScriptValueFromServiceJob, serviceJobFromQScriptValue);
|
||||||
|
qRegisterMetaType<Plasma::Service *>("Service*");
|
||||||
|
qRegisterMetaType<Plasma::ServiceJob *>("ServiceJob*");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,8 +30,6 @@
|
|||||||
|
|
||||||
using namespace Plasma;
|
using namespace Plasma;
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(Service*)
|
|
||||||
Q_DECLARE_METATYPE(ServiceJob*)
|
|
||||||
#ifndef DECLARATIVE_BINDING
|
#ifndef DECLARATIVE_BINDING
|
||||||
Q_DECLARE_METATYPE(QVariant)
|
Q_DECLARE_METATYPE(QVariant)
|
||||||
#endif
|
#endif
|
||||||
@ -40,6 +38,21 @@ Q_DECLARE_METATYPE(DataEngine::Data)
|
|||||||
|
|
||||||
template <class M>
|
template <class M>
|
||||||
QScriptValue qScriptValueFromMap(QScriptEngine *eng, const M &map)
|
QScriptValue qScriptValueFromMap(QScriptEngine *eng, const M &map)
|
||||||
|
{
|
||||||
|
//kDebug() << "qScriptValueFromMap called";
|
||||||
|
QScriptValue obj = eng->newObject();
|
||||||
|
typename M::const_iterator begin = map.constBegin();
|
||||||
|
typename M::const_iterator end = map.constEnd();
|
||||||
|
typename M::const_iterator it;
|
||||||
|
for (it = begin; it != end; ++it) {
|
||||||
|
obj.setProperty(it.key(), qScriptValueFromValue(eng, it.value()));
|
||||||
|
}
|
||||||
|
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class M>
|
||||||
|
QScriptValue qScriptValueFromVariantMap(QScriptEngine *eng, const M &map)
|
||||||
{
|
{
|
||||||
//kDebug() << "qScriptValueFromMap called";
|
//kDebug() << "qScriptValueFromMap called";
|
||||||
QScriptValue obj = eng->newObject();
|
QScriptValue obj = eng->newObject();
|
||||||
@ -70,6 +83,18 @@ void qScriptValueToMap(const QScriptValue &value, M &map)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
int qScriptRegisterVariantMapMetaType(
|
||||||
|
QScriptEngine *engine,
|
||||||
|
const QScriptValue &prototype = QScriptValue()
|
||||||
|
#ifndef qdoc
|
||||||
|
, T * /* dummy */ = 0
|
||||||
|
#endif
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return qScriptRegisterMetaType<T>(engine, qScriptValueFromVariantMap, qScriptValueToMap, prototype);
|
||||||
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
int qScriptRegisterMapMetaType(
|
int qScriptRegisterMapMetaType(
|
||||||
QScriptEngine *engine,
|
QScriptEngine *engine,
|
||||||
|
@ -92,7 +92,6 @@ QScriptValue constructIconClass(QScriptEngine *eng)
|
|||||||
{
|
{
|
||||||
QScriptValue proto = qScriptValueFromValue(eng, QIcon());
|
QScriptValue proto = qScriptValueFromValue(eng, QIcon());
|
||||||
QScriptValue::PropertyFlags getter = QScriptValue::PropertyGetter;
|
QScriptValue::PropertyFlags getter = QScriptValue::PropertyGetter;
|
||||||
QScriptValue::PropertyFlags setter = QScriptValue::PropertySetter;
|
|
||||||
proto.setProperty("addPixmap", eng->newFunction(addPixmap));
|
proto.setProperty("addPixmap", eng->newFunction(addPixmap));
|
||||||
proto.setProperty("addFile", eng->newFunction(addFile));
|
proto.setProperty("addFile", eng->newFunction(addFile));
|
||||||
proto.setProperty("null", eng->newFunction(isNull), getter);
|
proto.setProperty("null", eng->newFunction(isNull), getter);
|
||||||
|
@ -68,7 +68,6 @@ QScriptValue constructQPixmapClass(QScriptEngine *eng)
|
|||||||
{
|
{
|
||||||
QScriptValue proto = qScriptValueFromValue(eng, QPixmap());
|
QScriptValue proto = qScriptValueFromValue(eng, QPixmap());
|
||||||
QScriptValue::PropertyFlags getter = QScriptValue::PropertyGetter;
|
QScriptValue::PropertyFlags getter = QScriptValue::PropertyGetter;
|
||||||
QScriptValue::PropertyFlags setter = QScriptValue::PropertySetter;
|
|
||||||
proto.setProperty("null", eng->newFunction(null), getter);
|
proto.setProperty("null", eng->newFunction(null), getter);
|
||||||
proto.setProperty("rect", eng->newFunction(rect), getter);
|
proto.setProperty("rect", eng->newFunction(rect), getter);
|
||||||
proto.setProperty("scaled", eng->newFunction(scaled));
|
proto.setProperty("scaled", eng->newFunction(scaled));
|
||||||
|
@ -1 +1,2 @@
|
|||||||
add_subdirectory(plasmapkg)
|
add_subdirectory(plasmapkg)
|
||||||
|
add_subdirectory(plasma-remote-helper)
|
||||||
|
10
tools/plasma-remote-helper/CMakeLists.txt
Normal file
10
tools/plasma-remote-helper/CMakeLists.txt
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
set(plasma_remote_helper_SRCS
|
||||||
|
main.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
kde4_add_executable(plasma-remote-helper ${plasma_remote_helper_SRCS})
|
||||||
|
|
||||||
|
target_link_libraries(plasma-remote-helper ${KDE4_KDEUI_LIBS})
|
||||||
|
|
||||||
|
install(TARGETS plasma-remote-helper ${INSTALL_TARGETS_DEFAULT_ARGS})
|
||||||
|
|
2
tools/plasma-remote-helper/Messages.sh
Executable file
2
tools/plasma-remote-helper/Messages.sh
Executable file
@ -0,0 +1,2 @@
|
|||||||
|
#! /usr/bin/env bash
|
||||||
|
$XGETTEXT *.cpp -o $podir/plasma-remote-helper.pot
|
81
tools/plasma-remote-helper/main.cpp
Normal file
81
tools/plasma-remote-helper/main.cpp
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
/* Copyright 2011 Kevin Ottens <ervin@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,
|
||||||
|
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 Library 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 <iostream>
|
||||||
|
|
||||||
|
#include <QtDBus/QDBusInterface>
|
||||||
|
#include <QtDBus/QDBusReply>
|
||||||
|
|
||||||
|
#include <KDE/KApplication>
|
||||||
|
#include <KDE/KAboutData>
|
||||||
|
#include <KDE/KCmdLineArgs>
|
||||||
|
|
||||||
|
static const char description[] = I18N_NOOP("Trigger the installation of a remote Plasma Widget");
|
||||||
|
static const char version[] = "0.1";
|
||||||
|
|
||||||
|
int addRemotePlasmoidToShell(const QString &shellName, const QString &url)
|
||||||
|
{
|
||||||
|
QString serviceName = "org.kde." + shellName;
|
||||||
|
QDBusInterface iface(serviceName, "/App");
|
||||||
|
|
||||||
|
if (!iface.isValid()) {
|
||||||
|
std::cerr << "Error: Couldn't contact "
|
||||||
|
<< shellName.toLocal8Bit().constData() << std::endl;
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
|
QDBusReply<void> reply = iface.call("addRemotePlasmoid", url);
|
||||||
|
if (!reply.isValid()) {
|
||||||
|
std::cerr << "Error: Couldn't call addRemotePlasmoid on "
|
||||||
|
<< shellName.toLocal8Bit().constData() << std::endl;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
KAboutData aboutData("plasma-remote-helper", 0, ki18n("Plasma Remote Widget Helper"),
|
||||||
|
version, ki18n(description), KAboutData::License_GPL,
|
||||||
|
ki18n("(C) 2011 Kevin Ottens"));
|
||||||
|
aboutData.addAuthor( ki18n("Kevin Ottens"),
|
||||||
|
ki18n("Original author"),
|
||||||
|
"ervin@kde.org" );
|
||||||
|
|
||||||
|
KComponentData componentData(aboutData);
|
||||||
|
|
||||||
|
KCmdLineArgs::init( argc, argv, &aboutData );
|
||||||
|
|
||||||
|
KCmdLineOptions options;
|
||||||
|
options.add("+<url>", ki18n("URL to the Plasma Remote Widget."));
|
||||||
|
KCmdLineArgs::addCmdLineOptions( options );
|
||||||
|
|
||||||
|
KApplication app;
|
||||||
|
|
||||||
|
KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
|
||||||
|
if (args->count()<1) {
|
||||||
|
KCmdLineArgs::usageError(i18n("Syntax Error: Not enough arguments"));
|
||||||
|
} else if (args->count()>1) {
|
||||||
|
KCmdLineArgs::usageError(i18n("Syntax Error: Too many arguments"));
|
||||||
|
}
|
||||||
|
|
||||||
|
QString url = args->arg(0);
|
||||||
|
return addRemotePlasmoidToShell("plasma-desktop", url);
|
||||||
|
}
|
||||||
|
|
@ -18,6 +18,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <iomanip>
|
||||||
|
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QDBusInterface>
|
#include <QDBusInterface>
|
||||||
@ -74,41 +75,93 @@ void listPackages(const QStringList& types)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void renderTypeTable(const QMap<QString, QStringList> &plugins)
|
||||||
|
{
|
||||||
|
const QString nameHeader = i18n("Addon Name");
|
||||||
|
const QString pluginHeader = i18n("Service Type");
|
||||||
|
const QString pathHeader = i18n("Path");
|
||||||
|
int nameWidth = nameHeader.length();
|
||||||
|
int pluginWidth = pluginHeader.length();
|
||||||
|
int pathWidth = pathHeader.length();
|
||||||
|
|
||||||
|
QMapIterator<QString, QStringList> pluginIt(plugins);
|
||||||
|
while (pluginIt.hasNext()) {
|
||||||
|
pluginIt.next();
|
||||||
|
if (pluginIt.key().length() > nameWidth) {
|
||||||
|
nameWidth = pluginIt.key().length();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pluginIt.value()[0].length() > pluginWidth) {
|
||||||
|
pluginWidth = pluginIt.value()[0].length();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pluginIt.value()[1].length() > pathWidth) {
|
||||||
|
pathWidth = pluginIt.value()[1].length();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::cout << nameHeader.toLocal8Bit().constData() << std::setw(nameWidth - nameHeader.length() + 2) << ' '
|
||||||
|
<< pluginHeader.toLocal8Bit().constData() << std::setw(pluginWidth - pluginHeader.length() + 2) << ' '
|
||||||
|
<< pathHeader.toLocal8Bit().constData() << std::endl;
|
||||||
|
std::cout << std::setfill('-') << std::setw(nameWidth) << '-' << " "
|
||||||
|
<< std::setw(pluginWidth) << '-' << " "
|
||||||
|
<< std::setw(pathWidth) << '-' << std::endl;
|
||||||
|
std::cout << std::setfill(' ');
|
||||||
|
|
||||||
|
pluginIt.toFront();
|
||||||
|
while (pluginIt.hasNext()) {
|
||||||
|
pluginIt.next();
|
||||||
|
std::cout << pluginIt.key().toLocal8Bit().constData() << std::setw(nameWidth - pluginIt.key().length() + 2) << ' '
|
||||||
|
<< pluginIt.value()[0].toLocal8Bit().constData() << std::setw(pluginWidth - pluginIt.value()[0].length() + 2) << ' '
|
||||||
|
<< pluginIt.value()[1].toLocal8Bit().constData() << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void listTypes()
|
void listTypes()
|
||||||
{
|
{
|
||||||
output(i18n("Package types that are installable with this tool:"));
|
output(i18n("Package types that are installable with this tool:"));
|
||||||
output(i18n("Built in:"));
|
output(i18n("Built in:"));
|
||||||
output(i18n(" dataengine: Plasma DataEngine plugin"));
|
|
||||||
output(i18n(" layout-template: Plasma containment and widget layout script"));
|
QMap<QString, QStringList> builtIns;
|
||||||
output(i18n(" plasmoid: Plasma widget"));
|
builtIns.insert(i18n("DataEngine"), QStringList() << "Plasma/DataEngine" << "plasma/dataengines/");
|
||||||
output(i18n(" runner: Search plugin (KRunner, etc)"));
|
builtIns.insert(i18n("Layout Template"), QStringList() << "Plasma/LayoutTemplate" << "plasma/layout-templates/");
|
||||||
output(i18n(" theme: Plasma SVG theme"));
|
builtIns.insert(i18n("Plasmoid"), QStringList() << "Plasma/Applet" << "plasma/plasmoids/");
|
||||||
output(i18n(" wallpaper: Image pack for use with wallpaper backgrounds"));
|
builtIns.insert(i18n("Runner"), QStringList() << "Plasma/Runner" << "plasma/runners/");
|
||||||
output(i18n(" wallpaperplugin: Wallpaper plugin"));
|
builtIns.insert(i18n("Theme"), QStringList() << "" << "desktoptheme/");
|
||||||
|
builtIns.insert(i18n("Wallpaper Images"), QStringList() << "" << "wallpapers/");
|
||||||
|
builtIns.insert(i18n("Wallpaper Plugin"), QStringList() << "Plasma/Wallpaper" << "plasma/wallpapers/");
|
||||||
|
renderTypeTable(builtIns);
|
||||||
|
|
||||||
KService::List offers = KServiceTypeTrader::self()->query("Plasma/PackageStructure");
|
KService::List offers = KServiceTypeTrader::self()->query("Plasma/PackageStructure");
|
||||||
if (!offers.isEmpty()) {
|
if (!offers.isEmpty()) {
|
||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
output(i18n("Provided by plugins:"));
|
output(i18n("Provided by plugins:"));
|
||||||
|
|
||||||
|
QMap<QString, QStringList> plugins;
|
||||||
foreach (const KService::Ptr service, offers) {
|
foreach (const KService::Ptr service, offers) {
|
||||||
KPluginInfo info(service);
|
KPluginInfo info(service);
|
||||||
output(i18nc("Plugin name and the kind of Plasma related content it provides, both from the plugin's desktop file",
|
Plasma::PackageStructure::Ptr structure = Plasma::PackageStructure::load(info.pluginName());
|
||||||
" %1: %2", info.pluginName(), info.name()));
|
QString name = info.name();
|
||||||
|
QString plugin = info.pluginName();
|
||||||
|
QString path = structure->defaultPackageRoot();
|
||||||
|
plugins.insert(name, QStringList() << plugin << path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
renderTypeTable(plugins);
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList desktopFiles = KGlobal::dirs()->findAllResources("data", "plasma/packageformats/*rc", KStandardDirs::NoDuplicates);
|
QStringList desktopFiles = KGlobal::dirs()->findAllResources("data", "plasma/packageformats/*rc", KStandardDirs::NoDuplicates);
|
||||||
if (!desktopFiles.isEmpty()) {
|
if (!desktopFiles.isEmpty()) {
|
||||||
output(i18n("Provided by .desktop files:"));
|
output(i18n("Provided by .desktop files:"));
|
||||||
Plasma::PackageStructure structure;
|
Plasma::PackageStructure structure;
|
||||||
|
QMap<QString, QStringList> plugins;
|
||||||
foreach (const QString &file, desktopFiles) {
|
foreach (const QString &file, desktopFiles) {
|
||||||
// extract the type
|
// extract the type
|
||||||
KConfig config(file, KConfig::SimpleConfig);
|
KConfig config(file, KConfig::SimpleConfig);
|
||||||
structure.read(&config);
|
structure.read(&config);
|
||||||
// get the name based on the rc file name, just as Plasma::PackageStructure does
|
// get the name based on the rc file name, just as Plasma::PackageStructure does
|
||||||
const QString name = file.left(file.length() - 2);
|
const QString name = file.left(file.length() - 2);
|
||||||
output(i18nc("Plugin name and the kind of Plasma related content it provides, both from the plugin's desktop file",
|
plugins.insert(name, QStringList() << structure.type() << structure.defaultPackageRoot());
|
||||||
" %1: %2", name, structure.type()));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user