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

preferencesAboutTextFull
Claudio Valerio 12 years ago
commit 2150f98a36
  1. 6
      resources/library/applications/GeoInfo.wgt/js/GeoInfo.js
  2. 2
      resources/library/applications/GeoInfo.wgt/js/soapclient.js
  3. 4
      resources/library/search/Image Planete.wgs/css/basic.css
  4. 0
      resources/library/search/Image Planete.wgs/images/down.png
  5. 0
      resources/library/search/Image Planete.wgs/images/greySquare.png
  6. 0
      resources/library/search/Image Planete.wgs/images/icon-close.png
  7. 0
      resources/library/search/Image Planete.wgs/images/popupBack.png
  8. 0
      resources/library/search/Image Planete.wgs/images/search.png
  9. 0
      resources/library/search/Image Planete.wgs/images/search_app.png
  10. 0
      resources/library/search/Image Planete.wgs/images/trgDown.png
  11. 0
      resources/library/search/Image Planete.wgs/images/trgUp.png
  12. 0
      resources/library/search/Image Planete.wgs/images/up.png
  13. 6
      resources/library/search/Image Planete.wgs/index.html
  14. 0
      resources/library/search/Image Planete.wgs/scripts/jquery-1.6.2.min.js
  15. BIN
      resources/library/videos/Sciences/video_bourgeon.flv
  16. BIN
      resources/library/videos/Sciences/video_bourgeon.mpg
  17. 10
      resources/style.qss
  18. 4
      src/adaptors/UBCFFSubsetAdaptor.cpp
  19. 1
      src/adaptors/UBSvgSubsetAdaptor.cpp
  20. 19
      src/board/UBBoardController.cpp
  21. 2
      src/board/UBBoardController.h
  22. 61
      src/board/UBBoardView.cpp
  23. 2
      src/board/UBBoardView.h
  24. 181
      src/board/UBFeaturesController.cpp
  25. 17
      src/board/UBFeaturesController.h
  26. 3
      src/core/UB.h
  27. 35
      src/document/UBDocumentController.cpp
  28. 2
      src/document/UBDocumentController.h
  29. 48
      src/domain/UBAngleWidget.cpp
  30. 25
      src/domain/UBAngleWidget.h
  31. 54
      src/domain/UBGraphicsDelegateFrame.cpp
  32. 5
      src/domain/UBGraphicsDelegateFrame.h
  33. 25
      src/domain/UBGraphicsItemDelegate.cpp
  34. 3
      src/domain/UBGraphicsItemDelegate.h
  35. 19
      src/domain/UBGraphicsMediaItem.cpp
  36. 4
      src/domain/UBGraphicsMediaItem.h
  37. 12
      src/domain/UBGraphicsMediaItemDelegate.cpp
  38. 19
      src/domain/UBGraphicsScene.cpp
  39. 3
      src/domain/UBGraphicsScene.h
  40. 11
      src/domain/UBGraphicsStrokesGroup.cpp
  41. 6
      src/domain/UBGraphicsWidgetItem.cpp
  42. 3
      src/domain/UBGraphicsWidgetItem.h
  43. 2
      src/domain/domain.pri
  44. 7
      src/gui/UBDockPalette.cpp
  45. 2
      src/gui/UBDockPalette.h
  46. 119
      src/gui/UBFeaturesWidget.cpp
  47. 30
      src/gui/UBFeaturesWidget.h
  48. 2
      src/gui/UBRubberBand.cpp
  49. 14
      src/gui/UBTeacherGuideWidget.cpp
  50. 4
      src/gui/UBTeacherGuideWidget.h
  51. 182
      src/gui/UBToolWidget.cpp
  52. 39
      src/gui/UBToolWidget.h
  53. 2
      src/podcast/quicktime/UBAudioQueueRecorder.cpp
  54. 2
      src/podcast/quicktime/UBQuickTimeFile.cpp
  55. 5
      src/web/UBWebController.cpp

@ -106,7 +106,8 @@ function popupInfo(text)
// affiche le text de l'erreur en cas de problème // affiche le text de l'erreur en cas de problème
function erreur(texteErreur) function erreur(texteErreur)
{ {
alert(texteErreur); //alert(texteErreur);
sankore.showMessage(texteErreur);
} }
// permet d'appeller la fonction pour recevoir les statistiques du serveur // permet d'appeller la fonction pour recevoir les statistiques du serveur
@ -136,7 +137,8 @@ function recevoirStatsReponse(resultat, soapResponse)
+ "\n" + "\n"
+ "Version de l'application: " + objDomTree.getElements("env:Body")[0].getElements("ser:getInfosResponse")[0].getElements("GeoStats")[0].getElements("version")[0].getText()); + "Version de l'application: " + objDomTree.getElements("env:Body")[0].getElements("ser:getInfosResponse")[0].getElements("GeoStats")[0].getElements("version")[0].getText());
alert(stats); //alert(stats);
sankore.showMessage(stats);
} }
// permet d'appeller la fonction pour recevoir les informations du pays // permet d'appeller la fonction pour recevoir les informations du pays

@ -155,7 +155,7 @@ SOAPClient._onLoadWsdl = function(url, method, parameters, async, callback, req)
} }
SOAPClient._sendSoapRequest = function(url, method, parameters, async, callback, wsdl) SOAPClient._sendSoapRequest = function(url, method, parameters, async, callback, wsdl)
{ {
alert(); //alert();
// get namespace // get namespace
var ns = (wsdl.documentElement.attributes["targetNamespace"] + "" == "undefined") ? wsdl.documentElement.attributes.getNamedItem("targetNamespace").nodeValue : wsdl.documentElement.attributes["targetNamespace"].value; var ns = (wsdl.documentElement.attributes["targetNamespace"] + "" == "undefined") ? wsdl.documentElement.attributes.getNamedItem("targetNamespace").nodeValue : wsdl.documentElement.attributes["targetNamespace"].value;
// build SOAP request // build SOAP request

@ -154,6 +154,10 @@ a {
vertical-align: top; vertical-align: top;
} }
.imgContainer img{
max-width: 150px;
max-height:150px;
}
.filterContainer{ .filterContainer{
float: left; float: left;

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Before

Width:  |  Height:  |  Size: 214 B

After

Width:  |  Height:  |  Size: 214 B

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

Before

Width:  |  Height:  |  Size: 931 B

After

Width:  |  Height:  |  Size: 931 B

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Before

Width:  |  Height:  |  Size: 475 B

After

Width:  |  Height:  |  Size: 475 B

Before

Width:  |  Height:  |  Size: 448 B

After

Width:  |  Height:  |  Size: 448 B

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

@ -8,7 +8,7 @@
<script type="text/javascript"> <script type="text/javascript">
var category = "image"; var category = "image";
var thumbnails = true; var thumbnails = true;
var minHeight = 180; var minHeight = 150;
var minWidth = 150; var minWidth = 150;
var currentIndex = 0; var currentIndex = 0;
@ -78,12 +78,12 @@
// There is also a result.file property which has the escaped version // There is also a result.file property which has the escaped version
if (thumbnails) { if (thumbnails) {
newImg.src = result.file; newImg.src = result.file;
if(result.height >= result.width) /*if(result.height >= result.width)
newImg.height = minHeight; newImg.height = minHeight;
else{ else{
newImg.width = minWidth; newImg.width = minWidth;
//newImg.style.margin = (120 - result.height)/2 + "px 0"; //newImg.style.margin = (120 - result.height)/2 + "px 0";
} }*/
} else { } else {
newImg.src = "./images/thumbnail_icon.png"; newImg.src = "./images/thumbnail_icon.png";
} }

@ -70,6 +70,16 @@ QLabel#UBTGMediaDropMeLabel
padding: 2px; padding: 2px;
} }
QComboBox#DockPaletteWidgetComboBox QAbstractItemView
{
background-color: white;
color: black;
selection-background-color: lightgreen;
selection-color: black;
}
QComboBox#DockPaletteWidgetComboBox QComboBox#DockPaletteWidgetComboBox
{ {
background: white; background: white;

@ -1049,10 +1049,6 @@ void UBCFFSubsetAdaptor::UBCFFSubsetReader::repositionSvgItem(QGraphicsItem *ite
QTransform rTransform; QTransform rTransform;
QPointF newVector = rTransform.map(oldVector); QPointF newVector = rTransform.map(oldVector);
QRectF sr = mCurrentScene->sceneRect();
QRectF sr1 = mCurrentSceneRect;
QRectF sr2 = mCurrentScene->normalizedSceneRect();
QTransform tr = item->sceneTransform(); QTransform tr = item->sceneTransform();
item->setTransform(rTransform.scale(fullScaleX, fullScaleY), true); item->setTransform(rTransform.scale(fullScaleX, fullScaleY), true);
tr = item->sceneTransform(); tr = item->sceneTransform();

@ -591,6 +591,7 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
if(strokesGroup){ if(strokesGroup){
polygonItem->setTransform(strokesGroup->transform()); polygonItem->setTransform(strokesGroup->transform());
strokesGroup->addToGroup(polygonItem); strokesGroup->addToGroup(polygonItem);
polygonItem->setStrokesGroup(strokesGroup);
} }
}else{ }else{
mScene->addItem(polygonItem); mScene->addItem(polygonItem);

@ -544,7 +544,8 @@ void UBBoardController::duplicateItem(UBItem *item)
QGraphicsItem *commonItem = dynamic_cast<QGraphicsItem*>(item); QGraphicsItem *commonItem = dynamic_cast<QGraphicsItem*>(item);
if (commonItem) if (commonItem)
{ {
itemPos = commonItem->pos(); qreal shifting = UBSettings::settings()->objectFrameWidth;
itemPos = commonItem->pos() + QPointF(shifting,shifting);
itemSize = commonItem->boundingRect().size(); itemSize = commonItem->boundingRect().size();
} }
@ -612,6 +613,10 @@ void UBBoardController::duplicateItem(UBItem *item)
{ {
createdItem->setSourceUrl(item->sourceUrl()); createdItem->setSourceUrl(item->sourceUrl());
item->copyItemParameters(createdItem); item->copyItemParameters(createdItem);
QGraphicsItem *createdGitem = dynamic_cast<QGraphicsItem*>(createdItem);
if (createdGitem)
createdGitem->setPos(itemPos);
} }
} }
@ -954,12 +959,12 @@ UBItem *UBBoardController::downloadFinished(bool pSuccess, QUrl sourceUrl, QStri
if (!pSuccess) if (!pSuccess)
{ {
UBApplication::showMessage(tr("Downloading content %1 failed").arg(sourceUrl.toString())); showMessage(tr("Downloading content %1 failed").arg(sourceUrl.toString()));
return NULL; return NULL;
} }
if (!sourceUrl.toString().startsWith("file://") && !sourceUrl.toString().startsWith("uniboardTool://")) if (!sourceUrl.toString().startsWith("file://") && !sourceUrl.toString().startsWith("uniboardTool://"))
UBApplication::showMessage(tr("Download finished")); showMessage(tr("Download finished"));
if (UBMimeType::RasterImage == itemMimeType) if (UBMimeType::RasterImage == itemMimeType)
{ {
@ -1237,7 +1242,7 @@ UBItem *UBBoardController::downloadFinished(bool pSuccess, QUrl sourceUrl, QStri
} }
else else
{ {
UBApplication::showMessage(tr("Unknown tool type %1").arg(sourceUrl.toString())); showMessage(tr("Unknown tool type %1").arg(sourceUrl.toString()));
} }
} }
else if (sourceUrl.toString().contains("edumedia-sciences.com")) else if (sourceUrl.toString().contains("edumedia-sciences.com"))
@ -1292,7 +1297,7 @@ UBItem *UBBoardController::downloadFinished(bool pSuccess, QUrl sourceUrl, QStri
} }
else else
{ {
UBApplication::showMessage(tr("Unknown content type %1").arg(pContentTypeHeader)); showMessage(tr("Unknown content type %1").arg(pContentTypeHeader));
qWarning() << "ignoring mime type" << pContentTypeHeader ; qWarning() << "ignoring mime type" << pContentTypeHeader ;
} }
@ -1484,8 +1489,12 @@ void UBBoardController::boardViewResized(QResizeEvent* event)
mControlView->centerOn(0,0); mControlView->centerOn(0,0);
if (mDisplayView)
mDisplayView->centerOn(0,0);
mPaletteManager->containerResized(); mPaletteManager->containerResized();
UBApplication::boardController->controlView()->scene()->moveMagnifier();
} }

@ -193,7 +193,7 @@ class UBBoardController : public UBDocumentContainer
UBItem *downloadFinished(bool pSuccess, QUrl sourceUrl, QString pHeader, QByteArray pData, QPointF pPos, QSize pSize, bool isBackground = false); UBItem *downloadFinished(bool pSuccess, QUrl sourceUrl, QString pHeader, QByteArray pData, QPointF pPos, QSize pSize, bool isBackground = false);
void changeBackground(bool isDark, bool isCrossed); void changeBackground(bool isDark, bool isCrossed);
void setToolCursor(int tool); void setToolCursor(int tool);
void showMessage(const QString& message, bool showSpinningWheel); void showMessage(const QString& message, bool showSpinningWheel = false);
void hideMessage(); void hideMessage();
void setDisabled(bool disable); void setDisabled(bool disable);
void setColorIndex(int pColorIndex); void setColorIndex(int pColorIndex);

