Libplasma
containmentitem.cpp
59 // This can happen only if the client QML code declares a PlasmoidItem somewhere else than the root object
63 connect(m_containment.data(), &Plasma::Containment::appletAboutToBeRemoved, this, &ContainmentItem::appletRemovedForward);
64 connect(m_containment.data(), &Plasma::Containment::appletAboutToBeAdded, this, &ContainmentItem::appletAddedForward);
66 connect(m_containment->corona(), &Plasma::Corona::editModeChanged, this, &ContainmentItem::editModeChanged);
73 // This can happen only if the client QML code declares a PlasmoidItem somewhere else than the root object
92 defaults = KConfigGroup(KSharedConfig::openConfig(m_containment->corona()->kPackage().filePath("defaults")), QStringLiteral("Desktop"));
94 defaults = KConfigGroup(KSharedConfig::openConfig(m_containment->corona()->kPackage().filePath("defaults")), QStringLiteral("Panel"));
98 KPackage::Package pkg = KPackage::PackageLoader::self()->loadPackage(QStringLiteral("Plasma/Generic"));
113 QObject *toolBoxObject = qmlObject()->createObjectFromSource(pkg.fileUrl("mainscript"), nullptr, toolboxProperties);
129 connect(m_containment.data(), &Plasma::Containment::wallpaperPluginChanged, this, &ContainmentItem::loadWallpaper);
131 connect(m_containment, &Plasma::Containment::internalActionsChanged, this, &ContainmentItem::actionsChanged);
132 connect(m_containment, &Plasma::Containment::contextualActionsChanged, this, &ContainmentItem::actionsChanged);
147Plasma::Applet *ContainmentItem::createApplet(const QString &plugin, const QVariantList &args, const QRectF &geom)
152void ContainmentItem::setAppletArgs(Plasma::Applet *applet, const QString &mimetype, const QVariant &data)
158 PlasmoidItem *plasmoidItem = qobject_cast<PlasmoidItem *>(AppletQuickItem::itemForApplet(applet));
170 ContainmentItem *contInterface = qobject_cast<ContainmentItem *>(AppletQuickItem::itemForApplet(c));
191 PlasmoidItem *appletItem = qobject_cast<PlasmoidItem *>(AppletQuickItem::itemForApplet(applet));
205 PlasmoidItem *appletItem = qobject_cast<PlasmoidItem *>(AppletQuickItem::itemForApplet(applet));
274 std::sort(horizontalGrid.begin(), horizontalGrid.end(), [&leftAlignedGrid, &rightAlignedGrid, rect](int a, int b) {
337 QMouseEvent me(QEvent::MouseButtonRelease, QPointF(), globalPos, Qt::RightButton, Qt::RightButton, Qt::NoModifier);
341void ContainmentItem::processMimeData(QObject *mimeDataProxy, int x, int y, KIO::DropJob *dropJob)
363 m_dropMenu = QPointer<DropMenu>(new DropMenu(dropJob, mapToGlobal(QPoint(x, y)).toPoint(), this));
367 qDebug() << "Arrived mimeData" << mimeData->urls() << mimeData->formats() << "at" << x << ", " << y;
370 if (!mimeData->hasUrls() && mimeData->hasFormat(QStringLiteral("text/x-orgkdeplasmataskmanager_taskurl"))) {
371 QList<QUrl> urls = {QUrl(QString::fromUtf8(mimeData->data(QStringLiteral("text/x-orgkdeplasmataskmanager_taskurl"))))};
393 // Set parent to null and free up from old container only if we are dropping on a different containment
446 QObject::connect(job, &KIO::MimetypeJob::mimeTypeFound, this, &ContainmentItem::mimeTypeRetrieved);
477 setAppletArgs(applet, pluginFormats[selectedPlugin], mimeData->data(pluginFormats[selectedPlugin]));
540 QList<KPluginMetaData> appletList = Plasma::PluginLoader::self()->listAppletMetaDataForUrl(tjob->url());
543 qDebug() << "No applets found matching the url (" << tjob->url() << ") or the mimetype (" << mimetype << ")";
566 if ((!appletList.isEmpty() || !wallpaperList.isEmpty() || isPlasmaPackage) && !m_dropMenu->isMultipleMimetypes()) {
573 installPlasmaPackageAction = new QAction(QIcon::fromTheme(QStringLiteral("application-x-plasma")), i18n("Install"), m_dropMenu);
604 createApplet(package.metadata().pluginId(), QVariantList(), QRect(m_dropMenu->dropPoint(), QSize(-1, -1)));
623 Plasma::Applet *applet = createApplet(action->data().toString(), QVariantList(), QRect(m_dropMenu->dropPoint(), QSize(-1, -1)));
633 Plasma::Applet *applet = createApplet(action->data().toString(), QVariantList(), QRect(m_dropMenu->dropPoint(), QSize(-1, -1)));
671 // case in which we created the menu ourselves, just the "fetching type entry, directly create the icon applet
673 Plasma::Applet *applet = createApplet(QStringLiteral("org.kde.plasma.icon"), QVariantList(), QRect(m_dropMenu->dropPoint(), QSize(-1, -1)));
685 PlasmoidItem *appletGraphicObject = qobject_cast<PlasmoidItem *>(AppletQuickItem::itemForApplet(applet));
701 } else if (position.isNull() && m_containment->containmentType() == Plasma::Containment::Type::Desktop) {
718 PlasmoidItem *appletGraphicObject = qobject_cast<PlasmoidItem *>(AppletQuickItem::itemForApplet(applet));
733 if (m_containment->containmentType() != Plasma::Containment::Type::Desktop && m_containment->containmentType() != Plasma::Containment::Type::Custom) {
767 QQmlExpression expr(qmlObject()->engine()->rootContext(), m_wallpaperItem, QStringLiteral("parent"));
781 event->setAccepted(m_containment->containmentActions().contains(Plasma::ContainmentActions::eventToString(event)));
863 // this happens if a window which does not accept focus spawns a new window that takes focus and X grab
967 QMouseEvent me(QEvent::MouseButtonRelease, localPos, QPointF(), Qt::RightButton, Qt::RightButton, event->modifiers());
973void ContainmentItem::addAppletActions(QMenu *desktopMenu, Plasma::Applet *applet, QEvent *event)
1004 && (m_containment->containmentType() != Plasma::Containment::Type::Panel || m_containment->isUserConfiguring())) {
1070 // This can happen only if the client QML code declares a PlasmoidItem somewhere else than the root object
Q_INVOKABLE QObject * containmentItemAt(int x, int y)
Search for a containment at those coordinates.
Definition containmentitem.cpp:165
Q_INVOKABLE QPointF adjustToAvailableScreenRegion(int x, int y, int w, int h) const
Given a geometry, it adjusts it moving it completely inside of the boundaries of availableScreenRegio...
Definition containmentitem.cpp:219
Q_INVOKABLE AppletQuickItem * itemFor(Plasma::Applet *applet) const
Returns the corresponding PlasmoidItem of one of its applets.
Definition containmentitem.cpp:135
Q_INVOKABLE QPointF mapToApplet(Plasma::Applet *applet, int x, int y)
Map coordinates from relative to this containment to relative to the given applet.
Definition containmentitem.cpp:203
Q_INVOKABLE void processMimeData(QMimeData *data, int x, int y, KIO::DropJob *dropJob=nullptr)
Process the mime data arrived to a particular coordinate, either with a drag and drop or paste with m...
Definition containmentitem.cpp:351
Q_INVOKABLE void openContextMenu(const QPointF &globalPos)
Opens the context menu of the Corona.
Definition containmentitem.cpp:331
Q_INVOKABLE QPointF mapFromApplet(Plasma::Applet *applet, int x, int y)
Map coordinates from relative to the given applet to relative to this containment.
Definition containmentitem.cpp:189
static void manage(QWidget *widget, bool programmers_mode=false)
static Q_INVOKABLE bool authorizeAction(const QString &action)
const QUrl & url() const
void mimeTypeFound(KIO::Job *job, const QString &mimeType)
virtual QString errorString() const
int error() const
void result(KJob *job)
void finished(KJob *job)
static KNotification * event(const QString &eventId, const QString &text=QString(), const QPixmap &pixmap=QPixmap(), const NotificationFlags &flags=CloseOnTimeout, const QString &componentName=QString())
CloseOnTimeout
Package loadPackage(const QString &packageFormat, const QString &packagePath=QString())
static PackageLoader * self()
void setPath(const QString &path)
QUrl fileUrl(const QByteArray &key, const QString &filename=QString()) const
bool isValid() const
const QString path() const
void setDefaultPackageRoot(const QString &packageRoot)
KPluginMetaData metadata() const
bool isHidden() const
bool isValid() const
void contextualActionsChanged(const QList< QAction * > &actions)
Emitted when the list of contextual actions has changed.
void internalActionsChanged(const QList< QAction * > &actions)
Emitted when the list of internal actions has changed.
virtual QList< QAction * > contextualActions()
Implement this to provide a list of actions that can be added to another menu for example,...
Definition containmentactions.cpp:102
virtual void restore(const KConfigGroup &config)
This method should be called once the plugin is loaded or settings are changed.
Definition containmentactions.cpp:71
virtual void performPreviousAction()
Called when a "previous" action is triggered (e.g.
Definition containmentactions.cpp:97
virtual void performNextAction()
Called when a "next" action is triggered (e.g.
Definition containmentactions.cpp:92
Containment * containment()
Definition containmentactions.cpp:63
void setContainment(Containment *newContainment)
newContainment the containment the plugin should be associated with.
Definition containmentactions.cpp:150
static QString eventToString(QEvent *event)
Turns a mouse or wheel event into a string suitable for a ContainmentActions.
Definition containmentactions.cpp:107
The base class for plugins that provide backgrounds and applet grouping containers.
Definition containment.h:47
@ Custom
A containment that is neither a desktop nor a panel but something application specific.
Definition containment.h:138
void wallpaperPluginChanged()
Emitted when the wallpaper plugin is changed.
void appletAboutToBeRemoved(Plasma::Applet *applet)
This signal is emitted right before appletRemoved, it can be used to do a preliminary setup on the ap...
void appletAboutToBeAdded(Plasma::Applet *applet, const QRectF &geometryHint)
This signal is emitted right before appletAdded, it can be used to do a preliminary setup on the appl...
void editModeChanged(bool edit)
emitted when the editMode state changes
QList< KPluginMetaData > listAppletMetaDataForUrl(const QUrl &url)
Returns a list of all known applets associated with a certain URL.
Definition pluginloader.cpp:193
QList< KPluginMetaData > listAppletMetaDataForMimeType(const QString &mimetype)
Returns a list of all known applets associated with a certain mimetype.
Definition pluginloader.cpp:185
void externalData(const QString &mimetype, const QVariant &data)
somebody else, usually the containment sent some data to the applet
static WallpaperItem * loadWallpaper(ContainmentItem *ContainmentItem)
Instantiate the WallpaperItem for a given containment, using the proper plugin.
Definition wallpaperitem.cpp:124
static QList< KPluginMetaData > listWallpaperMetadataForMimetype(const QString &mimetype, const QString &formFactor=QString())
Returns a list of all known wallpapers that can accept the given mimetype.
Definition wallpaperitem.cpp:72
QString i18nc(const char *context, const char *text, const TYPE &arg...)
QString i18n(const char *text, const TYPE &arg...)
KIOCORE_EXPORT MimetypeJob * mimetype(const QUrl &url, JobFlags flags=DefaultFlags)
QFlags< JobFlag > JobFlags
HideProgressInfo
GeoCoordinates geo(const QVariant &location)
KGuiItem defaults()
KCOREADDONS_EXPORT QList< QUrl > urlsFromMimeData(const QMimeData *mimeData, DecodeOptions decodeOptions=PreferKdeUrls, MetaDataMap *metaData=nullptr)
QVariant data() const const
bool isEnabled() const const
void setIcon(const QIcon &icon)
void setData(const QVariant &data)
void setSeparator(bool b)
void trigger()
void triggered(bool checked)
MouseButtonRelease
void restoreOverrideCursor()
void setOverrideCursor(const QCursor &cursor)
const Key & key() const const
const_iterator constBegin() const const
bool contains(const Key &key) const const
qsizetype count() const const
iterator insert(const Key &key, const T &value)
bool isEmpty() const const
QIcon fromTheme(const QString &name)
const_reference at(qsizetype i) const const
iterator begin()
qsizetype count() const const
pointer data()
iterator end()
bool isEmpty() const const
iterator insert(const Key &key, const T &value)
bool invokeMethod(QObject *context, Functor &&function, FunctorReturnType *ret)
QByteArray data(const QString &mimeType) const const
virtual QStringList formats() const const
virtual bool hasFormat(const QString &mimeType) const const
bool hasUrls() const const
void setUrls(const QList< QUrl > &urls)
QList< QUrl > urls() const const
QMimeType mimeTypeForUrl(const QUrl &url) const const
QObject(QObject *parent)
Q_EMITQ_EMIT
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
void destroyed(QObject *obj)
bool disconnect(const QMetaObject::Connection &connection)
virtual const QMetaObject * metaObject() const const
QVariant property(const char *name) const const
T qobject_cast(QObject *object)
bool setProperty(const char *name, QVariant &&value)
int x() const const
int y() const const
bool isNull() const const
qreal x() const const
qreal y() const const
void ungrabMouse()
ItemSceneChange
virtual void classBegin() override
virtual bool event(QEvent *ev) override
Flags flags() const const
height
virtual void itemChange(ItemChange change, const ItemChangeData &value)
virtual void keyPressEvent(QKeyEvent *event)
QPointF mapToGlobal(const QPointF &point) const const
QPointF mapToItem(const QQuickItem *item, const QPointF &point) const const
QPointF mapToScene(const QPointF &point) const const
void setParentItem(QQuickItem *parent)
void setSize(const QSizeF &size)
bool isVisible() const const
width
QQuickWindow * window() const const
QQuickItem * mouseGrabberItem() const const
activeFocusItem
int bottom() const const
bool contains(const QPoint &point, bool proper) const const
int left() const const
int right() const const
int top() const const
QPoint topLeft() const const
qreal height() const const
QSizeF size() const const
QPointF topLeft() const const
qreal width() const const
qreal x() const const
qreal y() const const
const_iterator begin() const const
QRect boundingRect() const const
typedef const_iterator
const_iterator end() const const
bool isEmpty() const const
void translate(const QPoint &point)
bool contains(const QSet< T > &other) const const
iterator insert(const T &value)
QString fromUtf8(QByteArrayView str)
QString number(double n, char format, int precision)
QStringList split(QChar sep, Qt::SplitBehavior behavior, Qt::CaseSensitivity cs) const const
QueuedConnection
WaitCursor
Key_Menu
NoModifier
AllButtons
SkipEmptyParts
WA_TranslucentBackground
singleShot
bool isValid() const const
QString toLocalFile() const const
QVariant fromValue(T &&value)
QString toString() const const
T value() const const
QVersionNumber fromString(QAnyStringView string, qsizetype *suffixIndex)
void addActions(const QList< QAction * > &actions)
QRect geometry() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri Jan 24 2025 11:48:23 by doxygen 1.13.2 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri Jan 24 2025 11:48:23 by doxygen 1.13.2 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.