Sankore-724. Properties contains image now. When image loads - user see "loading" image.

preferencesAboutTextFull
Aleksei Kanash 12 years ago
parent 8dc7656521
commit 4ccd5a45b7
  1. 1
      resources/sankore.qrc
  2. 47
      src/gui/UBFeaturesWidget.cpp
  3. 7
      src/gui/UBFeaturesWidget.h

@ -265,6 +265,7 @@
<file>images/libpalette/notFound.png</file>
<file>images/libpalette/trash_favorite.svg</file>
<file>images/libpalette/back.png</file>
<file>images/libpalette/loading.png</file>
<file>images/stylusPalette/eraserArrow.png</file>
<file>images/stylusPalette/eraserOnArrow.png</file>
<file>images/stylusPalette/markerArrow.png</file>

@ -10,7 +10,9 @@
#include "globals/UBGlobals.h"
#include "board/UBBoardController.h"
UBFeaturesWidget::UBFeaturesWidget(QWidget *parent, const char *name):UBDockPaletteWidget(parent)
UBFeaturesWidget::UBFeaturesWidget(QWidget *parent, const char *name)
: UBDockPaletteWidget(parent)
, imageGatherer(NULL)
{
setObjectName(name);
mName = "FeaturesWidget";
@ -139,6 +141,8 @@ UBFeaturesWidget::~UBFeaturesWidget()
delete thumbSlider;
thumbSlider = NULL;
}
if (NULL != imageGatherer)
delete imageGatherer;
}
bool UBFeaturesWidget::eventFilter( QObject *target, QEvent *event )
@ -353,7 +357,19 @@ void UBFeaturesWidget::thumbnailSizeChanged( int value )
void UBFeaturesWidget::onDisplayMetadata( QMap<QString,QString> metadata )
{
UBFeature feature( QString(), QPixmap(":images/libpalette/notFound.png"), QString(), metadata["Url"], FEATURE_ITEM );
QString previewImageUrl;
previewImageUrl = ":images/libpalette/loading.png";
if (!imageGatherer)
imageGatherer = new UBDownloadHttpFile(0, this);
connect(imageGatherer, SIGNAL(downloadFinished(int, bool, QUrl, QString, QByteArray, QPointF, QSize, bool)), this, SLOT(onPreviewLoaded(int, bool, QUrl, QString, QByteArray, QPointF, QSize, bool)));
// We send here the request and store its reply in order to be able to cancel it if needed
imageGatherer->get(QUrl(metadata["Url"]), QPoint(0,0), QSize(), false);
UBFeature feature( QString(), QPixmap(previewImageUrl), QString(), metadata["Url"], FEATURE_ITEM );
feature.setMetadata( metadata );
featureProperties->showElement( feature );
@ -361,6 +377,16 @@ void UBFeaturesWidget::onDisplayMetadata( QMap<QString,QString> metadata )
mActionBar->setCurrentState( IN_PROPERTIES );
}
void UBFeaturesWidget::onPreviewLoaded(int id, bool pSuccess, QUrl sourceUrl, QString pContentTypeHeader, QByteArray pData, QPointF pPos, QSize pSize, bool isBackground)
{
QImage img;
img.loadFromData(pData);
QPixmap pix = QPixmap::fromImage(img);
featureProperties->setOrigPixmap(pix);
featureProperties->setThumbnail(pix);
}
void UBFeaturesWidget::onAddDownloadedFileToLibrary(bool pSuccess, QUrl sourceUrl, QString pContentHeader, QByteArray pData)
{
if ( pSuccess )
@ -738,6 +764,20 @@ UBFeature UBFeatureProperties::getCurrentElement() const
return UBFeature();
}
void UBFeatureProperties::setOrigPixmap(QPixmap &pix)
{
if (mpOrigPixmap)
delete mpOrigPixmap;
mpOrigPixmap = new QPixmap(pix);
}
void UBFeatureProperties::setThumbnail(QPixmap &pix)
{
mpThumbnail->setPixmap(pix.scaledToWidth(THUMBNAIL_WIDTH));
}
void UBFeatureProperties::adaptSize()
{
if( NULL != mpOrigPixmap )
@ -819,7 +859,8 @@ void UBFeatureProperties::onAddToPage()
{
QWidget *w = parentWidget()->parentWidget();
UBFeaturesWidget* featuresWidget = dynamic_cast<UBFeaturesWidget*>( w );
featuresWidget->getFeaturesController()->addItemToPage( *mpElement );
if (featuresWidget)
featuresWidget->getFeaturesController()->addItemToPage( *mpElement );
}
void UBFeatureProperties::onAddToLib()

@ -88,7 +88,11 @@ private:
int currentStackedWidget;
UBDownloadHttpFile* imageGatherer;
private slots:
void onPreviewLoaded(int id, bool pSuccess, QUrl sourceUrl, QString pContentTypeHeader, QByteArray pData, QPointF pPos, QSize pSize, bool isBackground);
void currentSelected( const QModelIndex & );
//void currentPathChanged(const QString &);
void currentPathChanged( const QModelIndex & );
@ -153,6 +157,9 @@ public:
void showElement(const UBFeature &elem);
UBFeature getCurrentElement() const;
void setOrigPixmap(QPixmap &pix);
void setThumbnail(QPixmap &pix);
protected:
void resizeEvent(QResizeEvent *event);
void showEvent(QShowEvent *event);

Loading…
Cancel
Save