From b1bdf7f0b9b8386bc11843856a132f3c29f22ce8 Mon Sep 17 00:00:00 2001 From: Claudio Valerio Date: Wed, 23 May 2012 11:58:06 +0200 Subject: [PATCH 1/9] removed unused settings --- src/core/UBSettings.cpp | 1 - src/core/UBSettings.h | 1 - src/gui/UBNavigatorPalette.cpp | 1 - 3 files changed, 3 deletions(-) diff --git a/src/core/UBSettings.cpp b/src/core/UBSettings.cpp index 78d3fd54..c6109e0c 100644 --- a/src/core/UBSettings.cpp +++ b/src/core/UBSettings.cpp @@ -204,7 +204,6 @@ void UBSettings::init() appEnableAutomaticSoftwareUpdates = new UBSetting(this, "App", "EnableAutomaticSoftwareUpdates", true); appEnableSoftwareUpdates = new UBSetting(this, "App", "EnableSoftwareUpdates", true); appToolBarOrientationVertical = new UBSetting(this, "App", "ToolBarOrientationVertical", false); - navigPaletteWidth = new UBSetting(this, "Board", "NavigPaletteWidth", 270); rightLibPaletteWidth = new UBSetting(this, "Board", "RightLibPaletteWidth", 270); rightLibPaletteIsCollapsed = new UBSetting(this,"Board", "RightLibPaletteIsCollapsed",false); leftLibPaletteWidth = new UBSetting(this, "Board", "LeftLibPaletteWidth",270); diff --git a/src/core/UBSettings.h b/src/core/UBSettings.h index acb4b28a..10ff0f64 100644 --- a/src/core/UBSettings.h +++ b/src/core/UBSettings.h @@ -314,7 +314,6 @@ class UBSettings : public QObject UBSetting* gipThumbnailWidth; UBSetting* soundThumbnailWidth; - UBSetting* navigPaletteWidth; UBSetting* rightLibPaletteWidth; UBSetting* rightLibPaletteIsCollapsed; UBSetting* leftLibPaletteWidth; diff --git a/src/gui/UBNavigatorPalette.cpp b/src/gui/UBNavigatorPalette.cpp index 4ffdb342..df67c67e 100644 --- a/src/gui/UBNavigatorPalette.cpp +++ b/src/gui/UBNavigatorPalette.cpp @@ -145,7 +145,6 @@ void UBNavigatorPalette::resizeEvent(QResizeEvent *event) { mNavigator->setMinimumHeight(height() - 2*border()); } - UBSettings::settings()->navigPaletteWidth->set(width()); } void UBNavigatorPalette::timerEvent(QTimerEvent *event) From b42afc9e6d0c28805bc2a1185886c555feaf4020 Mon Sep 17 00:00:00 2001 From: Claudio Valerio Date: Wed, 23 May 2012 14:21:24 +0200 Subject: [PATCH 2/9] fixed issue 622 --- src/core/UBSettings.cpp | 12 ++++++---- src/core/UBSettings.h | 12 ++++++---- src/gui/UBDockPalette.cpp | 1 + src/gui/UBDockPalette.h | 2 ++ src/gui/UBLeftPalette.cpp | 47 +++++++++++++++++++++++++++++++++----- src/gui/UBLeftPalette.h | 2 ++ src/gui/UBRightPalette.cpp | 47 ++++++++++++++++++++++++++++++++------ src/gui/UBRightPalette.h | 2 ++ 8 files changed, 104 insertions(+), 21 deletions(-) diff --git a/src/core/UBSettings.cpp b/src/core/UBSettings.cpp index c6109e0c..b8450d19 100644 --- a/src/core/UBSettings.cpp +++ b/src/core/UBSettings.cpp @@ -204,10 +204,14 @@ void UBSettings::init() appEnableAutomaticSoftwareUpdates = new UBSetting(this, "App", "EnableAutomaticSoftwareUpdates", true); appEnableSoftwareUpdates = new UBSetting(this, "App", "EnableSoftwareUpdates", true); appToolBarOrientationVertical = new UBSetting(this, "App", "ToolBarOrientationVertical", false); - rightLibPaletteWidth = new UBSetting(this, "Board", "RightLibPaletteWidth", 270); - rightLibPaletteIsCollapsed = new UBSetting(this,"Board", "RightLibPaletteIsCollapsed",false); - leftLibPaletteWidth = new UBSetting(this, "Board", "LeftLibPaletteWidth",270); - leftLibPaletteIsCollapsed = new UBSetting(this,"Board","LeftLibPaletteIsCollapsed",false); + rightLibPaletteBoardModeWidth = new UBSetting(this, "Board", "RightLibPaletteBoardModeWidth", 270); + rightLibPaletteBoardModeIsCollapsed = new UBSetting(this,"Board", "RightLibPaletteBoardModeIsCollapsed",false); + rightLibPaletteDesktopModeWidth = new UBSetting(this, "Board", "RightLibPaletteDesktopModeWidth", 270); + rightLibPaletteDesktopModeIsCollapsed = new UBSetting(this,"Board", "RightLibPaletteDesktopModeIsCollapsed",false); + leftLibPaletteBoardModeWidth = new UBSetting(this, "Board", "LeftLibPaletteBoardModeWidth",270); + leftLibPaletteBoardModeIsCollapsed = new UBSetting(this,"Board","LeftLibPaletteBoardModeIsCollapsed",false); + leftLibPaletteDesktopModeWidth = new UBSetting(this, "Board", "LeftLibPaletteDesktopModeWidth",270); + leftLibPaletteDesktopModeIsCollapsed = new UBSetting(this,"Board","LeftLibPaletteDesktopModeIsCollapsed",false); appIsInSoftwareUpdateProcess = new UBSetting(this, "App", "IsInSoftwareUpdateProcess", false); appLastSessionDocumentUUID = new UBSetting(this, "App", "LastSessionDocumentUUID", ""); diff --git a/src/core/UBSettings.h b/src/core/UBSettings.h index 10ff0f64..c928b6fa 100644 --- a/src/core/UBSettings.h +++ b/src/core/UBSettings.h @@ -314,10 +314,14 @@ class UBSettings : public QObject UBSetting* gipThumbnailWidth; UBSetting* soundThumbnailWidth; - UBSetting* rightLibPaletteWidth; - UBSetting* rightLibPaletteIsCollapsed; - UBSetting* leftLibPaletteWidth; - UBSetting* leftLibPaletteIsCollapsed; + UBSetting* rightLibPaletteBoardModeWidth; + UBSetting* rightLibPaletteBoardModeIsCollapsed; + UBSetting* rightLibPaletteDesktopModeWidth; + UBSetting* rightLibPaletteDesktopModeIsCollapsed; + UBSetting* leftLibPaletteBoardModeWidth; + UBSetting* leftLibPaletteBoardModeIsCollapsed; + UBSetting* leftLibPaletteDesktopModeWidth; + UBSetting* leftLibPaletteDesktopModeIsCollapsed; UBSetting* communityUser; UBSetting* communityPsw; diff --git a/src/gui/UBDockPalette.cpp b/src/gui/UBDockPalette.cpp index 70af85f9..293684fd 100644 --- a/src/gui/UBDockPalette.cpp +++ b/src/gui/UBDockPalette.cpp @@ -531,6 +531,7 @@ void UBDockPalette::setVisible(bool visible) bool UBDockPalette::switchMode(eUBDockPaletteWidgetMode mode) { + mCurrentMode = mode; bool hasVisibleElements = false; //-------------------------------// // get full palette widgets list, parse it, show all widgets for BOARD mode, and hide all other diff --git a/src/gui/UBDockPalette.h b/src/gui/UBDockPalette.h index 9efeeec0..569f391b 100644 --- a/src/gui/UBDockPalette.h +++ b/src/gui/UBDockPalette.h @@ -115,6 +115,8 @@ public: bool switchMode(eUBDockPaletteWidgetMode mode); + eUBDockPaletteWidgetMode mCurrentMode; + QVector GetWidgetsList() { return mRegisteredWidgets; } public: diff --git a/src/gui/UBLeftPalette.cpp b/src/gui/UBLeftPalette.cpp index 21b3521b..fab827c6 100644 --- a/src/gui/UBLeftPalette.cpp +++ b/src/gui/UBLeftPalette.cpp @@ -25,11 +25,19 @@ UBLeftPalette::UBLeftPalette(QWidget *parent, const char *name): { setObjectName(name); setOrientation(eUBDockOrientation_Left); - - mLastWidth = UBSettings::settings()->leftLibPaletteWidth->get().toInt(); mCollapseWidth = 150; - if(UBSettings::settings()->leftLibPaletteIsCollapsed->get().toBool()) + bool isCollapsed = false; + if(mCurrentMode == eUBDockPaletteWidget_BOARD){ + mLastWidth = UBSettings::settings()->leftLibPaletteBoardModeWidth->get().toInt(); + isCollapsed = UBSettings::settings()->leftLibPaletteBoardModeIsCollapsed->get().toBool(); + } + else{ + mLastWidth = UBSettings::settings()->leftLibPaletteDesktopModeWidth->get().toInt(); + isCollapsed = UBSettings::settings()->leftLibPaletteDesktopModeIsCollapsed->get().toBool(); + } + + if(isCollapsed) resize(0,parentWidget()->height()); else resize(mLastWidth, parentWidget()->height()); @@ -58,8 +66,35 @@ void UBLeftPalette::updateMaxWidth() void UBLeftPalette::resizeEvent(QResizeEvent *event) { int newWidth = width(); - if(newWidth > mCollapseWidth) - UBSettings::settings()->leftLibPaletteWidth->set(newWidth); - UBSettings::settings()->leftLibPaletteIsCollapsed->set(newWidth == 0); + if(mCurrentMode == eUBDockPaletteWidget_BOARD){ + if(newWidth > mCollapseWidth) + UBSettings::settings()->leftLibPaletteBoardModeWidth->set(newWidth); + UBSettings::settings()->leftLibPaletteBoardModeIsCollapsed->set(newWidth == 0); + } + else{ + if(newWidth > mCollapseWidth) + UBSettings::settings()->leftLibPaletteDesktopModeWidth->set(newWidth); + UBSettings::settings()->leftLibPaletteDesktopModeIsCollapsed->set(newWidth == 0); + } UBDockPalette::resizeEvent(event); } + + +bool UBLeftPalette::switchMode(eUBDockPaletteWidgetMode mode) +{ + int newModeWidth; + if(mode == eUBDockPaletteWidget_BOARD){ + mLastWidth = UBSettings::settings()->leftLibPaletteBoardModeWidth->get().toInt(); + newModeWidth = mLastWidth; + if(UBSettings::settings()->leftLibPaletteBoardModeIsCollapsed->get().toBool()) + newModeWidth = 0; + } + else{ + mLastWidth = UBSettings::settings()->leftLibPaletteDesktopModeWidth->get().toInt(); + newModeWidth = mLastWidth; + if(UBSettings::settings()->leftLibPaletteDesktopModeIsCollapsed->get().toBool()) + newModeWidth = 0; + } + resize(newModeWidth,height()); + return UBDockPalette::switchMode(mode); +} diff --git a/src/gui/UBLeftPalette.h b/src/gui/UBLeftPalette.h index cdb49330..8ae3bdf3 100644 --- a/src/gui/UBLeftPalette.h +++ b/src/gui/UBLeftPalette.h @@ -23,6 +23,8 @@ public: UBLeftPalette(QWidget* parent=0, const char* name="UBLeftPalette"); ~UBLeftPalette(); + bool switchMode(eUBDockPaletteWidgetMode mode); + protected: void updateMaxWidth(); void resizeEvent(QResizeEvent *event); diff --git a/src/gui/UBRightPalette.cpp b/src/gui/UBRightPalette.cpp index 9762b5e8..be8205c2 100644 --- a/src/gui/UBRightPalette.cpp +++ b/src/gui/UBRightPalette.cpp @@ -28,9 +28,16 @@ UBRightPalette::UBRightPalette(QWidget *parent, const char *name): setObjectName(name); setOrientation(eUBDockOrientation_Right); mCollapseWidth = 150; - - mLastWidth = UBSettings::settings()->rightLibPaletteWidth->get().toInt(); - if(UBSettings::settings()->rightLibPaletteIsCollapsed->get().toBool()) + bool isCollapsed = false; + if(mCurrentMode == eUBDockPaletteWidget_BOARD){ + mLastWidth = UBSettings::settings()->rightLibPaletteBoardModeWidth->get().toInt(); + isCollapsed = UBSettings::settings()->rightLibPaletteBoardModeIsCollapsed->get().toBool(); + } + else{ + mLastWidth = UBSettings::settings()->rightLibPaletteDesktopModeWidth->get().toInt(); + isCollapsed = UBSettings::settings()->rightLibPaletteDesktopModeIsCollapsed->get().toBool(); + } + if(isCollapsed) resize(0,parentWidget()->height()); else resize(mLastWidth, parentWidget()->height()); @@ -62,10 +69,17 @@ void UBRightPalette::mouseMoveEvent(QMouseEvent *event) void UBRightPalette::resizeEvent(QResizeEvent *event) { int newWidth = width(); - if(newWidth > mCollapseWidth) - UBSettings::settings()->rightLibPaletteWidth->set(newWidth); - UBSettings::settings()->rightLibPaletteIsCollapsed->set(newWidth == 0); - UBDockPalette::resizeEvent(event); + if(mCurrentMode == eUBDockPaletteWidget_BOARD){ + if(newWidth > mCollapseWidth) + UBSettings::settings()->rightLibPaletteBoardModeWidth->set(newWidth); + UBSettings::settings()->rightLibPaletteBoardModeIsCollapsed->set(newWidth == 0); + } + else{ + if(newWidth > mCollapseWidth) + UBSettings::settings()->rightLibPaletteDesktopModeWidth->set(newWidth); + UBSettings::settings()->rightLibPaletteDesktopModeIsCollapsed->set(newWidth == 0); + } + UBDockPalette::resizeEvent(event); emit resized(); } @@ -78,3 +92,22 @@ void UBRightPalette::updateMaxWidth() setMaximumHeight(parentWidget()->height()); setMinimumHeight(parentWidget()->height()); } + +bool UBRightPalette::switchMode(eUBDockPaletteWidgetMode mode) +{ + int newModeWidth; + if(mode == eUBDockPaletteWidget_BOARD){ + mLastWidth = UBSettings::settings()->rightLibPaletteBoardModeWidth->get().toInt(); + newModeWidth = mLastWidth; + if(UBSettings::settings()->rightLibPaletteBoardModeIsCollapsed->get().toBool()) + newModeWidth = 0; + } + else{ + mLastWidth = UBSettings::settings()->rightLibPaletteDesktopModeWidth->get().toInt(); + newModeWidth = mLastWidth; + if(UBSettings::settings()->rightLibPaletteDesktopModeIsCollapsed->get().toBool()) + newModeWidth = 0; + } + resize(newModeWidth,height()); + return UBDockPalette::switchMode(mode); +} diff --git a/src/gui/UBRightPalette.h b/src/gui/UBRightPalette.h index df0e82e5..00e6dd14 100644 --- a/src/gui/UBRightPalette.h +++ b/src/gui/UBRightPalette.h @@ -23,6 +23,7 @@ class UBRightPalette : public UBDockPalette public: UBRightPalette(QWidget* parent=0, const char* name="UBRightPalette"); ~UBRightPalette(); + bool switchMode(eUBDockPaletteWidgetMode mode); signals: void resized(); @@ -31,6 +32,7 @@ protected: void updateMaxWidth(); void mouseMoveEvent(QMouseEvent *event); void resizeEvent(QResizeEvent *event); + }; #endif // UBRIGHTPALETTE_H From ad18a5f46a5bc7db3a2a9dcce252f17687e11d8b Mon Sep 17 00:00:00 2001 From: Anatoly Mihalchenko Date: Wed, 23 May 2012 15:45:13 +0300 Subject: [PATCH 3/9] SANKORE-576 First, lost of text formating. New format and then lost of text. --- src/adaptors/UBSvgSubsetAdaptor.cpp | 32 ++++++++++++++--------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/adaptors/UBSvgSubsetAdaptor.cpp b/src/adaptors/UBSvgSubsetAdaptor.cpp index 8148b66c..f8a98903 100644 --- a/src/adaptors/UBSvgSubsetAdaptor.cpp +++ b/src/adaptors/UBSvgSubsetAdaptor.cpp @@ -2314,6 +2314,22 @@ UBGraphicsTextItem* UBSvgSubsetAdaptor::UBSvgSubsetReader::textItemFromSvg() QStringRef ubFillOnDarkBackground = mXmlReader.attributes().value(mNamespaceUri, "fill-on-dark-background"); QStringRef ubFillOnLightBackground = mXmlReader.attributes().value(mNamespaceUri, "fill-on-light-background"); + if (!ubFillOnDarkBackground.isNull()) { + QColor color; + color.setNamedColor(ubFillOnDarkBackground.toString()); + if (!color.isValid()) + color = Qt::white; + textItem->setColorOnDarkBackground(color); + } + + if (!ubFillOnLightBackground.isNull()) { + QColor color; + color.setNamedColor(ubFillOnLightBackground.toString()); + if (!color.isValid()) + color = Qt::black; + textItem->setColorOnLightBackground(color); + } + QString text; while (!(mXmlReader.isEndElement() && (mXmlReader.name() == "font" || mXmlReader.name() == "foreignObject"))) @@ -2382,22 +2398,6 @@ UBGraphicsTextItem* UBSvgSubsetAdaptor::UBSvgSubsetReader::textItemFromSvg() textItem->setDefaultTextColor(textColor); } - if (!ubFillOnDarkBackground.isNull()) { - QColor color; - color.setNamedColor(ubFillOnDarkBackground.toString()); - if (!color.isValid()) - color = Qt::white; - textItem->setColorOnDarkBackground(color); - } - - if (!ubFillOnLightBackground.isNull()) { - QColor color; - color.setNamedColor(ubFillOnLightBackground.toString()); - if (!color.isValid()) - color = Qt::black; - textItem->setColorOnLightBackground(color); - } - while (!(mXmlReader.isEndElement() && mXmlReader.name() == "font")) { if (mXmlReader.hasError()) { break; From ae98231fa76db65a3e3d0525f4f742ec97f2e47b Mon Sep 17 00:00:00 2001 From: Claudio Valerio Date: Wed, 23 May 2012 17:08:01 +0200 Subject: [PATCH 4/9] fixed script --- release.linux.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/release.linux.sh b/release.linux.sh index 1b2dcd44..e68754d2 100755 --- a/release.linux.sh +++ b/release.linux.sh @@ -52,7 +52,7 @@ if [ ! -f $QT_GUI_TRANSLATIONS ]; then exit 1 else $LRELEASES $QT_GUI_TRANSLATIONS_PRO_FILE -elif +fi VERSION=`cat build/linux/release/version` if [ ! -f build/linux/release/version ]; then @@ -62,8 +62,8 @@ else LAST_COMMITED_VERSION="`git describe $(git rev-list --tags --max-count=1)`" if [ "v$VERSION" != "$LAST_COMMITED_VERSION" ]; then echo creating a tag with the version $VERSION - git tag -a "v$VERSION" -m "Generating setup for v$VERSION" - git push origin --tags +# git tag -a "v$VERSION" -m "Generating setup for v$VERSION" +# git push origin --tags fi fi From 9a43cde3ffd203d3800489ea3690e9b27f11b56e Mon Sep 17 00:00:00 2001 From: Anatoly Mihalchenko Date: Wed, 23 May 2012 18:35:26 +0300 Subject: [PATCH 5/9] SANKORE-566 Interactivities:New interactivities call crash if they will be converted as tool --- src/api/UBWidgetUniboardAPI.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/api/UBWidgetUniboardAPI.cpp b/src/api/UBWidgetUniboardAPI.cpp index 260734ad..71a22881 100644 --- a/src/api/UBWidgetUniboardAPI.cpp +++ b/src/api/UBWidgetUniboardAPI.cpp @@ -467,7 +467,10 @@ void UBWidgetUniboardAPI::sendFileMetadata(QString metaData) void UBWidgetUniboardAPI::enableDropOnWidget(bool enable) { - mGraphicsWidget->setAcceptDrops(enable); + if (mGraphicsWidget) + { + mGraphicsWidget->setAcceptDrops(enable); + } } void UBWidgetUniboardAPI::ProcessDropEvent(QDropEvent *event) From b529da115c617b2641e0ab8eaeab16a3f7442b63 Mon Sep 17 00:00:00 2001 From: Anatoly Mihalchenko Date: Wed, 23 May 2012 19:12:18 +0300 Subject: [PATCH 6/9] SANKORE-615 Text object :commands "ctrl+V" aren't work properly, by the both cases, if text was copied from external apps. --- src/board/UBBoardController.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/board/UBBoardController.cpp b/src/board/UBBoardController.cpp index c1f86511..5ac4af43 100644 --- a/src/board/UBBoardController.cpp +++ b/src/board/UBBoardController.cpp @@ -1959,8 +1959,12 @@ void UBBoardController::processMimeData(const QMimeData* pMimeData, const QPoint if("" != url) { downloadURL(url, pPos); - return; } + else + { + mActiveScene->addTextHtml(qsHtml, pPos); + } + return; } if (pMimeData->hasUrls()) @@ -1996,11 +2000,11 @@ void UBBoardController::processMimeData(const QMimeData* pMimeData, const QPoint if("" != pMimeData->text()){ // Sometimes, it is possible to have an URL as text. we check here if it is the case QString qsTmp = pMimeData->text().remove(QRegExp("[\\0]")); - if(qsTmp.startsWith("http")){ + if(qsTmp.startsWith("http://") || qsTmp.startsWith("https://")){ downloadURL(QUrl(qsTmp), pPos); } else{ - mActiveScene->addTextHtml(pMimeData->html(), pPos); + mActiveScene->addTextHtml(pMimeData->text(), pPos); } } else{ From 8d14c8c83300ffd6f2e9454a06943d7168768545 Mon Sep 17 00:00:00 2001 From: Claudio Valerio Date: Thu, 24 May 2012 11:14:16 +0200 Subject: [PATCH 7/9] fixed path on drop item --- .../library/interactivities/associer_images.wgt/js/script.js | 1 - .../library/interactivities/associer_sounds.wgt/js/script.js | 3 +-- .../interactivities/categoriser_images.wgt/js/script.js | 3 +-- resources/library/interactivities/etudier.wgt/js/script.js | 3 +-- .../interactivities/ordonner_des_images.wgt/js/script.js | 1 - .../interactivities/ordonner_des_letters.wgt/js/script.js | 3 +-- .../interactivities/ordonner_des_lettres.wgt/js/script.js | 3 +-- .../library/interactivities/selectionner.wgt/js/script.js | 1 - 8 files changed, 5 insertions(+), 13 deletions(-) diff --git a/resources/library/interactivities/associer_images.wgt/js/script.js b/resources/library/interactivities/associer_images.wgt/js/script.js index 7d5494cf..8e3829b1 100644 --- a/resources/library/interactivities/associer_images.wgt/js/script.js +++ b/resources/library/interactivities/associer_images.wgt/js/script.js @@ -705,7 +705,6 @@ function onDropTarget(obj, event) { } textData = stringToXML(textData); var tmp = textData.getElementsByTagName("path")[0].firstChild.textContent; - tmp = tmp.substr(1, tmp.length); var tmp_img = $("").attr("src", tmp); $(obj).append(tmp_img); setTimeout(function(){ diff --git a/resources/library/interactivities/associer_sounds.wgt/js/script.js b/resources/library/interactivities/associer_sounds.wgt/js/script.js index 8be79320..1019b85c 100644 --- a/resources/library/interactivities/associer_sounds.wgt/js/script.js +++ b/resources/library/interactivities/associer_sounds.wgt/js/script.js @@ -811,7 +811,6 @@ function onDropAudio(obj, event) { var tmp_type = textData.getElementsByTagName("type")[0].firstChild.textContent; if(tmp_type.substr(0, 5) == "audio"){ var audio_block = $(obj).find(".audio_block"); - tmp = tmp.substr(1, tmp.length); $(obj).find("audio").remove(); audio_block.find(":first-child").removeClass("stop").addClass("play"); var source = $("").attr("src", tmp); @@ -839,4 +838,4 @@ if (window.widget) { $(this).parent().find(":first-child").removeClass("stop").addClass("play"); }); } -} \ No newline at end of file +} diff --git a/resources/library/interactivities/categoriser_images.wgt/js/script.js b/resources/library/interactivities/categoriser_images.wgt/js/script.js index 9951a041..43735020 100644 --- a/resources/library/interactivities/categoriser_images.wgt/js/script.js +++ b/resources/library/interactivities/categoriser_images.wgt/js/script.js @@ -698,7 +698,6 @@ function onDropTarget(obj, event) { textData = stringToXML(textData); if(textData.getElementsByTagName("ready")[0].firstChild.textContent == "true"){ var tmp = textData.getElementsByTagName("path")[0].firstChild.textContent; - tmp = tmp.substr(1, tmp.length); var img_block = $("
"); $("
").appendTo(img_block); $("").appendTo(img_block); @@ -743,4 +742,4 @@ function onDropTarget(obj, event) { event.cancelBubble = true; } return false; -} \ No newline at end of file +} diff --git a/resources/library/interactivities/etudier.wgt/js/script.js b/resources/library/interactivities/etudier.wgt/js/script.js index 52cbbf28..f823c713 100644 --- a/resources/library/interactivities/etudier.wgt/js/script.js +++ b/resources/library/interactivities/etudier.wgt/js/script.js @@ -529,7 +529,6 @@ function onDropTarget(obj, event) { textData = stringToXML(textData); var tmp = textData.getElementsByTagName("path")[0].firstChild.textContent; var tmp_type = textData.getElementsByTagName("type")[0].firstChild.textContent; - tmp = tmp.substr(1, tmp.length); if(tmp_type.substr(0, 5) == "audio"){ var audio_block = $("
").draggable().appendTo($(obj)); audio_block.css("position","absolute").css("top",event.clientY).css("left",event.clientX); @@ -587,4 +586,4 @@ $(window).resize(function(){ $(this).width(slider.width()).height(slider.height()); }); slider.setSize(slider.width(), slider.height()); -}) \ No newline at end of file +}) diff --git a/resources/library/interactivities/ordonner_des_images.wgt/js/script.js b/resources/library/interactivities/ordonner_des_images.wgt/js/script.js index 2dc90199..bd11f808 100644 --- a/resources/library/interactivities/ordonner_des_images.wgt/js/script.js +++ b/resources/library/interactivities/ordonner_des_images.wgt/js/script.js @@ -444,7 +444,6 @@ function onDropTarget(obj, event) { } textData = stringToXML(textData); var tmp = textData.getElementsByTagName("path")[0].firstChild.textContent; - tmp = tmp.substr(1, tmp.length); var tmp_img = $("").attr("src", tmp); $(obj).append(tmp_img); setTimeout(function(){ diff --git a/resources/library/interactivities/ordonner_des_letters.wgt/js/script.js b/resources/library/interactivities/ordonner_des_letters.wgt/js/script.js index 2cf9d4bf..bca8ff38 100644 --- a/resources/library/interactivities/ordonner_des_letters.wgt/js/script.js +++ b/resources/library/interactivities/ordonner_des_letters.wgt/js/script.js @@ -438,7 +438,6 @@ function onDropAudio(obj, event) { var tmp_type = textData.getElementsByTagName("type")[0].firstChild.textContent; if(tmp_type.substr(0, 5) == "audio"){ var audio_block = $(obj).find(".audio_block"); - tmp = tmp.substr(1, tmp.length); $(obj).find("audio").remove(); audio_block.find(":first-child").removeClass("stop").addClass("play"); var source = $("").attr("src", tmp); @@ -466,4 +465,4 @@ if (window.widget) { $(this).parent().find(":first-child").removeClass("stop").addClass("play"); }); } -} \ No newline at end of file +} diff --git a/resources/library/interactivities/ordonner_des_lettres.wgt/js/script.js b/resources/library/interactivities/ordonner_des_lettres.wgt/js/script.js index 2cf9d4bf..bca8ff38 100644 --- a/resources/library/interactivities/ordonner_des_lettres.wgt/js/script.js +++ b/resources/library/interactivities/ordonner_des_lettres.wgt/js/script.js @@ -438,7 +438,6 @@ function onDropAudio(obj, event) { var tmp_type = textData.getElementsByTagName("type")[0].firstChild.textContent; if(tmp_type.substr(0, 5) == "audio"){ var audio_block = $(obj).find(".audio_block"); - tmp = tmp.substr(1, tmp.length); $(obj).find("audio").remove(); audio_block.find(":first-child").removeClass("stop").addClass("play"); var source = $("").attr("src", tmp); @@ -466,4 +465,4 @@ if (window.widget) { $(this).parent().find(":first-child").removeClass("stop").addClass("play"); }); } -} \ No newline at end of file +} diff --git a/resources/library/interactivities/selectionner.wgt/js/script.js b/resources/library/interactivities/selectionner.wgt/js/script.js index 70935ce1..3998aa94 100644 --- a/resources/library/interactivities/selectionner.wgt/js/script.js +++ b/resources/library/interactivities/selectionner.wgt/js/script.js @@ -415,7 +415,6 @@ function onDropTarget(obj, event) { textData = stringToXML(textData); var tmp = textData.getElementsByTagName("path")[0].firstChild.textContent; var tmp_type = textData.getElementsByTagName("type")[0].firstChild.textContent; - tmp = tmp.substr(1, tmp.length); if(tmp_type.substr(0, 5) == "audio"){ var img_tmp = $("
").insertBefore($(obj).find(".add_img")); var audio_block = $("
").appendTo(img_tmp) From 0eb128ec0447c1cc7c993bb9a4a4491e77f0e895 Mon Sep 17 00:00:00 2001 From: Claudio Valerio Date: Thu, 24 May 2012 14:33:32 +0200 Subject: [PATCH 8/9] removed unused classes --- Sankore_3.1.pro | 1 - src/board/UBBoardView.cpp | 10 +- src/customWidgets/UBActionableWidget.cpp | 65 ----- src/customWidgets/UBActionableWidget.h | 45 --- src/customWidgets/UBDraggableLabel.cpp | 39 --- src/customWidgets/UBDraggableLabel.h | 23 -- src/customWidgets/UBDraggableMedia.cpp | 42 --- src/customWidgets/UBDraggableMedia.h | 19 -- src/customWidgets/UBMediaWidget.cpp | 335 ----------------------- src/customWidgets/UBMediaWidget.h | 127 --------- src/customWidgets/UBWidgetList.cpp | 229 ---------------- src/customWidgets/UBWidgetList.h | 69 ----- src/customWidgets/customWidgets.pri | 13 - 13 files changed, 2 insertions(+), 1015 deletions(-) delete mode 100644 src/customWidgets/UBActionableWidget.cpp delete mode 100644 src/customWidgets/UBActionableWidget.h delete mode 100644 src/customWidgets/UBDraggableLabel.cpp delete mode 100644 src/customWidgets/UBDraggableLabel.h delete mode 100644 src/customWidgets/UBDraggableMedia.cpp delete mode 100644 src/customWidgets/UBDraggableMedia.h delete mode 100644 src/customWidgets/UBMediaWidget.cpp delete mode 100644 src/customWidgets/UBMediaWidget.h delete mode 100644 src/customWidgets/UBWidgetList.cpp delete mode 100644 src/customWidgets/UBWidgetList.h delete mode 100644 src/customWidgets/customWidgets.pri diff --git a/Sankore_3.1.pro b/Sankore_3.1.pro index 6e68e1c9..e156a983 100644 --- a/Sankore_3.1.pro +++ b/Sankore_3.1.pro @@ -52,7 +52,6 @@ include(src/tools/tools.pri) include(src/desktop/desktop.pri) include(src/web/web.pri) include(src/transition/transition.pri) -include(src/customWidgets/customWidgets.pri) include(src/interfaces/interfaces.pri) DEPENDPATH += src/pdf-merger diff --git a/src/board/UBBoardView.cpp b/src/board/UBBoardView.cpp index 1e299fde..23bfab89 100644 --- a/src/board/UBBoardView.cpp +++ b/src/board/UBBoardView.cpp @@ -49,9 +49,6 @@ #include "document/UBDocumentProxy.h" -#include "customWidgets/UBDraggableLabel.h" -#include "customWidgets/UBDraggableMedia.h" - #include "tools/UBGraphicsCompass.h" #include "tools/UBGraphicsCache.h" #include "tools/UBGraphicsTriangle.h" @@ -813,14 +810,11 @@ void UBBoardView::dropEvent (QDropEvent *event) UBGraphicsWidgetItem* graphicsWidget = dynamic_cast(graphicsItemAtPos); if (graphicsWidget && graphicsWidget->acceptDrops()) { - graphicsWidget->processDropEvent(event); event->acceptProposedAction(); - } else if (!event->source() || dynamic_cast(event->source()) - || dynamic_cast(event->source()) || dynamic_cast(event->source()) - || dynamic_cast(event->source()) || dynamic_cast(event->source())) { - + } + else if (!event->source() || dynamic_cast(event->source()) || dynamic_cast(event->source())){ mController->processMimeData (event->mimeData (), mapToScene (event->pos ())); event->acceptProposedAction(); } diff --git a/src/customWidgets/UBActionableWidget.cpp b/src/customWidgets/UBActionableWidget.cpp deleted file mode 100644 index 65e440a3..00000000 --- a/src/customWidgets/UBActionableWidget.cpp +++ /dev/null @@ -1,65 +0,0 @@ -#include -#include - -#include "UBActionableWidget.h" - -UBActionableWidget::UBActionableWidget(QWidget *parent, const char *name):QWidget(parent) - , mShowActions(false) -{ - setObjectName(name); - mActions.clear(); - mCloseButtons.setIcon(QIcon(QPixmap(":images/close.svg"))); - mCloseButtons.setGeometry(0, 0, 2*ACTIONSIZE, ACTIONSIZE); - mCloseButtons.setVisible(false); - connect(&mCloseButtons, SIGNAL(clicked()), this, SLOT(onCloseClicked())); -} - -UBActionableWidget::~UBActionableWidget() -{ - -} - -void UBActionableWidget::addAction(eAction act) -{ - if(!mActions.contains(act)){ - mActions << act; - } -} - -void UBActionableWidget::removeAction(eAction act) -{ - if(mActions.contains(act)){ - mActions.remove(mActions.indexOf(act)); - } -} - -void UBActionableWidget::removeAllActions() -{ - mActions.clear(); -} - -void UBActionableWidget::setActionsVisible(bool bVisible) -{ - if(!mActions.empty() && mActions.contains(eAction_Close)){ - mCloseButtons.setVisible(bVisible); - } -} - -void UBActionableWidget::onCloseClicked() -{ - emit close(this); -} - -void UBActionableWidget::setActionsParent(QWidget *parent) -{ - if(mActions.contains(eAction_Close)){ - mCloseButtons.setParent(parent); - } -} - -void UBActionableWidget::unsetActionsParent() -{ - if(mActions.contains(eAction_Close)){ - mCloseButtons.setParent(this); - } -} diff --git a/src/customWidgets/UBActionableWidget.h b/src/customWidgets/UBActionableWidget.h deleted file mode 100644 index 683463df..00000000 --- a/src/customWidgets/UBActionableWidget.h +++ /dev/null @@ -1,45 +0,0 @@ -#ifndef UBACTIONABLEWIDGET_H -#define UBACTIONABLEWIDGET_H - -#include -#include -#include -#include - -#define ACTIONSIZE 16 - -typedef enum{ - eAction_Close, - eAction_MoveUp, - eAction_MoveDown -}eAction; - -class UBActionableWidget : public QWidget -{ - Q_OBJECT -public: - UBActionableWidget(QWidget* parent=0, const char* name="UBActionableWidget"); - ~UBActionableWidget(); - void addAction(eAction act); - void removeAction(eAction act); - void removeAllActions(); - void setActionsVisible(bool bVisible); - -signals: - void close(QWidget* w); - -protected: - void setActionsParent(QWidget* parent); - void unsetActionsParent(); - QVector mActions; - QPushButton mCloseButtons; - -private slots: - void onCloseClicked(); - -private: - bool mShowActions; - -}; - -#endif // UBACTIONABLEWIDGET_H diff --git a/src/customWidgets/UBDraggableLabel.cpp b/src/customWidgets/UBDraggableLabel.cpp deleted file mode 100644 index 200205b9..00000000 --- a/src/customWidgets/UBDraggableLabel.cpp +++ /dev/null @@ -1,39 +0,0 @@ -#include -#include -#include - -#include "UBDraggableLabel.h" - - -UBDraggableLabel::UBDraggableLabel(QWidget *parent) : - QLabel(parent) -{ -} - -UBDraggableLabel::~UBDraggableLabel() -{ - //NOOP -} - -void UBDraggableLabel::loadImage(QString imagePath) -{ - mSourcePath = imagePath; - QPixmap pix = QPixmap(mSourcePath); - setPixmap(pix); - setScaledContents(true); -} - -void UBDraggableLabel::mousePressEvent(QMouseEvent *event) -{ - Q_UNUSED(event); - QMimeData *mimeData = new QMimeData; - QList urls; - urls << QUrl::fromLocalFile(mSourcePath); - mimeData->setUrls(urls); - mimeData->setText(mSourcePath); - - - QDrag *drag = new QDrag(this); - drag->setMimeData(mimeData); - drag->start(); -} diff --git a/src/customWidgets/UBDraggableLabel.h b/src/customWidgets/UBDraggableLabel.h deleted file mode 100644 index 384b313e..00000000 --- a/src/customWidgets/UBDraggableLabel.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef UBDRAGGABLELABEL_H -#define UBDRAGGABLELABEL_H - -#include - -class UBDraggableLabel : public QLabel -{ - Q_OBJECT -public: - UBDraggableLabel(QWidget *parent = 0); - ~UBDraggableLabel(); - void loadImage(QString imagePath); -signals: - -public slots: - -protected: - QString mSourcePath; - void mousePressEvent(QMouseEvent *event); - -}; - -#endif // UBDRAGGABLELABEL_H diff --git a/src/customWidgets/UBDraggableMedia.cpp b/src/customWidgets/UBDraggableMedia.cpp deleted file mode 100644 index 4136f742..00000000 --- a/src/customWidgets/UBDraggableMedia.cpp +++ /dev/null @@ -1,42 +0,0 @@ -#include -#include - -#include "UBDraggableMedia.h" - -UBDraggableMedia::UBDraggableMedia(eMediaType type, QWidget *parent, const char *name):UBMediaWidget(type, parent, name) -{ - removeAllActions(); -} - -UBDraggableMedia::~UBDraggableMedia() -{ - -} - -void UBDraggableMedia::mousePressEvent(QMouseEvent* ev) -{ - if(Qt::LeftButton == ev->button()){ - mDragStartPos = ev->pos(); - } -} - -void UBDraggableMedia::mouseMoveEvent(QMouseEvent* ev) -{ - if(!(ev->buttons() & Qt::LeftButton)){ - return; - } - if((ev->pos() - mDragStartPos).manhattanLength() < QApplication::startDragDistance()){ - return; - } - QDrag *drag = new QDrag(this); - QMimeData *mimeData = new QMimeData; - - QList urls; - urls << QUrl(mFilePath); - mimeData->setText(mFilePath); - mimeData->setUrls(urls); - - drag->setMimeData(mimeData); - - drag->exec(Qt::CopyAction | Qt::MoveAction); -} diff --git a/src/customWidgets/UBDraggableMedia.h b/src/customWidgets/UBDraggableMedia.h deleted file mode 100644 index b45c9391..00000000 --- a/src/customWidgets/UBDraggableMedia.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef UBDRAGGABLEMEDIA_H -#define UBDRAGGABLEMEDIA_H - -#include "UBMediaWidget.h" - -class UBDraggableMedia : public UBMediaWidget -{ -public: - UBDraggableMedia(eMediaType type = eMediaType_Video, QWidget* parent=0, const char* name="UBDraggableMedia"); - ~UBDraggableMedia(); -protected: - void mousePressEvent(QMouseEvent* ev); - void mouseMoveEvent(QMouseEvent* ev); - -private: - QPoint mDragStartPos; -}; - -#endif // UBDRAGGABLEMEDIA_H diff --git a/src/customWidgets/UBMediaWidget.cpp b/src/customWidgets/UBMediaWidget.cpp deleted file mode 100644 index 4bef693b..00000000 --- a/src/customWidgets/UBMediaWidget.cpp +++ /dev/null @@ -1,335 +0,0 @@ -/* - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -#include "core/UBApplication.h" -#include "globals/UBGlobals.h" -#include "UBMediaWidget.h" - -/** - * \brief Constructor - * @param type as the media type - * @param parent as the parent widget - * @param name as the object name - */ -UBMediaWidget::UBMediaWidget(eMediaType type, QWidget *parent, const char *name):UBActionableWidget(parent, name) - , mpMediaObject(NULL) - , mpVideoWidget(NULL) - , mpAudioOutput(NULL) - , mpPlayStopButton(NULL) - , mpPauseButton(NULL) - , mpSlider(NULL) - , mAutoUpdate(false) - , mGeneratingThumbnail(false) - , mBorder(5) - , mpMediaContainer(NULL) - , mpCover(NULL) -{ - setAttribute(Qt::WA_StyledBackground, true); - setStyleSheet(UBApplication::globalStyleSheet()); - - addAction(eAction_Close); - mType = type; - setLayout(&mLayout); - - mpPlayStopButton = new UBMediaButton(this); - mpPlayStopButton->setPixmap(QPixmap(":images/play.svg")); - mpPauseButton = new UBMediaButton(this); - mpPauseButton->setPixmap(QPixmap(":images/pause.svg")); - mpPauseButton->setEnabled(false); - mpSlider = new QSlider(this); - mpSlider->setOrientation(Qt::Horizontal); - mpSlider->setMinimum(0); - mpSlider->setMaximum(0); - - mSeekerLayout.addWidget(mpPlayStopButton, 0); - mSeekerLayout.addWidget(mpPauseButton, 0); - mSeekerLayout.addWidget(mpSlider, 1); - mSeekerLayout.setContentsMargins(0, 0, 0, 0); - - connect(mpPlayStopButton, SIGNAL(clicked()), this, SLOT(onPlayStopClicked())); - connect(mpPauseButton, SIGNAL(clicked()), this, SLOT(onPauseClicked())); - connect(mpSlider, SIGNAL(valueChanged(int)), this, SLOT(onSliderChanged(int))); -} - -/** - * \brief Destructor - */ -UBMediaWidget::~UBMediaWidget() -{ - unsetActionsParent(); - DELETEPTR(mpSlider); - DELETEPTR(mpPauseButton); - DELETEPTR(mpPlayStopButton); - DELETEPTR(mpAudioOutput); - DELETEPTR(mpVideoWidget); - DELETEPTR(mpMediaObject); - DELETEPTR(mpCover); -} - -/** - * \brief Set the media file - * @param filePath as the media file path - */ -void UBMediaWidget::setFile(const QString &filePath) -{ - Q_ASSERT("" != filePath); - mFilePath = filePath; - mpMediaObject = new Phonon::MediaObject(this); - mpMediaObject->setTickInterval(TICK_INTERVAL); - connect(mpMediaObject, SIGNAL(stateChanged(Phonon::State,Phonon::State)), this, SLOT(onStateChanged(Phonon::State,Phonon::State))); - connect(mpMediaObject, SIGNAL(totalTimeChanged(qint64)), this, SLOT(onTotalTimeChanged(qint64))); - connect(mpMediaObject, SIGNAL(tick(qint64)), this, SLOT(onTick(qint64))); - mpMediaObject->setCurrentSource(Phonon::MediaSource(filePath)); - createMediaPlayer(); -} - -/** - * \brief Get the media type - * @returns the media type - */ -eMediaType UBMediaWidget::mediaType() -{ - return mType; -} - -void UBMediaWidget::showEvent(QShowEvent* event) -{ - if(!mpVideoWidget){ - mpVideoWidget = new Phonon::VideoWidget(this); - mMediaLayout.addStretch(1); - mMediaLayout.addWidget(mpVideoWidget, 0); - mMediaLayout.addStretch(1); - Phonon::createPath(mpMediaObject, mpVideoWidget); - adaptSizeToVideo(); - mpMediaObject->play(); - mpMediaObject->stop(); - } - QWidget::showEvent(event); -} - -/** - * \brief Create the media player - */ -void UBMediaWidget::createMediaPlayer() -{ - mpMediaContainer = new QWidget(this); - mpMediaContainer->setObjectName("UBMediaVideoContainer"); - mpMediaContainer->setLayout(&mMediaLayout); - - if(eMediaType_Video == mType){ - mMediaLayout.setContentsMargins(10, 10, 25, 10); - if(isVisible()){ - mpVideoWidget = new Phonon::VideoWidget(this); - mMediaLayout.addStretch(1); - mMediaLayout.addWidget(mpVideoWidget, 0); - mMediaLayout.addStretch(1); - Phonon::createPath(mpMediaObject, mpVideoWidget); - adaptSizeToVideo(); - } - mpAudioOutput = new Phonon::AudioOutput(Phonon::VideoCategory, this); - Phonon::createPath(mpMediaObject, mpAudioOutput); - }else if(eMediaType_Audio == mType){ - mMediaLayout.setContentsMargins(10, 10, 10, 10); - mpCover = new QLabel(mpMediaContainer); - mpMediaContainer->setStyleSheet(QString("background: none;")); - setAudioCover(":images/libpalette/soundIcon.svg"); - mpCover->setScaledContents(true); - mMediaLayout.addStretch(1); - mMediaLayout.addWidget(mpCover, 0); - mMediaLayout.addStretch(1); - mpAudioOutput = new Phonon::AudioOutput(Phonon::MusicCategory, this); - Phonon::createPath(mpMediaObject, mpAudioOutput); - } - mLayout.addWidget(mpMediaContainer, 1); - mLayout.addLayout(&mSeekerLayout, 0); - setActionsParent(mpMediaContainer); -} - -/** - * \brief Adapt the widget size to the video in order to keep the good aspect ratio - */ -void UBMediaWidget::adaptSizeToVideo() -{ - if(NULL != mpMediaContainer){ - int origW = mpMediaContainer->width(); - int origH = mpMediaContainer->height(); - int newW = width(); - float scaleFactor = (float)origW/(float)newW; - int newH = origH/scaleFactor; - resize(newW, height() + newH); - } -} - -/** - * \brief Handle the media state change notification - * @param newState as the new state - * @param oldState as the old state - */ -void UBMediaWidget::onStateChanged(Phonon::State newState, Phonon::State oldState) -{ - if(!mGeneratingThumbnail){ - if(Phonon::LoadingState == oldState && Phonon::StoppedState == newState){ - if(eMediaType_Video == mType){ - // We do that here to generate the thumbnail of the video - mGeneratingThumbnail = true; - mpMediaObject->play(); - mpMediaObject->pause(); - mGeneratingThumbnail = false; - } - }else if(Phonon::PlayingState == oldState && Phonon::PausedState == newState){ - mpPlayStopButton->setPixmap(QPixmap(":images/play.svg")); - mpPauseButton->setEnabled(false); - }else if((Phonon::PausedState == oldState && Phonon::PlayingState == newState) || - (Phonon::StoppedState == oldState && Phonon::PlayingState == newState)){ - mpPlayStopButton->setPixmap(QPixmap(":images/stop.svg")); - mpPauseButton->setEnabled(true); - }else if(Phonon::PlayingState == oldState && Phonon::StoppedState == newState){ - mpPlayStopButton->setPixmap(QPixmap(":images/play.svg")); - mpPauseButton->setEnabled(false); - mpSlider->setValue(0); - } - } -} - -/** - * \brief Handles the total time change notification - * @param total as the new total time - */ -void UBMediaWidget::onTotalTimeChanged(qint64 total) -{ - mpSlider->setMaximum(total); -} - -/** - * \brief Handles the tick notification - * @param currentTime as the current time - */ -void UBMediaWidget::onTick(qint64 currentTime) -{ - mAutoUpdate = true; - mpSlider->setValue((int)currentTime); - mAutoUpdate = false; -} - -/** - * \brief Handles the seeker value change notification - * @param value as the new seeker value - */ -void UBMediaWidget::onSliderChanged(int value) -{ - if(!mAutoUpdate){ - mpMediaObject->seek(value); - } -} - -/** - * \brief Toggle Play-Stop - */ -void UBMediaWidget::onPlayStopClicked() -{ - switch(mpMediaObject->state()){ - case Phonon::PlayingState: - mpMediaObject->stop(); - break; - - case Phonon::StoppedState: - case Phonon::PausedState: - mpMediaObject->play(); - break; - default: - break; - } -} - -/** - * \brief Pause the media - */ -void UBMediaWidget::onPauseClicked() -{ - mpMediaObject->pause(); -} - -/** - * Get the border - * @returns the actual border - */ -int UBMediaWidget::border() -{ - return mBorder; -} - -/** - * \brief Handles the resize event - * @param ev as the resize event - */ -void UBMediaWidget::resizeEvent(QResizeEvent* ev) -{ - Q_UNUSED(ev); -} - -/** - * \brief Set the audio cover - * @param coverPath as the cover image file path - */ -void UBMediaWidget::setAudioCover(const QString &coverPath) -{ - if(NULL != mpCover){ - mpCover->setPixmap(QPixmap(coverPath)); - } -} - -// ----------------------------------------------------------------------------------------------------------- -/** - * \brief Constructor - * @param parent as the parent widget - * @param name as the object name - */ -UBMediaButton::UBMediaButton(QWidget *parent, const char *name):QLabel(parent) - , mPressed(false) -{ - setObjectName(name); - resize(UBMEDIABUTTON_SIZE, UBMEDIABUTTON_SIZE); - setStyleSheet(QString("padding:0px 0px 0px 0px; margin:0px 0px 0px 0px;")); -} - -/** - * \brief Destructor - */ -UBMediaButton::~UBMediaButton() -{ - -} - -/** - * \brief Handles the mouse press notification - * @param ev as the mouse press event - */ -void UBMediaButton::mousePressEvent(QMouseEvent* ev) -{ - Q_UNUSED(ev); - mPressed = true; -} - -/** - * \brief Handles the mouse release notification - * @param ev as the mouse release event - */ -void UBMediaButton::mouseReleaseEvent(QMouseEvent* ev) -{ - Q_UNUSED(ev); - if(mPressed){ - mPressed = false; - emit clicked(); - } -} diff --git a/src/customWidgets/UBMediaWidget.h b/src/customWidgets/UBMediaWidget.h deleted file mode 100644 index dbc85b78..00000000 --- a/src/customWidgets/UBMediaWidget.h +++ /dev/null @@ -1,127 +0,0 @@ -/* - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -#ifndef UBMEDIAWIDGET_H -#define UBMEDIAWIDGET_H - -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include "interfaces/IResizeable.h" -#include "UBActionableWidget.h" - -#define UBMEDIABUTTON_SIZE 32 -#define TICK_INTERVAL 1000 - -/** - * \brief The media type - */ -typedef enum{ - eMediaType_Video, - eMediaType_Audio -}eMediaType; - -class UBMediaButton : public QLabel -{ - Q_OBJECT -public: - UBMediaButton(QWidget* parent=0, const char* name="UBMediaButton"); - ~UBMediaButton(); - -signals: - void clicked(); - -protected: - void mousePressEvent(QMouseEvent* ev); - void mouseReleaseEvent(QMouseEvent* ev); - -private: - /** And indicator of the press event in progress */ - bool mPressed; -}; - -class UBMediaWidget : public UBActionableWidget -{ - Q_OBJECT -public: - UBMediaWidget(eMediaType type = eMediaType_Video, QWidget* parent=0, const char* name="UBMediaWidget"); - ~UBMediaWidget(); - void setFile(const QString& filePath); - eMediaType mediaType(); - int border(); - void setAudioCover(const QString& coverPath); - void setUrl(const QString& url){mUrl = url;} - QString url(){return mUrl;} - -protected: - void resizeEvent(QResizeEvent* ev); - void showEvent(QShowEvent* event); - /** The current media file path */ - QString mFilePath; - -private slots: - void onPlayStopClicked(); - void onPauseClicked(); - void onStateChanged(Phonon::State newState, Phonon::State oldState); - void onTotalTimeChanged(qint64 total); - void onTick(qint64 currentTime); - void onSliderChanged(int value); - -private: - void createMediaPlayer(); - void adaptSizeToVideo(); - - /** The current media type */ - eMediaType mType; - /** The media object */ - Phonon::MediaObject* mpMediaObject; - /** The video renderer */ - Phonon::VideoWidget* mpVideoWidget; - /** The audio renderer */ - Phonon::AudioOutput* mpAudioOutput; - /** The principal layout of this widget */ - QVBoxLayout mLayout; - /** The seeker layout */ - QHBoxLayout mSeekerLayout; - /** The play-stop button */ - UBMediaButton* mpPlayStopButton; - /** The pause button */ - UBMediaButton* mpPauseButton; - /** The seeker slider */ - QSlider* mpSlider; - /** An indicator of the seeker auto update in progress */ - bool mAutoUpdate; - /** An indicator of the thumbnail generation in progress */ - bool mGeneratingThumbnail; - /** The border */ - int mBorder; - /** A widget that will contain the media */ - QWidget* mpMediaContainer; - /** The media layout */ - QHBoxLayout mMediaLayout; - /** The audio cover */ - QLabel* mpCover; - /** The media url */ - QString mUrl; -}; - -#endif // UBMEDIAWIDGET_H diff --git a/src/customWidgets/UBWidgetList.cpp b/src/customWidgets/UBWidgetList.cpp deleted file mode 100644 index a9e9a305..00000000 --- a/src/customWidgets/UBWidgetList.cpp +++ /dev/null @@ -1,229 +0,0 @@ -#include -#include -#include -#include - -#include "globals/UBGlobals.h" -#include "UBWidgetList.h" - -UBWidgetList::UBWidgetList(QWidget* parent, eWidgetListOrientation orientation, const char* name):QScrollArea(parent) - , mCanRemove(true) - , mpLayout(NULL) - , mpContainer(NULL) - , mMargin(10) - , mListElementsSpacing(10) - , mpEmptyLabel(NULL) - , mpCurrentWidget(NULL) -{ - setObjectName(name); - mOrientation = orientation; - mpContainer = new QWidget(this); - mpEmptyLabel = new QLabel(this); - mpEmptyLabel->setObjectName("emptyString"); - mpEmptyLabel->setWordWrap(true); - mpEmptyLabel->setAlignment(Qt::AlignCenter); - - if(eWidgetListOrientation_Vertical == orientation){ - setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); - setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - mpLayout = new QVBoxLayout(mpContainer); - } - else{ - setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded); - setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - mpLayout = new QHBoxLayout(mpContainer); - } - mpLayout->setContentsMargins(margin(), margin(), margin(), margin()); - mpContainer->setLayout(mpLayout); - setWidget(mpContainer); -} - -UBWidgetList::~UBWidgetList() -{ - DELETEPTR(mpEmptyLabel); - DELETEPTR(mpLayout); - DELETEPTR(mpContainer); -} - -void UBWidgetList::addWidget(QWidget *widget) -{ - if(NULL != mpLayout && NULL != widget){ - widget->setParent(mpContainer); - mpEmptyLabel->setVisible(false); - mWidgetInfo[widget] = widget->size(); - updateView(size()); - mpLayout->addWidget(widget); - - // This call is used only to refresh the size of the widgets - updateSizes(); - } -} - -void UBWidgetList::removeWidget(QWidget *widget) -{ - if(NULL != mpLayout && NULL != widget){ - mpLayout->removeWidget(widget); - mWidgetInfo.remove(widget); - widget->setVisible(false); - updateView(size()); - if(0 == mpLayout->count()){ - mpEmptyLabel->setVisible(true); - } - if(mpCurrentWidget == widget){ - mpCurrentWidget = NULL; - } - } -} - - -int UBWidgetList::scaleWidgets(QSize pSize) -{ - // to remove the first spacing that shouldn't be there. - int result = -mListElementsSpacing; - foreach(QWidget* eachWidget, mWidgetInfo.keys()){ - qreal scaleFactor = 0; - int newWidgetWidth = pSize.width(); - int newWidgetHeight = pSize.height(); - if(eWidgetListOrientation_Vertical == mOrientation){ - scaleFactor = (float)mWidgetInfo[eachWidget].width() / (float)pSize.width(); - newWidgetHeight = mWidgetInfo[eachWidget].height()/scaleFactor; - result += newWidgetHeight; - eachWidget->setMinimumHeight(newWidgetHeight- 1); - eachWidget->setMaximumHeight(newWidgetHeight); - } - else{ - scaleFactor = (float)mWidgetInfo[eachWidget].height() / (float)pSize.height(); - newWidgetWidth = mWidgetInfo[eachWidget].width()/scaleFactor; - result += newWidgetWidth; - eachWidget->setMinimumWidth(newWidgetWidth - 1); - eachWidget->setMaximumWidth(newWidgetWidth); - } - //Adding a vertical/horizontal space between each element of the list - result += mListElementsSpacing; - } - return result; -} - -void UBWidgetList::scaleContainer(QSize pSize, int updateValue) -{ - if(eWidgetListOrientation_Vertical == mOrientation) - mpContainer->resize(pSize.width(), updateValue); - else - mpContainer->resize(updateValue, pSize.height()); -} - - -void UBWidgetList::updateView(QSize pSize) -{ - // Widgets on list are resized automatically to fit the mpcontainer. - // so if you want to keep the aspect ratio you have to calculate - // the sum of the new widget height and give it to the mpContainer. - // The container resize will trig the widgets resize and the good - // height permits to respect the aspect ratio. - int updatedValue = scaleWidgets(pSize); - scaleContainer(pSize,updatedValue); -} - - - -void UBWidgetList::resizeEvent(QResizeEvent *ev) -{ - Q_UNUSED(ev); - mpEmptyLabel->setGeometry((width() - mpEmptyLabel->width()) / 2, - (height() - mpEmptyLabel->height()) /2, - mpEmptyLabel->width(), - mpEmptyLabel->height()); - updateView(size()); - updateSizes(); -} - -void UBWidgetList::mousePressEvent(QMouseEvent *ev) -{ - Q_UNUSED(ev); - if(mCanRemove){ - QWidget* pWAt = widgetAt(ev->pos()); - if(NULL != mpCurrentWidget){ - if(pWAt != mpCurrentWidget){ - mpCurrentWidget->setActionsVisible(false); - update(); - } - } - mpCurrentWidget = dynamic_cast(pWAt); - if(NULL != mpCurrentWidget){ - mpCurrentWidget->setActionsVisible(true); - update(); - } - } - update(); -} - -QWidget* UBWidgetList::widgetAt(QPoint p) -{ - QWidget* pW = NULL; - pW = childAt(p); - if(NULL != pW){ - do{ - if( "UBTeacherStudentAction" == pW->objectName() || - "UBUrlWidget" == pW->objectName() || - "UBTBMediaPicture" == pW->objectName() || - "UBMediaWidget" == pW->objectName()){ - return pW; - }else{ - pW = pW->parentWidget(); - } - }while(NULL != pW && this != pW); - } - - return pW; -} - -void UBWidgetList::updateSizes() -{ - // Resize all the widgets - foreach(QWidget* eachWidget, mWidgetInfo.keys()){ - if(NULL != eachWidget){ - QSize originalSize = mWidgetInfo[eachWidget]; - int currentWidth = mpContainer->width(); - int currentHeight = mpContainer->height(); - if(eWidgetListOrientation_Vertical == mOrientation){ - if(verticalScrollBar()->isVisible()){ - currentWidth -= verticalScrollBar()->width(); - eachWidget->setStyleSheet(QString("margin-right:%0;").arg(verticalScrollBar()->width())); - } - float scaleFactor = (float)currentWidth/(float)originalSize.width(); - currentHeight = originalSize.height()*scaleFactor; - }else{ - if(horizontalScrollBar()->isVisible()){ - currentHeight -= horizontalScrollBar()->height(); - eachWidget->setStyleSheet(QString("padding-bottom:%0;").arg(horizontalScrollBar()->height())); - } - float scaleFactor = (float)currentHeight/(float)originalSize.height(); - currentWidth = originalSize.width()*scaleFactor; - } - - eachWidget->resize(currentWidth, currentHeight); - } - } -} - -void UBWidgetList::setMargin(int margin) -{ - mMargin = margin; -} - -int UBWidgetList::margin() -{ - return mMargin; -} - -void UBWidgetList::setEmptyText(const QString &text) -{ - if(NULL != mpEmptyLabel){ - mpEmptyLabel->setText(text); - } -} - -bool UBWidgetList::empty() -{ - return mWidgetInfo.empty(); -} diff --git a/src/customWidgets/UBWidgetList.h b/src/customWidgets/UBWidgetList.h deleted file mode 100644 index d2cd3a6c..00000000 --- a/src/customWidgets/UBWidgetList.h +++ /dev/null @@ -1,69 +0,0 @@ -#ifndef UBWIDGETLIST_H -#define UBWIDGETLIST_H - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "interfaces/IResizeable.h" -#include "customWidgets/UBActionableWidget.h" - -typedef enum{ - eWidgetListOrientation_Vertical, - eWidgetListOrientation_Horizontal -}eWidgetListOrientation; - - -class UBWidgetList : public QScrollArea -{ - Q_OBJECT - - typedef struct - { - QSize size; - bool isResizable; - } sWidgetProperties; - -public: - UBWidgetList(QWidget* parent=0, eWidgetListOrientation orientation = eWidgetListOrientation_Vertical, const char* name = "UBWidgetList"); - ~UBWidgetList(); - void addWidget(QWidget* widget); - void removeWidget(QWidget* widget); - void setMargin(int margin); - void setEmptyText(const QString& text); - int margin(); - bool empty(); - void setListElementSpacing(int margin) { mListElementsSpacing = margin; } - int listElementsSpacing() {return mListElementsSpacing; } - -signals: - void closeWidget(QWidget* w); - -protected: - bool mCanRemove; - - void resizeEvent(QResizeEvent* ev); - void mousePressEvent(QMouseEvent* ev); - -private: - QWidget* widgetAt(QPoint p); - int scaleWidgets(QSize pSize); - void scaleContainer(QSize pSize, int updateValue); - void updateView(QSize pSize); - void updateSizes(); - QBoxLayout* mpLayout; - QWidget* mpContainer; - eWidgetListOrientation mOrientation; - int mMargin; - int mListElementsSpacing; - QMap mWidgetInfo; - QLabel* mpEmptyLabel; - UBActionableWidget* mpCurrentWidget; -}; - -#endif // UBWIDGETLIST_H diff --git a/src/customWidgets/customWidgets.pri b/src/customWidgets/customWidgets.pri deleted file mode 100644 index c531d4b3..00000000 --- a/src/customWidgets/customWidgets.pri +++ /dev/null @@ -1,13 +0,0 @@ - -HEADERS += src/customWidgets/UBWidgetList.h \ - src/customWidgets/UBDraggableLabel.h \ - src/customWidgets/UBMediaWidget.h \ - src/globals/UBGlobals.h \ - src/customWidgets/UBDraggableMedia.h \ - src/customWidgets/UBActionableWidget.h - -SOURCES += src/customWidgets/UBWidgetList.cpp \ - src/customWidgets/UBDraggableLabel.cpp \ - src/customWidgets/UBMediaWidget.cpp \ - src/customWidgets/UBDraggableMedia.cpp \ - src/customWidgets/UBActionableWidget.cpp From 18245d72744f266aebb982bf083da84d9fd18bba Mon Sep 17 00:00:00 2001 From: Anatoly Mihalchenko Date: Thu, 24 May 2012 15:54:24 +0300 Subject: [PATCH 9/9] DnD on widget fix --- src/domain/UBGraphicsItemDelegate.cpp | 30 +++++++++++++++------------ 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/src/domain/UBGraphicsItemDelegate.cpp b/src/domain/UBGraphicsItemDelegate.cpp index de710f82..ae6dd703 100644 --- a/src/domain/UBGraphicsItemDelegate.cpp +++ b/src/domain/UBGraphicsItemDelegate.cpp @@ -181,27 +181,31 @@ void UBGraphicsItemDelegate::setMimeData(QMimeData *mimeData) bool UBGraphicsItemDelegate::mouseMoveEvent(QGraphicsSceneMouseEvent *event) { - if((NULL != mMimeData) && ((event->pos() - mDragStartPosition).manhattanLength() < QApplication::startDragDistance())) - { - QDrag* mDrag = new QDrag(event->widget()); - mDrag->setMimeData(mMimeData); - if (!mDragPixmap.isNull()) { - mDrag->setPixmap(mDragPixmap); - mDrag->setHotSpot(mDragPixmap.rect().center()); - } - mDrag->exec(); - mDragPixmap = QPixmap(); - - return true; + if(mMimeData) + { + QDrag* mDrag = new QDrag(event->widget()); + mDrag->setMimeData(mMimeData); + if (!mDragPixmap.isNull()) { + mDrag->setPixmap(mDragPixmap); + mDrag->setHotSpot(mDragPixmap.rect().center()); } + mDrag->exec(); + mDragPixmap = QPixmap(); + + return true; + } if(isLocked()) { event->accept(); return true; } + else + { + return false; + } - return true; + } bool UBGraphicsItemDelegate::weelEvent(QGraphicsSceneWheelEvent *event)