|
|
|
@ -19,6 +19,10 @@
|
|
|
|
|
|
|
|
|
|
#include "dialog.h"
|
|
|
|
|
|
|
|
|
|
// Qt
|
|
|
|
|
#include <QScreen>
|
|
|
|
|
#include <QWindow>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace Latte {
|
|
|
|
|
namespace Quick {
|
|
|
|
@ -43,6 +47,68 @@ void Dialog::setContainsMouse(bool contains)
|
|
|
|
|
emit containsMouseChanged();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Plasma::Types::Location Dialog::edge() const
|
|
|
|
|
{
|
|
|
|
|
return m_edge;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Dialog::setEdge(const Plasma::Types::Location &edge)
|
|
|
|
|
{
|
|
|
|
|
if (m_edge == edge) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_edge = edge;
|
|
|
|
|
emit edgeChanged();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Dialog::adjustGeometry(const QRect &geom)
|
|
|
|
|
{
|
|
|
|
|
if (location() != Plasma::Types::Floating) {
|
|
|
|
|
PlasmaQuick::Dialog::adjustGeometry(geom);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
auto visualparent = visualParent();
|
|
|
|
|
|
|
|
|
|
if (visualparent && visualparent->window() && visualparent->window()->screen()) {
|
|
|
|
|
QPointF parenttopleftf = visualparent->mapToGlobal(QPointF(0, 0));
|
|
|
|
|
QPoint parenttopleft = parenttopleftf.toPoint();
|
|
|
|
|
QScreen *screen = visualparent->window()->screen();
|
|
|
|
|
QRect screengeometry = screen->geometry();
|
|
|
|
|
|
|
|
|
|
int x = 0;
|
|
|
|
|
int y = 0;
|
|
|
|
|
|
|
|
|
|
if (m_edge == Plasma::Types::LeftEdge || m_edge == Plasma::Types::RightEdge) {
|
|
|
|
|
y = parenttopleft.y() + (visualparent->height()/2) - (geom.height()/2);
|
|
|
|
|
} else {
|
|
|
|
|
x = parenttopleft.x() + (visualparent->width()/2) - (geom.width()/2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (m_edge == Plasma::Types::LeftEdge) {
|
|
|
|
|
x = parenttopleft.x() + visualparent->width() - 1;
|
|
|
|
|
} else if (m_edge == Plasma::Types::RightEdge) {
|
|
|
|
|
x = parenttopleft.x() - geom.width() + 1;
|
|
|
|
|
} else if (m_edge == Plasma::Types::TopEdge) {
|
|
|
|
|
y = parenttopleft.y() + visualparent->height() - 1;
|
|
|
|
|
} else { // bottom case
|
|
|
|
|
y = parenttopleft.y() - geom.height() + 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
x = qBound(screengeometry.x(), x, screengeometry.right()-1);
|
|
|
|
|
y = qBound(screengeometry.y(), y, screengeometry.bottom()-1);
|
|
|
|
|
|
|
|
|
|
QRect repositionedrect(x, y, geom.width(), geom.height());
|
|
|
|
|
setGeometry(repositionedrect);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PlasmaQuick::Dialog::adjustGeometry(geom);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool Dialog::event(QEvent *e)
|
|
|
|
|
{
|
|
|
|
|
if (e->type() == QEvent::Enter) {
|
|
|
|
|