diff --git a/resources/sankore.qrc b/resources/sankore.qrc
index d81ac808..f94729e7 100644
--- a/resources/sankore.qrc
+++ b/resources/sankore.qrc
@@ -347,5 +347,10 @@
images/licenses/ccbyncsa.png
images/licenses/ccbynd.png
images/licenses/ccbysa.png
+ images/teacherGuide/audio.png
+ images/teacherGuide/image.png
+ images/teacherGuide/link.png
+ images/teacherGuide/movie.png
+ images/teacherGuide/w3c.png
diff --git a/resources/style.qss b/resources/style.qss
index e68f1f66..38eeecbc 100644
--- a/resources/style.qss
+++ b/resources/style.qss
@@ -3,7 +3,8 @@ QWidget#documentNavigator,
QWidget#UBLibPathViewer,
QWidget#UBLibNavigatorWidget,
QWidget#UBLibItemProperties,
-QWidget#UBDownloadWidget
+QWidget#UBDownloadWidget,
+QWidget#UBTeacherGuideWidget
{
background: #EEEEEE;
border-radius: 10px;
@@ -41,9 +42,11 @@ QLabel#DockPaletteWidgetTitle
font-weight:bold;
}
-QLineEdit#DockPaletteWidgetLineEdit
+QLineEdit#UBTGLineEdit,
+QLabel#UBTGMediaDropMeLabel
{
background: white;
+ border: 1 solid #999999;
border-radius : 10px;
padding: 2px;
}
@@ -200,4 +203,59 @@ QSlider::groove::horizontal
height:10px;
border-radius:5px;
border:1px solid #555555;
-}
\ No newline at end of file
+}
+
+QLabel#UBTGEditionDocumentTitle
+{
+ color: black;
+ font-size : 14px;
+ font-weight:bold;
+}
+
+QLabel#UBTGPresentationDocumentTitle
+{
+ color: black;
+ font-size : 12px;
+ font-weight:bold;
+}
+
+QLabel#UBTGEditionPageNumberLabel
+{
+ color: black;
+ font-size : 12px;
+ font-weight:bold;
+}
+
+QLabel#UBTGPresentationPageNumberLabel
+{
+ color: black;
+ font-size : 12px;
+}
+
+UBTGAdaptableText#UBTGEditionPageTitle,
+UBTGAdaptableText#UBTGEditionComment
+{
+ color: black;
+ font-size : 12px;
+}
+
+UBTGAdaptableText#UBTGPresentationPageTitle
+{
+ color: black;
+ font-size:16px;
+ font-weight:bold;
+ border : none;
+}
+
+UBTGAdaptableText#UBTGPresentationComment
+{
+ color: black;
+ font-size:12px;
+ border : none;
+}
+
+QFrame#UBTGEditionSeparator,
+QFrame#UBTGPresentationSepartor
+{
+ background-color: #cccccc;
+}
diff --git a/src/gui/UBTGWidgetTreeDelegate.cpp b/src/gui/UBTGWidgetTreeDelegate.cpp
new file mode 100644
index 00000000..928beac9
--- /dev/null
+++ b/src/gui/UBTGWidgetTreeDelegate.cpp
@@ -0,0 +1,34 @@
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include "UBTGWidgetTreeDelegate.h"
+
+UBTGWidgetTreeDelegate::UBTGWidgetTreeDelegate(QObject *parent) :
+ QStyledItemDelegate(parent)
+{
+ //NOOP
+}
+
+void UBTGWidgetTreeDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const
+{
+ if(index.data(Qt::UserRole) != eUBTGAddSubItemWidgetType_None){
+ painter->setBackgroundMode(Qt::OpaqueMode);
+ painter->setBackground(QBrush(QColor(Qt::red)));
+ QStyleOptionButton styleButton;
+ styleButton.text = "pipo";
+ styleButton.rect = option.rect;
+ QApplication::style()->drawControl(QStyle::CE_PushButtonLabel,&styleButton,painter);
+ }
+ else
+ QStyledItemDelegate::paint(painter,option,index);
+}
+
+QSize UBTGWidgetTreeDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
+{
+ QSize size = QStyledItemDelegate::sizeHint(option,index);
+ return size;
+}
diff --git a/src/gui/UBTGWidgetTreeDelegate.h b/src/gui/UBTGWidgetTreeDelegate.h
new file mode 100644
index 00000000..75343346
--- /dev/null
+++ b/src/gui/UBTGWidgetTreeDelegate.h
@@ -0,0 +1,35 @@
+#ifndef UBTGWIDGETTREEDELEGATE_H
+#define UBTGWIDGETTREEDELEGATE_H
+
+class QPainter;
+class QStyleOptionViewItem;
+class QModelIndex;
+
+#include
+
+
+typedef enum
+{
+ eUBTGAddSubItemWidgetType_None,
+ eUBTGAddSubItemWidgetType_Action ,
+ eUBTGAddSubItemWidgetType_Media,
+ eUBTGAddSubItemWidgetType_Url
+}eUBTGAddSubItemWidgetType;
+
+
+class UBTGWidgetTreeDelegate : public QStyledItemDelegate
+{
+ Q_OBJECT
+public:
+ explicit UBTGWidgetTreeDelegate(QObject *parent = 0);
+
+ virtual void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const;
+ virtual QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const;
+
+signals:
+
+public slots:
+
+};
+
+#endif // UBTGWIDGETTREEDELEGATE_H
diff --git a/src/gui/UBTeacherGuideWidget.cpp b/src/gui/UBTeacherGuideWidget.cpp
index f67c8d54..4fe76953 100644
--- a/src/gui/UBTeacherGuideWidget.cpp
+++ b/src/gui/UBTeacherGuideWidget.cpp
@@ -35,13 +35,7 @@
#include "web/UBWebController.h"
-typedef enum
-{
- eUBTGAddSubItemWidgetType_None,
- eUBTGAddSubItemWidgetType_Action ,
- eUBTGAddSubItemWidgetType_Media,
- eUBTGAddSubItemWidgetType_Url
-}eUBTGAddSubItemWidgetType;
+#define UBTG_SEPARATOR_FIXED_HEIGHT 3
/***************************************************************************
@@ -52,33 +46,52 @@ UBTeacherGuideEditionWidget::UBTeacherGuideEditionWidget(QWidget *parent, const
QWidget(parent)
, mpLayout(NULL)
, mpDocumentTitle(NULL)
+ , mpPageNumberLabel(NULL)
, mpPageTitle(NULL)
, mpComment(NULL)
+ , mpSeparator(NULL)
, mpTreeWidget(NULL)
, mpRootWidgetItem(NULL)
, mpAddAnActionItem(NULL)
, mpAddAMediaItem(NULL)
, mpAddALinkItem(NULL)
+ , mpTreeDelegate(NULL)
{
setObjectName(name);
mpLayout = new QVBoxLayout(this);
+ mpPageNumberLabel = new QLabel(this);
+ mpPageNumberLabel->setAlignment(Qt::AlignRight);
+ mpPageNumberLabel->setObjectName("UBTGEditionPageNumberLabel");
+ mpLayout->addWidget(mpPageNumberLabel);
// tree basic configuration
mpDocumentTitle = new QLabel(this);
- mpDocumentTitle->setText("title document");
- mpDocumentTitle->setStyleSheet( "QWidget {background-color: white}");
+ mpDocumentTitle->setText("Document title");
+ mpDocumentTitle->setObjectName("UBTGEditionDocumentTitle");
mpLayout->addWidget(mpDocumentTitle);
mpPageTitle = new UBTGAdaptableText(0,this);
+ mpPageTitle->setObjectName("UBTGEditionPageTitle");
+ mpPageTitle->setPlaceHolderText(tr("Type title here ..."));
mpLayout->addWidget(mpPageTitle);
mpComment = new UBTGAdaptableText(0,this);
+ mpComment->setObjectName("UBTGEditionComment");
+ mpComment->setPlaceHolderText(tr("Type comment here ..."));
mpLayout->addWidget(mpComment);
+ mpSeparator = new QFrame(this);
+ mpSeparator->setObjectName("UBTGEditionSeparator");
+ mpSeparator->setFixedHeight(UBTG_SEPARATOR_FIXED_HEIGHT);
+ mpLayout->addWidget(mpSeparator);
+
mpTreeWidget = new QTreeWidget(this);
mpLayout->addWidget(mpTreeWidget);
+ mpTreeDelegate = new UBTGWidgetTreeDelegate();
+
mpRootWidgetItem = mpTreeWidget->invisibleRootItem();
+ //mpTreeWidget->setItemDelegate(mpTreeDelegate);
mpTreeWidget->setRootIsDecorated(false);
mpTreeWidget->setIndentation(0);
mpTreeWidget->setDropIndicatorShown(false);
@@ -88,9 +101,10 @@ UBTeacherGuideEditionWidget::UBTeacherGuideEditionWidget(QWidget *parent, const
mpTreeWidget->header()->setStretchLastSection(false);
mpTreeWidget->header()->setResizeMode(0, QHeaderView::Stretch);
mpTreeWidget->header()->setResizeMode(1, QHeaderView::Fixed);
- mpTreeWidget->header()->setDefaultSectionSize(32);
+ mpTreeWidget->header()->setDefaultSectionSize(18);
connect(mpTreeWidget,SIGNAL(itemClicked(QTreeWidgetItem*,int)),this,SLOT(onAddItemClicked(QTreeWidgetItem*,int)));
+ connect(UBApplication::boardController,SIGNAL(activeSceneChanged()),this,SLOT(onActiveSceneChanged()));
mpAddAnActionItem = new UBAddItem(tr("Add an action"),eUBTGAddSubItemWidgetType_Action,mpTreeWidget);
mpAddAMediaItem = new UBAddItem(tr("Add a media"),eUBTGAddSubItemWidgetType_Media,mpTreeWidget);
@@ -104,15 +118,31 @@ UBTeacherGuideEditionWidget::UBTeacherGuideEditionWidget(QWidget *parent, const
UBTeacherGuideEditionWidget::~UBTeacherGuideEditionWidget()
{
DELETEPTR(mpDocumentTitle);
+ DELETEPTR(mpPageNumberLabel);
DELETEPTR(mpPageTitle);
DELETEPTR(mpComment);
+ DELETEPTR(mpSeparator);
DELETEPTR(mpAddAnActionItem);
DELETEPTR(mpAddAMediaItem);
DELETEPTR(mpAddALinkItem);
+ DELETEPTR(mpTreeDelegate);
DELETEPTR(mpTreeWidget)
DELETEPTR(mpLayout);
}
+void UBTeacherGuideEditionWidget::showEvent(QShowEvent* event)
+{
+ mpPageTitle->setFocus();
+ mpComment->setFocus();
+ setFocus();
+ QWidget::showEvent(event);
+}
+
+void UBTeacherGuideEditionWidget::onActiveSceneChanged()
+{
+ cleanData();
+ mpPageNumberLabel->setText(tr("Page: %0").arg(UBApplication::boardController->activeSceneIndex() + 1));
+}
void UBTeacherGuideEditionWidget::cleanData()
{
@@ -141,12 +171,12 @@ QVector UBTeacherGuideEditionWidget::getPageAndCommentData()
QVectorresult;
tUBGEElementNode* pageTitle = new tUBGEElementNode();
pageTitle->type = "pageTitle";
- pageTitle->attributes.insert("value",mpPageTitle->toPlainText());
+ pageTitle->attributes.insert("value",mpPageTitle->text());
result << pageTitle;
tUBGEElementNode* comment = new tUBGEElementNode();
comment->type = "comment";
- comment->attributes.insert("value",mpComment->toPlainText());
+ comment->attributes.insert("value",mpComment->text());
result << comment;
return result;
}
@@ -229,36 +259,58 @@ UBTeacherGuidePresentationWidget::UBTeacherGuidePresentationWidget(QWidget *pare
, mpComment(NULL)
, mpLayout(NULL)
, mpButtonTitleLayout(NULL)
- , mpDocumentTile(NULL)
+ , mpDocumentTitle(NULL)
+ , mpPageNumberLabel(NULL)
+ , mpSeparator(NULL)
, mpModePushButton(NULL)
, mpTreeWidget(NULL)
, mpRootWidgetItem(NULL)
, mpMediaSwitchItem(NULL)
{
setObjectName(name);
+
mpLayout = new QVBoxLayout(this);
+
+ mpPageNumberLabel = new QLabel(this);
+ mpPageNumberLabel->setAlignment(Qt::AlignRight);
+ mpPageNumberLabel->setObjectName("UBTGPresentationPageNumberLabel");
+
+ mpLayout->addWidget(mpPageNumberLabel);
+
mpButtonTitleLayout = new QHBoxLayout(0);
mpModePushButton = new QPushButton(this);
mpModePushButton->setIcon(QIcon(":images/pencil.svg"));
+ mpModePushButton->setMaximumWidth(32);
+
connect(mpModePushButton,SIGNAL(clicked()),parentWidget(),SLOT(changeMode()));
- mpDocumentTile = new QLabel(this);
- mpDocumentTile->setText("Document title");
+ mpDocumentTitle = new QLabel(this);
+ mpDocumentTitle->setObjectName("UBTGPresentationDocumentTitle");
+ mpDocumentTitle->setText("Document title");
mpButtonTitleLayout->addWidget(mpModePushButton);
- mpButtonTitleLayout->addWidget(mpDocumentTile);
+ mpButtonTitleLayout->addWidget(mpDocumentTitle);
mpLayout->addLayout(mpButtonTitleLayout);
mpPageTitle = new UBTGAdaptableText(0,this);
+ mpPageTitle->setObjectName("UBTGPresentationPageTitle");
mpPageTitle->setReadOnly(true);
+ mpPageTitle->setStyleSheet("background-color:transparent");
mpLayout->addWidget(mpPageTitle);
mpComment = new UBTGAdaptableText(0,this);
+ mpComment->setObjectName("UBTGPresentationComment");
mpComment->setReadOnly(true);
+ mpComment->setStyleSheet("background-color:transparent");
mpLayout->addWidget(mpComment);
+ mpSeparator = new QFrame(this);
+ mpSeparator->setFixedHeight(UBTG_SEPARATOR_FIXED_HEIGHT);
+ mpSeparator->setObjectName("UBTGPresentationSepartor");
+ mpLayout->addWidget(mpSeparator);
+
mpTreeWidget = new QTreeWidget(this);
mpLayout->addWidget(mpTreeWidget);
@@ -268,31 +320,55 @@ UBTeacherGuidePresentationWidget::UBTeacherGuidePresentationWidget(QWidget *pare
mpTreeWidget->setDropIndicatorShown(false);
mpTreeWidget->header()->close();
mpTreeWidget->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
-// mpTreeWidget->setColumnCount(1);
connect(mpTreeWidget,SIGNAL(itemClicked(QTreeWidgetItem*,int)),this,SLOT(onAddItemClicked(QTreeWidgetItem*,int)));
-
+ connect(UBApplication::boardController,SIGNAL(activeSceneChanged()),this,SLOT(onActiveSceneChanged()));
}
UBTeacherGuidePresentationWidget::~UBTeacherGuidePresentationWidget()
{
DELETEPTR(mpComment);
DELETEPTR(mpPageTitle);
+ DELETEPTR(mpPageNumberLabel);
+ DELETEPTR(mpSeparator);
DELETEPTR(mpMediaSwitchItem);
DELETEPTR(mpModePushButton);
- DELETEPTR(mpDocumentTile);
+ DELETEPTR(mpDocumentTitle);
DELETEPTR(mpButtonTitleLayout);
DELETEPTR(mpTreeWidget);
DELETEPTR(mpLayout);
}
+void UBTeacherGuidePresentationWidget::cleanData()
+{
+ mpPageTitle->showText("");
+ mpComment->showText("");
+ //tree clean
+ QList itemToRemove = mpRootWidgetItem->takeChildren();
+ foreach(QTreeWidgetItem* eachItem, itemToRemove){
+ DELETEPTR(eachItem);
+ }
+ // the mpMediaSwitchItem is deleted by the previous loop but the pointer is not set to zero
+ mpMediaSwitchItem = NULL;
+}
+
+void UBTeacherGuidePresentationWidget::onActiveSceneChanged()
+{
+ cleanData();
+ mpPageNumberLabel->setText(tr("Page: %0").arg(UBApplication::boardController->activeSceneIndex() + 1));
+}
+
void UBTeacherGuidePresentationWidget::createMediaButtonItem()
{
if(!mpMediaSwitchItem){
//create the media button
mpMediaSwitchItem = new QTreeWidgetItem(mpRootWidgetItem);
- mpMediaSwitchItem->setIcon(0,QIcon(":images/plus.svg"));
+ //mpMediaSwitchItem->setIcon(0,QIcon(":images/plus.svg"));
+ mpMediaSwitchItem->setText(0,"+");
mpMediaSwitchItem->setExpanded(false);
mpMediaSwitchItem->setData(0,tUBTGTreeWidgetItemRole_HasAnAction,tUBTGActionAssociateOnClickItem_EXPAND);
+ mpMediaSwitchItem->setData(0,Qt::BackgroundRole,QVariant(QColor(200,200,200)));
+ mpMediaSwitchItem->setData(0,Qt::FontRole, QVariant(QFont(QApplication::font().family(),16)));
+ mpMediaSwitchItem->setData(0,Qt::TextAlignmentRole,QVariant(Qt::AlignCenter));
mpRootWidgetItem->addChild(mpMediaSwitchItem);
}
}
@@ -300,13 +376,7 @@ void UBTeacherGuidePresentationWidget::createMediaButtonItem()
void UBTeacherGuidePresentationWidget::showData(QVector data)
{
- //tree clean
- QList itemToRemove = mpRootWidgetItem->takeChildren();
- foreach(QTreeWidgetItem* eachItem, itemToRemove){
- DELETEPTR(eachItem);
- }
- // the mpMediaSwitchItem is deleted by the previous loop but the pointer is not set to zero
- mpMediaSwitchItem = NULL;
+ cleanData();
foreach(tUBGEElementNode* element, data){
if(element->type == "pageTitle")
@@ -316,20 +386,23 @@ void UBTeacherGuidePresentationWidget::showData(QVector data)
else if(element->type == "action"){
QTreeWidgetItem* newWidgetItem = new QTreeWidgetItem(mpRootWidgetItem);
newWidgetItem->setText(0,element->attributes.value("task"));
- QColor color = element->attributes.value("owner").toInt()?QColor().red():QColor().green();
- newWidgetItem->setTextColor(0,color);
+ QColor color = element->attributes.value("owner").toInt() == 0 ? QColor(Qt::red):QColor(Qt::green);
+ newWidgetItem->setData(0,Qt::ForegroundRole,QBrush(color));
newWidgetItem->setData(0,tUBTGTreeWidgetItemRole_HasAnAction,tUBTGActionAssociateOnClickItem_NONE);
+ newWidgetItem->setData(0,Qt::FontRole, QVariant(QFont(QApplication::font().family(),11)));
mpRootWidgetItem->addChild(newWidgetItem);
}
else if(element->type == "media"){
createMediaButtonItem();
QTreeWidgetItem* newWidgetItem = new QTreeWidgetItem(mpMediaSwitchItem);
+ newWidgetItem->setIcon(0,QIcon(":images/teacherGuide/"+ element->attributes.value("mediaType") +".png"));
newWidgetItem->setText(0,element->attributes.value("title"));
newWidgetItem->setData(0,tUBTGTreeWidgetItemRole_HasAnAction,tUBTGActionAssociateOnClickItem_MEDIA);
+ newWidgetItem->setData(0,Qt::FontRole, QVariant(QFont(QApplication::font().family(),11)));
mpRootWidgetItem->addChild(newWidgetItem);
QTreeWidgetItem* mediaItem = new QTreeWidgetItem(newWidgetItem);
- mediaItem->setText(0,element->attributes.value("title"));
+ //mediaItem->setBackground(0,QBrush(QColor("#EEEEEF")));
mediaItem->setData(0,tUBTGTreeWidgetItemRole_HasAnAction,tUBTGActionAssociateOnClickItem_NONE);
UBTGMediaWidget* mediaWidget = new UBTGMediaWidget(element->attributes.value("relativePath"),newWidgetItem);
newWidgetItem->setExpanded(false);
@@ -338,13 +411,14 @@ void UBTeacherGuidePresentationWidget::showData(QVector data)
else if(element->type == "link"){
createMediaButtonItem();
QTreeWidgetItem* newWidgetItem = new QTreeWidgetItem(mpMediaSwitchItem);
+ newWidgetItem->setIcon(0,QIcon(":images/teacherGuide/link.png"));
newWidgetItem->setText(0,element->attributes.value("title"));
newWidgetItem->setData(0,tUBTGTreeWidgetItemRole_HasAnAction,tUBTGActionAssociateOnClickItem_URL);
newWidgetItem->setData(0,tUBTGTreeWidgetItemRole_HasAnUrl,QVariant(element->attributes.value("url")));
+ newWidgetItem->setData(0,Qt::FontRole, QVariant(QFont(QApplication::font().family(),11)));
mpRootWidgetItem->addChild(newWidgetItem);
}
}
-
}
void UBTeacherGuidePresentationWidget::onAddItemClicked(QTreeWidgetItem* widget, int column)
@@ -355,6 +429,10 @@ void UBTeacherGuidePresentationWidget::onAddItemClicked(QTreeWidgetItem* widget,
{
case tUBTGActionAssociateOnClickItem_EXPAND:
widget->setExpanded(!widget->isExpanded());
+ if(widget->isExpanded())
+ mpMediaSwitchItem->setText(0,"-");
+ else
+ mpMediaSwitchItem->setText(0,"+");
break;
case tUBTGActionAssociateOnClickItem_URL:
widget->data(column,tUBTGTreeWidgetItemRole_HasAnUrl).toString();
@@ -377,12 +455,13 @@ UBTeacherGuideWidget::UBTeacherGuideWidget(QWidget *parent, const char *name): Q
, mpPresentationWidget(NULL)
{
setObjectName(name);
+
mpEditionWidget = new UBTeacherGuideEditionWidget(this);
addWidget(mpEditionWidget);
mpPresentationWidget = new UBTeacherGuidePresentationWidget(this);
addWidget(mpPresentationWidget);
- setCurrentWidget(mpEditionWidget);
+ setCurrentWidget(mpPresentationWidget);
connect(UBApplication::boardController->controlView(),SIGNAL(clickOnBoard()),this,SLOT(showPresentationMode()));
connectToStylusPalette();
}
@@ -405,8 +484,8 @@ void UBTeacherGuideWidget::connectToStylusPalette()
void UBTeacherGuideWidget::showPresentationMode()
{
if(currentWidget()!=mpPresentationWidget){
- currentData = mpEditionWidget->getData();
- mpPresentationWidget->showData(currentData);
+ mCurrentData = mpEditionWidget->getData();
+ mpPresentationWidget->showData(mCurrentData);
setCurrentWidget(mpPresentationWidget);
}
}
diff --git a/src/gui/UBTeacherGuideWidget.h b/src/gui/UBTeacherGuideWidget.h
index 076d5d26..fc984d4a 100644
--- a/src/gui/UBTeacherGuideWidget.h
+++ b/src/gui/UBTeacherGuideWidget.h
@@ -23,7 +23,7 @@ class QVBoxLayout;
class QPushButton;
#include "UBTeacherGuideWidgetsTools.h"
-
+#include "UBTGWidgetTreeDelegate.h"
/***************************************************************************
* class UBTeacherGuideEditionWidget *
@@ -39,6 +39,8 @@ public:
public slots:
void onAddItemClicked(QTreeWidgetItem* widget, int column);
+ void onActiveSceneChanged();
+ void showEvent(QShowEvent* event);
private:
QList getChildrenList(QTreeWidgetItem* widgetItem);
@@ -46,13 +48,16 @@ private:
QVBoxLayout* mpLayout;
QLabel* mpDocumentTitle;
+ QLabel* mpPageNumberLabel;
UBTGAdaptableText* mpPageTitle;
UBTGAdaptableText* mpComment;
+ QFrame* mpSeparator;
QTreeWidget* mpTreeWidget;
QTreeWidgetItem* mpRootWidgetItem;
UBAddItem* mpAddAnActionItem;
UBAddItem* mpAddAMediaItem;
UBAddItem* mpAddALinkItem;
+ UBTGWidgetTreeDelegate* mpTreeDelegate;
};
@@ -67,9 +72,11 @@ public:
explicit UBTeacherGuidePresentationWidget(QWidget* parent, const char* name = "UBTeacherGuidePresentationName");
~UBTeacherGuidePresentationWidget();
void showData(QVectordata);
+ void cleanData();
public slots:
void onAddItemClicked(QTreeWidgetItem* widget, int column);
+ void onActiveSceneChanged();
private:
void createMediaButtonItem();
@@ -78,7 +85,9 @@ private:
UBTGAdaptableText* mpComment;
QVBoxLayout* mpLayout;
QHBoxLayout* mpButtonTitleLayout;
- QLabel* mpDocumentTile;
+ QLabel* mpDocumentTitle;
+ QLabel* mpPageNumberLabel;
+ QFrame* mpSeparator;
QPushButton* mpModePushButton;
QTreeWidget* mpTreeWidget;
QTreeWidgetItem* mpRootWidgetItem;
@@ -107,7 +116,7 @@ public slots:
private:
UBTeacherGuideEditionWidget* mpEditionWidget;
UBTeacherGuidePresentationWidget* mpPresentationWidget;
- QVectorcurrentData;
+ QVectormCurrentData;
};
diff --git a/src/gui/UBTeacherGuideWidgetsTools.cpp b/src/gui/UBTeacherGuideWidgetsTools.cpp
index 60c9f89b..b101113b 100644
--- a/src/gui/UBTeacherGuideWidgetsTools.cpp
+++ b/src/gui/UBTeacherGuideWidgetsTools.cpp
@@ -23,8 +23,10 @@
#include
#include
#include
+#include
#include "UBTeacherGuideWidgetsTools.h"
+#include "UBTGWidgetTreeDelegate.h"
#include "globals/UBGlobals.h"
@@ -40,6 +42,9 @@ UBAddItem::UBAddItem(const QString &string, int addSubItemWidgetType, QTreeWidge
setText(0,string);
setData(0,Qt::UserRole,QVariant(addSubItemWidgetType));
setData(1,Qt::UserRole,QVariant(addSubItemWidgetType));
+ setData(0,Qt::BackgroundRole,QVariant(QColor(200,200,200)));
+ setData(1,Qt::BackgroundRole,QVariant(QColor(200,200,200)));
+ setData(0,Qt::FontRole,QVariant(QFont(QApplication::font().family(),12)));
}
UBAddItem::~UBAddItem()
@@ -56,20 +61,21 @@ UBTGActionWidget::UBTGActionWidget(QTreeWidgetItem* widget, QWidget* parent, con
, mpTask(NULL)
{
setObjectName(name);
+ SET_STYLE_SHEET();
mpLayout = new QVBoxLayout(this);
mpOwner = new QComboBox(this);
+ mpOwner->setObjectName("DockPaletteWidgetComboBox");
+ mpOwner->setMinimumHeight(22);
QStringList qslOwner;
qslOwner << tr("Teacher") << tr("Student");
mpOwner->insertItems(0,qslOwner);
mpOwner->setCurrentIndex(0);
- connect(mpOwner,SIGNAL(currentIndexChanged(int)),this,SLOT(onOwnerChange(int)));
mpTask = new UBTGAdaptableText(widget,this);
mpTask->setAcceptRichText(true);
mpTask->setTextColor(QColor().green());
mpTask->setObjectName("ActionWidgetTaskTextEdit");
mpLayout->addWidget(mpOwner,0);
mpLayout->addWidget(mpTask,1);
- setStyleSheet( "QWidget {background-color: white}");
}
UBTGActionWidget::~UBTGActionWidget()
@@ -79,20 +85,12 @@ UBTGActionWidget::~UBTGActionWidget()
DELETEPTR(mpLayout);
}
-void UBTGActionWidget::onOwnerChange(int ownerId)
-{
- if(ownerId == 0)
- mpTask->setTextColor(QColor().red());
- else
- mpTask->setTextColor(QColor().green());
-}
-
tUBGEElementNode* UBTGActionWidget::saveData()
{
tUBGEElementNode* result = new tUBGEElementNode();
result->type = "action";
- result->attributes.insert("owner",QString(mpOwner->currentIndex()));
- result->attributes.insert("task",mpTask->toPlainText());
+ result->attributes.insert("owner",QString("%0").arg(mpOwner->currentIndex()));
+ result->attributes.insert("task",mpTask->text());
return result;
}
@@ -102,17 +100,66 @@ tUBGEElementNode* UBTGActionWidget::saveData()
UBTGAdaptableText::UBTGAdaptableText(QTreeWidgetItem* widget, QWidget* parent, const char* name):QTextEdit(parent)
, mBottomMargin(5)
, mpTreeWidgetItem(widget)
+ , mMinimumHeight(20)
+ , mHasPlaceHolder(false)
{
setObjectName(name);
- setStyleSheet( "QWidget {background-color: white}");
+ setStyleSheet( "QWidget {background: white; border:1 solid #999999; border-radius : 10px; padding: 2px;}");
connect(this,SIGNAL(textChanged()),this,SLOT(onTextChanged()));
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+ setMinimumHeight(mMinimumHeight);
+}
+
+void UBTGAdaptableText::setPlaceHolderText(QString text)
+{
+
+ // the space addition is to make this string unique and check against it to know
+ // if we are talking about a typed string or the placeholder string
+ mPlaceHolderText = text + " ";
+ setTextColor(QColor(Qt::lightGray));
+ setText(mPlaceHolderText);
+ onTextChanged();
+ if(isHidden())
+ show();
+ mHasPlaceHolder = true;
+}
+
+void UBTGAdaptableText::focusInEvent(QFocusEvent *e)
+{
+ if(mHasPlaceHolder && toPlainText() == mPlaceHolderText){
+ setText("");
+ setTextColor(QColor(Qt::black));
+ }
+
+ e->accept();
+}
+
+
+void UBTGAdaptableText::focusOutEvent(QFocusEvent *e)
+{
+ if(mHasPlaceHolder && toPlainText().length() == 0){
+ setTextColor(QColor(Qt::lightGray));
+ setText(mPlaceHolderText);
+ }
+ e->accept();
+}
+
+QString UBTGAdaptableText::text()
+{
+ QString result = toPlainText();
+ if(mHasPlaceHolder && result == mPlaceHolderText)
+ return "";
+
+ return result;
}
void UBTGAdaptableText::onTextChanged()
{
- setFixedHeight(document()->size().height()+mBottomMargin);
+ if(document()->size().height() < mMinimumHeight)
+ setFixedHeight(mMinimumHeight);
+ else
+ setFixedHeight(document()->size().height()+mBottomMargin);
updateGeometry();
//to trig the widget item to resize it
if(mpTreeWidgetItem){
@@ -120,7 +167,6 @@ void UBTGAdaptableText::onTextChanged()
mpTreeWidgetItem->setExpanded(true);
setFocus();
}
-
}
void UBTGAdaptableText::showText(const QString & text)
@@ -131,6 +177,8 @@ void UBTGAdaptableText::showText(const QString & text)
hide();
setReadOnly(true);
onTextChanged();
+ if(isHidden())
+ show();
}
void UBTGAdaptableText::bottomMargin(int newValue)
@@ -155,8 +203,8 @@ UBTGMediaWidget::UBTGMediaWidget(QTreeWidgetItem* widget, QWidget* parent,const
, mIsPresentationMode(false)
{
setObjectName(name);
- setStyleSheet( "QWidget {background-color: white}");
mpDropMeWidget = new QLabel();
+ mpDropMeWidget->setObjectName("UBTGMediaDropMeLabel");
mpDropMeWidget->setText(tr("drop media here ..."));
mpDropMeWidget->setAlignment(Qt::AlignCenter);
setAcceptDrops(true);
@@ -176,6 +224,7 @@ UBTGMediaWidget::UBTGMediaWidget(QString relativePath, QTreeWidgetItem* widget,
, mpWebView(NULL)
, mRelativePath(relativePath)
, mIsPresentationMode(true)
+ , mMediaType("")
{
setObjectName(name);
setAcceptDrops(false);
@@ -202,8 +251,9 @@ tUBGEElementNode* UBTGMediaWidget::saveData()
return 0;
tUBGEElementNode* result = new tUBGEElementNode();
result->type = "media";
- result->attributes.insert("title",mpTitle->toPlainText());
+ result->attributes.insert("title",mpTitle->text());
result->attributes.insert("relativePath",mRelativePath);
+ result->attributes.insert("mediaType",mMediaType);
return result;
}
@@ -218,15 +268,20 @@ void UBTGMediaWidget::createWorkWidget(QString& path)
qDebug() << mimeType;
bool setMedia = true;
if(mimeType.contains("audio") || mimeType.contains("video")){
+ mMediaType = mimeType.contains("audio")? "audio":"movie";
mpMediaWidget = new UBMediaWidget(mimeType.contains("audio")?eMediaType_Audio:eMediaType_Video);
mpMediaWidget->setFile(path);
}
else if(mimeType.contains("image")){
+ mMediaType = "image";
mpMediaLabelWidget = new QLabel();
- mpMediaLabelWidget->setPixmap(QPixmap(QUrl(path).toLocalFile()));
+ QPixmap pixmap = QPixmap(QUrl(path).toLocalFile());
+ pixmap = pixmap.scaledToWidth(mpTreeWidgetItem->treeWidget()->size().width());
+ mpMediaLabelWidget->setPixmap(pixmap);
mpMediaLabelWidget->setScaledContents(true);
}
else if(mimeType.contains("application")){
+ mMediaType = "w3c";
mpWebView = new QWebView(0);
mpWebView->setAcceptDrops(false);
mpWebView->settings()->setAttribute(QWebSettings::JavaEnabled, true);
@@ -258,6 +313,7 @@ void UBTGMediaWidget::createWorkWidget(QString& path)
mpLayout->addWidget(mpMediaLabelWidget);
}
else if (mpMediaWidget){
+ mpMediaWidget->setMaximumHeight(mpTreeWidgetItem->treeWidget()->size().width());
mpMediaWidget->setParent(mpWorkWidget);
mpLayout->addWidget(mpMediaWidget);
}
@@ -337,12 +393,14 @@ UBTGUrlWidget::UBTGUrlWidget(QWidget* parent, const char* name ):QWidget(parent)
, mpUrl(NULL)
{
setObjectName(name);
- setStyleSheet( "QWidget {background-color: white}");
-
+ SET_STYLE_SHEET();
mpLayout = new QVBoxLayout(this);
- mpTitle = new QLineEdit("title",this);
- mpUrl = new QLineEdit("url",this);
-
+ mpTitle = new QLineEdit(this);
+ mpTitle->setObjectName("UBTGLineEdit");
+ mpTitle->setPlaceholderText(tr("Insert link title here..."));
+ mpUrl = new QLineEdit(this);
+ mpUrl->setObjectName("UBTGLineEdit");
+ mpUrl->setPlaceholderText("http://");
mpLayout->addWidget(mpTitle);
mpLayout->addWidget(mpUrl);
}
diff --git a/src/gui/UBTeacherGuideWidgetsTools.h b/src/gui/UBTeacherGuideWidgetsTools.h
index 40da7b1d..1383b522 100644
--- a/src/gui/UBTeacherGuideWidgetsTools.h
+++ b/src/gui/UBTeacherGuideWidgetsTools.h
@@ -65,17 +65,18 @@ public slots:
class UBTGActionWidget : public QWidget, public iUBTGSavableData
{
Q_OBJECT
+
public:
- explicit UBTGActionWidget(QTreeWidgetItem* widget, QWidget* parent = 0,const char* name = "UBActionWidget");
+ explicit UBTGActionWidget(QTreeWidgetItem* widget, QWidget* parent = 0,const char* name = "UBTGActionWidget");
~UBTGActionWidget();
void update();
tUBGEElementNode* saveData();
-public slots:
- void onOwnerChange(int ownerId);
+
private:
QVBoxLayout* mpLayout;
QComboBox* mpOwner;
UBTGAdaptableText* mpTask;
+
protected:
QTreeWidgetItem* mpTreeWidgetItem;
};
@@ -88,13 +89,21 @@ public:
explicit UBTGAdaptableText(QTreeWidgetItem* widget = 0, QWidget *parent = 0, const char* name = "UBTGAdaptableText");
void showText(const QString & text);
void bottomMargin(int newValue);
-signals:
+ void setPlaceHolderText(QString text);
+ QString text();
public slots:
void onTextChanged();
+
+protected:
+ void focusInEvent(QFocusEvent *e);
+ void focusOutEvent(QFocusEvent *e);
private:
int mBottomMargin;
QTreeWidgetItem* mpTreeWidgetItem;
+ int mMinimumHeight;
+ bool mHasPlaceHolder;
+ QString mPlaceHolderText;
};
@@ -106,10 +115,12 @@ public:
UBTGMediaWidget(QString relativePath, QTreeWidgetItem* widget = 0, QWidget* parent = 0, const char* name = "UBTGMediaWidget");
~UBTGMediaWidget();
tUBGEElementNode* saveData();
+
protected:
void dragEnterEvent(QDragEnterEvent* event);
void dropEvent(QDropEvent* event);
void mousePressEvent(QMouseEvent* event);
+
private:
void parseMimeData(const QMimeData* pMimeData);
void createWorkWidget(QString& path);
@@ -125,6 +136,7 @@ private:
QWebView* mpWebView;
QString mRelativePath;
bool mIsPresentationMode;
+ QString mMediaType;
};
class UBTGUrlWidget : public QWidget , public iUBTGSavableData
diff --git a/src/gui/gui.pri b/src/gui/gui.pri
index 9191c598..264b9df3 100644
--- a/src/gui/gui.pri
+++ b/src/gui/gui.pri
@@ -50,7 +50,8 @@ HEADERS += src/gui/UBThumbnailView.h \
src/gui/UBDockTeacherGuideWidget.h \
src/gui/UBTeacherGuideWidget.h \
src/gui/UBTeacherGuideWidgetsTools.h \
- src/gui/UBTeacherGuideDelegate.h
+ src/gui/UBTeacherGuideDelegate.h \
+ src/gui/UBTGWidgetTreeDelegate.h
SOURCES += src/gui/UBThumbnailView.cpp \
src/gui/UBFloatingPalette.cpp \
@@ -103,7 +104,8 @@ SOURCES += src/gui/UBThumbnailView.cpp \
src/gui/UBDockTeacherGuideWidget.cpp \
src/gui/UBTeacherGuideWidget.cpp \
src/gui/UBTeacherGuideWidgetsTools.cpp \
- src/gui/UBTeacherGuideDelegate.cpp
+ src/gui/UBTeacherGuideDelegate.cpp \
+ src/gui/UBTGWidgetTreeDelegate.cpp
win32 {