Commit 33d2bfab authored by shibakaneki's avatar shibakaneki

Merge branch 'master' of github.com:Sankore/Sankore-3.1

parents 368a4dc5 8238b22e
...@@ -639,7 +639,7 @@ QDomElement UBCFFAdaptor::UBToCFFConverter::parseSvgPageSection(const QDomElemen ...@@ -639,7 +639,7 @@ QDomElement UBCFFAdaptor::UBToCFFConverter::parseSvgPageSection(const QDomElemen
void UBCFFAdaptor::UBToCFFConverter::writeQDomElementToXML(const QDomNode &node) void UBCFFAdaptor::UBToCFFConverter::writeQDomElementToXML(const QDomNode &node)
{ {
if (!node.isNull()) if (!node.isNull()){
if (node.isText()) if (node.isText())
{ {
mIWBContentWriter->writeCharacters(node.nodeValue()); mIWBContentWriter->writeCharacters(node.nodeValue());
...@@ -662,6 +662,7 @@ void UBCFFAdaptor::UBToCFFConverter::writeQDomElementToXML(const QDomNode &node) ...@@ -662,6 +662,7 @@ void UBCFFAdaptor::UBToCFFConverter::writeQDomElementToXML(const QDomNode &node)
mIWBContentWriter->writeEndElement(); mIWBContentWriter->writeEndElement();
} }
}
} }
bool UBCFFAdaptor::UBToCFFConverter::writeExtendedIwbSection() bool UBCFFAdaptor::UBToCFFConverter::writeExtendedIwbSection()
...@@ -1322,7 +1323,7 @@ QDomNode UBCFFAdaptor::UBToCFFConverter::findNodeByTagName(const QDomNode &node, ...@@ -1322,7 +1323,7 @@ QDomNode UBCFFAdaptor::UBToCFFConverter::findNodeByTagName(const QDomNode &node,
if (!iterNode.firstChildElement().isNull()) if (!iterNode.firstChildElement().isNull())
{ {
QDomNode foundNode = findNodeByTagName(iterNode.firstChildElement(), tagName); QDomNode foundNode = findNodeByTagName(iterNode.firstChildElement(), tagName);
if (!foundNode.isNull()) if (!foundNode.isNull()){
if (foundNode.isElement()) if (foundNode.isElement())
{ {
if (tagName == foundNode.toElement().tagName()) if (tagName == foundNode.toElement().tagName())
...@@ -1332,6 +1333,7 @@ QDomNode UBCFFAdaptor::UBToCFFConverter::findNodeByTagName(const QDomNode &node, ...@@ -1332,6 +1333,7 @@ QDomNode UBCFFAdaptor::UBToCFFConverter::findNodeByTagName(const QDomNode &node,
break; break;
} }
} }
}
if (!iterNode.nextSibling().isNull()) if (!iterNode.nextSibling().isNull())
iterNode = iterNode.nextSibling(); iterNode = iterNode.nextSibling();
......
...@@ -347,5 +347,10 @@ ...@@ -347,5 +347,10 @@
<file>images/licenses/ccbyncsa.png</file> <file>images/licenses/ccbyncsa.png</file>
<file>images/licenses/ccbynd.png</file> <file>images/licenses/ccbynd.png</file>
<file>images/licenses/ccbysa.png</file> <file>images/licenses/ccbysa.png</file>
<file>images/teacherGuide/audio.png</file>
<file>images/teacherGuide/image.png</file>
<file>images/teacherGuide/link.png</file>
<file>images/teacherGuide/movie.png</file>
<file>images/teacherGuide/w3c.png</file>
</qresource> </qresource>
</RCC> </RCC>
...@@ -4,22 +4,13 @@ QWidget#UBLibPathViewer, ...@@ -4,22 +4,13 @@ QWidget#UBLibPathViewer,
QWidget#UBLibNavigatorWidget, QWidget#UBLibNavigatorWidget,
QWidget#UBLibItemProperties, QWidget#UBLibItemProperties,
QWidget#UBDownloadWidget, QWidget#UBDownloadWidget,
QWidget#UBWidgetList, QWidget#UBTeacherGuideWidget
QWidget#UBTeacherBarDropMediaZone,
QWidget#UBTBMediaContainer
{ {
background: #EEEEEE; background: #EEEEEE;
border-radius: 10px; border-radius: 10px;
border: 2px solid #999999; border: 2px solid #999999;
} }
QFrame#UBTBSeparator
{
background: #DDDDDD;
border-radius: 2px;
border: 1px solid #DDDDDD;
}
QWidget#UBMediaVideoContainer QWidget#UBMediaVideoContainer
{ {
background: #000000; background: #000000;
...@@ -27,40 +18,6 @@ QWidget#UBMediaVideoContainer ...@@ -27,40 +18,6 @@ QWidget#UBMediaVideoContainer
border: 2px solid #999999; border: 2px solid #999999;
} }
QWidget#UBTBPreviewWidget
{
background: #FFFFFF;
border-radius: 10px;
border: 2px solid #999999;
}
QLabel#UBTBPreviewSessionTitle
{
font-size: 12px;
}
QLabel#UBTeacherBarPreviewTitle
{
color: #555555;
font-size : 20px;
font-weight:bold;
padding-left:5px;
}
QLabel#UBMediaPlayerButton
{
padding: 0px 0px 0px 0px;
}
QLabel#UBTeacherBarPreviewSubtitle
{
color: #555555;
font-size : 15px;
font-weight:bold;
padding-left:5px;
}
QWidget#UBLibWebView QWidget#UBLibWebView
{ {
background: #EEEEEE; background: #EEEEEE;
...@@ -68,30 +25,6 @@ QWidget#UBLibWebView ...@@ -68,30 +25,6 @@ QWidget#UBLibWebView
border: 2px solid #999999; border: 2px solid #999999;
} }
QWidget#UBActionPreviewOwner
{
color: #555555;
font-size : 12px;
font-weight: bold;
}
QWidget#UBTeacherBarPreviewComments,
QWidget#UBTeacherBarTargetBox
{
border-radius: 10px;
border: white 2px solid;
padding: 5px 5px 5px 5px;
background-color: white;
}
QWidget#UBActionPreviewContent,
QTextEdit#UBCommentPreview
{
border-radius : 10px;
border: 2px solid #999999;
padding: 5px 5px 5px 5px;
}
QWebView#SearchEngineView QWebView#SearchEngineView
{ {
background:white; background:white;
...@@ -109,9 +42,11 @@ QLabel#DockPaletteWidgetTitle ...@@ -109,9 +42,11 @@ QLabel#DockPaletteWidgetTitle
font-weight:bold; font-weight:bold;
} }
QLineEdit#DockPaletteWidgetLineEdit QLineEdit#UBTGLineEdit,
QLabel#UBTGMediaDropMeLabel
{ {
background: white; background: white;
border: 1 solid #999999;
border-radius : 10px; border-radius : 10px;
padding: 2px; padding: 2px;
} }
...@@ -269,3 +204,58 @@ QSlider::groove::horizontal ...@@ -269,3 +204,58 @@ QSlider::groove::horizontal
border-radius:5px; border-radius:5px;
border:1px solid #555555; border:1px solid #555555;
} }
QLabel#UBTGEditionDocumentTitle
{
color: black;
font-size : 14px;
font-weight:bold;
}
QLabel#UBTGPresentationDocumentTitle
{
color: black;
font-size : 12px;
font-weight:bold;
}
QLabel#UBTGEditionPageNumberLabel
{
color: black;
font-size : 12px;
font-weight:bold;
}
QLabel#UBTGPresentationPageNumberLabel
{
color: black;
font-size : 12px;
}
UBTGAdaptableText#UBTGEditionPageTitle,
UBTGAdaptableText#UBTGEditionComment
{
color: black;
font-size : 12px;
}
UBTGAdaptableText#UBTGPresentationPageTitle
{
color: black;
font-size:16px;
font-weight:bold;
border : none;
}
UBTGAdaptableText#UBTGPresentationComment
{
color: black;
font-size:12px;
border : none;
}
QFrame#UBTGEditionSeparator,
QFrame#UBTGPresentationSepartor
{
background-color: #cccccc;
}
...@@ -191,7 +191,7 @@ UBDocumentProxy* UBImportDocument::importFile(const QFile& pFile, const QString& ...@@ -191,7 +191,7 @@ UBDocumentProxy* UBImportDocument::importFile(const QFile& pFile, const QString&
return 0; return 0;
} }
else{ else{
UBDocumentProxy* newDocument = UBPersistenceManager::persistenceManager()->createDocumentFromDir(documentRootFolder); UBDocumentProxy* newDocument = UBPersistenceManager::persistenceManager()->createDocumentFromDir(documentRootFolder, pGroup);
UBApplication::showMessage(tr("Import successful.")); UBApplication::showMessage(tr("Import successful."));
return newDocument; return newDocument;
} }
......
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#include "gui/UBZoomPalette.h" #include "gui/UBZoomPalette.h"
#include "gui/UBActionPalette.h" #include "gui/UBActionPalette.h"
#include "gui/UBFavoriteToolPalette.h" #include "gui/UBFavoriteToolPalette.h"
#include "gui/UBDockTeacherGuideWidget.h"
#include "web/UBWebPage.h" #include "web/UBWebPage.h"
...@@ -84,6 +85,7 @@ UBBoardPaletteManager::UBBoardPaletteManager(QWidget* container, UBBoardControll ...@@ -84,6 +85,7 @@ UBBoardPaletteManager::UBBoardPaletteManager(QWidget* container, UBBoardControll
, mpCachePropWidget(NULL) , mpCachePropWidget(NULL)
, mpDownloadWidget(NULL) , mpDownloadWidget(NULL)
, mpDesktopLibWidget(NULL) , mpDesktopLibWidget(NULL)
, mpTeacherGuideWidget(NULL)
, mDownloadInProgress(false) , mDownloadInProgress(false)
{ {
setupPalettes(); setupPalettes();
...@@ -135,6 +137,7 @@ void UBBoardPaletteManager::setupDockPaletteWidgets() ...@@ -135,6 +137,7 @@ void UBBoardPaletteManager::setupDockPaletteWidgets()
mpCachePropWidget = new UBCachePropertiesWidget(); mpCachePropWidget = new UBCachePropertiesWidget();
mpDownloadWidget = new UBDockDownloadWidget(); mpDownloadWidget = new UBDockDownloadWidget();
mpTeacherGuideWidget = new UBDockTeacherGuideWidget();
// Add the dock palettes // Add the dock palettes
mLeftPalette = new UBLeftPalette(mContainer); mLeftPalette = new UBLeftPalette(mContainer);
...@@ -143,6 +146,9 @@ void UBBoardPaletteManager::setupDockPaletteWidgets() ...@@ -143,6 +146,9 @@ void UBBoardPaletteManager::setupDockPaletteWidgets()
mLeftPalette->registerWidget(mpPageNavigWidget); mLeftPalette->registerWidget(mpPageNavigWidget);
mLeftPalette->addTab(mpPageNavigWidget); mLeftPalette->addTab(mpPageNavigWidget);
mLeftPalette->registerWidget(mpTeacherGuideWidget);
mLeftPalette->addTab(mpTeacherGuideWidget);
mLeftPalette->connectSignals(); mLeftPalette->connectSignals();
mRightPalette = new UBRightPalette(mContainer); mRightPalette = new UBRightPalette(mContainer);
...@@ -232,6 +238,7 @@ void UBBoardPaletteManager::setupPalettes() ...@@ -232,6 +238,7 @@ void UBBoardPaletteManager::setupPalettes()
#endif #endif
} }
setupDockPaletteWidgets(); setupDockPaletteWidgets();
......
...@@ -40,6 +40,7 @@ class UBServerXMLHttpRequest; ...@@ -40,6 +40,7 @@ class UBServerXMLHttpRequest;
class UBKeyboardPalette; class UBKeyboardPalette;
class UBMainWindow; class UBMainWindow;
class UBApplicationController; class UBApplicationController;
class UBDockTeacherGuideWidget;
class UBBoardPaletteManager : public QObject class UBBoardPaletteManager : public QObject
{ {
...@@ -52,6 +53,7 @@ class UBBoardPaletteManager : public QObject ...@@ -52,6 +53,7 @@ class UBBoardPaletteManager : public QObject
void setupLayout(); void setupLayout();
UBLeftPalette* leftPalette(){return mLeftPalette;} UBLeftPalette* leftPalette(){return mLeftPalette;}
UBRightPalette* rightPalette(){return mRightPalette;} UBRightPalette* rightPalette(){return mRightPalette;}
UBStylusPalette* stylusPalette(){return mStylusPalette;}
void showVirtualKeyboard(bool show = true); void showVirtualKeyboard(bool show = true);
void initPalettesPosAtStartup(); void initPalettesPosAtStartup();
void connectToDocumentController(); void connectToDocumentController();
...@@ -134,6 +136,8 @@ class UBBoardPaletteManager : public QObject ...@@ -134,6 +136,8 @@ class UBBoardPaletteManager : public QObject
// lib widget! // lib widget!
UBLibWidget* mpDesktopLibWidget; UBLibWidget* mpDesktopLibWidget;
UBDockTeacherGuideWidget* mpTeacherGuideWidget;
bool mDownloadInProgress; bool mDownloadInProgress;
private slots: private slots:
......
...@@ -35,8 +35,8 @@ ...@@ -35,8 +35,8 @@
#include "gui/UBToolWidget.h" #include "gui/UBToolWidget.h"
#include "gui/UBResources.h" #include "gui/UBResources.h"
#include "gui/UBMainWindow.h" #include "gui/UBMainWindow.h"
#include "gui/UBMediaPlayer.h"
#include "gui/UBThumbnailWidget.h" #include "gui/UBThumbnailWidget.h"
#include "gui/UBTeacherGuideWidgetsTools.h"
#include "board/UBBoardController.h" #include "board/UBBoardController.h"
...@@ -49,9 +49,6 @@ ...@@ -49,9 +49,6 @@
#include "document/UBDocumentProxy.h" #include "document/UBDocumentProxy.h"
#include "customWidgets/UBDraggableLabel.h"
#include "customWidgets/UBDraggableMedia.h"
#include "tools/UBGraphicsCompass.h" #include "tools/UBGraphicsCompass.h"
#include "tools/UBGraphicsCache.h" #include "tools/UBGraphicsCache.h"
#include "tools/UBGraphicsTriangle.h" #include "tools/UBGraphicsTriangle.h"
...@@ -379,8 +376,7 @@ void UBBoardView::tabletEvent (QTabletEvent * event) ...@@ -379,8 +376,7 @@ void UBBoardView::tabletEvent (QTabletEvent * event)
} }
void void UBBoardView::mousePressEvent (QMouseEvent *event)
UBBoardView::mousePressEvent (QMouseEvent *event)
{ {
if (isAbsurdPoint (event->pos ())) if (isAbsurdPoint (event->pos ()))
{ {
...@@ -390,8 +386,11 @@ UBBoardView::mousePressEvent (QMouseEvent *event) ...@@ -390,8 +386,11 @@ UBBoardView::mousePressEvent (QMouseEvent *event)
mMouseDownPos = event->pos (); mMouseDownPos = event->pos ();
emit clickOnBoard();
if (event->button () == Qt::LeftButton && isInteractive ()) if (event->button () == Qt::LeftButton && isInteractive ())
{ {
UBStylusTool::Enum currentTool = (UBStylusTool::Enum)UBDrawingController::drawingController ()->stylusTool (); UBStylusTool::Enum currentTool = (UBStylusTool::Enum)UBDrawingController::drawingController ()->stylusTool ();
if (!mTabletStylusIsPressed) if (!mTabletStylusIsPressed)
...@@ -765,11 +764,6 @@ UBBoardView::drawItems (QPainter *painter, int numItems, ...@@ -765,11 +764,6 @@ UBBoardView::drawItems (QPainter *painter, int numItems,
} }
} }
//void UBBoardView::dragEnterEvent (QDragEnterEvent *event)
//{
// // TODO UB 4.x be smarter with drag accept code .... we cannot handle everything ...
// event->acceptProposedAction ();
//}
void UBBoardView::dragMoveEvent (QDragMoveEvent *event) void UBBoardView::dragMoveEvent (QDragMoveEvent *event)
{ {
...@@ -806,15 +800,17 @@ void UBBoardView::dropEvent (QDropEvent *event) ...@@ -806,15 +800,17 @@ void UBBoardView::dropEvent (QDropEvent *event)
QGraphicsItem* graphicsItemAtPos = itemAt(event->pos().x(),event->pos().y()); QGraphicsItem* graphicsItemAtPos = itemAt(event->pos().x(),event->pos().y());
UBGraphicsWidgetItem* graphicsWidget = dynamic_cast<UBGraphicsWidgetItem*>(graphicsItemAtPos); UBGraphicsWidgetItem* graphicsWidget = dynamic_cast<UBGraphicsWidgetItem*>(graphicsItemAtPos);
if (graphicsWidget && graphicsWidget->acceptDrops()) { qDebug() << event->source();
if (graphicsWidget && graphicsWidget->acceptDrops()) {
graphicsWidget->processDropEvent(event); graphicsWidget->processDropEvent(event);
event->acceptProposedAction(); event->acceptProposedAction();
} else if (!event->source() || dynamic_cast<UBThumbnailWidget *>(event->source()) }
|| dynamic_cast<QWebView*>(event->source()) || dynamic_cast<UBDraggableMediaPlayer *>(event->source()) else if (!event->source()
|| dynamic_cast<UBDraggableLabel *>(event->source()) || dynamic_cast<UBDraggableMedia *>(event->source())) { || dynamic_cast<UBThumbnailWidget *>(event->source())
|| dynamic_cast<QWebView*>(event->source())
|| dynamic_cast<UBTGMediaWidget*>(event->source())) {
mController->processMimeData (event->mimeData (), mapToScene (event->pos ())); mController->processMimeData (event->mimeData (), mapToScene (event->pos ()));
event->acceptProposedAction(); event->acceptProposedAction();
} }
......
...@@ -46,6 +46,7 @@ class UBBoardView : public QGraphicsView ...@@ -46,6 +46,7 @@ class UBBoardView : public QGraphicsView
void resized(QResizeEvent* event); void resized(QResizeEvent* event);
void hidden(); void hidden();
void shown(); void shown();
void clickOnBoard();
protected: protected:
......
...@@ -645,22 +645,6 @@ void UBStyle::drawItemText(QPainter *painter, const QRect &rect, int alignment, ...@@ -645,22 +645,6 @@ void UBStyle::drawItemText(QPainter *painter, const QRect &rect, int alignment,
painter->setPen(savedPen); painter->setPen(savedPen);
} }
QString UBApplication::globalStyleSheet()
{
QString style;
QFile f(":style.qss");
if(f.exists())
{
if(f.open(QIODevice::ReadOnly))
{
style = QString(f.readAll());
}
}
return style;
}
QString UBApplication::urlFromHtml(QString html) QString UBApplication::urlFromHtml(QString html)
{ {
QString _html; QString _html;
......
...@@ -78,7 +78,6 @@ class UBApplication : public QtSingleApplication ...@@ -78,7 +78,6 @@ class UBApplication : public QtSingleApplication
static void setDisabled(bool disable); static void setDisabled(bool disable);
static QObject* staticMemoryCleaner; static QObject* staticMemoryCleaner;
static QString globalStyleSheet();
void decorateActionMenu(QAction* action); void decorateActionMenu(QAction* action);
void insertSpaceToToolbarBeforeAction(QToolBar* toolbar, QAction* action, int width = -1); void insertSpaceToToolbarBeforeAction(QToolBar* toolbar, QAction* action, int width = -1);
......
...@@ -337,6 +337,9 @@ void UBApplicationController::showBoard() ...@@ -337,6 +337,9 @@ void UBApplicationController::showBoard()
mMainWindow->tutorialToolBar->hide(); mMainWindow->tutorialToolBar->hide();
mMainWindow->boardToolBar->show(); mMainWindow->boardToolBar->show();
if (mMainMode == Document && UBApplication::documentController->getSelectedItemIndex() != -1)
UBApplication::boardController->setActiveDocumentScene(UBApplication::documentController->getCurrentDocument(), UBApplication::documentController->getSelectedItemIndex());
mMainMode = Board; mMainMode = Board;
adaptToolBar(); adaptToolBar();
......
...@@ -254,13 +254,23 @@ UBDocumentProxy* UBPersistenceManager::createDocument(const QString& pGroupName, ...@@ -254,13 +254,23 @@ UBDocumentProxy* UBPersistenceManager::createDocument(const QString& pGroupName,
return doc; return doc;
} }
UBDocumentProxy* UBPersistenceManager::createDocumentFromDir(const QString& pDocumentDirectory, const QString& pGroupName, const QString& pName, bool withEmptyPage)
UBDocumentProxy* UBPersistenceManager::createDocumentFromDir(const QString& pDocumentDirectory)
{ {
checkIfDocumentRepositoryExists(); checkIfDocumentRepositoryExists();
UBDocumentProxy* doc = new UBDocumentProxy(pDocumentDirectory); // deleted in UBPersistenceManager::destructor UBDocumentProxy* doc = new UBDocumentProxy(pDocumentDirectory); // deleted in UBPersistenceManager::destructor
if (pGroupName.length() > 0)
{
doc->setMetaData(UBSettings::documentGroupName, pGroupName);
}
if (pName.length() > 0)
{
doc->setMetaData(UBSettings::documentName, pName);
}
if (withEmptyPage) createDocumentSceneAt(doc, 0);
QMap<QString, QVariant> metadatas = UBMetadataDcSubsetAdaptor::load(pDocumentDirectory); QMap<QString, QVariant> metadatas = UBMetadataDcSubsetAdaptor::load(pDocumentDirectory);
foreach(QString key, metadatas.keys()) foreach(QString key, metadatas.keys())
......
...@@ -46,7 +46,7 @@ class UBPersistenceManager : public QObject ...@@ -46,7 +46,7 @@ class UBPersistenceManager : public QObject
static void destroy(); static void destroy();
virtual UBDocumentProxy* createDocument(const QString& pGroupName = "", const QString& pName = "", bool withEmptyPage = true); virtual UBDocumentProxy* createDocument(const QString& pGroupName = "", const QString& pName = "", bool withEmptyPage = true);
virtual UBDocumentProxy* createDocumentFromDir(const QString& pDocumentDirectory); virtual UBDocumentProxy* createDocumentFromDir(const QString& pDocumentDirectory, const QString& pGroupName = "", const QString& pName = "", bool withEmptyPage = false);
virtual UBDocumentProxy* persistDocumentMetadata(UBDocumentProxy* pDocumentProxy); virtual UBDocumentProxy* persistDocumentMetadata(UBDocumentProxy* pDocumentProxy);
......
/*
* 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 <http://www.gnu.org/licenses/>.
*/
#include <QPainter> #include <QPainter>
#include <QDebug> #include <QDebug>
......
/*
* 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 <http://www.gnu.org/licenses/>.
*/
#ifndef UBACTIONABLEWIDGET_H #ifndef UBACTIONABLEWIDGET_H
#define UBACTIONABLEWIDGET_H #define UBACTIONABLEWIDGET_H
......
#include <QMimeData>
#include <QDrag>
#include <QUrl>
#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<QUrl> urls;
urls << QUrl::fromLocalFile(mSourcePath);
mimeData->setUrls(urls);
mimeData->setText(mSourcePath);
QDrag *drag = new QDrag(this);
drag->setMimeData(mimeData);
drag->start();
}
#ifndef UBDRAGGABLELABEL_H
#define UBDRAGGABLELABEL_H
#include <QLabel>
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
#include <QApplication>
#include <QUrl>
#include "UBDraggableMedia.h"
UBDraggableMedia::UBDraggableMedia(eMediaType type, QWidget *parent, const char *name):UBMediaWidget(type, parent, name)
{
removeAllActions();
}
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<QUrl> urls;
urls << QUrl(mFilePath);
mimeData->setText(mFilePath);
mimeData->setUrls(urls);
drag->setMimeData(mimeData);
drag->exec(Qt::CopyAction | Qt::MoveAction);
}
#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
...@@ -34,9 +34,10 @@ UBMediaWidget::UBMediaWidget(eMediaType type, QWidget *parent, const char *name) ...@@ -34,9 +34,10 @@ UBMediaWidget::UBMediaWidget(eMediaType type, QWidget *parent, const char *name)
, mBorder(5) , mBorder(5)
, mpMediaContainer(NULL) , mpMediaContainer(NULL)
, mpCover(NULL) , mpCover(NULL)
// , mpVideoStackedWidget(NULL)
// , mpSnapshotVideoWidget(NULL)
{ {
setAttribute(Qt::WA_StyledBackground, true); SET_STYLE_SHEET();
setStyleSheet(UBApplication::globalStyleSheet());
addAction(eAction_Close); addAction(eAction_Close);
mType = type; mType = type;
...@@ -73,6 +74,8 @@ UBMediaWidget::~UBMediaWidget() ...@@ -73,6 +74,8 @@ UBMediaWidget::~UBMediaWidget()
DELETEPTR(mpPlayStopButton); DELETEPTR(mpPlayStopButton);
DELETEPTR(mpAudioOutput); DELETEPTR(mpAudioOutput);
DELETEPTR(mpVideoWidget); DELETEPTR(mpVideoWidget);
// DELETEPTR(mpVideoStackedWidget);
// DELETEPTR(mpSnapshotVideoWidget);
DELETEPTR(mpMediaObject); DELETEPTR(mpMediaObject);
DELETEPTR(mpCover); DELETEPTR(mpCover);
} }
...@@ -118,6 +121,13 @@ void UBMediaWidget::showEvent(QShowEvent* event) ...@@ -118,6 +121,13 @@ void UBMediaWidget::showEvent(QShowEvent* event)
QWidget::showEvent(event); QWidget::showEvent(event);
} }
void UBMediaWidget::hideEvent(QHideEvent* event)
{
if(mpMediaObject->state() == Phonon::PlayingState)
mpMediaObject->stop();
UBActionableWidget::hideEvent(event);
}
/** /**
* \brief Create the media player * \brief Create the media player
*/ */
...@@ -128,10 +138,17 @@ void UBMediaWidget::createMediaPlayer() ...@@ -128,10 +138,17 @@ void UBMediaWidget::createMediaPlayer()
mpMediaContainer->setLayout(&mMediaLayout); mpMediaContainer->setLayout(&mMediaLayout);
if(eMediaType_Video == mType){ if(eMediaType_Video == mType){
mMediaLayout.setContentsMargins(10, 10, 25, 10); mMediaLayout.setContentsMargins(10, 10, 10, 10);
if(isVisible()){ if(isVisible()){
mpVideoWidget = new Phonon::VideoWidget(this); mpVideoWidget = new Phonon::VideoWidget(this);
mMediaLayout.addStretch(1); mMediaLayout.addStretch(1);
// mpVideoStackedWidget = new QStackedWidget(this);
// mpVideoStackedWidget->addWidget(mpVideoWidget);
// mpSnapshotVideoWidget = new QLabel(this);
// mpVideoStackedWidget->addWidget(mpSnapshotVideoWidget);
// mMediaLayout.addWidget(mpVideoStackedWidget,0);
mMediaLayout.addWidget(mpVideoWidget, 0); mMediaLayout.addWidget(mpVideoWidget, 0);
mMediaLayout.addStretch(1); mMediaLayout.addStretch(1);
Phonon::createPath(mpMediaObject, mpVideoWidget); Phonon::createPath(mpMediaObject, mpVideoWidget);
...@@ -171,6 +188,22 @@ void UBMediaWidget::adaptSizeToVideo() ...@@ -171,6 +188,22 @@ void UBMediaWidget::adaptSizeToVideo()
} }
} }
//void UBMediaWidget::updateView(Phonon::State nextState)
//{
// if(eMediaType_Video == mType){
// if(nextState != Phonon::PlayingState){
// const QPixmap& snapshot = QPixmap::grabWindow(mpVideoWidget->winId());
// if(snapshot.size().width()!= 0){
// mpSnapshotVideoWidget->setPixmap(snapshot);
// mpVideoStackedWidget->setCurrentWidget(mpSnapshotVideoWidget);
// }
// }
// else
// mpVideoStackedWidget->setCurrentWidget(mpVideoWidget);
// }
//}
/** /**
* \brief Handle the media state change notification * \brief Handle the media state change notification
* @param newState as the new state * @param newState as the new state
...@@ -199,6 +232,7 @@ void UBMediaWidget::onStateChanged(Phonon::State newState, Phonon::State oldStat ...@@ -199,6 +232,7 @@ void UBMediaWidget::onStateChanged(Phonon::State newState, Phonon::State oldStat
mpPauseButton->setEnabled(false); mpPauseButton->setEnabled(false);
mpSlider->setValue(0); mpSlider->setValue(0);
} }
//updateView(newState);
} }
} }
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include <QLabel> #include <QLabel>
#include <QSlider> #include <QSlider>
#include <QMouseEvent> #include <QMouseEvent>
#include <QStackedWidget>
#include <phonon/MediaObject> #include <phonon/MediaObject>
#include <phonon/VideoWidget> #include <phonon/VideoWidget>
...@@ -75,6 +76,7 @@ public: ...@@ -75,6 +76,7 @@ public:
protected: protected:
void resizeEvent(QResizeEvent* ev); void resizeEvent(QResizeEvent* ev);
void showEvent(QShowEvent* event); void showEvent(QShowEvent* event);
void hideEvent(QHideEvent* event);
/** The current media file path */ /** The current media file path */
QString mFilePath; QString mFilePath;
...@@ -89,6 +91,7 @@ private slots: ...@@ -89,6 +91,7 @@ private slots:
private: private:
void createMediaPlayer(); void createMediaPlayer();
void adaptSizeToVideo(); void adaptSizeToVideo();
// void updateView(Phonon::State nextState);
/** The current media type */ /** The current media type */
eMediaType mType; eMediaType mType;
...@@ -122,6 +125,9 @@ private: ...@@ -122,6 +125,9 @@ private:
QLabel* mpCover; QLabel* mpCover;
/** The media url */ /** The media url */
QString mUrl; QString mUrl;
// QStackedWidget* mpVideoStackedWidget;
// QLabel* mpSnapshotVideoWidget;
}; };
#endif // UBMEDIAWIDGET_H #endif // UBMEDIAWIDGET_H
#include <QDebug>
#include <QScrollBar>
#include <QApplication>
#include <QPainter>
#include "globals/UBGlobals.h"
#include "UBWidgetList.h"
UBWidgetList::UBWidgetList(QWidget* parent, eWidgetListOrientation orientation, const char* name):QScrollArea(parent)
, mCanRemove(true)
, mpLayout(NULL)
, mpContainer(NULL)
, mMargin(10)
, mListElementsSpacing(10)
, mpEmptyLabel(NULL)
, mpCurrentWidget(NULL)
{
setObjectName(name);
mOrientation = 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);
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
mpLayout = new QVBoxLayout(mpContainer);
}
else{
setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
mpLayout = new QHBoxLayout(mpContainer);
}
mpLayout->setContentsMargins(margin(), margin(), margin(), margin());
mpContainer->setLayout(mpLayout);
setWidget(mpContainer);
}
UBWidgetList::~UBWidgetList()
{
DELETEPTR(mpEmptyLabel);
DELETEPTR(mpLayout);
DELETEPTR(mpContainer);
}
void UBWidgetList::addWidget(QWidget *widget)
{
if(NULL != mpLayout && NULL != widget){
widget->setParent(mpContainer);
mpEmptyLabel->setVisible(false);
mWidgetInfo[widget] = widget->size();
updateView(size());
mpLayout->addWidget(widget);
// This call is used only to refresh the size of the widgets
updateSizes();
}
}
void UBWidgetList::removeWidget(QWidget *widget)
{
if(NULL != mpLayout && NULL != widget){
mpLayout->removeWidget(widget);
mWidgetInfo.remove(widget);
widget->setVisible(false);
updateView(size());
if(0 == mpLayout->count()){
mpEmptyLabel->setVisible(true);
}
if(mpCurrentWidget == widget){
mpCurrentWidget = NULL;
}
}
}
int UBWidgetList::scaleWidgets(QSize pSize)
{
// to remove the first spacing that shouldn't be there.
int result = -mListElementsSpacing;
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- 1);
eachWidget->setMaximumHeight(newWidgetHeight);
}
else{
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;
}
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)
{
Q_UNUSED(ev);
mpEmptyLabel->setGeometry((width() - mpEmptyLabel->width()) / 2,
(height() - mpEmptyLabel->height()) /2,
mpEmptyLabel->width(),
mpEmptyLabel->height());
updateView(size());
updateSizes();
}
void UBWidgetList::mousePressEvent(QMouseEvent *ev)
{
Q_UNUSED(ev);
if(mCanRemove){
QWidget* pWAt = widgetAt(ev->pos());
if(NULL != mpCurrentWidget){
if(pWAt != mpCurrentWidget){
mpCurrentWidget->setActionsVisible(false);
update();
}
}
mpCurrentWidget = dynamic_cast<UBActionableWidget*>(pWAt);
if(NULL != mpCurrentWidget){
mpCurrentWidget->setActionsVisible(true);
update();
}
}
update();
}
QWidget* UBWidgetList::widgetAt(QPoint p)
{
QWidget* pW = NULL;
pW = childAt(p);
if(NULL != pW){
do{
if( "UBTeacherStudentAction" == pW->objectName() ||
"UBUrlWidget" == pW->objectName() ||
"UBTBMediaPicture" == pW->objectName() ||
"UBMediaWidget" == pW->objectName()){
return pW;
}else{
pW = pW->parentWidget();
}
}while(NULL != pW && this != pW);
}
return pW;
}
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)
{
mMargin = margin;
}
int UBWidgetList::margin()
{
return mMargin;
}
void UBWidgetList::setEmptyText(const QString &text)
{
if(NULL != mpEmptyLabel){
mpEmptyLabel->setText(text);
}
}
bool UBWidgetList::empty()
{
return mWidgetInfo.empty();
}
#ifndef UBWIDGETLIST_H
#define UBWIDGETLIST_H
#include <QWidget>
#include <QScrollArea>
#include <QBoxLayout>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QResizeEvent>
#include <QVector>
#include <QLabel>
#include "interfaces/IResizeable.h"
#include "customWidgets/UBActionableWidget.h"
typedef enum{
eWidgetListOrientation_Vertical,
eWidgetListOrientation_Horizontal
}eWidgetListOrientation;
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 removeWidget(QWidget* widget);
void setMargin(int margin);
void setEmptyText(const QString& text);
int margin();
bool empty();
void setListElementSpacing(int margin) { mListElementsSpacing = margin; }
int listElementsSpacing() {return mListElementsSpacing; }
signals:
void closeWidget(QWidget* w);
protected:
bool mCanRemove;
void resizeEvent(QResizeEvent* ev);
void mousePressEvent(QMouseEvent* ev);
private:
QWidget* widgetAt(QPoint p);
int scaleWidgets(QSize pSize);
void scaleContainer(QSize pSize, int updateValue);
void updateView(QSize pSize);
void updateSizes();
QBoxLayout* mpLayout;
QWidget* mpContainer;
eWidgetListOrientation mOrientation;
int mMargin;
int mListElementsSpacing;
QMap<QWidget*, QSize> mWidgetInfo;
QLabel* mpEmptyLabel;
UBActionableWidget* mpCurrentWidget;
};
#endif // UBWIDGETLIST_H
HEADERS += src/customWidgets/UBWidgetList.h \ HEADERS += \
src/customWidgets/UBDraggableLabel.h \
src/customWidgets/UBMediaWidget.h \ src/customWidgets/UBMediaWidget.h \
src/globals/UBGlobals.h \
src/customWidgets/UBDraggableMedia.h \
src/customWidgets/UBActionableWidget.h src/customWidgets/UBActionableWidget.h
SOURCES += src/customWidgets/UBWidgetList.cpp \ SOURCES += \
src/customWidgets/UBDraggableLabel.cpp \
src/customWidgets/UBMediaWidget.cpp \ src/customWidgets/UBMediaWidget.cpp \
src/customWidgets/UBDraggableMedia.cpp \
src/customWidgets/UBActionableWidget.cpp src/customWidgets/UBActionableWidget.cpp
...@@ -762,21 +762,6 @@ void UBDesktopAnnotationController::togglePropertyPalette(UBActionPalette *palet ...@@ -762,21 +762,6 @@ void UBDesktopAnnotationController::togglePropertyPalette(UBActionPalette *palet
void UBDesktopAnnotationController::switchCursor(const int tool) void UBDesktopAnnotationController::switchCursor(const int tool)
{ {
// enum Enum
// {
// Pen = 0,
// Eraser,
// Marker,
// Selector,
// Hand,
// ZoomIn,
// ZoomOut,
// Pointer,
// Line,
// Text,
// Capture
// };
mTransparentDrawingScene->setToolCursor(tool); mTransparentDrawingScene->setToolCursor(tool);
mTransparentDrawingView->setToolCursor(tool); mTransparentDrawingView->setToolCursor(tool);
} }
...@@ -826,17 +811,6 @@ void UBDesktopAnnotationController::onDesktopPaletteMaximized() ...@@ -826,17 +811,6 @@ void UBDesktopAnnotationController::onDesktopPaletteMaximized()
connect(pPointerButton, SIGNAL(pressed()), this, SLOT(pointerActionPressed())); connect(pPointerButton, SIGNAL(pressed()), this, SLOT(pointerActionPressed()));
connect(pPointerButton, SIGNAL(released()), this, SLOT(pointerActionReleased())); connect(pPointerButton, SIGNAL(released()), this, SLOT(pointerActionReleased()));
} }
// enum Enum
// {
// Hand,
// ZoomIn,
// ZoomOut,
// Line,
// Text,
// Capture
// };
} }
/** /**
...@@ -872,16 +846,6 @@ void UBDesktopAnnotationController::onDesktopPaletteMinimize() ...@@ -872,16 +846,6 @@ void UBDesktopAnnotationController::onDesktopPaletteMinimize()
void UBDesktopAnnotationController::TransparentWidgetResized() void UBDesktopAnnotationController::TransparentWidgetResized()
{ {
/*
int rW = UBApplication::boardController->paletteManager()->rightPalette()->width();
int rH_ = UBApplication::boardController->paletteManager()->rightPalette()->height();
int rH = mTransparentDrawingView->height();
UBApplication::boardController->paletteManager()->rightPalette()->resize(rW+1, rH);
// UBApplication::boardController->paletteManager()->rightPalette()->resize(500, 500);
*/
onTransparentWidgetResized(); onTransparentWidgetResized();
} }
...@@ -900,8 +864,6 @@ void UBDesktopAnnotationController::onTransparentWidgetResized() ...@@ -900,8 +864,6 @@ void UBDesktopAnnotationController::onTransparentWidgetResized()
UBApplication::boardController->paletteManager()->leftPalette()->resize(lW+1, rH); UBApplication::boardController->paletteManager()->leftPalette()->resize(lW+1, rH);
UBApplication::boardController->paletteManager()->leftPalette()->resize(lW, rH); UBApplication::boardController->paletteManager()->leftPalette()->resize(lW, rH);
// mRightPalette->resize(mRightPalette->width(), mTransparentDrawingView->height());
} }
void UBDesktopAnnotationController::updateMask(bool bTransparent) void UBDesktopAnnotationController::updateMask(bool bTransparent)
......
...@@ -160,6 +160,9 @@ void UBDocumentController::selectDocument(UBDocumentProxy* proxy, bool setAsCurr ...@@ -160,6 +160,9 @@ void UBDocumentController::selectDocument(UBDocumentProxy* proxy, bool setAsCurr
mDocumentUI->documentTreeWidget->scrollToItem(selected); mDocumentUI->documentTreeWidget->scrollToItem(selected);
mDocumentThumbs = UBThumbnailAdaptor::load(selectedDocumentProxy());
refreshDocumentThumbnailsView();
mSelectionType = Document; mSelectionType = Document;
} }
} }
...@@ -268,11 +271,10 @@ void UBDocumentController::refreshDocumentThumbnailsView() ...@@ -268,11 +271,10 @@ void UBDocumentController::refreshDocumentThumbnailsView()
if (proxy) if (proxy)
{ {
mCurrentDocument = proxy; mCurrentDocument = proxy;
QList<QPixmap> thumbs = UBThumbnailAdaptor::load(proxy);
for (int i = 0; i < thumbs.count(); i++) for (int i = 0; i < mDocumentThumbs.count(); i++)
{ {
QPixmap pix = thumbs.at(i); QPixmap pix = mDocumentThumbs.at(i);
QGraphicsPixmapItem *pixmapItem = new UBSceneThumbnailPixmap(pix, proxy, i); // deleted by the tree widget QGraphicsPixmapItem *pixmapItem = new UBSceneThumbnailPixmap(pix, proxy, i); // deleted by the tree widget
if (proxy == mBoardController->activeDocument() && mBoardController->activeSceneIndex() == i) if (proxy == mBoardController->activeDocument() && mBoardController->activeSceneIndex() == i)
...@@ -507,7 +509,7 @@ void UBDocumentController::openSelectedItem() ...@@ -507,7 +509,7 @@ void UBDocumentController::openSelectedItem()
if (proxy && isOKToOpenDocument(proxy)) if (proxy && isOKToOpenDocument(proxy))
{ {
mBoardController->setActiveDocumentScene(proxy, thumb->sceneIndex()); //mBoardController->setActiveDocumentScene(proxy, thumb->sceneIndex());
UBApplication::applicationController->showBoard(); UBApplication::applicationController->showBoard();
} }
} }
...@@ -561,6 +563,7 @@ void UBDocumentController::duplicateSelectedItem() ...@@ -561,6 +563,7 @@ void UBDocumentController::duplicateSelectedItem()
foreach (int sceneIndex, selectedSceneIndexes) foreach (int sceneIndex, selectedSceneIndexes)
{ {
UBPersistenceManager::persistenceManager()->duplicateDocumentScene(proxy, sceneIndex + offset); UBPersistenceManager::persistenceManager()->duplicateDocumentScene(proxy, sceneIndex + offset);
mDocumentThumbs.insert(sceneIndex + offset, mDocumentThumbs.at(sceneIndex + offset));
offset++; offset++;
} }
} }
...@@ -921,6 +924,7 @@ void UBDocumentController::itemClicked(QTreeWidgetItem * item, int column ) ...@@ -921,6 +924,7 @@ void UBDocumentController::itemClicked(QTreeWidgetItem * item, int column )
Q_UNUSED(item); Q_UNUSED(item);
Q_UNUSED(column); Q_UNUSED(column);
selectDocument(selectedDocumentProxy(), false);
itemSelectionChanged(); itemSelectionChanged();
} }
...@@ -1043,6 +1047,7 @@ void UBDocumentController::addFolderOfImages() ...@@ -1043,6 +1047,7 @@ void UBDocumentController::addFolderOfImages()
{ {
document->setMetaData(UBSettings::documentUpdatedAt, UBStringUtils::toUtcIsoDateTime(QDateTime::currentDateTime())); document->setMetaData(UBSettings::documentUpdatedAt, UBStringUtils::toUtcIsoDateTime(QDateTime::currentDateTime()));
UBMetadataDcSubsetAdaptor::persist(document); UBMetadataDcSubsetAdaptor::persist(document);
mDocumentThumbs = UBThumbnailAdaptor::load(selectedDocumentProxy());
refreshDocumentThumbnailsView(); refreshDocumentThumbnailsView();
} }
} }
...@@ -1057,6 +1062,7 @@ void UBDocumentController::addFileToDocument() ...@@ -1057,6 +1062,7 @@ void UBDocumentController::addFileToDocument()
if (document) if (document)
{ {
addFileToDocument(document); addFileToDocument(document);
mDocumentThumbs = UBThumbnailAdaptor::load(document);
refreshDocumentThumbnailsView(); refreshDocumentThumbnailsView();
} }
} }
...@@ -1108,12 +1114,9 @@ void UBDocumentController::moveSceneToIndex(UBDocumentProxy* proxy, int source, ...@@ -1108,12 +1114,9 @@ void UBDocumentController::moveSceneToIndex(UBDocumentProxy* proxy, int source,
proxy->setMetaData(UBSettings::documentUpdatedAt, UBStringUtils::toUtcIsoDateTime(QDateTime::currentDateTime())); proxy->setMetaData(UBSettings::documentUpdatedAt, UBStringUtils::toUtcIsoDateTime(QDateTime::currentDateTime()));
UBMetadataDcSubsetAdaptor::persist(proxy); UBMetadataDcSubsetAdaptor::persist(proxy);
mDocumentThumbs.insert(target, mDocumentThumbs.takeAt(source));
refreshDocumentThumbnailsView(); refreshDocumentThumbnailsView();
mDocumentUI->thumbnailWidget->hightlightItem(target);
// Notify the move to anyone interested in knowing it
emit movedToIndex(target);
UBApplication::boardController->setActiveDocumentScene(proxy, target);
} }
...@@ -1321,7 +1324,8 @@ void UBDocumentController::addToDocument() ...@@ -1321,7 +1324,8 @@ void UBDocumentController::addToDocument()
} }
int newActiveSceneIndex = selectedItems.count() == mBoardController->activeDocument()->pageCount() ? 0 : oldActiveSceneIndex + 1; int newActiveSceneIndex = selectedItems.count() == mBoardController->activeDocument()->pageCount() ? 0 : oldActiveSceneIndex + 1;
mBoardController->setActiveDocumentScene(mBoardController->activeDocument(), newActiveSceneIndex); mDocumentUI->thumbnailWidget->selectItemAt(newActiveSceneIndex, false);
selectDocument(mBoardController->activeDocument());
mBoardController->activeDocument()->setMetaData(UBSettings::documentUpdatedAt, UBStringUtils::toUtcIsoDateTime(QDateTime::currentDateTime())); mBoardController->activeDocument()->setMetaData(UBSettings::documentUpdatedAt, UBStringUtils::toUtcIsoDateTime(QDateTime::currentDateTime()));
UBMetadataDcSubsetAdaptor::persist(mBoardController->activeDocument()); UBMetadataDcSubsetAdaptor::persist(mBoardController->activeDocument());
...@@ -1495,6 +1499,7 @@ void UBDocumentController::addImages() ...@@ -1495,6 +1499,7 @@ void UBDocumentController::addImages()
{ {
document->setMetaData(UBSettings::documentUpdatedAt, UBStringUtils::toUtcIsoDateTime(QDateTime::currentDateTime())); document->setMetaData(UBSettings::documentUpdatedAt, UBStringUtils::toUtcIsoDateTime(QDateTime::currentDateTime()));
UBMetadataDcSubsetAdaptor::persist(document); UBMetadataDcSubsetAdaptor::persist(document);
mDocumentThumbs = UBThumbnailAdaptor::load(selectedDocumentProxy());
refreshDocumentThumbnailsView(); refreshDocumentThumbnailsView();
} }
} }
...@@ -1605,6 +1610,13 @@ void UBDocumentController::deletePages(QList<QGraphicsItem *> itemsToDelete) ...@@ -1605,6 +1610,13 @@ void UBDocumentController::deletePages(QList<QGraphicsItem *> itemsToDelete)
UBPersistenceManager::persistenceManager()->deleteDocumentScenes(proxy, sceneIndexes); UBPersistenceManager::persistenceManager()->deleteDocumentScenes(proxy, sceneIndexes);
proxy->setMetaData(UBSettings::documentUpdatedAt, UBStringUtils::toUtcIsoDateTime(QDateTime::currentDateTime())); proxy->setMetaData(UBSettings::documentUpdatedAt, UBStringUtils::toUtcIsoDateTime(QDateTime::currentDateTime()));
UBMetadataDcSubsetAdaptor::persist(proxy); UBMetadataDcSubsetAdaptor::persist(proxy);
int offset = 0;
foreach(int index, sceneIndexes)
{
mDocumentThumbs.removeAt(index - offset);
offset++;
}
refreshDocumentThumbnailsView(); refreshDocumentThumbnailsView();
int minIndex = proxy->pageCount() - 1; int minIndex = proxy->pageCount() - 1;
...@@ -1616,3 +1628,15 @@ void UBDocumentController::deletePages(QList<QGraphicsItem *> itemsToDelete) ...@@ -1616,3 +1628,15 @@ void UBDocumentController::deletePages(QList<QGraphicsItem *> itemsToDelete)
} }
} }
} }
int UBDocumentController::getSelectedItemIndex()
{
QList<QGraphicsItem*> selectedItems = mDocumentUI->thumbnailWidget->selectedItems();
if (selectedItems.count() > 0)
{
UBSceneThumbnailPixmap* thumb = dynamic_cast<UBSceneThumbnailPixmap*> (selectedItems.last());
return thumb->sceneIndex();
}
else return -1;
}
\ No newline at end of file
...@@ -48,8 +48,9 @@ class UBDocumentController : public QObject ...@@ -48,8 +48,9 @@ class UBDocumentController : public QObject
QWidget* controlView(); QWidget* controlView();
UBDocumentProxyTreeItem* findDocument(UBDocumentProxy* proxy); UBDocumentProxyTreeItem* findDocument(UBDocumentProxy* proxy);
bool addFileToDocument(UBDocumentProxy* document); bool addFileToDocument(UBDocumentProxy* document);
UBDocumentProxy* getCurrentDocument(); UBDocumentProxy* getCurrentDocument() { return mCurrentDocument; };
void deletePages(QList<QGraphicsItem*> itemsToDelete); void deletePages(QList<QGraphicsItem*> itemsToDelete);
int getSelectedItemIndex();
signals: signals:
void refreshThumbnails(); void refreshThumbnails();
...@@ -111,6 +112,7 @@ class UBDocumentController : public QObject ...@@ -111,6 +112,7 @@ class UBDocumentController : public QObject
bool mToolsPalettePositionned; bool mToolsPalettePositionned;
UBDocumentGroupTreeItem* mTrashTi; UBDocumentGroupTreeItem* mTrashTi;
UBDocumentProxy* mCurrentDocument; UBDocumentProxy* mCurrentDocument;
QList<QPixmap> mDocumentThumbs;
// UBKeyboardPalette *mKeyboardPalette; // UBKeyboardPalette *mKeyboardPalette;
......
/*
* 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 <http://www.gnu.org/licenses/>.
*/
#ifndef UBGLOBALS_H #ifndef UBGLOBALS_H
#define UBGLOBALS_H #define UBGLOBALS_H
#include <QString>
#include <QFile>
#define DELETEPTR(ptr) if(NULL != ptr){ \ #define DELETEPTR(ptr) if(NULL != ptr){ \
delete ptr; \ delete ptr; \
ptr = NULL; \ ptr = NULL; \
} }
#define SET_STYLE_SHEET() {\
setAttribute(Qt::WA_StyledBackground, true);\
QString style;\
QFile f(":style.qss");\
if(f.exists() && f.open(QIODevice::ReadOnly))\
style = QString(f.readAll());\
setStyleSheet(style);\
}
#ifdef Q_WS_WIN #ifdef Q_WS_WIN
#define WARNINGS_DISABLE __pragma(warning(push, 0)); #define WARNINGS_DISABLE __pragma(warning(push, 0));
......
...@@ -231,6 +231,7 @@ void UBActionPalette::mouseReleaseEvent(QMouseEvent * event) ...@@ -231,6 +231,7 @@ void UBActionPalette::mouseReleaseEvent(QMouseEvent * event)
void UBActionPalette::actionChanged() void UBActionPalette::actionChanged()
{ {
emit itemOnActionPaletteChanged();
for(int i = 0; i < mActions.length() && i < mButtons.length(); i++) for(int i = 0; i < mActions.length() && i < mButtons.length(); i++)
{ {
mButtons.at(i)->setVisible(mActions.at(i)->isVisible()); mButtons.at(i)->setVisible(mActions.at(i)->isVisible());
......
...@@ -56,10 +56,12 @@ class UBActionPalette : public UBFloatingPalette ...@@ -56,10 +56,12 @@ class UBActionPalette : public UBFloatingPalette
public slots: public slots:
void close(); void close();
signals: signals:
void closed(); void closed();
void buttonGroupClicked(int id); void buttonGroupClicked(int id);
void customMouseReleased(); void customMouseReleased();
void itemOnActionPaletteChanged();
protected: protected:
virtual void paintEvent(QPaintEvent *event); virtual void paintEvent(QPaintEvent *event);
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "core/UBApplication.h" #include "core/UBApplication.h"
#include "core/UBApplicationController.h" #include "core/UBApplicationController.h"
#include "globals/UBGlobals.h"
#include "board/UBBoardController.h" #include "board/UBBoardController.h"
#include "domain/UBGraphicsScene.h" #include "domain/UBGraphicsScene.h"
...@@ -34,8 +35,8 @@ UBCachePropertiesWidget::UBCachePropertiesWidget(QWidget *parent, const char *na ...@@ -34,8 +35,8 @@ UBCachePropertiesWidget::UBCachePropertiesWidget(QWidget *parent, const char *na
, mpCurrentCache(NULL) , mpCurrentCache(NULL)
{ {
setObjectName(name); setObjectName(name);
setAttribute(Qt::WA_StyledBackground, true);
setStyleSheet(UBApplication::globalStyleSheet()); SET_STYLE_SHEET();
mName = "CachePropWidget"; mName = "CachePropWidget";
mVisibleState = false; mVisibleState = false;
......
...@@ -15,6 +15,8 @@ ...@@ -15,6 +15,8 @@
#include "UBDockDownloadWidget.h" #include "UBDockDownloadWidget.h"
#include "core/UBApplication.h" #include "core/UBApplication.h"
#include "globals/UBGlobals.h"
UBDockDownloadWidget::UBDockDownloadWidget(QWidget *parent, const char *name):UBDockPaletteWidget(parent, name) UBDockDownloadWidget::UBDockDownloadWidget(QWidget *parent, const char *name):UBDockPaletteWidget(parent, name)
, mpLayout(NULL) , mpLayout(NULL)
, mpDLWidget(NULL) , mpDLWidget(NULL)
...@@ -22,8 +24,7 @@ UBDockDownloadWidget::UBDockDownloadWidget(QWidget *parent, const char *name):UB ...@@ -22,8 +24,7 @@ UBDockDownloadWidget::UBDockDownloadWidget(QWidget *parent, const char *name):UB
mName = "DownloadWidget"; mName = "DownloadWidget";
mVisibleState = false; mVisibleState = false;
setAttribute(Qt::WA_StyledBackground, true); SET_STYLE_SHEET();
setStyleSheet(UBApplication::globalStyleSheet());
mIconToLeft = QPixmap(":images/download_open.png"); mIconToLeft = QPixmap(":images/download_open.png");
mIconToRight = QPixmap(":images/download_close.png"); mIconToRight = QPixmap(":images/download_close.png");
......
/*
* 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 <http://www.gnu.org/licenses/>.
*/
#include "core/UBApplication.h"
#include "globals/UBGlobals.h"
#include "UBDockTeacherGuideWidget.h"
#include "UBTeacherGuideWidget.h"
UBDockTeacherGuideWidget::UBDockTeacherGuideWidget(QWidget* parent, const char* name):
UBDockPaletteWidget(parent,name)
, mpTeacherGuideWidget(NULL)
{
mName = "TeacherGuide";
SET_STYLE_SHEET();
mIconToLeft = QPixmap(":images/teacher_open.png");
mIconToRight = QPixmap(":images/teacher_close.png");
mpLayout = new QVBoxLayout(this);
setLayout(mpLayout);
mpTeacherGuideWidget = new UBTeacherGuideWidget(this);
mpLayout->addWidget(mpTeacherGuideWidget);
}
UBDockTeacherGuideWidget::~UBDockTeacherGuideWidget()
{
DELETEPTR(mpTeacherGuideWidget);
DELETEPTR(mpLayout);
}
/*
* 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 <http://www.gnu.org/licenses/>.
*/
#ifndef UBDOCKTEACHERGUIDEWIDGET_H
#define UBDOCKTEACHERGUIDEWIDGET_H
class QVBoxLayout;
class UBTeacherGuideWidget;
#include "UBDockPaletteWidget.h"
class UBDockTeacherGuideWidget : public UBDockPaletteWidget
{
Q_OBJECT
public:
UBDockTeacherGuideWidget(QWidget* parent=0, const char* name="UBDockTeacherGuideWidget");
~UBDockTeacherGuideWidget();
bool visibleInMode(eUBDockPaletteWidgetMode mode){ return mode == eUBDockPaletteWidget_BOARD; }
private:
QVBoxLayout* mpLayout;
UBTeacherGuideWidget* mpTeacherGuideWidget;
};
#endif // UBDOCKTEACHERGUIDEWIDGET_H
...@@ -56,7 +56,6 @@ UBDocumentNavigator::UBDocumentNavigator(QWidget *parent, const char *name):QGra ...@@ -56,7 +56,6 @@ UBDocumentNavigator::UBDocumentNavigator(QWidget *parent, const char *name):QGra
setFrameShadow(QFrame::Plain); setFrameShadow(QFrame::Plain);
connect(UBApplication::boardController, SIGNAL(activeSceneChanged()), this, SLOT(addNewPage())); connect(UBApplication::boardController, SIGNAL(activeSceneChanged()), this, SLOT(addNewPage()));
connect(UBApplication::boardController, SIGNAL(setDocOnPageNavigator(UBDocumentProxy*)), this, SLOT(generateThumbnails()));
connect(mScene, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged())); connect(mScene, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged()));
connect(UBApplication::boardController, SIGNAL(documentReorganized(int)), this, SLOT(onMovedToIndex(int))); connect(UBApplication::boardController, SIGNAL(documentReorganized(int)), this, SLOT(onMovedToIndex(int)));
} }
......
...@@ -18,8 +18,10 @@ ...@@ -18,8 +18,10 @@
#include <QApplication> #include <QApplication>
#include "UBDownloadWidget.h" #include "UBDownloadWidget.h"
#include "core/UBApplication.h"
#include "globals/UBGlobals.h"
#include "core/UBApplication.h"
#include "core/memcheck.h" #include "core/memcheck.h"
/** /**
...@@ -36,8 +38,7 @@ UBDownloadWidget::UBDownloadWidget(QWidget *parent, const char *name):QWidget(pa ...@@ -36,8 +38,7 @@ UBDownloadWidget::UBDownloadWidget(QWidget *parent, const char *name):QWidget(pa
{ {
setObjectName(name); setObjectName(name);
setWindowTitle(tr("Downloading files")); setWindowTitle(tr("Downloading files"));
setAttribute(Qt::WA_StyledBackground, true); SET_STYLE_SHEET();
setStyleSheet(UBApplication::globalStyleSheet());
resize(400, 300); resize(400, 300);
mpLayout = new QVBoxLayout(this); mpLayout = new QVBoxLayout(this);
......
...@@ -18,10 +18,12 @@ ...@@ -18,10 +18,12 @@
#include "core/UBApplication.h" #include "core/UBApplication.h"
#include "core/UBDownloadManager.h" #include "core/UBDownloadManager.h"
#include "core/memcheck.h"
#include "frameworks/UBFileSystemUtils.h" #include "frameworks/UBFileSystemUtils.h"
#include "core/memcheck.h" #include "globals/UBGlobals.h"
/** /**
* \brief Constructor * \brief Constructor
...@@ -43,8 +45,7 @@ UBLibItemProperties::UBLibItemProperties(QWidget *parent, const char *name):QWid ...@@ -43,8 +45,7 @@ UBLibItemProperties::UBLibItemProperties(QWidget *parent, const char *name):QWid
{ {
setObjectName(name); setObjectName(name);
setAttribute(Qt::WA_StyledBackground, true); SET_STYLE_SHEET();
setStyleSheet(UBApplication::globalStyleSheet());
// Create the GUI // Create the GUI
mpLayout = new QVBoxLayout(this); mpLayout = new QVBoxLayout(this);
......
...@@ -18,6 +18,8 @@ ...@@ -18,6 +18,8 @@
#include "core/UBApplication.h" #include "core/UBApplication.h"
#include "core/memcheck.h" #include "core/memcheck.h"
#include "globals/UBGlobals.h"
static int lowBoundForSlider = 40; static int lowBoundForSlider = 40;
static int topBoundForSlider = 120; static int topBoundForSlider = 120;
static int tickIntervalForSlider = 10; static int tickIntervalForSlider = 10;
...@@ -35,8 +37,7 @@ UBLibNavigatorWidget::UBLibNavigatorWidget(QWidget *parent, const char *name):QW ...@@ -35,8 +37,7 @@ UBLibNavigatorWidget::UBLibNavigatorWidget(QWidget *parent, const char *name):QW
{ {
setObjectName(name); setObjectName(name);
setAttribute(Qt::WA_StyledBackground, true); SET_STYLE_SHEET();
setStyleSheet(UBApplication::globalStyleSheet());
setAcceptDrops(true); setAcceptDrops(true);
......
#include <QDomDocument> #include <QDomDocument>
#include "core/UBApplication.h" #include "core/UBApplication.h"
#include "core/memcheck.h"
#include "board/UBBoardController.h" #include "board/UBBoardController.h"
#include "globals/UBGlobals.h"
#include "UBLibWebView.h" #include "UBLibWebView.h"
#include "core/memcheck.h"
UBLibWebView::UBLibWebView(QWidget* parent, const char* name):QWidget(parent) UBLibWebView::UBLibWebView(QWidget* parent, const char* name):QWidget(parent)
, mpView(NULL) , mpView(NULL)
...@@ -15,8 +19,7 @@ UBLibWebView::UBLibWebView(QWidget* parent, const char* name):QWidget(parent) ...@@ -15,8 +19,7 @@ UBLibWebView::UBLibWebView(QWidget* parent, const char* name):QWidget(parent)
{ {
setObjectName(name); setObjectName(name);
setAttribute(Qt::WA_StyledBackground, true); SET_STYLE_SHEET();
setStyleSheet(UBApplication::globalStyleSheet());
mpLayout = new QVBoxLayout(); mpLayout = new QVBoxLayout();
setLayout(mpLayout); setLayout(mpLayout);
......
...@@ -15,10 +15,12 @@ ...@@ -15,10 +15,12 @@
#include <QDebug> #include <QDebug>
#include "UBLibWidget.h" #include "UBLibWidget.h"
#include "core/UBApplication.h"
#include "core/UBApplication.h"
#include "core/memcheck.h" #include "core/memcheck.h"
#include "globals/UBGlobals.h"
/** /**
* \brief Constructor * \brief Constructor
* @param parent as the parent widget * @param parent as the parent widget
...@@ -37,8 +39,7 @@ UBLibWidget::UBLibWidget(QWidget *parent, const char *name):UBDockPaletteWidget( ...@@ -37,8 +39,7 @@ UBLibWidget::UBLibWidget(QWidget *parent, const char *name):UBDockPaletteWidget(
mName = "LibWidget"; mName = "LibWidget";
mVisibleState = true; mVisibleState = true;
setAttribute(Qt::WA_StyledBackground, true); SET_STYLE_SHEET();
setStyleSheet(UBApplication::globalStyleSheet());
mIconToLeft = QPixmap(":images/library_open.png"); mIconToLeft = QPixmap(":images/library_open.png");
mIconToRight = QPixmap(":images/library_close.png"); mIconToRight = QPixmap(":images/library_close.png");
......
This diff is collapsed.
#ifndef UBUBMediaPlayer_H
#define UBUBMediaPlayer_H
#include <QtGui/QWidget>
#include <QtGui/QApplication>
#include <QtCore/QTimerEvent>
#include <QtGui/QShowEvent>
#include <QtGui/QIcon>
#include <QtCore/QBasicTimer>
#include <QtGui/QAction>
#include <phonon/audiooutput.h>
#include <phonon/backendcapabilities.h>
#include <phonon/effect.h>
#include <phonon/effectparameter.h>
#include <phonon/effectwidget.h>
#include <phonon/mediaobject.h>
#include <phonon/seekslider.h>
#include <phonon/videowidget.h>
#include <phonon/volumeslider.h>
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();
protected:
void resizeEvent(QResizeEvent* pEvent);
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;
};
class UBDraggableMediaPlayer : public UBMediaPlayer
{
Q_OBJECT
public:
UBDraggableMediaPlayer();
void setFile(const QString &text);
protected:
QString mSourcePath;
void mousePressEvent(QMouseEvent *event);
};
#endif // UBUBMediaPlayer_H
...@@ -14,9 +14,12 @@ ...@@ -14,9 +14,12 @@
*/ */
#include "UBPageNavigationWidget.h" #include "UBPageNavigationWidget.h"
#include "core/UBApplication.h" #include "core/UBApplication.h"
#include "board/UBBoardController.h"
#include "core/memcheck.h" #include "core/memcheck.h"
#include "board/UBBoardController.h"
#include "globals/UBGlobals.h"
/** /**
* \brief Constructor * \brief Constructor
* @param parent as the parent widget * @param parent as the parent widget
...@@ -32,8 +35,8 @@ UBPageNavigationWidget::UBPageNavigationWidget(QWidget *parent, const char *name ...@@ -32,8 +35,8 @@ UBPageNavigationWidget::UBPageNavigationWidget(QWidget *parent, const char *name
setObjectName(name); setObjectName(name);
mName = "PageNavigator"; mName = "PageNavigator";
mVisibleState = true; mVisibleState = true;
setAttribute(Qt::WA_StyledBackground, true);
setStyleSheet(UBApplication::globalStyleSheet()); SET_STYLE_SHEET();
mIconToRight = QPixmap(":images/pages_open.png"); mIconToRight = QPixmap(":images/pages_open.png");
mIconToLeft = QPixmap(":images/pages_close.png"); mIconToLeft = QPixmap(":images/pages_close.png");
......
#include <QApplication>
#include <QStyleOptionButton>
#include <QStyledItemDelegate>
#include <QStyleOptionViewItem>
#include <QPainter>
#include <QModelIndex>
#include "UBTGWidgetTreeDelegate.h"
UBTGWidgetTreeDelegate::UBTGWidgetTreeDelegate(QObject *parent) :
QStyledItemDelegate(parent)
{
//NOOP
}
void UBTGWidgetTreeDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const
{
if(index.data(Qt::UserRole) != eUBTGAddSubItemWidgetType_None){
painter->setBackgroundMode(Qt::OpaqueMode);
painter->setBackground(QBrush(QColor(Qt::red)));
QStyleOptionButton styleButton;
styleButton.text = "pipo";
styleButton.rect = option.rect;
QApplication::style()->drawControl(QStyle::CE_PushButtonLabel,&styleButton,painter);
}
else
QStyledItemDelegate::paint(painter,option,index);
}
QSize UBTGWidgetTreeDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
{
QSize size = QStyledItemDelegate::sizeHint(option,index);
return size;
}
#ifndef UBTGWIDGETTREEDELEGATE_H
#define UBTGWIDGETTREEDELEGATE_H
class QPainter;
class QStyleOptionViewItem;
class QModelIndex;
#include <QStyledItemDelegate>
typedef enum
{
eUBTGAddSubItemWidgetType_None,
eUBTGAddSubItemWidgetType_Action ,
eUBTGAddSubItemWidgetType_Media,
eUBTGAddSubItemWidgetType_Url
}eUBTGAddSubItemWidgetType;
class UBTGWidgetTreeDelegate : public QStyledItemDelegate
{
Q_OBJECT
public:
explicit UBTGWidgetTreeDelegate(QObject *parent = 0);
virtual void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const;
virtual QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const;
signals:
public slots:
};
#endif // UBTGWIDGETTREEDELEGATE_H
#include "UBTeacherGuideDelegate.h"
UBTeacherGuideDelegate::UBTeacherGuideDelegate()
{
}
#ifndef UBTEACHERGUIDEDELEGATE_H
#define UBTEACHERGUIDEDELEGATE_H
class UBTeacherGuideDelegate
{
public:
UBTeacherGuideDelegate();
};
#endif // UBTEACHERGUIDEDELEGATE_H
This diff is collapsed.
/*
* 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 <http://www.gnu.org/licenses/>.
*/
#ifndef UBTEACHERGUIDEWIDGET_H
#define UBTEACHERGUIDEWIDGET_H
class QTreeWidget;
class QHeaderView;
class QLabel;
class QVBoxLayout;
class QPushButton;
#include "UBTeacherGuideWidgetsTools.h"
#include "UBTGWidgetTreeDelegate.h"
/***************************************************************************
* class UBTeacherGuideEditionWidget *
***************************************************************************/
class UBTeacherGuideEditionWidget : public QWidget
{
Q_OBJECT
public:
explicit UBTeacherGuideEditionWidget(QWidget* parent = 0, const char* name="UBTeacherGuideEditionWidget");
~UBTeacherGuideEditionWidget();
void cleanData();
QVector<tUBGEElementNode*> getData();
public slots:
void onAddItemClicked(QTreeWidgetItem* widget, int column);
void onActiveSceneChanged();
void showEvent(QShowEvent* event);
private:
QList<QTreeWidgetItem*> getChildrenList(QTreeWidgetItem* widgetItem);
QVector<tUBGEElementNode*> getPageAndCommentData();
QVBoxLayout* mpLayout;
QLabel* mpDocumentTitle;
QLabel* mpPageNumberLabel;
UBTGAdaptableText* mpPageTitle;
UBTGAdaptableText* mpComment;
QFrame* mpSeparator;
QTreeWidget* mpTreeWidget;
QTreeWidgetItem* mpRootWidgetItem;
UBAddItem* mpAddAnActionItem;
UBAddItem* mpAddAMediaItem;
UBAddItem* mpAddALinkItem;
UBTGWidgetTreeDelegate* mpTreeDelegate;
};
/***************************************************************************
* class UBTeacherGuidePresentationWidget *
***************************************************************************/
class UBTeacherGuidePresentationWidget : public QWidget
{
Q_OBJECT
public:
explicit UBTeacherGuidePresentationWidget(QWidget* parent, const char* name = "UBTeacherGuidePresentationName");
~UBTeacherGuidePresentationWidget();
void showData(QVector<tUBGEElementNode*>data);
void cleanData();
public slots:
void onAddItemClicked(QTreeWidgetItem* widget, int column);
void onActiveSceneChanged();
private:
void createMediaButtonItem();
UBTGAdaptableText* mpPageTitle;
UBTGAdaptableText* mpComment;
QVBoxLayout* mpLayout;
QHBoxLayout* mpButtonTitleLayout;
QLabel* mpDocumentTitle;
QLabel* mpPageNumberLabel;
QFrame* mpSeparator;
QPushButton* mpModePushButton;
QTreeWidget* mpTreeWidget;
QTreeWidgetItem* mpRootWidgetItem;
QTreeWidgetItem* mpMediaSwitchItem;
};
/***************************************************************************
* class UBTeacherGuideWidget *
***************************************************************************/
class UBTeacherGuideWidget : public QStackedWidget
{
Q_OBJECT
public:
explicit UBTeacherGuideWidget(QWidget* parent = 0, const char* name="UBTeacherGuideWidget");
~UBTeacherGuideWidget();
public slots:
void changeMode();
void showPresentationMode();
void connectToStylusPalette();
private:
UBTeacherGuideEditionWidget* mpEditionWidget;
UBTeacherGuidePresentationWidget* mpPresentationWidget;
QVector<tUBGEElementNode*>mCurrentData;
};
#endif // UBTEACHERGUIDEWIDGET_H
This diff is collapsed.
/*
* 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 <http://www.gnu.org/licenses/>.
*/
#ifndef UBTEACHERGUIDEWIDGETSTOOLS_H
#define UBTEACHERGUIDEWIDGETSTOOLS_H
#include <QObject>
#include <QTreeWidgetItem>
#include <QTextEdit>
#include <QLabel>
#include <QDragEnterEvent>
#include <QDropEvent>
#include <QLineEdit>
#include <QMimeData>
#include <QStackedWidget>
#include <QWebView>
#include "customWidgets/UBMediaWidget.h"
class QTreeWidget;
class QVBoxLayout;
class QComboBox;
class QTextEdit;
class QWidget;
class UBTGAdaptableText;
class QDomElement;
typedef struct
{
QString type;
QMap<QString,QString> attributes;
}tUBGEElementNode;
class iUBTGSavableData
{
public:
virtual tUBGEElementNode* saveData() = 0;
};
class UBAddItem : public QTreeWidgetItem
{
public:
explicit UBAddItem(const QString &strings, int addSubItemWidgetType, QTreeWidget* parent = 0);
~UBAddItem();
signals:
public slots:
};
class UBTGActionWidget : public QWidget, public iUBTGSavableData
{
Q_OBJECT
public:
explicit UBTGActionWidget(QTreeWidgetItem* widget, QWidget* parent = 0,const char* name = "UBTGActionWidget");
~UBTGActionWidget();
void update();
tUBGEElementNode* saveData();
private:
QVBoxLayout* mpLayout;
QComboBox* mpOwner;
UBTGAdaptableText* mpTask;
protected:
QTreeWidgetItem* mpTreeWidgetItem;
};
class UBTGAdaptableText : public QTextEdit
{
Q_OBJECT
public:
explicit UBTGAdaptableText(QTreeWidgetItem* widget = 0, QWidget *parent = 0, const char* name = "UBTGAdaptableText");
void showText(const QString & text);
void bottomMargin(int newValue);
void setPlaceHolderText(QString text);
QString text();
public slots:
void onTextChanged();
protected:
void focusInEvent(QFocusEvent *e);
void focusOutEvent(QFocusEvent *e);
private:
int mBottomMargin;
QTreeWidgetItem* mpTreeWidgetItem;
int mMinimumHeight;
bool mHasPlaceHolder;
QString mPlaceHolderText;
};
class UBTGMediaWidget : public QStackedWidget , public iUBTGSavableData
{
Q_OBJECT
public:
UBTGMediaWidget(QTreeWidgetItem* widget = 0, QWidget* parent = 0, const char* name = "UBTGMediaWidget");
UBTGMediaWidget(QString relativePath, QTreeWidgetItem* widget = 0, QWidget* parent = 0, const char* name = "UBTGMediaWidget");
~UBTGMediaWidget();
tUBGEElementNode* saveData();
protected:
void dragEnterEvent(QDragEnterEvent* event);
void dropEvent(QDropEvent* event);
void mousePressEvent(QMouseEvent* event);
private:
void parseMimeData(const QMimeData* pMimeData);
void createWorkWidget(QString& path);
void updateSize();
QTreeWidgetItem* mpTreeWidgetItem;
QLabel* mpDropMeWidget;
QWidget* mpWorkWidget;
QVBoxLayout* mpLayout;
UBTGAdaptableText* mpTitle;
QLabel* mpMediaLabelWidget;
UBMediaWidget* mpMediaWidget;
QWebView* mpWebView;
QString mRelativePath;
bool mIsPresentationMode;
QString mMediaType;
};
class UBTGUrlWidget : public QWidget , public iUBTGSavableData
{
Q_OBJECT
public:
UBTGUrlWidget(QWidget* parent = 0, const char* name = "UBTGUrlWidget");
~UBTGUrlWidget();
tUBGEElementNode* saveData();
private:
QVBoxLayout* mpLayout;
QLineEdit* mpTitle;
QLineEdit* mpUrl;
};
#endif // UBTEACHERGUIDEWIDGETSTOOLS_H
...@@ -243,7 +243,7 @@ void UBThumbnailWidget::mousePressEvent(QMouseEvent *event) ...@@ -243,7 +243,7 @@ void UBThumbnailWidget::mousePressEvent(QMouseEvent *event)
if (Qt::ControlModifier & event->modifiers() || Qt::ShiftModifier & event->modifiers()) if (Qt::ControlModifier & event->modifiers() || Qt::ShiftModifier & event->modifiers())
{ {
mSelectedThumbnailItems = selectedItems(); // mSelectedThumbnailItems = selectedItems().toSet();
return; return;
} }
...@@ -261,7 +261,7 @@ void UBThumbnailWidget::mousePressEvent(QMouseEvent *event) ...@@ -261,7 +261,7 @@ void UBThumbnailWidget::mousePressEvent(QMouseEvent *event)
int index2 = mGraphicItems.indexOf(underlyingItem); int index2 = mGraphicItems.indexOf(underlyingItem);
if (-1 == index2) if (-1 == index2)
{ {
mSelectedThumbnailItems = selectedItems(); mSelectedThumbnailItems = selectedItems().toSet();
return; return;
} }
mSelectionSpan = index2 - index1; mSelectionSpan = index2 - index1;
...@@ -300,40 +300,64 @@ void UBThumbnailWidget::mouseMoveEvent(QMouseEvent *event) ...@@ -300,40 +300,64 @@ void UBThumbnailWidget::mouseMoveEvent(QMouseEvent *event)
if (mLassoRectItem) if (mLassoRectItem)
{ {
bSelectionInProgress = true; bSelectionInProgress = true;
int incrementLassoMinWidth = 2;
QPointF currentScenePos = mapToScene(event->pos()); QPointF currentScenePos = mapToScene(event->pos());
QRectF lassoRect( QRectF lassoRect(
qMin(mMousePressScenePos.x(), currentScenePos.x()), qMin(mMousePressScenePos.y(), currentScenePos.y()), qMin(mMousePressScenePos.x(), currentScenePos.x()), qMin(mMousePressScenePos.y(), currentScenePos.y()),
qAbs(mMousePressScenePos.x() - currentScenePos.x()), qAbs(mMousePressScenePos.y() - currentScenePos.y())); qAbs(mMousePressScenePos.x() - currentScenePos.x()), qAbs(mMousePressScenePos.y() - currentScenePos.y()));
QRectF incrementXSelection(
qMin(prevMoveMousePos.x(), currentScenePos.x()), qMin(mMousePressScenePos.y(), currentScenePos.y()),
qAbs(prevMoveMousePos.x() - currentScenePos.x())+incrementLassoMinWidth, qAbs(mMousePressScenePos.y() - currentScenePos.y()));
QRectF incrementYSelection(
qMin(mMousePressScenePos.x(), currentScenePos.x()), qMin(prevMoveMousePos.y(), currentScenePos.y()),
qAbs(mMousePressScenePos.x() - currentScenePos.x()), qAbs(prevMoveMousePos.y() - currentScenePos.y())+incrementLassoMinWidth);
prevMoveMousePos = currentScenePos;
mLassoRectItem->setRect(lassoRect); mLassoRectItem->setRect(lassoRect);
QList<QGraphicsItem*> lassoSelectedItems = scene()->items(lassoRect, Qt::IntersectsItemBoundingRect);
QList<QGraphicsItem*> lassoSelectedThumbnailItems; QSet<QGraphicsItem*> incSelectedItems = scene()->items(incrementXSelection, Qt::IntersectsItemBoundingRect).toSet()
foreach (QGraphicsItem *lassoSelectedItem, lassoSelectedItems) + scene()->items(incrementYSelection, Qt::IntersectsItemBoundingRect).toSet();
mPreviouslyIncrementalSelectedItems = incSelectedItems;
QSet<QGraphicsItem*> lassoSelectedItems;
QSet<QGraphicsItem*> lassoSelectedThumbnailItems;
foreach (QGraphicsItem *lassoSelectedItem, incSelectedItems)
{
if (lassoSelectedItem)
{ {
UBThumbnail *thumbnailItem = dynamic_cast<UBThumbnail*>(lassoSelectedItem); UBSceneThumbnailPixmap *thumbnailItem = dynamic_cast<UBSceneThumbnailPixmap*>(lassoSelectedItem);
if (thumbnailItem) if (thumbnailItem)
lassoSelectedThumbnailItems.append(lassoSelectedItems); {
lassoSelectedItem->setSelected(true);
lassoSelectedThumbnailItems += lassoSelectedItem;
}
}
} }
unselectAll(); QSet<QGraphicsItem*> toUnset;
foreach (QGraphicsItem *lassoSelectedItem, lassoSelectedThumbnailItems) toUnset = mSelectedThumbnailItems - lassoSelectedThumbnailItems;
{ foreach(QGraphicsItem* item, toUnset)
if (Qt::ControlModifier & event->modifiers())
{ {
if (!mSelectedThumbnailItems.contains(lassoSelectedItem)) item->setSelected(false);
selectItemAt(mGraphicItems.indexOf(lassoSelectedItem), true);
} }
else
mSelectedThumbnailItems += lassoSelectedItems;
// foreach (QGraphicsItem *lassoSelectedItem, lassoSelectedThumbnailItems)
{ {
selectItemAt(mGraphicItems.indexOf(lassoSelectedItem), true);
}
} }
if (Qt::ControlModifier & event->modifiers()) if (Qt::ControlModifier & event->modifiers())
{ {
foreach (QGraphicsItem *selectedItem, mSelectedThumbnailItems) for (int i = 0; i < mSelectedThumbnailItems.count()-1; i++)
{ {
if (!lassoSelectedThumbnailItems.contains(selectedItem)) mSelectedThumbnailItems.values().at(i)->setSelected(true);
selectItemAt(mGraphicItems.indexOf(selectedItem), true); }
// foreach (QGraphicsItem *selectedItem, mSelectedThumbnailItems)
{
// selectedItem->setSelected(true);
} }
} }
} }
...@@ -609,14 +633,6 @@ void UBThumbnailWidget::selectAll() ...@@ -609,14 +633,6 @@ void UBThumbnailWidget::selectAll()
} }
} }
void UBThumbnailWidget::unselectAll()
{
foreach (QGraphicsItem* item, mGraphicItems)
{
item->setSelected(false);
}
}
int UBThumbnailWidget::rowCount() const int UBThumbnailWidget::rowCount() const
{ {
UBThumbnail *lastThumbnail = dynamic_cast<UBThumbnail*>(mGraphicItems.last()); UBThumbnail *lastThumbnail = dynamic_cast<UBThumbnail*>(mGraphicItems.last());
......
...@@ -93,7 +93,6 @@ class UBThumbnailWidget : public QGraphicsView ...@@ -93,7 +93,6 @@ class UBThumbnailWidget : public QGraphicsView
private: private:
void selectAll(); void selectAll();
void unselectAll();
void selectItems(int startIndex, int count); void selectItems(int startIndex, int count);
int rowCount() const; int rowCount() const;
int columnCount() const; int columnCount() const;
...@@ -106,6 +105,8 @@ class UBThumbnailWidget : public QGraphicsView ...@@ -106,6 +105,8 @@ class UBThumbnailWidget : public QGraphicsView
QString mMimeType; QString mMimeType;
QPointF prevMoveMousePos;
qreal mThumbnailWidth; qreal mThumbnailWidth;
qreal mThumbnailHeight; qreal mThumbnailHeight;
qreal mSpacing; qreal mSpacing;
...@@ -113,7 +114,8 @@ class UBThumbnailWidget : public QGraphicsView ...@@ -113,7 +114,8 @@ class UBThumbnailWidget : public QGraphicsView
UBThumbnail *mLastSelectedThumbnail; UBThumbnail *mLastSelectedThumbnail;
int mSelectionSpan; int mSelectionSpan;
QGraphicsRectItem *mLassoRectItem; QGraphicsRectItem *mLassoRectItem;
QList<QGraphicsItem*> mSelectedThumbnailItems; QSet<QGraphicsItem*> mSelectedThumbnailItems;
QSet<QGraphicsItem*> mPreviouslyIncrementalSelectedItems;
QTime mClickTime; QTime mClickTime;
}; };
......
...@@ -46,7 +46,11 @@ HEADERS += src/gui/UBThumbnailView.h \ ...@@ -46,7 +46,11 @@ HEADERS += src/gui/UBThumbnailView.h \
src/gui/UBLibWebView.h \ src/gui/UBLibWebView.h \
src/gui/UBDownloadWidget.h \ src/gui/UBDownloadWidget.h \
src/gui/UBDockDownloadWidget.h \ src/gui/UBDockDownloadWidget.h \
src/gui/UBMediaPlayer.h src/gui/UBDockTeacherGuideWidget.h \
src/gui/UBTeacherGuideWidget.h \
src/gui/UBTeacherGuideWidgetsTools.h \
src/gui/UBTeacherGuideDelegate.h \
src/gui/UBTGWidgetTreeDelegate.h
SOURCES += src/gui/UBThumbnailView.cpp \ SOURCES += src/gui/UBThumbnailView.cpp \
src/gui/UBFloatingPalette.cpp \ src/gui/UBFloatingPalette.cpp \
...@@ -95,7 +99,11 @@ SOURCES += src/gui/UBThumbnailView.cpp \ ...@@ -95,7 +99,11 @@ SOURCES += src/gui/UBThumbnailView.cpp \
src/gui/UBLibWebView.cpp \ src/gui/UBLibWebView.cpp \
src/gui/UBDownloadWidget.cpp \ src/gui/UBDownloadWidget.cpp \
src/gui/UBDockDownloadWidget.cpp \ src/gui/UBDockDownloadWidget.cpp \
src/gui/UBMediaPlayer.cpp src/gui/UBDockTeacherGuideWidget.cpp \
src/gui/UBTeacherGuideWidget.cpp \
src/gui/UBTeacherGuideWidgetsTools.cpp \
src/gui/UBTeacherGuideDelegate.cpp \
src/gui/UBTGWidgetTreeDelegate.cpp
win32 { win32 {
...@@ -123,15 +131,3 @@ linux-g++-64 { ...@@ -123,15 +131,3 @@ linux-g++-64 {
SOURCES += src/gui/UBKeyboardPalette_linux.cpp SOURCES += src/gui/UBKeyboardPalette_linux.cpp
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment