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

preferencesAboutTextFull
Claudio Valerio 12 years ago
commit 72958a79ca
  1. BIN
      JournalDesModifications.pdf
  2. BIN
      ReleaseNotes.pdf
  3. 2
      Sankore_3.1.pro
  4. 19
      resources/i18n/sankore_ar.ts
  5. 19
      resources/i18n/sankore_bg.ts
  6. 19
      resources/i18n/sankore_ca.ts
  7. 19
      resources/i18n/sankore_cs.ts
  8. 19
      resources/i18n/sankore_da.ts
  9. 19
      resources/i18n/sankore_de.ts
  10. 19
      resources/i18n/sankore_el.ts
  11. 19
      resources/i18n/sankore_en.ts
  12. 19
      resources/i18n/sankore_en_UK.ts
  13. 19
      resources/i18n/sankore_es.ts
  14. 432
      resources/i18n/sankore_fr.ts
  15. 432
      resources/i18n/sankore_fr_CH.ts
  16. 19
      resources/i18n/sankore_it.ts
  17. 19
      resources/i18n/sankore_iw.ts
  18. 19
      resources/i18n/sankore_ja.ts
  19. 19
      resources/i18n/sankore_ko.ts
  20. 19
      resources/i18n/sankore_mg.ts
  21. 19
      resources/i18n/sankore_nb.ts
  22. 19
      resources/i18n/sankore_nl.ts
  23. 19
      resources/i18n/sankore_pl.ts
  24. 19
      resources/i18n/sankore_pt.ts
  25. 19
      resources/i18n/sankore_rm.ts
  26. 19
      resources/i18n/sankore_ro.ts
  27. 19
      resources/i18n/sankore_ru.ts
  28. 19
      resources/i18n/sankore_sk.ts
  29. 19
      resources/i18n/sankore_sv.ts
  30. 19
      resources/i18n/sankore_tr.ts
  31. 19
      resources/i18n/sankore_zh.ts
  32. BIN
      resources/images/toolPalette/aristoTool.png
  33. BIN
      resources/images/toque.png
  34. 131
      resources/images/toque.svg
  35. 27
      resources/library/applications/OpenStreetMap.wgt/index.html
  36. 77
      resources/library/interactivities/Cat images.wgt/js/script.js
  37. 82
      resources/library/interactivities/Cat images.wgt/locales/fr/js/script.js
  38. 82
      resources/library/interactivities/Cat images.wgt/locales/ru/js/script.js
  39. 71
      resources/library/interactivities/Cat text.wgt/js/script.js
  40. 70
      resources/library/interactivities/Cat text.wgt/locales/fr/js/script.js
  41. 70
      resources/library/interactivities/Cat text.wgt/locales/ru/js/script.js
  42. 3
      resources/sankore.qrc
  43. 5
      src/adaptors/UBImportDocument.cpp
  44. 32
      src/adaptors/UBSvgSubsetAdaptor.cpp
  45. 13
      src/adaptors/UBThumbnailAdaptor.cpp
  46. 2
      src/api/UBLibraryAPI.cpp
  47. 4
      src/api/UBWidgetUniboardAPI.cpp
  48. 201
      src/board/UBBoardController.cpp
  49. 12
      src/board/UBBoardController.h
  50. 1
      src/board/UBBoardPaletteManager.cpp
  51. 18
      src/board/UBBoardView.cpp
  52. 2
      src/board/UBFeaturesController.cpp
  53. 1
      src/core/UB.h
  54. 4
      src/core/UBApplication.cpp
  55. 148
      src/core/UBDownloadManager.cpp
  56. 33
      src/core/UBDownloadManager.h
  57. 16
      src/core/UBPersistenceManager.cpp
  58. 5
      src/core/UBPersistenceManager.h
  59. 2
      src/core/main.cpp
  60. 2
      src/document/UBDocumentContainer.cpp
  61. 2
      src/document/UBDocumentContainer.h
  62. 3
      src/domain/UBGraphicsDelegateFrame.cpp
  63. 1
      src/domain/UBGraphicsItemDelegate.cpp
  64. 10
      src/domain/UBGraphicsMediaItem.cpp
  65. 57
      src/domain/UBGraphicsScene.cpp
  66. 1
      src/domain/UBGraphicsScene.h
  67. 3
      src/domain/UBGraphicsWidgetItem.cpp
  68. 2
      src/frameworks/UBFileSystemUtils.cpp
  69. 5
      src/frameworks/UBFileSystemUtils.h
  70. 1
      src/frameworks/UBPlatformUtils_linux.cpp
  71. 22
      src/gui/UBDocumentNavigator.cpp
  72. 12
      src/gui/UBFeaturesWidget.cpp
  73. 14
      src/gui/UBFeaturesWidget.h
  74. 3
      src/gui/UBTeacherGuideWidgetsTools.cpp
  75. 186
      src/gui/UBToolWidget.cpp
  76. 54
      src/gui/UBToolWidget.h
  77. 828
      src/tools/UBGraphicsAristo.cpp
  78. 156
      src/tools/UBGraphicsAristo.h
  79. 15
      src/tools/UBGraphicsCache.cpp
  80. 12
      src/tools/UBGraphicsCache.h
  81. 6
      src/tools/UBToolsManager.cpp
  82. 1
      src/tools/UBToolsManager.h
  83. 15
      src/tools/tools.pri
  84. 2
      src/web/UBTrapFlashController.cpp
  85. 2
      src/web/browser/WBWebTrapWebView.cpp

Binary file not shown.

Binary file not shown.

@ -11,7 +11,7 @@ CONFIG += debug_and_release \
VERSION_MAJ = 2
VERSION_MIN = 00
VERSION_TYPE = b # a = alpha, b = beta, r = release, other => error
VERSION_PATCH = 07
VERSION_PATCH = 08
VERSION = "$${VERSION_MAJ}.$${VERSION_MIN}.$${VERSION_TYPE}.$${VERSION_PATCH}"
VERSION = $$replace(VERSION, "\\.r", "")

@ -1511,6 +1511,21 @@
<translation type="unfinished">سلة المهملات</translation>
</message>
</context>
<context>
<name>UBFeaturesNewFolderDialog</name>
<message>
<source>Accept</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Cancel</source>
<translation type="unfinished">إلغاء </translation>
</message>
<message>
<source>Enter a new folder name</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>UBFeaturesProgressInfo</name>
<message>
@ -2096,6 +2111,10 @@ Do you want to ignore these errors for this host?</source>
<source>Cache</source>
<translation>تخزين مؤقت</translation>
</message>
<message>
<source>Aristo</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>UBTrapFlashController</name>

@ -1503,6 +1503,21 @@
<translation type="unfinished">Кошче</translation>
</message>
</context>
<context>
<name>UBFeaturesNewFolderDialog</name>
<message>
<source>Accept</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Cancel</source>
<translation type="unfinished">Отмени</translation>
</message>
<message>
<source>Enter a new folder name</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>UBFeaturesProgressInfo</name>
<message>
@ -2094,6 +2109,10 @@ Do you want to ignore these errors for this host?</source>
<source>Cache</source>
<translation>Кеш</translation>
</message>
<message>
<source>Aristo</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>UBTrapFlashController</name>

@ -1504,6 +1504,21 @@
<translation type="unfinished">Paperera</translation>
</message>
</context>
<context>
<name>UBFeaturesNewFolderDialog</name>
<message>
<source>Accept</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Cancel</source>
<translation type="unfinished">Cancel·la</translation>
</message>
<message>
<source>Enter a new folder name</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>UBFeaturesProgressInfo</name>
<message>
@ -2090,6 +2105,10 @@ Voleu ignorar aquests errors per a aquest amfitrió?</translation>
<source>Cache</source>
<translation>Memòria cau</translation>
</message>
<message>
<source>Aristo</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>UBTrapFlashController</name>

@ -1506,6 +1506,21 @@
<translation type="unfinished">Koš</translation>
</message>
</context>
<context>
<name>UBFeaturesNewFolderDialog</name>
<message>
<source>Accept</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Cancel</source>
<translation type="unfinished">Zrušit</translation>
</message>
<message>
<source>Enter a new folder name</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>UBFeaturesProgressInfo</name>
<message>
@ -2097,6 +2112,10 @@ Chcete ignorovat tyto chyby na tomto serveru?</translation>
<source>Magnifier</source>
<translation>Lupa</translation>
</message>
<message>
<source>Aristo</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>UBTrapFlashController</name>

@ -1502,6 +1502,21 @@
<translation type="unfinished">Papirkurv</translation>
</message>
</context>
<context>
<name>UBFeaturesNewFolderDialog</name>
<message>
<source>Accept</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Cancel</source>
<translation type="unfinished">Annuller</translation>
</message>
<message>
<source>Enter a new folder name</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>UBFeaturesProgressInfo</name>
<message>
@ -2093,6 +2108,10 @@ Do you want to ignore these errors for this host?</source>
<source>Cache</source>
<translation>Cache</translation>
</message>
<message>
<source>Aristo</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>UBTrapFlashController</name>

@ -1502,6 +1502,21 @@
<translation type="unfinished">Papierkorb</translation>
</message>
</context>
<context>
<name>UBFeaturesNewFolderDialog</name>
<message>
<source>Accept</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Cancel</source>
<translation type="unfinished">Abbrechen</translation>
</message>
<message>
<source>Enter a new folder name</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>UBFeaturesProgressInfo</name>
<message>
@ -2101,6 +2116,10 @@ Möchten Sie diese Fehler auf diesem Computer ignorieren?</translation>
<source>Cache</source>
<translation>Zwischenspeicher</translation>
</message>
<message>
<source>Aristo</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>UBTrapFlashController</name>

@ -1502,6 +1502,21 @@
<translation type="unfinished">Κάδος ανακύκλωσης</translation>
</message>
</context>
<context>
<name>UBFeaturesNewFolderDialog</name>
<message>
<source>Accept</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Cancel</source>
<translation type="unfinished">Άκυρο</translation>
</message>
<message>
<source>Enter a new folder name</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>UBFeaturesProgressInfo</name>
<message>
@ -2093,6 +2108,10 @@ Do you want to ignore these errors for this host?</source>
<source>Cache</source>
<translation>Προβολέας</translation>
</message>
<message>
<source>Aristo</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>UBTrapFlashController</name>

@ -1500,6 +1500,21 @@
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>UBFeaturesNewFolderDialog</name>
<message>
<source>Accept</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Cancel</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Enter a new folder name</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>UBFeaturesProgressInfo</name>
<message>
@ -2085,6 +2100,10 @@ Do you want to ignore these errors for this host?</source>
<source>Cache</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Aristo</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>UBTrapFlashController</name>

@ -1500,6 +1500,21 @@
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>UBFeaturesNewFolderDialog</name>
<message>
<source>Accept</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Cancel</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Enter a new folder name</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>UBFeaturesProgressInfo</name>
<message>
@ -2085,6 +2100,10 @@ Do you want to ignore these errors for this host?</source>
<source>Cache</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Aristo</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>UBTrapFlashController</name>

@ -1502,6 +1502,21 @@
<translation type="unfinished">Papelera</translation>
</message>
</context>
<context>
<name>UBFeaturesNewFolderDialog</name>
<message>
<source>Accept</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Cancel</source>
<translation type="unfinished">Cancelar</translation>
</message>
<message>
<source>Enter a new folder name</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>UBFeaturesProgressInfo</name>
<message>
@ -2087,6 +2102,10 @@ Do you want to ignore these errors for this host?</source>
<source>Cache</source>
<translation>Caché</translation>
</message>
<message>
<source>Aristo</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>UBTrapFlashController</name>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -1504,6 +1504,21 @@ Sei sicuro di voler rimuovere %n pagina(e) dal documento &apos;%1&apos; selezion
<translation type="unfinished">Cestino</translation>
</message>
</context>
<context>
<name>UBFeaturesNewFolderDialog</name>
<message>
<source>Accept</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Cancel</source>
<translation type="unfinished">Annulla</translation>
</message>
<message>
<source>Enter a new folder name</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>UBFeaturesProgressInfo</name>
<message>
@ -2098,6 +2113,10 @@ risorsa multimediale ...</translation>
<source>Cache</source>
<translation>Cache</translation>
</message>
<message>
<source>Aristo</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>UBTrapFlashController</name>

@ -1499,6 +1499,21 @@
</message>
<message>
<source>Trash</source>
<translation type="unfinished">סל</translation>
</message>
</context>
<context>
<name>UBFeaturesNewFolderDialog</name>
<message>
<source>Accept</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Cancel</source>
<translation type="unfinished">בטל</translation>
</message>
<message>
<source>Enter a new folder name</source>
<translation type="unfinished"></translation>
</message>
</context>
@ -2088,6 +2103,10 @@ Do you want to ignore these errors for this host?</source>
<source>Cache</source>
<translation>מטמון</translation>
</message>
<message>
<source>Aristo</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>UBTrapFlashController</name>

@ -1500,6 +1500,21 @@
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>UBFeaturesNewFolderDialog</name>
<message>
<source>Accept</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Cancel</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Enter a new folder name</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>UBFeaturesProgressInfo</name>
<message>
@ -2092,6 +2107,10 @@ Do you want to ignore these errors for this host?</source>
<source>Cache</source>
<translation></translation>
</message>
<message>
<source>Aristo</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>UBTrapFlashController</name>

@ -1500,6 +1500,21 @@
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>UBFeaturesNewFolderDialog</name>
<message>
<source>Accept</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Cancel</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Enter a new folder name</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>UBFeaturesProgressInfo</name>
<message>
@ -2091,6 +2106,10 @@ Do you want to ignore these errors for this host?</source>
<source>Cache</source>
<translation></translation>
</message>
<message>
<source>Aristo</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>UBTrapFlashController</name>

@ -1502,6 +1502,21 @@
<translation type="unfinished">Daba</translation>
</message>
</context>
<context>
<name>UBFeaturesNewFolderDialog</name>
<message>
<source>Accept</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Cancel</source>
<translation type="unfinished">Ajanony</translation>
</message>
<message>
<source>Enter a new folder name</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>UBFeaturesProgressInfo</name>
<message>
@ -2093,6 +2108,10 @@ Tena tsy te hiraharaha an&apos;ireo tsy mety ho an&apos;ilay milina ve ianao?</t
<source>Cache</source>
<translation>Tahiry</translation>
</message>
<message>
<source>Aristo</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>UBTrapFlashController</name>

@ -1505,6 +1505,21 @@
<translation type="unfinished">Søppel</translation>
</message>
</context>
<context>
<name>UBFeaturesNewFolderDialog</name>
<message>
<source>Accept</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Cancel</source>
<translation type="unfinished">Avbryt</translation>
</message>
<message>
<source>Enter a new folder name</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>UBFeaturesProgressInfo</name>
<message>
@ -2091,6 +2106,10 @@ Do you want to ignore these errors for this host?</source>
<source>Cache</source>
<translation>Skjul</translation>
</message>
<message>
<source>Aristo</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>UBTrapFlashController</name>

@ -1502,6 +1502,21 @@
<translation type="unfinished">Prullenbak</translation>
</message>
</context>
<context>
<name>UBFeaturesNewFolderDialog</name>
<message>
<source>Accept</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Cancel</source>
<translation type="unfinished">Annuleren</translation>
</message>
<message>
<source>Enter a new folder name</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>UBFeaturesProgressInfo</name>
<message>
@ -2087,6 +2102,10 @@ Do you want to ignore these errors for this host?</source>
<source>Cache</source>
<translation>Cache</translation>
</message>
<message>
<source>Aristo</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>UBTrapFlashController</name>

@ -1509,6 +1509,21 @@
<translation type="unfinished">Kosz</translation>
</message>
</context>
<context>
<name>UBFeaturesNewFolderDialog</name>
<message>
<source>Accept</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Cancel</source>
<translation type="unfinished">Anuluj</translation>
</message>
<message>
<source>Enter a new folder name</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>UBFeaturesProgressInfo</name>
<message>
@ -2100,6 +2115,10 @@ Czy chcesz ignorować te błędy dla tego hosta?</translation>
<source>Cache</source>
<translation>Pamięć podręczna</translation>
</message>
<message>
<source>Aristo</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>UBTrapFlashController</name>

@ -1505,6 +1505,21 @@
<translation type="unfinished">Lixo</translation>
</message>
</context>
<context>
<name>UBFeaturesNewFolderDialog</name>
<message>
<source>Accept</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Cancel</source>
<translation type="unfinished">Cancelar</translation>
</message>
<message>
<source>Enter a new folder name</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>UBFeaturesProgressInfo</name>
<message>
@ -2092,6 +2107,10 @@ Quer ignorar estes erros, deste servidor?</translation>
<source>Cache</source>
<translation>Cache</translation>
</message>
<message>
<source>Aristo</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>UBTrapFlashController</name>

@ -1500,6 +1500,21 @@
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>UBFeaturesNewFolderDialog</name>
<message>
<source>Accept</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Cancel</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Enter a new folder name</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>UBFeaturesProgressInfo</name>
<message>
@ -2085,6 +2100,10 @@ Do you want to ignore these errors for this host?</source>
<source>Cache</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Aristo</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>UBTrapFlashController</name>

@ -1502,6 +1502,21 @@
<translation type="unfinished">Coş de gunoi</translation>
</message>
</context>
<context>
<name>UBFeaturesNewFolderDialog</name>
<message>
<source>Accept</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Cancel</source>
<translation type="unfinished">Anulare</translation>
</message>
<message>
<source>Enter a new folder name</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>UBFeaturesProgressInfo</name>
<message>
@ -2093,6 +2108,10 @@ Doriţi să ignoraţi aceste erori pentru acest host?</translation>
<source>Cache</source>
<translation>Cache</translation>
</message>
<message>
<source>Aristo</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>UBTrapFlashController</name>

@ -1502,6 +1502,21 @@
<translation type="unfinished">Корзина</translation>
</message>
</context>
<context>
<name>UBFeaturesNewFolderDialog</name>
<message>
<source>Accept</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Cancel</source>
<translation type="unfinished">Отмена</translation>
</message>
<message>
<source>Enter a new folder name</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>UBFeaturesProgressInfo</name>
<message>
@ -2093,6 +2108,10 @@ Do you want to ignore these errors for this host?</source>
<source>Cache</source>
<translation>Кэш</translation>
</message>
<message>
<source>Aristo</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>UBTrapFlashController</name>

@ -1506,6 +1506,21 @@
<translation type="unfinished">Kôš</translation>
</message>
</context>
<context>
<name>UBFeaturesNewFolderDialog</name>
<message>
<source>Accept</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Cancel</source>
<translation type="unfinished">Zrušiť</translation>
</message>
<message>
<source>Enter a new folder name</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>UBFeaturesProgressInfo</name>
<message>
@ -2097,6 +2112,10 @@ Chcete ignorovať tieto chyby na tomto serveri?</translation>
<source>Magnifier</source>
<translation>Lupa</translation>
</message>
<message>
<source>Aristo</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>UBTrapFlashController</name>

@ -1502,6 +1502,21 @@
<translation type="unfinished">Papperskorg</translation>
</message>
</context>
<context>
<name>UBFeaturesNewFolderDialog</name>
<message>
<source>Accept</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Cancel</source>
<translation type="unfinished">Avsluta</translation>
</message>
<message>
<source>Enter a new folder name</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>UBFeaturesProgressInfo</name>
<message>
@ -2093,6 +2108,10 @@ Vill du ignorera felen för den här värden?</translation>
<source>Cache</source>
<translation>Cache</translation>
</message>
<message>
<source>Aristo</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>UBTrapFlashController</name>

@ -1501,6 +1501,21 @@
<translation type="unfinished">Çöp</translation>
</message>
</context>
<context>
<name>UBFeaturesNewFolderDialog</name>
<message>
<source>Accept</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Cancel</source>
<translation type="unfinished">İptal</translation>
</message>
<message>
<source>Enter a new folder name</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>UBFeaturesProgressInfo</name>
<message>
@ -2091,6 +2106,10 @@ Bu host için yukarıdaki hatalar yok sayılsın mı?</translation>
<source>Cache</source>
<translation>Gizli Yer</translation>
</message>
<message>
<source>Aristo</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>UBTrapFlashController</name>

@ -1500,6 +1500,21 @@
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>UBFeaturesNewFolderDialog</name>
<message>
<source>Accept</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Cancel</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Enter a new folder name</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>UBFeaturesProgressInfo</name>
<message>
@ -2091,6 +2106,10 @@ Do you want to ignore these errors for this host?</source>
<source>Cache</source>
<translation></translation>
</message>
<message>
<source>Aristo</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>UBTrapFlashController</name>

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

