Libplasma
containmentitem.cpp
61 // This can happen only if the client QML code declares a PlasmoidItem somewhere else than the root object
65 connect(m_containment.data(), &Plasma::Containment::appletAboutToBeRemoved, this, &ContainmentItem::appletRemovedForward);
66 connect(m_containment.data(), &Plasma::Containment::appletAboutToBeAdded, this, &ContainmentItem::appletAddedForward);
68 connect(m_containment->corona(), &Plasma::Corona::editModeChanged, this, &ContainmentItem::editModeChanged);
75 // This can happen only if the client QML code declares a PlasmoidItem somewhere else than the root object
91 if (m_containment && m_containment->isContainment() && m_containment->containmentType() == Plasma::Containment::Type::Panel) {
93 defaults = KConfigGroup(KSharedConfig::openConfig(m_containment->corona()->kPackage().filePath("defaults")), QStringLiteral("Panel"));
96 KPackage::Package pkg = KPackage::PackageLoader::self()->loadPackage(QStringLiteral("Plasma/Generic"));
106 QObject *toolBoxObject = qmlObject()->createObjectFromSource(pkg.fileUrl("mainscript"), nullptr, toolboxProperties);
117 qCWarning(LOG_PLASMAQUICK) << "Toolbox not loading, toolbox package is either invalid or disabled.";
122 connect(m_containment.data(), &Plasma::Containment::wallpaperPluginChanged, this, &ContainmentItem::loadWallpaper);
124 connect(m_containment, &Plasma::Containment::internalActionsChanged, this, &ContainmentItem::actionsChanged);
125 connect(m_containment, &Plasma::Containment::contextualActionsChanged, this, &ContainmentItem::actionsChanged);
140Plasma::Applet *ContainmentItem::createApplet(const QString &plugin, const QVariantList &args, const QRectF &geom)
145void ContainmentItem::setAppletArgs(Plasma::Applet *applet, const QString &mimetype, const QVariant &data)
151 PlasmoidItem *plasmoidItem = qobject_cast<PlasmoidItem *>(AppletQuickItem::itemForApplet(applet));
163 ContainmentItem *contInterface = qobject_cast<ContainmentItem *>(AppletQuickItem::itemForApplet(c));
184 PlasmoidItem *appletItem = qobject_cast<PlasmoidItem *>(AppletQuickItem::itemForApplet(applet));
198 PlasmoidItem *appletItem = qobject_cast<PlasmoidItem *>(AppletQuickItem::itemForApplet(applet));
267 std::sort(horizontalGrid.begin(), horizontalGrid.end(), [&leftAlignedGrid, &rightAlignedGrid, rect](int a, int b) {
330 QMouseEvent me(QEvent::MouseButtonRelease, QPointF(), globalPos, Qt::RightButton, Qt::RightButton, Qt::NoModifier);
334void ContainmentItem::processMimeData(QObject *mimeDataProxy, int x, int y, KIO::DropJob *dropJob)
356 m_dropMenu = QPointer<DropMenu>(new DropMenu(dropJob, mapToGlobal(QPoint(x, y)).toPoint(), this));
360 qCDebug(LOG_PLASMAQUICK) << "Arrived mimeData" << mimeData->urls() << mimeData->formats() << "at" << x << ", " << y;
363 if (!mimeData->hasUrls() && mimeData->hasFormat(QStringLiteral("text/x-orgkdeplasmataskmanager_taskurl"))) {
364 QList<QUrl> urls = {QUrl(QString::fromUtf8(mimeData->data(QStringLiteral("text/x-orgkdeplasmataskmanager_taskurl"))))};
386 // Set parent to null and free up from old container only if we are dropping on a different containment
439 QObject::connect(job, &KIO::MimetypeJob::mimeTypeFound, this, &ContainmentItem::mimeTypeRetrieved);
470 setAppletArgs(applet, pluginFormats[selectedPlugin], mimeData->data(pluginFormats[selectedPlugin]));
533 QList<KPluginMetaData> appletList = Plasma::PluginLoader::self()->listAppletMetaDataForUrl(tjob->url());
536 qCDebug(LOG_PLASMAQUICK) << "No applets found matching the url (" << tjob->url() << ") or the mimetype (" << mimetype << ")";
540 qCDebug(LOG_PLASMAQUICK) << "Bailing out. Cannot find associated dropEvent related to the TransferJob";
559 if ((!appletList.isEmpty() || !wallpaperList.isEmpty() || isPlasmaPackage) && !m_dropMenu->isMultipleMimetypes()) {
566 installPlasmaPackageAction = new QAction(QIcon::fromTheme(QStringLiteral("application-x-plasma")), i18n("Install"), m_dropMenu);
597 createApplet(package.metadata().pluginId(), QVariantList(), QRect(m_dropMenu->dropPoint(), QSize(-1, -1)));
616 Plasma::Applet *applet = createApplet(action->data().toString(), QVariantList(), QRect(m_dropMenu->dropPoint(), QSize(-1, -1)));
626 Plasma::Applet *applet = createApplet(action->data().toString(), QVariantList(), QRect(m_dropMenu->dropPoint(), QSize(-1, -1)));
664 // case in which we created the menu ourselves, just the "fetching type entry, directly create the icon applet
666 Plasma::Applet *applet = createApplet(QStringLiteral("org.kde.plasma.icon"), QVariantList(), QRect(m_dropMenu->dropPoint(), QSize(-1, -1)));
678 PlasmoidItem *appletGraphicObject = qobject_cast<PlasmoidItem *>(AppletQuickItem::itemForApplet(applet));
694 } else if (position.isNull() && m_containment->containmentType() == Plasma::Containment::Type::Desktop) {
711 PlasmoidItem *appletGraphicObject = qobject_cast<PlasmoidItem *>(AppletQuickItem::itemForApplet(applet));
726 if (m_containment->containmentType() != Plasma::Containment::Type::Desktop && m_containment->containmentType() != Plasma::Containment::Type::Custom) {
760 QQmlExpression expr(qmlObject()->engine()->rootContext(), m_wallpaperItem, QStringLiteral("parent"));
774 event->setAccepted(m_containment->containmentActions().contains(Plasma::ContainmentActions::eventToString(event)));
856 // this happens if a window which does not accept focus spawns a new window that takes focus and X grab
960 QMouseEvent me(QEvent::MouseButtonRelease, localPos, QPointF(), Qt::RightButton, Qt::RightButton, event->modifiers());
966void ContainmentItem::addAppletActions(QMenu *desktopMenu, Plasma::Applet *applet, QEvent *event)
997 && (m_containment->containmentType() != Plasma::Containment::Type::Panel || m_containment->isUserConfiguring())) {
1063 // 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:158
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:212
Q_INVOKABLE AppletQuickItem * itemFor(Plasma::Applet *applet) const
Returns the corresponding PlasmoidItem of one of its applets.
Definition containmentitem.cpp:128
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:196
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:344
Q_INVOKABLE void openContextMenu(const QPointF &globalPos)
Opens the context menu of the Corona.
Definition containmentitem.cpp:324
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:182
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)
QString errorText() const
bool kill(KJob::KillVerbosity verbosity=KJob::Quietly)
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:125
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:73
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 bool event(QEvent *e)
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
virtual void classBegin()=0
void ungrabMouse()
ItemSceneChange
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 Apr 11 2025 11:56:56 by doxygen 1.13.2 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri Apr 11 2025 11:56:56 by doxygen 1.13.2 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.