From a725bc80535bb6b1c8844fcad30e7c1b70c66ffe Mon Sep 17 00:00:00 2001 From: shibakaneki Date: Wed, 29 Aug 2012 15:20:06 +0200 Subject: [PATCH] Fixed issue 1033 --- src/gui/UBTeacherGuideWidget.cpp | 11 +++++++++++ src/gui/UBTeacherGuideWidget.h | 5 +++++ src/gui/UBTeacherGuideWidgetsTools.cpp | 9 +++++++-- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/gui/UBTeacherGuideWidget.cpp b/src/gui/UBTeacherGuideWidget.cpp index 7de10dbf..ca73ec76 100644 --- a/src/gui/UBTeacherGuideWidget.cpp +++ b/src/gui/UBTeacherGuideWidget.cpp @@ -685,6 +685,7 @@ UBTeacherGuidePageZeroWidget::UBTeacherGuidePageZeroWidget(QWidget* parent, cons mpSessionTitle = new UBTGAdaptableText(0, this, "UBTGSessionTitle"); mpSessionTitle->setPlaceHolderText(tr("Type session title here ...")); mpButtonTitleLayout->addWidget(mpSessionTitle); + connect(this, SIGNAL(resized()), mpSessionTitle, SLOT(onTextChanged())); mpLayout->addLayout(mpButtonTitleLayout); @@ -703,6 +704,7 @@ UBTeacherGuidePageZeroWidget::UBTeacherGuidePageZeroWidget(QWidget* parent, cons mpAuthors->setObjectName("UBTGZeroPageInputText"); mpAuthors->setPlaceHolderText(tr("Type authors here ...")); mpLayout->addWidget(mpAuthors); + connect(this, SIGNAL(resized()), mpAuthors, SLOT(onTextChanged())); mpCreationLabel = new QLabel(this); mpCreationLabel->setObjectName("UBTGZeroPageDateLabel"); @@ -727,6 +729,7 @@ UBTeacherGuidePageZeroWidget::UBTeacherGuidePageZeroWidget(QWidget* parent, cons mpObjectives->setObjectName("UBTGZeroPageInputText"); mpObjectives->setPlaceHolderText(tr("Type objectives here...")); mpLayout->addWidget(mpObjectives); + connect(this, SIGNAL(resized()), mpObjectives, SLOT(onTextChanged())); mpSeparatorObjectives = new QFrame(this); mpSeparatorObjectives->setFixedHeight(UBTG_SEPARATOR_FIXED_HEIGHT); @@ -747,6 +750,7 @@ UBTeacherGuidePageZeroWidget::UBTeacherGuidePageZeroWidget(QWidget* parent, cons mpKeywords = new UBTGAdaptableText(0, this); mpKeywords->setPlaceHolderText(tr("Type keywords here ...")); mpLayout->addWidget(mpKeywords); + connect(this, SIGNAL(resized()), mpKeywords, SLOT(onTextChanged())); mpSchoolLevelItemLabel = new QLabel(this); mpSchoolLevelItemLabel->setObjectName("UBTGZeroPageItemLabel"); @@ -1122,6 +1126,12 @@ bool UBTeacherGuidePageZeroWidget::isModified() return result; } +void UBTeacherGuidePageZeroWidget::resizeEvent(QResizeEvent* ev){ + emit resized(); + + QWidget::resizeEvent(ev); +} + /*************************************************************************** * class UBTeacherGuideWidget * ***************************************************************************/ @@ -1238,3 +1248,4 @@ bool UBTeacherGuideWidget::isModified() else return mpEditionWidget->isModified(); } + diff --git a/src/gui/UBTeacherGuideWidget.h b/src/gui/UBTeacherGuideWidget.h index 1d165f13..a970807e 100644 --- a/src/gui/UBTeacherGuideWidget.h +++ b/src/gui/UBTeacherGuideWidget.h @@ -136,11 +136,16 @@ public: QVector getData(); bool isModified(); +signals: + void resized(); public slots: void onActiveSceneChanged(); void switchToMode(tUBTGZeroPageMode mode = tUBTGZeroPageMode_EDITION); +protected: + void resizeEvent(QResizeEvent* ev); + private: void fillComboBoxes(); void loadData(); diff --git a/src/gui/UBTeacherGuideWidgetsTools.cpp b/src/gui/UBTeacherGuideWidgetsTools.cpp index d9c88efd..55246e99 100644 --- a/src/gui/UBTeacherGuideWidgetsTools.cpp +++ b/src/gui/UBTeacherGuideWidgetsTools.cpp @@ -174,6 +174,7 @@ void UBTGAdaptableText::showEvent(QShowEvent* e) if(!mIsUpdatingSize && mHasPlaceHolder && toPlainText().isEmpty()) setPlainText(mPlaceHolderText); else + // If the teacherguide is collapsed, don't updated the size. Or set the size as the expanded size onTextChanged(); } @@ -188,9 +189,12 @@ QString UBTGAdaptableText::text() void UBTGAdaptableText::onTextChanged() { + qDebug() << ">> onTextChanged CALLED!"; qreal documentSize = document()->size().height(); - if(height() == documentSize + mBottomMargin) - return; + qDebug() << ">> documentSize: " << documentSize << ", height: " << height(); + if(height() == documentSize + mBottomMargin){ + return; + } mIsUpdatingSize = true; @@ -208,6 +212,7 @@ void UBTGAdaptableText::onTextChanged() setFocus(); } mIsUpdatingSize = false; + } void UBTGAdaptableText::setInitialText(const QString& text) {