@ -0,0 +1,131 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 15.1.0, SVG Export Plug-In -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" [
<!ENTITY ns_flows "http://ns.adobe.com/Flows/1.0/">
]>
<svg version="1.1"
xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:a="http://ns.adobe.com/AdobeSVGViewerExtensions/3.0/"
x="0px" y="0px" width="107px" height="107px" viewBox="-17.174 -24.39 107 107"
overflow="visible" enable-background="new -17.174 -24.39 107 107" xml:space="preserve">
<defs>
</defs>
<g>
<linearGradient id="SVGID_1_" gradientUnits="userSpaceOnUse" x1="12.2129" y1="39.3477" x2="59.75" y2="39.3477">
<stop offset="0" style="stop-color:#898989"/>
<stop offset="0.0798" style="stop-color:#58585A"/>
<stop offset="0.4447" style="stop-color:#474749"/>
<stop offset="0.7853" style="stop-color:#3D3D3F"/>
<stop offset="0.8232" style="stop-color:#464648"/>
<stop offset="0.8857" style="stop-color:#5F5F61"/>
<stop offset="0.9646" style="stop-color:#87888A"/>
<stop offset="1" style="stop-color:#9B9C9E"/>
</linearGradient>
<path fill="url(#SVGID_1_)" d="M59.45,37.001l-1.48-9.818l-44.251,1.82l-1.206,7.998c-0.195,0.645-0.3,1.307-0.3,1.981
c0,6.921,10.642,12.53,23.769,12.53s23.769-5.609,23.769-12.53C59.75,38.308,59.646,37.646,59.45,37.001z"/>
<linearGradient id="SVGID_2_" gradientUnits="userSpaceOnUse" x1="13.1631" y1="38.3486" x2="58.7988" y2="38.3486">
<stop offset="0" style="stop-color:#898989"/>
<stop offset="0.0859" style="stop-color:#676769"/>
<stop offset="0.268" style="stop-color:#616163"/>
<stop offset="0.4049" style="stop-color:#58585A"/>
<stop offset="0.908" style="stop-color:#676769"/>
<stop offset="0.9389" style="stop-color:#6D6D6F"/>
<stop offset="0.9815" style="stop-color:#7F7F80"/>
<stop offset="1" style="stop-color:#898989"/>
</linearGradient>
<path fill="url(#SVGID_2_)" d="M58.512,36.071l-1.422-9.523l-42.48,1.766l-1.158,7.758c-0.188,0.625-0.288,1.268-0.288,1.922
c0,6.713,10.217,12.155,22.818,12.155s22.817-5.442,22.817-12.155C58.799,37.339,58.699,36.696,58.512,36.071z"/>
</g>
<linearGradient id="SVGID_3_" gradientUnits="userSpaceOnUse" x1="13.3369" y1="31.8486" x2="58.6104" y2="31.8486">
<stop offset="0" style="stop-color:#898989"/>
<stop offset="0.0859" style="stop-color:#3D3D3F"/>
<stop offset="0.39" style="stop-color:#434345"/>
<stop offset="0.8089" style="stop-color:#555557"/>
<stop offset="0.865" style="stop-color:#58585A"/>
<stop offset="1" style="stop-color:#58585A"/>
</linearGradient>
<path fill="url(#SVGID_3_)" d="M13.337,31.536c2,0.104,6.124,4.434,12.807,6.387c6.149,1.796,12.109,2.05,17.251,0
c8.431-3.361,13.344-8.442,15.216-6.49l-1-7.102H14.455L13.337,31.536z"/>
<polygon fill="#4C4C4C" points="36.026,31.402 35.981,31.382 35.981,36.613 36.034,36.638 72.053,19.763 72.053,17.504
67.232,17.504 "/>
<polygon fill="#58585A" points="35.981,31.382 4.822,17.504 0,17.504 0,19.763 35.981,36.613 "/>
<g>
<polygon fill="#B0B2B3" points="36.034,0.628 0,17.504 36.034,34.38 72.053,17.504 "/>
<linearGradient id="SVGID_4_" gradientUnits="userSpaceOnUse" x1="0" y1="17.5039" x2="72.0527" y2="17.5039">
<stop offset="0" style="stop-color:#676769"/>
<stop offset="0.3361" style="stop-color:#6D6D6F"/>
<stop offset="0.799" style="stop-color:#7F7F80"/>
<stop offset="1" style="stop-color:#898989"/>
</linearGradient>
<polygon fill="url(#SVGID_4_)" points="36.034,0.628 0,17.504 36.034,34.38 72.053,17.504 "/>
</g>
<linearGradient id="SVGID_5_" gradientUnits="userSpaceOnUse" x1="0" y1="25.5254" x2="72.0527" y2="25.5254">
<stop offset="0" style="stop-color:#58585A"/>
<stop offset="0.2484" style="stop-color:#5B5B5D"/>
<stop offset="0.4496" style="stop-color:#656567"/>
<stop offset="0.6342" style="stop-color:#767678"/>
<stop offset="0.8089" style="stop-color:#8D8E90"/>
<stop offset="0.9752" style="stop-color:#ABADAE"/>
<stop offset="1" style="stop-color:#B0B2B3"/>
</linearGradient>
<polygon fill="url(#SVGID_5_)" points="71.615,16.671 72.053,17.504 36.034,34.38 0,17.504 0.438,16.671 "/>
<g>
<polygon fill="#B0B2B3" points="36.034,0 0.438,16.671 36.034,33.341 71.615,16.671 "/>
<linearGradient id="SVGID_6_" gradientUnits="userSpaceOnUse" x1="0.4375" y1="16.6704" x2="71.6152" y2="16.6704">
<stop offset="0" style="stop-color:#3D3D3F"/>
<stop offset="0.1996" style="stop-color:#434345"/>
<stop offset="0.4751" style="stop-color:#555556"/>
<stop offset="0.7934" style="stop-color:#727273"/>
<stop offset="1" style="stop-color:#898989"/>
</linearGradient>
<polygon fill="url(#SVGID_6_)" points="36.034,0 0.438,16.671 36.034,33.341 71.615,16.671 "/>
</g>
<polyline fill="none" stroke="#F4CC4D" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" points="
37.981,15.245 17.606,24.812 17.606,40.544 "/>
<g>
<path fill="#C2981E" d="M20.072,38.685H15.14l-2.854,15.502c0,0.743,2.381,2.803,5.32,2.803c2.938,0,5.32-2.06,5.32-2.803
L20.072,38.685z"/>
<linearGradient id="SVGID_7_" gradientUnits="userSpaceOnUse" x1="16.2759" y1="47.8516" x2="20.8228" y2="47.5343">
<stop offset="0.5031" style="stop-color:#F4CC4D"/>
<stop offset="0.6585" style="stop-color:#EEC649"/>
<stop offset="0.8725" style="stop-color:#DCB43E"/>
<stop offset="1" style="stop-color:#CEA636"/>
</linearGradient>
<path fill="url(#SVGID_7_)" d="M20.072,38.685H15.14l-2.854,15.502c0,0.743,2.381,2.803,5.32,2.803c2.938,0,5.32-2.06,5.32-2.803
L20.072,38.685z"/>
</g>
<linearGradient id="SVGID_8_" gradientUnits="userSpaceOnUse" x1="18.2104" y1="44.4365" x2="20.937" y2="51.7485">
<stop offset="0" style="stop-color:#EAC049"/>
<stop offset="0.3765" style="stop-color:#E4BA45"/>
<stop offset="0.8952" style="stop-color:#D2AA39"/>
<stop offset="0.9877" style="stop-color:#CEA636"/>
</linearGradient>
<polygon fill="url(#SVGID_8_)" points="20.535,56.606 18.673,41.413 19.269,41.341 21.131,56.533 "/>
<linearGradient id="SVGID_9_" gradientUnits="userSpaceOnUse" x1="19.7891" y1="45.0312" x2="22.4774" y2="51.315">
<stop offset="0" style="stop-color:#CEA636"/>
<stop offset="0.416" style="stop-color:#CBA230"/>
<stop offset="0.9877" style="stop-color:#C2981E"/>
</linearGradient>
<polygon fill="url(#SVGID_9_)" points="22.019,55.55 19.634,40.843 20.226,40.747 22.61,55.454 "/>
<path fill="#B79537" d="M20.384,40.379c-0.584,0.987-1.588,1.745-2.814,1.745c-1.229,0-2.188-0.593-2.771-1.58l0.172-1.494
l5.169-0.275L20.384,40.379z"/>
<radialGradient id="SVGID_10_" cx="16.71" cy="36.7051" r="5.0908" gradientUnits="userSpaceOnUse">
<stop offset="0.5031" style="stop-color:#F4CC4D"/>
<stop offset="0.6585" style="stop-color:#EEC649"/>
<stop offset="0.8725" style="stop-color:#DCB43E"/>
<stop offset="1" style="stop-color:#CEA636"/>
</radialGradient>
<circle fill="url(#SVGID_10_)" cx="17.606" cy="38.685" r="2.923"/>
<g>
<path fill="#B79537" d="M17.606,56.989c-2.939,0-5.32-2.06-5.32-2.803v0.799c0,0.742,2.381,2.803,5.32,2.803
c2.938,0,5.32-2.061,5.32-2.803v-0.799C22.927,54.93,20.545,56.989,17.606,56.989z"/>
<linearGradient id="SVGID_11_" gradientUnits="userSpaceOnUse" x1="13.0371" y1="56.083" x2="22.2794" y2="55.6343">
<stop offset="0" style="stop-color:#F4CC4D"/>
<stop offset="0.2114" style="stop-color:#EEC647"/>
<stop offset="0.5031" style="stop-color:#DDB437"/>
<stop offset="0.8282" style="stop-color:#C2981E"/>
<stop offset="0.9877" style="stop-color:#D3A522"/>
</linearGradient>
<path fill="url(#SVGID_11_)" d="M17.606,56.989c-2.939,0-5.32-2.06-5.32-2.803v0.799c0,0.742,2.381,2.803,5.32,2.803
c2.938,0,5.32-2.061,5.32-2.803v-0.799C22.927,54.93,20.545,56.989,17.606,56.989z"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 7.7 KiB

@ -68,7 +68,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/* API identifier */
/* Geonames API identifier */
var geonamesUser = "yimgo";
/* map variable will be used to manipulate the map. This will be initialized like an OpenLayers.Map object. */
@ -149,6 +149,17 @@
});
}
function importData(data)
{
map.setCenter(new OpenLayers.LonLat(data["center"]["lon"], data["center"]["lat"]), data["zoom"]);
}
function exportData()
{
if (window.sankore)
sankore.setPreference("osm", JSON.stringify({center: map.getCenter(), zoom: map.getZoom()}));
}
window.onload = function() {
map = new OpenLayers.Map({
div: "map"
@ -199,6 +210,20 @@
return false;
});
/* importing state from Sankoré preferences */
if (window.sankore) {
if (sankore.preference("osm","")) {
importData(JSON.parse(sankore.preference("osm","")));
}
}
/* exporting state when receiving a leave event */
if (window.widget) {
window.widget.onleave = function() {
exportData();
}
}
};
-->
</script>

