diff --git a/Sankore_3.1.pro b/Sankore_3.1.pro
index a8467a52..c2372f83 100644
--- a/Sankore_3.1.pro
+++ b/Sankore_3.1.pro
@@ -53,6 +53,8 @@ include(src/desktop/desktop.pri)
include(src/web/web.pri)
include(src/softwareupdate/softwareupdate.pri)
include(src/transition/transition.pri)
+include(src/customWidgets/customWidgets.pri)
+include(src/interfaces/interfaces.pri)
DEPENDPATH += src/pdf-merger
INCLUDEPATH += src/pdf-merger
@@ -398,3 +400,4 @@ INSTALLS = UB_ETC \
UB_THIRDPARTY_INTERACTIVE
OTHER_FILES +=
+
diff --git a/resources/images/duration1.png b/resources/images/duration1.png
new file mode 100644
index 00000000..5f1f8355
Binary files /dev/null and b/resources/images/duration1.png differ
diff --git a/resources/images/duration2.png b/resources/images/duration2.png
new file mode 100644
index 00000000..37dcb1ca
Binary files /dev/null and b/resources/images/duration2.png differ
diff --git a/resources/images/duration3.png b/resources/images/duration3.png
new file mode 100644
index 00000000..9c61f7f8
Binary files /dev/null and b/resources/images/duration3.png differ
diff --git a/resources/images/licenses/ccby.png b/resources/images/licenses/ccby.png
new file mode 100644
index 00000000..822491ed
Binary files /dev/null and b/resources/images/licenses/ccby.png differ
diff --git a/resources/images/licenses/ccbync.png b/resources/images/licenses/ccbync.png
new file mode 100644
index 00000000..5f982147
Binary files /dev/null and b/resources/images/licenses/ccbync.png differ
diff --git a/resources/images/licenses/ccbyncnd.png b/resources/images/licenses/ccbyncnd.png
new file mode 100644
index 00000000..49f272f8
Binary files /dev/null and b/resources/images/licenses/ccbyncnd.png differ
diff --git a/resources/images/licenses/ccbyncsa.png b/resources/images/licenses/ccbyncsa.png
new file mode 100644
index 00000000..0f2a0f10
Binary files /dev/null and b/resources/images/licenses/ccbyncsa.png differ
diff --git a/resources/images/licenses/ccbynd.png b/resources/images/licenses/ccbynd.png
new file mode 100644
index 00000000..8f317035
Binary files /dev/null and b/resources/images/licenses/ccbynd.png differ
diff --git a/resources/images/licenses/ccbysa.png b/resources/images/licenses/ccbysa.png
new file mode 100644
index 00000000..f0a944e0
Binary files /dev/null and b/resources/images/licenses/ccbysa.png differ
diff --git a/resources/sankore.qrc b/resources/sankore.qrc
index c0ff2a69..d81ac808 100644
--- a/resources/sankore.qrc
+++ b/resources/sankore.qrc
@@ -338,5 +338,14 @@
images/download_close.png
images/download_open.png
images/tab_mask.png
+ 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 cfa6b41c..8ce2d992 100644
--- a/resources/style.qss
+++ b/resources/style.qss
@@ -1,16 +1,65 @@
QWidget#DockPaletteWidgetBox,
QWidget#documentNavigator,
QWidget#UBLibPathViewer,
-QWidget#UBTeacherStudentAction,
QWidget#UBLibNavigatorWidget,
QWidget#UBLibItemProperties,
-QWidget#UBDownloadWidget
+QWidget#UBDownloadWidget,
+QWidget#UBWidgetList,
+QWidget#UBTeacherBarDropMediaZone,
+QWidget#UBTBMediaContainer
{
background: #EEEEEE;
border-radius: 10px;
border: 2px solid #999999;
}
+QFrame#UBTBSeparator
+{
+ background: #DDDDDD;
+ border-radius: 2px;
+ border: 1px solid #DDDDDD;
+}
+
+QWidget#UBMediaVideoContainer
+{
+ background: #000000;
+ border-radius: 10px;
+ border: 2px solid #999999;
+}
+
+QWidget#UBTeacherBarPreviewWidget
+{
+ background: #FFFFFF;
+ border-radius: 10px;
+ border: 2px solid #999999;
+}
+
+QLabel#UBTBPreviewSessionTitle
+{
+ font-size: 12px;
+}
+
+QLabel#UBTeacherBarPreviewTitle
+{
+ color: #555555;
+ font-size : 20px;
+ font-weight:bold;
+ padding-left:5px;
+}
+
+QLabel#UBMediaPlayerButton
+{
+ padding: 0px 0px 0px 0px;
+}
+
+QLabel#UBTeacherBarPreviewSubtitle
+{
+ color: #555555;
+ font-size : 15px;
+ font-weight:bold;
+ padding-left:5px;
+}
+
QWidget#UBLibWebView
{
background: #EEEEEE;
@@ -18,6 +67,30 @@ QWidget#UBLibWebView
border: 2px solid #999999;
}
+QWidget#UBActionPreviewOwner
+{
+ color: #555555;
+ font-size : 12px;
+ font-weight: bold;
+}
+
+QWidget#UBTeacherBarPreviewComments,
+QWidget#UBTeacherBarTargetBox
+{
+ border-radius: 10px;
+ border: white 2px solid;
+ padding: 5px 5px 5px 5px;
+ background-color: white;
+}
+
+QWidget#UBActionPreviewContent,
+QTextEdit#UBCommentPreview
+{
+ border-radius : 10px;
+ border: 2px solid #999999;
+ padding: 5px 5px 5px 5px;
+}
+
QWebView#SearchEngineView
{
background:white;
diff --git a/src/adaptors/UBImportDocument.cpp b/src/adaptors/UBImportDocument.cpp
index 17251ae5..f441b980 100644
--- a/src/adaptors/UBImportDocument.cpp
+++ b/src/adaptors/UBImportDocument.cpp
@@ -14,7 +14,6 @@
*/
#include "UBImportDocument.h"
-#include "UBMetadataDcSubsetAdaptor.h"
#include "document/UBDocumentProxy.h"
#include "frameworks/UBFileSystemUtils.h"
@@ -49,7 +48,7 @@ QStringList UBImportDocument::supportedExtentions()
QString UBImportDocument::importFileFilter()
{
- return tr("Sankore 3.1 (*.ubz)");
+ return tr("Open-Sankore (*.ubz)");
}
diff --git a/src/adaptors/UBImportImage.cpp b/src/adaptors/UBImportImage.cpp
index 5418b1da..f2829dd6 100644
--- a/src/adaptors/UBImportImage.cpp
+++ b/src/adaptors/UBImportImage.cpp
@@ -14,7 +14,6 @@
*/
#include "UBImportImage.h"
-#include "UBMetadataDcSubsetAdaptor.h"
#include "UBSvgSubsetAdaptor.h"
#include "document/UBDocumentProxy.h"
diff --git a/src/adaptors/UBImportPDF.cpp b/src/adaptors/UBImportPDF.cpp
index e15e1541..d3cf8b38 100644
--- a/src/adaptors/UBImportPDF.cpp
+++ b/src/adaptors/UBImportPDF.cpp
@@ -14,7 +14,6 @@
*/
#include "UBImportPDF.h"
-#include "UBMetadataDcSubsetAdaptor.h"
#include "UBSvgSubsetAdaptor.h"
#include "document/UBDocumentProxy.h"
diff --git a/src/adaptors/UBMetadataDcSubsetAdaptor.cpp b/src/adaptors/UBMetadataDcSubsetAdaptor.cpp
index 2bd280d6..145196e9 100644
--- a/src/adaptors/UBMetadataDcSubsetAdaptor.cpp
+++ b/src/adaptors/UBMetadataDcSubsetAdaptor.cpp
@@ -97,7 +97,7 @@ void UBMetadataDcSubsetAdaptor::persist(UBDocumentProxy* proxy)
// introduced in UB 4.2
xmlWriter.writeTextElement(nsDc, "identifier", proxy->metaData(UBSettings::documentIdentifer).toString());
- xmlWriter.writeTextElement(UBSettings::uniboardDocumentNamespaceUri, "version", UBSettings::currentFileVersion);
+ xmlWriter.writeTextElement(UBSettings::uniboardDocumentNamespaceUri, "version", UBSettings::currentFileVersion);
QString width = QString::number(proxy->defaultDocumentSize().width());
QString height = QString::number(proxy->defaultDocumentSize().height());
xmlWriter.writeTextElement(UBSettings::uniboardDocumentNamespaceUri, "size", QString("%1x%2").arg(width).arg(height));
@@ -105,6 +105,15 @@ void UBMetadataDcSubsetAdaptor::persist(UBDocumentProxy* proxy)
// introduced in UB 4.4
xmlWriter.writeTextElement(UBSettings::uniboardDocumentNamespaceUri, "updated-at", proxy->metaData(UBSettings::documentUpdatedAt).toString());
+ // introduced in OpenSankore 1.40.00
+ xmlWriter.writeTextElement(UBSettings::uniboardDocumentNamespaceUri,UBSettings::sessionTitle,proxy->metaData(UBSettings::sessionTitle).toString());
+ xmlWriter.writeTextElement(UBSettings::uniboardDocumentNamespaceUri,UBSettings::sessionTarget,proxy->metaData(UBSettings::sessionTarget).toString());
+ xmlWriter.writeTextElement(UBSettings::uniboardDocumentNamespaceUri,UBSettings::sessionLicence,proxy->metaData(UBSettings::sessionLicence).toString());
+ xmlWriter.writeTextElement(UBSettings::uniboardDocumentNamespaceUri,UBSettings::sessionKeywords,proxy->metaData(UBSettings::sessionKeywords).toString());
+ xmlWriter.writeTextElement(UBSettings::uniboardDocumentNamespaceUri,UBSettings::sessionLevel,proxy->metaData(UBSettings::sessionLevel).toString());
+ xmlWriter.writeTextElement(UBSettings::uniboardDocumentNamespaceUri,UBSettings::sessionTopic,proxy->metaData(UBSettings::sessionTopic).toString());
+ xmlWriter.writeTextElement(UBSettings::uniboardDocumentNamespaceUri,UBSettings::sessionAuthors,proxy->metaData(UBSettings::sessionAuthors).toString());
+
xmlWriter.writeEndElement(); //dc:Description
xmlWriter.writeEndElement(); //RDF
@@ -204,7 +213,41 @@ QMap UBMetadataDcSubsetAdaptor::load(QString pPath)
metadata.insert(UBSettings::documentUpdatedAt, xml.readElementText());
updatedAtFound = true;
}
-
+ else if (xml.name() == UBSettings::sessionTitle // introduced in OpenSankore 1.40.00
+ && xml.namespaceUri() == UBSettings::uniboardDocumentNamespaceUri)
+ {
+ metadata.insert(UBSettings::sessionTitle, xml.readElementText());
+ }
+ else if (xml.name() == UBSettings::sessionTarget // introduced in OpenSankore 1.40.00
+ && xml.namespaceUri() == UBSettings::uniboardDocumentNamespaceUri)
+ {
+ metadata.insert(UBSettings::sessionTarget, xml.readElementText());
+ }
+ else if (xml.name() == UBSettings::sessionLicence // introduced in OpenSankore 1.40.00
+ && xml.namespaceUri() == UBSettings::uniboardDocumentNamespaceUri)
+ {
+ metadata.insert(UBSettings::sessionLicence, xml.readElementText());
+ }
+ else if (xml.name() == UBSettings::sessionKeywords // introduced in OpenSankore 1.40.00
+ && xml.namespaceUri() == UBSettings::uniboardDocumentNamespaceUri)
+ {
+ metadata.insert(UBSettings::sessionKeywords, xml.readElementText());
+ }
+ else if (xml.name() == UBSettings::sessionLevel // introduced in OpenSankore 1.40.00
+ && xml.namespaceUri() == UBSettings::uniboardDocumentNamespaceUri)
+ {
+ metadata.insert(UBSettings::sessionLevel, xml.readElementText());
+ }
+ else if (xml.name() == UBSettings::sessionTopic // introduced in OpenSankore 1.40.00
+ && xml.namespaceUri() == UBSettings::uniboardDocumentNamespaceUri)
+ {
+ metadata.insert(UBSettings::sessionTopic, xml.readElementText());
+ }
+ else if (xml.name() == UBSettings::sessionAuthors // introduced in OpenSankore 1.40.00
+ && xml.namespaceUri() == UBSettings::uniboardDocumentNamespaceUri)
+ {
+ metadata.insert(UBSettings::sessionAuthors, xml.readElementText());
+ }
metadata.insert(UBSettings::documentVersion, docVersion);
}
diff --git a/src/board/UBBoardPaletteManager.cpp b/src/board/UBBoardPaletteManager.cpp
index 8c20d89a..91b16b8e 100644
--- a/src/board/UBBoardPaletteManager.cpp
+++ b/src/board/UBBoardPaletteManager.cpp
@@ -193,6 +193,10 @@ void UBBoardPaletteManager::setupDockPaletteWidgets()
mLeftPalette->registerWidget(mpPageNavigWidget);
mLeftPalette->addTab(mpPageNavigWidget);
+ // The teacher bar widget will always be there
+ mLeftPalette->registerWidget(mpTeacherBarWidget);
+ mLeftPalette->addTab(mpTeacherBarWidget);
+
mLeftPalette->connectSignals();
mRightPalette = new UBRightPalette(mContainer);
@@ -201,11 +205,6 @@ void UBBoardPaletteManager::setupDockPaletteWidgets()
mRightPalette->addTab(mpLibWidget);
// The cache widget will be visible only if a cache is put on the page
mRightPalette->registerWidget(mpCachePropWidget);
- // The teacher bar widget will always be there
-
- // TeacherBarWidget moved to left side just for testing!!!!
- mLeftPalette->registerWidget(mpTeacherBarWidget);
- mLeftPalette->addTab(mpTeacherBarWidget);
// The download widget will be part of the right palette but
// will become visible only when the first download starts
@@ -791,9 +790,6 @@ void UBBoardPaletteManager::changeMode(eUBDockPaletteWidgetMode newMode, bool is
}
else
mKeyboardPalette->setParent(0);
-
-// mKeyboardPalette->update();
-
}
}
break;
diff --git a/src/board/UBBoardView.cpp b/src/board/UBBoardView.cpp
index ed816413..94ccc729 100644
--- a/src/board/UBBoardView.cpp
+++ b/src/board/UBBoardView.cpp
@@ -20,6 +20,7 @@
#include "UBDrawingController.h"
#include "frameworks/UBGeometryUtils.h"
+#include "frameworks/UBPlatformUtils.h"
#include "core/UBSettings.h"
#include "core/UBMimeData.h"
@@ -34,6 +35,8 @@
#include "gui/UBToolWidget.h"
#include "gui/UBResources.h"
#include "gui/UBMainWindow.h"
+#include "gui/UBMediaPlayer.h"
+#include "gui/UBThumbnailWidget.h"
#include "board/UBBoardController.h"
@@ -43,9 +46,9 @@
#include "domain/UBItem.h"
#include "document/UBDocumentProxy.h"
-#include "../gui/UBThumbnailWidget.h"
-#include "frameworks/UBPlatformUtils.h"
+#include "customWidgets/UBDraggableLabel.h"
+#include "customWidgets/UBDraggableMedia.h"
#include "core/memcheck.h"
@@ -864,7 +867,8 @@ void UBBoardView::dropEvent (QDropEvent *event)
return;
}
- if(!event->source() || dynamic_cast(event->source()) || dynamic_cast(event->source()))
+ qDebug() << event->source();
+ if(!event->source() || dynamic_cast(event->source()) || dynamic_cast(event->source()) || dynamic_cast(event->source()) || dynamic_cast(event->source()) || dynamic_cast(event->source()))
{
mController->processMimeData (event->mimeData (), mapToScene (event->pos ()));
event->acceptProposedAction ();
diff --git a/src/core/UBApplicationController.cpp b/src/core/UBApplicationController.cpp
index 68c9b81b..2c24539a 100644
--- a/src/core/UBApplicationController.cpp
+++ b/src/core/UBApplicationController.cpp
@@ -722,7 +722,6 @@ void UBApplicationController::importFile(const QString& pFilePath)
void UBApplicationController::useMultiScreen(bool use)
{
mDisplayManager->setUseMultiScreen(use);
-
}
diff --git a/src/core/UBDisplayManager.cpp b/src/core/UBDisplayManager.cpp
index 6ecdc679..96c25059 100644
--- a/src/core/UBDisplayManager.cpp
+++ b/src/core/UBDisplayManager.cpp
@@ -48,7 +48,7 @@ UBDisplayManager::UBDisplayManager(QObject *parent)
void UBDisplayManager::initScreenIndexes()
{
- int screenCount = numScreens();
+ int screenCount = 1;//= numScreens();
mScreenIndexesRoles.clear();
diff --git a/src/core/UBPersistenceManager.cpp b/src/core/UBPersistenceManager.cpp
index a4e44b29..4e2d5d9e 100644
--- a/src/core/UBPersistenceManager.cpp
+++ b/src/core/UBPersistenceManager.cpp
@@ -1102,16 +1102,35 @@ void UBPersistenceManager::persistTeacherBar(UBDocumentProxy* pDocumentProxy, in
// Set the element values
QDomElement teacherBarElem = teacherBarNode.toElement();
teacherBarElem.setAttribute("title", infos.title);
- teacherBarElem.setAttribute("phasis", infos.phasis);
- teacherBarElem.setAttribute("duration", infos.Duration);
- teacherBarElem.setAttribute("equipment", infos.material);
- teacherBarElem.setAttribute("activity", infos.activity);
- teacherBarElem.setAttribute("action1Teacher", infos.action1Master);
- teacherBarElem.setAttribute("action1Student", infos.action1Student);
- teacherBarElem.setAttribute("action2Teacher", infos.action2Master);
- teacherBarElem.setAttribute("action2Student", infos.action2Student);
- teacherBarElem.setAttribute("action3Teacher", infos.action3Master);
- teacherBarElem.setAttribute("action3Student", infos.action3Student);
+
+ QString qsAct;
+ for(int i=0; i documentSizes;
- //QSize defaultDocumentSize;
+ QSize defaultDocumentSize;
UBSetting* svgViewBoxMargin;
UBSetting* pdfMargin;
diff --git a/src/customWidgets/UBDraggableLabel.cpp b/src/customWidgets/UBDraggableLabel.cpp
new file mode 100644
index 00000000..200205b9
--- /dev/null
+++ b/src/customWidgets/UBDraggableLabel.cpp
@@ -0,0 +1,39 @@
+#include
+#include
+#include
+
+#include "UBDraggableLabel.h"
+
+
+UBDraggableLabel::UBDraggableLabel(QWidget *parent) :
+ QLabel(parent)
+{
+}
+
+UBDraggableLabel::~UBDraggableLabel()
+{
+ //NOOP
+}
+
+void UBDraggableLabel::loadImage(QString imagePath)
+{
+ mSourcePath = imagePath;
+ QPixmap pix = QPixmap(mSourcePath);
+ setPixmap(pix);
+ setScaledContents(true);
+}
+
+void UBDraggableLabel::mousePressEvent(QMouseEvent *event)
+{
+ Q_UNUSED(event);
+ QMimeData *mimeData = new QMimeData;
+ QList urls;
+ urls << QUrl::fromLocalFile(mSourcePath);
+ mimeData->setUrls(urls);
+ mimeData->setText(mSourcePath);
+
+
+ QDrag *drag = new QDrag(this);
+ drag->setMimeData(mimeData);
+ drag->start();
+}
diff --git a/src/customWidgets/UBDraggableLabel.h b/src/customWidgets/UBDraggableLabel.h
new file mode 100644
index 00000000..384b313e
--- /dev/null
+++ b/src/customWidgets/UBDraggableLabel.h
@@ -0,0 +1,23 @@
+#ifndef UBDRAGGABLELABEL_H
+#define UBDRAGGABLELABEL_H
+
+#include
+
+class UBDraggableLabel : public QLabel
+{
+ Q_OBJECT
+public:
+ UBDraggableLabel(QWidget *parent = 0);
+ ~UBDraggableLabel();
+ void loadImage(QString imagePath);
+signals:
+
+public slots:
+
+protected:
+ QString mSourcePath;
+ void mousePressEvent(QMouseEvent *event);
+
+};
+
+#endif // UBDRAGGABLELABEL_H
diff --git a/src/customWidgets/UBDraggableMedia.cpp b/src/customWidgets/UBDraggableMedia.cpp
new file mode 100644
index 00000000..6d2551f2
--- /dev/null
+++ b/src/customWidgets/UBDraggableMedia.cpp
@@ -0,0 +1,42 @@
+#include
+#include
+
+#include "UBDraggableMedia.h"
+
+UBDraggableMedia::UBDraggableMedia(eMediaType type, QWidget *parent, const char *name):UBMediaWidget(type, parent, name)
+{
+
+}
+
+UBDraggableMedia::~UBDraggableMedia()
+{
+
+}
+
+void UBDraggableMedia::mousePressEvent(QMouseEvent* ev)
+{
+ if(Qt::LeftButton == ev->button()){
+ mDragStartPos = ev->pos();
+ }
+}
+
+void UBDraggableMedia::mouseMoveEvent(QMouseEvent* ev)
+{
+ if(!(ev->buttons() & Qt::LeftButton)){
+ return;
+ }
+ if((ev->pos() - mDragStartPos).manhattanLength() < QApplication::startDragDistance()){
+ return;
+ }
+ QDrag *drag = new QDrag(this);
+ QMimeData *mimeData = new QMimeData;
+
+ QList urls;
+ urls << QUrl(mFilePath);
+ mimeData->setText(mFilePath);
+ mimeData->setUrls(urls);
+
+ drag->setMimeData(mimeData);
+
+ Qt::DropAction dropAction = drag->exec(Qt::CopyAction | Qt::MoveAction);
+}
diff --git a/src/customWidgets/UBDraggableMedia.h b/src/customWidgets/UBDraggableMedia.h
new file mode 100644
index 00000000..b45c9391
--- /dev/null
+++ b/src/customWidgets/UBDraggableMedia.h
@@ -0,0 +1,19 @@
+#ifndef UBDRAGGABLEMEDIA_H
+#define UBDRAGGABLEMEDIA_H
+
+#include "UBMediaWidget.h"
+
+class UBDraggableMedia : public UBMediaWidget
+{
+public:
+ UBDraggableMedia(eMediaType type = eMediaType_Video, QWidget* parent=0, const char* name="UBDraggableMedia");
+ ~UBDraggableMedia();
+protected:
+ void mousePressEvent(QMouseEvent* ev);
+ void mouseMoveEvent(QMouseEvent* ev);
+
+private:
+ QPoint mDragStartPos;
+};
+
+#endif // UBDRAGGABLEMEDIA_H
diff --git a/src/customWidgets/UBGlobals.h b/src/customWidgets/UBGlobals.h
new file mode 100644
index 00000000..1707ceac
--- /dev/null
+++ b/src/customWidgets/UBGlobals.h
@@ -0,0 +1,9 @@
+#ifndef UBGLOBALS_H
+#define UBGLOBALS_H
+
+#define DELETEPTR(ptr) if(NULL != ptr){ \
+ delete ptr; \
+ ptr = NULL; \
+ }
+
+#endif // UBGLOBALS_H
diff --git a/src/customWidgets/UBMediaWidget.cpp b/src/customWidgets/UBMediaWidget.cpp
new file mode 100644
index 00000000..c1809d93
--- /dev/null
+++ b/src/customWidgets/UBMediaWidget.cpp
@@ -0,0 +1,334 @@
+/*
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+#include "core/UBApplication.h"
+#include "UBGlobals.h"
+#include "UBMediaWidget.h"
+
+/**
+ * \brief Constructor
+ * @param type as the media type
+ * @param parent as the parent widget
+ * @param name as the object name
+ */
+UBMediaWidget::UBMediaWidget(eMediaType type, QWidget *parent, const char *name):QWidget(parent)
+ , mpMediaObject(NULL)
+ , mpVideoWidget(NULL)
+ , mpAudioOutput(NULL)
+ , mpPlayStopButton(NULL)
+ , mpPauseButton(NULL)
+ , mpSlider(NULL)
+ , mAutoUpdate(false)
+ , mGeneratingThumbnail(false)
+ , mBorder(5)
+ , mpMediaContainer(NULL)
+ , mpCover(NULL)
+{
+ setObjectName(name);
+
+ setAttribute(Qt::WA_StyledBackground, true);
+ setStyleSheet(UBApplication::globalStyleSheet());
+
+ mType = type;
+ setLayout(&mLayout);
+
+ mpPlayStopButton = new UBMediaButton(this);
+ mpPlayStopButton->setPixmap(QPixmap(":images/play.svg"));
+ mpPauseButton = new UBMediaButton(this);
+ mpPauseButton->setPixmap(QPixmap(":images/pause.svg"));
+ mpPauseButton->setEnabled(false);
+ mpSlider = new QSlider(this);
+ mpSlider->setOrientation(Qt::Horizontal);
+ mpSlider->setMinimum(0);
+ mpSlider->setMaximum(0);
+
+ mSeekerLayout.addWidget(mpPlayStopButton, 0);
+ mSeekerLayout.addWidget(mpPauseButton, 0);
+ mSeekerLayout.addWidget(mpSlider, 1);
+ mSeekerLayout.setContentsMargins(0, 0, 0, 0);
+
+ connect(mpPlayStopButton, SIGNAL(clicked()), this, SLOT(onPlayStopClicked()));
+ connect(mpPauseButton, SIGNAL(clicked()), this, SLOT(onPauseClicked()));
+ connect(mpSlider, SIGNAL(valueChanged(int)), this, SLOT(onSliderChanged(int)));
+}
+
+/**
+ * \brief Destructor
+ */
+UBMediaWidget::~UBMediaWidget()
+{
+ DELETEPTR(mpSlider);
+ DELETEPTR(mpPauseButton);
+ DELETEPTR(mpPlayStopButton);
+ DELETEPTR(mpAudioOutput);
+ DELETEPTR(mpVideoWidget);
+ DELETEPTR(mpMediaObject);
+ DELETEPTR(mpCover);
+}
+
+/**
+ * \brief Set the media file
+ * @param filePath as the media file path
+ */
+void UBMediaWidget::setFile(const QString &filePath)
+{
+ Q_ASSERT("" != filePath);
+ mFilePath = filePath;
+ mpMediaObject = new Phonon::MediaObject(this);
+ mpMediaObject->setTickInterval(TICK_INTERVAL);
+ connect(mpMediaObject, SIGNAL(stateChanged(Phonon::State,Phonon::State)), this, SLOT(onStateChanged(Phonon::State,Phonon::State)));
+ connect(mpMediaObject, SIGNAL(totalTimeChanged(qint64)), this, SLOT(onTotalTimeChanged(qint64)));
+ connect(mpMediaObject, SIGNAL(tick(qint64)), this, SLOT(onTick(qint64)));
+ mpMediaObject->setCurrentSource(Phonon::MediaSource(filePath));
+ createMediaPlayer();
+}
+
+/**
+ * \brief Get the media type
+ * @returns the media type
+ */
+eMediaType UBMediaWidget::mediaType()
+{
+ return mType;
+}
+
+void UBMediaWidget::showEvent(QShowEvent* event)
+{
+ if(!mpVideoWidget){
+ mpVideoWidget = new Phonon::VideoWidget(this);
+ mMediaLayout.addStretch(1);
+ mMediaLayout.addWidget(mpVideoWidget, 0);
+ mMediaLayout.addStretch(1);
+ Phonon::createPath(mpMediaObject, mpVideoWidget);
+ adaptSizeToVideo();
+ mpMediaObject->play();
+ mpMediaObject->stop();
+ }
+ QWidget::showEvent(event);
+}
+
+/**
+ * \brief Create the media player
+ */
+void UBMediaWidget::createMediaPlayer()
+{
+ mpMediaContainer = new QWidget(this);
+ mpMediaContainer->setObjectName("UBMediaVideoContainer");
+ mpMediaContainer->setLayout(&mMediaLayout);
+
+ if(eMediaType_Video == mType){
+ mMediaLayout.setContentsMargins(10, 10, 25, 10);
+ if(isVisible()){
+ mpVideoWidget = new Phonon::VideoWidget(this);
+ mMediaLayout.addStretch(1);
+ mMediaLayout.addWidget(mpVideoWidget, 0);
+ mMediaLayout.addStretch(1);
+ Phonon::createPath(mpMediaObject, mpVideoWidget);
+ adaptSizeToVideo();
+ }
+ mpAudioOutput = new Phonon::AudioOutput(Phonon::VideoCategory, this);
+ Phonon::createPath(mpMediaObject, mpAudioOutput);
+ }else if(eMediaType_Audio == mType){
+ mMediaLayout.setContentsMargins(10, 10, 10, 10);
+ mpCover = new QLabel(mpMediaContainer);
+ mpMediaContainer->setStyleSheet(QString("background: none;"));
+ setAudioCover(":images/libpalette/soundIcon.svg");
+ mpCover->setScaledContents(true);
+ mMediaLayout.addStretch(1);
+ mMediaLayout.addWidget(mpCover, 0);
+ mMediaLayout.addStretch(1);
+ mpAudioOutput = new Phonon::AudioOutput(Phonon::MusicCategory, this);
+ Phonon::createPath(mpMediaObject, mpAudioOutput);
+ }
+ mLayout.addWidget(mpMediaContainer, 1);
+ mLayout.addLayout(&mSeekerLayout, 0);
+}
+
+/**
+ * \brief Adapt the widget size to the video in order to keep the good aspect ratio
+ */
+void UBMediaWidget::adaptSizeToVideo()
+{
+ if(NULL != mpMediaContainer){
+ int origW = mpMediaContainer->width();
+ int origH = mpMediaContainer->height();
+ int newW = width();
+ float scaleFactor = (float)origW/(float)newW;
+ int newH = origH/scaleFactor;
+ resize(newW, height() + newH);
+ }
+}
+
+/**
+ * \brief Handle the media state change notification
+ * @param newState as the new state
+ * @param oldState as the old state
+ */
+void UBMediaWidget::onStateChanged(Phonon::State newState, Phonon::State oldState)
+{
+ if(!mGeneratingThumbnail){
+ if(Phonon::LoadingState == oldState && Phonon::StoppedState == newState){
+ if(eMediaType_Video == mType){
+ // We do that here to generate the thumbnail of the video
+ mGeneratingThumbnail = true;
+ mpMediaObject->play();
+ mpMediaObject->pause();
+ mGeneratingThumbnail = false;
+ }
+ }else if(Phonon::PlayingState == oldState && Phonon::PausedState == newState){
+ mpPlayStopButton->setPixmap(QPixmap(":images/play.svg"));
+ mpPauseButton->setEnabled(false);
+ }else if((Phonon::PausedState == oldState && Phonon::PlayingState == newState) ||
+ (Phonon::StoppedState == oldState && Phonon::PlayingState == newState)){
+ mpPlayStopButton->setPixmap(QPixmap(":images/stop.svg"));
+ mpPauseButton->setEnabled(true);
+ }else if(Phonon::PlayingState == oldState && Phonon::StoppedState == newState){
+ mpPlayStopButton->setPixmap(QPixmap(":images/play.svg"));
+ mpPauseButton->setEnabled(false);
+ mpSlider->setValue(0);
+ }
+ }
+}
+
+/**
+ * \brief Handles the total time change notification
+ * @param total as the new total time
+ */
+void UBMediaWidget::onTotalTimeChanged(qint64 total)
+{
+ mpSlider->setMaximum(total);
+}
+
+/**
+ * \brief Handles the tick notification
+ * @param currentTime as the current time
+ */
+void UBMediaWidget::onTick(qint64 currentTime)
+{
+ mAutoUpdate = true;
+ mpSlider->setValue((int)currentTime);
+ mAutoUpdate = false;
+}
+
+/**
+ * \brief Handles the seeker value change notification
+ * @param value as the new seeker value
+ */
+void UBMediaWidget::onSliderChanged(int value)
+{
+ if(!mAutoUpdate){
+ mpMediaObject->seek(value);
+ }
+}
+
+/**
+ * \brief Toggle Play-Stop
+ */
+void UBMediaWidget::onPlayStopClicked()
+{
+ switch(mpMediaObject->state()){
+ case Phonon::PlayingState:
+ mpMediaObject->stop();
+ break;
+
+ case Phonon::StoppedState:
+ case Phonon::PausedState:
+ mpMediaObject->play();
+ break;
+ default:
+ break;
+ }
+}
+
+/**
+ * \brief Pause the media
+ */
+void UBMediaWidget::onPauseClicked()
+{
+ mpMediaObject->pause();
+}
+
+/**
+ * Get the border
+ * @returns the actual border
+ */
+int UBMediaWidget::border()
+{
+ return mBorder;
+}
+
+/**
+ * \brief Handles the resize event
+ * @param ev as the resize event
+ */
+void UBMediaWidget::resizeEvent(QResizeEvent* ev)
+{
+ Q_UNUSED(ev);
+}
+
+/**
+ * \brief Set the audio cover
+ * @param coverPath as the cover image file path
+ */
+void UBMediaWidget::setAudioCover(const QString &coverPath)
+{
+ if(NULL != mpCover){
+ mpCover->setPixmap(QPixmap(coverPath));
+ }
+}
+
+// -----------------------------------------------------------------------------------------------------------
+/**
+ * \brief Constructor
+ * @param parent as the parent widget
+ * @param name as the object name
+ */
+UBMediaButton::UBMediaButton(QWidget *parent, const char *name):QLabel(parent)
+ , mPressed(false)
+{
+ setObjectName(name);
+ resize(UBMEDIABUTTON_SIZE, UBMEDIABUTTON_SIZE);
+ setStyleSheet(QString("padding:0px 0px 0px 0px; margin:0px 0px 0px 0px;"));
+}
+
+/**
+ * \brief Destructor
+ */
+UBMediaButton::~UBMediaButton()
+{
+
+}
+
+/**
+ * \brief Handles the mouse press notification
+ * @param ev as the mouse press event
+ */
+void UBMediaButton::mousePressEvent(QMouseEvent* ev)
+{
+ Q_UNUSED(ev);
+ mPressed = true;
+}
+
+/**
+ * \brief Handles the mouse release notification
+ * @param ev as the mouse release event
+ */
+void UBMediaButton::mouseReleaseEvent(QMouseEvent* ev)
+{
+ Q_UNUSED(ev);
+ if(mPressed){
+ mPressed = false;
+ emit clicked();
+ }
+}
diff --git a/src/customWidgets/UBMediaWidget.h b/src/customWidgets/UBMediaWidget.h
new file mode 100644
index 00000000..5192c3c7
--- /dev/null
+++ b/src/customWidgets/UBMediaWidget.h
@@ -0,0 +1,122 @@
+/*
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+#ifndef UBMEDIAWIDGET_H
+#define UBMEDIAWIDGET_H
+
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include
+#include
+#include
+
+#include "interfaces/IResizeable.h"
+
+#define UBMEDIABUTTON_SIZE 32
+#define TICK_INTERVAL 1000
+
+/**
+ * \brief The media type
+ */
+typedef enum{
+ eMediaType_Video,
+ eMediaType_Audio
+}eMediaType;
+
+class UBMediaButton : public QLabel
+{
+ Q_OBJECT
+public:
+ UBMediaButton(QWidget* parent=0, const char* name="UBMediaButton");
+ ~UBMediaButton();
+
+signals:
+ void clicked();
+
+protected:
+ void mousePressEvent(QMouseEvent* ev);
+ void mouseReleaseEvent(QMouseEvent* ev);
+
+private:
+ /** And indicator of the press event in progress */
+ bool mPressed;
+};
+
+class UBMediaWidget : public QWidget
+{
+ Q_OBJECT
+public:
+ UBMediaWidget(eMediaType type = eMediaType_Video, QWidget* parent=0, const char* name="UBMediaWidget");
+ ~UBMediaWidget();
+ void setFile(const QString& filePath);
+ eMediaType mediaType();
+ int border();
+ void setAudioCover(const QString& coverPath);
+
+protected:
+ void resizeEvent(QResizeEvent* ev);
+ void showEvent(QShowEvent* event);
+ /** The current media file path */
+ QString mFilePath;
+
+private slots:
+ void onPlayStopClicked();
+ void onPauseClicked();
+ void onStateChanged(Phonon::State newState, Phonon::State oldState);
+ void onTotalTimeChanged(qint64 total);
+ void onTick(qint64 currentTime);
+ void onSliderChanged(int value);
+
+private:
+ void createMediaPlayer();
+ void adaptSizeToVideo();
+
+ /** The current media type */
+ eMediaType mType;
+ /** The media object */
+ Phonon::MediaObject* mpMediaObject;
+ /** The video renderer */
+ Phonon::VideoWidget* mpVideoWidget;
+ /** The audio renderer */
+ Phonon::AudioOutput* mpAudioOutput;
+ /** The principal layout of this widget */
+ QVBoxLayout mLayout;
+ /** The seeker layout */
+ QHBoxLayout mSeekerLayout;
+ /** The play-stop button */
+ UBMediaButton* mpPlayStopButton;
+ /** The pause button */
+ UBMediaButton* mpPauseButton;
+ /** The seeker slider */
+ QSlider* mpSlider;
+ /** An indicator of the seeker auto update in progress */
+ bool mAutoUpdate;
+ /** An indicator of the thumbnail generation in progress */
+ bool mGeneratingThumbnail;
+ /** The border */
+ int mBorder;
+ /** A widget that will contain the media */
+ QWidget* mpMediaContainer;
+ /** The media layout */
+ QHBoxLayout mMediaLayout;
+ /** The audio cover */
+ QLabel* mpCover;
+};
+
+#endif // UBMEDIAWIDGET_H
diff --git a/src/customWidgets/UBWidgetList.cpp b/src/customWidgets/UBWidgetList.cpp
new file mode 100644
index 00000000..6481acb4
--- /dev/null
+++ b/src/customWidgets/UBWidgetList.cpp
@@ -0,0 +1,185 @@
+#include
+#include
+
+#include "UBGlobals.h"
+#include "UBWidgetList.h"
+
+UBWidgetList::UBWidgetList(QWidget* parent, eWidgetListOrientation orientation, const char* name):QScrollArea(parent)
+ , mpLayout(NULL)
+ , mpContainer(NULL)
+ , mMargin(5)
+ , mListElementsSpacing(10)
+ , mpEmptyLabel(NULL)
+{
+ setObjectName(name);
+ mOrientation = 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);
+ setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+ mpLayout = new QVBoxLayout(mpContainer);
+ }
+ else{
+ setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
+ setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+ mpLayout = new QHBoxLayout(mpContainer);
+ }
+ mpLayout->setContentsMargins(margin(), margin(), margin(), margin());
+ mpContainer->setLayout(mpLayout);
+ setWidget(mpContainer);
+}
+
+UBWidgetList::~UBWidgetList()
+{
+ DELETEPTR(mpEmptyLabel);
+ DELETEPTR(mpLayout);
+ DELETEPTR(mpContainer);
+}
+
+void UBWidgetList::addWidget(QWidget *widget)
+{
+ if(NULL != mpLayout && NULL != widget){
+ widget->setParent(mpContainer);
+ mpEmptyLabel->setVisible(false);
+ mWidgetInfo[widget] = widget->size();
+ updateView(size());
+ mpLayout->addWidget(widget);
+
+ // This call is used only to refresh the size of the widgets
+ updateSizes();
+ }
+}
+
+void UBWidgetList::removeWidget(QWidget *widget)
+{
+ if(NULL != mpLayout && NULL != widget){
+ mpLayout->removeWidget(widget);
+ mWidgetInfo.remove(widget);
+ widget->setVisible(false);
+ updateView(size());
+ if(0 == mpLayout->count()){
+ mpEmptyLabel->setVisible(true);
+ }
+ }
+}
+
+
+int UBWidgetList::scaleWidgets(QSize pSize)
+{
+ // to remove the first spacing that shouldn't be there.
+ int result = -mListElementsSpacing;
+ foreach(QWidget* eachWidget, mWidgetInfo.keys()){
+ 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;
+ result += newWidgetHeight;
+ eachWidget->setMinimumHeight(newWidgetHeight- 1);
+ eachWidget->setMaximumHeight(newWidgetHeight);
+ }
+ else{
+ scaleFactor = (float)mWidgetInfo[eachWidget].height() / (float)pSize.height();
+ newWidgetWidth = mWidgetInfo[eachWidget].width()/scaleFactor;
+ result += newWidgetWidth;
+ eachWidget->setMinimumWidth(newWidgetWidth - 1);
+ eachWidget->setMaximumWidth(newWidgetWidth);
+ }
+ //Adding a vertical/horizontal space between each element of the list
+ result += mListElementsSpacing;
+ }
+ return result;
+}
+
+void UBWidgetList::scaleContainer(QSize pSize, int updateValue)
+{
+ if(eWidgetListOrientation_Vertical == mOrientation)
+ mpContainer->resize(pSize.width(), updateValue);
+ else
+ mpContainer->resize(updateValue, pSize.height());
+}
+
+
+void UBWidgetList::updateView(QSize pSize)
+{
+ // Widgets on list are resized automatically to fit the mpcontainer.
+ // so if you want to keep the aspect ratio you have to calculate
+ // the sum of the new widget height and give it to the mpContainer.
+ // The container resize will trig the widgets resize and the good
+ // height permits to respect the aspect ratio.
+ int updatedValue = scaleWidgets(pSize);
+ scaleContainer(pSize,updatedValue);
+}
+
+
+
+void UBWidgetList::resizeEvent(QResizeEvent *ev)
+{
+ Q_UNUSED(ev);
+ mpEmptyLabel->setGeometry((width() - mpEmptyLabel->width()) / 2,
+ (height() - mpEmptyLabel->height()) /2,
+ mpEmptyLabel->width(),
+ mpEmptyLabel->height());
+ updateView(size());
+ updateSizes();
+}
+
+void UBWidgetList::updateSizes()
+{
+ // Resize all the widgets
+ foreach(QWidget* eachWidget, mWidgetInfo.keys()){
+ if(NULL != eachWidget){
+ QSize originalSize = mWidgetInfo[eachWidget];
+ int currentWidth = mpContainer->width();
+ int currentHeight = mpContainer->height();
+ if(eWidgetListOrientation_Vertical == mOrientation){
+ if(verticalScrollBar()->isVisible()){
+ currentWidth -= verticalScrollBar()->width();
+ eachWidget->setStyleSheet(QString("margin-right:%0;").arg(verticalScrollBar()->width()));
+ }
+ float scaleFactor = (float)currentWidth/(float)originalSize.width();
+ currentHeight = originalSize.height()*scaleFactor;
+ }else{
+ if(horizontalScrollBar()->isVisible()){
+ currentHeight -= horizontalScrollBar()->height();
+ eachWidget->setStyleSheet(QString("padding-bottom:%0;").arg(horizontalScrollBar()->height()));
+ }
+ float scaleFactor = (float)currentHeight/(float)originalSize.height();
+ currentWidth = originalSize.width()*scaleFactor;
+ }
+
+ eachWidget->resize(currentWidth, currentHeight);
+ }
+ }
+}
+
+void UBWidgetList::setMargin(int margin)
+{
+ mMargin = margin;
+}
+
+int UBWidgetList::margin()
+{
+ return mMargin;
+}
+
+void UBWidgetList::setEmptyText(const QString &text)
+{
+ if(NULL != mpEmptyLabel){
+ mpEmptyLabel->setText(text);
+ }
+}
+
+bool UBWidgetList::empty()
+{
+ return mWidgetInfo.empty();
+}
+
+// TODO : - add onHover 'delete' button
+
diff --git a/src/customWidgets/UBWidgetList.h b/src/customWidgets/UBWidgetList.h
new file mode 100644
index 00000000..865386ad
--- /dev/null
+++ b/src/customWidgets/UBWidgetList.h
@@ -0,0 +1,60 @@
+#ifndef UBWIDGETLIST_H
+#define UBWIDGETLIST_H
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include "interfaces/IResizeable.h"
+
+typedef enum{
+ eWidgetListOrientation_Vertical,
+ eWidgetListOrientation_Horizontal
+}eWidgetListOrientation;
+
+
+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 removeWidget(QWidget* widget);
+ void setMargin(int margin);
+ void setEmptyText(const QString& text);
+ int margin();
+ bool empty();
+ void setListElementSpacing(int margin) { mListElementsSpacing = margin; }
+ int listElementsSpacing() {return mListElementsSpacing; }
+
+protected:
+ void resizeEvent(QResizeEvent* ev);
+
+private:
+ int scaleWidgets(QSize pSize);
+ void scaleContainer(QSize pSize, int updateValue);
+ void updateView(QSize pSize);
+ void updateSizes();
+ QBoxLayout* mpLayout;
+ QWidget* mpContainer;
+ eWidgetListOrientation mOrientation;
+ int mMargin;
+ int mListElementsSpacing;
+ QMap mWidgetInfo;
+ QLabel* mpEmptyLabel;
+};
+
+#endif // UBWIDGETLIST_H
diff --git a/src/customWidgets/customWidgets.pri b/src/customWidgets/customWidgets.pri
new file mode 100644
index 00000000..aa7b0255
--- /dev/null
+++ b/src/customWidgets/customWidgets.pri
@@ -0,0 +1,11 @@
+
+HEADERS += src/customWidgets/UBWidgetList.h \
+ src/customWidgets/UBDraggableLabel.h \
+ src/customWidgets/UBMediaWidget.h \
+ src/customWidgets/UBGlobals.h \
+ src/customWidgets/UBDraggableMedia.h
+
+SOURCES += src/customWidgets/UBWidgetList.cpp \
+ src/customWidgets/UBDraggableLabel.cpp \
+ src/customWidgets/UBMediaWidget.cpp \
+ src/customWidgets/UBDraggableMedia.cpp
diff --git a/src/document/UBDocumentController.cpp b/src/document/UBDocumentController.cpp
index fa8d6066..9d1f8d42 100644
--- a/src/document/UBDocumentController.cpp
+++ b/src/document/UBDocumentController.cpp
@@ -37,7 +37,6 @@
#include "board/UBBoardPaletteManager.h"
#include "board/UBDrawingController.h"
-//#include "gui/UBKeyboardPalette.h"
#include "gui/UBThumbnailView.h"
#include "gui/UBDocumentTreeWidget.h"
@@ -69,7 +68,6 @@ UBDocumentController::UBDocumentController(UBMainWindow* mainWindow)
, mToolsPalette(0)
, mToolsPalettePositionned(false)
, mTrashTi(0)
-// , mKeyboardPalette(0)
{
setupViews();
setupToolbar();
diff --git a/src/document/UBDocumentProxy.cpp b/src/document/UBDocumentProxy.cpp
index ae084d81..50ef04db 100644
--- a/src/document/UBDocumentProxy.cpp
+++ b/src/document/UBDocumentProxy.cpp
@@ -48,7 +48,15 @@ void UBDocumentProxy::init()
setUuid(QUuid::createUuid());
- setDefaultDocumentSize(UBSettings::settings()->pageSize->get().toSize());
+ setDefaultDocumentSize(UBSettings::settings()->defaultDocumentSize);
+
+ setSessionTitle("");
+ setSessionTarget("");
+ setSessionLicence("");
+ setSessionKeywords("");
+ setSessionLevel("");
+ setSessionTopic("");
+ setSessionAuthor("");
}
@@ -196,6 +204,97 @@ void UBDocumentProxy::setUuid(const QUuid& uuid)
UBSettings::uniboardDocumentNamespaceUri + "/" + UBStringUtils::toCanonicalUuid(uuid));
}
+QString UBDocumentProxy::sessionTitle() const
+{
+ if(mMetaDatas.contains(UBSettings::sessionTitle))
+ return metaData(UBSettings::sessionTitle).toString();
+ else
+ return QString();
+}
+
+void UBDocumentProxy::setSessionTitle(const QString & sessionTitle)
+{
+ setMetaData(UBSettings::sessionTitle,QVariant(sessionTitle));
+}
+
+QString UBDocumentProxy::sessionTarget() const
+{
+ if(mMetaDatas.contains(UBSettings::sessionTarget))
+ return metaData(UBSettings::sessionTarget).toString();
+ else
+ return QString();
+}
+
+void UBDocumentProxy::setSessionTarget(const QString & sessionTarget)
+{
+ setMetaData(UBSettings::sessionTarget,QVariant(sessionTarget));
+}
+
+QString UBDocumentProxy::sessionLicence() const
+{
+ if(mMetaDatas.contains(UBSettings::sessionLicence))
+ return metaData(UBSettings::sessionLicence).toString();
+ else
+ return QString();
+}
+
+void UBDocumentProxy::setSessionLicence(const QString & sessionLicence)
+{
+ setMetaData(UBSettings::sessionLicence,QVariant(sessionLicence));
+}
+
+void UBDocumentProxy::setSessionKeywords(const QString &kw)
+{
+ setMetaData(UBSettings::sessionKeywords,QVariant(kw));
+}
+
+QString UBDocumentProxy::sessionKeywords()
+{
+ if(mMetaDatas.contains(UBSettings::sessionKeywords))
+ return metaData(UBSettings::sessionKeywords).toString();
+ else
+ return QString();
+}
+
+void UBDocumentProxy::setSessionLevel(const QString &level)
+{
+ setMetaData(UBSettings::sessionLevel,QVariant(level));
+}
+
+QString UBDocumentProxy::sessionLevel()
+{
+ if(mMetaDatas.contains(UBSettings::sessionLevel))
+ return metaData(UBSettings::sessionLevel).toString();
+ else
+ return QString();
+}
+
+void UBDocumentProxy::setSessionTopic(const QString &topic)
+{
+ setMetaData(UBSettings::sessionTopic,QVariant(topic));
+}
+
+QString UBDocumentProxy::sessionTopic()
+{
+ if(mMetaDatas.contains(UBSettings::sessionTopic))
+ return metaData(UBSettings::sessionTopic).toString();
+ else
+ return QString();
+}
+
+void UBDocumentProxy::setSessionAuthor(const QString &authors)
+{
+ setMetaData(UBSettings::sessionAuthors,QVariant(authors));
+}
+
+QString UBDocumentProxy::sessionAuthors()
+{
+ if(mMetaDatas.contains(UBSettings::sessionAuthors))
+ return metaData(UBSettings::sessionAuthors).toString();
+ else
+ return QString();
+}
+
bool UBDocumentProxy::isModified() const
{
return mIsModified;
diff --git a/src/document/UBDocumentProxy.h b/src/document/UBDocumentProxy.h
index 20edb47a..a8ec9b3b 100644
--- a/src/document/UBDocumentProxy.h
+++ b/src/document/UBDocumentProxy.h
@@ -45,6 +45,21 @@ class UBDocumentProxy : public QObject
QString name() const;
QString groupName() const;
+ QString sessionTitle() const;
+ void setSessionTitle(const QString& sessionTitle);
+ QString sessionTarget() const;
+ void setSessionTarget(const QString& sessionTarget);
+ QString sessionLicence() const;
+ void setSessionLicence(const QString& sessionLicence);
+ void setSessionKeywords(const QString& kw);
+ QString sessionKeywords();
+ void setSessionLevel(const QString& level);
+ QString sessionLevel();
+ void setSessionTopic(const QString& topic);
+ QString sessionTopic();
+ void setSessionAuthor(const QString& authors);
+ QString sessionAuthors();
+
QSize defaultDocumentSize() const;
void setDefaultDocumentSize(QSize pSize);
diff --git a/src/gui/UBDockPaletteWidget.cpp b/src/gui/UBDockPaletteWidget.cpp
index c845d019..24090ac3 100644
--- a/src/gui/UBDockPaletteWidget.cpp
+++ b/src/gui/UBDockPaletteWidget.cpp
@@ -27,6 +27,15 @@ QString UBDockPaletteWidget::name()
return mName;
}
+/**
+ * When a widget registers a mode it means that it would be displayed on that mode
+ */
+void UBDockPaletteWidget::registerMode(eUBDockPaletteWidgetMode mode)
+{
+ if(!mRegisteredModes.contains(mode))
+ mRegisteredModes.append(mode);
+}
+
void UBDockPaletteWidget::slot_changeMode(eUBDockPaletteWidgetMode newMode)
{
this->setVisible(this->visibleInMode( newMode ));
diff --git a/src/gui/UBDockPaletteWidget.h b/src/gui/UBDockPaletteWidget.h
index 0b69a9e6..7cbf154a 100644
--- a/src/gui/UBDockPaletteWidget.h
+++ b/src/gui/UBDockPaletteWidget.h
@@ -5,6 +5,10 @@
#include
#include
+
+/**
+ * This enum defines the different mode availables.
+ */
typedef enum
{
eUBDockPaletteWidget_BOARD,
@@ -27,6 +31,8 @@ public:
virtual bool visibleInMode(eUBDockPaletteWidgetMode mode) = 0;
+ void registerMode(eUBDockPaletteWidgetMode mode);
+
bool visibleState(){return mVisibleState;}
void setVisibleState(bool state){mVisibleState = state;}
@@ -44,7 +50,7 @@ protected:
QString mName;
/* The current widget available mode list */
- //QVector mRegisteredModes;
+ QVector mRegisteredModes;
bool mVisibleState;
};
diff --git a/src/gui/UBMediaPlayer.cpp b/src/gui/UBMediaPlayer.cpp
new file mode 100644
index 00000000..4ac7a0a4
--- /dev/null
+++ b/src/gui/UBMediaPlayer.cpp
@@ -0,0 +1,389 @@
+#include "UBMediaPlayer.h"
+
+
+
+#include
+
+#define SLIDER_RANGE 8
+
+
+MediaVideoWidget::MediaVideoWidget(UBMediaPlayer *player, QWidget *parent) :
+ Phonon::VideoWidget(parent), m_player(player)/*, m_action(this)*/
+{
+// m_action.setCheckable(true);
+// m_action.setChecked(false);
+// m_action.setShortcut(QKeySequence( Qt::AltModifier + Qt::Key_Return));
+// m_action.setShortcutContext(Qt::WindowShortcut);
+// connect(&m_action, SIGNAL(toggled(bool)), SLOT(setFullScreen(bool)));
+// addAction(&m_action);
+// setAcceptDrops(true);
+}
+
+void MediaVideoWidget::timerEvent(QTimerEvent *e)
+{
+ if (e->timerId() == m_timer.timerId()) {
+ //let's store the cursor shape
+#ifndef QT_NO_CURSOR
+ setCursor(Qt::BlankCursor);
+#endif
+ }
+ Phonon::VideoWidget::timerEvent(e);
+}
+
+
+UBMediaPlayer::UBMediaPlayer() :
+ playButton(0),
+ m_AudioOutput(Phonon::VideoCategory),
+ m_videoWidget(new MediaVideoWidget(this))
+{
+ setContextMenuPolicy(Qt::CustomContextMenu);
+ m_videoWidget->setContextMenuPolicy(Qt::CustomContextMenu);
+
+ QSize buttonSize(26, 20);
+
+// QPushButton *openButton = new QPushButton(this);
+
+//// openButton->setIcon(style()->standardIcon(QStyle::SP_DialogOpenButton));
+//// QPalette bpal;
+//// QColor arrowcolor = bpal.buttonText().color();
+//// if (arrowcolor == Qt::black)
+//// arrowcolor = QColor(80, 80, 80);
+//// bpal.setBrush(QPalette::ButtonText, arrowcolor);
+//// openButton->setPalette(bpal);
+
+// rewindButton = new QPushButton(this);
+// rewindButton->setIcon(style()->standardIcon(QStyle::SP_MediaSkipBackward));
+
+// forwardButton = new QPushButton(this);
+// forwardButton->setIcon(style()->standardIcon(QStyle::SP_MediaSkipForward));
+// forwardButton->setEnabled(false);
+
+ playButton = new QPushButton(this);
+ playIcon = style()->standardIcon(QStyle::SP_MediaPlay);
+ pauseIcon = style()->standardIcon(QStyle::SP_MediaPause);
+ playButton->setIcon(playIcon);
+
+ slider = new Phonon::SeekSlider(this);
+ slider->setMediaObject(&m_MediaObject);
+
+ QVBoxLayout *vLayout = new QVBoxLayout(this);
+ vLayout->setContentsMargins(1, 1, 1, 1);
+
+// QHBoxLayout *layout = new QHBoxLayout();
+
+// info = new QLabel(this);
+// info->setMinimumHeight(70);
+// info->setAcceptDrops(false);
+// info->setMargin(2);
+// info->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken);
+// info->setLineWidth(2);
+// info->setAutoFillBackground(true);
+
+// QPalette palette;
+// palette.setBrush(QPalette::WindowText, Qt::white);
+#ifndef Q_WS_MAC
+// rewindButton->setMinimumSize(buttonSize);
+// forwardButton->setMinimumSize(buttonSize);
+ playButton->setMinimumSize(buttonSize);
+#endif
+// info->setStyleSheet("border-image:url(:/images/screen.png) ; border-width:3px");
+// info->setPalette(palette);
+// info->setText(tr("No media"));
+
+
+// layout->addWidget(rewindButton);
+// layout->addWidget(playButton);
+// layout->addWidget(forwardButton);
+
+// layout->addStretch();
+
+// vLayout->addWidget(info);
+ initVideoWindow();
+ vLayout->addWidget(&m_videoWindow);
+// m_videoWidget->setStyleSheet(QString("background:red;"));
+ QVBoxLayout *buttonPanelLayout = new QVBoxLayout();
+#ifndef Q_WS_WIN
+ m_videoWindow.hide();
+#endif
+// buttonPanelLayout->addLayout(layout);
+
+// timeLabel = new QLabel(this);
+ progressLabel = new QLabel(this);
+ QWidget *sliderPanel = new QWidget(this);
+// sliderPanel->setStyleSheet(QString("background:green;"));
+ QHBoxLayout *sliderLayout = new QHBoxLayout();
+// playButton->setStyleSheet(QString("background:yellow;"));
+ sliderLayout->addWidget(playButton);
+ sliderLayout->addWidget(slider);
+// sliderLayout->addWidget(timeLabel);
+ sliderLayout->addWidget(progressLabel);
+ sliderLayout->setContentsMargins(0, 0, 0, 0);
+ sliderPanel->setLayout(sliderLayout);
+
+ buttonPanelLayout->addWidget(sliderPanel);
+ buttonPanelLayout->setContentsMargins(0, 0, 0, 0);
+#ifdef Q_OS_MAC
+// layout->setSpacing(4);
+ buttonPanelLayout->setSpacing(0);
+// info->setMinimumHeight(100);
+// info->setFont(QFont("verdana", 15));
+// openButton->setFocusPolicy(Qt::NoFocus);
+#endif
+ QWidget *buttonPanelWidget = new QWidget(this);
+ buttonPanelWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
+ buttonPanelWidget->setLayout(buttonPanelLayout);
+ vLayout->addWidget(buttonPanelWidget);
+
+ QHBoxLayout *labelLayout = new QHBoxLayout();
+ vLayout->addLayout(labelLayout);
+ setLayout(vLayout);
+
+
+ // Setup signal connections:
+// connect(rewindButton, SIGNAL(clicked()), this, SLOT(rewind()));
+
+ connect(playButton, SIGNAL(clicked()), this, SLOT(playPause()));
+// connect(forwardButton, SIGNAL(clicked()), this, SLOT(forward()));
+
+// connect(&m_MediaObject, SIGNAL(totalTimeChanged(qint64)), this, SLOT(updateTime()));
+// connect(&m_MediaObject, SIGNAL(tick(qint64)), this, SLOT(updateTime()));
+ connect(&m_MediaObject, SIGNAL(finished()), this, SLOT(finished()));
+ connect(&m_MediaObject, SIGNAL(stateChanged(Phonon::State,Phonon::State)), this, SLOT(stateChanged(Phonon::State,Phonon::State)));
+ connect(&m_MediaObject, SIGNAL(bufferStatus(int)), this, SLOT(bufferStatus(int)));
+ connect(&m_MediaObject, SIGNAL(hasVideoChanged(bool)), this, SLOT(hasVideoChanged(bool)));
+
+// rewindButton->setEnabled(false);
+ playButton->setEnabled(false);
+// setAcceptDrops(true);
+
+ m_audioOutputPath = Phonon::createPath(&m_MediaObject, &m_AudioOutput);
+ Phonon::createPath(&m_MediaObject, m_videoWidget);
+
+ resize(minimumSizeHint());
+}
+
+void UBMediaPlayer::stateChanged(Phonon::State newstate, Phonon::State oldstate)
+{
+ if (oldstate == Phonon::LoadingState) {
+ QRect videoHintRect = QRect(QPoint(0, 0), m_videoWindow.sizeHint());
+ QApplication::desktop()->screenGeometry().intersected(videoHintRect);
+
+ if (m_MediaObject.hasVideo()) {
+ qApp->processEvents();
+ resize(sizeHint());
+ } else
+ resize(minimumSize());
+
+ }
+
+ switch (newstate) {
+ case Phonon::ErrorState:
+ if (m_MediaObject.errorType() == Phonon::FatalError) {
+ playButton->setEnabled(false);
+// rewindButton->setEnabled(false);
+ } else {
+ m_MediaObject.pause();
+ }
+ QMessageBox::warning(this, "Phonon UBMediaPlayer", m_MediaObject.errorString(), QMessageBox::Close);
+ break;
+
+ case Phonon::StoppedState:
+// m_videoWidget-> (false);
+ // Fall through
+ case Phonon::PausedState:
+ playButton->setIcon(playIcon);
+ if (m_MediaObject.currentSource().type() != Phonon::MediaSource::Invalid){
+ playButton->setEnabled(true);
+// rewindButton->setEnabled(true);
+ } else {
+ playButton->setEnabled(false);
+// rewindButton->setEnabled(false);
+ }
+ break;
+ case Phonon::PlayingState:
+ playButton->setEnabled(true);
+ playButton->setIcon(pauseIcon);
+ if (m_MediaObject.hasVideo())
+ m_videoWindow.show();
+ // Fall through
+ case Phonon::BufferingState:
+// rewindButton->setEnabled(true);
+ break;
+ case Phonon::LoadingState:
+// rewindButton->setEnabled(false);
+ break;
+ }
+
+}
+
+void UBMediaPlayer::setVolume(qreal volume)
+{
+ m_AudioOutput.setVolume(volume);
+}
+
+
+void UBMediaPlayer::initVideoWindow()
+{
+ QVBoxLayout *videoLayout = new QVBoxLayout();
+ videoLayout->addWidget(m_videoWidget);
+ videoLayout->setContentsMargins(0, 0, 0, 0);
+ m_videoWindow.setLayout(videoLayout);
+ m_videoWindow.setMinimumSize(60, 40);
+}
+
+void UBMediaPlayer::playPause()
+{
+ if (m_MediaObject.state() == Phonon::PlayingState)
+ m_MediaObject.pause();
+ else {
+ if (m_MediaObject.currentTime() == m_MediaObject.totalTime())
+ m_MediaObject.seek(0);
+ m_MediaObject.play();
+ }
+}
+
+void UBMediaPlayer::setFile(const QString &fileName)
+{
+ setWindowTitle(fileName.right(fileName.length() - fileName.lastIndexOf('/') - 1));
+ m_MediaObject.setCurrentSource(Phonon::MediaSource(fileName));
+}
+
+void UBMediaPlayer::setLocation(const QString& location)
+{
+ setWindowTitle(location.right(location.length() - location.lastIndexOf('/') - 1));
+ m_MediaObject.setCurrentSource(Phonon::MediaSource(QUrl::fromEncoded(location.toUtf8())));
+ m_MediaObject.play();
+}
+
+
+void UBMediaPlayer::openFile()
+{
+ QStringList fileNames = QFileDialog::getOpenFileNames(this, QString(), QDesktopServices::storageLocation(QDesktopServices::MusicLocation));
+
+
+ m_MediaObject.clearQueue();
+ if (fileNames.size() > 0) {
+ QString fileName = fileNames[0];
+ setFile(fileName);
+ for (int i=1; isetEnabled(m_MediaObject.queue().size() > 0);
+}
+
+void UBMediaPlayer::bufferStatus(int percent)
+{
+ if (percent == 100)
+ progressLabel->setText(QString());
+ else {
+ QString str = QString::fromLatin1("(%1%)").arg(percent);
+ progressLabel->setText(str);
+ }
+}
+
+//void UBMediaPlayer::updateTime()
+//{
+// long len = m_MediaObject.totalTime();
+// long pos = m_MediaObject.currentTime();
+// QString timeString;
+// if (pos || len)
+// {
+// int sec = pos/1000;
+// int min = sec/60;
+// int hour = min/60;
+// int msec = pos;
+
+// QTime playTime(hour%60, min%60, sec%60, msec%1000);
+// sec = len / 1000;
+// min = sec / 60;
+// hour = min / 60;
+// msec = len;
+
+// QTime stopTime(hour%60, min%60, sec%60, msec%1000);
+// QString timeFormat = "m:ss";
+// if (hour > 0)
+// timeFormat = "h:mm:ss";
+// timeString = playTime.toString(timeFormat);
+// if (len)
+// timeString += " / " + stopTime.toString(timeFormat);
+// }
+// timeLabel->setText(timeString);
+//}
+
+void UBMediaPlayer::rewind()
+{
+ m_MediaObject.seek(0);
+}
+
+void UBMediaPlayer::forward()
+{
+ QList queue = m_MediaObject.queue();
+ if (queue.size() > 0) {
+ m_MediaObject.setCurrentSource(queue[0]);
+// forwardButton->setEnabled(queue.size() > 1);
+ m_MediaObject.play();
+ }
+}
+
+void UBMediaPlayer::openUrl()
+{
+ QSettings settings;
+ settings.beginGroup(QLatin1String("BrowserMainWindow"));
+ QString sourceURL = settings.value("location").toString();
+ bool ok = false;
+ sourceURL = QInputDialog::getText(this, tr("Open Location"), tr("Please enter a valid address here:"), QLineEdit::Normal, sourceURL, &ok);
+ if (ok && !sourceURL.isEmpty()) {
+ setLocation(sourceURL);
+ settings.setValue("location", sourceURL);
+ }
+}
+
+void UBMediaPlayer::finished()
+{
+}
+
+void UBMediaPlayer::hasVideoChanged(bool bHasVideo)
+{
+// info->setVisible(!bHasVideo);
+ m_videoWindow.setVisible(bHasVideo);
+}
+
+void UBMediaPlayer::resizeEvent(QResizeEvent* pEvent)
+{
+// int origWidth = m_videoWindow.width();
+// int origHeight = m_videoWindow.height();
+
+// float scaleFactor = (float)origWidth / (float)width();
+// int newWidth = width();
+// int newHeigth = origHeight/scaleFactor;
+
+// m_videoWindow.resize(newWidth, newHeigth);
+}
+
+//*************************************************************************
+UBDraggableMediaPlayer::UBDraggableMediaPlayer():UBMediaPlayer()
+{
+// setAcceptDrops(true);
+}
+
+void UBDraggableMediaPlayer::setFile(const QString &text)
+{
+ mSourcePath = text;
+ UBMediaPlayer::setFile(text);
+}
+
+void UBDraggableMediaPlayer::mousePressEvent(QMouseEvent *event)
+{
+ Q_UNUSED(event);
+ QMimeData *mimeData = new QMimeData;
+ QList urls;
+ urls << QUrl::fromLocalFile(mSourcePath);
+ mimeData->setUrls(urls);
+ mimeData->setText(mSourcePath);
+
+
+ QDrag *drag = new QDrag(this);
+ drag->setMimeData(mimeData);
+ drag->start();
+}
+
diff --git a/src/gui/UBMediaPlayer.h b/src/gui/UBMediaPlayer.h
new file mode 100644
index 00000000..9e5e0e1a
--- /dev/null
+++ b/src/gui/UBMediaPlayer.h
@@ -0,0 +1,107 @@
+#ifndef UBUBMediaPlayer_H
+#define UBUBMediaPlayer_H
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+QT_BEGIN_NAMESPACE
+class QPushButton;
+class QLabel;
+class QSlider;
+class QTextEdit;
+QT_END_NAMESPACE
+
+class UBMediaPlayer;
+
+class MediaVideoWidget : public Phonon::VideoWidget
+{
+ Q_OBJECT;
+
+public:
+ MediaVideoWidget(UBMediaPlayer *player, QWidget *parent = 0);
+
+protected:
+ void timerEvent(QTimerEvent *e);
+
+private:
+ UBMediaPlayer* m_player;
+ QBasicTimer m_timer;
+// QAction m_action;
+};
+
+class UBMediaPlayer : public QWidget
+{
+ Q_OBJECT
+public:
+ UBMediaPlayer();
+
+ void setFile(const QString &text);
+ void setLocation(const QString &location);
+ void setVolume(qreal volume);
+
+public slots:
+ void openFile();
+ void rewind();
+ void forward();
+// void updateTime();
+ void finished();
+ void playPause();
+
+protected:
+ void resizeEvent(QResizeEvent* pEvent);
+
+private slots:
+ void stateChanged(Phonon::State newstate, Phonon::State oldstate);
+ void bufferStatus(int percent);
+ void openUrl();
+
+ void hasVideoChanged(bool);
+
+private:
+ void initVideoWindow();
+
+ QIcon playIcon;
+ QIcon pauseIcon;
+ QPushButton *playButton;
+// QPushButton *rewindButton;
+// QPushButton *forwardButton;
+ Phonon::SeekSlider *slider;
+// QLabel *timeLabel;
+ QLabel *progressLabel;
+// QLabel *info;
+
+ QWidget m_videoWindow;
+ Phonon::MediaObject m_MediaObject;
+ Phonon::AudioOutput m_AudioOutput;
+ MediaVideoWidget *m_videoWidget;
+ Phonon::Path m_audioOutputPath;
+};
+
+class UBDraggableMediaPlayer : public UBMediaPlayer
+{
+ Q_OBJECT
+public:
+ UBDraggableMediaPlayer();
+ void setFile(const QString &text);
+protected:
+ QString mSourcePath;
+ void mousePressEvent(QMouseEvent *event);
+};
+
+
+#endif // UBUBMediaPlayer_H
diff --git a/src/gui/UBTBDocumentEditWidget.cpp b/src/gui/UBTBDocumentEditWidget.cpp
new file mode 100644
index 00000000..8d0b94f5
--- /dev/null
+++ b/src/gui/UBTBDocumentEditWidget.cpp
@@ -0,0 +1,212 @@
+#include "UBTBDocumentEditWidget.h"
+#include "customWidgets/UBGlobals.h"
+
+UBTBDocumentEditWidget::UBTBDocumentEditWidget(UBTeacherBarDataMgr* pDataMgr, QWidget *parent, const char *name):QWidget(parent)
+ , mpPageViewButton(NULL)
+ , mpPreviewButton(NULL)
+ , mpTitleLabel(NULL)
+ , mpTitle(NULL)
+ , mpTargetLabel(NULL)
+ , mpTarget(NULL)
+ , mpMetadataLabel(NULL)
+ , mpLicenseLabel(NULL)
+ , mpLicenseCombox(NULL)
+ , mpKeywords(NULL)
+ , mpLevel(NULL)
+ , mpTopic(NULL)
+ , mpAuthor(NULL)
+ , mpKeywordLabel(NULL)
+ , mpLevelLabel(NULL)
+ , mpTopicLabel(NULL)
+ , mpAuthorLabel(NULL)
+{
+ setObjectName(name);
+
+ mpDataMgr = pDataMgr;
+
+ setLayout(&mLayout);
+ mLayout.setContentsMargins(0, 0, 0, 0);
+
+ mpContainer = new QWidget(this);
+ mpContainer->setObjectName("DockPaletteWidgetBox");
+ mLayout.addWidget(mpContainer, 1);
+ mpContainer->setLayout(&mContainerLayout);
+
+ // Title
+ mpTitleLabel = new QLabel(tr("Session Title"), mpContainer);
+ mpTitleLabel->setAlignment(Qt::AlignLeft);
+ mpTitleLabel->setObjectName("UBTeacherBarPreviewSubtitle");
+ mContainerLayout.addWidget(mpTitleLabel, 0);
+ mpTitle = new QLineEdit(mpContainer);
+ mpTitle->setObjectName("DockPaletteWidgetLineEdit");
+ mContainerLayout.addWidget(mpTitle, 0);
+ mContainerLayout.addWidget(&mTitleSeparator);
+
+ // Target
+ mpTargetLabel = new QLabel(tr("Session Target"), mpContainer);
+ mpTargetLabel->setObjectName("UBTeacherBarPreviewSubtitle");
+ mContainerLayout.addWidget(mpTargetLabel, 0);
+ mpTarget = new QTextEdit(mpContainer);
+ mpTarget->setObjectName("UBTeacherBarTargetBox");
+ mContainerLayout.addWidget(mpTarget, 1);
+ mContainerLayout.addWidget(&mTargetSeparator);
+
+ // Metadata
+ mpMetadataLabel = new QLabel(tr("Metadata"), mpContainer);
+ mpMetadataLabel->setObjectName("UBTeacherBarPreviewSubtitle");
+ mpMetadataLabel->setAlignment(Qt::AlignLeft);
+ mContainerLayout.addWidget(mpMetadataLabel, 0);
+ mpKeywords = new QLineEdit(this);
+ mpKeywords->setObjectName("DockPaletteWidgetLineEdit");
+ mpLevel = new QComboBox(this);
+ mpLevel->setObjectName("DockPaletteWidgetComboBox");
+ mpTopic = new QComboBox(this);
+ mpTopic->setObjectName("DockPaletteWidgetComboBox");
+ mpAuthor = new QLineEdit(this);
+ mpAuthor->setObjectName("DockPaletteWidgetLineEdit");
+ mpKeywordLabel = new QLabel(tr("Keywords:"), this);
+ mpLevelLabel = new QLabel(tr("Level:"), this);
+ mpTopicLabel = new QLabel(tr("Topic:"), this);
+ mpAuthorLabel = new QLabel(tr("Author"), this);
+
+ mKeywordLayout.addWidget(mpKeywordLabel, 0);
+ mKeywordLayout.addWidget(mpKeywords, 1);
+ mLevelLayout.addWidget(mpLevelLabel, 0);
+ mLevelLayout.addWidget(mpLevel, 1);
+ mTopicLayout.addWidget(mpTopicLabel, 0);
+ mTopicLayout.addWidget(mpTopic, 1);
+ mAuthorLayout.addWidget(mpAuthorLabel, 0);
+ mAuthorLayout.addWidget(mpAuthor, 1);
+
+ mContainerLayout.addLayout(&mKeywordLayout, 0);
+ mContainerLayout.addLayout(&mLevelLayout, 0);
+ mContainerLayout.addLayout(&mTopicLayout, 0);
+ mContainerLayout.addLayout(&mAuthorLayout, 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");
+ mPreviewLayout.addWidget(mpPageViewButton, 0);
+ mpPreviewButton = new QPushButton(tr("Preview"), this);
+ mpPreviewButton->setObjectName("DockPaletteWidgetButton");
+ mPreviewLayout.addWidget(mpPreviewButton, 0);
+ mPreviewLayout.addStretch(1);
+ mLayout.addLayout(&mPreviewLayout, 0);
+
+ connect(mpPageViewButton, SIGNAL(clicked()), this, SLOT(onPageView()));
+ 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)));
+ connect(mpKeywords, SIGNAL(textChanged(QString)), this, SLOT(onKeywordChanged(QString)));
+ connect(mpLevel, SIGNAL(currentIndexChanged(QString)), this, SLOT(onLevelChanged(QString)));
+ connect(mpTopic, SIGNAL(currentIndexChanged(QString)), this, SLOT(onTopicChanged(QString)));
+ connect(mpAuthor, SIGNAL(textChanged(QString)), this, SLOT(onAuthorChanged(QString)));
+}
+
+UBTBDocumentEditWidget::~UBTBDocumentEditWidget()
+{
+ DELETEPTR(mpTitleLabel);
+ DELETEPTR(mpTitle);
+ DELETEPTR(mpTargetLabel);
+ DELETEPTR(mpTarget);
+ DELETEPTR(mpMetadataLabel);
+ DELETEPTR(mpKeywordLabel);
+ DELETEPTR(mpLevelLabel);
+ DELETEPTR(mpTopicLabel);
+ DELETEPTR(mpAuthorLabel);
+ DELETEPTR(mpKeywords);
+ DELETEPTR(mpLevel);
+ DELETEPTR(mpTopic);
+ DELETEPTR(mpAuthor);
+ DELETEPTR(mpLicenseLabel);
+ DELETEPTR(mpLicenseCombox);
+ DELETEPTR(mpPageViewButton);
+ DELETEPTR(mpPreviewButton);
+}
+
+void UBTBDocumentEditWidget::onPageView()
+{
+ emit changeTBState(eTeacherBarState_PageEdit);
+}
+
+void UBTBDocumentEditWidget::onPreview()
+{
+ emit changeTBState(eTeacherBarState_DocumentPreview);
+}
+
+void UBTBDocumentEditWidget::onSessionTitleChanged()
+{
+ mpDataMgr->setSessionTitle(mpTitle->text());
+ emit valueChanged();
+}
+
+void UBTBDocumentEditWidget::onSessionTargetChanged()
+{
+ mpDataMgr->setSessionTarget(mpTarget->document()->toPlainText());
+ emit valueChanged();
+}
+
+void UBTBDocumentEditWidget::onLicenseCurrentIndexChanged(int selection)
+{
+ mpDataMgr->setSessionLicence((eLicense)selection);
+ emit valueChanged();
+}
+
+void UBTBDocumentEditWidget::updateFields()
+{
+ mpTitle->setText(mpDataMgr->sessionTitle());
+ mpTarget->setPlainText(mpDataMgr->sessionTarget());
+ mpKeywords->setText(mpDataMgr->keywords());
+ // TODO: retrieve the level
+ // TODO retrieve the topic
+ mpAuthor->setText(mpDataMgr->authors());
+}
+
+void UBTBDocumentEditWidget::clearFields()
+{
+ mpTitle->setText("");
+ mpTarget->setPlainText("");
+}
+
+void UBTBDocumentEditWidget::onKeywordChanged(const QString &kw)
+{
+ mpDataMgr->setKeywords(kw);
+ emit valueChanged();
+}
+
+void UBTBDocumentEditWidget::onLevelChanged(const QString &level)
+{
+ mpDataMgr->setLevel(level);
+ emit valueChanged();
+}
+
+void UBTBDocumentEditWidget::onTopicChanged(const QString &topic)
+{
+ mpDataMgr->setTopic(topic);
+ emit valueChanged();
+}
+
+void UBTBDocumentEditWidget::onAuthorChanged(const QString &authors)
+{
+ mpDataMgr->setAuthors(authors);
+ emit valueChanged();
+}
diff --git a/src/gui/UBTBDocumentEditWidget.h b/src/gui/UBTBDocumentEditWidget.h
new file mode 100644
index 00000000..7d782247
--- /dev/null
+++ b/src/gui/UBTBDocumentEditWidget.h
@@ -0,0 +1,73 @@
+#ifndef UBTBDOCUMENTEDITWIDGET_H
+#define UBTBDOCUMENTEDITWIDGET_H
+
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include "UBTeacherBarDataMgr.h"
+
+class UBTBDocumentEditWidget : public QWidget
+{
+ Q_OBJECT
+public:
+ UBTBDocumentEditWidget(UBTeacherBarDataMgr* pDataMgr, QWidget* parent=0, const char* name="UBTBDocumentEditWidget");
+ ~UBTBDocumentEditWidget();
+ void updateFields();
+ void clearFields();
+
+signals:
+ void changeTBState(eTeacherBarState state);
+ void valueChanged();
+
+private slots:
+ void onPageView();
+ void onPreview();
+ void onSessionTitleChanged();
+ void onSessionTargetChanged();
+ void onLicenseCurrentIndexChanged(int selection);
+ void onKeywordChanged(const QString& kw);
+ void onLevelChanged(const QString& level);
+ void onTopicChanged(const QString& topic);
+ void onAuthorChanged(const QString& authors);
+
+private:
+ QVBoxLayout mLayout;
+ QHBoxLayout mPageLayout;
+ QHBoxLayout mPreviewLayout;
+ QVBoxLayout mContainerLayout;
+ QPushButton* mpPageViewButton;
+ QPushButton* mpPreviewButton;
+ UBTBSeparator mTitleSeparator;
+ UBTBSeparator mTargetSeparator;
+ UBTBSeparator mLicenseSeparator;
+
+ QHBoxLayout mKeywordLayout;
+ QHBoxLayout mLevelLayout;
+ QHBoxLayout mTopicLayout;
+ QHBoxLayout mAuthorLayout;
+
+ QWidget* mpContainer;
+ QLabel* mpTitleLabel;
+ QLineEdit* mpTitle;
+ QLabel* mpTargetLabel;
+ QTextEdit* mpTarget;
+ QLabel* mpMetadataLabel;
+ QLabel* mpLicenseLabel;
+ QComboBox* mpLicenseCombox;
+ QLineEdit* mpKeywords;
+ QComboBox* mpLevel;
+ QComboBox* mpTopic;
+ QLineEdit* mpAuthor;
+ QLabel* mpKeywordLabel;
+ QLabel* mpLevelLabel;
+ QLabel* mpTopicLabel;
+ QLabel* mpAuthorLabel;
+
+ UBTeacherBarDataMgr* mpDataMgr;
+};
+
+#endif // UBTBDOCUMENTEDITWIDGET_H
diff --git a/src/gui/UBTBDocumentPreviewWidget.cpp b/src/gui/UBTBDocumentPreviewWidget.cpp
new file mode 100644
index 00000000..39d75199
--- /dev/null
+++ b/src/gui/UBTBDocumentPreviewWidget.cpp
@@ -0,0 +1,57 @@
+#include "customWidgets/UBGlobals.h"
+#include "UBTBDocumentPreviewWidget.h"
+
+UBTBDocumentPreviewWidget::UBTBDocumentPreviewWidget(UBTeacherBarDataMgr *pDataMgr, QWidget *parent, const char *name):QWidget(parent)
+ , mpPageViewButton(NULL)
+ , mpEditButton(NULL)
+{
+ setObjectName(name);
+ mpDataMgr = pDataMgr;
+
+ setLayout(&mLayout);
+
+ mpPageViewButton = new QPushButton(tr("Page View"), this);
+ mpPageViewButton->setObjectName("DockPaletteWidgetButton");
+ mPageLayout.addStretch(1);
+ mPageLayout.addWidget(mpPageViewButton, 0);
+ mPageLayout.addStretch(1);
+ mLayout.addLayout(&mPageLayout);
+
+ // TODO : Add the elements here
+
+ mpEditButton = new QPushButton(tr("Edit"), this);
+ mpEditButton->setObjectName("DockPaletteWidgetButton");
+ mPreviewLayout.addStretch(1);
+ mPreviewLayout.addWidget(mpEditButton, 0);
+ mPreviewLayout.addStretch(1);
+ mLayout.addLayout(&mPreviewLayout);
+
+ connect(mpPageViewButton, SIGNAL(clicked()), this, SLOT(onPageView()));
+ connect(mpEditButton, SIGNAL(clicked()), this, SLOT(onEdit()));
+}
+
+UBTBDocumentPreviewWidget::~UBTBDocumentPreviewWidget()
+{
+ DELETEPTR(mpPageViewButton);
+ DELETEPTR(mpEditButton);
+}
+
+void UBTBDocumentPreviewWidget::onEdit()
+{
+ emit changeTBState(eTeacherBarState_DocumentEdit);
+}
+
+void UBTBDocumentPreviewWidget::onPageView()
+{
+ emit changeTBState(eTeacherBarState_PagePreview);
+}
+
+void UBTBDocumentPreviewWidget::updateFields()
+{
+
+}
+
+void UBTBDocumentPreviewWidget::clearFields()
+{
+
+}
diff --git a/src/gui/UBTBDocumentPreviewWidget.h b/src/gui/UBTBDocumentPreviewWidget.h
new file mode 100644
index 00000000..99959afa
--- /dev/null
+++ b/src/gui/UBTBDocumentPreviewWidget.h
@@ -0,0 +1,35 @@
+#ifndef UBTBDOCUMENTPREVIEWWIDGET_H
+#define UBTBDOCUMENTPREVIEWWIDGET_H
+
+#include
+#include
+
+#include "UBTeacherBarDataMgr.h"
+
+class UBTBDocumentPreviewWidget : public QWidget
+{
+ Q_OBJECT
+public:
+ UBTBDocumentPreviewWidget(UBTeacherBarDataMgr* pDataMgr, QWidget* parent=0, const char* name="UBTBDocumentPreviewWidget");
+ ~UBTBDocumentPreviewWidget();
+ void updateFields();
+ void clearFields();
+
+signals:
+ void changeTBState(eTeacherBarState state);
+
+private slots:
+ void onPageView();
+ void onEdit();
+
+private:
+ QVBoxLayout mLayout;
+ QHBoxLayout mPageLayout;
+ QHBoxLayout mPreviewLayout;
+ QPushButton* mpPageViewButton;
+ QPushButton* mpEditButton;
+
+ UBTeacherBarDataMgr* mpDataMgr;
+};
+
+#endif // UBTBDOCUMENTPREVIEWWIDGET_H
diff --git a/src/gui/UBTBPageEditWidget.cpp b/src/gui/UBTBPageEditWidget.cpp
new file mode 100644
index 00000000..39f6716c
--- /dev/null
+++ b/src/gui/UBTBPageEditWidget.cpp
@@ -0,0 +1,534 @@
+#include "customWidgets/UBGlobals.h"
+#include "core/UBApplication.h"
+#include "frameworks/UBFileSystemUtils.h"
+#include "gui/UBMediaPlayer.h"
+#include "customWidgets/UBMediaWidget.h"
+
+#include "UBTBPageEditWidget.h"
+
+UBTBPageEditWidget::UBTBPageEditWidget(UBTeacherBarDataMgr *pDataMgr, QWidget *parent, const char *name):QWidget(parent)
+ , mpDataMgr(NULL)
+ , mpTitleLabel(NULL)
+ , mpTitle(NULL)
+ , mpMediaLabel(NULL)
+ , mpActionLabel(NULL)
+ , mpActions(NULL)
+ , mpActionButton(NULL)
+ , mpLinkLabel(NULL)
+ , mpLinks(NULL)
+ , mpLinkButton(NULL)
+ , mpCommentLabel(NULL)
+ , mpComments(NULL)
+ , mpDocumentEditbutton(NULL)
+ , mpPagePreviewButton(NULL)
+ , mpContainer(NULL)
+{
+ Q_UNUSED(name);
+ mpDataMgr = pDataMgr;
+ mActions.clear();
+ mUrls.clear();
+ setAttribute(Qt::WA_StyledBackground, true);
+ setStyleSheet(UBApplication::globalStyleSheet());
+ mClearingFields = false;
+ mLayout.setContentsMargins(0, 0, 0, 0);
+ setLayout(&mLayout);
+
+ mpContainer = new QWidget(this);
+ mpContainer->setObjectName("DockPaletteWidgetBox");
+ mpContainer->setLayout(&mContainerLayout);
+ mLayout.addWidget(mpContainer, 1);
+
+ // Title
+ mpTitleLabel = new QLabel(tr("Title"), mpContainer);
+ mpTitle = new QLineEdit(mpContainer);
+ mpTitle->setObjectName("DockPaletteWidgetLineEdit");
+ mContainerLayout.addWidget(mpTitleLabel, 0);
+ mContainerLayout.addWidget(mpTitle, 0);
+
+ // Actions
+ mpActionLabel = new QLabel(tr("Actions"), mpContainer);
+ mContainerLayout.addWidget(mpActionLabel, 0);
+ mpActions = new UBWidgetList(mpContainer);
+ mpActions->setEmptyText(tr("Add actions"));
+ mContainerLayout.addWidget(mpActions, 1);
+ mpActionButton = new QPushButton(mpContainer);
+ mpActionButton->setObjectName("DockPaletteWidgetButton");
+ mpActionButton->setText(tr("Add action"));
+ mActionLayout.addWidget(mpActionButton, 0);
+ mActionLayout.addStretch(1);
+ mContainerLayout.addLayout(&mActionLayout, 0);
+
+ // Media
+ mpMediaLabel = new QLabel(tr("Medias"), mpContainer);
+ mContainerLayout.addWidget(mpMediaLabel, 0);
+ mpMediaContainer = new UBTBMediaContainer(mpContainer);
+ mpMediaContainer->setEmptyText(tr("Drop media here"));
+ mContainerLayout.addWidget(mpMediaContainer, 1);
+
+ // Links
+ mpLinkLabel = new QLabel(tr("Links"), mpContainer);
+ mContainerLayout.addWidget(mpLinkLabel, 0);
+ mpLinks = new UBWidgetList(mpContainer);
+ mContainerLayout.addWidget(mpLinks, 1);
+ mpLinkButton = new QPushButton(tr("Add link"), mpContainer);
+ mpLinkButton->setObjectName("DockPaletteWidgetButton");
+ mLinkLayout.addWidget(mpLinkButton, 0);
+ mLinkLayout.addStretch(1);
+ mContainerLayout.addLayout(&mLinkLayout, 0);
+
+ // Comments
+ mpCommentLabel = new QLabel(tr("Comments"), mpContainer);
+ mContainerLayout.addWidget(mpCommentLabel, 0);
+ mpComments = new QTextEdit(mpContainer);
+ mpComments->setObjectName("DockPaletteWidgetBox");
+ mpComments->setStyleSheet("background:white;");
+ mContainerLayout.addWidget(mpComments, 1);
+
+ mpPagePreviewButton = new QPushButton(tr("Preview"), this);
+ mpPagePreviewButton->setObjectName("DockPaletteWidgetButton");
+ mpDocumentEditbutton = new QPushButton(tr("Document View"), this);
+ mpDocumentEditbutton->setObjectName("DockPaletteWidgetButton");
+ mPagePreviewLayout.addWidget(mpDocumentEditbutton, 0);
+ mPagePreviewLayout.addWidget(mpPagePreviewButton, 0);
+ mPagePreviewLayout.addStretch(1);
+ mLayout.addLayout(&mPagePreviewLayout, 0);
+
+ connect(mpTitle, SIGNAL(textChanged(QString)), this, SLOT(onTitleChanged()));
+ connect(mpComments, SIGNAL(textChanged()), this, SLOT(onCommentsChanged()));
+ connect(mpActionButton, SIGNAL(clicked()), this, SLOT(onActionButton()));
+ connect(mpLinkButton, SIGNAL(clicked()), this, SLOT(onLinkButton()));
+ connect(mpDocumentEditbutton, SIGNAL(clicked()), this, SLOT(onDocumentEditClicked()));
+ connect(mpPagePreviewButton, SIGNAL(clicked()), this, SLOT(onPagePreviewClicked()));
+ connect(mpMediaContainer, SIGNAL(mediaDropped(QString)), this, SLOT(onMediaDropped(QString)));
+}
+
+UBTBPageEditWidget::~UBTBPageEditWidget()
+{
+ DELETEPTR(mpDocumentEditbutton);
+ DELETEPTR(mpPagePreviewButton);
+ DELETEPTR(mpComments);
+ DELETEPTR(mpCommentLabel);
+ DELETEPTR(mpLinks);
+ DELETEPTR(mpLinkLabel);
+ DELETEPTR(mpLinkButton);
+ DELETEPTR(mpMediaLabel);
+ DELETEPTR(mpActionButton);
+ DELETEPTR(mpActionLabel);
+ DELETEPTR(mpTitleLabel);
+ DELETEPTR(mpTitle);
+}
+
+void UBTBPageEditWidget::onTitleChanged()
+{
+ if(!mClearingFields){
+ mpDataMgr->setPageTitle(mpTitle->text());
+ emit valueChanged();
+ }
+}
+
+void UBTBPageEditWidget::onCommentsChanged()
+{
+ if(!mClearingFields){
+ mpDataMgr->setComments(mpComments->document()->toPlainText());
+ emit valueChanged();
+ }
+}
+
+void UBTBPageEditWidget::onActionButton()
+{
+ UBTeacherStudentAction* pAction = new UBTeacherStudentAction(this);
+ mActions << pAction;
+ mpActions->addWidget(pAction);
+ emit valueChanged();
+}
+
+void UBTBPageEditWidget::onLinkButton()
+{
+ UBUrlWidget* pUrl = new UBUrlWidget(this);
+ mUrls << pUrl;
+ mpLinks->addWidget(pUrl);
+ emit valueChanged();
+}
+
+void UBTBPageEditWidget::onMediaDropped(const QString &url)
+{
+ if("" != url){
+ QWidget* pMedia = mpMediaContainer->generateMediaWidget(url);
+ if(NULL != pMedia){
+ mMedias << pMedia;
+ mMediaUrls << url;
+ //mpDataMgr->medias()->append(pMedia);
+ //mpDataMgr->addMediaUrl(url);
+ mpMediaContainer->addWidget(pMedia);
+ emit valueChanged();
+ }
+ }
+}
+
+void UBTBPageEditWidget::onDocumentEditClicked()
+{
+ emit changeTBState(eTeacherBarState_DocumentEdit);
+}
+
+void UBTBPageEditWidget::onPagePreviewClicked()
+{
+ emit changeTBState(eTeacherBarState_PagePreview);
+}
+
+void UBTBPageEditWidget::saveFields()
+{
+ mpDataMgr->actions()->clear();
+ mpDataMgr->urls()->clear();
+ mpDataMgr->mediaUrls()->clear();
+ mpDataMgr->medias()->clear();
+
+ foreach(UBTeacherStudentAction* pAct, mActions){
+ sAction action;
+ action.type = pAct->comboValue().toInt();
+ action.content = pAct->text();
+ mpDataMgr->actions()->append(action);
+ }
+ foreach(UBUrlWidget* pUrl, mUrls){
+ sLink link;
+ link.title = pUrl->title();
+ link.link = pUrl->url();
+ mpDataMgr->urls()->append(link);
+ }
+ foreach(QString url, mMediaUrls){
+ qDebug() << "saving media :" << url;
+ mpDataMgr->mediaUrls()->append(url);
+ }
+ foreach(QWidget* pMedia, mMedias){
+ mpDataMgr->medias()->append(pMedia);
+ }
+}
+
+void UBTBPageEditWidget::updateFields()
+{
+ // Title
+ mpTitle->setText(mpDataMgr->pageTitle());
+ // Actions
+ foreach(sAction action, *mpDataMgr->actions()){
+ UBTeacherStudentAction* pAction = new UBTeacherStudentAction(this);
+ pAction->setComboValue(action.type);
+ pAction->setText(action.content);
+ mActions << pAction;
+ mpActions->addWidget(pAction);
+ }
+ // Medias
+ foreach(QString url, *mpDataMgr->mediaUrls()){
+ if(!url.isEmpty()){
+ mMediaUrls << url;
+ QWidget* pWidget = mpMediaContainer->generateMediaWidget(url);
+ if(pWidget != NULL){
+ mMedias << pWidget;
+ mpMediaContainer->addWidget(pWidget);
+ }
+ }
+ }
+
+ // Links
+ foreach(sLink link, *mpDataMgr->urls()){
+ UBUrlWidget* urlWidget = new UBUrlWidget(this);
+ urlWidget->setTitle(link.title);
+ urlWidget->setUrl(link.link);
+ mUrls << urlWidget;
+ mpLinks->addWidget(urlWidget);
+ }
+ // Comments
+ mpComments->document()->setPlainText(mpDataMgr->comments());
+}
+
+void UBTBPageEditWidget::clearFields()
+{
+ mClearingFields = true;
+ // Title
+ mpTitle->setText("");
+ // Actions
+ foreach(UBTeacherStudentAction* pAction, mActions){
+ mpActions->removeWidget(pAction);
+ DELETEPTR(pAction);
+ }
+ mActions.clear();
+ // Medias
+ foreach(QWidget* pMedia, mMedias){
+ if(NULL != pMedia){
+ mpMediaContainer->removeWidget(pMedia);
+ DELETEPTR(pMedia);
+ }
+ }
+ mMedias.clear();
+ mMediaUrls.clear();
+ // Links
+ foreach(UBUrlWidget* pLink, mUrls){
+ mpLinks->removeWidget(pLink);
+ DELETEPTR(pLink);
+ }
+ mUrls.clear();
+ // Comments
+ mpComments->setText("");
+
+ mClearingFields = false;
+}
+
+// ---------------------------------------------------------------------------------------------
+UBUrlWidget::UBUrlWidget(QWidget *parent, const char *name):QWidget(parent)
+ , mpLayout(NULL)
+ , mpUrlLabel(NULL)
+ , mpUrl(NULL)
+{
+ setObjectName(name);
+ setAttribute(Qt::WA_StyledBackground, true);
+ setStyleSheet(UBApplication::globalStyleSheet());
+
+ mpLayout = new QVBoxLayout(this);
+ setLayout(mpLayout);
+
+ mpLabelLayout = new QHBoxLayout(0);
+ mpUrlLabel = new QLabel(tr("Url"), this);
+ mpLabelLayout->addWidget(mpUrlLabel, 0);
+ mpUrl = new QLineEdit(this);
+ mpUrl->setObjectName("DockPaletteWidgetLineEdit");
+ mpUrl->setMinimumHeight(20);
+ mpLabelLayout->addWidget(mpUrl, 1);
+
+ mpTitleLayout = new QHBoxLayout(0);
+ mpTitleLabel = new QLabel(tr("Title"),this);
+ mpTitleLayout->addWidget(mpTitleLabel,0);
+ mpTitle = new QLineEdit(this);
+ mpTitle->setObjectName("DockPaletteWidgetLineEdit");
+ mpTitle->setMinimumHeight(20);
+ mpTitleLayout->addWidget(mpTitle,1);
+
+ mpLayout->addLayout(mpTitleLayout);
+ mpLayout->addLayout(mpLabelLayout);
+}
+
+UBUrlWidget::~UBUrlWidget()
+{
+ DELETEPTR(mpTitle);
+ DELETEPTR(mpTitleLabel);
+ DELETEPTR(mpUrlLabel);
+ DELETEPTR(mpUrl);
+ DELETEPTR(mpTitleLayout);
+ DELETEPTR(mpLabelLayout);
+ DELETEPTR(mpLayout);
+}
+
+QString UBUrlWidget::url()
+{
+ QString str;
+
+ if(NULL != mpUrl){
+ str = mpUrl->text() + ";" + mpTitle->text();
+ }
+
+ return str;
+}
+
+void UBUrlWidget::setUrl(const QString &url)
+{
+ if(NULL != mpUrl){
+ mpUrl->setText(url);
+ }
+}
+
+// ------------------------------------------------------------------------------------------------------------------------------------
+UBTBMediaContainer::UBTBMediaContainer(QWidget *parent, const char *name) : UBWidgetList(parent)
+{
+ setObjectName(name);
+ setAcceptDrops(true);
+}
+
+UBTBMediaContainer::~UBTBMediaContainer()
+{
+
+}
+
+void UBTBMediaContainer::dropEvent(QDropEvent* pEvent)
+{
+ QPixmap pixFromDropEvent;
+ QString mimeType;
+ QString resourcePath;
+ if(pEvent->mimeData()->hasText()){
+ resourcePath = pEvent->mimeData()->text();
+ }
+ else if(pEvent->mimeData()->hasUrls()){
+ resourcePath = pEvent->mimeData()->urls().at(0).toLocalFile();
+ }
+ else if(pEvent->mimeData()->hasImage()){
+ pixFromDropEvent.loadFromData(pEvent->mimeData()->imageData().toByteArray());
+ if(!pixFromDropEvent.isNull())
+ mimeType = "image";
+ }
+
+ if (mimeType.isEmpty() && resourcePath.isEmpty()){
+ pEvent->acceptProposedAction();
+ return;
+ }
+ if(!resourcePath.isEmpty()){
+ emit mediaDropped(resourcePath);
+ pEvent->acceptProposedAction();
+ }
+}
+
+void UBTBMediaContainer::dragEnterEvent(QDragEnterEvent* pEvent)
+{
+ pEvent->acceptProposedAction();
+}
+
+void UBTBMediaContainer::dragMoveEvent(QDragMoveEvent* pEvent)
+{
+ pEvent->acceptProposedAction();
+}
+
+void UBTBMediaContainer::dragLeaveEvent(QDragLeaveEvent* pEvent)
+{
+ pEvent->accept();
+}
+
+void UBTBMediaContainer::addMedia(const QString& mediaPath)
+{
+ if(!mediaPath.isEmpty())
+ mMediaList.append(mediaPath);
+ else
+ qWarning() << __FUNCTION__ << "empty path";
+
+ QString mimeType = UBFileSystemUtils::mimeTypeFromFileName(mediaPath);
+ if(mimeType.contains("image")){
+ QPixmap pix = QPixmap(mediaPath);
+ QLabel* label = new QLabel();
+ label->setPixmap(pix);
+ label->setScaledContents(true);
+ addWidget(label);
+ }
+ else if(mimeType.contains("video") || mimeType.contains("audio")){
+ UBMediaPlayer* mediaPlayer = new UBMediaPlayer();
+ mediaPlayer->setFile(mediaPath);
+ addWidget(mediaPlayer);
+ }
+ else{
+ qWarning() << "pMediaPath" << mediaPath;
+ qWarning() << "bad idea to come here";
+ }
+}
+
+QStringList UBTBMediaContainer::mediaUrls()
+{
+ return mMediaList;
+}
+
+void UBTBMediaContainer::cleanMedias()
+{
+ mMediaList.clear();
+}
+
+QWidget* UBTBMediaContainer::generateMediaWidget(const QString& url)
+{
+ QWidget* pW = NULL;
+
+ if(!url.isEmpty())
+ mMediaList.append(url);
+ else
+ qWarning() << __FUNCTION__ << "empty path";
+
+ QString mimeType = UBFileSystemUtils::mimeTypeFromFileName(url);
+ if(mimeType.contains("image")){
+ QPixmap pix = QPixmap(url);
+ QLabel* label = new QLabel();
+ pix.scaledToWidth(label->width());
+ label->resize(pix.width(), pix.height());
+ label->setPixmap(pix);
+ label->setScaledContents(true);
+ pW = label;
+ }
+ else if(mimeType.contains("video") || mimeType.contains("audio")){
+ UBMediaWidget* mediaPlayer = new UBMediaWidget(mimeType.contains("audio")?eMediaType_Audio:eMediaType_Video);
+ mediaPlayer->setFile(url);
+ pW = mediaPlayer;
+ }
+ else{
+ qWarning() << "pMediaPath" << url;
+ qWarning() << "bad idea to come here";
+ }
+
+ return pW;
+}
+
+UBTeacherStudentAction::UBTeacherStudentAction(QWidget *parent, const char *name):QWidget(parent)
+ , mpText(NULL)
+ , mpLayout(NULL)
+ , mpComboLayout(NULL)
+ , mpCombo(NULL)
+{
+ setObjectName(name);
+
+ setAttribute(Qt::WA_StyledBackground, true);
+ setStyleSheet(UBApplication::globalStyleSheet());
+
+ // Create the GUI
+ mpLayout = new QHBoxLayout(this);
+ setLayout(mpLayout);
+
+ mpComboLayout = new QVBoxLayout();
+
+ mpCombo = new QComboBox(this);
+ mpCombo->setObjectName("DockPaletteWidgetComboBox");
+ mpCombo->setMinimumWidth(80);
+ mpCombo->addItem(tr("Teacher"));
+ mpCombo->addItem(tr("Student"));
+ mpComboLayout->addWidget(mpCombo, 0);
+ mpComboLayout->addStretch(1);
+
+ mpLayout->addLayout(mpComboLayout, 0);
+
+ mpText = new QTextEdit(this);
+ mpText->setObjectName("DockPaletteWidgetBox");
+ mpText->setStyleSheet("background:white;");
+
+ mpLayout->addWidget(mpText, 1);
+
+}
+
+UBTeacherStudentAction::~UBTeacherStudentAction()
+{
+ DELETEPTR(mpCombo);
+ DELETEPTR(mpText);
+ DELETEPTR(mpComboLayout);
+ DELETEPTR(mpLayout);
+}
+
+QString UBTeacherStudentAction::text()
+{
+ QString str;
+ if(NULL != mpText){
+ str = mpText->document()->toPlainText();
+ }
+ return str;
+}
+
+QString UBTeacherStudentAction::comboValue()
+{
+ QString str;
+
+ if(NULL != mpCombo){
+ str = QString("%0").arg(mpCombo->currentIndex());
+ }
+
+ return str;
+}
+
+void UBTeacherStudentAction::setComboValue(int value)
+{
+ if(NULL != mpCombo){
+ mpCombo->setCurrentIndex(value);
+ }
+}
+
+void UBTeacherStudentAction::setText(const QString& text)
+{
+ if(NULL != mpText){
+ mpText->document()->setPlainText(text);
+ }
+}
+
diff --git a/src/gui/UBTBPageEditWidget.h b/src/gui/UBTBPageEditWidget.h
new file mode 100644
index 00000000..0f3c61b9
--- /dev/null
+++ b/src/gui/UBTBPageEditWidget.h
@@ -0,0 +1,141 @@
+#ifndef UBTBPAGEEDITWIDGET_H
+#define UBTBPAGEEDITWIDGET_H
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include "core/UBPersistenceManager.h"
+#include "customWidgets/UBWidgetList.h"
+#include "interfaces/IDropable.h"
+#include "UBTeacherBarDataMgr.h"
+
+class UBTeacherStudentAction : public QWidget
+{
+ Q_OBJECT
+
+public:
+ UBTeacherStudentAction(QWidget* parent=0, const char* name="UBTeacherStudentAction");
+ ~UBTeacherStudentAction();
+ QString text();
+ QString comboValue();
+ void setComboValue(int value);
+ void setText(const QString& text);
+
+private:
+ QTextEdit* mpText;
+ QHBoxLayout* mpLayout;
+ QVBoxLayout* mpComboLayout;
+ QComboBox* mpCombo;
+};
+
+class UBUrlWidget : public QWidget
+{
+public:
+ UBUrlWidget(QWidget* parent=0, const char* name="UBUrlWidget");
+ ~UBUrlWidget();
+
+ QString url();
+ void setUrl(const QString& url);
+
+ QString title(){return mpTitle->text();}
+ void setTitle(const QString& title){mpTitle->setText(title);}
+
+private:
+ QVBoxLayout* mpLayout;
+ QHBoxLayout* mpLabelLayout;
+ QHBoxLayout* mpTitleLayout;
+ QLabel* mpUrlLabel;
+ QLineEdit* mpUrl;
+
+ QLabel* mpTitleLabel;
+ QLineEdit* mpTitle;
+};
+
+class UBTBMediaContainer : public UBWidgetList
+ , public IDropable
+{
+ Q_OBJECT
+public:
+ UBTBMediaContainer(QWidget* parent=0, const char* name="UBTBMediaContainer");
+ ~UBTBMediaContainer();
+ QStringList mediaUrls();
+ QWidget* generateMediaWidget(const QString& url);
+ void cleanMedias();
+
+signals:
+ void mediaDropped(const QString& url);
+
+protected:
+ void dropEvent(QDropEvent* pEvent);
+ void dragEnterEvent(QDragEnterEvent* pEvent);
+ void dragMoveEvent(QDragMoveEvent* pEvent);
+ void dragLeaveEvent(QDragLeaveEvent* pEvent);
+
+private:
+ void addMedia(const QString& mediaPath);
+
+ QStringList mMediaList;
+};
+
+class UBTBPageEditWidget : public QWidget
+{
+ Q_OBJECT
+public:
+ UBTBPageEditWidget(UBTeacherBarDataMgr* pDataMgr, QWidget* parent=0, const char* name="UBTBPageEditWidget");
+ ~UBTBPageEditWidget();
+ void saveFields();
+ void updateFields();
+ void clearFields();
+
+signals:
+ void valueChanged();
+ void changeTBState(eTeacherBarState state);
+
+private slots:
+ void onTitleChanged();
+ void onCommentsChanged();
+ void onActionButton();
+ void onLinkButton();
+ void onMediaDropped(const QString& url);
+ void onDocumentEditClicked();
+ void onPagePreviewClicked();
+
+private:
+ QVBoxLayout mLayout;
+ QHBoxLayout mTitleLayout;
+ QVBoxLayout mContainerLayout;
+ QHBoxLayout mActionLayout;
+ QHBoxLayout mLinkLayout;
+ QHBoxLayout mDocumentViewLayout;
+ QHBoxLayout mPagePreviewLayout;
+
+ UBTeacherBarDataMgr* mpDataMgr;
+ QLabel* mpTitleLabel;
+ QLineEdit* mpTitle;
+ QLabel* mpMediaLabel;
+ UBTBMediaContainer* mpMediaContainer;
+ QLabel* mpActionLabel;
+ UBWidgetList* mpActions;
+ QPushButton* mpActionButton;
+ QLabel* mpLinkLabel;
+ UBWidgetList* mpLinks;
+ QPushButton* mpLinkButton;
+ QLabel* mpCommentLabel;
+ QTextEdit* mpComments;
+ QPushButton* mpDocumentEditbutton;
+ QPushButton* mpPagePreviewButton;
+ QWidget* mpContainer;
+
+ QVector mActions;
+ QVector mUrls;
+ QVector mMedias;
+ QStringList mMediaUrls;
+ bool mClearingFields;
+};
+
+#endif // UBTBPAGEEDITWIDGET_H
diff --git a/src/gui/UBTeacherBarDataMgr.cpp b/src/gui/UBTeacherBarDataMgr.cpp
new file mode 100644
index 00000000..2a772441
--- /dev/null
+++ b/src/gui/UBTeacherBarDataMgr.cpp
@@ -0,0 +1,184 @@
+#include "UBTeacherBarDataMgr.h"
+
+#include "core/UBApplication.h"
+#include "core/UBPersistenceManager.h"
+
+#include "board/UBBoardController.h"
+
+#include "customWidgets/UBGlobals.h"
+
+#include "adaptors/UBMetadataDcSubsetAdaptor.h"
+
+
+UBTeacherBarDataMgr::UBTeacherBarDataMgr()
+{
+
+}
+
+UBTeacherBarDataMgr::~UBTeacherBarDataMgr()
+{
+
+}
+
+void UBTeacherBarDataMgr::clearLists()
+{
+ mActionList.clear();
+ mUrlList.clear();
+ mMediaList.clear();
+ mMediaUrls.clear();
+}
+
+void UBTeacherBarDataMgr::saveContent()
+{
+ // Store the page information in the UBZ
+ sTeacherBarInfos infos;
+
+ // Page Title
+ infos.title = mPageTitle;
+ // Actions
+ foreach(sAction action, mActionList){
+ infos.actions << QString("%0;%1").arg(action.type).arg(action.content);
+ }
+ // Media
+ foreach(QString media, mMediaUrls){
+ infos.medias << media;
+ }
+ // Links
+ foreach(sLink link, mUrlList){
+ if("" != link.title && "" != link.link){
+ infos.urls << QString("%0;%1").arg(link.title).arg(link.link);
+ }
+ }
+ // Comments
+ infos.comments = mComments;
+
+ UBDocumentProxy* documentProxy = UBApplication::boardController->activeDocument();
+ if(documentProxy){
+ UBPersistenceManager::persistenceManager()->persistTeacherBar(documentProxy, UBApplication::boardController->activeSceneIndex(), infos);
+
+ documentProxy->setSessionTitle(mSessionTitle);
+ documentProxy->setSessionTarget(mSessionTarget);
+ documentProxy->setSessionLicence(QString("%0").arg(mSessionLicence));
+ documentProxy->setSessionKeywords(mAuthors);
+ documentProxy->setSessionLevel(mLevel);
+ documentProxy->setSessionTopic(mTopic);
+ documentProxy->setSessionAuthor(mAuthors);
+
+ UBMetadataDcSubsetAdaptor::persist(documentProxy);
+ }
+}
+
+
+
+void UBTeacherBarDataMgr::loadContent(bool docChanged)
+{
+ clearLists();
+ UBDocumentProxy* documentProxy = UBApplication::boardController->activeDocument();
+
+ sTeacherBarInfos nextInfos = UBPersistenceManager::persistenceManager()->getTeacherBarInfos(documentProxy, UBApplication::boardController->activeSceneIndex());
+ if(true/*docChanged*/){
+ mSessionTitle = documentProxy->sessionTitle();
+ mSessionTarget = documentProxy->sessionTarget();
+ mSessionLicence = (eLicense)documentProxy->sessionLicence().toInt();
+ mKeywords = documentProxy->sessionKeywords();
+ mLevel = documentProxy->sessionLevel();
+ mTopic = documentProxy->sessionTopic();
+ mAuthors = documentProxy->sessionAuthors();
+ }
+
+ // Page Title
+ mPageTitle = nextInfos.title;
+ // Actions
+ foreach(QString eachAction, nextInfos.actions){
+ QStringList qslAction = eachAction.split(";");
+ if(2 <= qslAction.size()){
+ sAction action;
+ action.type = qslAction.at(0).toInt();
+ action.content = qslAction.at(1);
+ mActionList << action;
+ }
+ }
+ // Media URL
+ if((nextInfos.medias.size() == 1) && (nextInfos.medias.at(0) == "")){
+ // Do not retrieve it
+ }
+ else{
+ mMediaUrls = nextInfos.medias;
+ }
+
+ // Links
+ foreach(QString eachUrl, nextInfos.urls){
+ QStringList qslUrl = eachUrl.split(';');
+ if(2 <= qslUrl.size()){
+ sLink link;
+ link.title = qslUrl.at(0);
+ link.link = qslUrl.at(1);
+ mUrlList << link;
+ }
+ }
+
+ // Comments
+ 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
new file mode 100644
index 00000000..b182e892
--- /dev/null
+++ b/src/gui/UBTeacherBarDataMgr.h
@@ -0,0 +1,141 @@
+#ifndef UBTEACHERBARDATAMGR_H
+#define UBTEACHERBARDATAMGR_H
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+typedef enum{
+ eTeacherBarState_DocumentEdit,
+ eTeacherBarState_DocumentPreview,
+ eTeacherBarState_PageEdit,
+ eTeacherBarState_PagePreview
+}eTeacherBarState;
+
+typedef enum{
+ eActionOwner_Teacher,
+ eActionOwner_Student
+}eActionOwner;
+
+typedef struct{
+ int type;
+ QString content;
+}sAction;
+
+typedef struct{
+ QString title;
+ 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:
+ UBTeacherBarDataMgr();
+ ~UBTeacherBarDataMgr();
+
+ // Session Title
+ void setSessionTitle(const QString& title){mSessionTitle = title;}
+ QString sessionTitle(){return mSessionTitle;}
+
+ // Session Target
+ void setSessionTarget(const QString& target){mSessionTarget = target;}
+ QString sessionTarget(){return mSessionTarget;}
+
+ // Licence
+ void setSessionLicence(eLicense licence){mSessionLicence = licence;}
+ eLicense sessionLicence(){return mSessionLicence;}
+
+ // Page Title
+ void setPageTitle(const QString& title){mPageTitle = title;}
+ QString pageTitle(){return mPageTitle;}
+
+ // Actions
+ QVector* actions(){return &mActionList;}
+
+ // Medias
+ QVector* medias(){return &mMediaList;}
+ void addMediaUrl(const QString& url){mMediaUrls << url;}
+ QStringList* mediaUrls(){return &mMediaUrls;}
+
+ // Urls
+ QVector* urls(){return &mUrlList;}
+
+ // Comments
+ void setComments(const QString& c){mComments = c;}
+ QString comments(){return mComments;}
+
+ // Keywords
+ void setKeywords(const QString& kw){mKeywords = kw;}
+ QString keywords(){return mKeywords;}
+
+ // Level
+ void setLevel(const QString& level){mLevel = level;}
+ QString level(){return mLevel;}
+
+ // Topic
+ void setTopic(const QString& topic){mTopic = topic;}
+ QString topic(){return mTopic;}
+
+ // Authors
+ void setAuthors(const QString& authors){mAuthors = authors;}
+ QString authors(){return mAuthors;}
+
+
+ // Others
+ void clearLists();
+ void saveContent();
+ void loadContent(bool docChanged = false);
+
+private:
+ QString mSessionTitle;
+ QString mSessionTarget;
+ eLicense mSessionLicence;
+ QString mPageTitle;
+ QString mComments;
+ QString mKeywords;
+ QString mLevel;
+ QString mTopic;
+ QString mAuthors;
+
+ QVector mActionList;
+ QVector mUrlList;
+ QVector mMediaList;
+ QStringList mMediaUrls;
+};
+
+#endif // UBTEACHERBARDATAMGR_H
diff --git a/src/gui/UBTeacherBarPreviewWidget.cpp b/src/gui/UBTeacherBarPreviewWidget.cpp
new file mode 100644
index 00000000..9b93008b
--- /dev/null
+++ b/src/gui/UBTeacherBarPreviewWidget.cpp
@@ -0,0 +1,354 @@
+#include "core/UBApplication.h"
+#include "customWidgets/UBGlobals.h"
+#include "board/UBBoardController.h"
+#include "frameworks/UBFileSystemUtils.h"
+
+#include "UBTeacherBarPreviewWidget.h"
+
+
+UBTeacherBarPreviewMedia::UBTeacherBarPreviewMedia(QWidget* parent, const char* name) : QWidget(parent)
+{
+ setObjectName(name);
+ mWidget = new UBWidgetList(parent);
+ mLayout.addWidget(mWidget);
+ setLayout(&mLayout);
+ mWidgetList.clear();
+}
+
+UBTeacherBarPreviewMedia::~UBTeacherBarPreviewMedia()
+{
+ DELETEPTR(mWidget);
+}
+
+void UBTeacherBarPreviewMedia::cleanMedia()
+{
+ foreach(QWidget* eachWidget, mWidgetList.keys()){
+ if(QString(eachWidget->metaObject()->className()).contains("UBDraggable")){
+ mWidget->removeWidget(eachWidget);
+ delete eachWidget;
+ eachWidget = NULL;
+ }
+ else{
+ mWidget->removeWidget(eachWidget);
+ }
+ }
+ mWidgetList.clear();
+}
+
+void UBTeacherBarPreviewMedia::loadWidgets(QList pWidgetsList, bool isResizable)
+{
+ foreach(QWidget*eachWidget, pWidgetsList){
+ mWidget->addWidget(eachWidget);
+ mWidgetList[eachWidget]="DRAG UNAVAILABLE";
+ }
+}
+
+
+//int UBTeacherBarPreviewMedia::loadMedia(QStringList pMedias)
+//{
+// int addedMedia = 0;
+//// foreach(QString eachString, pMedias){
+//// if(!eachString.isEmpty()){
+//// QString mimeType = UBFileSystemUtils::mimeTypeFromFileName(eachString);
+//// if(mimeType.contains("image")){
+//// UBDraggableLabel* label = new UBDraggableLabel();
+//// 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;
+//// qWarning() << "bad idea to come here";
+//// }
+//// }
+//// }
+// return addedMedia;
+//}
+
+// -----------------------------------------------------------------------------------------------
+UBActionPreview::UBActionPreview(QWidget *parent, const char *name):QWidget(parent)
+ , mpOwner(NULL)
+ , mpContent(NULL)
+{
+ setObjectName(name);
+ setLayout(&mLayout);
+ mpOwner = new QLabel(this);
+ mpOwner->setObjectName("UBActionPreviewOwner");
+ mOwnerLayout.addWidget(mpOwner, 0);
+ mOwnerLayout.addStretch(1);
+ mLayout.addLayout(&mOwnerLayout);
+ mpContent = new QTextEdit(this);
+ mpContent->setReadOnly(true);
+ mpContent->setObjectName("UBActionPreviewContent");
+ //mpContent->setWordWrap(true);
+ mLayout.addWidget(mpContent);
+ setContentsMargins(-9, -9, -9, -9);
+}
+
+UBActionPreview::~UBActionPreview()
+{
+ if(NULL != mpOwner){
+ delete mpOwner;
+ mpOwner = NULL;
+ }
+ if(NULL != mpContent){
+ delete mpContent;
+ mpContent = NULL;
+ }
+}
+
+void UBActionPreview::setOwner(int owner)
+{
+ if(NULL != mpOwner && NULL != mpContent){
+ switch(owner){
+ case eActionOwner_Teacher:
+ mpOwner->setText(tr("Teacher"));
+ mpContent->setStyleSheet("background:lightblue; border:lightblue;");
+ break;
+
+ case eActionOwner_Student:
+ mpOwner->setText(tr("Student"));
+ mpContent->setStyleSheet("background:lightgreen; border:lightgreen;");
+ break;
+ }
+ }
+}
+
+void UBActionPreview::setContent(const QString &content)
+{
+ if(NULL != mpContent){
+ mpContent->setText(content);
+ setMinimumHeight(mpOwner->height() + mpContent->document()->documentLayout()->documentSize().toSize().height());
+ }
+}
+
+// -------------------------------------------------------------------------------------------------------------------
+UBTBPreviewContainer::UBTBPreviewContainer(QWidget *parent, const char *name):UBWidgetList(parent)
+{
+ setObjectName(name);
+}
+
+UBTBPreviewContainer::~UBTBPreviewContainer()
+{
+
+}
+
+// ------------------------------------------------------------------------------------
+UBTeacherBarPreviewWidget::UBTeacherBarPreviewWidget(UBTeacherBarDataMgr* pDataMgr, QWidget *parent, const char *name):QWidget(parent)
+ , mpEditButton(NULL)
+ , mpSessionTitle(NULL)
+ , mpTitle(NULL)
+ , mpTitleLabel(NULL)
+ , mpPageNbrLabel(NULL)
+ , mpContentContainer(NULL)
+ , mpScheduleLabel(NULL)
+ , mpLicenseLabel(NULL)
+{
+ setObjectName(name);
+ mpDataMgr = pDataMgr;
+ setLayout(&mLayout);
+
+ setAttribute(Qt::WA_StyledBackground, true);
+ setStyleSheet(UBApplication::globalStyleSheet());
+
+ // Build the Preview widget
+ // Session Title
+ mTitleContainer.setLayout(&mTitleLayout);
+ mpSessionTitle = new QLabel(this);
+ mpSessionTitle->setText(tr("Session: "));
+ mpSessionTitle->setWordWrap(true);
+ mpSessionTitle->setAlignment(Qt::AlignRight);
+ mpSessionTitle->setObjectName("UBTBPreviewSessionTitle");
+ mLayout.addWidget(mpSessionTitle);
+
+ // Title
+ mTitleContainer.setLayout(&mTitleLayout);
+ mTitleLayout.setContentsMargins(0, 0, 0, 0);
+ mpTitleLabel = new QLabel(&mTitleContainer);
+ mpTitleLabel->setText(tr("Activity"));
+ mpTitleLabel->setObjectName("UBTeacherBarPreviewSubtitle");
+ mTitleLayout.addWidget(mpTitleLabel, 0);
+ mpTitle = new QLabel(&mTitleContainer);
+ mpTitle->setObjectName("UBTeacherBarPreviewTitle");
+ mpTitle->setWordWrap(true);
+ mpTitle->setAlignment(Qt::AlignLeft);
+ mTitleLayout.addWidget(mpTitle, 1);
+ mpPageNbrLabel = new QLabel(tr("Page n° "), &mTitleContainer);
+ mpPageNbrLabel->setAlignment(Qt::AlignRight);
+ mpPageNbrLabel->setObjectName("UBTBPreviewSessionTitle");
+ mTitleLayout.addWidget(mpPageNbrLabel);
+ mTitleLayout.addWidget(&mTitleSeparator);
+ mLayout.addWidget(&mTitleContainer);
+
+ // Content
+ mpContentContainer = new UBTBPreviewContainer(this);
+ mLayout.addWidget(mpContentContainer, 1);
+
+ // License
+ mLayout.addWidget(&mLicenseSeparator);
+ mpLicenseLabel = new UBTBLicenseWidget(this);
+ mLayout.addWidget(mpLicenseLabel);
+
+ // Edit button
+ mpEditButton = new QPushButton(tr("Edit infos"), this);
+ mpEditButton->setObjectName("DockPaletteWidgetButton");
+ mEditLayout.addStretch(1);
+ mEditLayout.addWidget(mpEditButton, 0);
+ mEditLayout.addStretch(1);
+ mLayout.addLayout(&mEditLayout, 0);
+
+
+ connect(mpEditButton, SIGNAL(clicked()), this, SLOT(onEdit()));
+ connect(UBApplication::boardController, SIGNAL(activeSceneChanged()), this, SLOT(onActiveSceneChanged()));
+}
+
+UBTeacherBarPreviewWidget::~UBTeacherBarPreviewWidget()
+{
+ DELETEPTR(mpEditButton);
+ DELETEPTR(mpLicenseLabel);
+ DELETEPTR(mpScheduleLabel);
+ DELETEPTR(mpPageNbrLabel);
+ DELETEPTR(mpTitle);
+ DELETEPTR(mpTitleLabel);
+ DELETEPTR(mpSessionTitle);
+}
+
+void UBTeacherBarPreviewWidget::onActiveSceneChanged()
+{
+ mpPageNbrLabel->setText(tr("Page n° %0").arg(UBApplication::boardController->activeSceneIndex()));
+}
+
+void UBTeacherBarPreviewWidget::onEdit()
+{
+ emit showEditMode();
+}
+
+void UBTeacherBarPreviewWidget::updateFields()
+{
+ // Session Title
+ if("" != mpDataMgr->sessionTitle()){
+ mpSessionTitle->setText(mpDataMgr->sessionTitle());
+ mpSessionTitle->setVisible(true);
+ }else{
+ mpSessionTitle->setVisible(false);
+ }
+
+ // Page Title
+ if("" != mpDataMgr->pageTitle()){
+ mpTitle->setText(mpDataMgr->pageTitle());
+ mpPageNbrLabel->setText(tr("Page n° %0").arg(UBApplication::boardController->activeSceneIndex()));
+ mTitleContainer.setVisible(true);
+ }else{
+ mTitleContainer.setVisible(false);
+ }
+
+ // Actions
+ generateActions();
+
+ // Media
+ generateMedias();
+
+ // Comments
+ generateComments();
+
+ // Links
+ generateLinks();
+
+ // License
+ mpLicenseLabel->setLicense(mpDataMgr->sessionLicence());
+
+}
+
+void UBTeacherBarPreviewWidget::clearFields()
+{
+ // Session Title
+ mpSessionTitle->setText("");
+
+ // Page Title
+ mpTitle->setText("");
+
+ // Medias
+ if(!mStoredWidgets.empty()){
+ foreach(QWidget* pW, mStoredWidgets){
+ mpContentContainer->removeWidget(pW);
+ DELETEPTR(pW);
+ }
+ mStoredWidgets.clear();
+ }
+
+ // License
+ mpLicenseLabel->setLicense(eLicense_CCBY);
+}
+
+void UBTeacherBarPreviewWidget::generateActions()
+{
+ if(!mpDataMgr->actions()->empty()){
+ foreach(sAction act, *mpDataMgr->actions()){
+ mpTmpAction = new UBActionPreview(this);
+ mpTmpAction->setOwner(act.type);
+ mpTmpAction->setContent(act.content);
+ mpContentContainer->addWidget(mpTmpAction);
+ mStoredWidgets << mpTmpAction;
+ }
+ }
+}
+
+void UBTeacherBarPreviewWidget::generateMedias()
+{
+ if(isVisible()){
+ foreach(QString mediaUrl, *mpDataMgr->mediaUrls()){
+ QString mimeType = UBFileSystemUtils::mimeTypeFromFileName(mediaUrl);
+ if(mimeType.contains("image")){
+ mpTmpLabel = new UBDraggableLabel();
+ mpTmpLabel->loadImage(mediaUrl);
+ mStoredWidgets << mpTmpLabel;
+ mpContentContainer->addWidget(mpTmpLabel);
+ }
+ else if(mimeType.contains("video") || mimeType.contains("audio")){
+ UBDraggableMedia* mediaPlayer = new UBDraggableMedia(mimeType.contains("audio")?eMediaType_Audio:eMediaType_Video);
+ mediaPlayer->setFile(mediaUrl);
+ mStoredWidgets << mediaPlayer;
+ mpContentContainer->addWidget(mediaPlayer);
+ }
+ }
+ }
+}
+
+void UBTeacherBarPreviewWidget::generateLinks()
+{
+ if(!mpDataMgr->urls()->empty()){
+ foreach(sLink link, *mpDataMgr->urls()){
+ mpTmpLink = new QLabel(QString("%1").arg(link.link).arg(link.title), this);
+ mpTmpLink->setObjectName("UBLinkPreview");
+ mpTmpLink->setOpenExternalLinks(true);
+ mpContentContainer->addWidget(mpTmpLink);
+ mStoredWidgets << mpTmpLink;
+ }
+ }
+}
+
+void UBTeacherBarPreviewWidget::generateComments()
+{
+ if("" != mpDataMgr->comments()){
+ mpTmpComment = new QTextEdit(this);
+ mpTmpComment->setObjectName("UBCommentPreview");
+ mpTmpComment->setPlainText(mpDataMgr->comments());
+ mpTmpComment->setReadOnly(true);
+ mpContentContainer->addWidget(mpTmpComment);
+ mStoredWidgets << mpTmpComment;
+ }
+}
+
+void UBTeacherBarPreviewWidget::showEvent(QShowEvent* ev)
+{
+ updateFields();
+}
+
diff --git a/src/gui/UBTeacherBarPreviewWidget.h b/src/gui/UBTeacherBarPreviewWidget.h
new file mode 100644
index 00000000..ada45f6e
--- /dev/null
+++ b/src/gui/UBTeacherBarPreviewWidget.h
@@ -0,0 +1,120 @@
+#ifndef UBTEACHERBARPREVIEWWIDGET_H
+#define UBTEACHERBARPREVIEWWIDGET_H
+
+#include
+#include
+#include
+
+#include "core/UBPersistenceManager.h"
+#include "customWidgets/UBWidgetList.h"
+#include "customWidgets/UBMediaWidget.h"
+#include "customWidgets/UBDraggableMedia.h"
+#include "customWidgets/UBDraggableLabel.h"
+#include "UBTeacherBarDataMgr.h"
+
+class UBTeacherBarPreviewMedia : public QWidget
+{
+ Q_OBJECT
+public:
+ UBTeacherBarPreviewMedia(QWidget* parent=0, const char* name="UBTeacherBarPreviewMedia");
+ ~UBTeacherBarPreviewMedia();
+// int loadMedia(QStringList pMedias);
+ void loadWidgets(QList pWidgetList, bool isResizable = true);
+ void cleanMedia();
+
+private:
+ UBWidgetList* mWidget;
+ QVBoxLayout mLayout;
+ QMapmWidgetList;
+};
+
+class UBActionPreview : public QWidget
+{
+public:
+ UBActionPreview(QWidget* parent=0, const char* name="UBActionPreview");
+ ~UBActionPreview();
+ void setOwner(int owner);
+ void setContent(const QString& content);
+
+private:
+ QLabel* mpOwner;
+ QTextEdit* mpContent;
+
+ QVBoxLayout mLayout;
+ QHBoxLayout mOwnerLayout;
+};
+
+class UBTBPreviewContainer : public UBWidgetList
+{
+public:
+ UBTBPreviewContainer(QWidget* parent=0, const char* name="UBTBPreviewContainer");
+ ~UBTBPreviewContainer();
+};
+
+class UBTeacherBarPreviewWidget : public QWidget
+{
+ Q_OBJECT
+public:
+ UBTeacherBarPreviewWidget(UBTeacherBarDataMgr* pDataMgr, QWidget* parent=0, const char* name="UBTeacherBarPreviewWidget");
+ ~UBTeacherBarPreviewWidget();
+ void updateFields();
+ void clearFields();
+
+signals:
+ void showEditMode();
+
+protected:
+ void showEvent(QShowEvent* ev);
+
+private slots:
+ void onEdit();
+ void onActiveSceneChanged();
+
+private:
+ void generateActions();
+ void generateMedias();
+ void generateLinks();
+ void generateComments();
+
+ QVBoxLayout mLayout;
+ QHBoxLayout mEditLayout;
+ QPushButton* mpEditButton;
+
+ // Titles
+ QVBoxLayout mTitleLayout;
+ UBTBSeparator mTitleSeparator;
+ QWidget mTitleContainer;
+ QLabel* mpSessionTitle;
+ QLabel* mpTitle;
+ QLabel* mpTitleLabel;
+ QLabel* mpPageNbrLabel;
+ UBTBPreviewContainer* mpContentContainer;
+
+ // Schedule
+ QLabel* mpScheduleLabel;
+
+ // License
+ UBTBSeparator mLicenseSeparator;
+ // TODO : replace the QLabel of the license by a widget done for that!
+ UBTBLicenseWidget* mpLicenseLabel;
+
+
+ /** Pointer to the datas */
+ UBTeacherBarDataMgr* mpDataMgr;
+ /** The list of stored widgets */
+ QList mStoredWidgets;
+ /** A temporary action widget */
+ UBActionPreview* mpTmpAction;
+ /** A temporary media widget */
+ UBTeacherBarPreviewMedia* mpTmpMedia;
+ /** A temporary link */
+ QLabel* mpTmpLink;
+ /** A temporary comments field */
+ QTextEdit* mpTmpComment;
+ /** A temporary media object */
+ UBDraggableMedia* mTmpMedia;
+ /** A temporary label object */
+ UBDraggableLabel* mpTmpLabel;
+};
+
+#endif // UBTEACHERBARPREVIEWWIDGET_H
diff --git a/src/gui/UBTeacherBarWidget.cpp b/src/gui/UBTeacherBarWidget.cpp
index 52c21bb2..d6d5e9dc 100644
--- a/src/gui/UBTeacherBarWidget.cpp
+++ b/src/gui/UBTeacherBarWidget.cpp
@@ -1,7 +1,8 @@
- #include "UBTeacherBarWidget.h"
+#include "UBTeacherBarWidget.h"
#include "core/UBApplication.h"
#include "core/UBPersistenceManager.h"
+
#include "UBMainWindow.h"
#include "document/UBDocumentController.h"
@@ -10,34 +11,24 @@
#include "board/UBBoardController.h"
#include "board/UBBoardPaletteManager.h"
+#include "gui/UBMediaPlayer.h"
+
+#include "customWidgets/UBDraggableLabel.h"
+#include "customWidgets/UBMediaWidget.h"
+#include "customWidgets/UBGlobals.h"
+
#include "core/memcheck.h"
UBTeacherBarWidget::UBTeacherBarWidget(QWidget *parent, const char *name):UBDockPaletteWidget(parent)
- , mpLayout(NULL)
- , mpTitleLayout(NULL)
- , mpPhasisLayout(NULL)
- , mpDurationLayout(NULL)
- , mpEquipmentLayout(NULL)
- , mpActivityLayout(NULL)
- , mpTitleLabel(NULL)
- , mpPhasisLabel(NULL)
- , mpDurationLabel(NULL)
- , mpEquipmentLabel(NULL)
- , mpActivityLabel(NULL)
- , mpTitle(NULL)
- , mpEquipment(NULL)
- , mpPhasis(NULL)
- , mpDuration(NULL)
- , mpActivity(NULL)
- , mpAction1(NULL)
- , mpAction2(NULL)
- , mpAction3(NULL)
- , mpContainer(NULL)
- , mpContainerLayout(NULL)
-{
+ , mpStackWidget(NULL)
+ , mpPreview(NULL)
+ , mpDocPreviewWidget(NULL)
+ , mpDocEditWidget(NULL)
+ {
setObjectName(name);
mName = "TeacherBarWidget";
mVisibleState = true;
+ mData.clearLists();
setAttribute(Qt::WA_StyledBackground, true);
setStyleSheet(UBApplication::globalStyleSheet());
@@ -46,235 +37,50 @@ UBTeacherBarWidget::UBTeacherBarWidget(QWidget *parent, const char *name):UBDock
mIconToRight = QPixmap(":images/teacher_close.png");
// Create the GUI
- mpContainerLayout = new QVBoxLayout(this);
- setLayout(mpContainerLayout);
-
- mpContainer = new QWidget(this);
- mpContainer->setObjectName("DockPaletteWidgetBox");
- mpContainerLayout->addWidget(mpContainer);
-
- mpLayout = new QVBoxLayout(mpContainer);
- mpContainer->setLayout(mpLayout);
-
- // Title
- mpTitleLabel = new QLabel(tr("Title"), mpContainer);
- mpTitleLabel->setMinimumWidth(LABEL_MINWIDHT);
- mpTitleLabel->setAlignment(Qt::AlignRight);
- mpTitle = new QLineEdit(mpContainer);
- mpTitle->setObjectName("DockPaletteWidgetLineEdit");
- connect(mpTitle, SIGNAL(textChanged(const QString&)), this, SLOT(onTitleTextChanged(const QString&)));
- mpTitleLayout = new QHBoxLayout();
- mpTitleLayout->addWidget(mpTitleLabel, 0);
- mpTitleLayout->addWidget(mpTitle, 1);
- mpLayout->addLayout(mpTitleLayout);
+ setLayout(&mLayout);
- // Phasis
- mpPhasisLabel = new QLabel(tr("Phasis"), mpContainer);
- mpPhasisLabel->setMinimumWidth(LABEL_MINWIDHT);
- mpPhasisLabel->setAlignment(Qt::AlignRight);
- mpPhasis = new QComboBox(mpContainer);
- mpPhasis->setObjectName("DockPaletteWidgetComboBox");
- mpPhasisLayout = new QHBoxLayout();
- mpPhasisLayout->addWidget(mpPhasisLabel, 0);
- mpPhasisLayout->addWidget(mpPhasis, 1);
- mpLayout->addLayout(mpPhasisLayout);
+ mpStackWidget = new QStackedWidget(this);
+ mLayout.addWidget(mpStackWidget);
+ mpPageEditWidget = new UBTBPageEditWidget(&mData, mpStackWidget);
+ mpPreview = new UBTeacherBarPreviewWidget(&mData, mpStackWidget);
+ mpDocPreviewWidget = new UBTBDocumentPreviewWidget(&mData, mpStackWidget);
+ mpDocEditWidget = new UBTBDocumentEditWidget(&mData, mpStackWidget);
- // Duration
- mpDurationLabel = new QLabel(tr("Duration"), mpContainer);
- mpDurationLabel->setMinimumWidth(LABEL_MINWIDHT);
- mpDurationLabel->setAlignment(Qt::AlignRight);
- mpDuration = new QComboBox(mpContainer);
- mpDuration->setObjectName("DockPaletteWidgetComboBox");
- mpDurationLayout = new QHBoxLayout();
- mpDurationLayout->addWidget(mpDurationLabel, 0);
- mpDurationLayout->addWidget(mpDuration, 1);
- mpLayout->addLayout(mpDurationLayout);
-
- // Equipment
- mpEquipmentLabel = new QLabel(tr("Equipment"), mpContainer);
- mpEquipmentLabel->setMinimumWidth(LABEL_MINWIDHT);
- mpEquipmentLabel->setAlignment(Qt::AlignRight);
- mpEquipment = new QLineEdit(mpContainer);
- mpEquipment->setObjectName("DockPaletteWidgetLineEdit");
- connect(mpEquipment, SIGNAL(textChanged(const QString&)), this, SLOT(onEquipmentTextChanged(const QString&)));
- mpEquipmentLayout = new QHBoxLayout();
- mpEquipmentLayout->addWidget(mpEquipmentLabel, 0);
- mpEquipmentLayout->addWidget(mpEquipment, 1);
- mpLayout->addLayout(mpEquipmentLayout);
-
- // Activity
- mpActivityLabel = new QLabel(tr("Activity"), mpContainer);
- mpActivityLabel->setMinimumWidth(LABEL_MINWIDHT);
- mpActivityLabel->setAlignment(Qt::AlignRight);
- mpActivity = new QComboBox(mpContainer);
- mpActivity->setObjectName("DockPaletteWidgetComboBox");
- mpActivityLayout = new QHBoxLayout();
- mpActivityLayout->addWidget(mpActivityLabel, 0);
- mpActivityLayout->addWidget(mpActivity, 1);
- mpLayout->addLayout(mpActivityLayout);
-
- // Actions
- mpAction1 = new UBTeacherStudentAction(1, mpContainer);
- mpAction2 = new UBTeacherStudentAction(2, mpContainer);
- mpAction3 = new UBTeacherStudentAction(3, mpContainer);
-
- mpLayout->addWidget(mpAction1);
- mpLayout->addWidget(mpAction2);
- mpLayout->addWidget(mpAction3);
-
- populateCombos();
+ mpStackWidget->addWidget(mpPageEditWidget);
+ mpStackWidget->addWidget(mpPreview);
+ mpStackWidget->addWidget(mpDocPreviewWidget);
+ mpStackWidget->addWidget(mpDocEditWidget);
connect(UBApplication::boardController, SIGNAL(activeSceneWillChange()), this, SLOT(saveContent()));
- connect(UBApplication::boardController, SIGNAL(activeSceneChanged()), this, SLOT(loadContent()));
connect(UBApplication::mainWindow->actionQuit, SIGNAL(triggered()), this, SLOT(saveContent()));
- connect(mpTitle, SIGNAL(textChanged(QString)), this, SLOT(onValueChanged()));
- connect(mpPhasis, SIGNAL(currentIndexChanged(int)), this, SLOT(onValueChanged()));
- connect(mpDuration, SIGNAL(currentIndexChanged(int)), this, SLOT(onValueChanged()));
- connect(mpEquipment, SIGNAL(textChanged(QString)), this, SLOT(onValueChanged()));
- connect(mpActivity, SIGNAL(currentIndexChanged(int)), this, SLOT(onValueChanged()));
- connect(mpAction1->teacher(), SIGNAL(textChanged()), this, SLOT(onValueChanged()));
- connect(mpAction1->student(), SIGNAL(textChanged()), this, SLOT(onValueChanged()));
- connect(mpAction2->teacher(), SIGNAL(textChanged()), this, SLOT(onValueChanged()));
- connect(mpAction2->student(), SIGNAL(textChanged()), this, SLOT(onValueChanged()));
- connect(mpAction3->teacher(), SIGNAL(textChanged()), this, SLOT(onValueChanged()));
- connect(mpAction3->student(), SIGNAL(textChanged()), this, SLOT(onValueChanged()));
+ connect(UBApplication::boardController, SIGNAL(activeSceneChanged()), this, SLOT(loadContentInfos()));
+ connect(UBApplication::boardController, SIGNAL(activeDocumentChanged()), this, SLOT(onActiveDocumentChanged()));
+
+ connect(mpPreview, SIGNAL(showEditMode()), this, SLOT(onShowEditMode()));
+ connect(mpDocPreviewWidget, SIGNAL(changeTBState(eTeacherBarState)), this, SLOT(onTBStateChanged(eTeacherBarState)));
+ connect(mpDocEditWidget, SIGNAL(changeTBState(eTeacherBarState)), this, SLOT(onTBStateChanged(eTeacherBarState)));
+ connect(mpPageEditWidget, SIGNAL(changeTBState(eTeacherBarState)), this, SLOT(onTBStateChanged(eTeacherBarState)));
+ connect(mpPageEditWidget, SIGNAL(valueChanged()), this, SLOT(onValueChanged()));
+ connect(mpDocEditWidget, SIGNAL(valueChanged()), this, SLOT(onValueChanged()));
}
UBTeacherBarWidget::~UBTeacherBarWidget()
{
- if(NULL != mpAction3)
- {
- delete mpAction3;
- mpAction3 = NULL;
- }
- if(NULL != mpAction2)
- {
- delete mpAction2;
- mpAction2 = NULL;
- }
- if(NULL != mpAction1)
- {
- delete mpAction1;
- mpAction1 = NULL;
- }
- if(NULL != mpActivityLabel)
- {
- delete mpActivityLabel;
- mpActivityLabel = NULL;
- }
- if(NULL != mpActivity)
- {
- delete mpActivity;
- mpActivity = NULL;
- }
- if(NULL != mpActivityLayout)
- {
- delete mpActivityLayout;
- mpActivityLayout = NULL;
- }
- if(NULL != mpEquipmentLabel)
- {
- delete mpEquipmentLabel;
- mpEquipmentLabel = NULL;
- }
- if(NULL != mpEquipment)
- {
- delete mpEquipment;
- mpEquipment = NULL;
- }
- if(NULL != mpEquipmentLayout)
- {
- delete mpEquipmentLayout;
- mpEquipmentLayout = NULL;
- }
- if(NULL != mpDurationLabel)
- {
- delete mpDurationLabel;
- mpDurationLabel = NULL;
- }
- if(NULL != mpDuration)
- {
- delete mpDuration;
- mpDuration = NULL;
- }
- if(NULL != mpDurationLayout)
- {
- delete mpDurationLayout;
- mpDurationLayout = NULL;
- }
- if(NULL != mpPhasisLabel)
- {
- delete mpPhasisLabel;
- mpPhasisLabel = NULL;
- }
- if(NULL != mpPhasisLayout)
- {
- delete mpPhasisLayout;
- mpPhasisLayout = NULL;
- }
- if(NULL != mpTitleLabel)
- {
- delete mpTitleLabel;
- mpTitleLabel = NULL;
- }
- if(NULL != mpTitle)
- {
- delete mpTitle;
- mpTitle = NULL;
- }
- if(NULL != mpTitleLayout)
- {
- delete mpTitleLayout;
- mpTitleLayout = NULL;
- }
- if(NULL != mpLayout)
- {
- delete mpLayout;
- mpLayout = NULL;
- }
- if(NULL != mpContainer)
- {
- delete mpContainer;
- mpContainer = NULL;
- }
- if(NULL != mpContainerLayout)
- {
- delete mpContainerLayout;
- mpContainerLayout = NULL;
- }
+ DELETEPTR(mpDocPreviewWidget);
+ DELETEPTR(mpDocEditWidget);
+ DELETEPTR(mpPageEditWidget);
+ DELETEPTR(mpPreview);
+ DELETEPTR(mpStackWidget);
}
-void UBTeacherBarWidget::populateCombos()
+void UBTeacherBarWidget::onActiveDocumentChanged()
{
- QStringList qslPhasis;
- qslPhasis << tr("") << tr("I discover") << tr("I experiment") << tr("I train myself") << tr("I play") << tr("I memorize");
- mpPhasis->insertItems(0, qslPhasis);
- mpPhasis->setCurrentIndex(0);
-
- QStringList qslDuration;
- qslDuration << tr("") << tr("Short") << tr("Middle") << tr("Long");
- mpDuration->insertItems(0, qslDuration);
- mpDuration->setCurrentIndex(0);
-
- QStringList qslActivity;
- qslActivity << tr("") << tr("Alone") << tr("By Group") << tr("All together");
- mpActivity->insertItems(0, qslActivity);
- mpActivity->setCurrentIndex(0);
+ loadContent(true);
}
void UBTeacherBarWidget::onValueChanged()
{
- if( mpTitle->text() == ""
- && mpDuration->currentIndex() == 0
- && mpPhasis->currentIndex() == 0
- && mpEquipment->text() == ""
- && mpActivity->currentIndex() == 0
- && mpAction1->teacherText() == ""
- && mpAction1->studentText() == ""
- && mpAction2->teacherText() == ""
- && mpAction2->studentText() == ""
- && mpAction3->teacherText() == ""
- && mpAction3->studentText() == "")
+ if(isEmpty())
{
mIconToLeft = QPixmap(":images/teacher_open_disabled.png");
mIconToRight = QPixmap(":images/teacher_close_disabled.png");
@@ -290,165 +96,89 @@ void UBTeacherBarWidget::onValueChanged()
void UBTeacherBarWidget::saveContent()
{
- sTeacherBarInfos infos;
- infos.title = mpTitle->text();
- infos.phasis = mpPhasis->currentIndex();
- infos.Duration = mpDuration->currentIndex();
- infos.material = mpEquipment->text();
- infos.activity = mpActivity->currentIndex();
- infos.action1Master = mpAction1->teacherText();
- infos.action1Student = mpAction1->studentText();
- infos.action2Master = mpAction2->teacherText();
- infos.action2Student = mpAction2->studentText();
- infos.action3Master = mpAction3->teacherText();
- infos.action3Student = mpAction3->studentText();
- UBPersistenceManager::persistenceManager()->persistTeacherBar(UBApplication::boardController->activeDocument(), UBApplication::boardController->activeSceneIndex(), infos);
-}
-
-void UBTeacherBarWidget::loadContent()
-{
- sTeacherBarInfos nextInfos = UBPersistenceManager::persistenceManager()->getTeacherBarInfos(UBApplication::boardController->activeDocument(), UBApplication::boardController->activeSceneIndex());
- mpTitle->setText(nextInfos.title);
- mpPhasis->setCurrentIndex(nextInfos.phasis);
- mpDuration->setCurrentIndex(nextInfos.Duration);
- mpEquipment->setText(nextInfos.material);
- mpActivity->setCurrentIndex(nextInfos.activity);
- mpAction1->setTeacherText(nextInfos.action1Master);
- mpAction1->setStudentText(nextInfos.action1Student);
- mpAction2->setTeacherText(nextInfos.action2Master);
- mpAction2->setStudentText(nextInfos.action2Student);
- mpAction3->setTeacherText(nextInfos.action3Master);
- mpAction3->setStudentText(nextInfos.action3Student);
-}
-
-void UBTeacherBarWidget::onTitleTextChanged(const QString& text)
-{
- mpTitle->setToolTip(text);
+ mpPageEditWidget->saveFields();
+ mData.saveContent();
}
-void UBTeacherBarWidget::onEquipmentTextChanged(const QString& text)
+void UBTeacherBarWidget::loadContentInfos()
{
- mpEquipment->setToolTip(text);
+ loadContent(false);
}
-UBTeacherStudentAction::UBTeacherStudentAction(int actionNumber, QWidget *parent, const char *name):QWidget(parent)
- , mpActionLabel(NULL)
- , mpTeacherLabel(NULL)
- , mpStudentLabel(NULL)
- , mpTeacher(NULL)
- , mpStudent(NULL)
- , mpLayout(NULL)
- , mpTeacherLayout(NULL)
- , mpStudentLayout(NULL)
+void UBTeacherBarWidget::loadContent(bool docChanged)
{
- setObjectName(name);
- mActionNumber = actionNumber;
-
- setAttribute(Qt::WA_StyledBackground, true);
- setStyleSheet(UBApplication::globalStyleSheet());
-
- // Create the GUI
- mpLayout = new QVBoxLayout(this);
- setLayout(mpLayout);
-
- mpActionLabel = new QLabel(tr("Action %0").arg(mActionNumber), this);
- mpLayout->addWidget(mpActionLabel, 0);
-
- mpTeacherLayout = new QHBoxLayout();
-
- //TODO: I'm not able to translate this string using the normal way *qm file why?
- mpTeacherLabel = new QLabel(tr("Teacher"), this);
-// mpTeacherLabel = new QLabel(tr("Enseignant"), this);
- mpTeacherLabel->setAlignment(Qt::AlignTop);
- mpTeacher = new QTextEdit(this);
- mpTeacher->setObjectName("TeacherStudentBox");
- mpTeacher->setStyleSheet("background-color:#FF9F6D");
- mpTeacherLayout->addWidget(mpTeacherLabel, 0);
- mpTeacherLayout->addWidget(mpTeacher, 1);
- mpLayout->addLayout(mpTeacherLayout, 1);
+ // Clear the old datas
+ mpPageEditWidget->clearFields();
+ mpPreview->clearFields();
+ if(docChanged){
+ mpDocEditWidget->clearFields();
+ mpDocPreviewWidget->clearFields();
+ }
- mpStudentLayout = new QHBoxLayout();
- mpStudentLabel = new QLabel(tr("Student"), this);
-// mpStudentLabel = new QLabel(tr("Élève"), this);
- mpStudentLabel->setAlignment(Qt::AlignTop);
- mpStudent = new QTextEdit(this);
- mpStudent->setObjectName("TeacherStudentBox");
- mpStudent->setStyleSheet("background-color:#06E983");
- mpStudentLayout->addWidget(mpStudentLabel, 0);
- mpStudentLayout->addWidget(mpStudent, 1);
- mpLayout->addLayout(mpStudentLayout, 1);
-}
+ // Update the datas
+ mData.loadContent(docChanged);
-UBTeacherStudentAction::~UBTeacherStudentAction()
-{
- if(NULL != mpActionLabel)
- {
- delete mpActionLabel;
- mpActionLabel = NULL;
- }
- if(NULL != mpTeacherLabel)
- {
- delete mpTeacherLabel;
- mpTeacherLabel = NULL;
- }
- if(NULL != mpTeacher)
- {
- delete mpTeacher;
- mpTeacher = NULL;
- }
- if(NULL != mpTeacherLayout)
- {
- delete mpTeacherLayout;
- mpTeacherLayout = NULL;
- }
- if(NULL != mpStudentLabel)
- {
- delete mpStudentLabel;
- mpStudentLabel = NULL;
- }
- if(NULL != mpStudent)
- {
- delete mpStudent;
- mpStudent = NULL;
- }
- if(NULL != mpStudentLayout)
- {
- delete mpStudentLayout;
- mpStudentLayout = NULL;
- }
- if(NULL != mpLayout)
- {
- delete mpLayout;
- mpLayout = NULL;
+ // Update the fields
+ mpPageEditWidget->updateFields();
+ //mpPreview->updateFields();
+ if(docChanged){
+ mpDocEditWidget->updateFields();
+ mpDocPreviewWidget->updateFields();
}
-}
-
-QString UBTeacherStudentAction::teacherText()
-{
- return mpTeacher->document()->toPlainText();
-}
-QString UBTeacherStudentAction::studentText()
-{
- return mpStudent->document()->toPlainText();
+ if(!isEmpty()){
+ onTBStateChanged(eTeacherBarState_PagePreview);
+ }else{
+ if(1 == UBApplication::boardController->activeDocument()->pageCount()){
+ onTBStateChanged(eTeacherBarState_DocumentEdit);
+ }else{
+ onTBStateChanged(eTeacherBarState_PageEdit);
+ }
+ }
}
-void UBTeacherStudentAction::setTeacherText(QString text)
+bool UBTeacherBarWidget::isEmpty()
{
- mpTeacher->setText(text);
+ return mData.pageTitle() == "" &&
+ mData.urls()->empty() &&
+ mData.actions()->empty() &&
+ mData.medias()->empty() &&
+ mData.comments() == "" &&
+ mData.authors() == "" &&
+ mData.keywords() == "" &&
+ mData.level() == "" &&
+ mData.topic() == "";
}
-void UBTeacherStudentAction::setStudentText(QString text)
+void UBTeacherBarWidget::onShowEditMode()
{
- mpStudent->setText(text);
+ onTBStateChanged(eTeacherBarState_PageEdit);
}
-QTextEdit* UBTeacherStudentAction::teacher()
+void UBTeacherBarWidget::onTBStateChanged(eTeacherBarState state)
{
- return mpTeacher;
+ switch(state){
+ case eTeacherBarState_DocumentEdit:
+ //mpDocEditWidget->updateFields();
+ mpStackWidget->setCurrentWidget(mpDocEditWidget);
+ break;
+ case eTeacherBarState_DocumentPreview:
+ //mpDocPreviewWidget->updateFields();
+ mpStackWidget->setCurrentWidget(mpDocPreviewWidget);
+ break;
+ case eTeacherBarState_PageEdit:
+ mpPageEditWidget->clearFields();
+ mpPageEditWidget->updateFields();
+ mpStackWidget->setCurrentWidget(mpPageEditWidget);
+ break;
+ case eTeacherBarState_PagePreview:
+ saveContent();
+ mpPreview->clearFields();
+ if(mpPreview->isVisible()){
+ mpPreview->updateFields();
+ }
+ mpStackWidget->setCurrentWidget(mpPreview);
+ break;
+ }
}
-QTextEdit* UBTeacherStudentAction::student()
-{
- return mpStudent;
-}
diff --git a/src/gui/UBTeacherBarWidget.h b/src/gui/UBTeacherBarWidget.h
index e3fb2bce..bac2a132 100644
--- a/src/gui/UBTeacherBarWidget.h
+++ b/src/gui/UBTeacherBarWidget.h
@@ -7,38 +7,24 @@
#include
#include
#include
+#include
+#include
+#include
+#include
#include
+#include
#include "UBDockPaletteWidget.h"
+#include "customWidgets/UBWidgetList.h"
+#include "interfaces/IDropable.h"
+#include "UBTeacherBarDataMgr.h"
+#include "UBTBDocumentPreviewWidget.h"
+#include "UBTBPageEditWidget.h"
+#include "UBTeacherBarPreviewWidget.h"
+#include "UBTBDocumentEditWidget.h"
#define LABEL_MINWIDHT 80
-class UBTeacherStudentAction : public QWidget
-{
- Q_OBJECT
-
-public:
- UBTeacherStudentAction(int actionNumber, QWidget* parent=0, const char* name="UBTeacherStudentAction");
- ~UBTeacherStudentAction();
- QString teacherText();
- QString studentText();
- void setTeacherText(QString text);
- void setStudentText(QString text);
- QTextEdit* teacher();
- QTextEdit* student();
-
-private:
- int mActionNumber;
- QLabel* mpActionLabel;
- QLabel* mpTeacherLabel;
- QLabel* mpStudentLabel;
- QTextEdit* mpTeacher;
- QTextEdit* mpStudent;
- QVBoxLayout* mpLayout;
- QHBoxLayout* mpTeacherLayout;
- QHBoxLayout* mpStudentLayout;
-};
-
class UBTeacherBarWidget : public UBDockPaletteWidget
{
Q_OBJECT
@@ -50,39 +36,32 @@ public:
{
return (mode == eUBDockPaletteWidget_BOARD) || (mode == eUBDockPaletteWidget_DESKTOP);
}
+
+ void loadContent(bool docChanged = false);
public slots:
void saveContent();
- void loadContent();
+
private slots:
+ void loadContentInfos();
void onValueChanged();
- void onTitleTextChanged(const QString& text);
- void onEquipmentTextChanged(const QString& text);
+ void onShowEditMode();
+ void onTBStateChanged(eTeacherBarState state);
+ void onActiveDocumentChanged();
private:
- void populateCombos();
+ bool isEmpty();
+
+ QVBoxLayout mLayout;
+ QStackedWidget* mpStackWidget;
+ eTeacherBarState mState;
+
+ UBTBPageEditWidget* mpPageEditWidget;
+ UBTeacherBarPreviewWidget* mpPreview;
+ UBTBDocumentPreviewWidget* mpDocPreviewWidget;
+ UBTBDocumentEditWidget* mpDocEditWidget;
- QVBoxLayout* mpLayout;
- QHBoxLayout* mpTitleLayout;
- QHBoxLayout* mpPhasisLayout;
- QHBoxLayout* mpDurationLayout;
- QHBoxLayout* mpEquipmentLayout;
- QHBoxLayout* mpActivityLayout;
- QLabel* mpTitleLabel;
- QLabel* mpPhasisLabel;
- QLabel* mpDurationLabel;
- QLabel* mpEquipmentLabel;
- QLabel* mpActivityLabel;
- QLineEdit* mpTitle;
- QLineEdit* mpEquipment;
- QComboBox* mpPhasis;
- QComboBox* mpDuration;
- QComboBox* mpActivity;
- UBTeacherStudentAction* mpAction1;
- UBTeacherStudentAction* mpAction2;
- UBTeacherStudentAction* mpAction3;
- QWidget* mpContainer;
- QVBoxLayout* mpContainerLayout;
+ UBTeacherBarDataMgr mData;
};
#endif // UBTEACHERBARWIDGET_H
diff --git a/src/gui/UBVideoPlayer.h b/src/gui/UBVideoPlayer.h
index ced2cc3b..287ad382 100644
--- a/src/gui/UBVideoPlayer.h
+++ b/src/gui/UBVideoPlayer.h
@@ -35,6 +35,11 @@ class UBVideoPlayer : public QWidget
return mVideoPlayer;
}
+ void loadMedia(QUrl url)
+ {
+ mVideoPlayer->load(Phonon::MediaSource(url));
+ }
+
protected:
Phonon::VideoPlayer* mVideoPlayer;
diff --git a/src/gui/gui.pri b/src/gui/gui.pri
index 20075dfb..5fa7ab62 100644
--- a/src/gui/gui.pri
+++ b/src/gui/gui.pri
@@ -26,27 +26,33 @@ HEADERS += src/gui/UBThumbnailView.h \
src/gui/UBActionPalette.h \
src/gui/UBFavoriteToolPalette.h \
src/gui/UBKeyboardPalette.h \
- src/gui/UBNavigatorPalette.h \
- src/gui/UBDocumentNavigator.h \
- src/gui/UBDockPalette.h \
- src/gui/UBPropertyPalette.h \
- src/gui/UBLibNavigatorWidget.h \
- src/gui/UBLibItemProperties.h \
- src/gui/UBLibActionBar.h \
- src/gui/UBLibraryWidget.h \
- src/gui/UBLibPathViewer.h \
- src/gui/UBUpdateDlg.h \
- src/gui/UBDockPaletteWidget.h \
- src/gui/UBLeftPalette.h \
- src/gui/UBRightPalette.h \
- src/gui/UBPageNavigationWidget.h \
- src/gui/UBLibWidget.h \
- src/gui/UBMagnifer.h \
- src/gui/UBCachePropertiesWidget.h \
- src/gui/UBTeacherBarWidget.h \
- src/gui/UBLibWebView.h \
- src/gui/UBDownloadWidget.h \
- src/gui/UBDockDownloadWidget.h
+ src/gui/UBNavigatorPalette.h \
+ src/gui/UBDocumentNavigator.h \
+ src/gui/UBDockPalette.h \
+ src/gui/UBPropertyPalette.h \
+ src/gui/UBLibNavigatorWidget.h \
+ src/gui/UBLibItemProperties.h \
+ src/gui/UBLibActionBar.h \
+ src/gui/UBLibraryWidget.h \
+ src/gui/UBLibPathViewer.h \
+ src/gui/UBUpdateDlg.h \
+ src/gui/UBDockPaletteWidget.h \
+ src/gui/UBLeftPalette.h \
+ src/gui/UBRightPalette.h \
+ src/gui/UBPageNavigationWidget.h \
+ src/gui/UBLibWidget.h \
+ src/gui/UBMagnifer.h \
+ src/gui/UBCachePropertiesWidget.h \
+ src/gui/UBTeacherBarWidget.h \
+ src/gui/UBLibWebView.h \
+ src/gui/UBDownloadWidget.h \
+ src/gui/UBDockDownloadWidget.h \
+ src/gui/UBMediaPlayer.h \
+ src/gui/UBTeacherBarDataMgr.h \
+ src/gui/UBTBDocumentEditWidget.h \
+ src/gui/UBTBDocumentPreviewWidget.h \
+ src/gui/UBTeacherBarPreviewWidget.h \
+ src/gui/UBTBPageEditWidget.h
SOURCES += src/gui/UBThumbnailView.cpp \
src/gui/UBFloatingPalette.cpp \
@@ -75,27 +81,33 @@ SOURCES += src/gui/UBThumbnailView.cpp \
src/gui/UBActionPalette.cpp \
src/gui/UBFavoriteToolPalette.cpp \
src/gui/UBKeyboardPalette.cpp \
- src/gui/UBNavigatorPalette.cpp \
- src/gui/UBDocumentNavigator.cpp \
- src/gui/UBDockPalette.cpp \
- src/gui/UBPropertyPalette.cpp \
- src/gui/UBLibNavigatorWidget.cpp \
- src/gui/UBLibItemProperties.cpp \
- src/gui/UBLibActionBar.cpp \
- src/gui/UBLibraryWidget.cpp \
- src/gui/UBLibPathViewer.cpp \
- src/gui/UBUpdateDlg.cpp \
- src/gui/UBDockPaletteWidget.cpp \
- src/gui/UBLeftPalette.cpp \
- src/gui/UBRightPalette.cpp \
- src/gui/UBPageNavigationWidget.cpp \
- src/gui/UBLibWidget.cpp \
- src/gui/UBMagnifer.cpp \
- src/gui/UBCachePropertiesWidget.cpp \
- src/gui/UBTeacherBarWidget.cpp \
- src/gui/UBLibWebView.cpp \
- src/gui/UBDownloadWidget.cpp \
- src/gui/UBDockDownloadWidget.cpp
+ src/gui/UBNavigatorPalette.cpp \
+ src/gui/UBDocumentNavigator.cpp \
+ src/gui/UBDockPalette.cpp \
+ src/gui/UBPropertyPalette.cpp \
+ src/gui/UBLibNavigatorWidget.cpp \
+ src/gui/UBLibItemProperties.cpp \
+ src/gui/UBLibActionBar.cpp \
+ src/gui/UBLibraryWidget.cpp \
+ src/gui/UBLibPathViewer.cpp \
+ src/gui/UBUpdateDlg.cpp \
+ src/gui/UBDockPaletteWidget.cpp \
+ src/gui/UBLeftPalette.cpp \
+ src/gui/UBRightPalette.cpp \
+ src/gui/UBPageNavigationWidget.cpp \
+ src/gui/UBLibWidget.cpp \
+ src/gui/UBMagnifer.cpp \
+ src/gui/UBCachePropertiesWidget.cpp \
+ src/gui/UBTeacherBarWidget.cpp \
+ src/gui/UBLibWebView.cpp \
+ src/gui/UBDownloadWidget.cpp \
+ src/gui/UBDockDownloadWidget.cpp \
+ src/gui/UBMediaPlayer.cpp \
+ src/gui/UBTeacherBarDataMgr.cpp \
+ src/gui/UBTBDocumentEditWidget.cpp \
+ src/gui/UBTBDocumentPreviewWidget.cpp \
+ src/gui/UBTeacherBarPreviewWidget.cpp \
+ src/gui/UBTBPageEditWidget.cpp
win32 {
diff --git a/src/interfaces/IDropable.h b/src/interfaces/IDropable.h
new file mode 100644
index 00000000..a75f4f16
--- /dev/null
+++ b/src/interfaces/IDropable.h
@@ -0,0 +1,21 @@
+#ifndef IDROPABLE_H
+#define IDROPABLE_H
+
+#include
+#include
+#include
+#include
+
+class IDropable
+{
+public:
+ virtual ~IDropable(){}
+
+protected:
+ virtual void dropEvent(QDropEvent* pEvent) = 0;
+ virtual void dragEnterEvent(QDragEnterEvent* pEvent) = 0;
+ virtual void dragMoveEvent(QDragMoveEvent* pEvent) = 0;
+ virtual void dragLeaveEvent(QDragLeaveEvent* pEvent) = 0;
+};
+
+#endif // IDROPABLE_H
diff --git a/src/interfaces/IResizeable.h b/src/interfaces/IResizeable.h
new file mode 100644
index 00000000..b84ac8e5
--- /dev/null
+++ b/src/interfaces/IResizeable.h
@@ -0,0 +1,15 @@
+#ifndef IRESIZEABLE_H
+#define IRESIZEABLE_H
+
+#include
+
+class IResizeable
+{
+public:
+ ~IResizeable();
+
+protected:
+ virtual void resizeEvent(QResizeEvent* pEvent) = 0;
+};
+
+#endif // IRESIZEABLE_H
diff --git a/src/interfaces/interfaces.pri b/src/interfaces/interfaces.pri
new file mode 100644
index 00000000..55098bf3
--- /dev/null
+++ b/src/interfaces/interfaces.pri
@@ -0,0 +1,3 @@
+HEADERS += src/interfaces/IDropable.h \
+ src/interfaces/IDropable.h \
+ src/interfaces/IResizeable.h
diff --git a/src/podcast/youtube/UBYouTubePublisher.cpp b/src/podcast/youtube/UBYouTubePublisher.cpp
index 5cd44662..f160d4a4 100644
--- a/src/podcast/youtube/UBYouTubePublisher.cpp
+++ b/src/podcast/youtube/UBYouTubePublisher.cpp
@@ -24,7 +24,7 @@
#include "core/UBSetting.h"
#include "gui/UBMainWindow.h"
-#include "gui/UBVideoPlayer.h"
+//#include "gui/UBVideoPlayer.h"
#include "network/UBNetworkAccessManager.h"
#include "network/UBServerXMLHttpRequest.h"
diff --git a/src/web/UBWebController.cpp b/src/web/UBWebController.cpp
index 92b592ed..aae76119 100644
--- a/src/web/UBWebController.cpp
+++ b/src/web/UBWebController.cpp
@@ -20,6 +20,7 @@
#include "frameworks/UBPlatformUtils.h"
#include "UBWebController.h"
+#include "UBOEmbedParser.h"
#include "UBTrapFlashController.h"
#include "web/browser/WBBrowserWindow.h"
@@ -79,6 +80,7 @@ UBWebController::UBWebController(UBMainWindow* mainWindow)
}
+
UBWebController::~UBWebController()
{
// NOOP
@@ -95,6 +97,7 @@ void UBWebController::initialiazemOEmbedProviders()
mOEmbedProviders << "metacafe.com";
mOEmbedProviders << "qik.com";
mOEmbedProviders << "slideshare";
+ mOEmbedProviders << "5min.com";
mOEmbedProviders << "twitpic.com";
mOEmbedProviders << "viddler.com";
mOEmbedProviders << "vimeo.com";
@@ -323,8 +326,6 @@ void UBWebController::activePageChanged()
mTrapFlashController->updateTrapFlashFromPage((*mCurrentWebBrowser)->currentTabWebView()->page()->currentFrame());
}
-
-
mMainWindow->actionWebTrap->setChecked(false);
QUrl latestUrl = (*mCurrentWebBrowser)->currentTabWebView()->url();
@@ -333,7 +334,6 @@ void UBWebController::activePageChanged()
//UBApplication::mainWindow->actionWebOEmbed->setEnabled(hasEmbeddedContent());
// And remove this line once the previous one is uncommented
UBApplication::mainWindow->actionWebOEmbed->setEnabled(isOEmbedable(latestUrl));
-
UBApplication::mainWindow->actionEduMedia->setEnabled(isEduMedia(latestUrl));
emit activeWebPageChanged((*mCurrentWebBrowser)->currentTabWebView());
diff --git a/src/web/UBWebController.h b/src/web/UBWebController.h
index 03a0829a..1636826a 100644
--- a/src/web/UBWebController.h
+++ b/src/web/UBWebController.h
@@ -19,7 +19,7 @@
#include
#include
-#include "web/UBOEmbedParser.h"
+#include "UBOEmbedParser.h"
class WBBrowserWindow;
class UBApplication;
@@ -30,6 +30,7 @@ class UBWebToolsPalette;
class WBWebView;
class UBServerXMLHttpRequest;
+
class UBWebController : public QObject
{
Q_OBJECT;
@@ -104,27 +105,35 @@ class UBWebController : public QObject
void lookForEmbedContent(QString* pHtml, QString tag, QString attribute, QList* pList);
void checkForOEmbed(QString* pHtml);
-
QStackedWidget mStackedWidget[TotalNumberOfWebInstances];
+
UBMainWindow *mMainWindow;
+
WBBrowserWindow* mWebBrowserList[TotalNumberOfWebInstances];
WBBrowserWindow** mCurrentWebBrowser;
+
QWidget* mBrowserWidget;
UBTrapFlashController* mTrapFlashController;
UBWebToolsPalette** mToolsCurrentPalette;
UBWebToolsPalette* mToolsPaletteList[TotalNumberOfWebInstances];
// UBKeyboardPalette** mKeyboardCurrentPalette;
// UBKeyboardPalette* mKeyboardPaletteList[TotalNumberOfWebInstances];
+
bool mToolsPalettePositionned;
bool mToolsPalettePositionnedList[TotalNumberOfWebInstances];
+
bool mDownloadViewIsVisible;
+
QStringList mOEmbedProviders;
+
UBOEmbedParser mOEmbedParser;
+
private slots:
void activePageChanged();
void trapFlash();
+
void toggleWebTrap(bool checked);
void onOEmbedParsed(QVector contents);
@@ -137,6 +146,7 @@ class UBWebController : public QObject
* @param pCapturedPixmap QPixmap corresponding to the capture.
*/
void imageCaptured(const QPixmap& pCapturedPixmap, bool pageMode, const QUrl& source);
+
void activeWebPageChanged(WBWebView* pWebView);
};
diff --git a/src/web/web.pri b/src/web/web.pri
index 8d89a572..fcc383c1 100644
--- a/src/web/web.pri
+++ b/src/web/web.pri
@@ -14,20 +14,21 @@ HEADERS += src/web/UBWebController.h \
src/web/UBWebPage.h \
src/web/UBWebPluginWidget.h \
src/web/UBRoutedMouseEventWebView.h \
- src/web/browser/WBBrowserWindow.h \
- src/web/browser/WBChaseWidget.h \
- src/web/browser/WBDownloadManager.h \
- src/web/browser/WBModelMenu.h \
- src/web/browser/WBEditTableView.h \
- src/web/browser/WBSearchLineEdit.h \
- src/web/browser/WBSqueezeLabel.h \
- src/web/browser/WBTabWidget.h \
- src/web/browser/WBToolBarSearch.h \
- src/web/browser/WBUrlLineEdit.h \
- src/web/browser/WBWebView.h \
- src/web/browser/WBHistory.h \
- src/web/browser/WBWebTrapWebView.h \
- src/web/UBOEmbedParser.h
+ src/web/UBOEmbedParser.h\
+ src/web/browser/WBBrowserWindow.h \
+ src/web/browser/WBChaseWidget.h \
+ src/web/browser/WBDownloadManager.h \
+ src/web/browser/WBModelMenu.h \
+ src/web/browser/WBEditTableView.h \
+ src/web/browser/WBSearchLineEdit.h \
+ src/web/browser/WBSqueezeLabel.h \
+ src/web/browser/WBTabWidget.h \
+ src/web/browser/WBToolBarSearch.h \
+ src/web/browser/WBUrlLineEdit.h \
+ src/web/browser/WBWebView.h \
+ src/web/browser/WBHistory.h \
+ src/web/browser/WBWebTrapWebView.h
+
SOURCES += src/web/UBWebController.cpp \
src/web/UBTrapFlashController.cpp \
@@ -35,19 +36,21 @@ SOURCES += src/web/UBWebController.cpp \
src/web/UBWebPage.cpp \
src/web/UBWebPluginWidget.cpp \
src/web/UBRoutedMouseEventWebView.cpp \
- src/web/browser/WBBrowserWindow.cpp \
- src/web/browser/WBChaseWidget.cpp \
- src/web/browser/WBDownloadManager.cpp \
- src/web/browser/WBModelMenu.cpp \
- src/web/browser/WBEditTableView.cpp \
- src/web/browser/WBSearchLineEdit.cpp \
- src/web/browser/WBSqueezeLabel.cpp \
- src/web/browser/WBTabWidget.cpp \
- src/web/browser/WBToolBarSearch.cpp \
- src/web/browser/WBUrlLineEdit.cpp \
- src/web/browser/WBWebView.cpp \
- src/web/browser/WBHistory.cpp \
- src/web/browser/WBWebTrapWebView.cpp \
- src/web/UBOEmbedParser.cpp
+ src/web/UBOEmbedParser.cpp\
+ src/web/browser/WBBrowserWindow.cpp \
+ src/web/browser/WBChaseWidget.cpp \
+ src/web/browser/WBDownloadManager.cpp \
+ src/web/browser/WBModelMenu.cpp \
+ src/web/browser/WBEditTableView.cpp \
+ src/web/browser/WBSearchLineEdit.cpp \
+ src/web/browser/WBSqueezeLabel.cpp \
+ src/web/browser/WBTabWidget.cpp \
+ src/web/browser/WBToolBarSearch.cpp \
+ src/web/browser/WBUrlLineEdit.cpp \
+ src/web/browser/WBWebView.cpp \
+ src/web/browser/WBHistory.cpp \
+ src/web/browser/WBWebTrapWebView.cpp\
+
+