first implementation of title on scene

preferencesAboutTextFull
Claudio Valerio 13 years ago
parent 66db929290
commit 9ed62340ac
  1. 42
      src/domain/UBGraphicsScene.cpp
  2. 9
      src/domain/UBGraphicsScene.h
  3. 46
      src/gui/UBTeacherGuideWidget.cpp
  4. 4
      src/gui/UBTeacherGuideWidget.h

@ -396,15 +396,15 @@ bool UBGraphicsScene::inputDevicePress(const QPointF& scenePos, const qreal& pre
mAddedItems.clear(); mAddedItems.clear();
mRemovedItems.clear(); mRemovedItems.clear();
if (UBDrawingController::drawingController()->mActiveRuler) if (UBDrawingController::drawingController()->mActiveRuler)
{ {
UBDrawingController::drawingController()->mActiveRuler->StartLine(scenePos, width); UBDrawingController::drawingController()->mActiveRuler->StartLine(scenePos, width);
} }
else else
{ {
moveTo(scenePos); moveTo(scenePos);
drawLineTo(scenePos, width, UBDrawingController::drawingController()->stylusTool() == UBStylusTool::Line); drawLineTo(scenePos, width, UBDrawingController::drawingController()->stylusTool() == UBStylusTool::Line);
} }
accepted = true; accepted = true;
} }
else if (currentTool == UBStylusTool::Eraser) else if (currentTool == UBStylusTool::Eraser)
@ -711,7 +711,7 @@ void UBGraphicsScene::drawLineTo(const QPointF &pEndPoint, const qreal &pWidth,
} }
} }
if (bLineStyle) if (bLineStyle)
{ {
QSetIterator<QGraphicsItem*> itItems(mAddedItems); QSetIterator<QGraphicsItem*> itItems(mAddedItems);
@ -736,7 +736,7 @@ void UBGraphicsScene::drawLineTo(const QPointF &pEndPoint, const qreal &pWidth,
mPreviousPolygonItems.append(polygonItem); mPreviousPolygonItems.append(polygonItem);
if (!bLineStyle) if (!bLineStyle)
{ {
mPreviousPoint = pEndPoint; mPreviousPoint = pEndPoint;
mPreviousWidth = pWidth; mPreviousWidth = pWidth;
@ -1473,6 +1473,30 @@ UBGraphicsTextItem* UBGraphicsScene::addText(const QString& pString, const QPoin
, UBSettings::settings()->isItalicFont()); , UBSettings::settings()->isItalicFont());
} }
UBGraphicsTextItem* UBGraphicsScene::textForObjectName(const QString& pString, const QString& objectName)
{
UBGraphicsTextItem* textItem = 0;
bool found = false;
//looking for a previous such item text
for(int i=0; i < mFastAccessItems.count() && !found ; i += 1){
UBGraphicsTextItem* currentItem = dynamic_cast<UBGraphicsTextItem*>(mFastAccessItems.at(i));
if(currentItem && currentItem->objectName() == objectName){
textItem = currentItem;
found=true;
}
}
if(!textItem){
textItem = addTextWithFont(pString,QPointF(0,0) ,64,"",true,false);
textItem->setObjectName(objectName);
textItem->Delegate()->setCanDuplicate(false);
}
textItem->setPlainText(pString);
textItem->adjustSize();
QSizeF size = textItem->size();
textItem->setPos(QPointF(-size.width()/2.0,-size.height()/2.0));
return textItem;
}
UBGraphicsTextItem* UBGraphicsScene::addTextWithFont(const QString& pString, const QPointF& pTopLeft UBGraphicsTextItem* UBGraphicsScene::addTextWithFont(const QString& pString, const QPointF& pTopLeft
, int pointSize, const QString& fontFamily, bool bold, bool italic) , int pointSize, const QString& fontFamily, bool bold, bool italic)
@ -1930,7 +1954,7 @@ void UBGraphicsScene::addMask(const QPointF &center)
UBGraphicsCurtainItem* curtain = new UBGraphicsCurtainItem(); // mem : owned and destroyed by the scene UBGraphicsCurtainItem* curtain = new UBGraphicsCurtainItem(); // mem : owned and destroyed by the scene
mTools << curtain; mTools << curtain;
addItem(curtain); addItem(curtain);
QRectF rect = UBApplication::boardController->activeScene()->normalizedSceneRect(); QRectF rect = UBApplication::boardController->activeScene()->normalizedSceneRect();
rect.setRect(center.x() - rect.width()/4, center.y() - rect.height()/4, rect.width()/2 , rect.height()/2); rect.setRect(center.x() - rect.width()/4, center.y() - rect.height()/4, rect.width()/2 , rect.height()/2);

@ -133,6 +133,7 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
UBGraphicsAudioItem* addAudio(const QUrl& pAudioFileUrl, bool shouldPlayAsap, const QPointF& pPos = QPointF(0, 0)); UBGraphicsAudioItem* addAudio(const QUrl& pAudioFileUrl, bool shouldPlayAsap, const QPointF& pPos = QPointF(0, 0));
UBGraphicsSvgItem* addSvg(const QUrl& pSvgFileUrl, const QPointF& pPos = QPointF(0, 0)); UBGraphicsSvgItem* addSvg(const QUrl& pSvgFileUrl, const QPointF& pPos = QPointF(0, 0));
UBGraphicsTextItem* addText(const QString& pString, const QPointF& pTopLeft = QPointF(0, 0)); UBGraphicsTextItem* addText(const QString& pString, const QPointF& pTopLeft = QPointF(0, 0));
UBGraphicsTextItem* textForObjectName(const QString& pString, const QString &objectName = "UBTGZeroPageSessionTitle");
UBGraphicsTextItem* addTextWithFont(const QString& pString, const QPointF& pTopLeft = QPointF(0, 0) UBGraphicsTextItem* addTextWithFont(const QString& pString, const QPointF& pTopLeft = QPointF(0, 0)
, int pointSize = -1, const QString& fontFamily = "", bool bold = false, bool italic = false); , int pointSize = -1, const QString& fontFamily = "", bool bold = false, bool italic = false);
@ -280,10 +281,10 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
mTools << item; mTools << item;
} }
const QPointF& previousPoint() const QPointF& previousPoint()
{ {
return mPreviousPoint; return mPreviousPoint;
} }
void setSelectedZLevel(QGraphicsItem *item); void setSelectedZLevel(QGraphicsItem *item);
void setOwnZlevel(QGraphicsItem *item); void setOwnZlevel(QGraphicsItem *item);

