diff --git a/src/customWidgets/UBWidgetList.cpp b/src/customWidgets/UBWidgetList.cpp index 67c157b2..b46d0770 100644 --- a/src/customWidgets/UBWidgetList.cpp +++ b/src/customWidgets/UBWidgetList.cpp @@ -12,6 +12,8 @@ UBWidgetList::UBWidgetList(QWidget* parent, eWidgetListOrientation orientation, mpContainer = new QWidget(this); mpEmptyLabel = new QLabel(this); mpEmptyLabel->setObjectName("emptyString"); + mpEmptyLabel->setWordWrap(true); + mpEmptyLabel->setAlignment(Qt::AlignCenter); if(eWidgetListOrientation_Vertical == orientation){ setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); diff --git a/src/gui/UBTeacherBarWidget.cpp b/src/gui/UBTeacherBarWidget.cpp index 65c4ad91..479e570f 100644 --- a/src/gui/UBTeacherBarWidget.cpp +++ b/src/gui/UBTeacherBarWidget.cpp @@ -278,11 +278,11 @@ void UBTeacherBarWidget::saveContent() infos.title = mpTitle->text(); // Duration if(mpDuration1->isChecked()){ - infos.Duration = 0; + infos.Duration = eDuration_Quarter; }else if(mpDuration2->isChecked()){ - infos.Duration = 1; + infos.Duration = eDuration_Half; }else{ - infos.Duration = 2; + infos.Duration = eDuration_ThreeQuarter; } // Actions for(int i=0; isetText(nextInfos.title); // Duration switch(nextInfos.Duration){ - case 0: mpDuration1->setChecked(true); + case eDuration_Quarter: mpDuration1->setChecked(true); break; - case 1: mpDuration2->setChecked(true); + case eDuration_Half: mpDuration2->setChecked(true); break; - case 2: mpDuration3->setChecked(true); + case eDuration_ThreeQuarter: mpDuration3->setChecked(true); break; default: mpDuration1->setChecked(true); break; @@ -351,8 +351,18 @@ void UBTeacherBarWidget::loadContent() } if(!isEmpty()){ + // Update the fields of the preview widget + mpPreview->setTitle(mpTitle->text()); mpPreview->mediaViewer()->loadMedia(nextInfos.medias); mpStackWidget->setCurrentWidget(mpPreview); + if(mpDuration1->isChecked()){ + mpPreview->setDuration(eDuration_Quarter); + }else if(mpDuration2->isChecked()){ + mpPreview->setDuration(eDuration_Half); + }else{ + mpPreview->setDuration(eDuration_ThreeQuarter); + } + } } @@ -675,22 +685,60 @@ void UBUrlWidget::setUrl(const QString &url) // ------------------------------------------------------------------------------------ UBTeacherBarPreviewWidget::UBTeacherBarPreviewWidget(QWidget *parent, const char *name):QWidget(parent) - , mpLayout(NULL) , mpEditButton(NULL) - , mpEditLayout(NULL) + , mpTitle(NULL) + , mpDuration(NULL) + , mpActionsLabel(NULL) + , mpMediaLabel(NULL) + , mpCommentsLabel(NULL) { setObjectName(name); - mpLayout = new QVBoxLayout(this); - setLayout(mpLayout); + setLayout(&mLayout); + + setAttribute(Qt::WA_StyledBackground, true); + setStyleSheet(UBApplication::globalStyleSheet()); + + // Build the Preview widget + // Title + duration + mpTitle = new QLabel(this); + mpTitle->setObjectName("UBTeacherBarPreviewTitle"); + mpTitle->setWordWrap(true); + mpTitle->setAlignment(Qt::AlignCenter); + mpDuration = new QLabel(this); + mTitleDurationLayout.addWidget(mpTitle, 0); + mTitleDurationLayout.addWidget(mpDuration, 1); + mLayout.addLayout(&mTitleDurationLayout, 0); + // Actions + mpActionsLabel = new QLabel(tr("Actions"), this); + mActionLabelLayout.addWidget(mpActionsLabel, 0); + mActionLabelLayout.addStretch(1); + mLayout.addLayout(&mActionLabelLayout); + + // Media + mpMediaLabel = new QLabel(tr("Medias"), this); + mMediaLabelLayout.addWidget(mpMediaLabel, 0); + mMediaLabelLayout.addStretch(1); + mLayout.addLayout(&mMediaLabelLayout); + mLayout.addWidget(&mMediaViewer, 0); + + // Temporary stretch + mLayout.addStretch(1); + + // Comments + mpCommentsLabel = new QLabel(tr("Comments"), this); + mCommentsLabelLayout.addWidget(mpCommentsLabel, 0); + mCommentsLabelLayout.addStretch(1); + mLayout.addLayout(&mCommentsLabelLayout); + + // Edit button mpEditButton = new QPushButton(tr("Edit infos"), this); - mpEditLayout = new QVBoxLayout(); - mpEditLayout->addStretch(1); - mpEditLayout->addWidget(mpEditButton, 0); - mpEditLayout->addStretch(1); - mpEditLayout->addWidget(&mMediaViewer); - mpLayout->addLayout(mpEditLayout); + mpEditButton->setObjectName("DockPaletteWidgetButton"); + mEditLayout.addStretch(1); + mEditLayout.addWidget(mpEditButton, 0); + mEditLayout.addStretch(1); + mLayout.addLayout(&mEditLayout, 0); connect(mpEditButton, SIGNAL(clicked()), this, SLOT(onEdit())); @@ -698,18 +746,30 @@ UBTeacherBarPreviewWidget::UBTeacherBarPreviewWidget(QWidget *parent, const char UBTeacherBarPreviewWidget::~UBTeacherBarPreviewWidget() { + if(NULL != mpTitle){ + delete mpTitle; + mpTitle = NULL; + } + if(NULL != mpDuration){ + delete mpDuration; + mpDuration = NULL; + } + if(NULL != mpActionsLabel){ + delete mpActionsLabel; + mpActionsLabel = NULL; + } + if(NULL != mpMediaLabel){ + delete mpMediaLabel; + mpMediaLabel = NULL; + } + if(NULL != mpCommentsLabel){ + delete mpCommentsLabel; + mpCommentsLabel = NULL; + } if(NULL != mpEditButton){ delete mpEditButton; mpEditButton = NULL; } - if(NULL != mpEditLayout){ - delete mpEditLayout; - mpEditLayout = NULL; - } - if(NULL != mpLayout){ - delete mpLayout; - mpLayout = NULL; - } } void UBTeacherBarPreviewWidget::onEdit() @@ -717,6 +777,33 @@ void UBTeacherBarPreviewWidget::onEdit() emit showEditMode(); } +void UBTeacherBarPreviewWidget::setTitle(const QString &title) +{ + if(NULL != mpTitle){ + mpTitle->setText(title); + } +} + +void UBTeacherBarPreviewWidget::setDuration(eDuration duration) +{ + if(NULL != mpDuration){ + QPixmap p; + switch(duration){ + case eDuration_Quarter: + p = QPixmap(":images/duration1.png"); + break; + case eDuration_Half: + p = QPixmap(":images/duration2.png"); + break; + case eDuration_ThreeQuarter: + p = QPixmap(":images/duration3.png"); + break; + default: + break; + } + mpDuration->setPixmap(p.scaledToHeight(16, Qt::SmoothTransformation)); + } +} // ------------------------------------------------------------------------------------ UBTeacherBarPreviewMedia::UBTeacherBarPreviewMedia(QWidget* parent, const char* name) : QWidget(parent) diff --git a/src/gui/UBTeacherBarWidget.h b/src/gui/UBTeacherBarWidget.h index 50377d65..a76de6a7 100644 --- a/src/gui/UBTeacherBarWidget.h +++ b/src/gui/UBTeacherBarWidget.h @@ -21,6 +21,12 @@ class UBMediaPlayer; #define LABEL_MINWIDHT 80 +typedef enum{ + eDuration_Quarter, + eDuration_Half, + eDuration_ThreeQuarter +}eDuration; + class UBTeacherStudentAction : public QWidget { Q_OBJECT @@ -111,6 +117,8 @@ public: UBTeacherBarPreviewWidget(QWidget* parent=0, const char* name="UBTeacherBarPreviewWidget"); ~UBTeacherBarPreviewWidget(); UBTeacherBarPreviewMedia* mediaViewer() {return &mMediaViewer;} + void setTitle(const QString& title); + void setDuration(eDuration duration); signals: void showEditMode(); @@ -119,10 +127,19 @@ private slots: void onEdit(); private: - QVBoxLayout* mpLayout; - QPushButton* mpEditButton; - QVBoxLayout* mpEditLayout; + QVBoxLayout mLayout; + QHBoxLayout mEditLayout; + QHBoxLayout mTitleDurationLayout; + QHBoxLayout mActionLabelLayout; + QHBoxLayout mMediaLabelLayout; + QHBoxLayout mCommentsLabelLayout; UBTeacherBarPreviewMedia mMediaViewer; + QPushButton* mpEditButton; + QLabel* mpTitle; + QLabel* mpDuration; + QLabel* mpActionsLabel; + QLabel* mpMediaLabel; + QLabel* mpCommentsLabel; }; class UBTeacherBarWidget : public UBDockPaletteWidget