From 34e778e14e1d820b21f14e2f83e46f79bbfc03d4 Mon Sep 17 00:00:00 2001 From: Claudio Valerio Date: Tue, 3 Jan 2012 10:26:00 +0100 Subject: [PATCH 01/84] first draft of 'nouvelle barre du prof' --- src/board/UBBoardPaletteManager.cpp | 10 +- src/gui/UBDockPaletteWidget.cpp | 3 + src/gui/UBDockPaletteWidget.h | 4 + src/gui/UBTeacherBarWidget.cpp | 129 ++++++++++++++++++- src/gui/UBTeacherBarWidget.h | 28 +++++ src/gui/UBVideoPlayer.h | 5 + src/gui/gui.pri | 88 ++++++------- src/podcast/youtube/UBYouTubePublisher.cpp | 2 +- src/web/UBWebController.cpp | 136 +-------------------- src/web/UBWebController.h | 29 +++-- src/web/web.pri | 8 +- 11 files changed, 243 insertions(+), 199 deletions(-) diff --git a/src/board/UBBoardPaletteManager.cpp b/src/board/UBBoardPaletteManager.cpp index 483fbbac..eb10433f 100644 --- a/src/board/UBBoardPaletteManager.cpp +++ b/src/board/UBBoardPaletteManager.cpp @@ -199,6 +199,10 @@ void UBBoardPaletteManager::setupDockPaletteWidgets() mLeftPalette->registerWidget(mpPageNavigWidget); mLeftPalette->addTab(mpPageNavigWidget); + // The teacher bar widget will always be there + mLeftPalette->registerWidget(mpTeacherBarWidget); + mLeftPalette->addTab(mpTeacherBarWidget); + mLeftPalette->connectSignals(); mRightPalette = new UBRightPalette(mContainer); @@ -207,9 +211,6 @@ void UBBoardPaletteManager::setupDockPaletteWidgets() mRightPalette->addTab(mpLibWidget); // The cache widget will be visible only if a cache is put on the page mRightPalette->registerWidget(mpCachePropWidget); - // The teacher bar widget will always be there - mRightPalette->registerWidget(mpTeacherBarWidget); - mRightPalette->addTab(mpTeacherBarWidget); // The download widget will be part of the right palette but // will become visible only when the first download starts mRightPalette->registerWidget(mpDownloadWidget); @@ -820,9 +821,6 @@ void UBBoardPaletteManager::changeMode(eUBDockPaletteWidgetMode newMode, bool is } else mKeyboardPalette->setParent(0); - -// mKeyboardPalette->update(); - } } break; diff --git a/src/gui/UBDockPaletteWidget.cpp b/src/gui/UBDockPaletteWidget.cpp index 16bcb322..32dbd286 100644 --- a/src/gui/UBDockPaletteWidget.cpp +++ b/src/gui/UBDockPaletteWidget.cpp @@ -27,6 +27,9 @@ QString UBDockPaletteWidget::name() return mName; } +/** + * When a widget registers a mode it means that it would be displayed on that mode + */ void UBDockPaletteWidget::registerMode(eUBDockPaletteWidgetMode mode) { if(!mRegisteredModes.contains(mode)) diff --git a/src/gui/UBDockPaletteWidget.h b/src/gui/UBDockPaletteWidget.h index fdf50a87..98768253 100644 --- a/src/gui/UBDockPaletteWidget.h +++ b/src/gui/UBDockPaletteWidget.h @@ -5,6 +5,10 @@ #include #include + +/** + * This enum defines the different mode availables. + */ typedef enum { eUBDockPaletteWidget_BOARD, diff --git a/src/gui/UBTeacherBarWidget.cpp b/src/gui/UBTeacherBarWidget.cpp index 52c21bb2..75033ed9 100644 --- a/src/gui/UBTeacherBarWidget.cpp +++ b/src/gui/UBTeacherBarWidget.cpp @@ -32,6 +32,7 @@ UBTeacherBarWidget::UBTeacherBarWidget(QWidget *parent, const char *name):UBDock , mpAction1(NULL) , mpAction2(NULL) , mpAction3(NULL) + , mpDropMediaZone(NULL) , mpContainer(NULL) , mpContainerLayout(NULL) { @@ -122,6 +123,10 @@ UBTeacherBarWidget::UBTeacherBarWidget(QWidget *parent, const char *name):UBDock mpLayout->addWidget(mpAction2); mpLayout->addWidget(mpAction3); + // Media + mpDropMediaZone = new UBTeacherBarDropMediaZone(); + mpLayout->addWidget(mpDropMediaZone); + populateCombos(); connect(UBApplication::boardController, SIGNAL(activeSceneWillChange()), this, SLOT(saveContent())); @@ -142,6 +147,11 @@ UBTeacherBarWidget::UBTeacherBarWidget(QWidget *parent, const char *name):UBDock UBTeacherBarWidget::~UBTeacherBarWidget() { + if(NULL != mpDropMediaZone) + { + delete mpDropMediaZone; + mpDropMediaZone = NULL; + } if(NULL != mpAction3) { delete mpAction3; @@ -356,9 +366,7 @@ UBTeacherStudentAction::UBTeacherStudentAction(int actionNumber, QWidget *parent mpTeacherLayout = new QHBoxLayout(); - //TODO: I'm not able to translate this string using the normal way *qm file why? mpTeacherLabel = new QLabel(tr("Teacher"), this); -// mpTeacherLabel = new QLabel(tr("Enseignant"), this); mpTeacherLabel->setAlignment(Qt::AlignTop); mpTeacher = new QTextEdit(this); mpTeacher->setObjectName("TeacherStudentBox"); @@ -369,7 +377,6 @@ UBTeacherStudentAction::UBTeacherStudentAction(int actionNumber, QWidget *parent mpStudentLayout = new QHBoxLayout(); mpStudentLabel = new QLabel(tr("Student"), this); -// mpStudentLabel = new QLabel(tr("Élève"), this); mpStudentLabel->setAlignment(Qt::AlignTop); mpStudent = new QTextEdit(this); mpStudent->setObjectName("TeacherStudentBox"); @@ -452,3 +459,119 @@ QTextEdit* UBTeacherStudentAction::student() { return mpStudent; } + +#include "gui/UBMediaPlayer.h" +#include "gui/UBVideoPlayer.h" +#include "frameworks/UBFileSystemUtils.h" + +UBTeacherBarDropMediaZone::UBTeacherBarDropMediaZone(QWidget *parent, const char *name):QWidget(parent) + , mpTitleLabel(NULL) + , mpImageTab(NULL) + , mpTabWidget(NULL) + , mpLayout(NULL) +{ + setObjectName(name); + setAcceptDrops(true); + + setAttribute(Qt::WA_StyledBackground, true); + setStyleSheet(UBApplication::globalStyleSheet()); + + // Create the GUI + mpLayout = new QVBoxLayout(this); + setLayout(mpLayout); + + + mpImageTab = new QLabel(); + mpVideoTab = new UBMediaPlayer(); + mpAudioTab = new UBMediaPlayer(); + + mpTitleLabel = new QLabel(tr("Drop media here")); + mpLayout->addWidget(mpTitleLabel); + mpTabWidget = new QTabWidget(); + mpTabWidget->setMinimumHeight(200); + mpTabWidget->addTab(mpImageTab,QIcon(":images/toolbar/extraTool.png"),""); + mpTabWidget->addTab(mpVideoTab,QIcon(":images/libpalette/movieIcon.svg"),""); + mpTabWidget->addTab(mpAudioTab,QIcon(":images/libpalette/soundIcon.svg"),""); + mpLayout->addWidget(mpTabWidget); +} + +UBTeacherBarDropMediaZone::~UBTeacherBarDropMediaZone() +{ + if(NULL != mpTitleLabel) + { + delete mpTitleLabel; + mpTitleLabel = NULL; + } + if(NULL != mpImageTab) + { + delete mpImageTab; + mpImageTab = NULL; + } + if(NULL != mpVideoTab) + { + delete mpVideoTab; + mpVideoTab = NULL; + } + if(NULL != mpAudioTab) + { + delete mpAudioTab; + mpAudioTab = NULL; + } + if(NULL != mpTabWidget) + { + delete mpTabWidget; + mpTabWidget = NULL; + } + if(NULL != mpLayout) + { + delete mpLayout; + mpLayout = NULL; + } +} + + +void UBTeacherBarDropMediaZone::dragEnterEvent(QDragEnterEvent *pEvent) +{ + setBackgroundRole(QPalette::Highlight); + pEvent->acceptProposedAction(); +} + +void UBTeacherBarDropMediaZone::dragLeaveEvent(QDragLeaveEvent *pEvent) +{ + setBackgroundRole(QPalette::Dark); + pEvent->accept(); +} + +void UBTeacherBarDropMediaZone::dropEvent(QDropEvent *pEvent) +{ + setBackgroundRole(QPalette::Dark); + if(pEvent->mimeData()->hasHtml()) qDebug() << pEvent->mimeData()->html(); + if(pEvent->mimeData()->hasUrls()) qDebug() << pEvent->mimeData()->urls(); + if(pEvent->mimeData()->hasText()) qDebug() << pEvent->mimeData()->text(); + QString mimeType = UBFileSystemUtils::mimeTypeFromFileName(pEvent->mimeData()->urls().at(0).toLocalFile()); + if(mimeType.contains("image")){ + QPixmap pix = QPixmap(pEvent->mimeData()->urls().at(0).toLocalFile()); + mpImageTab->setPixmap(pix); + mpTabWidget->setCurrentWidget(mpImageTab); + } + else if(mimeType.contains("video")){ + mpVideoTab->setFile(pEvent->mimeData()->urls().at(0).toLocalFile()); + mpVideoTab->playPause(); + + mpTabWidget->setCurrentWidget(mpVideoTab); + } + else if(mimeType.contains("audio")){ + mpVideoTab->setFile(pEvent->mimeData()->urls().at(0).toLocalFile()); + mpVideoTab->playPause(); + mpTabWidget->setCurrentWidget(mpAudioTab); + } + else{ + qWarning() << "bad idea to come here"; + } + pEvent->acceptProposedAction(); +} + +void UBTeacherBarDropMediaZone::dragMoveEvent(QDragMoveEvent *pEvent) +{ + pEvent->acceptProposedAction(); +} diff --git a/src/gui/UBTeacherBarWidget.h b/src/gui/UBTeacherBarWidget.h index a021027f..585e7f8a 100644 --- a/src/gui/UBTeacherBarWidget.h +++ b/src/gui/UBTeacherBarWidget.h @@ -1,6 +1,9 @@ #ifndef UBTEACHERBARWIDGET_H #define UBTEACHERBARWIDGET_H +class UBMediaPlayer; +class UBVideoPlayer; + #include #include #include @@ -39,6 +42,30 @@ private: QHBoxLayout* mpStudentLayout; }; + +class UBTeacherBarDropMediaZone : public QWidget +{ + Q_OBJECT + +public: + UBTeacherBarDropMediaZone(QWidget* parent=0, const char* name="UBTeacherBarDropMediaZone"); + ~UBTeacherBarDropMediaZone(); + +private: + QLabel* mpTitleLabel; + QLabel* mpImageTab; + UBMediaPlayer* mpVideoTab; + UBMediaPlayer* mpAudioTab; + QTabWidget* mpTabWidget; + QVBoxLayout* mpLayout; + +protected: + void dragEnterEvent(QDragEnterEvent* pEvent); + void dropEvent(QDropEvent *pEvent); + void dragMoveEvent(QDragMoveEvent* pEvent); + void dragLeaveEvent(QDragLeaveEvent* pEvent); +}; + class UBTeacherBarWidget : public UBDockPaletteWidget { Q_OBJECT @@ -75,6 +102,7 @@ private: UBTeacherStudentAction* mpAction1; UBTeacherStudentAction* mpAction2; UBTeacherStudentAction* mpAction3; + UBTeacherBarDropMediaZone* mpDropMediaZone; QWidget* mpContainer; QVBoxLayout* mpContainerLayout; }; diff --git a/src/gui/UBVideoPlayer.h b/src/gui/UBVideoPlayer.h index ced2cc3b..287ad382 100644 --- a/src/gui/UBVideoPlayer.h +++ b/src/gui/UBVideoPlayer.h @@ -35,6 +35,11 @@ class UBVideoPlayer : public QWidget return mVideoPlayer; } + void loadMedia(QUrl url) + { + mVideoPlayer->load(Phonon::MediaSource(url)); + } + protected: Phonon::VideoPlayer* mVideoPlayer; diff --git a/src/gui/gui.pri b/src/gui/gui.pri index 20075dfb..d1a187cd 100644 --- a/src/gui/gui.pri +++ b/src/gui/gui.pri @@ -26,27 +26,28 @@ HEADERS += src/gui/UBThumbnailView.h \ src/gui/UBActionPalette.h \ src/gui/UBFavoriteToolPalette.h \ src/gui/UBKeyboardPalette.h \ - src/gui/UBNavigatorPalette.h \ - src/gui/UBDocumentNavigator.h \ - src/gui/UBDockPalette.h \ - src/gui/UBPropertyPalette.h \ - src/gui/UBLibNavigatorWidget.h \ - src/gui/UBLibItemProperties.h \ - src/gui/UBLibActionBar.h \ - src/gui/UBLibraryWidget.h \ - src/gui/UBLibPathViewer.h \ - src/gui/UBUpdateDlg.h \ - src/gui/UBDockPaletteWidget.h \ - src/gui/UBLeftPalette.h \ - src/gui/UBRightPalette.h \ - src/gui/UBPageNavigationWidget.h \ - src/gui/UBLibWidget.h \ - src/gui/UBMagnifer.h \ - src/gui/UBCachePropertiesWidget.h \ - src/gui/UBTeacherBarWidget.h \ - src/gui/UBLibWebView.h \ - src/gui/UBDownloadWidget.h \ - src/gui/UBDockDownloadWidget.h + src/gui/UBNavigatorPalette.h \ + src/gui/UBDocumentNavigator.h \ + src/gui/UBDockPalette.h \ + src/gui/UBPropertyPalette.h \ + src/gui/UBLibNavigatorWidget.h \ + src/gui/UBLibItemProperties.h \ + src/gui/UBLibActionBar.h \ + src/gui/UBLibraryWidget.h \ + src/gui/UBLibPathViewer.h \ + src/gui/UBUpdateDlg.h \ + src/gui/UBDockPaletteWidget.h \ + src/gui/UBLeftPalette.h \ + src/gui/UBRightPalette.h \ + src/gui/UBPageNavigationWidget.h \ + src/gui/UBLibWidget.h \ + src/gui/UBMagnifer.h \ + src/gui/UBCachePropertiesWidget.h \ + src/gui/UBTeacherBarWidget.h \ + src/gui/UBLibWebView.h \ + src/gui/UBDownloadWidget.h \ + src/gui/UBDockDownloadWidget.h \ + src/gui/UBMediaPlayer.h SOURCES += src/gui/UBThumbnailView.cpp \ src/gui/UBFloatingPalette.cpp \ @@ -75,27 +76,28 @@ SOURCES += src/gui/UBThumbnailView.cpp \ src/gui/UBActionPalette.cpp \ src/gui/UBFavoriteToolPalette.cpp \ src/gui/UBKeyboardPalette.cpp \ - src/gui/UBNavigatorPalette.cpp \ - src/gui/UBDocumentNavigator.cpp \ - src/gui/UBDockPalette.cpp \ - src/gui/UBPropertyPalette.cpp \ - src/gui/UBLibNavigatorWidget.cpp \ - src/gui/UBLibItemProperties.cpp \ - src/gui/UBLibActionBar.cpp \ - src/gui/UBLibraryWidget.cpp \ - src/gui/UBLibPathViewer.cpp \ - src/gui/UBUpdateDlg.cpp \ - src/gui/UBDockPaletteWidget.cpp \ - src/gui/UBLeftPalette.cpp \ - src/gui/UBRightPalette.cpp \ - src/gui/UBPageNavigationWidget.cpp \ - src/gui/UBLibWidget.cpp \ - src/gui/UBMagnifer.cpp \ - src/gui/UBCachePropertiesWidget.cpp \ - src/gui/UBTeacherBarWidget.cpp \ - src/gui/UBLibWebView.cpp \ - src/gui/UBDownloadWidget.cpp \ - src/gui/UBDockDownloadWidget.cpp + src/gui/UBNavigatorPalette.cpp \ + src/gui/UBDocumentNavigator.cpp \ + src/gui/UBDockPalette.cpp \ + src/gui/UBPropertyPalette.cpp \ + src/gui/UBLibNavigatorWidget.cpp \ + src/gui/UBLibItemProperties.cpp \ + src/gui/UBLibActionBar.cpp \ + src/gui/UBLibraryWidget.cpp \ + src/gui/UBLibPathViewer.cpp \ + src/gui/UBUpdateDlg.cpp \ + src/gui/UBDockPaletteWidget.cpp \ + src/gui/UBLeftPalette.cpp \ + src/gui/UBRightPalette.cpp \ + src/gui/UBPageNavigationWidget.cpp \ + src/gui/UBLibWidget.cpp \ + src/gui/UBMagnifer.cpp \ + src/gui/UBCachePropertiesWidget.cpp \ + src/gui/UBTeacherBarWidget.cpp \ + src/gui/UBLibWebView.cpp \ + src/gui/UBDownloadWidget.cpp \ + src/gui/UBDockDownloadWidget.cpp \ + src/gui/UBMediaPlayer.cpp win32 { @@ -123,3 +125,5 @@ linux-g++-64 { SOURCES += src/gui/UBKeyboardPalette_linux.cpp } + + diff --git a/src/podcast/youtube/UBYouTubePublisher.cpp b/src/podcast/youtube/UBYouTubePublisher.cpp index 5cd44662..f160d4a4 100644 --- a/src/podcast/youtube/UBYouTubePublisher.cpp +++ b/src/podcast/youtube/UBYouTubePublisher.cpp @@ -24,7 +24,7 @@ #include "core/UBSetting.h" #include "gui/UBMainWindow.h" -#include "gui/UBVideoPlayer.h" +//#include "gui/UBVideoPlayer.h" #include "network/UBNetworkAccessManager.h" #include "network/UBServerXMLHttpRequest.h" diff --git a/src/web/UBWebController.cpp b/src/web/UBWebController.cpp index f556872f..436397b3 100644 --- a/src/web/UBWebController.cpp +++ b/src/web/UBWebController.cpp @@ -14,8 +14,6 @@ */ #include -#include -#include #include "frameworks/UBPlatformUtils.h" @@ -62,6 +60,7 @@ UBWebController::UBWebController(UBMainWindow* mainWindow) // , mKeyboardCurrentPalette(0) , mToolsPalettePositionned(false) , mDownloadViewIsVisible(false) + { connect(mMainWindow->actionWebTools, SIGNAL(toggled(bool)), this, SLOT(toggleWebToolsPalette(bool))); @@ -73,13 +72,11 @@ UBWebController::UBWebController(UBMainWindow* mainWindow) mToolsPalettePositionnedList[i] = false; } - connect(&mOEmbedParser, SIGNAL(oembedParsed(QVector)), this, SLOT(onOEmbedParsed(QVector))); - - // TODO : Comment the next line to continue the Youtube button bugfix initialiazemOEmbedProviders(); } + UBWebController::~UBWebController() { // NOOP @@ -96,6 +93,7 @@ void UBWebController::initialiazemOEmbedProviders() mOEmbedProviders << "metacafe.com"; mOEmbedProviders << "qik.com"; mOEmbedProviders << "slideshare"; + mOEmbedProviders << "5min.com"; mOEmbedProviders << "twitpic.com"; mOEmbedProviders << "viddler.com"; mOEmbedProviders << "vimeo.com"; @@ -328,53 +326,16 @@ void UBWebController::activePageChanged() mTrapFlashController->updateTrapFlashFromPage((*mCurrentWebBrowser)->currentTabWebView()->page()->currentFrame()); } - - mMainWindow->actionWebTrap->setChecked(false); QUrl latestUrl = (*mCurrentWebBrowser)->currentTabWebView()->url(); - - // TODO : Uncomment the next line to continue the youtube button bugfix - //UBApplication::mainWindow->actionWebOEmbed->setEnabled(hasEmbeddedContent()); - // And remove this line once the previous one is uncommented UBApplication::mainWindow->actionWebOEmbed->setEnabled(isOEmbedable(latestUrl)); - UBApplication::mainWindow->actionEduMedia->setEnabled(isEduMedia(latestUrl)); emit activeWebPageChanged((*mCurrentWebBrowser)->currentTabWebView()); } } -bool UBWebController::hasEmbeddedContent() -{ - bool bHasContent = false; - if(mCurrentWebBrowser){ - QString html = (*mCurrentWebBrowser)->currentTabWebView()->webPage()->mainFrame()->toHtml(); - - // search the presence of "+oembed" - QString query = "\\+oembed([^>]*)>"; - QRegExp exp(query); - exp.indexIn(html); - QStringList results = exp.capturedTexts(); - if(2 <= results.size() && "" != results.at(1)){ - // An embedded content has been found, no need to check the other ones - bHasContent = true; - }else{ - QList contentUrls; - lookForEmbedContent(&html, "embed", "src", &contentUrls); - lookForEmbedContent(&html, "video", "src", &contentUrls); - lookForEmbedContent(&html, "object", "data", &contentUrls); - - // TODO: check the hidden iFrame - - if(!contentUrls.empty()){ - bHasContent = true; - } - } - } - - return bHasContent; -} QPixmap UBWebController::captureCurrentPage() { @@ -580,12 +541,9 @@ void UBWebController::showTabAtTop(bool attop) void UBWebController::captureoEmbed() { - if ( mCurrentWebBrowser && (*mCurrentWebBrowser) && (*mCurrentWebBrowser)->currentTabWebView()){ - // TODO : Uncomment the next lines to continue the youtube button bugfix - // getEmbeddableContent(); - - // And comment from here - + if ( mCurrentWebBrowser && (*mCurrentWebBrowser) + && (*mCurrentWebBrowser)->currentTabWebView()) + { QWebView* webView = (*mCurrentWebBrowser)->currentTabWebView(); QUrl currentUrl = webView->url(); @@ -599,56 +557,9 @@ void UBWebController::captureoEmbed() UBDrawingController::drawingController()->setStylusTool(UBStylusTool::Selector); } } - // --> Until here } } -void UBWebController::lookForEmbedContent(QString* pHtml, QString tag, QString attribute, QList *pList) -{ - if(NULL != pHtml && NULL != pList){ - QVector urlsFound; - // Check for content - QRegExp exp(QString("<%0(.*)").arg(tag)); - exp.indexIn(*pHtml); - QStringList strl = exp.capturedTexts(); - if(2 <= strl.size() && strl.at(1) != ""){ - // Here we call this regular expression: - // src\s?=\s?['"]([^'"]*)['"] - // It says: give me all characters that are after src=" (or src = ") - QRegExp src(QString("%0\\s?=\\s?['\"]([^'\"]*)['\"]").arg(attribute)); - for(int i=1; iappend(QUrl(urls.at(1))); - } - } - } - } -} - -void UBWebController::checkForOEmbed(QString *pHtml) -{ - mOEmbedParser.parse(*pHtml); -} - -void UBWebController::getEmbeddableContent() -{ - // Get the source code of the page - if(mCurrentWebBrowser){ - QNetworkAccessManager* pNam = (*mCurrentWebBrowser)->currentTabWebView()->webPage()->networkAccessManager(); - if(NULL != pNam){ - QString html = (*mCurrentWebBrowser)->currentTabWebView()->webPage()->mainFrame()->toHtml(); - mOEmbedParser.setNetworkAccessManager(pNam); - - // First, we have to check if there is some oembed content - checkForOEmbed(&html); - - // Note: The other contents will be verified once the oembed ones have been checked - } - } -} void UBWebController::captureEduMedia() { @@ -809,38 +720,3 @@ void UBWebController::cut() act->trigger(); } } - -void UBWebController::onOEmbedParsed(QVector contents) -{ - QList urls; - - foreach(sOEmbedContent cnt, contents){ - urls << QUrl(cnt.url); - } - - // TODO : Implement this - //lookForEmbedContent(&html, "embed", "src", &urls); - //lookForEmbedContent(&html, "video", "src", &contentUrls); - //lookForEmbedContent(&html, "object", "data", &contentUrls); - - // TODO: check the hidden iFrame - - if(!urls.empty()){ - QUrl contentUrl; // The selected content url - - if(1 == urls.size()){ - contentUrl = urls.at(0); - }else{ - // TODO : Display a dialog box asking the user which content to get and set contentUrl to the selected content - - } - - UBGraphicsW3CWidgetItem * widget = UBApplication::boardController->activeScene()->addOEmbed(contentUrl); - - if(widget) - { - UBApplication::applicationController->showBoard(); - UBDrawingController::drawingController()->setStylusTool(UBStylusTool::Selector); - } - } -} diff --git a/src/web/UBWebController.h b/src/web/UBWebController.h index 8faa752d..29640cbe 100644 --- a/src/web/UBWebController.h +++ b/src/web/UBWebController.h @@ -19,7 +19,6 @@ #include #include -#include "web/UBOEmbedParser.h" class WBBrowserWindow; class UBApplication; @@ -31,6 +30,7 @@ class WBWebView; class UBServerXMLHttpRequest; //class UBKeyboardPalette; + class UBWebController : public QObject { Q_OBJECT; @@ -88,9 +88,6 @@ class UBWebController : public QObject void captureEduMedia(); bool isOEmbedable(const QUrl& pUrl); - bool hasEmbeddedContent(); - void getEmbeddableContent(); - bool isEduMedia(const QUrl& pUrl); void copy(); @@ -98,36 +95,41 @@ class UBWebController : public QObject void cut(); private: - void initialiazemOEmbedProviders(); - void tutorialWebInstance(); - void webBrowserInstance(); - void paraschoolWebInstance(); - void lookForEmbedContent(QString* pHtml, QString tag, QString attribute, QList* pList); - void checkForOEmbed(QString* pHtml); - QStackedWidget mStackedWidget[TotalNumberOfWebInstances]; + UBMainWindow *mMainWindow; + WBBrowserWindow* mWebBrowserList[TotalNumberOfWebInstances]; WBBrowserWindow** mCurrentWebBrowser; + QWidget* mBrowserWidget; UBTrapFlashController* mTrapFlashController; UBWebToolsPalette** mToolsCurrentPalette; UBWebToolsPalette* mToolsPaletteList[TotalNumberOfWebInstances]; // UBKeyboardPalette** mKeyboardCurrentPalette; // UBKeyboardPalette* mKeyboardPaletteList[TotalNumberOfWebInstances]; + bool mToolsPalettePositionned; bool mToolsPalettePositionnedList[TotalNumberOfWebInstances]; + bool mDownloadViewIsVisible; + QStringList mOEmbedProviders; - UBOEmbedParser mOEmbedParser; + + void initialiazemOEmbedProviders(); + + void tutorialWebInstance(); + void webBrowserInstance(); + void paraschoolWebInstance(); private slots: void activePageChanged(); void trapFlash(); + void toggleWebTrap(bool checked); - void onOEmbedParsed(QVector contents); + // void showKeyboard(bool checked); signals: @@ -137,6 +139,7 @@ class UBWebController : public QObject * @param pCapturedPixmap QPixmap corresponding to the capture. */ void imageCaptured(const QPixmap& pCapturedPixmap, bool pageMode, const QUrl& source); + void activeWebPageChanged(WBWebView* pWebView); }; diff --git a/src/web/web.pri b/src/web/web.pri index 8d89a572..0e38d0c0 100644 --- a/src/web/web.pri +++ b/src/web/web.pri @@ -26,8 +26,7 @@ HEADERS += src/web/UBWebController.h \ src/web/browser/WBUrlLineEdit.h \ src/web/browser/WBWebView.h \ src/web/browser/WBHistory.h \ - src/web/browser/WBWebTrapWebView.h \ - src/web/UBOEmbedParser.h + src/web/browser/WBWebTrapWebView.h SOURCES += src/web/UBWebController.cpp \ src/web/UBTrapFlashController.cpp \ @@ -47,7 +46,8 @@ SOURCES += src/web/UBWebController.cpp \ src/web/browser/WBUrlLineEdit.cpp \ src/web/browser/WBWebView.cpp \ src/web/browser/WBHistory.cpp \ - src/web/browser/WBWebTrapWebView.cpp \ - src/web/UBOEmbedParser.cpp + src/web/browser/WBWebTrapWebView.cpp + + From b824051438c837864e5a905adb0004d5a8ee0ce2 Mon Sep 17 00:00:00 2001 From: Claudio Valerio Date: Tue, 3 Jan 2012 10:49:12 +0100 Subject: [PATCH 02/84] new player class --- src/gui/UBMediaPlayer.cpp | 346 +++++++++++++++++++++++++++++++++ src/gui/UBMediaPlayer.h | 92 +++++++++ src/gui/UBTeacherBarWidget.cpp | 2 +- 3 files changed, 439 insertions(+), 1 deletion(-) create mode 100644 src/gui/UBMediaPlayer.cpp create mode 100644 src/gui/UBMediaPlayer.h diff --git a/src/gui/UBMediaPlayer.cpp b/src/gui/UBMediaPlayer.cpp new file mode 100644 index 00000000..17770378 --- /dev/null +++ b/src/gui/UBMediaPlayer.cpp @@ -0,0 +1,346 @@ +#include "UBMediaPlayer.h" + + + +#include + +#define SLIDER_RANGE 8 + + +MediaVideoWidget::MediaVideoWidget(UBMediaPlayer *player, QWidget *parent) : + Phonon::VideoWidget(parent), m_player(player)/*, m_action(this)*/ +{ +// m_action.setCheckable(true); +// m_action.setChecked(false); +// m_action.setShortcut(QKeySequence( Qt::AltModifier + Qt::Key_Return)); +// m_action.setShortcutContext(Qt::WindowShortcut); +// connect(&m_action, SIGNAL(toggled(bool)), SLOT(setFullScreen(bool))); +// addAction(&m_action); +// setAcceptDrops(true); +} + +void MediaVideoWidget::timerEvent(QTimerEvent *e) +{ + if (e->timerId() == m_timer.timerId()) { + //let's store the cursor shape +#ifndef QT_NO_CURSOR + setCursor(Qt::BlankCursor); +#endif + } + Phonon::VideoWidget::timerEvent(e); +} + + +UBMediaPlayer::UBMediaPlayer() : + playButton(0), + m_AudioOutput(Phonon::VideoCategory), + m_videoWidget(new MediaVideoWidget(this)) +{ + setContextMenuPolicy(Qt::CustomContextMenu); + m_videoWidget->setContextMenuPolicy(Qt::CustomContextMenu); + + QSize buttonSize(34, 28); + +// QPushButton *openButton = new QPushButton(this); + +//// openButton->setIcon(style()->standardIcon(QStyle::SP_DialogOpenButton)); +//// QPalette bpal; +//// QColor arrowcolor = bpal.buttonText().color(); +//// if (arrowcolor == Qt::black) +//// arrowcolor = QColor(80, 80, 80); +//// bpal.setBrush(QPalette::ButtonText, arrowcolor); +//// openButton->setPalette(bpal); + +// rewindButton = new QPushButton(this); +// rewindButton->setIcon(style()->standardIcon(QStyle::SP_MediaSkipBackward)); + +// forwardButton = new QPushButton(this); +// forwardButton->setIcon(style()->standardIcon(QStyle::SP_MediaSkipForward)); +// forwardButton->setEnabled(false); + + playButton = new QPushButton(this); + playIcon = style()->standardIcon(QStyle::SP_MediaPlay); + pauseIcon = style()->standardIcon(QStyle::SP_MediaPause); + playButton->setIcon(playIcon); + + slider = new Phonon::SeekSlider(this); + slider->setMediaObject(&m_MediaObject); + + QVBoxLayout *vLayout = new QVBoxLayout(this); + vLayout->setContentsMargins(8, 8, 8, 8); + +// QHBoxLayout *layout = new QHBoxLayout(); + +// info = new QLabel(this); +// info->setMinimumHeight(70); +// info->setAcceptDrops(false); +// info->setMargin(2); +// info->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken); +// info->setLineWidth(2); +// info->setAutoFillBackground(true); + +// QPalette palette; +// palette.setBrush(QPalette::WindowText, Qt::white); +#ifndef Q_WS_MAC +// rewindButton->setMinimumSize(buttonSize); +// forwardButton->setMinimumSize(buttonSize); + playButton->setMinimumSize(buttonSize); +#endif +// info->setStyleSheet("border-image:url(:/images/screen.png) ; border-width:3px"); +// info->setPalette(palette); +// info->setText(tr("
No media
")); + + +// layout->addWidget(rewindButton); +// layout->addWidget(playButton); +// layout->addWidget(forwardButton); + +// layout->addStretch(); + +// vLayout->addWidget(info); + initVideoWindow(); + vLayout->addWidget(&m_videoWindow); + QVBoxLayout *buttonPanelLayout = new QVBoxLayout(); + m_videoWindow.hide(); +// buttonPanelLayout->addLayout(layout); + +// timeLabel = new QLabel(this); + progressLabel = new QLabel(this); + QWidget *sliderPanel = new QWidget(this); + QHBoxLayout *sliderLayout = new QHBoxLayout(); + sliderLayout->addWidget(playButton); + sliderLayout->addWidget(slider); +// sliderLayout->addWidget(timeLabel); + sliderLayout->addWidget(progressLabel); + sliderLayout->setContentsMargins(0, 0, 0, 0); + sliderPanel->setLayout(sliderLayout); + + buttonPanelLayout->addWidget(sliderPanel); + buttonPanelLayout->setContentsMargins(0, 0, 0, 0); +#ifdef Q_OS_MAC +// layout->setSpacing(4); + buttonPanelLayout->setSpacing(0); + info->setMinimumHeight(100); + info->setFont(QFont("verdana", 15)); + openButton->setFocusPolicy(Qt::NoFocus); +#endif + QWidget *buttonPanelWidget = new QWidget(this); + buttonPanelWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); + buttonPanelWidget->setLayout(buttonPanelLayout); + vLayout->addWidget(buttonPanelWidget); + + QHBoxLayout *labelLayout = new QHBoxLayout(); + + vLayout->addLayout(labelLayout); + setLayout(vLayout); + + + // Setup signal connections: +// connect(rewindButton, SIGNAL(clicked()), this, SLOT(rewind())); + + connect(playButton, SIGNAL(clicked()), this, SLOT(playPause())); +// connect(forwardButton, SIGNAL(clicked()), this, SLOT(forward())); + +// connect(&m_MediaObject, SIGNAL(totalTimeChanged(qint64)), this, SLOT(updateTime())); +// connect(&m_MediaObject, SIGNAL(tick(qint64)), this, SLOT(updateTime())); + connect(&m_MediaObject, SIGNAL(finished()), this, SLOT(finished())); + connect(&m_MediaObject, SIGNAL(stateChanged(Phonon::State,Phonon::State)), this, SLOT(stateChanged(Phonon::State,Phonon::State))); + connect(&m_MediaObject, SIGNAL(bufferStatus(int)), this, SLOT(bufferStatus(int))); + connect(&m_MediaObject, SIGNAL(hasVideoChanged(bool)), this, SLOT(hasVideoChanged(bool))); + +// rewindButton->setEnabled(false); + playButton->setEnabled(false); +// setAcceptDrops(true); + + m_audioOutputPath = Phonon::createPath(&m_MediaObject, &m_AudioOutput); + Phonon::createPath(&m_MediaObject, m_videoWidget); + + resize(minimumSizeHint()); +} + +void UBMediaPlayer::stateChanged(Phonon::State newstate, Phonon::State oldstate) +{ + if (oldstate == Phonon::LoadingState) { + QRect videoHintRect = QRect(QPoint(0, 0), m_videoWindow.sizeHint()); + QApplication::desktop()->screenGeometry().intersected(videoHintRect); + + if (m_MediaObject.hasVideo()) { + qApp->processEvents(); + resize(sizeHint()); + } else + resize(minimumSize()); + + } + + switch (newstate) { + case Phonon::ErrorState: + if (m_MediaObject.errorType() == Phonon::FatalError) { + playButton->setEnabled(false); +// rewindButton->setEnabled(false); + } else { + m_MediaObject.pause(); + } + QMessageBox::warning(this, "Phonon UBMediaPlayer", m_MediaObject.errorString(), QMessageBox::Close); + break; + + case Phonon::StoppedState: +// m_videoWidget-> (false); + // Fall through + case Phonon::PausedState: + playButton->setIcon(playIcon); + if (m_MediaObject.currentSource().type() != Phonon::MediaSource::Invalid){ + playButton->setEnabled(true); +// rewindButton->setEnabled(true); + } else { + playButton->setEnabled(false); +// rewindButton->setEnabled(false); + } + break; + case Phonon::PlayingState: + playButton->setEnabled(true); + playButton->setIcon(pauseIcon); + if (m_MediaObject.hasVideo()) + m_videoWindow.show(); + // Fall through + case Phonon::BufferingState: +// rewindButton->setEnabled(true); + break; + case Phonon::LoadingState: +// rewindButton->setEnabled(false); + break; + } + +} + +void UBMediaPlayer::setVolume(qreal volume) +{ + m_AudioOutput.setVolume(volume); +} + + +void UBMediaPlayer::initVideoWindow() +{ + QVBoxLayout *videoLayout = new QVBoxLayout(); + videoLayout->addWidget(m_videoWidget); + videoLayout->setContentsMargins(0, 0, 0, 0); + m_videoWindow.setLayout(videoLayout); + m_videoWindow.setMinimumSize(70, 70); +} + +void UBMediaPlayer::playPause() +{ + if (m_MediaObject.state() == Phonon::PlayingState) + m_MediaObject.pause(); + else { + if (m_MediaObject.currentTime() == m_MediaObject.totalTime()) + m_MediaObject.seek(0); + m_MediaObject.play(); + } +} + +void UBMediaPlayer::setFile(const QString &fileName) +{ + setWindowTitle(fileName.right(fileName.length() - fileName.lastIndexOf('/') - 1)); + m_MediaObject.setCurrentSource(Phonon::MediaSource(fileName)); + m_MediaObject.play(); +} + +void UBMediaPlayer::setLocation(const QString& location) +{ + setWindowTitle(location.right(location.length() - location.lastIndexOf('/') - 1)); + m_MediaObject.setCurrentSource(Phonon::MediaSource(QUrl::fromEncoded(location.toUtf8()))); + m_MediaObject.play(); +} + + +void UBMediaPlayer::openFile() +{ + QStringList fileNames = QFileDialog::getOpenFileNames(this, QString(), QDesktopServices::storageLocation(QDesktopServices::MusicLocation)); + + + m_MediaObject.clearQueue(); + if (fileNames.size() > 0) { + QString fileName = fileNames[0]; + setFile(fileName); + for (int i=1; isetEnabled(m_MediaObject.queue().size() > 0); +} + +void UBMediaPlayer::bufferStatus(int percent) +{ + if (percent == 100) + progressLabel->setText(QString()); + else { + QString str = QString::fromLatin1("(%1%)").arg(percent); + progressLabel->setText(str); + } +} + +//void UBMediaPlayer::updateTime() +//{ +// long len = m_MediaObject.totalTime(); +// long pos = m_MediaObject.currentTime(); +// QString timeString; +// if (pos || len) +// { +// int sec = pos/1000; +// int min = sec/60; +// int hour = min/60; +// int msec = pos; + +// QTime playTime(hour%60, min%60, sec%60, msec%1000); +// sec = len / 1000; +// min = sec / 60; +// hour = min / 60; +// msec = len; + +// QTime stopTime(hour%60, min%60, sec%60, msec%1000); +// QString timeFormat = "m:ss"; +// if (hour > 0) +// timeFormat = "h:mm:ss"; +// timeString = playTime.toString(timeFormat); +// if (len) +// timeString += " / " + stopTime.toString(timeFormat); +// } +// timeLabel->setText(timeString); +//} + +void UBMediaPlayer::rewind() +{ + m_MediaObject.seek(0); +} + +void UBMediaPlayer::forward() +{ + QList queue = m_MediaObject.queue(); + if (queue.size() > 0) { + m_MediaObject.setCurrentSource(queue[0]); +// forwardButton->setEnabled(queue.size() > 1); + m_MediaObject.play(); + } +} + +void UBMediaPlayer::openUrl() +{ + QSettings settings; + settings.beginGroup(QLatin1String("BrowserMainWindow")); + QString sourceURL = settings.value("location").toString(); + bool ok = false; + sourceURL = QInputDialog::getText(this, tr("Open Location"), tr("Please enter a valid address here:"), QLineEdit::Normal, sourceURL, &ok); + if (ok && !sourceURL.isEmpty()) { + setLocation(sourceURL); + settings.setValue("location", sourceURL); + } +} + +void UBMediaPlayer::finished() +{ +} + +void UBMediaPlayer::hasVideoChanged(bool bHasVideo) +{ +// info->setVisible(!bHasVideo); + m_videoWindow.setVisible(bHasVideo); +} diff --git a/src/gui/UBMediaPlayer.h b/src/gui/UBMediaPlayer.h new file mode 100644 index 00000000..6e563698 --- /dev/null +++ b/src/gui/UBMediaPlayer.h @@ -0,0 +1,92 @@ +#ifndef UBUBMediaPlayer_H +#define UBUBMediaPlayer_H + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE +class QPushButton; +class QLabel; +class QSlider; +class QTextEdit; +QT_END_NAMESPACE + +class UBMediaPlayer; + +class MediaVideoWidget : public Phonon::VideoWidget +{ + Q_OBJECT; + +public: + MediaVideoWidget(UBMediaPlayer *player, QWidget *parent = 0); + +protected: + void timerEvent(QTimerEvent *e); + +private: + UBMediaPlayer* m_player; + QBasicTimer m_timer; +// QAction m_action; +}; + +class UBMediaPlayer : public QWidget +{ + Q_OBJECT +public: + UBMediaPlayer(); + + void setFile(const QString &text); + void setLocation(const QString &location); + void setVolume(qreal volume); + +public slots: + void openFile(); + void rewind(); + void forward(); +// void updateTime(); + void finished(); + void playPause(); + +private slots: + void stateChanged(Phonon::State newstate, Phonon::State oldstate); + void bufferStatus(int percent); + void openUrl(); + + void hasVideoChanged(bool); + +private: + void initVideoWindow(); + + QIcon playIcon; + QIcon pauseIcon; + QPushButton *playButton; +// QPushButton *rewindButton; +// QPushButton *forwardButton; + Phonon::SeekSlider *slider; +// QLabel *timeLabel; + QLabel *progressLabel; +// QLabel *info; + + QWidget m_videoWindow; + Phonon::MediaObject m_MediaObject; + Phonon::AudioOutput m_AudioOutput; + MediaVideoWidget *m_videoWidget; + Phonon::Path m_audioOutputPath; +}; + +#endif // UBUBMediaPlayer_H diff --git a/src/gui/UBTeacherBarWidget.cpp b/src/gui/UBTeacherBarWidget.cpp index 75033ed9..ec0cbcce 100644 --- a/src/gui/UBTeacherBarWidget.cpp +++ b/src/gui/UBTeacherBarWidget.cpp @@ -488,7 +488,7 @@ UBTeacherBarDropMediaZone::UBTeacherBarDropMediaZone(QWidget *parent, const char mpTitleLabel = new QLabel(tr("Drop media here")); mpLayout->addWidget(mpTitleLabel); mpTabWidget = new QTabWidget(); - mpTabWidget->setMinimumHeight(200); + mpTabWidget->setMinimumHeight(120); mpTabWidget->addTab(mpImageTab,QIcon(":images/toolbar/extraTool.png"),""); mpTabWidget->addTab(mpVideoTab,QIcon(":images/libpalette/movieIcon.svg"),""); mpTabWidget->addTab(mpAudioTab,QIcon(":images/libpalette/soundIcon.svg"),""); From 23f2cef57de33e68e8fb974d0654f0004b5ad75f Mon Sep 17 00:00:00 2001 From: shibakaneki Date: Tue, 3 Jan 2012 14:47:04 +0100 Subject: [PATCH 03/84] Did some modification on the teacher bar --- resources/images/duration1.png | Bin 0 -> 1164 bytes resources/images/duration2.png | Bin 0 -> 1178 bytes resources/images/duration3.png | Bin 0 -> 1338 bytes resources/sankore.qrc | 3 + src/gui/UBTeacherBarWidget.cpp | 193 ++++++++------------------------- src/gui/UBTeacherBarWidget.h | 18 ++- 6 files changed, 56 insertions(+), 158 deletions(-) create mode 100644 resources/images/duration1.png create mode 100644 resources/images/duration2.png create mode 100644 resources/images/duration3.png diff --git a/resources/images/duration1.png b/resources/images/duration1.png new file mode 100644 index 0000000000000000000000000000000000000000..e05ffa8ee03484d3fc8a798b9e7597f7eaa1ac0d GIT binary patch literal 1164 zcmV;71atd|P)Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L01FcU01FcV0GgZ_00007bV*G`2iySz z4F?R!(zz7?000?uMObu0Z*6U5Zgc=ca%Ew3Wn>_CX>@2HM@dakSAh-}000B$Nkl&*br zt7RoS*Yr6z_2A~p%c=q(jE|NYZ94$yqoR2&7qJ6`Vne8p1A|uXw+i5&t|qe4U@|*a z$*ZAMVEz^`0a$iXDFA?z+xc|o!k>}x!IfuL?)O+U{}h<6#JpYlU8~f^dQVIby}t7F zz#~AUv>Bkwj)%7+0`$7PmYokJvIFI$PEQ%;8-NA7%pZh4G<&<^Vc){TCoK)O0uUqr z0%))H%I-^(r~U0U--}0&Th5rd-e>Z6XPjVO521G3I|JOPI0D3k*M-CMq1oGIW@7Z1 zNOi+bZFJss_=d-#t+y-z5Jk>})4RQePTxdivgN#$2pF%1Ja0#xkPLdq%K{*3`$1fy z_aX1#{pYRScrZV!CE$&#Qh_IK?5a03|}{BTEE+g9zA=DDpRqUV(Lq0IVAUNJ<1CX#`+dA^^)q z02Uzoy+O_a;l< z1;iiSu97+-4cxY3-ZB7Pid2udVvGXneyPs(SHR$vuykmulEwyz6f18J9Y6sH)5qql z^z*=!9mWp?fDVMIgOg>9b_|#;Rnk@!fC3mrkIu6DDK5wEcgYmHUu@RdUAJEb7R~1K eV;$>Qmh=~BJur+Rvz`V30000Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L01FcU01FcV0GgZ_00007bV*G`2iySz z4F@6=1hm=!000?uMObu0Z*6U5Zgc=ca%Ew3Wn>_CX>@2HM@dakSAh-}000B^NklmD2IJKmNqq;L8UUw$!R9^~_w{P|? zGzZ|uZf^iE1i%Ntook#cT3PV3S`WBz}SS-f8TKZkVRIU#^TO9rNeD2XB zK-|)n0eIE;@oGeXRP8Zt(-r0X57{~m4=`^95K_zhV`$%D^oHH0(8n)MtEvFRH@^m; zyVNtgUoD32tv=J*r_atBIpa+-KX+LR=A{rS(#B-~FN=-BZy>b>tgN&_i zOsj>?_g>T3RIp=M5dbmCnbmr=7xI{9XXc#^N+Mvo6!v*F@`Sj}IQ<|1Vs0ORPV~cN z47~r^(f^PLnAF?BN6cZElm$S1`)<7fIBYYzNl`$GfKljFi5A0XUI60CKd4s#dmYBX z>>VLH0*0V-C9Q^`d;olU2XNfT_=o_+g2%0Q0EcZxx3o}_MnEqp(PcH$O9IeI3xKma zrjrD~MiBrT2|yDq08$pFi3FgY769k9_gMG559xw&qTI=S^)55ha&P~ZV4*+3Dn9w=^Pbf2yua!3MiIACPmjKLb)qGDR zGhe8Mw&0PNnPtZTY--JXdyLy$c=2<*&^Wngf_?zoS~1_8;I~~-&M#-IEC6DmG@u0t z%?Wq s1bx@$2q5UZIGF=RNnf3P(vv9HUq!8q0QEr*YXATM07*qoM6N<$f`fen1^@s6 literal 0 HcmV?d00001 diff --git a/resources/images/duration3.png b/resources/images/duration3.png new file mode 100644 index 0000000000000000000000000000000000000000..9280a6421ebe27461f8043180d4ed2b2e2fdc4f7 GIT binary patch literal 1338 zcmV-A1;zS_P)Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L01FcU01FcV0GgZ_00007bV*G`2iySz z4F@-Q*-$Y6000?uMObu0Z*6U5Zgc=ca%Ew3Wn>_CX>@2HM@dakSAh-}000D)Nkl=0T^xQBzs&Zf~;mnqK00IcM&! z-`CIG<@N9xoVEF6Q78(!RHV4Ac7J+sxG(gjlIw5MIhxY^^v$pSpN_59X_nn_~bnYbqKD8A-A~wn=3P7g!J!%86+)R6fQXrH7 zFI1|Sner9{kQw>A)e0c&pu2Ntgxm!5K;>FDQ9XqKbg3P{N+anK1d!SAc+?JHxtaFx zH%j~jxSUsTBY_<&V8)Yl3aJo(D$}XieD!lokiU;Xhzzpd`~-(I3#PnVJB4tkz{>&Nuj z(eBV^Qm&_^K6v5Vwa|wz*Ih3A2QRK3qFN4Wh4?jMymO z|FwZCnUAJ~K*Y?HcfaZhCHvW2u13b~4eKVVXQh#J6`Kl0eK;wk3m5G*Nj-5V48)l* w5KG)hnl@@tzgbO;k1EN5e>(e2&!lnv3z>$(?+sp-)Bpeg07*qoM6N<$f*>kfH~;_u literal 0 HcmV?d00001 diff --git a/resources/sankore.qrc b/resources/sankore.qrc index c0ff2a69..8601be9f 100644 --- a/resources/sankore.qrc +++ b/resources/sankore.qrc @@ -338,5 +338,8 @@ images/download_close.png images/download_open.png images/tab_mask.png + images/duration1.png + images/duration2.png + images/duration3.png diff --git a/src/gui/UBTeacherBarWidget.cpp b/src/gui/UBTeacherBarWidget.cpp index ec0cbcce..bf454bf2 100644 --- a/src/gui/UBTeacherBarWidget.cpp +++ b/src/gui/UBTeacherBarWidget.cpp @@ -15,26 +15,20 @@ UBTeacherBarWidget::UBTeacherBarWidget(QWidget *parent, const char *name):UBDockPaletteWidget(parent) , mpLayout(NULL) , mpTitleLayout(NULL) - , mpPhasisLayout(NULL) , mpDurationLayout(NULL) - , mpEquipmentLayout(NULL) - , mpActivityLayout(NULL) , mpTitleLabel(NULL) - , mpPhasisLabel(NULL) , mpDurationLabel(NULL) - , mpEquipmentLabel(NULL) - , mpActivityLabel(NULL) , mpTitle(NULL) - , mpEquipment(NULL) - , mpPhasis(NULL) - , mpDuration(NULL) - , mpActivity(NULL) , mpAction1(NULL) , mpAction2(NULL) , mpAction3(NULL) , mpDropMediaZone(NULL) , mpContainer(NULL) , mpContainerLayout(NULL) + , mpDuration1(NULL) + , mpDuration2(NULL) + , mpDuration3(NULL) + , mpDurationButtons(NULL) { setObjectName(name); mName = "TeacherBarWidget"; @@ -69,51 +63,26 @@ UBTeacherBarWidget::UBTeacherBarWidget(QWidget *parent, const char *name):UBDock mpTitleLayout->addWidget(mpTitle, 1); mpLayout->addLayout(mpTitleLayout); - // Phasis - mpPhasisLabel = new QLabel(tr("Phasis"), mpContainer); - mpPhasisLabel->setMinimumWidth(LABEL_MINWIDHT); - mpPhasisLabel->setAlignment(Qt::AlignRight); - mpPhasis = new QComboBox(mpContainer); - mpPhasis->setObjectName("DockPaletteWidgetComboBox"); - mpPhasisLayout = new QHBoxLayout(); - mpPhasisLayout->addWidget(mpPhasisLabel, 0); - mpPhasisLayout->addWidget(mpPhasis, 1); - mpLayout->addLayout(mpPhasisLayout); - // Duration mpDurationLabel = new QLabel(tr("Duration"), mpContainer); mpDurationLabel->setMinimumWidth(LABEL_MINWIDHT); - mpDurationLabel->setAlignment(Qt::AlignRight); - mpDuration = new QComboBox(mpContainer); - mpDuration->setObjectName("DockPaletteWidgetComboBox"); mpDurationLayout = new QHBoxLayout(); - mpDurationLayout->addWidget(mpDurationLabel, 0); - mpDurationLayout->addWidget(mpDuration, 1); + mpDurationLayout->addWidget(mpDurationLabel, 1); + mpDuration1 = new QCheckBox(this); + mpDuration1->setIcon(QIcon(":images/duration1.png")); + mpDurationLayout->addWidget(mpDuration1, 0); + mpDuration2 = new QCheckBox(this); + mpDuration2->setIcon(QIcon(":images/duration2.png")); + mpDurationLayout->addWidget(mpDuration2, 0); + mpDuration3 = new QCheckBox(this); + mpDuration3->setIcon(QIcon(":images/duration3.png")); + mpDurationLayout->addWidget(mpDuration3, 0); + mpDurationButtons = new QButtonGroup(this); + mpDurationButtons->addButton(mpDuration1); + mpDurationButtons->addButton(mpDuration2); + mpDurationButtons->addButton(mpDuration3); mpLayout->addLayout(mpDurationLayout); - // Equipment - mpEquipmentLabel = new QLabel(tr("Equipment"), mpContainer); - mpEquipmentLabel->setMinimumWidth(LABEL_MINWIDHT); - mpEquipmentLabel->setAlignment(Qt::AlignRight); - mpEquipment = new QLineEdit(mpContainer); - mpEquipment->setObjectName("DockPaletteWidgetLineEdit"); - connect(mpEquipment, SIGNAL(textChanged(const QString&)), this, SLOT(onEquipmentTextChanged(const QString&))); - mpEquipmentLayout = new QHBoxLayout(); - mpEquipmentLayout->addWidget(mpEquipmentLabel, 0); - mpEquipmentLayout->addWidget(mpEquipment, 1); - mpLayout->addLayout(mpEquipmentLayout); - - // Activity - mpActivityLabel = new QLabel(tr("Activity"), mpContainer); - mpActivityLabel->setMinimumWidth(LABEL_MINWIDHT); - mpActivityLabel->setAlignment(Qt::AlignRight); - mpActivity = new QComboBox(mpContainer); - mpActivity->setObjectName("DockPaletteWidgetComboBox"); - mpActivityLayout = new QHBoxLayout(); - mpActivityLayout->addWidget(mpActivityLabel, 0); - mpActivityLayout->addWidget(mpActivity, 1); - mpLayout->addLayout(mpActivityLayout); - // Actions mpAction1 = new UBTeacherStudentAction(1, mpContainer); mpAction2 = new UBTeacherStudentAction(2, mpContainer); @@ -133,10 +102,6 @@ UBTeacherBarWidget::UBTeacherBarWidget(QWidget *parent, const char *name):UBDock connect(UBApplication::boardController, SIGNAL(activeSceneChanged()), this, SLOT(loadContent())); connect(UBApplication::mainWindow->actionQuit, SIGNAL(triggered()), this, SLOT(saveContent())); connect(mpTitle, SIGNAL(textChanged(QString)), this, SLOT(onValueChanged())); - connect(mpPhasis, SIGNAL(currentIndexChanged(int)), this, SLOT(onValueChanged())); - connect(mpDuration, SIGNAL(currentIndexChanged(int)), this, SLOT(onValueChanged())); - connect(mpEquipment, SIGNAL(textChanged(QString)), this, SLOT(onValueChanged())); - connect(mpActivity, SIGNAL(currentIndexChanged(int)), this, SLOT(onValueChanged())); connect(mpAction1->teacher(), SIGNAL(textChanged()), this, SLOT(onValueChanged())); connect(mpAction1->student(), SIGNAL(textChanged()), this, SLOT(onValueChanged())); connect(mpAction2->teacher(), SIGNAL(textChanged()), this, SLOT(onValueChanged())); @@ -147,108 +112,67 @@ UBTeacherBarWidget::UBTeacherBarWidget(QWidget *parent, const char *name):UBDock UBTeacherBarWidget::~UBTeacherBarWidget() { - if(NULL != mpDropMediaZone) - { + if(NULL != mpDropMediaZone){ delete mpDropMediaZone; mpDropMediaZone = NULL; } - if(NULL != mpAction3) - { + if(NULL != mpAction3){ delete mpAction3; mpAction3 = NULL; } - if(NULL != mpAction2) - { + if(NULL != mpAction2){ delete mpAction2; mpAction2 = NULL; } - if(NULL != mpAction1) - { + if(NULL != mpAction1){ delete mpAction1; mpAction1 = NULL; } - if(NULL != mpActivityLabel) - { - delete mpActivityLabel; - mpActivityLabel = NULL; - } - if(NULL != mpActivity) - { - delete mpActivity; - mpActivity = NULL; - } - if(NULL != mpActivityLayout) - { - delete mpActivityLayout; - mpActivityLayout = NULL; - } - if(NULL != mpEquipmentLabel) - { - delete mpEquipmentLabel; - mpEquipmentLabel = NULL; + if(NULL != mpDurationLabel){ + delete mpDurationLabel; + mpDurationLabel = NULL; } - if(NULL != mpEquipment) - { - delete mpEquipment; - mpEquipment = NULL; + if(NULL != mpDuration1){ + delete mpDuration1; + mpDuration1 = NULL; } - if(NULL != mpEquipmentLayout) - { - delete mpEquipmentLayout; - mpEquipmentLayout = NULL; + if(NULL != mpDuration2){ + delete mpDuration2; + mpDuration2 = NULL; } - if(NULL != mpDurationLabel) - { - delete mpDurationLabel; - mpDurationLabel = NULL; + if(NULL != mpDuration3){ + delete mpDuration3; + mpDuration3 = NULL; } - if(NULL != mpDuration) - { - delete mpDuration; - mpDuration = NULL; + if(NULL != mpDurationButtons){ + delete mpDurationButtons; + mpDurationButtons = NULL; } - if(NULL != mpDurationLayout) - { + if(NULL != mpDurationLayout){ delete mpDurationLayout; mpDurationLayout = NULL; } - if(NULL != mpPhasisLabel) - { - delete mpPhasisLabel; - mpPhasisLabel = NULL; - } - if(NULL != mpPhasisLayout) - { - delete mpPhasisLayout; - mpPhasisLayout = NULL; - } - if(NULL != mpTitleLabel) - { + if(NULL != mpTitleLabel){ delete mpTitleLabel; mpTitleLabel = NULL; } - if(NULL != mpTitle) - { + if(NULL != mpTitle){ delete mpTitle; mpTitle = NULL; } - if(NULL != mpTitleLayout) - { + if(NULL != mpTitleLayout){ delete mpTitleLayout; mpTitleLayout = NULL; } - if(NULL != mpLayout) - { + if(NULL != mpLayout){ delete mpLayout; mpLayout = NULL; } - if(NULL != mpContainer) - { + if(NULL != mpContainer){ delete mpContainer; mpContainer = NULL; } - if(NULL != mpContainerLayout) - { + if(NULL != mpContainerLayout){ delete mpContainerLayout; mpContainerLayout = NULL; } @@ -256,29 +180,12 @@ UBTeacherBarWidget::~UBTeacherBarWidget() void UBTeacherBarWidget::populateCombos() { - QStringList qslPhasis; - qslPhasis << tr("") << tr("I discover") << tr("I experiment") << tr("I train myself") << tr("I play") << tr("I memorize"); - mpPhasis->insertItems(0, qslPhasis); - mpPhasis->setCurrentIndex(0); - - QStringList qslDuration; - qslDuration << tr("") << tr("Short") << tr("Middle") << tr("Long"); - mpDuration->insertItems(0, qslDuration); - mpDuration->setCurrentIndex(0); - - QStringList qslActivity; - qslActivity << tr("") << tr("Alone") << tr("By Group") << tr("All together"); - mpActivity->insertItems(0, qslActivity); - mpActivity->setCurrentIndex(0); + } void UBTeacherBarWidget::onValueChanged() { if( mpTitle->text() == "" - && mpDuration->currentIndex() == 0 - && mpPhasis->currentIndex() == 0 - && mpEquipment->text() == "" - && mpActivity->currentIndex() == 0 && mpAction1->teacherText() == "" && mpAction1->studentText() == "" && mpAction2->teacherText() == "" @@ -302,10 +209,6 @@ void UBTeacherBarWidget::saveContent() { sTeacherBarInfos infos; infos.title = mpTitle->text(); - infos.phasis = mpPhasis->currentIndex(); - infos.Duration = mpDuration->currentIndex(); - infos.material = mpEquipment->text(); - infos.activity = mpActivity->currentIndex(); infos.action1Master = mpAction1->teacherText(); infos.action1Student = mpAction1->studentText(); infos.action2Master = mpAction2->teacherText(); @@ -319,10 +222,6 @@ void UBTeacherBarWidget::loadContent() { sTeacherBarInfos nextInfos = UBPersistenceManager::persistenceManager()->getTeacherBarInfos(UBApplication::boardController->activeDocument(), UBApplication::boardController->activeSceneIndex()); mpTitle->setText(nextInfos.title); - mpPhasis->setCurrentIndex(nextInfos.phasis); - mpDuration->setCurrentIndex(nextInfos.Duration); - mpEquipment->setText(nextInfos.material); - mpActivity->setCurrentIndex(nextInfos.activity); mpAction1->setTeacherText(nextInfos.action1Master); mpAction1->setStudentText(nextInfos.action1Student); mpAction2->setTeacherText(nextInfos.action2Master); @@ -338,7 +237,7 @@ void UBTeacherBarWidget::onTitleTextChanged(const QString& text) void UBTeacherBarWidget::onEquipmentTextChanged(const QString& text) { - mpEquipment->setToolTip(text); + } UBTeacherStudentAction::UBTeacherStudentAction(int actionNumber, QWidget *parent, const char *name):QWidget(parent) diff --git a/src/gui/UBTeacherBarWidget.h b/src/gui/UBTeacherBarWidget.h index 585e7f8a..ec7946fb 100644 --- a/src/gui/UBTeacherBarWidget.h +++ b/src/gui/UBTeacherBarWidget.h @@ -10,7 +10,9 @@ class UBVideoPlayer; #include #include #include -#include +#include +#include +#include #include "UBDockPaletteWidget.h" @@ -85,26 +87,20 @@ private: QVBoxLayout* mpLayout; QHBoxLayout* mpTitleLayout; - QHBoxLayout* mpPhasisLayout; QHBoxLayout* mpDurationLayout; - QHBoxLayout* mpEquipmentLayout; - QHBoxLayout* mpActivityLayout; QLabel* mpTitleLabel; - QLabel* mpPhasisLabel; QLabel* mpDurationLabel; - QLabel* mpEquipmentLabel; - QLabel* mpActivityLabel; QLineEdit* mpTitle; - QLineEdit* mpEquipment; - QComboBox* mpPhasis; - QComboBox* mpDuration; - QComboBox* mpActivity; UBTeacherStudentAction* mpAction1; UBTeacherStudentAction* mpAction2; UBTeacherStudentAction* mpAction3; UBTeacherBarDropMediaZone* mpDropMediaZone; QWidget* mpContainer; QVBoxLayout* mpContainerLayout; + QCheckBox* mpDuration1; + QCheckBox* mpDuration2; + QCheckBox* mpDuration3; + QButtonGroup* mpDurationButtons; }; #endif // UBTEACHERBARWIDGET_H From df8a8a5ec9dfe61cf5b1efa9b5fe414fc39296da Mon Sep 17 00:00:00 2001 From: Claudio Valerio Date: Wed, 4 Jan 2012 13:21:12 +0100 Subject: [PATCH 04/84] added class UBWidgetList --- Sankore_3.1.pro | 2 + src/customWidgets/UBWidgetList.cpp | 133 ++++++++++++++++++++++++++++ src/customWidgets/UBWidgetList.h | 44 +++++++++ src/customWidgets/customWidgets.pri | 5 ++ 4 files changed, 184 insertions(+) create mode 100644 src/customWidgets/UBWidgetList.cpp create mode 100644 src/customWidgets/UBWidgetList.h create mode 100644 src/customWidgets/customWidgets.pri diff --git a/Sankore_3.1.pro b/Sankore_3.1.pro index 3005b8b1..5dfa1b33 100644 --- a/Sankore_3.1.pro +++ b/Sankore_3.1.pro @@ -53,6 +53,7 @@ include(src/desktop/desktop.pri) include(src/web/web.pri) include(src/softwareupdate/softwareupdate.pri) include(src/transition/transition.pri) +include(src/customWidgets/customWidgets.pri) DEPENDPATH += src/pdf-merger INCLUDEPATH += src/pdf-merger @@ -398,3 +399,4 @@ INSTALLS = UB_ETC \ UB_THIRDPARTY_INTERACTIVE OTHER_FILES += + diff --git a/src/customWidgets/UBWidgetList.cpp b/src/customWidgets/UBWidgetList.cpp new file mode 100644 index 00000000..2daf1576 --- /dev/null +++ b/src/customWidgets/UBWidgetList.cpp @@ -0,0 +1,133 @@ +#include +#include "UBWidgetList.h" + +UBWidgetList::UBWidgetList(QWidget* parent, eWidgetListOrientation orientation, const char* name):QScrollArea(parent) + , mpLayout(NULL) + , mpContainer(NULL) + , mMargin(5) + , mpEmptyLabel(NULL) +{ + setObjectName(name); + mOrientation = orientation; + mpContainer = new QWidget(this); + mWidgets.clear(); + + if(eWidgetListOrientation_Vertical == orientation){ + setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); + setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + mpLayout = new QVBoxLayout(mpContainer); + mpContainer->resize(width(), mpContainer->height()); + }else{ + setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded); + setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + mpLayout = new QHBoxLayout(mpContainer); + mpContainer->resize(mpContainer->width(), height()); + } + mpLayout->setContentsMargins(margin(), margin(), margin(), margin()); + mpContainer->setLayout(mpLayout); + setWidget(mpContainer); +} + +UBWidgetList::~UBWidgetList() +{ + if(NULL != mpEmptyLabel){ + delete mpEmptyLabel; + mpEmptyLabel = NULL; + } + if(NULL != mpLayout){ + delete mpLayout; + mpLayout = NULL; + } + if(NULL != mpContainer){ + delete mpContainer; + mpContainer = NULL; + } +} + +void UBWidgetList::addWidget(QWidget *widget) +{ + if(NULL != mpLayout){ + updateSize(true, widget); + mpLayout->addWidget(widget); + mWidgets << widget; + } +} + +void UBWidgetList::removeWidget(QWidget *widget) +{ + if(NULL != mpLayout){ + mpLayout->removeWidget(widget); + mWidgets.remove(mWidgets.indexOf(widget)); + updateSize(false, widget); + widget->setVisible(false); + } +} + +void UBWidgetList::updateSize(bool widgetAdded, QWidget *widget) +{ + float scaleFactor; + int newWidgetWidth; + int newWidgetHeight; + + if(eWidgetListOrientation_Vertical == mOrientation){ + scaleFactor = (float)widget->width() / (float)mpContainer->width(); + }else{ + scaleFactor = (float)widget->height() / (float)mpContainer->height(); + } + + newWidgetWidth = widget->width()*scaleFactor; + newWidgetHeight = widget->height()*scaleFactor; + + widget->resize(newWidgetWidth, newWidgetHeight); + + // Now we have to update the container + if(eWidgetListOrientation_Vertical == mOrientation){ + if(widgetAdded){ + mpContainer->resize(mpContainer->width(), mpContainer->height() + newWidgetHeight); + }else{ + mpContainer->resize(mpContainer->width(), mpContainer->height() - newWidgetHeight); + } + }else{ + if(widgetAdded){ + mpContainer->resize(mpContainer->width() + newWidgetWidth, mpContainer->height()); + }else{ + mpContainer->resize(mpContainer->width() - newWidgetWidth, mpContainer->height()); + } + } +} + +void UBWidgetList::resizeEvent(QResizeEvent *ev) +{ + if(ev->oldSize().width() >= 0 && ev->oldSize().height() >= 0){ + float scale; + if(eWidgetListOrientation_Vertical == mOrientation){ + scale = (float)ev->size().width() / (float)ev->oldSize().width(); + updateAllWidgetsize(scale); + mpContainer->resize(width() - 2, mpContainer->height()*scale); + }else{ + scale = (float)ev->size().height() / (float)ev->oldSize().height(); + updateAllWidgetsize(scale); + mpContainer->resize(mpContainer->width()*scale, height() - 2); + } + } +} + +void UBWidgetList::updateAllWidgetsize(float scale) +{ + for(int i=0; iresize(mWidgets.at(i)->width()*scale, mWidgets.at(i)->height()*scale); + } +} + +void UBWidgetList::setMargin(int margin) +{ + mMargin = margin; +} + +int UBWidgetList::margin() +{ + return mMargin; +} + +// TODO : - add onHover 'delete' button +// - add empty label diff --git a/src/customWidgets/UBWidgetList.h b/src/customWidgets/UBWidgetList.h new file mode 100644 index 00000000..171ece88 --- /dev/null +++ b/src/customWidgets/UBWidgetList.h @@ -0,0 +1,44 @@ +#ifndef UBWIDGETLIST_H +#define UBWIDGETLIST_H + +#include +#include +#include +#include +#include +#include +#include +#include + +typedef enum{ + eWidgetListOrientation_Vertical, + eWidgetListOrientation_Horizontal +}eWidgetListOrientation; + +class UBWidgetList : public QScrollArea +{ + Q_OBJECT + +public: + UBWidgetList(QWidget* parent=0, eWidgetListOrientation orientation = eWidgetListOrientation_Vertical, const char* name = "UBWidgetList"); + ~UBWidgetList(); + void addWidget(QWidget* widget); + void removeWidget(QWidget* widget); + void setMargin(int margin); + int margin(); + +protected: + void resizeEvent(QResizeEvent* ev); + +private: + void updateSize(bool widgetAdded, QWidget* widget); + void updateAllWidgetsize(float scale); + QLayout* mpLayout; + QWidget* mpContainer; + eWidgetListOrientation mOrientation; + int mMargin; + QVector mWidgets; + QLabel* mpEmptyLabel; +}; + +#endif // UBWIDGETLIST_H diff --git a/src/customWidgets/customWidgets.pri b/src/customWidgets/customWidgets.pri new file mode 100644 index 00000000..a5609d31 --- /dev/null +++ b/src/customWidgets/customWidgets.pri @@ -0,0 +1,5 @@ + +HEADERS += src/customWidgets/UBWidgetList.h + +SOURCES += src/customWidgets/UBWidgetList.cpp + From f5931f0f05536d67f064fcfa7ccee6d966d6f7c9 Mon Sep 17 00:00:00 2001 From: shibakaneki Date: Wed, 4 Jan 2012 13:46:03 +0100 Subject: [PATCH 05/84] src/adaptors --- src/customWidgets/UBWidgetList.cpp | 18 ++++++++++++++- src/customWidgets/UBWidgetList.h | 1 + src/gui/UBTeacherBarWidget.cpp | 37 ++---------------------------- src/gui/UBTeacherBarWidget.h | 2 -- 4 files changed, 20 insertions(+), 38 deletions(-) diff --git a/src/customWidgets/UBWidgetList.cpp b/src/customWidgets/UBWidgetList.cpp index 2daf1576..87a9538d 100644 --- a/src/customWidgets/UBWidgetList.cpp +++ b/src/customWidgets/UBWidgetList.cpp @@ -11,6 +11,8 @@ UBWidgetList::UBWidgetList(QWidget* parent, eWidgetListOrientation orientation, mOrientation = orientation; mpContainer = new QWidget(this); mWidgets.clear(); + mpEmptyLabel = new QLabel(this); + mpEmptyLabel->setObjectName("emptyString"); if(eWidgetListOrientation_Vertical == orientation){ setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); @@ -47,6 +49,7 @@ UBWidgetList::~UBWidgetList() void UBWidgetList::addWidget(QWidget *widget) { if(NULL != mpLayout){ + mpEmptyLabel->setVisible(false); updateSize(true, widget); mpLayout->addWidget(widget); mWidgets << widget; @@ -60,6 +63,9 @@ void UBWidgetList::removeWidget(QWidget *widget) mWidgets.remove(mWidgets.indexOf(widget)); updateSize(false, widget); widget->setVisible(false); + if(0 == mpLayout->count()){ + mpEmptyLabel->setVisible(true); + } } } @@ -98,6 +104,10 @@ void UBWidgetList::updateSize(bool widgetAdded, QWidget *widget) void UBWidgetList::resizeEvent(QResizeEvent *ev) { + mpEmptyLabel->setGeometry((width() - mpEmptyLabel->width()) / 2, + (height() - mpEmptyLabel->height()) /2, + mpEmptyLabel->width(), + mpEmptyLabel->height()); if(ev->oldSize().width() >= 0 && ev->oldSize().height() >= 0){ float scale; if(eWidgetListOrientation_Vertical == mOrientation){ @@ -129,5 +139,11 @@ int UBWidgetList::margin() return mMargin; } +void UBWidgetList::setEmptyText(const QString &text) +{ + if(NULL != mpEmptyLabel){ + mpEmptyLabel->setText(text); + } +} + // TODO : - add onHover 'delete' button -// - add empty label diff --git a/src/customWidgets/UBWidgetList.h b/src/customWidgets/UBWidgetList.h index 171ece88..87337458 100644 --- a/src/customWidgets/UBWidgetList.h +++ b/src/customWidgets/UBWidgetList.h @@ -25,6 +25,7 @@ public: void addWidget(QWidget* widget); void removeWidget(QWidget* widget); void setMargin(int margin); + void setEmptyText(const QString& text); int margin(); protected: diff --git a/src/gui/UBTeacherBarWidget.cpp b/src/gui/UBTeacherBarWidget.cpp index bf454bf2..2557b50b 100644 --- a/src/gui/UBTeacherBarWidget.cpp +++ b/src/gui/UBTeacherBarWidget.cpp @@ -20,8 +20,6 @@ UBTeacherBarWidget::UBTeacherBarWidget(QWidget *parent, const char *name):UBDock , mpDurationLabel(NULL) , mpTitle(NULL) , mpAction1(NULL) - , mpAction2(NULL) - , mpAction3(NULL) , mpDropMediaZone(NULL) , mpContainer(NULL) , mpContainerLayout(NULL) @@ -53,11 +51,9 @@ UBTeacherBarWidget::UBTeacherBarWidget(QWidget *parent, const char *name):UBDock // Title mpTitleLabel = new QLabel(tr("Title"), mpContainer); - mpTitleLabel->setMinimumWidth(LABEL_MINWIDHT); - mpTitleLabel->setAlignment(Qt::AlignRight); mpTitle = new QLineEdit(mpContainer); mpTitle->setObjectName("DockPaletteWidgetLineEdit"); - connect(mpTitle, SIGNAL(textChanged(const QString&)), this, SLOT(onTitleTextChanged(const QString&))); + connect(mpTitle, SIGNAL(textChanged(const QString&)), this, SLOT(onTitleTextChanged(const QString&))); mpTitleLayout = new QHBoxLayout(); mpTitleLayout->addWidget(mpTitleLabel, 0); mpTitleLayout->addWidget(mpTitle, 1); @@ -65,7 +61,6 @@ UBTeacherBarWidget::UBTeacherBarWidget(QWidget *parent, const char *name):UBDock // Duration mpDurationLabel = new QLabel(tr("Duration"), mpContainer); - mpDurationLabel->setMinimumWidth(LABEL_MINWIDHT); mpDurationLayout = new QHBoxLayout(); mpDurationLayout->addWidget(mpDurationLabel, 1); mpDuration1 = new QCheckBox(this); @@ -85,12 +80,8 @@ UBTeacherBarWidget::UBTeacherBarWidget(QWidget *parent, const char *name):UBDock // Actions mpAction1 = new UBTeacherStudentAction(1, mpContainer); - mpAction2 = new UBTeacherStudentAction(2, mpContainer); - mpAction3 = new UBTeacherStudentAction(3, mpContainer); mpLayout->addWidget(mpAction1); - mpLayout->addWidget(mpAction2); - mpLayout->addWidget(mpAction3); // Media mpDropMediaZone = new UBTeacherBarDropMediaZone(); @@ -104,10 +95,6 @@ UBTeacherBarWidget::UBTeacherBarWidget(QWidget *parent, const char *name):UBDock connect(mpTitle, SIGNAL(textChanged(QString)), this, SLOT(onValueChanged())); connect(mpAction1->teacher(), SIGNAL(textChanged()), this, SLOT(onValueChanged())); connect(mpAction1->student(), SIGNAL(textChanged()), this, SLOT(onValueChanged())); - connect(mpAction2->teacher(), SIGNAL(textChanged()), this, SLOT(onValueChanged())); - connect(mpAction2->student(), SIGNAL(textChanged()), this, SLOT(onValueChanged())); - connect(mpAction3->teacher(), SIGNAL(textChanged()), this, SLOT(onValueChanged())); - connect(mpAction3->student(), SIGNAL(textChanged()), this, SLOT(onValueChanged())); } UBTeacherBarWidget::~UBTeacherBarWidget() @@ -116,14 +103,6 @@ UBTeacherBarWidget::~UBTeacherBarWidget() delete mpDropMediaZone; mpDropMediaZone = NULL; } - if(NULL != mpAction3){ - delete mpAction3; - mpAction3 = NULL; - } - if(NULL != mpAction2){ - delete mpAction2; - mpAction2 = NULL; - } if(NULL != mpAction1){ delete mpAction1; mpAction1 = NULL; @@ -187,11 +166,7 @@ void UBTeacherBarWidget::onValueChanged() { if( mpTitle->text() == "" && mpAction1->teacherText() == "" - && mpAction1->studentText() == "" - && mpAction2->teacherText() == "" - && mpAction2->studentText() == "" - && mpAction3->teacherText() == "" - && mpAction3->studentText() == "") + && mpAction1->studentText() == "") { mIconToLeft = QPixmap(":images/teacher_open_disabled.png"); mIconToRight = QPixmap(":images/teacher_close_disabled.png"); @@ -211,10 +186,6 @@ void UBTeacherBarWidget::saveContent() infos.title = mpTitle->text(); infos.action1Master = mpAction1->teacherText(); infos.action1Student = mpAction1->studentText(); - infos.action2Master = mpAction2->teacherText(); - infos.action2Student = mpAction2->studentText(); - infos.action3Master = mpAction3->teacherText(); - infos.action3Student = mpAction3->studentText(); UBPersistenceManager::persistenceManager()->persistTeacherBar(UBApplication::boardController->activeDocument(), UBApplication::boardController->activeSceneIndex(), infos); } @@ -224,10 +195,6 @@ void UBTeacherBarWidget::loadContent() mpTitle->setText(nextInfos.title); mpAction1->setTeacherText(nextInfos.action1Master); mpAction1->setStudentText(nextInfos.action1Student); - mpAction2->setTeacherText(nextInfos.action2Master); - mpAction2->setStudentText(nextInfos.action2Student); - mpAction3->setTeacherText(nextInfos.action3Master); - mpAction3->setStudentText(nextInfos.action3Student); } void UBTeacherBarWidget::onTitleTextChanged(const QString& text) diff --git a/src/gui/UBTeacherBarWidget.h b/src/gui/UBTeacherBarWidget.h index ec7946fb..67a3e97b 100644 --- a/src/gui/UBTeacherBarWidget.h +++ b/src/gui/UBTeacherBarWidget.h @@ -92,8 +92,6 @@ private: QLabel* mpDurationLabel; QLineEdit* mpTitle; UBTeacherStudentAction* mpAction1; - UBTeacherStudentAction* mpAction2; - UBTeacherStudentAction* mpAction3; UBTeacherBarDropMediaZone* mpDropMediaZone; QWidget* mpContainer; QVBoxLayout* mpContainerLayout; From e4d14dcf8b34f56f25816bca64da9051aba33631 Mon Sep 17 00:00:00 2001 From: shibakaneki Date: Wed, 4 Jan 2012 14:00:08 +0100 Subject: [PATCH 06/84] updated missing files --- resources/images/duration1.png | Bin 1164 -> 795 bytes resources/images/duration2.png | Bin 1178 -> 909 bytes resources/images/duration3.png | Bin 1338 -> 1140 bytes 3 files changed, 0 insertions(+), 0 deletions(-) diff --git a/resources/images/duration1.png b/resources/images/duration1.png index e05ffa8ee03484d3fc8a798b9e7597f7eaa1ac0d..5f1f83557afb6952748ea72cc2aad8364c6e5d55 100644 GIT binary patch delta 675 zcmV;U0$lx!37ZCxVFwNY27DVy)RAZ>e*$(%L_t(|+U=S*V zAwe-JT4}&a5XC4cT8Suv;5H&?Cw7Wr;|oMlD@DQ0x{LTIglH$CpahE`SL1iGs!&eICCGT3WRVu-#PccN#+7DE@bxt;^t3L>%GF(lCRg5@A22tOgiODe~XXa zjF|9d#OtCr@p63h_CIj|a+%fwpry9wSUivt|M*|B`x7I#|6C0~uW=&)iqASaAl1t6*KA+{Szd`w!|8ptX0H~>f*J3knj>Al%7 z^I5?u^EkE8+_gS@TDxL<18^J1f7Jj5U%PA_OJjTDShR3&@&hX8qG`Es_q<_+^rcj1%Pz( z@*{F~HC)Ej3{WZ&Dwr_@fR^+n?Nmg2r?zWanQZ_7z+IIvp$h^HNJwaMp zpp|}J05m|zWnLEmk|E?X&u0J_xGPLr3-qLK2mnbC^qMye!0jN67`Ft#jS$S3w*@ZBJA7`Fw0-5_upw-o?R7C6_IEse*@=9L_t(|+U=V^OcPNY$3NHBAjLm)B5~0W z5=~DM5X*#hA{Y{2g0MMgNH8WWCa@Vd8eK?K5`u$U0~0neB9j#tDuD#A(L{+ZBuvFW zEt1&QfoHhXYq?$z=-uNx-?jJsyx+aw@AvLKkX*_^|3OAo&j1}j8xRB&*brt7RoS*Yr6z_2A~p%c=q(jE|NY zZ94$yqoR2&7qJ6`Vne8p1A|uXf42(YpROjd(O@z=R>`ZORABxVFacP0Q7Hg`liT@p z=faQ_R8){lc)Xde>LBWM~_?1 zn7Q6(@^@#PU|tWQcH27x+^9GL#Dv#{!}Ouq+ht~A^q5F>!%l5<-gWqf$D*ybECCQj z&VOpep0c^`+f4XL8&#Qh_IK?5a z03|}{BTEE+g9zA=DDpRqUV(Lq0IVAUNJ<1CX#`+dA^^)q02USvP1^)If%$3sXfb7ic{&j3Kk0 R1^@s607*qo1w^hwV1gS1=$ill diff --git a/resources/images/duration2.png b/resources/images/duration2.png index 29263f1403c45f83da86d00f2492fa74d0c2763d..37dcb1cacca0c1b080717f93e5119839e10852ce 100644 GIT binary patch delta 790 zcmV+x1L^#l35^GkVFwNd2Si=(g^_3{e*)-9L_t(|+U=V^XcJK!$KPEGog&H73>FNM zL4v_liIWXDsHH@k2r2Dk#Zah!mY_77xHTv){s{y{oeTz&ixn|C1g@PLYEvSiLntSh z;aqZWQnpIUj-{?_-MwA>MI3-mrrQB%Cx4aW9fGo97vv5$ysA(3`LmldVgl`fw0MHwu5r7eZzr6^c z0Zd6X0W<(xO*sG!z$z(af9L>qKm)MUm975(FxQ_j5X}3l9IyR+4lV%>LD>Mk53q}J zsx1K8r$MN~Wt$tSKqbIgkrQ3F!nCHqU*-5#eT85W;4aBA-7iD5rC@2FOSbDO1(5(( zxe+z|I!sFnBKdT|i0Fab|Suwjkvw3($Z@;ka1dsqBC~!F+e|X{Et)i&gmzf9Q`jn2dTYPyh6W256 zvDAQJOG6}|4x2G=Isv$nK=hFr93Y54G}S8zYL3mB1wq}xNuw}^;pps0BLUYR6#`p( UYMH7l00000NkvXX1g=70f_sH#DF6Tf delta 1061 zcmV+=1ls$J2bu|xVFwKdA`}F)+L34{e*^VNL_t(|+U=V^NE=Zc$G?}PsPS*6fQzDn zk{F29xTx9E6d^hpvUN}dZNa5Qx6(~%7ok-U9l8abR1j>om@cMPAzn~OMHeAc{GUp5 zcU?|A(wF4CoHTdO@BA*w_jAAZ-tYJFdjREP9{US!?DiS}y#P7^*Z?#Es0Uzie?==R z8D8MaZjr9K5>mD2IJKmNqq;L8UUw$!R9^~_w{P|?GzZ|uZf^iE1i%Ntook#cT3PV3 zS`WBz0OHC&s8;}c9mc`z9U(gchM;pLt%jj|0DO7} zaNNlFhycWb$E|k&hiyi;v`~^pKrblKWi``F0?0OgVbNYi4v?DpQPe-uE9764UOLW%_7 zlokNB=l5Qv0FGz@U`Yu_Bmi+*0MwlcaT0(XiU91807Pg3P<<&x{sCZS*$V(+y_;`6 z;KI_s&$APub-e>kU=IScVcOEbW;9BeE z%hSTOEzV8JIS&9~N0`t$08c10k*}3D?}?C^WtRZVYt?*DBr{*Ag|^_4n3-kA0c>i` ze0z-BTzK(wywEtgXM%nJ+gdT-oZz=zQO+-CtSkUxp){Zce+bP9e!FigGa$ELSoW!~ znPrmzJf%Dx+GE_NJDl;nd%c&G`;4Od0%G@Q(G8Spc8m8!GV^lgyy6HTEQ}+ikSCO< zg=^p1pAjYI6$6lLk@o+YF?L0{pnv&~UFmHR#Z!PVCFr~~l>-EQ*X9Ty=)5?Y14c<- foqf`iDA!*_6RnH@^+67600000NkvXXu0mjf_qFLh diff --git a/resources/images/duration3.png b/resources/images/duration3.png index 9280a6421ebe27461f8043180d4ed2b2e2fdc4f7..9c61f7f8d1f509bc18fa4d3e24cb3b32a9c1702e 100644 GIT binary patch delta 1022 zcmVv(tiGPCOG$hB|VlkwK zEKqR1XlK$3q3wEgcbA#FTn|j1szR5v{dg9HieIxk^4iF-EFQPDJ_62 zcsv4_F?oq;r8hMExXC$}QUc-yPgDT2E7b0gnGX?2GQdwNfKKBkF|P6idrop_AjyK~ zLjavltEHu{!TBnYebHpW^OeCs^!y9@>i>jdQe*gdgaI4X7 zP6EVMeLAyQxSp*Gpy>br0Prf&)|djsT75c`O56~6Mu4gV006)*M@>)*@F|cQRsmvf zf97P!yitO#0{{TvK#G(=Er7%jE$jkRPzwmikX)z*Y-2J7)B?Vy>ocJiz)Tvw!S^F- zp#=I42n#4UwC%wH&14M=f5;{SK3D`WS;GQk0cr~t0Zi7g0F0zOun1tXG6gsw65u!{ zKzcx}!XkjldgS$Z-G+8~HVfB_8NPaluvv;7Wvtf$3LiBi_UcD69uXk-hbF}?Ad>Oe z7b15)X^BZCZV)59$xBSXx#_@TUJ5I{p<%IBpN)<68zC`HhLMwBf6SX9wL4@MTlJ$c zMg2;wX<0iqmWMZp0lsmQ7#}TjG{$v1tnvhV#8UlOERtwHeEhJx-*uJTUb~!MD`fai ztEJ`9J(o3Z0RRB7`fk_RT)r=NUCP%95&rI%siEfv=aX1tIDIL4`?Gd_N`Y4h3Et=< z7T#WWRQ_umr$=Hse|xaL(m%Z}6!=R2^t#R-tmiUT!e!9n-0opZLFUZ4i{JI$3wc?o z4qv+Rr?#uZ^^-RN006KwxBL74mCT8Z^WTa$u{>p}w*8H@AZK{ab3kNT7mEi+3XN^4 zHsKAIZ?wm|UqX+?hs!tGJFS+MR65lq0-taP&@m5bay%+YY+tgj7?ZkWhMC^cqAIr< z?fzdkP${!$icN%9iMF2B^MsULHpg~o_~od{r$A~>+7*IYILVg&0Zqn%6e%GwL`!0b sDj-90w=tQ5`HC8VGy$G^{AoH~srdtru! z>1?2q7)VUxU`^A(aBhNi6m*WgD8(&cDYzFK@m)9A3uS#HbPCeFkWuFB7;9y2H7~YW zWwdFUKqOR1iyg!1UMz7@Q(5kAZ?g27UgCKN9 zxoVEF6Q7UGmPgj_rE_ zGE>?#fDSo+yc`MOt0lr*cLkW=q$Q*14C1een|i_i=0uV@Amxdy3vtwdxMk&441+@FUL9|YN3bs1R%4v?}JKo z$3^#@pLBHYB>_IQ6+R+1f66BcK&JOSY6Gy`OnZbtsU5&dBk2+ZklFBf)DB>|nfCBEO8f-4p%EqZ#4QBCsTBYT z191uguxJQ?MF>EXRsh6}q)7-sy;cBh)IRpg2Vm3+fX!-R6arAGe-!{b<&V8)Yl3aJ zo(D$}XieD!lnt*Db?EfMDWH?IVXKPCqNt^m_}IL6*qiuuDa_O>g)^onUqi)l1B zySDRwOWjOTPdxD#$e~g_0Q|FSTOU~KrqepK{%NAjr5gKJe`Q3Q z7d-|jVPF(9f8Z6B0KS4>{qaM;t?u{VUZP%4myzcVdY*sl$Mo6J?$BpauBW9wc;VZ% z(1$PAT`v0vFRmVAk``KKsM#k+8>n5sarIB(e2&!lnv3z>$(?+sp-)Bpeg07*qoM6N<$f|iy;r~m)} From 002c544cff0d43d1cbb54c4c2865e7eef1a74749 Mon Sep 17 00:00:00 2001 From: shibakaneki Date: Wed, 4 Jan 2012 14:38:41 +0100 Subject: [PATCH 07/84] Added the action viewer --- resources/style.qss | 3 ++- src/gui/UBTeacherBarWidget.cpp | 18 ++++-------------- src/gui/UBTeacherBarWidget.h | 5 +++-- 3 files changed, 9 insertions(+), 17 deletions(-) diff --git a/resources/style.qss b/resources/style.qss index cfa6b41c..503822a7 100644 --- a/resources/style.qss +++ b/resources/style.qss @@ -4,7 +4,8 @@ QWidget#UBLibPathViewer, QWidget#UBTeacherStudentAction, QWidget#UBLibNavigatorWidget, QWidget#UBLibItemProperties, -QWidget#UBDownloadWidget +QWidget#UBDownloadWidget, +QWidget#UBWidgetList { background: #EEEEEE; border-radius: 10px; diff --git a/src/gui/UBTeacherBarWidget.cpp b/src/gui/UBTeacherBarWidget.cpp index 2557b50b..7674e111 100644 --- a/src/gui/UBTeacherBarWidget.cpp +++ b/src/gui/UBTeacherBarWidget.cpp @@ -27,6 +27,7 @@ UBTeacherBarWidget::UBTeacherBarWidget(QWidget *parent, const char *name):UBDock , mpDuration2(NULL) , mpDuration3(NULL) , mpDurationButtons(NULL) + , mpActions(NULL) { setObjectName(name); mName = "TeacherBarWidget"; @@ -79,9 +80,9 @@ UBTeacherBarWidget::UBTeacherBarWidget(QWidget *parent, const char *name):UBDock mpLayout->addLayout(mpDurationLayout); // Actions - mpAction1 = new UBTeacherStudentAction(1, mpContainer); - - mpLayout->addWidget(mpAction1); + mpActions = new UBWidgetList(this); + mpActions->setEmptyText(tr("Add actions")); + mpLayout->addWidget(mpActions); // Media mpDropMediaZone = new UBTeacherBarDropMediaZone(); @@ -93,8 +94,6 @@ UBTeacherBarWidget::UBTeacherBarWidget(QWidget *parent, const char *name):UBDock connect(UBApplication::boardController, SIGNAL(activeSceneChanged()), this, SLOT(loadContent())); connect(UBApplication::mainWindow->actionQuit, SIGNAL(triggered()), this, SLOT(saveContent())); connect(mpTitle, SIGNAL(textChanged(QString)), this, SLOT(onValueChanged())); - connect(mpAction1->teacher(), SIGNAL(textChanged()), this, SLOT(onValueChanged())); - connect(mpAction1->student(), SIGNAL(textChanged()), this, SLOT(onValueChanged())); } UBTeacherBarWidget::~UBTeacherBarWidget() @@ -184,8 +183,6 @@ void UBTeacherBarWidget::saveContent() { sTeacherBarInfos infos; infos.title = mpTitle->text(); - infos.action1Master = mpAction1->teacherText(); - infos.action1Student = mpAction1->studentText(); UBPersistenceManager::persistenceManager()->persistTeacherBar(UBApplication::boardController->activeDocument(), UBApplication::boardController->activeSceneIndex(), infos); } @@ -193,8 +190,6 @@ void UBTeacherBarWidget::loadContent() { sTeacherBarInfos nextInfos = UBPersistenceManager::persistenceManager()->getTeacherBarInfos(UBApplication::boardController->activeDocument(), UBApplication::boardController->activeSceneIndex()); mpTitle->setText(nextInfos.title); - mpAction1->setTeacherText(nextInfos.action1Master); - mpAction1->setStudentText(nextInfos.action1Student); } void UBTeacherBarWidget::onTitleTextChanged(const QString& text) @@ -202,11 +197,6 @@ void UBTeacherBarWidget::onTitleTextChanged(const QString& text) mpTitle->setToolTip(text); } -void UBTeacherBarWidget::onEquipmentTextChanged(const QString& text) -{ - -} - UBTeacherStudentAction::UBTeacherStudentAction(int actionNumber, QWidget *parent, const char *name):QWidget(parent) , mpActionLabel(NULL) , mpTeacherLabel(NULL) diff --git a/src/gui/UBTeacherBarWidget.h b/src/gui/UBTeacherBarWidget.h index 67a3e97b..423761bd 100644 --- a/src/gui/UBTeacherBarWidget.h +++ b/src/gui/UBTeacherBarWidget.h @@ -15,6 +15,7 @@ class UBVideoPlayer; #include #include "UBDockPaletteWidget.h" +#include "customWidgets/UBWidgetList.h" #define LABEL_MINWIDHT 80 @@ -79,8 +80,7 @@ private slots: void saveContent(); void loadContent(); void onValueChanged(); - void onTitleTextChanged(const QString& text); - void onEquipmentTextChanged(const QString& text); + void onTitleTextChanged(const QString& text); private: void populateCombos(); @@ -99,6 +99,7 @@ private: QCheckBox* mpDuration2; QCheckBox* mpDuration3; QButtonGroup* mpDurationButtons; + UBWidgetList* mpActions; }; #endif // UBTEACHERBARWIDGET_H From 0045204c7a623dafd7589d9ed8a02c944d3fb787 Mon Sep 17 00:00:00 2001 From: Claudio Valerio Date: Wed, 4 Jan 2012 14:39:52 +0100 Subject: [PATCH 08/84] first draft --- src/gui/UBTeacherBarWidget.cpp | 103 ++++++++------------------------- src/gui/UBTeacherBarWidget.h | 12 ++-- 2 files changed, 28 insertions(+), 87 deletions(-) diff --git a/src/gui/UBTeacherBarWidget.cpp b/src/gui/UBTeacherBarWidget.cpp index 2557b50b..bd0a20b0 100644 --- a/src/gui/UBTeacherBarWidget.cpp +++ b/src/gui/UBTeacherBarWidget.cpp @@ -1,7 +1,8 @@ - #include "UBTeacherBarWidget.h" +#include "UBTeacherBarWidget.h" #include "core/UBApplication.h" #include "core/UBPersistenceManager.h" + #include "UBMainWindow.h" #include "document/UBDocumentController.h" @@ -10,6 +11,10 @@ #include "board/UBBoardController.h" #include "board/UBBoardPaletteManager.h" +#include "gui/UBMediaPlayer.h" + +#include "frameworks/UBFileSystemUtils.h" + #include "core/memcheck.h" UBTeacherBarWidget::UBTeacherBarWidget(QWidget *parent, const char *name):UBDockPaletteWidget(parent) @@ -326,110 +331,50 @@ QTextEdit* UBTeacherStudentAction::student() return mpStudent; } -#include "gui/UBMediaPlayer.h" -#include "gui/UBVideoPlayer.h" -#include "frameworks/UBFileSystemUtils.h" -UBTeacherBarDropMediaZone::UBTeacherBarDropMediaZone(QWidget *parent, const char *name):QWidget(parent) - , mpTitleLabel(NULL) - , mpImageTab(NULL) - , mpTabWidget(NULL) - , mpLayout(NULL) +UBTeacherBarDropMediaZone::UBTeacherBarDropMediaZone(QWidget *parent, const char *name):UBWidgetList(parent) + { setObjectName(name); setAcceptDrops(true); - - setAttribute(Qt::WA_StyledBackground, true); - setStyleSheet(UBApplication::globalStyleSheet()); - - // Create the GUI - mpLayout = new QVBoxLayout(this); - setLayout(mpLayout); - - - mpImageTab = new QLabel(); - mpVideoTab = new UBMediaPlayer(); - mpAudioTab = new UBMediaPlayer(); - - mpTitleLabel = new QLabel(tr("Drop media here")); - mpLayout->addWidget(mpTitleLabel); - mpTabWidget = new QTabWidget(); - mpTabWidget->setMinimumHeight(120); - mpTabWidget->addTab(mpImageTab,QIcon(":images/toolbar/extraTool.png"),""); - mpTabWidget->addTab(mpVideoTab,QIcon(":images/libpalette/movieIcon.svg"),""); - mpTabWidget->addTab(mpAudioTab,QIcon(":images/libpalette/soundIcon.svg"),""); - mpLayout->addWidget(mpTabWidget); + setEmptyText(tr("Drag media here ...")); } UBTeacherBarDropMediaZone::~UBTeacherBarDropMediaZone() { - if(NULL != mpTitleLabel) - { - delete mpTitleLabel; - mpTitleLabel = NULL; - } - if(NULL != mpImageTab) - { - delete mpImageTab; - mpImageTab = NULL; - } - if(NULL != mpVideoTab) - { - delete mpVideoTab; - mpVideoTab = NULL; - } - if(NULL != mpAudioTab) - { - delete mpAudioTab; - mpAudioTab = NULL; - } - if(NULL != mpTabWidget) - { - delete mpTabWidget; - mpTabWidget = NULL; - } - if(NULL != mpLayout) - { - delete mpLayout; - mpLayout = NULL; - } + qDeleteAll(mWidgetList); } void UBTeacherBarDropMediaZone::dragEnterEvent(QDragEnterEvent *pEvent) { - setBackgroundRole(QPalette::Highlight); pEvent->acceptProposedAction(); } void UBTeacherBarDropMediaZone::dragLeaveEvent(QDragLeaveEvent *pEvent) { - setBackgroundRole(QPalette::Dark); pEvent->accept(); } void UBTeacherBarDropMediaZone::dropEvent(QDropEvent *pEvent) { - setBackgroundRole(QPalette::Dark); - if(pEvent->mimeData()->hasHtml()) qDebug() << pEvent->mimeData()->html(); - if(pEvent->mimeData()->hasUrls()) qDebug() << pEvent->mimeData()->urls(); - if(pEvent->mimeData()->hasText()) qDebug() << pEvent->mimeData()->text(); QString mimeType = UBFileSystemUtils::mimeTypeFromFileName(pEvent->mimeData()->urls().at(0).toLocalFile()); if(mimeType.contains("image")){ QPixmap pix = QPixmap(pEvent->mimeData()->urls().at(0).toLocalFile()); - mpImageTab->setPixmap(pix); - mpTabWidget->setCurrentWidget(mpImageTab); - } - else if(mimeType.contains("video")){ - mpVideoTab->setFile(pEvent->mimeData()->urls().at(0).toLocalFile()); - mpVideoTab->playPause(); - - mpTabWidget->setCurrentWidget(mpVideoTab); - } - else if(mimeType.contains("audio")){ - mpVideoTab->setFile(pEvent->mimeData()->urls().at(0).toLocalFile()); - mpVideoTab->playPause(); - mpTabWidget->setCurrentWidget(mpAudioTab); + float ratio = (float)width()/(float)pix.width(); + pix.transformed(QTransform::scale((float)pix.width()/ratio,(float)pix.height()/ratio)); + QLabel* label = new QLabel(); + label->setPixmap(pix); + label->setScaledContents(true); + addWidget(label); + mWidgetList << label; + } + else if(mimeType.contains("video") || mimeType.contains("audio")){ + UBMediaPlayer* mediaPlayer = new UBMediaPlayer(); + mediaPlayer->setFile(pEvent->mimeData()->urls().at(0).toLocalFile()); + mediaPlayer->playPause(); + addWidget(mediaPlayer); + mWidgetList << mediaPlayer; } else{ qWarning() << "bad idea to come here"; diff --git a/src/gui/UBTeacherBarWidget.h b/src/gui/UBTeacherBarWidget.h index 67a3e97b..a7abe72c 100644 --- a/src/gui/UBTeacherBarWidget.h +++ b/src/gui/UBTeacherBarWidget.h @@ -2,7 +2,6 @@ #define UBTEACHERBARWIDGET_H class UBMediaPlayer; -class UBVideoPlayer; #include #include @@ -14,6 +13,8 @@ class UBVideoPlayer; #include #include +#include "customWidgets/UBWidgetList.h" + #include "UBDockPaletteWidget.h" #define LABEL_MINWIDHT 80 @@ -45,7 +46,7 @@ private: }; -class UBTeacherBarDropMediaZone : public QWidget +class UBTeacherBarDropMediaZone : public UBWidgetList { Q_OBJECT @@ -54,12 +55,7 @@ public: ~UBTeacherBarDropMediaZone(); private: - QLabel* mpTitleLabel; - QLabel* mpImageTab; - UBMediaPlayer* mpVideoTab; - UBMediaPlayer* mpAudioTab; - QTabWidget* mpTabWidget; - QVBoxLayout* mpLayout; + QListmWidgetList; protected: void dragEnterEvent(QDragEnterEvent* pEvent); From 176977677e755cac0fd8261f498b44f0478a4365 Mon Sep 17 00:00:00 2001 From: Claudio Valerio Date: Wed, 4 Jan 2012 14:41:35 +0100 Subject: [PATCH 09/84] second draft --- src/gui/UBTeacherBarWidget.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/gui/UBTeacherBarWidget.cpp b/src/gui/UBTeacherBarWidget.cpp index 5a62f301..3b403e2c 100644 --- a/src/gui/UBTeacherBarWidget.cpp +++ b/src/gui/UBTeacherBarWidget.cpp @@ -351,8 +351,6 @@ void UBTeacherBarDropMediaZone::dropEvent(QDropEvent *pEvent) QString mimeType = UBFileSystemUtils::mimeTypeFromFileName(pEvent->mimeData()->urls().at(0).toLocalFile()); if(mimeType.contains("image")){ QPixmap pix = QPixmap(pEvent->mimeData()->urls().at(0).toLocalFile()); - float ratio = (float)width()/(float)pix.width(); - pix.transformed(QTransform::scale((float)pix.width()/ratio,(float)pix.height()/ratio)); QLabel* label = new QLabel(); label->setPixmap(pix); label->setScaledContents(true); From 5c0d14b7dede99c63f4b2cac97741bbe9071433e Mon Sep 17 00:00:00 2001 From: shibakaneki Date: Wed, 4 Jan 2012 14:45:34 +0100 Subject: [PATCH 10/84] Updated the stylesheet --- resources/style.qss | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/resources/style.qss b/resources/style.qss index 503822a7..fabe3668 100644 --- a/resources/style.qss +++ b/resources/style.qss @@ -5,7 +5,8 @@ QWidget#UBTeacherStudentAction, QWidget#UBLibNavigatorWidget, QWidget#UBLibItemProperties, QWidget#UBDownloadWidget, -QWidget#UBWidgetList +QWidget#UBWidgetList, +QWidget#UBTeacherBarDropMediaZone { background: #EEEEEE; border-radius: 10px; From 38ee9bf8b6719506e29ec3b69eb041df5b2697dc Mon Sep 17 00:00:00 2001 From: shibakaneki Date: Wed, 4 Jan 2012 17:00:33 +0100 Subject: [PATCH 11/84] backup --- src/gui/UBTeacherBarWidget.cpp | 93 ++++++++++++++++++++++++++++------ src/gui/UBTeacherBarWidget.h | 14 +++-- 2 files changed, 89 insertions(+), 18 deletions(-) diff --git a/src/gui/UBTeacherBarWidget.cpp b/src/gui/UBTeacherBarWidget.cpp index 3b403e2c..b5aa5d33 100644 --- a/src/gui/UBTeacherBarWidget.cpp +++ b/src/gui/UBTeacherBarWidget.cpp @@ -25,6 +25,7 @@ UBTeacherBarWidget::UBTeacherBarWidget(QWidget *parent, const char *name):UBDock , mpDurationLabel(NULL) , mpTitle(NULL) , mpAction1(NULL) + , mpMediaLabel(NULL) , mpDropMediaZone(NULL) , mpContainer(NULL) , mpContainerLayout(NULL) @@ -32,7 +33,13 @@ UBTeacherBarWidget::UBTeacherBarWidget(QWidget *parent, const char *name):UBDock , mpDuration2(NULL) , mpDuration3(NULL) , mpDurationButtons(NULL) + , mpActionLabel(NULL) , mpActions(NULL) + , mpActionButton(NULL) + , mpCommentLabel(NULL) + , mpComments(NULL) + , mpLinkLabel(NULL) + , mpLinks(NULL) { setObjectName(name); mName = "TeacherBarWidget"; @@ -60,15 +67,13 @@ UBTeacherBarWidget::UBTeacherBarWidget(QWidget *parent, const char *name):UBDock mpTitle = new QLineEdit(mpContainer); mpTitle->setObjectName("DockPaletteWidgetLineEdit"); connect(mpTitle, SIGNAL(textChanged(const QString&)), this, SLOT(onTitleTextChanged(const QString&))); - mpTitleLayout = new QHBoxLayout(); - mpTitleLayout->addWidget(mpTitleLabel, 0); - mpTitleLayout->addWidget(mpTitle, 1); - mpLayout->addLayout(mpTitleLayout); + mpLayout->addWidget(mpTitleLabel, 0); + mpLayout->addWidget(mpTitle, 0); // Duration mpDurationLabel = new QLabel(tr("Duration"), mpContainer); + mpLayout->addWidget(mpDurationLabel, 0); mpDurationLayout = new QHBoxLayout(); - mpDurationLayout->addWidget(mpDurationLabel, 1); mpDuration1 = new QCheckBox(this); mpDuration1->setIcon(QIcon(":images/duration1.png")); mpDurationLayout->addWidget(mpDuration1, 0); @@ -82,35 +87,88 @@ UBTeacherBarWidget::UBTeacherBarWidget(QWidget *parent, const char *name):UBDock mpDurationButtons->addButton(mpDuration1); mpDurationButtons->addButton(mpDuration2); mpDurationButtons->addButton(mpDuration3); - mpLayout->addLayout(mpDurationLayout); + mpLayout->addLayout(mpDurationLayout, 0); // Actions + mpActionLabel = new QLabel(tr("Actions"), this); + mpLayout->addWidget(mpActionLabel, 0); mpActions = new UBWidgetList(this); mpActions->setEmptyText(tr("Add actions")); - mpLayout->addWidget(mpActions); + mpLayout->addWidget(mpActions, 1); + mpActionButton = new QPushButton(this); + mpActionButton->setObjectName("DockPaletteWidgetButton"); + mpActionButton->setText(tr("Add action")); + mpLayout->addWidget(mpActionButton, 0); // Media + mpMediaLabel = new QLabel(tr("Media"), this); + mpLayout->addWidget(mpMediaLabel, 0); mpDropMediaZone = new UBTeacherBarDropMediaZone(); - mpLayout->addWidget(mpDropMediaZone); - - populateCombos(); + mpLayout->addWidget(mpDropMediaZone, 1); + + // Links + mpLinkLabel = new QLabel(tr("Links"), this); + mpLayout->addWidget(mpLinkLabel, 0); + mpLinks = new UBWidgetList(this); + mpLayout->addWidget(mpLinks, 1); + mpLinkButton = new QPushButton(tr("Add link"), this); + mpLinkButton->setObjectName("DockPaletteWidgetButton"); + mpLayout->addWidget(mpLinkButton); + + // Comments + mpCommentLabel = new QLabel(tr("Comments"), this); + mpLayout->addWidget(mpCommentLabel, 0); + mpComments = new QTextEdit(this); + mpComments->setObjectName("DockPaletteWidgetBox"); + mpComments->setStyleSheet("background:white;"); + mpLayout->addWidget(mpComments, 1); connect(UBApplication::boardController, SIGNAL(activeSceneWillChange()), this, SLOT(saveContent())); connect(UBApplication::boardController, SIGNAL(activeSceneChanged()), this, SLOT(loadContent())); connect(UBApplication::mainWindow->actionQuit, SIGNAL(triggered()), this, SLOT(saveContent())); connect(mpTitle, SIGNAL(textChanged(QString)), this, SLOT(onValueChanged())); + connect(mpActionButton, SIGNAL(clicked()), this, SLOT(onActionButton())); + connect(mpLinkButton, SIGNAL(clicked()), this, SLOT(onLinkButton())); } UBTeacherBarWidget::~UBTeacherBarWidget() { + if(NULL != mpComments){ + delete mpComments; + mpComments = NULL; + } + if(NULL != mpCommentLabel){ + delete mpCommentLabel; + mpCommentLabel = NULL; + } + if(NULL != mpLinks){ + delete mpLinks; + mpLinks = NULL; + } + if(NULL != mpLinkLabel){ + delete mpLinkLabel; + mpLinkLabel = NULL; + } if(NULL != mpDropMediaZone){ delete mpDropMediaZone; mpDropMediaZone = NULL; } + if(NULL != mpMediaLabel){ + delete mpMediaLabel; + mpMediaLabel = NULL; + } + if(NULL != mpActionButton){ + delete mpActionButton; + mpActionButton = NULL; + } if(NULL != mpAction1){ delete mpAction1; mpAction1 = NULL; } + if(NULL != mpActionLabel){ + delete mpActionLabel; + mpActionLabel = NULL; + } if(NULL != mpDurationLabel){ delete mpDurationLabel; mpDurationLabel = NULL; @@ -161,11 +219,6 @@ UBTeacherBarWidget::~UBTeacherBarWidget() } } -void UBTeacherBarWidget::populateCombos() -{ - -} - void UBTeacherBarWidget::onValueChanged() { if( mpTitle->text() == "" @@ -202,6 +255,16 @@ void UBTeacherBarWidget::onTitleTextChanged(const QString& text) mpTitle->setToolTip(text); } +void UBTeacherBarWidget::onActionButton() +{ + +} + +void UBTeacherBarWidget::onLinkButton() +{ + +} + UBTeacherStudentAction::UBTeacherStudentAction(int actionNumber, QWidget *parent, const char *name):QWidget(parent) , mpActionLabel(NULL) , mpTeacherLabel(NULL) diff --git a/src/gui/UBTeacherBarWidget.h b/src/gui/UBTeacherBarWidget.h index 9ac35434..5176bf25 100644 --- a/src/gui/UBTeacherBarWidget.h +++ b/src/gui/UBTeacherBarWidget.h @@ -12,7 +12,7 @@ class UBMediaPlayer; #include #include #include - +#include #include "customWidgets/UBWidgetList.h" #include "UBDockPaletteWidget.h" @@ -77,10 +77,10 @@ private slots: void loadContent(); void onValueChanged(); void onTitleTextChanged(const QString& text); + void onActionButton(); + void onLinkButton(); private: - void populateCombos(); - QVBoxLayout* mpLayout; QHBoxLayout* mpTitleLayout; QHBoxLayout* mpDurationLayout; @@ -88,6 +88,7 @@ private: QLabel* mpDurationLabel; QLineEdit* mpTitle; UBTeacherStudentAction* mpAction1; + QLabel* mpMediaLabel; UBTeacherBarDropMediaZone* mpDropMediaZone; QWidget* mpContainer; QVBoxLayout* mpContainerLayout; @@ -95,7 +96,14 @@ private: QCheckBox* mpDuration2; QCheckBox* mpDuration3; QButtonGroup* mpDurationButtons; + QLabel* mpActionLabel; UBWidgetList* mpActions; + QPushButton* mpActionButton; + QLabel* mpLinkLabel; + UBWidgetList* mpLinks; + QPushButton* mpLinkButton; + QLabel* mpCommentLabel; + QTextEdit* mpComments; }; #endif // UBTEACHERBARWIDGET_H From 453debb2a35578675d5a36ff7c5103c48bc622b1 Mon Sep 17 00:00:00 2001 From: Claudio Valerio Date: Wed, 4 Jan 2012 17:04:58 +0100 Subject: [PATCH 12/84] changed to have a correct the wrong resize behaviour --- src/customWidgets/UBWidgetList.cpp | 15 +++++++--- src/gui/UBTeacherBarWidget.cpp | 44 +++++++++++++++++++++++++----- src/gui/UBTeacherBarWidget.h | 5 +++- 3 files changed, 52 insertions(+), 12 deletions(-) diff --git a/src/customWidgets/UBWidgetList.cpp b/src/customWidgets/UBWidgetList.cpp index 87a9538d..fa3ce3ed 100644 --- a/src/customWidgets/UBWidgetList.cpp +++ b/src/customWidgets/UBWidgetList.cpp @@ -76,16 +76,23 @@ void UBWidgetList::updateSize(bool widgetAdded, QWidget *widget) int newWidgetHeight; if(eWidgetListOrientation_Vertical == mOrientation){ - scaleFactor = (float)widget->width() / (float)mpContainer->width(); + scaleFactor = (float)mpContainer->width() / (float)widget->width(); }else{ - scaleFactor = (float)widget->height() / (float)mpContainer->height(); + scaleFactor = (float)mpContainer->height() / (float)widget->height(); } - newWidgetWidth = widget->width()*scaleFactor; - newWidgetHeight = widget->height()*scaleFactor; + newWidgetWidth = (int)((float)widget->width()*scaleFactor); + newWidgetHeight = (int)((float)widget->height()*scaleFactor); + + qDebug() << "container size " << mpContainer->size(); + qDebug() << "widget size " << widget->size(); + qDebug() << "scale factor " << scaleFactor; + widget->resize(newWidgetWidth, newWidgetHeight); + qDebug() << "widget new value " << newWidgetWidth << "x" << newWidgetHeight; + // Now we have to update the container if(eWidgetListOrientation_Vertical == mOrientation){ if(widgetAdded){ diff --git a/src/gui/UBTeacherBarWidget.cpp b/src/gui/UBTeacherBarWidget.cpp index 3b403e2c..20229a03 100644 --- a/src/gui/UBTeacherBarWidget.cpp +++ b/src/gui/UBTeacherBarWidget.cpp @@ -322,12 +322,16 @@ QTextEdit* UBTeacherStudentAction::student() } -UBTeacherBarDropMediaZone::UBTeacherBarDropMediaZone(QWidget *parent, const char *name):UBWidgetList(parent) +UBTeacherBarDropMediaZone::UBTeacherBarDropMediaZone(QWidget *parent, const char *name):QWidget(parent) { setObjectName(name); setAcceptDrops(true); - setEmptyText(tr("Drag media here ...")); + + mWidget.setEmptyText(tr("Drag media here ...")); + mLayout.addWidget(&mWidget); + setLayout(&mLayout); + } UBTeacherBarDropMediaZone::~UBTeacherBarDropMediaZone() @@ -348,20 +352,46 @@ void UBTeacherBarDropMediaZone::dragLeaveEvent(QDragLeaveEvent *pEvent) void UBTeacherBarDropMediaZone::dropEvent(QDropEvent *pEvent) { - QString mimeType = UBFileSystemUtils::mimeTypeFromFileName(pEvent->mimeData()->urls().at(0).toLocalFile()); + QPixmap pixFromDropEvent; + QString mimeType; + QString resourcePath; + if(pEvent->mimeData()->hasText()){ + qDebug() << "pEvent->mimeData()->hasText()" << pEvent->mimeData()->text(); + resourcePath = pEvent->mimeData()->text(); + } + else if(pEvent->mimeData()->hasUrls()){ + qDebug() << "pEvent->mimeData()->hasUrls()" << pEvent->mimeData()->urls().at(0); + resourcePath = pEvent->mimeData()->urls().at(0).toLocalFile(); + } + else if(pEvent->mimeData()->hasImage()){ + qDebug() << "pEvent->mimeData()->hasImage()"; + pixFromDropEvent.loadFromData(pEvent->mimeData()->imageData().toByteArray()); + if(!pixFromDropEvent.isNull()) + mimeType = "image"; + } + + if (mimeType.isEmpty() && resourcePath.isEmpty()){ + pEvent->acceptProposedAction(); + return; + } + + mimeType = mimeType.isEmpty() ? UBFileSystemUtils::mimeTypeFromFileName(resourcePath) : mimeType; if(mimeType.contains("image")){ - QPixmap pix = QPixmap(pEvent->mimeData()->urls().at(0).toLocalFile()); + qDebug() << pixFromDropEvent.size(); + QPixmap pix = pixFromDropEvent.height() ? pixFromDropEvent : QPixmap(resourcePath); QLabel* label = new QLabel(); label->setPixmap(pix); + //label->resize(size()); label->setScaledContents(true); - addWidget(label); + mWidget.addWidget(label); mWidgetList << label; } else if(mimeType.contains("video") || mimeType.contains("audio")){ UBMediaPlayer* mediaPlayer = new UBMediaPlayer(); - mediaPlayer->setFile(pEvent->mimeData()->urls().at(0).toLocalFile()); + mediaPlayer->setFile(resourcePath); + //mediaPlayer->resize(size()); mediaPlayer->playPause(); - addWidget(mediaPlayer); + mWidget.addWidget(mediaPlayer); mWidgetList << mediaPlayer; } else{ diff --git a/src/gui/UBTeacherBarWidget.h b/src/gui/UBTeacherBarWidget.h index 9ac35434..63f7e262 100644 --- a/src/gui/UBTeacherBarWidget.h +++ b/src/gui/UBTeacherBarWidget.h @@ -47,7 +47,7 @@ private: }; -class UBTeacherBarDropMediaZone : public UBWidgetList +class UBTeacherBarDropMediaZone : public QWidget { Q_OBJECT @@ -57,6 +57,9 @@ public: private: QListmWidgetList; + UBWidgetList mWidget; + QVBoxLayout mLayout; + protected: void dragEnterEvent(QDragEnterEvent* pEvent); From 89e16fdecdcbce12890a995eff450541f3aa9ecc Mon Sep 17 00:00:00 2001 From: shibakaneki Date: Thu, 5 Jan 2012 08:47:07 +0100 Subject: [PATCH 13/84] Added some minor changes on the GUI --- src/gui/UBTeacherBarWidget.cpp | 26 ++++++++++++++++++++++++-- src/gui/UBTeacherBarWidget.h | 2 ++ 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/gui/UBTeacherBarWidget.cpp b/src/gui/UBTeacherBarWidget.cpp index c9e33340..dfc0d712 100644 --- a/src/gui/UBTeacherBarWidget.cpp +++ b/src/gui/UBTeacherBarWidget.cpp @@ -36,10 +36,13 @@ UBTeacherBarWidget::UBTeacherBarWidget(QWidget *parent, const char *name):UBDock , mpActionLabel(NULL) , mpActions(NULL) , mpActionButton(NULL) + , mpActionLayout(NULL) , mpCommentLabel(NULL) , mpComments(NULL) , mpLinkLabel(NULL) , mpLinks(NULL) + , mpLinkButton(NULL) + , mpLinkLayout(NULL) { setObjectName(name); mName = "TeacherBarWidget"; @@ -76,6 +79,7 @@ UBTeacherBarWidget::UBTeacherBarWidget(QWidget *parent, const char *name):UBDock mpDurationLayout = new QHBoxLayout(); mpDuration1 = new QCheckBox(this); mpDuration1->setIcon(QIcon(":images/duration1.png")); + mpDuration1->setChecked(true); mpDurationLayout->addWidget(mpDuration1, 0); mpDuration2 = new QCheckBox(this); mpDuration2->setIcon(QIcon(":images/duration2.png")); @@ -98,7 +102,10 @@ UBTeacherBarWidget::UBTeacherBarWidget(QWidget *parent, const char *name):UBDock mpActionButton = new QPushButton(this); mpActionButton->setObjectName("DockPaletteWidgetButton"); mpActionButton->setText(tr("Add action")); - mpLayout->addWidget(mpActionButton, 0); + mpActionLayout = new QHBoxLayout(); + mpActionLayout->addWidget(mpActionButton, 0); + mpActionLayout->addStretch(1); + mpLayout->addLayout(mpActionLayout, 0); // Media mpMediaLabel = new QLabel(tr("Media"), this); @@ -113,7 +120,10 @@ UBTeacherBarWidget::UBTeacherBarWidget(QWidget *parent, const char *name):UBDock mpLayout->addWidget(mpLinks, 1); mpLinkButton = new QPushButton(tr("Add link"), this); mpLinkButton->setObjectName("DockPaletteWidgetButton"); - mpLayout->addWidget(mpLinkButton); + mpLinkLayout = new QHBoxLayout(); + mpLinkLayout->addWidget(mpLinkButton, 0); + mpLinkLayout->addStretch(1); + mpLayout->addLayout(mpLinkLayout, 0); // Comments mpCommentLabel = new QLabel(tr("Comments"), this); @@ -149,6 +159,14 @@ UBTeacherBarWidget::~UBTeacherBarWidget() delete mpLinkLabel; mpLinkLabel = NULL; } + if(NULL != mpLinkButton){ + delete mpLinkButton; + mpLinkButton = NULL; + } + if(NULL != mpLinkLayout){ + delete mpLinkLayout; + mpLinkLayout = NULL; + } if(NULL != mpDropMediaZone){ delete mpDropMediaZone; mpDropMediaZone = NULL; @@ -161,6 +179,10 @@ UBTeacherBarWidget::~UBTeacherBarWidget() delete mpActionButton; mpActionButton = NULL; } + if(NULL != mpActionLayout){ + delete mpActionLayout; + mpActionLayout = NULL; + } if(NULL != mpAction1){ delete mpAction1; mpAction1 = NULL; diff --git a/src/gui/UBTeacherBarWidget.h b/src/gui/UBTeacherBarWidget.h index 7ba1eeb9..a9d939d0 100644 --- a/src/gui/UBTeacherBarWidget.h +++ b/src/gui/UBTeacherBarWidget.h @@ -102,9 +102,11 @@ private: QLabel* mpActionLabel; UBWidgetList* mpActions; QPushButton* mpActionButton; + QHBoxLayout* mpActionLayout; QLabel* mpLinkLabel; UBWidgetList* mpLinks; QPushButton* mpLinkButton; + QHBoxLayout* mpLinkLayout; QLabel* mpCommentLabel; QTextEdit* mpComments; }; From 9b470227833083506ce15d8bbab6fed440f51761 Mon Sep 17 00:00:00 2001 From: shibakaneki Date: Thu, 5 Jan 2012 09:48:52 +0100 Subject: [PATCH 14/84] Added the actions --- src/gui/UBTeacherBarWidget.cpp | 136 ++++++++++----------------------- src/gui/UBTeacherBarWidget.h | 27 +++---- 2 files changed, 52 insertions(+), 111 deletions(-) diff --git a/src/gui/UBTeacherBarWidget.cpp b/src/gui/UBTeacherBarWidget.cpp index dfc0d712..8b80beb1 100644 --- a/src/gui/UBTeacherBarWidget.cpp +++ b/src/gui/UBTeacherBarWidget.cpp @@ -243,9 +243,7 @@ UBTeacherBarWidget::~UBTeacherBarWidget() void UBTeacherBarWidget::onValueChanged() { - if( mpTitle->text() == "" - && mpAction1->teacherText() == "" - && mpAction1->studentText() == "") + if( mpTitle->text() == "") { mIconToLeft = QPixmap(":images/teacher_open_disabled.png"); mIconToRight = QPixmap(":images/teacher_close_disabled.png"); @@ -279,7 +277,9 @@ void UBTeacherBarWidget::onTitleTextChanged(const QString& text) void UBTeacherBarWidget::onActionButton() { - + UBTeacherStudentAction* pAction = new UBTeacherStudentAction(this); + mActionList << pAction; + mpActions->addWidget(pAction); } void UBTeacherBarWidget::onLinkButton() @@ -287,126 +287,74 @@ void UBTeacherBarWidget::onLinkButton() } -UBTeacherStudentAction::UBTeacherStudentAction(int actionNumber, QWidget *parent, const char *name):QWidget(parent) - , mpActionLabel(NULL) - , mpTeacherLabel(NULL) - , mpStudentLabel(NULL) - , mpTeacher(NULL) - , mpStudent(NULL) - , mpLayout(NULL) - , mpTeacherLayout(NULL) - , mpStudentLayout(NULL) +UBTeacherStudentAction::UBTeacherStudentAction(QWidget *parent, const char *name):QWidget(parent) + , mpText(NULL) + , mpLayout(NULL) + , mpComboLayout(NULL) + , mpCombo(NULL) { setObjectName(name); - mActionNumber = actionNumber; setAttribute(Qt::WA_StyledBackground, true); setStyleSheet(UBApplication::globalStyleSheet()); // Create the GUI - mpLayout = new QVBoxLayout(this); + mpLayout = new QHBoxLayout(this); setLayout(mpLayout); - mpActionLabel = new QLabel(tr("Action %0").arg(mActionNumber), this); - mpLayout->addWidget(mpActionLabel, 0); + mpComboLayout = new QVBoxLayout(); + + mpCombo = new QComboBox(this); + mpCombo->addItem(tr("Teacher")); + mpCombo->addItem(tr("Student")); + mpComboLayout->addWidget(0); + mpComboLayout->addStretch(1); + + mpLayout->addLayout(mpComboLayout, 0); + + mpText = new QTextEdit(this); + mpLayout->addWidget(mpText, 1); - mpTeacherLayout = new QHBoxLayout(); - - mpTeacherLabel = new QLabel(tr("Teacher"), this); - mpTeacherLabel->setAlignment(Qt::AlignTop); - mpTeacher = new QTextEdit(this); - mpTeacher->setObjectName("TeacherStudentBox"); - mpTeacher->setStyleSheet("background-color:#FF9F6D"); - mpTeacherLayout->addWidget(mpTeacherLabel, 0); - mpTeacherLayout->addWidget(mpTeacher, 1); - mpLayout->addLayout(mpTeacherLayout, 1); - - mpStudentLayout = new QHBoxLayout(); - mpStudentLabel = new QLabel(tr("Student"), this); - mpStudentLabel->setAlignment(Qt::AlignTop); - mpStudent = new QTextEdit(this); - mpStudent->setObjectName("TeacherStudentBox"); - mpStudent->setStyleSheet("background-color:#06E983"); - mpStudentLayout->addWidget(mpStudentLabel, 0); - mpStudentLayout->addWidget(mpStudent, 1); - mpLayout->addLayout(mpStudentLayout, 1); } UBTeacherStudentAction::~UBTeacherStudentAction() { - if(NULL != mpActionLabel) - { - delete mpActionLabel; - mpActionLabel = NULL; - } - if(NULL != mpTeacherLabel) - { - delete mpTeacherLabel; - mpTeacherLabel = NULL; - } - if(NULL != mpTeacher) - { - delete mpTeacher; - mpTeacher = NULL; - } - if(NULL != mpTeacherLayout) - { - delete mpTeacherLayout; - mpTeacherLayout = NULL; - } - if(NULL != mpStudentLabel) - { - delete mpStudentLabel; - mpStudentLabel = NULL; + if(NULL != mpCombo){ + delete mpCombo; + mpCombo = NULL; } - if(NULL != mpStudent) - { - delete mpStudent; - mpStudent = NULL; + if(NULL != mpText){ + delete mpText; + mpText = NULL; } - if(NULL != mpStudentLayout) - { - delete mpStudentLayout; - mpStudentLayout = NULL; + if(NULL != mpComboLayout){ + delete mpComboLayout; + mpComboLayout = NULL; } - if(NULL != mpLayout) - { + if(NULL != mpLayout){ delete mpLayout; mpLayout = NULL; } } -QString UBTeacherStudentAction::teacherText() +QString UBTeacherStudentAction::text() { - return mpTeacher->document()->toPlainText(); -} - -QString UBTeacherStudentAction::studentText() -{ - return mpStudent->document()->toPlainText(); -} - -void UBTeacherStudentAction::setTeacherText(QString text) -{ - mpTeacher->setText(text); + QString str; + if(NULL != mpText){ + str = mpText->document()->toPlainText(); + } + return str; } -void UBTeacherStudentAction::setStudentText(QString text) +QString UBTeacherStudentAction::comboValue() { - mpStudent->setText(text); -} + QString str; -QTextEdit* UBTeacherStudentAction::teacher() -{ - return mpTeacher; -} + // TODO : Implement this method -QTextEdit* UBTeacherStudentAction::student() -{ - return mpStudent; + return str; } - UBTeacherBarDropMediaZone::UBTeacherBarDropMediaZone(QWidget *parent, const char *name):QWidget(parent) { diff --git a/src/gui/UBTeacherBarWidget.h b/src/gui/UBTeacherBarWidget.h index a9d939d0..f0c997b9 100644 --- a/src/gui/UBTeacherBarWidget.h +++ b/src/gui/UBTeacherBarWidget.h @@ -13,7 +13,7 @@ class UBMediaPlayer; #include #include #include -#include "customWidgets/UBWidgetList.h" +#include #include "UBDockPaletteWidget.h" #include "customWidgets/UBWidgetList.h" @@ -25,25 +25,16 @@ class UBTeacherStudentAction : public QWidget Q_OBJECT public: - UBTeacherStudentAction(int actionNumber, QWidget* parent=0, const char* name="UBTeacherStudentAction"); + UBTeacherStudentAction(QWidget* parent=0, const char* name="UBTeacherStudentAction"); ~UBTeacherStudentAction(); - QString teacherText(); - QString studentText(); - void setTeacherText(QString text); - void setStudentText(QString text); - QTextEdit* teacher(); - QTextEdit* student(); + QString comboValue(); + QString text(); private: - int mActionNumber; - QLabel* mpActionLabel; - QLabel* mpTeacherLabel; - QLabel* mpStudentLabel; - QTextEdit* mpTeacher; - QTextEdit* mpStudent; - QVBoxLayout* mpLayout; - QHBoxLayout* mpTeacherLayout; - QHBoxLayout* mpStudentLayout; + QTextEdit* mpText; + QHBoxLayout* mpLayout; + QVBoxLayout* mpComboLayout; + QComboBox* mpCombo; }; @@ -109,6 +100,8 @@ private: QHBoxLayout* mpLinkLayout; QLabel* mpCommentLabel; QTextEdit* mpComments; + + QVector mActionList; }; #endif // UBTEACHERBARWIDGET_H From 80e9b93ae6529f545e54146f78071cbfef6689a4 Mon Sep 17 00:00:00 2001 From: shibakaneki Date: Thu, 5 Jan 2012 10:08:45 +0100 Subject: [PATCH 15/84] Added the Links widgets --- src/gui/UBTeacherBarWidget.cpp | 48 +++++++++++++++++++++++++++++++++- src/gui/UBTeacherBarWidget.h | 15 +++++++++++ 2 files changed, 62 insertions(+), 1 deletion(-) diff --git a/src/gui/UBTeacherBarWidget.cpp b/src/gui/UBTeacherBarWidget.cpp index 8b80beb1..e5647a6c 100644 --- a/src/gui/UBTeacherBarWidget.cpp +++ b/src/gui/UBTeacherBarWidget.cpp @@ -47,6 +47,8 @@ UBTeacherBarWidget::UBTeacherBarWidget(QWidget *parent, const char *name):UBDock setObjectName(name); mName = "TeacherBarWidget"; mVisibleState = true; + mActionList.clear(); + mUrlList.clear(); setAttribute(Qt::WA_StyledBackground, true); setStyleSheet(UBApplication::globalStyleSheet()); @@ -284,7 +286,9 @@ void UBTeacherBarWidget::onActionButton() void UBTeacherBarWidget::onLinkButton() { - + UBUrlWidget* pUrl = new UBUrlWidget(this); + mUrlList << pUrl; + mpLinks->addWidget(pUrl); } UBTeacherStudentAction::UBTeacherStudentAction(QWidget *parent, const char *name):QWidget(parent) @@ -437,3 +441,45 @@ void UBTeacherBarDropMediaZone::dragMoveEvent(QDragMoveEvent *pEvent) { pEvent->acceptProposedAction(); } + +// --------------------------------------------------------------------------------------------- +UBUrlWidget::UBUrlWidget(QWidget *parent, const char *name):QWidget(parent) + , mpLayout(NULL) + , mpUrlLabel(NULL) + , mpUrl(NULL) +{ + setObjectName(name); + mpLayout = new QHBoxLayout(this); + setLayout(mpLayout); + mpUrlLabel = new QLabel(tr("Url"), this); + mpLayout->addWidget(mpUrlLabel, 0); + mpUrl = new QLineEdit(this); + mpLayout->addWidget(mpUrl, 1); +} + +UBUrlWidget::~UBUrlWidget() +{ + if(NULL != mpUrlLabel){ + delete mpUrlLabel; + mpUrlLabel = NULL; + } + if(NULL != mpUrl){ + delete mpUrl; + mpUrl = NULL; + } + if(NULL != mpLayout){ + delete mpLayout; + mpLayout = NULL; + } +} + +QString UBUrlWidget::url() +{ + QString str; + + if(NULL != mpUrl){ + str = mpUrl->text(); + } + + return str; +} diff --git a/src/gui/UBTeacherBarWidget.h b/src/gui/UBTeacherBarWidget.h index f0c997b9..29933d9d 100644 --- a/src/gui/UBTeacherBarWidget.h +++ b/src/gui/UBTeacherBarWidget.h @@ -59,6 +59,20 @@ protected: void dragLeaveEvent(QDragLeaveEvent* pEvent); }; +class UBUrlWidget : public QWidget +{ +public: + UBUrlWidget(QWidget* parent=0, const char* name="UBUrlWidget"); + ~UBUrlWidget(); + + QString url(); + +private: + QHBoxLayout* mpLayout; + QLabel* mpUrlLabel; + QLineEdit* mpUrl; +}; + class UBTeacherBarWidget : public UBDockPaletteWidget { Q_OBJECT @@ -102,6 +116,7 @@ private: QTextEdit* mpComments; QVector mActionList; + QVector mUrlList; }; #endif // UBTEACHERBARWIDGET_H From 883d22be7b927ad39437df4ba897b4aa1855b51b Mon Sep 17 00:00:00 2001 From: shibakaneki Date: Thu, 5 Jan 2012 10:36:09 +0100 Subject: [PATCH 16/84] Corrected a problem --- src/gui/UBTeacherBarWidget.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/UBTeacherBarWidget.cpp b/src/gui/UBTeacherBarWidget.cpp index e5647a6c..d92f5cf2 100644 --- a/src/gui/UBTeacherBarWidget.cpp +++ b/src/gui/UBTeacherBarWidget.cpp @@ -311,7 +311,7 @@ UBTeacherStudentAction::UBTeacherStudentAction(QWidget *parent, const char *name mpCombo = new QComboBox(this); mpCombo->addItem(tr("Teacher")); mpCombo->addItem(tr("Student")); - mpComboLayout->addWidget(0); + mpComboLayout->addWidget(mpCombo, 0); mpComboLayout->addStretch(1); mpLayout->addLayout(mpComboLayout, 0); From 0aab9a99576542427bb510bee6020ce30cd95308 Mon Sep 17 00:00:00 2001 From: shibakaneki Date: Thu, 5 Jan 2012 10:53:35 +0100 Subject: [PATCH 17/84] Stylized the widgets --- resources/style.qss | 1 - src/gui/UBTeacherBarWidget.cpp | 9 +++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/resources/style.qss b/resources/style.qss index fabe3668..8681fb80 100644 --- a/resources/style.qss +++ b/resources/style.qss @@ -1,7 +1,6 @@ QWidget#DockPaletteWidgetBox, QWidget#documentNavigator, QWidget#UBLibPathViewer, -QWidget#UBTeacherStudentAction, QWidget#UBLibNavigatorWidget, QWidget#UBLibItemProperties, QWidget#UBDownloadWidget, diff --git a/src/gui/UBTeacherBarWidget.cpp b/src/gui/UBTeacherBarWidget.cpp index d92f5cf2..3a682e8a 100644 --- a/src/gui/UBTeacherBarWidget.cpp +++ b/src/gui/UBTeacherBarWidget.cpp @@ -309,6 +309,8 @@ UBTeacherStudentAction::UBTeacherStudentAction(QWidget *parent, const char *name mpComboLayout = new QVBoxLayout(); mpCombo = new QComboBox(this); + mpCombo->setObjectName("DockPaletteWidgetComboBox"); + mpCombo->setMinimumWidth(80); mpCombo->addItem(tr("Teacher")); mpCombo->addItem(tr("Student")); mpComboLayout->addWidget(mpCombo, 0); @@ -317,6 +319,9 @@ UBTeacherStudentAction::UBTeacherStudentAction(QWidget *parent, const char *name mpLayout->addLayout(mpComboLayout, 0); mpText = new QTextEdit(this); + mpText->setObjectName("DockPaletteWidgetBox"); + mpText->setStyleSheet("background:white;"); + mpLayout->addWidget(mpText, 1); } @@ -449,11 +454,15 @@ UBUrlWidget::UBUrlWidget(QWidget *parent, const char *name):QWidget(parent) , mpUrl(NULL) { setObjectName(name); + setAttribute(Qt::WA_StyledBackground, true); + setStyleSheet(UBApplication::globalStyleSheet()); + mpLayout = new QHBoxLayout(this); setLayout(mpLayout); mpUrlLabel = new QLabel(tr("Url"), this); mpLayout->addWidget(mpUrlLabel, 0); mpUrl = new QLineEdit(this); + mpUrl->setObjectName("DockPaletteWidgetLineEdit"); mpLayout->addWidget(mpUrl, 1); } From bac4c4caac970f231c7e4a6f6efafdc7a25b4431 Mon Sep 17 00:00:00 2001 From: Claudio Valerio Date: Thu, 5 Jan 2012 10:59:23 +0100 Subject: [PATCH 18/84] first draft for fixing resize problem --- src/customWidgets/UBWidgetList.cpp | 41 ++++++++++++++++-------------- src/gui/UBTeacherBarWidget.cpp | 17 ++++++++----- src/gui/UBTeacherBarWidget.h | 2 +- 3 files changed, 33 insertions(+), 27 deletions(-) diff --git a/src/customWidgets/UBWidgetList.cpp b/src/customWidgets/UBWidgetList.cpp index fa3ce3ed..667d8908 100644 --- a/src/customWidgets/UBWidgetList.cpp +++ b/src/customWidgets/UBWidgetList.cpp @@ -50,9 +50,9 @@ void UBWidgetList::addWidget(QWidget *widget) { if(NULL != mpLayout){ mpEmptyLabel->setVisible(false); + mWidgets << widget; updateSize(true, widget); mpLayout->addWidget(widget); - mWidgets << widget; } } @@ -76,34 +76,31 @@ void UBWidgetList::updateSize(bool widgetAdded, QWidget *widget) int newWidgetHeight; if(eWidgetListOrientation_Vertical == mOrientation){ - scaleFactor = (float)mpContainer->width() / (float)widget->width(); + scaleFactor = (float)widget->width() / (float)mpContainer->width(); }else{ - scaleFactor = (float)mpContainer->height() / (float)widget->height(); + scaleFactor = (float)widget->height() / (float)mpContainer->height(); } - newWidgetWidth = (int)((float)widget->width()*scaleFactor); - newWidgetHeight = (int)((float)widget->height()*scaleFactor); - - qDebug() << "container size " << mpContainer->size(); - qDebug() << "widget size " << widget->size(); - qDebug() << "scale factor " << scaleFactor; - + newWidgetWidth = widget->width()/scaleFactor; + newWidgetHeight = widget->height()/scaleFactor; widget->resize(newWidgetWidth, newWidgetHeight); - qDebug() << "widget new value " << newWidgetWidth << "x" << newWidgetHeight; // Now we have to update the container if(eWidgetListOrientation_Vertical == mOrientation){ if(widgetAdded){ mpContainer->resize(mpContainer->width(), mpContainer->height() + newWidgetHeight); - }else{ + } + else{ mpContainer->resize(mpContainer->width(), mpContainer->height() - newWidgetHeight); } - }else{ + } + else{ if(widgetAdded){ mpContainer->resize(mpContainer->width() + newWidgetWidth, mpContainer->height()); - }else{ + } + else{ mpContainer->resize(mpContainer->width() - newWidgetWidth, mpContainer->height()); } } @@ -119,12 +116,17 @@ void UBWidgetList::resizeEvent(QResizeEvent *ev) float scale; if(eWidgetListOrientation_Vertical == mOrientation){ scale = (float)ev->size().width() / (float)ev->oldSize().width(); - updateAllWidgetsize(scale); - mpContainer->resize(width() - 2, mpContainer->height()*scale); - }else{ + if(scale != 0 && scale < 10){ + updateAllWidgetsize(scale); + mpContainer->resize(width() - 2, mpContainer->height()*scale); + } + } + else{ scale = (float)ev->size().height() / (float)ev->oldSize().height(); - updateAllWidgetsize(scale); - mpContainer->resize(mpContainer->width()*scale, height() - 2); + if(scale != 0 && scale < 10){ + updateAllWidgetsize(scale); + mpContainer->resize(mpContainer->width()*scale, height() - 2); + } } } } @@ -154,3 +156,4 @@ void UBWidgetList::setEmptyText(const QString &text) } // TODO : - add onHover 'delete' button + diff --git a/src/gui/UBTeacherBarWidget.cpp b/src/gui/UBTeacherBarWidget.cpp index 3a682e8a..d65e41fe 100644 --- a/src/gui/UBTeacherBarWidget.cpp +++ b/src/gui/UBTeacherBarWidget.cpp @@ -112,7 +112,7 @@ UBTeacherBarWidget::UBTeacherBarWidget(QWidget *parent, const char *name):UBDock // Media mpMediaLabel = new QLabel(tr("Media"), this); mpLayout->addWidget(mpMediaLabel, 0); - mpDropMediaZone = new UBTeacherBarDropMediaZone(); + mpDropMediaZone = new UBTeacherBarDropMediaZone(this); mpLayout->addWidget(mpDropMediaZone, 1); // Links @@ -369,9 +369,9 @@ UBTeacherBarDropMediaZone::UBTeacherBarDropMediaZone(QWidget *parent, const char { setObjectName(name); setAcceptDrops(true); - - mWidget.setEmptyText(tr("Drag media here ...")); - mLayout.addWidget(&mWidget); + mWidget = new UBWidgetList(parent); + mWidget->setEmptyText(tr("Drag media here ...")); + mLayout.addWidget(mWidget); setLayout(&mLayout); } @@ -379,6 +379,10 @@ UBTeacherBarDropMediaZone::UBTeacherBarDropMediaZone(QWidget *parent, const char UBTeacherBarDropMediaZone::~UBTeacherBarDropMediaZone() { qDeleteAll(mWidgetList); + if(mWidget){ + delete mWidget; + mWidget = NULL; + } } @@ -423,9 +427,8 @@ void UBTeacherBarDropMediaZone::dropEvent(QDropEvent *pEvent) QPixmap pix = pixFromDropEvent.height() ? pixFromDropEvent : QPixmap(resourcePath); QLabel* label = new QLabel(); label->setPixmap(pix); - //label->resize(size()); label->setScaledContents(true); - mWidget.addWidget(label); + mWidget->addWidget(label); mWidgetList << label; } else if(mimeType.contains("video") || mimeType.contains("audio")){ @@ -433,7 +436,7 @@ void UBTeacherBarDropMediaZone::dropEvent(QDropEvent *pEvent) mediaPlayer->setFile(resourcePath); //mediaPlayer->resize(size()); mediaPlayer->playPause(); - mWidget.addWidget(mediaPlayer); + mWidget->addWidget(mediaPlayer); mWidgetList << mediaPlayer; } else{ diff --git a/src/gui/UBTeacherBarWidget.h b/src/gui/UBTeacherBarWidget.h index 29933d9d..644b496a 100644 --- a/src/gui/UBTeacherBarWidget.h +++ b/src/gui/UBTeacherBarWidget.h @@ -48,7 +48,7 @@ public: private: QListmWidgetList; - UBWidgetList mWidget; + UBWidgetList* mWidget; QVBoxLayout mLayout; From 0fb7cad9883006f92a64346139d6dd7ce0b404d0 Mon Sep 17 00:00:00 2001 From: shibakaneki Date: Thu, 5 Jan 2012 11:33:24 +0100 Subject: [PATCH 19/84] Added some logic in the teacher bar --- src/customWidgets/UBWidgetList.cpp | 5 +++++ src/customWidgets/UBWidgetList.h | 1 + src/gui/UBTeacherBarWidget.cpp | 16 ++++++++++++++-- src/gui/UBTeacherBarWidget.h | 1 + 4 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/customWidgets/UBWidgetList.cpp b/src/customWidgets/UBWidgetList.cpp index 667d8908..5ec2ea96 100644 --- a/src/customWidgets/UBWidgetList.cpp +++ b/src/customWidgets/UBWidgetList.cpp @@ -155,5 +155,10 @@ void UBWidgetList::setEmptyText(const QString &text) } } +bool UBWidgetList::empty() +{ + return mWidgets.empty(); +} + // TODO : - add onHover 'delete' button diff --git a/src/customWidgets/UBWidgetList.h b/src/customWidgets/UBWidgetList.h index 87337458..0aa00572 100644 --- a/src/customWidgets/UBWidgetList.h +++ b/src/customWidgets/UBWidgetList.h @@ -27,6 +27,7 @@ public: void setMargin(int margin); void setEmptyText(const QString& text); int margin(); + bool empty(); protected: void resizeEvent(QResizeEvent* ev); diff --git a/src/gui/UBTeacherBarWidget.cpp b/src/gui/UBTeacherBarWidget.cpp index d65e41fe..93e1fc61 100644 --- a/src/gui/UBTeacherBarWidget.cpp +++ b/src/gui/UBTeacherBarWidget.cpp @@ -245,7 +245,11 @@ UBTeacherBarWidget::~UBTeacherBarWidget() void UBTeacherBarWidget::onValueChanged() { - if( mpTitle->text() == "") + if( mpTitle->text() == "" && + mpLinks->empty() && + mpActions->empty() && + mpDropMediaZone->empty() && + mpComments->document()->toPlainText() == "") { mIconToLeft = QPixmap(":images/teacher_open_disabled.png"); mIconToRight = QPixmap(":images/teacher_close_disabled.png"); @@ -291,6 +295,7 @@ void UBTeacherBarWidget::onLinkButton() mpLinks->addWidget(pUrl); } +// --------------------------------------------------------------------------------------------- UBTeacherStudentAction::UBTeacherStudentAction(QWidget *parent, const char *name):QWidget(parent) , mpText(NULL) , mpLayout(NULL) @@ -359,11 +364,14 @@ QString UBTeacherStudentAction::comboValue() { QString str; - // TODO : Implement this method + if(NULL != mpCombo){ + str = mpCombo->currentText(); + } return str; } +// --------------------------------------------------------------------------------------------- UBTeacherBarDropMediaZone::UBTeacherBarDropMediaZone(QWidget *parent, const char *name):QWidget(parent) { @@ -385,6 +393,10 @@ UBTeacherBarDropMediaZone::~UBTeacherBarDropMediaZone() } } +bool UBTeacherBarDropMediaZone::empty() +{ + return mWidget->empty(); +} void UBTeacherBarDropMediaZone::dragEnterEvent(QDragEnterEvent *pEvent) { diff --git a/src/gui/UBTeacherBarWidget.h b/src/gui/UBTeacherBarWidget.h index 644b496a..b29b5136 100644 --- a/src/gui/UBTeacherBarWidget.h +++ b/src/gui/UBTeacherBarWidget.h @@ -45,6 +45,7 @@ class UBTeacherBarDropMediaZone : public QWidget public: UBTeacherBarDropMediaZone(QWidget* parent=0, const char* name="UBTeacherBarDropMediaZone"); ~UBTeacherBarDropMediaZone(); + bool empty(); private: QListmWidgetList; From ca29e0d5e36f96a57d4c76108fc0ca7b191a5316 Mon Sep 17 00:00:00 2001 From: shibakaneki Date: Thu, 5 Jan 2012 14:34:57 +0100 Subject: [PATCH 20/84] Added the ability to save the values of the teacher bar in the UBZ file --- src/core/UBPersistenceManager.cpp | 53 ++++++++++++------- src/core/UBPersistenceManager.h | 13 ++--- src/gui/UBTeacherBarWidget.cpp | 88 ++++++++++++++++++++++++++++++- src/gui/UBTeacherBarWidget.h | 3 ++ 4 files changed, 128 insertions(+), 29 deletions(-) diff --git a/src/core/UBPersistenceManager.cpp b/src/core/UBPersistenceManager.cpp index 9ac5d13a..d3389c19 100644 --- a/src/core/UBPersistenceManager.cpp +++ b/src/core/UBPersistenceManager.cpp @@ -1086,16 +1086,36 @@ void UBPersistenceManager::persistTeacherBar(UBDocumentProxy* pDocumentProxy, in // Set the element values QDomElement teacherBarElem = teacherBarNode.toElement(); teacherBarElem.setAttribute("title", infos.title); - teacherBarElem.setAttribute("phasis", infos.phasis); - teacherBarElem.setAttribute("duration", infos.Duration); - teacherBarElem.setAttribute("equipment", infos.material); - teacherBarElem.setAttribute("activity", infos.activity); - teacherBarElem.setAttribute("action1Teacher", infos.action1Master); - teacherBarElem.setAttribute("action1Student", infos.action1Student); - teacherBarElem.setAttribute("action2Teacher", infos.action2Master); - teacherBarElem.setAttribute("action2Student", infos.action2Student); - teacherBarElem.setAttribute("action3Teacher", infos.action3Master); - teacherBarElem.setAttribute("action3Student", infos.action3Student); + teacherBarElem.setAttribute("duration", QString("%0").arg(infos.Duration)); + + QString qsAct; + for(int i=0; itext(); + // Duration + if(mpDuration1->isChecked()){ + infos.Duration = 0; + }else if(mpDuration2->isChecked()){ + infos.Duration = 1; + }else{ + infos.Duration = 2; + } + // Actions + for(int i=0; icomboValue()).arg(mActionList.at(i)->text()); + } + // Media + // TODO : Get the url of the dropped medias and store them in infos.medias + + // Links + for(int j=0; jurl()){ + infos.urls << mUrlList.at(j)->url(); + } + } + // Comments + infos.comments = mpComments->document()->toPlainText(); + UBPersistenceManager::persistenceManager()->persistTeacherBar(UBApplication::boardController->activeDocument(), UBApplication::boardController->activeSceneIndex(), infos); } void UBTeacherBarWidget::loadContent() { sTeacherBarInfos nextInfos = UBPersistenceManager::persistenceManager()->getTeacherBarInfos(UBApplication::boardController->activeDocument(), UBApplication::boardController->activeSceneIndex()); + // Title mpTitle->setText(nextInfos.title); + // Duration + switch(nextInfos.Duration){ + case 0: mpDuration1->setChecked(true); + break; + case 1: mpDuration2->setChecked(true); + break; + case 2: mpDuration3->setChecked(true); + break; + default: mpDuration1->setChecked(true); + break; + } + // Actions + for(int i=0; i= 2){ + UBTeacherStudentAction* pAction = new UBTeacherStudentAction(this); + pAction->setComboValue(qslAction.at(0).toInt()); + pAction->setText(qslAction.at(1)); + mActionList << pAction; + mpActions->addWidget(pAction); + } + } + // Media + // TODO : Add the media items here + + // Links + for(int j=0; jsetUrl(qsUrl); + mUrlList << pLink; + mpLinks->addWidget(pLink); + } + } + // Comments + if(NULL != mpComments){ + mpComments->document()->setPlainText(nextInfos.comments); + } } void UBTeacherBarWidget::onTitleTextChanged(const QString& text) @@ -365,12 +430,26 @@ QString UBTeacherStudentAction::comboValue() QString str; if(NULL != mpCombo){ - str = mpCombo->currentText(); + str = QString("%0").arg(mpCombo->currentIndex()); } return str; } +void UBTeacherStudentAction::setComboValue(int value) +{ + if(NULL != mpCombo){ + mpCombo->setCurrentIndex(value); + } +} + +void UBTeacherStudentAction::setText(const QString& text) +{ + if(NULL != mpText){ + mpText->document()->setPlainText(text); + } +} + // --------------------------------------------------------------------------------------------- UBTeacherBarDropMediaZone::UBTeacherBarDropMediaZone(QWidget *parent, const char *name):QWidget(parent) @@ -507,3 +586,10 @@ QString UBUrlWidget::url() return str; } + +void UBUrlWidget::setUrl(const QString &url) +{ + if(NULL != mpUrl){ + mpUrl->setText(url); + } +} diff --git a/src/gui/UBTeacherBarWidget.h b/src/gui/UBTeacherBarWidget.h index b29b5136..f59f64ed 100644 --- a/src/gui/UBTeacherBarWidget.h +++ b/src/gui/UBTeacherBarWidget.h @@ -29,6 +29,8 @@ public: ~UBTeacherStudentAction(); QString comboValue(); QString text(); + void setComboValue(int value); + void setText(const QString& text); private: QTextEdit* mpText; @@ -67,6 +69,7 @@ public: ~UBUrlWidget(); QString url(); + void setUrl(const QString& url); private: QHBoxLayout* mpLayout; From 84abba1f77b92eac06b9607e7e12b44d1a5ff868 Mon Sep 17 00:00:00 2001 From: shibakaneki Date: Thu, 5 Jan 2012 15:12:36 +0100 Subject: [PATCH 21/84] Fixed an issue in the teacherbar --- src/gui/UBTeacherBarWidget.cpp | 23 ++++++++++++++++++----- src/gui/UBTeacherBarWidget.h | 2 +- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/gui/UBTeacherBarWidget.cpp b/src/gui/UBTeacherBarWidget.cpp index 833e1796..2c41ed50 100644 --- a/src/gui/UBTeacherBarWidget.cpp +++ b/src/gui/UBTeacherBarWidget.cpp @@ -24,7 +24,6 @@ UBTeacherBarWidget::UBTeacherBarWidget(QWidget *parent, const char *name):UBDock , mpTitleLabel(NULL) , mpDurationLabel(NULL) , mpTitle(NULL) - , mpAction1(NULL) , mpMediaLabel(NULL) , mpDropMediaZone(NULL) , mpContainer(NULL) @@ -185,10 +184,6 @@ UBTeacherBarWidget::~UBTeacherBarWidget() delete mpActionLayout; mpActionLayout = NULL; } - if(NULL != mpAction1){ - delete mpAction1; - mpAction1 = NULL; - } if(NULL != mpActionLabel){ delete mpActionLabel; mpActionLabel = NULL; @@ -297,6 +292,7 @@ void UBTeacherBarWidget::saveContent() void UBTeacherBarWidget::loadContent() { + clearWidgetLists(); sTeacherBarInfos nextInfos = UBPersistenceManager::persistenceManager()->getTeacherBarInfos(UBApplication::boardController->activeDocument(), UBApplication::boardController->activeSceneIndex()); // Title mpTitle->setText(nextInfos.title); @@ -360,6 +356,23 @@ void UBTeacherBarWidget::onLinkButton() mpLinks->addWidget(pUrl); } +void UBTeacherBarWidget::clearWidgetLists() +{ + if(NULL != mpActions){ + for(int i=0; iremoveWidget(mActionList.at(i)); + } + mActionList.clear(); + } + + if(NULL != mpLinks){ + for(int i=0; iremoveWidget(mUrlList.at(i)); + } + mUrlList.clear(); + } +} + // --------------------------------------------------------------------------------------------- UBTeacherStudentAction::UBTeacherStudentAction(QWidget *parent, const char *name):QWidget(parent) , mpText(NULL) diff --git a/src/gui/UBTeacherBarWidget.h b/src/gui/UBTeacherBarWidget.h index f59f64ed..07ca9674 100644 --- a/src/gui/UBTeacherBarWidget.h +++ b/src/gui/UBTeacherBarWidget.h @@ -93,13 +93,13 @@ private slots: void onLinkButton(); private: + void clearWidgetLists(); QVBoxLayout* mpLayout; QHBoxLayout* mpTitleLayout; QHBoxLayout* mpDurationLayout; QLabel* mpTitleLabel; QLabel* mpDurationLabel; QLineEdit* mpTitle; - UBTeacherStudentAction* mpAction1; QLabel* mpMediaLabel; UBTeacherBarDropMediaZone* mpDropMediaZone; QWidget* mpContainer; From b731b302de929ace527a50991835f5087039388a Mon Sep 17 00:00:00 2001 From: Claudio Valerio Date: Thu, 5 Jan 2012 15:13:00 +0100 Subject: [PATCH 22/84] fixed UBWidgetList resize issue --- src/core/UBApplicationController.cpp | 1 - src/customWidgets/UBWidgetList.cpp | 112 ++++++++++++--------------- src/customWidgets/UBWidgetList.h | 8 +- 3 files changed, 54 insertions(+), 67 deletions(-) diff --git a/src/core/UBApplicationController.cpp b/src/core/UBApplicationController.cpp index 68c9b81b..2c24539a 100644 --- a/src/core/UBApplicationController.cpp +++ b/src/core/UBApplicationController.cpp @@ -722,7 +722,6 @@ void UBApplicationController::importFile(const QString& pFilePath) void UBApplicationController::useMultiScreen(bool use) { mDisplayManager->setUseMultiScreen(use); - } diff --git a/src/customWidgets/UBWidgetList.cpp b/src/customWidgets/UBWidgetList.cpp index 5ec2ea96..67c157b2 100644 --- a/src/customWidgets/UBWidgetList.cpp +++ b/src/customWidgets/UBWidgetList.cpp @@ -10,7 +10,6 @@ UBWidgetList::UBWidgetList(QWidget* parent, eWidgetListOrientation orientation, setObjectName(name); mOrientation = orientation; mpContainer = new QWidget(this); - mWidgets.clear(); mpEmptyLabel = new QLabel(this); mpEmptyLabel->setObjectName("emptyString"); @@ -18,12 +17,13 @@ UBWidgetList::UBWidgetList(QWidget* parent, eWidgetListOrientation orientation, setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); mpLayout = new QVBoxLayout(mpContainer); - mpContainer->resize(width(), mpContainer->height()); - }else{ + mpContainer->resize(mpContainer->width(), mpContainer->height()); + } + else{ setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded); setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); mpLayout = new QHBoxLayout(mpContainer); - mpContainer->resize(mpContainer->width(), height()); + mpContainer->resize(mpContainer->width(), mpContainer->height()); } mpLayout->setContentsMargins(margin(), margin(), margin(), margin()); mpContainer->setLayout(mpLayout); @@ -50,8 +50,8 @@ void UBWidgetList::addWidget(QWidget *widget) { if(NULL != mpLayout){ mpEmptyLabel->setVisible(false); - mWidgets << widget; - updateSize(true, widget); + mWidgetInfo[widget] = widget->size(); + updateView(size()); mpLayout->addWidget(widget); } } @@ -60,82 +60,68 @@ void UBWidgetList::removeWidget(QWidget *widget) { if(NULL != mpLayout){ mpLayout->removeWidget(widget); - mWidgets.remove(mWidgets.indexOf(widget)); - updateSize(false, widget); + mWidgetInfo.remove(widget); widget->setVisible(false); + updateView(size()); if(0 == mpLayout->count()){ mpEmptyLabel->setVisible(true); } } } -void UBWidgetList::updateSize(bool widgetAdded, QWidget *widget) -{ - float scaleFactor; - int newWidgetWidth; - int newWidgetHeight; - - if(eWidgetListOrientation_Vertical == mOrientation){ - scaleFactor = (float)widget->width() / (float)mpContainer->width(); - }else{ - scaleFactor = (float)widget->height() / (float)mpContainer->height(); - } - - newWidgetWidth = widget->width()/scaleFactor; - newWidgetHeight = widget->height()/scaleFactor; - widget->resize(newWidgetWidth, newWidgetHeight); - - - // Now we have to update the container - if(eWidgetListOrientation_Vertical == mOrientation){ - if(widgetAdded){ - mpContainer->resize(mpContainer->width(), mpContainer->height() + newWidgetHeight); - } - else{ - mpContainer->resize(mpContainer->width(), mpContainer->height() - newWidgetHeight); - } - } - else{ - if(widgetAdded){ - mpContainer->resize(mpContainer->width() + newWidgetWidth, mpContainer->height()); +int UBWidgetList::scaleWidgets(QSize pSize) +{ + int result = 0; + foreach(QWidget* eachWidget, mWidgetInfo.keys()){ + qDebug() << __FUNCTION__ << "eachWidget : " << eachWidget; + qreal scaleFactor = 0; + int newWidgetWidth = pSize.width(); + int newWidgetHeight = pSize.height(); + if(eWidgetListOrientation_Vertical == mOrientation){ + scaleFactor = (float)mWidgetInfo[eachWidget].width() / (float)pSize.width(); + qDebug() << __FUNCTION__ << "scale factor: " << scaleFactor; + newWidgetHeight = mWidgetInfo[eachWidget].height()/scaleFactor; + result += newWidgetHeight; } else{ - mpContainer->resize(mpContainer->width() - newWidgetWidth, mpContainer->height()); + scaleFactor = (float)mWidgetInfo[eachWidget].height() / (float)pSize.height(); + newWidgetWidth = mWidgetInfo[eachWidget].width()/scaleFactor; + result += newWidgetWidth; } } + return result; +} + +void UBWidgetList::scaleContainer(QSize pSize, int updateValue) +{ + if(eWidgetListOrientation_Vertical == mOrientation) + mpContainer->resize(pSize.width(), updateValue); + else + mpContainer->resize(updateValue, pSize.height()); } + +void UBWidgetList::updateView(QSize pSize) +{ + // Widgets on list are resized automatically to fit the mpcontainer. + // so if you want to keep the aspect ratio you have to calculate + // the sum of the new widget height and give it to the mpContainer. + // The container resize will trig the widgets resize and the good + // height permits to respect the aspect ratio. + int updatedValue = scaleWidgets(pSize); + scaleContainer(pSize,updatedValue); +} + + + void UBWidgetList::resizeEvent(QResizeEvent *ev) { mpEmptyLabel->setGeometry((width() - mpEmptyLabel->width()) / 2, (height() - mpEmptyLabel->height()) /2, mpEmptyLabel->width(), mpEmptyLabel->height()); - if(ev->oldSize().width() >= 0 && ev->oldSize().height() >= 0){ - float scale; - if(eWidgetListOrientation_Vertical == mOrientation){ - scale = (float)ev->size().width() / (float)ev->oldSize().width(); - if(scale != 0 && scale < 10){ - updateAllWidgetsize(scale); - mpContainer->resize(width() - 2, mpContainer->height()*scale); - } - } - else{ - scale = (float)ev->size().height() / (float)ev->oldSize().height(); - if(scale != 0 && scale < 10){ - updateAllWidgetsize(scale); - mpContainer->resize(mpContainer->width()*scale, height() - 2); - } - } - } -} - -void UBWidgetList::updateAllWidgetsize(float scale) -{ - for(int i=0; iresize(mWidgets.at(i)->width()*scale, mWidgets.at(i)->height()*scale); - } + updateView(size()); } void UBWidgetList::setMargin(int margin) @@ -157,7 +143,7 @@ void UBWidgetList::setEmptyText(const QString &text) bool UBWidgetList::empty() { - return mWidgets.empty(); + return mWidgetInfo.empty(); } // TODO : - add onHover 'delete' button diff --git a/src/customWidgets/UBWidgetList.h b/src/customWidgets/UBWidgetList.h index 0aa00572..2dd0895f 100644 --- a/src/customWidgets/UBWidgetList.h +++ b/src/customWidgets/UBWidgetList.h @@ -15,6 +15,7 @@ typedef enum{ eWidgetListOrientation_Horizontal }eWidgetListOrientation; + class UBWidgetList : public QScrollArea { Q_OBJECT @@ -33,13 +34,14 @@ protected: void resizeEvent(QResizeEvent* ev); private: - void updateSize(bool widgetAdded, QWidget* widget); - void updateAllWidgetsize(float scale); + int scaleWidgets(QSize pSize); + void scaleContainer(QSize pSize, int updateValue); + void updateView(QSize pSize); QLayout* mpLayout; QWidget* mpContainer; eWidgetListOrientation mOrientation; int mMargin; - QVector mWidgets; + QMap mWidgetInfo; QLabel* mpEmptyLabel; }; From 17f0fa9b8e40d22299be7904e64c32cc4ca84b99 Mon Sep 17 00:00:00 2001 From: shibakaneki Date: Thu, 5 Jan 2012 16:13:22 +0100 Subject: [PATCH 23/84] updated the parents in the teacher bar --- src/gui/UBTeacherBarWidget.cpp | 33 +++++++++++++++++++-------------- src/gui/UBTeacherBarWidget.h | 2 ++ 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/src/gui/UBTeacherBarWidget.cpp b/src/gui/UBTeacherBarWidget.cpp index 2c41ed50..04679ec0 100644 --- a/src/gui/UBTeacherBarWidget.cpp +++ b/src/gui/UBTeacherBarWidget.cpp @@ -42,6 +42,7 @@ UBTeacherBarWidget::UBTeacherBarWidget(QWidget *parent, const char *name):UBDock , mpLinks(NULL) , mpLinkButton(NULL) , mpLinkLayout(NULL) + , mpStackWidget(NULL) { setObjectName(name); mName = "TeacherBarWidget"; @@ -88,19 +89,19 @@ UBTeacherBarWidget::UBTeacherBarWidget(QWidget *parent, const char *name):UBDock mpDuration3 = new QCheckBox(this); mpDuration3->setIcon(QIcon(":images/duration3.png")); mpDurationLayout->addWidget(mpDuration3, 0); - mpDurationButtons = new QButtonGroup(this); + mpDurationButtons = new QButtonGroup(mpContainer); mpDurationButtons->addButton(mpDuration1); mpDurationButtons->addButton(mpDuration2); mpDurationButtons->addButton(mpDuration3); mpLayout->addLayout(mpDurationLayout, 0); // Actions - mpActionLabel = new QLabel(tr("Actions"), this); + mpActionLabel = new QLabel(tr("Actions"), mpContainer); mpLayout->addWidget(mpActionLabel, 0); - mpActions = new UBWidgetList(this); + mpActions = new UBWidgetList(mpContainer); mpActions->setEmptyText(tr("Add actions")); mpLayout->addWidget(mpActions, 1); - mpActionButton = new QPushButton(this); + mpActionButton = new QPushButton(mpContainer); mpActionButton->setObjectName("DockPaletteWidgetButton"); mpActionButton->setText(tr("Add action")); mpActionLayout = new QHBoxLayout(); @@ -109,17 +110,17 @@ UBTeacherBarWidget::UBTeacherBarWidget(QWidget *parent, const char *name):UBDock mpLayout->addLayout(mpActionLayout, 0); // Media - mpMediaLabel = new QLabel(tr("Media"), this); + mpMediaLabel = new QLabel(tr("Media"), mpContainer); mpLayout->addWidget(mpMediaLabel, 0); - mpDropMediaZone = new UBTeacherBarDropMediaZone(this); + mpDropMediaZone = new UBTeacherBarDropMediaZone(mpContainer); mpLayout->addWidget(mpDropMediaZone, 1); // Links - mpLinkLabel = new QLabel(tr("Links"), this); + mpLinkLabel = new QLabel(tr("Links"), mpContainer); mpLayout->addWidget(mpLinkLabel, 0); - mpLinks = new UBWidgetList(this); + mpLinks = new UBWidgetList(mpContainer); mpLayout->addWidget(mpLinks, 1); - mpLinkButton = new QPushButton(tr("Add link"), this); + mpLinkButton = new QPushButton(tr("Add link"), mpContainer); mpLinkButton->setObjectName("DockPaletteWidgetButton"); mpLinkLayout = new QHBoxLayout(); mpLinkLayout->addWidget(mpLinkButton, 0); @@ -127,7 +128,7 @@ UBTeacherBarWidget::UBTeacherBarWidget(QWidget *parent, const char *name):UBDock mpLayout->addLayout(mpLinkLayout, 0); // Comments - mpCommentLabel = new QLabel(tr("Comments"), this); + mpCommentLabel = new QLabel(tr("Comments"), mpContainer); mpLayout->addWidget(mpCommentLabel, 0); mpComments = new QTextEdit(this); mpComments->setObjectName("DockPaletteWidgetBox"); @@ -236,6 +237,10 @@ UBTeacherBarWidget::~UBTeacherBarWidget() delete mpContainerLayout; mpContainerLayout = NULL; } + if(NULL != mpStackWidget){ + delete mpStackWidget; + mpStackWidget = NULL; + } } void UBTeacherBarWidget::onValueChanged() @@ -311,7 +316,7 @@ void UBTeacherBarWidget::loadContent() for(int i=0; i= 2){ - UBTeacherStudentAction* pAction = new UBTeacherStudentAction(this); + UBTeacherStudentAction* pAction = new UBTeacherStudentAction(mpContainer); pAction->setComboValue(qslAction.at(0).toInt()); pAction->setText(qslAction.at(1)); mActionList << pAction; @@ -325,7 +330,7 @@ void UBTeacherBarWidget::loadContent() for(int j=0; jsetUrl(qsUrl); mUrlList << pLink; mpLinks->addWidget(pLink); @@ -344,14 +349,14 @@ void UBTeacherBarWidget::onTitleTextChanged(const QString& text) void UBTeacherBarWidget::onActionButton() { - UBTeacherStudentAction* pAction = new UBTeacherStudentAction(this); + UBTeacherStudentAction* pAction = new UBTeacherStudentAction(mpContainer); mActionList << pAction; mpActions->addWidget(pAction); } void UBTeacherBarWidget::onLinkButton() { - UBUrlWidget* pUrl = new UBUrlWidget(this); + UBUrlWidget* pUrl = new UBUrlWidget(mpContainer); mUrlList << pUrl; mpLinks->addWidget(pUrl); } diff --git a/src/gui/UBTeacherBarWidget.h b/src/gui/UBTeacherBarWidget.h index 07ca9674..8082bc6f 100644 --- a/src/gui/UBTeacherBarWidget.h +++ b/src/gui/UBTeacherBarWidget.h @@ -14,6 +14,7 @@ class UBMediaPlayer; #include #include #include +#include #include "UBDockPaletteWidget.h" #include "customWidgets/UBWidgetList.h" @@ -118,6 +119,7 @@ private: QHBoxLayout* mpLinkLayout; QLabel* mpCommentLabel; QTextEdit* mpComments; + QStackedWidget* mpStackWidget; QVector mActionList; QVector mUrlList; From 15ea3abdb645fa6978005914af506376e9b9e312 Mon Sep 17 00:00:00 2001 From: Claudio Valerio Date: Thu, 5 Jan 2012 16:24:40 +0100 Subject: [PATCH 24/84] saved media infos into svg file --- src/gui/UBTeacherBarWidget.cpp | 82 ++++++++++++++++++++++++---------- src/gui/UBTeacherBarWidget.h | 5 +++ 2 files changed, 64 insertions(+), 23 deletions(-) diff --git a/src/gui/UBTeacherBarWidget.cpp b/src/gui/UBTeacherBarWidget.cpp index 04679ec0..1b16d44f 100644 --- a/src/gui/UBTeacherBarWidget.cpp +++ b/src/gui/UBTeacherBarWidget.cpp @@ -282,6 +282,7 @@ void UBTeacherBarWidget::saveContent() } // Media // TODO : Get the url of the dropped medias and store them in infos.medias + infos.medias = mpDropMediaZone->mediaList(); // Links for(int j=0; jreloadMedia(nextInfos.medias); // Links for(int j=0; jcleanMedias(); + if(NULL != mpActions){ for(int i=0; iremoveWidget(mActionList.at(i)); @@ -483,13 +487,25 @@ UBTeacherBarDropMediaZone::UBTeacherBarDropMediaZone(QWidget *parent, const char UBTeacherBarDropMediaZone::~UBTeacherBarDropMediaZone() { - qDeleteAll(mWidgetList); + cleanMedias(); if(mWidget){ delete mWidget; mWidget = NULL; } } +void UBTeacherBarDropMediaZone::cleanMedias() +{ + foreach(QWidget* eachWidget,mWidgetList){ + mWidget->removeWidget(eachWidget); + delete eachWidget; + } + + mWidgetList.clear(); + + mMediaList.clear(); +} + bool UBTeacherBarDropMediaZone::empty() { return mWidget->empty(); @@ -505,6 +521,46 @@ void UBTeacherBarDropMediaZone::dragLeaveEvent(QDragLeaveEvent *pEvent) pEvent->accept(); } + +void UBTeacherBarDropMediaZone::addMedia(QString pMediaPath) +{ + if(!pMediaPath.isEmpty()) + mMediaList.append(pMediaPath); + else + qWarning() << __FUNCTION__ << "empty path"; + + QString mimeType = UBFileSystemUtils::mimeTypeFromFileName(pMediaPath); + if(mimeType.contains("image")){ + QPixmap pix = QPixmap(pMediaPath); + QLabel* label = new QLabel(); + label->setPixmap(pix); + label->setScaledContents(true); + mWidget->addWidget(label); + mWidgetList << label; + } + else if(mimeType.contains("video") || mimeType.contains("audio")){ + UBMediaPlayer* mediaPlayer = new UBMediaPlayer(); + mediaPlayer->setFile(pMediaPath); + mediaPlayer->playPause(); + mWidget->addWidget(mediaPlayer); + mWidgetList << mediaPlayer; + } + else{ + qWarning() << "pMediaPath" << pMediaPath; + qWarning() << "bad idea to come here"; + } + +} + +void UBTeacherBarDropMediaZone::reloadMedia(QStringList pList) +{ + cleanMedias(); + foreach(QString eachString, pList){ + addMedia(eachString); + } + +} + void UBTeacherBarDropMediaZone::dropEvent(QDropEvent *pEvent) { QPixmap pixFromDropEvent; @@ -529,28 +585,8 @@ void UBTeacherBarDropMediaZone::dropEvent(QDropEvent *pEvent) pEvent->acceptProposedAction(); return; } - - mimeType = mimeType.isEmpty() ? UBFileSystemUtils::mimeTypeFromFileName(resourcePath) : mimeType; - if(mimeType.contains("image")){ - qDebug() << pixFromDropEvent.size(); - QPixmap pix = pixFromDropEvent.height() ? pixFromDropEvent : QPixmap(resourcePath); - QLabel* label = new QLabel(); - label->setPixmap(pix); - label->setScaledContents(true); - mWidget->addWidget(label); - mWidgetList << label; - } - else if(mimeType.contains("video") || mimeType.contains("audio")){ - UBMediaPlayer* mediaPlayer = new UBMediaPlayer(); - mediaPlayer->setFile(resourcePath); - //mediaPlayer->resize(size()); - mediaPlayer->playPause(); - mWidget->addWidget(mediaPlayer); - mWidgetList << mediaPlayer; - } - else{ - qWarning() << "bad idea to come here"; - } + if(!resourcePath.isEmpty()) + addMedia(resourcePath); pEvent->acceptProposedAction(); } diff --git a/src/gui/UBTeacherBarWidget.h b/src/gui/UBTeacherBarWidget.h index 8082bc6f..d72fbf70 100644 --- a/src/gui/UBTeacherBarWidget.h +++ b/src/gui/UBTeacherBarWidget.h @@ -48,9 +48,14 @@ class UBTeacherBarDropMediaZone : public QWidget public: UBTeacherBarDropMediaZone(QWidget* parent=0, const char* name="UBTeacherBarDropMediaZone"); ~UBTeacherBarDropMediaZone(); + QStringList mediaList() {return mMediaList;} + void reloadMedia(QStringList pList); + void cleanMedias(); bool empty(); private: + void addMedia(QString pMediaPath); + QStringList mMediaList; QListmWidgetList; UBWidgetList* mWidget; QVBoxLayout mLayout; From f60872774b2cae7564a96c2a940bc7b811159c5b Mon Sep 17 00:00:00 2001 From: shibakaneki Date: Thu, 5 Jan 2012 16:26:00 +0100 Subject: [PATCH 25/84] backup --- src/gui/UBTeacherBarWidget.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/gui/UBTeacherBarWidget.cpp b/src/gui/UBTeacherBarWidget.cpp index 04679ec0..55e463e8 100644 --- a/src/gui/UBTeacherBarWidget.cpp +++ b/src/gui/UBTeacherBarWidget.cpp @@ -62,7 +62,10 @@ UBTeacherBarWidget::UBTeacherBarWidget(QWidget *parent, const char *name):UBDock mpContainer = new QWidget(this); mpContainer->setObjectName("DockPaletteWidgetBox"); - mpContainerLayout->addWidget(mpContainer); + + mpStackWidget = new QStackedWidget(this); + mpContainerLayout->addWidget(mpStackWidget); + mpStackWidget->addWidget(mpContainer); mpLayout = new QVBoxLayout(mpContainer); mpContainer->setLayout(mpLayout); From 3e7e2d81703bf8676d1db638fd3c940466f9ee4e Mon Sep 17 00:00:00 2001 From: Claudio Valerio Date: Thu, 5 Jan 2012 16:35:44 +0100 Subject: [PATCH 26/84] fixed start on laod media player issue --- src/gui/UBMediaPlayer.cpp | 1 - src/gui/UBTeacherBarWidget.cpp | 1 - 2 files changed, 2 deletions(-) diff --git a/src/gui/UBMediaPlayer.cpp b/src/gui/UBMediaPlayer.cpp index 17770378..421f891b 100644 --- a/src/gui/UBMediaPlayer.cpp +++ b/src/gui/UBMediaPlayer.cpp @@ -242,7 +242,6 @@ void UBMediaPlayer::setFile(const QString &fileName) { setWindowTitle(fileName.right(fileName.length() - fileName.lastIndexOf('/') - 1)); m_MediaObject.setCurrentSource(Phonon::MediaSource(fileName)); - m_MediaObject.play(); } void UBMediaPlayer::setLocation(const QString& location) diff --git a/src/gui/UBTeacherBarWidget.cpp b/src/gui/UBTeacherBarWidget.cpp index 1b16d44f..688e2147 100644 --- a/src/gui/UBTeacherBarWidget.cpp +++ b/src/gui/UBTeacherBarWidget.cpp @@ -541,7 +541,6 @@ void UBTeacherBarDropMediaZone::addMedia(QString pMediaPath) else if(mimeType.contains("video") || mimeType.contains("audio")){ UBMediaPlayer* mediaPlayer = new UBMediaPlayer(); mediaPlayer->setFile(pMediaPath); - mediaPlayer->playPause(); mWidget->addWidget(mediaPlayer); mWidgetList << mediaPlayer; } From 079f7534c85b39825090f19c7ecfe73c23dc209c Mon Sep 17 00:00:00 2001 From: shibakaneki Date: Thu, 5 Jan 2012 16:57:17 +0100 Subject: [PATCH 27/84] First backup of the teacherbar preview widget --- src/gui/UBTeacherBarWidget.cpp | 75 +++++++++++++++++++++++++++++++--- src/gui/UBTeacherBarWidget.h | 22 ++++++++++ 2 files changed, 92 insertions(+), 5 deletions(-) diff --git a/src/gui/UBTeacherBarWidget.cpp b/src/gui/UBTeacherBarWidget.cpp index cb84c90d..5b50c6f8 100644 --- a/src/gui/UBTeacherBarWidget.cpp +++ b/src/gui/UBTeacherBarWidget.cpp @@ -43,6 +43,7 @@ UBTeacherBarWidget::UBTeacherBarWidget(QWidget *parent, const char *name):UBDock , mpLinkButton(NULL) , mpLinkLayout(NULL) , mpStackWidget(NULL) + , mpPreview(NULL) { setObjectName(name); mName = "TeacherBarWidget"; @@ -63,9 +64,12 @@ UBTeacherBarWidget::UBTeacherBarWidget(QWidget *parent, const char *name):UBDock mpContainer = new QWidget(this); mpContainer->setObjectName("DockPaletteWidgetBox"); + mpPreview = new UBTeacherBarPreviewWidget(this); + mpStackWidget = new QStackedWidget(this); mpContainerLayout->addWidget(mpStackWidget); mpStackWidget->addWidget(mpContainer); + mpStackWidget->addWidget(mpPreview); mpLayout = new QVBoxLayout(mpContainer); mpContainer->setLayout(mpLayout); @@ -144,6 +148,7 @@ UBTeacherBarWidget::UBTeacherBarWidget(QWidget *parent, const char *name):UBDock connect(mpTitle, SIGNAL(textChanged(QString)), this, SLOT(onValueChanged())); connect(mpActionButton, SIGNAL(clicked()), this, SLOT(onActionButton())); connect(mpLinkButton, SIGNAL(clicked()), this, SLOT(onLinkButton())); + connect(mpPreview, SIGNAL(showEditMode()), this, SLOT(onShowEditMode())); } UBTeacherBarWidget::~UBTeacherBarWidget() @@ -240,6 +245,10 @@ UBTeacherBarWidget::~UBTeacherBarWidget() delete mpContainerLayout; mpContainerLayout = NULL; } + if(NULL != mpPreview){ + delete mpPreview; + mpPreview = NULL; + } if(NULL != mpStackWidget){ delete mpStackWidget; mpStackWidget = NULL; @@ -248,11 +257,7 @@ UBTeacherBarWidget::~UBTeacherBarWidget() void UBTeacherBarWidget::onValueChanged() { - if( mpTitle->text() == "" && - mpLinks->empty() && - mpActions->empty() && - mpDropMediaZone->empty() && - mpComments->document()->toPlainText() == "") + if(isEmpty()) { mIconToLeft = QPixmap(":images/teacher_open_disabled.png"); mIconToRight = QPixmap(":images/teacher_close_disabled.png"); @@ -345,6 +350,19 @@ void UBTeacherBarWidget::loadContent() if(NULL != mpComments){ mpComments->document()->setPlainText(nextInfos.comments); } + + if(!isEmpty()){ + mpStackWidget->setCurrentWidget(mpPreview); + } +} + +bool UBTeacherBarWidget::isEmpty() +{ + return mpTitle->text() == "" && + mpLinks->empty() && + mpActions->empty() && + mpDropMediaZone->empty() && + mpComments->document()->toPlainText() == ""; } void UBTeacherBarWidget::onTitleTextChanged(const QString& text) @@ -385,6 +403,11 @@ void UBTeacherBarWidget::clearWidgetLists() } } +void UBTeacherBarWidget::onShowEditMode() +{ + mpStackWidget->setCurrentWidget(mpContainer); +} + // --------------------------------------------------------------------------------------------- UBTeacherStudentAction::UBTeacherStudentAction(QWidget *parent, const char *name):QWidget(parent) , mpText(NULL) @@ -650,3 +673,45 @@ void UBUrlWidget::setUrl(const QString &url) mpUrl->setText(url); } } + +// ------------------------------------------------------------------------------------ +UBTeacherBarPreviewWidget::UBTeacherBarPreviewWidget(QWidget *parent, const char *name):QWidget(parent) + , mpLayout(NULL) + , mpEditButton(NULL) + , mpEditLayout(NULL) +{ + setObjectName(name); + + mpLayout = new QVBoxLayout(this); + setLayout(mpLayout); + + mpEditButton = new QPushButton(tr("Edit infos"), this); + mpEditLayout = new QHBoxLayout(); + mpEditLayout->addStretch(1); + mpEditLayout->addWidget(mpEditButton, 0); + mpEditLayout->addStretch(1); + mpLayout->addLayout(mpEditLayout); + + connect(mpEditButton, SIGNAL(clicked()), this, SLOT(onEdit())); +} + +UBTeacherBarPreviewWidget::~UBTeacherBarPreviewWidget() +{ + if(NULL != mpEditButton){ + delete mpEditButton; + mpEditButton = NULL; + } + if(NULL != mpEditLayout){ + delete mpEditLayout; + mpEditLayout = NULL; + } + if(NULL != mpLayout){ + delete mpLayout; + mpLayout = NULL; + } +} + +void UBTeacherBarPreviewWidget::onEdit() +{ + emit showEditMode(); +} diff --git a/src/gui/UBTeacherBarWidget.h b/src/gui/UBTeacherBarWidget.h index d72fbf70..7e9caa3f 100644 --- a/src/gui/UBTeacherBarWidget.h +++ b/src/gui/UBTeacherBarWidget.h @@ -83,6 +83,25 @@ private: QLineEdit* mpUrl; }; +class UBTeacherBarPreviewWidget : public QWidget +{ + Q_OBJECT +public: + UBTeacherBarPreviewWidget(QWidget* parent=0, const char* name="UBTeacherBarPreviewWidget"); + ~UBTeacherBarPreviewWidget(); + +signals: + void showEditMode(); + +private slots: + void onEdit(); + +private: + QVBoxLayout* mpLayout; + QPushButton* mpEditButton; + QHBoxLayout* mpEditLayout; +}; + class UBTeacherBarWidget : public UBDockPaletteWidget { Q_OBJECT @@ -97,9 +116,11 @@ private slots: void onTitleTextChanged(const QString& text); void onActionButton(); void onLinkButton(); + void onShowEditMode(); private: void clearWidgetLists(); + bool isEmpty(); QVBoxLayout* mpLayout; QHBoxLayout* mpTitleLayout; QHBoxLayout* mpDurationLayout; @@ -125,6 +146,7 @@ private: QLabel* mpCommentLabel; QTextEdit* mpComments; QStackedWidget* mpStackWidget; + UBTeacherBarPreviewWidget* mpPreview; QVector mActionList; QVector mUrlList; From afab4879e1263cad40567ac9aeb8f25d5703b593 Mon Sep 17 00:00:00 2001 From: Claudio Valerio Date: Thu, 5 Jan 2012 18:18:48 +0100 Subject: [PATCH 28/84] dnd try and first media viewer widget --- src/board/UBBoardView.cpp | 4 +- src/gui/UBMediaPlayer.cpp | 8 ++-- src/gui/UBTeacherBarWidget.cpp | 79 +++++++++++++++++++++++++++++++++- src/gui/UBTeacherBarWidget.h | 25 ++++++++++- 4 files changed, 108 insertions(+), 8 deletions(-) diff --git a/src/board/UBBoardView.cpp b/src/board/UBBoardView.cpp index d5ff09e6..af99f131 100644 --- a/src/board/UBBoardView.cpp +++ b/src/board/UBBoardView.cpp @@ -33,6 +33,8 @@ #include "gui/UBToolWidget.h" #include "gui/UBResources.h" #include "gui/UBMainWindow.h" +#include "gui/UBTeacherBarWidget.h" + #include "board/UBBoardController.h" @@ -725,7 +727,7 @@ void UBBoardView::dropEvent (QDropEvent *event) { qDebug() << event->source(); - if(!event->source() || dynamic_cast(event->source()) || dynamic_cast(event->source())) + if(!event->source() || dynamic_cast(event->source()) || dynamic_cast(event->source()) || dynamic_cast(event->source())) { mController->processMimeData (event->mimeData (), mapToScene (event->pos ())); event->acceptProposedAction (); diff --git a/src/gui/UBMediaPlayer.cpp b/src/gui/UBMediaPlayer.cpp index 421f891b..357d161e 100644 --- a/src/gui/UBMediaPlayer.cpp +++ b/src/gui/UBMediaPlayer.cpp @@ -39,7 +39,7 @@ UBMediaPlayer::UBMediaPlayer() : setContextMenuPolicy(Qt::CustomContextMenu); m_videoWidget->setContextMenuPolicy(Qt::CustomContextMenu); - QSize buttonSize(34, 28); + QSize buttonSize(26, 20); // QPushButton *openButton = new QPushButton(this); @@ -67,7 +67,7 @@ UBMediaPlayer::UBMediaPlayer() : slider->setMediaObject(&m_MediaObject); QVBoxLayout *vLayout = new QVBoxLayout(this); - vLayout->setContentsMargins(8, 8, 8, 8); + vLayout->setContentsMargins(1, 1, 1, 1); // QHBoxLayout *layout = new QHBoxLayout(); @@ -101,7 +101,7 @@ UBMediaPlayer::UBMediaPlayer() : initVideoWindow(); vLayout->addWidget(&m_videoWindow); QVBoxLayout *buttonPanelLayout = new QVBoxLayout(); - m_videoWindow.hide(); +// m_videoWindow.hide(); // buttonPanelLayout->addLayout(layout); // timeLabel = new QLabel(this); @@ -224,7 +224,7 @@ void UBMediaPlayer::initVideoWindow() videoLayout->addWidget(m_videoWidget); videoLayout->setContentsMargins(0, 0, 0, 0); m_videoWindow.setLayout(videoLayout); - m_videoWindow.setMinimumSize(70, 70); + m_videoWindow.setMinimumSize(100, 100); } void UBMediaPlayer::playPause() diff --git a/src/gui/UBTeacherBarWidget.cpp b/src/gui/UBTeacherBarWidget.cpp index 17057d94..65c4ad91 100644 --- a/src/gui/UBTeacherBarWidget.cpp +++ b/src/gui/UBTeacherBarWidget.cpp @@ -333,7 +333,6 @@ void UBTeacherBarWidget::loadContent() } } // Media - // TODO : Add the media items here mpDropMediaZone->reloadMedia(nextInfos.medias); // Links @@ -352,6 +351,7 @@ void UBTeacherBarWidget::loadContent() } if(!isEmpty()){ + mpPreview->mediaViewer()->loadMedia(nextInfos.medias); mpStackWidget->setCurrentWidget(mpPreview); } } @@ -685,12 +685,14 @@ UBTeacherBarPreviewWidget::UBTeacherBarPreviewWidget(QWidget *parent, const char setLayout(mpLayout); mpEditButton = new QPushButton(tr("Edit infos"), this); - mpEditLayout = new QHBoxLayout(); + mpEditLayout = new QVBoxLayout(); mpEditLayout->addStretch(1); mpEditLayout->addWidget(mpEditButton, 0); mpEditLayout->addStretch(1); + mpEditLayout->addWidget(&mMediaViewer); mpLayout->addLayout(mpEditLayout); + connect(mpEditButton, SIGNAL(clicked()), this, SLOT(onEdit())); } @@ -714,3 +716,76 @@ void UBTeacherBarPreviewWidget::onEdit() { emit showEditMode(); } + + +// ------------------------------------------------------------------------------------ +UBTeacherBarPreviewMedia::UBTeacherBarPreviewMedia(QWidget* parent, const char* name) : QWidget(parent) +{ + setObjectName(name); + setAcceptDrops(true); + mWidget = new UBWidgetList(parent); + mWidget->setEmptyText(tr("No media found")); + mLayout.addWidget(mWidget); + setLayout(&mLayout); + //TO TEST only +// QStringList mediaPathList; +// mediaPathList << "/home/claudio/Desktop/PIPPO.jpg"; +// loadMedia(mediaPathList); +} + +UBTeacherBarPreviewMedia::~UBTeacherBarPreviewMedia() +{ + if(mWidget){ + delete mWidget; + mWidget = NULL; + } + +} + + +// for test only +QString tempString; + +void UBTeacherBarPreviewMedia::loadMedia(QStringList pMedias) +{ + foreach(QString eachString, pMedias){ + if(!eachString.isEmpty()){ + tempString = eachString; + QString mimeType = UBFileSystemUtils::mimeTypeFromFileName(eachString); + if(mimeType.contains("image")){ + QPixmap pix = QPixmap(eachString); + QLabel* label = new QLabel(); + label->setPixmap(pix); + label->setScaledContents(true); + mWidget->addWidget(label); + // mWidgetList << label; + } + else if(mimeType.contains("video") || mimeType.contains("audio")){ + UBMediaPlayer* mediaPlayer = new UBMediaPlayer(); + mediaPlayer->setFile(eachString); + mWidget->addWidget(mediaPlayer); + // mWidgetList << mediaPlayer; + } + else{ + qWarning() << "pMediaPath" << eachString; + qWarning() << "bad idea to come here"; + } + } + } +} + +void UBTeacherBarPreviewMedia::mousePressEvent(QMouseEvent *event) +{ + Q_UNUSED(event); + QMimeData *mimeData = new QMimeData; + QList urls; + urls << QUrl::fromLocalFile(tempString); + mimeData->setUrls(urls); + mimeData->setText(tempString); + + + QDrag *drag = new QDrag(this); + drag->setMimeData(mimeData); + drag->start(); +} + diff --git a/src/gui/UBTeacherBarWidget.h b/src/gui/UBTeacherBarWidget.h index 7e9caa3f..50377d65 100644 --- a/src/gui/UBTeacherBarWidget.h +++ b/src/gui/UBTeacherBarWidget.h @@ -68,6 +68,27 @@ protected: void dragLeaveEvent(QDragLeaveEvent* pEvent); }; + + +class UBTeacherBarPreviewMedia : public QWidget +{ + Q_OBJECT +public: + UBTeacherBarPreviewMedia(QWidget* parent=0, const char* name="UBTeacherBarPreviewMedia"); + ~UBTeacherBarPreviewMedia(); + void loadMedia(QStringList pMedias); + +private: + UBWidgetList* mWidget; + QVBoxLayout mLayout; + +protected: + void mousePressEvent(QMouseEvent *event); + +public slots: + +}; + class UBUrlWidget : public QWidget { public: @@ -89,6 +110,7 @@ class UBTeacherBarPreviewWidget : public QWidget public: UBTeacherBarPreviewWidget(QWidget* parent=0, const char* name="UBTeacherBarPreviewWidget"); ~UBTeacherBarPreviewWidget(); + UBTeacherBarPreviewMedia* mediaViewer() {return &mMediaViewer;} signals: void showEditMode(); @@ -99,7 +121,8 @@ private slots: private: QVBoxLayout* mpLayout; QPushButton* mpEditButton; - QHBoxLayout* mpEditLayout; + QVBoxLayout* mpEditLayout; + UBTeacherBarPreviewMedia mMediaViewer; }; class UBTeacherBarWidget : public UBDockPaletteWidget From 08f9384b4321c77ae073d3415ce9be605d79ad0f Mon Sep 17 00:00:00 2001 From: Claudio Valerio Date: Fri, 6 Jan 2012 10:51:35 +0100 Subject: [PATCH 29/84] handling drop from preview mode --- src/board/UBBoardView.cpp | 10 +++--- src/core/UBDisplayManager.cpp | 2 +- src/customWidgets/UBDraggableLabel.cpp | 39 +++++++++++++++++++++++ src/customWidgets/UBDraggableLabel.h | 23 ++++++++++++++ src/customWidgets/customWidgets.pri | 8 +++-- src/gui/UBMediaPlayer.cpp | 28 ++++++++++++++++ src/gui/UBMediaPlayer.h | 12 +++++++ src/gui/UBTeacherBarWidget.cpp | 44 +++++++------------------- src/gui/UBTeacherBarWidget.h | 7 +--- 9 files changed, 126 insertions(+), 47 deletions(-) create mode 100644 src/customWidgets/UBDraggableLabel.cpp create mode 100644 src/customWidgets/UBDraggableLabel.h diff --git a/src/board/UBBoardView.cpp b/src/board/UBBoardView.cpp index af99f131..4cbfe088 100644 --- a/src/board/UBBoardView.cpp +++ b/src/board/UBBoardView.cpp @@ -19,6 +19,7 @@ #include "UBDrawingController.h" #include "frameworks/UBGeometryUtils.h" +#include "frameworks/UBPlatformUtils.h" #include "core/UBSettings.h" #include "core/UBMimeData.h" @@ -33,8 +34,8 @@ #include "gui/UBToolWidget.h" #include "gui/UBResources.h" #include "gui/UBMainWindow.h" -#include "gui/UBTeacherBarWidget.h" - +#include "gui/UBMediaPlayer.h" +#include "gui/UBThumbnailWidget.h" #include "board/UBBoardController.h" @@ -44,9 +45,8 @@ #include "domain/UBItem.h" #include "document/UBDocumentProxy.h" -#include "../gui/UBThumbnailWidget.h" -#include "frameworks/UBPlatformUtils.h" +#include "customWidgets/UBDraggableLabel.h" #include "core/memcheck.h" @@ -727,7 +727,7 @@ void UBBoardView::dropEvent (QDropEvent *event) { qDebug() << event->source(); - if(!event->source() || dynamic_cast(event->source()) || dynamic_cast(event->source()) || dynamic_cast(event->source())) + if(!event->source() || dynamic_cast(event->source()) || dynamic_cast(event->source()) || dynamic_cast(event->source()) || dynamic_cast(event->source())) { mController->processMimeData (event->mimeData (), mapToScene (event->pos ())); event->acceptProposedAction (); diff --git a/src/core/UBDisplayManager.cpp b/src/core/UBDisplayManager.cpp index 6ecdc679..c6214d15 100644 --- a/src/core/UBDisplayManager.cpp +++ b/src/core/UBDisplayManager.cpp @@ -48,7 +48,7 @@ UBDisplayManager::UBDisplayManager(QObject *parent) void UBDisplayManager::initScreenIndexes() { - int screenCount = numScreens(); + int screenCount = 1;//numScreens(); mScreenIndexesRoles.clear(); diff --git a/src/customWidgets/UBDraggableLabel.cpp b/src/customWidgets/UBDraggableLabel.cpp new file mode 100644 index 00000000..200205b9 --- /dev/null +++ b/src/customWidgets/UBDraggableLabel.cpp @@ -0,0 +1,39 @@ +#include +#include +#include + +#include "UBDraggableLabel.h" + + +UBDraggableLabel::UBDraggableLabel(QWidget *parent) : + QLabel(parent) +{ +} + +UBDraggableLabel::~UBDraggableLabel() +{ + //NOOP +} + +void UBDraggableLabel::loadImage(QString imagePath) +{ + mSourcePath = imagePath; + QPixmap pix = QPixmap(mSourcePath); + setPixmap(pix); + setScaledContents(true); +} + +void UBDraggableLabel::mousePressEvent(QMouseEvent *event) +{ + Q_UNUSED(event); + QMimeData *mimeData = new QMimeData; + QList urls; + urls << QUrl::fromLocalFile(mSourcePath); + mimeData->setUrls(urls); + mimeData->setText(mSourcePath); + + + QDrag *drag = new QDrag(this); + drag->setMimeData(mimeData); + drag->start(); +} diff --git a/src/customWidgets/UBDraggableLabel.h b/src/customWidgets/UBDraggableLabel.h new file mode 100644 index 00000000..384b313e --- /dev/null +++ b/src/customWidgets/UBDraggableLabel.h @@ -0,0 +1,23 @@ +#ifndef UBDRAGGABLELABEL_H +#define UBDRAGGABLELABEL_H + +#include + +class UBDraggableLabel : public QLabel +{ + Q_OBJECT +public: + UBDraggableLabel(QWidget *parent = 0); + ~UBDraggableLabel(); + void loadImage(QString imagePath); +signals: + +public slots: + +protected: + QString mSourcePath; + void mousePressEvent(QMouseEvent *event); + +}; + +#endif // UBDRAGGABLELABEL_H diff --git a/src/customWidgets/customWidgets.pri b/src/customWidgets/customWidgets.pri index a5609d31..321f3d45 100644 --- a/src/customWidgets/customWidgets.pri +++ b/src/customWidgets/customWidgets.pri @@ -1,5 +1,9 @@ -HEADERS += src/customWidgets/UBWidgetList.h +HEADERS += src/customWidgets/UBWidgetList.h \ + src/customWidgets/UBDraggableLabel.h -SOURCES += src/customWidgets/UBWidgetList.cpp +SOURCES += src/customWidgets/UBWidgetList.cpp \ + src/customWidgets/UBDraggableLabel.cpp + + diff --git a/src/gui/UBMediaPlayer.cpp b/src/gui/UBMediaPlayer.cpp index 357d161e..c68253b3 100644 --- a/src/gui/UBMediaPlayer.cpp +++ b/src/gui/UBMediaPlayer.cpp @@ -343,3 +343,31 @@ void UBMediaPlayer::hasVideoChanged(bool bHasVideo) // info->setVisible(!bHasVideo); m_videoWindow.setVisible(bHasVideo); } + +//************************************************************************* +UBDraggableMediaPlayer::UBDraggableMediaPlayer():UBMediaPlayer() +{ +// setAcceptDrops(true); +} + +void UBDraggableMediaPlayer::setFile(const QString &text) +{ + mSourcePath = text; + UBMediaPlayer::setFile(text); +} + +void UBDraggableMediaPlayer::mousePressEvent(QMouseEvent *event) +{ + Q_UNUSED(event); + QMimeData *mimeData = new QMimeData; + QList urls; + urls << QUrl::fromLocalFile(mSourcePath); + mimeData->setUrls(urls); + mimeData->setText(mSourcePath); + + + QDrag *drag = new QDrag(this); + drag->setMimeData(mimeData); + drag->start(); +} + diff --git a/src/gui/UBMediaPlayer.h b/src/gui/UBMediaPlayer.h index 6e563698..86534802 100644 --- a/src/gui/UBMediaPlayer.h +++ b/src/gui/UBMediaPlayer.h @@ -89,4 +89,16 @@ private: Phonon::Path m_audioOutputPath; }; +class UBDraggableMediaPlayer : public UBMediaPlayer +{ + Q_OBJECT +public: + UBDraggableMediaPlayer(); + void setFile(const QString &text); +protected: + QString mSourcePath; + void mousePressEvent(QMouseEvent *event); +}; + + #endif // UBUBMediaPlayer_H diff --git a/src/gui/UBTeacherBarWidget.cpp b/src/gui/UBTeacherBarWidget.cpp index 65c4ad91..e2336b10 100644 --- a/src/gui/UBTeacherBarWidget.cpp +++ b/src/gui/UBTeacherBarWidget.cpp @@ -15,6 +15,8 @@ #include "frameworks/UBFileSystemUtils.h" +#include "customWidgets/UBDraggableLabel.h" + #include "core/memcheck.h" UBTeacherBarWidget::UBTeacherBarWidget(QWidget *parent, const char *name):UBDockPaletteWidget(parent) @@ -583,7 +585,6 @@ void UBTeacherBarDropMediaZone::reloadMedia(QStringList pList) foreach(QString eachString, pList){ addMedia(eachString); } - } void UBTeacherBarDropMediaZone::dropEvent(QDropEvent *pEvent) @@ -722,15 +723,11 @@ void UBTeacherBarPreviewWidget::onEdit() UBTeacherBarPreviewMedia::UBTeacherBarPreviewMedia(QWidget* parent, const char* name) : QWidget(parent) { setObjectName(name); - setAcceptDrops(true); mWidget = new UBWidgetList(parent); mWidget->setEmptyText(tr("No media found")); mLayout.addWidget(mWidget); setLayout(&mLayout); - //TO TEST only -// QStringList mediaPathList; -// mediaPathList << "/home/claudio/Desktop/PIPPO.jpg"; -// loadMedia(mediaPathList); + mWidgetList.clear(); } UBTeacherBarPreviewMedia::~UBTeacherBarPreviewMedia() @@ -743,28 +740,25 @@ UBTeacherBarPreviewMedia::~UBTeacherBarPreviewMedia() } -// for test only -QString tempString; - void UBTeacherBarPreviewMedia::loadMedia(QStringList pMedias) { + foreach(QWidget* eachWidget, mWidgetList.keys()) + delete eachWidget; + mWidgetList.clear(); foreach(QString eachString, pMedias){ if(!eachString.isEmpty()){ - tempString = eachString; QString mimeType = UBFileSystemUtils::mimeTypeFromFileName(eachString); if(mimeType.contains("image")){ - QPixmap pix = QPixmap(eachString); - QLabel* label = new QLabel(); - label->setPixmap(pix); - label->setScaledContents(true); + UBDraggableLabel* label = new UBDraggableLabel(); + label->loadImage(eachString); mWidget->addWidget(label); - // mWidgetList << label; + mWidgetList[label]=eachString; } else if(mimeType.contains("video") || mimeType.contains("audio")){ - UBMediaPlayer* mediaPlayer = new UBMediaPlayer(); + UBDraggableMediaPlayer* mediaPlayer = new UBDraggableMediaPlayer(); mediaPlayer->setFile(eachString); mWidget->addWidget(mediaPlayer); - // mWidgetList << mediaPlayer; + mWidgetList[mediaPlayer] = eachString; } else{ qWarning() << "pMediaPath" << eachString; @@ -773,19 +767,3 @@ void UBTeacherBarPreviewMedia::loadMedia(QStringList pMedias) } } } - -void UBTeacherBarPreviewMedia::mousePressEvent(QMouseEvent *event) -{ - Q_UNUSED(event); - QMimeData *mimeData = new QMimeData; - QList urls; - urls << QUrl::fromLocalFile(tempString); - mimeData->setUrls(urls); - mimeData->setText(tempString); - - - QDrag *drag = new QDrag(this); - drag->setMimeData(mimeData); - drag->start(); -} - diff --git a/src/gui/UBTeacherBarWidget.h b/src/gui/UBTeacherBarWidget.h index 50377d65..a7097cbe 100644 --- a/src/gui/UBTeacherBarWidget.h +++ b/src/gui/UBTeacherBarWidget.h @@ -81,12 +81,7 @@ public: private: UBWidgetList* mWidget; QVBoxLayout mLayout; - -protected: - void mousePressEvent(QMouseEvent *event); - -public slots: - + QMapmWidgetList; }; class UBUrlWidget : public QWidget From 91621dbb9b4c9f48ba240ef3c79503c5ac30dd26 Mon Sep 17 00:00:00 2001 From: Claudio Valerio Date: Fri, 6 Jan 2012 10:57:32 +0100 Subject: [PATCH 30/84] restored good version --- src/core/UBDisplayManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/UBDisplayManager.cpp b/src/core/UBDisplayManager.cpp index c6214d15..6ecdc679 100644 --- a/src/core/UBDisplayManager.cpp +++ b/src/core/UBDisplayManager.cpp @@ -48,7 +48,7 @@ UBDisplayManager::UBDisplayManager(QObject *parent) void UBDisplayManager::initScreenIndexes() { - int screenCount = 1;//numScreens(); + int screenCount = numScreens(); mScreenIndexesRoles.clear(); From 03fef88c4fac3de08bac78be17b3a37e457789d9 Mon Sep 17 00:00:00 2001 From: shibakaneki Date: Fri, 6 Jan 2012 11:29:26 +0100 Subject: [PATCH 31/84] Backup --- src/customWidgets/UBWidgetList.cpp | 2 + src/gui/UBTeacherBarWidget.cpp | 135 ++++++++++++++++++++++++----- src/gui/UBTeacherBarWidget.h | 23 ++++- 3 files changed, 133 insertions(+), 27 deletions(-) diff --git a/src/customWidgets/UBWidgetList.cpp b/src/customWidgets/UBWidgetList.cpp index 67c157b2..b46d0770 100644 --- a/src/customWidgets/UBWidgetList.cpp +++ b/src/customWidgets/UBWidgetList.cpp @@ -12,6 +12,8 @@ UBWidgetList::UBWidgetList(QWidget* parent, eWidgetListOrientation orientation, mpContainer = new QWidget(this); mpEmptyLabel = new QLabel(this); mpEmptyLabel->setObjectName("emptyString"); + mpEmptyLabel->setWordWrap(true); + mpEmptyLabel->setAlignment(Qt::AlignCenter); if(eWidgetListOrientation_Vertical == orientation){ setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); diff --git a/src/gui/UBTeacherBarWidget.cpp b/src/gui/UBTeacherBarWidget.cpp index 65c4ad91..479e570f 100644 --- a/src/gui/UBTeacherBarWidget.cpp +++ b/src/gui/UBTeacherBarWidget.cpp @@ -278,11 +278,11 @@ void UBTeacherBarWidget::saveContent() infos.title = mpTitle->text(); // Duration if(mpDuration1->isChecked()){ - infos.Duration = 0; + infos.Duration = eDuration_Quarter; }else if(mpDuration2->isChecked()){ - infos.Duration = 1; + infos.Duration = eDuration_Half; }else{ - infos.Duration = 2; + infos.Duration = eDuration_ThreeQuarter; } // Actions for(int i=0; isetText(nextInfos.title); // Duration switch(nextInfos.Duration){ - case 0: mpDuration1->setChecked(true); + case eDuration_Quarter: mpDuration1->setChecked(true); break; - case 1: mpDuration2->setChecked(true); + case eDuration_Half: mpDuration2->setChecked(true); break; - case 2: mpDuration3->setChecked(true); + case eDuration_ThreeQuarter: mpDuration3->setChecked(true); break; default: mpDuration1->setChecked(true); break; @@ -351,8 +351,18 @@ void UBTeacherBarWidget::loadContent() } if(!isEmpty()){ + // Update the fields of the preview widget + mpPreview->setTitle(mpTitle->text()); mpPreview->mediaViewer()->loadMedia(nextInfos.medias); mpStackWidget->setCurrentWidget(mpPreview); + if(mpDuration1->isChecked()){ + mpPreview->setDuration(eDuration_Quarter); + }else if(mpDuration2->isChecked()){ + mpPreview->setDuration(eDuration_Half); + }else{ + mpPreview->setDuration(eDuration_ThreeQuarter); + } + } } @@ -675,22 +685,60 @@ void UBUrlWidget::setUrl(const QString &url) // ------------------------------------------------------------------------------------ UBTeacherBarPreviewWidget::UBTeacherBarPreviewWidget(QWidget *parent, const char *name):QWidget(parent) - , mpLayout(NULL) , mpEditButton(NULL) - , mpEditLayout(NULL) + , mpTitle(NULL) + , mpDuration(NULL) + , mpActionsLabel(NULL) + , mpMediaLabel(NULL) + , mpCommentsLabel(NULL) { setObjectName(name); - mpLayout = new QVBoxLayout(this); - setLayout(mpLayout); + setLayout(&mLayout); + + setAttribute(Qt::WA_StyledBackground, true); + setStyleSheet(UBApplication::globalStyleSheet()); + + // Build the Preview widget + // Title + duration + mpTitle = new QLabel(this); + mpTitle->setObjectName("UBTeacherBarPreviewTitle"); + mpTitle->setWordWrap(true); + mpTitle->setAlignment(Qt::AlignCenter); + mpDuration = new QLabel(this); + mTitleDurationLayout.addWidget(mpTitle, 0); + mTitleDurationLayout.addWidget(mpDuration, 1); + mLayout.addLayout(&mTitleDurationLayout, 0); + // Actions + mpActionsLabel = new QLabel(tr("Actions"), this); + mActionLabelLayout.addWidget(mpActionsLabel, 0); + mActionLabelLayout.addStretch(1); + mLayout.addLayout(&mActionLabelLayout); + + // Media + mpMediaLabel = new QLabel(tr("Medias"), this); + mMediaLabelLayout.addWidget(mpMediaLabel, 0); + mMediaLabelLayout.addStretch(1); + mLayout.addLayout(&mMediaLabelLayout); + mLayout.addWidget(&mMediaViewer, 0); + + // Temporary stretch + mLayout.addStretch(1); + + // Comments + mpCommentsLabel = new QLabel(tr("Comments"), this); + mCommentsLabelLayout.addWidget(mpCommentsLabel, 0); + mCommentsLabelLayout.addStretch(1); + mLayout.addLayout(&mCommentsLabelLayout); + + // Edit button mpEditButton = new QPushButton(tr("Edit infos"), this); - mpEditLayout = new QVBoxLayout(); - mpEditLayout->addStretch(1); - mpEditLayout->addWidget(mpEditButton, 0); - mpEditLayout->addStretch(1); - mpEditLayout->addWidget(&mMediaViewer); - mpLayout->addLayout(mpEditLayout); + mpEditButton->setObjectName("DockPaletteWidgetButton"); + mEditLayout.addStretch(1); + mEditLayout.addWidget(mpEditButton, 0); + mEditLayout.addStretch(1); + mLayout.addLayout(&mEditLayout, 0); connect(mpEditButton, SIGNAL(clicked()), this, SLOT(onEdit())); @@ -698,18 +746,30 @@ UBTeacherBarPreviewWidget::UBTeacherBarPreviewWidget(QWidget *parent, const char UBTeacherBarPreviewWidget::~UBTeacherBarPreviewWidget() { + if(NULL != mpTitle){ + delete mpTitle; + mpTitle = NULL; + } + if(NULL != mpDuration){ + delete mpDuration; + mpDuration = NULL; + } + if(NULL != mpActionsLabel){ + delete mpActionsLabel; + mpActionsLabel = NULL; + } + if(NULL != mpMediaLabel){ + delete mpMediaLabel; + mpMediaLabel = NULL; + } + if(NULL != mpCommentsLabel){ + delete mpCommentsLabel; + mpCommentsLabel = NULL; + } if(NULL != mpEditButton){ delete mpEditButton; mpEditButton = NULL; } - if(NULL != mpEditLayout){ - delete mpEditLayout; - mpEditLayout = NULL; - } - if(NULL != mpLayout){ - delete mpLayout; - mpLayout = NULL; - } } void UBTeacherBarPreviewWidget::onEdit() @@ -717,6 +777,33 @@ void UBTeacherBarPreviewWidget::onEdit() emit showEditMode(); } +void UBTeacherBarPreviewWidget::setTitle(const QString &title) +{ + if(NULL != mpTitle){ + mpTitle->setText(title); + } +} + +void UBTeacherBarPreviewWidget::setDuration(eDuration duration) +{ + if(NULL != mpDuration){ + QPixmap p; + switch(duration){ + case eDuration_Quarter: + p = QPixmap(":images/duration1.png"); + break; + case eDuration_Half: + p = QPixmap(":images/duration2.png"); + break; + case eDuration_ThreeQuarter: + p = QPixmap(":images/duration3.png"); + break; + default: + break; + } + mpDuration->setPixmap(p.scaledToHeight(16, Qt::SmoothTransformation)); + } +} // ------------------------------------------------------------------------------------ UBTeacherBarPreviewMedia::UBTeacherBarPreviewMedia(QWidget* parent, const char* name) : QWidget(parent) diff --git a/src/gui/UBTeacherBarWidget.h b/src/gui/UBTeacherBarWidget.h index 50377d65..a76de6a7 100644 --- a/src/gui/UBTeacherBarWidget.h +++ b/src/gui/UBTeacherBarWidget.h @@ -21,6 +21,12 @@ class UBMediaPlayer; #define LABEL_MINWIDHT 80 +typedef enum{ + eDuration_Quarter, + eDuration_Half, + eDuration_ThreeQuarter +}eDuration; + class UBTeacherStudentAction : public QWidget { Q_OBJECT @@ -111,6 +117,8 @@ public: UBTeacherBarPreviewWidget(QWidget* parent=0, const char* name="UBTeacherBarPreviewWidget"); ~UBTeacherBarPreviewWidget(); UBTeacherBarPreviewMedia* mediaViewer() {return &mMediaViewer;} + void setTitle(const QString& title); + void setDuration(eDuration duration); signals: void showEditMode(); @@ -119,10 +127,19 @@ private slots: void onEdit(); private: - QVBoxLayout* mpLayout; - QPushButton* mpEditButton; - QVBoxLayout* mpEditLayout; + QVBoxLayout mLayout; + QHBoxLayout mEditLayout; + QHBoxLayout mTitleDurationLayout; + QHBoxLayout mActionLabelLayout; + QHBoxLayout mMediaLabelLayout; + QHBoxLayout mCommentsLabelLayout; UBTeacherBarPreviewMedia mMediaViewer; + QPushButton* mpEditButton; + QLabel* mpTitle; + QLabel* mpDuration; + QLabel* mpActionsLabel; + QLabel* mpMediaLabel; + QLabel* mpCommentsLabel; }; class UBTeacherBarWidget : public UBDockPaletteWidget From 1eba2bb0f48ad29a5515fa04e5dce40e1ca923b5 Mon Sep 17 00:00:00 2001 From: Claudio Valerio Date: Fri, 6 Jan 2012 11:32:50 +0100 Subject: [PATCH 32/84] merged --- src/gui/UBTeacherBarWidget.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/gui/UBTeacherBarWidget.cpp b/src/gui/UBTeacherBarWidget.cpp index 52985f84..b5e788da 100644 --- a/src/gui/UBTeacherBarWidget.cpp +++ b/src/gui/UBTeacherBarWidget.cpp @@ -356,6 +356,7 @@ void UBTeacherBarWidget::loadContent() // Update the fields of the preview widget mpPreview->setTitle(mpTitle->text()); mpPreview->mediaViewer()->loadMedia(nextInfos.medias); + mpStackWidget->setCurrentWidget(mpPreview); if(mpDuration1->isChecked()){ mpPreview->setDuration(eDuration_Quarter); @@ -366,6 +367,9 @@ void UBTeacherBarWidget::loadContent() } } + // this is always done becasue it allows to clean the media on + // changing the page + mpPreview->mediaViewer()->loadMedia(nextInfos.medias); } bool UBTeacherBarWidget::isEmpty() @@ -829,8 +833,6 @@ UBTeacherBarPreviewMedia::~UBTeacherBarPreviewMedia() void UBTeacherBarPreviewMedia::loadMedia(QStringList pMedias) { - foreach(QWidget* eachWidget, mWidgetList.keys()) - delete eachWidget; mWidgetList.clear(); foreach(QString eachString, pMedias){ if(!eachString.isEmpty()){ From fb2f09deede96b77d9f54ce04274934cac78de36 Mon Sep 17 00:00:00 2001 From: shibakaneki Date: Fri, 6 Jan 2012 12:49:58 +0100 Subject: [PATCH 33/84] updated stylesheet --- resources/style.qss | 21 +++++++++++++++++++++ src/gui/UBTeacherBarWidget.cpp | 20 +++++++++++++++++++- src/gui/UBTeacherBarWidget.h | 3 +++ 3 files changed, 43 insertions(+), 1 deletion(-) diff --git a/resources/style.qss b/resources/style.qss index 8681fb80..f631984c 100644 --- a/resources/style.qss +++ b/resources/style.qss @@ -12,6 +12,27 @@ QWidget#UBTeacherBarDropMediaZone border: 2px solid #999999; } +QWidget#UBTeacherBarPreviewWidget +{ + background: #FFFFFF; + border-radius: 10px; + border: 2px solid #999999; +} + +QLabel#UBTeacherBarPreviewTitle +{ + color: #555555; + font-size : 18px; + font-weight:bold; +} + +QLabel#UBTeacherBarPreviewSubtitle +{ + color: #555555; + font-size : 14px; + font-weight:bold; +} + QWidget#UBLibWebView { background: #EEEEEE; diff --git a/src/gui/UBTeacherBarWidget.cpp b/src/gui/UBTeacherBarWidget.cpp index 52985f84..112a256b 100644 --- a/src/gui/UBTeacherBarWidget.cpp +++ b/src/gui/UBTeacherBarWidget.cpp @@ -364,7 +364,7 @@ void UBTeacherBarWidget::loadContent() }else{ mpPreview->setDuration(eDuration_ThreeQuarter); } - + mpPreview->setComments(mpComments->document()->toPlainText()); } } @@ -692,6 +692,7 @@ UBTeacherBarPreviewWidget::UBTeacherBarPreviewWidget(QWidget *parent, const char , mpActionsLabel(NULL) , mpMediaLabel(NULL) , mpCommentsLabel(NULL) + , mpComments(NULL) { setObjectName(name); @@ -713,12 +714,14 @@ UBTeacherBarPreviewWidget::UBTeacherBarPreviewWidget(QWidget *parent, const char // Actions mpActionsLabel = new QLabel(tr("Actions"), this); + mpActionsLabel->setObjectName("UBTeacherBarPreviewSubtitle"); mActionLabelLayout.addWidget(mpActionsLabel, 0); mActionLabelLayout.addStretch(1); mLayout.addLayout(&mActionLabelLayout); // Media mpMediaLabel = new QLabel(tr("Medias"), this); + mpMediaLabel->setObjectName("UBTeacherBarPreviewSubtitle"); mMediaLabelLayout.addWidget(mpMediaLabel, 0); mMediaLabelLayout.addStretch(1); mLayout.addLayout(&mMediaLabelLayout); @@ -729,9 +732,13 @@ UBTeacherBarPreviewWidget::UBTeacherBarPreviewWidget(QWidget *parent, const char // Comments mpCommentsLabel = new QLabel(tr("Comments"), this); + mpCommentsLabel->setObjectName("UBTeacherBarPreviewSubtitle"); mCommentsLabelLayout.addWidget(mpCommentsLabel, 0); mCommentsLabelLayout.addStretch(1); mLayout.addLayout(&mCommentsLabelLayout); + mpComments = new QLabel(this); + mpComments->setWordWrap(true); + mLayout.addWidget(mpComments); // Edit button mpEditButton = new QPushButton(tr("Edit infos"), this); @@ -747,6 +754,10 @@ UBTeacherBarPreviewWidget::UBTeacherBarPreviewWidget(QWidget *parent, const char UBTeacherBarPreviewWidget::~UBTeacherBarPreviewWidget() { + if(NULL != mpComments){ + delete mpComments; + mpComments = NULL; + } if(NULL != mpTitle){ delete mpTitle; mpTitle = NULL; @@ -806,6 +817,13 @@ void UBTeacherBarPreviewWidget::setDuration(eDuration duration) } } +void UBTeacherBarPreviewWidget::setComments(const QString &comments) +{ + if(NULL != mpComments){ + mpComments->setText(comments); + } +} + // ------------------------------------------------------------------------------------ UBTeacherBarPreviewMedia::UBTeacherBarPreviewMedia(QWidget* parent, const char* name) : QWidget(parent) { diff --git a/src/gui/UBTeacherBarWidget.h b/src/gui/UBTeacherBarWidget.h index 5ee8f336..8937bf24 100644 --- a/src/gui/UBTeacherBarWidget.h +++ b/src/gui/UBTeacherBarWidget.h @@ -114,6 +114,7 @@ public: UBTeacherBarPreviewMedia* mediaViewer() {return &mMediaViewer;} void setTitle(const QString& title); void setDuration(eDuration duration); + void setComments(const QString& comments); signals: void showEditMode(); @@ -129,12 +130,14 @@ private: QHBoxLayout mMediaLabelLayout; QHBoxLayout mCommentsLabelLayout; UBTeacherBarPreviewMedia mMediaViewer; + QPushButton* mpEditButton; QLabel* mpTitle; QLabel* mpDuration; QLabel* mpActionsLabel; QLabel* mpMediaLabel; QLabel* mpCommentsLabel; + QLabel* mpComments; }; class UBTeacherBarWidget : public UBDockPaletteWidget From e93410f1370619d20f6794c129e3fa0e77a0a706 Mon Sep 17 00:00:00 2001 From: Claudio Valerio Date: Fri, 6 Jan 2012 12:51:27 +0100 Subject: [PATCH 34/84] resolved issue --- src/gui/UBTeacherBarWidget.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/gui/UBTeacherBarWidget.cpp b/src/gui/UBTeacherBarWidget.cpp index 84eed6b0..f4e14883 100644 --- a/src/gui/UBTeacherBarWidget.cpp +++ b/src/gui/UBTeacherBarWidget.cpp @@ -366,10 +366,10 @@ void UBTeacherBarWidget::loadContent() mpPreview->setDuration(eDuration_ThreeQuarter); } mpPreview->setComments(mpComments->document()->toPlainText()); + mpPreview->mediaViewer()->cleanMedia(); + mpPreview->mediaViewer()->loadMedia(nextInfos.medias); } - // this is always done becasue it allows to clean the media on - // changing the page - mpPreview->mediaViewer()->loadMedia(nextInfos.medias); + } bool UBTeacherBarWidget::isEmpty() @@ -848,10 +848,18 @@ UBTeacherBarPreviewMedia::~UBTeacherBarPreviewMedia() } +void UBTeacherBarPreviewMedia::cleanMedia() +{ + foreach(QWidget* eachWidget, mWidgetList.keys()){ + delete eachWidget; + eachWidget = NULL; + } + mWidgetList.clear(); +} + void UBTeacherBarPreviewMedia::loadMedia(QStringList pMedias) { - mWidgetList.clear(); foreach(QString eachString, pMedias){ if(!eachString.isEmpty()){ QString mimeType = UBFileSystemUtils::mimeTypeFromFileName(eachString); From b5dc5d1d46dcc601d97838d1d7d5dd1003a81bf5 Mon Sep 17 00:00:00 2001 From: Claudio Valerio Date: Fri, 6 Jan 2012 12:51:50 +0100 Subject: [PATCH 35/84] fixed duplicated widgets --- src/customWidgets/UBWidgetList.cpp | 2 -- src/gui/UBTeacherBarWidget.h | 1 + 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/customWidgets/UBWidgetList.cpp b/src/customWidgets/UBWidgetList.cpp index b46d0770..d73ded86 100644 --- a/src/customWidgets/UBWidgetList.cpp +++ b/src/customWidgets/UBWidgetList.cpp @@ -76,13 +76,11 @@ int UBWidgetList::scaleWidgets(QSize pSize) { int result = 0; foreach(QWidget* eachWidget, mWidgetInfo.keys()){ - qDebug() << __FUNCTION__ << "eachWidget : " << eachWidget; qreal scaleFactor = 0; int newWidgetWidth = pSize.width(); int newWidgetHeight = pSize.height(); if(eWidgetListOrientation_Vertical == mOrientation){ scaleFactor = (float)mWidgetInfo[eachWidget].width() / (float)pSize.width(); - qDebug() << __FUNCTION__ << "scale factor: " << scaleFactor; newWidgetHeight = mWidgetInfo[eachWidget].height()/scaleFactor; result += newWidgetHeight; } diff --git a/src/gui/UBTeacherBarWidget.h b/src/gui/UBTeacherBarWidget.h index 8937bf24..4195a21a 100644 --- a/src/gui/UBTeacherBarWidget.h +++ b/src/gui/UBTeacherBarWidget.h @@ -83,6 +83,7 @@ public: UBTeacherBarPreviewMedia(QWidget* parent=0, const char* name="UBTeacherBarPreviewMedia"); ~UBTeacherBarPreviewMedia(); void loadMedia(QStringList pMedias); + void cleanMedia(); private: UBWidgetList* mWidget; From 12a77f0ab923ee216435ac6f95366be3232142b1 Mon Sep 17 00:00:00 2001 From: Claudio Valerio Date: Fri, 6 Jan 2012 13:01:41 +0100 Subject: [PATCH 36/84] added method to load widgets --- src/gui/UBTeacherBarWidget.cpp | 8 ++++++++ src/gui/UBTeacherBarWidget.h | 1 + 2 files changed, 9 insertions(+) diff --git a/src/gui/UBTeacherBarWidget.cpp b/src/gui/UBTeacherBarWidget.cpp index f4e14883..670dde8d 100644 --- a/src/gui/UBTeacherBarWidget.cpp +++ b/src/gui/UBTeacherBarWidget.cpp @@ -857,6 +857,14 @@ void UBTeacherBarPreviewMedia::cleanMedia() mWidgetList.clear(); } +void UBTeacherBarPreviewMedia::loadWidgets(QList pWidgetsList) +{ + foreach(QWidget*eachWidget, pWidgetsList){ + mWidget->addWidget(eachWidget); + mWidgetList[eachWidget]="DRAG UNAVAILABLE"; + } +} + void UBTeacherBarPreviewMedia::loadMedia(QStringList pMedias) { diff --git a/src/gui/UBTeacherBarWidget.h b/src/gui/UBTeacherBarWidget.h index 4195a21a..862182a9 100644 --- a/src/gui/UBTeacherBarWidget.h +++ b/src/gui/UBTeacherBarWidget.h @@ -83,6 +83,7 @@ public: UBTeacherBarPreviewMedia(QWidget* parent=0, const char* name="UBTeacherBarPreviewMedia"); ~UBTeacherBarPreviewMedia(); void loadMedia(QStringList pMedias); + void loadWidgets(QList pWidgetList); void cleanMedia(); private: From e584c2cfd09f1cb91f6f4473c1cea1572617b9a1 Mon Sep 17 00:00:00 2001 From: shibakaneki Date: Fri, 6 Jan 2012 13:02:58 +0100 Subject: [PATCH 37/84] backup --- src/gui/UBTeacherBarWidget.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/gui/UBTeacherBarWidget.cpp b/src/gui/UBTeacherBarWidget.cpp index f4e14883..4c19586c 100644 --- a/src/gui/UBTeacherBarWidget.cpp +++ b/src/gui/UBTeacherBarWidget.cpp @@ -721,28 +721,30 @@ UBTeacherBarPreviewWidget::UBTeacherBarPreviewWidget(QWidget *parent, const char mpActionsLabel->setObjectName("UBTeacherBarPreviewSubtitle"); mActionLabelLayout.addWidget(mpActionsLabel, 0); mActionLabelLayout.addStretch(1); - mLayout.addLayout(&mActionLabelLayout); + mpActionsLabel->setVisible(false); + //mLayout.addLayout(&mActionLabelLayout); // Media mpMediaLabel = new QLabel(tr("Medias"), this); mpMediaLabel->setObjectName("UBTeacherBarPreviewSubtitle"); mMediaLabelLayout.addWidget(mpMediaLabel, 0); mMediaLabelLayout.addStretch(1); - mLayout.addLayout(&mMediaLabelLayout); - mLayout.addWidget(&mMediaViewer, 0); + mpMediaLabel->setVisible(false); + //mLayout.addLayout(&mMediaLabelLayout, 0); + mLayout.addWidget(&mMediaViewer, 1); - // Temporary stretch - mLayout.addStretch(1); // Comments mpCommentsLabel = new QLabel(tr("Comments"), this); mpCommentsLabel->setObjectName("UBTeacherBarPreviewSubtitle"); mCommentsLabelLayout.addWidget(mpCommentsLabel, 0); mCommentsLabelLayout.addStretch(1); - mLayout.addLayout(&mCommentsLabelLayout); + //mLayout.addLayout(&mCommentsLabelLayout); mpComments = new QLabel(this); mpComments->setWordWrap(true); - mLayout.addWidget(mpComments); + mpCommentsLabel->setVisible(false); + mpComments->setVisible(false); + //mLayout.addWidget(mpComments); // Edit button mpEditButton = new QPushButton(tr("Edit infos"), this); From ef2e24c0d80dff8efd85146f5b3920032605ffc7 Mon Sep 17 00:00:00 2001 From: Claudio Valerio Date: Fri, 6 Jan 2012 13:23:48 +0100 Subject: [PATCH 38/84] fixed widget to load on page change regarding the stored information --- src/gui/UBTeacherBarWidget.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/gui/UBTeacherBarWidget.cpp b/src/gui/UBTeacherBarWidget.cpp index 670dde8d..43df4246 100644 --- a/src/gui/UBTeacherBarWidget.cpp +++ b/src/gui/UBTeacherBarWidget.cpp @@ -352,6 +352,8 @@ void UBTeacherBarWidget::loadContent() mpComments->document()->setPlainText(nextInfos.comments); } + mpPreview->mediaViewer()->cleanMedia(); + if(!isEmpty()){ // Update the fields of the preview widget mpPreview->setTitle(mpTitle->text()); @@ -366,9 +368,12 @@ void UBTeacherBarWidget::loadContent() mpPreview->setDuration(eDuration_ThreeQuarter); } mpPreview->setComments(mpComments->document()->toPlainText()); - mpPreview->mediaViewer()->cleanMedia(); mpPreview->mediaViewer()->loadMedia(nextInfos.medias); } + else{ + mpStackWidget->setCurrentWidget(mpContainer); + } + } From abdea843ff81cb6efa0f127a999b3f68d3434ffa Mon Sep 17 00:00:00 2001 From: shibakaneki Date: Fri, 6 Jan 2012 13:56:04 +0100 Subject: [PATCH 39/84] backup of the teacher bar preview --- src/gui/UBTeacherBarWidget.cpp | 99 ++++++++++++++++++++++++++++++++-- src/gui/UBTeacherBarWidget.h | 8 +++ 2 files changed, 102 insertions(+), 5 deletions(-) diff --git a/src/gui/UBTeacherBarWidget.cpp b/src/gui/UBTeacherBarWidget.cpp index f82770b0..0275b1ac 100644 --- a/src/gui/UBTeacherBarWidget.cpp +++ b/src/gui/UBTeacherBarWidget.cpp @@ -365,9 +365,33 @@ void UBTeacherBarWidget::loadContent() }else{ mpPreview->setDuration(eDuration_ThreeQuarter); } - mpPreview->setComments(mpComments->document()->toPlainText()); - mpPreview->mediaViewer()->cleanMedia(); + + mpPreview->clean(); + + // Add the actions + if(!mActionList.empty()){ + QStringList actions; + foreach(UBTeacherStudentAction* action, mActionList){ + QString desc = QString("%0;%1").arg(action->comboValue()).arg(action->text()); + actions << desc; + } + mpPreview->setActions(actions); + } + + // Add the media mpPreview->mediaViewer()->loadMedia(nextInfos.medias); + + // Add the links + if(!mUrlList.empty()){ + QStringList links; + foreach(UBUrlWidget* url, mUrlList){ + links << url->url(); + } + mpPreview->setLinks(links); + } + + // Add the comments + mpPreview->setComments(mpComments->document()->toPlainText()); } } @@ -697,6 +721,7 @@ UBTeacherBarPreviewWidget::UBTeacherBarPreviewWidget(QWidget *parent, const char , mpMediaLabel(NULL) , mpCommentsLabel(NULL) , mpComments(NULL) + , mpLinksLabel(NULL) { setObjectName(name); @@ -733,6 +758,8 @@ UBTeacherBarPreviewWidget::UBTeacherBarPreviewWidget(QWidget *parent, const char //mLayout.addLayout(&mMediaLabelLayout, 0); mLayout.addWidget(&mMediaViewer, 1); + mpLinksLabel = new QLabel(tr("Links"), this); + mpLinksLabel->setObjectName("UBTeacherBarPreviewSubtitle"); // Comments mpCommentsLabel = new QLabel(tr("Comments"), this); @@ -760,6 +787,10 @@ UBTeacherBarPreviewWidget::UBTeacherBarPreviewWidget(QWidget *parent, const char UBTeacherBarPreviewWidget::~UBTeacherBarPreviewWidget() { + if(NULL != mpLinksLabel){ + delete mpLinksLabel; + mpLinksLabel = NULL; + } if(NULL != mpComments){ delete mpComments; mpComments = NULL; @@ -825,8 +856,64 @@ void UBTeacherBarPreviewWidget::setDuration(eDuration duration) void UBTeacherBarPreviewWidget::setComments(const QString &comments) { - if(NULL != mpComments){ + if("" != comments){ + mWidgets.clear(); mpComments->setText(comments); + mpComments->setVisible(true); + mpCommentsLabel->setVisible(true); + mWidgets << mpCommentsLabel; + mWidgets << mpComments; + mMediaViewer.loadWidgets(mWidgets); + } +} + +void UBTeacherBarPreviewWidget::clean() +{ + mMediaViewer.cleanMedia(); + hideElements(); +} + +void UBTeacherBarPreviewWidget::hideElements() +{ + mpActionsLabel->setVisible(false); + mpMediaLabel->setVisible(false); + mpCommentsLabel->setVisible(false); + mpComments->setVisible(false); + mpLinksLabel->setVisible(false); +} + +void UBTeacherBarPreviewWidget::setActions(QStringList actions) +{ + if(!actions.empty()){ + mWidgets.clear(); + mpActionsLabel->setVisible(true); + mWidgets << mpActionsLabel; + foreach(QString action, actions){ + QStringList desc = action.split(';'); + if(2 <= desc.size()){ + QString owner = desc.at(0); + QString act = desc.at(1); + + // TODO : Create the action widget here and add it to mWidgets + + } + } + mMediaViewer.loadWidgets(mWidgets); + } +} + +void UBTeacherBarPreviewWidget::setLinks(QStringList links) +{ + if(!links.empty()){ + mWidgets.clear(); + mpLinksLabel->setVisible(true); + mWidgets << mpLinksLabel; + foreach(QString link, links){ + mpTmpLink = new QLabel(link, this); + mpTmpLink->setOpenExternalLinks(true); + mWidgets << mpTmpLink; + } + mMediaViewer.loadWidgets(mWidgets); } } @@ -853,8 +940,10 @@ UBTeacherBarPreviewMedia::~UBTeacherBarPreviewMedia() void UBTeacherBarPreviewMedia::cleanMedia() { foreach(QWidget* eachWidget, mWidgetList.keys()){ - delete eachWidget; - eachWidget = NULL; + if(QString(eachWidget->metaObject()->className()).contains("UBDraggable")){ + delete eachWidget; + eachWidget = NULL; + } } mWidgetList.clear(); } diff --git a/src/gui/UBTeacherBarWidget.h b/src/gui/UBTeacherBarWidget.h index 862182a9..5ebe6558 100644 --- a/src/gui/UBTeacherBarWidget.h +++ b/src/gui/UBTeacherBarWidget.h @@ -117,6 +117,9 @@ public: void setTitle(const QString& title); void setDuration(eDuration duration); void setComments(const QString& comments); + void setActions(QStringList actions); + void setLinks(QStringList links); + void clean(); signals: void showEditMode(); @@ -125,6 +128,8 @@ private slots: void onEdit(); private: + void hideElements(); + QVBoxLayout mLayout; QHBoxLayout mEditLayout; QHBoxLayout mTitleDurationLayout; @@ -132,6 +137,7 @@ private: QHBoxLayout mMediaLabelLayout; QHBoxLayout mCommentsLabelLayout; UBTeacherBarPreviewMedia mMediaViewer; + QList mWidgets; QPushButton* mpEditButton; QLabel* mpTitle; @@ -140,6 +146,8 @@ private: QLabel* mpMediaLabel; QLabel* mpCommentsLabel; QLabel* mpComments; + QLabel* mpLinksLabel; + QLabel* mpTmpLink; }; class UBTeacherBarWidget : public UBDockPaletteWidget From c7c931b92aa7c5b7769405f885ce96b03b4a7126 Mon Sep 17 00:00:00 2001 From: shibakaneki Date: Fri, 6 Jan 2012 14:36:56 +0100 Subject: [PATCH 40/84] added the links in the teacherbar preview --- src/gui/UBTeacherBarWidget.cpp | 47 ++++++++++------------------------ src/gui/UBTeacherBarWidget.h | 3 --- 2 files changed, 14 insertions(+), 36 deletions(-) diff --git a/src/gui/UBTeacherBarWidget.cpp b/src/gui/UBTeacherBarWidget.cpp index e1022004..cf155423 100644 --- a/src/gui/UBTeacherBarWidget.cpp +++ b/src/gui/UBTeacherBarWidget.cpp @@ -746,37 +746,9 @@ UBTeacherBarPreviewWidget::UBTeacherBarPreviewWidget(QWidget *parent, const char mTitleDurationLayout.addWidget(mpDuration, 1); mLayout.addLayout(&mTitleDurationLayout, 0); - // Actions - mpActionsLabel = new QLabel(tr("Actions"), this); - mpActionsLabel->setObjectName("UBTeacherBarPreviewSubtitle"); - mActionLabelLayout.addWidget(mpActionsLabel, 0); - mActionLabelLayout.addStretch(1); - mpActionsLabel->setVisible(false); - //mLayout.addLayout(&mActionLabelLayout); - - // Media - mpMediaLabel = new QLabel(tr("Medias"), this); - mpMediaLabel->setObjectName("UBTeacherBarPreviewSubtitle"); - mMediaLabelLayout.addWidget(mpMediaLabel, 0); - mMediaLabelLayout.addStretch(1); - mpMediaLabel->setVisible(false); - //mLayout.addLayout(&mMediaLabelLayout, 0); mLayout.addWidget(&mMediaViewer, 1); - mpLinksLabel = new QLabel(tr("Links"), this); - mpLinksLabel->setObjectName("UBTeacherBarPreviewSubtitle"); - - // Comments - mpCommentsLabel = new QLabel(tr("Comments"), this); - mpCommentsLabel->setObjectName("UBTeacherBarPreviewSubtitle"); - mCommentsLabelLayout.addWidget(mpCommentsLabel, 0); - mCommentsLabelLayout.addStretch(1); - //mLayout.addLayout(&mCommentsLabelLayout); - mpComments = new QLabel(this); - mpComments->setWordWrap(true); - mpCommentsLabel->setVisible(false); - mpComments->setVisible(false); - //mLayout.addWidget(mpComments); + hideElements(); // Edit button mpEditButton = new QPushButton(tr("Edit infos"), this); @@ -880,6 +852,17 @@ void UBTeacherBarPreviewWidget::clean() void UBTeacherBarPreviewWidget::hideElements() { + mpActionsLabel = new QLabel(tr("Actions"), this); + mpActionsLabel->setObjectName("UBTeacherBarPreviewSubtitle"); + mpMediaLabel = new QLabel(tr("Media"), this); + mpMediaLabel->setObjectName("UBTeacherBarPreviewSubtitle"); + mpCommentsLabel = new QLabel(tr("Comments"), this); + mpCommentsLabel->setObjectName("UBTeacherBarPreviewSubtitle"); + mpComments = new QLabel(this); + mpComments->setWordWrap(true); + mpLinksLabel = new QLabel(tr("Links"), this); + mpLinksLabel->setObjectName("UBTeacherBarPreviewSubtitle"); + mpActionsLabel->setVisible(false); mpMediaLabel->setVisible(false); mpCommentsLabel->setVisible(false); @@ -945,10 +928,8 @@ UBTeacherBarPreviewMedia::~UBTeacherBarPreviewMedia() void UBTeacherBarPreviewMedia::cleanMedia() { foreach(QWidget* eachWidget, mWidgetList.keys()){ - if(QString(eachWidget->metaObject()->className()).contains("UBDraggable")){ - delete eachWidget; - eachWidget = NULL; - } + delete eachWidget; + eachWidget = NULL; } mWidgetList.clear(); } diff --git a/src/gui/UBTeacherBarWidget.h b/src/gui/UBTeacherBarWidget.h index 5ebe6558..126af37d 100644 --- a/src/gui/UBTeacherBarWidget.h +++ b/src/gui/UBTeacherBarWidget.h @@ -133,9 +133,6 @@ private: QVBoxLayout mLayout; QHBoxLayout mEditLayout; QHBoxLayout mTitleDurationLayout; - QHBoxLayout mActionLabelLayout; - QHBoxLayout mMediaLabelLayout; - QHBoxLayout mCommentsLabelLayout; UBTeacherBarPreviewMedia mMediaViewer; QList mWidgets; From e114d8adf0163a4f33db8963136ef45e90600250 Mon Sep 17 00:00:00 2001 From: shibakaneki Date: Fri, 6 Jan 2012 14:58:04 +0100 Subject: [PATCH 41/84] added the action preview in the teacher bar --- src/gui/UBTeacherBarWidget.cpp | 61 ++++++++++++++++++++++++++++++++-- src/gui/UBTeacherBarWidget.h | 22 ++++++++++++ 2 files changed, 80 insertions(+), 3 deletions(-) diff --git a/src/gui/UBTeacherBarWidget.cpp b/src/gui/UBTeacherBarWidget.cpp index cf155423..f20095d9 100644 --- a/src/gui/UBTeacherBarWidget.cpp +++ b/src/gui/UBTeacherBarWidget.cpp @@ -881,9 +881,10 @@ void UBTeacherBarPreviewWidget::setActions(QStringList actions) if(2 <= desc.size()){ QString owner = desc.at(0); QString act = desc.at(1); - - // TODO : Create the action widget here and add it to mWidgets - + mpTmpAction = new UBActionPreview(this); + mpTmpAction->setOwner(owner); + mpTmpAction->setContent(act); + mWidgets << mpTmpAction; } } mMediaViewer.loadWidgets(mWidgets); @@ -967,3 +968,57 @@ void UBTeacherBarPreviewMedia::loadMedia(QStringList pMedias) } } } + +// ----------------------------------------------------------------------------------------------- +UBActionPreview::UBActionPreview(QWidget *parent, const char *name):QWidget(parent) + , mpOwner(NULL) + , mpContent(NULL) +{ + setObjectName(name); + setLayout(&mLayout); + mpOwner = new QLabel(this); + mpOwner->setObjectName("UBActionPreviewOwner"); + mOwnerLayout.addWidget(mpOwner, 0); + mOwnerLayout.addStretch(1); + mLayout.addLayout(&mOwnerLayout); + mpContent = new QLabel(this); + mpContent->setObjectName("UBActionPreviewContent"); + mpContent->setWordWrap(true); + mLayout.addWidget(mpContent); +} + +UBActionPreview::~UBActionPreview() +{ + if(NULL != mpOwner){ + delete mpOwner; + mpOwner = NULL; + } + if(NULL != mpContent){ + delete mpContent; + mpContent = NULL; + } +} + +void UBActionPreview::setOwner(const QString &owner) +{ + if(NULL != mpOwner && NULL != mpContent){ + switch(owner.toInt()){ + case eActionOwner_Teacher: + mpOwner->setText(tr("Teacher")); + mpContent->setStyleSheet("background:lightblue;"); + break; + + case eActionOwner_Student: + mpOwner->setText(tr("Student")); + mpContent->setStyleSheet("background:lightgreen;"); + break; + } + } +} + +void UBActionPreview::setContent(const QString &content) +{ + if(NULL != mpContent){ + mpContent->setText(content); + } +} diff --git a/src/gui/UBTeacherBarWidget.h b/src/gui/UBTeacherBarWidget.h index 126af37d..3e53f97d 100644 --- a/src/gui/UBTeacherBarWidget.h +++ b/src/gui/UBTeacherBarWidget.h @@ -27,6 +27,11 @@ typedef enum{ eDuration_ThreeQuarter }eDuration; +typedef enum{ + eActionOwner_Teacher, + eActionOwner_Student +}eActionOwner; + class UBTeacherStudentAction : public QWidget { Q_OBJECT @@ -107,6 +112,22 @@ private: QLineEdit* mpUrl; }; +class UBActionPreview : public QWidget +{ +public: + UBActionPreview(QWidget* parent=0, const char* name="UBActionPreview"); + ~UBActionPreview(); + void setOwner(const QString& owner); + void setContent(const QString& content); + +private: + QLabel* mpOwner; + QLabel* mpContent; + + QVBoxLayout mLayout; + QHBoxLayout mOwnerLayout; +}; + class UBTeacherBarPreviewWidget : public QWidget { Q_OBJECT @@ -145,6 +166,7 @@ private: QLabel* mpComments; QLabel* mpLinksLabel; QLabel* mpTmpLink; + UBActionPreview* mpTmpAction; }; class UBTeacherBarWidget : public UBDockPaletteWidget From 92abcddbbe6f7f945d6213cf4411f9f35c051afe Mon Sep 17 00:00:00 2001 From: Claudio Valerio Date: Fri, 6 Jan 2012 15:02:38 +0100 Subject: [PATCH 42/84] resolved conflict --- src/gui/UBTeacherBarWidget.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/gui/UBTeacherBarWidget.cpp b/src/gui/UBTeacherBarWidget.cpp index f20095d9..646b459d 100644 --- a/src/gui/UBTeacherBarWidget.cpp +++ b/src/gui/UBTeacherBarWidget.cpp @@ -911,8 +911,9 @@ UBTeacherBarPreviewMedia::UBTeacherBarPreviewMedia(QWidget* parent, const char* { setObjectName(name); mWidget = new UBWidgetList(parent); - mWidget->setEmptyText(tr("No media found")); +// mWidget->setEmptyText(tr("No media found")); mLayout.addWidget(mWidget); + mWidget->setStyleSheet(QString("background-color: red;")); setLayout(&mLayout); mWidgetList.clear(); } @@ -929,8 +930,11 @@ UBTeacherBarPreviewMedia::~UBTeacherBarPreviewMedia() void UBTeacherBarPreviewMedia::cleanMedia() { foreach(QWidget* eachWidget, mWidgetList.keys()){ - delete eachWidget; - eachWidget = NULL; + if(QString(eachWidget->metaObject()->className()).contains("UBDraggable")){ + delete eachWidget; + eachWidget = NULL; + } + mWidget->removeWidget(eachWidget); } mWidgetList.clear(); } From 64542002d65390676b7725bdf3fa94d52c17ed7c Mon Sep 17 00:00:00 2001 From: Claudio Valerio Date: Fri, 6 Jan 2012 15:19:43 +0100 Subject: [PATCH 43/84] fixed last scale issues --- src/customWidgets/UBWidgetList.cpp | 8 ++++++++ src/gui/UBMediaPlayer.cpp | 8 +++++--- src/gui/UBTeacherBarWidget.cpp | 7 +++++-- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/customWidgets/UBWidgetList.cpp b/src/customWidgets/UBWidgetList.cpp index d73ded86..cc2ee125 100644 --- a/src/customWidgets/UBWidgetList.cpp +++ b/src/customWidgets/UBWidgetList.cpp @@ -53,6 +53,7 @@ void UBWidgetList::addWidget(QWidget *widget) if(NULL != mpLayout){ mpEmptyLabel->setVisible(false); mWidgetInfo[widget] = widget->size(); + qDebug() << __FUNCTION__ << "widget->size () " << widget->size(); updateView(size()); mpLayout->addWidget(widget); } @@ -75,6 +76,7 @@ void UBWidgetList::removeWidget(QWidget *widget) int UBWidgetList::scaleWidgets(QSize pSize) { int result = 0; + int count = 0; foreach(QWidget* eachWidget, mWidgetInfo.keys()){ qreal scaleFactor = 0; int newWidgetWidth = pSize.width(); @@ -89,6 +91,12 @@ int UBWidgetList::scaleWidgets(QSize pSize) newWidgetWidth = mWidgetInfo[eachWidget].width()/scaleFactor; result += newWidgetWidth; } + qDebug() << __PRETTY_FUNCTION__ << "widget " << &eachWidget; + qDebug() << __PRETTY_FUNCTION__ << "count " << count++; + qDebug() << __PRETTY_FUNCTION__ << "widget orignal size " << mWidgetInfo[eachWidget]; + qDebug() << __PRETTY_FUNCTION__ << "containes size " << pSize; + qDebug() << __PRETTY_FUNCTION__ << "scale factor " << scaleFactor; + qDebug() << __PRETTY_FUNCTION__ << "new height " << result; } return result; } diff --git a/src/gui/UBMediaPlayer.cpp b/src/gui/UBMediaPlayer.cpp index c68253b3..b7c13c78 100644 --- a/src/gui/UBMediaPlayer.cpp +++ b/src/gui/UBMediaPlayer.cpp @@ -100,14 +100,17 @@ UBMediaPlayer::UBMediaPlayer() : // vLayout->addWidget(info); initVideoWindow(); vLayout->addWidget(&m_videoWindow); +// m_videoWidget->setStyleSheet(QString("background:red;")); QVBoxLayout *buttonPanelLayout = new QVBoxLayout(); -// m_videoWindow.hide(); + //m_videoWindow.hide(); // buttonPanelLayout->addLayout(layout); // timeLabel = new QLabel(this); progressLabel = new QLabel(this); QWidget *sliderPanel = new QWidget(this); +// sliderPanel->setStyleSheet(QString("background:green;")); QHBoxLayout *sliderLayout = new QHBoxLayout(); +// playButton->setStyleSheet(QString("background:yellow;")); sliderLayout->addWidget(playButton); sliderLayout->addWidget(slider); // sliderLayout->addWidget(timeLabel); @@ -130,7 +133,6 @@ UBMediaPlayer::UBMediaPlayer() : vLayout->addWidget(buttonPanelWidget); QHBoxLayout *labelLayout = new QHBoxLayout(); - vLayout->addLayout(labelLayout); setLayout(vLayout); @@ -224,7 +226,7 @@ void UBMediaPlayer::initVideoWindow() videoLayout->addWidget(m_videoWidget); videoLayout->setContentsMargins(0, 0, 0, 0); m_videoWindow.setLayout(videoLayout); - m_videoWindow.setMinimumSize(100, 100); + m_videoWindow.setMinimumSize(60, 40); } void UBMediaPlayer::playPause() diff --git a/src/gui/UBTeacherBarWidget.cpp b/src/gui/UBTeacherBarWidget.cpp index 646b459d..188f1f0f 100644 --- a/src/gui/UBTeacherBarWidget.cpp +++ b/src/gui/UBTeacherBarWidget.cpp @@ -913,7 +913,7 @@ UBTeacherBarPreviewMedia::UBTeacherBarPreviewMedia(QWidget* parent, const char* mWidget = new UBWidgetList(parent); // mWidget->setEmptyText(tr("No media found")); mLayout.addWidget(mWidget); - mWidget->setStyleSheet(QString("background-color: red;")); +// mWidget->setStyleSheet(QString("background-color: red;")); setLayout(&mLayout); mWidgetList.clear(); } @@ -931,10 +931,13 @@ void UBTeacherBarPreviewMedia::cleanMedia() { foreach(QWidget* eachWidget, mWidgetList.keys()){ if(QString(eachWidget->metaObject()->className()).contains("UBDraggable")){ + mWidget->removeWidget(eachWidget); delete eachWidget; eachWidget = NULL; } - mWidget->removeWidget(eachWidget); + else{ + mWidget->removeWidget(eachWidget); + } } mWidgetList.clear(); } From e849733736ef1528cc41974d0bbf22ecbdd6213e Mon Sep 17 00:00:00 2001 From: shibakaneki Date: Fri, 6 Jan 2012 15:20:13 +0100 Subject: [PATCH 44/84] backup --- resources/style.qss | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/resources/style.qss b/resources/style.qss index f631984c..323f062c 100644 --- a/resources/style.qss +++ b/resources/style.qss @@ -40,6 +40,19 @@ QWidget#UBLibWebView border: 2px solid #999999; } +QWidget#UBActionPreviewOwner +{ + color: #555555; + font-size : 10px; + font-weight:bold; +} + +QWidget#UBActionPreviewContent +{ + border-radius : 10px; + border: 2px solid; +} + QWebView#SearchEngineView { background:white; From c39f52134937e55063c0a747c35d16016b0db389 Mon Sep 17 00:00:00 2001 From: Claudio Valerio Date: Fri, 6 Jan 2012 16:19:09 +0100 Subject: [PATCH 45/84] fixed url issue --- src/gui/UBTeacherBarWidget.cpp | 47 +++++++++++++++++++++++++++++----- src/gui/UBTeacherBarWidget.h | 7 ++++- 2 files changed, 47 insertions(+), 7 deletions(-) diff --git a/src/gui/UBTeacherBarWidget.cpp b/src/gui/UBTeacherBarWidget.cpp index 188f1f0f..03b1644a 100644 --- a/src/gui/UBTeacherBarWidget.cpp +++ b/src/gui/UBTeacherBarWidget.cpp @@ -386,7 +386,12 @@ void UBTeacherBarWidget::loadContent() if(!mUrlList.empty()){ QStringList links; foreach(UBUrlWidget* url, mUrlList){ - links << url->url(); + QStringList list = url->url().split(";"); + QString formedlink = "" + list.at(1) + ""; + links << formedlink; } mpPreview->setLinks(links); } @@ -674,17 +679,37 @@ UBUrlWidget::UBUrlWidget(QWidget *parent, const char *name):QWidget(parent) setAttribute(Qt::WA_StyledBackground, true); setStyleSheet(UBApplication::globalStyleSheet()); - mpLayout = new QHBoxLayout(this); + mpLayout = new QVBoxLayout(this); setLayout(mpLayout); + + mpLabelLayout = new QHBoxLayout(this); mpUrlLabel = new QLabel(tr("Url"), this); - mpLayout->addWidget(mpUrlLabel, 0); + mpLabelLayout->addWidget(mpUrlLabel, 0); mpUrl = new QLineEdit(this); mpUrl->setObjectName("DockPaletteWidgetLineEdit"); - mpLayout->addWidget(mpUrl, 1); + mpLabelLayout->addWidget(mpUrl, 1); + + mpTitleLayout = new QHBoxLayout(this); + mpTitleLabel = new QLabel(tr("Title"),this); + mpTitleLayout->addWidget(mpTitleLabel,0); + mpTitle = new QLineEdit(this); + mpTitle->setObjectName("DockPaletteWidgetLineEdit"); + mpTitleLayout->addWidget(mpTitle,1); + + mpLayout->addLayout(mpTitleLayout); + mpLayout->addLayout(mpLabelLayout); } UBUrlWidget::~UBUrlWidget() { + if(NULL != mpTitle){ + delete mpTitle; + mpTitle = NULL; + } + if(NULL != mpTitleLabel){ + delete mpTitleLabel; + mpTitleLabel = NULL; + } if(NULL != mpUrlLabel){ delete mpUrlLabel; mpUrlLabel = NULL; @@ -693,6 +718,14 @@ UBUrlWidget::~UBUrlWidget() delete mpUrl; mpUrl = NULL; } + if(NULL != mpTitleLayout){ + delete mpTitleLayout; + mpTitleLayout = NULL; + } + if(NULL != mpLabelLayout){ + delete mpLabelLayout; + mpLabelLayout = NULL; + } if(NULL != mpLayout){ delete mpLayout; mpLayout = NULL; @@ -704,7 +737,7 @@ QString UBUrlWidget::url() QString str; if(NULL != mpUrl){ - str = mpUrl->text(); + str = mpUrl->text() + ";" + mpTitle->text(); } return str; @@ -712,8 +745,10 @@ QString UBUrlWidget::url() void UBUrlWidget::setUrl(const QString &url) { + QStringList list = url.split(";"); if(NULL != mpUrl){ - mpUrl->setText(url); + mpUrl->setText(list.at(0)); + mpTitle->setText(list.at(1)); } } diff --git a/src/gui/UBTeacherBarWidget.h b/src/gui/UBTeacherBarWidget.h index 3e53f97d..3916d528 100644 --- a/src/gui/UBTeacherBarWidget.h +++ b/src/gui/UBTeacherBarWidget.h @@ -107,9 +107,14 @@ public: void setUrl(const QString& url); private: - QHBoxLayout* mpLayout; + QVBoxLayout* mpLayout; + QHBoxLayout* mpLabelLayout; + QHBoxLayout* mpTitleLayout; QLabel* mpUrlLabel; QLineEdit* mpUrl; + + QLabel* mpTitleLabel; + QLineEdit* mpTitle; }; class UBActionPreview : public QWidget From 3b8a522873ba08b4e7c34afc2e2eb0cd5afbf187 Mon Sep 17 00:00:00 2001 From: Claudio Valerio <=claudio@open-sankore.org> Date: Fri, 6 Jan 2012 16:44:24 +0100 Subject: [PATCH 46/84] fixed build issue on windows --- src/customWidgets/UBWidgetList.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/customWidgets/UBWidgetList.cpp b/src/customWidgets/UBWidgetList.cpp index cc2ee125..c0d98f9d 100644 --- a/src/customWidgets/UBWidgetList.cpp +++ b/src/customWidgets/UBWidgetList.cpp @@ -91,12 +91,14 @@ int UBWidgetList::scaleWidgets(QSize pSize) newWidgetWidth = mWidgetInfo[eachWidget].width()/scaleFactor; result += newWidgetWidth; } - qDebug() << __PRETTY_FUNCTION__ << "widget " << &eachWidget; +#ifndef Q_WS_WIN + qDebug() << __PRETTY_FUNCTION__ << "widget " << &eachWidget; qDebug() << __PRETTY_FUNCTION__ << "count " << count++; qDebug() << __PRETTY_FUNCTION__ << "widget orignal size " << mWidgetInfo[eachWidget]; qDebug() << __PRETTY_FUNCTION__ << "containes size " << pSize; qDebug() << __PRETTY_FUNCTION__ << "scale factor " << scaleFactor; qDebug() << __PRETTY_FUNCTION__ << "new height " << result; +#endif } return result; } From c0fefa26a0234397da8f8320e608f5172f529a7f Mon Sep 17 00:00:00 2001 From: Claudio Valerio Date: Fri, 6 Jan 2012 16:48:10 +0100 Subject: [PATCH 47/84] fixed build issue on mac --- src/gui/UBMediaPlayer.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gui/UBMediaPlayer.cpp b/src/gui/UBMediaPlayer.cpp index b7c13c78..d158fb53 100644 --- a/src/gui/UBMediaPlayer.cpp +++ b/src/gui/UBMediaPlayer.cpp @@ -123,9 +123,9 @@ UBMediaPlayer::UBMediaPlayer() : #ifdef Q_OS_MAC // layout->setSpacing(4); buttonPanelLayout->setSpacing(0); - info->setMinimumHeight(100); - info->setFont(QFont("verdana", 15)); - openButton->setFocusPolicy(Qt::NoFocus); +// info->setMinimumHeight(100); +// info->setFont(QFont("verdana", 15)); +// openButton->setFocusPolicy(Qt::NoFocus); #endif QWidget *buttonPanelWidget = new QWidget(this); buttonPanelWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); From 8b333c21b91429a060db8ab881e1fa045908b1af Mon Sep 17 00:00:00 2001 From: shibakaneki Date: Mon, 9 Jan 2012 09:46:24 +0100 Subject: [PATCH 48/84] Updated the styles --- resources/style.qss | 3 ++- src/gui/UBTeacherBarWidget.cpp | 7 ++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/resources/style.qss b/resources/style.qss index 323f062c..384ece67 100644 --- a/resources/style.qss +++ b/resources/style.qss @@ -29,8 +29,9 @@ QLabel#UBTeacherBarPreviewTitle QLabel#UBTeacherBarPreviewSubtitle { color: #555555; - font-size : 14px; + font-size : 15px; font-weight:bold; + padding-top: 10px; } QWidget#UBLibWebView diff --git a/src/gui/UBTeacherBarWidget.cpp b/src/gui/UBTeacherBarWidget.cpp index 03b1644a..43c9859f 100644 --- a/src/gui/UBTeacherBarWidget.cpp +++ b/src/gui/UBTeacherBarWidget.cpp @@ -558,7 +558,8 @@ UBTeacherBarDropMediaZone::UBTeacherBarDropMediaZone(QWidget *parent, const char mWidget->setEmptyText(tr("Drag media here ...")); mLayout.addWidget(mWidget); setLayout(&mLayout); - + // The next line is disgusting. This is a quickfix that must be reworked later + setContentsMargins(-9, -9, -9, -9); } UBTeacherBarDropMediaZone::~UBTeacherBarDropMediaZone() @@ -687,6 +688,7 @@ UBUrlWidget::UBUrlWidget(QWidget *parent, const char *name):QWidget(parent) mpLabelLayout->addWidget(mpUrlLabel, 0); mpUrl = new QLineEdit(this); mpUrl->setObjectName("DockPaletteWidgetLineEdit"); + mpUrl->setMinimumHeight(20); mpLabelLayout->addWidget(mpUrl, 1); mpTitleLayout = new QHBoxLayout(this); @@ -694,6 +696,7 @@ UBUrlWidget::UBUrlWidget(QWidget *parent, const char *name):QWidget(parent) mpTitleLayout->addWidget(mpTitleLabel,0); mpTitle = new QLineEdit(this); mpTitle->setObjectName("DockPaletteWidgetLineEdit"); + mpTitle->setMinimumHeight(20); mpTitleLayout->addWidget(mpTitle,1); mpLayout->addLayout(mpTitleLayout); @@ -782,6 +785,8 @@ UBTeacherBarPreviewWidget::UBTeacherBarPreviewWidget(QWidget *parent, const char mLayout.addLayout(&mTitleDurationLayout, 0); mLayout.addWidget(&mMediaViewer, 1); + // The next line is disgusting. This is a quickfix that must be reworked later + mMediaViewer.setContentsMargins(-9, -9, -9, -9); hideElements(); From 5e8a46147472fda0cc667fd66d39255a1b668d06 Mon Sep 17 00:00:00 2001 From: Claudio Valerio Date: Mon, 9 Jan 2012 09:52:38 +0100 Subject: [PATCH 49/84] fixed ratio and added space between list elements --- src/customWidgets/UBWidgetList.cpp | 7 ++++++- src/customWidgets/UBWidgetList.h | 3 +++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/customWidgets/UBWidgetList.cpp b/src/customWidgets/UBWidgetList.cpp index c0d98f9d..7115b14f 100644 --- a/src/customWidgets/UBWidgetList.cpp +++ b/src/customWidgets/UBWidgetList.cpp @@ -5,6 +5,7 @@ UBWidgetList::UBWidgetList(QWidget* parent, eWidgetListOrientation orientation, , mpLayout(NULL) , mpContainer(NULL) , mMargin(5) + , mListElementsSpacing(10) , mpEmptyLabel(NULL) { setObjectName(name); @@ -75,7 +76,8 @@ void UBWidgetList::removeWidget(QWidget *widget) int UBWidgetList::scaleWidgets(QSize pSize) { - int result = 0; + // to remove the first spacing that shouldn't be there. + int result = -mListElementsSpacing; int count = 0; foreach(QWidget* eachWidget, mWidgetInfo.keys()){ qreal scaleFactor = 0; @@ -85,6 +87,7 @@ int UBWidgetList::scaleWidgets(QSize pSize) scaleFactor = (float)mWidgetInfo[eachWidget].width() / (float)pSize.width(); newWidgetHeight = mWidgetInfo[eachWidget].height()/scaleFactor; result += newWidgetHeight; + eachWidget->setMinimumHeight(newWidgetHeight); } else{ scaleFactor = (float)mWidgetInfo[eachWidget].height() / (float)pSize.height(); @@ -99,6 +102,8 @@ int UBWidgetList::scaleWidgets(QSize pSize) qDebug() << __PRETTY_FUNCTION__ << "scale factor " << scaleFactor; qDebug() << __PRETTY_FUNCTION__ << "new height " << result; #endif + //Adding a vertical/horizontal space between each element of the list + result += mListElementsSpacing; } return result; } diff --git a/src/customWidgets/UBWidgetList.h b/src/customWidgets/UBWidgetList.h index 2dd0895f..6cdfef66 100644 --- a/src/customWidgets/UBWidgetList.h +++ b/src/customWidgets/UBWidgetList.h @@ -29,6 +29,8 @@ public: void setEmptyText(const QString& text); int margin(); bool empty(); + void setListElementSpacing(int margin) { mListElementsSpacing = margin; } + int listElementsSpacing() {return mListElementsSpacing; } protected: void resizeEvent(QResizeEvent* ev); @@ -41,6 +43,7 @@ private: QWidget* mpContainer; eWidgetListOrientation mOrientation; int mMargin; + int mListElementsSpacing; QMap mWidgetInfo; QLabel* mpEmptyLabel; }; From 8cbd8a8a73f2b883ac5d477886664b7f84ab4db3 Mon Sep 17 00:00:00 2001 From: Claudio Valerio Date: Mon, 9 Jan 2012 09:52:50 +0100 Subject: [PATCH 50/84] mimimal change --- src/gui/UBMediaPlayer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/UBMediaPlayer.cpp b/src/gui/UBMediaPlayer.cpp index d158fb53..8bb60905 100644 --- a/src/gui/UBMediaPlayer.cpp +++ b/src/gui/UBMediaPlayer.cpp @@ -102,7 +102,7 @@ UBMediaPlayer::UBMediaPlayer() : vLayout->addWidget(&m_videoWindow); // m_videoWidget->setStyleSheet(QString("background:red;")); QVBoxLayout *buttonPanelLayout = new QVBoxLayout(); - //m_videoWindow.hide(); + m_videoWindow.hide(); // buttonPanelLayout->addLayout(layout); // timeLabel = new QLabel(this); From 81ed0c74c2fce88e0498acdacc8494468afa8360 Mon Sep 17 00:00:00 2001 From: shibakaneki Date: Mon, 9 Jan 2012 10:49:17 +0100 Subject: [PATCH 51/84] Stylized the teacher bar preview --- resources/style.qss | 13 +++++++++++-- src/gui/UBTeacherBarWidget.cpp | 6 ++++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/resources/style.qss b/resources/style.qss index 384ece67..e279c597 100644 --- a/resources/style.qss +++ b/resources/style.qss @@ -44,14 +44,23 @@ QWidget#UBLibWebView QWidget#UBActionPreviewOwner { color: #555555; - font-size : 10px; - font-weight:bold; + font-size : 12px; + font-weight: bold; +} + +QWidget#UBTeacherBarPreviewComments +{ + border-radius: 10px; + border: white 2px solid; + padding: 5px 5px 5px 5px; + background-color: white; } QWidget#UBActionPreviewContent { border-radius : 10px; border: 2px solid; + padding: 5px 5px 5px 5px; } QWebView#SearchEngineView diff --git a/src/gui/UBTeacherBarWidget.cpp b/src/gui/UBTeacherBarWidget.cpp index 43c9859f..3b311908 100644 --- a/src/gui/UBTeacherBarWidget.cpp +++ b/src/gui/UBTeacherBarWidget.cpp @@ -900,6 +900,7 @@ void UBTeacherBarPreviewWidget::hideElements() mpCommentsLabel->setObjectName("UBTeacherBarPreviewSubtitle"); mpComments = new QLabel(this); mpComments->setWordWrap(true); + mpComments->setObjectName("UBTeacherBarPreviewComments"); mpLinksLabel = new QLabel(tr("Links"), this); mpLinksLabel->setObjectName("UBTeacherBarPreviewSubtitle"); @@ -1032,6 +1033,7 @@ UBActionPreview::UBActionPreview(QWidget *parent, const char *name):QWidget(pare mpContent->setObjectName("UBActionPreviewContent"); mpContent->setWordWrap(true); mLayout.addWidget(mpContent); + setContentsMargins(-9, -9, -9, -9); } UBActionPreview::~UBActionPreview() @@ -1052,12 +1054,12 @@ void UBActionPreview::setOwner(const QString &owner) switch(owner.toInt()){ case eActionOwner_Teacher: mpOwner->setText(tr("Teacher")); - mpContent->setStyleSheet("background:lightblue;"); + mpContent->setStyleSheet("background:lightblue; border:lightblue;"); break; case eActionOwner_Student: mpOwner->setText(tr("Student")); - mpContent->setStyleSheet("background:lightgreen;"); + mpContent->setStyleSheet("background:lightgreen; border:lightgreen;"); break; } } From a94f7f63de05df51ae321594aca8661edb1d0d81 Mon Sep 17 00:00:00 2001 From: Claudio Valerio Date: Mon, 9 Jan 2012 15:11:31 +0100 Subject: [PATCH 52/84] I don't know --- src/customWidgets/UBWidgetList.cpp | 61 +++++++++++++++++++----------- src/customWidgets/UBWidgetList.h | 10 ++++- src/gui/UBTeacherBarWidget.cpp | 36 +++++++++++++----- src/gui/UBTeacherBarWidget.h | 5 ++- 4 files changed, 77 insertions(+), 35 deletions(-) diff --git a/src/customWidgets/UBWidgetList.cpp b/src/customWidgets/UBWidgetList.cpp index 7115b14f..482a0780 100644 --- a/src/customWidgets/UBWidgetList.cpp +++ b/src/customWidgets/UBWidgetList.cpp @@ -49,12 +49,12 @@ UBWidgetList::~UBWidgetList() } } -void UBWidgetList::addWidget(QWidget *widget) +void UBWidgetList::addWidget(QWidget *widget, bool isResizable) { if(NULL != mpLayout){ mpEmptyLabel->setVisible(false); - mWidgetInfo[widget] = widget->size(); - qDebug() << __FUNCTION__ << "widget->size () " << widget->size(); + mWidgetInfo[widget] = {widget->size(), isResizable}; + qDebug() << __FUNCTION__ << "widget : " << widget << " widget->size () " << widget->size() << " isResizable " << isResizable; updateView(size()); mpLayout->addWidget(widget); } @@ -80,28 +80,45 @@ int UBWidgetList::scaleWidgets(QSize pSize) int result = -mListElementsSpacing; int count = 0; foreach(QWidget* eachWidget, mWidgetInfo.keys()){ - qreal scaleFactor = 0; - int newWidgetWidth = pSize.width(); - int newWidgetHeight = pSize.height(); - if(eWidgetListOrientation_Vertical == mOrientation){ - scaleFactor = (float)mWidgetInfo[eachWidget].width() / (float)pSize.width(); - newWidgetHeight = mWidgetInfo[eachWidget].height()/scaleFactor; - result += newWidgetHeight; - eachWidget->setMinimumHeight(newWidgetHeight); + if(mWidgetInfo[eachWidget].isResizable){ + qreal scaleFactor = 0; + int newWidgetWidth = pSize.width(); + int newWidgetHeight = pSize.height(); + if(eWidgetListOrientation_Vertical == mOrientation){ + scaleFactor = (float)mWidgetInfo[eachWidget].size.width() / (float)pSize.width(); + newWidgetHeight = mWidgetInfo[eachWidget].size.height()/scaleFactor; + result += newWidgetHeight; + eachWidget->setMinimumHeight(newWidgetHeight); + eachWidget->setMaximumHeight(newWidgetHeight + 1); + } + else{ + scaleFactor = (float)mWidgetInfo[eachWidget].size.height() / (float)pSize.height(); + newWidgetWidth = mWidgetInfo[eachWidget].size.width()/scaleFactor; + result += newWidgetWidth; + eachWidget->setMinimumWidth(newWidgetWidth); + eachWidget->setMinimumWidth(newWidgetWidth+1); + } +#ifndef Q_WS_WIN + qDebug() << __PRETTY_FUNCTION__ << "widget " << &eachWidget; + qDebug() << __PRETTY_FUNCTION__ << "count " << count++; + qDebug() << __PRETTY_FUNCTION__ << "widget orignal size " << mWidgetInfo[eachWidget].size; + qDebug() << __PRETTY_FUNCTION__ << "containes size " << pSize; + qDebug() << __PRETTY_FUNCTION__ << "scale factor " << scaleFactor; + qDebug() << __PRETTY_FUNCTION__ << "new height " << result; +#endif } else{ - scaleFactor = (float)mWidgetInfo[eachWidget].height() / (float)pSize.height(); - newWidgetWidth = mWidgetInfo[eachWidget].width()/scaleFactor; - result += newWidgetWidth; + if(eWidgetListOrientation_Vertical == mOrientation){ + result += mWidgetInfo[eachWidget].size.height(); + eachWidget->setMinimumHeight(mWidgetInfo[eachWidget].size.height()); + eachWidget->setMaximumHeight(mWidgetInfo[eachWidget].size.height() + 1); + } + else{ + result += mWidgetInfo[eachWidget].size.width(); + eachWidget->setMinimumWidth(mWidgetInfo[eachWidget].size.width()); + eachWidget->setMaximumWidth(mWidgetInfo[eachWidget].size.width() + 1); + } } -#ifndef Q_WS_WIN - qDebug() << __PRETTY_FUNCTION__ << "widget " << &eachWidget; - qDebug() << __PRETTY_FUNCTION__ << "count " << count++; - qDebug() << __PRETTY_FUNCTION__ << "widget orignal size " << mWidgetInfo[eachWidget]; - qDebug() << __PRETTY_FUNCTION__ << "containes size " << pSize; - qDebug() << __PRETTY_FUNCTION__ << "scale factor " << scaleFactor; - qDebug() << __PRETTY_FUNCTION__ << "new height " << result; -#endif //Adding a vertical/horizontal space between each element of the list result += mListElementsSpacing; } diff --git a/src/customWidgets/UBWidgetList.h b/src/customWidgets/UBWidgetList.h index 6cdfef66..fe0c8f29 100644 --- a/src/customWidgets/UBWidgetList.h +++ b/src/customWidgets/UBWidgetList.h @@ -20,10 +20,16 @@ class UBWidgetList : public QScrollArea { Q_OBJECT + typedef struct + { + QSize size; + bool isResizable; + } sWidgetProperties; + public: UBWidgetList(QWidget* parent=0, eWidgetListOrientation orientation = eWidgetListOrientation_Vertical, const char* name = "UBWidgetList"); ~UBWidgetList(); - void addWidget(QWidget* widget); + void addWidget(QWidget* widget, bool isResizable = true); void removeWidget(QWidget* widget); void setMargin(int margin); void setEmptyText(const QString& text); @@ -44,7 +50,7 @@ private: eWidgetListOrientation mOrientation; int mMargin; int mListElementsSpacing; - QMap mWidgetInfo; + QMap mWidgetInfo; QLabel* mpEmptyLabel; }; diff --git a/src/gui/UBTeacherBarWidget.cpp b/src/gui/UBTeacherBarWidget.cpp index 3b311908..cfdf18ce 100644 --- a/src/gui/UBTeacherBarWidget.cpp +++ b/src/gui/UBTeacherBarWidget.cpp @@ -119,7 +119,7 @@ UBTeacherBarWidget::UBTeacherBarWidget(QWidget *parent, const char *name):UBDock mpLayout->addLayout(mpActionLayout, 0); // Media - mpMediaLabel = new QLabel(tr("Media"), mpContainer); + mpMediaLabel = new QLabel(tr("Medias"), mpContainer); mpLayout->addWidget(mpMediaLabel, 0); mpDropMediaZone = new UBTeacherBarDropMediaZone(mpContainer); mpLayout->addWidget(mpDropMediaZone, 1); @@ -380,7 +380,15 @@ void UBTeacherBarWidget::loadContent() } // Add the media - mpPreview->mediaViewer()->loadMedia(nextInfos.medias); + if(nextInfos.medias.count() > 0){ + QList widgetList; + widgetList.append(mpPreview->mediaLabel()); + mpPreview->mediaViewer()->loadWidgets(widgetList,false); + int loadedMedia = mpPreview->mediaViewer()->loadMedia(nextInfos.medias); + if(loadedMedia) + mpPreview->mediaLabel()->setVisible(true); + } + // Add the links if(!mUrlList.empty()){ @@ -879,8 +887,10 @@ void UBTeacherBarPreviewWidget::setComments(const QString &comments) mpComments->setVisible(true); mpCommentsLabel->setVisible(true); mWidgets << mpCommentsLabel; + mMediaViewer.loadWidgets(mWidgets, false); + mWidgets.clear(); mWidgets << mpComments; - mMediaViewer.loadWidgets(mWidgets); + mMediaViewer.loadWidgets(mWidgets, true); } } @@ -894,7 +904,7 @@ void UBTeacherBarPreviewWidget::hideElements() { mpActionsLabel = new QLabel(tr("Actions"), this); mpActionsLabel->setObjectName("UBTeacherBarPreviewSubtitle"); - mpMediaLabel = new QLabel(tr("Media"), this); + mpMediaLabel = new QLabel(tr("Medias"), this); mpMediaLabel->setObjectName("UBTeacherBarPreviewSubtitle"); mpCommentsLabel = new QLabel(tr("Comments"), this); mpCommentsLabel->setObjectName("UBTeacherBarPreviewSubtitle"); @@ -917,6 +927,8 @@ void UBTeacherBarPreviewWidget::setActions(QStringList actions) mWidgets.clear(); mpActionsLabel->setVisible(true); mWidgets << mpActionsLabel; + mediaViewer()->loadWidgets(mWidgets,false); + mWidgets.clear(); foreach(QString action, actions){ QStringList desc = action.split(';'); if(2 <= desc.size()){ @@ -928,7 +940,7 @@ void UBTeacherBarPreviewWidget::setActions(QStringList actions) mWidgets << mpTmpAction; } } - mMediaViewer.loadWidgets(mWidgets); + mMediaViewer.loadWidgets(mWidgets, true); } } @@ -938,12 +950,14 @@ void UBTeacherBarPreviewWidget::setLinks(QStringList links) mWidgets.clear(); mpLinksLabel->setVisible(true); mWidgets << mpLinksLabel; + mMediaViewer.loadWidgets(mWidgets, false); + mWidgets.clear(); foreach(QString link, links){ mpTmpLink = new QLabel(link, this); mpTmpLink->setOpenExternalLinks(true); mWidgets << mpTmpLink; } - mMediaViewer.loadWidgets(mWidgets); + mMediaViewer.loadWidgets(mWidgets, true); } } @@ -983,17 +997,18 @@ void UBTeacherBarPreviewMedia::cleanMedia() mWidgetList.clear(); } -void UBTeacherBarPreviewMedia::loadWidgets(QList pWidgetsList) +void UBTeacherBarPreviewMedia::loadWidgets(QList pWidgetsList, bool isResizable) { foreach(QWidget*eachWidget, pWidgetsList){ - mWidget->addWidget(eachWidget); + mWidget->addWidget(eachWidget,isResizable); mWidgetList[eachWidget]="DRAG UNAVAILABLE"; } } -void UBTeacherBarPreviewMedia::loadMedia(QStringList pMedias) +int UBTeacherBarPreviewMedia::loadMedia(QStringList pMedias) { + int addedMedia = 0; foreach(QString eachString, pMedias){ if(!eachString.isEmpty()){ QString mimeType = UBFileSystemUtils::mimeTypeFromFileName(eachString); @@ -1002,12 +1017,14 @@ void UBTeacherBarPreviewMedia::loadMedia(QStringList pMedias) label->loadImage(eachString); mWidget->addWidget(label); mWidgetList[label]=eachString; + addedMedia += 1; } else if(mimeType.contains("video") || mimeType.contains("audio")){ UBDraggableMediaPlayer* mediaPlayer = new UBDraggableMediaPlayer(); mediaPlayer->setFile(eachString); mWidget->addWidget(mediaPlayer); mWidgetList[mediaPlayer] = eachString; + addedMedia += 1; } else{ qWarning() << "pMediaPath" << eachString; @@ -1015,6 +1032,7 @@ void UBTeacherBarPreviewMedia::loadMedia(QStringList pMedias) } } } + return addedMedia; } // ----------------------------------------------------------------------------------------------- diff --git a/src/gui/UBTeacherBarWidget.h b/src/gui/UBTeacherBarWidget.h index 3916d528..b2910594 100644 --- a/src/gui/UBTeacherBarWidget.h +++ b/src/gui/UBTeacherBarWidget.h @@ -87,8 +87,8 @@ class UBTeacherBarPreviewMedia : public QWidget public: UBTeacherBarPreviewMedia(QWidget* parent=0, const char* name="UBTeacherBarPreviewMedia"); ~UBTeacherBarPreviewMedia(); - void loadMedia(QStringList pMedias); - void loadWidgets(QList pWidgetList); + int loadMedia(QStringList pMedias); + void loadWidgets(QList pWidgetList, bool isResizable = true); void cleanMedia(); private: @@ -146,6 +146,7 @@ public: void setActions(QStringList actions); void setLinks(QStringList links); void clean(); + QLabel* mediaLabel() { return mpMediaLabel;} signals: void showEditMode(); From 3c905ba23371de47e905f31f9474f6b63946fe25 Mon Sep 17 00:00:00 2001 From: Claudio Valerio Date: Mon, 9 Jan 2012 15:23:42 +0100 Subject: [PATCH 53/84] fixed syntax error --- src/customWidgets/UBWidgetList.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/customWidgets/UBWidgetList.cpp b/src/customWidgets/UBWidgetList.cpp index 482a0780..2832ca61 100644 --- a/src/customWidgets/UBWidgetList.cpp +++ b/src/customWidgets/UBWidgetList.cpp @@ -53,7 +53,8 @@ void UBWidgetList::addWidget(QWidget *widget, bool isResizable) { if(NULL != mpLayout){ mpEmptyLabel->setVisible(false); - mWidgetInfo[widget] = {widget->size(), isResizable}; + sWidgetProperties properties = {widget->size(), isResizable}; + mWidgetInfo[widget] = properties; qDebug() << __FUNCTION__ << "widget : " << widget << " widget->size () " << widget->size() << " isResizable " << isResizable; updateView(size()); mpLayout->addWidget(widget); From 04dacaa607b8aecd81307e11ff897d00b0952991 Mon Sep 17 00:00:00 2001 From: Claudio Valerio <=claudio@open-sankore.org> Date: Mon, 9 Jan 2012 15:57:51 +0100 Subject: [PATCH 54/84] fixed player windows on windows --- src/gui/UBMediaPlayer.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/gui/UBMediaPlayer.cpp b/src/gui/UBMediaPlayer.cpp index 8bb60905..641ac162 100644 --- a/src/gui/UBMediaPlayer.cpp +++ b/src/gui/UBMediaPlayer.cpp @@ -102,7 +102,9 @@ UBMediaPlayer::UBMediaPlayer() : vLayout->addWidget(&m_videoWindow); // m_videoWidget->setStyleSheet(QString("background:red;")); QVBoxLayout *buttonPanelLayout = new QVBoxLayout(); - m_videoWindow.hide(); +#ifdef Q_WS_MAC + m_videoWindow.hide(); +#endif // buttonPanelLayout->addLayout(layout); // timeLabel = new QLabel(this); From afa89214a85578473b8415b5a69cba87f0c434f0 Mon Sep 17 00:00:00 2001 From: Claudio Valerio Date: Mon, 9 Jan 2012 16:04:49 +0100 Subject: [PATCH 55/84] last commit --- Sankore_3.1.pro | 4 ++-- src/gui/UBMediaPlayer.cpp | 4 ++-- src/gui/UBTeacherBarWidget.cpp | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Sankore_3.1.pro b/Sankore_3.1.pro index 5dfa1b33..787b195b 100644 --- a/Sankore_3.1.pro +++ b/Sankore_3.1.pro @@ -12,8 +12,8 @@ linux-g++-64 { VERSION_MAJ = 1 VERSION_MIN = 40 -VERSION_TYPE = b # a = alpha, b = beta, r = release, other => error -VERSION_PATCH = 01 +VERSION_TYPE = a # a = alpha, b = beta, r = release, other => error +VERSION_PATCH = 00 VERSION = "$${VERSION_MAJ}.$${VERSION_MIN}.$${VERSION_TYPE}.$${VERSION_PATCH}" VERSION = $$replace(VERSION, "\\.r", "") diff --git a/src/gui/UBMediaPlayer.cpp b/src/gui/UBMediaPlayer.cpp index 641ac162..62ea98c8 100644 --- a/src/gui/UBMediaPlayer.cpp +++ b/src/gui/UBMediaPlayer.cpp @@ -102,8 +102,8 @@ UBMediaPlayer::UBMediaPlayer() : vLayout->addWidget(&m_videoWindow); // m_videoWidget->setStyleSheet(QString("background:red;")); QVBoxLayout *buttonPanelLayout = new QVBoxLayout(); -#ifdef Q_WS_MAC - m_videoWindow.hide(); +#ifndef Q_WS_WIN + m_videoWindow.hide(); #endif // buttonPanelLayout->addLayout(layout); diff --git a/src/gui/UBTeacherBarWidget.cpp b/src/gui/UBTeacherBarWidget.cpp index cfdf18ce..3a9a8a75 100644 --- a/src/gui/UBTeacherBarWidget.cpp +++ b/src/gui/UBTeacherBarWidget.cpp @@ -386,7 +386,7 @@ void UBTeacherBarWidget::loadContent() mpPreview->mediaViewer()->loadWidgets(widgetList,false); int loadedMedia = mpPreview->mediaViewer()->loadMedia(nextInfos.medias); if(loadedMedia) - mpPreview->mediaLabel()->setVisible(true); + mpPreview->mediaLabel()->setVisible(true); } From 955e928930d47c27f0cf03e12d9cd71711acb9f4 Mon Sep 17 00:00:00 2001 From: shibakaneki Date: Thu, 12 Jan 2012 14:36:08 +0100 Subject: [PATCH 56/84] partial backup of the ubmediawidget --- Sankore_3.1.pro | 1 + resources/style.qss | 17 ++- src/customWidgets/UBGlobals.h | 9 ++ src/customWidgets/UBMediaWidget.cpp | 209 ++++++++++++++++++++++++++++ src/customWidgets/UBMediaWidget.h | 85 +++++++++++ src/customWidgets/UBWidgetList.cpp | 68 +++++---- src/customWidgets/UBWidgetList.h | 7 +- src/customWidgets/customWidgets.pri | 10 +- src/gui/UBMediaPlayer.cpp | 12 ++ src/gui/UBMediaPlayer.h | 3 + src/gui/UBTeacherBarWidget.cpp | 182 ++++++++++++++++++++++-- src/gui/UBTeacherBarWidget.h | 33 ++++- src/interfaces/IDropable.h | 21 +++ src/interfaces/IResizeable.h | 15 ++ src/interfaces/interfaces.pri | 3 + 15 files changed, 628 insertions(+), 47 deletions(-) create mode 100644 src/customWidgets/UBGlobals.h create mode 100644 src/customWidgets/UBMediaWidget.cpp create mode 100644 src/customWidgets/UBMediaWidget.h create mode 100644 src/interfaces/IDropable.h create mode 100644 src/interfaces/IResizeable.h create mode 100644 src/interfaces/interfaces.pri diff --git a/Sankore_3.1.pro b/Sankore_3.1.pro index 5dfa1b33..78afe48f 100644 --- a/Sankore_3.1.pro +++ b/Sankore_3.1.pro @@ -54,6 +54,7 @@ include(src/web/web.pri) include(src/softwareupdate/softwareupdate.pri) include(src/transition/transition.pri) include(src/customWidgets/customWidgets.pri) +include(src/interfaces/interfaces.pri) DEPENDPATH += src/pdf-merger INCLUDEPATH += src/pdf-merger diff --git a/resources/style.qss b/resources/style.qss index e279c597..a3fec87d 100644 --- a/resources/style.qss +++ b/resources/style.qss @@ -5,13 +5,23 @@ QWidget#UBLibNavigatorWidget, QWidget#UBLibItemProperties, QWidget#UBDownloadWidget, QWidget#UBWidgetList, -QWidget#UBTeacherBarDropMediaZone +QWidget#UBTeacherBarDropMediaZone, +QWidget#UBTBMediaContainer { background: #EEEEEE; border-radius: 10px; border: 2px solid #999999; } +QWidget#UBMediaVideoContainer +{ + background: #000000; + border-radius: 10px; + border: 2px solid #999999; + margin: 0px 0px 0px 0px; + padding: 0px 0px 0px 0px; +} + QWidget#UBTeacherBarPreviewWidget { background: #FFFFFF; @@ -26,6 +36,11 @@ QLabel#UBTeacherBarPreviewTitle font-weight:bold; } +QLabel#UBMediaPlayerButton +{ + padding: 0px 0px 0px 0px; +} + QLabel#UBTeacherBarPreviewSubtitle { color: #555555; diff --git a/src/customWidgets/UBGlobals.h b/src/customWidgets/UBGlobals.h new file mode 100644 index 00000000..1707ceac --- /dev/null +++ b/src/customWidgets/UBGlobals.h @@ -0,0 +1,9 @@ +#ifndef UBGLOBALS_H +#define UBGLOBALS_H + +#define DELETEPTR(ptr) if(NULL != ptr){ \ + delete ptr; \ + ptr = NULL; \ + } + +#endif // UBGLOBALS_H diff --git a/src/customWidgets/UBMediaWidget.cpp b/src/customWidgets/UBMediaWidget.cpp new file mode 100644 index 00000000..eabe51bd --- /dev/null +++ b/src/customWidgets/UBMediaWidget.cpp @@ -0,0 +1,209 @@ +#include "core/UBApplication.h" +#include "UBGlobals.h" +#include "UBMediaWidget.h" + +UBMediaWidget::UBMediaWidget(eMediaType type, QWidget *parent, const char *name):QWidget(parent) + , mpMediaObject(NULL) + , mpVideoWidget(NULL) + , mpAudioOutput(NULL) + , mpPlayStopButton(NULL) + , mpPauseButton(NULL) + , mpSlider(NULL) + , mAutoUpdate(false) + , mGeneratingThumbnail(false) + , mBorder(5) + , mpVideoContainer(NULL) +{ + setObjectName(name); + + setAttribute(Qt::WA_StyledBackground, true); + setStyleSheet(UBApplication::globalStyleSheet()); + + mType = type; + setLayout(&mLayout); + + mpPlayStopButton = new UBMediaButton(this); + mpPlayStopButton->setPixmap(QPixmap(":images/play.svg")); + mpPauseButton = new UBMediaButton(this); + mpPauseButton->setPixmap(QPixmap(":images/pause.svg")); + mpPauseButton->setEnabled(false); + mpSlider = new QSlider(this); + mpSlider->setOrientation(Qt::Horizontal); + mpSlider->setMinimum(0); + mpSlider->setMaximum(0); + + mSeekerLayout.addWidget(mpPlayStopButton, 0); + mSeekerLayout.addWidget(mpPauseButton, 0); + mSeekerLayout.addWidget(mpSlider, 1); + + connect(mpPlayStopButton, SIGNAL(clicked()), this, SLOT(onPlayStopClicked())); + connect(mpPauseButton, SIGNAL(clicked()), this, SLOT(onPauseClicked())); + connect(mpSlider, SIGNAL(valueChanged(int)), this, SLOT(onSliderChanged(int))); +} + +UBMediaWidget::~UBMediaWidget() +{ + DELETEPTR(mpSlider); + DELETEPTR(mpPauseButton); + DELETEPTR(mpPlayStopButton); + DELETEPTR(mpAudioOutput); + DELETEPTR(mpVideoWidget); + DELETEPTR(mpVideoContainer); + DELETEPTR(mpMediaObject); +} + +void UBMediaWidget::setFile(const QString &filePath) +{ + Q_ASSERT("" != filePath); + mFilePath = filePath; + mpMediaObject = new Phonon::MediaObject(this); + mpMediaObject->setTickInterval(TICK_INTERVAL); + connect(mpMediaObject, SIGNAL(stateChanged(Phonon::State,Phonon::State)), this, SLOT(onStateChanged(Phonon::State,Phonon::State))); + connect(mpMediaObject, SIGNAL(totalTimeChanged(qint64)), this, SLOT(onTotalTimeChanged(qint64))); + connect(mpMediaObject, SIGNAL(tick(qint64)), this, SLOT(onTick(qint64))); + mpMediaObject->setCurrentSource(Phonon::MediaSource(filePath)); + createMediaPlayer(); +} + +eMediaType UBMediaWidget::mediaType() +{ + return mType; +} + +void UBMediaWidget::createMediaPlayer() +{ + if(eMediaType_Video == mType){ + mpVideoWidget = new Phonon::VideoWidget(this); + mpVideoWidget->setStyleSheet(QString("margin: 0px 0px 0px 0px; padding: 0px 0px 0px 0px;")); + mpVideoContainer = new QWidget(this); + mpVideoContainer->setObjectName("UBMediaVideoContainer"); + mpVideoContainer->setLayout(&mVideoLayout); + mVideoLayout.addWidget(mpVideoWidget, 1); + Phonon::createPath(mpMediaObject, mpVideoWidget); + adaptSizeToVideo(); + mLayout.addWidget(mpVideoContainer, 1); + mpAudioOutput = new Phonon::AudioOutput(Phonon::VideoCategory, this); + Phonon::createPath(mpMediaObject, mpAudioOutput); + }else if(eMediaType_Audio == mType){ + mpAudioOutput = new Phonon::AudioOutput(Phonon::MusicCategory, this); + Phonon::createPath(mpMediaObject, mpAudioOutput); + } + mLayout.addLayout(&mSeekerLayout, 0); +} + +void UBMediaWidget::adaptSizeToVideo() +{ + if(NULL != mpVideoWidget){ + int origW = mpVideoWidget->width(); + int origH = mpVideoWidget->height(); + int newW = width(); + float scaleFactor = (float)origW/(float)newW; + int newH = origH/scaleFactor; + resize(width(), height() + newH); + } +} + +void UBMediaWidget::onStateChanged(Phonon::State newState, Phonon::State oldState) +{ + if(!mGeneratingThumbnail){ + if(Phonon::LoadingState == oldState && Phonon::StoppedState == newState){ + if(eMediaType_Video == mType){ + // We do that here to generate the thumbnail of the video + mGeneratingThumbnail = true; + mpMediaObject->play(); + mpMediaObject->pause(); + mGeneratingThumbnail = false; + } + }else if(Phonon::PlayingState == oldState && Phonon::PausedState == newState){ + mpPlayStopButton->setPixmap(QPixmap(":images/play.svg")); + mpPauseButton->setEnabled(false); + }else if((Phonon::PausedState == oldState && Phonon::PlayingState == newState) || + (Phonon::StoppedState == oldState && Phonon::PlayingState == newState)){ + mpPlayStopButton->setPixmap(QPixmap(":images/stop.svg")); + mpPauseButton->setEnabled(true); + }else if(Phonon::PlayingState == oldState && Phonon::StoppedState == newState){ + mpPlayStopButton->setPixmap(QPixmap(":images/play.svg")); + mpPauseButton->setEnabled(false); + mpSlider->setValue(0); + } + } +} + +void UBMediaWidget::onTotalTimeChanged(qint64 total) +{ + mpSlider->setMaximum(total); +} + +void UBMediaWidget::onTick(qint64 currentTime) +{ + mAutoUpdate = true; + mpSlider->setValue((int)currentTime); + mAutoUpdate = false; +} + +void UBMediaWidget::onSliderChanged(int value) +{ + if(!mAutoUpdate){ + mpMediaObject->seek(value); + } +} + +void UBMediaWidget::onPlayStopClicked() +{ + switch(mpMediaObject->state()){ + case Phonon::PlayingState: + mpMediaObject->stop(); + break; + + case Phonon::StoppedState: + case Phonon::PausedState: + mpMediaObject->play(); + break; + default: + break; + } +} + +void UBMediaWidget::onPauseClicked() +{ + mpMediaObject->pause(); +} + +int UBMediaWidget::border() +{ + return mBorder; +} + +void UBMediaWidget::resizeEvent(QResizeEvent* ev) +{ + Q_UNUSED(ev); +} + +// ----------------------------------------------------------------------------------------------------------- +UBMediaButton::UBMediaButton(QWidget *parent, const char *name):QLabel(parent) + , mPressed(false) +{ + setObjectName(name); + resize(UBMEDIABUTTON_SIZE, UBMEDIABUTTON_SIZE); + setStyleSheet(QString("padding:0px 0px 0px 0px;")); +} + +UBMediaButton::~UBMediaButton() +{ + +} + +void UBMediaButton::mousePressEvent(QMouseEvent* ev) +{ + Q_UNUSED(ev); + mPressed = true; +} + +void UBMediaButton::mouseReleaseEvent(QMouseEvent* ev) +{ + Q_UNUSED(ev); + if(mPressed){ + mPressed = false; + emit clicked(); + } +} diff --git a/src/customWidgets/UBMediaWidget.h b/src/customWidgets/UBMediaWidget.h new file mode 100644 index 00000000..c835ab91 --- /dev/null +++ b/src/customWidgets/UBMediaWidget.h @@ -0,0 +1,85 @@ +#ifndef UBMEDIAWIDGET_H +#define UBMEDIAWIDGET_H + +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include "interfaces/IResizeable.h" + +#define UBMEDIABUTTON_SIZE 32 +#define TICK_INTERVAL 1000 + +typedef enum{ + eMediaType_Video, + eMediaType_Audio +}eMediaType; + +class UBMediaButton : public QLabel +{ + Q_OBJECT +public: + UBMediaButton(QWidget* parent=0, const char* name="UBMediaButton"); + ~UBMediaButton(); + +signals: + void clicked(); + +protected: + void mousePressEvent(QMouseEvent* ev); + void mouseReleaseEvent(QMouseEvent* ev); + +private: + bool mPressed; +}; + +class UBMediaWidget : public QWidget +{ + Q_OBJECT +public: + UBMediaWidget(eMediaType type = eMediaType_Video, QWidget* parent=0, const char* name="UBMediaWidget"); + ~UBMediaWidget(); + void setFile(const QString& filePath); + eMediaType mediaType(); + int border(); + +protected: + void resizeEvent(QResizeEvent* ev); + +private slots: + void onPlayStopClicked(); + void onPauseClicked(); + void onStateChanged(Phonon::State newState, Phonon::State oldState); + void onTotalTimeChanged(qint64 total); + void onTick(qint64 currentTime); + void onSliderChanged(int value); + +private: + void createMediaPlayer(); + void adaptSizeToVideo(); + + QString mFilePath; + eMediaType mType; + Phonon::MediaObject* mpMediaObject; + Phonon::VideoWidget* mpVideoWidget; + Phonon::AudioOutput* mpAudioOutput; + QVBoxLayout mLayout; + QHBoxLayout mSeekerLayout; + UBMediaButton* mpPlayStopButton; + UBMediaButton* mpPauseButton; + QSlider* mpSlider; + bool mAutoUpdate; + bool mGeneratingThumbnail; + int mBorder; + QWidget* mpVideoContainer; + QVBoxLayout mVideoLayout; +}; + +#endif // UBMEDIAWIDGET_H diff --git a/src/customWidgets/UBWidgetList.cpp b/src/customWidgets/UBWidgetList.cpp index 7115b14f..b025bfdb 100644 --- a/src/customWidgets/UBWidgetList.cpp +++ b/src/customWidgets/UBWidgetList.cpp @@ -1,4 +1,7 @@ #include +#include + +#include "UBGlobals.h" #include "UBWidgetList.h" UBWidgetList::UBWidgetList(QWidget* parent, eWidgetListOrientation orientation, const char* name):QScrollArea(parent) @@ -20,13 +23,11 @@ UBWidgetList::UBWidgetList(QWidget* parent, eWidgetListOrientation orientation, setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); mpLayout = new QVBoxLayout(mpContainer); - mpContainer->resize(mpContainer->width(), mpContainer->height()); } else{ setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded); setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); mpLayout = new QHBoxLayout(mpContainer); - mpContainer->resize(mpContainer->width(), mpContainer->height()); } mpLayout->setContentsMargins(margin(), margin(), margin(), margin()); mpContainer->setLayout(mpLayout); @@ -35,28 +36,22 @@ UBWidgetList::UBWidgetList(QWidget* parent, eWidgetListOrientation orientation, UBWidgetList::~UBWidgetList() { - if(NULL != mpEmptyLabel){ - delete mpEmptyLabel; - mpEmptyLabel = NULL; - } - if(NULL != mpLayout){ - delete mpLayout; - mpLayout = NULL; - } - if(NULL != mpContainer){ - delete mpContainer; - mpContainer = NULL; - } + DELETEPTR(mpEmptyLabel); + DELETEPTR(mpLayout); + DELETEPTR(mpContainer); } void UBWidgetList::addWidget(QWidget *widget) { - if(NULL != mpLayout){ + if(NULL != mpLayout && NULL != widget){ + widget->setParent(mpContainer); mpEmptyLabel->setVisible(false); mWidgetInfo[widget] = widget->size(); - qDebug() << __FUNCTION__ << "widget->size () " << widget->size(); updateView(size()); mpLayout->addWidget(widget); + + // This call is used only to refresh the size of the widgets + updateSizes(); } } @@ -78,7 +73,6 @@ int UBWidgetList::scaleWidgets(QSize pSize) { // to remove the first spacing that shouldn't be there. int result = -mListElementsSpacing; - int count = 0; foreach(QWidget* eachWidget, mWidgetInfo.keys()){ qreal scaleFactor = 0; int newWidgetWidth = pSize.width(); @@ -87,21 +81,12 @@ int UBWidgetList::scaleWidgets(QSize pSize) scaleFactor = (float)mWidgetInfo[eachWidget].width() / (float)pSize.width(); newWidgetHeight = mWidgetInfo[eachWidget].height()/scaleFactor; result += newWidgetHeight; - eachWidget->setMinimumHeight(newWidgetHeight); } else{ scaleFactor = (float)mWidgetInfo[eachWidget].height() / (float)pSize.height(); newWidgetWidth = mWidgetInfo[eachWidget].width()/scaleFactor; result += newWidgetWidth; } -#ifndef Q_WS_WIN - qDebug() << __PRETTY_FUNCTION__ << "widget " << &eachWidget; - qDebug() << __PRETTY_FUNCTION__ << "count " << count++; - qDebug() << __PRETTY_FUNCTION__ << "widget orignal size " << mWidgetInfo[eachWidget]; - qDebug() << __PRETTY_FUNCTION__ << "containes size " << pSize; - qDebug() << __PRETTY_FUNCTION__ << "scale factor " << scaleFactor; - qDebug() << __PRETTY_FUNCTION__ << "new height " << result; -#endif //Adding a vertical/horizontal space between each element of the list result += mListElementsSpacing; } @@ -132,11 +117,42 @@ void UBWidgetList::updateView(QSize pSize) void UBWidgetList::resizeEvent(QResizeEvent *ev) { + Q_UNUSED(ev); mpEmptyLabel->setGeometry((width() - mpEmptyLabel->width()) / 2, (height() - mpEmptyLabel->height()) /2, mpEmptyLabel->width(), mpEmptyLabel->height()); updateView(size()); + updateSizes(); +} + +void UBWidgetList::updateSizes() +{ + // Resize all the widgets + foreach(QWidget* eachWidget, mWidgetInfo.keys()){ + if(NULL != eachWidget){ + QSize originalSize = mWidgetInfo[eachWidget]; + int currentWidth = mpContainer->width(); + int currentHeight = mpContainer->height(); + if(eWidgetListOrientation_Vertical == mOrientation){ + if(verticalScrollBar()->isVisible()){ + currentWidth -= verticalScrollBar()->width(); + eachWidget->setStyleSheet(QString("margin-right:%0;").arg(verticalScrollBar()->width())); + } + float scaleFactor = (float)currentWidth/(float)originalSize.width(); + currentHeight = originalSize.height()*scaleFactor; + }else{ + if(horizontalScrollBar()->isVisible()){ + currentHeight -= horizontalScrollBar()->height(); + eachWidget->setStyleSheet(QString("padding-bottom:%0;").arg(horizontalScrollBar()->height())); + } + float scaleFactor = (float)currentHeight/(float)originalSize.height(); + currentWidth = originalSize.width()*scaleFactor; + } + + eachWidget->resize(currentWidth, currentHeight); + } + } } void UBWidgetList::setMargin(int margin) diff --git a/src/customWidgets/UBWidgetList.h b/src/customWidgets/UBWidgetList.h index 6cdfef66..fc7d9627 100644 --- a/src/customWidgets/UBWidgetList.h +++ b/src/customWidgets/UBWidgetList.h @@ -3,13 +3,15 @@ #include #include -#include +#include #include #include #include #include #include +#include "interfaces/IResizeable.h" + typedef enum{ eWidgetListOrientation_Vertical, eWidgetListOrientation_Horizontal @@ -39,7 +41,8 @@ private: int scaleWidgets(QSize pSize); void scaleContainer(QSize pSize, int updateValue); void updateView(QSize pSize); - QLayout* mpLayout; + void updateSizes(); + QBoxLayout* mpLayout; QWidget* mpContainer; eWidgetListOrientation mOrientation; int mMargin; diff --git a/src/customWidgets/customWidgets.pri b/src/customWidgets/customWidgets.pri index 321f3d45..e46249f5 100644 --- a/src/customWidgets/customWidgets.pri +++ b/src/customWidgets/customWidgets.pri @@ -1,9 +1,9 @@ HEADERS += src/customWidgets/UBWidgetList.h \ - src/customWidgets/UBDraggableLabel.h + src/customWidgets/UBDraggableLabel.h \ + src/customWidgets/UBMediaWidget.h \ + src/customWidgets/UBGlobals.h SOURCES += src/customWidgets/UBWidgetList.cpp \ - src/customWidgets/UBDraggableLabel.cpp - - - + src/customWidgets/UBDraggableLabel.cpp \ + src/customWidgets/UBMediaWidget.cpp diff --git a/src/gui/UBMediaPlayer.cpp b/src/gui/UBMediaPlayer.cpp index 8bb60905..cae48d13 100644 --- a/src/gui/UBMediaPlayer.cpp +++ b/src/gui/UBMediaPlayer.cpp @@ -346,6 +346,18 @@ void UBMediaPlayer::hasVideoChanged(bool bHasVideo) m_videoWindow.setVisible(bHasVideo); } +void UBMediaPlayer::resizeEvent(QResizeEvent* pEvent) +{ +// int origWidth = m_videoWindow.width(); +// int origHeight = m_videoWindow.height(); + +// float scaleFactor = (float)origWidth / (float)width(); +// int newWidth = width(); +// int newHeigth = origHeight/scaleFactor; + +// m_videoWindow.resize(newWidth, newHeigth); +} + //************************************************************************* UBDraggableMediaPlayer::UBDraggableMediaPlayer():UBMediaPlayer() { diff --git a/src/gui/UBMediaPlayer.h b/src/gui/UBMediaPlayer.h index 86534802..9e5e0e1a 100644 --- a/src/gui/UBMediaPlayer.h +++ b/src/gui/UBMediaPlayer.h @@ -62,6 +62,9 @@ public slots: void finished(); void playPause(); +protected: + void resizeEvent(QResizeEvent* pEvent); + private slots: void stateChanged(Phonon::State newstate, Phonon::State oldstate); void bufferStatus(int percent); diff --git a/src/gui/UBTeacherBarWidget.cpp b/src/gui/UBTeacherBarWidget.cpp index 3b311908..87c4b4b5 100644 --- a/src/gui/UBTeacherBarWidget.cpp +++ b/src/gui/UBTeacherBarWidget.cpp @@ -16,6 +16,7 @@ #include "frameworks/UBFileSystemUtils.h" #include "customWidgets/UBDraggableLabel.h" +#include "customWidgets/UBMediaWidget.h" #include "core/memcheck.h" @@ -27,7 +28,6 @@ UBTeacherBarWidget::UBTeacherBarWidget(QWidget *parent, const char *name):UBDock , mpDurationLabel(NULL) , mpTitle(NULL) , mpMediaLabel(NULL) - , mpDropMediaZone(NULL) , mpContainer(NULL) , mpContainerLayout(NULL) , mpDuration1(NULL) @@ -46,6 +46,7 @@ UBTeacherBarWidget::UBTeacherBarWidget(QWidget *parent, const char *name):UBDock , mpLinkLayout(NULL) , mpStackWidget(NULL) , mpPreview(NULL) + , mpMediaContainer(NULL) { setObjectName(name); mName = "TeacherBarWidget"; @@ -121,8 +122,8 @@ UBTeacherBarWidget::UBTeacherBarWidget(QWidget *parent, const char *name):UBDock // Media mpMediaLabel = new QLabel(tr("Media"), mpContainer); mpLayout->addWidget(mpMediaLabel, 0); - mpDropMediaZone = new UBTeacherBarDropMediaZone(mpContainer); - mpLayout->addWidget(mpDropMediaZone, 1); + mpMediaContainer = new UBTBMediaContainer(this); + mpLayout->addWidget(mpMediaContainer, 1); // Links mpLinkLabel = new QLabel(tr("Links"), mpContainer); @@ -151,10 +152,15 @@ UBTeacherBarWidget::UBTeacherBarWidget(QWidget *parent, const char *name):UBDock connect(mpActionButton, SIGNAL(clicked()), this, SLOT(onActionButton())); connect(mpLinkButton, SIGNAL(clicked()), this, SLOT(onLinkButton())); connect(mpPreview, SIGNAL(showEditMode()), this, SLOT(onShowEditMode())); + connect(mpMediaContainer, SIGNAL(mediaDropped(QString)), this, SLOT(onMediaDropped(QString))); } UBTeacherBarWidget::~UBTeacherBarWidget() { + if(NULL != mpMediaContainer){ + delete mpMediaContainer; + mpMediaContainer = NULL; + } if(NULL != mpComments){ delete mpComments; mpComments = NULL; @@ -179,10 +185,6 @@ UBTeacherBarWidget::~UBTeacherBarWidget() delete mpLinkLayout; mpLinkLayout = NULL; } - if(NULL != mpDropMediaZone){ - delete mpDropMediaZone; - mpDropMediaZone = NULL; - } if(NULL != mpMediaLabel){ delete mpMediaLabel; mpMediaLabel = NULL; @@ -291,8 +293,9 @@ void UBTeacherBarWidget::saveContent() infos.actions << QString("%0;%1").arg(mActionList.at(i)->comboValue()).arg(mActionList.at(i)->text()); } // Media - // TODO : Get the url of the dropped medias and store them in infos.medias - infos.medias = mpDropMediaZone->mediaList(); + foreach(QString media, mpMediaContainer->mediaUrls()){ + infos.medias << media; + } // Links for(int j=0; jreloadMedia(nextInfos.medias); + foreach(QString url, nextInfos.medias){ + if("" != url){ + QWidget* pMedia = mpMediaContainer->generateMediaWidget(url); + if(NULL != pMedia){ + mMediaList << pMedia; + mpMediaContainer->addWidget(pMedia); + } + } + } // Links for(int j=0; jtext() == "" && mpLinks->empty() && mpActions->empty() && - mpDropMediaZone->empty() && + mpMediaContainer->empty() && mpComments->document()->toPlainText() == ""; } @@ -436,11 +447,19 @@ void UBTeacherBarWidget::onLinkButton() void UBTeacherBarWidget::clearWidgetLists() { - mpDropMediaZone->cleanMedias(); + if(NULL != mpMediaContainer){ + for(int i=0; iremoveWidget(mMediaList.at(i)); + delete mMediaList.at(i); + } + mMediaList.clear(); + mpMediaContainer->cleanMedias(); + } if(NULL != mpActions){ for(int i=0; iremoveWidget(mActionList.at(i)); + delete mActionList.at(i); } mActionList.clear(); } @@ -448,6 +467,7 @@ void UBTeacherBarWidget::clearWidgetLists() if(NULL != mpLinks){ for(int i=0; iremoveWidget(mUrlList.at(i)); + delete mUrlList.at(i); } mUrlList.clear(); } @@ -458,6 +478,17 @@ void UBTeacherBarWidget::onShowEditMode() mpStackWidget->setCurrentWidget(mpContainer); } +void UBTeacherBarWidget::onMediaDropped(const QString &url) +{ + if("" != url){ + QWidget* pMedia = mpMediaContainer->generateMediaWidget(url); + if(NULL != pMedia){ + mMediaList << pMedia; + mpMediaContainer->addWidget(pMedia); + } + } +} + // --------------------------------------------------------------------------------------------- UBTeacherStudentAction::UBTeacherStudentAction(QWidget *parent, const char *name):QWidget(parent) , mpText(NULL) @@ -1071,3 +1102,130 @@ void UBActionPreview::setContent(const QString &content) mpContent->setText(content); } } + +// ------------------------------------------------------------------------------------------------------------------------------------ +UBTBMediaContainer::UBTBMediaContainer(QWidget *parent, const char *name) : UBWidgetList(parent) +{ + setObjectName(name); + setAcceptDrops(true); +} + +UBTBMediaContainer::~UBTBMediaContainer() +{ + +} + +void UBTBMediaContainer::dropEvent(QDropEvent* pEvent) +{ + QPixmap pixFromDropEvent; + QString mimeType; + QString resourcePath; + if(pEvent->mimeData()->hasText()){ + qDebug() << "text dropped"; + resourcePath = pEvent->mimeData()->text(); + } + else if(pEvent->mimeData()->hasUrls()){ + qDebug() << "url dropped"; + resourcePath = pEvent->mimeData()->urls().at(0).toLocalFile(); + } + else if(pEvent->mimeData()->hasImage()){ + qDebug() << "image dropped"; + pixFromDropEvent.loadFromData(pEvent->mimeData()->imageData().toByteArray()); + if(!pixFromDropEvent.isNull()) + mimeType = "image"; + } + + if (mimeType.isEmpty() && resourcePath.isEmpty()){ + pEvent->acceptProposedAction(); + return; + } + if(!resourcePath.isEmpty()){ + qDebug() << "emitting 'mediaDropped'"; + emit mediaDropped(resourcePath); + pEvent->acceptProposedAction(); + } +} + +void UBTBMediaContainer::dragEnterEvent(QDragEnterEvent* pEvent) +{ + pEvent->acceptProposedAction(); +} + +void UBTBMediaContainer::dragMoveEvent(QDragMoveEvent* pEvent) +{ + pEvent->acceptProposedAction(); +} + +void UBTBMediaContainer::dragLeaveEvent(QDragLeaveEvent* pEvent) +{ + pEvent->accept(); +} + +void UBTBMediaContainer::addMedia(const QString& mediaPath) +{ + if(!mediaPath.isEmpty()) + mMediaList.append(mediaPath); + else + qWarning() << __FUNCTION__ << "empty path"; + + QString mimeType = UBFileSystemUtils::mimeTypeFromFileName(mediaPath); + if(mimeType.contains("image")){ + QPixmap pix = QPixmap(mediaPath); + QLabel* label = new QLabel(); + label->setPixmap(pix); + label->setScaledContents(true); + addWidget(label); + } + else if(mimeType.contains("video") || mimeType.contains("audio")){ + UBMediaPlayer* mediaPlayer = new UBMediaPlayer(); + mediaPlayer->setFile(mediaPath); + addWidget(mediaPlayer); + } + else{ + qWarning() << "pMediaPath" << mediaPath; + qWarning() << "bad idea to come here"; + } +} + +QStringList UBTBMediaContainer::mediaUrls() +{ + return mMediaList; +} + +void UBTBMediaContainer::cleanMedias() +{ + mMediaList.clear(); +} + +QWidget* UBTBMediaContainer::generateMediaWidget(const QString& url) +{ + QWidget* pW = NULL; + + if(!url.isEmpty()) + mMediaList.append(url); + else + qWarning() << __FUNCTION__ << "empty path"; + + QString mimeType = UBFileSystemUtils::mimeTypeFromFileName(url); + if(mimeType.contains("image")){ + QPixmap pix = QPixmap(url); + QLabel* label = new QLabel(); + pix.scaledToWidth(label->width()); + label->resize(pix.width(), pix.height()); + label->setPixmap(pix); + label->setScaledContents(true); + pW = label; + } + else if(mimeType.contains("video") || mimeType.contains("audio")){ + UBMediaPlayer* mediaPlayer = new UBMediaPlayer(); + //UBMediaWidget* mediaPlayer = new UBMediaWidget(mimeType.contains("audio")?eMediaType_Audio:eMediaType_Video); + mediaPlayer->setFile(url); + pW = mediaPlayer; + } + else{ + qWarning() << "pMediaPath" << url; + qWarning() << "bad idea to come here"; + } + + return pW; +} diff --git a/src/gui/UBTeacherBarWidget.h b/src/gui/UBTeacherBarWidget.h index 3916d528..e23ec228 100644 --- a/src/gui/UBTeacherBarWidget.h +++ b/src/gui/UBTeacherBarWidget.h @@ -18,6 +18,7 @@ class UBMediaPlayer; #include "UBDockPaletteWidget.h" #include "customWidgets/UBWidgetList.h" +#include "interfaces/IDropable.h" #define LABEL_MINWIDHT 80 @@ -174,6 +175,33 @@ private: UBActionPreview* mpTmpAction; }; + +class UBTBMediaContainer : public UBWidgetList + , public IDropable +{ + Q_OBJECT +public: + UBTBMediaContainer(QWidget* parent=0, const char* name="UBTBMediaContainer"); + ~UBTBMediaContainer(); + QStringList mediaUrls(); + QWidget* generateMediaWidget(const QString& url); + void cleanMedias(); + +signals: + void mediaDropped(const QString& url); + +protected: + void dropEvent(QDropEvent* pEvent); + void dragEnterEvent(QDragEnterEvent* pEvent); + void dragMoveEvent(QDragMoveEvent* pEvent); + void dragLeaveEvent(QDragLeaveEvent* pEvent); + +private: + void addMedia(const QString& mediaPath); + + QStringList mMediaList; +}; + class UBTeacherBarWidget : public UBDockPaletteWidget { Q_OBJECT @@ -189,6 +217,7 @@ private slots: void onActionButton(); void onLinkButton(); void onShowEditMode(); + void onMediaDropped(const QString& url); private: void clearWidgetLists(); @@ -200,7 +229,6 @@ private: QLabel* mpDurationLabel; QLineEdit* mpTitle; QLabel* mpMediaLabel; - UBTeacherBarDropMediaZone* mpDropMediaZone; QWidget* mpContainer; QVBoxLayout* mpContainerLayout; QCheckBox* mpDuration1; @@ -222,6 +250,9 @@ private: QVector mActionList; QVector mUrlList; + QVector mMediaList; + + UBTBMediaContainer* mpMediaContainer; }; #endif // UBTEACHERBARWIDGET_H diff --git a/src/interfaces/IDropable.h b/src/interfaces/IDropable.h new file mode 100644 index 00000000..a75f4f16 --- /dev/null +++ b/src/interfaces/IDropable.h @@ -0,0 +1,21 @@ +#ifndef IDROPABLE_H +#define IDROPABLE_H + +#include +#include +#include +#include + +class IDropable +{ +public: + virtual ~IDropable(){} + +protected: + virtual void dropEvent(QDropEvent* pEvent) = 0; + virtual void dragEnterEvent(QDragEnterEvent* pEvent) = 0; + virtual void dragMoveEvent(QDragMoveEvent* pEvent) = 0; + virtual void dragLeaveEvent(QDragLeaveEvent* pEvent) = 0; +}; + +#endif // IDROPABLE_H diff --git a/src/interfaces/IResizeable.h b/src/interfaces/IResizeable.h new file mode 100644 index 00000000..b84ac8e5 --- /dev/null +++ b/src/interfaces/IResizeable.h @@ -0,0 +1,15 @@ +#ifndef IRESIZEABLE_H +#define IRESIZEABLE_H + +#include + +class IResizeable +{ +public: + ~IResizeable(); + +protected: + virtual void resizeEvent(QResizeEvent* pEvent) = 0; +}; + +#endif // IRESIZEABLE_H diff --git a/src/interfaces/interfaces.pri b/src/interfaces/interfaces.pri new file mode 100644 index 00000000..55098bf3 --- /dev/null +++ b/src/interfaces/interfaces.pri @@ -0,0 +1,3 @@ +HEADERS += src/interfaces/IDropable.h \ + src/interfaces/IDropable.h \ + src/interfaces/IResizeable.h From 432af59ca3fa2e317aa0fcc99a93a33bbe4dbe22 Mon Sep 17 00:00:00 2001 From: shibakaneki Date: Thu, 12 Jan 2012 15:08:29 +0100 Subject: [PATCH 57/84] resolved a conflict --- src/customWidgets/UBWidgetList.h | 4 ++-- src/gui/UBTeacherBarWidget.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/customWidgets/UBWidgetList.h b/src/customWidgets/UBWidgetList.h index 50823b08..865386ad 100644 --- a/src/customWidgets/UBWidgetList.h +++ b/src/customWidgets/UBWidgetList.h @@ -31,7 +31,7 @@ class UBWidgetList : public QScrollArea public: UBWidgetList(QWidget* parent=0, eWidgetListOrientation orientation = eWidgetListOrientation_Vertical, const char* name = "UBWidgetList"); ~UBWidgetList(); - void addWidget(QWidget* widget, bool isResizable = true); + void addWidget(QWidget* widget); void removeWidget(QWidget* widget); void setMargin(int margin); void setEmptyText(const QString& text); @@ -53,7 +53,7 @@ private: eWidgetListOrientation mOrientation; int mMargin; int mListElementsSpacing; - QMap mWidgetInfo; + QMap mWidgetInfo; QLabel* mpEmptyLabel; }; diff --git a/src/gui/UBTeacherBarWidget.cpp b/src/gui/UBTeacherBarWidget.cpp index 6d75471a..a718a40a 100644 --- a/src/gui/UBTeacherBarWidget.cpp +++ b/src/gui/UBTeacherBarWidget.cpp @@ -1031,7 +1031,7 @@ void UBTeacherBarPreviewMedia::cleanMedia() void UBTeacherBarPreviewMedia::loadWidgets(QList pWidgetsList, bool isResizable) { foreach(QWidget*eachWidget, pWidgetsList){ - mWidget->addWidget(eachWidget,isResizable); + mWidget->addWidget(eachWidget); mWidgetList[eachWidget]="DRAG UNAVAILABLE"; } } From f8cbf42134a6ccd58f3d967359f9557cb3b4f9ed Mon Sep 17 00:00:00 2001 From: Claudio Valerio Date: Thu, 12 Jan 2012 16:20:09 +0100 Subject: [PATCH 58/84] fixed horizontal widgetlist --- src/customWidgets/UBWidgetList.cpp | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/customWidgets/UBWidgetList.cpp b/src/customWidgets/UBWidgetList.cpp index 13dca3a9..0ba01bb0 100644 --- a/src/customWidgets/UBWidgetList.cpp +++ b/src/customWidgets/UBWidgetList.cpp @@ -81,18 +81,15 @@ int UBWidgetList::scaleWidgets(QSize pSize) scaleFactor = (float)mWidgetInfo[eachWidget].width() / (float)pSize.width(); newWidgetHeight = mWidgetInfo[eachWidget].height()/scaleFactor; result += newWidgetHeight; + eachWidget->setMinimumHeight(newWidgetHeight- 1); + eachWidget->setMaximumHeight(newWidgetHeight); } else{ - if(eWidgetListOrientation_Vertical == mOrientation){ - result += mWidgetInfo[eachWidget].height(); - eachWidget->setMinimumHeight(mWidgetInfo[eachWidget].height()); - eachWidget->setMaximumHeight(mWidgetInfo[eachWidget].height() + 1); - } - else{ - result += mWidgetInfo[eachWidget].width(); - eachWidget->setMinimumWidth(mWidgetInfo[eachWidget].width()); - eachWidget->setMaximumWidth(mWidgetInfo[eachWidget].width() + 1); - } + scaleFactor = (float)mWidgetInfo[eachWidget].height() / (float)pSize.height(); + newWidgetWidth = mWidgetInfo[eachWidget].width()/scaleFactor; + result += newWidgetWidth; + eachWidget->setMinimumWidth(newWidgetWidth - 1); + eachWidget->setMaximumWidth(newWidgetWidth); } //Adding a vertical/horizontal space between each element of the list result += mListElementsSpacing; From ff7fe04fe19e31f43e8ae4b24b88bd0092f23c62 Mon Sep 17 00:00:00 2001 From: shibakaneki Date: Fri, 13 Jan 2012 09:50:48 +0100 Subject: [PATCH 59/84] Updated the video widget rendering --- resources/style.qss | 2 -- src/customWidgets/UBMediaWidget.cpp | 13 +++++++------ src/gui/UBTeacherBarWidget.cpp | 4 ++-- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/resources/style.qss b/resources/style.qss index a3fec87d..d80964a1 100644 --- a/resources/style.qss +++ b/resources/style.qss @@ -18,8 +18,6 @@ QWidget#UBMediaVideoContainer background: #000000; border-radius: 10px; border: 2px solid #999999; - margin: 0px 0px 0px 0px; - padding: 0px 0px 0px 0px; } QWidget#UBTeacherBarPreviewWidget diff --git a/src/customWidgets/UBMediaWidget.cpp b/src/customWidgets/UBMediaWidget.cpp index eabe51bd..24be6760 100644 --- a/src/customWidgets/UBMediaWidget.cpp +++ b/src/customWidgets/UBMediaWidget.cpp @@ -35,6 +35,7 @@ UBMediaWidget::UBMediaWidget(eMediaType type, QWidget *parent, const char *name) mSeekerLayout.addWidget(mpPlayStopButton, 0); mSeekerLayout.addWidget(mpPauseButton, 0); mSeekerLayout.addWidget(mpSlider, 1); + mSeekerLayout.setContentsMargins(0, 0, 0, 0); connect(mpPlayStopButton, SIGNAL(clicked()), this, SLOT(onPlayStopClicked())); connect(mpPauseButton, SIGNAL(clicked()), this, SLOT(onPauseClicked())); @@ -74,9 +75,9 @@ void UBMediaWidget::createMediaPlayer() { if(eMediaType_Video == mType){ mpVideoWidget = new Phonon::VideoWidget(this); - mpVideoWidget->setStyleSheet(QString("margin: 0px 0px 0px 0px; padding: 0px 0px 0px 0px;")); mpVideoContainer = new QWidget(this); mpVideoContainer->setObjectName("UBMediaVideoContainer"); + mVideoLayout.setContentsMargins(10, 10, 25, 10); mpVideoContainer->setLayout(&mVideoLayout); mVideoLayout.addWidget(mpVideoWidget, 1); Phonon::createPath(mpMediaObject, mpVideoWidget); @@ -93,13 +94,13 @@ void UBMediaWidget::createMediaPlayer() void UBMediaWidget::adaptSizeToVideo() { - if(NULL != mpVideoWidget){ - int origW = mpVideoWidget->width(); - int origH = mpVideoWidget->height(); + if(NULL != mpVideoContainer){ + int origW = mpVideoContainer->width(); + int origH = mpVideoContainer->height(); int newW = width(); float scaleFactor = (float)origW/(float)newW; int newH = origH/scaleFactor; - resize(width(), height() + newH); + resize(newW, height() + newH); } } @@ -185,7 +186,7 @@ UBMediaButton::UBMediaButton(QWidget *parent, const char *name):QLabel(parent) { setObjectName(name); resize(UBMEDIABUTTON_SIZE, UBMEDIABUTTON_SIZE); - setStyleSheet(QString("padding:0px 0px 0px 0px;")); + setStyleSheet(QString("padding:0px 0px 0px 0px; margin:0px 0px 0px 0px;")); } UBMediaButton::~UBMediaButton() diff --git a/src/gui/UBTeacherBarWidget.cpp b/src/gui/UBTeacherBarWidget.cpp index a718a40a..0f439cf7 100644 --- a/src/gui/UBTeacherBarWidget.cpp +++ b/src/gui/UBTeacherBarWidget.cpp @@ -1235,8 +1235,8 @@ QWidget* UBTBMediaContainer::generateMediaWidget(const QString& url) pW = label; } else if(mimeType.contains("video") || mimeType.contains("audio")){ - UBMediaPlayer* mediaPlayer = new UBMediaPlayer(); - //UBMediaWidget* mediaPlayer = new UBMediaWidget(mimeType.contains("audio")?eMediaType_Audio:eMediaType_Video); + //UBMediaPlayer* mediaPlayer = new UBMediaPlayer(); + UBMediaWidget* mediaPlayer = new UBMediaWidget(mimeType.contains("audio")?eMediaType_Audio:eMediaType_Video); mediaPlayer->setFile(url); pW = mediaPlayer; } From 78562cd4215ecaf1addba557c7f6a3854aaa7b78 Mon Sep 17 00:00:00 2001 From: shibakaneki Date: Fri, 13 Jan 2012 09:57:39 +0100 Subject: [PATCH 60/84] hiding not finished implementation for backup reasons --- src/gui/UBTeacherBarWidget.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/UBTeacherBarWidget.cpp b/src/gui/UBTeacherBarWidget.cpp index 0f439cf7..a718a40a 100644 --- a/src/gui/UBTeacherBarWidget.cpp +++ b/src/gui/UBTeacherBarWidget.cpp @@ -1235,8 +1235,8 @@ QWidget* UBTBMediaContainer::generateMediaWidget(const QString& url) pW = label; } else if(mimeType.contains("video") || mimeType.contains("audio")){ - //UBMediaPlayer* mediaPlayer = new UBMediaPlayer(); - UBMediaWidget* mediaPlayer = new UBMediaWidget(mimeType.contains("audio")?eMediaType_Audio:eMediaType_Video); + UBMediaPlayer* mediaPlayer = new UBMediaPlayer(); + //UBMediaWidget* mediaPlayer = new UBMediaWidget(mimeType.contains("audio")?eMediaType_Audio:eMediaType_Video); mediaPlayer->setFile(url); pW = mediaPlayer; } From 4c4d569b35d0a8c0671c4858bd0d3fe1eb5e4d14 Mon Sep 17 00:00:00 2001 From: shibakaneki Date: Fri, 13 Jan 2012 11:09:14 +0100 Subject: [PATCH 61/84] Enabled UBMediaMidget --- src/customWidgets/UBMediaWidget.cpp | 1 - src/gui/UBTeacherBarWidget.cpp | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/customWidgets/UBMediaWidget.cpp b/src/customWidgets/UBMediaWidget.cpp index 24be6760..9dc0a8d0 100644 --- a/src/customWidgets/UBMediaWidget.cpp +++ b/src/customWidgets/UBMediaWidget.cpp @@ -49,7 +49,6 @@ UBMediaWidget::~UBMediaWidget() DELETEPTR(mpPlayStopButton); DELETEPTR(mpAudioOutput); DELETEPTR(mpVideoWidget); - DELETEPTR(mpVideoContainer); DELETEPTR(mpMediaObject); } diff --git a/src/gui/UBTeacherBarWidget.cpp b/src/gui/UBTeacherBarWidget.cpp index a718a40a..0f439cf7 100644 --- a/src/gui/UBTeacherBarWidget.cpp +++ b/src/gui/UBTeacherBarWidget.cpp @@ -1235,8 +1235,8 @@ QWidget* UBTBMediaContainer::generateMediaWidget(const QString& url) pW = label; } else if(mimeType.contains("video") || mimeType.contains("audio")){ - UBMediaPlayer* mediaPlayer = new UBMediaPlayer(); - //UBMediaWidget* mediaPlayer = new UBMediaWidget(mimeType.contains("audio")?eMediaType_Audio:eMediaType_Video); + //UBMediaPlayer* mediaPlayer = new UBMediaPlayer(); + UBMediaWidget* mediaPlayer = new UBMediaWidget(mimeType.contains("audio")?eMediaType_Audio:eMediaType_Video); mediaPlayer->setFile(url); pW = mediaPlayer; } From af1e875a7109b40cb2eda05eb28ed2a62a81530e Mon Sep 17 00:00:00 2001 From: shibakaneki Date: Fri, 13 Jan 2012 12:01:54 +0100 Subject: [PATCH 62/84] Modified the audio midget --- src/customWidgets/UBMediaWidget.cpp | 40 ++++++--- src/customWidgets/UBMediaWidget.h | 6 +- src/gui/UBTeacherBarWidget.cpp | 126 +--------------------------- src/gui/UBTeacherBarWidget.h | 31 ------- 4 files changed, 35 insertions(+), 168 deletions(-) diff --git a/src/customWidgets/UBMediaWidget.cpp b/src/customWidgets/UBMediaWidget.cpp index 9dc0a8d0..31523a90 100644 --- a/src/customWidgets/UBMediaWidget.cpp +++ b/src/customWidgets/UBMediaWidget.cpp @@ -12,7 +12,8 @@ UBMediaWidget::UBMediaWidget(eMediaType type, QWidget *parent, const char *name) , mAutoUpdate(false) , mGeneratingThumbnail(false) , mBorder(5) - , mpVideoContainer(NULL) + , mpMediaContainer(NULL) + , mpCover(NULL) { setObjectName(name); @@ -50,6 +51,7 @@ UBMediaWidget::~UBMediaWidget() DELETEPTR(mpAudioOutput); DELETEPTR(mpVideoWidget); DELETEPTR(mpMediaObject); + DELETEPTR(mpCover); } void UBMediaWidget::setFile(const QString &filePath) @@ -72,30 +74,41 @@ eMediaType UBMediaWidget::mediaType() void UBMediaWidget::createMediaPlayer() { + mpMediaContainer = new QWidget(this); + mpMediaContainer->setObjectName("UBMediaVideoContainer"); + mpMediaContainer->setLayout(&mMediaLayout); + if(eMediaType_Video == mType){ + mMediaLayout.setContentsMargins(10, 10, 25, 10); mpVideoWidget = new Phonon::VideoWidget(this); - mpVideoContainer = new QWidget(this); - mpVideoContainer->setObjectName("UBMediaVideoContainer"); - mVideoLayout.setContentsMargins(10, 10, 25, 10); - mpVideoContainer->setLayout(&mVideoLayout); - mVideoLayout.addWidget(mpVideoWidget, 1); + mMediaLayout.addStretch(1); + mMediaLayout.addWidget(mpVideoWidget, 0); + mMediaLayout.addStretch(1); Phonon::createPath(mpMediaObject, mpVideoWidget); adaptSizeToVideo(); - mLayout.addWidget(mpVideoContainer, 1); mpAudioOutput = new Phonon::AudioOutput(Phonon::VideoCategory, this); Phonon::createPath(mpMediaObject, mpAudioOutput); }else if(eMediaType_Audio == mType){ + mMediaLayout.setContentsMargins(10, 10, 10, 10); + mpCover = new QLabel(mpMediaContainer); + mpMediaContainer->setStyleSheet(QString("background: none;")); + setAudioCover(":images/libpalette/soundIcon.svg"); + mpCover->setScaledContents(true); + mMediaLayout.addStretch(1); + mMediaLayout.addWidget(mpCover, 0); + mMediaLayout.addStretch(1); mpAudioOutput = new Phonon::AudioOutput(Phonon::MusicCategory, this); Phonon::createPath(mpMediaObject, mpAudioOutput); } + mLayout.addWidget(mpMediaContainer, 1); mLayout.addLayout(&mSeekerLayout, 0); } void UBMediaWidget::adaptSizeToVideo() { - if(NULL != mpVideoContainer){ - int origW = mpVideoContainer->width(); - int origH = mpVideoContainer->height(); + if(NULL != mpMediaContainer){ + int origW = mpMediaContainer->width(); + int origH = mpMediaContainer->height(); int newW = width(); float scaleFactor = (float)origW/(float)newW; int newH = origH/scaleFactor; @@ -179,6 +192,13 @@ void UBMediaWidget::resizeEvent(QResizeEvent* ev) Q_UNUSED(ev); } +void UBMediaWidget::setAudioCover(const QString &coverPath) +{ + if(NULL != mpCover){ + mpCover->setPixmap(QPixmap(coverPath)); + } +} + // ----------------------------------------------------------------------------------------------------------- UBMediaButton::UBMediaButton(QWidget *parent, const char *name):QLabel(parent) , mPressed(false) diff --git a/src/customWidgets/UBMediaWidget.h b/src/customWidgets/UBMediaWidget.h index c835ab91..3f4be679 100644 --- a/src/customWidgets/UBMediaWidget.h +++ b/src/customWidgets/UBMediaWidget.h @@ -49,6 +49,7 @@ public: void setFile(const QString& filePath); eMediaType mediaType(); int border(); + void setAudioCover(const QString& coverPath); protected: void resizeEvent(QResizeEvent* ev); @@ -78,8 +79,9 @@ private: bool mAutoUpdate; bool mGeneratingThumbnail; int mBorder; - QWidget* mpVideoContainer; - QVBoxLayout mVideoLayout; + QWidget* mpMediaContainer; + QHBoxLayout mMediaLayout; + QLabel* mpCover; }; #endif // UBMEDIAWIDGET_H diff --git a/src/gui/UBTeacherBarWidget.cpp b/src/gui/UBTeacherBarWidget.cpp index 0f439cf7..c3e31d21 100644 --- a/src/gui/UBTeacherBarWidget.cpp +++ b/src/gui/UBTeacherBarWidget.cpp @@ -123,6 +123,7 @@ UBTeacherBarWidget::UBTeacherBarWidget(QWidget *parent, const char *name):UBDock mpMediaLabel = new QLabel(tr("Medias"), mpContainer); mpLayout->addWidget(mpMediaLabel, 0); mpMediaContainer = new UBTBMediaContainer(this); + mpMediaContainer->setEmptyText(tr("Drop media here")); mpLayout->addWidget(mpMediaContainer, 1); // Links @@ -587,128 +588,6 @@ void UBTeacherStudentAction::setText(const QString& text) } } -// --------------------------------------------------------------------------------------------- -UBTeacherBarDropMediaZone::UBTeacherBarDropMediaZone(QWidget *parent, const char *name):QWidget(parent) - -{ - setObjectName(name); - setAcceptDrops(true); - mWidget = new UBWidgetList(parent); - mWidget->setEmptyText(tr("Drag media here ...")); - mLayout.addWidget(mWidget); - setLayout(&mLayout); - // The next line is disgusting. This is a quickfix that must be reworked later - setContentsMargins(-9, -9, -9, -9); -} - -UBTeacherBarDropMediaZone::~UBTeacherBarDropMediaZone() -{ - cleanMedias(); - if(mWidget){ - delete mWidget; - mWidget = NULL; - } -} - -void UBTeacherBarDropMediaZone::cleanMedias() -{ - foreach(QWidget* eachWidget,mWidgetList){ - mWidget->removeWidget(eachWidget); - delete eachWidget; - } - - mWidgetList.clear(); - - mMediaList.clear(); -} - -bool UBTeacherBarDropMediaZone::empty() -{ - return mWidget->empty(); -} - -void UBTeacherBarDropMediaZone::dragEnterEvent(QDragEnterEvent *pEvent) -{ - pEvent->acceptProposedAction(); -} - -void UBTeacherBarDropMediaZone::dragLeaveEvent(QDragLeaveEvent *pEvent) -{ - pEvent->accept(); -} - - -void UBTeacherBarDropMediaZone::addMedia(QString pMediaPath) -{ - if(!pMediaPath.isEmpty()) - mMediaList.append(pMediaPath); - else - qWarning() << __FUNCTION__ << "empty path"; - - QString mimeType = UBFileSystemUtils::mimeTypeFromFileName(pMediaPath); - if(mimeType.contains("image")){ - QPixmap pix = QPixmap(pMediaPath); - QLabel* label = new QLabel(); - label->setPixmap(pix); - label->setScaledContents(true); - mWidget->addWidget(label); - mWidgetList << label; - } - else if(mimeType.contains("video") || mimeType.contains("audio")){ - UBMediaPlayer* mediaPlayer = new UBMediaPlayer(); - mediaPlayer->setFile(pMediaPath); - mWidget->addWidget(mediaPlayer); - mWidgetList << mediaPlayer; - } - else{ - qWarning() << "pMediaPath" << pMediaPath; - qWarning() << "bad idea to come here"; - } - -} - -void UBTeacherBarDropMediaZone::reloadMedia(QStringList pList) -{ - cleanMedias(); - foreach(QString eachString, pList){ - addMedia(eachString); - } -} - -void UBTeacherBarDropMediaZone::dropEvent(QDropEvent *pEvent) -{ - QPixmap pixFromDropEvent; - QString mimeType; - QString resourcePath; - if(pEvent->mimeData()->hasText()){ - qDebug() << "pEvent->mimeData()->hasText()" << pEvent->mimeData()->text(); - resourcePath = pEvent->mimeData()->text(); - } - else if(pEvent->mimeData()->hasUrls()){ - qDebug() << "pEvent->mimeData()->hasUrls()" << pEvent->mimeData()->urls().at(0); - resourcePath = pEvent->mimeData()->urls().at(0).toLocalFile(); - } - else if(pEvent->mimeData()->hasImage()){ - qDebug() << "pEvent->mimeData()->hasImage()"; - pixFromDropEvent.loadFromData(pEvent->mimeData()->imageData().toByteArray()); - if(!pixFromDropEvent.isNull()) - mimeType = "image"; - } - - if (mimeType.isEmpty() && resourcePath.isEmpty()){ - pEvent->acceptProposedAction(); - return; - } - if(!resourcePath.isEmpty()) - addMedia(resourcePath); - pEvent->acceptProposedAction(); -} - -void UBTeacherBarDropMediaZone::dragMoveEvent(QDragMoveEvent *pEvent) -{ - pEvent->acceptProposedAction(); -} - // --------------------------------------------------------------------------------------------- UBUrlWidget::UBUrlWidget(QWidget *parent, const char *name):QWidget(parent) , mpLayout(NULL) @@ -997,9 +876,7 @@ UBTeacherBarPreviewMedia::UBTeacherBarPreviewMedia(QWidget* parent, const char* { setObjectName(name); mWidget = new UBWidgetList(parent); -// mWidget->setEmptyText(tr("No media found")); mLayout.addWidget(mWidget); -// mWidget->setStyleSheet(QString("background-color: red;")); setLayout(&mLayout); mWidgetList.clear(); } @@ -1235,7 +1112,6 @@ QWidget* UBTBMediaContainer::generateMediaWidget(const QString& url) pW = label; } else if(mimeType.contains("video") || mimeType.contains("audio")){ - //UBMediaPlayer* mediaPlayer = new UBMediaPlayer(); UBMediaWidget* mediaPlayer = new UBMediaWidget(mimeType.contains("audio")?eMediaType_Audio:eMediaType_Video); mediaPlayer->setFile(url); pW = mediaPlayer; diff --git a/src/gui/UBTeacherBarWidget.h b/src/gui/UBTeacherBarWidget.h index f4341a14..7bb80512 100644 --- a/src/gui/UBTeacherBarWidget.h +++ b/src/gui/UBTeacherBarWidget.h @@ -52,36 +52,6 @@ private: QComboBox* mpCombo; }; - -class UBTeacherBarDropMediaZone : public QWidget -{ - Q_OBJECT - -public: - UBTeacherBarDropMediaZone(QWidget* parent=0, const char* name="UBTeacherBarDropMediaZone"); - ~UBTeacherBarDropMediaZone(); - QStringList mediaList() {return mMediaList;} - void reloadMedia(QStringList pList); - void cleanMedias(); - bool empty(); - -private: - void addMedia(QString pMediaPath); - QStringList mMediaList; - QListmWidgetList; - UBWidgetList* mWidget; - QVBoxLayout mLayout; - - -protected: - void dragEnterEvent(QDragEnterEvent* pEvent); - void dropEvent(QDropEvent *pEvent); - void dragMoveEvent(QDragMoveEvent* pEvent); - void dragLeaveEvent(QDragLeaveEvent* pEvent); -}; - - - class UBTeacherBarPreviewMedia : public QWidget { Q_OBJECT @@ -176,7 +146,6 @@ private: UBActionPreview* mpTmpAction; }; - class UBTBMediaContainer : public UBWidgetList , public IDropable { From f5f1f835fdaa0f01846fdbe0dba99798e6139117 Mon Sep 17 00:00:00 2001 From: shibakaneki Date: Fri, 13 Jan 2012 12:38:30 +0100 Subject: [PATCH 63/84] Added some comments in the code --- src/customWidgets/UBMediaWidget.cpp | 88 +++++++++++++++++++++++++++++ src/customWidgets/UBMediaWidget.h | 34 +++++++++++ src/gui/UBTeacherBarWidget.cpp | 4 -- 3 files changed, 122 insertions(+), 4 deletions(-) diff --git a/src/customWidgets/UBMediaWidget.cpp b/src/customWidgets/UBMediaWidget.cpp index 31523a90..572db702 100644 --- a/src/customWidgets/UBMediaWidget.cpp +++ b/src/customWidgets/UBMediaWidget.cpp @@ -1,7 +1,27 @@ +/* + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ #include "core/UBApplication.h" #include "UBGlobals.h" #include "UBMediaWidget.h" +/** + * \brief Constructor + * @param type as the media type + * @param parent as the parent widget + * @param name as the object name + */ UBMediaWidget::UBMediaWidget(eMediaType type, QWidget *parent, const char *name):QWidget(parent) , mpMediaObject(NULL) , mpVideoWidget(NULL) @@ -43,6 +63,9 @@ UBMediaWidget::UBMediaWidget(eMediaType type, QWidget *parent, const char *name) connect(mpSlider, SIGNAL(valueChanged(int)), this, SLOT(onSliderChanged(int))); } +/** + * \brief Destructor + */ UBMediaWidget::~UBMediaWidget() { DELETEPTR(mpSlider); @@ -54,6 +77,10 @@ UBMediaWidget::~UBMediaWidget() DELETEPTR(mpCover); } +/** + * \brief Set the media file + * @param filePath as the media file path + */ void UBMediaWidget::setFile(const QString &filePath) { Q_ASSERT("" != filePath); @@ -67,11 +94,18 @@ void UBMediaWidget::setFile(const QString &filePath) createMediaPlayer(); } +/** + * \brief Get the media type + * @returns the media type + */ eMediaType UBMediaWidget::mediaType() { return mType; } +/** + * \brief Create the media player + */ void UBMediaWidget::createMediaPlayer() { mpMediaContainer = new QWidget(this); @@ -104,6 +138,9 @@ void UBMediaWidget::createMediaPlayer() mLayout.addLayout(&mSeekerLayout, 0); } +/** + * \brief Adapt the widget size to the video in order to keep the good aspect ratio + */ void UBMediaWidget::adaptSizeToVideo() { if(NULL != mpMediaContainer){ @@ -116,6 +153,11 @@ void UBMediaWidget::adaptSizeToVideo() } } +/** + * \brief Handle the media state change notification + * @param newState as the new state + * @param oldState as the old state + */ void UBMediaWidget::onStateChanged(Phonon::State newState, Phonon::State oldState) { if(!mGeneratingThumbnail){ @@ -142,11 +184,19 @@ void UBMediaWidget::onStateChanged(Phonon::State newState, Phonon::State oldStat } } +/** + * \brief Handles the total time change notification + * @param total as the new total time + */ void UBMediaWidget::onTotalTimeChanged(qint64 total) { mpSlider->setMaximum(total); } +/** + * \brief Handles the tick notification + * @param currentTime as the current time + */ void UBMediaWidget::onTick(qint64 currentTime) { mAutoUpdate = true; @@ -154,6 +204,10 @@ void UBMediaWidget::onTick(qint64 currentTime) mAutoUpdate = false; } +/** + * \brief Handles the seeker value change notification + * @param value as the new seeker value + */ void UBMediaWidget::onSliderChanged(int value) { if(!mAutoUpdate){ @@ -161,6 +215,9 @@ void UBMediaWidget::onSliderChanged(int value) } } +/** + * \brief Toggle Play-Stop + */ void UBMediaWidget::onPlayStopClicked() { switch(mpMediaObject->state()){ @@ -177,21 +234,36 @@ void UBMediaWidget::onPlayStopClicked() } } +/** + * \brief Pause the media + */ void UBMediaWidget::onPauseClicked() { mpMediaObject->pause(); } +/** + * Get the border + * @returns the actual border + */ int UBMediaWidget::border() { return mBorder; } +/** + * \brief Handles the resize event + * @param ev as the resize event + */ void UBMediaWidget::resizeEvent(QResizeEvent* ev) { Q_UNUSED(ev); } +/** + * \brief Set the audio cover + * @param coverPath as the cover image file path + */ void UBMediaWidget::setAudioCover(const QString &coverPath) { if(NULL != mpCover){ @@ -200,6 +272,11 @@ void UBMediaWidget::setAudioCover(const QString &coverPath) } // ----------------------------------------------------------------------------------------------------------- +/** + * \brief Constructor + * @param parent as the parent widget + * @param name as the object name + */ UBMediaButton::UBMediaButton(QWidget *parent, const char *name):QLabel(parent) , mPressed(false) { @@ -208,17 +285,28 @@ UBMediaButton::UBMediaButton(QWidget *parent, const char *name):QLabel(parent) setStyleSheet(QString("padding:0px 0px 0px 0px; margin:0px 0px 0px 0px;")); } +/** + * \brief Destructor + */ UBMediaButton::~UBMediaButton() { } +/** + * \brief Handles the mouse press notification + * @param ev as the mouse press event + */ void UBMediaButton::mousePressEvent(QMouseEvent* ev) { Q_UNUSED(ev); mPressed = true; } +/** + * \brief Handles the mouse release notification + * @param ev as the mouse release event + */ void UBMediaButton::mouseReleaseEvent(QMouseEvent* ev) { Q_UNUSED(ev); diff --git a/src/customWidgets/UBMediaWidget.h b/src/customWidgets/UBMediaWidget.h index 3f4be679..ba7d774b 100644 --- a/src/customWidgets/UBMediaWidget.h +++ b/src/customWidgets/UBMediaWidget.h @@ -1,3 +1,17 @@ +/* + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ #ifndef UBMEDIAWIDGET_H #define UBMEDIAWIDGET_H @@ -17,6 +31,9 @@ #define UBMEDIABUTTON_SIZE 32 #define TICK_INTERVAL 1000 +/** + * \brief The media type + */ typedef enum{ eMediaType_Video, eMediaType_Audio @@ -37,6 +54,7 @@ protected: void mouseReleaseEvent(QMouseEvent* ev); private: + /** And indicator of the press event in progress */ bool mPressed; }; @@ -66,21 +84,37 @@ private: void createMediaPlayer(); void adaptSizeToVideo(); + /** The current media file path */ QString mFilePath; + /** The current media type */ eMediaType mType; + /** The media object */ Phonon::MediaObject* mpMediaObject; + /** The video renderer */ Phonon::VideoWidget* mpVideoWidget; + /** The audio renderer */ Phonon::AudioOutput* mpAudioOutput; + /** The principal layout of this widget */ QVBoxLayout mLayout; + /** The seeker layout */ QHBoxLayout mSeekerLayout; + /** The play-stop button */ UBMediaButton* mpPlayStopButton; + /** The pause button */ UBMediaButton* mpPauseButton; + /** The seeker slider */ QSlider* mpSlider; + /** An indicator of the seeker auto update in progress */ bool mAutoUpdate; + /** An indicator of the thumbnail generation in progress */ bool mGeneratingThumbnail; + /** The border */ int mBorder; + /** A widget that will contain the media */ QWidget* mpMediaContainer; + /** The media layout */ QHBoxLayout mMediaLayout; + /** The audio cover */ QLabel* mpCover; }; diff --git a/src/gui/UBTeacherBarWidget.cpp b/src/gui/UBTeacherBarWidget.cpp index c3e31d21..06058bbd 100644 --- a/src/gui/UBTeacherBarWidget.cpp +++ b/src/gui/UBTeacherBarWidget.cpp @@ -1016,15 +1016,12 @@ void UBTBMediaContainer::dropEvent(QDropEvent* pEvent) QString mimeType; QString resourcePath; if(pEvent->mimeData()->hasText()){ - qDebug() << "text dropped"; resourcePath = pEvent->mimeData()->text(); } else if(pEvent->mimeData()->hasUrls()){ - qDebug() << "url dropped"; resourcePath = pEvent->mimeData()->urls().at(0).toLocalFile(); } else if(pEvent->mimeData()->hasImage()){ - qDebug() << "image dropped"; pixFromDropEvent.loadFromData(pEvent->mimeData()->imageData().toByteArray()); if(!pixFromDropEvent.isNull()) mimeType = "image"; @@ -1035,7 +1032,6 @@ void UBTBMediaContainer::dropEvent(QDropEvent* pEvent) return; } if(!resourcePath.isEmpty()){ - qDebug() << "emitting 'mediaDropped'"; emit mediaDropped(resourcePath); pEvent->acceptProposedAction(); } From 15f89fc7a2fc2a81bef965096b8bff617439a7e2 Mon Sep 17 00:00:00 2001 From: shibakaneki Date: Wed, 18 Jan 2012 09:29:14 +0100 Subject: [PATCH 64/84] Partial commit --- src/gui/UBTeacherBarWidget.cpp | 412 ++++++++++++++------------------- src/gui/UBTeacherBarWidget.h | 72 +++++- 2 files changed, 244 insertions(+), 240 deletions(-) diff --git a/src/gui/UBTeacherBarWidget.cpp b/src/gui/UBTeacherBarWidget.cpp index 06058bbd..6201f0d1 100644 --- a/src/gui/UBTeacherBarWidget.cpp +++ b/src/gui/UBTeacherBarWidget.cpp @@ -17,23 +17,18 @@ #include "customWidgets/UBDraggableLabel.h" #include "customWidgets/UBMediaWidget.h" +#include "customWidgets/UBGlobals.h" #include "core/memcheck.h" UBTeacherBarWidget::UBTeacherBarWidget(QWidget *parent, const char *name):UBDockPaletteWidget(parent) , mpLayout(NULL) , mpTitleLayout(NULL) - , mpDurationLayout(NULL) , mpTitleLabel(NULL) - , mpDurationLabel(NULL) , mpTitle(NULL) , mpMediaLabel(NULL) , mpContainer(NULL) , mpContainerLayout(NULL) - , mpDuration1(NULL) - , mpDuration2(NULL) - , mpDuration3(NULL) - , mpDurationButtons(NULL) , mpActionLabel(NULL) , mpActions(NULL) , mpActionButton(NULL) @@ -47,6 +42,8 @@ UBTeacherBarWidget::UBTeacherBarWidget(QWidget *parent, const char *name):UBDock , mpStackWidget(NULL) , mpPreview(NULL) , mpMediaContainer(NULL) + , mpDocPreviewWidget(NULL) + , mpDocEditWidget(NULL) { setObjectName(name); mName = "TeacherBarWidget"; @@ -68,11 +65,15 @@ UBTeacherBarWidget::UBTeacherBarWidget(QWidget *parent, const char *name):UBDock mpContainer->setObjectName("DockPaletteWidgetBox"); mpPreview = new UBTeacherBarPreviewWidget(this); + mpDocPreviewWidget = new UBTBDocumentPreviewWidget(this); + mpDocEditWidget = new UBTBDocumentEditWidget(this); mpStackWidget = new QStackedWidget(this); mpContainerLayout->addWidget(mpStackWidget); mpStackWidget->addWidget(mpContainer); mpStackWidget->addWidget(mpPreview); + mpStackWidget->addWidget(mpDocPreviewWidget); + mpStackWidget->addWidget(mpDocEditWidget); mpLayout = new QVBoxLayout(mpContainer); mpContainer->setLayout(mpLayout); @@ -85,26 +86,6 @@ UBTeacherBarWidget::UBTeacherBarWidget(QWidget *parent, const char *name):UBDock mpLayout->addWidget(mpTitleLabel, 0); mpLayout->addWidget(mpTitle, 0); - // Duration - mpDurationLabel = new QLabel(tr("Duration"), mpContainer); - mpLayout->addWidget(mpDurationLabel, 0); - mpDurationLayout = new QHBoxLayout(); - mpDuration1 = new QCheckBox(this); - mpDuration1->setIcon(QIcon(":images/duration1.png")); - mpDuration1->setChecked(true); - mpDurationLayout->addWidget(mpDuration1, 0); - mpDuration2 = new QCheckBox(this); - mpDuration2->setIcon(QIcon(":images/duration2.png")); - mpDurationLayout->addWidget(mpDuration2, 0); - mpDuration3 = new QCheckBox(this); - mpDuration3->setIcon(QIcon(":images/duration3.png")); - mpDurationLayout->addWidget(mpDuration3, 0); - mpDurationButtons = new QButtonGroup(mpContainer); - mpDurationButtons->addButton(mpDuration1); - mpDurationButtons->addButton(mpDuration2); - mpDurationButtons->addButton(mpDuration3); - mpLayout->addLayout(mpDurationLayout, 0); - // Actions mpActionLabel = new QLabel(tr("Actions"), mpContainer); mpLayout->addWidget(mpActionLabel, 0); @@ -154,110 +135,35 @@ UBTeacherBarWidget::UBTeacherBarWidget(QWidget *parent, const char *name):UBDock connect(mpLinkButton, SIGNAL(clicked()), this, SLOT(onLinkButton())); connect(mpPreview, SIGNAL(showEditMode()), this, SLOT(onShowEditMode())); connect(mpMediaContainer, SIGNAL(mediaDropped(QString)), this, SLOT(onMediaDropped(QString))); + connect(mpDocPreviewWidget, SIGNAL(onEditClicked()), this, SLOT(onTBStateChanged(eTeacherBarState))); + connect(mpDocPreviewWidget, SIGNAL(onPageViewClicked()), this, SLOT(onTBStateChanged(eTeacherBarState))); + connect(mpDocEditWidget, SIGNAL(onPageViewClicked()), this, SLOT(onTBStateChanged(eTeacherBarState))); + connect(mpDocEditWidget, SIGNAL(onPreviewClicked()), this, SLOT(onTBStateChanged(eTeacherBarState))); } UBTeacherBarWidget::~UBTeacherBarWidget() { - if(NULL != mpMediaContainer){ - delete mpMediaContainer; - mpMediaContainer = NULL; - } - if(NULL != mpComments){ - delete mpComments; - mpComments = NULL; - } - if(NULL != mpCommentLabel){ - delete mpCommentLabel; - mpCommentLabel = NULL; - } - if(NULL != mpLinks){ - delete mpLinks; - mpLinks = NULL; - } - if(NULL != mpLinkLabel){ - delete mpLinkLabel; - mpLinkLabel = NULL; - } - if(NULL != mpLinkButton){ - delete mpLinkButton; - mpLinkButton = NULL; - } - if(NULL != mpLinkLayout){ - delete mpLinkLayout; - mpLinkLayout = NULL; - } - if(NULL != mpMediaLabel){ - delete mpMediaLabel; - mpMediaLabel = NULL; - } - if(NULL != mpActionButton){ - delete mpActionButton; - mpActionButton = NULL; - } - if(NULL != mpActionLayout){ - delete mpActionLayout; - mpActionLayout = NULL; - } - if(NULL != mpActionLabel){ - delete mpActionLabel; - mpActionLabel = NULL; - } - if(NULL != mpDurationLabel){ - delete mpDurationLabel; - mpDurationLabel = NULL; - } - if(NULL != mpDuration1){ - delete mpDuration1; - mpDuration1 = NULL; - } - if(NULL != mpDuration2){ - delete mpDuration2; - mpDuration2 = NULL; - } - if(NULL != mpDuration3){ - delete mpDuration3; - mpDuration3 = NULL; - } - if(NULL != mpDurationButtons){ - delete mpDurationButtons; - mpDurationButtons = NULL; - } - if(NULL != mpDurationLayout){ - delete mpDurationLayout; - mpDurationLayout = NULL; - } - if(NULL != mpTitleLabel){ - delete mpTitleLabel; - mpTitleLabel = NULL; - } - if(NULL != mpTitle){ - delete mpTitle; - mpTitle = NULL; - } - if(NULL != mpTitleLayout){ - delete mpTitleLayout; - mpTitleLayout = NULL; - } - if(NULL != mpLayout){ - delete mpLayout; - mpLayout = NULL; - } - if(NULL != mpContainer){ - delete mpContainer; - mpContainer = NULL; - } - if(NULL != mpContainerLayout){ - delete mpContainerLayout; - mpContainerLayout = NULL; - } - if(NULL != mpPreview){ - delete mpPreview; - mpPreview = NULL; - } - if(NULL != mpStackWidget){ - delete mpStackWidget; - mpStackWidget = NULL; - } + DELETEPTR(mpDocPreviewWidget); + DELETEPTR(mpDocEditWidget); + DELETEPTR(mpMediaContainer); + DELETEPTR(mpComments); + DELETEPTR(mpCommentLabel); + DELETEPTR(mpLinks); + DELETEPTR(mpLinkLabel); + DELETEPTR(mpLinkButton); + DELETEPTR(mpLinkLayout); + DELETEPTR(mpMediaLabel); + DELETEPTR(mpActionButton); + DELETEPTR(mpActionLayout); + DELETEPTR(mpActionLabel); + DELETEPTR(mpTitleLabel); + DELETEPTR(mpTitle); + DELETEPTR(mpTitleLayout); + DELETEPTR(mpLayout); + DELETEPTR(mpContainer); + DELETEPTR(mpContainerLayout); + DELETEPTR(mpPreview); + DELETEPTR(mpStackWidget); } void UBTeacherBarWidget::onValueChanged() @@ -281,14 +187,7 @@ void UBTeacherBarWidget::saveContent() sTeacherBarInfos infos; // Title infos.title = mpTitle->text(); - // Duration - if(mpDuration1->isChecked()){ - infos.Duration = eDuration_Quarter; - }else if(mpDuration2->isChecked()){ - infos.Duration = eDuration_Half; - }else{ - infos.Duration = eDuration_ThreeQuarter; - } + // Actions for(int i=0; icomboValue()).arg(mActionList.at(i)->text()); @@ -316,17 +215,7 @@ void UBTeacherBarWidget::loadContent() sTeacherBarInfos nextInfos = UBPersistenceManager::persistenceManager()->getTeacherBarInfos(UBApplication::boardController->activeDocument(), UBApplication::boardController->activeSceneIndex()); // Title mpTitle->setText(nextInfos.title); - // Duration - switch(nextInfos.Duration){ - case eDuration_Quarter: mpDuration1->setChecked(true); - break; - case eDuration_Half: mpDuration2->setChecked(true); - break; - case eDuration_ThreeQuarter: mpDuration3->setChecked(true); - break; - default: mpDuration1->setChecked(true); - break; - } + // Actions for(int i=0; imediaViewer()->loadMedia(nextInfos.medias); mpStackWidget->setCurrentWidget(mpPreview); - if(mpDuration1->isChecked()){ - mpPreview->setDuration(eDuration_Quarter); - }else if(mpDuration2->isChecked()){ - mpPreview->setDuration(eDuration_Half); - }else{ - mpPreview->setDuration(eDuration_ThreeQuarter); - } mpPreview->clean(); // Add the actions @@ -498,6 +380,24 @@ void UBTeacherBarWidget::onMediaDropped(const QString &url) } } +void UBTeacherBarWidget::onTBStateChanged(eTeacherBarState state) +{ + switch(state){ + case eTeacherBarState_DocumentEdit: + mpStackWidget->setCurrentWidget(mpDocEditWidget); + break; + case eTeacherBarState_DocumentPreview: + mpStackWidget->setCurrentWidget(mpDocPreviewWidget); + break; + case eTeacherBarState_PageEdit: + mpStackWidget->setCurrentWidget(mpContainer); + break; + case eTeacherBarState_PagePreview: + mpStackWidget->setCurrentWidget(mpPreview); + break; + } +} + // --------------------------------------------------------------------------------------------- UBTeacherStudentAction::UBTeacherStudentAction(QWidget *parent, const char *name):QWidget(parent) , mpText(NULL) @@ -536,22 +436,10 @@ UBTeacherStudentAction::UBTeacherStudentAction(QWidget *parent, const char *name UBTeacherStudentAction::~UBTeacherStudentAction() { - if(NULL != mpCombo){ - delete mpCombo; - mpCombo = NULL; - } - if(NULL != mpText){ - delete mpText; - mpText = NULL; - } - if(NULL != mpComboLayout){ - delete mpComboLayout; - mpComboLayout = NULL; - } - if(NULL != mpLayout){ - delete mpLayout; - mpLayout = NULL; - } + DELETEPTR(mpCombo); + DELETEPTR(mpText); + DELETEPTR(mpComboLayout); + DELETEPTR(mpLayout); } QString UBTeacherStudentAction::text() @@ -623,34 +511,13 @@ UBUrlWidget::UBUrlWidget(QWidget *parent, const char *name):QWidget(parent) UBUrlWidget::~UBUrlWidget() { - if(NULL != mpTitle){ - delete mpTitle; - mpTitle = NULL; - } - if(NULL != mpTitleLabel){ - delete mpTitleLabel; - mpTitleLabel = NULL; - } - if(NULL != mpUrlLabel){ - delete mpUrlLabel; - mpUrlLabel = NULL; - } - if(NULL != mpUrl){ - delete mpUrl; - mpUrl = NULL; - } - if(NULL != mpTitleLayout){ - delete mpTitleLayout; - mpTitleLayout = NULL; - } - if(NULL != mpLabelLayout){ - delete mpLabelLayout; - mpLabelLayout = NULL; - } - if(NULL != mpLayout){ - delete mpLayout; - mpLayout = NULL; - } + DELETEPTR(mpTitle); + DELETEPTR(mpTitleLabel); + DELETEPTR(mpUrlLabel); + DELETEPTR(mpUrl); + DELETEPTR(mpTitleLayout); + DELETEPTR(mpLabelLayout); + DELETEPTR(mpLayout); } QString UBUrlWidget::url() @@ -683,6 +550,7 @@ UBTeacherBarPreviewWidget::UBTeacherBarPreviewWidget(QWidget *parent, const char , mpCommentsLabel(NULL) , mpComments(NULL) , mpLinksLabel(NULL) + , mpContentContainer(NULL) { setObjectName(name); @@ -702,7 +570,9 @@ UBTeacherBarPreviewWidget::UBTeacherBarPreviewWidget(QWidget *parent, const char mTitleDurationLayout.addWidget(mpDuration, 1); mLayout.addLayout(&mTitleDurationLayout, 0); - mLayout.addWidget(&mMediaViewer, 1); + mpContentContainer = new UBTBPreviewContainer(this); + mLayout.addWidget(mpContentContainer, 1); + //mLayout.addWidget(&mMediaViewer, 1); // The next line is disgusting. This is a quickfix that must be reworked later mMediaViewer.setContentsMargins(-9, -9, -9, -9); @@ -722,38 +592,15 @@ UBTeacherBarPreviewWidget::UBTeacherBarPreviewWidget(QWidget *parent, const char UBTeacherBarPreviewWidget::~UBTeacherBarPreviewWidget() { - if(NULL != mpLinksLabel){ - delete mpLinksLabel; - mpLinksLabel = NULL; - } - if(NULL != mpComments){ - delete mpComments; - mpComments = NULL; - } - if(NULL != mpTitle){ - delete mpTitle; - mpTitle = NULL; - } - if(NULL != mpDuration){ - delete mpDuration; - mpDuration = NULL; - } - if(NULL != mpActionsLabel){ - delete mpActionsLabel; - mpActionsLabel = NULL; - } - if(NULL != mpMediaLabel){ - delete mpMediaLabel; - mpMediaLabel = NULL; - } - if(NULL != mpCommentsLabel){ - delete mpCommentsLabel; - mpCommentsLabel = NULL; - } - if(NULL != mpEditButton){ - delete mpEditButton; - mpEditButton = NULL; - } + DELETEPTR(mpLinksLabel); + DELETEPTR(mpComments); + DELETEPTR(mpTitle); + DELETEPTR(mpDuration); + DELETEPTR(mpActionsLabel); + DELETEPTR(mpMediaLabel); + DELETEPTR(mpCommentsLabel); + DELETEPTR(mpContentContainer); + DELETEPTR(mpEditButton); } void UBTeacherBarPreviewWidget::onEdit() @@ -807,6 +654,13 @@ void UBTeacherBarPreviewWidget::setComments(const QString &comments) void UBTeacherBarPreviewWidget::clean() { mMediaViewer.cleanMedia(); + + foreach(QWidget* eachWidget, mStoredWidgets){ + delete eachWidget; + eachWidget = NULL; + } + mStoredWidgets.clear(); + hideElements(); } @@ -883,11 +737,7 @@ UBTeacherBarPreviewMedia::UBTeacherBarPreviewMedia(QWidget* parent, const char* UBTeacherBarPreviewMedia::~UBTeacherBarPreviewMedia() { - if(mWidget){ - delete mWidget; - mWidget = NULL; - } - + DELETEPTR(mWidget); } void UBTeacherBarPreviewMedia::cleanMedia() @@ -1119,3 +969,97 @@ QWidget* UBTBMediaContainer::generateMediaWidget(const QString& url) return pW; } + +// ------------------------------------------------------------------------------------------------------------------- +UBTBPreviewContainer::UBTBPreviewContainer(QWidget *parent, const char *name):UBWidgetList(parent) +{ + setObjectName(name); +} + +UBTBPreviewContainer::~UBTBPreviewContainer() +{ + +} + +// ------------------------------------------------------------------------------------------------------------------- +UBTBDocumentEditWidget::UBTBDocumentEditWidget(QWidget *parent, const char *name):QWidget(parent) + , mpPageViewButton(NULL) + , mpPreviewButton(NULL) + , mpTitleLabel(NULL) + , mpTitle(NULL) + , mpTargetLabel(NULL) + , mpTarget(NULL) + , mpMetadataLabel(NULL) + , mpLicenseLabel(NULL) +{ + setObjectName(name); + setLayout(&mLayout); + + mpPageViewButton = new QPushButton(tr("Page View"), this); + mPageLayout.addStretch(1); + mPageLayout.addWidget(mpPageViewButton, 0); + mPageLayout.addStretch(1); + mLayout.addLayout(&mPageLayout); + + mpTitleLabel = new QLabel(tr("Session Title:"), this); + mpTitleLabel->setAlignment(Qt::AlignLeft); + mLayout.addWidget(mpTitleLabel); + mpTitle = new QLineEdit(this); + mLayout.addWidget(mpTitle); + + + mpPreviewButton = new QPushButton(tr("Preview"), this); + mPreviewLayout.addStretch(1); + mPreviewLayout.addWidget(mpPreviewButton, 0); + mPreviewLayout.addStretch(1); + mLayout.addLayout(&mPreviewLayout); + + connect(mpPageViewButton, SIGNAL(clicked()), this, SIGNAL(onPageViewClicked())); + connect(mpPreviewButton, SIGNAL(clicked()), this, SIGNAL(onPreviewClicked())); +} + +UBTBDocumentEditWidget::~UBTBDocumentEditWidget() +{ + DELETEPTR(mpTitleLabel); + DELETEPTR(mpTitle); + DELETEPTR(mpTargetLabel); + DELETEPTR(mpTarget); + DELETEPTR(mpMetadataLabel); + DELETEPTR(mpLicenseLabel); + DELETEPTR(mpPageViewButton); + DELETEPTR(mpPreviewButton); +} + +// ------------------------------------------------------------------------------------------------------------------- +UBTBDocumentPreviewWidget::UBTBDocumentPreviewWidget(QWidget *parent, const char *name):QWidget(parent) + , mpPageViewButton(NULL) + , mpEditButton(NULL) +{ + setObjectName(name); + setLayout(&mLayout); + + mpPageViewButton = new QPushButton(tr("Page View"), this); + mPageLayout.addStretch(1); + mPageLayout.addWidget(mpPageViewButton, 0); + mPageLayout.addStretch(1); + mLayout.addLayout(&mPageLayout); + + // TODO : Add the elements here + + mpEditButton = new QPushButton(tr("Edit"), this); + mPreviewLayout.addStretch(1); + mPreviewLayout.addWidget(mpEditButton, 0); + mPreviewLayout.addStretch(1); + mLayout.addLayout(&mPreviewLayout); + + connect(mpPageViewButton, SIGNAL(clicked()), this, SIGNAL(onPageViewClicked())); + connect(mpEditButton, SIGNAL(clicked()), this, SIGNAL(onEditClicked())); +} + +UBTBDocumentPreviewWidget::~UBTBDocumentPreviewWidget() +{ + DELETEPTR(mpPageViewButton); + DELETEPTR(mpEditButton); +} + + diff --git a/src/gui/UBTeacherBarWidget.h b/src/gui/UBTeacherBarWidget.h index 7bb80512..ee74c7bc 100644 --- a/src/gui/UBTeacherBarWidget.h +++ b/src/gui/UBTeacherBarWidget.h @@ -22,6 +22,13 @@ class UBMediaPlayer; #define LABEL_MINWIDHT 80 +typedef enum{ + eTeacherBarState_DocumentEdit, + eTeacherBarState_DocumentPreview, + eTeacherBarState_PageEdit, + eTeacherBarState_PagePreview +}eTeacherBarState; + typedef enum{ eDuration_Quarter, eDuration_Half, @@ -104,6 +111,13 @@ private: QHBoxLayout mOwnerLayout; }; +class UBTBPreviewContainer : public UBWidgetList +{ +public: + UBTBPreviewContainer(QWidget* parent=0, const char* name="UBTBPreviewContainer"); + ~UBTBPreviewContainer(); +}; + class UBTeacherBarPreviewWidget : public QWidget { Q_OBJECT @@ -133,6 +147,7 @@ private: QHBoxLayout mTitleDurationLayout; UBTeacherBarPreviewMedia mMediaViewer; QList mWidgets; + QList mStoredWidgets; QPushButton* mpEditButton; QLabel* mpTitle; @@ -144,6 +159,7 @@ private: QLabel* mpLinksLabel; QLabel* mpTmpLink; UBActionPreview* mpTmpAction; + UBTBPreviewContainer* mpContentContainer; }; class UBTBMediaContainer : public UBWidgetList @@ -172,6 +188,51 @@ private: QStringList mMediaList; }; +class UBTBDocumentEditWidget : public QWidget +{ + Q_OBJECT +public: + UBTBDocumentEditWidget(QWidget* parent=0, const char* name="UBTBDocumentEditWidget"); + ~UBTBDocumentEditWidget(); + +signals: + void onPreviewClicked(); + void onPageViewClicked(); + +private: + QVBoxLayout mLayout; + QHBoxLayout mPageLayout; + QHBoxLayout mPreviewLayout; + QPushButton* mpPageViewButton; + QPushButton* mpPreviewButton; + + QLabel* mpTitleLabel; + QLineEdit* mpTitle; + QLabel* mpTargetLabel; + QTextEdit* mpTarget; + QLabel* mpMetadataLabel; + QLabel* mpLicenseLabel; +}; + +class UBTBDocumentPreviewWidget : public QWidget +{ + Q_OBJECT +public: + UBTBDocumentPreviewWidget(QWidget* parent=0, const char* name="UBTBDocumentPreviewWidget"); + ~UBTBDocumentPreviewWidget(); + +signals: + void onEditClicked(); + void onPageViewClicked(); + +private: + QVBoxLayout mLayout; + QHBoxLayout mPageLayout; + QHBoxLayout mPreviewLayout; + QPushButton* mpPageViewButton; + QPushButton* mpEditButton; +}; + class UBTeacherBarWidget : public UBDockPaletteWidget { Q_OBJECT @@ -188,23 +249,18 @@ private slots: void onLinkButton(); void onShowEditMode(); void onMediaDropped(const QString& url); + void onTBStateChanged(eTeacherBarState state); private: void clearWidgetLists(); bool isEmpty(); QVBoxLayout* mpLayout; QHBoxLayout* mpTitleLayout; - QHBoxLayout* mpDurationLayout; QLabel* mpTitleLabel; - QLabel* mpDurationLabel; QLineEdit* mpTitle; QLabel* mpMediaLabel; QWidget* mpContainer; QVBoxLayout* mpContainerLayout; - QCheckBox* mpDuration1; - QCheckBox* mpDuration2; - QCheckBox* mpDuration3; - QButtonGroup* mpDurationButtons; QLabel* mpActionLabel; UBWidgetList* mpActions; QPushButton* mpActionButton; @@ -223,6 +279,10 @@ private: QVector mMediaList; UBTBMediaContainer* mpMediaContainer; + eTeacherBarState mState; + + UBTBDocumentPreviewWidget* mpDocPreviewWidget; + UBTBDocumentEditWidget* mpDocEditWidget; }; #endif // UBTEACHERBARWIDGET_H From 3dd07bb46d95e2ba8f428b8e114e83530ca6af30 Mon Sep 17 00:00:00 2001 From: shibakaneki Date: Fri, 20 Jan 2012 08:40:35 +0100 Subject: [PATCH 65/84] backup while reworking the teacher bar --- src/gui/UBTBDocumentEditWidget.cpp | 88 +++ src/gui/UBTBDocumentEditWidget.h | 45 ++ src/gui/UBTBDocumentPreviewWidget.cpp | 48 ++ src/gui/UBTBDocumentPreviewWidget.h | 33 + src/gui/UBTBPageEditWidget.cpp | 417 ++++++++++ src/gui/UBTBPageEditWidget.h | 92 +++ src/gui/UBTeacherBarDataMgr.cpp | 97 +++ src/gui/UBTeacherBarDataMgr.h | 109 +++ src/gui/UBTeacherBarPreviewWidget.cpp | 314 ++++++++ src/gui/UBTeacherBarPreviewWidget.h | 96 +++ src/gui/UBTeacherBarWidget.cpp | 1050 +++---------------------- src/gui/UBTeacherBarWidget.h | 251 +----- src/gui/gui.pri | 16 +- 13 files changed, 1464 insertions(+), 1192 deletions(-) create mode 100644 src/gui/UBTBDocumentEditWidget.cpp create mode 100644 src/gui/UBTBDocumentEditWidget.h create mode 100644 src/gui/UBTBDocumentPreviewWidget.cpp create mode 100644 src/gui/UBTBDocumentPreviewWidget.h create mode 100644 src/gui/UBTBPageEditWidget.cpp create mode 100644 src/gui/UBTBPageEditWidget.h create mode 100644 src/gui/UBTeacherBarDataMgr.cpp create mode 100644 src/gui/UBTeacherBarDataMgr.h create mode 100644 src/gui/UBTeacherBarPreviewWidget.cpp create mode 100644 src/gui/UBTeacherBarPreviewWidget.h diff --git a/src/gui/UBTBDocumentEditWidget.cpp b/src/gui/UBTBDocumentEditWidget.cpp new file mode 100644 index 00000000..17fa19a8 --- /dev/null +++ b/src/gui/UBTBDocumentEditWidget.cpp @@ -0,0 +1,88 @@ +#include "UBTBDocumentEditWidget.h" +#include "customWidgets/UBGlobals.h" + +UBTBDocumentEditWidget::UBTBDocumentEditWidget(UBTeacherBarDataMgr* pDataMgr, QWidget *parent, const char *name):QWidget(parent) + , mpPageViewButton(NULL) + , mpPreviewButton(NULL) + , mpTitleLabel(NULL) + , mpTitle(NULL) + , mpTargetLabel(NULL) + , mpTarget(NULL) + , mpMetadataLabel(NULL) + , mpLicenseLabel(NULL) +{ + setObjectName(name); + + mpDataMgr = pDataMgr; + + setLayout(&mLayout); + mLayout.setContentsMargins(0, 0, 0, 0); + + mpContainer = new QWidget(this); + mpContainer->setObjectName("DockPaletteWidgetBox"); + mLayout.addWidget(mpContainer, 1); + mpContainer->setLayout(&mContainerLayout); + + // Title + mpTitleLabel = new QLabel(tr("Session Title"), mpContainer); + mpTitleLabel->setAlignment(Qt::AlignLeft); + //mpTitleLabel->setObjectName("UBTeacherBarPreviewSubtitle"); + mContainerLayout.addWidget(mpTitleLabel, 0); + mpTitle = new QLineEdit(mpContainer); + mpTitle->setObjectName("DockPaletteWidgetLineEdit"); + mContainerLayout.addWidget(mpTitle, 0); + + // Target + mpTargetLabel = new QLabel(tr("Session Target"), mpContainer); + //mpTargetLabel->setObjectName("UBTeacherBarPreviewSubtitle"); + mContainerLayout.addWidget(mpTargetLabel, 0); + mpTarget = new QTextEdit(mpContainer); + mpTarget->setObjectName("UBTeacherBarTargetBox"); + mContainerLayout.addWidget(mpTarget, 1); + + // Metadata + mpMetadataLabel = new QLabel(tr("Metadata"), mpContainer); + mpMetadataLabel->setAlignment(Qt::AlignLeft); + //mpMetadataLabel->setObjectName("UBTeacherBarPreviewSubtitle"); + mContainerLayout.addWidget(mpMetadataLabel, 0); + + // License + mpLicenseLabel = new QLabel(tr("License"), mpContainer); + mpLicenseLabel->setAlignment(Qt::AlignLeft); + //mpLicenseLabel->setObjectName("UBTeacherBarPreviewSubtitle"); + mContainerLayout.addWidget(mpLicenseLabel, 0); + + mpPageViewButton = new QPushButton(tr("Page View"), this); + mpPageViewButton->setObjectName("DockPaletteWidgetButton"); + mPreviewLayout.addWidget(mpPageViewButton, 0); + mpPreviewButton = new QPushButton(tr("Preview"), this); + mpPreviewButton->setObjectName("DockPaletteWidgetButton"); + mPreviewLayout.addWidget(mpPreviewButton, 0); + mPreviewLayout.addStretch(1); + mLayout.addLayout(&mPreviewLayout, 0); + + connect(mpPageViewButton, SIGNAL(clicked()), this, SLOT(onPageView())); + connect(mpPreviewButton, SIGNAL(clicked()), this, SLOT(onPreview())); +} + +UBTBDocumentEditWidget::~UBTBDocumentEditWidget() +{ + DELETEPTR(mpTitleLabel); + DELETEPTR(mpTitle); + DELETEPTR(mpTargetLabel); + DELETEPTR(mpTarget); + DELETEPTR(mpMetadataLabel); + DELETEPTR(mpLicenseLabel); + DELETEPTR(mpPageViewButton); + DELETEPTR(mpPreviewButton); +} + +void UBTBDocumentEditWidget::onPageView() +{ + emit changeTBState(eTeacherBarState_PageEdit); +} + +void UBTBDocumentEditWidget::onPreview() +{ + emit changeTBState(eTeacherBarState_DocumentPreview); +} diff --git a/src/gui/UBTBDocumentEditWidget.h b/src/gui/UBTBDocumentEditWidget.h new file mode 100644 index 00000000..f26559eb --- /dev/null +++ b/src/gui/UBTBDocumentEditWidget.h @@ -0,0 +1,45 @@ +#ifndef UBTBDOCUMENTEDITWIDGET_H +#define UBTBDOCUMENTEDITWIDGET_H + +#include +#include +#include +#include +#include + +#include "UBTeacherBarDataMgr.h" + +class UBTBDocumentEditWidget : public QWidget +{ + Q_OBJECT +public: + UBTBDocumentEditWidget(UBTeacherBarDataMgr* pDataMgr, QWidget* parent=0, const char* name="UBTBDocumentEditWidget"); + ~UBTBDocumentEditWidget(); + +signals: + void changeTBState(eTeacherBarState state); + +private slots: + void onPageView(); + void onPreview(); + +private: + QVBoxLayout mLayout; + QHBoxLayout mPageLayout; + QHBoxLayout mPreviewLayout; + QVBoxLayout mContainerLayout; + QPushButton* mpPageViewButton; + QPushButton* mpPreviewButton; + + QWidget* mpContainer; + QLabel* mpTitleLabel; + QLineEdit* mpTitle; + QLabel* mpTargetLabel; + QTextEdit* mpTarget; + QLabel* mpMetadataLabel; + QLabel* mpLicenseLabel; + + UBTeacherBarDataMgr* mpDataMgr; +}; + +#endif // UBTBDOCUMENTEDITWIDGET_H diff --git a/src/gui/UBTBDocumentPreviewWidget.cpp b/src/gui/UBTBDocumentPreviewWidget.cpp new file mode 100644 index 00000000..818dfce5 --- /dev/null +++ b/src/gui/UBTBDocumentPreviewWidget.cpp @@ -0,0 +1,48 @@ +#include "customWidgets/UBGlobals.h" +#include "UBTBDocumentPreviewWidget.h" + +UBTBDocumentPreviewWidget::UBTBDocumentPreviewWidget(UBTeacherBarDataMgr *pDataMgr, QWidget *parent, const char *name):QWidget(parent) + , mpPageViewButton(NULL) + , mpEditButton(NULL) +{ + setObjectName(name); + mpDataMgr = pDataMgr; + + setLayout(&mLayout); + + mpPageViewButton = new QPushButton(tr("Page View"), this); + mpPageViewButton->setObjectName("DockPaletteWidgetButton"); + mPageLayout.addStretch(1); + mPageLayout.addWidget(mpPageViewButton, 0); + mPageLayout.addStretch(1); + mLayout.addLayout(&mPageLayout); + + // TODO : Add the elements here + + mpEditButton = new QPushButton(tr("Edit"), this); + mpEditButton->setObjectName("DockPaletteWidgetButton"); + mPreviewLayout.addStretch(1); + mPreviewLayout.addWidget(mpEditButton, 0); + mPreviewLayout.addStretch(1); + mLayout.addLayout(&mPreviewLayout); + + connect(mpPageViewButton, SIGNAL(clicked()), this, SLOT(onPageView())); + connect(mpEditButton, SIGNAL(clicked()), this, SLOT(onEdit())); +} + +UBTBDocumentPreviewWidget::~UBTBDocumentPreviewWidget() +{ + DELETEPTR(mpPageViewButton); + DELETEPTR(mpEditButton); +} + +void UBTBDocumentPreviewWidget::onEdit() +{ + emit changeTBState(eTeacherBarState_DocumentEdit); +} + +void UBTBDocumentPreviewWidget::onPageView() +{ + emit changeTBState(eTeacherBarState_PagePreview); +} + diff --git a/src/gui/UBTBDocumentPreviewWidget.h b/src/gui/UBTBDocumentPreviewWidget.h new file mode 100644 index 00000000..0b426e3c --- /dev/null +++ b/src/gui/UBTBDocumentPreviewWidget.h @@ -0,0 +1,33 @@ +#ifndef UBTBDOCUMENTPREVIEWWIDGET_H +#define UBTBDOCUMENTPREVIEWWIDGET_H + +#include +#include + +#include "UBTeacherBarDataMgr.h" + +class UBTBDocumentPreviewWidget : public QWidget +{ + Q_OBJECT +public: + UBTBDocumentPreviewWidget(UBTeacherBarDataMgr* pDataMgr, QWidget* parent=0, const char* name="UBTBDocumentPreviewWidget"); + ~UBTBDocumentPreviewWidget(); + +signals: + void changeTBState(eTeacherBarState state); + +private slots: + void onPageView(); + void onEdit(); + +private: + QVBoxLayout mLayout; + QHBoxLayout mPageLayout; + QHBoxLayout mPreviewLayout; + QPushButton* mpPageViewButton; + QPushButton* mpEditButton; + + UBTeacherBarDataMgr* mpDataMgr; +}; + +#endif // UBTBDOCUMENTPREVIEWWIDGET_H diff --git a/src/gui/UBTBPageEditWidget.cpp b/src/gui/UBTBPageEditWidget.cpp new file mode 100644 index 00000000..121ab0b3 --- /dev/null +++ b/src/gui/UBTBPageEditWidget.cpp @@ -0,0 +1,417 @@ +#include "customWidgets/UBGlobals.h" +#include "core/UBApplication.h" +#include "frameworks/UBFileSystemUtils.h" +#include "gui/UBMediaPlayer.h" +#include "customWidgets/UBMediaWidget.h" + +#include "UBTBPageEditWidget.h" + +UBTBPageEditWidget::UBTBPageEditWidget(UBTeacherBarDataMgr *pDataMgr, QWidget *parent, const char *name):QWidget(parent) + , mpDataMgr(NULL) + , mpTitleLabel(NULL) + , mpTitle(NULL) + , mpMediaLabel(NULL) + , mpActionLabel(NULL) + , mpActions(NULL) + , mpActionButton(NULL) + , mpLinkLabel(NULL) + , mpLinks(NULL) + , mpLinkButton(NULL) + , mpCommentLabel(NULL) + , mpComments(NULL) + , mpDocumentEditbutton(NULL) + , mpPagePreviewButton(NULL) + , mpContainer(NULL) +{ + Q_UNUSED(name); + mpDataMgr = pDataMgr; + setAttribute(Qt::WA_StyledBackground, true); + setStyleSheet(UBApplication::globalStyleSheet()); + + mLayout.setContentsMargins(0, 0, 0, 0); + setLayout(&mLayout); + + mpContainer = new QWidget(this); + mpContainer->setObjectName("DockPaletteWidgetBox"); + mpContainer->setLayout(&mContainerLayout); + mLayout.addWidget(mpContainer, 1); + + // Title + mpTitleLabel = new QLabel(tr("Title"), mpContainer); + mpTitle = new QLineEdit(mpContainer); + mpTitle->setObjectName("DockPaletteWidgetLineEdit"); + connect(mpTitle, SIGNAL(textChanged(const QString&)), this, SLOT(onTitleTextChanged(const QString&))); + mContainerLayout.addWidget(mpTitleLabel, 0); + mContainerLayout.addWidget(mpTitle, 0); + + // Actions + mpActionLabel = new QLabel(tr("Actions"), mpContainer); + mContainerLayout.addWidget(mpActionLabel, 0); + mpActions = new UBWidgetList(mpContainer); + mpActions->setEmptyText(tr("Add actions")); + mContainerLayout.addWidget(mpActions, 1); + mpActionButton = new QPushButton(mpContainer); + mpActionButton->setObjectName("DockPaletteWidgetButton"); + mpActionButton->setText(tr("Add action")); + mActionLayout.addWidget(mpActionButton, 0); + mActionLayout.addStretch(1); + mContainerLayout.addLayout(&mActionLayout, 0); + + // Media + mpMediaLabel = new QLabel(tr("Medias"), mpContainer); + mContainerLayout.addWidget(mpMediaLabel, 0); + mpMediaContainer = new UBTBMediaContainer(mpContainer); + mpMediaContainer->setEmptyText(tr("Drop media here")); + mContainerLayout.addWidget(mpMediaContainer, 1); + + // Links + mpLinkLabel = new QLabel(tr("Links"), mpContainer); + mContainerLayout.addWidget(mpLinkLabel, 0); + mpLinks = new UBWidgetList(mpContainer); + mContainerLayout.addWidget(mpLinks, 1); + mpLinkButton = new QPushButton(tr("Add link"), mpContainer); + mpLinkButton->setObjectName("DockPaletteWidgetButton"); + mLinkLayout.addWidget(mpLinkButton, 0); + mLinkLayout.addStretch(1); + mContainerLayout.addLayout(&mLinkLayout, 0); + + // Comments + mpCommentLabel = new QLabel(tr("Comments"), mpContainer); + mContainerLayout.addWidget(mpCommentLabel, 0); + mpComments = new QTextEdit(mpContainer); + mpComments->setObjectName("DockPaletteWidgetBox"); + mpComments->setStyleSheet("background:white;"); + mContainerLayout.addWidget(mpComments, 1); + + mpPagePreviewButton = new QPushButton(tr("Preview"), this); + mpPagePreviewButton->setObjectName("DockPaletteWidgetButton"); + mpDocumentEditbutton = new QPushButton(tr("Document View"), this); + mpDocumentEditbutton->setObjectName("DockPaletteWidgetButton"); + mPagePreviewLayout.addWidget(mpDocumentEditbutton, 0); + mPagePreviewLayout.addWidget(mpPagePreviewButton, 0); + mPagePreviewLayout.addStretch(1); + mLayout.addLayout(&mPagePreviewLayout, 0); + + connect(mpTitle, SIGNAL(textChanged(QString)), this, SLOT(onValueChanged())); + connect(mpActionButton, SIGNAL(clicked()), this, SLOT(onActionButton())); + connect(mpLinkButton, SIGNAL(clicked()), this, SLOT(onLinkButton())); + connect(mpDocumentEditbutton, SIGNAL(clicked()), this, SLOT(onDocumentEditClicked())); + connect(mpPagePreviewButton, SIGNAL(clicked()), this, SLOT(onPagePreviewClicked())); + connect(mpMediaContainer, SIGNAL(mediaDropped(QString)), this, SLOT(onMediaDropped(QString))); +} + +UBTBPageEditWidget::~UBTBPageEditWidget() +{ + DELETEPTR(mpDocumentEditbutton); + DELETEPTR(mpPagePreviewButton); + DELETEPTR(mpComments); + DELETEPTR(mpCommentLabel); + DELETEPTR(mpLinks); + DELETEPTR(mpLinkLabel); + DELETEPTR(mpLinkButton); + DELETEPTR(mpMediaLabel); + DELETEPTR(mpActionButton); + DELETEPTR(mpActionLabel); + DELETEPTR(mpTitleLabel); + DELETEPTR(mpTitle); +} + +void UBTBPageEditWidget::onValueChanged() +{ + mpDataMgr->setPageTitle(mpTitle->text()); + mpDataMgr->setComments(mpComments->document()->toPlainText()); + emit valueChanged(); +} + +void UBTBPageEditWidget::onActionButton() +{ + UBTeacherStudentAction* pAction = new UBTeacherStudentAction(this); + mpDataMgr->actions() << pAction; + mpActions->addWidget(pAction); +} + +void UBTBPageEditWidget::onLinkButton() +{ + UBUrlWidget* pUrl = new UBUrlWidget(this); + mpDataMgr->urls() << pUrl; + mpLinks->addWidget(pUrl); +} + +void UBTBPageEditWidget::onMediaDropped(const QString &url) +{ + if("" != url){ + QWidget* pMedia = mpMediaContainer->generateMediaWidget(url); + if(NULL != pMedia){ + mpDataMgr->medias() << pMedia; + mpMediaContainer->addWidget(pMedia); + } + } +} + + +void UBTBPageEditWidget::saveInfos(sTeacherBarInfos *infos) +{ + if(NULL != infos){ + infos->title = mpTitle->text(); + + // Actions + for(int i=0; iactions().size(); i++){ + infos->actions << QString("%0;%1").arg(mpDataMgr->actions().at(i)->comboValue()).arg(mpDataMgr->actions().at(i)->text()); + } + // Media + foreach(QString media, mpMediaContainer->mediaUrls()){ + infos->medias << media; + } + + // Links + for(int j=0; jurls().size(); j++){ + if("" != mpDataMgr->urls().at(j)->url()){ + infos->urls << mpDataMgr->urls().at(j)->url(); + } + } + // Comments + infos->comments = mpComments->document()->toPlainText(); + } +} + +void UBTBPageEditWidget::loadInfos(sTeacherBarInfos* infos) +{ + if(NULL != infos){ + // Title + mpTitle->setText(infos->title); + mpDataMgr->setPageTitle(infos->title); + + // Actions + for(int i=0; iactions.size(); i++){ + QStringList qslAction = infos->actions.at(i).split(";"); + if(qslAction.size() >= 2){ + UBTeacherStudentAction* pAction = new UBTeacherStudentAction(this); + pAction->setComboValue(qslAction.at(0).toInt()); + pAction->setText(qslAction.at(1)); + mpDataMgr->actions() << pAction; + mpActions->addWidget(pAction); + } + } + // Media + foreach(QString url, infos->medias){ + if("" != url){ + QWidget* pMedia = mpMediaContainer->generateMediaWidget(url); + if(NULL != pMedia){ + mpDataMgr->medias() << pMedia; + mpMediaContainer->addWidget(pMedia); + } + } + } + + // Links + for(int j=0; jurls.size(); j++){ + QString qsUrl = infos->urls.at(j); + if("" != qsUrl){ + UBUrlWidget* pLink = new UBUrlWidget(this); + pLink->setUrl(qsUrl); + mpDataMgr->urls() << pLink; + mpLinks->addWidget(pLink); + } + } + // Comments + if(NULL != mpComments){ + mpComments->document()->setPlainText(infos->comments); + } + } +} + +void UBTBPageEditWidget::onDocumentEditClicked() +{ + emit changeTBState(eTeacherBarState_DocumentEdit); +} + +void UBTBPageEditWidget::onPagePreviewClicked() +{ + emit changeTBState(eTeacherBarState_PagePreview); +} + +// --------------------------------------------------------------------------------------------- +UBUrlWidget::UBUrlWidget(QWidget *parent, const char *name):QWidget(parent) + , mpLayout(NULL) + , mpUrlLabel(NULL) + , mpUrl(NULL) +{ + setObjectName(name); + setAttribute(Qt::WA_StyledBackground, true); + setStyleSheet(UBApplication::globalStyleSheet()); + + mpLayout = new QVBoxLayout(this); + setLayout(mpLayout); + + mpLabelLayout = new QHBoxLayout(this); + mpUrlLabel = new QLabel(tr("Url"), this); + mpLabelLayout->addWidget(mpUrlLabel, 0); + mpUrl = new QLineEdit(this); + mpUrl->setObjectName("DockPaletteWidgetLineEdit"); + mpUrl->setMinimumHeight(20); + mpLabelLayout->addWidget(mpUrl, 1); + + mpTitleLayout = new QHBoxLayout(this); + mpTitleLabel = new QLabel(tr("Title"),this); + mpTitleLayout->addWidget(mpTitleLabel,0); + mpTitle = new QLineEdit(this); + mpTitle->setObjectName("DockPaletteWidgetLineEdit"); + mpTitle->setMinimumHeight(20); + mpTitleLayout->addWidget(mpTitle,1); + + mpLayout->addLayout(mpTitleLayout); + mpLayout->addLayout(mpLabelLayout); +} + +UBUrlWidget::~UBUrlWidget() +{ + DELETEPTR(mpTitle); + DELETEPTR(mpTitleLabel); + DELETEPTR(mpUrlLabel); + DELETEPTR(mpUrl); + DELETEPTR(mpTitleLayout); + DELETEPTR(mpLabelLayout); + DELETEPTR(mpLayout); +} + +QString UBUrlWidget::url() +{ + QString str; + + if(NULL != mpUrl){ + str = mpUrl->text() + ";" + mpTitle->text(); + } + + return str; +} + +void UBUrlWidget::setUrl(const QString &url) +{ + QStringList list = url.split(";"); + if(NULL != mpUrl){ + mpUrl->setText(list.at(0)); + mpTitle->setText(list.at(1)); + } +} + +// ------------------------------------------------------------------------------------------------------------------------------------ +UBTBMediaContainer::UBTBMediaContainer(QWidget *parent, const char *name) : UBWidgetList(parent) +{ + setObjectName(name); + setAcceptDrops(true); +} + +UBTBMediaContainer::~UBTBMediaContainer() +{ + +} + +void UBTBMediaContainer::dropEvent(QDropEvent* pEvent) +{ + QPixmap pixFromDropEvent; + QString mimeType; + QString resourcePath; + if(pEvent->mimeData()->hasText()){ + resourcePath = pEvent->mimeData()->text(); + } + else if(pEvent->mimeData()->hasUrls()){ + resourcePath = pEvent->mimeData()->urls().at(0).toLocalFile(); + } + else if(pEvent->mimeData()->hasImage()){ + pixFromDropEvent.loadFromData(pEvent->mimeData()->imageData().toByteArray()); + if(!pixFromDropEvent.isNull()) + mimeType = "image"; + } + + if (mimeType.isEmpty() && resourcePath.isEmpty()){ + pEvent->acceptProposedAction(); + return; + } + if(!resourcePath.isEmpty()){ + emit mediaDropped(resourcePath); + pEvent->acceptProposedAction(); + } +} + +void UBTBMediaContainer::dragEnterEvent(QDragEnterEvent* pEvent) +{ + pEvent->acceptProposedAction(); +} + +void UBTBMediaContainer::dragMoveEvent(QDragMoveEvent* pEvent) +{ + pEvent->acceptProposedAction(); +} + +void UBTBMediaContainer::dragLeaveEvent(QDragLeaveEvent* pEvent) +{ + pEvent->accept(); +} + +void UBTBMediaContainer::addMedia(const QString& mediaPath) +{ + if(!mediaPath.isEmpty()) + mMediaList.append(mediaPath); + else + qWarning() << __FUNCTION__ << "empty path"; + + QString mimeType = UBFileSystemUtils::mimeTypeFromFileName(mediaPath); + if(mimeType.contains("image")){ + QPixmap pix = QPixmap(mediaPath); + QLabel* label = new QLabel(); + label->setPixmap(pix); + label->setScaledContents(true); + addWidget(label); + } + else if(mimeType.contains("video") || mimeType.contains("audio")){ + UBMediaPlayer* mediaPlayer = new UBMediaPlayer(); + mediaPlayer->setFile(mediaPath); + addWidget(mediaPlayer); + } + else{ + qWarning() << "pMediaPath" << mediaPath; + qWarning() << "bad idea to come here"; + } +} + +QStringList UBTBMediaContainer::mediaUrls() +{ + return mMediaList; +} + +void UBTBMediaContainer::cleanMedias() +{ + mMediaList.clear(); +} + +QWidget* UBTBMediaContainer::generateMediaWidget(const QString& url) +{ + QWidget* pW = NULL; + + if(!url.isEmpty()) + mMediaList.append(url); + else + qWarning() << __FUNCTION__ << "empty path"; + + QString mimeType = UBFileSystemUtils::mimeTypeFromFileName(url); + if(mimeType.contains("image")){ + QPixmap pix = QPixmap(url); + QLabel* label = new QLabel(); + pix.scaledToWidth(label->width()); + label->resize(pix.width(), pix.height()); + label->setPixmap(pix); + label->setScaledContents(true); + pW = label; + } + else if(mimeType.contains("video") || mimeType.contains("audio")){ + UBMediaWidget* mediaPlayer = new UBMediaWidget(mimeType.contains("audio")?eMediaType_Audio:eMediaType_Video); + mediaPlayer->setFile(url); + pW = mediaPlayer; + } + else{ + qWarning() << "pMediaPath" << url; + qWarning() << "bad idea to come here"; + } + + return pW; +} diff --git a/src/gui/UBTBPageEditWidget.h b/src/gui/UBTBPageEditWidget.h new file mode 100644 index 00000000..ed766eaa --- /dev/null +++ b/src/gui/UBTBPageEditWidget.h @@ -0,0 +1,92 @@ +#ifndef UBTBPAGEEDITWIDGET_H +#define UBTBPAGEEDITWIDGET_H + +#include +#include +#include +#include +#include +#include +#include + +#include "core/UBPersistenceManager.h" +#include "customWidgets/UBWidgetList.h" +#include "interfaces/IDropable.h" +#include "UBTeacherBarDataMgr.h" + +class UBTBMediaContainer : public UBWidgetList + , public IDropable +{ + Q_OBJECT +public: + UBTBMediaContainer(QWidget* parent=0, const char* name="UBTBMediaContainer"); + ~UBTBMediaContainer(); + QStringList mediaUrls(); + QWidget* generateMediaWidget(const QString& url); + void cleanMedias(); + +signals: + void mediaDropped(const QString& url); + +protected: + void dropEvent(QDropEvent* pEvent); + void dragEnterEvent(QDragEnterEvent* pEvent); + void dragMoveEvent(QDragMoveEvent* pEvent); + void dragLeaveEvent(QDragLeaveEvent* pEvent); + +private: + void addMedia(const QString& mediaPath); + + QStringList mMediaList; +}; + +class UBTBPageEditWidget : public QWidget +{ + Q_OBJECT +public: + UBTBPageEditWidget(UBTeacherBarDataMgr* pDataMgr, QWidget* parent=0, const char* name="UBTBPageEditWidget"); + ~UBTBPageEditWidget(); + + void saveInfos(sTeacherBarInfos* infos); + void loadInfos(sTeacherBarInfos* infos); + +signals: + void valueChanged(); + void changeTBState(eTeacherBarState state); + +private slots: + void onValueChanged(); + void onActionButton(); + void onLinkButton(); + void onMediaDropped(const QString& url); + void onDocumentEditClicked(); + void onPagePreviewClicked(); + +private: + QVBoxLayout mLayout; + QHBoxLayout mTitleLayout; + QVBoxLayout mContainerLayout; + QHBoxLayout mActionLayout; + QHBoxLayout mLinkLayout; + QHBoxLayout mDocumentViewLayout; + QHBoxLayout mPagePreviewLayout; + + UBTeacherBarDataMgr* mpDataMgr; + QLabel* mpTitleLabel; + QLineEdit* mpTitle; + QLabel* mpMediaLabel; + UBTBMediaContainer* mpMediaContainer; + QLabel* mpActionLabel; + UBWidgetList* mpActions; + QPushButton* mpActionButton; + QLabel* mpLinkLabel; + UBWidgetList* mpLinks; + QPushButton* mpLinkButton; + QLabel* mpCommentLabel; + QTextEdit* mpComments; + QPushButton* mpDocumentEditbutton; + QPushButton* mpPagePreviewButton; + QWidget* mpContainer; +}; + +#endif // UBTBPAGEEDITWIDGET_H diff --git a/src/gui/UBTeacherBarDataMgr.cpp b/src/gui/UBTeacherBarDataMgr.cpp new file mode 100644 index 00000000..96faf37b --- /dev/null +++ b/src/gui/UBTeacherBarDataMgr.cpp @@ -0,0 +1,97 @@ +#include "core/UBApplication.h" +#include "customWidgets/UBGlobals.h" +#include "UBTeacherBarDataMgr.h" + +UBTeacherBarDataMgr::UBTeacherBarDataMgr() +{ + +} + +UBTeacherBarDataMgr::~UBTeacherBarDataMgr() +{ + +} + +void UBTeacherBarDataMgr::clearLists() +{ + mActionList.clear(); + mUrlList.clear(); + mMediaList.clear(); +} + +UBTeacherStudentAction::UBTeacherStudentAction(QWidget *parent, const char *name):QWidget(parent) + , mpText(NULL) + , mpLayout(NULL) + , mpComboLayout(NULL) + , mpCombo(NULL) +{ + setObjectName(name); + + setAttribute(Qt::WA_StyledBackground, true); + setStyleSheet(UBApplication::globalStyleSheet()); + + // Create the GUI + mpLayout = new QHBoxLayout(this); + setLayout(mpLayout); + + mpComboLayout = new QVBoxLayout(); + + mpCombo = new QComboBox(this); + mpCombo->setObjectName("DockPaletteWidgetComboBox"); + mpCombo->setMinimumWidth(80); + mpCombo->addItem(tr("Teacher")); + mpCombo->addItem(tr("Student")); + mpComboLayout->addWidget(mpCombo, 0); + mpComboLayout->addStretch(1); + + mpLayout->addLayout(mpComboLayout, 0); + + mpText = new QTextEdit(this); + mpText->setObjectName("DockPaletteWidgetBox"); + mpText->setStyleSheet("background:white;"); + + mpLayout->addWidget(mpText, 1); + +} + +UBTeacherStudentAction::~UBTeacherStudentAction() +{ + DELETEPTR(mpCombo); + DELETEPTR(mpText); + DELETEPTR(mpComboLayout); + DELETEPTR(mpLayout); +} + +QString UBTeacherStudentAction::text() +{ + QString str; + if(NULL != mpText){ + str = mpText->document()->toPlainText(); + } + return str; +} + +QString UBTeacherStudentAction::comboValue() +{ + QString str; + + if(NULL != mpCombo){ + str = QString("%0").arg(mpCombo->currentIndex()); + } + + return str; +} + +void UBTeacherStudentAction::setComboValue(int value) +{ + if(NULL != mpCombo){ + mpCombo->setCurrentIndex(value); + } +} + +void UBTeacherStudentAction::setText(const QString& text) +{ + if(NULL != mpText){ + mpText->document()->setPlainText(text); + } +} diff --git a/src/gui/UBTeacherBarDataMgr.h b/src/gui/UBTeacherBarDataMgr.h new file mode 100644 index 00000000..43c809b9 --- /dev/null +++ b/src/gui/UBTeacherBarDataMgr.h @@ -0,0 +1,109 @@ +#ifndef UBTEACHERBARDATAMGR_H +#define UBTEACHERBARDATAMGR_H + +#include +#include +#include +#include +#include +#include +#include +#include + +typedef enum{ + eTeacherBarState_DocumentEdit, + eTeacherBarState_DocumentPreview, + eTeacherBarState_PageEdit, + eTeacherBarState_PagePreview +}eTeacherBarState; + +typedef enum{ + eActionOwner_Teacher, + eActionOwner_Student +}eActionOwner; + +class UBTeacherStudentAction : public QWidget +{ + Q_OBJECT + +public: + UBTeacherStudentAction(QWidget* parent=0, const char* name="UBTeacherStudentAction"); + ~UBTeacherStudentAction(); + QString text(); + QString comboValue(); + void setComboValue(int value); + void setText(const QString& text); + +private: + QTextEdit* mpText; + QHBoxLayout* mpLayout; + QVBoxLayout* mpComboLayout; + QComboBox* mpCombo; +}; + +class UBUrlWidget : public QWidget +{ +public: + UBUrlWidget(QWidget* parent=0, const char* name="UBUrlWidget"); + ~UBUrlWidget(); + + QString url(); + void setUrl(const QString& url); + +private: + QVBoxLayout* mpLayout; + QHBoxLayout* mpLabelLayout; + QHBoxLayout* mpTitleLayout; + QLabel* mpUrlLabel; + QLineEdit* mpUrl; + + QLabel* mpTitleLabel; + QLineEdit* mpTitle; +}; + +class UBTeacherBarDataMgr +{ +public: + UBTeacherBarDataMgr(); + ~UBTeacherBarDataMgr(); + + // Session Title + void setSessionTitle(const QString& title){mSessionTitle = title;} + QString sessionTitle(){return mSessionTitle;} + + // Session Target + void setSessionTarget(const QString& target){mSessionTarget = target;} + QString sessionTarget(){return mSessionTarget;} + + // Page Title + void setPageTitle(const QString& title){mPageTitle = title;} + QString pageTitle(){return mPageTitle;} + + // Actions + QVector actions(){return mActionList;} + + // Medias + QVector medias(){return mMediaList;} + + // Urls + QVector urls(){return mUrlList;} + + // Comments + void setComments(const QString& c){mComments = c;} + QString comments(){return mComments;} + + // Others + void clearLists(); + +private: + QString mSessionTitle; + QString mSessionTarget; + QString mPageTitle; + QString mComments; + + QVector mActionList; + QVector mUrlList; + QVector mMediaList; +}; + +#endif // UBTEACHERBARDATAMGR_H diff --git a/src/gui/UBTeacherBarPreviewWidget.cpp b/src/gui/UBTeacherBarPreviewWidget.cpp new file mode 100644 index 00000000..7dbf450e --- /dev/null +++ b/src/gui/UBTeacherBarPreviewWidget.cpp @@ -0,0 +1,314 @@ +#include "core/UBApplication.h" +#include "customWidgets/UBGlobals.h" +#include "frameworks/UBFileSystemUtils.h" + +#include "UBTeacherBarPreviewWidget.h" + + +UBTeacherBarPreviewMedia::UBTeacherBarPreviewMedia(QWidget* parent, const char* name) : QWidget(parent) +{ + setObjectName(name); + mWidget = new UBWidgetList(parent); + mLayout.addWidget(mWidget); + setLayout(&mLayout); + mWidgetList.clear(); +} + +UBTeacherBarPreviewMedia::~UBTeacherBarPreviewMedia() +{ + DELETEPTR(mWidget); +} + +void UBTeacherBarPreviewMedia::cleanMedia() +{ + foreach(QWidget* eachWidget, mWidgetList.keys()){ + if(QString(eachWidget->metaObject()->className()).contains("UBDraggable")){ + mWidget->removeWidget(eachWidget); + delete eachWidget; + eachWidget = NULL; + } + else{ + mWidget->removeWidget(eachWidget); + } + } + mWidgetList.clear(); +} + +void UBTeacherBarPreviewMedia::loadWidgets(QList pWidgetsList, bool isResizable) +{ + foreach(QWidget*eachWidget, pWidgetsList){ + mWidget->addWidget(eachWidget); + mWidgetList[eachWidget]="DRAG UNAVAILABLE"; + } +} + + +int UBTeacherBarPreviewMedia::loadMedia(QStringList pMedias) +{ + int addedMedia = 0; +// foreach(QString eachString, pMedias){ +// if(!eachString.isEmpty()){ +// QString mimeType = UBFileSystemUtils::mimeTypeFromFileName(eachString); +// if(mimeType.contains("image")){ +// UBDraggableLabel* label = new UBDraggableLabel(); +// label->loadImage(eachString); +// mWidget->addWidget(label); +// mWidgetList[label]=eachString; +// addedMedia += 1; +// } +// else if(mimeType.contains("video") || mimeType.contains("audio")){ +// UBDraggableMediaPlayer* mediaPlayer = new UBDraggableMediaPlayer(); +// mediaPlayer->setFile(eachString); +// mWidget->addWidget(mediaPlayer); +// mWidgetList[mediaPlayer] = eachString; +// addedMedia += 1; +// } +// else{ +// qWarning() << "pMediaPath" << eachString; +// qWarning() << "bad idea to come here"; +// } +// } +// } + return addedMedia; +} + +// ----------------------------------------------------------------------------------------------- +UBActionPreview::UBActionPreview(QWidget *parent, const char *name):QWidget(parent) + , mpOwner(NULL) + , mpContent(NULL) +{ + setObjectName(name); + setLayout(&mLayout); + mpOwner = new QLabel(this); + mpOwner->setObjectName("UBActionPreviewOwner"); + mOwnerLayout.addWidget(mpOwner, 0); + mOwnerLayout.addStretch(1); + mLayout.addLayout(&mOwnerLayout); + mpContent = new QLabel(this); + mpContent->setObjectName("UBActionPreviewContent"); + mpContent->setWordWrap(true); + mLayout.addWidget(mpContent); + setContentsMargins(-9, -9, -9, -9); +} + +UBActionPreview::~UBActionPreview() +{ + if(NULL != mpOwner){ + delete mpOwner; + mpOwner = NULL; + } + if(NULL != mpContent){ + delete mpContent; + mpContent = NULL; + } +} + +void UBActionPreview::setOwner(const QString &owner) +{ + if(NULL != mpOwner && NULL != mpContent){ + switch(owner.toInt()){ + case eActionOwner_Teacher: + mpOwner->setText(tr("Teacher")); + mpContent->setStyleSheet("background:lightblue; border:lightblue;"); + break; + + case eActionOwner_Student: + mpOwner->setText(tr("Student")); + mpContent->setStyleSheet("background:lightgreen; border:lightgreen;"); + break; + } + } +} + +void UBActionPreview::setContent(const QString &content) +{ + if(NULL != mpContent){ + mpContent->setText(content); + } +} + +// ------------------------------------------------------------------------------------------------------------------- +UBTBPreviewContainer::UBTBPreviewContainer(QWidget *parent, const char *name):UBWidgetList(parent) +{ + setObjectName(name); +} + +UBTBPreviewContainer::~UBTBPreviewContainer() +{ + +} + +// ------------------------------------------------------------------------------------ +UBTeacherBarPreviewWidget::UBTeacherBarPreviewWidget(UBTeacherBarDataMgr* pDataMgr, QWidget *parent, const char *name):QWidget(parent) + , mpEditButton(NULL) + , mpTitle(NULL) + , mpDuration(NULL) + , mpActionsLabel(NULL) + , mpMediaLabel(NULL) + , mpCommentsLabel(NULL) + , mpComments(NULL) + , mpLinksLabel(NULL) + , mpContentContainer(NULL) +{ + setObjectName(name); + mpDataMgr = pDataMgr; + setLayout(&mLayout); + + setAttribute(Qt::WA_StyledBackground, true); + setStyleSheet(UBApplication::globalStyleSheet()); + + // Build the Preview widget + // Title + duration + mpTitle = new QLabel(this); + mpTitle->setObjectName("UBTeacherBarPreviewTitle"); + mpTitle->setWordWrap(true); + mpTitle->setAlignment(Qt::AlignCenter); + mpDuration = new QLabel(this); + mTitleDurationLayout.addWidget(mpTitle, 0); + mTitleDurationLayout.addWidget(mpDuration, 1); + mLayout.addLayout(&mTitleDurationLayout, 0); + + mpContentContainer = new UBTBPreviewContainer(this); + mLayout.addWidget(mpContentContainer, 1); + //mLayout.addWidget(&mMediaViewer, 1); + // The next line is disgusting. This is a quickfix that must be reworked later + mMediaViewer.setContentsMargins(-9, -9, -9, -9); + + hideElements(); + + // Edit button + mpEditButton = new QPushButton(tr("Edit infos"), this); + mpEditButton->setObjectName("DockPaletteWidgetButton"); + mEditLayout.addStretch(1); + mEditLayout.addWidget(mpEditButton, 0); + mEditLayout.addStretch(1); + mLayout.addLayout(&mEditLayout, 0); + + + connect(mpEditButton, SIGNAL(clicked()), this, SLOT(onEdit())); +} + +UBTeacherBarPreviewWidget::~UBTeacherBarPreviewWidget() +{ + DELETEPTR(mpLinksLabel); + DELETEPTR(mpComments); + DELETEPTR(mpTitle); + DELETEPTR(mpDuration); + DELETEPTR(mpActionsLabel); + DELETEPTR(mpMediaLabel); + DELETEPTR(mpCommentsLabel); + DELETEPTR(mpContentContainer); + DELETEPTR(mpEditButton); +} + +void UBTeacherBarPreviewWidget::onEdit() +{ + emit showEditMode(); +} + +void UBTeacherBarPreviewWidget::setTitle(const QString &title) +{ + if(NULL != mpTitle){ + mpTitle->setText(title); + } +} + +void UBTeacherBarPreviewWidget::setComments(const QString &comments) +{ + if("" != comments){ + mWidgets.clear(); + mpComments->setText(comments); + mpComments->setVisible(true); + mpCommentsLabel->setVisible(true); + mWidgets << mpCommentsLabel; + mMediaViewer.loadWidgets(mWidgets, false); + mWidgets.clear(); + mWidgets << mpComments; + mMediaViewer.loadWidgets(mWidgets, true); + } +} + +void UBTeacherBarPreviewWidget::clean() +{ + mMediaViewer.cleanMedia(); + + foreach(QWidget* eachWidget, mStoredWidgets){ + delete eachWidget; + eachWidget = NULL; + } + mStoredWidgets.clear(); + + hideElements(); +} + +void UBTeacherBarPreviewWidget::hideElements() +{ + mpActionsLabel = new QLabel(tr("Actions"), this); + mpActionsLabel->setObjectName("UBTeacherBarPreviewSubtitle"); + mpMediaLabel = new QLabel(tr("Medias"), this); + mpMediaLabel->setObjectName("UBTeacherBarPreviewSubtitle"); + mpCommentsLabel = new QLabel(tr("Comments"), this); + mpCommentsLabel->setObjectName("UBTeacherBarPreviewSubtitle"); + mpComments = new QLabel(this); + mpComments->setWordWrap(true); + mpComments->setObjectName("UBTeacherBarPreviewComments"); + mpLinksLabel = new QLabel(tr("Links"), this); + mpLinksLabel->setObjectName("UBTeacherBarPreviewSubtitle"); + + mpActionsLabel->setVisible(false); + mpMediaLabel->setVisible(false); + mpCommentsLabel->setVisible(false); + mpComments->setVisible(false); + mpLinksLabel->setVisible(false); +} + +void UBTeacherBarPreviewWidget::setActions(QStringList actions) +{ + if(!actions.empty()){ + mWidgets.clear(); + mpActionsLabel->setVisible(true); + mWidgets << mpActionsLabel; + mediaViewer()->loadWidgets(mWidgets,false); + mWidgets.clear(); + foreach(QString action, actions){ + QStringList desc = action.split(';'); + if(2 <= desc.size()){ + QString owner = desc.at(0); + QString act = desc.at(1); + mpTmpAction = new UBActionPreview(this); + mpTmpAction->setOwner(owner); + mpTmpAction->setContent(act); + mWidgets << mpTmpAction; + } + } + mMediaViewer.loadWidgets(mWidgets, true); + } +} + +void UBTeacherBarPreviewWidget::setLinks(QStringList links) +{ + if(!links.empty()){ + mWidgets.clear(); + mpLinksLabel->setVisible(true); + mWidgets << mpLinksLabel; + mMediaViewer.loadWidgets(mWidgets, false); + mWidgets.clear(); + foreach(QString link, links){ + mpTmpLink = new QLabel(link, this); + mpTmpLink->setOpenExternalLinks(true); + mWidgets << mpTmpLink; + } + mMediaViewer.loadWidgets(mWidgets, true); + } +} + +void UBTeacherBarPreviewWidget::loadInfos(sTeacherBarInfos *infos) +{ + if(NULL != infos){ + setTitle(infos->title); + mediaViewer()->loadMedia(infos->medias); + + // Add the comments + //setComments(); + } +} diff --git a/src/gui/UBTeacherBarPreviewWidget.h b/src/gui/UBTeacherBarPreviewWidget.h new file mode 100644 index 00000000..69f853dc --- /dev/null +++ b/src/gui/UBTeacherBarPreviewWidget.h @@ -0,0 +1,96 @@ +#ifndef UBTEACHERBARPREVIEWWIDGET_H +#define UBTEACHERBARPREVIEWWIDGET_H + +#include +#include +#include + +#include "core/UBPersistenceManager.h" +#include "customWidgets/UBWidgetList.h" +#include "UBTeacherBarDataMgr.h" + +class UBTeacherBarPreviewMedia : public QWidget +{ + Q_OBJECT +public: + UBTeacherBarPreviewMedia(QWidget* parent=0, const char* name="UBTeacherBarPreviewMedia"); + ~UBTeacherBarPreviewMedia(); + int loadMedia(QStringList pMedias); + void loadWidgets(QList pWidgetList, bool isResizable = true); + void cleanMedia(); + +private: + UBWidgetList* mWidget; + QVBoxLayout mLayout; + QMapmWidgetList; +}; + +class UBActionPreview : public QWidget +{ +public: + UBActionPreview(QWidget* parent=0, const char* name="UBActionPreview"); + ~UBActionPreview(); + void setOwner(const QString& owner); + void setContent(const QString& content); + +private: + QLabel* mpOwner; + QLabel* mpContent; + + QVBoxLayout mLayout; + QHBoxLayout mOwnerLayout; +}; + +class UBTBPreviewContainer : public UBWidgetList +{ +public: + UBTBPreviewContainer(QWidget* parent=0, const char* name="UBTBPreviewContainer"); + ~UBTBPreviewContainer(); +}; + +class UBTeacherBarPreviewWidget : public QWidget +{ + Q_OBJECT +public: + UBTeacherBarPreviewWidget(UBTeacherBarDataMgr* pDataMgr, QWidget* parent=0, const char* name="UBTeacherBarPreviewWidget"); + ~UBTeacherBarPreviewWidget(); + UBTeacherBarPreviewMedia* mediaViewer() {return &mMediaViewer;} + void setTitle(const QString& title); + void setComments(const QString& comments); + void setActions(QStringList actions); + void setLinks(QStringList links); + void clean(); + QLabel* mediaLabel() { return mpMediaLabel;} + void loadInfos(sTeacherBarInfos* infos); + +signals: + void showEditMode(); + +private slots: + void onEdit(); + +private: + void hideElements(); + + QVBoxLayout mLayout; + QHBoxLayout mEditLayout; + QHBoxLayout mTitleDurationLayout; + UBTeacherBarPreviewMedia mMediaViewer; + QList mWidgets; + QList mStoredWidgets; + + QPushButton* mpEditButton; + QLabel* mpTitle; + QLabel* mpDuration; + QLabel* mpActionsLabel; + QLabel* mpMediaLabel; + QLabel* mpCommentsLabel; + QLabel* mpComments; + QLabel* mpLinksLabel; + QLabel* mpTmpLink; + UBActionPreview* mpTmpAction; + UBTBPreviewContainer* mpContentContainer; + UBTeacherBarDataMgr* mpDataMgr; +}; + +#endif // UBTEACHERBARPREVIEWWIDGET_H diff --git a/src/gui/UBTeacherBarWidget.cpp b/src/gui/UBTeacherBarWidget.cpp index 6201f0d1..0ac3107d 100644 --- a/src/gui/UBTeacherBarWidget.cpp +++ b/src/gui/UBTeacherBarWidget.cpp @@ -13,8 +13,6 @@ #include "gui/UBMediaPlayer.h" -#include "frameworks/UBFileSystemUtils.h" - #include "customWidgets/UBDraggableLabel.h" #include "customWidgets/UBMediaWidget.h" #include "customWidgets/UBGlobals.h" @@ -22,34 +20,15 @@ #include "core/memcheck.h" UBTeacherBarWidget::UBTeacherBarWidget(QWidget *parent, const char *name):UBDockPaletteWidget(parent) - , mpLayout(NULL) - , mpTitleLayout(NULL) - , mpTitleLabel(NULL) - , mpTitle(NULL) - , mpMediaLabel(NULL) - , mpContainer(NULL) - , mpContainerLayout(NULL) - , mpActionLabel(NULL) - , mpActions(NULL) - , mpActionButton(NULL) - , mpActionLayout(NULL) - , mpCommentLabel(NULL) - , mpComments(NULL) - , mpLinkLabel(NULL) - , mpLinks(NULL) - , mpLinkButton(NULL) - , mpLinkLayout(NULL) , mpStackWidget(NULL) , mpPreview(NULL) - , mpMediaContainer(NULL) , mpDocPreviewWidget(NULL) , mpDocEditWidget(NULL) -{ + { setObjectName(name); mName = "TeacherBarWidget"; mVisibleState = true; - mActionList.clear(); - mUrlList.clear(); + mData.clearLists(); setAttribute(Qt::WA_StyledBackground, true); setStyleSheet(UBApplication::globalStyleSheet()); @@ -58,110 +37,35 @@ UBTeacherBarWidget::UBTeacherBarWidget(QWidget *parent, const char *name):UBDock mIconToRight = QPixmap(":images/teacher_close.png"); // Create the GUI - mpContainerLayout = new QVBoxLayout(this); - setLayout(mpContainerLayout); - - mpContainer = new QWidget(this); - mpContainer->setObjectName("DockPaletteWidgetBox"); + setLayout(&mLayout); - mpPreview = new UBTeacherBarPreviewWidget(this); - mpDocPreviewWidget = new UBTBDocumentPreviewWidget(this); - mpDocEditWidget = new UBTBDocumentEditWidget(this); + mpPageEditWidget = new UBTBPageEditWidget(&mData, this); + mpPreview = new UBTeacherBarPreviewWidget(&mData, this); + mpDocPreviewWidget = new UBTBDocumentPreviewWidget(&mData, this); + mpDocEditWidget = new UBTBDocumentEditWidget(&mData, this); mpStackWidget = new QStackedWidget(this); - mpContainerLayout->addWidget(mpStackWidget); - mpStackWidget->addWidget(mpContainer); + mLayout.addWidget(mpStackWidget); + mpStackWidget->addWidget(mpPageEditWidget); mpStackWidget->addWidget(mpPreview); mpStackWidget->addWidget(mpDocPreviewWidget); mpStackWidget->addWidget(mpDocEditWidget); - mpLayout = new QVBoxLayout(mpContainer); - mpContainer->setLayout(mpLayout); - - // Title - mpTitleLabel = new QLabel(tr("Title"), mpContainer); - mpTitle = new QLineEdit(mpContainer); - mpTitle->setObjectName("DockPaletteWidgetLineEdit"); - connect(mpTitle, SIGNAL(textChanged(const QString&)), this, SLOT(onTitleTextChanged(const QString&))); - mpLayout->addWidget(mpTitleLabel, 0); - mpLayout->addWidget(mpTitle, 0); - - // Actions - mpActionLabel = new QLabel(tr("Actions"), mpContainer); - mpLayout->addWidget(mpActionLabel, 0); - mpActions = new UBWidgetList(mpContainer); - mpActions->setEmptyText(tr("Add actions")); - mpLayout->addWidget(mpActions, 1); - mpActionButton = new QPushButton(mpContainer); - mpActionButton->setObjectName("DockPaletteWidgetButton"); - mpActionButton->setText(tr("Add action")); - mpActionLayout = new QHBoxLayout(); - mpActionLayout->addWidget(mpActionButton, 0); - mpActionLayout->addStretch(1); - mpLayout->addLayout(mpActionLayout, 0); - - // Media - mpMediaLabel = new QLabel(tr("Medias"), mpContainer); - mpLayout->addWidget(mpMediaLabel, 0); - mpMediaContainer = new UBTBMediaContainer(this); - mpMediaContainer->setEmptyText(tr("Drop media here")); - mpLayout->addWidget(mpMediaContainer, 1); - - // Links - mpLinkLabel = new QLabel(tr("Links"), mpContainer); - mpLayout->addWidget(mpLinkLabel, 0); - mpLinks = new UBWidgetList(mpContainer); - mpLayout->addWidget(mpLinks, 1); - mpLinkButton = new QPushButton(tr("Add link"), mpContainer); - mpLinkButton->setObjectName("DockPaletteWidgetButton"); - mpLinkLayout = new QHBoxLayout(); - mpLinkLayout->addWidget(mpLinkButton, 0); - mpLinkLayout->addStretch(1); - mpLayout->addLayout(mpLinkLayout, 0); - - // Comments - mpCommentLabel = new QLabel(tr("Comments"), mpContainer); - mpLayout->addWidget(mpCommentLabel, 0); - mpComments = new QTextEdit(this); - mpComments->setObjectName("DockPaletteWidgetBox"); - mpComments->setStyleSheet("background:white;"); - mpLayout->addWidget(mpComments, 1); - connect(UBApplication::boardController, SIGNAL(activeSceneWillChange()), this, SLOT(saveContent())); connect(UBApplication::boardController, SIGNAL(activeSceneChanged()), this, SLOT(loadContent())); connect(UBApplication::mainWindow->actionQuit, SIGNAL(triggered()), this, SLOT(saveContent())); - connect(mpTitle, SIGNAL(textChanged(QString)), this, SLOT(onValueChanged())); - connect(mpActionButton, SIGNAL(clicked()), this, SLOT(onActionButton())); - connect(mpLinkButton, SIGNAL(clicked()), this, SLOT(onLinkButton())); + connect(mpPreview, SIGNAL(showEditMode()), this, SLOT(onShowEditMode())); - connect(mpMediaContainer, SIGNAL(mediaDropped(QString)), this, SLOT(onMediaDropped(QString))); - connect(mpDocPreviewWidget, SIGNAL(onEditClicked()), this, SLOT(onTBStateChanged(eTeacherBarState))); - connect(mpDocPreviewWidget, SIGNAL(onPageViewClicked()), this, SLOT(onTBStateChanged(eTeacherBarState))); - connect(mpDocEditWidget, SIGNAL(onPageViewClicked()), this, SLOT(onTBStateChanged(eTeacherBarState))); - connect(mpDocEditWidget, SIGNAL(onPreviewClicked()), this, SLOT(onTBStateChanged(eTeacherBarState))); + connect(mpDocPreviewWidget, SIGNAL(changeTBState(eTeacherBarState)), this, SLOT(onTBStateChanged(eTeacherBarState))); + connect(mpDocEditWidget, SIGNAL(changeTBState(eTeacherBarState)), this, SLOT(onTBStateChanged(eTeacherBarState))); + connect(mpPageEditWidget, SIGNAL(changeTBState(eTeacherBarState)), this, SLOT(onTBStateChanged(eTeacherBarState))); } UBTeacherBarWidget::~UBTeacherBarWidget() { DELETEPTR(mpDocPreviewWidget); DELETEPTR(mpDocEditWidget); - DELETEPTR(mpMediaContainer); - DELETEPTR(mpComments); - DELETEPTR(mpCommentLabel); - DELETEPTR(mpLinks); - DELETEPTR(mpLinkLabel); - DELETEPTR(mpLinkButton); - DELETEPTR(mpLinkLayout); - DELETEPTR(mpMediaLabel); - DELETEPTR(mpActionButton); - DELETEPTR(mpActionLayout); - DELETEPTR(mpActionLabel); - DELETEPTR(mpTitleLabel); - DELETEPTR(mpTitle); - DELETEPTR(mpTitleLayout); - DELETEPTR(mpLayout); - DELETEPTR(mpContainer); - DELETEPTR(mpContainerLayout); + DELETEPTR(mpPageEditWidget); DELETEPTR(mpPreview); DELETEPTR(mpStackWidget); } @@ -185,199 +89,114 @@ void UBTeacherBarWidget::onValueChanged() void UBTeacherBarWidget::saveContent() { sTeacherBarInfos infos; - // Title - infos.title = mpTitle->text(); - - // Actions - for(int i=0; icomboValue()).arg(mActionList.at(i)->text()); - } - // Media - foreach(QString media, mpMediaContainer->mediaUrls()){ - infos.medias << media; - } - - // Links - for(int j=0; jurl()){ - infos.urls << mUrlList.at(j)->url(); - } - } - // Comments - infos.comments = mpComments->document()->toPlainText(); - + mpPageEditWidget->saveInfos(&infos); UBPersistenceManager::persistenceManager()->persistTeacherBar(UBApplication::boardController->activeDocument(), UBApplication::boardController->activeSceneIndex(), infos); } void UBTeacherBarWidget::loadContent() { - clearWidgetLists(); - sTeacherBarInfos nextInfos = UBPersistenceManager::persistenceManager()->getTeacherBarInfos(UBApplication::boardController->activeDocument(), UBApplication::boardController->activeSceneIndex()); - // Title - mpTitle->setText(nextInfos.title); - - // Actions - for(int i=0; i= 2){ - UBTeacherStudentAction* pAction = new UBTeacherStudentAction(mpContainer); - pAction->setComboValue(qslAction.at(0).toInt()); - pAction->setText(qslAction.at(1)); - mActionList << pAction; - mpActions->addWidget(pAction); - } - } - // Media - foreach(QString url, nextInfos.medias){ - if("" != url){ - QWidget* pMedia = mpMediaContainer->generateMediaWidget(url); - if(NULL != pMedia){ - mMediaList << pMedia; - mpMediaContainer->addWidget(pMedia); - } - } - } - - // Links - for(int j=0; jsetUrl(qsUrl); - mUrlList << pLink; - mpLinks->addWidget(pLink); - } - } - // Comments - if(NULL != mpComments){ - mpComments->document()->setPlainText(nextInfos.comments); - } - - mpPreview->mediaViewer()->cleanMedia(); - - if(!isEmpty()){ - // Update the fields of the preview widget - mpPreview->setTitle(mpTitle->text()); - mpPreview->mediaViewer()->loadMedia(nextInfos.medias); - - mpStackWidget->setCurrentWidget(mpPreview); - mpPreview->clean(); - - // Add the actions - if(!mActionList.empty()){ - QStringList actions; - foreach(UBTeacherStudentAction* action, mActionList){ - QString desc = QString("%0;%1").arg(action->comboValue()).arg(action->text()); - actions << desc; - } - mpPreview->setActions(actions); - } - - // Add the media - if(nextInfos.medias.count() > 0){ - QList widgetList; - widgetList.append(mpPreview->mediaLabel()); - mpPreview->mediaViewer()->loadWidgets(widgetList,false); - int loadedMedia = mpPreview->mediaViewer()->loadMedia(nextInfos.medias); - if(loadedMedia) - mpPreview->mediaLabel()->setVisible(true); - } - - - // Add the links - if(!mUrlList.empty()){ - QStringList links; - foreach(UBUrlWidget* url, mUrlList){ - QStringList list = url->url().split(";"); - QString formedlink = "" + list.at(1) + ""; - links << formedlink; - } - mpPreview->setLinks(links); - } - - // Add the comments - mpPreview->setComments(mpComments->document()->toPlainText()); - } - else{ - mpStackWidget->setCurrentWidget(mpContainer); - } - - +// clearWidgetLists(); +// sTeacherBarInfos nextInfos = UBPersistenceManager::persistenceManager()->getTeacherBarInfos(UBApplication::boardController->activeDocument(), UBApplication::boardController->activeSceneIndex()); + +// mpPageEditWidget->loadInfos(&nextInfos); +// mpPreview->mediaViewer()->cleanMedia(); + +// if(!isEmpty()){ +// // Update the fields of the preview widget +// onTBStateChanged(eTeacherBarState_PagePreview); +// mpPreview->clean(); +// mpPreview->loadInfos(&nextInfos); + +// // Add the actions +// if(!mActionList.empty()){ +// QStringList actions; +// foreach(UBTeacherStudentAction* action, mActionList){ +// QString desc = QString("%0;%1").arg(action->comboValue()).arg(action->text()); +// actions << desc; +// } +// mpPreview->setActions(actions); +// } + +// // Add the media +// if(nextInfos.medias.count() > 0){ +// QList widgetList; +// widgetList.append(mpPreview->mediaLabel()); +// mpPreview->mediaViewer()->loadWidgets(widgetList,false); +// int loadedMedia = mpPreview->mediaViewer()->loadMedia(nextInfos.medias); +// if(loadedMedia) +// mpPreview->mediaLabel()->setVisible(true); +// } + + +// // Add the links +// if(!mUrlList.empty()){ +// QStringList links; +// foreach(UBUrlWidget* url, mUrlList){ +// QStringList list = url->url().split(";"); +// QString formedlink = "" + list.at(1) + ""; +// links << formedlink; +// } +// mpPreview->setLinks(links); +// } +// } +// else{ +// // If the document has only one page, show the document edit page +// if(1 == UBApplication::boardController->activeDocument()->pageCount()){ +// onTBStateChanged(eTeacherBarState_DocumentEdit); +// }else{ +// onTBStateChanged(eTeacherBarState_PageEdit); +// } +// } } bool UBTeacherBarWidget::isEmpty() { - return mpTitle->text() == "" && - mpLinks->empty() && - mpActions->empty() && - mpMediaContainer->empty() && - mpComments->document()->toPlainText() == ""; + return mData.pageTitle() == "" && + mData.urls().empty() && + mData.actions().empty() && + mData.medias().empty() && + mData.comments() == ""; } void UBTeacherBarWidget::onTitleTextChanged(const QString& text) { - mpTitle->setToolTip(text); -} - -void UBTeacherBarWidget::onActionButton() -{ - UBTeacherStudentAction* pAction = new UBTeacherStudentAction(mpContainer); - mActionList << pAction; - mpActions->addWidget(pAction); -} - -void UBTeacherBarWidget::onLinkButton() -{ - UBUrlWidget* pUrl = new UBUrlWidget(mpContainer); - mUrlList << pUrl; - mpLinks->addWidget(pUrl); + //mpTitle->setToolTip(text); } void UBTeacherBarWidget::clearWidgetLists() { - if(NULL != mpMediaContainer){ - for(int i=0; iremoveWidget(mMediaList.at(i)); - delete mMediaList.at(i); - } - mMediaList.clear(); - mpMediaContainer->cleanMedias(); - } - - if(NULL != mpActions){ - for(int i=0; iremoveWidget(mActionList.at(i)); - delete mActionList.at(i); - } - mActionList.clear(); - } - - if(NULL != mpLinks){ - for(int i=0; iremoveWidget(mUrlList.at(i)); - delete mUrlList.at(i); - } - mUrlList.clear(); - } +// if(NULL != mpMediaContainer){ +// for(int i=0; iremoveWidget(mMediaList.at(i)); +// delete mMediaList.at(i); +// } +// mMediaList.clear(); +// mpMediaContainer->cleanMedias(); +// } + +// if(NULL != mpActions){ +// for(int i=0; iremoveWidget(mActionList.at(i)); +// delete mActionList.at(i); +// } +// mActionList.clear(); +// } + +// if(NULL != mpLinks){ +// for(int i=0; iremoveWidget(mUrlList.at(i)); +// delete mUrlList.at(i); +// } +// mUrlList.clear(); +// } } void UBTeacherBarWidget::onShowEditMode() { - mpStackWidget->setCurrentWidget(mpContainer); -} - -void UBTeacherBarWidget::onMediaDropped(const QString &url) -{ - if("" != url){ - QWidget* pMedia = mpMediaContainer->generateMediaWidget(url); - if(NULL != pMedia){ - mMediaList << pMedia; - mpMediaContainer->addWidget(pMedia); - } - } + mpStackWidget->setCurrentWidget(mpPageEditWidget); } void UBTeacherBarWidget::onTBStateChanged(eTeacherBarState state) @@ -390,7 +209,7 @@ void UBTeacherBarWidget::onTBStateChanged(eTeacherBarState state) mpStackWidget->setCurrentWidget(mpDocPreviewWidget); break; case eTeacherBarState_PageEdit: - mpStackWidget->setCurrentWidget(mpContainer); + mpStackWidget->setCurrentWidget(mpPageEditWidget); break; case eTeacherBarState_PagePreview: mpStackWidget->setCurrentWidget(mpPreview); @@ -398,668 +217,3 @@ void UBTeacherBarWidget::onTBStateChanged(eTeacherBarState state) } } -// --------------------------------------------------------------------------------------------- -UBTeacherStudentAction::UBTeacherStudentAction(QWidget *parent, const char *name):QWidget(parent) - , mpText(NULL) - , mpLayout(NULL) - , mpComboLayout(NULL) - , mpCombo(NULL) -{ - setObjectName(name); - - setAttribute(Qt::WA_StyledBackground, true); - setStyleSheet(UBApplication::globalStyleSheet()); - - // Create the GUI - mpLayout = new QHBoxLayout(this); - setLayout(mpLayout); - - mpComboLayout = new QVBoxLayout(); - - mpCombo = new QComboBox(this); - mpCombo->setObjectName("DockPaletteWidgetComboBox"); - mpCombo->setMinimumWidth(80); - mpCombo->addItem(tr("Teacher")); - mpCombo->addItem(tr("Student")); - mpComboLayout->addWidget(mpCombo, 0); - mpComboLayout->addStretch(1); - - mpLayout->addLayout(mpComboLayout, 0); - - mpText = new QTextEdit(this); - mpText->setObjectName("DockPaletteWidgetBox"); - mpText->setStyleSheet("background:white;"); - - mpLayout->addWidget(mpText, 1); - -} - -UBTeacherStudentAction::~UBTeacherStudentAction() -{ - DELETEPTR(mpCombo); - DELETEPTR(mpText); - DELETEPTR(mpComboLayout); - DELETEPTR(mpLayout); -} - -QString UBTeacherStudentAction::text() -{ - QString str; - if(NULL != mpText){ - str = mpText->document()->toPlainText(); - } - return str; -} - -QString UBTeacherStudentAction::comboValue() -{ - QString str; - - if(NULL != mpCombo){ - str = QString("%0").arg(mpCombo->currentIndex()); - } - - return str; -} - -void UBTeacherStudentAction::setComboValue(int value) -{ - if(NULL != mpCombo){ - mpCombo->setCurrentIndex(value); - } -} - -void UBTeacherStudentAction::setText(const QString& text) -{ - if(NULL != mpText){ - mpText->document()->setPlainText(text); - } -} - -// --------------------------------------------------------------------------------------------- -UBUrlWidget::UBUrlWidget(QWidget *parent, const char *name):QWidget(parent) - , mpLayout(NULL) - , mpUrlLabel(NULL) - , mpUrl(NULL) -{ - setObjectName(name); - setAttribute(Qt::WA_StyledBackground, true); - setStyleSheet(UBApplication::globalStyleSheet()); - - mpLayout = new QVBoxLayout(this); - setLayout(mpLayout); - - mpLabelLayout = new QHBoxLayout(this); - mpUrlLabel = new QLabel(tr("Url"), this); - mpLabelLayout->addWidget(mpUrlLabel, 0); - mpUrl = new QLineEdit(this); - mpUrl->setObjectName("DockPaletteWidgetLineEdit"); - mpUrl->setMinimumHeight(20); - mpLabelLayout->addWidget(mpUrl, 1); - - mpTitleLayout = new QHBoxLayout(this); - mpTitleLabel = new QLabel(tr("Title"),this); - mpTitleLayout->addWidget(mpTitleLabel,0); - mpTitle = new QLineEdit(this); - mpTitle->setObjectName("DockPaletteWidgetLineEdit"); - mpTitle->setMinimumHeight(20); - mpTitleLayout->addWidget(mpTitle,1); - - mpLayout->addLayout(mpTitleLayout); - mpLayout->addLayout(mpLabelLayout); -} - -UBUrlWidget::~UBUrlWidget() -{ - DELETEPTR(mpTitle); - DELETEPTR(mpTitleLabel); - DELETEPTR(mpUrlLabel); - DELETEPTR(mpUrl); - DELETEPTR(mpTitleLayout); - DELETEPTR(mpLabelLayout); - DELETEPTR(mpLayout); -} - -QString UBUrlWidget::url() -{ - QString str; - - if(NULL != mpUrl){ - str = mpUrl->text() + ";" + mpTitle->text(); - } - - return str; -} - -void UBUrlWidget::setUrl(const QString &url) -{ - QStringList list = url.split(";"); - if(NULL != mpUrl){ - mpUrl->setText(list.at(0)); - mpTitle->setText(list.at(1)); - } -} - -// ------------------------------------------------------------------------------------ -UBTeacherBarPreviewWidget::UBTeacherBarPreviewWidget(QWidget *parent, const char *name):QWidget(parent) - , mpEditButton(NULL) - , mpTitle(NULL) - , mpDuration(NULL) - , mpActionsLabel(NULL) - , mpMediaLabel(NULL) - , mpCommentsLabel(NULL) - , mpComments(NULL) - , mpLinksLabel(NULL) - , mpContentContainer(NULL) -{ - setObjectName(name); - - setLayout(&mLayout); - - setAttribute(Qt::WA_StyledBackground, true); - setStyleSheet(UBApplication::globalStyleSheet()); - - // Build the Preview widget - // Title + duration - mpTitle = new QLabel(this); - mpTitle->setObjectName("UBTeacherBarPreviewTitle"); - mpTitle->setWordWrap(true); - mpTitle->setAlignment(Qt::AlignCenter); - mpDuration = new QLabel(this); - mTitleDurationLayout.addWidget(mpTitle, 0); - mTitleDurationLayout.addWidget(mpDuration, 1); - mLayout.addLayout(&mTitleDurationLayout, 0); - - mpContentContainer = new UBTBPreviewContainer(this); - mLayout.addWidget(mpContentContainer, 1); - //mLayout.addWidget(&mMediaViewer, 1); - // The next line is disgusting. This is a quickfix that must be reworked later - mMediaViewer.setContentsMargins(-9, -9, -9, -9); - - hideElements(); - - // Edit button - mpEditButton = new QPushButton(tr("Edit infos"), this); - mpEditButton->setObjectName("DockPaletteWidgetButton"); - mEditLayout.addStretch(1); - mEditLayout.addWidget(mpEditButton, 0); - mEditLayout.addStretch(1); - mLayout.addLayout(&mEditLayout, 0); - - - connect(mpEditButton, SIGNAL(clicked()), this, SLOT(onEdit())); -} - -UBTeacherBarPreviewWidget::~UBTeacherBarPreviewWidget() -{ - DELETEPTR(mpLinksLabel); - DELETEPTR(mpComments); - DELETEPTR(mpTitle); - DELETEPTR(mpDuration); - DELETEPTR(mpActionsLabel); - DELETEPTR(mpMediaLabel); - DELETEPTR(mpCommentsLabel); - DELETEPTR(mpContentContainer); - DELETEPTR(mpEditButton); -} - -void UBTeacherBarPreviewWidget::onEdit() -{ - emit showEditMode(); -} - -void UBTeacherBarPreviewWidget::setTitle(const QString &title) -{ - if(NULL != mpTitle){ - mpTitle->setText(title); - } -} - -void UBTeacherBarPreviewWidget::setDuration(eDuration duration) -{ - if(NULL != mpDuration){ - QPixmap p; - switch(duration){ - case eDuration_Quarter: - p = QPixmap(":images/duration1.png"); - break; - case eDuration_Half: - p = QPixmap(":images/duration2.png"); - break; - case eDuration_ThreeQuarter: - p = QPixmap(":images/duration3.png"); - break; - default: - break; - } - mpDuration->setPixmap(p.scaledToHeight(16, Qt::SmoothTransformation)); - } -} - -void UBTeacherBarPreviewWidget::setComments(const QString &comments) -{ - if("" != comments){ - mWidgets.clear(); - mpComments->setText(comments); - mpComments->setVisible(true); - mpCommentsLabel->setVisible(true); - mWidgets << mpCommentsLabel; - mMediaViewer.loadWidgets(mWidgets, false); - mWidgets.clear(); - mWidgets << mpComments; - mMediaViewer.loadWidgets(mWidgets, true); - } -} - -void UBTeacherBarPreviewWidget::clean() -{ - mMediaViewer.cleanMedia(); - - foreach(QWidget* eachWidget, mStoredWidgets){ - delete eachWidget; - eachWidget = NULL; - } - mStoredWidgets.clear(); - - hideElements(); -} - -void UBTeacherBarPreviewWidget::hideElements() -{ - mpActionsLabel = new QLabel(tr("Actions"), this); - mpActionsLabel->setObjectName("UBTeacherBarPreviewSubtitle"); - mpMediaLabel = new QLabel(tr("Medias"), this); - mpMediaLabel->setObjectName("UBTeacherBarPreviewSubtitle"); - mpCommentsLabel = new QLabel(tr("Comments"), this); - mpCommentsLabel->setObjectName("UBTeacherBarPreviewSubtitle"); - mpComments = new QLabel(this); - mpComments->setWordWrap(true); - mpComments->setObjectName("UBTeacherBarPreviewComments"); - mpLinksLabel = new QLabel(tr("Links"), this); - mpLinksLabel->setObjectName("UBTeacherBarPreviewSubtitle"); - - mpActionsLabel->setVisible(false); - mpMediaLabel->setVisible(false); - mpCommentsLabel->setVisible(false); - mpComments->setVisible(false); - mpLinksLabel->setVisible(false); -} - -void UBTeacherBarPreviewWidget::setActions(QStringList actions) -{ - if(!actions.empty()){ - mWidgets.clear(); - mpActionsLabel->setVisible(true); - mWidgets << mpActionsLabel; - mediaViewer()->loadWidgets(mWidgets,false); - mWidgets.clear(); - foreach(QString action, actions){ - QStringList desc = action.split(';'); - if(2 <= desc.size()){ - QString owner = desc.at(0); - QString act = desc.at(1); - mpTmpAction = new UBActionPreview(this); - mpTmpAction->setOwner(owner); - mpTmpAction->setContent(act); - mWidgets << mpTmpAction; - } - } - mMediaViewer.loadWidgets(mWidgets, true); - } -} - -void UBTeacherBarPreviewWidget::setLinks(QStringList links) -{ - if(!links.empty()){ - mWidgets.clear(); - mpLinksLabel->setVisible(true); - mWidgets << mpLinksLabel; - mMediaViewer.loadWidgets(mWidgets, false); - mWidgets.clear(); - foreach(QString link, links){ - mpTmpLink = new QLabel(link, this); - mpTmpLink->setOpenExternalLinks(true); - mWidgets << mpTmpLink; - } - mMediaViewer.loadWidgets(mWidgets, true); - } -} - -// ------------------------------------------------------------------------------------ -UBTeacherBarPreviewMedia::UBTeacherBarPreviewMedia(QWidget* parent, const char* name) : QWidget(parent) -{ - setObjectName(name); - mWidget = new UBWidgetList(parent); - mLayout.addWidget(mWidget); - setLayout(&mLayout); - mWidgetList.clear(); -} - -UBTeacherBarPreviewMedia::~UBTeacherBarPreviewMedia() -{ - DELETEPTR(mWidget); -} - -void UBTeacherBarPreviewMedia::cleanMedia() -{ - foreach(QWidget* eachWidget, mWidgetList.keys()){ - if(QString(eachWidget->metaObject()->className()).contains("UBDraggable")){ - mWidget->removeWidget(eachWidget); - delete eachWidget; - eachWidget = NULL; - } - else{ - mWidget->removeWidget(eachWidget); - } - } - mWidgetList.clear(); -} - -void UBTeacherBarPreviewMedia::loadWidgets(QList pWidgetsList, bool isResizable) -{ - foreach(QWidget*eachWidget, pWidgetsList){ - mWidget->addWidget(eachWidget); - mWidgetList[eachWidget]="DRAG UNAVAILABLE"; - } -} - - -int UBTeacherBarPreviewMedia::loadMedia(QStringList pMedias) -{ - int addedMedia = 0; - foreach(QString eachString, pMedias){ - if(!eachString.isEmpty()){ - QString mimeType = UBFileSystemUtils::mimeTypeFromFileName(eachString); - if(mimeType.contains("image")){ - UBDraggableLabel* label = new UBDraggableLabel(); - label->loadImage(eachString); - mWidget->addWidget(label); - mWidgetList[label]=eachString; - addedMedia += 1; - } - else if(mimeType.contains("video") || mimeType.contains("audio")){ - UBDraggableMediaPlayer* mediaPlayer = new UBDraggableMediaPlayer(); - mediaPlayer->setFile(eachString); - mWidget->addWidget(mediaPlayer); - mWidgetList[mediaPlayer] = eachString; - addedMedia += 1; - } - else{ - qWarning() << "pMediaPath" << eachString; - qWarning() << "bad idea to come here"; - } - } - } - return addedMedia; -} - -// ----------------------------------------------------------------------------------------------- -UBActionPreview::UBActionPreview(QWidget *parent, const char *name):QWidget(parent) - , mpOwner(NULL) - , mpContent(NULL) -{ - setObjectName(name); - setLayout(&mLayout); - mpOwner = new QLabel(this); - mpOwner->setObjectName("UBActionPreviewOwner"); - mOwnerLayout.addWidget(mpOwner, 0); - mOwnerLayout.addStretch(1); - mLayout.addLayout(&mOwnerLayout); - mpContent = new QLabel(this); - mpContent->setObjectName("UBActionPreviewContent"); - mpContent->setWordWrap(true); - mLayout.addWidget(mpContent); - setContentsMargins(-9, -9, -9, -9); -} - -UBActionPreview::~UBActionPreview() -{ - if(NULL != mpOwner){ - delete mpOwner; - mpOwner = NULL; - } - if(NULL != mpContent){ - delete mpContent; - mpContent = NULL; - } -} - -void UBActionPreview::setOwner(const QString &owner) -{ - if(NULL != mpOwner && NULL != mpContent){ - switch(owner.toInt()){ - case eActionOwner_Teacher: - mpOwner->setText(tr("Teacher")); - mpContent->setStyleSheet("background:lightblue; border:lightblue;"); - break; - - case eActionOwner_Student: - mpOwner->setText(tr("Student")); - mpContent->setStyleSheet("background:lightgreen; border:lightgreen;"); - break; - } - } -} - -void UBActionPreview::setContent(const QString &content) -{ - if(NULL != mpContent){ - mpContent->setText(content); - } -} - -// ------------------------------------------------------------------------------------------------------------------------------------ -UBTBMediaContainer::UBTBMediaContainer(QWidget *parent, const char *name) : UBWidgetList(parent) -{ - setObjectName(name); - setAcceptDrops(true); -} - -UBTBMediaContainer::~UBTBMediaContainer() -{ - -} - -void UBTBMediaContainer::dropEvent(QDropEvent* pEvent) -{ - QPixmap pixFromDropEvent; - QString mimeType; - QString resourcePath; - if(pEvent->mimeData()->hasText()){ - resourcePath = pEvent->mimeData()->text(); - } - else if(pEvent->mimeData()->hasUrls()){ - resourcePath = pEvent->mimeData()->urls().at(0).toLocalFile(); - } - else if(pEvent->mimeData()->hasImage()){ - pixFromDropEvent.loadFromData(pEvent->mimeData()->imageData().toByteArray()); - if(!pixFromDropEvent.isNull()) - mimeType = "image"; - } - - if (mimeType.isEmpty() && resourcePath.isEmpty()){ - pEvent->acceptProposedAction(); - return; - } - if(!resourcePath.isEmpty()){ - emit mediaDropped(resourcePath); - pEvent->acceptProposedAction(); - } -} - -void UBTBMediaContainer::dragEnterEvent(QDragEnterEvent* pEvent) -{ - pEvent->acceptProposedAction(); -} - -void UBTBMediaContainer::dragMoveEvent(QDragMoveEvent* pEvent) -{ - pEvent->acceptProposedAction(); -} - -void UBTBMediaContainer::dragLeaveEvent(QDragLeaveEvent* pEvent) -{ - pEvent->accept(); -} - -void UBTBMediaContainer::addMedia(const QString& mediaPath) -{ - if(!mediaPath.isEmpty()) - mMediaList.append(mediaPath); - else - qWarning() << __FUNCTION__ << "empty path"; - - QString mimeType = UBFileSystemUtils::mimeTypeFromFileName(mediaPath); - if(mimeType.contains("image")){ - QPixmap pix = QPixmap(mediaPath); - QLabel* label = new QLabel(); - label->setPixmap(pix); - label->setScaledContents(true); - addWidget(label); - } - else if(mimeType.contains("video") || mimeType.contains("audio")){ - UBMediaPlayer* mediaPlayer = new UBMediaPlayer(); - mediaPlayer->setFile(mediaPath); - addWidget(mediaPlayer); - } - else{ - qWarning() << "pMediaPath" << mediaPath; - qWarning() << "bad idea to come here"; - } -} - -QStringList UBTBMediaContainer::mediaUrls() -{ - return mMediaList; -} - -void UBTBMediaContainer::cleanMedias() -{ - mMediaList.clear(); -} - -QWidget* UBTBMediaContainer::generateMediaWidget(const QString& url) -{ - QWidget* pW = NULL; - - if(!url.isEmpty()) - mMediaList.append(url); - else - qWarning() << __FUNCTION__ << "empty path"; - - QString mimeType = UBFileSystemUtils::mimeTypeFromFileName(url); - if(mimeType.contains("image")){ - QPixmap pix = QPixmap(url); - QLabel* label = new QLabel(); - pix.scaledToWidth(label->width()); - label->resize(pix.width(), pix.height()); - label->setPixmap(pix); - label->setScaledContents(true); - pW = label; - } - else if(mimeType.contains("video") || mimeType.contains("audio")){ - UBMediaWidget* mediaPlayer = new UBMediaWidget(mimeType.contains("audio")?eMediaType_Audio:eMediaType_Video); - mediaPlayer->setFile(url); - pW = mediaPlayer; - } - else{ - qWarning() << "pMediaPath" << url; - qWarning() << "bad idea to come here"; - } - - return pW; -} - -// ------------------------------------------------------------------------------------------------------------------- -UBTBPreviewContainer::UBTBPreviewContainer(QWidget *parent, const char *name):UBWidgetList(parent) -{ - setObjectName(name); -} - -UBTBPreviewContainer::~UBTBPreviewContainer() -{ - -} - -// ------------------------------------------------------------------------------------------------------------------- -UBTBDocumentEditWidget::UBTBDocumentEditWidget(QWidget *parent, const char *name):QWidget(parent) - , mpPageViewButton(NULL) - , mpPreviewButton(NULL) - , mpTitleLabel(NULL) - , mpTitle(NULL) - , mpTargetLabel(NULL) - , mpTarget(NULL) - , mpMetadataLabel(NULL) - , mpLicenseLabel(NULL) -{ - setObjectName(name); - setLayout(&mLayout); - - mpPageViewButton = new QPushButton(tr("Page View"), this); - mPageLayout.addStretch(1); - mPageLayout.addWidget(mpPageViewButton, 0); - mPageLayout.addStretch(1); - mLayout.addLayout(&mPageLayout); - - mpTitleLabel = new QLabel(tr("Session Title:"), this); - mpTitleLabel->setAlignment(Qt::AlignLeft); - mLayout.addWidget(mpTitleLabel); - mpTitle = new QLineEdit(this); - mLayout.addWidget(mpTitle); - - - mpPreviewButton = new QPushButton(tr("Preview"), this); - mPreviewLayout.addStretch(1); - mPreviewLayout.addWidget(mpPreviewButton, 0); - mPreviewLayout.addStretch(1); - mLayout.addLayout(&mPreviewLayout); - - connect(mpPageViewButton, SIGNAL(clicked()), this, SIGNAL(onPageViewClicked())); - connect(mpPreviewButton, SIGNAL(clicked()), this, SIGNAL(onPreviewClicked())); -} - -UBTBDocumentEditWidget::~UBTBDocumentEditWidget() -{ - DELETEPTR(mpTitleLabel); - DELETEPTR(mpTitle); - DELETEPTR(mpTargetLabel); - DELETEPTR(mpTarget); - DELETEPTR(mpMetadataLabel); - DELETEPTR(mpLicenseLabel); - DELETEPTR(mpPageViewButton); - DELETEPTR(mpPreviewButton); -} - -// ------------------------------------------------------------------------------------------------------------------- -UBTBDocumentPreviewWidget::UBTBDocumentPreviewWidget(QWidget *parent, const char *name):QWidget(parent) - , mpPageViewButton(NULL) - , mpEditButton(NULL) -{ - setObjectName(name); - setLayout(&mLayout); - - mpPageViewButton = new QPushButton(tr("Page View"), this); - mPageLayout.addStretch(1); - mPageLayout.addWidget(mpPageViewButton, 0); - mPageLayout.addStretch(1); - mLayout.addLayout(&mPageLayout); - - // TODO : Add the elements here - - mpEditButton = new QPushButton(tr("Edit"), this); - mPreviewLayout.addStretch(1); - mPreviewLayout.addWidget(mpEditButton, 0); - mPreviewLayout.addStretch(1); - mLayout.addLayout(&mPreviewLayout); - - connect(mpPageViewButton, SIGNAL(clicked()), this, SIGNAL(onPageViewClicked())); - connect(mpEditButton, SIGNAL(clicked()), this, SIGNAL(onEditClicked())); -} - -UBTBDocumentPreviewWidget::~UBTBDocumentPreviewWidget() -{ - DELETEPTR(mpPageViewButton); - DELETEPTR(mpEditButton); -} - - diff --git a/src/gui/UBTeacherBarWidget.h b/src/gui/UBTeacherBarWidget.h index ee74c7bc..ec486074 100644 --- a/src/gui/UBTeacherBarWidget.h +++ b/src/gui/UBTeacherBarWidget.h @@ -1,8 +1,6 @@ #ifndef UBTEACHERBARWIDGET_H #define UBTEACHERBARWIDGET_H -class UBMediaPlayer; - #include #include #include @@ -19,220 +17,14 @@ class UBMediaPlayer; #include "UBDockPaletteWidget.h" #include "customWidgets/UBWidgetList.h" #include "interfaces/IDropable.h" +#include "UBTeacherBarDataMgr.h" +#include "UBTBDocumentPreviewWidget.h" +#include "UBTBPageEditWidget.h" +#include "UBTeacherBarPreviewWidget.h" +#include "UBTBDocumentEditWidget.h" #define LABEL_MINWIDHT 80 -typedef enum{ - eTeacherBarState_DocumentEdit, - eTeacherBarState_DocumentPreview, - eTeacherBarState_PageEdit, - eTeacherBarState_PagePreview -}eTeacherBarState; - -typedef enum{ - eDuration_Quarter, - eDuration_Half, - eDuration_ThreeQuarter -}eDuration; - -typedef enum{ - eActionOwner_Teacher, - eActionOwner_Student -}eActionOwner; - -class UBTeacherStudentAction : public QWidget -{ - Q_OBJECT - -public: - UBTeacherStudentAction(QWidget* parent=0, const char* name="UBTeacherStudentAction"); - ~UBTeacherStudentAction(); - QString comboValue(); - QString text(); - void setComboValue(int value); - void setText(const QString& text); - -private: - QTextEdit* mpText; - QHBoxLayout* mpLayout; - QVBoxLayout* mpComboLayout; - QComboBox* mpCombo; -}; - -class UBTeacherBarPreviewMedia : public QWidget -{ - Q_OBJECT -public: - UBTeacherBarPreviewMedia(QWidget* parent=0, const char* name="UBTeacherBarPreviewMedia"); - ~UBTeacherBarPreviewMedia(); - int loadMedia(QStringList pMedias); - void loadWidgets(QList pWidgetList, bool isResizable = true); - void cleanMedia(); - -private: - UBWidgetList* mWidget; - QVBoxLayout mLayout; - QMapmWidgetList; -}; - -class UBUrlWidget : public QWidget -{ -public: - UBUrlWidget(QWidget* parent=0, const char* name="UBUrlWidget"); - ~UBUrlWidget(); - - QString url(); - void setUrl(const QString& url); - -private: - QVBoxLayout* mpLayout; - QHBoxLayout* mpLabelLayout; - QHBoxLayout* mpTitleLayout; - QLabel* mpUrlLabel; - QLineEdit* mpUrl; - - QLabel* mpTitleLabel; - QLineEdit* mpTitle; -}; - -class UBActionPreview : public QWidget -{ -public: - UBActionPreview(QWidget* parent=0, const char* name="UBActionPreview"); - ~UBActionPreview(); - void setOwner(const QString& owner); - void setContent(const QString& content); - -private: - QLabel* mpOwner; - QLabel* mpContent; - - QVBoxLayout mLayout; - QHBoxLayout mOwnerLayout; -}; - -class UBTBPreviewContainer : public UBWidgetList -{ -public: - UBTBPreviewContainer(QWidget* parent=0, const char* name="UBTBPreviewContainer"); - ~UBTBPreviewContainer(); -}; - -class UBTeacherBarPreviewWidget : public QWidget -{ - Q_OBJECT -public: - UBTeacherBarPreviewWidget(QWidget* parent=0, const char* name="UBTeacherBarPreviewWidget"); - ~UBTeacherBarPreviewWidget(); - UBTeacherBarPreviewMedia* mediaViewer() {return &mMediaViewer;} - void setTitle(const QString& title); - void setDuration(eDuration duration); - void setComments(const QString& comments); - void setActions(QStringList actions); - void setLinks(QStringList links); - void clean(); - QLabel* mediaLabel() { return mpMediaLabel;} - -signals: - void showEditMode(); - -private slots: - void onEdit(); - -private: - void hideElements(); - - QVBoxLayout mLayout; - QHBoxLayout mEditLayout; - QHBoxLayout mTitleDurationLayout; - UBTeacherBarPreviewMedia mMediaViewer; - QList mWidgets; - QList mStoredWidgets; - - QPushButton* mpEditButton; - QLabel* mpTitle; - QLabel* mpDuration; - QLabel* mpActionsLabel; - QLabel* mpMediaLabel; - QLabel* mpCommentsLabel; - QLabel* mpComments; - QLabel* mpLinksLabel; - QLabel* mpTmpLink; - UBActionPreview* mpTmpAction; - UBTBPreviewContainer* mpContentContainer; -}; - -class UBTBMediaContainer : public UBWidgetList - , public IDropable -{ - Q_OBJECT -public: - UBTBMediaContainer(QWidget* parent=0, const char* name="UBTBMediaContainer"); - ~UBTBMediaContainer(); - QStringList mediaUrls(); - QWidget* generateMediaWidget(const QString& url); - void cleanMedias(); - -signals: - void mediaDropped(const QString& url); - -protected: - void dropEvent(QDropEvent* pEvent); - void dragEnterEvent(QDragEnterEvent* pEvent); - void dragMoveEvent(QDragMoveEvent* pEvent); - void dragLeaveEvent(QDragLeaveEvent* pEvent); - -private: - void addMedia(const QString& mediaPath); - - QStringList mMediaList; -}; - -class UBTBDocumentEditWidget : public QWidget -{ - Q_OBJECT -public: - UBTBDocumentEditWidget(QWidget* parent=0, const char* name="UBTBDocumentEditWidget"); - ~UBTBDocumentEditWidget(); - -signals: - void onPreviewClicked(); - void onPageViewClicked(); - -private: - QVBoxLayout mLayout; - QHBoxLayout mPageLayout; - QHBoxLayout mPreviewLayout; - QPushButton* mpPageViewButton; - QPushButton* mpPreviewButton; - - QLabel* mpTitleLabel; - QLineEdit* mpTitle; - QLabel* mpTargetLabel; - QTextEdit* mpTarget; - QLabel* mpMetadataLabel; - QLabel* mpLicenseLabel; -}; - -class UBTBDocumentPreviewWidget : public QWidget -{ - Q_OBJECT -public: - UBTBDocumentPreviewWidget(QWidget* parent=0, const char* name="UBTBDocumentPreviewWidget"); - ~UBTBDocumentPreviewWidget(); - -signals: - void onEditClicked(); - void onPageViewClicked(); - -private: - QVBoxLayout mLayout; - QHBoxLayout mPageLayout; - QHBoxLayout mPreviewLayout; - QPushButton* mpPageViewButton; - QPushButton* mpEditButton; -}; - class UBTeacherBarWidget : public UBDockPaletteWidget { Q_OBJECT @@ -245,44 +37,23 @@ private slots: void loadContent(); void onValueChanged(); void onTitleTextChanged(const QString& text); - void onActionButton(); - void onLinkButton(); void onShowEditMode(); - void onMediaDropped(const QString& url); void onTBStateChanged(eTeacherBarState state); private: void clearWidgetLists(); bool isEmpty(); - QVBoxLayout* mpLayout; - QHBoxLayout* mpTitleLayout; - QLabel* mpTitleLabel; - QLineEdit* mpTitle; - QLabel* mpMediaLabel; - QWidget* mpContainer; - QVBoxLayout* mpContainerLayout; - QLabel* mpActionLabel; - UBWidgetList* mpActions; - QPushButton* mpActionButton; - QHBoxLayout* mpActionLayout; - QLabel* mpLinkLabel; - UBWidgetList* mpLinks; - QPushButton* mpLinkButton; - QHBoxLayout* mpLinkLayout; - QLabel* mpCommentLabel; - QTextEdit* mpComments; - QStackedWidget* mpStackWidget; - UBTeacherBarPreviewWidget* mpPreview; - QVector mActionList; - QVector mUrlList; - QVector mMediaList; - - UBTBMediaContainer* mpMediaContainer; + QVBoxLayout mLayout; + QStackedWidget* mpStackWidget; eTeacherBarState mState; + UBTBPageEditWidget* mpPageEditWidget; + UBTeacherBarPreviewWidget* mpPreview; UBTBDocumentPreviewWidget* mpDocPreviewWidget; UBTBDocumentEditWidget* mpDocEditWidget; + + UBTeacherBarDataMgr mData; }; #endif // UBTEACHERBARWIDGET_H diff --git a/src/gui/gui.pri b/src/gui/gui.pri index d1a187cd..5fa7ab62 100644 --- a/src/gui/gui.pri +++ b/src/gui/gui.pri @@ -47,7 +47,12 @@ HEADERS += src/gui/UBThumbnailView.h \ src/gui/UBLibWebView.h \ src/gui/UBDownloadWidget.h \ src/gui/UBDockDownloadWidget.h \ - src/gui/UBMediaPlayer.h + src/gui/UBMediaPlayer.h \ + src/gui/UBTeacherBarDataMgr.h \ + src/gui/UBTBDocumentEditWidget.h \ + src/gui/UBTBDocumentPreviewWidget.h \ + src/gui/UBTeacherBarPreviewWidget.h \ + src/gui/UBTBPageEditWidget.h SOURCES += src/gui/UBThumbnailView.cpp \ src/gui/UBFloatingPalette.cpp \ @@ -97,7 +102,12 @@ SOURCES += src/gui/UBThumbnailView.cpp \ src/gui/UBLibWebView.cpp \ src/gui/UBDownloadWidget.cpp \ src/gui/UBDockDownloadWidget.cpp \ - src/gui/UBMediaPlayer.cpp + src/gui/UBMediaPlayer.cpp \ + src/gui/UBTeacherBarDataMgr.cpp \ + src/gui/UBTBDocumentEditWidget.cpp \ + src/gui/UBTBDocumentPreviewWidget.cpp \ + src/gui/UBTeacherBarPreviewWidget.cpp \ + src/gui/UBTBPageEditWidget.cpp win32 { @@ -125,5 +135,3 @@ linux-g++-64 { SOURCES += src/gui/UBKeyboardPalette_linux.cpp } - - From 9ec91284124cf0c2826a24ddd7f469745ee5c791 Mon Sep 17 00:00:00 2001 From: shibakaneki Date: Fri, 20 Jan 2012 16:02:42 +0100 Subject: [PATCH 66/84] backup of the teacherbar rework --- src/gui/UBTBDocumentEditWidget.cpp | 10 ++ src/gui/UBTBDocumentEditWidget.h | 2 + src/gui/UBTBDocumentPreviewWidget.cpp | 9 ++ src/gui/UBTBDocumentPreviewWidget.h | 2 + src/gui/UBTBPageEditWidget.cpp | 219 +++++++++++++++++--------- src/gui/UBTBPageEditWidget.h | 51 +++++- src/gui/UBTeacherBarDataMgr.cpp | 115 +++++++------- src/gui/UBTeacherBarDataMgr.h | 58 ++----- src/gui/UBTeacherBarPreviewWidget.cpp | 13 +- src/gui/UBTeacherBarPreviewWidget.h | 3 +- src/gui/UBTeacherBarWidget.cpp | 128 ++++----------- src/gui/UBTeacherBarWidget.h | 2 - 12 files changed, 334 insertions(+), 278 deletions(-) diff --git a/src/gui/UBTBDocumentEditWidget.cpp b/src/gui/UBTBDocumentEditWidget.cpp index 17fa19a8..bf2b7190 100644 --- a/src/gui/UBTBDocumentEditWidget.cpp +++ b/src/gui/UBTBDocumentEditWidget.cpp @@ -86,3 +86,13 @@ void UBTBDocumentEditWidget::onPreview() { emit changeTBState(eTeacherBarState_DocumentPreview); } + +void UBTBDocumentEditWidget::updateFields() +{ + +} + +void UBTBDocumentEditWidget::clearFields() +{ + +} diff --git a/src/gui/UBTBDocumentEditWidget.h b/src/gui/UBTBDocumentEditWidget.h index f26559eb..705adcfe 100644 --- a/src/gui/UBTBDocumentEditWidget.h +++ b/src/gui/UBTBDocumentEditWidget.h @@ -15,6 +15,8 @@ class UBTBDocumentEditWidget : public QWidget public: UBTBDocumentEditWidget(UBTeacherBarDataMgr* pDataMgr, QWidget* parent=0, const char* name="UBTBDocumentEditWidget"); ~UBTBDocumentEditWidget(); + void updateFields(); + void clearFields(); signals: void changeTBState(eTeacherBarState state); diff --git a/src/gui/UBTBDocumentPreviewWidget.cpp b/src/gui/UBTBDocumentPreviewWidget.cpp index 818dfce5..39d75199 100644 --- a/src/gui/UBTBDocumentPreviewWidget.cpp +++ b/src/gui/UBTBDocumentPreviewWidget.cpp @@ -46,3 +46,12 @@ void UBTBDocumentPreviewWidget::onPageView() emit changeTBState(eTeacherBarState_PagePreview); } +void UBTBDocumentPreviewWidget::updateFields() +{ + +} + +void UBTBDocumentPreviewWidget::clearFields() +{ + +} diff --git a/src/gui/UBTBDocumentPreviewWidget.h b/src/gui/UBTBDocumentPreviewWidget.h index 0b426e3c..99959afa 100644 --- a/src/gui/UBTBDocumentPreviewWidget.h +++ b/src/gui/UBTBDocumentPreviewWidget.h @@ -12,6 +12,8 @@ class UBTBDocumentPreviewWidget : public QWidget public: UBTBDocumentPreviewWidget(UBTeacherBarDataMgr* pDataMgr, QWidget* parent=0, const char* name="UBTBDocumentPreviewWidget"); ~UBTBDocumentPreviewWidget(); + void updateFields(); + void clearFields(); signals: void changeTBState(eTeacherBarState state); diff --git a/src/gui/UBTBPageEditWidget.cpp b/src/gui/UBTBPageEditWidget.cpp index 121ab0b3..d596e806 100644 --- a/src/gui/UBTBPageEditWidget.cpp +++ b/src/gui/UBTBPageEditWidget.cpp @@ -25,6 +25,8 @@ UBTBPageEditWidget::UBTBPageEditWidget(UBTeacherBarDataMgr *pDataMgr, QWidget *p { Q_UNUSED(name); mpDataMgr = pDataMgr; + mActions.clear(); + mUrls.clear(); setAttribute(Qt::WA_StyledBackground, true); setStyleSheet(UBApplication::globalStyleSheet()); @@ -93,6 +95,7 @@ UBTBPageEditWidget::UBTBPageEditWidget(UBTeacherBarDataMgr *pDataMgr, QWidget *p mLayout.addLayout(&mPagePreviewLayout, 0); connect(mpTitle, SIGNAL(textChanged(QString)), this, SLOT(onValueChanged())); + connect(mpComments, SIGNAL(textChanged()), this, SLOT(onValueChanged())); connect(mpActionButton, SIGNAL(clicked()), this, SLOT(onActionButton())); connect(mpLinkButton, SIGNAL(clicked()), this, SLOT(onLinkButton())); connect(mpDocumentEditbutton, SIGNAL(clicked()), this, SLOT(onDocumentEditClicked())); @@ -126,14 +129,14 @@ void UBTBPageEditWidget::onValueChanged() void UBTBPageEditWidget::onActionButton() { UBTeacherStudentAction* pAction = new UBTeacherStudentAction(this); - mpDataMgr->actions() << pAction; + mActions << pAction; mpActions->addWidget(pAction); } void UBTBPageEditWidget::onLinkButton() { UBUrlWidget* pUrl = new UBUrlWidget(this); - mpDataMgr->urls() << pUrl; + mUrls << pUrl; mpLinks->addWidget(pUrl); } @@ -143,91 +146,87 @@ void UBTBPageEditWidget::onMediaDropped(const QString &url) QWidget* pMedia = mpMediaContainer->generateMediaWidget(url); if(NULL != pMedia){ mpDataMgr->medias() << pMedia; + mpDataMgr->addMediaUrl(url); mpMediaContainer->addWidget(pMedia); } } } - -void UBTBPageEditWidget::saveInfos(sTeacherBarInfos *infos) +void UBTBPageEditWidget::onDocumentEditClicked() { - if(NULL != infos){ - infos->title = mpTitle->text(); + emit changeTBState(eTeacherBarState_DocumentEdit); +} - // Actions - for(int i=0; iactions().size(); i++){ - infos->actions << QString("%0;%1").arg(mpDataMgr->actions().at(i)->comboValue()).arg(mpDataMgr->actions().at(i)->text()); - } - // Media - foreach(QString media, mpMediaContainer->mediaUrls()){ - infos->medias << media; - } +void UBTBPageEditWidget::onPagePreviewClicked() +{ + emit changeTBState(eTeacherBarState_PagePreview); +} - // Links - for(int j=0; jurls().size(); j++){ - if("" != mpDataMgr->urls().at(j)->url()){ - infos->urls << mpDataMgr->urls().at(j)->url(); - } - } - // Comments - infos->comments = mpComments->document()->toPlainText(); +void UBTBPageEditWidget::saveFields() +{ + mpDataMgr->actions()->clear(); + mpDataMgr->urls()->clear(); + foreach(UBTeacherStudentAction* pAct, mActions){ + sAction action; + action.type = pAct->comboValue().toInt(); + action.content = pAct->text(); + mpDataMgr->actions()->append(action); + } + foreach(UBUrlWidget* pUrl, mUrls){ + sLink link; + link.title = pUrl->title(); + link.link = pUrl->url(); + mpDataMgr->urls()->append(link); } + + // TODO : Medias } -void UBTBPageEditWidget::loadInfos(sTeacherBarInfos* infos) +void UBTBPageEditWidget::updateFields() { - if(NULL != infos){ - // Title - mpTitle->setText(infos->title); - mpDataMgr->setPageTitle(infos->title); - - // Actions - for(int i=0; iactions.size(); i++){ - QStringList qslAction = infos->actions.at(i).split(";"); - if(qslAction.size() >= 2){ - UBTeacherStudentAction* pAction = new UBTeacherStudentAction(this); - pAction->setComboValue(qslAction.at(0).toInt()); - pAction->setText(qslAction.at(1)); - mpDataMgr->actions() << pAction; - mpActions->addWidget(pAction); - } - } - // Media - foreach(QString url, infos->medias){ - if("" != url){ - QWidget* pMedia = mpMediaContainer->generateMediaWidget(url); - if(NULL != pMedia){ - mpDataMgr->medias() << pMedia; - mpMediaContainer->addWidget(pMedia); - } - } - } + mpTitle->setText(mpDataMgr->pageTitle()); + qDebug() << "mpComments will become: " << mpDataMgr->comments(); + + foreach(sAction action, *mpDataMgr->actions()){ + UBTeacherStudentAction* pAction = new UBTeacherStudentAction(this); + pAction->setComboValue(action.type); + pAction->setText(action.content); + mActions << pAction; + mpActions->addWidget(pAction); + } - // Links - for(int j=0; jurls.size(); j++){ - QString qsUrl = infos->urls.at(j); - if("" != qsUrl){ - UBUrlWidget* pLink = new UBUrlWidget(this); - pLink->setUrl(qsUrl); - mpDataMgr->urls() << pLink; - mpLinks->addWidget(pLink); - } - } - // Comments - if(NULL != mpComments){ - mpComments->document()->setPlainText(infos->comments); - } + foreach(sLink link, *mpDataMgr->urls()){ + UBUrlWidget* urlWidget = new UBUrlWidget(this); + urlWidget->setTitle(link.title); + urlWidget->setUrl(link.link); + mUrls << urlWidget; + mpLinks->addWidget(urlWidget); } -} -void UBTBPageEditWidget::onDocumentEditClicked() -{ - emit changeTBState(eTeacherBarState_DocumentEdit); + // TODO: add the medias + + qDebug() << "mpComments will become: " << mpDataMgr->comments(); + mpComments->setPlainText(mpDataMgr->comments()); } -void UBTBPageEditWidget::onPagePreviewClicked() +void UBTBPageEditWidget::clearFields() { - emit changeTBState(eTeacherBarState_PagePreview); + mpTitle->setText(""); + mpComments->setText(""); + foreach(UBTeacherStudentAction* pAction, mActions){ + mpActions->removeWidget(pAction); + DELETEPTR(pAction); + } + mActions.clear(); + + foreach(UBUrlWidget* pLink, mUrls){ + mpLinks->removeWidget(pLink); + DELETEPTR(pLink); + } + mUrls.clear(); + + // TODO: clean the media? + } // --------------------------------------------------------------------------------------------- @@ -287,10 +286,8 @@ QString UBUrlWidget::url() void UBUrlWidget::setUrl(const QString &url) { - QStringList list = url.split(";"); if(NULL != mpUrl){ - mpUrl->setText(list.at(0)); - mpTitle->setText(list.at(1)); + mpUrl->setText(url); } } @@ -415,3 +412,81 @@ QWidget* UBTBMediaContainer::generateMediaWidget(const QString& url) return pW; } + +UBTeacherStudentAction::UBTeacherStudentAction(QWidget *parent, const char *name):QWidget(parent) + , mpText(NULL) + , mpLayout(NULL) + , mpComboLayout(NULL) + , mpCombo(NULL) +{ + setObjectName(name); + + setAttribute(Qt::WA_StyledBackground, true); + setStyleSheet(UBApplication::globalStyleSheet()); + + // Create the GUI + mpLayout = new QHBoxLayout(this); + setLayout(mpLayout); + + mpComboLayout = new QVBoxLayout(); + + mpCombo = new QComboBox(this); + mpCombo->setObjectName("DockPaletteWidgetComboBox"); + mpCombo->setMinimumWidth(80); + mpCombo->addItem(tr("Teacher")); + mpCombo->addItem(tr("Student")); + mpComboLayout->addWidget(mpCombo, 0); + mpComboLayout->addStretch(1); + + mpLayout->addLayout(mpComboLayout, 0); + + mpText = new QTextEdit(this); + mpText->setObjectName("DockPaletteWidgetBox"); + mpText->setStyleSheet("background:white;"); + + mpLayout->addWidget(mpText, 1); + +} + +UBTeacherStudentAction::~UBTeacherStudentAction() +{ + DELETEPTR(mpCombo); + DELETEPTR(mpText); + DELETEPTR(mpComboLayout); + DELETEPTR(mpLayout); +} + +QString UBTeacherStudentAction::text() +{ + QString str; + if(NULL != mpText){ + str = mpText->document()->toPlainText(); + } + return str; +} + +QString UBTeacherStudentAction::comboValue() +{ + QString str; + + if(NULL != mpCombo){ + str = QString("%0").arg(mpCombo->currentIndex()); + } + + return str; +} + +void UBTeacherStudentAction::setComboValue(int value) +{ + if(NULL != mpCombo){ + mpCombo->setCurrentIndex(value); + } +} + +void UBTeacherStudentAction::setText(const QString& text) +{ + if(NULL != mpText){ + mpText->document()->setPlainText(text); + } +} + diff --git a/src/gui/UBTBPageEditWidget.h b/src/gui/UBTBPageEditWidget.h index ed766eaa..bbcd5576 100644 --- a/src/gui/UBTBPageEditWidget.h +++ b/src/gui/UBTBPageEditWidget.h @@ -14,6 +14,48 @@ #include "interfaces/IDropable.h" #include "UBTeacherBarDataMgr.h" +class UBTeacherStudentAction : public QWidget +{ + Q_OBJECT + +public: + UBTeacherStudentAction(QWidget* parent=0, const char* name="UBTeacherStudentAction"); + ~UBTeacherStudentAction(); + QString text(); + QString comboValue(); + void setComboValue(int value); + void setText(const QString& text); + +private: + QTextEdit* mpText; + QHBoxLayout* mpLayout; + QVBoxLayout* mpComboLayout; + QComboBox* mpCombo; +}; + +class UBUrlWidget : public QWidget +{ +public: + UBUrlWidget(QWidget* parent=0, const char* name="UBUrlWidget"); + ~UBUrlWidget(); + + QString url(); + void setUrl(const QString& url); + + QString title(){return mpTitle->text();} + void setTitle(const QString& title){mpTitle->setText(title);} + +private: + QVBoxLayout* mpLayout; + QHBoxLayout* mpLabelLayout; + QHBoxLayout* mpTitleLayout; + QLabel* mpUrlLabel; + QLineEdit* mpUrl; + + QLabel* mpTitleLabel; + QLineEdit* mpTitle; +}; + class UBTBMediaContainer : public UBWidgetList , public IDropable { @@ -46,9 +88,9 @@ class UBTBPageEditWidget : public QWidget public: UBTBPageEditWidget(UBTeacherBarDataMgr* pDataMgr, QWidget* parent=0, const char* name="UBTBPageEditWidget"); ~UBTBPageEditWidget(); - - void saveInfos(sTeacherBarInfos* infos); - void loadInfos(sTeacherBarInfos* infos); + void saveFields(); + void updateFields(); + void clearFields(); signals: void valueChanged(); @@ -87,6 +129,9 @@ private: QPushButton* mpDocumentEditbutton; QPushButton* mpPagePreviewButton; QWidget* mpContainer; + + QVector mActions; + QVector mUrls; }; #endif // UBTBPAGEEDITWIDGET_H diff --git a/src/gui/UBTeacherBarDataMgr.cpp b/src/gui/UBTeacherBarDataMgr.cpp index 96faf37b..8ee86c8c 100644 --- a/src/gui/UBTeacherBarDataMgr.cpp +++ b/src/gui/UBTeacherBarDataMgr.cpp @@ -1,5 +1,8 @@ #include "core/UBApplication.h" +#include "core/UBPersistenceManager.h" +#include "board/UBBoardController.h" #include "customWidgets/UBGlobals.h" + #include "UBTeacherBarDataMgr.h" UBTeacherBarDataMgr::UBTeacherBarDataMgr() @@ -19,79 +22,75 @@ void UBTeacherBarDataMgr::clearLists() mMediaList.clear(); } -UBTeacherStudentAction::UBTeacherStudentAction(QWidget *parent, const char *name):QWidget(parent) - , mpText(NULL) - , mpLayout(NULL) - , mpComboLayout(NULL) - , mpCombo(NULL) +void UBTeacherBarDataMgr::saveContent() { - setObjectName(name); + // Store the page information in the UBZ + sTeacherBarInfos infos; - setAttribute(Qt::WA_StyledBackground, true); - setStyleSheet(UBApplication::globalStyleSheet()); + infos.title = mPageTitle; - // Create the GUI - mpLayout = new QHBoxLayout(this); - setLayout(mpLayout); + // Actions + foreach(sAction action, mActionList){ + infos.actions << QString("%0;%1").arg(action.type).arg(action.content); + } - mpComboLayout = new QVBoxLayout(); + // Media + foreach(QString media, mMediaUrls){ + infos.medias << media; + } - mpCombo = new QComboBox(this); - mpCombo->setObjectName("DockPaletteWidgetComboBox"); - mpCombo->setMinimumWidth(80); - mpCombo->addItem(tr("Teacher")); - mpCombo->addItem(tr("Student")); - mpComboLayout->addWidget(mpCombo, 0); - mpComboLayout->addStretch(1); + // Links + foreach(sLink link, mUrlList){ + if("" != link.title && "" != link.link){ + infos.urls << QString("%0;%1").arg(link.title).arg(link.link); + } + } - mpLayout->addLayout(mpComboLayout, 0); + // Comments + infos.comments = mComments; - mpText = new QTextEdit(this); - mpText->setObjectName("DockPaletteWidgetBox"); - mpText->setStyleSheet("background:white;"); + UBPersistenceManager::persistenceManager()->persistTeacherBar(UBApplication::boardController->activeDocument(), UBApplication::boardController->activeSceneIndex(), infos); - mpLayout->addWidget(mpText, 1); + // TODO: Store the document metadata somewhere } -UBTeacherStudentAction::~UBTeacherStudentAction() +void UBTeacherBarDataMgr::loadContent() { - DELETEPTR(mpCombo); - DELETEPTR(mpText); - DELETEPTR(mpComboLayout); - DELETEPTR(mpLayout); -} - -QString UBTeacherStudentAction::text() -{ - QString str; - if(NULL != mpText){ - str = mpText->document()->toPlainText(); + clearLists(); + + sTeacherBarInfos nextInfos = UBPersistenceManager::persistenceManager()->getTeacherBarInfos(UBApplication::boardController->activeDocument(), UBApplication::boardController->activeSceneIndex()); + + // Page Title + mPageTitle = nextInfos.title; + // Actions + foreach(QString eachAction, nextInfos.actions){ + QStringList qslAction = eachAction.split(";"); + if(2 <= qslAction.size()){ + sAction action; + action.type = qslAction.at(0).toInt(); + action.content = qslAction.at(1); + mActionList << action; + } } - return str; -} - -QString UBTeacherStudentAction::comboValue() -{ - QString str; - - if(NULL != mpCombo){ - str = QString("%0").arg(mpCombo->currentIndex()); + // Media URL + mMediaUrls = nextInfos.medias; + + // Links + foreach(QString eachUrl, nextInfos.urls){ + QStringList qslUrl = eachUrl.split(';'); + if(2 <= qslUrl.size()){ + sLink link; + link.title = qslUrl.at(0); + link.link = qslUrl.at(1); + mUrlList << link; + } } - return str; -} + // Comments + mComments = nextInfos.comments; -void UBTeacherStudentAction::setComboValue(int value) -{ - if(NULL != mpCombo){ - mpCombo->setCurrentIndex(value); - } -} + // TODO : Read the document metadata file and populate the metadata infos here -void UBTeacherStudentAction::setText(const QString& text) -{ - if(NULL != mpText){ - mpText->document()->setPlainText(text); - } } + diff --git a/src/gui/UBTeacherBarDataMgr.h b/src/gui/UBTeacherBarDataMgr.h index 43c809b9..96323fa6 100644 --- a/src/gui/UBTeacherBarDataMgr.h +++ b/src/gui/UBTeacherBarDataMgr.h @@ -22,44 +22,15 @@ typedef enum{ eActionOwner_Student }eActionOwner; -class UBTeacherStudentAction : public QWidget -{ - Q_OBJECT - -public: - UBTeacherStudentAction(QWidget* parent=0, const char* name="UBTeacherStudentAction"); - ~UBTeacherStudentAction(); - QString text(); - QString comboValue(); - void setComboValue(int value); - void setText(const QString& text); - -private: - QTextEdit* mpText; - QHBoxLayout* mpLayout; - QVBoxLayout* mpComboLayout; - QComboBox* mpCombo; -}; +typedef struct{ + int type; + QString content; +}sAction; -class UBUrlWidget : public QWidget -{ -public: - UBUrlWidget(QWidget* parent=0, const char* name="UBUrlWidget"); - ~UBUrlWidget(); - - QString url(); - void setUrl(const QString& url); - -private: - QVBoxLayout* mpLayout; - QHBoxLayout* mpLabelLayout; - QHBoxLayout* mpTitleLayout; - QLabel* mpUrlLabel; - QLineEdit* mpUrl; - - QLabel* mpTitleLabel; - QLineEdit* mpTitle; -}; +typedef struct{ + QString title; + QString link; +}sLink; class UBTeacherBarDataMgr { @@ -80,13 +51,15 @@ public: QString pageTitle(){return mPageTitle;} // Actions - QVector actions(){return mActionList;} + QVector* actions(){return &mActionList;} // Medias QVector medias(){return mMediaList;} + void addMediaUrl(const QString& url){mMediaUrls << url;} + QStringList mediaUrls(){return mMediaUrls;} // Urls - QVector urls(){return mUrlList;} + QVector* urls(){return &mUrlList;} // Comments void setComments(const QString& c){mComments = c;} @@ -94,6 +67,8 @@ public: // Others void clearLists(); + void saveContent(); + void loadContent(); private: QString mSessionTitle; @@ -101,9 +76,10 @@ private: QString mPageTitle; QString mComments; - QVector mActionList; - QVector mUrlList; + QVector mActionList; + QVector mUrlList; QVector mMediaList; + QStringList mMediaUrls; }; #endif // UBTEACHERBARDATAMGR_H diff --git a/src/gui/UBTeacherBarPreviewWidget.cpp b/src/gui/UBTeacherBarPreviewWidget.cpp index 7dbf450e..662996df 100644 --- a/src/gui/UBTeacherBarPreviewWidget.cpp +++ b/src/gui/UBTeacherBarPreviewWidget.cpp @@ -302,13 +302,12 @@ void UBTeacherBarPreviewWidget::setLinks(QStringList links) } } -void UBTeacherBarPreviewWidget::loadInfos(sTeacherBarInfos *infos) +void UBTeacherBarPreviewWidget::updateFields() +{ + +} + +void UBTeacherBarPreviewWidget::clearFields() { - if(NULL != infos){ - setTitle(infos->title); - mediaViewer()->loadMedia(infos->medias); - // Add the comments - //setComments(); - } } diff --git a/src/gui/UBTeacherBarPreviewWidget.h b/src/gui/UBTeacherBarPreviewWidget.h index 69f853dc..db70b142 100644 --- a/src/gui/UBTeacherBarPreviewWidget.h +++ b/src/gui/UBTeacherBarPreviewWidget.h @@ -61,7 +61,8 @@ public: void setLinks(QStringList links); void clean(); QLabel* mediaLabel() { return mpMediaLabel;} - void loadInfos(sTeacherBarInfos* infos); + void updateFields(); + void clearFields(); signals: void showEditMode(); diff --git a/src/gui/UBTeacherBarWidget.cpp b/src/gui/UBTeacherBarWidget.cpp index 0ac3107d..569a4d3e 100644 --- a/src/gui/UBTeacherBarWidget.cpp +++ b/src/gui/UBTeacherBarWidget.cpp @@ -59,6 +59,7 @@ UBTeacherBarWidget::UBTeacherBarWidget(QWidget *parent, const char *name):UBDock connect(mpDocPreviewWidget, SIGNAL(changeTBState(eTeacherBarState)), this, SLOT(onTBStateChanged(eTeacherBarState))); connect(mpDocEditWidget, SIGNAL(changeTBState(eTeacherBarState)), this, SLOT(onTBStateChanged(eTeacherBarState))); connect(mpPageEditWidget, SIGNAL(changeTBState(eTeacherBarState)), this, SLOT(onTBStateChanged(eTeacherBarState))); + connect(mpPageEditWidget, SIGNAL(valueChanged()), this, SLOT(onValueChanged())); } UBTeacherBarWidget::~UBTeacherBarWidget() @@ -88,110 +89,49 @@ void UBTeacherBarWidget::onValueChanged() void UBTeacherBarWidget::saveContent() { - sTeacherBarInfos infos; - mpPageEditWidget->saveInfos(&infos); - UBPersistenceManager::persistenceManager()->persistTeacherBar(UBApplication::boardController->activeDocument(), UBApplication::boardController->activeSceneIndex(), infos); + mpPageEditWidget->saveFields(); + mData.saveContent(); } void UBTeacherBarWidget::loadContent() { -// clearWidgetLists(); -// sTeacherBarInfos nextInfos = UBPersistenceManager::persistenceManager()->getTeacherBarInfos(UBApplication::boardController->activeDocument(), UBApplication::boardController->activeSceneIndex()); - -// mpPageEditWidget->loadInfos(&nextInfos); -// mpPreview->mediaViewer()->cleanMedia(); - -// if(!isEmpty()){ -// // Update the fields of the preview widget -// onTBStateChanged(eTeacherBarState_PagePreview); -// mpPreview->clean(); -// mpPreview->loadInfos(&nextInfos); - -// // Add the actions -// if(!mActionList.empty()){ -// QStringList actions; -// foreach(UBTeacherStudentAction* action, mActionList){ -// QString desc = QString("%0;%1").arg(action->comboValue()).arg(action->text()); -// actions << desc; -// } -// mpPreview->setActions(actions); -// } - -// // Add the media -// if(nextInfos.medias.count() > 0){ -// QList widgetList; -// widgetList.append(mpPreview->mediaLabel()); -// mpPreview->mediaViewer()->loadWidgets(widgetList,false); -// int loadedMedia = mpPreview->mediaViewer()->loadMedia(nextInfos.medias); -// if(loadedMedia) -// mpPreview->mediaLabel()->setVisible(true); -// } - - -// // Add the links -// if(!mUrlList.empty()){ -// QStringList links; -// foreach(UBUrlWidget* url, mUrlList){ -// QStringList list = url->url().split(";"); -// QString formedlink = "" + list.at(1) + ""; -// links << formedlink; -// } -// mpPreview->setLinks(links); -// } -// } -// else{ -// // If the document has only one page, show the document edit page -// if(1 == UBApplication::boardController->activeDocument()->pageCount()){ -// onTBStateChanged(eTeacherBarState_DocumentEdit); -// }else{ -// onTBStateChanged(eTeacherBarState_PageEdit); -// } -// } + // Clear the old datas + mpPageEditWidget->clearFields(); + mpPreview->clearFields(); + mpDocEditWidget->clearFields(); + mpDocPreviewWidget->clearFields(); + + // Update the datas + mData.loadContent(); + + qDebug() << mData.comments(); + + // Update the fields + mpPageEditWidget->updateFields(); + mpPreview->updateFields(); + mpDocEditWidget->updateFields(); + mpDocPreviewWidget->updateFields(); + + if(!isEmpty()){ + onTBStateChanged(eTeacherBarState_PagePreview); + }else{ + if(1 == UBApplication::boardController->activeDocument()->pageCount()){ + onTBStateChanged(eTeacherBarState_DocumentEdit); + }else{ + onTBStateChanged(eTeacherBarState_PageEdit); + } + } } bool UBTeacherBarWidget::isEmpty() { return mData.pageTitle() == "" && - mData.urls().empty() && - mData.actions().empty() && + mData.urls()->empty() && + mData.actions()->empty() && mData.medias().empty() && - mData.comments() == ""; -} - -void UBTeacherBarWidget::onTitleTextChanged(const QString& text) -{ - //mpTitle->setToolTip(text); -} - -void UBTeacherBarWidget::clearWidgetLists() -{ -// if(NULL != mpMediaContainer){ -// for(int i=0; iremoveWidget(mMediaList.at(i)); -// delete mMediaList.at(i); -// } -// mMediaList.clear(); -// mpMediaContainer->cleanMedias(); -// } - -// if(NULL != mpActions){ -// for(int i=0; iremoveWidget(mActionList.at(i)); -// delete mActionList.at(i); -// } -// mActionList.clear(); -// } - -// if(NULL != mpLinks){ -// for(int i=0; iremoveWidget(mUrlList.at(i)); -// delete mUrlList.at(i); -// } -// mUrlList.clear(); -// } + mData.comments() == "" && + mData.sessionTarget() == "" && + mData.sessionTitle() == ""; } void UBTeacherBarWidget::onShowEditMode() diff --git a/src/gui/UBTeacherBarWidget.h b/src/gui/UBTeacherBarWidget.h index ec486074..6b38645b 100644 --- a/src/gui/UBTeacherBarWidget.h +++ b/src/gui/UBTeacherBarWidget.h @@ -36,12 +36,10 @@ private slots: void saveContent(); void loadContent(); void onValueChanged(); - void onTitleTextChanged(const QString& text); void onShowEditMode(); void onTBStateChanged(eTeacherBarState state); private: - void clearWidgetLists(); bool isEmpty(); QVBoxLayout mLayout; From b9949772275e1d71cddace2611764e4dc14c4bf6 Mon Sep 17 00:00:00 2001 From: shibakaneki Date: Mon, 23 Jan 2012 09:38:51 +0100 Subject: [PATCH 67/84] Partial backup of the teacherbar rework --- src/gui/UBTBPageEditWidget.cpp | 15 +++++++++------ src/gui/UBTBPageEditWidget.h | 3 ++- src/gui/UBTeacherBarWidget.cpp | 2 -- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/gui/UBTBPageEditWidget.cpp b/src/gui/UBTBPageEditWidget.cpp index d596e806..693c3674 100644 --- a/src/gui/UBTBPageEditWidget.cpp +++ b/src/gui/UBTBPageEditWidget.cpp @@ -94,8 +94,8 @@ UBTBPageEditWidget::UBTBPageEditWidget(UBTeacherBarDataMgr *pDataMgr, QWidget *p mPagePreviewLayout.addStretch(1); mLayout.addLayout(&mPagePreviewLayout, 0); - connect(mpTitle, SIGNAL(textChanged(QString)), this, SLOT(onValueChanged())); - connect(mpComments, SIGNAL(textChanged()), this, SLOT(onValueChanged())); + connect(mpTitle, SIGNAL(textChanged(QString)), this, SLOT(onTitleChanged())); + connect(mpComments, SIGNAL(textChanged()), this, SLOT(onCommentsChanged())); connect(mpActionButton, SIGNAL(clicked()), this, SLOT(onActionButton())); connect(mpLinkButton, SIGNAL(clicked()), this, SLOT(onLinkButton())); connect(mpDocumentEditbutton, SIGNAL(clicked()), this, SLOT(onDocumentEditClicked())); @@ -119,9 +119,14 @@ UBTBPageEditWidget::~UBTBPageEditWidget() DELETEPTR(mpTitle); } -void UBTBPageEditWidget::onValueChanged() +void UBTBPageEditWidget::onTitleChanged() { mpDataMgr->setPageTitle(mpTitle->text()); + emit valueChanged(); +} + +void UBTBPageEditWidget::onCommentsChanged() +{ mpDataMgr->setComments(mpComments->document()->toPlainText()); emit valueChanged(); } @@ -185,7 +190,6 @@ void UBTBPageEditWidget::saveFields() void UBTBPageEditWidget::updateFields() { mpTitle->setText(mpDataMgr->pageTitle()); - qDebug() << "mpComments will become: " << mpDataMgr->comments(); foreach(sAction action, *mpDataMgr->actions()){ UBTeacherStudentAction* pAction = new UBTeacherStudentAction(this); @@ -205,8 +209,7 @@ void UBTBPageEditWidget::updateFields() // TODO: add the medias - qDebug() << "mpComments will become: " << mpDataMgr->comments(); - mpComments->setPlainText(mpDataMgr->comments()); + mpComments->document()->setPlainText(mpDataMgr->comments()); } void UBTBPageEditWidget::clearFields() diff --git a/src/gui/UBTBPageEditWidget.h b/src/gui/UBTBPageEditWidget.h index bbcd5576..fa56047d 100644 --- a/src/gui/UBTBPageEditWidget.h +++ b/src/gui/UBTBPageEditWidget.h @@ -97,7 +97,8 @@ signals: void changeTBState(eTeacherBarState state); private slots: - void onValueChanged(); + void onTitleChanged(); + void onCommentsChanged(); void onActionButton(); void onLinkButton(); void onMediaDropped(const QString& url); diff --git a/src/gui/UBTeacherBarWidget.cpp b/src/gui/UBTeacherBarWidget.cpp index 569a4d3e..75c8a978 100644 --- a/src/gui/UBTeacherBarWidget.cpp +++ b/src/gui/UBTeacherBarWidget.cpp @@ -104,8 +104,6 @@ void UBTeacherBarWidget::loadContent() // Update the datas mData.loadContent(); - qDebug() << mData.comments(); - // Update the fields mpPageEditWidget->updateFields(); mpPreview->updateFields(); From 247964f20b0904a4bf81643e81da469dcbee72af Mon Sep 17 00:00:00 2001 From: Claudio Valerio Date: Mon, 23 Jan 2012 10:25:00 +0100 Subject: [PATCH 68/84] removed double layer warning --- src/gui/UBTBPageEditWidget.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/UBTBPageEditWidget.cpp b/src/gui/UBTBPageEditWidget.cpp index 693c3674..ab1dc7a8 100644 --- a/src/gui/UBTBPageEditWidget.cpp +++ b/src/gui/UBTBPageEditWidget.cpp @@ -245,7 +245,7 @@ UBUrlWidget::UBUrlWidget(QWidget *parent, const char *name):QWidget(parent) mpLayout = new QVBoxLayout(this); setLayout(mpLayout); - mpLabelLayout = new QHBoxLayout(this); + mpLabelLayout = new QHBoxLayout(0); mpUrlLabel = new QLabel(tr("Url"), this); mpLabelLayout->addWidget(mpUrlLabel, 0); mpUrl = new QLineEdit(this); @@ -253,7 +253,7 @@ UBUrlWidget::UBUrlWidget(QWidget *parent, const char *name):QWidget(parent) mpUrl->setMinimumHeight(20); mpLabelLayout->addWidget(mpUrl, 1); - mpTitleLayout = new QHBoxLayout(this); + mpTitleLayout = new QHBoxLayout(0); mpTitleLabel = new QLabel(tr("Title"),this); mpTitleLayout->addWidget(mpTitleLabel,0); mpTitle = new QLineEdit(this); From 17be2c005025382a8515149ff25cf653658e767e Mon Sep 17 00:00:00 2001 From: shibakaneki Date: Mon, 23 Jan 2012 10:27:14 +0100 Subject: [PATCH 69/84] backup --- src/gui/UBTBPageEditWidget.cpp | 4 ++-- src/gui/UBTeacherBarDataMgr.h | 2 +- src/gui/UBTeacherBarWidget.cpp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/gui/UBTBPageEditWidget.cpp b/src/gui/UBTBPageEditWidget.cpp index 693c3674..22c017a9 100644 --- a/src/gui/UBTBPageEditWidget.cpp +++ b/src/gui/UBTBPageEditWidget.cpp @@ -150,7 +150,7 @@ void UBTBPageEditWidget::onMediaDropped(const QString &url) if("" != url){ QWidget* pMedia = mpMediaContainer->generateMediaWidget(url); if(NULL != pMedia){ - mpDataMgr->medias() << pMedia; + mpDataMgr->medias()->append(pMedia); mpDataMgr->addMediaUrl(url); mpMediaContainer->addWidget(pMedia); } @@ -228,7 +228,7 @@ void UBTBPageEditWidget::clearFields() } mUrls.clear(); - // TODO: clean the media? + mpMediaContainer->cleanMedias(); } diff --git a/src/gui/UBTeacherBarDataMgr.h b/src/gui/UBTeacherBarDataMgr.h index 96323fa6..2c299474 100644 --- a/src/gui/UBTeacherBarDataMgr.h +++ b/src/gui/UBTeacherBarDataMgr.h @@ -54,7 +54,7 @@ public: QVector* actions(){return &mActionList;} // Medias - QVector medias(){return mMediaList;} + QVector* medias(){return &mMediaList;} void addMediaUrl(const QString& url){mMediaUrls << url;} QStringList mediaUrls(){return mMediaUrls;} diff --git a/src/gui/UBTeacherBarWidget.cpp b/src/gui/UBTeacherBarWidget.cpp index 75c8a978..d0bbc85b 100644 --- a/src/gui/UBTeacherBarWidget.cpp +++ b/src/gui/UBTeacherBarWidget.cpp @@ -126,7 +126,7 @@ bool UBTeacherBarWidget::isEmpty() return mData.pageTitle() == "" && mData.urls()->empty() && mData.actions()->empty() && - mData.medias().empty() && + mData.medias()->empty() && mData.comments() == "" && mData.sessionTarget() == "" && mData.sessionTitle() == ""; From 4e6a17b6b9fc0ffcde3e1469d51f1f0e9149bf46 Mon Sep 17 00:00:00 2001 From: shibakaneki Date: Mon, 23 Jan 2012 10:54:49 +0100 Subject: [PATCH 70/84] Added the save / load media in the teacherbar --- src/gui/UBTBPageEditWidget.cpp | 36 ++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/src/gui/UBTBPageEditWidget.cpp b/src/gui/UBTBPageEditWidget.cpp index d1ba3c31..5e512d52 100644 --- a/src/gui/UBTBPageEditWidget.cpp +++ b/src/gui/UBTBPageEditWidget.cpp @@ -171,6 +171,7 @@ void UBTBPageEditWidget::saveFields() { mpDataMgr->actions()->clear(); mpDataMgr->urls()->clear(); + foreach(UBTeacherStudentAction* pAct, mActions){ sAction action; action.type = pAct->comboValue().toInt(); @@ -183,14 +184,13 @@ void UBTBPageEditWidget::saveFields() link.link = pUrl->url(); mpDataMgr->urls()->append(link); } - - // TODO : Medias } void UBTBPageEditWidget::updateFields() { + // Title mpTitle->setText(mpDataMgr->pageTitle()); - + // Actions foreach(sAction action, *mpDataMgr->actions()){ UBTeacherStudentAction* pAction = new UBTeacherStudentAction(this); pAction->setComboValue(action.type); @@ -198,7 +198,13 @@ void UBTBPageEditWidget::updateFields() mActions << pAction; mpActions->addWidget(pAction); } - + // Medias + foreach(QString url, mpDataMgr->mediaUrls()){ + QWidget* pWidget = mpMediaContainer->generateMediaWidget(url); + mpDataMgr->medias()->append(pWidget); + mpMediaContainer->addWidget(pWidget); + } + // Links foreach(sLink link, *mpDataMgr->urls()){ UBUrlWidget* urlWidget = new UBUrlWidget(this); urlWidget->setTitle(link.title); @@ -206,30 +212,36 @@ void UBTBPageEditWidget::updateFields() mUrls << urlWidget; mpLinks->addWidget(urlWidget); } - - // TODO: add the medias - + // Comments mpComments->document()->setPlainText(mpDataMgr->comments()); } void UBTBPageEditWidget::clearFields() { + // Title mpTitle->setText(""); - mpComments->setText(""); + // Actions foreach(UBTeacherStudentAction* pAction, mActions){ mpActions->removeWidget(pAction); DELETEPTR(pAction); } mActions.clear(); - + // Medias + foreach(QWidget* pMedia, *mpDataMgr->medias()){ + if(NULL != pMedia){ + mpMediaContainer->removeWidget(pMedia); + DELETEPTR(pMedia); + } + } + mpDataMgr->mediaUrls().clear(); + // Links foreach(UBUrlWidget* pLink, mUrls){ mpLinks->removeWidget(pLink); DELETEPTR(pLink); } mUrls.clear(); - - mpMediaContainer->cleanMedias(); - + // Comments + mpComments->setText(""); } // --------------------------------------------------------------------------------------------- From 2fcf84315b2ecc7a48f56e6b8223bdaf9a27b60b Mon Sep 17 00:00:00 2001 From: Claudio Valerio Date: Mon, 23 Jan 2012 15:30:18 +0100 Subject: [PATCH 71/84] fixed video issue on linux --- src/core/UBDisplayManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/UBDisplayManager.cpp b/src/core/UBDisplayManager.cpp index 6ecdc679..96c25059 100644 --- a/src/core/UBDisplayManager.cpp +++ b/src/core/UBDisplayManager.cpp @@ -48,7 +48,7 @@ UBDisplayManager::UBDisplayManager(QObject *parent) void UBDisplayManager::initScreenIndexes() { - int screenCount = numScreens(); + int screenCount = 1;//= numScreens(); mScreenIndexesRoles.clear(); From 95380fc88125a04f23b6446f2939406f5ec60e1f Mon Sep 17 00:00:00 2001 From: Claudio Valerio Date: Mon, 23 Jan 2012 15:30:30 +0100 Subject: [PATCH 72/84] fixed video issue on linux --- src/adaptors/UBImportDocument.cpp | 3 +- src/adaptors/UBImportImage.cpp | 1 - src/adaptors/UBImportPDF.cpp | 1 - src/customWidgets/UBMediaWidget.cpp | 29 +++++++++++--- src/customWidgets/UBMediaWidget.h | 1 + src/document/UBDocumentController.cpp | 2 - src/gui/UBTBPageEditWidget.cpp | 8 +++- src/gui/UBTeacherBarPreviewWidget.cpp | 56 +++++++++++++-------------- src/gui/UBTeacherBarPreviewWidget.h | 2 +- 9 files changed, 60 insertions(+), 43 deletions(-) diff --git a/src/adaptors/UBImportDocument.cpp b/src/adaptors/UBImportDocument.cpp index 17251ae5..f441b980 100644 --- a/src/adaptors/UBImportDocument.cpp +++ b/src/adaptors/UBImportDocument.cpp @@ -14,7 +14,6 @@ */ #include "UBImportDocument.h" -#include "UBMetadataDcSubsetAdaptor.h" #include "document/UBDocumentProxy.h" #include "frameworks/UBFileSystemUtils.h" @@ -49,7 +48,7 @@ QStringList UBImportDocument::supportedExtentions() QString UBImportDocument::importFileFilter() { - return tr("Sankore 3.1 (*.ubz)"); + return tr("Open-Sankore (*.ubz)"); } diff --git a/src/adaptors/UBImportImage.cpp b/src/adaptors/UBImportImage.cpp index 5418b1da..f2829dd6 100644 --- a/src/adaptors/UBImportImage.cpp +++ b/src/adaptors/UBImportImage.cpp @@ -14,7 +14,6 @@ */ #include "UBImportImage.h" -#include "UBMetadataDcSubsetAdaptor.h" #include "UBSvgSubsetAdaptor.h" #include "document/UBDocumentProxy.h" diff --git a/src/adaptors/UBImportPDF.cpp b/src/adaptors/UBImportPDF.cpp index b178b154..c8769996 100644 --- a/src/adaptors/UBImportPDF.cpp +++ b/src/adaptors/UBImportPDF.cpp @@ -14,7 +14,6 @@ */ #include "UBImportPDF.h" -#include "UBMetadataDcSubsetAdaptor.h" #include "UBSvgSubsetAdaptor.h" #include "document/UBDocumentProxy.h" diff --git a/src/customWidgets/UBMediaWidget.cpp b/src/customWidgets/UBMediaWidget.cpp index 572db702..c1809d93 100644 --- a/src/customWidgets/UBMediaWidget.cpp +++ b/src/customWidgets/UBMediaWidget.cpp @@ -103,6 +103,21 @@ eMediaType UBMediaWidget::mediaType() return mType; } +void UBMediaWidget::showEvent(QShowEvent* event) +{ + if(!mpVideoWidget){ + mpVideoWidget = new Phonon::VideoWidget(this); + mMediaLayout.addStretch(1); + mMediaLayout.addWidget(mpVideoWidget, 0); + mMediaLayout.addStretch(1); + Phonon::createPath(mpMediaObject, mpVideoWidget); + adaptSizeToVideo(); + mpMediaObject->play(); + mpMediaObject->stop(); + } + QWidget::showEvent(event); +} + /** * \brief Create the media player */ @@ -114,12 +129,14 @@ void UBMediaWidget::createMediaPlayer() if(eMediaType_Video == mType){ mMediaLayout.setContentsMargins(10, 10, 25, 10); - mpVideoWidget = new Phonon::VideoWidget(this); - mMediaLayout.addStretch(1); - mMediaLayout.addWidget(mpVideoWidget, 0); - mMediaLayout.addStretch(1); - Phonon::createPath(mpMediaObject, mpVideoWidget); - adaptSizeToVideo(); + if(isVisible()){ + mpVideoWidget = new Phonon::VideoWidget(this); + mMediaLayout.addStretch(1); + mMediaLayout.addWidget(mpVideoWidget, 0); + mMediaLayout.addStretch(1); + Phonon::createPath(mpMediaObject, mpVideoWidget); + adaptSizeToVideo(); + } mpAudioOutput = new Phonon::AudioOutput(Phonon::VideoCategory, this); Phonon::createPath(mpMediaObject, mpAudioOutput); }else if(eMediaType_Audio == mType){ diff --git a/src/customWidgets/UBMediaWidget.h b/src/customWidgets/UBMediaWidget.h index ba7d774b..ef8a65a2 100644 --- a/src/customWidgets/UBMediaWidget.h +++ b/src/customWidgets/UBMediaWidget.h @@ -71,6 +71,7 @@ public: protected: void resizeEvent(QResizeEvent* ev); + void showEvent(QShowEvent* event); private slots: void onPlayStopClicked(); diff --git a/src/document/UBDocumentController.cpp b/src/document/UBDocumentController.cpp index 7ee43999..9cae24db 100644 --- a/src/document/UBDocumentController.cpp +++ b/src/document/UBDocumentController.cpp @@ -37,7 +37,6 @@ #include "board/UBBoardPaletteManager.h" #include "board/UBDrawingController.h" -//#include "gui/UBKeyboardPalette.h" #include "gui/UBThumbnailView.h" #include "gui/UBDocumentTreeWidget.h" @@ -69,7 +68,6 @@ UBDocumentController::UBDocumentController(UBMainWindow* mainWindow) , mToolsPalette(0) , mToolsPalettePositionned(false) , mTrashTi(0) -// , mKeyboardPalette(0) { setupViews(); setupToolbar(); diff --git a/src/gui/UBTBPageEditWidget.cpp b/src/gui/UBTBPageEditWidget.cpp index 5e512d52..f80c894f 100644 --- a/src/gui/UBTBPageEditWidget.cpp +++ b/src/gui/UBTBPageEditWidget.cpp @@ -200,9 +200,13 @@ void UBTBPageEditWidget::updateFields() } // Medias foreach(QString url, mpDataMgr->mediaUrls()){ + if(url.isEmpty()) + continue; QWidget* pWidget = mpMediaContainer->generateMediaWidget(url); - mpDataMgr->medias()->append(pWidget); - mpMediaContainer->addWidget(pWidget); + if(pWidget != NULL){ + mpDataMgr->medias()->append(pWidget); + mpMediaContainer->addWidget(pWidget); + } } // Links foreach(sLink link, *mpDataMgr->urls()){ diff --git a/src/gui/UBTeacherBarPreviewWidget.cpp b/src/gui/UBTeacherBarPreviewWidget.cpp index 662996df..2181a549 100644 --- a/src/gui/UBTeacherBarPreviewWidget.cpp +++ b/src/gui/UBTeacherBarPreviewWidget.cpp @@ -43,34 +43,34 @@ void UBTeacherBarPreviewMedia::loadWidgets(QList pWidgetsList, bool is } -int UBTeacherBarPreviewMedia::loadMedia(QStringList pMedias) -{ - int addedMedia = 0; -// foreach(QString eachString, pMedias){ -// if(!eachString.isEmpty()){ -// QString mimeType = UBFileSystemUtils::mimeTypeFromFileName(eachString); -// if(mimeType.contains("image")){ -// UBDraggableLabel* label = new UBDraggableLabel(); -// label->loadImage(eachString); -// mWidget->addWidget(label); -// mWidgetList[label]=eachString; -// addedMedia += 1; -// } -// else if(mimeType.contains("video") || mimeType.contains("audio")){ -// UBDraggableMediaPlayer* mediaPlayer = new UBDraggableMediaPlayer(); -// mediaPlayer->setFile(eachString); -// mWidget->addWidget(mediaPlayer); -// mWidgetList[mediaPlayer] = eachString; -// addedMedia += 1; -// } -// else{ -// qWarning() << "pMediaPath" << eachString; -// qWarning() << "bad idea to come here"; -// } -// } -// } - return addedMedia; -} +//int UBTeacherBarPreviewMedia::loadMedia(QStringList pMedias) +//{ +// int addedMedia = 0; +//// foreach(QString eachString, pMedias){ +//// if(!eachString.isEmpty()){ +//// QString mimeType = UBFileSystemUtils::mimeTypeFromFileName(eachString); +//// if(mimeType.contains("image")){ +//// UBDraggableLabel* label = new UBDraggableLabel(); +//// label->loadImage(eachString); +//// mWidget->addWidget(label); +//// mWidgetList[label]=eachString; +//// addedMedia += 1; +//// } +//// else if(mimeType.contains("video") || mimeType.contains("audio")){ +//// UBDraggableMediaPlayer* mediaPlayer = new UBDraggableMediaPlayer(); +//// mediaPlayer->setFile(eachString); +//// mWidget->addWidget(mediaPlayer); +//// mWidgetList[mediaPlayer] = eachString; +//// addedMedia += 1; +//// } +//// else{ +//// qWarning() << "pMediaPath" << eachString; +//// qWarning() << "bad idea to come here"; +//// } +//// } +//// } +// return addedMedia; +//} // ----------------------------------------------------------------------------------------------- UBActionPreview::UBActionPreview(QWidget *parent, const char *name):QWidget(parent) diff --git a/src/gui/UBTeacherBarPreviewWidget.h b/src/gui/UBTeacherBarPreviewWidget.h index db70b142..a7ff6e9b 100644 --- a/src/gui/UBTeacherBarPreviewWidget.h +++ b/src/gui/UBTeacherBarPreviewWidget.h @@ -15,7 +15,7 @@ class UBTeacherBarPreviewMedia : public QWidget public: UBTeacherBarPreviewMedia(QWidget* parent=0, const char* name="UBTeacherBarPreviewMedia"); ~UBTeacherBarPreviewMedia(); - int loadMedia(QStringList pMedias); +// int loadMedia(QStringList pMedias); void loadWidgets(QList pWidgetList, bool isResizable = true); void cleanMedia(); From 6e81d74d41f3cda36a47797e3877a9d07b19dfb4 Mon Sep 17 00:00:00 2001 From: shibakaneki Date: Mon, 23 Jan 2012 15:50:12 +0100 Subject: [PATCH 73/84] Added some logic for the Document description datas in the teacherbar --- src/core/UBPersistenceManager.cpp | 2 -- src/core/UBPersistenceManager.h | 3 +-- src/gui/UBTBDocumentEditWidget.cpp | 22 +++++++++++++++++-- src/gui/UBTBDocumentEditWidget.h | 3 +++ src/gui/UBTBPageEditWidget.cpp | 1 - src/gui/UBTeacherBarDataMgr.cpp | 27 ++++++++++++++++++------ src/gui/UBTeacherBarDataMgr.h | 2 +- src/gui/UBTeacherBarWidget.cpp | 34 +++++++++++++++++++++--------- src/gui/UBTeacherBarWidget.h | 4 +++- 9 files changed, 73 insertions(+), 25 deletions(-) diff --git a/src/core/UBPersistenceManager.cpp b/src/core/UBPersistenceManager.cpp index d3389c19..f0502955 100644 --- a/src/core/UBPersistenceManager.cpp +++ b/src/core/UBPersistenceManager.cpp @@ -1086,7 +1086,6 @@ void UBPersistenceManager::persistTeacherBar(UBDocumentProxy* pDocumentProxy, in // Set the element values QDomElement teacherBarElem = teacherBarNode.toElement(); teacherBarElem.setAttribute("title", infos.title); - teacherBarElem.setAttribute("duration", QString("%0").arg(infos.Duration)); QString qsAct; for(int i=0; isetSessionTitle(mpTitle->text()); + emit valueChanged(); +} +void UBTBDocumentEditWidget::onSessionTargetChanged() +{ + mpDataMgr->setSessionTarget(mpTarget->document()->toPlainText()); + emit valueChanged(); } -void UBTBDocumentEditWidget::clearFields() +void UBTBDocumentEditWidget::updateFields() { + mpTitle->setText(mpDataMgr->sessionTitle()); + mpTarget->setPlainText(mpDataMgr->sessionTarget()); +} +void UBTBDocumentEditWidget::clearFields() +{ + mpTitle->setText(""); + mpTarget->setPlainText(""); } + + diff --git a/src/gui/UBTBDocumentEditWidget.h b/src/gui/UBTBDocumentEditWidget.h index 705adcfe..147e5404 100644 --- a/src/gui/UBTBDocumentEditWidget.h +++ b/src/gui/UBTBDocumentEditWidget.h @@ -20,10 +20,13 @@ public: signals: void changeTBState(eTeacherBarState state); + void valueChanged(); private slots: void onPageView(); void onPreview(); + void onSessionTitleChanged(); + void onSessionTargetChanged(); private: QVBoxLayout mLayout; diff --git a/src/gui/UBTBPageEditWidget.cpp b/src/gui/UBTBPageEditWidget.cpp index 5e512d52..c93a5332 100644 --- a/src/gui/UBTBPageEditWidget.cpp +++ b/src/gui/UBTBPageEditWidget.cpp @@ -42,7 +42,6 @@ UBTBPageEditWidget::UBTBPageEditWidget(UBTeacherBarDataMgr *pDataMgr, QWidget *p mpTitleLabel = new QLabel(tr("Title"), mpContainer); mpTitle = new QLineEdit(mpContainer); mpTitle->setObjectName("DockPaletteWidgetLineEdit"); - connect(mpTitle, SIGNAL(textChanged(const QString&)), this, SLOT(onTitleTextChanged(const QString&))); mContainerLayout.addWidget(mpTitleLabel, 0); mContainerLayout.addWidget(mpTitle, 0); diff --git a/src/gui/UBTeacherBarDataMgr.cpp b/src/gui/UBTeacherBarDataMgr.cpp index 8ee86c8c..857898d0 100644 --- a/src/gui/UBTeacherBarDataMgr.cpp +++ b/src/gui/UBTeacherBarDataMgr.cpp @@ -20,6 +20,7 @@ void UBTeacherBarDataMgr::clearLists() mActionList.clear(); mUrlList.clear(); mMediaList.clear(); + mMediaUrls.clear(); } void UBTeacherBarDataMgr::saveContent() @@ -27,40 +28,49 @@ void UBTeacherBarDataMgr::saveContent() // Store the page information in the UBZ sTeacherBarInfos infos; + // Page Title infos.title = mPageTitle; - // Actions foreach(sAction action, mActionList){ infos.actions << QString("%0;%1").arg(action.type).arg(action.content); } - // Media foreach(QString media, mMediaUrls){ infos.medias << media; } - // Links foreach(sLink link, mUrlList){ if("" != link.title && "" != link.link){ infos.urls << QString("%0;%1").arg(link.title).arg(link.link); } } - // Comments infos.comments = mComments; UBPersistenceManager::persistenceManager()->persistTeacherBar(UBApplication::boardController->activeDocument(), UBApplication::boardController->activeSceneIndex(), infos); // TODO: Store the document metadata somewhere + // Session Title + //... = mSessionTitle; + // Session Target + //... = mSessionTarget; } -void UBTeacherBarDataMgr::loadContent() +void UBTeacherBarDataMgr::loadContent(bool docChanged) { clearLists(); sTeacherBarInfos nextInfos = UBPersistenceManager::persistenceManager()->getTeacherBarInfos(UBApplication::boardController->activeDocument(), UBApplication::boardController->activeSceneIndex()); + if(docChanged){ + // TODO: Read these information from the metadata file + + // Session Title + //mSessionTitle = ...; + // Session Target + //mSessionTarget = ...; + } // Page Title mPageTitle = nextInfos.title; // Actions @@ -74,7 +84,12 @@ void UBTeacherBarDataMgr::loadContent() } } // Media URL - mMediaUrls = nextInfos.medias; + if((nextInfos.medias.size() == 1) && (nextInfos.medias.at(0) == "")){ + // Do not retrieve it + } + else{ + mMediaUrls = nextInfos.medias; + } // Links foreach(QString eachUrl, nextInfos.urls){ diff --git a/src/gui/UBTeacherBarDataMgr.h b/src/gui/UBTeacherBarDataMgr.h index 2c299474..3ac888be 100644 --- a/src/gui/UBTeacherBarDataMgr.h +++ b/src/gui/UBTeacherBarDataMgr.h @@ -68,7 +68,7 @@ public: // Others void clearLists(); void saveContent(); - void loadContent(); + void loadContent(bool docChanged = false); private: QString mSessionTitle; diff --git a/src/gui/UBTeacherBarWidget.cpp b/src/gui/UBTeacherBarWidget.cpp index d0bbc85b..7d8ab771 100644 --- a/src/gui/UBTeacherBarWidget.cpp +++ b/src/gui/UBTeacherBarWidget.cpp @@ -52,14 +52,16 @@ UBTeacherBarWidget::UBTeacherBarWidget(QWidget *parent, const char *name):UBDock mpStackWidget->addWidget(mpDocEditWidget); connect(UBApplication::boardController, SIGNAL(activeSceneWillChange()), this, SLOT(saveContent())); - connect(UBApplication::boardController, SIGNAL(activeSceneChanged()), this, SLOT(loadContent())); connect(UBApplication::mainWindow->actionQuit, SIGNAL(triggered()), this, SLOT(saveContent())); + connect(UBApplication::boardController, SIGNAL(activeSceneChanged()), this, SLOT(loadContentInfos())); + connect(UBApplication::boardController, SIGNAL(activeDocumentChanged()), this, SLOT(onActiveDocumentChanged())); connect(mpPreview, SIGNAL(showEditMode()), this, SLOT(onShowEditMode())); connect(mpDocPreviewWidget, SIGNAL(changeTBState(eTeacherBarState)), this, SLOT(onTBStateChanged(eTeacherBarState))); connect(mpDocEditWidget, SIGNAL(changeTBState(eTeacherBarState)), this, SLOT(onTBStateChanged(eTeacherBarState))); connect(mpPageEditWidget, SIGNAL(changeTBState(eTeacherBarState)), this, SLOT(onTBStateChanged(eTeacherBarState))); connect(mpPageEditWidget, SIGNAL(valueChanged()), this, SLOT(onValueChanged())); + connect(mpDocEditWidget, SIGNAL(valueChanged()), this, SLOT(onValueChanged())); } UBTeacherBarWidget::~UBTeacherBarWidget() @@ -71,6 +73,11 @@ UBTeacherBarWidget::~UBTeacherBarWidget() DELETEPTR(mpStackWidget); } +void UBTeacherBarWidget::onActiveDocumentChanged() +{ + loadContent(true); +} + void UBTeacherBarWidget::onValueChanged() { if(isEmpty()) @@ -93,22 +100,31 @@ void UBTeacherBarWidget::saveContent() mData.saveContent(); } -void UBTeacherBarWidget::loadContent() +void UBTeacherBarWidget::loadContentInfos() +{ + loadContent(false); +} + +void UBTeacherBarWidget::loadContent(bool docChanged) { // Clear the old datas mpPageEditWidget->clearFields(); mpPreview->clearFields(); - mpDocEditWidget->clearFields(); - mpDocPreviewWidget->clearFields(); + if(docChanged){ + mpDocEditWidget->clearFields(); + mpDocPreviewWidget->clearFields(); + } // Update the datas - mData.loadContent(); + mData.loadContent(docChanged); // Update the fields mpPageEditWidget->updateFields(); mpPreview->updateFields(); - mpDocEditWidget->updateFields(); - mpDocPreviewWidget->updateFields(); + if(docChanged){ + mpDocEditWidget->updateFields(); + mpDocPreviewWidget->updateFields(); + } if(!isEmpty()){ onTBStateChanged(eTeacherBarState_PagePreview); @@ -127,9 +143,7 @@ bool UBTeacherBarWidget::isEmpty() mData.urls()->empty() && mData.actions()->empty() && mData.medias()->empty() && - mData.comments() == "" && - mData.sessionTarget() == "" && - mData.sessionTitle() == ""; + mData.comments() == ""; } void UBTeacherBarWidget::onShowEditMode() diff --git a/src/gui/UBTeacherBarWidget.h b/src/gui/UBTeacherBarWidget.h index 6b38645b..2bea6677 100644 --- a/src/gui/UBTeacherBarWidget.h +++ b/src/gui/UBTeacherBarWidget.h @@ -34,12 +34,14 @@ public: private slots: void saveContent(); - void loadContent(); + void loadContentInfos(); void onValueChanged(); void onShowEditMode(); void onTBStateChanged(eTeacherBarState state); + void onActiveDocumentChanged(); private: + void loadContent(bool docChanged = false); bool isEmpty(); QVBoxLayout mLayout; From e3b51cc19e5bba3f6430501b3bfa3ab6445b63d8 Mon Sep 17 00:00:00 2001 From: Claudio Valerio Date: Tue, 24 Jan 2012 16:49:21 +0100 Subject: [PATCH 74/84] persisted session parameters --- src/adaptors/UBMetadataDcSubsetAdaptor.cpp | 23 ++++++++++- src/core/UBSettings.cpp | 3 ++ src/core/UBSettings.h | 3 ++ src/document/UBDocumentProxy.cpp | 44 ++++++++++++++++++++++ src/document/UBDocumentProxy.h | 6 +++ src/gui/UBTeacherBarDataMgr.cpp | 39 +++++++++++-------- src/gui/UBTeacherBarDataMgr.h | 5 +++ 7 files changed, 105 insertions(+), 18 deletions(-) diff --git a/src/adaptors/UBMetadataDcSubsetAdaptor.cpp b/src/adaptors/UBMetadataDcSubsetAdaptor.cpp index a5dded62..7f6574c6 100644 --- a/src/adaptors/UBMetadataDcSubsetAdaptor.cpp +++ b/src/adaptors/UBMetadataDcSubsetAdaptor.cpp @@ -97,7 +97,7 @@ void UBMetadataDcSubsetAdaptor::persist(UBDocumentProxy* proxy) // introduced in UB 4.2 xmlWriter.writeTextElement(nsDc, "identifier", proxy->metaData(UBSettings::documentIdentifer).toString()); - xmlWriter.writeTextElement(UBSettings::uniboardDocumentNamespaceUri, "version", UBSettings::currentFileVersion); + xmlWriter.writeTextElement(UBSettings::uniboardDocumentNamespaceUri, "version", UBSettings::currentFileVersion); QString width = QString::number(proxy->defaultDocumentSize().width()); QString height = QString::number(proxy->defaultDocumentSize().height()); xmlWriter.writeTextElement(UBSettings::uniboardDocumentNamespaceUri, "size", QString("%1x%2").arg(width).arg(height)); @@ -105,6 +105,11 @@ void UBMetadataDcSubsetAdaptor::persist(UBDocumentProxy* proxy) // introduced in UB 4.4 xmlWriter.writeTextElement(UBSettings::uniboardDocumentNamespaceUri, "updated-at", proxy->metaData(UBSettings::documentUpdatedAt).toString()); + // introduced in OpenSankore 1.40.00 + xmlWriter.writeTextElement(UBSettings::uniboardDocumentNamespaceUri,UBSettings::sessionTitle,proxy->metaData(UBSettings::sessionTitle).toString()); + xmlWriter.writeTextElement(UBSettings::uniboardDocumentNamespaceUri,UBSettings::sessionTarget,proxy->metaData(UBSettings::sessionTarget).toString()); + xmlWriter.writeTextElement(UBSettings::uniboardDocumentNamespaceUri,UBSettings::sessionLicence,proxy->metaData(UBSettings::sessionLicence).toString()); + xmlWriter.writeEndElement(); //dc:Description xmlWriter.writeEndElement(); //RDF @@ -204,7 +209,21 @@ QMap UBMetadataDcSubsetAdaptor::load(QString pPath) metadata.insert(UBSettings::documentUpdatedAt, xml.readElementText()); updatedAtFound = true; } - + else if (xml.name() == UBSettings::sessionTitle // introduced in OpenSankore 1.40.00 + && xml.namespaceUri() == UBSettings::uniboardDocumentNamespaceUri) + { + metadata.insert(UBSettings::sessionTitle, xml.readElementText()); + } + else if (xml.name() == UBSettings::sessionTarget // introduced in OpenSankore 1.40.00 + && xml.namespaceUri() == UBSettings::uniboardDocumentNamespaceUri) + { + metadata.insert(UBSettings::sessionTarget, xml.readElementText()); + } + else if (xml.name() == UBSettings::sessionLicence // introduced in OpenSankore 1.40.00 + && xml.namespaceUri() == UBSettings::uniboardDocumentNamespaceUri) + { + metadata.insert(UBSettings::sessionLicence, xml.readElementText()); + } metadata.insert(UBSettings::documentVersion, docVersion); } diff --git a/src/core/UBSettings.cpp b/src/core/UBSettings.cpp index 0db96ae9..1ae24e61 100644 --- a/src/core/UBSettings.cpp +++ b/src/core/UBSettings.cpp @@ -36,6 +36,9 @@ QString UBSettings::documentSize = QString("Size"); QString UBSettings::documentIdentifer = QString("ID"); QString UBSettings::documentVersion = QString("Version"); QString UBSettings::documentUpdatedAt = QString("UpdatedAt"); +QString UBSettings::sessionTitle = QString("sessionTitle"); +QString UBSettings::sessionTarget = QString("sessionTarget"); +QString UBSettings::sessionLicence = QString("sessionLicence"); QString UBSettings::trashedDocumentGroupNamePrefix = QString("_Trash:"); diff --git a/src/core/UBSettings.h b/src/core/UBSettings.h index dde60f13..e05c2599 100644 --- a/src/core/UBSettings.h +++ b/src/core/UBSettings.h @@ -153,6 +153,9 @@ class UBSettings : public QObject static QString documentIdentifer; static QString documentVersion; static QString documentUpdatedAt; + static QString sessionTitle; + static QString sessionTarget; + static QString sessionLicence; static QString trashedDocumentGroupNamePrefix; diff --git a/src/document/UBDocumentProxy.cpp b/src/document/UBDocumentProxy.cpp index 98c1c137..aa70a8a1 100644 --- a/src/document/UBDocumentProxy.cpp +++ b/src/document/UBDocumentProxy.cpp @@ -49,6 +49,10 @@ void UBDocumentProxy::init() setUuid(QUuid::createUuid()); setDefaultDocumentSize(UBSettings::settings()->defaultDocumentSize); + + setSessionTitle(""); + setSessionTarget(""); + setSessionLicence(""); } @@ -196,6 +200,46 @@ void UBDocumentProxy::setUuid(const QUuid& uuid) UBSettings::uniboardDocumentNamespaceUri + "/" + UBStringUtils::toCanonicalUuid(uuid)); } +QString UBDocumentProxy::sessionTitle() const +{ + if(mMetaDatas.contains(UBSettings::sessionTitle)) + return metaData(UBSettings::sessionTitle).toString(); + else + return QString(); +} + +void UBDocumentProxy::setSessionTitle(const QString & sessionTitle) +{ + setMetaData(UBSettings::sessionTitle,QVariant(sessionTitle)); +} + +QString UBDocumentProxy::sessionTarget() const +{ + if(mMetaDatas.contains(UBSettings::sessionTarget)) + return metaData(UBSettings::sessionTarget).toString(); + else + return QString(); +} + +void UBDocumentProxy::setSessionTarget(const QString & sessionTarget) +{ + setMetaData(UBSettings::sessionTarget,QVariant(sessionTarget)); +} + +QString UBDocumentProxy::sessionLicence() const +{ + if(mMetaDatas.contains(UBSettings::sessionLicence)) + return metaData(UBSettings::sessionLicence).toString(); + else + return QString(); +} + +void UBDocumentProxy::setSessionLicence(const QString & sessionLicence) +{ + setMetaData(UBSettings::sessionLicence,QVariant(sessionLicence)); +} + + bool UBDocumentProxy::isModified() const { return mIsModified; diff --git a/src/document/UBDocumentProxy.h b/src/document/UBDocumentProxy.h index 20edb47a..70d708bd 100644 --- a/src/document/UBDocumentProxy.h +++ b/src/document/UBDocumentProxy.h @@ -45,6 +45,12 @@ class UBDocumentProxy : public QObject QString name() const; QString groupName() const; + QString sessionTitle() const; + void setSessionTitle(const QString& sessionTitle); + QString sessionTarget() const; + void setSessionTarget(const QString& sessionTarget); + QString sessionLicence() const; + void setSessionLicence(const QString& sessionLicence); QSize defaultDocumentSize() const; void setDefaultDocumentSize(QSize pSize); diff --git a/src/gui/UBTeacherBarDataMgr.cpp b/src/gui/UBTeacherBarDataMgr.cpp index 857898d0..28cbcb24 100644 --- a/src/gui/UBTeacherBarDataMgr.cpp +++ b/src/gui/UBTeacherBarDataMgr.cpp @@ -1,9 +1,14 @@ +#include "UBTeacherBarDataMgr.h" + #include "core/UBApplication.h" #include "core/UBPersistenceManager.h" + #include "board/UBBoardController.h" + #include "customWidgets/UBGlobals.h" -#include "UBTeacherBarDataMgr.h" +#include "adaptors/UBMetadataDcSubsetAdaptor.h" + UBTeacherBarDataMgr::UBTeacherBarDataMgr() { @@ -47,30 +52,32 @@ void UBTeacherBarDataMgr::saveContent() // Comments infos.comments = mComments; - UBPersistenceManager::persistenceManager()->persistTeacherBar(UBApplication::boardController->activeDocument(), UBApplication::boardController->activeSceneIndex(), infos); + UBDocumentProxy* documentProxy = UBApplication::boardController->activeDocument(); + if(documentProxy){ + UBPersistenceManager::persistenceManager()->persistTeacherBar(documentProxy, UBApplication::boardController->activeSceneIndex(), infos); - // TODO: Store the document metadata somewhere - // Session Title - //... = mSessionTitle; - // Session Target - //... = mSessionTarget; + documentProxy->setSessionTitle(mSessionTitle); + documentProxy->setSessionTarget(mSessionTarget); + documentProxy->setSessionLicence(mSessionLicence); + UBMetadataDcSubsetAdaptor::persist(documentProxy); + } } + + void UBTeacherBarDataMgr::loadContent(bool docChanged) { clearLists(); + UBDocumentProxy* documentProxy = UBApplication::boardController->activeDocument(); - sTeacherBarInfos nextInfos = UBPersistenceManager::persistenceManager()->getTeacherBarInfos(UBApplication::boardController->activeDocument(), UBApplication::boardController->activeSceneIndex()); - - if(docChanged){ - // TODO: Read these information from the metadata file - - // Session Title - //mSessionTitle = ...; - // Session Target - //mSessionTarget = ...; + sTeacherBarInfos nextInfos = UBPersistenceManager::persistenceManager()->getTeacherBarInfos(documentProxy, UBApplication::boardController->activeSceneIndex()); + if(true/*docChanged*/){ + mSessionTitle = documentProxy->sessionTitle(); + mSessionTarget = documentProxy->sessionTarget(); + mSessionLicence = documentProxy->sessionLicence(); } + // Page Title mPageTitle = nextInfos.title; // Actions diff --git a/src/gui/UBTeacherBarDataMgr.h b/src/gui/UBTeacherBarDataMgr.h index 3ac888be..73c28cc1 100644 --- a/src/gui/UBTeacherBarDataMgr.h +++ b/src/gui/UBTeacherBarDataMgr.h @@ -46,6 +46,10 @@ public: void setSessionTarget(const QString& target){mSessionTarget = target;} QString sessionTarget(){return mSessionTarget;} + // Licence + void setSessionLicence(const QString& licence){mSessionLicence = licence;} + QString sessionLicence(){return mSessionLicence;} + // Page Title void setPageTitle(const QString& title){mPageTitle = title;} QString pageTitle(){return mPageTitle;} @@ -73,6 +77,7 @@ public: private: QString mSessionTitle; QString mSessionTarget; + QString mSessionLicence; QString mPageTitle; QString mComments; From a375322955dce53a30b19345f1b1d5bd50595093 Mon Sep 17 00:00:00 2001 From: shibakaneki Date: Wed, 25 Jan 2012 08:47:02 +0100 Subject: [PATCH 75/84] Backup --- resources/images/licenses/ccby.png | Bin 0 -> 4739 bytes resources/images/licenses/ccbync.png | Bin 0 -> 5145 bytes resources/images/licenses/ccbyncnd.png | Bin 0 -> 5281 bytes resources/images/licenses/ccbyncsa.png | Bin 0 -> 5460 bytes resources/images/licenses/ccbynd.png | Bin 0 -> 4880 bytes resources/images/licenses/ccbysa.png | Bin 0 -> 5083 bytes resources/style.qss | 20 +- src/customWidgets/UBWidgetList.cpp | 2 +- src/gui/UBTeacherBarPreviewWidget.cpp | 245 ++++++++++++++----------- src/gui/UBTeacherBarPreviewWidget.h | 65 ++++--- src/gui/UBTeacherBarWidget.cpp | 16 +- 11 files changed, 207 insertions(+), 141 deletions(-) create mode 100644 resources/images/licenses/ccby.png create mode 100644 resources/images/licenses/ccbync.png create mode 100644 resources/images/licenses/ccbyncnd.png create mode 100644 resources/images/licenses/ccbyncsa.png create mode 100644 resources/images/licenses/ccbynd.png create mode 100644 resources/images/licenses/ccbysa.png diff --git a/resources/images/licenses/ccby.png b/resources/images/licenses/ccby.png new file mode 100644 index 0000000000000000000000000000000000000000..822491edb993b072fc183a2ce23adfa8c94cee7c GIT binary patch literal 4739 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 RjS2t&002ovPDHLkV1k=~?l=Gd literal 0 HcmV?d00001 diff --git a/resources/images/licenses/ccbync.png b/resources/images/licenses/ccbync.png new file mode 100644 index 0000000000000000000000000000000000000000..5f982147075ad08691e3b3c53e92633ca0ddcb2f GIT binary patch literal 5145 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 z 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 literal 0 HcmV?d00001 diff --git a/resources/images/licenses/ccbyncsa.png b/resources/images/licenses/ccbyncsa.png new file mode 100644 index 0000000000000000000000000000000000000000..0f2a0f10722d3fabffe8af5d5eed09866e25909a GIT binary patch literal 5460 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 literal 0 HcmV?d00001 diff --git a/resources/style.qss b/resources/style.qss index d80964a1..bdb0966a 100644 --- a/resources/style.qss +++ b/resources/style.qss @@ -13,6 +13,13 @@ QWidget#UBTBMediaContainer border: 2px solid #999999; } +QFrame#UBTBSeparator +{ + background: #DDDDDD; + border-radius: 2px; + border: 1px solid #DDDDDD; +} + QWidget#UBMediaVideoContainer { background: #000000; @@ -27,11 +34,17 @@ QWidget#UBTeacherBarPreviewWidget border: 2px solid #999999; } +QLabel#UBTBPreviewSessionTitle +{ + font-size: 12px; +} + QLabel#UBTeacherBarPreviewTitle { color: #555555; - font-size : 18px; + font-size : 20px; font-weight:bold; + padding-left:5px; } QLabel#UBMediaPlayerButton @@ -44,7 +57,7 @@ QLabel#UBTeacherBarPreviewSubtitle color: #555555; font-size : 15px; font-weight:bold; - padding-top: 10px; + padding-left:5px; } QWidget#UBLibWebView @@ -61,7 +74,8 @@ QWidget#UBActionPreviewOwner font-weight: bold; } -QWidget#UBTeacherBarPreviewComments +QWidget#UBTeacherBarPreviewComments, +QWidget#UBTeacherBarTargetBox { border-radius: 10px; border: white 2px solid; diff --git a/src/customWidgets/UBWidgetList.cpp b/src/customWidgets/UBWidgetList.cpp index 0ba01bb0..6481acb4 100644 --- a/src/customWidgets/UBWidgetList.cpp +++ b/src/customWidgets/UBWidgetList.cpp @@ -57,7 +57,7 @@ void UBWidgetList::addWidget(QWidget *widget) void UBWidgetList::removeWidget(QWidget *widget) { - if(NULL != mpLayout){ + if(NULL != mpLayout && NULL != widget){ mpLayout->removeWidget(widget); mWidgetInfo.remove(widget); widget->setVisible(false); diff --git a/src/gui/UBTeacherBarPreviewWidget.cpp b/src/gui/UBTeacherBarPreviewWidget.cpp index 2181a549..7d2ad585 100644 --- a/src/gui/UBTeacherBarPreviewWidget.cpp +++ b/src/gui/UBTeacherBarPreviewWidget.cpp @@ -1,5 +1,6 @@ #include "core/UBApplication.h" #include "customWidgets/UBGlobals.h" +#include "board/UBBoardController.h" #include "frameworks/UBFileSystemUtils.h" #include "UBTeacherBarPreviewWidget.h" @@ -84,9 +85,10 @@ UBActionPreview::UBActionPreview(QWidget *parent, const char *name):QWidget(pare mOwnerLayout.addWidget(mpOwner, 0); mOwnerLayout.addStretch(1); mLayout.addLayout(&mOwnerLayout); - mpContent = new QLabel(this); + mpContent = new QTextEdit(this); + mpContent->setReadOnly(true); mpContent->setObjectName("UBActionPreviewContent"); - mpContent->setWordWrap(true); + //mpContent->setWordWrap(true); mLayout.addWidget(mpContent); setContentsMargins(-9, -9, -9, -9); } @@ -103,10 +105,10 @@ UBActionPreview::~UBActionPreview() } } -void UBActionPreview::setOwner(const QString &owner) +void UBActionPreview::setOwner(int owner) { if(NULL != mpOwner && NULL != mpContent){ - switch(owner.toInt()){ + switch(owner){ case eActionOwner_Teacher: mpOwner->setText(tr("Teacher")); mpContent->setStyleSheet("background:lightblue; border:lightblue;"); @@ -124,6 +126,7 @@ void UBActionPreview::setContent(const QString &content) { if(NULL != mpContent){ mpContent->setText(content); + setMinimumHeight(mpOwner->height() + mpContent->height()); } } @@ -136,19 +139,30 @@ UBTBPreviewContainer::UBTBPreviewContainer(QWidget *parent, const char *name):UB UBTBPreviewContainer::~UBTBPreviewContainer() { +} +// ------------------------------------------------------------------------------------ +UBTBPreviewSeparator::UBTBPreviewSeparator(QWidget *parent, const char *name):QFrame(parent) +{ + setObjectName("UBTBSeparator"); + setMinimumHeight(5); + setMaximumHeight(5); +} + +UBTBPreviewSeparator::~UBTBPreviewSeparator() +{ + } // ------------------------------------------------------------------------------------ UBTeacherBarPreviewWidget::UBTeacherBarPreviewWidget(UBTeacherBarDataMgr* pDataMgr, QWidget *parent, const char *name):QWidget(parent) , mpEditButton(NULL) + , mpSessionTitle(NULL) , mpTitle(NULL) - , mpDuration(NULL) - , mpActionsLabel(NULL) - , mpMediaLabel(NULL) - , mpCommentsLabel(NULL) - , mpComments(NULL) - , mpLinksLabel(NULL) + , mpTitleLabel(NULL) + , mpPageNbrLabel(NULL) , mpContentContainer(NULL) + , mpScheduleLabel(NULL) + , mpLicenseLabel(NULL) { setObjectName(name); mpDataMgr = pDataMgr; @@ -158,23 +172,45 @@ UBTeacherBarPreviewWidget::UBTeacherBarPreviewWidget(UBTeacherBarDataMgr* pDataM setStyleSheet(UBApplication::globalStyleSheet()); // Build the Preview widget - // Title + duration - mpTitle = new QLabel(this); + // Session Title + mTitleContainer.setLayout(&mTitleLayout); + mpSessionTitle = new QLabel(this); + mpSessionTitle->setText(tr("Session: ")); + mpSessionTitle->setWordWrap(true); + mpSessionTitle->setAlignment(Qt::AlignRight); + mpSessionTitle->setObjectName("UBTBPreviewSessionTitle"); + mLayout.addWidget(mpSessionTitle); + + // Title + mTitleContainer.setLayout(&mTitleLayout); + mTitleLayout.setContentsMargins(0, 0, 0, 0); + mpTitleLabel = new QLabel(&mTitleContainer); + mpTitleLabel->setText(tr("Activity")); + mpTitleLabel->setObjectName("UBTeacherBarPreviewSubtitle"); + mTitleLayout.addWidget(mpTitleLabel, 0); + mpTitle = new QLabel(&mTitleContainer); mpTitle->setObjectName("UBTeacherBarPreviewTitle"); mpTitle->setWordWrap(true); - mpTitle->setAlignment(Qt::AlignCenter); - mpDuration = new QLabel(this); - mTitleDurationLayout.addWidget(mpTitle, 0); - mTitleDurationLayout.addWidget(mpDuration, 1); - mLayout.addLayout(&mTitleDurationLayout, 0); - + mpTitle->setAlignment(Qt::AlignLeft); + mTitleLayout.addWidget(mpTitle, 1); + mpPageNbrLabel = new QLabel(tr("Page n° "), &mTitleContainer); + mpPageNbrLabel->setAlignment(Qt::AlignRight); + mpPageNbrLabel->setObjectName("UBTBPreviewSessionTitle"); + mTitleLayout.addWidget(mpPageNbrLabel); + mTitleLayout.addWidget(&mTitleSeparator); + mLayout.addWidget(&mTitleContainer); + + // Content mpContentContainer = new UBTBPreviewContainer(this); mLayout.addWidget(mpContentContainer, 1); - //mLayout.addWidget(&mMediaViewer, 1); - // The next line is disgusting. This is a quickfix that must be reworked later - mMediaViewer.setContentsMargins(-9, -9, -9, -9); - hideElements(); + // License + mLayout.addWidget(&mLicenseSeparator); + mpLicenseLabel = new QLabel(tr("License"), this); + mpLicenseLabel->setObjectName("UBTeacherBarPreviewSubtitle"); + mLayout.addWidget(mpLicenseLabel); + // TODO : Add the license field here + // Edit button mpEditButton = new QPushButton(tr("Edit infos"), this); @@ -186,128 +222,121 @@ UBTeacherBarPreviewWidget::UBTeacherBarPreviewWidget(UBTeacherBarDataMgr* pDataM connect(mpEditButton, SIGNAL(clicked()), this, SLOT(onEdit())); + connect(UBApplication::boardController, SIGNAL(activeSceneChanged()), this, SLOT(onActiveSceneChanged())); } UBTeacherBarPreviewWidget::~UBTeacherBarPreviewWidget() { - DELETEPTR(mpLinksLabel); - DELETEPTR(mpComments); - DELETEPTR(mpTitle); - DELETEPTR(mpDuration); - DELETEPTR(mpActionsLabel); - DELETEPTR(mpMediaLabel); - DELETEPTR(mpCommentsLabel); - DELETEPTR(mpContentContainer); DELETEPTR(mpEditButton); + DELETEPTR(mpLicenseLabel); + DELETEPTR(mpScheduleLabel); + DELETEPTR(mpPageNbrLabel); + DELETEPTR(mpTitle); + DELETEPTR(mpTitleLabel); + DELETEPTR(mpSessionTitle); } -void UBTeacherBarPreviewWidget::onEdit() +void UBTeacherBarPreviewWidget::onActiveSceneChanged() { - emit showEditMode(); + mpPageNbrLabel->setText(tr("Page n° %0").arg(UBApplication::boardController->activeSceneIndex())); } -void UBTeacherBarPreviewWidget::setTitle(const QString &title) +void UBTeacherBarPreviewWidget::onEdit() { - if(NULL != mpTitle){ - mpTitle->setText(title); - } + emit showEditMode(); } -void UBTeacherBarPreviewWidget::setComments(const QString &comments) +void UBTeacherBarPreviewWidget::updateFields() { - if("" != comments){ - mWidgets.clear(); - mpComments->setText(comments); - mpComments->setVisible(true); - mpCommentsLabel->setVisible(true); - mWidgets << mpCommentsLabel; - mMediaViewer.loadWidgets(mWidgets, false); - mWidgets.clear(); - mWidgets << mpComments; - mMediaViewer.loadWidgets(mWidgets, true); + // First, remove the previous elements + if(!mStoredWidgets.empty()){ + foreach(QWidget* pW, mStoredWidgets){ + mpContentContainer->removeWidget(pW); + if( pW->objectName() == "UBActionPreview" || + pW->objectName() == "UBLinkPreview" || + pW->objectName() == "UBCommentsPreview"){ + // Here we delete all preview widget excepting the media because they are handled by the data manager + delete pW; + pW = NULL; + } + } + mStoredWidgets.clear(); } -} -void UBTeacherBarPreviewWidget::clean() -{ - mMediaViewer.cleanMedia(); + // Session Title + mpSessionTitle->setText(mpDataMgr->sessionTitle()); - foreach(QWidget* eachWidget, mStoredWidgets){ - delete eachWidget; - eachWidget = NULL; + // Page Title + if("" != mpDataMgr->pageTitle()){ + mpTitle->setText(mpDataMgr->pageTitle()); + mpPageNbrLabel->setText(tr("Page n° %0").arg(UBApplication::boardController->activeSceneIndex())); + mTitleContainer.setVisible(true); + }else{ + mTitleContainer.setVisible(false); } - mStoredWidgets.clear(); - hideElements(); + // Actions + generateActions(); + + // Media + generateMedias(); + + // Links + generateLinks(); + + // Comments + generateComments(); + } -void UBTeacherBarPreviewWidget::hideElements() +void UBTeacherBarPreviewWidget::clearFields() { - mpActionsLabel = new QLabel(tr("Actions"), this); - mpActionsLabel->setObjectName("UBTeacherBarPreviewSubtitle"); - mpMediaLabel = new QLabel(tr("Medias"), this); - mpMediaLabel->setObjectName("UBTeacherBarPreviewSubtitle"); - mpCommentsLabel = new QLabel(tr("Comments"), this); - mpCommentsLabel->setObjectName("UBTeacherBarPreviewSubtitle"); - mpComments = new QLabel(this); - mpComments->setWordWrap(true); - mpComments->setObjectName("UBTeacherBarPreviewComments"); - mpLinksLabel = new QLabel(tr("Links"), this); - mpLinksLabel->setObjectName("UBTeacherBarPreviewSubtitle"); - - mpActionsLabel->setVisible(false); - mpMediaLabel->setVisible(false); - mpCommentsLabel->setVisible(false); - mpComments->setVisible(false); - mpLinksLabel->setVisible(false); + } -void UBTeacherBarPreviewWidget::setActions(QStringList actions) +void UBTeacherBarPreviewWidget::generateActions() { - if(!actions.empty()){ - mWidgets.clear(); - mpActionsLabel->setVisible(true); - mWidgets << mpActionsLabel; - mediaViewer()->loadWidgets(mWidgets,false); - mWidgets.clear(); - foreach(QString action, actions){ - QStringList desc = action.split(';'); - if(2 <= desc.size()){ - QString owner = desc.at(0); - QString act = desc.at(1); - mpTmpAction = new UBActionPreview(this); - mpTmpAction->setOwner(owner); - mpTmpAction->setContent(act); - mWidgets << mpTmpAction; - } + if(!mpDataMgr->actions()->empty()){ + foreach(sAction act, *mpDataMgr->actions()){ + mpTmpAction = new UBActionPreview(this); + mpTmpAction->setOwner(act.type); + mpTmpAction->setContent(act.content); + mpContentContainer->addWidget(mpTmpAction); + mStoredWidgets << mpTmpAction; } - mMediaViewer.loadWidgets(mWidgets, true); } } -void UBTeacherBarPreviewWidget::setLinks(QStringList links) +void UBTeacherBarPreviewWidget::generateMedias() { - if(!links.empty()){ - mWidgets.clear(); - mpLinksLabel->setVisible(true); - mWidgets << mpLinksLabel; - mMediaViewer.loadWidgets(mWidgets, false); - mWidgets.clear(); - foreach(QString link, links){ - mpTmpLink = new QLabel(link, this); - mpTmpLink->setOpenExternalLinks(true); - mWidgets << mpTmpLink; + foreach(QWidget* pMedia, *mpDataMgr->medias()){ + if(NULL != pMedia){ + mpContentContainer->addWidget(pMedia); + mStoredWidgets << pMedia; } - mMediaViewer.loadWidgets(mWidgets, true); } } -void UBTeacherBarPreviewWidget::updateFields() +void UBTeacherBarPreviewWidget::generateLinks() { - + if(!mpDataMgr->urls()->empty()){ + foreach(sLink link, *mpDataMgr->urls()){ + mpTmpLink = new QLabel(QString("%1").arg(link.link).arg(link.title), this); + mpTmpLink->setObjectName("UBLinkPreview"); + mpContentContainer->addWidget(mpTmpLink); + mStoredWidgets << mpTmpLink; + } + } } -void UBTeacherBarPreviewWidget::clearFields() +void UBTeacherBarPreviewWidget::generateComments() { - + if("" != mpDataMgr->comments()){ + mpTmpComment = new QTextEdit(this); + mpTmpComment->setObjectName("UBCommentPreview"); + mpTmpComment->setPlainText(mpDataMgr->comments()); + mpTmpComment->setReadOnly(true); + mpContentContainer->addWidget(mpTmpComment); + mStoredWidgets << mpTmpComment; + } } diff --git a/src/gui/UBTeacherBarPreviewWidget.h b/src/gui/UBTeacherBarPreviewWidget.h index a7ff6e9b..882bfc01 100644 --- a/src/gui/UBTeacherBarPreviewWidget.h +++ b/src/gui/UBTeacherBarPreviewWidget.h @@ -4,6 +4,7 @@ #include #include #include +#include #include "core/UBPersistenceManager.h" #include "customWidgets/UBWidgetList.h" @@ -30,12 +31,12 @@ class UBActionPreview : public QWidget public: UBActionPreview(QWidget* parent=0, const char* name="UBActionPreview"); ~UBActionPreview(); - void setOwner(const QString& owner); + void setOwner(int owner); void setContent(const QString& content); private: QLabel* mpOwner; - QLabel* mpContent; + QTextEdit* mpContent; QVBoxLayout mLayout; QHBoxLayout mOwnerLayout; @@ -48,19 +49,19 @@ public: ~UBTBPreviewContainer(); }; +class UBTBPreviewSeparator : public QFrame +{ +public: + UBTBPreviewSeparator(QWidget* parent=0, const char* name="UBTBPreviewSeparator"); + ~UBTBPreviewSeparator(); +}; + class UBTeacherBarPreviewWidget : public QWidget { Q_OBJECT public: UBTeacherBarPreviewWidget(UBTeacherBarDataMgr* pDataMgr, QWidget* parent=0, const char* name="UBTeacherBarPreviewWidget"); ~UBTeacherBarPreviewWidget(); - UBTeacherBarPreviewMedia* mediaViewer() {return &mMediaViewer;} - void setTitle(const QString& title); - void setComments(const QString& comments); - void setActions(QStringList actions); - void setLinks(QStringList links); - void clean(); - QLabel* mediaLabel() { return mpMediaLabel;} void updateFields(); void clearFields(); @@ -69,29 +70,47 @@ signals: private slots: void onEdit(); + void onActiveSceneChanged(); private: - void hideElements(); + void generateActions(); + void generateMedias(); + void generateLinks(); + void generateComments(); QVBoxLayout mLayout; QHBoxLayout mEditLayout; - QHBoxLayout mTitleDurationLayout; - UBTeacherBarPreviewMedia mMediaViewer; - QList mWidgets; - QList mStoredWidgets; - QPushButton* mpEditButton; + + // Titles + QVBoxLayout mTitleLayout; + UBTBPreviewSeparator mTitleSeparator; + QWidget mTitleContainer; + QLabel* mpSessionTitle; QLabel* mpTitle; - QLabel* mpDuration; - QLabel* mpActionsLabel; - QLabel* mpMediaLabel; - QLabel* mpCommentsLabel; - QLabel* mpComments; - QLabel* mpLinksLabel; - QLabel* mpTmpLink; - UBActionPreview* mpTmpAction; + QLabel* mpTitleLabel; + QLabel* mpPageNbrLabel; UBTBPreviewContainer* mpContentContainer; + + // Schedule + QLabel* mpScheduleLabel; + + // License + UBTBPreviewSeparator mLicenseSeparator; + QLabel* mpLicenseLabel; + + /** Pointer to the datas */ UBTeacherBarDataMgr* mpDataMgr; + /** The list of stored widgets */ + QList mStoredWidgets; + /** A temporary action widget */ + UBActionPreview* mpTmpAction; + /** A temporary media widget */ + UBTeacherBarPreviewMedia* mpTmpMedia; + /** A temporary link */ + QLabel* mpTmpLink; + /** A temporary comments field */ + QTextEdit* mpTmpComment; }; #endif // UBTEACHERBARPREVIEWWIDGET_H diff --git a/src/gui/UBTeacherBarWidget.cpp b/src/gui/UBTeacherBarWidget.cpp index 7d8ab771..322b3f91 100644 --- a/src/gui/UBTeacherBarWidget.cpp +++ b/src/gui/UBTeacherBarWidget.cpp @@ -39,13 +39,13 @@ UBTeacherBarWidget::UBTeacherBarWidget(QWidget *parent, const char *name):UBDock // Create the GUI setLayout(&mLayout); - mpPageEditWidget = new UBTBPageEditWidget(&mData, this); - mpPreview = new UBTeacherBarPreviewWidget(&mData, this); - mpDocPreviewWidget = new UBTBDocumentPreviewWidget(&mData, this); - mpDocEditWidget = new UBTBDocumentEditWidget(&mData, this); - mpStackWidget = new QStackedWidget(this); mLayout.addWidget(mpStackWidget); + mpPageEditWidget = new UBTBPageEditWidget(&mData, mpStackWidget); + mpPreview = new UBTeacherBarPreviewWidget(&mData, mpStackWidget); + mpDocPreviewWidget = new UBTBDocumentPreviewWidget(&mData, mpStackWidget); + mpDocEditWidget = new UBTBDocumentEditWidget(&mData, mpStackWidget); + mpStackWidget->addWidget(mpPageEditWidget); mpStackWidget->addWidget(mpPreview); mpStackWidget->addWidget(mpDocPreviewWidget); @@ -120,7 +120,7 @@ void UBTeacherBarWidget::loadContent(bool docChanged) // Update the fields mpPageEditWidget->updateFields(); - mpPreview->updateFields(); + //mpPreview->updateFields(); if(docChanged){ mpDocEditWidget->updateFields(); mpDocPreviewWidget->updateFields(); @@ -155,15 +155,19 @@ void UBTeacherBarWidget::onTBStateChanged(eTeacherBarState state) { switch(state){ case eTeacherBarState_DocumentEdit: + //mpDocEditWidget->updateFields(); mpStackWidget->setCurrentWidget(mpDocEditWidget); break; case eTeacherBarState_DocumentPreview: + //mpDocPreviewWidget->updateFields(); mpStackWidget->setCurrentWidget(mpDocPreviewWidget); break; case eTeacherBarState_PageEdit: + mpPageEditWidget->updateFields(); mpStackWidget->setCurrentWidget(mpPageEditWidget); break; case eTeacherBarState_PagePreview: + mpPreview->updateFields(); mpStackWidget->setCurrentWidget(mpPreview); break; } From b8e15166984256f7f6af131e9df89fc31a21628d Mon Sep 17 00:00:00 2001 From: shibakaneki Date: Wed, 25 Jan 2012 14:18:20 +0100 Subject: [PATCH 76/84] Backuping some rework on the teacherbar --- src/gui/UBTBPageEditWidget.cpp | 41 ++++++++++---- src/gui/UBTBPageEditWidget.h | 3 ++ src/gui/UBTeacherBarPreviewWidget.cpp | 77 +++++++++++++++++++-------- src/gui/UBTeacherBarPreviewWidget.h | 14 +++++ src/gui/UBTeacherBarWidget.cpp | 5 +- 5 files changed, 108 insertions(+), 32 deletions(-) diff --git a/src/gui/UBTBPageEditWidget.cpp b/src/gui/UBTBPageEditWidget.cpp index 4abda81d..4173aba1 100644 --- a/src/gui/UBTBPageEditWidget.cpp +++ b/src/gui/UBTBPageEditWidget.cpp @@ -29,7 +29,7 @@ UBTBPageEditWidget::UBTBPageEditWidget(UBTeacherBarDataMgr *pDataMgr, QWidget *p mUrls.clear(); setAttribute(Qt::WA_StyledBackground, true); setStyleSheet(UBApplication::globalStyleSheet()); - + mClearingFields = false; mLayout.setContentsMargins(0, 0, 0, 0); setLayout(&mLayout); @@ -120,14 +120,18 @@ UBTBPageEditWidget::~UBTBPageEditWidget() void UBTBPageEditWidget::onTitleChanged() { - mpDataMgr->setPageTitle(mpTitle->text()); - emit valueChanged(); + if(!mClearingFields){ + mpDataMgr->setPageTitle(mpTitle->text()); + emit valueChanged(); + } } void UBTBPageEditWidget::onCommentsChanged() { - mpDataMgr->setComments(mpComments->document()->toPlainText()); - emit valueChanged(); + if(!mClearingFields){ + mpDataMgr->setComments(mpComments->document()->toPlainText()); + emit valueChanged(); + } } void UBTBPageEditWidget::onActionButton() @@ -135,6 +139,7 @@ void UBTBPageEditWidget::onActionButton() UBTeacherStudentAction* pAction = new UBTeacherStudentAction(this); mActions << pAction; mpActions->addWidget(pAction); + emit valueChanged(); } void UBTBPageEditWidget::onLinkButton() @@ -142,6 +147,7 @@ void UBTBPageEditWidget::onLinkButton() UBUrlWidget* pUrl = new UBUrlWidget(this); mUrls << pUrl; mpLinks->addWidget(pUrl); + emit valueChanged(); } void UBTBPageEditWidget::onMediaDropped(const QString &url) @@ -149,9 +155,12 @@ void UBTBPageEditWidget::onMediaDropped(const QString &url) if("" != url){ QWidget* pMedia = mpMediaContainer->generateMediaWidget(url); if(NULL != pMedia){ - mpDataMgr->medias()->append(pMedia); - mpDataMgr->addMediaUrl(url); + mMedias << pMedia; + mMediaUrls << url; + //mpDataMgr->medias()->append(pMedia); + //mpDataMgr->addMediaUrl(url); mpMediaContainer->addWidget(pMedia); + emit valueChanged(); } } } @@ -170,6 +179,8 @@ void UBTBPageEditWidget::saveFields() { mpDataMgr->actions()->clear(); mpDataMgr->urls()->clear(); + mpDataMgr->mediaUrls().clear(); + mpDataMgr->medias()->clear(); foreach(UBTeacherStudentAction* pAct, mActions){ sAction action; @@ -183,6 +194,12 @@ void UBTBPageEditWidget::saveFields() link.link = pUrl->url(); mpDataMgr->urls()->append(link); } + foreach(QString url, mMediaUrls){ + mpDataMgr->mediaUrls().append(url); + } + foreach(QWidget* pMedia, mMedias){ + mpDataMgr->medias()->append(pMedia); + } } void UBTBPageEditWidget::updateFields() @@ -203,7 +220,7 @@ void UBTBPageEditWidget::updateFields() continue; QWidget* pWidget = mpMediaContainer->generateMediaWidget(url); if(pWidget != NULL){ - mpDataMgr->medias()->append(pWidget); + mMedias << pWidget; mpMediaContainer->addWidget(pWidget); } } @@ -221,6 +238,7 @@ void UBTBPageEditWidget::updateFields() void UBTBPageEditWidget::clearFields() { + mClearingFields = true; // Title mpTitle->setText(""); // Actions @@ -230,13 +248,14 @@ void UBTBPageEditWidget::clearFields() } mActions.clear(); // Medias - foreach(QWidget* pMedia, *mpDataMgr->medias()){ + foreach(QWidget* pMedia, mMedias){ if(NULL != pMedia){ mpMediaContainer->removeWidget(pMedia); DELETEPTR(pMedia); } } - mpDataMgr->mediaUrls().clear(); + mMedias.clear(); + mMediaUrls.clear(); // Links foreach(UBUrlWidget* pLink, mUrls){ mpLinks->removeWidget(pLink); @@ -245,6 +264,8 @@ void UBTBPageEditWidget::clearFields() mUrls.clear(); // Comments mpComments->setText(""); + + mClearingFields = false; } // --------------------------------------------------------------------------------------------- diff --git a/src/gui/UBTBPageEditWidget.h b/src/gui/UBTBPageEditWidget.h index fa56047d..0f3c61b9 100644 --- a/src/gui/UBTBPageEditWidget.h +++ b/src/gui/UBTBPageEditWidget.h @@ -133,6 +133,9 @@ private: QVector mActions; QVector mUrls; + QVector mMedias; + QStringList mMediaUrls; + bool mClearingFields; }; #endif // UBTBPAGEEDITWIDGET_H diff --git a/src/gui/UBTeacherBarPreviewWidget.cpp b/src/gui/UBTeacherBarPreviewWidget.cpp index 7d2ad585..9b7b136f 100644 --- a/src/gui/UBTeacherBarPreviewWidget.cpp +++ b/src/gui/UBTeacherBarPreviewWidget.cpp @@ -248,23 +248,13 @@ void UBTeacherBarPreviewWidget::onEdit() void UBTeacherBarPreviewWidget::updateFields() { - // First, remove the previous elements - if(!mStoredWidgets.empty()){ - foreach(QWidget* pW, mStoredWidgets){ - mpContentContainer->removeWidget(pW); - if( pW->objectName() == "UBActionPreview" || - pW->objectName() == "UBLinkPreview" || - pW->objectName() == "UBCommentsPreview"){ - // Here we delete all preview widget excepting the media because they are handled by the data manager - delete pW; - pW = NULL; - } - } - mStoredWidgets.clear(); - } - // Session Title - mpSessionTitle->setText(mpDataMgr->sessionTitle()); + if("" != mpDataMgr->sessionTitle()){ + mpSessionTitle->setText(mpDataMgr->sessionTitle()); + mpSessionTitle->setVisible(true); + }else{ + mpSessionTitle->setVisible(false); + } // Page Title if("" != mpDataMgr->pageTitle()){ @@ -279,7 +269,7 @@ void UBTeacherBarPreviewWidget::updateFields() generateActions(); // Media - generateMedias(); + //generateMedias(); // Links generateLinks(); @@ -291,7 +281,20 @@ void UBTeacherBarPreviewWidget::updateFields() void UBTeacherBarPreviewWidget::clearFields() { + // Session Title + mpSessionTitle->setText(""); + + // Page Title + mpTitle->setText(""); + // Medias + if(!mStoredWidgets.empty()){ + foreach(QWidget* pW, mStoredWidgets){ + mpContentContainer->removeWidget(pW); + DELETEPTR(pW); + } + mStoredWidgets.clear(); + } } void UBTeacherBarPreviewWidget::generateActions() @@ -309,10 +312,25 @@ void UBTeacherBarPreviewWidget::generateActions() void UBTeacherBarPreviewWidget::generateMedias() { - foreach(QWidget* pMedia, *mpDataMgr->medias()){ - if(NULL != pMedia){ - mpContentContainer->addWidget(pMedia); - mStoredWidgets << pMedia; + if(isVisible()){ + foreach(QString mediaUrl, mpDataMgr->mediaUrls()){ + QString mimeType = UBFileSystemUtils::mimeTypeFromFileName(mediaUrl); + if(mimeType.contains("image")){ + QPixmap pix = QPixmap(mediaUrl); + QLabel* label = new QLabel(); + pix.scaledToWidth(label->width()); + label->resize(pix.width(), pix.height()); + label->setPixmap(pix); + label->setScaledContents(true); + mStoredWidgets << label; + mpContentContainer->addWidget(label); + } + else if(mimeType.contains("video") || mimeType.contains("audio")){ + UBMediaWidget* mediaPlayer = new UBMediaWidget(mimeType.contains("audio")?eMediaType_Audio:eMediaType_Video); + mediaPlayer->setFile(mediaUrl); + mStoredWidgets << mediaPlayer; + mpContentContainer->addWidget(mediaPlayer); + } } } } @@ -323,6 +341,7 @@ void UBTeacherBarPreviewWidget::generateLinks() foreach(sLink link, *mpDataMgr->urls()){ mpTmpLink = new QLabel(QString("%1").arg(link.link).arg(link.title), this); mpTmpLink->setObjectName("UBLinkPreview"); + mpTmpLink->setOpenExternalLinks(true); mpContentContainer->addWidget(mpTmpLink); mStoredWidgets << mpTmpLink; } @@ -340,3 +359,19 @@ void UBTeacherBarPreviewWidget::generateComments() mStoredWidgets << mpTmpComment; } } + +void UBTeacherBarPreviewWidget::showEvent(QShowEvent* ev) +{ + //updateFields(); +} + +// ----------------------------------------------------------------------------------------------------- +UBDraggableMedia::UBDraggableMedia(eMediaType type, QWidget *parent, const char *name):UBMediaWidget(type, parent, name) +{ + +} + +UBDraggableMedia::~UBDraggableMedia() +{ + +} diff --git a/src/gui/UBTeacherBarPreviewWidget.h b/src/gui/UBTeacherBarPreviewWidget.h index 882bfc01..36b75f38 100644 --- a/src/gui/UBTeacherBarPreviewWidget.h +++ b/src/gui/UBTeacherBarPreviewWidget.h @@ -8,6 +8,7 @@ #include "core/UBPersistenceManager.h" #include "customWidgets/UBWidgetList.h" +#include "customWidgets/UBMediaWidget.h" #include "UBTeacherBarDataMgr.h" class UBTeacherBarPreviewMedia : public QWidget @@ -56,6 +57,14 @@ public: ~UBTBPreviewSeparator(); }; +class UBDraggableMedia : public UBMediaWidget +{ +public: + UBDraggableMedia(eMediaType type = eMediaType_Video, QWidget* parent=0, const char* name="UBDraggableMedia"); + ~UBDraggableMedia(); + +}; + class UBTeacherBarPreviewWidget : public QWidget { Q_OBJECT @@ -68,6 +77,9 @@ public: signals: void showEditMode(); +protected: + void showEvent(QShowEvent* ev); + private slots: void onEdit(); void onActiveSceneChanged(); @@ -111,6 +123,8 @@ private: QLabel* mpTmpLink; /** A temporary comments field */ QTextEdit* mpTmpComment; + /** A temporary media object */ + UBDraggableMedia* mTmpMedia; }; #endif // UBTEACHERBARPREVIEWWIDGET_H diff --git a/src/gui/UBTeacherBarWidget.cpp b/src/gui/UBTeacherBarWidget.cpp index 322b3f91..1198fdd9 100644 --- a/src/gui/UBTeacherBarWidget.cpp +++ b/src/gui/UBTeacherBarWidget.cpp @@ -148,7 +148,7 @@ bool UBTeacherBarWidget::isEmpty() void UBTeacherBarWidget::onShowEditMode() { - mpStackWidget->setCurrentWidget(mpPageEditWidget); + onTBStateChanged(eTeacherBarState_PageEdit); } void UBTeacherBarWidget::onTBStateChanged(eTeacherBarState state) @@ -163,10 +163,13 @@ void UBTeacherBarWidget::onTBStateChanged(eTeacherBarState state) mpStackWidget->setCurrentWidget(mpDocPreviewWidget); break; case eTeacherBarState_PageEdit: + mpPageEditWidget->clearFields(); mpPageEditWidget->updateFields(); mpStackWidget->setCurrentWidget(mpPageEditWidget); break; case eTeacherBarState_PagePreview: + saveContent(); + mpPreview->clearFields(); mpPreview->updateFields(); mpStackWidget->setCurrentWidget(mpPreview); break; From 628f213f1b0a4d9cb5d8d5c3a49b6c386e6b1726 Mon Sep 17 00:00:00 2001 From: shibakaneki Date: Wed, 25 Jan 2012 16:02:10 +0100 Subject: [PATCH 77/84] Progressing with the medias into the new teacherbar --- src/gui/UBTBPageEditWidget.cpp | 21 ++++++++++++--------- src/gui/UBTeacherBarDataMgr.cpp | 3 --- src/gui/UBTeacherBarDataMgr.h | 2 +- src/gui/UBTeacherBarPreviewWidget.cpp | 2 +- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/gui/UBTBPageEditWidget.cpp b/src/gui/UBTBPageEditWidget.cpp index 4173aba1..39f6716c 100644 --- a/src/gui/UBTBPageEditWidget.cpp +++ b/src/gui/UBTBPageEditWidget.cpp @@ -179,7 +179,7 @@ void UBTBPageEditWidget::saveFields() { mpDataMgr->actions()->clear(); mpDataMgr->urls()->clear(); - mpDataMgr->mediaUrls().clear(); + mpDataMgr->mediaUrls()->clear(); mpDataMgr->medias()->clear(); foreach(UBTeacherStudentAction* pAct, mActions){ @@ -195,7 +195,8 @@ void UBTBPageEditWidget::saveFields() mpDataMgr->urls()->append(link); } foreach(QString url, mMediaUrls){ - mpDataMgr->mediaUrls().append(url); + qDebug() << "saving media :" << url; + mpDataMgr->mediaUrls()->append(url); } foreach(QWidget* pMedia, mMedias){ mpDataMgr->medias()->append(pMedia); @@ -215,15 +216,17 @@ void UBTBPageEditWidget::updateFields() mpActions->addWidget(pAction); } // Medias - foreach(QString url, mpDataMgr->mediaUrls()){ - if(url.isEmpty()) - continue; - QWidget* pWidget = mpMediaContainer->generateMediaWidget(url); - if(pWidget != NULL){ - mMedias << pWidget; - mpMediaContainer->addWidget(pWidget); + foreach(QString url, *mpDataMgr->mediaUrls()){ + if(!url.isEmpty()){ + mMediaUrls << url; + QWidget* pWidget = mpMediaContainer->generateMediaWidget(url); + if(pWidget != NULL){ + mMedias << pWidget; + mpMediaContainer->addWidget(pWidget); + } } } + // Links foreach(sLink link, *mpDataMgr->urls()){ UBUrlWidget* urlWidget = new UBUrlWidget(this); diff --git a/src/gui/UBTeacherBarDataMgr.cpp b/src/gui/UBTeacherBarDataMgr.cpp index 28cbcb24..b612aa57 100644 --- a/src/gui/UBTeacherBarDataMgr.cpp +++ b/src/gui/UBTeacherBarDataMgr.cpp @@ -111,8 +111,5 @@ void UBTeacherBarDataMgr::loadContent(bool docChanged) // Comments mComments = nextInfos.comments; - - // TODO : Read the document metadata file and populate the metadata infos here - } diff --git a/src/gui/UBTeacherBarDataMgr.h b/src/gui/UBTeacherBarDataMgr.h index 73c28cc1..3158dab6 100644 --- a/src/gui/UBTeacherBarDataMgr.h +++ b/src/gui/UBTeacherBarDataMgr.h @@ -60,7 +60,7 @@ public: // Medias QVector* medias(){return &mMediaList;} void addMediaUrl(const QString& url){mMediaUrls << url;} - QStringList mediaUrls(){return mMediaUrls;} + QStringList* mediaUrls(){return &mMediaUrls;} // Urls QVector* urls(){return &mUrlList;} diff --git a/src/gui/UBTeacherBarPreviewWidget.cpp b/src/gui/UBTeacherBarPreviewWidget.cpp index 9b7b136f..1779ddcf 100644 --- a/src/gui/UBTeacherBarPreviewWidget.cpp +++ b/src/gui/UBTeacherBarPreviewWidget.cpp @@ -313,7 +313,7 @@ void UBTeacherBarPreviewWidget::generateActions() void UBTeacherBarPreviewWidget::generateMedias() { if(isVisible()){ - foreach(QString mediaUrl, mpDataMgr->mediaUrls()){ + foreach(QString mediaUrl, *mpDataMgr->mediaUrls()){ QString mimeType = UBFileSystemUtils::mimeTypeFromFileName(mediaUrl); if(mimeType.contains("image")){ QPixmap pix = QPixmap(mediaUrl); From d461e3a7867a4362abe88f64c89f054c98c96245 Mon Sep 17 00:00:00 2001 From: shibakaneki Date: Wed, 25 Jan 2012 16:20:04 +0100 Subject: [PATCH 78/84] Enabled the display of the media in the teacher bar page preview --- src/gui/UBTeacherBarPreviewWidget.cpp | 4 ++-- src/gui/UBTeacherBarWidget.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gui/UBTeacherBarPreviewWidget.cpp b/src/gui/UBTeacherBarPreviewWidget.cpp index 1779ddcf..fb225ef8 100644 --- a/src/gui/UBTeacherBarPreviewWidget.cpp +++ b/src/gui/UBTeacherBarPreviewWidget.cpp @@ -269,7 +269,7 @@ void UBTeacherBarPreviewWidget::updateFields() generateActions(); // Media - //generateMedias(); + generateMedias(); // Links generateLinks(); @@ -362,7 +362,7 @@ void UBTeacherBarPreviewWidget::generateComments() void UBTeacherBarPreviewWidget::showEvent(QShowEvent* ev) { - //updateFields(); + updateFields(); } // ----------------------------------------------------------------------------------------------------- diff --git a/src/gui/UBTeacherBarWidget.cpp b/src/gui/UBTeacherBarWidget.cpp index 1198fdd9..3a66e246 100644 --- a/src/gui/UBTeacherBarWidget.cpp +++ b/src/gui/UBTeacherBarWidget.cpp @@ -170,7 +170,7 @@ void UBTeacherBarWidget::onTBStateChanged(eTeacherBarState state) case eTeacherBarState_PagePreview: saveContent(); mpPreview->clearFields(); - mpPreview->updateFields(); + //mpPreview->updateFields(); mpStackWidget->setCurrentWidget(mpPreview); break; } From 5ce549f174ca646ff739fe4f09f424e749027304 Mon Sep 17 00:00:00 2001 From: shibakaneki Date: Thu, 26 Jan 2012 15:45:22 +0100 Subject: [PATCH 79/84] Implemented the drag and drop from the teacherbar to the board --- src/board/UBBoardView.cpp | 3 +- src/customWidgets/UBDraggableMedia.cpp | 42 ++++++++++++++++++++++++++ src/customWidgets/UBDraggableMedia.h | 19 ++++++++++++ src/customWidgets/UBMediaWidget.h | 4 +-- src/customWidgets/customWidgets.pri | 6 ++-- src/gui/UBTeacherBarPreviewWidget.cpp | 24 +++------------ src/gui/UBTeacherBarPreviewWidget.h | 12 +++----- src/gui/UBTeacherBarWidget.cpp | 4 ++- 8 files changed, 81 insertions(+), 33 deletions(-) create mode 100644 src/customWidgets/UBDraggableMedia.cpp create mode 100644 src/customWidgets/UBDraggableMedia.h diff --git a/src/board/UBBoardView.cpp b/src/board/UBBoardView.cpp index 4cbfe088..5bd63181 100644 --- a/src/board/UBBoardView.cpp +++ b/src/board/UBBoardView.cpp @@ -47,6 +47,7 @@ #include "document/UBDocumentProxy.h" #include "customWidgets/UBDraggableLabel.h" +#include "customWidgets/UBDraggableMedia.h" #include "core/memcheck.h" @@ -727,7 +728,7 @@ void UBBoardView::dropEvent (QDropEvent *event) { qDebug() << event->source(); - if(!event->source() || dynamic_cast(event->source()) || dynamic_cast(event->source()) || dynamic_cast(event->source()) || dynamic_cast(event->source())) + if(!event->source() || dynamic_cast(event->source()) || dynamic_cast(event->source()) || dynamic_cast(event->source()) || dynamic_cast(event->source()) || dynamic_cast(event->source())) { mController->processMimeData (event->mimeData (), mapToScene (event->pos ())); event->acceptProposedAction (); diff --git a/src/customWidgets/UBDraggableMedia.cpp b/src/customWidgets/UBDraggableMedia.cpp new file mode 100644 index 00000000..6d2551f2 --- /dev/null +++ b/src/customWidgets/UBDraggableMedia.cpp @@ -0,0 +1,42 @@ +#include +#include + +#include "UBDraggableMedia.h" + +UBDraggableMedia::UBDraggableMedia(eMediaType type, QWidget *parent, const char *name):UBMediaWidget(type, parent, name) +{ + +} + +UBDraggableMedia::~UBDraggableMedia() +{ + +} + +void UBDraggableMedia::mousePressEvent(QMouseEvent* ev) +{ + if(Qt::LeftButton == ev->button()){ + mDragStartPos = ev->pos(); + } +} + +void UBDraggableMedia::mouseMoveEvent(QMouseEvent* ev) +{ + if(!(ev->buttons() & Qt::LeftButton)){ + return; + } + if((ev->pos() - mDragStartPos).manhattanLength() < QApplication::startDragDistance()){ + return; + } + QDrag *drag = new QDrag(this); + QMimeData *mimeData = new QMimeData; + + QList urls; + urls << QUrl(mFilePath); + mimeData->setText(mFilePath); + mimeData->setUrls(urls); + + drag->setMimeData(mimeData); + + Qt::DropAction dropAction = drag->exec(Qt::CopyAction | Qt::MoveAction); +} diff --git a/src/customWidgets/UBDraggableMedia.h b/src/customWidgets/UBDraggableMedia.h new file mode 100644 index 00000000..b45c9391 --- /dev/null +++ b/src/customWidgets/UBDraggableMedia.h @@ -0,0 +1,19 @@ +#ifndef UBDRAGGABLEMEDIA_H +#define UBDRAGGABLEMEDIA_H + +#include "UBMediaWidget.h" + +class UBDraggableMedia : public UBMediaWidget +{ +public: + UBDraggableMedia(eMediaType type = eMediaType_Video, QWidget* parent=0, const char* name="UBDraggableMedia"); + ~UBDraggableMedia(); +protected: + void mousePressEvent(QMouseEvent* ev); + void mouseMoveEvent(QMouseEvent* ev); + +private: + QPoint mDragStartPos; +}; + +#endif // UBDRAGGABLEMEDIA_H diff --git a/src/customWidgets/UBMediaWidget.h b/src/customWidgets/UBMediaWidget.h index ef8a65a2..5192c3c7 100644 --- a/src/customWidgets/UBMediaWidget.h +++ b/src/customWidgets/UBMediaWidget.h @@ -72,6 +72,8 @@ public: protected: void resizeEvent(QResizeEvent* ev); void showEvent(QShowEvent* event); + /** The current media file path */ + QString mFilePath; private slots: void onPlayStopClicked(); @@ -85,8 +87,6 @@ private: void createMediaPlayer(); void adaptSizeToVideo(); - /** The current media file path */ - QString mFilePath; /** The current media type */ eMediaType mType; /** The media object */ diff --git a/src/customWidgets/customWidgets.pri b/src/customWidgets/customWidgets.pri index e46249f5..aa7b0255 100644 --- a/src/customWidgets/customWidgets.pri +++ b/src/customWidgets/customWidgets.pri @@ -2,8 +2,10 @@ HEADERS += src/customWidgets/UBWidgetList.h \ src/customWidgets/UBDraggableLabel.h \ src/customWidgets/UBMediaWidget.h \ - src/customWidgets/UBGlobals.h + src/customWidgets/UBGlobals.h \ + src/customWidgets/UBDraggableMedia.h SOURCES += src/customWidgets/UBWidgetList.cpp \ src/customWidgets/UBDraggableLabel.cpp \ - src/customWidgets/UBMediaWidget.cpp + src/customWidgets/UBMediaWidget.cpp \ + src/customWidgets/UBDraggableMedia.cpp diff --git a/src/gui/UBTeacherBarPreviewWidget.cpp b/src/gui/UBTeacherBarPreviewWidget.cpp index fb225ef8..43331956 100644 --- a/src/gui/UBTeacherBarPreviewWidget.cpp +++ b/src/gui/UBTeacherBarPreviewWidget.cpp @@ -316,17 +316,13 @@ void UBTeacherBarPreviewWidget::generateMedias() foreach(QString mediaUrl, *mpDataMgr->mediaUrls()){ QString mimeType = UBFileSystemUtils::mimeTypeFromFileName(mediaUrl); if(mimeType.contains("image")){ - QPixmap pix = QPixmap(mediaUrl); - QLabel* label = new QLabel(); - pix.scaledToWidth(label->width()); - label->resize(pix.width(), pix.height()); - label->setPixmap(pix); - label->setScaledContents(true); - mStoredWidgets << label; - mpContentContainer->addWidget(label); + mpTmpLabel = new UBDraggableLabel(); + mpTmpLabel->loadImage(mediaUrl); + mStoredWidgets << mpTmpLabel; + mpContentContainer->addWidget(mpTmpLabel); } else if(mimeType.contains("video") || mimeType.contains("audio")){ - UBMediaWidget* mediaPlayer = new UBMediaWidget(mimeType.contains("audio")?eMediaType_Audio:eMediaType_Video); + UBDraggableMedia* mediaPlayer = new UBDraggableMedia(mimeType.contains("audio")?eMediaType_Audio:eMediaType_Video); mediaPlayer->setFile(mediaUrl); mStoredWidgets << mediaPlayer; mpContentContainer->addWidget(mediaPlayer); @@ -365,13 +361,3 @@ void UBTeacherBarPreviewWidget::showEvent(QShowEvent* ev) updateFields(); } -// ----------------------------------------------------------------------------------------------------- -UBDraggableMedia::UBDraggableMedia(eMediaType type, QWidget *parent, const char *name):UBMediaWidget(type, parent, name) -{ - -} - -UBDraggableMedia::~UBDraggableMedia() -{ - -} diff --git a/src/gui/UBTeacherBarPreviewWidget.h b/src/gui/UBTeacherBarPreviewWidget.h index 36b75f38..c1820777 100644 --- a/src/gui/UBTeacherBarPreviewWidget.h +++ b/src/gui/UBTeacherBarPreviewWidget.h @@ -9,6 +9,8 @@ #include "core/UBPersistenceManager.h" #include "customWidgets/UBWidgetList.h" #include "customWidgets/UBMediaWidget.h" +#include "customWidgets/UBDraggableMedia.h" +#include "customWidgets/UBDraggableLabel.h" #include "UBTeacherBarDataMgr.h" class UBTeacherBarPreviewMedia : public QWidget @@ -57,14 +59,6 @@ public: ~UBTBPreviewSeparator(); }; -class UBDraggableMedia : public UBMediaWidget -{ -public: - UBDraggableMedia(eMediaType type = eMediaType_Video, QWidget* parent=0, const char* name="UBDraggableMedia"); - ~UBDraggableMedia(); - -}; - class UBTeacherBarPreviewWidget : public QWidget { Q_OBJECT @@ -125,6 +119,8 @@ private: QTextEdit* mpTmpComment; /** A temporary media object */ UBDraggableMedia* mTmpMedia; + /** A temporary label object */ + UBDraggableLabel* mpTmpLabel; }; #endif // UBTEACHERBARPREVIEWWIDGET_H diff --git a/src/gui/UBTeacherBarWidget.cpp b/src/gui/UBTeacherBarWidget.cpp index 3a66e246..8b988526 100644 --- a/src/gui/UBTeacherBarWidget.cpp +++ b/src/gui/UBTeacherBarWidget.cpp @@ -170,7 +170,9 @@ void UBTeacherBarWidget::onTBStateChanged(eTeacherBarState state) case eTeacherBarState_PagePreview: saveContent(); mpPreview->clearFields(); - //mpPreview->updateFields(); + if(mpPreview->isVisible()){ + mpPreview->updateFields(); + } mpStackWidget->setCurrentWidget(mpPreview); break; } From d6af845cf01635d892e37c9a960028cd4a001fd0 Mon Sep 17 00:00:00 2001 From: shibakaneki Date: Fri, 27 Jan 2012 14:41:13 +0100 Subject: [PATCH 80/84] src/adaptors --- resources/sankore.qrc | 6 +++ resources/style.qss | 5 ++- src/gui/UBTBDocumentEditWidget.cpp | 23 ++++++++++ src/gui/UBTBDocumentEditWidget.h | 6 +++ src/gui/UBTeacherBarDataMgr.cpp | 65 ++++++++++++++++++++++++++- src/gui/UBTeacherBarDataMgr.h | 36 +++++++++++++-- src/gui/UBTeacherBarPreviewWidget.cpp | 29 +++++------- src/gui/UBTeacherBarPreviewWidget.h | 16 +++---- 8 files changed, 149 insertions(+), 37 deletions(-) diff --git a/resources/sankore.qrc b/resources/sankore.qrc index 8601be9f..d81ac808 100644 --- a/resources/sankore.qrc +++ b/resources/sankore.qrc @@ -341,5 +341,11 @@ images/duration1.png images/duration2.png images/duration3.png + images/licenses/ccby.png + images/licenses/ccbync.png + images/licenses/ccbyncnd.png + images/licenses/ccbyncsa.png + images/licenses/ccbynd.png + images/licenses/ccbysa.png diff --git a/resources/style.qss b/resources/style.qss index bdb0966a..8ce2d992 100644 --- a/resources/style.qss +++ b/resources/style.qss @@ -83,10 +83,11 @@ QWidget#UBTeacherBarTargetBox background-color: white; } -QWidget#UBActionPreviewContent +QWidget#UBActionPreviewContent, +QTextEdit#UBCommentPreview { border-radius : 10px; - border: 2px solid; + border: 2px solid #999999; padding: 5px 5px 5px 5px; } diff --git a/src/gui/UBTBDocumentEditWidget.cpp b/src/gui/UBTBDocumentEditWidget.cpp index 618dc0ca..1d93900c 100644 --- a/src/gui/UBTBDocumentEditWidget.cpp +++ b/src/gui/UBTBDocumentEditWidget.cpp @@ -10,6 +10,7 @@ UBTBDocumentEditWidget::UBTBDocumentEditWidget(UBTeacherBarDataMgr* pDataMgr, QW , mpTarget(NULL) , mpMetadataLabel(NULL) , mpLicenseLabel(NULL) + , mpLicenseCombox(NULL) { setObjectName(name); @@ -31,6 +32,7 @@ UBTBDocumentEditWidget::UBTBDocumentEditWidget(UBTeacherBarDataMgr* pDataMgr, QW mpTitle = new QLineEdit(mpContainer); mpTitle->setObjectName("DockPaletteWidgetLineEdit"); mContainerLayout.addWidget(mpTitle, 0); + mContainerLayout.addWidget(&mTitleSeparator); // Target mpTargetLabel = new QLabel(tr("Session Target"), mpContainer); @@ -39,18 +41,31 @@ UBTBDocumentEditWidget::UBTBDocumentEditWidget(UBTeacherBarDataMgr* pDataMgr, QW mpTarget = new QTextEdit(mpContainer); mpTarget->setObjectName("UBTeacherBarTargetBox"); mContainerLayout.addWidget(mpTarget, 1); + mContainerLayout.addWidget(&mTargetSeparator); // Metadata mpMetadataLabel = new QLabel(tr("Metadata"), mpContainer); mpMetadataLabel->setAlignment(Qt::AlignLeft); //mpMetadataLabel->setObjectName("UBTeacherBarPreviewSubtitle"); mContainerLayout.addWidget(mpMetadataLabel, 0); + mContainerLayout.addWidget(&mLicenseSeparator); // License mpLicenseLabel = new QLabel(tr("License"), mpContainer); mpLicenseLabel->setAlignment(Qt::AlignLeft); //mpLicenseLabel->setObjectName("UBTeacherBarPreviewSubtitle"); mContainerLayout.addWidget(mpLicenseLabel, 0); + mpLicenseCombox = new QComboBox(this); + mpLicenseCombox->setObjectName("DockPaletteWidgetComboBox"); + QStringList qslLicenses; + qslLicenses << "CC BY"; + qslLicenses << "CC BY-ND"; + qslLicenses << "CC BY-NC-SA"; + qslLicenses << "CC BY-SA"; + qslLicenses << "CC BY-NC"; + qslLicenses << "CC BY-NC-ND"; + mpLicenseCombox->addItems(qslLicenses); + mContainerLayout.addWidget(mpLicenseCombox); mpPageViewButton = new QPushButton(tr("Page View"), this); mpPageViewButton->setObjectName("DockPaletteWidgetButton"); @@ -65,6 +80,7 @@ UBTBDocumentEditWidget::UBTBDocumentEditWidget(UBTeacherBarDataMgr* pDataMgr, QW connect(mpPreviewButton, SIGNAL(clicked()), this, SLOT(onPreview())); connect(mpTitle, SIGNAL(textChanged(QString)), this, SLOT(onSessionTitleChanged())); connect(mpTarget, SIGNAL(textChanged()), this, SLOT(onSessionTargetChanged())); + connect(mpLicenseCombox, SIGNAL(currentIndexChanged(int)), this, SLOT(onLicenseCurrentIndexChanged(int))); } UBTBDocumentEditWidget::~UBTBDocumentEditWidget() @@ -75,6 +91,7 @@ UBTBDocumentEditWidget::~UBTBDocumentEditWidget() DELETEPTR(mpTarget); DELETEPTR(mpMetadataLabel); DELETEPTR(mpLicenseLabel); + DELETEPTR(mpLicenseCombox); DELETEPTR(mpPageViewButton); DELETEPTR(mpPreviewButton); } @@ -101,6 +118,12 @@ void UBTBDocumentEditWidget::onSessionTargetChanged() emit valueChanged(); } +void UBTBDocumentEditWidget::onLicenseCurrentIndexChanged(int selection) +{ + mpDataMgr->setSessionLicence((eLicense)selection); + emit valueChanged(); +} + void UBTBDocumentEditWidget::updateFields() { mpTitle->setText(mpDataMgr->sessionTitle()); diff --git a/src/gui/UBTBDocumentEditWidget.h b/src/gui/UBTBDocumentEditWidget.h index 147e5404..8cfb7ff9 100644 --- a/src/gui/UBTBDocumentEditWidget.h +++ b/src/gui/UBTBDocumentEditWidget.h @@ -6,6 +6,7 @@ #include #include #include +#include #include "UBTeacherBarDataMgr.h" @@ -27,6 +28,7 @@ private slots: void onPreview(); void onSessionTitleChanged(); void onSessionTargetChanged(); + void onLicenseCurrentIndexChanged(int selection); private: QVBoxLayout mLayout; @@ -35,6 +37,9 @@ private: QVBoxLayout mContainerLayout; QPushButton* mpPageViewButton; QPushButton* mpPreviewButton; + UBTBSeparator mTitleSeparator; + UBTBSeparator mTargetSeparator; + UBTBSeparator mLicenseSeparator; QWidget* mpContainer; QLabel* mpTitleLabel; @@ -43,6 +48,7 @@ private: QTextEdit* mpTarget; QLabel* mpMetadataLabel; QLabel* mpLicenseLabel; + QComboBox* mpLicenseCombox; UBTeacherBarDataMgr* mpDataMgr; }; diff --git a/src/gui/UBTeacherBarDataMgr.cpp b/src/gui/UBTeacherBarDataMgr.cpp index b612aa57..4233e58a 100644 --- a/src/gui/UBTeacherBarDataMgr.cpp +++ b/src/gui/UBTeacherBarDataMgr.cpp @@ -58,7 +58,7 @@ void UBTeacherBarDataMgr::saveContent() documentProxy->setSessionTitle(mSessionTitle); documentProxy->setSessionTarget(mSessionTarget); - documentProxy->setSessionLicence(mSessionLicence); + documentProxy->setSessionLicence(QString("%0").arg(mSessionLicence)); UBMetadataDcSubsetAdaptor::persist(documentProxy); } @@ -75,7 +75,7 @@ void UBTeacherBarDataMgr::loadContent(bool docChanged) if(true/*docChanged*/){ mSessionTitle = documentProxy->sessionTitle(); mSessionTarget = documentProxy->sessionTarget(); - mSessionLicence = documentProxy->sessionLicence(); + mSessionLicence = (eLicense)documentProxy->sessionLicence().toInt(); } // Page Title @@ -113,3 +113,64 @@ void UBTeacherBarDataMgr::loadContent(bool docChanged) mComments = nextInfos.comments; } +// ------------------------------------------------------------------------------------ +UBTBSeparator::UBTBSeparator(QWidget *parent, const char *name):QFrame(parent) +{ + setObjectName("UBTBSeparator"); + setMinimumHeight(5); + setMaximumHeight(5); +} + +UBTBSeparator::~UBTBSeparator() +{ + +} + +// ------------------------------------------------------------------------------------ +UBTBLicenseWidget::UBTBLicenseWidget(QWidget *parent, const char *name):QWidget(parent) +{ + setObjectName(name); + setLayout(&mLayout); + + mpIcon = new QLabel(this); + mpText = new QLabel(this); + mpText->setWordWrap(true); + mLayout.addWidget(mpIcon); + mLayout.addWidget(mpText); +} + +UBTBLicenseWidget::~UBTBLicenseWidget() +{ + DELETEPTR(mpIcon); + DELETEPTR(mpText); +} + +void UBTBLicenseWidget::setLicense(eLicense lic) +{ + switch(lic){ + case eLicense_CCBY: + mpIcon->setPixmap(QPixmap(":images/licenses/ccby.png")); + mpText->setText(tr("Creative Common License %0").arg("CC BY")); + break; + case eLicense_CCBYND: + mpIcon->setPixmap(QPixmap(":images/licenses/ccbynd.png")); + mpText->setText(tr("Creative Common License %0").arg("CC BY-ND")); + break; + case eLicense_CCBYNCSA: + mpIcon->setPixmap(QPixmap(":images/licenses/ccbyncsa.png")); + mpText->setText(tr("Creative Common License %0").arg("CC BY-NC-SA")); + break; + case eLicense_CCBYSA: + mpIcon->setPixmap(QPixmap(":images/licenses/ccbysa.png")); + mpText->setText(tr("Creative Common License %0").arg("CC BY-SA")); + break; + case eLicense_CCBYNC: + mpIcon->setPixmap(QPixmap(":images/licenses/ccbync.png")); + mpText->setText(tr("Creative Common License %0").arg("CC BY-NC")); + break; + case eLicense_CCBYNCND: + mpIcon->setPixmap(QPixmap(":images/licenses/ccbyncnd.png")); + mpText->setText(tr("Creative Common License %0").arg("CC BY-NC-ND")); + break; + } +} diff --git a/src/gui/UBTeacherBarDataMgr.h b/src/gui/UBTeacherBarDataMgr.h index 3158dab6..7ddca7e9 100644 --- a/src/gui/UBTeacherBarDataMgr.h +++ b/src/gui/UBTeacherBarDataMgr.h @@ -9,6 +9,7 @@ #include #include #include +#include typedef enum{ eTeacherBarState_DocumentEdit, @@ -32,6 +33,35 @@ typedef struct{ QString link; }sLink; +typedef enum{ + eLicense_CCBY, + eLicense_CCBYND, + eLicense_CCBYNCSA, + eLicense_CCBYSA, + eLicense_CCBYNC, + eLicense_CCBYNCND +}eLicense; + +class UBTBSeparator : public QFrame +{ +public: + UBTBSeparator(QWidget* parent=0, const char* name="UBTBSeparator"); + ~UBTBSeparator(); +}; + +class UBTBLicenseWidget : public QWidget +{ +public: + UBTBLicenseWidget(QWidget* parent=0, const char* name="UBTBLicenseWidget"); + ~UBTBLicenseWidget(); + void setLicense(eLicense lic); + +private: + QHBoxLayout mLayout; + QLabel* mpIcon; + QLabel* mpText; +}; + class UBTeacherBarDataMgr { public: @@ -47,8 +77,8 @@ public: QString sessionTarget(){return mSessionTarget;} // Licence - void setSessionLicence(const QString& licence){mSessionLicence = licence;} - QString sessionLicence(){return mSessionLicence;} + void setSessionLicence(eLicense licence){mSessionLicence = licence;} + eLicense sessionLicence(){return mSessionLicence;} // Page Title void setPageTitle(const QString& title){mPageTitle = title;} @@ -77,7 +107,7 @@ public: private: QString mSessionTitle; QString mSessionTarget; - QString mSessionLicence; + eLicense mSessionLicence; QString mPageTitle; QString mComments; diff --git a/src/gui/UBTeacherBarPreviewWidget.cpp b/src/gui/UBTeacherBarPreviewWidget.cpp index 43331956..9b93008b 100644 --- a/src/gui/UBTeacherBarPreviewWidget.cpp +++ b/src/gui/UBTeacherBarPreviewWidget.cpp @@ -126,7 +126,7 @@ void UBActionPreview::setContent(const QString &content) { if(NULL != mpContent){ mpContent->setText(content); - setMinimumHeight(mpOwner->height() + mpContent->height()); + setMinimumHeight(mpOwner->height() + mpContent->document()->documentLayout()->documentSize().toSize().height()); } } @@ -139,18 +139,6 @@ UBTBPreviewContainer::UBTBPreviewContainer(QWidget *parent, const char *name):UB UBTBPreviewContainer::~UBTBPreviewContainer() { -} -// ------------------------------------------------------------------------------------ -UBTBPreviewSeparator::UBTBPreviewSeparator(QWidget *parent, const char *name):QFrame(parent) -{ - setObjectName("UBTBSeparator"); - setMinimumHeight(5); - setMaximumHeight(5); -} - -UBTBPreviewSeparator::~UBTBPreviewSeparator() -{ - } // ------------------------------------------------------------------------------------ @@ -206,11 +194,8 @@ UBTeacherBarPreviewWidget::UBTeacherBarPreviewWidget(UBTeacherBarDataMgr* pDataM // License mLayout.addWidget(&mLicenseSeparator); - mpLicenseLabel = new QLabel(tr("License"), this); - mpLicenseLabel->setObjectName("UBTeacherBarPreviewSubtitle"); + mpLicenseLabel = new UBTBLicenseWidget(this); mLayout.addWidget(mpLicenseLabel); - // TODO : Add the license field here - // Edit button mpEditButton = new QPushButton(tr("Edit infos"), this); @@ -271,11 +256,14 @@ void UBTeacherBarPreviewWidget::updateFields() // Media generateMedias(); + // Comments + generateComments(); + // Links generateLinks(); - // Comments - generateComments(); + // License + mpLicenseLabel->setLicense(mpDataMgr->sessionLicence()); } @@ -295,6 +283,9 @@ void UBTeacherBarPreviewWidget::clearFields() } mStoredWidgets.clear(); } + + // License + mpLicenseLabel->setLicense(eLicense_CCBY); } void UBTeacherBarPreviewWidget::generateActions() diff --git a/src/gui/UBTeacherBarPreviewWidget.h b/src/gui/UBTeacherBarPreviewWidget.h index c1820777..ada45f6e 100644 --- a/src/gui/UBTeacherBarPreviewWidget.h +++ b/src/gui/UBTeacherBarPreviewWidget.h @@ -4,7 +4,6 @@ #include #include #include -#include #include "core/UBPersistenceManager.h" #include "customWidgets/UBWidgetList.h" @@ -52,13 +51,6 @@ public: ~UBTBPreviewContainer(); }; -class UBTBPreviewSeparator : public QFrame -{ -public: - UBTBPreviewSeparator(QWidget* parent=0, const char* name="UBTBPreviewSeparator"); - ~UBTBPreviewSeparator(); -}; - class UBTeacherBarPreviewWidget : public QWidget { Q_OBJECT @@ -90,7 +82,7 @@ private: // Titles QVBoxLayout mTitleLayout; - UBTBPreviewSeparator mTitleSeparator; + UBTBSeparator mTitleSeparator; QWidget mTitleContainer; QLabel* mpSessionTitle; QLabel* mpTitle; @@ -102,8 +94,10 @@ private: QLabel* mpScheduleLabel; // License - UBTBPreviewSeparator mLicenseSeparator; - QLabel* mpLicenseLabel; + UBTBSeparator mLicenseSeparator; + // TODO : replace the QLabel of the license by a widget done for that! + UBTBLicenseWidget* mpLicenseLabel; + /** Pointer to the datas */ UBTeacherBarDataMgr* mpDataMgr; From 4a051f2ac405a5472b8eff32f3dde97818b71856 Mon Sep 17 00:00:00 2001 From: Ivan Ilin Date: Fri, 27 Jan 2012 17:00:43 +0200 Subject: [PATCH 81/84] linux hotfix 6bbecff SANKORE-329 Visibility of palette based on children elements --- src/board/UBBoardPaletteManager.cpp | 6 +++--- src/desktop/UBDesktopAnnotationController.cpp | 19 ++++++++++++++++++- src/gui/UBDockPaletteWidget.h | 2 +- src/gui/UBTeacherBarWidget.h | 2 +- 4 files changed, 23 insertions(+), 6 deletions(-) diff --git a/src/board/UBBoardPaletteManager.cpp b/src/board/UBBoardPaletteManager.cpp index f1f1d00b..4c79f726 100644 --- a/src/board/UBBoardPaletteManager.cpp +++ b/src/board/UBBoardPaletteManager.cpp @@ -692,7 +692,7 @@ void UBBoardPaletteManager::changeMode(eUBDockPaletteWidgetMode newMode, bool is { case eUBDockPaletteWidget_BOARD: { - mLeftPalette->setParent(UBApplication::boardController->controlContainer()); + mLeftPalette->assignParent(UBApplication::boardController->controlContainer()); mRightPalette->assignParent(UBApplication::boardController->controlContainer()); if (UBPlatformUtils::hasVirtualKeyboard() && mKeyboardPalette != NULL) { @@ -721,7 +721,7 @@ void UBBoardPaletteManager::changeMode(eUBDockPaletteWidgetMode newMode, bool is case eUBDockPaletteWidget_DESKTOP: { - mLeftPalette->setParent((QWidget*)UBApplication::applicationController->uninotesController()->drawingView()); + mLeftPalette->assignParent((QWidget*)UBApplication::applicationController->uninotesController()->drawingView()); mRightPalette->assignParent((QWidget*)UBApplication::applicationController->uninotesController()->drawingView()); if (UBPlatformUtils::hasVirtualKeyboard() && mKeyboardPalette != NULL) { @@ -775,7 +775,7 @@ void UBBoardPaletteManager::changeMode(eUBDockPaletteWidgetMode newMode, bool is { mLeftPalette->setVisible(leftPaletteVisible); mRightPalette->setVisible(rightPaletteVisible); - mLeftPalette->setParent(0); + mLeftPalette->assignParent(0); mRightPalette->assignParent(0); if (UBPlatformUtils::hasVirtualKeyboard() && mKeyboardPalette != NULL) { diff --git a/src/desktop/UBDesktopAnnotationController.cpp b/src/desktop/UBDesktopAnnotationController.cpp index 09cd7ed8..a2a4eac0 100644 --- a/src/desktop/UBDesktopAnnotationController.cpp +++ b/src/desktop/UBDesktopAnnotationController.cpp @@ -888,12 +888,16 @@ void UBDesktopAnnotationController::TransparentWidgetResized() void UBDesktopAnnotationController::onTransparentWidgetResized() { int rW = UBApplication::boardController->paletteManager()->rightPalette()->width(); - int rH_ = UBApplication::boardController->paletteManager()->rightPalette()->height(); + int lW = UBApplication::boardController->paletteManager()->leftPalette()->width(); + int rH = mTransparentDrawingView->height(); UBApplication::boardController->paletteManager()->rightPalette()->resize(rW+1, rH); UBApplication::boardController->paletteManager()->rightPalette()->resize(rW, rH); + UBApplication::boardController->paletteManager()->leftPalette()->resize(lW+1, rH); + UBApplication::boardController->paletteManager()->leftPalette()->resize(lW, rH); + // mRightPalette->resize(mRightPalette->width(), mTransparentDrawingView->height()); } @@ -923,6 +927,19 @@ void UBDesktopAnnotationController::updateMask(bool bTransparent) UBApplication::boardController->paletteManager()->mKeyboardPalette->width(), UBApplication::boardController->paletteManager()->mKeyboardPalette->height()); } + if(UBApplication::boardController->paletteManager()->leftPalette()->isVisible()) + { + QRect leftPalette(UBApplication::boardController->paletteManager()->leftPalette()->geometry().x(), + UBApplication::boardController->paletteManager()->leftPalette()->geometry().y(), + UBApplication::boardController->paletteManager()->leftPalette()->width(), + UBApplication::boardController->paletteManager()->leftPalette()->height()); + + QRect tabsPalette(UBApplication::boardController->paletteManager()->leftPalette()->getTabPaletteRect()); + + p.drawRect(leftPalette); + p.drawRect(tabsPalette); + } + if(UBApplication::boardController->paletteManager()->rightPalette()->isVisible()) { QRect rightPalette(UBApplication::boardController->paletteManager()->rightPalette()->geometry().x(), diff --git a/src/gui/UBDockPaletteWidget.h b/src/gui/UBDockPaletteWidget.h index 195e6013..163ca0cd 100644 --- a/src/gui/UBDockPaletteWidget.h +++ b/src/gui/UBDockPaletteWidget.h @@ -25,7 +25,7 @@ public: QPixmap iconToLeft(); QString name(); - virtual bool visibleInMode(eUBDockPaletteWidgetMode mode) = NULL; + virtual bool visibleInMode(eUBDockPaletteWidgetMode mode) = 0; bool visibleState(){return mVisibleState;} void setVisibleState(bool state){mVisibleState = state;} diff --git a/src/gui/UBTeacherBarWidget.h b/src/gui/UBTeacherBarWidget.h index cd402a13..e3fb2bce 100644 --- a/src/gui/UBTeacherBarWidget.h +++ b/src/gui/UBTeacherBarWidget.h @@ -48,7 +48,7 @@ public: bool visibleInMode(eUBDockPaletteWidgetMode mode) { - return mode == eUBDockPaletteWidget_BOARD; + return (mode == eUBDockPaletteWidget_BOARD) || (mode == eUBDockPaletteWidget_DESKTOP); } public slots: From 07414cf6070c81d840a901a87423848f4bbea9a0 Mon Sep 17 00:00:00 2001 From: shibakaneki Date: Fri, 27 Jan 2012 16:26:06 +0100 Subject: [PATCH 82/84] Added some metadata fields --- src/adaptors/UBMetadataDcSubsetAdaptor.cpp | 24 +++++++ src/core/UBSettings.cpp | 4 ++ src/core/UBSettings.h | 4 ++ src/document/UBDocumentProxy.cpp | 55 +++++++++++++++ src/document/UBDocumentProxy.h | 9 +++ src/gui/UBTBDocumentEditWidget.cpp | 81 ++++++++++++++++++++-- src/gui/UBTBDocumentEditWidget.h | 17 +++++ src/gui/UBTeacherBarDataMgr.cpp | 8 +++ src/gui/UBTeacherBarDataMgr.h | 21 ++++++ src/gui/UBTeacherBarWidget.cpp | 6 +- 10 files changed, 224 insertions(+), 5 deletions(-) diff --git a/src/adaptors/UBMetadataDcSubsetAdaptor.cpp b/src/adaptors/UBMetadataDcSubsetAdaptor.cpp index 7f6574c6..cb676f7b 100644 --- a/src/adaptors/UBMetadataDcSubsetAdaptor.cpp +++ b/src/adaptors/UBMetadataDcSubsetAdaptor.cpp @@ -109,6 +109,10 @@ void UBMetadataDcSubsetAdaptor::persist(UBDocumentProxy* proxy) xmlWriter.writeTextElement(UBSettings::uniboardDocumentNamespaceUri,UBSettings::sessionTitle,proxy->metaData(UBSettings::sessionTitle).toString()); xmlWriter.writeTextElement(UBSettings::uniboardDocumentNamespaceUri,UBSettings::sessionTarget,proxy->metaData(UBSettings::sessionTarget).toString()); xmlWriter.writeTextElement(UBSettings::uniboardDocumentNamespaceUri,UBSettings::sessionLicence,proxy->metaData(UBSettings::sessionLicence).toString()); + xmlWriter.writeTextElement(UBSettings::uniboardDocumentNamespaceUri,UBSettings::sessionKeywords,proxy->metaData(UBSettings::sessionKeywords).toString()); + xmlWriter.writeTextElement(UBSettings::uniboardDocumentNamespaceUri,UBSettings::sessionLevel,proxy->metaData(UBSettings::sessionLevel).toString()); + xmlWriter.writeTextElement(UBSettings::uniboardDocumentNamespaceUri,UBSettings::sessionTopic,proxy->metaData(UBSettings::sessionTopic).toString()); + xmlWriter.writeTextElement(UBSettings::uniboardDocumentNamespaceUri,UBSettings::sessionAuthors,proxy->metaData(UBSettings::sessionAuthors).toString()); xmlWriter.writeEndElement(); //dc:Description xmlWriter.writeEndElement(); //RDF @@ -224,6 +228,26 @@ QMap UBMetadataDcSubsetAdaptor::load(QString pPath) { metadata.insert(UBSettings::sessionLicence, xml.readElementText()); } + else if (xml.name() == UBSettings::sessionKeywords // introduced in OpenSankore 1.40.00 + && xml.namespaceUri() == UBSettings::uniboardDocumentNamespaceUri) + { + metadata.insert(UBSettings::sessionKeywords, xml.readElementText()); + } + else if (xml.name() == UBSettings::sessionLevel // introduced in OpenSankore 1.40.00 + && xml.namespaceUri() == UBSettings::uniboardDocumentNamespaceUri) + { + metadata.insert(UBSettings::sessionLevel, xml.readElementText()); + } + else if (xml.name() == UBSettings::sessionTopic // introduced in OpenSankore 1.40.00 + && xml.namespaceUri() == UBSettings::uniboardDocumentNamespaceUri) + { + metadata.insert(UBSettings::sessionTopic, xml.readElementText()); + } + else if (xml.name() == UBSettings::sessionAuthors // introduced in OpenSankore 1.40.00 + && xml.namespaceUri() == UBSettings::uniboardDocumentNamespaceUri) + { + metadata.insert(UBSettings::sessionAuthors, xml.readElementText()); + } metadata.insert(UBSettings::documentVersion, docVersion); } diff --git a/src/core/UBSettings.cpp b/src/core/UBSettings.cpp index 1ae24e61..c17cf9c7 100644 --- a/src/core/UBSettings.cpp +++ b/src/core/UBSettings.cpp @@ -39,6 +39,10 @@ QString UBSettings::documentUpdatedAt = QString("UpdatedAt"); QString UBSettings::sessionTitle = QString("sessionTitle"); QString UBSettings::sessionTarget = QString("sessionTarget"); QString UBSettings::sessionLicence = QString("sessionLicence"); +QString UBSettings::sessionKeywords = QString("sessionAuthors"); +QString UBSettings::sessionLevel = QString("sessionLevel"); +QString UBSettings::sessionTopic = QString("sessionTopic"); +QString UBSettings::sessionAuthors = QString("sessionAuthors"); QString UBSettings::trashedDocumentGroupNamePrefix = QString("_Trash:"); diff --git a/src/core/UBSettings.h b/src/core/UBSettings.h index e05c2599..6445f7b8 100644 --- a/src/core/UBSettings.h +++ b/src/core/UBSettings.h @@ -156,6 +156,10 @@ class UBSettings : public QObject static QString sessionTitle; static QString sessionTarget; static QString sessionLicence; + static QString sessionKeywords; + static QString sessionLevel; + static QString sessionTopic; + static QString sessionAuthors; static QString trashedDocumentGroupNamePrefix; diff --git a/src/document/UBDocumentProxy.cpp b/src/document/UBDocumentProxy.cpp index aa70a8a1..b6047815 100644 --- a/src/document/UBDocumentProxy.cpp +++ b/src/document/UBDocumentProxy.cpp @@ -53,6 +53,10 @@ void UBDocumentProxy::init() setSessionTitle(""); setSessionTarget(""); setSessionLicence(""); + setSessionKeywords(""); + setSessionLevel(""); + setSessionTopic(""); + setSessionAuthor(""); } @@ -239,6 +243,57 @@ void UBDocumentProxy::setSessionLicence(const QString & sessionLicence) setMetaData(UBSettings::sessionLicence,QVariant(sessionLicence)); } +void UBDocumentProxy::setSessionKeywords(const QString &kw) +{ + setMetaData(UBSettings::sessionKeywords,QVariant(kw)); +} + +QString UBDocumentProxy::sessionKeywords() +{ + if(mMetaDatas.contains(UBSettings::sessionKeywords)) + return metaData(UBSettings::sessionKeywords).toString(); + else + return QString(); +} + +void UBDocumentProxy::setSessionLevel(const QString &level) +{ + setMetaData(UBSettings::sessionLevel,QVariant(level)); +} + +QString UBDocumentProxy::sessionLevel() +{ + if(mMetaDatas.contains(UBSettings::sessionLevel)) + return metaData(UBSettings::sessionLevel).toString(); + else + return QString(); +} + +void UBDocumentProxy::setSessionTopic(const QString &topic) +{ + setMetaData(UBSettings::sessionTopic,QVariant(topic)); +} + +QString UBDocumentProxy::sessionTopic() +{ + if(mMetaDatas.contains(UBSettings::sessionTopic)) + return metaData(UBSettings::sessionTopic).toString(); + else + return QString(); +} + +void UBDocumentProxy::setSessionAuthor(const QString &authors) +{ + setMetaData(UBSettings::sessionAuthors,QVariant(authors)); +} + +QString UBDocumentProxy::sessionAuthors() +{ + if(mMetaDatas.contains(UBSettings::sessionAuthors)) + return metaData(UBSettings::sessionAuthors).toString(); + else + return QString(); +} bool UBDocumentProxy::isModified() const { diff --git a/src/document/UBDocumentProxy.h b/src/document/UBDocumentProxy.h index 70d708bd..a8ec9b3b 100644 --- a/src/document/UBDocumentProxy.h +++ b/src/document/UBDocumentProxy.h @@ -51,6 +51,15 @@ class UBDocumentProxy : public QObject void setSessionTarget(const QString& sessionTarget); QString sessionLicence() const; void setSessionLicence(const QString& sessionLicence); + void setSessionKeywords(const QString& kw); + QString sessionKeywords(); + void setSessionLevel(const QString& level); + QString sessionLevel(); + void setSessionTopic(const QString& topic); + QString sessionTopic(); + void setSessionAuthor(const QString& authors); + QString sessionAuthors(); + QSize defaultDocumentSize() const; void setDefaultDocumentSize(QSize pSize); diff --git a/src/gui/UBTBDocumentEditWidget.cpp b/src/gui/UBTBDocumentEditWidget.cpp index 1d93900c..8d0b94f5 100644 --- a/src/gui/UBTBDocumentEditWidget.cpp +++ b/src/gui/UBTBDocumentEditWidget.cpp @@ -11,6 +11,14 @@ UBTBDocumentEditWidget::UBTBDocumentEditWidget(UBTeacherBarDataMgr* pDataMgr, QW , mpMetadataLabel(NULL) , mpLicenseLabel(NULL) , mpLicenseCombox(NULL) + , mpKeywords(NULL) + , mpLevel(NULL) + , mpTopic(NULL) + , mpAuthor(NULL) + , mpKeywordLabel(NULL) + , mpLevelLabel(NULL) + , mpTopicLabel(NULL) + , mpAuthorLabel(NULL) { setObjectName(name); @@ -27,7 +35,7 @@ UBTBDocumentEditWidget::UBTBDocumentEditWidget(UBTeacherBarDataMgr* pDataMgr, QW // Title mpTitleLabel = new QLabel(tr("Session Title"), mpContainer); mpTitleLabel->setAlignment(Qt::AlignLeft); - //mpTitleLabel->setObjectName("UBTeacherBarPreviewSubtitle"); + mpTitleLabel->setObjectName("UBTeacherBarPreviewSubtitle"); mContainerLayout.addWidget(mpTitleLabel, 0); mpTitle = new QLineEdit(mpContainer); mpTitle->setObjectName("DockPaletteWidgetLineEdit"); @@ -36,7 +44,7 @@ UBTBDocumentEditWidget::UBTBDocumentEditWidget(UBTeacherBarDataMgr* pDataMgr, QW // Target mpTargetLabel = new QLabel(tr("Session Target"), mpContainer); - //mpTargetLabel->setObjectName("UBTeacherBarPreviewSubtitle"); + mpTargetLabel->setObjectName("UBTeacherBarPreviewSubtitle"); mContainerLayout.addWidget(mpTargetLabel, 0); mpTarget = new QTextEdit(mpContainer); mpTarget->setObjectName("UBTeacherBarTargetBox"); @@ -45,15 +53,42 @@ UBTBDocumentEditWidget::UBTBDocumentEditWidget(UBTeacherBarDataMgr* pDataMgr, QW // Metadata mpMetadataLabel = new QLabel(tr("Metadata"), mpContainer); + mpMetadataLabel->setObjectName("UBTeacherBarPreviewSubtitle"); mpMetadataLabel->setAlignment(Qt::AlignLeft); - //mpMetadataLabel->setObjectName("UBTeacherBarPreviewSubtitle"); mContainerLayout.addWidget(mpMetadataLabel, 0); + mpKeywords = new QLineEdit(this); + mpKeywords->setObjectName("DockPaletteWidgetLineEdit"); + mpLevel = new QComboBox(this); + mpLevel->setObjectName("DockPaletteWidgetComboBox"); + mpTopic = new QComboBox(this); + mpTopic->setObjectName("DockPaletteWidgetComboBox"); + mpAuthor = new QLineEdit(this); + mpAuthor->setObjectName("DockPaletteWidgetLineEdit"); + mpKeywordLabel = new QLabel(tr("Keywords:"), this); + mpLevelLabel = new QLabel(tr("Level:"), this); + mpTopicLabel = new QLabel(tr("Topic:"), this); + mpAuthorLabel = new QLabel(tr("Author"), this); + + mKeywordLayout.addWidget(mpKeywordLabel, 0); + mKeywordLayout.addWidget(mpKeywords, 1); + mLevelLayout.addWidget(mpLevelLabel, 0); + mLevelLayout.addWidget(mpLevel, 1); + mTopicLayout.addWidget(mpTopicLabel, 0); + mTopicLayout.addWidget(mpTopic, 1); + mAuthorLayout.addWidget(mpAuthorLabel, 0); + mAuthorLayout.addWidget(mpAuthor, 1); + + mContainerLayout.addLayout(&mKeywordLayout, 0); + mContainerLayout.addLayout(&mLevelLayout, 0); + mContainerLayout.addLayout(&mTopicLayout, 0); + mContainerLayout.addLayout(&mAuthorLayout, 0); + mContainerLayout.addWidget(&mLicenseSeparator); // License mpLicenseLabel = new QLabel(tr("License"), mpContainer); mpLicenseLabel->setAlignment(Qt::AlignLeft); - //mpLicenseLabel->setObjectName("UBTeacherBarPreviewSubtitle"); + mpLicenseLabel->setObjectName("UBTeacherBarPreviewSubtitle"); mContainerLayout.addWidget(mpLicenseLabel, 0); mpLicenseCombox = new QComboBox(this); mpLicenseCombox->setObjectName("DockPaletteWidgetComboBox"); @@ -81,6 +116,10 @@ UBTBDocumentEditWidget::UBTBDocumentEditWidget(UBTeacherBarDataMgr* pDataMgr, QW connect(mpTitle, SIGNAL(textChanged(QString)), this, SLOT(onSessionTitleChanged())); connect(mpTarget, SIGNAL(textChanged()), this, SLOT(onSessionTargetChanged())); connect(mpLicenseCombox, SIGNAL(currentIndexChanged(int)), this, SLOT(onLicenseCurrentIndexChanged(int))); + connect(mpKeywords, SIGNAL(textChanged(QString)), this, SLOT(onKeywordChanged(QString))); + connect(mpLevel, SIGNAL(currentIndexChanged(QString)), this, SLOT(onLevelChanged(QString))); + connect(mpTopic, SIGNAL(currentIndexChanged(QString)), this, SLOT(onTopicChanged(QString))); + connect(mpAuthor, SIGNAL(textChanged(QString)), this, SLOT(onAuthorChanged(QString))); } UBTBDocumentEditWidget::~UBTBDocumentEditWidget() @@ -90,6 +129,14 @@ UBTBDocumentEditWidget::~UBTBDocumentEditWidget() DELETEPTR(mpTargetLabel); DELETEPTR(mpTarget); DELETEPTR(mpMetadataLabel); + DELETEPTR(mpKeywordLabel); + DELETEPTR(mpLevelLabel); + DELETEPTR(mpTopicLabel); + DELETEPTR(mpAuthorLabel); + DELETEPTR(mpKeywords); + DELETEPTR(mpLevel); + DELETEPTR(mpTopic); + DELETEPTR(mpAuthor); DELETEPTR(mpLicenseLabel); DELETEPTR(mpLicenseCombox); DELETEPTR(mpPageViewButton); @@ -128,6 +175,10 @@ void UBTBDocumentEditWidget::updateFields() { mpTitle->setText(mpDataMgr->sessionTitle()); mpTarget->setPlainText(mpDataMgr->sessionTarget()); + mpKeywords->setText(mpDataMgr->keywords()); + // TODO: retrieve the level + // TODO retrieve the topic + mpAuthor->setText(mpDataMgr->authors()); } void UBTBDocumentEditWidget::clearFields() @@ -136,4 +187,26 @@ void UBTBDocumentEditWidget::clearFields() mpTarget->setPlainText(""); } +void UBTBDocumentEditWidget::onKeywordChanged(const QString &kw) +{ + mpDataMgr->setKeywords(kw); + emit valueChanged(); +} + +void UBTBDocumentEditWidget::onLevelChanged(const QString &level) +{ + mpDataMgr->setLevel(level); + emit valueChanged(); +} +void UBTBDocumentEditWidget::onTopicChanged(const QString &topic) +{ + mpDataMgr->setTopic(topic); + emit valueChanged(); +} + +void UBTBDocumentEditWidget::onAuthorChanged(const QString &authors) +{ + mpDataMgr->setAuthors(authors); + emit valueChanged(); +} diff --git a/src/gui/UBTBDocumentEditWidget.h b/src/gui/UBTBDocumentEditWidget.h index 8cfb7ff9..7d782247 100644 --- a/src/gui/UBTBDocumentEditWidget.h +++ b/src/gui/UBTBDocumentEditWidget.h @@ -29,6 +29,10 @@ private slots: void onSessionTitleChanged(); void onSessionTargetChanged(); void onLicenseCurrentIndexChanged(int selection); + void onKeywordChanged(const QString& kw); + void onLevelChanged(const QString& level); + void onTopicChanged(const QString& topic); + void onAuthorChanged(const QString& authors); private: QVBoxLayout mLayout; @@ -41,6 +45,11 @@ private: UBTBSeparator mTargetSeparator; UBTBSeparator mLicenseSeparator; + QHBoxLayout mKeywordLayout; + QHBoxLayout mLevelLayout; + QHBoxLayout mTopicLayout; + QHBoxLayout mAuthorLayout; + QWidget* mpContainer; QLabel* mpTitleLabel; QLineEdit* mpTitle; @@ -49,6 +58,14 @@ private: QLabel* mpMetadataLabel; QLabel* mpLicenseLabel; QComboBox* mpLicenseCombox; + QLineEdit* mpKeywords; + QComboBox* mpLevel; + QComboBox* mpTopic; + QLineEdit* mpAuthor; + QLabel* mpKeywordLabel; + QLabel* mpLevelLabel; + QLabel* mpTopicLabel; + QLabel* mpAuthorLabel; UBTeacherBarDataMgr* mpDataMgr; }; diff --git a/src/gui/UBTeacherBarDataMgr.cpp b/src/gui/UBTeacherBarDataMgr.cpp index 4233e58a..2a772441 100644 --- a/src/gui/UBTeacherBarDataMgr.cpp +++ b/src/gui/UBTeacherBarDataMgr.cpp @@ -59,6 +59,10 @@ void UBTeacherBarDataMgr::saveContent() documentProxy->setSessionTitle(mSessionTitle); documentProxy->setSessionTarget(mSessionTarget); documentProxy->setSessionLicence(QString("%0").arg(mSessionLicence)); + documentProxy->setSessionKeywords(mAuthors); + documentProxy->setSessionLevel(mLevel); + documentProxy->setSessionTopic(mTopic); + documentProxy->setSessionAuthor(mAuthors); UBMetadataDcSubsetAdaptor::persist(documentProxy); } @@ -76,6 +80,10 @@ void UBTeacherBarDataMgr::loadContent(bool docChanged) mSessionTitle = documentProxy->sessionTitle(); mSessionTarget = documentProxy->sessionTarget(); mSessionLicence = (eLicense)documentProxy->sessionLicence().toInt(); + mKeywords = documentProxy->sessionKeywords(); + mLevel = documentProxy->sessionLevel(); + mTopic = documentProxy->sessionTopic(); + mAuthors = documentProxy->sessionAuthors(); } // Page Title diff --git a/src/gui/UBTeacherBarDataMgr.h b/src/gui/UBTeacherBarDataMgr.h index 7ddca7e9..b182e892 100644 --- a/src/gui/UBTeacherBarDataMgr.h +++ b/src/gui/UBTeacherBarDataMgr.h @@ -99,6 +99,23 @@ public: void setComments(const QString& c){mComments = c;} QString comments(){return mComments;} + // Keywords + void setKeywords(const QString& kw){mKeywords = kw;} + QString keywords(){return mKeywords;} + + // Level + void setLevel(const QString& level){mLevel = level;} + QString level(){return mLevel;} + + // Topic + void setTopic(const QString& topic){mTopic = topic;} + QString topic(){return mTopic;} + + // Authors + void setAuthors(const QString& authors){mAuthors = authors;} + QString authors(){return mAuthors;} + + // Others void clearLists(); void saveContent(); @@ -110,6 +127,10 @@ private: eLicense mSessionLicence; QString mPageTitle; QString mComments; + QString mKeywords; + QString mLevel; + QString mTopic; + QString mAuthors; QVector mActionList; QVector mUrlList; diff --git a/src/gui/UBTeacherBarWidget.cpp b/src/gui/UBTeacherBarWidget.cpp index 8b988526..d6d5e9dc 100644 --- a/src/gui/UBTeacherBarWidget.cpp +++ b/src/gui/UBTeacherBarWidget.cpp @@ -143,7 +143,11 @@ bool UBTeacherBarWidget::isEmpty() mData.urls()->empty() && mData.actions()->empty() && mData.medias()->empty() && - mData.comments() == ""; + mData.comments() == "" && + mData.authors() == "" && + mData.keywords() == "" && + mData.level() == "" && + mData.topic() == ""; } void UBTeacherBarWidget::onShowEditMode() From 927c77ac25639055065d91f31c05f956f571ce0c Mon Sep 17 00:00:00 2001 From: Anatoly Mihalchenko Date: Fri, 27 Jan 2012 18:31:02 +0300 Subject: [PATCH 83/84] Code refactoring: pointers instead of names in Palettes --- src/board/UBBoardPaletteManager.cpp | 13 +++++--- src/gui/UBCachePropertiesWidget.cpp | 8 ++--- src/gui/UBDockPalette.cpp | 50 +++++++++++------------------ src/gui/UBDockPalette.h | 7 ++-- src/gui/UBDockPaletteWidget.h | 4 +-- 5 files changed, 37 insertions(+), 45 deletions(-) diff --git a/src/board/UBBoardPaletteManager.cpp b/src/board/UBBoardPaletteManager.cpp index 4c79f726..8c20d89a 100644 --- a/src/board/UBBoardPaletteManager.cpp +++ b/src/board/UBBoardPaletteManager.cpp @@ -202,8 +202,11 @@ void UBBoardPaletteManager::setupDockPaletteWidgets() // The cache widget will be visible only if a cache is put on the page mRightPalette->registerWidget(mpCachePropWidget); // The teacher bar widget will always be there - mRightPalette->registerWidget(mpTeacherBarWidget); - mRightPalette->addTab(mpTeacherBarWidget); + + // TeacherBarWidget moved to left side just for testing!!!! + mLeftPalette->registerWidget(mpTeacherBarWidget); + mLeftPalette->addTab(mpTeacherBarWidget); + // The download widget will be part of the right palette but // will become visible only when the first download starts mRightPalette->registerWidget(mpDownloadWidget); @@ -211,8 +214,8 @@ void UBBoardPaletteManager::setupDockPaletteWidgets() changeMode(eUBDockPaletteWidget_BOARD, true); // Hide the tabs that must be hidden - mRightPalette->removeTab(mpDownloadWidget->name()); - mRightPalette->removeTab(mpCachePropWidget->name()); + mRightPalette->removeTab(mpDownloadWidget); + mRightPalette->removeTab(mpCachePropWidget); // mLeftPalette->showTabWidget(0); // mRightPalette->showTabWidget(0); @@ -998,7 +1001,7 @@ void UBBoardPaletteManager::stopDownloads() { mDownloadInProgress = false; mpDownloadWidget->setVisibleState(false); - mRightPalette->removeTab(mpDownloadWidget->name()); + mRightPalette->removeTab(mpDownloadWidget); } } diff --git a/src/gui/UBCachePropertiesWidget.cpp b/src/gui/UBCachePropertiesWidget.cpp index 751c5d15..e0c74986 100644 --- a/src/gui/UBCachePropertiesWidget.cpp +++ b/src/gui/UBCachePropertiesWidget.cpp @@ -222,7 +222,7 @@ void UBCachePropertiesWidget::onCloseClicked() emit cacheListEmpty(); } - emit hideTab(name()); + emit hideTab(this); } } @@ -300,7 +300,7 @@ void UBCachePropertiesWidget::updateCurrentCache() if("Cache" == it->data(Qt::UserRole).toString()) { setEnabled(true); - emit showTab(name()); + emit showTab(this); mpCurrentCache = dynamic_cast(it); if((NULL != mpCurrentCache) && (!mCaches.contains(mpCurrentCache))) { @@ -331,7 +331,7 @@ void UBCachePropertiesWidget::updateCurrentCache() // 1 - that this page has no cache // 2 - we are not in Board mode // 3 - we are in Board mode, but show desktop (as really - Desktop mode) - emit hideTab(name()); + emit hideTab(this); mpCurrentCache = NULL; setDisabled(true); } @@ -346,6 +346,6 @@ void UBCachePropertiesWidget::onSizeChanged(int newSize) void UBCachePropertiesWidget::onCacheEnabled() { - emit showTab(name()); + emit showTab(this); } diff --git a/src/gui/UBDockPalette.cpp b/src/gui/UBDockPalette.cpp index 7c3cb27e..82f28d76 100644 --- a/src/gui/UBDockPalette.cpp +++ b/src/gui/UBDockPalette.cpp @@ -567,19 +567,15 @@ void UBDockPalette::addTab(UBDockPaletteWidget *widget) * \brief Remove the given tab * @param widgetName as the tab widget name */ -void UBDockPalette::removeTab(const QString &widgetName) +void UBDockPalette::removeTab(UBDockPaletteWidget* widget) { - for(int i = 0; i < mTabWidgets.size(); i++) + int nWidget = mTabWidgets.indexOf(widget); + if( nWidget >= 0 ) { - UBDockPaletteWidget* pCrntWidget = mTabWidgets.at(i); - if(NULL != pCrntWidget && (pCrntWidget->name() == widgetName)) - { - mpStackWidget->removeWidget(pCrntWidget); - mTabWidgets.remove(i); - pCrntWidget->hide(); - update(); - break; - } + mpStackWidget->removeWidget(widget); + mTabWidgets.remove(nWidget); + widget->hide(); + update(); } resizeTabs(); mCurrentTab = qMax(mCurrentTab - 1, 0); @@ -607,17 +603,12 @@ int UBDockPalette::tabSpacing() * \brief Show the given widget * @param widgetName as the given widget name */ -void UBDockPalette::onShowTabWidget(const QString &widgetName) +void UBDockPalette::onShowTabWidget(UBDockPaletteWidget* widget) { - for(int i = 0; i < mRegisteredWidgets.size(); i++) + if (mRegisteredWidgets.contains(widget)) { - UBDockPaletteWidget* pCrntWidget = mRegisteredWidgets.at(i); - if(NULL != pCrntWidget && (pCrntWidget->name() == widgetName)) - { - pCrntWidget->setVisibleState(true); - addTab(pCrntWidget); - break; - } + widget->setVisibleState(true); + addTab(widget); } } @@ -625,16 +616,13 @@ void UBDockPalette::onShowTabWidget(const QString &widgetName) * \brief Hide the given widget * @param widgetName as the given widget name */ -void UBDockPalette::onHideTabWidget(const QString &widgetName) +void UBDockPalette::onHideTabWidget(UBDockPaletteWidget* widget) { - for(int i = 0; i < mRegisteredWidgets.size(); i++){ - UBDockPaletteWidget* pCrntWidget = mRegisteredWidgets.at(i); - if(NULL != pCrntWidget && (pCrntWidget->name() == widgetName)){ - pCrntWidget->setVisibleState(false); - break; - } + if (mRegisteredWidgets.contains(widget)) + { + widget->setVisibleState(false); + removeTab(widget); } - removeTab(widgetName); } /** @@ -644,8 +632,8 @@ void UBDockPalette::connectSignals() { for(int i=0; i < mRegisteredWidgets.size(); i++) { - connect(mRegisteredWidgets.at(i), SIGNAL(showTab(QString)), this, SLOT(onShowTabWidget(QString))); - connect(mRegisteredWidgets.at(i), SIGNAL(hideTab(QString)), this, SLOT(onHideTabWidget(QString))); + connect(mRegisteredWidgets.at(i), SIGNAL(showTab(UBDockPaletteWidget*)), this, SLOT(onShowTabWidget(UBDockPaletteWidget*))); + connect(mRegisteredWidgets.at(i), SIGNAL(hideTab(UBDockPaletteWidget*)), this, SLOT(onHideTabWidget(UBDockPaletteWidget*))); } } @@ -747,7 +735,7 @@ bool UBDockPalette::switchMode(eUBDockPaletteWidgetMode mode) } else { - removeTab(pNextWidget->name()); + removeTab(pNextWidget); } } } diff --git a/src/gui/UBDockPalette.h b/src/gui/UBDockPalette.h index 569c9854..ff3b546d 100644 --- a/src/gui/UBDockPalette.h +++ b/src/gui/UBDockPalette.h @@ -111,8 +111,9 @@ public: void setBackgroundBrush(const QBrush& brush); void registerWidget(UBDockPaletteWidget* widget); + void addTab(UBDockPaletteWidget* widget); - void removeTab(const QString& widgetName); + void removeTab(UBDockPaletteWidget* widget); void connectSignals(); @@ -129,8 +130,8 @@ public: eUBDockPaletteType paletteType(){return mPaletteType;} public slots: - void onShowTabWidget(const QString& widgetName); - void onHideTabWidget(const QString& widgetName); + void onShowTabWidget(UBDockPaletteWidget* widget); + void onHideTabWidget(UBDockPaletteWidget* widget); void onAllDownloadsFinished(); protected: diff --git a/src/gui/UBDockPaletteWidget.h b/src/gui/UBDockPaletteWidget.h index 163ca0cd..0b69a9e6 100644 --- a/src/gui/UBDockPaletteWidget.h +++ b/src/gui/UBDockPaletteWidget.h @@ -31,8 +31,8 @@ public: void setVisibleState(bool state){mVisibleState = state;} signals: - void hideTab(const QString& widgetName); - void showTab(const QString& widgetName); + void hideTab(UBDockPaletteWidget* widget); + void showTab(UBDockPaletteWidget* widget); public slots: void slot_changeMode(eUBDockPaletteWidgetMode newMode); From 7b595aec986aaccd20cae2ce22ff3ee64af35665 Mon Sep 17 00:00:00 2001 From: Claudio Valerio Date: Mon, 30 Jan 2012 15:02:11 +0100 Subject: [PATCH 84/84] fixed some issue due to merge --- src/core/UBDisplayManager.cpp | 2 +- src/core/UBSettings.h | 2 -- src/document/UBDocumentProxy.cpp | 2 +- src/domain/UBGraphicsScene.cpp | 1 - src/gui/UBActionPalette.cpp | 6 ++---- src/gui/UBMediaPlayer.cpp | 1 + 6 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/core/UBDisplayManager.cpp b/src/core/UBDisplayManager.cpp index 96c25059..6ecdc679 100644 --- a/src/core/UBDisplayManager.cpp +++ b/src/core/UBDisplayManager.cpp @@ -48,7 +48,7 @@ UBDisplayManager::UBDisplayManager(QObject *parent) void UBDisplayManager::initScreenIndexes() { - int screenCount = 1;//= numScreens(); + int screenCount = numScreens(); mScreenIndexesRoles.clear(); diff --git a/src/core/UBSettings.h b/src/core/UBSettings.h index 29c95d0b..21b4d4e1 100644 --- a/src/core/UBSettings.h +++ b/src/core/UBSettings.h @@ -273,8 +273,6 @@ class UBSettings : public QObject QMap documentSizes; - QSize defaultDocumentSize; - UBSetting* svgViewBoxMargin; UBSetting* pdfMargin; UBSetting* pdfPageFormat; diff --git a/src/document/UBDocumentProxy.cpp b/src/document/UBDocumentProxy.cpp index 50ef04db..aafcfeda 100644 --- a/src/document/UBDocumentProxy.cpp +++ b/src/document/UBDocumentProxy.cpp @@ -48,7 +48,7 @@ void UBDocumentProxy::init() setUuid(QUuid::createUuid()); - setDefaultDocumentSize(UBSettings::settings()->defaultDocumentSize); + setDefaultDocumentSize(UBSettings::settings()->pageSize->get().toSize()); setSessionTitle(""); setSessionTarget(""); diff --git a/src/domain/UBGraphicsScene.cpp b/src/domain/UBGraphicsScene.cpp index 995c70f0..0f2d0c52 100644 --- a/src/domain/UBGraphicsScene.cpp +++ b/src/domain/UBGraphicsScene.cpp @@ -1770,7 +1770,6 @@ void UBGraphicsScene::addMask(const QPointF ¢er) QRectF rect = UBApplication::boardController->activeScene()->normalizedSceneRect(); rect.setRect(center.x() - rect.width()/4, center.y() - rect.height()/4, rect.width()/2 , rect.height()/2); - QPointF origin = center.isNull() ? rect.bottomRight() : center; curtain->setRect(rect); UBGraphicsItem::assignZValue(curtain, toolLayerStart + toolOffsetCurtain); diff --git a/src/gui/UBActionPalette.cpp b/src/gui/UBActionPalette.cpp index 9647590e..304f8ec2 100644 --- a/src/gui/UBActionPalette.cpp +++ b/src/gui/UBActionPalette.cpp @@ -57,12 +57,10 @@ void UBActionPalette::init(Qt::Orientation orientation) mToolButtonStyle = Qt::ToolButtonIconOnly; mButtons.clear(); - QBoxLayout *layout = 0; - if (orientation == Qt::Horizontal) - layout = new QHBoxLayout(this); + new QHBoxLayout(this); else - layout = new QVBoxLayout(this); + new QVBoxLayout(this); updateLayout(); } diff --git a/src/gui/UBMediaPlayer.cpp b/src/gui/UBMediaPlayer.cpp index 4ac7a0a4..c0e9dc93 100644 --- a/src/gui/UBMediaPlayer.cpp +++ b/src/gui/UBMediaPlayer.cpp @@ -350,6 +350,7 @@ void UBMediaPlayer::hasVideoChanged(bool bHasVideo) void UBMediaPlayer::resizeEvent(QResizeEvent* pEvent) { + Q_UNUSED(pEvent); // int origWidth = m_videoWindow.width(); // int origHeight = m_videoWindow.height();