diff --git a/src/adaptors/UBCFFSubsetAdaptor.cpp b/src/adaptors/UBCFFSubsetAdaptor.cpp index 19e8a016..1dff442d 100644 --- a/src/adaptors/UBCFFSubsetAdaptor.cpp +++ b/src/adaptors/UBCFFSubsetAdaptor.cpp @@ -17,7 +17,9 @@ #include #include "core/UBPersistenceManager.h" + #include "document/UBDocumentProxy.h" + #include "domain/UBItem.h" #include "domain/UBGraphicsPolygonItem.h" #include "domain/UBGraphicsStroke.h" diff --git a/src/board/UBBoardController.cpp b/src/board/UBBoardController.cpp index d3faba2b..2f03f66f 100644 --- a/src/board/UBBoardController.cpp +++ b/src/board/UBBoardController.cpp @@ -65,6 +65,8 @@ #include "UBBoardPaletteManager.h" +#include "core/UBSettings.h" + #include "core/memcheck.h" //#include @@ -147,6 +149,13 @@ UBBoardController::~UBBoardController() } +int UBBoardController::currentPage() +{ + if(!UBSettings::settings()->teacherGuidePageZeroActivated->get().toBool()) + return mActiveSceneIndex; + return mActiveSceneIndex + 1; +} + void UBBoardController::setupViews() { mControlContainer = new QWidget(mMainWindow->centralWidget()); diff --git a/src/board/UBBoardController.h b/src/board/UBBoardController.h index d5d6bee1..4b293c68 100644 --- a/src/board/UBBoardController.h +++ b/src/board/UBBoardController.h @@ -57,6 +57,8 @@ class UBBoardController : public QObject QRectF controlGeometry(); void closing(); + int currentPage(); + UBDocumentProxy* activeDocument() { return mActiveDocument; diff --git a/src/board/UBBoardPaletteManager.cpp b/src/board/UBBoardPaletteManager.cpp index f21c089b..1eeee92c 100644 --- a/src/board/UBBoardPaletteManager.cpp +++ b/src/board/UBBoardPaletteManager.cpp @@ -129,25 +129,25 @@ void UBBoardPaletteManager::setupDockPaletteWidgets() //------------------------------------------------// // Create the widgets for the dock palettes - - mpPageNavigWidget = new UBPageNavigationWidget(); - mpLibWidget = new UBLibWidget(); mpCachePropWidget = new UBCachePropertiesWidget(); mpDownloadWidget = new UBDockDownloadWidget(); - mpTeacherGuideWidget = new UBDockTeacherGuideWidget(); // Add the dock palettes mLeftPalette = new UBLeftPalette(mContainer); // LEFT palette widgets + mpPageNavigWidget = new UBPageNavigationWidget(); mLeftPalette->registerWidget(mpPageNavigWidget); mLeftPalette->addTab(mpPageNavigWidget); - mLeftPalette->registerWidget(mpTeacherGuideWidget); - mLeftPalette->addTab(mpTeacherGuideWidget); + if(UBSettings::settings()->teacherGuidePageZeroActivated || UBSettings::settings()->teacherGuideLessonPagesActivated){ + mpTeacherGuideWidget = new UBDockTeacherGuideWidget(); + mLeftPalette->registerWidget(mpTeacherGuideWidget); + mLeftPalette->addTab(mpTeacherGuideWidget); + } mLeftPalette->connectSignals(); diff --git a/src/core/UBApplicationController.cpp b/src/core/UBApplicationController.cpp index 81847ad5..328fe88c 100644 --- a/src/core/UBApplicationController.cpp +++ b/src/core/UBApplicationController.cpp @@ -24,9 +24,6 @@ #include "core/UBDocumentManager.h" #include "core/UBDisplayManager.h" -#include "softwareupdate/UBSoftwareUpdateController.h" -#include "softwareupdate/UBSoftwareUpdate.h" - #include "board/UBBoardView.h" #include "board/UBBoardController.h" #include "board/UBBoardPaletteManager.h" diff --git a/src/core/UBSettings.cpp b/src/core/UBSettings.cpp index 28a2a8d5..541a6ca3 100644 --- a/src/core/UBSettings.cpp +++ b/src/core/UBSettings.cpp @@ -381,6 +381,8 @@ void UBSettings::init() angleTolerance = new UBSetting(this, "App", "AngleTolerance", 4); historyLimit = new UBSetting(this, "Web", "HistoryLimit", 15); + teacherGuidePageZeroActivated = new UBSetting(this,"DockPalette","TeacherGuideActivatePageZero",true); + teacherGuideLessonPagesActivated = new UBSetting(this,"DockPalette","TeacherGuideActvateLessonPages",true); } diff --git a/src/core/UBSettings.h b/src/core/UBSettings.h index 2bb7262b..d19b1378 100644 --- a/src/core/UBSettings.h +++ b/src/core/UBSettings.h @@ -330,6 +330,8 @@ class UBSettings : public QObject UBSetting* angleTolerance; UBSetting* historyLimit; + UBSetting* teacherGuidePageZeroActivated; + UBSetting* teacherGuideLessonPagesActivated; public slots: diff --git a/src/gui/UBTeacherGuideWidget.cpp b/src/gui/UBTeacherGuideWidget.cpp index 9fc0fdcd..c1ab5023 100644 --- a/src/gui/UBTeacherGuideWidget.cpp +++ b/src/gui/UBTeacherGuideWidget.cpp @@ -25,6 +25,7 @@ #include "core/UBApplication.h" #include "core/UBPersistenceManager.h" +#include "core/UBSettings.h" #include "globals/UBGlobals.h" @@ -146,7 +147,7 @@ void UBTeacherGuideEditionWidget::showEvent(QShowEvent* event) void UBTeacherGuideEditionWidget::onActiveSceneChanged() { cleanData(); - mpPageNumberLabel->setText(tr("Page: %0").arg(UBApplication::boardController->activeSceneIndex() + 1)); + mpPageNumberLabel->setText(tr("Page: %0").arg(UBApplication::boardController->currentPage())); } void UBTeacherGuideEditionWidget::cleanData() @@ -359,7 +360,7 @@ void UBTeacherGuidePresentationWidget::cleanData() void UBTeacherGuidePresentationWidget::onActiveSceneChanged() { cleanData(); - mpPageNumberLabel->setText(tr("Page: %0").arg(UBApplication::boardController->activeSceneIndex() + 1)); + mpPageNumberLabel->setText(tr("Page: %0").arg(UBApplication::boardController->currentPage())); } void UBTeacherGuidePresentationWidget::createMediaButtonItem() @@ -459,7 +460,7 @@ void UBTeacherGuidePresentationWidget::onAddItemClicked(QTreeWidgetItem* widget, /*************************************************************************** * class UBTeacherGuidePageZeroEditionWidget * ***************************************************************************/ -UBTeacherGuidePageZeroEditionWidget::UBTeacherGuidePageZeroEditionWidget(QWidget* parent, const char* name): QWidget(parent) +UBTeacherGuidePageZeroWidget::UBTeacherGuidePageZeroWidget(QWidget* parent, const char* name): QWidget(parent) , mpLayout(NULL) , mpButtonTitleLayout(NULL) , mpModePushButton(NULL) @@ -626,7 +627,7 @@ UBTeacherGuidePageZeroEditionWidget::UBTeacherGuidePageZeroEditionWidget(QWidget fillComboBoxes(); } -UBTeacherGuidePageZeroEditionWidget::~UBTeacherGuidePageZeroEditionWidget() +UBTeacherGuidePageZeroWidget::~UBTeacherGuidePageZeroWidget() { DELETEPTR(mpPageNumberLabel); DELETEPTR(mpSessionTitle); @@ -659,7 +660,7 @@ UBTeacherGuidePageZeroEditionWidget::~UBTeacherGuidePageZeroEditionWidget() DELETEPTR(mpLayout); } -void UBTeacherGuidePageZeroEditionWidget::fillComboBoxes() +void UBTeacherGuidePageZeroWidget::fillComboBoxes() { QString parametersConfigFilePath = UBSettings::settings()->applicationCustomizationDirectory() + "/teacherGuide/indexingParameters.xml"; QFile parametersFile(parametersConfigFilePath); @@ -704,7 +705,7 @@ void UBTeacherGuidePageZeroEditionWidget::fillComboBoxes() mpLicenceBox->addItems(licences); } -void UBTeacherGuidePageZeroEditionWidget::onSchoolLevelChanged(QString schoolLevel) +void UBTeacherGuidePageZeroWidget::onSchoolLevelChanged(QString schoolLevel) { QStringList subjects = mSubjects.value(mGradeLevelsMap.value(schoolLevel)); mpSchoolBranchBox->clear(); @@ -719,19 +720,19 @@ void UBTeacherGuidePageZeroEditionWidget::onSchoolLevelChanged(QString schoolLev } } -void UBTeacherGuidePageZeroEditionWidget::onActiveSceneChanged() +void UBTeacherGuidePageZeroWidget::onActiveSceneChanged() { UBDocumentProxy* documentProxy = UBApplication::documentController ? UBApplication::documentController->getCurrentDocument() : 0; - if(UBApplication::documentController && UBApplication::boardController->activeSceneIndex() == 0){ -// QDateTime creationDate = documentProxy->documentDate(); -// mpCreationLabel->setText(tr("Created the:") + creationDate.toString(Qt::SystemLocaleShortDate)); -// QDateTime updatedDate = documentProxy->lastUpdate(); -// mpLastModifiedLabel->setText(tr("Updated the:") + updatedDate.toString(Qt::SystemLocaleShortDate)); + if(UBApplication::documentController && UBApplication::boardController->currentPage() == 0){ + QDateTime creationDate = documentProxy->documentDate(); + mpCreationLabel->setText(tr("Created the:") + creationDate.toString(Qt::SystemLocaleShortDate)); + QDateTime updatedDate = documentProxy->lastUpdate(); + mpLastModifiedLabel->setText(tr("Updated the:") + updatedDate.toString(Qt::SystemLocaleShortDate)); } } -void UBTeacherGuidePageZeroEditionWidget::switchToMode(tUBTGZeroPageMode mode) +void UBTeacherGuidePageZeroWidget::switchToMode(tUBTGZeroPageMode mode) { if(mode == tUBTGZeroPageMode_EDITION){ mpModePushButton->hide(); @@ -767,10 +768,8 @@ void UBTeacherGuidePageZeroEditionWidget::switchToMode(tUBTGZeroPageMode mode) mpLicenceValueLabel->setText(mpLicenceBox->currentText()); QStringList licenceIconList; licenceIconList << ":images/licenses/ccby.png" << ":images/licenses/ccbynd.png" << ":images/licenses/ccbysa.png" << ":images/licenses/ccbync.png" << ":images/licenses/ccbyncnd.png" << ":images/licenses/ccbyncsa.png"; - int licenceBoxCurrentIndex = mpLicenceBox->currentIndex(); - // -1 is return if there is no values on the box - if(licenceBoxCurrentIndex > 0 && licenceBoxCurrentIndex < licenceIconList.count()){ - mpLicenceIcon->setPixmap(licenceIconList.at(licenceBoxCurrentIndex)); + if(mpLicenceBox->currentIndex() < 6){ + mpLicenceIcon->setPixmap(licenceIconList.at(mpLicenceBox->currentIndex())); mpLicenceIcon->show(); } mpLicenceValueLabel->show(); @@ -778,7 +777,7 @@ void UBTeacherGuidePageZeroEditionWidget::switchToMode(tUBTGZeroPageMode mode) } } -QVector UBTeacherGuidePageZeroEditionWidget::getData() +QVector UBTeacherGuidePageZeroWidget::getData() { QVectorresult; tUBGEElementNode* elementNode = new tUBGEElementNode(); @@ -837,24 +836,25 @@ QVector UBTeacherGuidePageZeroEditionWidget::getData() * class UBTeacherGuideWidget * ***************************************************************************/ UBTeacherGuideWidget::UBTeacherGuideWidget(QWidget* parent, const char* name): QStackedWidget(parent) - , mpPageZeroEditonWidget(NULL) + , mpPageZeroWidget(NULL) , mpEditionWidget(NULL) , mpPresentationWidget(NULL) { setObjectName(name); - - mpPageZeroEditonWidget = new UBTeacherGuidePageZeroEditionWidget(this); - addWidget(mpPageZeroEditonWidget); - setCurrentWidget(mpPageZeroEditonWidget); - // mpEditionWidget = new UBTeacherGuideEditionWidget(this); -// addWidget(mpEditionWidget); -// mpPresentationWidget = new UBTeacherGuidePresentationWidget(this); -// addWidget(mpPresentationWidget); -// setCurrentWidget(mpPresentationWidget); - + if(UBSettings::settings()->teacherGuidePageZeroActivated->get().toBool()){ + mpPageZeroWidget = new UBTeacherGuidePageZeroWidget(this); + addWidget(mpPageZeroWidget); + } + if(UBSettings::settings()->teacherGuideLessonPagesActivated->get().toBool()){ + mpEditionWidget = new UBTeacherGuideEditionWidget(this); + addWidget(mpEditionWidget); + mpPresentationWidget = new UBTeacherGuidePresentationWidget(this); + addWidget(mpPresentationWidget); + } connect(UBApplication::boardController->controlView(),SIGNAL(clickOnBoard()),this,SLOT(showPresentationMode())); connectToStylusPalette(); + connect(UBApplication::boardController,SIGNAL(activeSceneChanged()),this,SLOT(onActiveSceneChanged())); } @@ -864,19 +864,29 @@ UBTeacherGuideWidget::~UBTeacherGuideWidget() DELETEPTR(mpPresentationWidget); } + +void UBTeacherGuideWidget::onActiveSceneChanged() +{ + if(UBApplication::boardController->currentPage() == 0) + setCurrentWidget(mpPageZeroWidget); + else + setCurrentWidget(mpPresentationWidget); + +} + void UBTeacherGuideWidget::connectToStylusPalette() { if(UBApplication::boardController->paletteManager()) connect(UBApplication::boardController->paletteManager()->stylusPalette(),SIGNAL(itemOnActionPaletteChanged()),this,SLOT(showPresentationMode())); else - QTimer::singleShot(500,this,SLOT(connectToStylusPalette())); + QTimer::singleShot(100,this,SLOT(connectToStylusPalette())); } void UBTeacherGuideWidget::showPresentationMode() { - if(currentWidget()==mpPageZeroEditonWidget){ - mCurrentData = mpPageZeroEditonWidget->getData(); - mpPageZeroEditonWidget->switchToMode(tUBTGZeroPageMode_PRESENTATION); + if(currentWidget()==mpPageZeroWidget){ + mCurrentData = mpPageZeroWidget->getData(); + mpPageZeroWidget->switchToMode(tUBTGZeroPageMode_PRESENTATION); } else if(currentWidget()==mpEditionWidget){ mCurrentData = mpEditionWidget->getData(); diff --git a/src/gui/UBTeacherGuideWidget.h b/src/gui/UBTeacherGuideWidget.h index 20d7e395..cc1e62f3 100644 --- a/src/gui/UBTeacherGuideWidget.h +++ b/src/gui/UBTeacherGuideWidget.h @@ -105,13 +105,13 @@ private: /*************************************************************************** * class UBTeacherGuidePageZeroPresentationWidget * ***************************************************************************/ -class UBTeacherGuidePageZeroEditionWidget : public QWidget +class UBTeacherGuidePageZeroWidget : public QWidget { Q_OBJECT public: - explicit UBTeacherGuidePageZeroEditionWidget(QWidget* parent, const char* name = "UBTeacherGuidePageZeroEditionWidget"); - ~UBTeacherGuidePageZeroEditionWidget(); + explicit UBTeacherGuidePageZeroWidget(QWidget* parent, const char* name = "UBTeacherGuidePageZeroEditionWidget"); + ~UBTeacherGuidePageZeroWidget(); QVector getData(); @@ -185,9 +185,10 @@ public slots: void changeMode(); void showPresentationMode(); void connectToStylusPalette(); + void onActiveSceneChanged(); private: - UBTeacherGuidePageZeroEditionWidget* mpPageZeroEditonWidget; + UBTeacherGuidePageZeroWidget* mpPageZeroWidget; UBTeacherGuideEditionWidget* mpEditionWidget; UBTeacherGuidePresentationWidget* mpPresentationWidget; QVectormCurrentData;