diff -r 7cbcb2896f0e -r a642906a277a contactwidgethsplugin/contactwidgeths/src/contactwidgeths.cpp --- a/contactwidgethsplugin/contactwidgeths/src/contactwidgeths.cpp Tue Jul 06 14:05:47 2010 +0300 +++ b/contactwidgethsplugin/contactwidgeths/src/contactwidgeths.cpp Wed Aug 18 09:39:00 2010 +0300 @@ -41,6 +41,9 @@ #include "commlauncherwidget.h" #include "ihswidgetpreferenceservice.h" +const QString translationsPath = "/resource/qt/translations/"; +const QString translationsFile = "contactwidgethsplugin"; + const QString defaultAvatar = "qtg_large_avatar"; const QString addContactAvatar = "qtg_small_add"; const QString normalFrameName = "qtg_fr_hsshortcut_normal"; @@ -79,7 +82,7 @@ mTranslator(0) { // Localization file loading - mTranslator = new HbTranslator(); + mTranslator = new HbTranslator(translationsPath, translationsFile); mTranslator->loadCommon(); // UI creation done in onInitialize() @@ -132,15 +135,37 @@ */ ContactWidgetHs::~ContactWidgetHs() { - delete mLauncher; - delete mContactManager; - delete mAppManager; - delete mAvatar; - // Deleting request cancels all pending requests - delete mContactSelectRequest; - //,,first cancel? - delete mThumbnailManager; - delete mTranslator; + if (mLauncher) + { + delete mLauncher; + } + if (mContactManager) + { + delete mContactManager; + } + if (mAppManager) + { + delete mAppManager; + } + if (mAvatar) + { + delete mAvatar; + } + + // Deleting request cancels all pending requests + if (mContactSelectRequest) + { + delete mContactSelectRequest; + } + + if (mThumbnailManager) + { + delete mThumbnailManager; + } + if (mTranslator) + { + delete mTranslator; + } } /*! @@ -237,17 +262,38 @@ painter.end(); qDebug() << "setContactImage av 2"; //,, + int maxSize = (inputPixmap.width() > inputPixmap.height() ? inputPixmap.width():inputPixmap.height()); + int minSize = (inputPixmap.width() < inputPixmap.height() ? inputPixmap.width():inputPixmap.height()); + int sizeFrom = maxSize - minSize; // We may draw the icon when thumnail processing is still in progress, // so can't show the thumbnail yet. if (inputPixmap.width()>0) { + if (inputPixmap.width() < inputPixmap.height()) + { + QPixmap pm3 = inputPixmap.copy(0,sizeFrom/2,minSize,minSize); + QPixmap pm2 = pm3.scaled( QSize(contactIconSize, contactIconSize), Qt::KeepAspectRatio ); + qDebug() << "pm2 " << pm2.width() << " " << pm2.height(); + avatarPixmap = pm2; + } + else if (inputPixmap.width() > inputPixmap.height()) + { + QPixmap pm3 = inputPixmap.copy(sizeFrom/2,0,minSize,minSize); + QPixmap pm2 = pm3.scaled( QSize(contactIconSize, contactIconSize), Qt::KeepAspectRatio ); + qDebug() << "pm2 " << pm2.width() << " " << pm2.height(); + avatarPixmap = pm2; + }else + { QPixmap pm2 = inputPixmap.scaled( QSize(contactIconSize, contactIconSize), Qt::IgnoreAspectRatio ); qDebug() << "pm2 " << pm2.width() << " " << pm2.height(); avatarPixmap = pm2; // + } } HbIcon *avatarIcon = new HbIcon(QIcon(avatarPixmap)); mAvatarIconItem->setIcon(*avatarIcon); + mAvatarIconItem->setSize(QSize(contactIconSize, contactIconSize)); + mAvatarIconItem->setAspectRatioMode(Qt::KeepAspectRatio); // Then display the new image update(); @@ -411,7 +457,21 @@ */ void ContactWidgetHs::mousePressEvent(QGraphicsSceneMouseEvent *event) { - if (event && event->type() == QEvent::GraphicsSceneMousePress) { + Q_UNUSED(event); +} + +/*! + \fn void ContactWidgetHs::mouseReleaseEvent(QGraphicsSceneMouseEvent* event) + + Widget start is triggered from release \a event. + \sa +*/ +void ContactWidgetHs::mouseReleaseEvent(QGraphicsSceneMouseEvent* event) +{ + qDebug() << "mouseReleaseEvent event->type() = " << (int)event->type(); + + //Q_UNUSED(event); + if (event && event->type() == QEvent::GraphicsSceneMouseRelease) { // If the widget doesn't have contact yet and // there are contacts, select one. if (mContactLocalId == unUsedContactId) { @@ -444,17 +504,6 @@ } } -/*! - \fn void ContactWidgetHs::mouseReleaseEvent(QGraphicsSceneMouseEvent* event) - - Widget start is triggered from release \a event. - \sa -*/ -void ContactWidgetHs::mouseReleaseEvent(QGraphicsSceneMouseEvent* event) -{ - Q_UNUSED(event); -} - // Store contact data to member variables and to UI void ContactWidgetHs::getContactData() @@ -579,7 +628,11 @@ */ void ContactWidgetHs::onHide() { - qDebug() << "ContactWidgetHs::onHide()"; + qDebug() << "ContactWidgetHs::onHide()"; + // close the launcher if it's open + if (mLauncher->isVisible()) { + mLauncher->close(); + } } @@ -744,7 +797,17 @@ for(i=0; ideleteLater(); + mContactNameLabel->deleteLater(); + mAppManager->deleteLater(); + mLauncher->deleteLater(); + mContactLocalId = unUsedContactId; + delete mAvatar; + mContactHasAvatarDetail = false; + mContactManager->deleteLater(); + mThumbnailManager->deleteLater(); + emit finished(); break; }