void UBFloatingPalette::moveInsideParent(const QPoint &position) { QWidget *parent = parentWidget(); if (parent) { int margin = UBSettings::boardMargin - border(); qreal newX = qMax(margin, qMin(parent->width() - getParentRightOffset() - width() - margin, position.x())); qreal newY = qMax(margin, qMin(parent->height() - height() - margin, position.y())); if (!mCustomPosition && !mIsMoving) { if (mDefaultPosition == Qt::TopLeftCorner || mDefaultPosition == Qt::BottomLeftCorner) { newX = margin; } else { newX = qMax(margin, parent->width() - getParentRightOffset() - width() - margin); } } move(newX, newY); minimizePalette(QPoint(newX, newY)); } else { move(position); } }
void UBDesktopPalette::parentResized() { QPoint p = pos(); if (minimizedLocation() == eMinimizedLocation_Right) { p.setX(parentWidget()->width() - getParentRightOffset() -width()); } moveInsideParent(p); }