From kde-commits Mon Jan 28 13:06:13 2008 From: Anne-Marie Mahfouf Date: Mon, 28 Jan 2008 13:06:13 +0000 To: kde-commits Subject: extragear/plasma/applets/frame Message-Id: <1201525573.279250.23532.nullmailer () svn ! kde ! org> X-MARC-Message: https://marc.info/?l=kde-commits&m=120152558306040 SVN commit 767579 by annma: - create a Picture class to choose the picture and set Default Picture (TODO is to also move slideshow code here) - have a new picture as default, from ruphy If anyone can have a look at the code and report any problem, I'd be grateful, thanks! M +3 -2 CMakeLists.txt M +3 -1 TODO M +3 -45 frame.cpp M +0 -4 frame.h AM picture-frame-default.jpg D picture-frame-default.svg AM picture.cpp [License: GPL (v2+)] AM picture.h [License: GPL (v2+)] --- trunk/extragear/plasma/applets/frame/CMakeLists.txt #767578:767579 @@ -1,7 +1,8 @@ project(plasma-frame) set(frame_SRCS - frame.cpp) + frame.cpp + picture.cpp) kde4_add_ui_files(frame_SRCS config.ui ) @@ -11,4 +12,4 @@ install(TARGETS plasma_applet_frame DESTINATION ${PLUGIN_INSTALL_DIR}) install(FILES plasma-frame-default.desktop DESTINATION ${SERVICES_INSTALL_DIR}) -install(FILES picture-frame-default.svg DESTINATION ${DATA_INSTALL_DIR}/desktoptheme/default/widgets/) +install(FILES picture-frame-default.jpg DESTINATION ${DATA_INSTALL_DIR}/plasma-frame) --- trunk/extragear/plasma/applets/frame/TODO #767578:767579 @@ -1,6 +1,8 @@ TODO FOR 4.1: -- clean the code +- clean the code: class Picture is added (28th January 2008), still to do is add slideshow code there +- comic-like engine. +- engine to support many Pictures of The Day - Make the Wikipedia Picture Of The Day an engine (RSS) - Keep craig Duquette updated when it's done so he'll see about a flickr engine! - have several engines as the comic engine has. - clean the config dialog and take ideas from Desktop config (share some config settings?) - add recursive dirs as an option for slideshow (although beware of too many options) --- trunk/extragear/plasma/applets/frame/frame.cpp #767578:767579 @@ -47,6 +47,7 @@ #include #include +#include "picture.h" Frame::Frame(QObject *parent, const QVariantList &args) : Plasma::Applet(parent, args), @@ -98,36 +99,6 @@ } } -QImage Frame::loadDefaultImage(QString message) -{ - // Create a QImage with same axpect ratio of default svg and current pixelSize - QString svgFile = Plasma::Theme::self()->image("widgets/picture-frame-default"); - QSvgRenderer sr(svgFile); - int pixelSize = contentSize().toSize().width(); - double scale = (double) pixelSize / sr.boundsOnElement("boundingRect").size().width(); - QImage imload(pixelSize, - (int) (sr.boundsOnElement("boundingRect").size().height() * scale), - QImage::Format_ARGB32); - imload.fill(Qt::white); - QPainter p(&imload); - sr.render(&p, QRect(QPoint(0, 0), imload.size())); - - // Set the font and draw text in a textRect - QRectF textRect = sr.boundsOnElement("textArea"); - textRect = QRectF(textRect.x() * scale, - textRect.y() * scale, - textRect.width() * scale, - textRect.height() * scale); - QFont textFont; - // textFont.setItalic(true); - textFont.setBold(true); - textFont.setPixelSize(imload.height() / 15); - p.setFont(textFont); - p.drawText(textRect.toRect(), message); - p.end(); - return imload; -} - void Frame::setSlideShow() { QStringList picList; @@ -153,21 +124,8 @@ void Frame::choosePicture(const KUrl& currentUrl) { - if (currentUrl.url().isEmpty()) { - m_picture = loadDefaultImage("Put your photo here\nor drop a folder for starting a slideshow"); - } else { - QImage tempImage(currentUrl.path()); - if (tempImage.isNull()){ - m_picture = loadDefaultImage("Error loading image"); - } else { // Load success! Scale the image if it is too big - if (tempImage.width() > m_maxDimension || tempImage.height() > m_maxDimension) { - m_picture = tempImage.scaled(m_maxDimension,m_maxDimension, - Qt::KeepAspectRatio,Qt::SmoothTransformation); - } else { - m_picture = tempImage; - } - } - } + Picture myPicture; + m_picture = myPicture.setPicture(currentUrl); m_pixmapCache = QPixmap(); update(); --- trunk/extragear/plasma/applets/frame/frame.h #767578:767579 @@ -98,12 +98,8 @@ /// Frame & shadow outline thickness int m_frameOutline; int m_swOutline; - /// Max Picture Dimension - static const int m_maxDimension=800; /// Designer Config file Ui::config ui; - /// Default image - QImage loadDefaultImage(QString message); }; K_EXPORT_PLASMA_APPLET(frame, Frame) ** trunk/extragear/plasma/applets/frame/picture-frame-default.jpg #property svn:mime-type + image/jpeg ** trunk/extragear/plasma/applets/frame/picture.cpp #property svn:eol-style + native ** trunk/extragear/plasma/applets/frame/picture.h #property svn:eol-style + native