I don't know

preferencesAboutTextFull
Claudio Valerio 13 years ago
parent 81ed0c74c2
commit a94f7f63de
  1. 33
      src/customWidgets/UBWidgetList.cpp
  2. 10
      src/customWidgets/UBWidgetList.h
  3. 36
      src/gui/UBTeacherBarWidget.cpp
  4. 5
      src/gui/UBTeacherBarWidget.h

@ -49,12 +49,12 @@ UBWidgetList::~UBWidgetList()
}
}
void UBWidgetList::addWidget(QWidget *widget)
void UBWidgetList::addWidget(QWidget *widget, bool isResizable)
{
if(NULL != mpLayout){
mpEmptyLabel->setVisible(false);
mWidgetInfo[widget] = widget->size();
qDebug() << __FUNCTION__ << "widget->size () " << widget->size();
mWidgetInfo[widget] = {widget->size(), isResizable};
qDebug() << __FUNCTION__ << "widget : " << widget << " widget->size () " << widget->size() << " isResizable " << isResizable;
updateView(size());
mpLayout->addWidget(widget);
}
@ -80,28 +80,45 @@ int UBWidgetList::scaleWidgets(QSize pSize)
int result = -mListElementsSpacing;
int count = 0;
foreach(QWidget* eachWidget, mWidgetInfo.keys()){
if(mWidgetInfo[eachWidget].isResizable){
qreal scaleFactor = 0;
int newWidgetWidth = pSize.width();
int newWidgetHeight = pSize.height();
if(eWidgetListOrientation_Vertical == mOrientation){
scaleFactor = (float)mWidgetInfo[eachWidget].width() / (float)pSize.width();
newWidgetHeight = mWidgetInfo[eachWidget].height()/scaleFactor;
scaleFactor = (float)mWidgetInfo[eachWidget].size.width() / (float)pSize.width();
newWidgetHeight = mWidgetInfo[eachWidget].size.height()/scaleFactor;
result += newWidgetHeight;
eachWidget->setMinimumHeight(newWidgetHeight);
eachWidget->setMaximumHeight(newWidgetHeight + 1);
}
else{
scaleFactor = (float)mWidgetInfo[eachWidget].height() / (float)pSize.height();
newWidgetWidth = mWidgetInfo[eachWidget].width()/scaleFactor;
scaleFactor = (float)mWidgetInfo[eachWidget].size.height() / (float)pSize.height();
newWidgetWidth = mWidgetInfo[eachWidget].size.width()/scaleFactor;
result += newWidgetWidth;
eachWidget->setMinimumWidth(newWidgetWidth);
eachWidget->setMinimumWidth(newWidgetWidth+1);
}
#ifndef Q_WS_WIN
qDebug() << __PRETTY_FUNCTION__ << "widget " << &eachWidget;
qDebug() << __PRETTY_FUNCTION__ << "count " << count++;
qDebug() << __PRETTY_FUNCTION__ << "widget orignal size " << mWidgetInfo[eachWidget];
qDebug() << __PRETTY_FUNCTION__ << "widget orignal size " << mWidgetInfo[eachWidget].size;
qDebug() << __PRETTY_FUNCTION__ << "containes size " << pSize;
qDebug() << __PRETTY_FUNCTION__ << "scale factor " << scaleFactor;
qDebug() << __PRETTY_FUNCTION__ << "new height " << result;
#endif
}
else{
if(eWidgetListOrientation_Vertical == mOrientation){
result += mWidgetInfo[eachWidget].size.height();
eachWidget->setMinimumHeight(mWidgetInfo[eachWidget].size.height());
eachWidget->setMaximumHeight(mWidgetInfo[eachWidget].size.height() + 1);
}
else{
result += mWidgetInfo[eachWidget].size.width();
eachWidget->setMinimumWidth(mWidgetInfo[eachWidget].size.width());
eachWidget->setMaximumWidth(mWidgetInfo[eachWidget].size.width() + 1);
}
}
//Adding a vertical/horizontal space between each element of the list
result += mListElementsSpacing;
}

@ -20,10 +20,16 @@ class UBWidgetList : public QScrollArea
{
Q_OBJECT
typedef struct
{
QSize size;
bool isResizable;
} sWidgetProperties;
public:
UBWidgetList(QWidget* parent=0, eWidgetListOrientation orientation = eWidgetListOrientation_Vertical, const char* name = "UBWidgetList");
~UBWidgetList();
void addWidget(QWidget* widget);
void addWidget(QWidget* widget, bool isResizable = true);
void removeWidget(QWidget* widget);
void setMargin(int margin);
void setEmptyText(const QString& text);
@ -44,7 +50,7 @@ private:
eWidgetListOrientation mOrientation;
int mMargin;
int mListElementsSpacing;
QMap<QWidget*,QSize> mWidgetInfo;
QMap<QWidget*, sWidgetProperties> mWidgetInfo;
QLabel* mpEmptyLabel;
};

@ -119,7 +119,7 @@ UBTeacherBarWidget::UBTeacherBarWidget(QWidget *parent, const char *name):UBDock
mpLayout->addLayout(mpActionLayout, 0);
// Media
mpMediaLabel = new QLabel(tr("Media"), mpContainer);
mpMediaLabel = new QLabel(tr("Medias"), mpContainer);
mpLayout->addWidget(mpMediaLabel, 0);
mpDropMediaZone = new UBTeacherBarDropMediaZone(mpContainer);
mpLayout->addWidget(mpDropMediaZone, 1);
@ -380,7 +380,15 @@ void UBTeacherBarWidget::loadContent()
}
// Add the media
mpPreview->mediaViewer()->loadMedia(nextInfos.medias);
if(nextInfos.medias.count() > 0){
QList<QWidget*> widgetList;
widgetList.append(mpPreview->mediaLabel());
mpPreview->mediaViewer()->loadWidgets(widgetList,false);
int loadedMedia = mpPreview->mediaViewer()->loadMedia(nextInfos.medias);
if(loadedMedia)
mpPreview->mediaLabel()->setVisible(true);
}
// Add the links
if(!mUrlList.empty()){
@ -879,8 +887,10 @@ void UBTeacherBarPreviewWidget::setComments(const QString &comments)
mpComments->setVisible(true);
mpCommentsLabel->setVisible(true);
mWidgets << mpCommentsLabel;
mMediaViewer.loadWidgets(mWidgets, false);
mWidgets.clear();
mWidgets << mpComments;
mMediaViewer.loadWidgets(mWidgets);
mMediaViewer.loadWidgets(mWidgets, true);
}
}
@ -894,7 +904,7 @@ void UBTeacherBarPreviewWidget::hideElements()
{
mpActionsLabel = new QLabel(tr("Actions"), this);
mpActionsLabel->setObjectName("UBTeacherBarPreviewSubtitle");
mpMediaLabel = new QLabel(tr("Media"), this);
mpMediaLabel = new QLabel(tr("Medias"), this);
mpMediaLabel->setObjectName("UBTeacherBarPreviewSubtitle");
mpCommentsLabel = new QLabel(tr("Comments"), this);
mpCommentsLabel->setObjectName("UBTeacherBarPreviewSubtitle");
@ -917,6 +927,8 @@ void UBTeacherBarPreviewWidget::setActions(QStringList actions)
mWidgets.clear();
mpActionsLabel->setVisible(true);
mWidgets << mpActionsLabel;
mediaViewer()->loadWidgets(mWidgets,false);
mWidgets.clear();
foreach(QString action, actions){
QStringList desc = action.split(';');
if(2 <= desc.size()){
@ -928,7 +940,7 @@ void UBTeacherBarPreviewWidget::setActions(QStringList actions)
mWidgets << mpTmpAction;
}
}
mMediaViewer.loadWidgets(mWidgets);
mMediaViewer.loadWidgets(mWidgets, true);
}
}
@ -938,12 +950,14 @@ void UBTeacherBarPreviewWidget::setLinks(QStringList links)
mWidgets.clear();
mpLinksLabel->setVisible(true);
mWidgets << mpLinksLabel;
mMediaViewer.loadWidgets(mWidgets, false);
mWidgets.clear();
foreach(QString link, links){
mpTmpLink = new QLabel(link, this);
mpTmpLink->setOpenExternalLinks(true);
mWidgets << mpTmpLink;
}
mMediaViewer.loadWidgets(mWidgets);
mMediaViewer.loadWidgets(mWidgets, true);
}
}
@ -983,17 +997,18 @@ void UBTeacherBarPreviewMedia::cleanMedia()
mWidgetList.clear();
}
void UBTeacherBarPreviewMedia::loadWidgets(QList<QWidget*> pWidgetsList)
void UBTeacherBarPreviewMedia::loadWidgets(QList<QWidget*> pWidgetsList, bool isResizable)
{
foreach(QWidget*eachWidget, pWidgetsList){
mWidget->addWidget(eachWidget);
mWidget->addWidget(eachWidget,isResizable);
mWidgetList[eachWidget]="DRAG UNAVAILABLE";
}
}
void UBTeacherBarPreviewMedia::loadMedia(QStringList pMedias)
int UBTeacherBarPreviewMedia::loadMedia(QStringList pMedias)
{
int addedMedia = 0;
foreach(QString eachString, pMedias){
if(!eachString.isEmpty()){
QString mimeType = UBFileSystemUtils::mimeTypeFromFileName(eachString);
@ -1002,12 +1017,14 @@ void UBTeacherBarPreviewMedia::loadMedia(QStringList pMedias)
label->loadImage(eachString);
mWidget->addWidget(label);
mWidgetList[label]=eachString;
addedMedia += 1;
}
else if(mimeType.contains("video") || mimeType.contains("audio")){
UBDraggableMediaPlayer* mediaPlayer = new UBDraggableMediaPlayer();
mediaPlayer->setFile(eachString);
mWidget->addWidget(mediaPlayer);
mWidgetList[mediaPlayer] = eachString;
addedMedia += 1;
}
else{
qWarning() << "pMediaPath" << eachString;
@ -1015,6 +1032,7 @@ void UBTeacherBarPreviewMedia::loadMedia(QStringList pMedias)
}
}
}
return addedMedia;
}
// -----------------------------------------------------------------------------------------------

@ -87,8 +87,8 @@ class UBTeacherBarPreviewMedia : public QWidget
public:
UBTeacherBarPreviewMedia(QWidget* parent=0, const char* name="UBTeacherBarPreviewMedia");
~UBTeacherBarPreviewMedia();
void loadMedia(QStringList pMedias);
void loadWidgets(QList<QWidget*> pWidgetList);
int loadMedia(QStringList pMedias);
void loadWidgets(QList<QWidget*> pWidgetList, bool isResizable = true);
void cleanMedia();
private:
@ -146,6 +146,7 @@ public:
void setActions(QStringList actions);
void setLinks(QStringList links);
void clean();
QLabel* mediaLabel() { return mpMediaLabel;}
signals:
void showEditMode();

Loading…
Cancel
Save