@ -112,7 +112,7 @@ function start(){
drop: function(event, ui) {
if($(ui.draggable).parent().parent().html() == $(this).parent().html()){
var tmp_ui = $(ui.draggable).parent();
checkOnDrop($(this), $(ui.draggable));
$(this).append($(ui.draggable));
checkCorrectness(tmp_ui);
}
}
@ -341,7 +341,7 @@ function importData(data){
drop: function(event, ui) {
if($(ui.draggable).parent().parent().html() == $(this).parent().html()){
var tmp_ui = $(ui.draggable).parent();
checkOnDrop($(this), $(ui.draggable));
$(this).append($(ui.draggable));
checkCorrectness(tmp_ui);
}
}
@ -413,12 +413,11 @@ function importData(data){
drop: function(event, ui) {
if($(ui.draggable).parent().parent().html() == $(this).parent().html()){
var tmp_ui = $(ui.draggable).parent();
checkOnDrop($(this), $(ui.draggable));
$(this).append($(ui.draggable));
checkCorrectness(tmp_ui);
}
}
});
checkCorrectness(imgs_container);
}
all_imgs = $("<div class='all_imgs'>").appendTo(container);
@ -458,6 +457,7 @@ function importData(data){
}
});
container.appendTo("#data");
checkCorrectness(all_imgs);
}
}
}
@ -520,7 +520,7 @@ function showExample(){
drop: function(event, ui) {
if($(ui.draggable).parent().parent().html() == $(this).parent().html()){
var tmp_ui = $(ui.draggable).parent();
checkOnDrop($(this), $(ui.draggable));
$(this).append($(ui.draggable));
checkCorrectness(tmp_ui);
}
}
@ -531,7 +531,7 @@ function showExample(){
drop: function(event, ui) {
if($(ui.draggable).parent().parent().html() == $(this).parent().html()){
var tmp_ui = $(ui.draggable).parent();
checkOnDrop($(this), $(ui.draggable));
$(this).append($(ui.draggable));
checkCorrectness(tmp_ui);
}
}
@ -561,9 +561,9 @@ function addCategory(obj){
$("<button class='del_category'></button>").appendTo(imgs_container);
$("<button class='add_category'></button>").appendTo(imgs_container);
imgs_container.attr("ondragenter", "return false;")
.attr("ondragleave", "$(this).css(\"background-color\",\"\"); return false;")
.attr("ondragover", "$(this).css(\"background-color\",\"\"); return false;")
.attr("ondrop", "$(this).css(\"background-color\",\"\"); return onDropTarget(this,event);");
.attr("ondragleave", "$(this).css(\"background-color\",\"#e6f6ff\"); return false;")
.attr("ondragover", "$(this).css(\"background-color\",\"#c3e9ff\"); return false;")
.attr("ondrop", "$(this).css(\"background-color\",\"#e6f6ff\"); return onDropTarget(this,event);");
}
//add new container
@ -686,8 +686,7 @@ function returnId(){
}
//a func for checking when smth will drop
function checkOnDrop(dest, source){
dest.append(source);
function checkOnDrop(dest){
var tmp_count = dest.find("input[name='count']").val();
var tmp_mask = dest.find("input[name='mask']").val();
if(dest.find(".img_block").size() == tmp_count){
@ -697,47 +696,35 @@ function checkOnDrop(dest, source){
tmp_right = false;
});
if(tmp_right)
dest.removeClass("def_cont")
.removeClass("red_cont")
.addClass("green_cont");
dest.removeClass("def_cont").removeClass("red_cont").addClass("green_cont");
else
dest.removeClass("def_cont")
.removeClass("green_cont")
.addClass("red_cont");
dest.removeClass("def_cont").removeClass("green_cont").addClass("red_cont");
} else
dest.removeClass("def_cont")
.removeClass("green_cont")
.addClass("red_cont");
dest.removeClass("def_cont").removeClass("green_cont").addClass("red_cont");
}
//checking source on correctness
function checkCorrectness(source){
if(!source.hasClass("all_imgs")){
var tmp_count = source.find("input[name='count']").val();
var tmp_mask = source.find("input[name='mask']").val();
if(source.find(".img_block").size() == tmp_count){
var tmp_right = true;
source.find(".img_block").each(function(){
if($(this).find("input").val() != tmp_mask)
tmp_right = false;
});
if(tmp_right)
source.removeClass("def_cont")
.removeClass("red_cont")
.addClass("green_cont");
else
source.removeClass("def_cont")
.removeClass("green_cont")
.addClass("red_cont");
} else if(source.find(".img_block").size() == 0)
source.addClass("def_cont")
.removeClass("green_cont")
.removeClass("red_cont");
else
source.removeClass("def_cont")
.removeClass("green_cont")
.addClass("red_cont");
if(source.parent().find(".all_imgs").find(".img_block").size() == 0){
source.parent().find(".imgs_cont").each(function(){
checkOnDrop($(this))
})
} else {
source.parent().find(".imgs_cont").each(function(){
$(this).addClass("def_cont").removeClass("green_cont").removeClass("red_cont");
})
}
} else {
if(source.find(".img_block").size() > 0){
source.parent().find(".imgs_cont").each(function(){
$(this).addClass("def_cont").removeClass("green_cont").removeClass("red_cont");
})
} else {
source.parent().find(".imgs_cont").each(function(){
checkOnDrop($(this))
})
}
}
}

@ -130,7 +130,7 @@ function start(){
drop: function(event, ui) {
if($(ui.draggable).parent().parent().html() == $(this).parent().html()){
var tmp_ui = $(ui.draggable).parent();
checkOnDrop($(this), $(ui.draggable));
$(this).append($(ui.draggable));
checkCorrectness(tmp_ui);
}
}
@ -358,7 +358,7 @@ function importData(data){
drop: function(event, ui) {
if($(ui.draggable).parent().parent().html() == $(this).parent().html()){
var tmp_ui = $(ui.draggable).parent();
checkOnDrop($(this), $(ui.draggable));
$(this).append($(ui.draggable));
checkCorrectness(tmp_ui);
}
}
@ -430,7 +430,7 @@ function importData(data){
drop: function(event, ui) {
if($(ui.draggable).parent().parent().html() == $(this).parent().html()){
var tmp_ui = $(ui.draggable).parent();
checkOnDrop($(this), $(ui.draggable));
$(this).append($(ui.draggable));
checkCorrectness(tmp_ui);
}
}
@ -475,6 +475,7 @@ function importData(data){
}
});
container.appendTo("#data");
checkCorrectness(all_imgs);
}
}
}
@ -537,7 +538,7 @@ function showExample(){
drop: function(event, ui) {
if($(ui.draggable).parent().parent().html() == $(this).parent().html()){
var tmp_ui = $(ui.draggable).parent();
checkOnDrop($(this), $(ui.draggable));
$(this).append($(ui.draggable));
checkCorrectness(tmp_ui);
}
}
@ -548,7 +549,7 @@ function showExample(){
drop: function(event, ui) {
if($(ui.draggable).parent().parent().html() == $(this).parent().html()){
var tmp_ui = $(ui.draggable).parent();
checkOnDrop($(this), $(ui.draggable));
$(this).append($(ui.draggable));
checkCorrectness(tmp_ui);
}
}
@ -578,9 +579,9 @@ function addCategory(obj){
$("<button class='del_category'></button>").appendTo(imgs_container);
$("<button class='add_category'></button>").appendTo(imgs_container);
imgs_container.attr("ondragenter", "return false;")
.attr("ondragleave", "$(this).css(\"background-color\",\"\"); return false;")
.attr("ondragover", "$(this).css(\"background-color\",\"\"); return false;")
.attr("ondrop", "$(this).css(\"background-color\",\"\"); return onDropTarget(this,event);");
.attr("ondragleave", "$(this).css(\"background-color\",\"#e6f6ff\"); return false;")
.attr("ondragover", "$(this).css(\"background-color\",\"#c3e9ff\"); return false;")
.attr("ondrop", "$(this).css(\"background-color\",\"#e6f6ff\"); return onDropTarget(this,event);");
}
//add new container
@ -599,9 +600,9 @@ function addContainer(){
$("<button class='del_category'></button>").appendTo(imgs_container);
$("<button class='add_category'></button>").appendTo(imgs_container);
imgs_container.attr("ondragenter", "return false;")
.attr("ondragleave", "$(this).css(\"background-color\",\"\"); return false;")
.attr("ondragover", "$(this).css(\"background-color\",\"\"); return false;")
.attr("ondrop", "$(this).css(\"background-color\",\"\"); return onDropTarget(this,event);");
.attr("ondragleave", "$(this).css(\"background-color\",\"#e6f6ff\"); return false;")
.attr("ondragover", "$(this).css(\"background-color\",\"#c3e9ff\"); return false;")
.attr("ondrop", "$(this).css(\"background-color\",\"#e6f6ff\"); return onDropTarget(this,event);");
container.insertBefore($(".add_block"));
}
@ -704,8 +705,7 @@ function returnId(){
}
//a func for checking when smth will drop
function checkOnDrop(dest, source){
dest.append(source);
function checkOnDrop(dest){
var tmp_count = dest.find("input[name='count']").val();
var tmp_mask = dest.find("input[name='mask']").val();
if(dest.find(".img_block").size() == tmp_count){
@ -715,47 +715,35 @@ function checkOnDrop(dest, source){
tmp_right = false;
});
if(tmp_right)
dest.removeClass("def_cont")
.removeClass("red_cont")
.addClass("green_cont");
dest.removeClass("def_cont").removeClass("red_cont").addClass("green_cont");
else
dest.removeClass("def_cont")
.removeClass("green_cont")
.addClass("red_cont");
dest.removeClass("def_cont").removeClass("green_cont").addClass("red_cont");
} else
dest.removeClass("def_cont")
.removeClass("green_cont")
.addClass("red_cont");
dest.removeClass("def_cont").removeClass("green_cont").addClass("red_cont");
}
//checking source on correctness
function checkCorrectness(source){
if(!source.hasClass("all_imgs")){
var tmp_count = source.find("input[name='count']").val();
var tmp_mask = source.find("input[name='mask']").val();
if(source.find(".img_block").size() == tmp_count){
var tmp_right = true;
source.find(".img_block").each(function(){
if($(this).find("input").val() != tmp_mask)
tmp_right = false;
});
if(tmp_right)
source.removeClass("def_cont")
.removeClass("red_cont")
.addClass("green_cont");
else
source.removeClass("def_cont")
.removeClass("green_cont")
.addClass("red_cont");
} else if(source.find(".img_block").size() == 0)
source.addClass("def_cont")
.removeClass("green_cont")
.removeClass("red_cont");
else
source.removeClass("def_cont")
.removeClass("green_cont")
.addClass("red_cont");
if(source.parent().find(".all_imgs").find(".img_block").size() == 0){
source.parent().find(".imgs_cont").each(function(){
checkOnDrop($(this))
})
} else {
source.parent().find(".imgs_cont").each(function(){
$(this).addClass("def_cont").removeClass("green_cont").removeClass("red_cont");
})
}
} else {
if(source.find(".img_block").size() > 0){
source.parent().find(".imgs_cont").each(function(){
$(this).addClass("def_cont").removeClass("green_cont").removeClass("red_cont");
})
} else {
source.parent().find(".imgs_cont").each(function(){
checkOnDrop($(this))
})
}
}
}

@ -111,7 +111,7 @@ function start(){
drop: function(event, ui) {
if($(ui.draggable).parent().parent().html() == $(this).parent().html()){
var tmp_ui = $(ui.draggable).parent();
checkOnDrop($(this), $(ui.draggable));
$(this).append($(ui.draggable));
checkCorrectness(tmp_ui);
}
}
@ -342,7 +342,7 @@ function importData(data){
drop: function(event, ui) {
if($(ui.draggable).parent().parent().html() == $(this).parent().html()){
var tmp_ui = $(ui.draggable).parent();
checkOnDrop($(this), $(ui.draggable));
$(this).append($(ui.draggable));
checkCorrectness(tmp_ui);
}
}
@ -414,7 +414,7 @@ function importData(data){
drop: function(event, ui) {
if($(ui.draggable).parent().parent().html() == $(this).parent().html()){
var tmp_ui = $(ui.draggable).parent();
checkOnDrop($(this), $(ui.draggable));
$(this).append($(ui.draggable));
checkCorrectness(tmp_ui);
}
}
@ -459,6 +459,7 @@ function importData(data){
}
});
container.appendTo("#data");
checkCorrectness(all_imgs);
}
}
}
@ -521,7 +522,7 @@ function showExample(){
drop: function(event, ui) {
if($(ui.draggable).parent().parent().html() == $(this).parent().html()){
var tmp_ui = $(ui.draggable).parent();
checkOnDrop($(this), $(ui.draggable));
$(this).append($(ui.draggable));
checkCorrectness(tmp_ui);
}
}
@ -532,7 +533,7 @@ function showExample(){
drop: function(event, ui) {
if($(ui.draggable).parent().parent().html() == $(this).parent().html()){
var tmp_ui = $(ui.draggable).parent();
checkOnDrop($(this), $(ui.draggable));
$(this).append($(ui.draggable));
checkCorrectness(tmp_ui);
}
}
@ -562,9 +563,9 @@ function addCategory(obj){
$("<button class='del_category'></button>").appendTo(imgs_container);
$("<button class='add_category'></button>").appendTo(imgs_container);
imgs_container.attr("ondragenter", "return false;")
.attr("ondragleave", "$(this).css(\"background-color\",\"\"); return false;")
.attr("ondragover", "$(this).css(\"background-color\",\"\"); return false;")
.attr("ondrop", "$(this).css(\"background-color\",\"\"); return onDropTarget(this,event);");
.attr("ondragleave", "$(this).css(\"background-color\",\"#e6f6ff\"); return false;")
.attr("ondragover", "$(this).css(\"background-color\",\"#c3e9ff\"); return false;")
.attr("ondrop", "$(this).css(\"background-color\",\"#e6f6ff\"); return onDropTarget(this,event);");
}
//add new container
@ -583,9 +584,9 @@ function addContainer(){
$("<button class='del_category'></button>").appendTo(imgs_container);
$("<button class='add_category'></button>").appendTo(imgs_container);
imgs_container.attr("ondragenter", "return false;")
.attr("ondragleave", "$(this).css(\"background-color\",\"\"); return false;")
.attr("ondragover", "$(this).css(\"background-color\",\"\"); return false;")
.attr("ondrop", "$(this).css(\"background-color\",\"\"); return onDropTarget(this,event);");
.attr("ondragleave", "$(this).css(\"background-color\",\"#e6f6ff\"); return false;")
.attr("ondragover", "$(this).css(\"background-color\",\"#c3e9ff\"); return false;")
.attr("ondrop", "$(this).css(\"background-color\",\"#e6f6ff\"); return onDropTarget(this,event);");
container.insertBefore($(".add_block"));
}
@ -688,8 +689,7 @@ function returnId(){
}
//a func for checking when smth will drop
function checkOnDrop(dest, source){
dest.append(source);
function checkOnDrop(dest){
var tmp_count = dest.find("input[name='count']").val();
var tmp_mask = dest.find("input[name='mask']").val();
if(dest.find(".img_block").size() == tmp_count){
@ -699,47 +699,35 @@ function checkOnDrop(dest, source){
tmp_right = false;
});
if(tmp_right)
dest.removeClass("def_cont")
.removeClass("red_cont")
.addClass("green_cont");
dest.removeClass("def_cont").removeClass("red_cont").addClass("green_cont");
else
dest.removeClass("def_cont")
.removeClass("green_cont")
.addClass("red_cont");
dest.removeClass("def_cont").removeClass("green_cont").addClass("red_cont");
} else
dest.removeClass("def_cont")
.removeClass("green_cont")
.addClass("red_cont");
dest.removeClass("def_cont").removeClass("green_cont").addClass("red_cont");
}
//checking source on correctness
function checkCorrectness(source){
if(!source.hasClass("all_imgs")){
var tmp_count = source.find("input[name='count']").val();
var tmp_mask = source.find("input[name='mask']").val();
if(source.find(".img_block").size() == tmp_count){
var tmp_right = true;
source.find(".img_block").each(function(){
if($(this).find("input").val() != tmp_mask)
tmp_right = false;
});
if(tmp_right)
source.removeClass("def_cont")
.removeClass("red_cont")
.addClass("green_cont");
else
source.removeClass("def_cont")
.removeClass("green_cont")
.addClass("red_cont");
} else if(source.find(".img_block").size() == 0)
source.addClass("def_cont")
.removeClass("green_cont")
.removeClass("red_cont");
else
source.removeClass("def_cont")
.removeClass("green_cont")
.addClass("red_cont");
if(source.parent().find(".all_imgs").find(".img_block").size() == 0){
source.parent().find(".imgs_cont").each(function(){
checkOnDrop($(this))
})
} else {
source.parent().find(".imgs_cont").each(function(){
$(this).addClass("def_cont").removeClass("green_cont").removeClass("red_cont");
})
}
} else {
if(source.find(".img_block").size() > 0){
source.parent().find(".imgs_cont").each(function(){
$(this).addClass("def_cont").removeClass("green_cont").removeClass("red_cont");
})
} else {
source.parent().find(".imgs_cont").each(function(){
checkOnDrop($(this))
})
}
}
}

@ -120,7 +120,7 @@ function start(){
drop: function(event, ui) {
if($(ui.draggable).parent().parent().html() == $(this).parent().html()){
var tmp_ui = $(ui.draggable).parent();
checkOnDrop($(this), $(ui.draggable));
$(this).append($(ui.draggable));
checkCorrectness(tmp_ui);
}
}
@ -339,7 +339,7 @@ function importData(data){
drop: function(event, ui) {
if($(ui.draggable).parent().parent().html() == $(this).parent().html()){
var tmp_ui = $(ui.draggable).parent();
checkOnDrop($(this), $(ui.draggable));
$(this).append($(ui.draggable));
checkCorrectness(tmp_ui);
}
}
@ -410,12 +410,11 @@ function importData(data){
drop: function(event, ui) {
if($(ui.draggable).parent().parent().html() == $(this).parent().html()){
var tmp_ui = $(ui.draggable).parent();
checkOnDrop($(this), $(ui.draggable));
$(this).append($(ui.draggable));
checkCorrectness(tmp_ui);
}
}
});
checkCorrectness(imgs_container);
}
all_imgs = $("<div class='all_imgs'>").appendTo(container);
@ -453,6 +452,7 @@ function importData(data){
}
}
});
checkCorrectness(all_imgs);
}
}
}
@ -516,7 +516,7 @@ function showExample(){
drop: function(event, ui) {
if($(ui.draggable).parent().parent().html() == $(this).parent().html()){
var tmp_ui = $(ui.draggable).parent();
checkOnDrop($(this), $(ui.draggable));
$(this).append($(ui.draggable));
checkCorrectness(tmp_ui);
}
}
@ -527,7 +527,7 @@ function showExample(){
drop: function(event, ui) {
if($(ui.draggable).parent().parent().html() == $(this).parent().html()){
var tmp_ui = $(ui.draggable).parent();
checkOnDrop($(this), $(ui.draggable));
$(this).append($(ui.draggable));
checkCorrectness(tmp_ui);
}
}
@ -685,8 +685,7 @@ function changeStyle(val){
}
//a func for checking when smth will drop
function checkOnDrop(dest, source){
dest.append(source);
function checkOnDrop(dest){
var tmp_count = dest.find("input[name='count']").val();
var tmp_mask = dest.find("input[name='mask']").val();
if(dest.find(".img_block").size() == tmp_count){
@ -696,46 +695,34 @@ function checkOnDrop(dest, source){
tmp_right = false;
});
if(tmp_right)
dest.removeClass("def_cont")
.removeClass("red_cont")
.addClass("green_cont");
dest.removeClass("def_cont").removeClass("red_cont").addClass("green_cont");
else
dest.removeClass("def_cont")
.removeClass("green_cont")
.addClass("red_cont");
dest.removeClass("def_cont").removeClass("green_cont").addClass("red_cont");
} else
dest.removeClass("def_cont")
.removeClass("green_cont")
.addClass("red_cont");
dest.removeClass("def_cont").removeClass("green_cont").addClass("red_cont");
}
//checking source on correctness
function checkCorrectness(source){
if(!source.hasClass("all_imgs")){
var tmp_count = source.find("input[name='count']").val();
var tmp_mask = source.find("input[name='mask']").val();
if(source.find(".img_block").size() == tmp_count){
var tmp_right = true;
source.find(".img_block").each(function(){
if($(this).find("input").val() != tmp_mask)
tmp_right = false;
});
if(tmp_right)
source.removeClass("def_cont")
.removeClass("red_cont")
.addClass("green_cont");
else
source.removeClass("def_cont")
.removeClass("green_cont")
.addClass("red_cont");
} else if(source.find(".img_block").size() == 0)
source.addClass("def_cont")
.removeClass("green_cont")
.removeClass("red_cont");
else
source.removeClass("def_cont")
.removeClass("green_cont")
.addClass("red_cont");
if(source.parent().find(".all_imgs").find(".img_block").size() == 0){
source.parent().find(".imgs_cont").each(function(){
checkOnDrop($(this))
})
} else {
source.parent().find(".imgs_cont").each(function(){
$(this).addClass("def_cont").removeClass("green_cont").removeClass("red_cont");
})
}
} else {
if(source.find(".img_block").size() > 0){
source.parent().find(".imgs_cont").each(function(){
$(this).addClass("def_cont").removeClass("green_cont").removeClass("red_cont");
})
} else {
source.parent().find(".imgs_cont").each(function(){
checkOnDrop($(this))
})
}
}
}

@ -141,7 +141,7 @@ function start(){
drop: function(event, ui) {
if($(ui.draggable).parent().parent().html() == $(this).parent().html()){
var tmp_ui = $(ui.draggable).parent();
checkOnDrop($(this), $(ui.draggable));
$(this).append($(ui.draggable));
checkCorrectness(tmp_ui);
}
}
@ -360,7 +360,7 @@ function importData(data){
drop: function(event, ui) {
if($(ui.draggable).parent().parent().html() == $(this).parent().html()){
var tmp_ui = $(ui.draggable).parent();
checkOnDrop($(this), $(ui.draggable));
$(this).append($(ui.draggable));
checkCorrectness(tmp_ui);
}
}
@ -431,7 +431,7 @@ function importData(data){
drop: function(event, ui) {
if($(ui.draggable).parent().parent().html() == $(this).parent().html()){
var tmp_ui = $(ui.draggable).parent();
checkOnDrop($(this), $(ui.draggable));
$(this).append($(ui.draggable));
checkCorrectness(tmp_ui);
}
}
@ -474,6 +474,7 @@ function importData(data){
}
}
});
checkCorrectness(all_imgs);
}
}
}
@ -537,7 +538,7 @@ function showExample(){
drop: function(event, ui) {
if($(ui.draggable).parent().parent().html() == $(this).parent().html()){
var tmp_ui = $(ui.draggable).parent();
checkOnDrop($(this), $(ui.draggable));
$(this).append($(ui.draggable));
checkCorrectness(tmp_ui);
}
}
@ -548,7 +549,7 @@ function showExample(){
drop: function(event, ui) {
if($(ui.draggable).parent().parent().html() == $(this).parent().html()){
var tmp_ui = $(ui.draggable).parent();
checkOnDrop($(this), $(ui.draggable));
$(this).append($(ui.draggable));
checkCorrectness(tmp_ui);
}
}
@ -706,8 +707,7 @@ function changeStyle(val){
}
//a func for checking when smth will drop
function checkOnDrop(dest, source){
dest.append(source);
function checkOnDrop(dest){
var tmp_count = dest.find("input[name='count']").val();
var tmp_mask = dest.find("input[name='mask']").val();
if(dest.find(".img_block").size() == tmp_count){
@ -717,46 +717,34 @@ function checkOnDrop(dest, source){
tmp_right = false;
});
if(tmp_right)
dest.removeClass("def_cont")
.removeClass("red_cont")
.addClass("green_cont");
dest.removeClass("def_cont").removeClass("red_cont").addClass("green_cont");
else
dest.removeClass("def_cont")
.removeClass("green_cont")
.addClass("red_cont");
dest.removeClass("def_cont").removeClass("green_cont").addClass("red_cont");
} else
dest.removeClass("def_cont")
.removeClass("green_cont")
.addClass("red_cont");
dest.removeClass("def_cont").removeClass("green_cont").addClass("red_cont");
}
//checking source on correctness
function checkCorrectness(source){
if(!source.hasClass("all_imgs")){
var tmp_count = source.find("input[name='count']").val();
var tmp_mask = source.find("input[name='mask']").val();
if(source.find(".img_block").size() == tmp_count){
var tmp_right = true;
source.find(".img_block").each(function(){
if($(this).find("input").val() != tmp_mask)
tmp_right = false;
});
if(tmp_right)
source.removeClass("def_cont")
.removeClass("red_cont")
.addClass("green_cont");
else
source.removeClass("def_cont")
.removeClass("green_cont")
.addClass("red_cont");
} else if(source.find(".img_block").size() == 0)
source.addClass("def_cont")
.removeClass("green_cont")
.removeClass("red_cont");
else
source.removeClass("def_cont")
.removeClass("green_cont")
.addClass("red_cont");
if(source.parent().find(".all_imgs").find(".img_block").size() == 0){
source.parent().find(".imgs_cont").each(function(){
checkOnDrop($(this))
})
} else {
source.parent().find(".imgs_cont").each(function(){
$(this).addClass("def_cont").removeClass("green_cont").removeClass("red_cont");
})
}
} else {
if(source.find(".img_block").size() > 0){
source.parent().find(".imgs_cont").each(function(){
$(this).addClass("def_cont").removeClass("green_cont").removeClass("red_cont");
})
} else {
source.parent().find(".imgs_cont").each(function(){
checkOnDrop($(this))
})
}
}
}

@ -120,7 +120,7 @@ function start(){
drop: function(event, ui) {
if($(ui.draggable).parent().parent().html() == $(this).parent().html()){
var tmp_ui = $(ui.draggable).parent();
checkOnDrop($(this), $(ui.draggable));
$(this).append($(ui.draggable));
checkCorrectness(tmp_ui);
}
}
@ -339,7 +339,7 @@ function importData(data){
drop: function(event, ui) {
if($(ui.draggable).parent().parent().html() == $(this).parent().html()){
var tmp_ui = $(ui.draggable).parent();
checkOnDrop($(this), $(ui.draggable));
$(this).append($(ui.draggable));
checkCorrectness(tmp_ui);
}
}
@ -410,7 +410,7 @@ function importData(data){
drop: function(event, ui) {
if($(ui.draggable).parent().parent().html() == $(this).parent().html()){
var tmp_ui = $(ui.draggable).parent();
checkOnDrop($(this), $(ui.draggable));
$(this).append($(ui.draggable));
checkCorrectness(tmp_ui);
}
}
@ -453,6 +453,7 @@ function importData(data){
}
}
});
checkCorrectness(all_imgs);
}
}
}
@ -516,7 +517,7 @@ function showExample(){
drop: function(event, ui) {
if($(ui.draggable).parent().parent().html() == $(this).parent().html()){
var tmp_ui = $(ui.draggable).parent();
checkOnDrop($(this), $(ui.draggable));
$(this).append($(ui.draggable));
checkCorrectness(tmp_ui);
}
}
@ -527,7 +528,7 @@ function showExample(){
drop: function(event, ui) {
if($(ui.draggable).parent().parent().html() == $(this).parent().html()){
var tmp_ui = $(ui.draggable).parent();
checkOnDrop($(this), $(ui.draggable));
$(this).append($(ui.draggable));
checkCorrectness(tmp_ui);
}
}
@ -685,8 +686,7 @@ function changeStyle(val){
}
//a func for checking when smth will drop
function checkOnDrop(dest, source){
dest.append(source);
function checkOnDrop(dest){
var tmp_count = dest.find("input[name='count']").val();
var tmp_mask = dest.find("input[name='mask']").val();
if(dest.find(".img_block").size() == tmp_count){
@ -696,46 +696,34 @@ function checkOnDrop(dest, source){
tmp_right = false;
});
if(tmp_right)
dest.removeClass("def_cont")
.removeClass("red_cont")
.addClass("green_cont");
dest.removeClass("def_cont").removeClass("red_cont").addClass("green_cont");
else
dest.removeClass("def_cont")
.removeClass("green_cont")
.addClass("red_cont");
dest.removeClass("def_cont").removeClass("green_cont").addClass("red_cont");
} else
dest.removeClass("def_cont")
.removeClass("green_cont")
.addClass("red_cont");
dest.removeClass("def_cont").removeClass("green_cont").addClass("red_cont");
}
//checking source on correctness
function checkCorrectness(source){
if(!source.hasClass("all_imgs")){
var tmp_count = source.find("input[name='count']").val();
var tmp_mask = source.find("input[name='mask']").val();
if(source.find(".img_block").size() == tmp_count){
var tmp_right = true;
source.find(".img_block").each(function(){
if($(this).find("input").val() != tmp_mask)
tmp_right = false;
});
if(tmp_right)
source.removeClass("def_cont")
.removeClass("red_cont")
.addClass("green_cont");
else
source.removeClass("def_cont")
.removeClass("green_cont")
.addClass("red_cont");
} else if(source.find(".img_block").size() == 0)
source.addClass("def_cont")
.removeClass("green_cont")
.removeClass("red_cont");
else
source.removeClass("def_cont")
.removeClass("green_cont")
.addClass("red_cont");
if(source.parent().find(".all_imgs").find(".img_block").size() == 0){
source.parent().find(".imgs_cont").each(function(){
checkOnDrop($(this))
})
} else {
source.parent().find(".imgs_cont").each(function(){
$(this).addClass("def_cont").removeClass("green_cont").removeClass("red_cont");
})
}
} else {
if(source.find(".img_block").size() > 0){
source.parent().find(".imgs_cont").each(function(){
$(this).addClass("def_cont").removeClass("green_cont").removeClass("red_cont");
})
} else {
source.parent().find(".imgs_cont").each(function(){
checkOnDrop($(this))
})
}
}
}

@ -165,6 +165,7 @@
<file>images/toolPalette/triangleTool.png</file>
<file>images/toolPalette/protractorTool.png</file>
<file>images/toolPalette/compassTool.png</file>
<file>images/toolPalette/aristoTool.png</file>
<file>images/toolPalette/maskTool.png</file>
<file>images/toolPalette/magnifierTool.png</file>
<file>images/extraPalette/blackout.png</file>
@ -365,6 +366,6 @@
<file>images/teacherGuide/pencil.svg</file>
<file>images/duplicateDisabled.svg</file>
<file>images/teacherGuide/flash_24x24.svg</file>
<file>images/toque.png</file>
<file>images/toque.svg</file>
</qresource>
</RCC>

@ -171,8 +171,11 @@ UBDocumentProxy* UBImportDocument::importFile(const QFile& pFile, const QString&
return NULL;
}
bool addTitlePage = false;
if(UBSettings::settings()->teacherGuidePageZeroActivated->get().toBool() && !QFile(documentRootFolder+"/page000.svg").exists())
addTitlePage=true;
UBDocumentProxy* newDocument = UBPersistenceManager::persistenceManager()->createDocumentFromDir(documentRootFolder, pGroup);
UBDocumentProxy* newDocument = UBPersistenceManager::persistenceManager()->createDocumentFromDir(documentRootFolder, pGroup, "", false, addTitlePage);
UBApplication::showMessage(tr("Import successful."));
return newDocument;
}

@ -941,18 +941,6 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
readGroupRoot();
}
// else if (mXmlReader.name() == "teacherBar" || mXmlReader.name() == "teacherGuide"){
// sTeacherGuideNode.clear();
// sTeacherGuideNode += "<teacherGuide version=\"" + mXmlReader.attributes().value("version").toString() + "\">";
// sTeacherGuideNode += "\n";
// }
// else if (mXmlReader.name() == "media" || mXmlReader.name() == "link" || mXmlReader.name() == "title" || mXmlReader.name() == "comment" || mXmlReader.name() == "action")
// {
// sTeacherGuideNode += "<" + mXmlReader.name().toString() + " ";
// foreach(QXmlStreamAttribute attribute, mXmlReader.attributes())
// sTeacherGuideNode += attribute.name().toString() + "=\"" + attribute.value().toString() + "\" ";
// sTeacherGuideNode += " />\n";
// }
else
{
// NOOP
@ -976,17 +964,6 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
mGroupDarkBackgroundColor = QColor();
mGroupLightBackgroundColor = QColor();
}
// else if (mXmlReader.name() == "teacherBar" || mXmlReader.name() == "teacherGuide"){
// sTeacherGuideNode += "</teacherGuide>";
// qDebug() << sTeacherGuideNode;
// QMap<QString,IDataStorage*> elements = getAdditionalElementToStore();
// IDataStorage* storageClass = elements.value("teacherGuide");
// if(storageClass){
// storageClass->load(sTeacherGuideNode);
// }
// }
}
}
@ -1147,17 +1124,10 @@ bool UBSvgSubsetAdaptor::UBSvgSubsetWriter::persistScene(int pageIndex)
QDomElement groupRoot = groupDomDocument.createElement(tGroups);
groupDomDocument.appendChild(groupRoot);
static int i = 0;
qDebug() << "persist call no is " << ++i;
QBuffer buffer;
buffer.open(QBuffer::WriteOnly);
mXmlWriter.setDevice(&buffer);
//Unused variable
//QTime timer = QTime::currentTime();
mXmlWriter.setAutoFormatting(true);
mXmlWriter.writeStartDocument();
@ -3120,7 +3090,7 @@ UBGraphicsTriangle* UBSvgSubsetAdaptor::UBSvgSubsetReader::triangleFromSvg()
UBGraphicsCache* UBSvgSubsetAdaptor::UBSvgSubsetReader::cacheFromSvg()
{
UBGraphicsCache* pCache = new UBGraphicsCache();
UBGraphicsCache* pCache = UBGraphicsCache::instance(mScene);
pCache->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Tool));
graphicsItemFromSvg(pCache);