@ -71,6 +71,7 @@ UBBoardView::UBBoardView (UBBoardController* pController, QWidget* pParent)
, suspendedMousePressEvent(NULL) , suspendedMousePressEvent(NULL)
, mLongPressInterval(1000) , mLongPressInterval(1000)
, mIsDragInProgress(false) , mIsDragInProgress(false)
, mMultipleSelectionIsEnabled(false)
{ {
init (); init ();
@ -86,6 +87,7 @@ UBBoardView::UBBoardView (UBBoardController* pController, int pStartLayer, int p
, suspendedMousePressEvent(NULL) , suspendedMousePressEvent(NULL)
, mLongPressInterval(1000) , mLongPressInterval(1000)
, mIsDragInProgress(false) , mIsDragInProgress(false)
, mMultipleSelectionIsEnabled(false)
{ {
init (); init ();
@ -206,6 +208,11 @@ UBBoardView::keyPressEvent (QKeyEvent *event)
mController->addScene (); mController->addScene ();
break; break;
} }
case Qt::Key_Control:
case Qt::Key_Shift:
{
mMultipleSelectionIsEnabled = true;
}break;
} }
@ -266,6 +273,21 @@ UBBoardView::keyPressEvent (QKeyEvent *event)
} }
} }
void UBBoardView::keyReleaseEvent(QKeyEvent *event)
{
// if (!event->isAccepted ())
{
if (Qt::Key_Shift == event->key()
||Qt::Key_Control == event->key())
{
mMultipleSelectionIsEnabled = false;
}
}
QGraphicsView::keyReleaseEvent(event);
}
bool bool
UBBoardView::event (QEvent * e) UBBoardView::event (QEvent * e)
{ {
@ -424,7 +446,10 @@ bool UBBoardView::itemShouldReceiveMousePressEvent(QGraphicsItem *item)
UBStylusTool::Enum currentTool = (UBStylusTool::Enum)UBDrawingController::drawingController()->stylusTool(); UBStylusTool::Enum currentTool = (UBStylusTool::Enum)UBDrawingController::drawingController()->stylusTool();
if ((currentTool == UBStylusTool::Play) && UBGraphicsGroupContainerItem::Type == movingItem->type()) if ((currentTool == UBStylusTool::Play) && UBGraphicsGroupContainerItem::Type == movingItem->type())
return movingItem == NULL; {
movingItem = NULL;
return false;
}
switch(item->type()) switch(item->type())
{ {
@ -532,11 +557,7 @@ bool UBBoardView::itemShouldBeMoved(QGraphicsItem *item)
return true; return true;
case UBGraphicsTextItem::Type: case UBGraphicsTextItem::Type:
return !item->isSelected(); return !item->isSelected();
default:
return false;
} }
return false; return false;
} }
@ -577,7 +598,8 @@ void UBBoardView::handleItemMousePress(QMouseEvent *event)
if (movingItem && QGraphicsSvgItem::Type != movingItem->type() if (movingItem && QGraphicsSvgItem::Type != movingItem->type()
&& UBGraphicsDelegateFrame::Type != movingItem->type()) && UBGraphicsDelegateFrame::Type != movingItem->type()
&& !mMultipleSelectionIsEnabled)
{ {
foreach(QGraphicsItem *item, scene()->selectedItems()) foreach(QGraphicsItem *item, scene()->selectedItems())
{ {
@ -588,6 +610,9 @@ void UBBoardView::handleItemMousePress(QMouseEvent *event)
} }
} }
if (mMultipleSelectionIsEnabled)
return;
if (itemShouldReceiveMousePressEvent(movingItem)) if (itemShouldReceiveMousePressEvent(movingItem))
QGraphicsView::mousePressEvent (event); QGraphicsView::mousePressEvent (event);
else else
@ -945,6 +970,7 @@ UBBoardView::mouseReleaseEvent (QMouseEvent *event)
if (currentTool == UBStylusTool::Selector) if (currentTool == UBStylusTool::Selector)
{ {
bool bReleaseIsNeed = true;
if (mWidgetMoved) if (mWidgetMoved)
{ {
mWidgetMoved = false; mWidgetMoved = false;
@ -962,18 +988,34 @@ UBBoardView::mouseReleaseEvent (QMouseEvent *event)
} }
else else
{ {
if ( QGraphicsSvgItem::Type != movingItem->type() if (QGraphicsSvgItem::Type != movingItem->type() &&
&& UBGraphicsDelegateFrame::Type != movingItem->type()) UBGraphicsDelegateFrame::Type != movingItem->type() &&
UBToolWidget::Type != movingItem->type())
{
bReleaseIsNeed = false;
if (movingItem->isSelected() && mMultipleSelectionIsEnabled)
movingItem->setSelected(false);
else
{
if (movingItem->isSelected())
bReleaseIsNeed = true;
movingItem->setSelected(true); movingItem->setSelected(true);
} }
}
}
} }
if (mUBRubberBand && mUBRubberBand->isVisible()) { if (mUBRubberBand && mUBRubberBand->isVisible()) {
mUBRubberBand->hide(); mUBRubberBand->hide();
} }
if (bReleaseIsNeed)
{
QGraphicsView::mouseReleaseEvent (event); QGraphicsView::mouseReleaseEvent (event);
} }
}
else if (currentTool == UBStylusTool::Play) else if (currentTool == UBStylusTool::Play)
{ {
if (mWidgetMoved) if (mWidgetMoved)
@ -990,9 +1032,8 @@ UBBoardView::mouseReleaseEvent (QMouseEvent *event)
delete suspendedMousePressEvent; delete suspendedMousePressEvent;
suspendedMousePressEvent = NULL; suspendedMousePressEvent = NULL;
} }
QGraphicsView::mouseReleaseEvent (event);
} }
QGraphicsView::mouseReleaseEvent (event);
} }
else if (currentTool == UBStylusTool::Text) else if (currentTool == UBStylusTool::Text)
{ {

@ -65,6 +65,7 @@ class UBBoardView : public QGraphicsView
virtual bool event (QEvent * e); virtual bool event (QEvent * e);
virtual void keyPressEvent(QKeyEvent *event); virtual void keyPressEvent(QKeyEvent *event);
virtual void keyReleaseEvent(QKeyEvent *event);
virtual void tabletEvent(QTabletEvent * event); virtual void tabletEvent(QTabletEvent * event);
virtual void mouseDoubleClickEvent(QMouseEvent *event); virtual void mouseDoubleClickEvent(QMouseEvent *event);
virtual void mousePressEvent(QMouseEvent *event); virtual void mousePressEvent(QMouseEvent *event);
@ -145,6 +146,7 @@ class UBBoardView : public QGraphicsView
QTimer mLongPressTimer; QTimer mLongPressTimer;
bool mIsDragInProgress; bool mIsDragInProgress;
bool mMultipleSelectionIsEnabled;
private slots: private slots:

@ -21,7 +21,7 @@
const QString UBFeaturesController::virtualRootName = "root"; const QString UBFeaturesController::virtualRootName = "root";
void UBFeaturesComputingThread::scanFS(const QUrl & currentPath, const QString & currVirtualPath) void UBFeaturesComputingThread::scanFS(const QUrl & currentPath, const QString & currVirtualPath, const QSet<QUrl> &pFavoriteSet)
{ {
Q_ASSERT(QFileInfo(currentPath.toLocalFile()).exists()); Q_ASSERT(QFileInfo(currentPath.toLocalFile()).exists());
@ -47,27 +47,29 @@ void UBFeaturesComputingThread::scanFS(const QUrl & currentPath, const QString &
emit sendFeature(testFeature); emit sendFeature(testFeature);
emit featureSent(); emit featureSent();
emit scanPath(fullFileName);
// featuresList->append(testFeature); if ( pFavoriteSet.find(QUrl::fromLocalFile(fullFileName)) != pFavoriteSet.end()) {
//TODO send favoritePath from the controller or make favoritePath public and static
// if ( favoriteSet->find( QUrl::fromLocalFile( fullFileName ) ) != favoriteSet->end() ) { emit sendFeature(UBFeature( "/root/Favorites", icon, fileName, QUrl::fromLocalFile(fullFileName), featureType));
// featuresList->append( UBFeature( favoritePath, icon, fileName, QUrl::fromLocalFile( fullFileName ), featureType ) ); }
// }
if (featureType == FEATURE_FOLDER) { if (featureType == FEATURE_FOLDER) {
scanFS(QUrl::fromLocalFile(fullFileName), currVirtualPath + "/" + fileName); scanFS(QUrl::fromLocalFile(fullFileName), currVirtualPath + "/" + fileName, pFavoriteSet);
} }
} }
} }
void UBFeaturesComputingThread::scanAll(QList<QPair<QUrl, QString> > pScanningData) void UBFeaturesComputingThread::scanAll(QList<QPair<QUrl, QString> > pScanningData, const QSet<QUrl> &pFavoriteSet)
{ {
for (int i = 0; i < pScanningData.count(); i++) { for (int i = 0; i < pScanningData.count(); i++) {
if (abort) { if (abort) {
return; return;
} }
QPair<QUrl, QString> curPair = pScanningData.at(i); QPair<QUrl, QString> curPair = pScanningData.at(i);
scanFS(curPair.first, curPair.second);
emit scanCategory(UBFeaturesController::categoryNameForVirtualPath(curPair.second));
scanFS(curPair.first, curPair.second, pFavoriteSet);
} }
} }
@ -84,8 +86,6 @@ int UBFeaturesComputingThread::featuresCount(const QUrl &pPath)
if (featureType != FEATURE_INVALID && !fullFileName.contains(".thumbnail.")) { if (featureType != FEATURE_INVALID && !fullFileName.contains(".thumbnail.")) {
noItems++; noItems++;
} else {
continue;
} }
if (featureType == FEATURE_FOLDER) { if (featureType == FEATURE_FOLDER) {
@ -114,11 +114,12 @@ QThread(parent)
abort = false; abort = false;
} }
void UBFeaturesComputingThread::compute(const QList<QPair<QUrl, QString> > &pScanningData) void UBFeaturesComputingThread::compute(const QList<QPair<QUrl, QString> > &pScanningData, QSet<QUrl> *pFavoritesSet)
{ {
QMutexLocker curLocker(&mMutex); QMutexLocker curLocker(&mMutex);
mScanningData = pScanningData; mScanningData = pScanningData;
mFavoriteSet = *pFavoritesSet;
if (!isRunning()) { if (!isRunning()) {
start(LowPriority); start(LowPriority);
@ -135,6 +136,7 @@ void UBFeaturesComputingThread::run()
mMutex.lock(); mMutex.lock();
QList<QPair<QUrl, QString> > searchData = mScanningData; QList<QPair<QUrl, QString> > searchData = mScanningData;
QSet<QUrl> favoriteSet = mFavoriteSet;
mMutex.unlock(); mMutex.unlock();
if (abort) { if (abort) {
@ -152,7 +154,7 @@ void UBFeaturesComputingThread::run()
emit maxFilesCountEvaluated(fsCnt); emit maxFilesCountEvaluated(fsCnt);
emit scanStarted(); emit scanStarted();
scanAll(searchData); scanAll(searchData, favoriteSet);
emit scanFinished(); emit scanFinished();
mMutex.lock(); mMutex.lock();
@ -210,9 +212,12 @@ bool UBFeature::isFolder() const
|| elementType == FEATURE_FOLDER; || elementType == FEATURE_FOLDER;
} }
bool UBFeature::isDeletable()const bool UBFeature::isDeletable() const
{ {
return elementType == FEATURE_ITEM return elementType == FEATURE_ITEM
|| elementType == FEATURE_AUDIO
|| elementType == FEATURE_VIDEO
|| elementType == FEATURE_IMAGE
|| elementType == FEATURE_FOLDER; || elementType == FEATURE_FOLDER;
} }
@ -238,6 +243,7 @@ UBFeaturesController::UBFeaturesController(QWidget *pParentWidget) :
shapesPath = rootPath + "/Shapes"; shapesPath = rootPath + "/Shapes";
trashPath = rootPath + "/Trash"; trashPath = rootPath + "/Trash";
favoritePath = rootPath + "/Favorites"; favoritePath = rootPath + "/Favorites";
webSearchPath = rootPath + "/Web search";
//Initializing physical directories from UBSettings //Initializing physical directories from UBSettings
mUserAudioDirectoryPath = QUrl::fromLocalFile(UBSettings::settings()->userAudioDirectory()); mUserAudioDirectoryPath = QUrl::fromLocalFile(UBSettings::settings()->userAudioDirectory());
@ -295,11 +301,10 @@ UBFeaturesController::UBFeaturesController(QWidget *pParentWidget) :
connect(&mCThread, SIGNAL(scanStarted()), this, SIGNAL(scanStarted())); connect(&mCThread, SIGNAL(scanStarted()), this, SIGNAL(scanStarted()));
connect(&mCThread, SIGNAL(scanFinished()), this, SIGNAL(scanFinished())); connect(&mCThread, SIGNAL(scanFinished()), this, SIGNAL(scanFinished()));
connect(&mCThread, SIGNAL(maxFilesCountEvaluated(int)), this, SIGNAL(maxFilesCountEvaluated(int))); connect(&mCThread, SIGNAL(maxFilesCountEvaluated(int)), this, SIGNAL(maxFilesCountEvaluated(int)));
//Very unsafe function. Considering using deleteLater() instead connect(&mCThread, SIGNAL(scanCategory(QString)), this, SIGNAL(scanCategory(QString)));
// connect(qApp, SIGNAL(aboutToQuit()), &mCThread, SLOT(terminate())); connect(&mCThread, SIGNAL(scanPath(QString)), this, SIGNAL(scanPath(QString)));
QTimer::singleShot(0, this, SLOT(startThread())); QTimer::singleShot(0, this, SLOT(startThread()));
// startThread();
} }
void UBFeaturesController::startThread() void UBFeaturesController::startThread()
@ -323,7 +328,7 @@ void UBFeaturesController::startThread()
<< QPair<QUrl, QString>(trashDirectoryPath, trashPath) << QPair<QUrl, QString>(trashDirectoryPath, trashPath)
<< QPair<QUrl, QString>(mLibSearchDirectoryPath, rootPath + "/" + "Web search" ); << QPair<QUrl, QString>(mLibSearchDirectoryPath, rootPath + "/" + "Web search" );
mCThread.compute(computingData); mCThread.compute(computingData, favoriteSet);
} }
void UBFeaturesController::scanFS() void UBFeaturesController::scanFS()
@ -342,6 +347,7 @@ void UBFeaturesController::scanFS()
<< webSearchElement << webSearchElement
<< trashElement; << trashElement;
//filling favoriteList
loadFavoriteList(); loadFavoriteList();
QList <UBToolsManager::UBToolDescriptor> tools = UBToolsManager::manager()->allTools(); QList <UBToolsManager::UBToolDescriptor> tools = UBToolsManager::manager()->allTools();
@ -352,52 +358,7 @@ void UBFeaturesController::scanFS()
featuresList->append(UBFeature(favoritePath, tool.icon.toImage(), tool.label, QUrl(tool.id), FEATURE_INTERNAL)); featuresList->append(UBFeature(favoritePath, tool.icon.toImage(), tool.label, QUrl(tool.id), FEATURE_INTERNAL));
} }
} }
QTime time = QTime::currentTime();
//Claudio:
// don't change the order of the scans
// fileSystemScan( mLibAudiosDirectoryPath, audiosPath);
// fileSystemScan( mLibVideosDirectoryPath, moviesPath);
// fileSystemScan( mLibAnimationsDirectoryPath, flashPath);
// fileSystemScan( mLibPicturesDirectoryPath, picturesPath );
// fileSystemScan( mUserInteractiveDirectoryPath, appPath );
// fileSystemScan( mUserAudioDirectoryPath, audiosPath );
// fileSystemScan( mUserPicturesDirectoryPath, picturesPath );
// fileSystemScan( mUserVideoDirectoryPath, moviesPath );
// fileSystemScan( mUserAnimationDirectoryPath, flashPath );
// fileSystemScan( mLibApplicationsDirectoryPath, appPath );
// fileSystemScan( mLibShapesDirectoryPath, shapesPath );
// fileSystemScan( mLibInteractiveDirectoryPath, interactPath );
// fileSystemScan( trashDirectoryPath, trashPath );
// fileSystemScan( mLibSearchDirectoryPath, rootPath + "/" + "Web search" );
int i =0;
i += featuresCount(mLibAudiosDirectoryPath);
i += featuresCount(mLibVideosDirectoryPath);
i += featuresCount(mLibAnimationsDirectoryPath);
i += featuresCount(mLibPicturesDirectoryPath);
i += featuresCount(mUserInteractiveDirectoryPath);
i += featuresCount(mUserAudioDirectoryPath);
i += featuresCount(mUserPicturesDirectoryPath);
i += featuresCount(mUserVideoDirectoryPath);
i += featuresCount(mUserAnimationDirectoryPath);
i += featuresCount(mLibApplicationsDirectoryPath);
i += featuresCount(mLibShapesDirectoryPath);
i += featuresCount(mLibInteractiveDirectoryPath);
i += featuresCount(trashDirectoryPath);
i += featuresCount(mLibSearchDirectoryPath);
int msecs = QTime(time).msecsTo(QTime::currentTime());
qDebug() << "Loading library" << msecs << "msecs\nNumber of elements" << i;
// emit TopIndexingLimitSet(i);
// emit indexingProgressValueChanged(i / 4);
} }
void UBFeaturesController::fileSystemScan(const QUrl & currentPath, const QString & currVirtualPath) void UBFeaturesController::fileSystemScan(const QUrl & currentPath, const QString & currVirtualPath)
{ {
QFileInfoList fileInfoList = UBFileSystemUtils::allElementsInDirectory(currentPath.toLocalFile()); QFileInfoList fileInfoList = UBFileSystemUtils::allElementsInDirectory(currentPath.toLocalFile());
@ -492,7 +453,8 @@ void UBFeaturesController::addToFavorite( const QUrl &path )
{ {
QFileInfo fileInfo( filePath ); QFileInfo fileInfo( filePath );
QString fileName = fileInfo.fileName(); QString fileName = fileInfo.fileName();
UBFeature elem(favoritePath, getIcon( filePath, FEATURE_CATEGORY ), fileName, path, fileTypeFromUrl(filePath) ); UBFeatureElementType type = fileTypeFromUrl(fileInfo.absoluteFilePath());
UBFeature elem(favoritePath, getIcon(filePath, type), fileName, path, fileTypeFromUrl(filePath) );
favoriteSet->insert( path ); favoriteSet->insert( path );
saveFavoriteList(); saveFavoriteList();
@ -524,7 +486,7 @@ QString UBFeaturesController::fileNameFromUrl( const QUrl &url )
} }
UBFeatureElementType UBFeaturesController::fileTypeFromUrl( const QString &path ) UBFeatureElementType UBFeaturesController::fileTypeFromUrl(const QString &path)
{ {
QFileInfo fileInfo(path); QFileInfo fileInfo(path);
@ -535,7 +497,7 @@ UBFeatureElementType UBFeaturesController::fileTypeFromUrl( const QString &path
QString fileName = fileInfo.fileName(); QString fileName = fileInfo.fileName();
QString mimeString = UBFileSystemUtils::mimeTypeFromFileName(fileName); QString mimeString = UBFileSystemUtils::mimeTypeFromFileName(fileName);
UBFeatureElementType fileType = fileInfo.isDir() ? FEATURE_FOLDER : FEATURE_ITEM; UBFeatureElementType fileType = FEATURE_INVALID;
if ( mimeString.contains("application")) { if ( mimeString.contains("application")) {
if (mimeString.contains("application/search")) { if (mimeString.contains("application/search")) {
@ -545,6 +507,16 @@ UBFeatureElementType UBFeaturesController::fileTypeFromUrl( const QString &path
} }
} else if ( path.contains("uniboardTool://")) { } else if ( path.contains("uniboardTool://")) {
fileType = FEATURE_INTERNAL; fileType = FEATURE_INTERNAL;
} else if (mimeString.contains("audio")) {
fileType = FEATURE_AUDIO;
} else if (mimeString.contains("video")) {
fileType = FEATURE_VIDEO;
} else if (mimeString.contains("image")) {
fileType = FEATURE_IMAGE;
} else if (fileInfo.isDir()) {
fileType = FEATURE_FOLDER;
} else {
fileType = FEATURE_INVALID;
} }
return fileType; return fileType;
@ -554,64 +526,65 @@ QImage UBFeaturesController::getIcon(const QString &path, UBFeatureElementType p
{ {
if (pFType == FEATURE_FOLDER) { if (pFType == FEATURE_FOLDER) {
return QImage(":images/libpalette/folder.svg"); return QImage(":images/libpalette/folder.svg");
} else if (pFType == FEATURE_INTERACTIVE || pFType == FEATURE_SEARCH) {
} else if (pFType == FEATURE_INTERACTIVE) {
return QImage(UBGraphicsWidgetItem::iconFilePath(QUrl::fromLocalFile(path))); return QImage(UBGraphicsWidgetItem::iconFilePath(QUrl::fromLocalFile(path)));
} else if (pFType == FEATURE_INTERNAL) {
return QImage(UBToolsManager::manager()->iconFromToolId(path));
} else if (pFType == FEATURE_AUDIO) {
return QImage(":images/libpalette/soundIcon.svg");
} else if (pFType == FEATURE_VIDEO) {
return QImage(":images/libpalette/movieIcon.svg");
} else if (pFType == FEATURE_IMAGE) {
QImage pix(path);
if (pix.isNull()) {
pix = QImage(":images/libpalette/notFound.png");
} else {
pix = pix.scaledToWidth(qMin(UBSettings::maxThumbnailWidth, pix.width()));
} }
return pix;
if ( path.contains("uniboardTool://") ) {
return QImage( UBToolsManager::manager()->iconFromToolId(path) );
} if ( UBFileSystemUtils::mimeTypeFromFileName(path).contains("application")) {
return QImage( UBGraphicsWidgetItem::iconFilePath( QUrl::fromLocalFile(path) ) );
} }
QImage thumb; return QImage(":images/libpalette/notFound.png");
QString thumbnailPath = UBFileSystemUtils::thumbnailPath(path);
if ( QFileInfo( thumbnailPath ).exists() )
thumb = QImage( thumbnailPath );
else thumb = createThumbnail( path );
return thumb;
} }
bool UBFeaturesController::isDeletable( const QUrl &url ) bool UBFeaturesController::isDeletable( const QUrl &url )
{ {
UBFeatureElementType type = fileTypeFromUrl( fileNameFromUrl(url) ); UBFeatureElementType type = fileTypeFromUrl(fileNameFromUrl(url));
return type == FEATURE_ITEM; return type == FEATURE_AUDIO
|| type == FEATURE_VIDEO
|| type == FEATURE_IMAGE
|| type == FEATURE_ITEM;
}
QString UBFeaturesController::categoryNameForVirtualPath(const QString &str)
{
QString result;
int ind = str.lastIndexOf("/");
if (ind != -1) {
result = str.right(str.count() - ind - 1);
}
return result;
} }
QImage UBFeaturesController::createThumbnail(const QString &path) QImage UBFeaturesController::createThumbnail(const QString &path)
{ {
QString thumbnailPath = UBFileSystemUtils::thumbnailPath(path); QString thumbnailPath = path;
QString mimetype = UBFileSystemUtils::mimeTypeFromFileName(path); QString mimetype = UBFileSystemUtils::mimeTypeFromFileName(path);
QString extension = QFileInfo(path).completeSuffix();
if ( mimetype.contains("audio" )) if ( mimetype.contains("audio" )) {
thumbnailPath = ":images/libpalette/soundIcon.svg"; thumbnailPath = ":images/libpalette/soundIcon.svg";
else if ( mimetype.contains("video") ) } else if ( mimetype.contains("video")) {
thumbnailPath = ":images/libpalette/movieIcon.svg"; thumbnailPath = ":images/libpalette/movieIcon.svg";
else } else {
{
if ( extension.startsWith("svg", Qt::CaseInsensitive) || extension.startsWith("svgz", Qt::CaseInsensitive) )
{
thumbnailPath = path;
}
else
{
QImage pix(path); QImage pix(path);
if (!pix.isNull()) if (!pix.isNull()) {
{
pix = pix.scaledToWidth(qMin(UBSettings::maxThumbnailWidth, pix.width()), Qt::SmoothTransformation); pix = pix.scaledToWidth(qMin(UBSettings::maxThumbnailWidth, pix.width()), Qt::SmoothTransformation);
pix.save(thumbnailPath); return pix;
UBPlatformUtils::hideFile(thumbnailPath);
} } else {
else{
thumbnailPath = ":images/libpalette/notFound.png"; thumbnailPath = ":images/libpalette/notFound.png";
} }
}
} }
return QImage(thumbnailPath); return QImage(thumbnailPath);

@ -33,7 +33,7 @@ class UBFeaturesComputingThread : public QThread
public: public:
explicit UBFeaturesComputingThread(QObject *parent = 0); explicit UBFeaturesComputingThread(QObject *parent = 0);
virtual ~UBFeaturesComputingThread(); virtual ~UBFeaturesComputingThread();
void compute(const QList<QPair<QUrl, QString> > &pScanningData); void compute(const QList<QPair<QUrl, QString> > &pScanningData, QSet<QUrl> *pFavoritesSet);
protected: protected:
void run(); void run();
@ -44,12 +44,14 @@ signals:
void scanStarted(); void scanStarted();
void scanFinished(); void scanFinished();
void maxFilesCountEvaluated(int max); void maxFilesCountEvaluated(int max);
void scanCategory(const QString &str);
void scanPath(const QString &str);
public slots: public slots:
private: private:
void scanFS(const QUrl & currentPath, const QString & currVirtualPath); void scanFS(const QUrl & currentPath, const QString & currVirtualPath, const QSet<QUrl> &pFavoriteSet);
void scanAll(QList<QPair<QUrl, QString> > pScanningData); void scanAll(QList<QPair<QUrl, QString> > pScanningData, const QSet<QUrl> &pFavoriteSet);
int featuresCount(const QUrl &pPath); int featuresCount(const QUrl &pPath);
int featuresCountAll(QList<QPair<QUrl, QString> > pScanningData); int featuresCountAll(QList<QPair<QUrl, QString> > pScanningData);
@ -59,6 +61,7 @@ private:
QUrl mScanningPath; QUrl mScanningPath;
QString mScanningVirtualPath; QString mScanningVirtualPath;
QList<QPair<QUrl, QString> > mScanningData; QList<QPair<QUrl, QString> > mScanningData;
QSet<QUrl> mFavoriteSet;
bool restart; bool restart;
bool abort; bool abort;
}; };
@ -72,6 +75,9 @@ enum UBFeatureElementType
FEATURE_INTERACTIVE, FEATURE_INTERACTIVE,
FEATURE_INTERNAL, FEATURE_INTERNAL,
FEATURE_ITEM, FEATURE_ITEM,
FEATURE_AUDIO,
FEATURE_VIDEO,
FEATURE_IMAGE,
FEATURE_TRASH, FEATURE_TRASH,
FEATURE_FAVORITE, FEATURE_FAVORITE,
FEATURE_SEARCH, FEATURE_SEARCH,
@ -107,6 +113,7 @@ public:
private: private:
QString virtualDir; QString virtualDir;
QString virtualPath;
QImage mThumbnail; QImage mThumbnail;
QString mName; QString mName;
QUrl mPath; QUrl mPath;
@ -167,6 +174,7 @@ public:
static QImage getIcon( const QString &path, UBFeatureElementType pFType ); static QImage getIcon( const QString &path, UBFeatureElementType pFType );
static bool isDeletable( const QUrl &url ); static bool isDeletable( const QUrl &url );
static char featureTypeSplitter() {return ':';} static char featureTypeSplitter() {return ':';}
static QString categoryNameForVirtualPath(const QString &str);
static const QString virtualRootName; static const QString virtualRootName;
@ -178,6 +186,8 @@ signals:
void scanStarted(); void scanStarted();
void scanFinished(); void scanFinished();
void featureAddedFromThread(); void featureAddedFromThread();
void scanCategory(const QString &);
void scanPath(const QString &);
private slots: private slots:
void addNewFolder(QString name); void addNewFolder(QString name);
@ -233,6 +243,7 @@ private:
QString interactPath; QString interactPath;
QString trashPath; QString trashPath;
QString favoritePath; QString favoritePath;
QString webSearchPath;
int mLastItemOffsetIndex; int mLastItemOffsetIndex;
UBFeature currentElement; UBFeature currentElement;

@ -142,7 +142,8 @@ struct UBGraphicsItemType
TriangleItemType, TriangleItemType,
MagnifierItemType, MagnifierItemType,
cacheItemType, cacheItemType,
groupContainerType groupContainerType,
ToolWidgetItemType
}; };
}; };

@ -385,7 +385,12 @@ void UBDocumentController::setupViews()
mDocumentUI->thumbnailWidget->setBackgroundBrush(UBSettings::documentViewLightColor); mDocumentUI->thumbnailWidget->setBackgroundBrush(UBSettings::documentViewLightColor);
#ifdef Q_WS_MACX
mMessageWindow = new UBMessageWindow(NULL);
#else
mMessageWindow = new UBMessageWindow(mDocumentUI->thumbnailWidget); mMessageWindow = new UBMessageWindow(mDocumentUI->thumbnailWidget);
#endif
mMessageWindow->hide(); mMessageWindow->hide();
} }
@ -623,7 +628,7 @@ void UBDocumentController::deleteSelectedItem()
toBeDeleted << proxyTi; toBeDeleted << proxyTi;
} }
UBApplication::showMessage(tr("Emptying trash")); showMessage(tr("Emptying trash"));
for (int i = 0; i < toBeDeleted.count(); i++) for (int i = 0; i < toBeDeleted.count(); i++)
{ {
@ -633,7 +638,7 @@ void UBDocumentController::deleteSelectedItem()
UBPersistenceManager::persistenceManager()->deleteDocument(proxyTi->proxy()); UBPersistenceManager::persistenceManager()->deleteDocument(proxyTi->proxy());
} }
UBApplication::showMessage(tr("Emptied trash")); showMessage(tr("Emptied trash"));
QApplication::restoreOverrideCursor(); QApplication::restoreOverrideCursor();
mMainWindow->actionDelete->setEnabled(false); mMainWindow->actionDelete->setEnabled(false);
@ -683,7 +688,7 @@ void UBDocumentController::deleteSelectedItem()
{ {
UBDocumentProxyTreeItem* proxyTi = toBeDeleted.at(i); UBDocumentProxyTreeItem* proxyTi = toBeDeleted.at(i);
UBApplication::showMessage(QString("Deleting %1").arg(proxyTi->proxy()->metaData(UBSettings::documentName).toString())); showMessage(QString("Deleting %1").arg(proxyTi->proxy()->metaData(UBSettings::documentName).toString()));
// Move document to trash // Move document to trash
QString oldGroupName = proxyTi->proxy()->metaData(UBSettings::documentGroupName).toString(); QString oldGroupName = proxyTi->proxy()->metaData(UBSettings::documentGroupName).toString();
proxyTi->proxy()->setMetaData(UBSettings::documentGroupName, UBSettings::trashedDocumentGroupNamePrefix + oldGroupName); proxyTi->proxy()->setMetaData(UBSettings::documentGroupName, UBSettings::trashedDocumentGroupNamePrefix + oldGroupName);
@ -693,7 +698,7 @@ void UBDocumentController::deleteSelectedItem()
mTrashTi->addChild(proxyTi); mTrashTi->addChild(proxyTi);
proxyTi->setFlags(proxyTi->flags() ^ Qt::ItemIsEditable); proxyTi->setFlags(proxyTi->flags() ^ Qt::ItemIsEditable);
UBApplication::showMessage(QString("%1 deleted").arg(groupTi->groupName())); showMessage(QString("%1 deleted").arg(groupTi->groupName()));
} }
// dont remove default group // dont remove default group
@ -732,7 +737,7 @@ void UBDocumentController::exportDocument()
} }
else else
{ {
UBApplication::showMessage(tr("No document selected!")); showMessage(tr("No document selected!"));
} }
} }
@ -917,7 +922,7 @@ void UBDocumentController::importFile()
if (groupName == UBSettings::defaultDocumentGroupName || fileInfo.suffix() != "ubz") if (groupName == UBSettings::defaultDocumentGroupName || fileInfo.suffix() != "ubz")
groupName = ""; groupName = "";
UBApplication::showMessage(tr("Importing file %1...").arg(fileInfo.baseName()), true); showMessage(tr("Importing file %1...").arg(fileInfo.baseName()), true);
createdDocument = docManager->importFile(selectedFile, groupName); createdDocument = docManager->importFile(selectedFile, groupName);
@ -927,7 +932,7 @@ void UBDocumentController::importFile()
} }
else else
{ {
UBApplication::showMessage(tr("Failed to import file ... ")); showMessage(tr("Failed to import file ... "));
} }
} }
@ -958,7 +963,7 @@ void UBDocumentController::addFolderOfImages()
if (importedImageNumber == 0) if (importedImageNumber == 0)
{ {
UBApplication::showMessage(tr("Folder does not contain any image files!")); showMessage(tr("Folder does not contain any image files!"));
UBApplication::applicationController->showDocument(); UBApplication::applicationController->showDocument();
} }
else else
@ -1003,7 +1008,7 @@ bool UBDocumentController::addFileToDocument(UBDocumentProxy* document)
QApplication::processEvents(); QApplication::processEvents();
QFile selectedFile(filePath); QFile selectedFile(filePath);
UBApplication::showMessage(tr("Importing file %1...").arg(fileInfo.baseName()), true); showMessage(tr("Importing file %1...").arg(fileInfo.baseName()), true);
success = UBDocumentManager::documentManager()->addFileToDocument(document, selectedFile); success = UBDocumentManager::documentManager()->addFileToDocument(document, selectedFile);
@ -1014,7 +1019,7 @@ bool UBDocumentController::addFileToDocument(UBDocumentProxy* document)
} }
else else
{ {
UBApplication::showMessage(tr("Failed to import file ... ")); showMessage(tr("Failed to import file ... "));
} }
} }
@ -1382,13 +1387,19 @@ bool UBDocumentController::isOKToOpenDocument(UBDocumentProxy* proxy)
void UBDocumentController::showMessage(const QString& message, bool showSpinningWheel) void UBDocumentController::showMessage(const QString& message, bool showSpinningWheel)
{ {
if (mMessageWindow)
{
int margin = UBSettings::boardMargin; int margin = UBSettings::boardMargin;
QRect newSize = mDocumentUI->thumbnailWidget->geometry(); QRect newSize = mDocumentUI->thumbnailWidget->geometry();
if (mMessageWindow) #ifdef Q_WS_MACX
{ QPoint point(newSize.left() + margin, newSize.bottom() - mMessageWindow->height() - margin);
mMessageWindow->move(mDocumentUI->thumbnailWidget->mapToGlobal(point));
#else
mMessageWindow->move(margin, newSize.height() - mMessageWindow->height() - margin); mMessageWindow->move(margin, newSize.height() - mMessageWindow->height() - margin);
#endif
mMessageWindow->showMessage(message, showSpinningWheel); mMessageWindow->showMessage(message, showSpinningWheel);
} }
} }

