|
|
@ -17,6 +17,7 @@ |
|
|
|
#include "UBLibItemProperties.h" |
|
|
|
#include "UBLibItemProperties.h" |
|
|
|
|
|
|
|
|
|
|
|
#include "core/UBApplication.h" |
|
|
|
#include "core/UBApplication.h" |
|
|
|
|
|
|
|
#include "core/UBDownloadManager.h" |
|
|
|
|
|
|
|
|
|
|
|
#include "frameworks/UBFileSystemUtils.h" |
|
|
|
#include "frameworks/UBFileSystemUtils.h" |
|
|
|
|
|
|
|
|
|
|
@ -38,6 +39,7 @@ UBLibItemProperties::UBLibItemProperties(QWidget *parent, const char *name):QWid |
|
|
|
, mpThumbnail(NULL) |
|
|
|
, mpThumbnail(NULL) |
|
|
|
, mpOrigPixmap(NULL) |
|
|
|
, mpOrigPixmap(NULL) |
|
|
|
, mpElement(NULL) |
|
|
|
, mpElement(NULL) |
|
|
|
|
|
|
|
, mpItem(NULL) |
|
|
|
{ |
|
|
|
{ |
|
|
|
setObjectName(name); |
|
|
|
setObjectName(name); |
|
|
|
|
|
|
|
|
|
|
@ -81,8 +83,11 @@ UBLibItemProperties::UBLibItemProperties(QWidget *parent, const char *name):QWid |
|
|
|
mpObjInfoLabel->setStyleSheet(QString("color: #888888; font-size : 18px; font-weight:bold;")); |
|
|
|
mpObjInfoLabel->setStyleSheet(QString("color: #888888; font-size : 18px; font-weight:bold;")); |
|
|
|
mpLayout->addWidget(mpObjInfoLabel, 0); |
|
|
|
mpLayout->addWidget(mpObjInfoLabel, 0); |
|
|
|
|
|
|
|
|
|
|
|
mpObjInfos = new QTextEdit(this); |
|
|
|
mpObjInfos = new QTreeWidget(this); |
|
|
|
mpObjInfos->setReadOnly(true); |
|
|
|
mpObjInfos->setColumnCount(2); |
|
|
|
|
|
|
|
mpObjInfos->header()->hide(); |
|
|
|
|
|
|
|
mpObjInfos->setAlternatingRowColors(true); |
|
|
|
|
|
|
|
mpObjInfos->setRootIsDecorated(false); |
|
|
|
mpObjInfos->setObjectName("DockPaletteWidgetBox"); |
|
|
|
mpObjInfos->setObjectName("DockPaletteWidgetBox"); |
|
|
|
mpObjInfos->setStyleSheet("background:white;"); |
|
|
|
mpObjInfos->setStyleSheet("background:white;"); |
|
|
|
mpLayout->addWidget(mpObjInfos, 1); |
|
|
|
mpLayout->addWidget(mpObjInfos, 1); |
|
|
@ -173,8 +178,18 @@ void UBLibItemProperties::adaptSize() |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
void UBLibItemProperties::onAddToPage() |
|
|
|
void UBLibItemProperties::onAddToPage() |
|
|
|
{ |
|
|
|
{ |
|
|
|
UBLibWidget* libWidget = dynamic_cast<UBLibWidget*>(parentWidget()->parentWidget()); |
|
|
|
if(UBApplication::isFromWeb(mpElement->path().toString())){ |
|
|
|
libWidget->libNavigator()->libraryWidget()->libraryController()->addItemToPage(mpElement); |
|
|
|
sDownloadFileDesc desc; |
|
|
|
|
|
|
|
desc.isBackground = false; |
|
|
|
|
|
|
|
desc.modal = true; |
|
|
|
|
|
|
|
desc.name = QFileInfo(mpElement->path().toString()).fileName(); |
|
|
|
|
|
|
|
desc.url = mpElement->path().toString(); |
|
|
|
|
|
|
|
UBDownloadManager::downloadManager()->addFileToDownload(desc); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
UBLibWidget* libWidget = dynamic_cast<UBLibWidget*>(parentWidget()->parentWidget()); |
|
|
|
|
|
|
|
libWidget->libNavigator()->libraryWidget()->libraryController()->addItemToPage(mpElement); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -182,7 +197,14 @@ void UBLibItemProperties::onAddToPage() |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
void UBLibItemProperties::onAddToLib() |
|
|
|
void UBLibItemProperties::onAddToLib() |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
if(UBApplication::isFromWeb(mpElement->path().toString())){ |
|
|
|
|
|
|
|
sDownloadFileDesc desc; |
|
|
|
|
|
|
|
desc.isBackground = false; |
|
|
|
|
|
|
|
desc.modal = false; |
|
|
|
|
|
|
|
desc.name = QFileInfo(mpElement->path().toString()).fileName(); |
|
|
|
|
|
|
|
desc.url = mpElement->path().toString(); |
|
|
|
|
|
|
|
UBDownloadManager::downloadManager()->addFileToDownload(desc); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -190,8 +212,18 @@ void UBLibItemProperties::onAddToLib() |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
void UBLibItemProperties::onSetAsBackground() |
|
|
|
void UBLibItemProperties::onSetAsBackground() |
|
|
|
{ |
|
|
|
{ |
|
|
|
UBLibWidget* libWidget = dynamic_cast<UBLibWidget*>(parentWidget()->parentWidget()); |
|
|
|
if(UBApplication::isFromWeb(mpElement->path().toString())){ |
|
|
|
libWidget->libNavigator()->libraryWidget()->libraryController()->setItemAsBackground(mpElement); |
|
|
|
sDownloadFileDesc desc; |
|
|
|
|
|
|
|
desc.isBackground = true; |
|
|
|
|
|
|
|
desc.modal = true; |
|
|
|
|
|
|
|
desc.name = QFileInfo(mpElement->path().toString()).fileName(); |
|
|
|
|
|
|
|
desc.url = mpElement->path().toString(); |
|
|
|
|
|
|
|
UBDownloadManager::downloadManager()->addFileToDownload(desc); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
UBLibWidget* libWidget = dynamic_cast<UBLibWidget*>(parentWidget()->parentWidget()); |
|
|
|
|
|
|
|
libWidget->libNavigator()->libraryWidget()->libraryController()->setItemAsBackground(mpElement); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -210,20 +242,23 @@ void UBLibItemProperties::showElement(UBLibElement *elem) |
|
|
|
mpElement = elem; |
|
|
|
mpElement = elem; |
|
|
|
mpOrigPixmap = new QPixmap(QPixmap::fromImage(*elem->thumbnail())); |
|
|
|
mpOrigPixmap = new QPixmap(QPixmap::fromImage(*elem->thumbnail())); |
|
|
|
mpThumbnail->setPixmap(QPixmap::fromImage(*elem->thumbnail()).scaledToWidth(THUMBNAIL_WIDTH)); |
|
|
|
mpThumbnail->setPixmap(QPixmap::fromImage(*elem->thumbnail()).scaledToWidth(THUMBNAIL_WIDTH)); |
|
|
|
mpObjInfos->setText(elem->information()); |
|
|
|
populateMetadata(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if(UBFileSystemUtils::mimeTypeFromFileName(elem->path().toLocalFile()).contains("image")) |
|
|
|
if(UBApplication::isFromWeb(elem->path().toString())){ |
|
|
|
{ |
|
|
|
mpAddToLibButton->show(); |
|
|
|
// Show the Set as background button
|
|
|
|
if(elem->metadatas()["Type"].toLower().contains("image")){ |
|
|
|
mpAddToLibButton->hide(); |
|
|
|
mpSetAsBackgroundButton->show(); |
|
|
|
mpSetAsBackgroundButton->show(); |
|
|
|
}else{ |
|
|
|
} |
|
|
|
mpSetAsBackgroundButton->hide(); |
|
|
|
else |
|
|
|
} |
|
|
|
{ |
|
|
|
}else{ |
|
|
|
// TODO: if we are browsing ONLINE objects, we must show mpAddToLibButton !
|
|
|
|
|
|
|
|
mpSetAsBackgroundButton->hide(); |
|
|
|
|
|
|
|
mpAddToLibButton->hide(); |
|
|
|
mpAddToLibButton->hide(); |
|
|
|
|
|
|
|
if(UBFileSystemUtils::mimeTypeFromFileName(elem->path().toLocalFile()).contains("image")){ |
|
|
|
|
|
|
|
mpSetAsBackgroundButton->show(); |
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
mpSetAsBackgroundButton->hide(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -245,6 +280,25 @@ void UBLibItemProperties::showEvent(QShowEvent *event) |
|
|
|
adaptSize(); |
|
|
|
adaptSize(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void UBLibItemProperties::populateMetadata() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if(NULL != mpObjInfos){ |
|
|
|
|
|
|
|
mpObjInfos->clear(); |
|
|
|
|
|
|
|
QMap<QString, QString> metas = mpElement->metadatas(); |
|
|
|
|
|
|
|
QList<QString> lKeys = metas.keys(); |
|
|
|
|
|
|
|
QList<QString> lValues = metas.values(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for(int i=0; i< metas.size(); i++){ |
|
|
|
|
|
|
|
QStringList values; |
|
|
|
|
|
|
|
values << lKeys.at(i); |
|
|
|
|
|
|
|
values << lValues.at(i); |
|
|
|
|
|
|
|
mpItem = new QTreeWidgetItem(values); |
|
|
|
|
|
|
|
mpObjInfos->addTopLevelItem(mpItem); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
mpObjInfos->resizeColumnToContents(0); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* \brief Constructor |
|
|
|
* \brief Constructor |
|
|
|
* @param parent as the parent widget |
|
|
|
* @param parent as the parent widget |
|
|
|