fix tooltips

use adjustSize in updateMinimumWidth et al.
changing tooltip content updates sizeHints
using setGeometry is immediate, and will kill the animations.
for dialogs other than tooltips there is no change since adjustGeometry
is just setGeometry

Change-Id: I3e6310f12f76e400f2663b8409a2bbc7e7398f39
This commit is contained in:
Marco Martin 2014-09-23 19:11:29 +02:00
parent e3fd010166
commit 18b57ffc29
3 changed files with 17 additions and 6 deletions

View File

@ -29,12 +29,17 @@ void DialogTest::initTestCase()
m_panel->setGeometry(0, 0, 50, 50);
m_panel->setFlags(Qt::FramelessWindowHint|Qt::WindowDoesNotAcceptFocus);
m_panel2 = new QQuickView;
m_panel2->setGeometry(100, 0, 50, 50);
m_panel2->setFlags(Qt::FramelessWindowHint|Qt::WindowDoesNotAcceptFocus);
m_content = new QQuickItem;
m_content->setWidth(100);
m_content->setHeight(100);
m_dialog->setMainItem(m_content);
m_panel->show();
m_panel2->show();
KWindowSystem::setType(m_panel->winId(), NET::Dock);
m_dialog->setVisualParent(m_panel->contentItem());
m_dialog->show();
@ -44,6 +49,7 @@ void DialogTest::cleanupTestCase()
{
delete m_dialog;
delete m_panel;
delete m_panel2;
}
void DialogTest::position()
@ -52,6 +58,10 @@ void DialogTest::position()
QCOMPARE(m_dialog->x(), 0);
QCOMPARE(m_dialog->y(), 49);
m_dialog->setVisualParent(m_panel2->contentItem());
QCOMPARE(m_dialog->x(), 73);
QCOMPARE(m_dialog->y(), 49);
}
QTEST_MAIN(DialogTest)

View File

@ -40,6 +40,7 @@ private Q_SLOTS:
private:
QQuickView *m_panel;
QQuickView *m_panel2;
QQuickItem *m_content;
PlasmaQuick::Dialog *m_dialog;
};

View File

@ -319,7 +319,7 @@ void DialogPrivate::updateMinimumWidth()
repositionIfOffScreen();
if (visualParent) {
const QRect geom(q->popupPosition(visualParent, q->size()), q->size());
q->setGeometry(geom);
q->adjustGeometry(geom);
}
updateTheme();
@ -358,7 +358,7 @@ void DialogPrivate::updateMinimumHeight()
repositionIfOffScreen();
if (visualParent) {
const QRect geom(q->popupPosition(visualParent, q->size()), q->size());
q->setGeometry(geom);
q->adjustGeometry(geom);
}
updateTheme();
@ -392,7 +392,7 @@ void DialogPrivate::updateMaximumWidth()
repositionIfOffScreen();
if (visualParent) {
const QRect geom(q->popupPosition(visualParent, q->size()), q->size());
q->setGeometry(geom);
q->adjustGeometry(geom);
}
updateTheme();
@ -427,7 +427,7 @@ void DialogPrivate::updateMaximumHeight()
repositionIfOffScreen();
if (visualParent) {
const QRect geom(q->popupPosition(visualParent, q->size()), q->size());
q->setGeometry(geom);
q->adjustGeometry(geom);
}
updateTheme();
@ -856,7 +856,7 @@ QPoint Dialog::popupPosition(QQuickItem *item, const QSize &size)
if (dialogPos.x() + size.width() > avail.right()) {
// popup hits rhs
if (d->location == Plasma::Types::TopEdge || d->location == Plasma::Types::BottomEdge) {
dialogPos.setX(avail.right() - size.width() + 1);
dialogPos.setX(qMax(avail.left(), (avail.right() - size.width() + 1)));
} else {
dialogPos.setX(leftPoint.x());
}
@ -875,7 +875,7 @@ QPoint Dialog::popupPosition(QQuickItem *item, const QSize &size)
if (d->location == Plasma::Types::TopEdge || d->location == Plasma::Types::BottomEdge) {
dialogPos.setY(topPoint.y());
} else {
dialogPos.setY(avail.bottom() - size.height() + 1);
dialogPos.setY(qMax(avail.top(), (avail.bottom() - size.height() + 1)));
}
}