diff --git a/src/domain/UBGraphicsScene.cpp b/src/domain/UBGraphicsScene.cpp index e6dbdd1b..387c7f72 100644 --- a/src/domain/UBGraphicsScene.cpp +++ b/src/domain/UBGraphicsScene.cpp @@ -1480,15 +1480,18 @@ UBGraphicsTextItem* UBGraphicsScene::textForObjectName(const QString& pString, c //looking for a previous such item text for(int i=0; i < mFastAccessItems.count() && !found ; i += 1){ UBGraphicsTextItem* currentItem = dynamic_cast(mFastAccessItems.at(i)); - if(currentItem && currentItem->objectName() == objectName){ + if(currentItem && (currentItem->objectName() == objectName || currentItem->toPlainText() == pString)){ + // The second condition is necessary because the object name isn't stored. On reopeining the file we + // need another rule than the objectName textItem = currentItem; found=true; + if(currentItem->objectName() != objectName) + textItem->setObjectName(objectName); } } if(!textItem){ - textItem = addTextWithFont(pString,QPointF(0,0) ,64,"",true,false); + textItem = addTextWithFont(pString,QPointF(0,0) ,48,"",true,false); textItem->setObjectName(objectName); - textItem->Delegate()->setCanDuplicate(false); } textItem->setPlainText(pString); diff --git a/src/gui/UBTeacherGuideWidget.cpp b/src/gui/UBTeacherGuideWidget.cpp index b7022a73..77e3772d 100644 --- a/src/gui/UBTeacherGuideWidget.cpp +++ b/src/gui/UBTeacherGuideWidget.cpp @@ -829,7 +829,7 @@ void UBTeacherGuidePageZeroWidget::onActiveSceneChanged() QDateTime updatedDate = documentProxy->lastUpdate(); mpLastModifiedLabel->setText(tr("Updated the:\n") + updatedDate.toString(Qt::SystemLocaleShortDate)); loadData(); - UBApplication::boardController->activeScene()->textForObjectName(mpSessionTitle->text()); + updateSceneTitle(); } } @@ -873,6 +873,13 @@ void UBTeacherGuidePageZeroWidget::persistData() documentProxy->setMetaData(UBSettings::sessionLicence,mpLicenceBox->currentText()); } +void UBTeacherGuidePageZeroWidget::updateSceneTitle() +{ + QString sessionTitle = mpSessionTitle->text(); + if(!sessionTitle.isEmpty()) + UBApplication::boardController->activeScene()->textForObjectName(mpSessionTitle->text()); +} + void UBTeacherGuidePageZeroWidget::switchToMode(tUBTGZeroPageMode mode) { if(mode == tUBTGZeroPageMode_EDITION){ @@ -902,7 +909,7 @@ void UBTeacherGuidePageZeroWidget::switchToMode(tUBTGZeroPageMode mode) QString inputStyleSheet("QTextEdit { background: transparent; border: none;}"); mpModePushButton->show(); mpSessionTitle->setReadOnly(true); - UBApplication::boardController->activeScene()->textForObjectName(mpSessionTitle->text()); + updateSceneTitle(); mpSessionTitle->setStyleSheet(inputStyleSheet); mpSessionTitle->setTextColor(QColor(Qt::black)); QFont titleFont(QApplication::font().family(),14,1); diff --git a/src/gui/UBTeacherGuideWidget.h b/src/gui/UBTeacherGuideWidget.h index c8ed2574..81fb483f 100644 --- a/src/gui/UBTeacherGuideWidget.h +++ b/src/gui/UBTeacherGuideWidget.h @@ -135,6 +135,7 @@ private: void loadData(); void hideEvent(QHideEvent* event); bool eventFilter(QObject* object, QEvent* event); + void updateSceneTitle(); QVBoxLayout* mpLayout; QHBoxLayout* mpButtonTitleLayout;