diff --git a/resources/sankore.qrc b/resources/sankore.qrc index 8601be9f..d81ac808 100644 --- a/resources/sankore.qrc +++ b/resources/sankore.qrc @@ -341,5 +341,11 @@ images/duration1.png images/duration2.png images/duration3.png + images/licenses/ccby.png + images/licenses/ccbync.png + images/licenses/ccbyncnd.png + images/licenses/ccbyncsa.png + images/licenses/ccbynd.png + images/licenses/ccbysa.png diff --git a/resources/style.qss b/resources/style.qss index bdb0966a..8ce2d992 100644 --- a/resources/style.qss +++ b/resources/style.qss @@ -83,10 +83,11 @@ QWidget#UBTeacherBarTargetBox background-color: white; } -QWidget#UBActionPreviewContent +QWidget#UBActionPreviewContent, +QTextEdit#UBCommentPreview { border-radius : 10px; - border: 2px solid; + border: 2px solid #999999; padding: 5px 5px 5px 5px; } diff --git a/src/gui/UBTBDocumentEditWidget.cpp b/src/gui/UBTBDocumentEditWidget.cpp index 618dc0ca..1d93900c 100644 --- a/src/gui/UBTBDocumentEditWidget.cpp +++ b/src/gui/UBTBDocumentEditWidget.cpp @@ -10,6 +10,7 @@ UBTBDocumentEditWidget::UBTBDocumentEditWidget(UBTeacherBarDataMgr* pDataMgr, QW , mpTarget(NULL) , mpMetadataLabel(NULL) , mpLicenseLabel(NULL) + , mpLicenseCombox(NULL) { setObjectName(name); @@ -31,6 +32,7 @@ UBTBDocumentEditWidget::UBTBDocumentEditWidget(UBTeacherBarDataMgr* pDataMgr, QW mpTitle = new QLineEdit(mpContainer); mpTitle->setObjectName("DockPaletteWidgetLineEdit"); mContainerLayout.addWidget(mpTitle, 0); + mContainerLayout.addWidget(&mTitleSeparator); // Target mpTargetLabel = new QLabel(tr("Session Target"), mpContainer); @@ -39,18 +41,31 @@ UBTBDocumentEditWidget::UBTBDocumentEditWidget(UBTeacherBarDataMgr* pDataMgr, QW mpTarget = new QTextEdit(mpContainer); mpTarget->setObjectName("UBTeacherBarTargetBox"); mContainerLayout.addWidget(mpTarget, 1); + mContainerLayout.addWidget(&mTargetSeparator); // Metadata mpMetadataLabel = new QLabel(tr("Metadata"), mpContainer); mpMetadataLabel->setAlignment(Qt::AlignLeft); //mpMetadataLabel->setObjectName("UBTeacherBarPreviewSubtitle"); mContainerLayout.addWidget(mpMetadataLabel, 0); + mContainerLayout.addWidget(&mLicenseSeparator); // License mpLicenseLabel = new QLabel(tr("License"), mpContainer); mpLicenseLabel->setAlignment(Qt::AlignLeft); //mpLicenseLabel->setObjectName("UBTeacherBarPreviewSubtitle"); mContainerLayout.addWidget(mpLicenseLabel, 0); + mpLicenseCombox = new QComboBox(this); + mpLicenseCombox->setObjectName("DockPaletteWidgetComboBox"); + QStringList qslLicenses; + qslLicenses << "CC BY"; + qslLicenses << "CC BY-ND"; + qslLicenses << "CC BY-NC-SA"; + qslLicenses << "CC BY-SA"; + qslLicenses << "CC BY-NC"; + qslLicenses << "CC BY-NC-ND"; + mpLicenseCombox->addItems(qslLicenses); + mContainerLayout.addWidget(mpLicenseCombox); mpPageViewButton = new QPushButton(tr("Page View"), this); mpPageViewButton->setObjectName("DockPaletteWidgetButton"); @@ -65,6 +80,7 @@ UBTBDocumentEditWidget::UBTBDocumentEditWidget(UBTeacherBarDataMgr* pDataMgr, QW connect(mpPreviewButton, SIGNAL(clicked()), this, SLOT(onPreview())); connect(mpTitle, SIGNAL(textChanged(QString)), this, SLOT(onSessionTitleChanged())); connect(mpTarget, SIGNAL(textChanged()), this, SLOT(onSessionTargetChanged())); + connect(mpLicenseCombox, SIGNAL(currentIndexChanged(int)), this, SLOT(onLicenseCurrentIndexChanged(int))); } UBTBDocumentEditWidget::~UBTBDocumentEditWidget() @@ -75,6 +91,7 @@ UBTBDocumentEditWidget::~UBTBDocumentEditWidget() DELETEPTR(mpTarget); DELETEPTR(mpMetadataLabel); DELETEPTR(mpLicenseLabel); + DELETEPTR(mpLicenseCombox); DELETEPTR(mpPageViewButton); DELETEPTR(mpPreviewButton); } @@ -101,6 +118,12 @@ void UBTBDocumentEditWidget::onSessionTargetChanged() emit valueChanged(); } +void UBTBDocumentEditWidget::onLicenseCurrentIndexChanged(int selection) +{ + mpDataMgr->setSessionLicence((eLicense)selection); + emit valueChanged(); +} + void UBTBDocumentEditWidget::updateFields() { mpTitle->setText(mpDataMgr->sessionTitle()); diff --git a/src/gui/UBTBDocumentEditWidget.h b/src/gui/UBTBDocumentEditWidget.h index 147e5404..8cfb7ff9 100644 --- a/src/gui/UBTBDocumentEditWidget.h +++ b/src/gui/UBTBDocumentEditWidget.h @@ -6,6 +6,7 @@ #include #include #include +#include #include "UBTeacherBarDataMgr.h" @@ -27,6 +28,7 @@ private slots: void onPreview(); void onSessionTitleChanged(); void onSessionTargetChanged(); + void onLicenseCurrentIndexChanged(int selection); private: QVBoxLayout mLayout; @@ -35,6 +37,9 @@ private: QVBoxLayout mContainerLayout; QPushButton* mpPageViewButton; QPushButton* mpPreviewButton; + UBTBSeparator mTitleSeparator; + UBTBSeparator mTargetSeparator; + UBTBSeparator mLicenseSeparator; QWidget* mpContainer; QLabel* mpTitleLabel; @@ -43,6 +48,7 @@ private: QTextEdit* mpTarget; QLabel* mpMetadataLabel; QLabel* mpLicenseLabel; + QComboBox* mpLicenseCombox; UBTeacherBarDataMgr* mpDataMgr; }; diff --git a/src/gui/UBTeacherBarDataMgr.cpp b/src/gui/UBTeacherBarDataMgr.cpp index b612aa57..4233e58a 100644 --- a/src/gui/UBTeacherBarDataMgr.cpp +++ b/src/gui/UBTeacherBarDataMgr.cpp @@ -58,7 +58,7 @@ void UBTeacherBarDataMgr::saveContent() documentProxy->setSessionTitle(mSessionTitle); documentProxy->setSessionTarget(mSessionTarget); - documentProxy->setSessionLicence(mSessionLicence); + documentProxy->setSessionLicence(QString("%0").arg(mSessionLicence)); UBMetadataDcSubsetAdaptor::persist(documentProxy); } @@ -75,7 +75,7 @@ void UBTeacherBarDataMgr::loadContent(bool docChanged) if(true/*docChanged*/){ mSessionTitle = documentProxy->sessionTitle(); mSessionTarget = documentProxy->sessionTarget(); - mSessionLicence = documentProxy->sessionLicence(); + mSessionLicence = (eLicense)documentProxy->sessionLicence().toInt(); } // Page Title @@ -113,3 +113,64 @@ void UBTeacherBarDataMgr::loadContent(bool docChanged) mComments = nextInfos.comments; } +// ------------------------------------------------------------------------------------ +UBTBSeparator::UBTBSeparator(QWidget *parent, const char *name):QFrame(parent) +{ + setObjectName("UBTBSeparator"); + setMinimumHeight(5); + setMaximumHeight(5); +} + +UBTBSeparator::~UBTBSeparator() +{ + +} + +// ------------------------------------------------------------------------------------ +UBTBLicenseWidget::UBTBLicenseWidget(QWidget *parent, const char *name):QWidget(parent) +{ + setObjectName(name); + setLayout(&mLayout); + + mpIcon = new QLabel(this); + mpText = new QLabel(this); + mpText->setWordWrap(true); + mLayout.addWidget(mpIcon); + mLayout.addWidget(mpText); +} + +UBTBLicenseWidget::~UBTBLicenseWidget() +{ + DELETEPTR(mpIcon); + DELETEPTR(mpText); +} + +void UBTBLicenseWidget::setLicense(eLicense lic) +{ + switch(lic){ + case eLicense_CCBY: + mpIcon->setPixmap(QPixmap(":images/licenses/ccby.png")); + mpText->setText(tr("Creative Common License %0").arg("CC BY")); + break; + case eLicense_CCBYND: + mpIcon->setPixmap(QPixmap(":images/licenses/ccbynd.png")); + mpText->setText(tr("Creative Common License %0").arg("CC BY-ND")); + break; + case eLicense_CCBYNCSA: + mpIcon->setPixmap(QPixmap(":images/licenses/ccbyncsa.png")); + mpText->setText(tr("Creative Common License %0").arg("CC BY-NC-SA")); + break; + case eLicense_CCBYSA: + mpIcon->setPixmap(QPixmap(":images/licenses/ccbysa.png")); + mpText->setText(tr("Creative Common License %0").arg("CC BY-SA")); + break; + case eLicense_CCBYNC: + mpIcon->setPixmap(QPixmap(":images/licenses/ccbync.png")); + mpText->setText(tr("Creative Common License %0").arg("CC BY-NC")); + break; + case eLicense_CCBYNCND: + mpIcon->setPixmap(QPixmap(":images/licenses/ccbyncnd.png")); + mpText->setText(tr("Creative Common License %0").arg("CC BY-NC-ND")); + break; + } +} diff --git a/src/gui/UBTeacherBarDataMgr.h b/src/gui/UBTeacherBarDataMgr.h index 3158dab6..7ddca7e9 100644 --- a/src/gui/UBTeacherBarDataMgr.h +++ b/src/gui/UBTeacherBarDataMgr.h @@ -9,6 +9,7 @@ #include #include #include +#include typedef enum{ eTeacherBarState_DocumentEdit, @@ -32,6 +33,35 @@ typedef struct{ QString link; }sLink; +typedef enum{ + eLicense_CCBY, + eLicense_CCBYND, + eLicense_CCBYNCSA, + eLicense_CCBYSA, + eLicense_CCBYNC, + eLicense_CCBYNCND +}eLicense; + +class UBTBSeparator : public QFrame +{ +public: + UBTBSeparator(QWidget* parent=0, const char* name="UBTBSeparator"); + ~UBTBSeparator(); +}; + +class UBTBLicenseWidget : public QWidget +{ +public: + UBTBLicenseWidget(QWidget* parent=0, const char* name="UBTBLicenseWidget"); + ~UBTBLicenseWidget(); + void setLicense(eLicense lic); + +private: + QHBoxLayout mLayout; + QLabel* mpIcon; + QLabel* mpText; +}; + class UBTeacherBarDataMgr { public: @@ -47,8 +77,8 @@ public: QString sessionTarget(){return mSessionTarget;} // Licence - void setSessionLicence(const QString& licence){mSessionLicence = licence;} - QString sessionLicence(){return mSessionLicence;} + void setSessionLicence(eLicense licence){mSessionLicence = licence;} + eLicense sessionLicence(){return mSessionLicence;} // Page Title void setPageTitle(const QString& title){mPageTitle = title;} @@ -77,7 +107,7 @@ public: private: QString mSessionTitle; QString mSessionTarget; - QString mSessionLicence; + eLicense mSessionLicence; QString mPageTitle; QString mComments; diff --git a/src/gui/UBTeacherBarPreviewWidget.cpp b/src/gui/UBTeacherBarPreviewWidget.cpp index 43331956..9b93008b 100644 --- a/src/gui/UBTeacherBarPreviewWidget.cpp +++ b/src/gui/UBTeacherBarPreviewWidget.cpp @@ -126,7 +126,7 @@ void UBActionPreview::setContent(const QString &content) { if(NULL != mpContent){ mpContent->setText(content); - setMinimumHeight(mpOwner->height() + mpContent->height()); + setMinimumHeight(mpOwner->height() + mpContent->document()->documentLayout()->documentSize().toSize().height()); } } @@ -139,18 +139,6 @@ UBTBPreviewContainer::UBTBPreviewContainer(QWidget *parent, const char *name):UB UBTBPreviewContainer::~UBTBPreviewContainer() { -} -// ------------------------------------------------------------------------------------ -UBTBPreviewSeparator::UBTBPreviewSeparator(QWidget *parent, const char *name):QFrame(parent) -{ - setObjectName("UBTBSeparator"); - setMinimumHeight(5); - setMaximumHeight(5); -} - -UBTBPreviewSeparator::~UBTBPreviewSeparator() -{ - } // ------------------------------------------------------------------------------------ @@ -206,11 +194,8 @@ UBTeacherBarPreviewWidget::UBTeacherBarPreviewWidget(UBTeacherBarDataMgr* pDataM // License mLayout.addWidget(&mLicenseSeparator); - mpLicenseLabel = new QLabel(tr("License"), this); - mpLicenseLabel->setObjectName("UBTeacherBarPreviewSubtitle"); + mpLicenseLabel = new UBTBLicenseWidget(this); mLayout.addWidget(mpLicenseLabel); - // TODO : Add the license field here - // Edit button mpEditButton = new QPushButton(tr("Edit infos"), this); @@ -271,11 +256,14 @@ void UBTeacherBarPreviewWidget::updateFields() // Media generateMedias(); + // Comments + generateComments(); + // Links generateLinks(); - // Comments - generateComments(); + // License + mpLicenseLabel->setLicense(mpDataMgr->sessionLicence()); } @@ -295,6 +283,9 @@ void UBTeacherBarPreviewWidget::clearFields() } mStoredWidgets.clear(); } + + // License + mpLicenseLabel->setLicense(eLicense_CCBY); } void UBTeacherBarPreviewWidget::generateActions() diff --git a/src/gui/UBTeacherBarPreviewWidget.h b/src/gui/UBTeacherBarPreviewWidget.h index c1820777..ada45f6e 100644 --- a/src/gui/UBTeacherBarPreviewWidget.h +++ b/src/gui/UBTeacherBarPreviewWidget.h @@ -4,7 +4,6 @@ #include #include #include -#include #include "core/UBPersistenceManager.h" #include "customWidgets/UBWidgetList.h" @@ -52,13 +51,6 @@ public: ~UBTBPreviewContainer(); }; -class UBTBPreviewSeparator : public QFrame -{ -public: - UBTBPreviewSeparator(QWidget* parent=0, const char* name="UBTBPreviewSeparator"); - ~UBTBPreviewSeparator(); -}; - class UBTeacherBarPreviewWidget : public QWidget { Q_OBJECT @@ -90,7 +82,7 @@ private: // Titles QVBoxLayout mTitleLayout; - UBTBPreviewSeparator mTitleSeparator; + UBTBSeparator mTitleSeparator; QWidget mTitleContainer; QLabel* mpSessionTitle; QLabel* mpTitle; @@ -102,8 +94,10 @@ private: QLabel* mpScheduleLabel; // License - UBTBPreviewSeparator mLicenseSeparator; - QLabel* mpLicenseLabel; + UBTBSeparator mLicenseSeparator; + // TODO : replace the QLabel of the license by a widget done for that! + UBTBLicenseWidget* mpLicenseLabel; + /** Pointer to the datas */ UBTeacherBarDataMgr* mpDataMgr;