@ -71,7 +71,7 @@ class UBDocumentController : public UBDocumentContainer
void selectDocument(UBDocumentProxy* proxy, bool setAsCurrentDocument = true); void selectDocument(UBDocumentProxy* proxy, bool setAsCurrentDocument = true);
void show(); void show();
void hide(); void hide();
void showMessage(const QString& message, bool showSpinningWheel); void showMessage(const QString& message, bool showSpinningWheel = false);
void hideMessage(); void hideMessage();
void toggleDocumentToolsPalette(); void toggleDocumentToolsPalette();
void cut(); void cut();

@ -1,48 +0,0 @@
#include "UBAngleWidget.h"
#include <QPainter>
#include "core/memcheck.h"
UBAngleWidget::UBAngleWidget(QWidget *parent)
: QWidget(parent)
{
this->setFixedSize(45,30);
this->setWindowFlags(Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint);
this->setAttribute(Qt::WA_TranslucentBackground);
QImage mask_img(width(), height(), QImage::Format_Mono);
mask_img.fill(0xff);
QPainter mask_ptr(&mask_img);
mask_ptr.setBrush( QBrush( QColor(0, 0, 0) ) );
mask_ptr.drawRoundedRect(0,0,this->geometry().width() - 6,this->geometry().height() - 6,1,1);
bmpMask = QBitmap::fromImage(mask_img);
this->setMask(bmpMask);
}
UBAngleWidget::~UBAngleWidget()
{
}
void UBAngleWidget::paintEvent(QPaintEvent *event)
{
Q_UNUSED(event);
this->move(this->cursor().pos().x(), this->cursor().pos().y() - 30);
QPainter painter(this);
painter.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform);
QBrush brush(Qt::white);
painter.setBrush(brush);
painter.drawRoundedRect(1,1,this->geometry().width() - 10,this->geometry().height() - 10,1,1);
painter.setPen(QColor(85,50,127));
painter.setFont(QFont("Arial", 10));
painter.drawText(1,1,this->geometry().width() - 10,this->geometry().height() - 10, Qt::AlignCenter, text);
}
void UBAngleWidget::setText(QString newText)
{
text = newText;
text.append(QChar(176));
}