@ -23,7 +23,12 @@
#include "core/UBApplication.h"
#include "core/UBSettings.h"
#include "gui/UBDockTeacherGuideWidget.h"
#include "gui/UBTeacherGuideWidget.h"
#include "board/UBBoardController.h"
#include "board/UBBoardPaletteManager.h"
#include "document/UBDocumentProxy.h"
@ -120,7 +125,7 @@ void UBThumbnailAdaptor::persistScene(UBDocumentProxy* proxy, UBGraphicsScene* p
QFile thumbFile(fileName);
if (pScene->isModified() || overrideModified || !thumbFile.exists())
if (pScene->isModified() || overrideModified || !thumbFile.exists() || UBApplication::boardController->paletteManager()->teacherGuideDockWidget()->teacherGuideWidget()->isModified())
{
qreal nominalWidth = pScene->nominalSize().width();
qreal nominalHeight = pScene->nominalSize().height();
@ -152,6 +157,12 @@ void UBThumbnailAdaptor::persistScene(UBDocumentProxy* proxy, UBGraphicsScene* p
pScene->render(&painter, imageRect, sceneRect, Qt::KeepAspectRatio);
if(UBApplication::boardController->paletteManager()->teacherGuideDockWidget()->teacherGuideWidget()->isModified()){
QPixmap toque(":images/toque.svg");
painter.setOpacity(0.6);
painter.drawPixmap(QPoint(width - toque.width(),0),toque);
}
pScene->setRenderingContext(UBGraphicsScene::Screen);
pScene->setRenderingQuality(UBItem::RenderingQualityNormal);

@ -40,7 +40,7 @@ UBLibraryAPI::~UBLibraryAPI()
void UBLibraryAPI::addObject(QString pUrl, int width, int height, int x, int y, bool background)
{
if (UBApplication::boardController)
UBApplication::boardController->downloadURL(QUrl(pUrl), QPointF(x, y), QSize(width, height), background);
UBApplication::boardController->downloadURL(QUrl(pUrl), QString(), QPointF(x, y), QSize(width, height), background);
}

@ -201,7 +201,7 @@ void UBWidgetUniboardAPI::addObject(QString pUrl, int width, int height, int x,
if (UBApplication::boardController->activeScene() != mScene)
return;
UBApplication::boardController->downloadURL(QUrl(pUrl), QPointF(x, y), QSize(width, height), background);
UBApplication::boardController->downloadURL(QUrl(pUrl), QString(), QPointF(x, y), QSize(width, height), background);
}
@ -506,7 +506,7 @@ void UBWidgetUniboardAPI::ProcessDropEvent(QGraphicsSceneDragDropEvent *event)
sDownloadFileDesc desc;
desc.dest = sDownloadFileDesc::graphicsWidget;
desc.modal = true;
desc.url = url;
desc.srcUrl = url;
desc.currentSize = 0;
desc.name = QFileInfo(url).fileName();
desc.totalSize = 0; // The total size will be retrieved during the download

@ -95,6 +95,7 @@ UBBoardController::UBBoardController(UBMainWindow* mainWindow)
, mCleanupDone(false)
, mCacheWidgetIsEnabled(false)
, mDeletingSceneIndex(-1)
, mMovingSceneIndex(-1)
, mActionGroupText(tr("Group"))
, mActionUngroupText(tr("Ungroup"))
{
@ -131,7 +132,7 @@ void UBBoardController::init()
, this, SLOT(lastWindowClosed()));
connect(UBDownloadManager::downloadManager(), SIGNAL(downloadModalFinished()), this, SLOT(onDownloadModalFinished()));
connect(UBDownloadManager::downloadManager(), SIGNAL(addDownloadedFileToBoard(bool,QUrl,QString,QByteArray,QPointF,QSize,bool)), this, SLOT(downloadFinished(bool,QUrl,QString,QByteArray,QPointF,QSize,bool)));
connect(UBDownloadManager::downloadManager(), SIGNAL(addDownloadedFileToBoard(bool,QUrl,QUrl,QString,QByteArray,QPointF,QSize,bool)), this, SLOT(downloadFinished(bool,QUrl,QUrl,QString,QByteArray,QPointF,QSize,bool)));
UBDocumentProxy* doc = UBPersistenceManager::persistenceManager()->createDocument();
@ -562,7 +563,12 @@ UBGraphicsItem *UBBoardController::duplicateItem(UBItem *item)
}
UBMimeType::Enum itemMimeType;
QString contentTypeHeader = UBFileSystemUtils::mimeTypeFromFileName(item->sourceUrl().toLocalFile());
QString srcFile = item->sourceUrl().toLocalFile();
if (srcFile.isEmpty())
srcFile = item->sourceUrl().toString();
QString contentTypeHeader = UBFileSystemUtils::mimeTypeFromFileName(srcFile);
if(NULL != qgraphicsitem_cast<UBGraphicsGroupContainerItem*>(commonItem))
itemMimeType = UBMimeType::Group;
else
@ -587,8 +593,9 @@ UBGraphicsItem *UBBoardController::duplicateItem(UBItem *item)
if (mitem)
{
sourceUrl = mitem->mediaFileUrl();
downloadURL(sourceUrl, srcFile, itemPos, QSize(itemSize.width(), itemSize.height()), false, false);
}
}break;
}return NULL; // async operation
case UBMimeType::VectorImage:
{
@ -661,7 +668,7 @@ UBGraphicsItem *UBBoardController::duplicateItem(UBItem *item)
if (retItem)
return retItem;
UBItem *createdItem = downloadFinished(true, sourceUrl, contentTypeHeader, pData, itemPos, QSize(itemSize.width(), itemSize.height()), false);
UBItem *createdItem = downloadFinished(true, sourceUrl, sourceUrl, contentTypeHeader, pData, itemPos, QSize(itemSize.width(), itemSize.height()), false);
if (createdItem)
{
createdItem->setSourceUrl(item->sourceUrl());
@ -675,6 +682,7 @@ UBGraphicsItem *UBBoardController::duplicateItem(UBItem *item)
retItem = dynamic_cast<UBGraphicsItem *>(createdItem);
}
return retItem;
}
@ -960,7 +968,7 @@ void UBBoardController::groupButtonClicked()
}
}
void UBBoardController::downloadURL(const QUrl& url, const QPointF& pPos, const QSize& pSize, bool isBackground, bool internalData)
void UBBoardController::downloadURL(const QUrl& url, QString contentSourceUrl, const QPointF& pPos, const QSize& pSize, bool isBackground, bool internalData)
{
qDebug() << "something has been dropped on the board! Url is: " << url.toString();
QString sUrl = url.toString();
@ -971,7 +979,7 @@ void UBBoardController::downloadURL(const QUrl& url, const QPointF& pPos, const
if(sUrl.startsWith("uniboardTool://"))
{
downloadFinished(true, url, "application/vnd.mnemis-uniboard-tool", QByteArray(), pPos, pSize, isBackground);
downloadFinished(true, url, QUrl(), "application/vnd.mnemis-uniboard-tool", QByteArray(), pPos, pSize, isBackground);
}
else if (sUrl.startsWith("file://") || sUrl.startsWith("/"))
{
@ -984,22 +992,37 @@ void UBBoardController::downloadURL(const QUrl& url, const QPointF& pPos, const
|| contentType.startsWith("application/widget")
|| contentType.startsWith("application/vnd.apple-widget");
QFile file(fileName);
if (shouldLoadFileData)
{
QFile file(fileName);
file.open(QIODevice::ReadOnly);
downloadFinished(true, formedUrl, contentType, file.readAll(), pPos, pSize, isBackground, internalData);
if (shouldLoadFileData)
downloadFinished(true, formedUrl, QUrl(), contentType, file.readAll(), pPos, pSize, isBackground, internalData);
file.close();
}
else
{
// media items should be copyed in separate thread
sDownloadFileDesc desc;
desc.modal = false;
desc.srcUrl = sUrl;
desc.originalSrcUrl = contentSourceUrl;
desc.currentSize = 0;
desc.name = QFileInfo(url.toString()).fileName();
desc.totalSize = 0; // The total size will be retrieved during the download
desc.pos = pPos;
desc.size = pSize;
desc.isBackground = isBackground;
UBDownloadManager::downloadManager()->addFileToDownload(desc);
}
}
else
{
// When we fall there, it means that we are dropping something from the web to the board
sDownloadFileDesc desc;
desc.modal = true;
desc.url = url.toString();
desc.srcUrl = url.toString();
desc.currentSize = 0;
desc.name = QFileInfo(url.toString()).fileName();
desc.totalSize = 0; // The total size will be retrieved during the download
@ -1022,7 +1045,7 @@ void UBBoardController::downloadURL(const QUrl& url, const QPointF& pPos, const
}
UBItem *UBBoardController::downloadFinished(bool pSuccess, QUrl sourceUrl, QString pContentTypeHeader,
UBItem *UBBoardController::downloadFinished(bool pSuccess, QUrl sourceUrl, QUrl contentUrl, QString pContentTypeHeader,
QByteArray pData, QPointF pPos, QSize pSize,
bool isBackground, bool internalData)
{
@ -1157,11 +1180,9 @@ UBItem *UBBoardController::downloadFinished(bool pSuccess, QUrl sourceUrl, QStri
qDebug() << "accepting mime type" << mimeType << "as video";
UBGraphicsMediaItem *mediaVideoItem = 0;
QUuid uuid = QUuid::createUuid();
if (pData.length() > 0)
{
QUuid uuid = QUuid::createUuid();
QString destFile;
bool b = UBPersistenceManager::persistenceManager()->addFileToDocument(selectedDocument(),
sourceUrl.toString(),
@ -1178,16 +1199,19 @@ UBItem *UBBoardController::downloadFinished(bool pSuccess, QUrl sourceUrl, QStri
QUrl url = QUrl::fromLocalFile(destFile);
mediaVideoItem = mActiveScene->addMedia(url, false, pPos);
mediaVideoItem->setSourceUrl(sourceUrl);
mediaVideoItem->setUuid(uuid);
}
else
{
mediaVideoItem = addVideo(sourceUrl, false, pPos);
qDebug() << sourceUrl.toString();
mediaVideoItem = addVideo(sourceUrl, false, pPos, true);
}
if(mediaVideoItem){
if (contentUrl.isEmpty())
mediaVideoItem->setSourceUrl(sourceUrl);
else
mediaVideoItem->setSourceUrl(contentUrl);
mediaVideoItem->setUuid(uuid);
connect(this, SIGNAL(activeSceneChanged()), mediaVideoItem, SLOT(activeSceneChanged()));
}
@ -1201,10 +1225,9 @@ UBItem *UBBoardController::downloadFinished(bool pSuccess, QUrl sourceUrl, QStri
UBGraphicsMediaItem *audioMediaItem = 0;
QUuid uuid = QUuid::createUuid();
if (pData.length() > 0)
{
QUuid uuid = QUuid::createUuid();
QString destFile;
bool b = UBPersistenceManager::persistenceManager()->addFileToDocument(selectedDocument(),
sourceUrl.toString(),
@ -1221,16 +1244,18 @@ UBItem *UBBoardController::downloadFinished(bool pSuccess, QUrl sourceUrl, QStri
QUrl url = QUrl::fromLocalFile(destFile);
audioMediaItem = mActiveScene->addMedia(url, false, pPos);
audioMediaItem->setSourceUrl(sourceUrl);
audioMediaItem->setUuid(uuid);
}
else
{
audioMediaItem = addAudio(sourceUrl, false, pPos);
audioMediaItem = addAudio(sourceUrl, false, pPos, true);
}
if(audioMediaItem){
if (contentUrl.isEmpty())
audioMediaItem->setSourceUrl(sourceUrl);
else
audioMediaItem->setSourceUrl(contentUrl);
audioMediaItem->setUuid(uuid);
connect(this, SIGNAL(activeSceneChanged()), audioMediaItem, SLOT(activeSceneChanged()));
}
@ -1362,6 +1387,11 @@ UBItem *UBBoardController::downloadFinished(bool pSuccess, QUrl sourceUrl, QStri
mActiveScene->addMask(pPos);
UBDrawingController::drawingController()->setStylusTool(UBStylusTool::Selector);
}
else if (sourceUrl.toString() == UBToolsManager::manager()->aristo.id)
{
mActiveScene->addAristo(pPos);
UBDrawingController::drawingController()->setStylusTool(UBStylusTool::Selector);
}
else
{
showMessage(tr("Unknown tool type %1").arg(sourceUrl.toString()));
@ -1450,9 +1480,6 @@ void UBBoardController::setActiveDocumentScene(UBDocumentProxy* pDocumentProxy,
{
freezeW3CWidgets(true);
if(sceneChange)
emit activeSceneWillChange();
persistCurrentScene();
ClearUndoStack();
@ -1500,14 +1527,17 @@ void UBBoardController::moveSceneToIndex(int source, int target)
{
if (selectedDocument())
{
persistCurrentScene();
UBDocumentContainer::movePageToIndex(source, target);
selectedDocument()->setMetaData(UBSettings::documentUpdatedAt, UBStringUtils::toUtcIsoDateTime(QDateTime::currentDateTime()));
UBMetadataDcSubsetAdaptor::persist(selectedDocument());
mMovingSceneIndex = source;
setActiveDocumentScene(target);
mMovingSceneIndex = -1;
}
}
@ -1786,6 +1816,13 @@ qreal UBBoardController::currentZoom()
return 1.0;
}
void UBBoardController::removeTool(UBToolWidget* toolWidget)
{
toolWidget->hide();
delete toolWidget;
}
void UBBoardController::hide()
{
UBApplication::mainWindow->actionLibrary->setChecked(false);
@ -1800,11 +1837,9 @@ void UBBoardController::persistCurrentScene()
{
if(UBPersistenceManager::persistenceManager()
&& selectedDocument() && mActiveScene && mActiveSceneIndex != mDeletingSceneIndex
&& (mActiveSceneIndex >= 0)
&& (mActiveSceneIndex >= 0) && mActiveSceneIndex != mMovingSceneIndex
&& (mActiveScene->isModified() || (UBApplication::boardController->paletteManager()->teacherGuideDockWidget() && UBApplication::boardController->paletteManager()->teacherGuideDockWidget()->teacherGuideWidget()->isModified())))
{
emit activeSceneWillBePersisted();
UBPersistenceManager::persistenceManager()->persistDocumentScene(selectedDocument(), mActiveScene, mActiveSceneIndex);
updatePage(mActiveSceneIndex);
}
@ -2016,23 +2051,28 @@ void UBBoardController::grabScene(const QRectF& pSceneRect)
}
}
UBGraphicsMediaItem* UBBoardController::addVideo(const QUrl& pSourceUrl, bool startPlay, const QPointF& pos)
UBGraphicsMediaItem* UBBoardController::addVideo(const QUrl& pSourceUrl, bool startPlay, const QPointF& pos, bool bUseSource)
{
QUuid uuid = QUuid::createUuid();
QUrl concreteUrl = pSourceUrl;
QString destFile;
bool b = UBPersistenceManager::persistenceManager()->addFileToDocument(selectedDocument(),
pSourceUrl.toLocalFile(),
UBPersistenceManager::videoDirectory,
uuid,
destFile);
if (!b)
// media file is not in document folder yet
if (!bUseSource)
{
showMessage(tr("Add file operation failed: file copying error"));
return NULL;
}
concreteUrl = QUrl::fromLocalFile(destFile);
QString destFile;
bool b = UBPersistenceManager::persistenceManager()->addFileToDocument(selectedDocument(),
pSourceUrl.toLocalFile(),
UBPersistenceManager::videoDirectory,
uuid,
destFile);
if (!b)
{
showMessage(tr("Add file operation failed: file copying error"));
return NULL;
}
concreteUrl = QUrl::fromLocalFile(destFile);
}// else we just use source Url.
UBGraphicsMediaItem* vi = mActiveScene->addMedia(concreteUrl, startPlay, pos);
selectedDocument()->setMetaData(UBSettings::documentUpdatedAt, UBStringUtils::toUtcIsoDateTime(QDateTime::currentDateTime()));
@ -2046,23 +2086,27 @@ UBGraphicsMediaItem* UBBoardController::addVideo(const QUrl& pSourceUrl, bool st
}
UBGraphicsMediaItem* UBBoardController::addAudio(const QUrl& pSourceUrl, bool startPlay, const QPointF& pos)
UBGraphicsMediaItem* UBBoardController::addAudio(const QUrl& pSourceUrl, bool startPlay, const QPointF& pos, bool bUseSource)
{
QUuid uuid = QUuid::createUuid();
QUrl concreteUrl = pSourceUrl;
QString destFile;
bool b = UBPersistenceManager::persistenceManager()->addFileToDocument(selectedDocument(),
pSourceUrl.toLocalFile(),
UBPersistenceManager::audioDirectory,
uuid,
destFile);
if (!b)
// media file is not in document folder yet
if (!bUseSource)
{
showMessage(tr("Add file operation failed: file copying error"));
return NULL;
}
concreteUrl = QUrl::fromLocalFile(destFile);
QString destFile;
bool b = UBPersistenceManager::persistenceManager()->addFileToDocument(selectedDocument(),
pSourceUrl.toLocalFile(),
UBPersistenceManager::audioDirectory,
uuid,
destFile);
if (!b)
{
showMessage(tr("Add file operation failed: file copying error"));
return NULL;
}
concreteUrl = QUrl::fromLocalFile(destFile);
}// else we just use source Url.
UBGraphicsMediaItem* ai = mActiveScene->addMedia(concreteUrl, startPlay, pos);
selectedDocument()->setMetaData(UBSettings::documentUpdatedAt, UBStringUtils::toUtcIsoDateTime(QDateTime::currentDateTime()));
@ -2236,7 +2280,7 @@ void UBBoardController::processMimeData(const QMimeData* pMimeData, const QPoint
if("" != url)
{
downloadURL(url, pPos);
downloadURL(url, QString(), pPos);
return;
}
}
@ -2256,7 +2300,7 @@ void UBBoardController::processMimeData(const QMimeData* pMimeData, const QPoint
foreach(const QUrl url, urls){
QPointF pos(pPos + QPointF(index * 15, index * 15));
downloadURL(url, pos, QSize(), false, internalData);
downloadURL(url, QString(), pos, QSize(), false, internalData);
index++;
}
@ -2282,7 +2326,7 @@ void UBBoardController::processMimeData(const QMimeData* pMimeData, const QPoint
// 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")){
downloadURL(QUrl(qsTmp), pPos);
downloadURL(QUrl(qsTmp), QString(), pPos);
}
else{
mActiveScene->addTextHtml(pMimeData->html(), pPos);
@ -2296,7 +2340,7 @@ void UBBoardController::processMimeData(const QMimeData* pMimeData, const QPoint
QString qsUrl = UBPlatformUtils::urlFromClipboard();
if("" != qsUrl){
// We finally got the url of the dropped ressource! Let's import it!
downloadURL(qsUrl, pPos);
downloadURL(qsUrl, qsUrl, pPos);
return;
}
#endif
@ -2313,31 +2357,32 @@ void UBBoardController::togglePodcast(bool checked)
void UBBoardController::moveGraphicsWidgetToControlView(UBGraphicsWidgetItem* graphicsWidget)
{
graphicsWidget->remove();
mActiveScene->setURStackEnable(false);
UBGraphicsItem *toolW3C = duplicateItem(dynamic_cast<UBItem *>(graphicsWidget));
UBGraphicsWidgetItem *copyedGraphicsWidget = NULL;
graphicsWidget->remove(false);
mActiveScene->addItemToDeletion(graphicsWidget);
if (UBGraphicsWidgetItem::Type == toolW3C->type())
copyedGraphicsWidget = static_cast<UBGraphicsWidgetItem *>(toolW3C);
UBToolWidget *toolWidget = new UBToolWidget(copyedGraphicsWidget);
mActiveScene->addItem(toolWidget);
qreal ssf = 1 / UBApplication::boardController->systemScaleFactor();
toolWidget->setScale(ssf);
toolWidget->setPos(graphicsWidget->scenePos());
UBToolWidget *toolWidget = new UBToolWidget(graphicsWidget, mControlView);
mActiveScene->setURStackEnable(true);
QPoint controlViewPos = mControlView->mapFromScene(graphicsWidget->sceneBoundingRect().center());
toolWidget->centerOn(mControlView->mapTo(mControlContainer, controlViewPos));
toolWidget->show();
}
void UBBoardController::moveToolWidgetToScene(UBToolWidget* toolWidget)
{
UBGraphicsWidgetItem *graphicsWidgetItem = addW3cWidget(toolWidget->graphicsWidgetItem()->widgetUrl(), QPointF(0, 0));
graphicsWidgetItem->setPos(toolWidget->pos());
UBGraphicsWidgetItem *widgetToScene = toolWidget->toolWidget();
widgetToScene->resetTransform();
QPoint mainWindowCenter = toolWidget->mapTo(mMainWindow, QPoint(toolWidget->width(), toolWidget->height()) / 2);
QPoint controlViewCenter = mControlView->mapFrom(mMainWindow, mainWindowCenter);
QPointF scenePos = mControlView->mapToScene(controlViewCenter);
mActiveScene->addGraphicsWidget(widgetToScene, scenePos);
toolWidget->remove();
graphicsWidgetItem->setSelected(true);
}

@ -193,8 +193,8 @@ class UBBoardController : public UBDocumentContainer
void firstScene();
void lastScene();
void groupButtonClicked();
void downloadURL(const QUrl& url, const QPointF& pPos = QPointF(0.0, 0.0), const QSize& pSize = QSize(), bool isBackground = false, bool internalData = false);
UBItem *downloadFinished(bool pSuccess, QUrl sourceUrl, QString pHeader,
void downloadURL(const QUrl& url, QString contentSourceUrl = QString(), const QPointF& pPos = QPointF(0.0, 0.0), const QSize& pSize = QSize(), bool isBackground = false, bool internalData = false);
UBItem *downloadFinished(bool pSuccess, QUrl sourceUrl, QUrl contentUrl, QString pHeader,
QByteArray pData, QPointF pPos, QSize pSize,
bool isBackground = false, bool internalData = false);
void changeBackground(bool isDark, bool isCrossed);
@ -203,14 +203,15 @@ class UBBoardController : public UBDocumentContainer
void hideMessage();
void setDisabled(bool disable);
void setColorIndex(int pColorIndex);
void removeTool(UBToolWidget* toolWidget);
void hide();
void show();
void setWidePageSize(bool checked);
void setRegularPageSize(bool checked);
void stylusToolChanged(int tool);
void grabScene(const QRectF& pSceneRect);
UBGraphicsMediaItem* addVideo(const QUrl& pUrl, bool startPlay, const QPointF& pos);
UBGraphicsMediaItem* addAudio(const QUrl& pUrl, bool startPlay, const QPointF& pos);
UBGraphicsMediaItem* addVideo(const QUrl& pUrl, bool startPlay, const QPointF& pos, bool bUseSource = false);
UBGraphicsMediaItem* addAudio(const QUrl& pUrl, bool startPlay, const QPointF& pos, bool bUseSource = false);
UBGraphicsWidgetItem *addW3cWidget(const QUrl& pUrl, const QPointF& pos);
void cut();
@ -228,8 +229,6 @@ class UBBoardController : public UBDocumentContainer
signals:
void newPageAdded();
void activeSceneWillBePersisted();
void activeSceneWillChange();
void activeSceneChanged();
void zoomChanged(qreal pZoomFactor);
void systemScaleFactorChanged(qreal pSystemScaleFactor);
@ -285,6 +284,7 @@ class UBBoardController : public UBDocumentContainer
bool mCacheWidgetIsEnabled;
QGraphicsItem* mLastCreatedItem;
int mDeletingSceneIndex;
int mMovingSceneIndex;
QString mActionGroupText;
QString mActionUngroupText;

@ -995,6 +995,7 @@ void UBBoardPaletteManager::startDownloads()
mDownloadInProgress = true;
mpDownloadWidget->setVisibleState(true);
mRightPalette->addTab(mpDownloadWidget);
mpDownloadWidget;
}
}

@ -61,6 +61,7 @@
#include "tools/UBGraphicsCache.h"
#include "tools/UBGraphicsTriangle.h"
#include "tools/UBGraphicsProtractor.h"
#include "tools/UBGraphicsAristo.h"
#include "core/memcheck.h"
@ -307,7 +308,6 @@ UBBoardView::event (QEvent * e)
if (gestureEvent)
{
QSwipeGesture* swipe = dynamic_cast<QSwipeGesture*> (gestureEvent->gesture (Qt::SwipeGesture));
if (swipe)
{
if (swipe->horizontalDirection () == QSwipeGesture::Left)
@ -362,9 +362,7 @@ void UBBoardView::tabletEvent (QTabletEvent * event)
QPointF scenePos = viewportTransform ().inverted ().map (tabletPos);
qreal pressure = 1.0;
if (((currentTool == UBStylusTool::Pen || currentTool == UBStylusTool::Line)
&& mPenPressureSensitive)
|| (currentTool == UBStylusTool::Marker && mMarkerPressureSensitive))
if (((currentTool == UBStylusTool::Pen || currentTool == UBStylusTool::Line) && mPenPressureSensitive) || (currentTool == UBStylusTool::Marker && mMarkerPressureSensitive))
pressure = event->pressure ();
@ -521,6 +519,7 @@ Here we determines cases when items should to get mouse press event at pressing
case UBGraphicsTriangle::Type:
case UBGraphicsCompass::Type:
case UBGraphicsCache::Type:
case UBGraphicsAristo::Type:
return true;
case UBGraphicsDelegateFrame::Type:
@ -553,8 +552,8 @@ Here we determines cases when items should to get mouse press event at pressing
return false;
break;
case UBToolWidget::Type:
return true;
//case UBToolWidget::Type:
// return true;
case QGraphicsWebView::Type:
return true;
@ -1123,7 +1122,7 @@ UBBoardView::mouseReleaseEvent (QMouseEvent *event)
DelegateButton::Type != movingItem->type() &&
QGraphicsSvgItem::Type != movingItem->type() &&
UBGraphicsDelegateFrame::Type != movingItem->type() &&
UBToolWidget::Type != movingItem->type() &&
// UBToolWidget::Type != movingItem->type() &&
UBGraphicsCache::Type != movingItem->type() &&
QGraphicsWebView::Type != movingItem->type() && // for W3C widgets as Tools.
!(!isMultipleSelectionEnabled() && movingItem->parentItem() && UBGraphicsWidgetItem::Type == movingItem->type() && UBGraphicsGroupContainerItem::Type == movingItem->parentItem()->type()))
@ -1364,6 +1363,11 @@ void UBBoardView::dropEvent (QDropEvent *event)
event->acceptProposedAction();
}
}
//prevent features in UBFeaturesWidget deletion from the model when event is processing inside
//Qt base classes
if (event->dropAction() == Qt::MoveAction) {
event->setDropAction(Qt::CopyAction);
}
}
void

@ -711,7 +711,7 @@ void UBFeaturesController::addItemToPage(const UBFeature &item)
void UBFeaturesController::addItemAsBackground(const UBFeature &item)
{
UBApplication::boardController->downloadURL( item.getFullPath(), QPointF(), QSize(), true );
UBApplication::boardController->downloadURL( item.getFullPath(), QString(), QPointF(), QSize(), true );
}
UBFeature UBFeaturesController::getDestinationFeatureForUrl( const QUrl &url )

@ -145,6 +145,7 @@ struct UBGraphicsItemType
TriangleItemType,
MagnifierItemType,
cacheItemType,
AristoItemType,
groupContainerType,
ToolWidgetItemType,
GraphicsWidgetItemType,

@ -130,6 +130,8 @@ UBApplication::UBApplication(const QString &id, int &argc, char **argv) : QtSing
|| args.contains("log");
setupTranslators(args);
UBResources::resources();
if (!undoStack)
@ -139,8 +141,6 @@ UBApplication::UBApplication(const QString &id, int &argc, char **argv) : QtSing
UBSettings *settings = UBSettings::settings();
setupTranslators(args);
connect(settings->appToolBarPositionedAtTop, SIGNAL(changed(QVariant)), this, SLOT(toolBarPositionChanged(QVariant)));
connect(settings->appToolBarDisplayText, SIGNAL(changed(QVariant)), this, SLOT(toolBarDisplayTextChanged(QVariant)));
updateProtoActionsState();

@ -14,12 +14,79 @@
*/
#include "UBDownloadManager.h"
#include "core/UBApplication.h"
#include "core/UBPersistenceManager.h"
#include "gui/UBMainWindow.h"
#include "board/UBBoardController.h"
#include "board/UBBoardPaletteManager.h"
#include "frameworks/UBFileSystemUtils.h"
#include "core/memcheck.h"
UBAsyncLocalFileDownloader::UBAsyncLocalFileDownloader(sDownloadFileDesc desc, QObject *parent)
: QThread(parent)
, mDesc(desc)
, m_bAborting(false)
{
}
UBAsyncLocalFileDownloader *UBAsyncLocalFileDownloader::download()
{
if (!QFile::exists(QUrl(mDesc.srcUrl).toLocalFile())) {
qDebug() << "file" << mDesc.srcUrl << "does not present in fs";
return this;
}
start();
return this;
}
void UBAsyncLocalFileDownloader::run()
{
QString mimeType = UBFileSystemUtils::mimeTypeFromFileName(mDesc.srcUrl);
int position=mimeType.indexOf(";");
if(position != -1)
mimeType=mimeType.left(position);
UBMimeType::Enum itemMimeType = UBFileSystemUtils::mimeTypeFromString(mimeType);
QString destDirectory;
if (UBMimeType::Video == itemMimeType)
destDirectory = UBPersistenceManager::videoDirectory;
else
if (UBMimeType::Audio == itemMimeType)
destDirectory = UBPersistenceManager::audioDirectory;
if (mDesc.originalSrcUrl.isEmpty())
mDesc.originalSrcUrl = mDesc.srcUrl;
QString uuid = QUuid::createUuid();
UBPersistenceManager::persistenceManager()->addFileToDocument(UBApplication::boardController->selectedDocument(),
QUrl(mDesc.srcUrl).toLocalFile(),
destDirectory,
uuid,
mTo,
NULL);
if (m_bAborting)
{
if (QFile::exists(mTo))
QFile::remove(mTo);
}
else
emit signal_asyncCopyFinished(mDesc.id, !mTo.isEmpty(), QUrl::fromLocalFile(mTo), QUrl::fromLocalFile(mDesc.originalSrcUrl), "", NULL, mDesc.pos, mDesc.size, mDesc.isBackground);
}
void UBAsyncLocalFileDownloader::abort()
{
m_bAborting = true;
}
/** The unique instance of the download manager */
static UBDownloadManager* pInstance = NULL;
@ -100,7 +167,7 @@ void UBDownloadManager::init()
{
mCrntDL.clear();
mPendingDL.clear();
mReplies.clear();
mDownloads.clear();
mLastID = 1;
mDLAvailability.clear();
for(int i=0; i<SIMULTANEOUS_DOWNLOAD; i++)
@ -193,7 +260,8 @@ void UBDownloadManager::onDownloadProgress(int id, qint64 received, qint64 total
* \brief Called when the download of the given file is finished
* @param desc as the current downloaded file description
*/
void UBDownloadManager::onDownloadFinished(int id, bool pSuccess, QUrl sourceUrl, QString pContentTypeHeader, QByteArray pData, QPointF pPos, QSize pSize, bool isBackground)
void UBDownloadManager::onDownloadFinished(int id, bool pSuccess, QUrl sourceUrl, QUrl contentUrl, QString pContentTypeHeader, QByteArray pData, QPointF pPos, QSize pSize, bool isBackground)
{
// Temporary data for dnd do not delete it please
Q_UNUSED(pPos)
@ -209,9 +277,9 @@ void UBDownloadManager::onDownloadFinished(int id, bool pSuccess, QUrl sourceUrl
desc.contentTypeHeader = pContentTypeHeader;
emit downloadFinished(pSuccess, desc, pData);
} else if(desc.modal) {
} else if(desc.dest == sDownloadFileDesc::board) {
// The downloaded file is modal so we must put it on the board
emit addDownloadedFileToBoard(pSuccess, sourceUrl, pContentTypeHeader, pData, pPos, pSize, isBackground);
emit addDownloadedFileToBoard(pSuccess, sourceUrl, contentUrl, pContentTypeHeader, pData, pPos, pSize, isBackground);
}
else
{
@ -259,7 +327,7 @@ void UBDownloadManager::updateFileCurrentSize(int id, qint64 received, qint64 to
mCrntDL.remove(i);
// Here we don't forget to remove the reply related to the finished download
mReplies.remove(id);
mDownloads.remove(id);
// Free the download slot used by the finished file
for(int j=0; j<mDLAvailability.size();j++)
@ -302,15 +370,28 @@ void UBDownloadManager::updateFileCurrentSize(int id, qint64 received, qint64 to
*/
void UBDownloadManager::startFileDownload(sDownloadFileDesc desc)
{
UBDownloadHttpFile* http = new UBDownloadHttpFile(desc.id, this);
connect(http, SIGNAL(downloadProgress(int, qint64,qint64)), this, SLOT(onDownloadProgress(int,qint64,qint64)));
connect(http, SIGNAL(downloadFinished(int, bool, QUrl, QString, QByteArray, QPointF, QSize, bool)), this, SLOT(onDownloadFinished(int, bool, QUrl, QString, QByteArray, QPointF, QSize, bool)));
//the desc.url is encoded. So we have to decode it before.
QUrl url;
url.setEncodedUrl(desc.url.toUtf8());
// We send here the request and store its reply in order to be able to cancel it if needed
mReplies[desc.id] = http->get(url, desc.pos, desc.size, desc.isBackground);
if (desc.srcUrl.startsWith("file://") || desc.srcUrl.startsWith("/"))
{
UBAsyncLocalFileDownloader * cpHelper = new UBAsyncLocalFileDownloader(desc, this);
connect(cpHelper, SIGNAL(signal_asyncCopyFinished(int, bool, QUrl, QUrl, QString, QByteArray, QPointF, QSize, bool)), this, SLOT(onDownloadFinished(int, bool, QUrl, QUrl,QString, QByteArray, QPointF, QSize, bool)));
QObject *res = dynamic_cast<QObject *>(cpHelper->download());
if (!res)
delete res;
else
mDownloads[desc.id] = res;
}
else
{
UBDownloadHttpFile* http = new UBDownloadHttpFile(desc.id, this);
connect(http, SIGNAL(downloadProgress(int, qint64,qint64)), this, SLOT(onDownloadProgress(int,qint64,qint64)));
connect(http, SIGNAL(downloadFinished(int, bool, QUrl, QUrl, QString, QByteArray, QPointF, QSize, bool)), this, SLOT(onDownloadFinished(int, bool, QUrl, QUrl, QString, QByteArray, QPointF, QSize, bool)));
//the desc.srcUrl is encoded. So we have to decode it before.
QUrl url;
url.setEncodedUrl(desc.srcUrl.toUtf8());
// We send here the request and store its reply in order to be able to cancel it if needed
mDownloads[desc.id] = dynamic_cast<QObject *>(http->get(url, desc.pos, desc.size, desc.isBackground));
}
}
/**
@ -356,10 +437,18 @@ void UBDownloadManager::checkIfModalRemains()
void UBDownloadManager::cancelDownloads()
{
// Stop the current downloads
QMap<int, QNetworkReply*>::iterator it = mReplies.begin();
for(; it!=mReplies.end();it++)
QMap<int, QObject*>::iterator it = mDownloads.begin();
for(; it!=mDownloads.end();it++)
{
dynamic_cast<QNetworkReply*>(it.value())->abort();
QNetworkReply *netReply = dynamic_cast<QNetworkReply*>(it.value());
if (netReply)
netReply->abort();
else
{
UBAsyncLocalFileDownloader *localDownload = dynamic_cast<UBAsyncLocalFileDownloader *>(it.value());
if (localDownload)
localDownload->abort();
}
}
// Clear all the lists
@ -372,7 +461,8 @@ void UBDownloadManager::cancelDownloads()
void UBDownloadManager::onDownloadError(int id)
{
QNetworkReply* pReply = mReplies.value(id);
QNetworkReply *pReply = dynamic_cast<QNetworkReply *>(mDownloads.value(id));
if(NULL != pReply)
{
// Check which error occured:
@ -402,9 +492,25 @@ void UBDownloadManager::finishDownloads(bool cancel)
void UBDownloadManager::cancelDownload(int id)
{
if (!mDownloads.size())
return;
// Stop the download
mReplies[id]->abort();
mReplies.remove(id);
QNetworkReply *pNetworkDownload = dynamic_cast<QNetworkReply *>(mDownloads[id]);
if (pNetworkDownload)
pNetworkDownload->abort();
else
{
UBAsyncLocalFileDownloader *pLocalDownload = dynamic_cast<UBAsyncLocalFileDownloader *>(mDownloads[id]);
if (pLocalDownload)
{
if (pLocalDownload->isRunning())
pLocalDownload->abort();
}
}
mDownloads.remove(id);
// Remove the canceled download from the download lists
bool bFound = false;
@ -494,7 +600,7 @@ void UBDownloadHttpFile::onDownloadFinished(bool pSuccess, QUrl sourceUrl, QStri
if(pSuccess)
{
// Notify the end of the download
emit downloadFinished(mId, pSuccess, sourceUrl, pContentTypeHeader, pData, pPos, pSize, isBackground);
emit downloadFinished(mId, pSuccess, sourceUrl, sourceUrl, pContentTypeHeader, pData, pPos, pSize, isBackground);
}
else
{

@ -52,7 +52,8 @@ struct sDownloadFileDesc
int id;
int totalSize;
int currentSize;
QString url;
QString srcUrl;
QString originalSrcUrl;
QString contentTypeHeader;
bool modal;
QPointF pos; // For board drop only
@ -75,7 +76,7 @@ public:
signals:
void downloadProgress(int id, qint64 current,qint64 total);
void downloadFinished(int id, bool pSuccess, QUrl sourceUrl, QString pContentTypeHeader, QByteArray pData, QPointF pPos, QSize pSize, bool isBackground);
void downloadFinished(int id, bool pSuccess, QUrl sourceUrl, QUrl contentUrl, QString pContentTypeHeader, QByteArray pData, QPointF pPos, QSize pSize, bool isBackground);
void downloadError(int id);
private slots:
@ -86,6 +87,28 @@ private:
int mId;
};
class UBAsyncLocalFileDownloader : public QThread
{
Q_OBJECT
public:
UBAsyncLocalFileDownloader(sDownloadFileDesc desc, QObject *parent = 0);
UBAsyncLocalFileDownloader *download();
void run();
void abort();
signals:
void finished(QString srcUrl, QString resUrl);
void signal_asyncCopyFinished(int id, bool pSuccess, QUrl sourceUrl, QUrl contentUrl, QString pContentTypeHeader, QByteArray pData, QPointF pPos, QSize pSize, bool isBackground);
private:
sDownloadFileDesc mDesc;
bool m_bAborting;
QString mFrom;
QString mTo;
};
class UBDownloadManager : public QObject
{
Q_OBJECT
@ -108,7 +131,7 @@ signals:
void downloadFinished(bool pSuccess, int id, QUrl sourceUrl, QString pContentTypeHeader, QByteArray pData);
void downloadFinished(bool pSuccess, sDownloadFileDesc desc, QByteArray pData);
void downloadModalFinished();
void addDownloadedFileToBoard(bool pSuccess, QUrl sourceUrl, QString pContentTypeHeader, QByteArray pData, QPointF pPos, QSize pSize, bool isBackground);
void addDownloadedFileToBoard(bool pSuccess, QUrl sourceUrl, QUrl contentUrl, QString pContentTypeHeader, QByteArray pData, QPointF pPos, QSize pSize, bool isBackground);
void addDownloadedFileToLibrary(bool pSuccess, QUrl sourceUrl, QString pContentTypeHeader, QByteArray pData);
void cancelAllDownloads();
void allDownloadsFinished();
@ -116,7 +139,7 @@ signals:
private slots:
void onUpdateDownloadLists();
void onDownloadProgress(int id, qint64 received, qint64 total);
void onDownloadFinished(int id, bool pSuccess, QUrl sourceUrl, QString pContentTypeHeader, QByteArray pData, QPointF pPos, QSize pSize, bool isBackground);
void onDownloadFinished(int id, bool pSuccess, QUrl sourceUrl, QUrl contentUrl, QString pContentTypeHeader, QByteArray pData, QPointF pPos, QSize pSize, bool isBackground);
void onDownloadError(int id);
private:
@ -138,7 +161,7 @@ private:
/** The current download availability (-1 = free, otherwise the file ID is recorded)*/
QVector<int> mDLAvailability;
/** A map containing the replies of the GET operations */
QMap<int, QNetworkReply*> mReplies;
QMap<int, QObject*> mDownloads;
};
#endif // UBDOWNLOADMANAGER_H

@ -265,7 +265,7 @@ UBDocumentProxy* UBPersistenceManager::createDocument(const QString& pGroupName,
return doc;
}
UBDocumentProxy* UBPersistenceManager::createDocumentFromDir(const QString& pDocumentDirectory, const QString& pGroupName, const QString& pName, bool withEmptyPage)
UBDocumentProxy* UBPersistenceManager::createDocumentFromDir(const QString& pDocumentDirectory, const QString& pGroupName, const QString& pName, bool withEmptyPage, bool addTitlePage)
{
checkIfDocumentRepositoryExists();
@ -280,7 +280,8 @@ UBDocumentProxy* UBPersistenceManager::createDocumentFromDir(const QString& pDoc
{
doc->setMetaData(UBSettings::documentName, pName);
}
if (withEmptyPage) createDocumentSceneAt(doc, 0);
if(withEmptyPage) createDocumentSceneAt(doc, 0);
if(addTitlePage) persistDocumentScene(doc, mSceneCache.createScene(doc, 0, false), 0);
QMap<QString, QVariant> metadatas = UBMetadataDcSubsetAdaptor::load(pDocumentDirectory);
@ -463,11 +464,6 @@ void UBPersistenceManager::deleteDocumentScenes(UBDocumentProxy* proxy, const QL
}
}
foreach(int index, compactedIndexes)
{
emit documentSceneDeleted(proxy, index);
}
}
@ -576,8 +572,6 @@ void UBPersistenceManager::moveSceneToIndex(UBDocumentProxy* proxy, int source,
thumb.rename(proxy->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.thumbnail.jpg", target));
mSceneCache.moveScene(proxy, source, target);
emit documentSceneMoved(proxy, target);
}
@ -612,7 +606,7 @@ void UBPersistenceManager::persistDocumentScene(UBDocumentProxy* pDocumentProxy,
UBBoardPaletteManager* paletteManager = UBApplication::boardController->paletteManager();
bool teacherGuideModified = false;
if(paletteManager->teacherGuideDockWidget())
if(UBApplication::app()->boardController->currentPage() == pSceneIndex && paletteManager->teacherGuideDockWidget())
teacherGuideModified = paletteManager->teacherGuideDockWidget()->teacherGuideWidget()->isModified();
if (pDocumentProxy->isModified() || teacherGuideModified)
@ -628,8 +622,6 @@ void UBPersistenceManager::persistDocumentScene(UBDocumentProxy* pDocumentProxy,
}
mSceneCache.insert(pDocumentProxy, pSceneIndex, pScene);
emit documentCommitted(pDocumentProxy);
}

@ -47,7 +47,7 @@ class UBPersistenceManager : public QObject
static void destroy();
virtual UBDocumentProxy* createDocument(const QString& pGroupName = "", const QString& pName = "", bool withEmptyPage = true);
virtual UBDocumentProxy* createDocumentFromDir(const QString& pDocumentDirectory, const QString& pGroupName = "", const QString& pName = "", bool withEmptyPage = false);
virtual UBDocumentProxy* createDocumentFromDir(const QString& pDocumentDirectory, const QString& pGroupName = "", const QString& pName = "", bool withEmptyPage = false, bool addTitlePage = false);
virtual UBDocumentProxy* persistDocumentMetadata(UBDocumentProxy* pDocumentProxy);
@ -117,13 +117,10 @@ class UBPersistenceManager : public QObject
void documentCreated(UBDocumentProxy* pDocumentProxy);
void documentMetadataChanged(UBDocumentProxy* pDocumentProxy);
void documentCommitted(UBDocumentProxy* pDocumentProxy);
void documentWillBeDeleted(UBDocumentProxy* pDocumentProxy);
void documentSceneCreated(UBDocumentProxy* pDocumentProxy, int pIndex);
void documentSceneMoved(UBDocumentProxy* pDocumentProxy, int pIndex);
void documentSceneWillBeDeleted(UBDocumentProxy* pDocumentProxy, int pIndex);
void documentSceneDeleted(UBDocumentProxy* pDocumentProxy, int pDeletedIndex);
private:

@ -129,7 +129,7 @@ int main(int argc, char *argv[])
QObject::connect(&app, SIGNAL(messageReceived(const QString&)), &app, SLOT(handleOpenMessage(const QString&)));
qDebug() << fileToOpen;
qDebug() << "file name argument" << fileToOpen;
int result = app.exec(fileToOpen);
app.cleanup();

@ -94,7 +94,6 @@ void UBDocumentContainer::updatePage(int index)
void UBDocumentContainer::deleteThumbPage(int index)
{
mDocumentThumbs.removeAt(index);
emit documentPageDeleted(index);
}
void UBDocumentContainer::updateThumbPage(int index)
@ -106,7 +105,6 @@ void UBDocumentContainer::updateThumbPage(int index)
void UBDocumentContainer::insertThumbPage(int index)
{
mDocumentThumbs.insert(index, UBThumbnailAdaptor::get(mCurrentDocument, index));
emit documentPageAdded(index);
}
void UBDocumentContainer::reloadThumbnails()

@ -58,8 +58,6 @@ class UBDocumentContainer : public QObject
signals:
void documentSet(UBDocumentProxy* document);
void documentPageAdded(int index);
void documentPageDeleted(int index);
void documentPageUpdated(int index);
void documentThumbnailsUpdated(UBDocumentContainer* source);
};

@ -563,8 +563,7 @@ void UBGraphicsDelegateFrame::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
mTranslateX += fixedPoint.x() - bottomRight.x();
mTranslateY += fixedPoint.y() - bottomRight.y();
}
else if (moving() || rotating())
delegated()->setTransform(tr);
delegated()->setTransform(buildTransform());
}
else // resizing/resizing horizontally
{

@ -58,6 +58,7 @@ DelegateButton::DelegateButton(const QString & fileName, QGraphicsItem* pDelegat
{
setAcceptedMouseButtons(Qt::LeftButton);
setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Control));
setCacheMode(QGraphicsItem::NoCache); /* because of SANKORE-1017: this allows pixmap to be refreshed when grabbing window, thus teacher screen is synchronized with main screen. */
}
DelegateButton::~DelegateButton()

@ -73,7 +73,11 @@ UBGraphicsMediaItem::UBGraphicsMediaItem(const QUrl& pMediaFileUrl, QGraphicsIte
mMediaObject = new Phonon::MediaObject(this);
if (pMediaFileUrl.toLocalFile().contains("videos"))
QString mediaPath = pMediaFileUrl.toString();
if ("" == mediaPath)
mediaPath = pMediaFileUrl.toLocalFile();
if (mediaPath.toLower().contains("videos"))
{
mMediaType = mediaType_Video;
@ -91,7 +95,7 @@ UBGraphicsMediaItem::UBGraphicsMediaItem(const QUrl& pMediaFileUrl, QGraphicsIte
haveLinkedImage = true;
}
else
if (pMediaFileUrl.toLocalFile().contains("audios"))
if (mediaPath.toLower().contains("audios"))
{
mMediaType = mediaType_Audio;
mAudioOutput = new Phonon::AudioOutput(Phonon::MusicCategory, this);
@ -191,7 +195,7 @@ void UBGraphicsMediaItem::setSourceUrl(const QUrl &pSourceUrl)
UBAudioPresentationWidget* pAudioWidget = dynamic_cast<UBAudioPresentationWidget*>(mAudioWidget);
if (pAudioWidget)
{
pAudioWidget->setTitle(UBFileSystemUtils::lastPathComponent(pSourceUrl.toString()));
pAudioWidget->setTitle(UBFileSystemUtils::lastPathComponent(pSourceUrl.toLocalFile()));
}
UBItem::setSourceUrl(pSourceUrl);

@ -39,6 +39,7 @@
#include "tools/UBGraphicsTriangle.h"
#include "tools/UBGraphicsCurtainItem.h"
#include "tools/UBGraphicsCache.h"
#include "tools/UBGraphicsAristo.h"
#include "document/UBDocumentProxy.h"
@ -581,8 +582,8 @@ bool UBGraphicsScene::inputDeviceRelease()
addItem(pStrokes);
mDrawWithCompass = false;
}else if (mCurrentStroke)
{
}
else if (mCurrentStroke){
UBGraphicsStrokesGroup* pStrokes = new UBGraphicsStrokesGroup();
// Remove the strokes that were just drawn here and replace them by a stroke item
@ -628,8 +629,8 @@ bool UBGraphicsScene::inputDeviceRelease()
if (mCurrentStroke && mCurrentStroke->polygons().empty()){
delete mCurrentStroke;
mCurrentStroke = NULL;
}
mCurrentStroke = NULL;
return accepted;
}
@ -1216,6 +1217,11 @@ void UBGraphicsScene::textUndoCommandAdded(UBGraphicsTextItem *textItem)
}
UBGraphicsMediaItem* UBGraphicsScene::addMedia(const QUrl& pMediaFileUrl, bool shouldPlayAsap, const QPointF& pPos)
{
qDebug() << pMediaFileUrl.toLocalFile();
if (!QFile::exists(pMediaFileUrl.toLocalFile()))
if (!QFile::exists(pMediaFileUrl.toString()))
return NULL;
UBGraphicsMediaItem* mediaItem = new UBGraphicsMediaItem(pMediaFileUrl);
if(mediaItem){
connect(UBApplication::boardController, SIGNAL(activeSceneChanged()), mediaItem, SLOT(activeSceneChanged()));
@ -1310,7 +1316,7 @@ void UBGraphicsScene::addGraphicsWidget(UBGraphicsWidgetItem* graphicsWidget, co
if (graphicsWidget->canBeContent())
{
// graphicsWidget->widgetWebView()->loadMainHtml();
graphicsWidget->loadMainHtml();
graphicsWidget->setSelected(true);
if (mUndoRedoStackEnabled) { //should be deleted after scene own undo stack implemented
@ -1602,6 +1608,9 @@ void UBGraphicsScene::removeItem(QGraphicsItem* item)
--mItemCount;
mFastAccessItems.removeAll(item);
/* delete the item if it is cache to allow its reinstanciation, because Cache implements design pattern Singleton. */
if (dynamic_cast<UBGraphicsCache*>(item))
UBCoreGraphicsScene::deleteItem(item);
}
void UBGraphicsScene::removeItems(const QSet<QGraphicsItem*>& items)
@ -1937,19 +1946,35 @@ void UBGraphicsScene::addCompass(QPointF center)
compass->setVisible(true);
}
void UBGraphicsScene::addCache()
void UBGraphicsScene::addAristo(QPointF center)
{
UBGraphicsCache* cache = new UBGraphicsCache();
mTools << cache;
UBGraphicsAristo* aristo = new UBGraphicsAristo();
mTools << aristo;
addItem(cache);
aristo->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Tool));
cache->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Tool));
addItem(aristo);
cache->setVisible(true);
cache->setSelected(true);
UBApplication::boardController->notifyCache(true);
UBApplication::boardController->notifyPageChanged();
QPointF itemSceneCenter = aristo->sceneBoundingRect().center();
aristo->moveBy(center.x() - itemSceneCenter.x(), center.y() - itemSceneCenter.y());
aristo->setVisible(true);
setModified(true);
}
void UBGraphicsScene::addCache()
{
UBGraphicsCache* cache = UBGraphicsCache::instance(this);
if (!items().contains(cache)) {
addItem(cache);
cache->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Tool));
cache->setVisible(true);
cache->setSelected(true);
UBApplication::boardController->notifyCache(true);
UBApplication::boardController->notifyPageChanged();
}
}
void UBGraphicsScene::addMask(const QPointF &center)
@ -2277,10 +2302,12 @@ void UBGraphicsScene::setToolCursor(int tool)
if (mCurrentStroke && mCurrentStroke->polygons().empty()){
delete mCurrentStroke;
mCurrentStroke = NULL;
}
mCurrentStroke = NULL;
}
void UBGraphicsScene::initStroke(){
void UBGraphicsScene::initStroke()
{
mCurrentStroke = new UBGraphicsStroke();
}

@ -216,6 +216,7 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
void addCompass(QPointF center);
void addTriangle(QPointF center);
void addMagnifier(UBMagnifierParams params);
void addAristo(QPointF center);
void addMask(const QPointF &center = QPointF());
void addCache();

@ -563,7 +563,8 @@ void UBGraphicsWidgetItem::injectInlineJavaScript()
void UBGraphicsWidgetItem::paint( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
if (scene()->renderingContext() != UBGraphicsScene::Screen)
if (scene() && scene()->renderingContext() != UBGraphicsScene::Screen)
{
painter->drawPixmap(0, 0, snapshot());
}

@ -19,7 +19,6 @@
#include "core/UBApplication.h"
#include "board/UBBoardController.h"
#include "document/UBDocumentContainer.h"
#include "globals/UBGlobals.h"
@ -855,4 +854,3 @@ QString UBFileSystemUtils::readTextFile(QString path)
return "";
}

@ -17,14 +17,17 @@
#define UBFILESYSTEMUTILS_H_
#include <QtCore>
#include <QThread>
#include "core/UB.h"
class QuaZipFile;
class UBProcessingProgressListener;
class UBFileSystemUtils
class UBFileSystemUtils : public QObject
{
Q_OBJECT
public:
UBFileSystemUtils();

@ -17,6 +17,7 @@
#include <QtGui>
#include <unistd.h>
#include <X11/Xlib.h>
#include <X11/keysym.h>

@ -89,27 +89,9 @@ void UBDocumentNavigator::generateThumbnails(UBDocumentContainer* source)
{
const QPixmap* pix = source->pageAt(i);
QPixmap result(pix->width(),pix->height());
int pageIndex = UBDocumentContainer::pageFromSceneIndex(i);
QPainter composePainter;
composePainter.begin(&result);
composePainter.drawPixmap(QPoint(0,0),*pix);
if(pageIndex == UBApplication::boardController->currentPage() &&
((pageIndex == 0 && UBSettings::settings()->teacherGuidePageZeroActivated->get().toBool()) ||
(pageIndex && UBSettings::settings()->teacherGuideLessonPagesActivated->get().toBool()))
) {
if(UBApplication::boardController->paletteManager()->teacherGuideDockWidget()->teacherGuideWidget()->isModified()){
QPixmap toque(":images/toque.png");
composePainter.setOpacity(0.6);
composePainter.drawPixmap(QPoint(pix->width() - toque.width(),0),toque);
}
}
composePainter.end();
UBSceneThumbnailNavigPixmap* pixmapItem = new UBSceneThumbnailNavigPixmap(result, source->selectedDocument(), i);
UBSceneThumbnailNavigPixmap* pixmapItem = new UBSceneThumbnailNavigPixmap(*pix, source->selectedDocument(), i);
QString label = pageIndex == 0 ? tr("Title page") : tr("Page %0").arg(pageIndex);
UBThumbnailTextItem *labelItem = new UBThumbnailTextItem(label);
@ -128,7 +110,6 @@ void UBDocumentNavigator::generateThumbnails(UBDocumentContainer* source)
void UBDocumentNavigator::onScrollToSelectedPage(int index)
{
qDebug() << "Selection in widget: " << index;
int c = 0;
foreach(UBImgTextThumbnailElement el, mThumbsWithLabels)
{
@ -286,7 +267,6 @@ void UBDocumentNavigator::mousePressEvent(QMouseEvent *event)
break;
}
}
qDebug() << "Selected Scene: " << index;
UBApplication::boardController->setActiveDocumentScene(index);
}
QGraphicsView::mousePressEvent(event);

@ -12,10 +12,6 @@
const char *UBFeaturesWidget::objNamePathList = "PathList";
const char *UBFeaturesWidget::objNameFeatureList = "FeatureList";
const QString UBFeaturesNewFolderDialog::acceptText = tr("Accept");
const QString UBFeaturesNewFolderDialog::cancelText = tr("Cancel");
const QString UBFeaturesNewFolderDialog::labelText = tr("Enter a new folder name");
const QMargins FeatureListMargins(0, 0, 0, 30);
const int FeatureListBorderOffset = 10;
const char featureTypeSplitter = ':';
@ -198,7 +194,6 @@ void UBFeaturesWidget::lockIt(bool pLock)
mActionBar->setEnabled(!pLock);
pathListView->setEnabled(!pLock);
centralWidget->setLockedExcludingAdditional(pLock);
// pathListView->setLocked(true);
}
void UBFeaturesWidget::addToFavorite( const UBFeaturesMimeData * mimeData )
@ -578,6 +573,9 @@ void UBFeaturesCentralWidget::scanFinished()
}
UBFeaturesNewFolderDialog::UBFeaturesNewFolderDialog(QWidget *parent) : QWidget(parent)
, acceptText(tr("Accept"))
, cancelText(tr("Cancel"))
, labelText(tr("Enter a new folder name"))
{
this->setStyleSheet("background:white;");
@ -1048,8 +1046,8 @@ void UBFeatureProperties::onAddToLib()
desc.modal = false;
desc.name = QFileInfo( mpElement->getFullPath().toString()).fileName();
qDebug() << desc.name;
desc.url = mpElement->getFullPath().toString();
qDebug() << desc.url;
desc.srcUrl = mpElement->getFullPath().toString();
qDebug() << desc.srcUrl;
UBDownloadManager::downloadManager()->addFileToDownload(desc);
}
}

@ -193,9 +193,9 @@ public:
void setLockedExcludingAdditional(bool pLock);
QStackedWidget *mStackedWidget;
UBFeaturesNavigatorWidget *mNavigator;
UBFeatureProperties *mFeatureProperties;
UBFeaturesWebView *webView;
UBFeaturesNavigatorWidget *mNavigator;
UBFeatureProperties *mFeatureProperties;
UBFeaturesWebView *webView;
QStackedWidget *mAdditionalDataContainer;
@ -226,10 +226,6 @@ class UBFeaturesNewFolderDialog : public QWidget
Q_OBJECT
public:
static const QString acceptText;
static const QString cancelText;
static const QString labelText;
UBFeaturesNewFolderDialog(QWidget *parent = 0);
void setRegexp(const QRegExp pRegExp);
bool validString(const QString &pStr);
@ -249,7 +245,9 @@ private:
QRegExpValidator *mValidator;
QStringList mFileNameList;
QPushButton *acceptButton;
const QString acceptText;
const QString cancelText;
const QString labelText;
};
class UBFeaturesProgressInfo: public QWidget {

@ -230,10 +230,8 @@ void UBTGAdaptableText::bottomMargin(int newValue)
void UBTGAdaptableText::focusInEvent(QFocusEvent* e)
{
qDebug() << "pippa";
if(isReadOnly()){
e->ignore();
qDebug() << "ignored";
}
managePlaceholder(true);
QTextEdit::focusInEvent(e);
@ -247,7 +245,6 @@ void UBTGAdaptableText::focusOutEvent(QFocusEvent* e){
void UBTGAdaptableText::managePlaceholder(bool focus){
if(focus){
if(toPlainText() == mPlaceHolderText){
qDebug() << "Place holder found";
setTextColor(QColor(Qt::black));
setPlainText("");
}

@ -32,32 +32,32 @@ QPixmap* UBToolWidget::sClosePixmap = 0;
QPixmap* UBToolWidget::sUnpinPixmap = 0;
UBToolWidget::UBToolWidget(const QUrl& pUrl, QGraphicsItem *pParent)
: QGraphicsWidget(pParent, Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint)
UBToolWidget::UBToolWidget(const QUrl& pUrl, QWidget *pParent)
: QWidget(pParent, Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint)
, mShouldMoveWidget(false)
, mContentMargin(0)
, mFrameWidth(0)
, mGraphicsWebView(0)
, mGraphicsWidgetItem(0)
, mWebView(0)
, mToolWidget(0)
{
int widgetType = UBGraphicsWidgetItem::widgetType(pUrl);
if (widgetType == UBWidgetType::Apple)
mGraphicsWidgetItem = new UBGraphicsAppleWidgetItem(pUrl, this);
mToolWidget = new UBGraphicsAppleWidgetItem(pUrl);
else if (widgetType == UBWidgetType::W3C)
mGraphicsWidgetItem = new UBGraphicsW3CWidgetItem(pUrl, this);
mToolWidget = new UBGraphicsW3CWidgetItem(pUrl);
else
qDebug() << "UBToolWidget::UBToolWidget: Unknown widget Type";
initialize();
}
UBToolWidget::UBToolWidget(UBGraphicsWidgetItem *pWidget, QGraphicsItem *pParent)
: QGraphicsWidget(pParent, Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint)
UBToolWidget::UBToolWidget(UBGraphicsWidgetItem *pWidget, QWidget *pParent)
: QWidget(pParent, Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint)
, mShouldMoveWidget(false)
, mContentMargin(0)
, mFrameWidth(0)
, mGraphicsWebView(0)
, mGraphicsWidgetItem(pWidget)
, mWebView(0)
, mToolWidget(pWidget)
{
initialize();
javaScriptWindowObjectCleared();
@ -76,50 +76,66 @@ void UBToolWidget::initialize()
if(!sUnpinPixmap)
sUnpinPixmap = new QPixmap(":/images/unpin.svg");
UBGraphicsScene *wscene = dynamic_cast<UBGraphicsScene *>(mGraphicsWidgetItem->scene());
UBGraphicsScene *wscene = dynamic_cast<UBGraphicsScene *>(mToolWidget->scene());
if (wscene)
{
wscene->removeItemFromDeletion(mGraphicsWidgetItem);
wscene->removeItem(mGraphicsWidgetItem);
wscene->removeItemFromDeletion(mToolWidget);
wscene->removeItem(mToolWidget);
}
mGraphicsWidgetItem->setParent(this);
QGraphicsLinearLayout *graphicsLayout = new QGraphicsLinearLayout(Qt::Vertical, this);
mWebView = new QWebView(this);
QPalette palette = mWebView->page()->palette();
palette.setBrush(QPalette::Base, QBrush(Qt::transparent));
mWebView->page()->setPalette(palette);
mWebView->installEventFilter(this);
mFrameWidth = UBSettings::settings()->objectFrameWidth;
mContentMargin = sClosePixmap->width() / 2 + mFrameWidth;
graphicsLayout->setContentsMargins(mContentMargin, mContentMargin, mContentMargin, mContentMargin);
setPreferredSize(mGraphicsWidgetItem->preferredWidth() + mContentMargin * 2, mGraphicsWidgetItem->preferredHeight() + mContentMargin * 2);
setLayout(new QVBoxLayout());
layout()->setContentsMargins(mContentMargin, mContentMargin, mContentMargin, mContentMargin);
layout()->addWidget(mWebView);
mGraphicsWebView = new QGraphicsWebView(this);
connect(mGraphicsWebView->page()->mainFrame(), SIGNAL(javaScriptWindowObjectCleared()), this, SLOT(javaScriptWindowObjectCleared()));
mGraphicsWebView->load(mGraphicsWidgetItem->mainHtml());
graphicsLayout->addItem(mGraphicsWebView);
setFixedSize(mToolWidget->boundingRect().width() + mContentMargin * 2, mToolWidget->boundingRect().height() + mContentMargin * 2);
mGraphicsWebView->setAcceptDrops(false);
mGraphicsWebView->settings()->setAttribute(QWebSettings::PluginsEnabled, true);
mGraphicsWebView->setAttribute(Qt::WA_OpaquePaintEvent, false);
connect(mWebView->page()->mainFrame(), SIGNAL(javaScriptWindowObjectCleared()), this, SLOT(javaScriptWindowObjectCleared()));
mWebView->load(mToolWidget->mainHtml());
QPalette palette = mGraphicsWebView->page()->palette();
palette.setBrush(QPalette::Base, QBrush(Qt::transparent));
mGraphicsWebView->page()->setPalette(palette);
setLayout(graphicsLayout);
mWebView->setAcceptDrops(false);
mWebView->settings()->setAttribute(QWebSettings::PluginsEnabled, true);
mWebView->setAttribute(Qt::WA_OpaquePaintEvent, false);
connect(UBApplication::boardController, SIGNAL(activeSceneChanged()), this, SLOT(javaScriptWindowObjectCleared()));
}
bool UBToolWidget::event(QEvent *event)
bool UBToolWidget::eventFilter(QObject *obj, QEvent *event)
{
if (event->type() == QEvent::ShortcutOverride)
event->accept();
return QGraphicsWidget::event(event);
if (mShouldMoveWidget && obj == mWebView && event->type() == QEvent::MouseMove)
{
QMouseEvent *mouseMoveEvent = static_cast<QMouseEvent*>(event);
if (mouseMoveEvent->buttons() & Qt::LeftButton)
{
move(pos() - mMousePressPos + mWebView->mapTo(this, mouseMoveEvent->pos()));
event->accept();
return true;
}
}
// standard event processing
return QObject::eventFilter(obj, event);
}
void UBToolWidget::mousePressEvent(QGraphicsSceneMouseEvent *event)
void UBToolWidget::mousePressEvent(QMouseEvent *event)
{
QGraphicsWidget::mousePressEvent(event);
QWidget::mousePressEvent(event);
/* did webkit consume the mouse press ? */
mShouldMoveWidget = !event->isAccepted() && (event->buttons() & Qt::LeftButton);
@ -128,108 +144,92 @@ void UBToolWidget::mousePressEvent(QGraphicsSceneMouseEvent *event)
update();
}
void UBToolWidget::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
void UBToolWidget::mouseMoveEvent(QMouseEvent *event)
{
if(mShouldMoveWidget && (event->buttons() & Qt::LeftButton)) {
setPos(pos() - mMousePressPos + event->pos());
move(pos() - mMousePressPos + event->pos());
event->accept();
}
QGraphicsWidget::mouseMoveEvent(event);
QWidget::mouseMoveEvent(event);
}
void UBToolWidget::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
void UBToolWidget::mouseReleaseEvent(QMouseEvent *event)
{
mShouldMoveWidget = false;
if (event->pos().x() >= 0 && event->pos().x() < sClosePixmap->width() && event->pos().y() >= 0 && event->pos().y() < sClosePixmap->height()) {
remove();
UBApplication::boardController->removeTool(this);
event->accept();
}
else if (mGraphicsWidgetItem->canBeContent() && event->pos().x() >= mContentMargin && event->pos().x() < mContentMargin + sUnpinPixmap->width() && event->pos().y() >= 0 && event->pos().y() < sUnpinPixmap->height()) {
else if (mToolWidget->canBeContent() && event->pos().x() >= mContentMargin && event->pos().x() < mContentMargin + sUnpinPixmap->width() && event->pos().y() >= 0 && event->pos().y() < sUnpinPixmap->height()) {
UBApplication::boardController->moveToolWidgetToScene(this);
event->accept();
}
else
QGraphicsWidget::mouseReleaseEvent(event); /* don't propgate to parent, the widget is deleted in UBApplication */
QWidget::mouseReleaseEvent(event); /* don't propgate to parent, the widget is deleted in UBApplication */
}
void UBToolWidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
void UBToolWidget::paintEvent(QPaintEvent *event)
{
QGraphicsWidget::paint(painter, option, widget);
/* painting lightweight toolbar */
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);
QWidget::paintEvent(event);
//if (isActiveWindow())
{
QPainter painter(this);
painter.setRenderHint(QPainter::Antialiasing);
painter.setPen(Qt::NoPen);
painter.setBrush(QColor(127, 127, 127, 127));
painter.drawRoundedRect(QRectF(sClosePixmap->width() / 2
, sClosePixmap->height() / 2
, width() - sClosePixmap->width()
, mFrameWidth)
, mFrameWidth / 2
, mFrameWidth / 2);
painter.drawPixmap(0, 0, *sClosePixmap);
if (mToolWidget->canBeContent())
painter.drawPixmap(mContentMargin, 0, *sUnpinPixmap);
}
}
void UBToolWidget::javaScriptWindowObjectCleared()
{
UBWidgetUniboardAPI *uniboardAPI = new UBWidgetUniboardAPI(UBApplication::boardController->activeScene(), mGraphicsWidgetItem);
UBWidgetUniboardAPI *uniboardAPI = new UBWidgetUniboardAPI(UBApplication::boardController->activeScene(), mToolWidget);
mGraphicsWebView->page()->mainFrame()->addToJavaScriptWindowObject("sankore", uniboardAPI);
mWebView->page()->mainFrame()->addToJavaScriptWindowObject("sankore", uniboardAPI);
UBGraphicsW3CWidgetItem *graphicsW3cWidgetItem = dynamic_cast<UBGraphicsW3CWidgetItem*>(mGraphicsWidgetItem);
UBGraphicsW3CWidgetItem *graphicsW3cWidgetItem = dynamic_cast<UBGraphicsW3CWidgetItem*>(mToolWidget);
if (graphicsW3cWidgetItem)
{
UBW3CWidgetAPI* widgetAPI = new UBW3CWidgetAPI(graphicsW3cWidgetItem);
mGraphicsWebView->page()->mainFrame()->addToJavaScriptWindowObject("widget", widgetAPI);
mWebView->page()->mainFrame()->addToJavaScriptWindowObject("widget", widgetAPI);
}
}
UBGraphicsWidgetItem* UBToolWidget::graphicsWidgetItem() const
UBGraphicsWidgetItem* UBToolWidget::toolWidget() const
{
return mGraphicsWidgetItem;
return mToolWidget;
}
QPointF UBToolWidget::naturalCenter() const
QPoint UBToolWidget::naturalCenter() const
{
if (mGraphicsWebView)
return mGraphicsWebView->geometry().center();
if (mWebView)
return mWebView->geometry().center();
else
return QPointF(0, 0);
}
void UBToolWidget::centerOn(const QPointF& pos)
{
QGraphicsWidget::setPos(pos - QPointF(preferredWidth() / 2, preferredHeight() / 2));
return QPoint(0, 0);
}
void UBToolWidget::remove()
{
mGraphicsWebView->setHtml(QString());
scene()->removeItem(this);
}
UBGraphicsScene* UBToolWidget::scene()
{
return qobject_cast<UBGraphicsScene*>(QGraphicsItem::scene());
}
QPointF UBToolWidget::pos() const
{
return QPointF(QGraphicsItem::pos().x() + mContentMargin * scale(), QGraphicsItem::pos().y() + mContentMargin * scale());
}
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());
mToolWidget = NULL;
hide();
deleteLater();
}
int UBToolWidget::type() const
void UBToolWidget::centerOn(const QPoint& pos)
{
return Type;
QWidget::move(pos - QPoint(width() / 2, height() / 2));
}

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

@ -0,0 +1,828 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "UBGraphicsAristo.h"
#include "board/UBBoardController.h"
#include "board/UBDrawingController.h"
#include "core/UBApplication.h"
#include "domain/UBGraphicsScene.h"
#include <QColor>
#include <QFont>
#include <QFontMetricsF>
#include <QGraphicsItem>
#include <QLineF>
#include <QPolygonF>
#include <QRadialGradient>
#include <QString>
#include "core/memcheck.h"
const QRectF UBGraphicsAristo::sDefaultRect = QRectF(0, 0, 800, 500);
const UBGraphicsAristo::Orientation UBGraphicsAristo::sDefaultOrientation = UBGraphicsAristo::Bottom;
UBGraphicsAristo::UBGraphicsAristo()
: UBAbstractDrawRuler()
, QGraphicsPathItem()
, mMarking(false)
, mResizing(false)
, mRotating(false)
, mOrientation(Undefined)
, mRotatedAngle(0)
, mMarkerAngle(0)
, mStartAngle(0)
, mSpan(180)
, mHFlipSvgItem(0)
, mMarkerSvgItem(0)
, mResizeSvgItem(0)
, mRotateSvgItem(0)
{
mHFlipSvgItem = new QGraphicsSvgItem(":/images/vflipTool.svg", this);
mHFlipSvgItem->setVisible(false);
mHFlipSvgItem->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Control));
mResizeSvgItem = new QGraphicsSvgItem(":/images/resizeTool.svg", this);
mResizeSvgItem->setVisible(false);
mResizeSvgItem->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Control));
mRotateSvgItem = new QGraphicsSvgItem(":/images/rotateTool.svg", this);
mRotateSvgItem->setVisible(false);
mRotateSvgItem->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Control));
mMarkerSvgItem = new QGraphicsSvgItem(":/images/angleMarker.svg", this);
mMarkerSvgItem->setVisible(false);
mMarkerSvgItem->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Tool));
mMarkerSvgItem->setVisible(true);
create(*this);
setBoundingRect(sDefaultRect);
setOrientation(sDefaultOrientation);
}
UBGraphicsAristo::~UBGraphicsAristo()
{
/* NOOP */
}
/*
* setOrientation() modify the tool orientation.
* makeGeometryChange() is called so points are recomputed, control items are positionnated and shape is determined according to this modification.
*/
void UBGraphicsAristo::setOrientation(Orientation orientation)
{
mOrientation = orientation;
makeGeometryChange();
}
/* calculatePoints() is used to calculate polygon's apexes coordinates.
* This function handles orientation changes too.
*/
void UBGraphicsAristo::calculatePoints()
{
switch (mOrientation) {
case Bottom:
C.setX(boundingRect().center().x());
C.setY(boundingRect().bottom());
A.setX(boundingRect().left());
A.setY(boundingRect().bottom() - boundingRect().width() / 2);
B.setX(boundingRect().right());
B.setY(boundingRect().bottom() - boundingRect().width() / 2);
break;
case Top:
C.setX(boundingRect().center().x());
C.setY(boundingRect().top());
A.setX(boundingRect().left());
A.setY(boundingRect().top() + boundingRect().width() / 2);
B.setX(boundingRect().right());
B.setY(boundingRect().top() + boundingRect().width() / 2);
break;
default:
break;
}
}
/*
* setItemsPos() places control items according to A, B and C positions.
* Call this function after A, B or C position modification, mostly after calling calculatePoints().
* These positions has to be set when calling setPath() to allow hover events on items which are not into the main polygon.
*/
void UBGraphicsAristo::setItemsPos()
{
mCloseSvgItem->setPos(closeButtonRect().topLeft() + rotationCenter());
mHFlipSvgItem->setPos(hFlipRect().topLeft() + rotationCenter());
mRotateSvgItem->setPos(rotateRect().topLeft() + rotationCenter());
mResizeSvgItem->setPos(resizeButtonRect().topLeft() + rotationCenter());
mMarkerSvgItem->setPos(markerButtonRect().topLeft() + rotationCenter());
}
/*
* determinePath() modify the shape according to apexes coordinates and control item positions.
* This is useful when orientation is modified.
* Returns the painter path corresponding to object parameters.
*/
QPainterPath UBGraphicsAristo::determinePath()
{
QPainterPath path;
QPolygonF polygon;
polygon << A << B << C;
path.addPolygon(polygon);
path.addPath(mResizeSvgItem->shape().translated(mResizeSvgItem->pos()));
path.addPath(mMarkerSvgItem->shape().translated(mMarkerSvgItem->pos()));
return path;
}
/*
* setBoundingRect() is a helper to set the given rectangle as the new shape to limit apexes coordinates.
* This is useful when instanciating or resizing the object.
* makeGeometryChange() is called so points are recomputed, control items are positionnated and shape is determined according to this modification.
* Setting bounds' width less than 300 is not allowed.
*/
void UBGraphicsAristo::setBoundingRect(QRectF boundingRect)
{
if (boundingRect.width() < 300)
return;
QPainterPath path;
path.addRect(boundingRect);
setPath(path);
if (mOrientation != Undefined)
makeGeometryChange();
}
void UBGraphicsAristo::makeGeometryChange()
{
calculatePoints();
setItemsPos();
setPath(determinePath());
}
UBItem* UBGraphicsAristo::deepCopy(void) const
{
UBGraphicsAristo* copy = new UBGraphicsAristo();
copyItemParameters(copy);
return copy;
}
void UBGraphicsAristo::copyItemParameters(UBItem *copy) const
{
UBGraphicsAristo* cp = dynamic_cast<UBGraphicsAristo*>(copy);
if (cp)
{
/* TODO: copy all members */
cp->setPos(this->pos());
cp->setTransform(this->transform());
cp->setBoundingRect(boundingRect());
cp->setOrientation(mOrientation);
cp->mRotatedAngle = mRotatedAngle;
cp->mMarkerAngle = mMarkerAngle;
}
}
void UBGraphicsAristo::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
{
QPolygonF polygon;
painter->setBrush(fillBrush());
painter->setPen(drawColor());
polygon << A << B << C;
painter->drawPolygon(polygon);
polygon.clear();
paintGraduations(painter);
paintMarker(painter);
}
QBrush UBGraphicsAristo::fillBrush() const
{
QColor fillColor = edgeFillColor();// scene()->isDarkBackground() ? sDarkBackgroundFillColor : sFillColor;
QColor fillColorCenter = middleFillColor();//scene()->isDarkBackground() ? sDarkBackgroundFillColorCenter : sFillColorCenter;
QColor transparentWhite = Qt::white;
transparentWhite.setAlpha(scene()->isDarkBackground() ? sDrawTransparency : sFillTransparency);
QRadialGradient radialGradient(boundingRect().center(), radius(), boundingRect().center());
radialGradient.setColorAt(0, fillColorCenter);
radialGradient.setColorAt(1, fillColor);
return radialGradient;
}
/* paintGraduations() paints graduations on the ruler side (length graduations) and the two other sides (angle graduation) */
void UBGraphicsAristo::paintGraduations(QPainter *painter)
{
paintRulerGraduations(painter);
paintProtractorGraduations(painter);
}
void UBGraphicsAristo::paintRulerGraduations(QPainter *painter)
{
/* defining useful constants */
const int centimeterGraduationHeight = 15;
const int halfCentimeterGraduationHeight = 10;
const int millimeterGraduationHeight = 5;
const int millimetersPerCentimeter = 10;
const int millimetersPerHalfCentimeter = 5;
painter->save();
painter->setFont(font());
QFontMetricsF fontMetrics(painter->font());
/* Browsing milliters in half width of ruler side */
for (int millimeters = 0; millimeters < (boundingRect().width() / 2 - sLeftEdgeMargin - sRoundingRadius) / sPixelsPerMillimeter; millimeters++)
{
/* defining graduationHeight ; values are different to draw bigger lines if millimiter considered is a centimeter or a half centimeter */
int graduationHeight = (0 == millimeters % millimetersPerCentimeter) ?
centimeterGraduationHeight :
((0 == millimeters % millimetersPerHalfCentimeter) ?
halfCentimeterGraduationHeight : millimeterGraduationHeight);
/* correcting graduationHeight: draw the line in the other direction in case ruler is top-oriented, to stay inside the tool and inside the rect */
graduationHeight = mOrientation == Bottom ? graduationHeight : - graduationHeight;
/* drawing graduation to the left and to the right of origin, which is the center of graduated side */
painter->drawLine(QLine(rotationCenter().x() + sPixelsPerMillimeter * millimeters, rotationCenter().y(), rotationCenter().x() + sPixelsPerMillimeter * millimeters, rotationCenter().y() + graduationHeight));
if (millimeters != 0)
painter->drawLine(QLine(rotationCenter().x() - sPixelsPerMillimeter * millimeters, rotationCenter().y(), rotationCenter().x() - sPixelsPerMillimeter * millimeters, rotationCenter().y() + graduationHeight));
/* drawing associated value if considered graduation is a centimeter */
if (0 == millimeters % millimetersPerCentimeter)
{
/* defining graduation value */
QString text = QString("%1").arg((int)(millimeters / millimetersPerCentimeter));
/* staying inside polygon */
if (rotationCenter().x() + sPixelsPerMillimeter * millimeters + fontMetrics.width(text) / 2 < boundingRect().right())
{
qreal textWidth = fontMetrics.width(text);
qreal textHeight = fontMetrics.tightBoundingRect(text).height() + 5;
/* text y-coordinate is different according to tool's orientation */
qreal textY = mOrientation == Bottom ? A.y() + 5 + centimeterGraduationHeight : A.y() - 5 - centimeterGraduationHeight + graduationHeight;
/* if text's rect is not out of polygon's bounds, drawing value below or above graduation */
QPointF intersectionPoint;
bool paint = false;
if (mOrientation == Bottom && QLineF(QPointF(rotationCenter().x() - sPixelsPerMillimeter * millimeters - textWidth / 2, rotationCenter().y()), QPointF(rotationCenter().x() - sPixelsPerMillimeter * millimeters - textWidth / 2, textY + textHeight)).intersect(QLineF(A, C), &intersectionPoint) != QLineF::BoundedIntersection && QLineF(QPointF(rotationCenter().x() - sPixelsPerMillimeter * millimeters + textWidth / 2, rotationCenter().y()), QPointF(rotationCenter().x() - sPixelsPerMillimeter * millimeters + textWidth / 2, textY + textHeight)).intersect(QLineF(A, C), &intersectionPoint) != QLineF::BoundedIntersection) {
paint = true;
}
else if (mOrientation == Top && QLineF(QPointF(rotationCenter().x() - sPixelsPerMillimeter * millimeters - textWidth / 2, rotationCenter().y()), QPointF(rotationCenter().x() - sPixelsPerMillimeter * millimeters - textWidth / 2, textY - textHeight)).intersect(QLineF(A, C), &intersectionPoint) != QLineF::BoundedIntersection && QLineF(QPointF(rotationCenter().x() - sPixelsPerMillimeter * millimeters + textWidth / 2, rotationCenter().y()), QPointF(rotationCenter().x() - sPixelsPerMillimeter * millimeters + textWidth / 2, textY - textHeight)).intersect(QLineF(A, C), &intersectionPoint) != QLineF::BoundedIntersection) {
paint = true;
}
if (paint) {
painter->drawText(
QRectF(rotationCenter().x() + sPixelsPerMillimeter * millimeters - textWidth / 2, textY, textWidth, textHeight),
Qt::AlignVCenter, text);
if (millimeters != 0)
painter->drawText(
QRectF(rotationCenter().x() - sPixelsPerMillimeter * millimeters - textWidth / 2, textY, textWidth, textHeight),
Qt::AlignVCenter, text);
}
}
}
}
painter->restore();
}
void UBGraphicsAristo::paintProtractorGraduations(QPainter* painter)
{
/* defining useful constants */
const int tenDegreeGraduationLength = 15;
const int fiveDegreeGraduationLength = 10;
const int oneDegreeGraduationLength = 5;
painter->save();
QFont font1 = painter->font();
#ifdef Q_WS_MAC
font1.setPointSizeF(font1.pointSizeF() - 3);
#endif
QFontMetricsF fm1(font1);
//Font for internal arc
QFont font2 = painter->font();
font2.setPointSizeF(font1.pointSizeF()/1.5);
QFontMetricsF fm2(font2);
/* defining virtual arc diameter */
qreal rad = radius();
QPointF center = rotationCenter();
/* browsing angles */
for (int angle = 1; angle < mSpan; angle++)
{
int graduationLength = (0 == angle % 10) ? tenDegreeGraduationLength : ((0 == angle % 5) ? fiveDegreeGraduationLength : oneDegreeGraduationLength);
qreal co = cos(((qreal)angle + mStartAngle) * PI/180);
qreal si = sin(((qreal)angle + mStartAngle) * PI/180);
/* inverse sinus according to the orientation, to draw graduations on the polygon */
si = mOrientation == Bottom ? -si : si;
/* drawing the graduation around the virtual arc */
if (angle >= sArcAngleMargin && angle <= mSpan - sArcAngleMargin)
painter->drawLine(QLineF(QPointF(center.x()+ rad/2*co, center.y() - rad/2*si),
QPointF(center.x()+ (rad/2 + graduationLength)*co,
center.y() - (rad/2 + graduationLength)*si)));
QPointF intersectionPoint;
QLineF referenceLine;
if (angle < 90)
referenceLine.setP1(B);
else
referenceLine.setP1(A);
referenceLine.setP2(C);
/* if angle is 10-multiple, drawing it's value, rotated to be easily red */
if (0 == angle % 10) {
QString grad = QString("%1").arg((int)(angle));
QString grad2 = QString("%1").arg((int)mSpan - angle);
painter->setFont(font2);
painter->save();
painter->translate(center.x() + (rad/2 + graduationLength*1.5)*co, center.y() - (rad/2 + graduationLength*1.5)*si);
int degrees = mOrientation == Bottom ? angle : -angle;
painter->rotate(-90 + degrees);
painter->drawText(- fm2.width(grad)/2, - fm2.height()/2, fm2.width(grad), fm2.height(), Qt::AlignCenter, grad);
painter->restore();
painter->setFont(font1);
/* drawing the graduation near tool's side */
if (QLineF(QPointF(center.x()+ rad/2*co, center.y() - rad/2*si),
QPointF(center.x()+ (rad/2 + graduationLength)*co,
center.y() - (rad/2 + graduationLength)*si)).intersect(referenceLine, &intersectionPoint) == QLineF::UnboundedIntersection)
painter->drawLine(QLineF(QPointF(center.x() + (rad/2 + graduationLength*1.5 + fm2.width(grad)/2)*co,
center.y() - (rad/2 + graduationLength*1.5 + fm2.height()/2)*si),
intersectionPoint));
}
/* drawing the graduation near tool's side */
else
if (QLineF(QPointF(center.x()+ rad/2*co, center.y() - rad/2*si),
QPointF(center.x()+ (rad/2 + graduationLength)*co,
center.y() - (rad/2 + graduationLength)*si)).intersect(referenceLine, &intersectionPoint) == QLineF::UnboundedIntersection)
painter->drawLine(QLineF(QPointF(intersectionPoint.x() - (graduationLength*1.5)*co,
intersectionPoint.y() + (graduationLength*1.5)*si),
intersectionPoint));
}
painter->restore();
}
/* paintMarker() adjust marker button according to the current angle, draw the line allowing user to set precisely the angle, and draw the current angle's value. */
void UBGraphicsAristo::paintMarker(QPainter *painter)
{
/* adjusting marker button */
mMarkerSvgItem->resetTransform();
mMarkerSvgItem->translate(-markerButtonRect().left(), -markerButtonRect().top());
mMarkerSvgItem->rotate(mMarkerAngle);
mMarkerSvgItem->translate(markerButtonRect().left(), markerButtonRect().top());
qreal co = cos((mMarkerAngle) * PI/180);
qreal si = sin((mMarkerAngle) * PI/180);
/* Setting point composing the line (from point C) which intersects the line we want to draw. */
QPointF referencePoint;
if (mOrientation == Bottom) {
if ((int)mMarkerAngle % 360 < 90)
referencePoint = B;
else
referencePoint = A;
}
else if (mOrientation == Top) {
if ((int)mMarkerAngle % 360 < 270 && (int)mMarkerAngle % 360 > 0)
referencePoint = A;
else
referencePoint = B;
}
/* getting intersection point to draw the wanted line */
QLineF intersectedLine(rotationCenter(), QPointF(rotationCenter().x()+co, rotationCenter().y()+si));
QPointF intersectionPoint;
if (intersectedLine.intersect(QLineF(referencePoint, C), &intersectionPoint))
painter->drawLine(QLineF(intersectionPoint, rotationCenter()));
/* drawing angle value */
qreal rightAngle = mOrientation == Bottom ? mMarkerAngle : 360 - mMarkerAngle;
QString angleText = QString("%1°").arg(rightAngle, 0, 'f', 1);
QFont font1 = painter->font();
#ifdef Q_WS_MAC
font1.setPointSizeF(font1.pointSizeF() - 3);
#endif
QFontMetricsF fm1(font1);
if (mOrientation == Bottom)
painter->drawText(rotationCenter().x() - fm1.width(angleText)/2 - radius()/8, rotationCenter().y() + radius()/8 - fm1.height()/2, fm1.width(angleText), fm1.height(), Qt::AlignCenter, angleText);
else
painter->drawText(rotationCenter().x() - fm1.width(angleText)/2 - radius()/8, rotationCenter().y() - radius()/8 - fm1.height()/2, fm1.width(angleText), fm1.height(), Qt::AlignCenter, angleText);
}
void UBGraphicsAristo::rotateAroundCenter(qreal angle)
{
qreal oldAngle = mRotatedAngle;
mRotatedAngle = angle;
QTransform transform;
rotateAroundCenter(transform, rotationCenter());
setTransform(transform, true);
mRotatedAngle = oldAngle + angle; // We have to store absolute value for FLIP case
}
void UBGraphicsAristo::rotateAroundCenter(QTransform& transform, QPointF center)
{
transform.translate(center.x(), center.y());
transform.rotate(mRotatedAngle);
transform.translate(- center.x(), - center.y());
}
void UBGraphicsAristo::resize(qreal factor)
{
prepareGeometryChange();
translate(rotationCenter().x(), rotationCenter().y());
scale(factor, factor);
translate(-rotationCenter().x(), -rotationCenter().y());
}
QPointF UBGraphicsAristo::rotationCenter() const
{
return QPointF((A.x() + B.x()) / 2, (A.y() + B.y()) / 2);
}
QRectF UBGraphicsAristo::closeButtonRect() const
{
qreal y = radius() / 4 + hFlipRect().height() + 3 + rotateRect().height() + 3;
if (mOrientation == Top)
y = -y;
return QRectF(- mCloseSvgItem->boundingRect().width() / 2, y, mCloseSvgItem->boundingRect().width(), mCloseSvgItem->boundingRect().height());
}
QRectF UBGraphicsAristo::hFlipRect() const
{
qreal y = radius() / 4;
if (mOrientation == Top)
y = -y;
return QRectF(- mHFlipSvgItem->boundingRect().width() / 2, y, mHFlipSvgItem->boundingRect().width(), mHFlipSvgItem->boundingRect().height());
}
QRectF UBGraphicsAristo::markerButtonRect() const
{
return QRectF (radius()/2 - mMarkerSvgItem->boundingRect().width(), - mMarkerSvgItem->boundingRect().height()/2, mMarkerSvgItem->boundingRect().width(), mMarkerSvgItem->boundingRect().height());
}
QRectF UBGraphicsAristo::resizeButtonRect() const
{
return QRectF((B - rotationCenter()).x() - 100 - mResizeSvgItem->boundingRect().width()/2, - mResizeSvgItem->boundingRect().height()/2, mResizeSvgItem->boundingRect().width(), mResizeSvgItem->boundingRect().height());
}
QRectF UBGraphicsAristo::rotateRect() const
{
qreal y = radius() / 4 + hFlipRect().height() + 3;
if (mOrientation == Top)
y = -y;
return QRectF(- mRotateSvgItem->boundingRect().width() / 2, y, mRotateSvgItem->boundingRect().width(), mRotateSvgItem->boundingRect().height());
}
QCursor UBGraphicsAristo::flipCursor() const
{
return Qt::ArrowCursor;
}
QCursor UBGraphicsAristo::markerCursor() const
{
return Qt::ArrowCursor;
}
QCursor UBGraphicsAristo::resizeCursor() const
{
return Qt::ArrowCursor;
}
void UBGraphicsAristo::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
switch (toolFromPos(event->pos())) {
case Rotate:
mRotating = true;
event->accept();
break;
case Resize:
mResizing = true;
event->accept();
break;
case MoveMarker:
mMarking = true;
event->accept();
break;
default:
QGraphicsItem::mousePressEvent(event);
break;
}
mShowButtons = false;
mHFlipSvgItem->setVisible(false);
mCloseSvgItem->setVisible(false);
mRotateSvgItem->setVisible(mRotating);
mResizeSvgItem->setVisible(mResizing);
update();
}
void UBGraphicsAristo::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{
if (!mResizing && !mRotating && !mMarking)
{
QGraphicsItem::mouseMoveEvent(event);
}
else
{
QLineF currentLine(rotationCenter(), event->pos());
QLineF lastLine(rotationCenter(), event->lastPos());
if (mRotating) {
rotateAroundCenter(currentLine.angleTo(lastLine));
}
else if (mResizing) {
QPointF delta = event->pos() - event->lastPos();
setBoundingRect(QRectF(boundingRect().topLeft(), QSizeF(boundingRect().width() + delta.x(), boundingRect().height() + delta.x())));
}
else if(mMarking) {
qreal angle = currentLine.angleTo(lastLine);
mMarkerAngle += angle;
mMarkerAngle -= (int)(mMarkerAngle/360)*360;
if (mOrientation == Bottom) {
if (mMarkerAngle >= 270)
mMarkerAngle = 0;
else if (mMarkerAngle > 180)
mMarkerAngle = 180;
}
else if (mOrientation == Top) {
if (mMarkerAngle < 90)
mMarkerAngle = 360;
else if (mMarkerAngle < 180)
mMarkerAngle = 180;
}
update();
}
event->accept();
}
}
void UBGraphicsAristo::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
if (mResizing || mRotating || mMarking)
{
mResizing = false;
mRotating = false;
mMarking = false;
event->accept();
}
else
{
switch (toolFromPos(event->pos())) {
case Close :
hide();
emit hidden();
break;
case HorizontalFlip:
/* substracting difference to zero [2pi] twice, to obtain the desired angle */
mMarkerAngle -= 2 * (mMarkerAngle - (int)(mMarkerAngle/360)*360) - 360;
/* setting new orientation */
switch(mOrientation) {
case Bottom:
setOrientation(Top);
break;
case Top:
setOrientation(Bottom);
break;
default:
break;
}
default:
QGraphicsItem::mouseReleaseEvent(event);
break;
}
}
mShowButtons = true;
update();
if (scene())
scene()->setModified(true);
}
void UBGraphicsAristo::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
{
UBStylusTool::Enum currentTool = (UBStylusTool::Enum)UBDrawingController::drawingController ()->stylusTool ();
if (currentTool == UBStylusTool::Selector) {
mShowButtons = true;
mHFlipSvgItem->setVisible(true);
mRotateSvgItem->setVisible(true);
mResizeSvgItem->setVisible(true);
mCloseSvgItem->setVisible(true);
switch (toolFromPos(event->pos())) {
case HorizontalFlip:
setCursor(flipCursor());
break;
case Rotate:
setCursor(rotateCursor());
break;
case Resize:
setCursor(resizeCursor());
break;
case MoveMarker:
setCursor(markerCursor());
break;
case Close:
setCursor(closeCursor());
break;
default:
setCursor(moveCursor());
break;
}
event->accept();
update();
} else if (UBDrawingController::drawingController()->isDrawingTool()) {
setCursor(drawRulerLineCursor());
UBDrawingController::drawingController()->mActiveRuler = this;
event->accept();
}
}
void UBGraphicsAristo::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
{
mShowButtons = false;
setCursor(Qt::ArrowCursor);
mHFlipSvgItem->setVisible(false);
mRotateSvgItem->setVisible(false);
mResizeSvgItem->setVisible(false);
mCloseSvgItem->setVisible(false);
UBDrawingController::drawingController()->mActiveRuler = NULL;
event->accept();
update();
}
void UBGraphicsAristo::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
{
UBStylusTool::Enum currentTool = (UBStylusTool::Enum)UBDrawingController::drawingController ()->stylusTool ();
if (currentTool == UBStylusTool::Selector)
{
mShowButtons = true;
mHFlipSvgItem->setVisible(true);
mRotateSvgItem->setVisible(true);
mResizeSvgItem->setVisible(true);
mCloseSvgItem->setVisible(true);
switch (toolFromPos(event->pos())) {
case HorizontalFlip:
setCursor(flipCursor());
break;
case Rotate:
setCursor(rotateCursor());
break;
case Resize:
setCursor(resizeCursor());
break;
case MoveMarker:
setCursor(markerCursor());
break;
case Close:
setCursor(closeCursor());
break;
default:
setCursor(moveCursor());
break;
}
event->accept();
}
else if (UBDrawingController::drawingController()->isDrawingTool())
event->accept();
}
/*
* toolfromPos() returns the item type corresponding to the given position.
* This method is used to reduce the amount of code in each event function and improve class' maintainability.
* pos: event's position ; a rotation is done to counter elements rotation, like the marker button.
*/
UBGraphicsAristo::Tool UBGraphicsAristo::toolFromPos(QPointF pos)
{
pos = pos - rotationCenter();
qreal rotationAngle = mOrientation == Bottom ? - mMarkerAngle : Top ? 360 * (int)(mMarkerAngle / 360 + 1) - mMarkerAngle : 0;
QTransform t;
t.rotate(rotationAngle);
QPointF p2 = t.map(pos);
if (resizeButtonRect().contains(pos))
return Resize;
else if (closeButtonRect().contains(pos))
return Close;
else if (rotateRect().contains(pos))
return Rotate;
else if (markerButtonRect().contains(p2))
return MoveMarker;
else if (hFlipRect().contains(pos))
return HorizontalFlip;
else if (shape().contains(pos))
return Move;
else
return None;
}
void UBGraphicsAristo::StartLine(const QPointF &scenePos, qreal width)
{
QPointF itemPos = mapFromScene(scenePos);
qreal y;
y = rotationCenter().y();
if (itemPos.x() < boundingRect().x() + sLeftEdgeMargin)
itemPos.setX(boundingRect().x() + sLeftEdgeMargin);
if (itemPos.x() > boundingRect().x() + boundingRect().width() - sLeftEdgeMargin)
itemPos.setX(boundingRect().x() + boundingRect().width() - sLeftEdgeMargin);
itemPos.setY(y);
itemPos = mapToScene(itemPos);
scene()->moveTo(itemPos);
scene()->drawLineTo(itemPos, width, true);
}
void UBGraphicsAristo::DrawLine(const QPointF &scenePos, qreal width)
{
QPointF itemPos = mapFromScene(scenePos);
qreal y;
y = rotationCenter().y();
if (itemPos.x() < boundingRect().x() + sLeftEdgeMargin)
itemPos.setX(boundingRect().x() + sLeftEdgeMargin);
if (itemPos.x() > boundingRect().x() + boundingRect().width() - sLeftEdgeMargin)
itemPos.setX(boundingRect().x() + boundingRect().width() - sLeftEdgeMargin);
itemPos.setY(y);
itemPos = mapToScene(itemPos);
// We have to use "pointed" line for marker tool
scene()->drawLineTo(itemPos, width,
UBDrawingController::drawingController()->stylusTool() != UBStylusTool::Marker);
}
void UBGraphicsAristo::EndLine()
{
/* NOOP */
}
UBGraphicsScene* UBGraphicsAristo::scene() const
{
return static_cast<UBGraphicsScene*>(QGraphicsPathItem::scene());
}

@ -0,0 +1,156 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef UBGRAPHICSARISTO_H_
#define UBGRAPHICSARISTO_H_
#include "core/UB.h"
#include "domain/UBItem.h"
#include "domain/UBGraphicsScene.h"
#include "tools/UBAbstractDrawRuler.h"
#include <QtGlobal>
#include <QBrush>
#include <QCursor>
#include <QGraphicsPathItem>
#include <QGraphicsSceneHoverEvent>
#include <QGraphicsSceneMouseEvent>
#include <QGraphicsSvgItem>
#include <QObject>
#include <QPainter>
#include <QPainterPath>
#include <QPointF>
#include <QRectF>
#include <QStyleOptionGraphicsItem>
#include <QTransform>
#include <QWidget>
class UBGraphicsAristo : public UBAbstractDrawRuler, public QGraphicsPathItem, public UBItem
{
Q_OBJECT
public:
UBGraphicsAristo();
virtual ~UBGraphicsAristo();
enum {
Type = UBGraphicsItemType::AristoItemType
};
enum Tool {
None,
Move,
Resize,
Rotate,
Close,
MoveMarker,
HorizontalFlip
};
enum Orientation
{
Bottom = 0,
Top,
Undefined
};
void setOrientation(Orientation orientation);
void setBoundingRect(QRectF boundingRect);
virtual UBItem* deepCopy() const;
virtual void copyItemParameters(UBItem *copy) const;
virtual void StartLine(const QPointF& scenePos, qreal width);
virtual void DrawLine(const QPointF& position, qreal width);
virtual void EndLine();
virtual int type() const
{
return Type;
}
UBGraphicsScene* scene() const;
protected:
virtual void paint (QPainter *painter, const QStyleOptionGraphicsItem *styleOption, QWidget *widget);
virtual void rotateAroundCenter(qreal angle);
virtual void resize(qreal factor);
virtual QPointF rotationCenter() const;
virtual QRectF closeButtonRect() const;
QRectF hFlipRect() const;
QRectF markerButtonRect() const;
QRectF resizeButtonRect () const;
QRectF rotateRect() const;
QCursor flipCursor() const;
QCursor markerCursor() const;
QCursor resizeCursor() const;
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
virtual void hoverMoveEvent(QGraphicsSceneHoverEvent *event);
private:
Tool toolFromPos(QPointF pos);
QTransform calculateRotationTransform();
void rotateAroundCenter(QTransform& transform, QPointF center);
void calculatePoints();
QPainterPath determinePath();
void setItemsPos();
void makeGeometryChange();
QBrush fillBrush() const;
void paintGraduations(QPainter *painter);
void paintMarker(QPainter *painter);
void paintProtractorGraduations(QPainter* painter);
void paintRulerGraduations(QPainter *painter);
inline qreal radius () const
{
return sqrt(((B.x() - A.x())*(B.x() - A.x()))+((B.y() - A.y())*(B.y() - A.y()))) * 9 / 16 - 20;
}
bool mMarking;
bool mResizing;
bool mRotating;
Orientation mOrientation;
qreal mRotatedAngle;
qreal mMarkerAngle;
qreal mStartAngle;
qreal mSpan;
QGraphicsSvgItem* mHFlipSvgItem;
QGraphicsSvgItem* mMarkerSvgItem;
QGraphicsSvgItem* mResizeSvgItem;
QGraphicsSvgItem* mRotateSvgItem;
QPointF A, B, C;
static const int sArcAngleMargin = 5;
static const Orientation sDefaultOrientation;
static const QRectF sDefaultRect;
};
#endif /* UBGRAPHICSARISTO_H_ */

@ -24,11 +24,21 @@
#include "core/memcheck.h"
UBGraphicsCache::UBGraphicsCache():QGraphicsRectItem()
QMap<UBGraphicsScene*, UBGraphicsCache*> UBGraphicsCache::sInstances;
UBGraphicsCache* UBGraphicsCache::instance(UBGraphicsScene *scene)
{
if (!sInstances.contains(scene))
sInstances.insert(scene, new UBGraphicsCache(scene));
return sInstances[scene];
}
UBGraphicsCache::UBGraphicsCache(UBGraphicsScene *scene) : QGraphicsRectItem()
, mMaskColor(Qt::black)
, mMaskShape(eMaskShape_Circle)
, mShapeWidth(100)
, mDrawMask(false)
, mScene(scene)
{
// Get the board size and pass it to the shape
QRect boardRect = UBApplication::boardController->displayView()->rect();
@ -39,11 +49,12 @@ UBGraphicsCache::UBGraphicsCache():QGraphicsRectItem()
UBGraphicsCache::~UBGraphicsCache()
{
sInstances.remove(mScene);
}
UBItem* UBGraphicsCache::deepCopy() const
{
UBGraphicsCache* copy = new UBGraphicsCache();
UBGraphicsCache* copy = new UBGraphicsCache(mScene);
copyItemParameters(copy);

@ -30,7 +30,7 @@ typedef enum
class UBGraphicsCache : public QGraphicsRectItem, public UBItem
{
public:
UBGraphicsCache();
static UBGraphicsCache* instance(UBGraphicsScene *scene);
~UBGraphicsCache();
enum { Type = UBGraphicsItemType::cacheItemType };
@ -55,8 +55,7 @@ protected:
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
private:
void init();
QRectF updateRect(QPointF currentPoint);
static QMap<UBGraphicsScene*, UBGraphicsCache*> sInstances;
QColor mMaskColor;
eMaskShape mMaskShape;
@ -65,6 +64,13 @@ private:
QPointF mShapePos;
int mOldShapeWidth;
QPointF mOldShapePos;
UBGraphicsScene* mScene;
UBGraphicsCache(UBGraphicsScene *scene);
void init();
QRectF updateRect(QPointF currentPoint);
};
#endif // UBGRAPHICSCACHE_H

@ -91,6 +91,12 @@ UBToolsManager::UBToolsManager(QObject *parent)
mDescriptors << cache;
// --------------------------------------------------------------------------------
aristo.id = "uniboardTool://uniboard.mnemis.com/aristo";
aristo.icon = QPixmap(":/images/toolPalette/aristoTool.png");
aristo.label = tr("Aristo");
aristo.version = "1.0";
mToolsIcon.insert(aristo.id, ":/images/toolPalette/aristoTool.png");
mDescriptors << aristo;
}
UBToolsManager::~UBToolsManager()

@ -76,6 +76,7 @@ class UBToolsManager : public QObject
UBToolDescriptor triangle;
UBToolDescriptor magnifier;
UBToolDescriptor cache;
UBToolDescriptor aristo;
QString iconFromToolId(QString id) { return mToolsIcon.value(id);}

@ -1,20 +1,21 @@
HEADERS += src/tools/UBGraphicsRuler.h \
src/tools/UBGraphicsTriangle.h \
HEADERS += src/tools/UBGraphicsRuler.h \
src/tools/UBGraphicsTriangle.h \
src/tools/UBGraphicsProtractor.h \
src/tools/UBGraphicsCompass.h \
src/tools/UBGraphicsAristo.h \
src/tools/UBToolsManager.h \
src/tools/UBGraphicsCurtainItem.h \
src/tools/UBGraphicsCurtainItemDelegate.h \
src/tools/UBAbstractDrawRuler.h \
src/tools/UBGraphicsCache.h
src/tools/UBGraphicsCache.h
SOURCES += src/tools/UBGraphicsRuler.cpp \
src/tools/UBGraphicsTriangle.cpp \
SOURCES += src/tools/UBGraphicsRuler.cpp \
src/tools/UBGraphicsTriangle.cpp \
src/tools/UBGraphicsProtractor.cpp \
src/tools/UBGraphicsCompass.cpp \
src/tools/UBGraphicsAristo.cpp \
src/tools/UBToolsManager.cpp \
src/tools/UBGraphicsCurtainItem.cpp \
src/tools/UBGraphicsCurtainItemDelegate.cpp \
src/tools/UBAbstractDrawRuler.cpp \
src/tools/UBGraphicsCache.cpp
src/tools/UBGraphicsCache.cpp

@ -200,7 +200,7 @@ void UBTrapFlashController::createWidget()
// flash widget
UBWebKitUtils::HtmlObject selectedObject = mAvailableFlashes.at(selectedIndex - 1);
UBApplication::applicationController->showBoard();
UBApplication::boardController->downloadURL(QUrl(selectedObject.source), QPoint(0, 0), QSize(selectedObject.width, selectedObject.height));
UBApplication::boardController->downloadURL(QUrl(selectedObject.source), QString(), QPoint(0, 0), QSize(selectedObject.width, selectedObject.height));
}
QString freezedWidgetPath = UBPlatformUtils::applicationResourcesDirectory() + "/etc/freezedWidgetWrapper.html";

@ -281,7 +281,7 @@ void WBWebTrapWebView::trapElementAtPos(const QPoint& pos)
emit objectCaptured(QUrl(page()->currentFrame()->url().toString() + "/" + source), type,
htr.boundingRect().width(), htr.boundingRect().height());
UBApplication::boardController->downloadURL(QUrl(source), QPointF(0.0, 0.0));
UBApplication::boardController->downloadURL(QUrl(source));
UBApplication::applicationController->showBoard();
}
}

Loading…
Cancel
Save