Move availableScreenRect/Region up to AppletInterface.
Summary: Tested with Folder View and Simple Menu, both use cases (desktop containment margins, strut-aware dialog placement) addressed. Reviewers: #plasma, mart Subscribers: plasma-devel Tags: #plasma Differential Revision: https://phabricator.kde.org/D2932
This commit is contained in:
parent
3b33c0a566
commit
89a3e34bd2
@ -656,6 +656,49 @@ void AppletInterface::executeAction(const QString &name)
|
||||
}
|
||||
}
|
||||
|
||||
QVariantList AppletInterface::availableScreenRegion() const
|
||||
{
|
||||
QVariantList regVal;
|
||||
|
||||
if (!applet()->containment() || !applet()->containment()->corona()) {
|
||||
return regVal;
|
||||
}
|
||||
|
||||
QRegion reg = QRect(0, 0, width(), height());
|
||||
int screenId = screen();
|
||||
if (screenId > -1) {
|
||||
reg = applet()->containment()->corona()->availableScreenRegion(screenId);
|
||||
}
|
||||
|
||||
foreach (QRect rect, reg.rects()) {
|
||||
//make it relative
|
||||
QRect geometry = applet()->containment()->corona()->screenGeometry(screenId);
|
||||
rect.moveTo(rect.topLeft() - geometry.topLeft());
|
||||
regVal << QVariant::fromValue(QRectF(rect));
|
||||
}
|
||||
return regVal;
|
||||
}
|
||||
|
||||
QRect AppletInterface::availableScreenRect() const
|
||||
{
|
||||
if (!applet()->containment() || !applet()->containment()->corona()) {
|
||||
return QRect();
|
||||
}
|
||||
|
||||
QRect rect(0, 0, width(), height());
|
||||
|
||||
int screenId = screen();
|
||||
|
||||
if (screenId > -1) {
|
||||
rect = applet()->containment()->corona()->availableScreenRect(screenId);
|
||||
//make it relative
|
||||
QRect geometry = applet()->containment()->corona()->screenGeometry(screenId);
|
||||
rect.moveTo(rect.topLeft() - geometry.topLeft());
|
||||
}
|
||||
|
||||
return rect;
|
||||
}
|
||||
|
||||
bool AppletInterface::event(QEvent *event)
|
||||
{
|
||||
// QAction keyboard shortcuts cannot work with QML2 (and probably newver will
|
||||
|
@ -227,6 +227,18 @@ class AppletInterface : public PlasmaQuick::AppletQuickItem
|
||||
*/
|
||||
Q_PROPERTY(QString configurationRequiredReason READ configurationRequiredReason WRITE setConfigurationRequiredReason NOTIFY configurationRequiredReasonChanged)
|
||||
|
||||
/**
|
||||
* screen area free of panels: the coordinates are relative to the containment,
|
||||
* it's independent from the screen position
|
||||
* For more precise available geometry use availableScreenRegion()
|
||||
*/
|
||||
Q_PROPERTY(QRect availableScreenRect READ availableScreenRect NOTIFY availableScreenRectChanged)
|
||||
|
||||
/**
|
||||
* The available region of this screen, panels excluded. It's a list of rectangles
|
||||
*/
|
||||
Q_PROPERTY(QVariantList availableScreenRegion READ availableScreenRegion NOTIFY availableScreenRegionChanged)
|
||||
|
||||
public:
|
||||
AppletInterface(DeclarativeAppletScript *script, const QVariantList &args = QVariantList(), QQuickItem *parent = 0);
|
||||
~AppletInterface();
|
||||
@ -301,6 +313,10 @@ public:
|
||||
*/
|
||||
Q_INVOKABLE QStringList downloadedFiles() const;
|
||||
|
||||
QVariantList availableScreenRegion() const;
|
||||
|
||||
QRect availableScreenRect() const;
|
||||
|
||||
static AppletInterface *qmlAttachedProperties(QObject *object)
|
||||
{
|
||||
return qobject_cast<AppletInterface *>(AppletQuickItem::qmlAttachedProperties(object));
|
||||
@ -416,6 +432,8 @@ Q_SIGNALS:
|
||||
void hideOnWindowDeactivateChanged();
|
||||
void associatedApplicationChanged();
|
||||
void associatedApplicationUrlsChanged();
|
||||
void availableScreenRegionChanged();
|
||||
void availableScreenRectChanged();
|
||||
|
||||
void userConfiguringChanged();
|
||||
void globalShortcutChanged();
|
||||
|
@ -190,40 +190,6 @@ void ContainmentInterface::setContainmentType(Plasma::Types::ContainmentType typ
|
||||
appletScript()->setContainmentType(type);
|
||||
}
|
||||
|
||||
QVariantList ContainmentInterface::availableScreenRegion() const
|
||||
{
|
||||
QRegion reg = QRect(0, 0, width(), height());
|
||||
int screenId = screen();
|
||||
if (screenId > -1 && m_containment->corona()) {
|
||||
reg = m_containment->corona()->availableScreenRegion(screenId);
|
||||
}
|
||||
|
||||
QVariantList regVal;
|
||||
foreach (QRect rect, reg.rects()) {
|
||||
//make it relative
|
||||
QRect geometry = m_containment->corona()->screenGeometry(screenId);
|
||||
rect.moveTo(rect.topLeft() - geometry.topLeft());
|
||||
regVal << QVariant::fromValue(QRectF(rect));
|
||||
}
|
||||
return regVal;
|
||||
}
|
||||
|
||||
QRect ContainmentInterface::availableScreenRect() const
|
||||
{
|
||||
QRect rect(0, 0, width(), height());
|
||||
|
||||
int screenId = screen();
|
||||
|
||||
if (screenId > -1 && m_containment->corona()) {
|
||||
rect = m_containment->corona()->availableScreenRect(screenId);
|
||||
//make it relative
|
||||
QRect geometry = m_containment->corona()->screenGeometry(screenId);
|
||||
rect.moveTo(rect.topLeft() - geometry.topLeft());
|
||||
}
|
||||
|
||||
return rect;
|
||||
}
|
||||
|
||||
Plasma::Applet *ContainmentInterface::createApplet(const QString &plugin, const QVariantList &args, const QPoint &pos)
|
||||
{
|
||||
return createApplet(plugin, args, QRectF(pos, QSize()));
|
||||
|
@ -76,18 +76,6 @@ class ContainmentInterface : public AppletInterface
|
||||
*/
|
||||
Q_PROPERTY(QList<QObject *> actions READ actions NOTIFY actionsChanged)
|
||||
|
||||
/**
|
||||
* screen area free of panels: the coordinates are relative to the containment,
|
||||
* it's independent from the screen position
|
||||
* For more precise available geometry use availableScreenRegion()
|
||||
*/
|
||||
Q_PROPERTY(QRect availableScreenRect READ availableScreenRect NOTIFY availableScreenRectChanged)
|
||||
|
||||
/**
|
||||
* The available region of this screen, panels excluded. It's a list of rectangles
|
||||
*/
|
||||
Q_PROPERTY(QVariantList availableScreenRegion READ availableScreenRegion NOTIFY availableScreenRegionChanged)
|
||||
|
||||
public:
|
||||
ContainmentInterface(DeclarativeAppletScript *parent, const QVariantList &args = QVariantList());
|
||||
|
||||
@ -113,10 +101,6 @@ public:
|
||||
|
||||
QList<QObject *> actions() const;
|
||||
|
||||
QVariantList availableScreenRegion() const;
|
||||
|
||||
QRect availableScreenRect() const;
|
||||
|
||||
/**
|
||||
* Process the mime data arrived to a particular coordinate, either with a drag and drop or paste with middle mouse button
|
||||
*/
|
||||
@ -189,8 +173,6 @@ Q_SIGNALS:
|
||||
//Property notifiers
|
||||
void activityChanged();
|
||||
void activityNameChanged();
|
||||
void availableScreenRegionChanged();
|
||||
void availableScreenRectChanged();
|
||||
void appletsChanged();
|
||||
void drawWallpaperChanged();
|
||||
void containmentTypeChanged();
|
||||
|
Loading…
Reference in New Issue
Block a user