@ -1,25 +0,0 @@
#ifndef UBANGLEWIDGET_H
#define UBANGLEWIDGET_H
#include <QWidget>
#include <QBitmap>
class UBAngleWidget : public QWidget
{
Q_OBJECT
public:
UBAngleWidget(QWidget *parent = 0);
~UBAngleWidget();
void setText(QString);
protected:
void paintEvent(QPaintEvent *event);
private:
QString text;
QBitmap bmpMask;
};
#endif // UBANGLEWIDGET_H

@ -21,6 +21,9 @@
#include "core/UBApplication.h" #include "core/UBApplication.h"
#include "core/UBSettings.h" #include "core/UBSettings.h"
#include "board/UBBoardController.h"
#include "board/UBBoardView.h"
#include "domain/UBGraphicsItemDelegate.h" #include "domain/UBGraphicsItemDelegate.h"
#include "domain/UBGraphicsScene.h" #include "domain/UBGraphicsScene.h"
#include "domain/UBGraphicsProxyWidget.h" #include "domain/UBGraphicsProxyWidget.h"
@ -90,14 +93,11 @@ UBGraphicsDelegateFrame::UBGraphicsDelegateFrame(UBGraphicsItemDelegate* pDelega
positionHandles(); positionHandles();
this->setAcceptHoverEvents(true); this->setAcceptHoverEvents(true);
angleWidget = new UBAngleWidget();
} }
UBGraphicsDelegateFrame::~UBGraphicsDelegateFrame() UBGraphicsDelegateFrame::~UBGraphicsDelegateFrame()
{ {
delete angleWidget;
// NOOP // NOOP
} }
@ -226,10 +226,46 @@ void UBGraphicsDelegateFrame::mousePressEvent(QGraphicsSceneMouseEvent *event)
mInitialTransform = buildTransform(); mInitialTransform = buildTransform();
mCurrentTool = toolFromPos(event->pos()); mCurrentTool = toolFromPos(event->pos());
setCursorFromAngle(QString(""));
event->accept(); event->accept();
} }
void UBGraphicsDelegateFrame::setCursorFromAngle(QString angle)
{
if (mCurrentTool == Rotate)
{
QWidget *controlViewport = UBApplication::boardController->controlView()->viewport();
QSize cursorSize(45,30);
QImage mask_img(cursorSize, QImage::Format_Mono);
mask_img.fill(0xff);
QPainter mask_ptr(&mask_img);
mask_ptr.setBrush( QBrush( QColor(0, 0, 0) ) );
mask_ptr.drawRoundedRect(0,0, cursorSize.width()-1, cursorSize.height()-1, 6, 6);
QBitmap bmpMask = QBitmap::fromImage(mask_img);
QPixmap pixCursor(cursorSize);
pixCursor.fill(QColor(Qt::white));
QPainter painter(&pixCursor);
painter.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform);
painter.setBrush(QBrush(Qt::white));
painter.setPen(QPen(QColor(Qt::black)));
painter.drawRoundedRect(1,1,cursorSize.width()-2,cursorSize.height()-2,6,6);
painter.setFont(QFont("Arial", 10));
painter.drawText(1,1,cursorSize.width(),cursorSize.height(), Qt::AlignCenter, angle.append(QChar(176)));
painter.end();
pixCursor.setMask(bmpMask);
controlViewport->setCursor(pixCursor);
}
}
bool UBGraphicsDelegateFrame::canResizeBottomRight(qreal width, qreal height, qreal scaleFactor) bool UBGraphicsDelegateFrame::canResizeBottomRight(qreal width, qreal height, qreal scaleFactor)
{ {
bool res = false; bool res = false;
@ -427,12 +463,7 @@ void UBGraphicsDelegateFrame::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
} }
} }
if (!angleWidget->isVisible()) setCursorFromAngle(QString::number((int)mAngle % 360));
angleWidget->show();
angleWidget->setText(QString::number((int)mAngle % 360));
angleWidget->update();
} }
else if (moving()) else if (moving())
{ {
@ -525,9 +556,6 @@ QTransform UBGraphicsDelegateFrame::buildTransform()
void UBGraphicsDelegateFrame::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) void UBGraphicsDelegateFrame::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{ {
if (angleWidget->isVisible())
angleWidget->hide();
updateResizeCursors(); updateResizeCursors();
mDelegate->commitUndoStep(); mDelegate->commitUndoStep();

@ -18,7 +18,6 @@
#include <QtGui> #include <QtGui>
#include "core/UB.h" #include "core/UB.h"
#include "domain/UBAngleWidget.h"
class QGraphicsSceneMouseEvent; class QGraphicsSceneMouseEvent;
class UBGraphicsItemDelegate; class UBGraphicsItemDelegate;
@ -65,6 +64,7 @@ class UBGraphicsDelegateFrame: public QGraphicsRectItem, public QObject
inline bool resizingTop () const { return mCurrentTool == ResizeTop; } inline bool resizingTop () const { return mCurrentTool == ResizeTop; }
inline bool rotating () const { return mCurrentTool == Rotate; } inline bool rotating () const { return mCurrentTool == Rotate; }
inline bool moving () const { return mCurrentTool == Move; } inline bool moving () const { return mCurrentTool == Move; }
void setCursorFromAngle(QString angle);
bool canResizeBottomRight(qreal width, qreal height, qreal scaleFactor); bool canResizeBottomRight(qreal width, qreal height, qreal scaleFactor);
QTransform buildTransform (); QTransform buildTransform ();
@ -120,8 +120,5 @@ class UBGraphicsDelegateFrame: public QGraphicsRectItem, public QObject
bool mResizing; bool mResizing;
bool mMirroredXAtStart; bool mMirroredXAtStart;
bool mMirroredYAtStart; bool mMirroredYAtStart;
UBAngleWidget *angleWidget;
}; };
#endif /* UBGRAPHICSDELEGATEFRAME_H_ */ #endif /* UBGRAPHICSDELEGATEFRAME_H_ */

@ -418,10 +418,6 @@ bool UBGraphicsItemDelegate::isLocked()
void UBGraphicsItemDelegate::duplicate() void UBGraphicsItemDelegate::duplicate()
{ {
// TODO UB 4.x .. rewrite .. .this is absurde ... we know what we are duplicating
UBApplication::boardController->copy();
UBApplication::boardController->paste();
UBApplication::boardController->duplicateItem(dynamic_cast<UBItem*>(delegated())); UBApplication::boardController->duplicateItem(dynamic_cast<UBItem*>(delegated()));
} }
@ -1134,6 +1130,7 @@ DelegateMediaControl::DelegateMediaControl(UBGraphicsMediaItem* pDelegated, QGra
, mCurrentTimeInMs(0) , mCurrentTimeInMs(0)
, mTotalTimeInMs(0) , mTotalTimeInMs(0)
, mStartWidth(200) , mStartWidth(200)
, mSeecAreaBorderHeight(0)
{ {
setAcceptedMouseButtons(Qt::LeftButton); setAcceptedMouseButtons(Qt::LeftButton);
setBrush(QBrush(Qt::white)); setBrush(QBrush(Qt::white));
@ -1157,13 +1154,14 @@ void DelegateMediaControl::paint(QPainter *painter,
mLCDTimerArea.setHeight(rect().height()); mLCDTimerArea.setHeight(rect().height());
mLCDTimerArea.setWidth(rect().height()); mLCDTimerArea.setWidth(rect().height());
mSeecArea = rect();
mSeecArea.setWidth(rect().width()-mLCDTimerArea.width()-2); mSeecArea.setWidth(rect().width()-mLCDTimerArea.width()-2);
mSeecArea.setHeight(rect().height()-2*mSeecAreaBorderHeight);
mSeecArea.setY(mSeecAreaBorderHeight);
path.addRoundedRect(mSeecArea, mSeecArea.height()/2, mSeecArea.height()/2); path.addRoundedRect(mSeecArea, mSeecArea.height()/2, mSeecArea.height()/2);
painter->fillPath(path, brush()); painter->fillPath(path, brush());
qreal frameWidth = rect().height() / 2; qreal frameWidth = mSeecArea.height() / 2;
int position = frameWidth; int position = frameWidth;
if (mTotalTimeInMs > 0) if (mTotalTimeInMs > 0)
@ -1173,7 +1171,7 @@ void DelegateMediaControl::paint(QPainter *painter,
int clearance = 2; int clearance = 2;
int radius = frameWidth-clearance; int radius = frameWidth-clearance;
QRectF r(position - radius, clearance, radius * 2, radius * 2); QRectF r(position - radius, clearance+mSeecAreaBorderHeight, radius * 2, radius * 2);
painter->setBrush(UBSettings::documentViewLightColor); painter->setBrush(UBSettings::documentViewLightColor);
painter->drawEllipse(r); painter->drawEllipse(r);
@ -1193,18 +1191,17 @@ void DelegateMediaControl::positionHandles()
mLCDTimerArea.setHeight(parentItem()->boundingRect().height()); mLCDTimerArea.setHeight(parentItem()->boundingRect().height());
lcdTimer->setRect(mLCDTimerArea); lcdTimer->setRect(mLCDTimerArea);
lcdTimer->setPos(mSeecArea.width()-mLCDTimerArea.width(),0); lcdTimer->setPos(mSeecArea.width()-mLCDTimerArea.width(),0);
//lcdTimer->setRect(mLCDTimerArea);
//lcdTimer->setPos(mSeecArea.width()-mLCDTimerArea.width(),0);
mSeecArea.setWidth(rect().width()-mLCDTimerArea.width()); mSeecAreaBorderHeight = rect().height()/20;
mSeecArea.setWidth(rect().width()-mLCDTimerArea.width()-2);
mSeecArea.setHeight(rect().height()-2*mSeecAreaBorderHeight);
mSeecArea.setY(mSeecAreaBorderHeight);
QRectF selfRect = rect(); QRectF selfRect = rect();
selfRect.setHeight(parentItem()->boundingRect().height()); selfRect.setHeight(parentItem()->boundingRect().height());
setRect(selfRect); setRect(selfRect);
lcdTimer->setPos(rect().width() - mLCDTimerArea.width(), 0); lcdTimer->setPos(rect().width() - mLCDTimerArea.width(), 0);
//lcdTimer->setPos(rect().width() - mLCDTimerArea.width(), 0);
} }
void DelegateMediaControl::update() void DelegateMediaControl::update()
@ -1212,7 +1209,6 @@ void DelegateMediaControl::update()
QTime t; QTime t;
t = t.addMSecs(mCurrentTimeInMs < 0 ? 0 : mCurrentTimeInMs); t = t.addMSecs(mCurrentTimeInMs < 0 ? 0 : mCurrentTimeInMs);
lcdTimer->display(t.toString("m:ss")); lcdTimer->display(t.toString("m:ss"));
//lcdTimer->display(t.toString("m:ss"));
QGraphicsRectItem::update(); QGraphicsRectItem::update();
} }
@ -1247,7 +1243,7 @@ void DelegateMediaControl::mousePressEvent(QGraphicsSceneMouseEvent *event)
void DelegateMediaControl::mouseMoveEvent(QGraphicsSceneMouseEvent *event) void DelegateMediaControl::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{ {
qreal frameWidth = rect().height() / 2; qreal frameWidth = mSeecArea.height() / 2;
if (boundingRect().contains(event->pos() - QPointF(frameWidth,0)) if (boundingRect().contains(event->pos() - QPointF(frameWidth,0))
&& boundingRect().contains(event->pos() + QPointF(frameWidth,0))) && boundingRect().contains(event->pos() + QPointF(frameWidth,0)))
{ {
@ -1265,7 +1261,6 @@ void DelegateMediaControl::seekToMousePos(QPointF mousePos)
minX = frameWidth; minX = frameWidth;
length = mSeecArea.width() - lcdTimer->rect().width(); length = mSeecArea.width() - lcdTimer->rect().width();
length = mSeecArea.width() /*- lcdTimer->rect().width()*/;
qreal mouseX = mousePos.x(); qreal mouseX = mousePos.x();
if (mouseX >= (mSeecArea.width() - mSeecArea.height()/2)) if (mouseX >= (mSeecArea.width() - mSeecArea.height()/2))

@ -149,6 +149,7 @@ class DelegateMediaControl: public QObject, public QGraphicsRectItem
private: private:
int mStartWidth; int mStartWidth;
int mSeecAreaBorderHeight;
QRectF mSeecArea; QRectF mSeecArea;
QRectF mLCDTimerArea; QRectF mLCDTimerArea;
@ -284,7 +285,7 @@ class UBGraphicsItemDelegate : public QObject
qreal mAntiScaleRatio; qreal mAntiScaleRatio;
QList<DelegateButton*> mButtons; QList<DelegateButton*> mButtons;
QList<DelegateButton*> mToolBarButtons;
UBGraphicsToolBarItem* mToolBarItem; UBGraphicsToolBarItem* mToolBarItem;
protected slots: protected slots:

@ -35,11 +35,20 @@ UBAudioPresentationWidget::UBAudioPresentationWidget(QWidget *parent)
void UBAudioPresentationWidget::paintEvent(QPaintEvent *event) void UBAudioPresentationWidget::paintEvent(QPaintEvent *event)
{ {
QPainter painter(this); QPainter painter(this);
painter.fillRect(rect(), QBrush(Qt::black)); painter.fillRect(rect(), QBrush(Qt::white));
painter.drawRoundedRect(1,1, width()-2, height()-2, height()/5, height()/5);
QImage mask_img(size(), QImage::Format_Mono);
mask_img.fill(0xff);
QPainter mask_painter(&mask_img);
mask_painter.setBrush(QBrush( QColor(0, 0, 0)));
mask_painter.drawRoundedRect(1,1, width()-3, height()-3, height()/5, height()/5);
setMask(QBitmap::fromImage(mask_img));
if (QString() != mTitle) if (QString() != mTitle)
{ {
painter.setPen(QPen(Qt::white)); painter.setPen(QPen(Qt::black));
QRect titleRect = rect(); QRect titleRect = rect();
titleRect.setX(mBorderSize); titleRect.setX(mBorderSize);
titleRect.setY(2); titleRect.setY(2);
@ -54,13 +63,13 @@ bool UBGraphicsMediaItem::sIsMutedByDefault = false;
UBGraphicsMediaItem::UBGraphicsMediaItem(const QUrl& pMediaFileUrl, QGraphicsItem *parent) UBGraphicsMediaItem::UBGraphicsMediaItem(const QUrl& pMediaFileUrl, QGraphicsItem *parent)
: UBGraphicsProxyWidget(parent) : UBGraphicsProxyWidget(parent)
, mVideoWidget(NULL)
, mAudioWidget(NULL)
, mMuted(sIsMutedByDefault) , mMuted(sIsMutedByDefault)
, mMutedByUserAction(sIsMutedByDefault) , mMutedByUserAction(sIsMutedByDefault)
, mMediaFileUrl(pMediaFileUrl) , mMediaFileUrl(pMediaFileUrl)
, mInitialPos(0)
, mVideoWidget(NULL)
, mAudioWidget(NULL)
, mLinkedImage(NULL) , mLinkedImage(NULL)
, mInitialPos(0)
{ {
update(); update();

@ -139,8 +139,6 @@ private:
QUrl mMediaFileUrl; QUrl mMediaFileUrl;
QString mMediaSource; QString mMediaSource;
qint64 mInitialPos;
mediaType mMediaType; mediaType mMediaType;
bool mShouldMove; bool mShouldMove;
@ -149,5 +147,7 @@ private:
bool haveLinkedImage; bool haveLinkedImage;
QGraphicsPixmapItem *mLinkedImage; QGraphicsPixmapItem *mLinkedImage;
qint64 mInitialPos;
}; };
#endif // UBGRAPHICSMEDIAITEM_H #endif // UBGRAPHICSMEDIAITEM_H

@ -94,7 +94,7 @@ void UBGraphicsMediaItemDelegate::buildButtons()
connect(mMuteButton, SIGNAL(clicked(bool)), delegated(), SLOT(toggleMute())); connect(mMuteButton, SIGNAL(clicked(bool)), delegated(), SLOT(toggleMute()));
connect(mMuteButton, SIGNAL(clicked(bool)), this, SLOT(toggleMute())); // for changing button image connect(mMuteButton, SIGNAL(clicked(bool)), this, SLOT(toggleMute())); // for changing button image
mButtons << mPlayPauseButton << mStopButton << mMuteButton; mToolBarButtons << mPlayPauseButton << mStopButton << mMuteButton;
mToolBarItem->setItemsOnToolBar(QList<QGraphicsItem*>() << mPlayPauseButton << mStopButton << mMediaControl << mMuteButton); mToolBarItem->setItemsOnToolBar(QList<QGraphicsItem*>() << mPlayPauseButton << mStopButton << mMediaControl << mMuteButton);
mToolBarItem->setVisibleOnBoard(true); mToolBarItem->setVisibleOnBoard(true);
@ -135,7 +135,6 @@ void UBGraphicsMediaItemDelegate::positionHandles()
if (mediaItem->getMediaType() == UBGraphicsMediaItem::mediaType_Video) if (mediaItem->getMediaType() == UBGraphicsMediaItem::mediaType_Video)
{ {
mToolBarItem->setPos(0, delegated()->boundingRect().height()-mToolBarItem->rect().height()); mToolBarItem->setPos(0, delegated()->boundingRect().height()-mToolBarItem->rect().height());
// mToolBarItem->setScale(AntiScaleRatio);
toolBarRect.setWidth(delegated()->boundingRect().width()); toolBarRect.setWidth(delegated()->boundingRect().width());
} }
@ -156,14 +155,11 @@ void UBGraphicsMediaItemDelegate::positionHandles()
int toolBarMinimumWidth = 0; int toolBarMinimumWidth = 0;
int mediaItemWidth = mToolBarItem->boundingRect().width(); int mediaItemWidth = mToolBarItem->boundingRect().width();
foreach (DelegateButton* button, mButtons) foreach (DelegateButton* button, mToolBarButtons)
{
if (button->getSection() == Qt::TitleBarArea)
{ {
mediaItemWidth -= button->boundingRect().width() + mToolBarItem->getElementsPadding(); mediaItemWidth -= button->boundingRect().width() + mToolBarItem->getElementsPadding();
toolBarMinimumWidth += button->boundingRect().width() + mToolBarItem->getElementsPadding(); toolBarMinimumWidth += button->boundingRect().width() + mToolBarItem->getElementsPadding();
} }
}
toolBarMinimumWidth += mToolBarItem->boundingRect().height(); toolBarMinimumWidth += mToolBarItem->boundingRect().height();
UBAudioPresentationWidget* pAudioWidget = dynamic_cast<UBAudioPresentationWidget*>(delegated()->widget()); UBAudioPresentationWidget* pAudioWidget = dynamic_cast<UBAudioPresentationWidget*>(delegated()->widget());
@ -194,10 +190,6 @@ void UBGraphicsMediaItemDelegate::remove(bool canUndo)
if (delegated() && delegated()->mediaObject()) if (delegated() && delegated()->mediaObject())
delegated()->mediaObject()->stop(); delegated()->mediaObject()->stop();
QGraphicsScene* scene = mDelegated->scene();
scene->removeItem(mMediaControl);
UBGraphicsItemDelegate::remove(canUndo); UBGraphicsItemDelegate::remove(canUndo);
} }

@ -541,12 +541,14 @@ bool UBGraphicsScene::inputDeviceRelease()
mAddedItems.remove(mArcPolygonItem); mAddedItems.remove(mArcPolygonItem);
removeItem(mArcPolygonItem); removeItem(mArcPolygonItem);
UBCoreGraphicsScene::removeItemFromDeletion(mArcPolygonItem); UBCoreGraphicsScene::removeItemFromDeletion(mArcPolygonItem);
mArcPolygonItem->setStrokesGroup(pStrokes);
pStrokes->addToGroup(mArcPolygonItem); pStrokes->addToGroup(mArcPolygonItem);
// Add the center cross // Add the center cross
foreach(QGraphicsItem* item, mAddedItems){ foreach(QGraphicsItem* item, mAddedItems){
removeItem(item); removeItem(item);
UBCoreGraphicsScene::removeItemFromDeletion(item); UBCoreGraphicsScene::removeItemFromDeletion(item);
mArcPolygonItem->setStrokesGroup(pStrokes);
pStrokes->addToGroup(item); pStrokes->addToGroup(item);
} }
@ -1979,7 +1981,16 @@ void UBGraphicsScene::addMagnifier(UBMagnifierParams params)
setModified(true); setModified(true);
} }
void UBGraphicsScene::moveMagnifier(QPoint newPos) void UBGraphicsScene::moveMagnifier()
{
if (magniferControlViewWidget)
{
QPoint magnifierPos = QPoint(magniferControlViewWidget->pos().x() + magniferControlViewWidget->size().width() / 2, magniferControlViewWidget->pos().y() + magniferControlViewWidget->size().height() / 2 );
moveMagnifier(magnifierPos, true);
}
}
void UBGraphicsScene::moveMagnifier(QPoint newPos, bool forceGrab)
{ {
QWidget *cContainer = (QWidget*)(UBApplication::boardController->controlContainer()); QWidget *cContainer = (QWidget*)(UBApplication::boardController->controlContainer());
QGraphicsView *cView = (QGraphicsView*)UBApplication::boardController->controlView(); QGraphicsView *cView = (QGraphicsView*)UBApplication::boardController->controlView();
@ -1987,6 +1998,8 @@ void UBGraphicsScene::moveMagnifier(QPoint newPos)
QPoint dvZeroPoint = dView->mapToGlobal(QPoint(0,0)); QPoint dvZeroPoint = dView->mapToGlobal(QPoint(0,0));
QRect qcr = cView->geometry();
QRect qdr = dView->geometry();
int cvW = cView->width(); int cvW = cView->width();
int dvW = dView->width(); int dvW = dView->width();
qreal wCoeff = (qreal)dvW / (qreal)cvW; qreal wCoeff = (qreal)dvW / (qreal)cvW;
@ -1999,8 +2012,8 @@ void UBGraphicsScene::moveMagnifier(QPoint newPos)
QPoint cvPoint = cView->mapFromGlobal(globalPoint); QPoint cvPoint = cView->mapFromGlobal(globalPoint);
QPoint dvPoint( cvPoint.x() * wCoeff + dvZeroPoint.x(), cvPoint.y() * hCoeff + dvZeroPoint.y()); QPoint dvPoint( cvPoint.x() * wCoeff + dvZeroPoint.x(), cvPoint.y() * hCoeff + dvZeroPoint.y());
magniferControlViewWidget->grabNMove(globalPoint, globalPoint, false, false); magniferControlViewWidget->grabNMove(globalPoint, globalPoint, forceGrab, false);
magniferDisplayViewWidget->grabNMove(globalPoint, dvPoint, false, true); magniferDisplayViewWidget->grabNMove(globalPoint, dvPoint, forceGrab, true);
setModified(true); setModified(true);
} }

@ -326,7 +326,8 @@ public slots:
void selectionChangedProcessing(); void selectionChangedProcessing();
void updateGroupButtonState(); void updateGroupButtonState();
void moveMagnifier(QPoint newPos); void moveMagnifier();
void moveMagnifier(QPoint newPos, bool forceGrab = false);
void closeMagnifier(); void closeMagnifier();
void zoomInMagnifier(); void zoomInMagnifier();
void zoomOutMagnifier(); void zoomOutMagnifier();

@ -1,5 +1,7 @@
#include "UBGraphicsStrokesGroup.h" #include "UBGraphicsStrokesGroup.h"
#include "domain/UBGraphicsPolygonItem.h"
#include "core/memcheck.h" #include "core/memcheck.h"
UBGraphicsStrokesGroup::UBGraphicsStrokesGroup(QGraphicsItem *parent):QGraphicsItemGroup(parent) UBGraphicsStrokesGroup::UBGraphicsStrokesGroup(QGraphicsItem *parent):QGraphicsItemGroup(parent)
@ -63,6 +65,15 @@ UBItem* UBGraphicsStrokesGroup::deepCopy() const
{ {
UBGraphicsStrokesGroup* copy = new UBGraphicsStrokesGroup(); UBGraphicsStrokesGroup* copy = new UBGraphicsStrokesGroup();
QList<QGraphicsItem*> chl = childItems();
foreach(QGraphicsItem *child, chl)
{
UBGraphicsPolygonItem *polygon = dynamic_cast<UBGraphicsPolygonItem*>(child);
if (polygon)
copy->addToGroup(dynamic_cast<QGraphicsItem*>(polygon->deepCopy()));
}
copyItemParameters(copy); copyItemParameters(copy);
return copy; return copy;

@ -107,10 +107,16 @@ void UBGraphicsWidgetItem::initialize()
QPalette palette = page()->palette(); QPalette palette = page()->palette();
palette.setBrush(QPalette::Base, QBrush(Qt::transparent)); palette.setBrush(QPalette::Base, QBrush(Qt::transparent));
page()->setPalette(palette); page()->setPalette(palette);
page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks);
connect(page()->mainFrame(), SIGNAL(javaScriptWindowObjectCleared()), this, SLOT(javaScriptWindowObjectCleared())); connect(page()->mainFrame(), SIGNAL(javaScriptWindowObjectCleared()), this, SLOT(javaScriptWindowObjectCleared()));
connect(page(), SIGNAL(geometryChangeRequested(const QRect&)), this, SLOT(geometryChangeRequested(const QRect&))); connect(page(), SIGNAL(geometryChangeRequested(const QRect&)), this, SLOT(geometryChangeRequested(const QRect&)));
connect(this, SIGNAL(loadFinished(bool)), this, SLOT(mainFrameLoadFinished (bool))); connect(this, SIGNAL(loadFinished(bool)), this, SLOT(mainFrameLoadFinished (bool)));
connect(page(), SIGNAL(linkClicked(const QUrl&)), this, SLOT(onLinkClicked(const QUrl&)));
}
void UBGraphicsWidgetItem::onLinkClicked(const QUrl& url){
UBApplication::webController->loadUrl(url);
} }
QUrl UBGraphicsWidgetItem::mainHtml() QUrl UBGraphicsWidgetItem::mainHtml()

@ -152,6 +152,9 @@ class UBGraphicsWidgetItem : public UBGraphicsWebView
virtual void javaScriptWindowObjectCleared(); virtual void javaScriptWindowObjectCleared();
void mainFrameLoadFinished(bool ok); void mainFrameLoadFinished(bool ok);
private slots:
void onLinkClicked(const QUrl& url);
private: private:
bool mIsFrozen; bool mIsFrozen;
bool mIsTakingSnapshot; bool mIsTakingSnapshot;

@ -18,7 +18,6 @@ HEADERS += src/domain/UBGraphicsScene.h \
src/domain/UBGraphicsStroke.h \ src/domain/UBGraphicsStroke.h \
src/domain/UBGraphicsMediaItem.h \ src/domain/UBGraphicsMediaItem.h \
src/domain/UBAbstractUndoCommand.h\ src/domain/UBAbstractUndoCommand.h\
src/domain/UBAngleWidget.h \
src/domain/UBGraphicsGroupContainerItem.h \ src/domain/UBGraphicsGroupContainerItem.h \
src/domain/UBGraphicsGroupContainerItemDelegate.h \ src/domain/UBGraphicsGroupContainerItemDelegate.h \
src/domain/UBGraphicsStrokesGroup.h src/domain/UBGraphicsStrokesGroup.h
@ -50,7 +49,6 @@ SOURCES += src/domain/UBGraphicsScene.cpp \
src/domain/UBGraphicsStroke.cpp \ src/domain/UBGraphicsStroke.cpp \
src/domain/UBGraphicsMediaItem.cpp \ src/domain/UBGraphicsMediaItem.cpp \
src/domain/UBAbstractUndoCommand.cpp \ src/domain/UBAbstractUndoCommand.cpp \
src/domain/UBAngleWidget.cpp \
src/domain/ubgraphicsgroupcontaineritem.cpp \ src/domain/ubgraphicsgroupcontaineritem.cpp \
src/domain/ubgraphicsgroupcontaineritemdelegate.cpp \ src/domain/ubgraphicsgroupcontaineritemdelegate.cpp \
src/domain/UBGraphicsStrokesGroup.cpp src/domain/UBGraphicsStrokesGroup.cpp

@ -96,10 +96,6 @@ UBDockPalette::~UBDockPalette()
delete mpLayout; delete mpLayout;
mpLayout = NULL; mpLayout = NULL;
} }
if (NULL != mTabPalette) {
delete mTabPalette;
mTabPalette = NULL;
}
} }
/** /**
@ -533,6 +529,7 @@ void UBDockPalette::setVisible(bool visible)
bool UBDockPalette::switchMode(eUBDockPaletteWidgetMode mode) bool UBDockPalette::switchMode(eUBDockPaletteWidgetMode mode)
{ {
mLastOpenedTabForMode.insert(mCurrentMode, mpStackWidget->currentIndex());
mCurrentMode = mode; mCurrentMode = mode;
bool hasVisibleElements = false; bool hasVisibleElements = false;
//-------------------------------// //-------------------------------//
@ -556,7 +553,7 @@ bool UBDockPalette::switchMode(eUBDockPaletteWidgetMode mode)
//-------------------------------// //-------------------------------//
if(mRegisteredWidgets.size() > 0) if(mRegisteredWidgets.size() > 0)
showTabWidget(0); showTabWidget(mLastOpenedTabForMode.value(mCurrentMode));
update(); update();

@ -176,6 +176,8 @@ protected:
QVector<UBDockPaletteWidget*> mRegisteredWidgets; QVector<UBDockPaletteWidget*> mRegisteredWidgets;
/** The current tab widget */ /** The current tab widget */
QString mCrntTabWidget; QString mCrntTabWidget;
/** Last opened tab index depending on mode */
QMap<eUBDockPaletteWidgetMode,int> mLastOpenedTabForMode;
private slots: private slots:
void onToolbarPosUpdated(); void onToolbarPosUpdated();

@ -81,7 +81,9 @@ UBFeaturesWidget::UBFeaturesWidget(QWidget *parent, const char *name)
connect(controller, SIGNAL(scanStarted()), mActionBar, SLOT(lockIt())); connect(controller, SIGNAL(scanStarted()), mActionBar, SLOT(lockIt()));
connect(controller, SIGNAL(scanFinished()), mActionBar, SLOT(unlockIt())); connect(controller, SIGNAL(scanFinished()), mActionBar, SLOT(unlockIt()));
connect(controller, SIGNAL(maxFilesCountEvaluated(int)), centralWidget, SIGNAL(maxFilesCountEvaluated(int))); connect(controller, SIGNAL(maxFilesCountEvaluated(int)), centralWidget, SIGNAL(maxFilesCountEvaluated(int)));
connect(controller, SIGNAL(featureAddedFromThread()), centralWidget, SLOT(increaseStatusBarValue())); connect(controller, SIGNAL(featureAddedFromThread()), centralWidget, SIGNAL(increaseStatusBarValue()));
connect(controller, SIGNAL(scanCategory(QString)), centralWidget, SIGNAL(scanCategory(QString)));
connect(controller, SIGNAL(scanPath(QString)), centralWidget, SIGNAL(scanPath(QString)));
} }
UBFeaturesWidget::~UBFeaturesWidget() UBFeaturesWidget::~UBFeaturesWidget()
@ -497,15 +499,14 @@ UBFeaturesCentralWidget::UBFeaturesCentralWidget(QWidget *parent) : QWidget(pare
connect(this, SIGNAL(sendFileNameList(QStringList)), dlg, SLOT(setFileNameList(QStringList))); connect(this, SIGNAL(sendFileNameList(QStringList)), dlg, SLOT(setFileNameList(QStringList)));
//Progress bar to show scanning progress //Progress bar to show scanning progress
QProgressBar *progressBar = new QProgressBar(); UBFeaturesProgressInfo *progressBar = new UBFeaturesProgressInfo();
mAdditionalDataContainer->addWidget(progressBar); mAdditionalDataContainer->addWidget(progressBar);
mAdditionalDataContainer->setCurrentIndex(ProgressBarWidget); mAdditionalDataContainer->setCurrentIndex(ProgressBarWidget);
progressBar->setMinimum(0);
progressBar->setValue(0);
progressBar->setMaximum(10000);
connect(this, SIGNAL(maxFilesCountEvaluated(int)), progressBar, SLOT(setProgressMax(int)));
connect(this, SIGNAL(maxFilesCountEvaluated(int)), progressBar, SLOT(setMaximum(int))); connect(this, SIGNAL(increaseStatusBarValue()), progressBar, SLOT(increaseProgressValue()));
connect(this, SIGNAL(scanCategory(QString)), progressBar, SLOT(setCommmonInfoText(QString)));
connect(this, SIGNAL(scanPath(QString)), progressBar, SLOT(setDetailedInfoText(QString)));
mLayout->addWidget(mStackedWidget, 1); mLayout->addWidget(mStackedWidget, 1);
mLayout->addWidget(mAdditionalDataContainer, 0); mLayout->addWidget(mAdditionalDataContainer, 0);
@ -546,6 +547,11 @@ UBFeature UBFeaturesCentralWidget::getCurElementFromProperties()
void UBFeaturesCentralWidget::showAdditionalData(AddWidget pWidgetType, AddWidgetState pState) void UBFeaturesCentralWidget::showAdditionalData(AddWidget pWidgetType, AddWidgetState pState)
{ {
if (!mAdditionalDataContainer->widget(pWidgetType)) {
qDebug() << "can't find widget specified by UBFeaturesCentralWidget::showAdditionalData(AddWidget pWidgetType, AddWidgetState pState)";
return;
}
mAdditionalDataContainer->setMaximumHeight(mAdditionalDataContainer->widget(pWidgetType)->sizeHint().height()); mAdditionalDataContainer->setMaximumHeight(mAdditionalDataContainer->widget(pWidgetType)->sizeHint().height());
mAdditionalDataContainer->setCurrentIndex(pWidgetType); mAdditionalDataContainer->setCurrentIndex(pWidgetType);
@ -573,46 +579,21 @@ void UBFeaturesCentralWidget::hideAdditionalData()
void UBFeaturesCentralWidget::scanStarted() void UBFeaturesCentralWidget::scanStarted()
{ {
if (!mAdditionalDataContainer->widget(ProgressBarWidget)) { showAdditionalData(ProgressBarWidget);
return;
}
QProgressBar *progressBar = qobject_cast<QProgressBar*>(mAdditionalDataContainer->widget(ProgressBarWidget));
if (progressBar && !progressBar->isVisible()) {
showAdditionalData((AddWidget)1);
}
} }
void UBFeaturesCentralWidget::scanFinished() void UBFeaturesCentralWidget::scanFinished()
{ {
if (!mAdditionalDataContainer->widget(ProgressBarWidget)) {
return;
}
QProgressBar *progressBar = qobject_cast<QProgressBar*>(mAdditionalDataContainer->widget(ProgressBarWidget));
if (progressBar && progressBar->isVisible()) {
hideAdditionalData(); hideAdditionalData();
qDebug() << "progressBar max value is " << progressBar->maximum();
}
}
void UBFeaturesCentralWidget::increaseStatusBarValue()
{
if (!mAdditionalDataContainer->widget(ProgressBarWidget)) {
return;
}
QProgressBar *progressBar = qobject_cast<QProgressBar*>(mAdditionalDataContainer->widget(ProgressBarWidget));
if (progressBar) {
progressBar->setValue(progressBar->value() + 1);
}
} }
UBFeaturesNewFolderDialog::UBFeaturesNewFolderDialog(QWidget *parent) : QWidget(parent) UBFeaturesNewFolderDialog::UBFeaturesNewFolderDialog(QWidget *parent) : QWidget(parent)
{ {
this->setStyleSheet("background:white;"); this->setStyleSheet("background:white;");
QVBoxLayout *mainLayout = new QVBoxLayout(); QVBoxLayout *mainLayout = new QVBoxLayout(this);
setLayout(mainLayout);
QVBoxLayout *labelLayout = new QVBoxLayout(this); QVBoxLayout *labelLayout = new QVBoxLayout();
QLabel *mLabel = new QLabel(labelText, this); QLabel *mLabel = new QLabel(labelText, this);
mLineEdit = new QLineEdit(this); mLineEdit = new QLineEdit(this);
@ -622,7 +603,7 @@ UBFeaturesNewFolderDialog::UBFeaturesNewFolderDialog(QWidget *parent) : QWidget(
labelLayout->addWidget(mLabel); labelLayout->addWidget(mLabel);
labelLayout->addWidget(mLineEdit); labelLayout->addWidget(mLineEdit);
QHBoxLayout *buttonLayout = new QHBoxLayout(this); QHBoxLayout *buttonLayout = new QHBoxLayout();
acceptButton = new QPushButton(acceptText, this); acceptButton = new QPushButton(acceptText, this);
QPushButton *cancelButton = new QPushButton(cancelText, this); QPushButton *cancelButton = new QPushButton(cancelText, this);
@ -676,6 +657,64 @@ void UBFeaturesNewFolderDialog::reactOnTextChanged(const QString &pStr)
} }
} }
UBFeaturesProgressInfo::UBFeaturesProgressInfo(QWidget *parent) :
QWidget(parent),
mProgressBar(0),
mCommonInfoLabel(0),
mDetailedInfoLabel(0)
{
QVBoxLayout *mainLayer = new QVBoxLayout(this);
mProgressBar = new QProgressBar(this);
// setting defaults
mProgressBar->setMinimum(0);
mProgressBar->setMaximum(100000);
mProgressBar->setValue(0);
mProgressBar->setStyleSheet("background:white");
mCommonInfoLabel = new QLabel(this);
mDetailedInfoLabel = new QLabel(this);
mDetailedInfoLabel->setAlignment(Qt::AlignRight);
mCommonInfoLabel->hide();
mDetailedInfoLabel->hide();
mainLayer->addWidget(mCommonInfoLabel);
mainLayer->addWidget(mDetailedInfoLabel);
mainLayer->addWidget(mProgressBar);
}
void UBFeaturesProgressInfo::setCommmonInfoText(const QString &str)
{
mProgressBar->setFormat(str + tr(" load") + "(%p%)");
}
void UBFeaturesProgressInfo::setDetailedInfoText(const QString &str)
{
mDetailedInfoLabel->setText(str);
}
void UBFeaturesProgressInfo::setProgressMax(int pValue)
{
mProgressBar->setMaximum(pValue);
}
void UBFeaturesProgressInfo::setProgressMin(int pValue)
{
mProgressBar->setMinimum(pValue);
}
void UBFeaturesProgressInfo::increaseProgressValue()
{
mProgressBar->setValue(mProgressBar->value() + 1);
}
void UBFeaturesProgressInfo::sendFeature(UBFeature pFeature)
{
Q_UNUSED(pFeature);
}
UBFeaturesWebView::UBFeaturesWebView(QWidget* parent, const char* name):QWidget(parent) UBFeaturesWebView::UBFeaturesWebView(QWidget* parent, const char* name):QWidget(parent)
, mpView(NULL) , mpView(NULL)
, mpWebSettings(NULL) , mpWebSettings(NULL)
@ -1295,6 +1334,9 @@ Qt::ItemFlags UBFeaturesModel::flags( const QModelIndex &index ) const
UBFeature item = index.data( Qt::UserRole + 1 ).value<UBFeature>(); UBFeature item = index.data( Qt::UserRole + 1 ).value<UBFeature>();
if ( item.getType() == FEATURE_INTERACTIVE if ( item.getType() == FEATURE_INTERACTIVE
|| item.getType() == FEATURE_ITEM || item.getType() == FEATURE_ITEM
|| item.getType() == FEATURE_AUDIO
|| item.getType() == FEATURE_VIDEO
|| item.getType() == FEATURE_IMAGE
|| item.getType() == FEATURE_INTERNAL || item.getType() == FEATURE_INTERNAL
|| item.getType() == FEATURE_FOLDER) || item.getType() == FEATURE_FOLDER)
@ -1340,7 +1382,10 @@ bool UBFeaturesSearchProxyModel::filterAcceptsRow( int sourceRow, const QModelIn
UBFeature feature = sourceModel()->data(index, Qt::UserRole + 1).value<UBFeature>(); UBFeature feature = sourceModel()->data(index, Qt::UserRole + 1).value<UBFeature>();
bool isFile = feature.getType() == FEATURE_INTERACTIVE bool isFile = feature.getType() == FEATURE_INTERACTIVE
|| feature.getType() == FEATURE_INTERNAL || feature.getType() == FEATURE_INTERNAL
|| feature.getType() == FEATURE_ITEM; || feature.getType() == FEATURE_ITEM
|| feature.getType() == FEATURE_AUDIO
|| feature.getType() == FEATURE_VIDEO
|| feature.getType() == FEATURE_IMAGE;
return isFile && filterRegExp().exactMatch( feature.getName() ); return isFile && filterRegExp().exactMatch( feature.getName() );
} }

@ -45,6 +45,7 @@ class UBFeaturesNavigatorWidget;
class UBFeaturesMimeData; class UBFeaturesMimeData;
class UBFeaturesCentralWidget; class UBFeaturesCentralWidget;
class UBFeaturesNewFolderDialog; class UBFeaturesNewFolderDialog;
class UBFeaturesProgressBar;
class UBFeaturesWidget : public UBDockPaletteWidget class UBFeaturesWidget : public UBDockPaletteWidget
{ {
@ -189,7 +190,6 @@ public:
void setPropertiesThumbnail(const QPixmap &pix); void setPropertiesThumbnail(const QPixmap &pix);
StackElement currentView() const {return static_cast<StackElement>(mStackedWidget->currentIndex());} StackElement currentView() const {return static_cast<StackElement>(mStackedWidget->currentIndex());}
UBFeature getCurElementFromProperties(); UBFeature getCurElementFromProperties();
void showAdditionalData(AddWidget pWidgetType, AddWidgetState pState = NonModal);
void setLockedExcludingAdditional(bool pLock); void setLockedExcludingAdditional(bool pLock);
@ -207,6 +207,12 @@ signals:
// progressbar widget related signals // progressbar widget related signals
void maxFilesCountEvaluated(int pValue); void maxFilesCountEvaluated(int pValue);
void increaseStatusBarValue();
void scanCategory(const QString &);
void scanPath(const QString &);
public slots:
void showAdditionalData(AddWidget pWidgetType, AddWidgetState pState = NonModal);
private slots: private slots:
void createNewFolderSlot(QString pStr); void createNewFolderSlot(QString pStr);
@ -214,7 +220,6 @@ private slots:
void scanStarted(); void scanStarted();
void scanFinished(); void scanFinished();
void increaseStatusBarValue();
private: private:
@ -252,6 +257,27 @@ private:
}; };
class UBFeaturesProgressInfo: public QWidget {
Q_OBJECT
public:
UBFeaturesProgressInfo(QWidget *parent = 0);
private slots:
void setCommmonInfoText(const QString &str);
void setDetailedInfoText(const QString &str);
void setProgressMin(int pValue);
void setProgressMax(int pValue);
void increaseProgressValue();
void sendFeature(UBFeature pFeature);
private:
QProgressBar *mProgressBar;
QLabel *mCommonInfoLabel;
QLabel *mDetailedInfoLabel;
};
class UBFeaturesWebView : public QWidget class UBFeaturesWebView : public QWidget
{ {
Q_OBJECT Q_OBJECT

@ -33,8 +33,8 @@ UBRubberBand::UBRubberBand(Shape s, QWidget * p)
: QRubberBand(s, p) : QRubberBand(s, p)
, mResizingMode(None) , mResizingMode(None)
, mMouseIsPressed(false) , mMouseIsPressed(false)
, mLastPressedPoint(QPoint())
, mResizingBorderHeight(20) , mResizingBorderHeight(20)
, mLastPressedPoint(QPoint())
{ {
customStyle = NULL; customStyle = NULL;

@ -126,6 +126,11 @@ UBTeacherGuideEditionWidget::UBTeacherGuideEditionWidget(QWidget *parent, const
connect(mpTreeWidget, SIGNAL(itemClicked(QTreeWidgetItem*,int)), this, SLOT(onAddItemClicked(QTreeWidgetItem*,int))); connect(mpTreeWidget, SIGNAL(itemClicked(QTreeWidgetItem*,int)), this, SLOT(onAddItemClicked(QTreeWidgetItem*,int)));
connect(UBApplication::boardController, SIGNAL(activeSceneChanged()), this, SLOT(onActiveSceneChanged())); connect(UBApplication::boardController, SIGNAL(activeSceneChanged()), this, SLOT(onActiveSceneChanged()));
#ifdef Q_WS_MAC
// on mac and with the custom qt the widget on the tree are not automatically relocated when using the vertical scrollbar. To relocate them we link the valueChange signal of the vertical scrollbar witht a local signal to trig a change and a repaint of the tree widget
connect(mpTreeWidget->verticalScrollBar(),SIGNAL(valueChanged(int)),this,SLOT(onSliderMoved(int)));
#endif
mpAddAnActionItem = new UBAddItem(tr("Add an action"), eUBTGAddSubItemWidgetType_Action, mpTreeWidget); mpAddAnActionItem = new UBAddItem(tr("Add an action"), eUBTGAddSubItemWidgetType_Action, mpTreeWidget);
mpAddAMediaItem = new UBAddItem(tr("Add a media"), eUBTGAddSubItemWidgetType_Media, mpTreeWidget); mpAddAMediaItem = new UBAddItem(tr("Add a media"), eUBTGAddSubItemWidgetType_Media, mpTreeWidget);
mpAddALinkItem = new UBAddItem(tr("Add a link"), eUBTGAddSubItemWidgetType_Url, mpTreeWidget); mpAddALinkItem = new UBAddItem(tr("Add a link"), eUBTGAddSubItemWidgetType_Url, mpTreeWidget);
@ -154,6 +159,13 @@ UBTeacherGuideEditionWidget::~UBTeacherGuideEditionWidget()
DELETEPTR(mpLayout); DELETEPTR(mpLayout);
} }
#ifdef Q_WS_MAC
void UBTeacherGuideEditionWidget::onSliderMoved(int size)
{
Q_UNUSED(size);
mpAddAMediaItem->setExpanded(true);
}
#endif
void UBTeacherGuideEditionWidget::showEvent(QShowEvent* event) void UBTeacherGuideEditionWidget::showEvent(QShowEvent* event)
{ {
setFocus(); setFocus();
@ -322,7 +334,7 @@ void UBTeacherGuideEditionWidget::onAddItemClicked(QTreeWidgetItem* widget, int
UBTGMediaWidget* mediaWidget = new UBTGMediaWidget(widget); UBTGMediaWidget* mediaWidget = new UBTGMediaWidget(widget);
if (element) if (element)
mediaWidget->initializeWithDom(*element); mediaWidget->initializeWithDom(*element);
mpTreeWidget->setItemWidget(newWidgetItem, 0, mediaWidget); mpTreeWidget->setItemWidget(newWidgetItem,0, mediaWidget);
break; break;
} }
case eUBTGAddSubItemWidgetType_Url: { case eUBTGAddSubItemWidgetType_Url: {

@ -75,7 +75,9 @@ private:
private slots: private slots:
void onActiveDocumentChanged(); void onActiveDocumentChanged();
#ifdef Q_WS_MACX
void onSliderMoved(int size);
#endif
}; };

@ -14,38 +14,33 @@
*/ */
#include <QtGui> #include <QtGui>
#include "UBToolWidget.h" #include "UBToolWidget.h"
#include "frameworks/UBPlatformUtils.h"
#include "frameworks/UBFileSystemUtils.h"
#include "core/UBApplication.h"
#include "core/UBSettings.h"
#include "domain/UBGraphicsScene.h"
#include "domain/UBGraphicsWidgetItem.h"
#include "api/UBWidgetUniboardAPI.h" #include "api/UBWidgetUniboardAPI.h"
#include "api/UBW3CWidgetAPI.h" #include "api/UBW3CWidgetAPI.h"
#include "board/UBBoardController.h" #include "board/UBBoardController.h"
#include "board/UBBoardView.h" #include "board/UBBoardView.h"
#include "core/UBApplication.h"
#include "core/UBSettings.h"
#include "domain/UBGraphicsScene.h"
#include "domain/UBGraphicsWidgetItem.h"
#include "frameworks/UBPlatformUtils.h"
#include "frameworks/UBFileSystemUtils.h"
#include "core/memcheck.h" #include "core/memcheck.h"
QPixmap* UBToolWidget::sClosePixmap = 0; QPixmap* UBToolWidget::sClosePixmap = 0;
QPixmap* UBToolWidget::sUnpinPixmap = 0; QPixmap* UBToolWidget::sUnpinPixmap = 0;
UBToolWidget::UBToolWidget(const QUrl& pUrl, QGraphicsItem *pParent) UBToolWidget::UBToolWidget(const QUrl& pUrl, QGraphicsItem *pParent)
: QGraphicsWidget(pParent, Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint) : QGraphicsWidget(pParent, Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint)
, mGraphicsWidgetItem(0)
, mGraphicsWebView(0)
, mShouldMoveWidget(false) , mShouldMoveWidget(false)
, mContentMargin(0)
, mFrameWidth(0)
, mGraphicsWebView(0)
, mGraphicsWidgetItem(0)
{ {
int widgetType = UBGraphicsWidgetItem::widgetType(pUrl); int widgetType = UBGraphicsWidgetItem::widgetType(pUrl);
if (widgetType == UBWidgetType::Apple) if (widgetType == UBWidgetType::Apple)
mGraphicsWidgetItem = new UBGraphicsAppleWidgetItem(pUrl, this); mGraphicsWidgetItem = new UBGraphicsAppleWidgetItem(pUrl, this);
else if (widgetType == UBWidgetType::W3C) else if (widgetType == UBWidgetType::W3C)
@ -56,25 +51,23 @@ UBToolWidget::UBToolWidget(const QUrl& pUrl, QGraphicsItem *pParent)
initialize(); initialize();
} }
UBToolWidget::UBToolWidget(UBGraphicsWidgetItem *pWidget, QGraphicsItem *pParent) UBToolWidget::UBToolWidget(UBGraphicsWidgetItem *pWidget, QGraphicsItem *pParent)
: QGraphicsWidget(pParent, Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint) : QGraphicsWidget(pParent, Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint)
, mShouldMoveWidget(false) , mShouldMoveWidget(false)
, mContentMargin(0)
, mFrameWidth(0)
, mGraphicsWebView(0)
, mGraphicsWidgetItem(pWidget)
{ {
mGraphicsWidgetItem = pWidget;
initialize(); initialize();
javaScriptWindowObjectCleared(); javaScriptWindowObjectCleared();
} }
UBToolWidget::~UBToolWidget() UBToolWidget::~UBToolWidget()
{ {
// NOOP // NOOP
} }
void UBToolWidget::initialize() void UBToolWidget::initialize()
{ {
if (!sClosePixmap) if (!sClosePixmap)
@ -108,131 +101,85 @@ void UBToolWidget::initialize()
connect(UBApplication::boardController, SIGNAL(activeSceneChanged()), this, SLOT(javaScriptWindowObjectCleared())); connect(UBApplication::boardController, SIGNAL(activeSceneChanged()), this, SLOT(javaScriptWindowObjectCleared()));
} }
bool UBToolWidget::event(QEvent *event)
void UBToolWidget::javaScriptWindowObjectCleared()
{
UBWidgetUniboardAPI *uniboardAPI = new UBWidgetUniboardAPI(UBApplication::boardController->activeScene(), mGraphicsWidgetItem);
mGraphicsWebView->page()->mainFrame()->addToJavaScriptWindowObject("sankore", uniboardAPI);
UBGraphicsW3CWidgetItem *graphicsW3cWidgetItem = dynamic_cast<UBGraphicsW3CWidgetItem*>(mGraphicsWidgetItem);
if (graphicsW3cWidgetItem)
{
UBW3CWidgetAPI* widgetAPI = new UBW3CWidgetAPI(graphicsW3cWidgetItem);
mGraphicsWebView->page()->mainFrame()->addToJavaScriptWindowObject("widget", widgetAPI);
}
}
void UBToolWidget::setPos(const QPointF &point)
{ {
UBToolWidget::setPos(point.x(), point.y()); if (event->type() == QEvent::ShortcutOverride)
} event->accept();
return QGraphicsWidget::event(event);
void UBToolWidget::setPos(qreal x, qreal y)
{
QGraphicsItem::setPos(x - mContentMargin * scale(), y - mContentMargin * scale());
}
QPointF UBToolWidget::pos() const
{
return QPointF(QGraphicsItem::pos().x() + mContentMargin * scale(), QGraphicsItem::pos().y() + mContentMargin * scale());
}
void UBToolWidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
QGraphicsWidget::paint(painter, option, widget);
if (isActiveWindow())
{
painter->setRenderHint(QPainter::Antialiasing);
painter->setPen(Qt::NoPen);
painter->setBrush(QColor(127, 127, 127, 127));
painter->drawRoundedRect(QRectF(sClosePixmap->width() / 2, sClosePixmap->height() / 2, preferredWidth() - sClosePixmap->width(), mFrameWidth), mFrameWidth / 2, mFrameWidth / 2);
painter->drawPixmap(0, 0, *sClosePixmap);
if (mGraphicsWidgetItem->canBeContent())
painter->drawPixmap(mContentMargin, 0, *sUnpinPixmap);
}
} }
void UBToolWidget::mousePressEvent(QGraphicsSceneMouseEvent *event) void UBToolWidget::mousePressEvent(QGraphicsSceneMouseEvent *event)
{ {
QGraphicsWidget::mousePressEvent(event); QGraphicsWidget::mousePressEvent(event);
// did webkit consume the mouse press ? /* did webkit consume the mouse press ? */
mShouldMoveWidget = !event->isAccepted() && (event->buttons() & Qt::LeftButton); mShouldMoveWidget = !event->isAccepted() && (event->buttons() & Qt::LeftButton);
mMousePressPos = event->pos(); mMousePressPos = event->pos();
event->accept(); event->accept();
update(); update();
} }
void UBToolWidget::mouseMoveEvent(QGraphicsSceneMouseEvent *event) void UBToolWidget::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{ {
if(mShouldMoveWidget && (event->buttons() & Qt::LeftButton)) if(mShouldMoveWidget && (event->buttons() & Qt::LeftButton)) {
{
setPos(pos() - mMousePressPos + event->pos()); setPos(pos() - mMousePressPos + event->pos());
event->accept(); event->accept();
} }
QGraphicsWidget::mouseMoveEvent(event); QGraphicsWidget::mouseMoveEvent(event);
} }
void UBToolWidget::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) void UBToolWidget::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{ {
mShouldMoveWidget = false; mShouldMoveWidget = false;
if (event->pos().x() >= 0 && event->pos().x() < sClosePixmap->width() if (event->pos().x() >= 0 && event->pos().x() < sClosePixmap->width() && event->pos().y() >= 0 && event->pos().y() < sClosePixmap->height()) {
&& event->pos().y() >= 0 && event->pos().y() < sClosePixmap->height())
{
remove(); remove();
event->accept(); event->accept();
} }
else if (mGraphicsWidgetItem->canBeContent() && event->pos().x() >= mContentMargin && event->pos().x() < mContentMargin + sUnpinPixmap->width() else if (mGraphicsWidgetItem->canBeContent() && event->pos().x() >= mContentMargin && event->pos().x() < mContentMargin + sUnpinPixmap->width() && event->pos().y() >= 0 && event->pos().y() < sUnpinPixmap->height()) {
&& event->pos().y() >= 0 && event->pos().y() < sUnpinPixmap->height())
{
UBApplication::boardController->moveToolWidgetToScene(this); UBApplication::boardController->moveToolWidgetToScene(this);
event->accept(); event->accept();
} }
else else
QGraphicsWidget::mouseReleaseEvent(event); // don't propgate to parent, the widget is deleted in UBApplication::boardController->removeTool QGraphicsWidget::mouseReleaseEvent(event); /* don't propgate to parent, the widget is deleted in UBApplication */
} }
void UBToolWidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
bool UBToolWidget::eventFilter(QObject *obj, QEvent *event)
{ {
if (mShouldMoveWidget && obj == mGraphicsWidgetItem && event->type() == QEvent::MouseMove) QGraphicsWidget::paint(painter, option, widget);
{
QMouseEvent *mouseMoveEvent = static_cast<QMouseEvent*>(event);
if (mouseMoveEvent->buttons() & Qt::LeftButton) /* painting lightweight toolbar */
{ if (isActiveWindow()) {
setPos(pos() - mMousePressPos + mGraphicsWidgetItem->mapToItem(this, mouseMoveEvent->pos())); painter->setRenderHint(QPainter::Antialiasing);
painter->setPen(Qt::NoPen);
painter->setBrush(QColor(127, 127, 127, 127));
event->accept(); painter->drawRoundedRect(QRectF(sClosePixmap->width() / 2, sClosePixmap->height() / 2, preferredWidth() - sClosePixmap->width(), mFrameWidth), mFrameWidth / 2, mFrameWidth / 2);
return true; painter->drawPixmap(0, 0, *sClosePixmap);
} if (mGraphicsWidgetItem->canBeContent())
painter->drawPixmap(mContentMargin, 0, *sUnpinPixmap);
} }
// standard event processing
return QObject::eventFilter(obj, event);
} }
void UBToolWidget::javaScriptWindowObjectCleared()
void UBToolWidget::centerOn(const QPointF& pos)
{ {
QGraphicsWidget::setPos(pos - QPointF(preferredWidth() / 2, preferredHeight() / 2)); UBWidgetUniboardAPI *uniboardAPI = new UBWidgetUniboardAPI(UBApplication::boardController->activeScene(), mGraphicsWidgetItem);
mGraphicsWebView->page()->mainFrame()->addToJavaScriptWindowObject("sankore", uniboardAPI);
UBGraphicsW3CWidgetItem *graphicsW3cWidgetItem = dynamic_cast<UBGraphicsW3CWidgetItem*>(mGraphicsWidgetItem);
if (graphicsW3cWidgetItem)
{
UBW3CWidgetAPI* widgetAPI = new UBW3CWidgetAPI(graphicsW3cWidgetItem);
mGraphicsWebView->page()->mainFrame()->addToJavaScriptWindowObject("widget", widgetAPI);
}
} }
UBGraphicsWidgetItem* UBToolWidget::graphicsWidgetItem() const
{
return mGraphicsWidgetItem;
}
QPointF UBToolWidget::naturalCenter() const QPointF UBToolWidget::naturalCenter() const
{ {
@ -242,10 +189,15 @@ QPointF UBToolWidget::naturalCenter() const
return QPointF(0, 0); return QPointF(0, 0);
} }
void UBToolWidget::centerOn(const QPointF& pos)
{
QGraphicsWidget::setPos(pos - QPointF(preferredWidth() / 2, preferredHeight() / 2));
}
UBGraphicsWidgetItem* UBToolWidget::graphicsWidgetItem() const void UBToolWidget::remove()
{ {
return mGraphicsWidgetItem; mGraphicsWebView->setHtml(QString());
scene()->removeItem(this);
} }
UBGraphicsScene* UBToolWidget::scene() UBGraphicsScene* UBToolWidget::scene()
@ -253,8 +205,22 @@ UBGraphicsScene* UBToolWidget::scene()
return qobject_cast<UBGraphicsScene*>(QGraphicsItem::scene()); return qobject_cast<UBGraphicsScene*>(QGraphicsItem::scene());
} }
void UBToolWidget::remove() QPointF UBToolWidget::pos() const
{ {
mGraphicsWebView->setHtml(QString()); return QPointF(QGraphicsItem::pos().x() + mContentMargin * scale(), QGraphicsItem::pos().y() + mContentMargin * scale());
scene()->removeItem(this); }
void UBToolWidget::setPos(const QPointF &point)
{
UBToolWidget::setPos(point.x(), point.y());
}
void UBToolWidget::setPos(qreal x, qreal y)
{
QGraphicsItem::setPos(x - mContentMargin * scale(), y - mContentMargin * scale());
}
int UBToolWidget::type() const
{
return Type;
} }

@ -18,10 +18,10 @@
#include <QtGui> #include <QtGui>
#include <QtWebKit> #include <QtWebKit>
#include "core/UB.h"
class UBGraphicsWidgetItem;
class QWidget;
class UBGraphicsScene; class UBGraphicsScene;
class UBGraphicsWidgetItem;
class UBToolWidget : public QGraphicsWidget class UBToolWidget : public QGraphicsWidget
{ {
@ -32,44 +32,45 @@ class UBToolWidget : public QGraphicsWidget
UBToolWidget(UBGraphicsWidgetItem* pGraphicsWidgetItem, QGraphicsItem *pParent = 0); UBToolWidget(UBGraphicsWidgetItem* pGraphicsWidgetItem, QGraphicsItem *pParent = 0);
virtual ~UBToolWidget(); virtual ~UBToolWidget();
void centerOn(const QPointF& pos); UBGraphicsWidgetItem* graphicsWidgetItem() const;
QPointF naturalCenter() const; QPointF naturalCenter() const;
UBGraphicsWidgetItem* graphicsWidgetItem() const; void centerOn(const QPointF& pos);
void remove(); void remove();
virtual UBGraphicsScene* scene(); virtual UBGraphicsScene* scene();
virtual QPointF pos() const;
virtual void setPos(const QPointF &point); virtual void setPos(const QPointF &point);
virtual void setPos(qreal x, qreal y); virtual void setPos(qreal x, qreal y);
virtual QPointF pos() const; virtual int type() const;
enum
{
Type = UBGraphicsItemType::ToolWidgetItemType
};
protected: protected:
void initialize(); void initialize();
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
virtual bool event(QEvent *event);
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event); virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event); virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
virtual bool eventFilter(QObject *obj, QEvent *event);
private slots: private slots:
void javaScriptWindowObjectCleared(); void javaScriptWindowObjectCleared();
protected: protected:
static QPixmap *sClosePixmap;
static QPixmap *sUnpinPixmap;
UBGraphicsWidgetItem *mGraphicsWidgetItem;
QGraphicsWebView *mGraphicsWebView;
QPointF mMousePressPos;
bool mShouldMoveWidget; bool mShouldMoveWidget;
int mContentMargin; int mContentMargin;
int mFrameWidth; int mFrameWidth;
QGraphicsWebView *mGraphicsWebView;
UBGraphicsWidgetItem *mGraphicsWidgetItem;
QPointF mMousePressPos;
static QPixmap *sClosePixmap;
static QPixmap *sUnpinPixmap;
}; };
#endif /* UBTOOLWIDGET_H_ */ #endif /* UBTOOLWIDGET_H_ */