@ -43,6 +43,8 @@
#include "document/UBDocumentProxy.h" #include "document/UBDocumentProxy.h"
#include "document/UBDocumentController.h" #include "document/UBDocumentController.h"
#include "domain/UBGraphicsTextItem.h"
#define UBTG_SEPARATOR_FIXED_HEIGHT 3 #define UBTG_SEPARATOR_FIXED_HEIGHT 3
typedef enum typedef enum
@ -193,6 +195,8 @@ QDomElement* UBTeacherGuideEditionWidget::save(QDomElement* parentElement)
void UBTeacherGuideEditionWidget::onActiveSceneChanged() void UBTeacherGuideEditionWidget::onActiveSceneChanged()
{ {
load(UBSvgSubsetAdaptor::sTeacherGuideNode);
qDebug() << "UBSvgSubsetAdaptor::sTeacherGuideNode " << UBSvgSubsetAdaptor::sTeacherGuideNode;
mpPageNumberLabel->setText(tr("Page: %0").arg(UBApplication::boardController->currentPage())); mpPageNumberLabel->setText(tr("Page: %0").arg(UBApplication::boardController->currentPage()));
UBDocumentProxy* documentProxy = UBApplication::boardController->activeDocument(); UBDocumentProxy* documentProxy = UBApplication::boardController->activeDocument();
if(mpDocumentTitle) if(mpDocumentTitle)
@ -565,8 +569,10 @@ UBTeacherGuidePageZeroWidget::UBTeacherGuidePageZeroWidget(QWidget* parent, cons
, mpLicenceBox(NULL) , mpLicenceBox(NULL)
, mpLicenceIcon(NULL) , mpLicenceIcon(NULL)
, mpLicenceLayout(NULL) , mpLicenceLayout(NULL)
, mpSceneItemSessionTitle(NULL)
{ {
setObjectName(name); setObjectName(name);
QString chapterStyle("QLabel {font-size:16px; font-weight:bold;}");
mpLayout = new QVBoxLayout(this); mpLayout = new QVBoxLayout(this);
mpPageNumberLabel = new QLabel(this); mpPageNumberLabel = new QLabel(this);
@ -586,7 +592,6 @@ UBTeacherGuidePageZeroWidget::UBTeacherGuidePageZeroWidget(QWidget* parent, cons
mpSessionTitle = new UBTGAdaptableText(0,this,"UBTGSessionTitle"); mpSessionTitle = new UBTGAdaptableText(0,this,"UBTGSessionTitle");
mpSessionTitle->setPlaceHolderText(tr("Type session title here ...")); mpSessionTitle->setPlaceHolderText(tr("Type session title here ..."));
//mpSessionTitle->setObjectName("UBTGSessionTitle");
mpButtonTitleLayout->addWidget(mpSessionTitle); mpButtonTitleLayout->addWidget(mpSessionTitle);
mpLayout->addLayout(mpButtonTitleLayout); mpLayout->addLayout(mpButtonTitleLayout);
@ -599,6 +604,7 @@ UBTeacherGuidePageZeroWidget::UBTeacherGuidePageZeroWidget(QWidget* parent, cons
mpAuthorsLabel = new QLabel(this); mpAuthorsLabel = new QLabel(this);
mpAuthorsLabel->setObjectName("UBTGZeroPageEditionModeTitle"); mpAuthorsLabel->setObjectName("UBTGZeroPageEditionModeTitle");
mpAuthorsLabel->setText(tr("Author(s)")); mpAuthorsLabel->setText(tr("Author(s)"));
mpAuthorsLabel->setStyleSheet(chapterStyle);
mpLayout->addWidget(mpAuthorsLabel); mpLayout->addWidget(mpAuthorsLabel);
mpAuthors = new UBTGAdaptableText(0,this); mpAuthors = new UBTGAdaptableText(0,this);
@ -622,6 +628,7 @@ UBTeacherGuidePageZeroWidget::UBTeacherGuidePageZeroWidget(QWidget* parent, cons
mpGoalsLabel = new QLabel(this); mpGoalsLabel = new QLabel(this);
mpGoalsLabel->setObjectName("UBTGZeroPageEditionModeTitle"); mpGoalsLabel->setObjectName("UBTGZeroPageEditionModeTitle");
mpGoalsLabel->setText(tr("Goal(s)")); mpGoalsLabel->setText(tr("Goal(s)"));
mpGoalsLabel->setStyleSheet(chapterStyle);
mpLayout->addWidget(mpGoalsLabel); mpLayout->addWidget(mpGoalsLabel);
mpGoals = new UBTGAdaptableText(0,this); mpGoals = new UBTGAdaptableText(0,this);
@ -637,11 +644,13 @@ UBTeacherGuidePageZeroWidget::UBTeacherGuidePageZeroWidget(QWidget* parent, cons
mpIndexLabel = new QLabel(this); mpIndexLabel = new QLabel(this);
mpIndexLabel->setObjectName("UBTGZeroPageEditionModeTitle"); mpIndexLabel->setObjectName("UBTGZeroPageEditionModeTitle");
mpIndexLabel->setText(tr("Resource indexing")); mpIndexLabel->setText(tr("Resource indexing"));
mpIndexLabel->setStyleSheet(chapterStyle);
mpLayout->addWidget(mpIndexLabel); mpLayout->addWidget(mpIndexLabel);
mpKeywordsLabel = new QLabel(this); mpKeywordsLabel = new QLabel(this);
mpKeywordsLabel->setObjectName("UBTGZeroPageItemLabel"); mpKeywordsLabel->setObjectName("UBTGZeroPageItemLabel");
mpKeywordsLabel->setText(tr("Keywords:")); mpKeywordsLabel->setText(tr("Keywords:"));
mpKeywordsLabel->setStyleSheet(chapterStyle);
mpLayout->addWidget(mpKeywordsLabel); mpLayout->addWidget(mpKeywordsLabel);
mpKeywords = new UBTGAdaptableText(0,this); mpKeywords = new UBTGAdaptableText(0,this);
mpKeywords->setPlaceHolderText(tr("Type keywords here ...")); mpKeywords->setPlaceHolderText(tr("Type keywords here ..."));
@ -650,6 +659,7 @@ UBTeacherGuidePageZeroWidget::UBTeacherGuidePageZeroWidget(QWidget* parent, cons
mpSchoolLevelItemLabel = new QLabel(this); mpSchoolLevelItemLabel = new QLabel(this);
mpSchoolLevelItemLabel->setObjectName("UBTGZeroPageItemLabel"); mpSchoolLevelItemLabel->setObjectName("UBTGZeroPageItemLabel");
mpSchoolLevelItemLabel->setText(tr("Level:")); mpSchoolLevelItemLabel->setText(tr("Level:"));
mpSchoolLevelItemLabel->setStyleSheet(chapterStyle);
mpLayout->addWidget(mpSchoolLevelItemLabel); mpLayout->addWidget(mpSchoolLevelItemLabel);
mpSchoolLevelBox = new QComboBox(this); mpSchoolLevelBox = new QComboBox(this);
mpSchoolLevelBox->setObjectName("DockPaletteWidgetComboBox"); mpSchoolLevelBox->setObjectName("DockPaletteWidgetComboBox");
@ -661,6 +671,7 @@ UBTeacherGuidePageZeroWidget::UBTeacherGuidePageZeroWidget(QWidget* parent, cons
mpSchoolBranchItemLabel = new QLabel(this); mpSchoolBranchItemLabel = new QLabel(this);
mpSchoolBranchItemLabel->setObjectName("UBTGZeroPageItemLabel"); mpSchoolBranchItemLabel->setObjectName("UBTGZeroPageItemLabel");
mpSchoolBranchItemLabel->setText(tr("Branch:")); mpSchoolBranchItemLabel->setText(tr("Branch:"));
mpSchoolBranchItemLabel->setStyleSheet(chapterStyle);
mpLayout->addWidget(mpSchoolBranchItemLabel); mpLayout->addWidget(mpSchoolBranchItemLabel);
mpSchoolBranchBox = new QComboBox(this); mpSchoolBranchBox = new QComboBox(this);
mpSchoolBranchBox->setObjectName("DockPaletteWidgetComboBox"); mpSchoolBranchBox->setObjectName("DockPaletteWidgetComboBox");
@ -671,6 +682,7 @@ UBTeacherGuidePageZeroWidget::UBTeacherGuidePageZeroWidget(QWidget* parent, cons
mpSchoolTypeItemLabel = new QLabel(this); mpSchoolTypeItemLabel = new QLabel(this);
mpSchoolTypeItemLabel->setObjectName("UBTGZeroPageItemLabel"); mpSchoolTypeItemLabel->setObjectName("UBTGZeroPageItemLabel");
mpSchoolTypeItemLabel->setText(tr("Type:")); mpSchoolTypeItemLabel->setText(tr("Type:"));
mpSchoolTypeItemLabel->setStyleSheet(chapterStyle);
mpLayout->addWidget(mpSchoolTypeItemLabel); mpLayout->addWidget(mpSchoolTypeItemLabel);
mpSchoolTypeBox = new QComboBox(this); mpSchoolTypeBox = new QComboBox(this);
mpSchoolTypeBox->setObjectName("DockPaletteWidgetComboBox"); mpSchoolTypeBox->setObjectName("DockPaletteWidgetComboBox");
@ -685,7 +697,8 @@ UBTeacherGuidePageZeroWidget::UBTeacherGuidePageZeroWidget(QWidget* parent, cons
mpLicenceLabel = new QLabel(this); mpLicenceLabel = new QLabel(this);
mpLicenceLabel->setObjectName("UBTGZeroPageItemLabel"); mpLicenceLabel->setObjectName("UBTGZeroPageItemLabel");
mpLicenceLabel->setText(tr("Licence:")); mpLicenceLabel->setText(tr("Licence"));
mpLicenceLabel->setStyleSheet(chapterStyle);
mpLayout->addWidget(mpLicenceLabel); mpLayout->addWidget(mpLicenceLabel);
mpLicenceBox = new QComboBox(this); mpLicenceBox = new QComboBox(this);
mpLicenceBox->setObjectName("DockPaletteWidgetComboBox"); mpLicenceBox->setObjectName("DockPaletteWidgetComboBox");
@ -697,6 +710,8 @@ UBTeacherGuidePageZeroWidget::UBTeacherGuidePageZeroWidget(QWidget* parent, cons
mpLicenceLayout->addWidget(mpLicenceValueLabel); mpLicenceLayout->addWidget(mpLicenceValueLabel);
mpLayout->addLayout(mpLicenceLayout); mpLayout->addLayout(mpLicenceLayout);
mpLayout->addStretch(1); mpLayout->addStretch(1);
setLayout(mpLayout);
connect(UBApplication::boardController,SIGNAL(activeSceneChanged()), this, SLOT(onActiveSceneChanged())); connect(UBApplication::boardController,SIGNAL(activeSceneChanged()), this, SLOT(onActiveSceneChanged()));
fillComboBoxes(); fillComboBoxes();
} }
@ -810,10 +825,11 @@ void UBTeacherGuidePageZeroWidget::onActiveSceneChanged()
UBDocumentProxy* documentProxy = UBApplication::boardController->activeDocument(); UBDocumentProxy* documentProxy = UBApplication::boardController->activeDocument();
if(documentProxy && UBApplication::boardController->currentPage() == 0){ if(documentProxy && UBApplication::boardController->currentPage() == 0){
QDateTime creationDate = documentProxy->documentDate(); QDateTime creationDate = documentProxy->documentDate();
mpCreationLabel->setText(tr("Created the: ") + creationDate.toString(Qt::SystemLocaleShortDate)); mpCreationLabel->setText(tr("Created the:\n") + creationDate.toString(Qt::SystemLocaleShortDate));
QDateTime updatedDate = documentProxy->lastUpdate(); QDateTime updatedDate = documentProxy->lastUpdate();
mpLastModifiedLabel->setText(tr("Updated the: ") + updatedDate.toString(Qt::SystemLocaleShortDate)); mpLastModifiedLabel->setText(tr("Updated the:\n") + updatedDate.toString(Qt::SystemLocaleShortDate));
loadData(); loadData();
UBApplication::boardController->activeScene()->textForObjectName(mpSessionTitle->text());
} }
} }
@ -860,12 +876,18 @@ void UBTeacherGuidePageZeroWidget::persistData()
void UBTeacherGuidePageZeroWidget::switchToMode(tUBTGZeroPageMode mode) void UBTeacherGuidePageZeroWidget::switchToMode(tUBTGZeroPageMode mode)
{ {
if(mode == tUBTGZeroPageMode_EDITION){ if(mode == tUBTGZeroPageMode_EDITION){
QString inputStyleSheet("QTextEdit { background: white; border-radius: 10px; border: 2px;}");
mpModePushButton->hide(); mpModePushButton->hide();
mpSessionTitle->setReadOnly(false); mpSessionTitle->setReadOnly(false);
mpSessionTitle->setObjectName("UBTGEditionModeSessionTitle"); mpSessionTitle->setStyleSheet(inputStyleSheet);
QFont titleFont(QApplication::font().family(),11,-1);
mpSessionTitle->document()->setDefaultFont(titleFont);
mpAuthors->setReadOnly(false); mpAuthors->setReadOnly(false);
mpAuthors->setStyleSheet(inputStyleSheet);
mpGoals->setReadOnly(false); mpGoals->setReadOnly(false);
mpGoals->setStyleSheet(inputStyleSheet);
mpKeywords->setReadOnly(false); mpKeywords->setReadOnly(false);
mpKeywords->setStyleSheet(inputStyleSheet);
mpSchoolLevelValueLabel->hide(); mpSchoolLevelValueLabel->hide();
mpSchoolLevelBox->show(); mpSchoolLevelBox->show();
mpSchoolBranchValueLabel->hide(); mpSchoolBranchValueLabel->hide();
@ -877,12 +899,23 @@ void UBTeacherGuidePageZeroWidget::switchToMode(tUBTGZeroPageMode mode)
mpLicenceBox->show(); mpLicenceBox->show();
} }
else{ else{
QString inputStyleSheet("QTextEdit { background: transparent; border: none;}");
mpModePushButton->show(); mpModePushButton->show();
mpSessionTitle->setReadOnly(true); mpSessionTitle->setReadOnly(true);
mpSessionTitle->setObjectName("UBTGPresentationSessionTitle"); UBApplication::boardController->activeScene()->textForObjectName(mpSessionTitle->text());
mpSessionTitle->setStyleSheet(inputStyleSheet);
mpSessionTitle->setTextColor(QColor(Qt::black));
QFont titleFont(QApplication::font().family(),14,1);
mpSessionTitle->document()->setDefaultFont(titleFont);
mpAuthors->setReadOnly(true); mpAuthors->setReadOnly(true);
mpAuthors->setStyleSheet(inputStyleSheet);
mpAuthors->setTextColor(QColor(Qt::black));
mpGoals->setReadOnly(true); mpGoals->setReadOnly(true);
mpGoals->setStyleSheet(inputStyleSheet);
mpGoals->setTextColor(QColor(Qt::black));
mpKeywords->setReadOnly(true); mpKeywords->setReadOnly(true);
mpKeywords->setStyleSheet(inputStyleSheet);
mpKeywords->setTextColor(QColor(Qt::black));
mpSchoolLevelValueLabel->setText(mpSchoolLevelBox->currentText()); mpSchoolLevelValueLabel->setText(mpSchoolLevelBox->currentText());
mpSchoolLevelValueLabel->show(); mpSchoolLevelValueLabel->show();
mpSchoolLevelBox->hide(); mpSchoolLevelBox->hide();
@ -902,6 +935,7 @@ void UBTeacherGuidePageZeroWidget::switchToMode(tUBTGZeroPageMode mode)
mpLicenceBox->hide(); mpLicenceBox->hide();
persistData(); persistData();
} }
update();
} }
QVector<tUBGEElementNode*> UBTeacherGuidePageZeroWidget::getData() QVector<tUBGEElementNode*> UBTeacherGuidePageZeroWidget::getData()

@ -22,6 +22,7 @@ class QLabel;
class QVBoxLayout; class QVBoxLayout;
class QPushButton; class QPushButton;
class UBDocumentProxy; class UBDocumentProxy;
class UBGraphicsTextItem;
#include "UBTeacherGuideWidgetsTools.h" #include "UBTeacherGuideWidgetsTools.h"
@ -175,6 +176,8 @@ private:
QLabel* mpLicenceIcon; QLabel* mpLicenceIcon;
QHBoxLayout* mpLicenceLayout; QHBoxLayout* mpLicenceLayout;
UBGraphicsTextItem* mpSceneItemSessionTitle;
QMap<QString,QString> mGradeLevelsMap; QMap<QString,QString> mGradeLevelsMap;
QMap<QString,QStringList> mSubjects; QMap<QString,QStringList> mSubjects;
@ -205,7 +208,6 @@ private:
UBTeacherGuideEditionWidget* mpEditionWidget; UBTeacherGuideEditionWidget* mpEditionWidget;
UBTeacherGuidePresentationWidget* mpPresentationWidget; UBTeacherGuidePresentationWidget* mpPresentationWidget;
QVector<tUBGEElementNode*>mCurrentData; QVector<tUBGEElementNode*>mCurrentData;
}; };
#endif // UBTEACHERGUIDEWIDGET_H #endif // UBTEACHERGUIDEWIDGET_H

Loading…
Cancel
Save