I made a patch for BUG 188315 of Picture Frame
http://bugs.kde.org/show_bug.cgi?id=183315

by applying it, PictureFrame keeps itself aligned to nearest margin of
its containment when switching images. It's useful if the slideshow
contains images with different aspect ratio and you want to place it to
the right, bottom or bottom-right corners of the screen.

I used moveBy() to do the trick, but I don't understand why it doesn't
work if I uncomment emit appletTransformedItself();

maybe a plasmoid is not supposed to do stuff like this...

- Antonio
Index: applets/frame/frame.cpp
===================================================================
--- applets/frame/frame.cpp	(revisione 942639)
+++ applets/frame/frame.cpp	(copia locale)
@@ -39,7 +39,7 @@
 #include <KDirSelectDialog>
 #include <KServiceTypeTrader>
 #include <kglobalsettings.h>
-
+#include <Plasma/Containment>
 #include <Plasma/PaintUtils>
 #include <Plasma/DataEngine>
 
@@ -200,14 +200,25 @@
 
 void Frame::updatePicture()
 {
+    QRectF prGeometry = geometry();   
     QImage picture = m_mySlideShow->image();
     m_pictureSize = picture.size();
     QSizeF sizeHint = contentSizeHint();
     if (geometry().size() != sizeHint) {
         resize(sizeHint);
-        emit appletTransformedItself();
     }
-
+    if (location() == Plasma::Floating) {
+	QPointF displacement = QPointF(0,0);
+	QSizeF containmentSize = containment()->size();
+ 	if (prGeometry.left() > (containmentSize.width() - prGeometry.right())) {
+	    displacement.setX(prGeometry.width() - geometry().width());
+	}
+	if (prGeometry.top() > (containmentSize.height() - prGeometry.bottom())) {
+	    displacement.setY(prGeometry.height() - geometry().height());
+	}
+	moveBy(displacement.x(),displacement.y());
+    }
+    //emit appletTransformedItself();
     update();
 }
 
_______________________________________________
Plasma-devel mailing list
Plasma-devel@kde.org
https://mail.kde.org/mailman/listinfo/plasma-devel

Reply via email to