@ -139,7 +139,7 @@ QString UBAudioQueueRecorder::deviceUIDFromDeviceID(AudioDeviceID id)
{ {
char *cname = new char[1024]; char *cname = new char[1024];
bool result = CFStringGetCString (name, cname, 1024, kCFStringEncodingASCII); CFStringGetCString (name, cname, 1024, kCFStringEncodingASCII);
int length = CFStringGetLength (name); int length = CFStringGetLength (name);
uid = QString::fromAscii(cname, length); uid = QString::fromAscii(cname, length);

@ -151,7 +151,7 @@ bool UBQuickTimeFile::createCompressionSession()
} }
OSStatus err = noErr; OSStatus err = noErr;
ICMEncodedFrameOutputRecord encodedFrameOutputRecord = {0}; ICMEncodedFrameOutputRecord encodedFrameOutputRecord = {NULL, NULL, NULL};
ICMCompressionSessionOptionsRef sessionOptions = 0; ICMCompressionSessionOptionsRef sessionOptions = 0;
err = ICMCompressionSessionOptionsCreate(0, &sessionOptions); err = ICMCompressionSessionOptionsCreate(0, &sessionOptions);

@ -719,15 +719,16 @@ bool UBWebController::isEduMedia(const QUrl& pUrl)
void UBWebController::loadUrl(const QUrl& url) void UBWebController::loadUrl(const QUrl& url)
{ {
UBApplication::applicationController->showInternet();
if (UBSettings::settings()->webUseExternalBrowser->get().toBool()) if (UBSettings::settings()->webUseExternalBrowser->get().toBool())
{ {
QDesktopServices::openUrl(url); QDesktopServices::openUrl(url);
} }
else else
{ {
UBApplication::applicationController->showInternet(); bool webBrowserAlreadyInstanciated = mStackedWidget->widget(WebBrowser) != NULL;
if (mCurrentWebBrowser && !(*mCurrentWebBrowser)) { if (!webBrowserAlreadyInstanciated) {
(*mCurrentWebBrowser)->loadUrl(url); (*mCurrentWebBrowser)->loadUrl(url);
} }
else { else {

Loading…
Cancel
Save