first implementation of title on scene

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

@ -1473,6 +1473,30 @@ UBGraphicsTextItem* UBGraphicsScene::addText(const QString& pString, const QPoin
, 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
, int pointSize, const QString& fontFamily, bool bold, bool italic)

@ -133,6 +133,7 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
UBGraphicsAudioItem* addAudio(const QUrl& pAudioFileUrl, bool shouldPlayAsap, 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* textForObjectName(const QString& pString, const QString &objectName = "UBTGZeroPageSessionTitle");
UBGraphicsTextItem* addTextWithFont(const QString& pString, const QPointF& pTopLeft = QPointF(0, 0)
, int pointSize = -1, const QString& fontFamily = "", bool bold = false, bool italic = false);

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

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

Loading…
Cancel
Save