diff --git a/LICENSE.txt b/LICENSE similarity index 100% rename from LICENSE.txt rename to LICENSE diff --git a/Open-Sankore.packproj b/Open-Sankore.packproj index f443040f..a0933772 100644 --- a/Open-Sankore.packproj +++ b/Open-Sankore.packproj @@ -28,7 +28,7 @@ Mode 1 Path - LICENSE.txt + LICENSE Path Type 2 diff --git a/Sankore_3.1.pro b/Sankore_3.1.pro index 7e046954..642c794a 100644 --- a/Sankore_3.1.pro +++ b/Sankore_3.1.pro @@ -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 = 06 +VERSION_PATCH = 08 VERSION = "$${VERSION_MAJ}.$${VERSION_MIN}.$${VERSION_TYPE}.$${VERSION_PATCH}" VERSION = $$replace(VERSION, "\\.r", "") @@ -49,8 +49,6 @@ include(src/podcast/podcast.pri) include(src/tools/tools.pri) include(src/desktop/desktop.pri) include(src/web/web.pri) -include(src/interfaces/interfaces.pri) -include(src/customWidgets/customWidgets.pri) DEPENDPATH += src/pdf-merger INCLUDEPATH += src/pdf-merger @@ -76,7 +74,6 @@ FORMS += resources/forms/mainWindow.ui \ resources/forms/blackoutWidget.ui \ resources/forms/trapFlash.ui \ resources/forms/youTubePublishingDialog.ui \ - resources/forms/webPublishing.ui \ resources/forms/capturePublishing.ui \ resources/forms/intranetPodcastPublishingDialog.ui diff --git a/resources/customizations/fonts/AndBasR.ttf b/resources/customizations/fonts/AndBasR.ttf new file mode 100755 index 00000000..d785cc9d Binary files /dev/null and b/resources/customizations/fonts/AndBasR.ttf differ diff --git a/resources/customizations/fonts/ec_cour.ttf b/resources/customizations/fonts/ec_cour.ttf new file mode 100644 index 00000000..571571e3 Binary files /dev/null and b/resources/customizations/fonts/ec_cour.ttf differ diff --git a/resources/customizations/fonts/ecl_cour.ttf b/resources/customizations/fonts/ecl_cour.ttf new file mode 100644 index 00000000..af61c8e8 Binary files /dev/null and b/resources/customizations/fonts/ecl_cour.ttf differ diff --git a/resources/customizations/teacherGuide/indexingParameters.xml b/resources/customizations/teacherGuide/indexingParameters.xml deleted file mode 100644 index 2a194515..00000000 --- a/resources/customizations/teacherGuide/indexingParameters.xml +++ /dev/null @@ -1,218 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/resources/etc/Tutorial/tutorial_en/CSS/grid.css b/resources/etc/Tutorial/tutorial_en/CSS/grid.css deleted file mode 100644 index ae6553be..00000000 --- a/resources/etc/Tutorial/tutorial_en/CSS/grid.css +++ /dev/null @@ -1,54 +0,0 @@ - -.main {margin:0 auto; width:800px; padding-top:10px; } - - -.g320,.g480,.g640,.g960,.g80,.g240,.g400,.g560,.g720,.g880,.g960 {float:left; display: inline; padding-top: 10px;} - -.g800 {float:left; display: inline; width:800px;} - -.g200 {float:left; display: inline; width:190px; padding-top: 10px; padding-left: 10px;} -.g200left {float:left; display: inline; width:190px; padding-top: 10px; padding-left: 5px} - -.g160 {width:150px; } -.g320 {width:310px;} -.g480 {width:470px;} -.g600 {width:600px;} -.g640 {width:630px;} -.g800 {width:790px;} -.g960 {width:950px;} - -.g80 {width:70px;} -.g240 {width:230px;} -.g400 {width:390px;} -.g560 {width:550px;} -.g720 {width:710px;} -.g880 {width:870px;} - -.ml80{margin-left:90px;} -.ml160{margin-left:170px;} -.ml240{margin-left:250px;} -.ml320{margin-left:330px;} -.ml400{margin-left:410px;} -.ml480{margin-left:490px;} -.ml560{margin-left:560px;} -.ml640{margin-left:650px;} -.ml720{margin-left:730px;} -.ml800{margin-left:810px;} -.ml880{margin-left:890px;} -.ml960{margin-left:970px;} - -.inside{margin-left:0;} - -p.grid{ padding-left:10px;} - -.clear {clear:both;} -.clearfix, .main{ display:block;} - -.clearfix:after, .main:after { - visibility: hidden; - display: block; - font-size: 0; - content: " "; - clear: both; - height: 0; - } diff --git a/resources/etc/Tutorial/tutorial_en/CSS/reset.css b/resources/etc/Tutorial/tutorial_en/CSS/reset.css deleted file mode 100644 index e60e93f5..00000000 --- a/resources/etc/Tutorial/tutorial_en/CSS/reset.css +++ /dev/null @@ -1,29 +0,0 @@ -html, body, div, span, object, iframe, -h1, h2, h3, h4, h5, h6, p, blockquote, pre, -a, abbr, acronym, address, code, -del, dfn, em, img, q, dl, dt, dd, ol, ul, li, -fieldset, form, label, legend, -table, caption, tbody, tfoot, thead, tr, th, td { - margin: 0; - padding: 0; - border: 0; - font-weight: inherit; - font-style: inherit; - font-size: 100%; - font-family: inherit; - vertical-align: baseline; -} - - -/* Tables still need 'cellspacing="0"' in the markup. */ -table { border-collapse: separate; border-spacing: 0; } -caption, th, td { text-align: left; font-weight: normal; } -table, td, th { vertical-align: middle; } - -/* Remove possible quote marks (") from ,
. */ -blockquote:before, blockquote:after, q:before, q:after { content: ""; } -blockquote, q { quotes: "" ""; } - -/* Remove annoying border on linked images. */ -a img { border: none; } - diff --git a/resources/etc/Tutorial/tutorial_en/CSS/typography.css b/resources/etc/Tutorial/tutorial_en/CSS/typography.css deleted file mode 100644 index fbfc4539..00000000 --- a/resources/etc/Tutorial/tutorial_en/CSS/typography.css +++ /dev/null @@ -1,94 +0,0 @@ - -body { font:75%/1.5em "lucida grande","lucida sans unicode", sans-serif;} - -p { padding:0 0 1em 0;color:#111;} - - -p.first:first-letter{ float:left;font-family: Palatino,'Palatino Linotype',Georgia, sans-serif;font-size:3em;font-weight:700;line-height:1em;margin-bottom:-0.2em;padding:0.2em 0.1em 0 0; } -p img { float: left; margin: 0.3em 0.833em 0.833em 0; padding: 0; } -p img.right { float: right; margin: 0.3em 0 0.833em 0.833em; } - - -h1,h2{ line-height: normal; font-family: Helvetica, Verdana, Arial, sans-serif; font-weight:normal; color: #333; } -h3,h4,h5,h6 { font-family: Helvetica, Verdana, Arial, sans-serif; text-align: left; line-height: normal; font-weight: normal; color: #333; } - - -h1 { font-size: 2.2em; margin-bottom: 0.682em; } -h2 { font-size: 1.9em; margin-bottom: 0.79em; } -h3 { font-size: 1.7em; margin-bottom: 0.882em; } -h4 { font-size: 1.4em; margin-bottom: 1.071em; } -h5,h6 { font-size: 1.2em; margin-bottom: 1.154em; } - -/* Color palete */ -.water { color:#5582d1; } -.earth { color:#4e3e2c; } -.air { color:#f1fff7; } -.fire { color:#ff8a19; } -.wine { color:#4a040a; } -.beer { color:#F0C030; } -.caffe { color:#473523; } -.caffe-cream { color:#b68d3d; } -.espresso { color:#2c1901; } -.caramel{ color:#ab671f; } -.chocolate { color:#290200; } -.black-pepper { color:#444334; } -.pepper-lite { color:#8d8a72; } -.lipstick { color:#c20c0c; } - - -li ul, -li ol { margin:0 1.5em; } -ul, ol { margin: 0 1.5em 1.5em 1.5em; } - - -dl { margin: 0 0 1.5em 0; } -dl dt { font-weight: bold; } -dl dd { margin-left: 1.5em; } - -a { color:#035292; text-decoration:none; } -a:hover { text-decoration: underline; } - - -table { margin-bottom:1.5em; border-collapse: collapse; } -th { font-weight:bold; } -tr,th,td { margin:0; padding:0 1.5em 0 1em; height:18px; } -tfoot { font-style: italic; } -caption { text-align:center; font-family:Georgia, serif; } - - -abbr, acronym { border-bottom:1px dotted #000; } -address { margin-top:1.5em; font-style: italic; } -del {color:#000;} - - -blockquote { padding:1em 1em 1em 1.5em; font-family:baskerville,"palatino linotype",serif; } -blockquote > *:first-child:before { content:"\201C";font-size:2.5em;margin-left:-.62em;font-family:georgia,serif;padding-right:.2em;color:#aaa;line-height:0; }/* From Tripoli */ - -strong { ont-weight: bold; } -em, dfn { font-style: italic; } -dfn { font-weight: bold; } -pre, code { margin: 1.5em 0; white-space: pre; } -pre, code, tt { font: 1em monospace; line-height: 1.5; } -tt { display: block; margin: 1.5em 0; } -hr { margin-bottom:1.5em; } - -/*other small things */ - -.tc { text-align:center; } -.tr { text-align:right; } -.tl { text-align:left; } -.b { font-weight:bold; } -.i { font-style:italic; } - -.indent { text-indent:1.5em;} -.open { font-variant: small-caps; } -p.break { text-align:center;text-indent:0;line-height:0; } -p.zero{padding:0; margin:0} -p.one { padding:0 1em 1em 1em;color:#111;} -p img.right10 { float: right; margin:0.833em; } - -.oldbook { font-family:"Book Antiqua","Warnock Pro","Goudy Old Style","Palatino",Georgia,serif; } -.note { font-family:Georgia, "Times New Roman", Times, serif; font-style:italic; font-size:0.9em; margin:0.1em; color:#333; } -.mono { font-family:"Courier New", Courier, monospace; } - - diff --git a/resources/etc/Tutorial/tutorial_en/images/logo_open_sankore.png b/resources/etc/Tutorial/tutorial_en/images/logo_open_sankore.png deleted file mode 100644 index 0c63bfd7..00000000 Binary files a/resources/etc/Tutorial/tutorial_en/images/logo_open_sankore.png and /dev/null differ diff --git a/resources/etc/Tutorial/tutorial_en/images/manuel.png b/resources/etc/Tutorial/tutorial_en/images/manuel.png deleted file mode 100644 index 221bf6ae..00000000 Binary files a/resources/etc/Tutorial/tutorial_en/images/manuel.png and /dev/null differ diff --git a/resources/etc/Tutorial/tutorial_en/images/pedago.png b/resources/etc/Tutorial/tutorial_en/images/pedago.png deleted file mode 100644 index 02112edf..00000000 Binary files a/resources/etc/Tutorial/tutorial_en/images/pedago.png and /dev/null differ diff --git a/resources/etc/Tutorial/tutorial_en/images/tech.png b/resources/etc/Tutorial/tutorial_en/images/tech.png deleted file mode 100644 index 1ab2d87b..00000000 Binary files a/resources/etc/Tutorial/tutorial_en/images/tech.png and /dev/null differ diff --git a/resources/etc/Tutorial/tutorial_en/images/video.png b/resources/etc/Tutorial/tutorial_en/images/video.png deleted file mode 100644 index e6697e2d..00000000 Binary files a/resources/etc/Tutorial/tutorial_en/images/video.png and /dev/null differ diff --git a/resources/etc/Tutorial/tutorial_en/index.html b/resources/etc/Tutorial/tutorial_en/index.html deleted file mode 100644 index c47a787d..00000000 --- a/resources/etc/Tutorial/tutorial_en/index.html +++ /dev/null @@ -1,72 +0,0 @@ - - - - - - - - - - - - - -
- -
- - - -
- -
- -

Welcome to the tutorial space of Open-Sankoré. We propose you a set of online ressources to help you discover our software and improve your teaching and technical knowledge. If you have questions to ask us or want to contribute to the project, simply visit our website open-sankore.org

- -
- -
- - -

Video tutorials
- -
- - - - - - -
 
- -
- - - diff --git a/resources/etc/Tutorial/tutorial_fr/CSS/grid.css b/resources/etc/Tutorial/tutorial_fr/CSS/grid.css deleted file mode 100644 index ae6553be..00000000 --- a/resources/etc/Tutorial/tutorial_fr/CSS/grid.css +++ /dev/null @@ -1,54 +0,0 @@ - -.main {margin:0 auto; width:800px; padding-top:10px; } - - -.g320,.g480,.g640,.g960,.g80,.g240,.g400,.g560,.g720,.g880,.g960 {float:left; display: inline; padding-top: 10px;} - -.g800 {float:left; display: inline; width:800px;} - -.g200 {float:left; display: inline; width:190px; padding-top: 10px; padding-left: 10px;} -.g200left {float:left; display: inline; width:190px; padding-top: 10px; padding-left: 5px} - -.g160 {width:150px; } -.g320 {width:310px;} -.g480 {width:470px;} -.g600 {width:600px;} -.g640 {width:630px;} -.g800 {width:790px;} -.g960 {width:950px;} - -.g80 {width:70px;} -.g240 {width:230px;} -.g400 {width:390px;} -.g560 {width:550px;} -.g720 {width:710px;} -.g880 {width:870px;} - -.ml80{margin-left:90px;} -.ml160{margin-left:170px;} -.ml240{margin-left:250px;} -.ml320{margin-left:330px;} -.ml400{margin-left:410px;} -.ml480{margin-left:490px;} -.ml560{margin-left:560px;} -.ml640{margin-left:650px;} -.ml720{margin-left:730px;} -.ml800{margin-left:810px;} -.ml880{margin-left:890px;} -.ml960{margin-left:970px;} - -.inside{margin-left:0;} - -p.grid{ padding-left:10px;} - -.clear {clear:both;} -.clearfix, .main{ display:block;} - -.clearfix:after, .main:after { - visibility: hidden; - display: block; - font-size: 0; - content: " "; - clear: both; - height: 0; - } diff --git a/resources/etc/Tutorial/tutorial_fr/CSS/reset.css b/resources/etc/Tutorial/tutorial_fr/CSS/reset.css deleted file mode 100644 index e60e93f5..00000000 --- a/resources/etc/Tutorial/tutorial_fr/CSS/reset.css +++ /dev/null @@ -1,29 +0,0 @@ -html, body, div, span, object, iframe, -h1, h2, h3, h4, h5, h6, p, blockquote, pre, -a, abbr, acronym, address, code, -del, dfn, em, img, q, dl, dt, dd, ol, ul, li, -fieldset, form, label, legend, -table, caption, tbody, tfoot, thead, tr, th, td { - margin: 0; - padding: 0; - border: 0; - font-weight: inherit; - font-style: inherit; - font-size: 100%; - font-family: inherit; - vertical-align: baseline; -} - - -/* Tables still need 'cellspacing="0"' in the markup. */ -table { border-collapse: separate; border-spacing: 0; } -caption, th, td { text-align: left; font-weight: normal; } -table, td, th { vertical-align: middle; } - -/* Remove possible quote marks (") from ,
. */ -blockquote:before, blockquote:after, q:before, q:after { content: ""; } -blockquote, q { quotes: "" ""; } - -/* Remove annoying border on linked images. */ -a img { border: none; } - diff --git a/resources/etc/Tutorial/tutorial_fr/CSS/typography.css b/resources/etc/Tutorial/tutorial_fr/CSS/typography.css deleted file mode 100644 index fbfc4539..00000000 --- a/resources/etc/Tutorial/tutorial_fr/CSS/typography.css +++ /dev/null @@ -1,94 +0,0 @@ - -body { font:75%/1.5em "lucida grande","lucida sans unicode", sans-serif;} - -p { padding:0 0 1em 0;color:#111;} - - -p.first:first-letter{ float:left;font-family: Palatino,'Palatino Linotype',Georgia, sans-serif;font-size:3em;font-weight:700;line-height:1em;margin-bottom:-0.2em;padding:0.2em 0.1em 0 0; } -p img { float: left; margin: 0.3em 0.833em 0.833em 0; padding: 0; } -p img.right { float: right; margin: 0.3em 0 0.833em 0.833em; } - - -h1,h2{ line-height: normal; font-family: Helvetica, Verdana, Arial, sans-serif; font-weight:normal; color: #333; } -h3,h4,h5,h6 { font-family: Helvetica, Verdana, Arial, sans-serif; text-align: left; line-height: normal; font-weight: normal; color: #333; } - - -h1 { font-size: 2.2em; margin-bottom: 0.682em; } -h2 { font-size: 1.9em; margin-bottom: 0.79em; } -h3 { font-size: 1.7em; margin-bottom: 0.882em; } -h4 { font-size: 1.4em; margin-bottom: 1.071em; } -h5,h6 { font-size: 1.2em; margin-bottom: 1.154em; } - -/* Color palete */ -.water { color:#5582d1; } -.earth { color:#4e3e2c; } -.air { color:#f1fff7; } -.fire { color:#ff8a19; } -.wine { color:#4a040a; } -.beer { color:#F0C030; } -.caffe { color:#473523; } -.caffe-cream { color:#b68d3d; } -.espresso { color:#2c1901; } -.caramel{ color:#ab671f; } -.chocolate { color:#290200; } -.black-pepper { color:#444334; } -.pepper-lite { color:#8d8a72; } -.lipstick { color:#c20c0c; } - - -li ul, -li ol { margin:0 1.5em; } -ul, ol { margin: 0 1.5em 1.5em 1.5em; } - - -dl { margin: 0 0 1.5em 0; } -dl dt { font-weight: bold; } -dl dd { margin-left: 1.5em; } - -a { color:#035292; text-decoration:none; } -a:hover { text-decoration: underline; } - - -table { margin-bottom:1.5em; border-collapse: collapse; } -th { font-weight:bold; } -tr,th,td { margin:0; padding:0 1.5em 0 1em; height:18px; } -tfoot { font-style: italic; } -caption { text-align:center; font-family:Georgia, serif; } - - -abbr, acronym { border-bottom:1px dotted #000; } -address { margin-top:1.5em; font-style: italic; } -del {color:#000;} - - -blockquote { padding:1em 1em 1em 1.5em; font-family:baskerville,"palatino linotype",serif; } -blockquote > *:first-child:before { content:"\201C";font-size:2.5em;margin-left:-.62em;font-family:georgia,serif;padding-right:.2em;color:#aaa;line-height:0; }/* From Tripoli */ - -strong { ont-weight: bold; } -em, dfn { font-style: italic; } -dfn { font-weight: bold; } -pre, code { margin: 1.5em 0; white-space: pre; } -pre, code, tt { font: 1em monospace; line-height: 1.5; } -tt { display: block; margin: 1.5em 0; } -hr { margin-bottom:1.5em; } - -/*other small things */ - -.tc { text-align:center; } -.tr { text-align:right; } -.tl { text-align:left; } -.b { font-weight:bold; } -.i { font-style:italic; } - -.indent { text-indent:1.5em;} -.open { font-variant: small-caps; } -p.break { text-align:center;text-indent:0;line-height:0; } -p.zero{padding:0; margin:0} -p.one { padding:0 1em 1em 1em;color:#111;} -p img.right10 { float: right; margin:0.833em; } - -.oldbook { font-family:"Book Antiqua","Warnock Pro","Goudy Old Style","Palatino",Georgia,serif; } -.note { font-family:Georgia, "Times New Roman", Times, serif; font-style:italic; font-size:0.9em; margin:0.1em; color:#333; } -.mono { font-family:"Courier New", Courier, monospace; } - - diff --git a/resources/etc/Tutorial/tutorial_fr/images/logo_open_sankore.png b/resources/etc/Tutorial/tutorial_fr/images/logo_open_sankore.png deleted file mode 100644 index 0c63bfd7..00000000 Binary files a/resources/etc/Tutorial/tutorial_fr/images/logo_open_sankore.png and /dev/null differ diff --git a/resources/etc/Tutorial/tutorial_fr/images/manuel.png b/resources/etc/Tutorial/tutorial_fr/images/manuel.png deleted file mode 100644 index 221bf6ae..00000000 Binary files a/resources/etc/Tutorial/tutorial_fr/images/manuel.png and /dev/null differ diff --git a/resources/etc/Tutorial/tutorial_fr/images/pedago.png b/resources/etc/Tutorial/tutorial_fr/images/pedago.png deleted file mode 100644 index 02112edf..00000000 Binary files a/resources/etc/Tutorial/tutorial_fr/images/pedago.png and /dev/null differ diff --git a/resources/etc/Tutorial/tutorial_fr/images/tech.png b/resources/etc/Tutorial/tutorial_fr/images/tech.png deleted file mode 100644 index 1ab2d87b..00000000 Binary files a/resources/etc/Tutorial/tutorial_fr/images/tech.png and /dev/null differ diff --git a/resources/etc/Tutorial/tutorial_fr/images/video.png b/resources/etc/Tutorial/tutorial_fr/images/video.png deleted file mode 100644 index e6697e2d..00000000 Binary files a/resources/etc/Tutorial/tutorial_fr/images/video.png and /dev/null differ diff --git a/resources/etc/Tutorial/tutorial_fr/index.html b/resources/etc/Tutorial/tutorial_fr/index.html deleted file mode 100644 index 66467cf7..00000000 --- a/resources/etc/Tutorial/tutorial_fr/index.html +++ /dev/null @@ -1,72 +0,0 @@ - - - - - - - - - - - - - -
- -
- - - -
- -
- -

Bienvenue l'espace tutoriel du logiciel Open-Sankoré. Nous vous proposons une série de ressources en ligne pour vous aider à découvrir le logiciel et améliorer vos connaissances pédagogiques et techniques. Si vous avez des questions à nous poser ou désirez contribuer à notre projet, rendez-vous sur notre site open-sankore.org

- -
- -
- - -

Tutoriels video
- -
- - - - - - -
 
- -
- - - diff --git a/resources/forms/mainWindow.ui b/resources/forms/mainWindow.ui index 575d475d..980ef5c8 100644 --- a/resources/forms/mainWindow.ui +++ b/resources/forms/mainWindow.ui @@ -7,7 +7,7 @@ 0 0 1342 - 334 + 223 @@ -170,44 +170,6 @@ - - - Qt::PreventContextMenu - - - Tutorial - - - Qt::LeftToRight - - - false - - - Qt::BottomToolBarArea|Qt::TopToolBarArea - - - - 48 - 32 - - - - false - - - TopToolBarArea - - - true - - - - - - - - true diff --git a/resources/forms/preferences.ui b/resources/forms/preferences.ui index 942f7bfa..33465d5d 100644 --- a/resources/forms/preferences.ui +++ b/resources/forms/preferences.ui @@ -24,7 +24,7 @@ - 5 + 3 @@ -609,97 +609,6 @@ - - - - 0 - 0 - - - - Planète Sankoré ID for exporting file - - - - - - - - User: - - - - - - - - 5 - - - 0 - - - - - QLineEdit::Normal - - - - - - - Pass: - - - - - - - QLineEdit::Password - - - - - - - - - - - - Qt::Horizontal - - - QSizePolicy::Preferred - - - - 40 - 20 - - - - - - - - - 0 - 0 - - - - Restore credentials on reboot - - - true - - - - - - - Qt::Vertical diff --git a/resources/forms/webPublishing.ui b/resources/forms/webPublishing.ui deleted file mode 100644 index d71282e5..00000000 --- a/resources/forms/webPublishing.ui +++ /dev/null @@ -1,132 +0,0 @@ - - - documentPublishingDialog - - - Qt::WindowModal - - - - 0 - 0 - 607 - 405 - - - - Dialog - - - - - - QFormLayout::AllNonFixedFieldsGrow - - - - - Title - - - - - - - 60 - - - - - - - E-mail - - - - - - - - - - Author - - - - - - - - - - Description - - - - - - - - 0 - 0 - - - - - 0 - 168 - - - - - - - - Qt::Vertical - - - - 20 - 10 - - - - - - - - Attach Downloadable PDF Version - - - - - - - Attach Downloadable Uniboard File (UBZ) - - - - - - - Warning: This documents contains video, which will not be displayed properly on the Web - - - true - - - - - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - - - - diff --git a/resources/images/duration1.png b/resources/images/duration1.png deleted file mode 100644 index 5f1f8355..00000000 Binary files a/resources/images/duration1.png and /dev/null differ diff --git a/resources/images/duration2.png b/resources/images/duration2.png deleted file mode 100644 index 37dcb1ca..00000000 Binary files a/resources/images/duration2.png and /dev/null differ diff --git a/resources/images/duration3.png b/resources/images/duration3.png deleted file mode 100644 index 9c61f7f8..00000000 Binary files a/resources/images/duration3.png and /dev/null differ diff --git a/resources/images/licenses/ccby.png b/resources/images/licenses/ccby.png deleted file mode 100644 index 822491ed..00000000 Binary files a/resources/images/licenses/ccby.png and /dev/null differ diff --git a/resources/images/licenses/ccbync.png b/resources/images/licenses/ccbync.png deleted file mode 100644 index 5f982147..00000000 Binary files a/resources/images/licenses/ccbync.png and /dev/null differ diff --git a/resources/images/licenses/ccbyncnd.png b/resources/images/licenses/ccbyncnd.png deleted file mode 100644 index 49f272f8..00000000 Binary files a/resources/images/licenses/ccbyncnd.png and /dev/null differ diff --git a/resources/images/licenses/ccbyncsa.png b/resources/images/licenses/ccbyncsa.png deleted file mode 100644 index 0f2a0f10..00000000 Binary files a/resources/images/licenses/ccbyncsa.png and /dev/null differ diff --git a/resources/images/licenses/ccbynd.png b/resources/images/licenses/ccbynd.png deleted file mode 100644 index 8f317035..00000000 Binary files a/resources/images/licenses/ccbynd.png and /dev/null differ diff --git a/resources/images/licenses/ccbysa.png b/resources/images/licenses/ccbysa.png deleted file mode 100644 index f0a944e0..00000000 Binary files a/resources/images/licenses/ccbysa.png and /dev/null differ diff --git a/resources/images/teacherGuide/audio_24x24.svg b/resources/images/teacherGuide/audio_24x24.svg deleted file mode 100644 index fc5c2294..00000000 --- a/resources/images/teacherGuide/audio_24x24.svg +++ /dev/null @@ -1,91 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/resources/images/teacherGuide/flash_24x24.svg b/resources/images/teacherGuide/flash_24x24.svg deleted file mode 100644 index 03c15458..00000000 --- a/resources/images/teacherGuide/flash_24x24.svg +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - diff --git a/resources/images/teacherGuide/image_24x24.svg b/resources/images/teacherGuide/image_24x24.svg deleted file mode 100644 index 5b197269..00000000 --- a/resources/images/teacherGuide/image_24x24.svg +++ /dev/null @@ -1,81 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/resources/images/teacherGuide/link_24x24.svg b/resources/images/teacherGuide/link_24x24.svg deleted file mode 100644 index a2c47cd9..00000000 --- a/resources/images/teacherGuide/link_24x24.svg +++ /dev/null @@ -1,168 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/resources/images/teacherGuide/movie_24x24.svg b/resources/images/teacherGuide/movie_24x24.svg deleted file mode 100644 index d22e4470..00000000 --- a/resources/images/teacherGuide/movie_24x24.svg +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/resources/images/teacherGuide/pencil.svg b/resources/images/teacherGuide/pencil.svg deleted file mode 100644 index e7e6a2ce..00000000 --- a/resources/images/teacherGuide/pencil.svg +++ /dev/null @@ -1,61 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/resources/images/teacherGuide/w3c_24x24.svg b/resources/images/teacherGuide/w3c_24x24.svg deleted file mode 100644 index 07a37ac0..00000000 --- a/resources/images/teacherGuide/w3c_24x24.svg +++ /dev/null @@ -1,112 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/resources/images/teacher_close.png b/resources/images/teacher_close.png deleted file mode 100644 index bee2ea0d..00000000 Binary files a/resources/images/teacher_close.png and /dev/null differ diff --git a/resources/images/teacher_close_disabled.png b/resources/images/teacher_close_disabled.png deleted file mode 100644 index 8f3c988c..00000000 Binary files a/resources/images/teacher_close_disabled.png and /dev/null differ diff --git a/resources/images/teacher_open.png b/resources/images/teacher_open.png deleted file mode 100644 index 17469cc7..00000000 Binary files a/resources/images/teacher_open.png and /dev/null differ diff --git a/resources/images/teacher_open_disabled.png b/resources/images/teacher_open_disabled.png deleted file mode 100644 index 99e78cd9..00000000 Binary files a/resources/images/teacher_open_disabled.png and /dev/null differ diff --git a/resources/images/toque.svg b/resources/images/toque.svg deleted file mode 100644 index 146cddc5..00000000 --- a/resources/images/toque.svg +++ /dev/null @@ -1,131 +0,0 @@ - - - -]> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/resources/sankore.qrc b/resources/sankore.qrc index b98a501b..c2e99561 100644 --- a/resources/sankore.qrc +++ b/resources/sankore.qrc @@ -339,32 +339,11 @@ images/closeDisabled.svg images/menuDisabled.svg images/moveUpDisabled.svg - images/teacher_close.png - images/teacher_open.png - images/teacher_close_disabled.png style.qss - images/teacher_open_disabled.png images/libpalette/WebSearchCategory.svg images/download_close.png images/download_open.png images/tab_mask.png - images/duration1.png - images/duration2.png - images/duration3.png - images/licenses/ccby.png - images/licenses/ccbync.png - images/licenses/ccbyncnd.png - images/licenses/ccbyncsa.png - images/licenses/ccbynd.png - images/licenses/ccbysa.png - images/teacherGuide/audio_24x24.svg - images/teacherGuide/image_24x24.svg - images/teacherGuide/link_24x24.svg - images/teacherGuide/movie_24x24.svg - images/teacherGuide/w3c_24x24.svg - images/teacherGuide/pencil.svg images/duplicateDisabled.svg - images/teacherGuide/flash_24x24.svg - images/toque.svg diff --git a/src/adaptors/UBCFFSubsetAdaptor.cpp b/src/adaptors/UBCFFSubsetAdaptor.cpp index 73a81c5b..56b4890e 100644 --- a/src/adaptors/UBCFFSubsetAdaptor.cpp +++ b/src/adaptors/UBCFFSubsetAdaptor.cpp @@ -1215,13 +1215,17 @@ UBGraphicsGroupContainerItem *UBCFFSubsetAdaptor::UBCFFSubsetReader::parseIwbGro pStrokesGroup->addToGroup(poly); } } - if (currentStroke->polygons().empty()) + if (currentStroke->polygons().empty()){ delete currentStroke; + currentStroke = NULL; + } if (pStrokesGroup->childItems().count()) mCurrentScene->addItem(pStrokesGroup); - else + else{ delete pStrokesGroup; + pStrokesGroup = NULL; + } if (pStrokesGroup) { diff --git a/src/adaptors/UBExportCFF.cpp b/src/adaptors/UBExportCFF.cpp index 3d3b94c9..ee78796c 100644 --- a/src/adaptors/UBExportCFF.cpp +++ b/src/adaptors/UBExportCFF.cpp @@ -51,10 +51,10 @@ QString UBExportCFF::exportExtention() void UBExportCFF::persist(UBDocumentProxy* pDocument) { - QString src = pDocument->persistencePath(); - if (!pDocument) return; + + QString src = pDocument->persistencePath(); QString filename = askForFileName(pDocument, tr("Export as IWB File")); @@ -82,4 +82,4 @@ void UBExportCFF::persist(UBDocumentProxy* pDocument) } -} \ No newline at end of file +} diff --git a/src/adaptors/UBImportDocument.cpp b/src/adaptors/UBImportDocument.cpp index f155385d..db88e77c 100644 --- a/src/adaptors/UBImportDocument.cpp +++ b/src/adaptors/UBImportDocument.cpp @@ -179,11 +179,7 @@ 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, "", false, addTitlePage); + UBDocumentProxy* newDocument = UBPersistenceManager::persistenceManager()->createDocumentFromDir(documentRootFolder, pGroup, "", false, false); UBApplication::showMessage(tr("Import successful.")); return newDocument; } diff --git a/src/adaptors/UBMetadataDcSubsetAdaptor.cpp b/src/adaptors/UBMetadataDcSubsetAdaptor.cpp index 676bbca8..8f59fb26 100644 --- a/src/adaptors/UBMetadataDcSubsetAdaptor.cpp +++ b/src/adaptors/UBMetadataDcSubsetAdaptor.cpp @@ -117,15 +117,6 @@ void UBMetadataDcSubsetAdaptor::persist(UBDocumentProxy* proxy) // introduced in UB 4.4 xmlWriter.writeTextElement(UBSettings::uniboardDocumentNamespaceUri, "updated-at", UBStringUtils::toUtcIsoDateTime(QDateTime::currentDateTimeUtc())); - // introduced in OpenSankore 1.40.00 - xmlWriter.writeTextElement(UBSettings::uniboardDocumentNamespaceUri,UBSettings::sessionTitle,proxy->metaData(UBSettings::sessionTitle).toString()); - xmlWriter.writeTextElement(UBSettings::uniboardDocumentNamespaceUri,UBSettings::sessionAuthors,proxy->metaData(UBSettings::sessionAuthors).toString()); - xmlWriter.writeTextElement(UBSettings::uniboardDocumentNamespaceUri,UBSettings::sessionObjectives,proxy->metaData(UBSettings::sessionObjectives).toString()); - xmlWriter.writeTextElement(UBSettings::uniboardDocumentNamespaceUri,UBSettings::sessionKeywords,proxy->metaData(UBSettings::sessionKeywords).toString()); - xmlWriter.writeTextElement(UBSettings::uniboardDocumentNamespaceUri,UBSettings::sessionGradeLevel,proxy->metaData(UBSettings::sessionGradeLevel).toString()); - xmlWriter.writeTextElement(UBSettings::uniboardDocumentNamespaceUri,UBSettings::sessionSubjects,proxy->metaData(UBSettings::sessionSubjects).toString()); - xmlWriter.writeTextElement(UBSettings::uniboardDocumentNamespaceUri,UBSettings::sessionType,proxy->metaData(UBSettings::sessionType).toString()); - xmlWriter.writeTextElement(UBSettings::uniboardDocumentNamespaceUri,UBSettings::sessionLicence,proxy->metaData(UBSettings::sessionLicence).toString()); xmlWriter.writeEndElement(); //dc:Description xmlWriter.writeEndElement(); //RDF @@ -226,47 +217,6 @@ QMap UBMetadataDcSubsetAdaptor::load(QString pPath) metadata.insert(UBSettings::documentUpdatedAt, xml.readElementText()); updatedAtFound = true; } - else if (xml.name() == UBSettings::sessionTitle // introduced in OpenSankore 1.40.00 - && xml.namespaceUri() == UBSettings::uniboardDocumentNamespaceUri) - { - metadata.insert(UBSettings::sessionTitle, xml.readElementText()); - } - else if (xml.name() == UBSettings::sessionAuthors // introduced in OpenSankore 1.40.00 - && xml.namespaceUri() == UBSettings::uniboardDocumentNamespaceUri) - { - metadata.insert(UBSettings::sessionAuthors, xml.readElementText()); - } - else if (xml.name() == UBSettings::sessionObjectives // introduced in OpenSankore 1.40.00 - && xml.namespaceUri() == UBSettings::uniboardDocumentNamespaceUri) - { - metadata.insert(UBSettings::sessionObjectives, xml.readElementText()); - } - else if (xml.name() == UBSettings::sessionKeywords // introduced in OpenSankore 1.40.00 - && xml.namespaceUri() == UBSettings::uniboardDocumentNamespaceUri) - { - metadata.insert(UBSettings::sessionKeywords, xml.readElementText()); - } - else if (xml.name() == UBSettings::sessionGradeLevel // introduced in OpenSankore 1.40.00 - && xml.namespaceUri() == UBSettings::uniboardDocumentNamespaceUri) - { - metadata.insert(UBSettings::sessionGradeLevel, xml.readElementText()); - } - else if (xml.name() == UBSettings::sessionSubjects // introduced in OpenSankore 1.40.00 - && xml.namespaceUri() == UBSettings::uniboardDocumentNamespaceUri) - { - metadata.insert(UBSettings::sessionSubjects, xml.readElementText()); - } - else if (xml.name() == UBSettings::sessionType // introduced in OpenSankore 1.40.00 - && xml.namespaceUri() == UBSettings::uniboardDocumentNamespaceUri) - { - metadata.insert(UBSettings::sessionType, xml.readElementText()); - } - else if (xml.name() == UBSettings::sessionLicence // introduced in OpenSankore 1.40.00 - && xml.namespaceUri() == UBSettings::uniboardDocumentNamespaceUri) - { - metadata.insert(UBSettings::sessionLicence, xml.readElementText()); - } - metadata.insert(UBSettings::documentVersion, docVersion); } diff --git a/src/adaptors/UBSvgSubsetAdaptor.cpp b/src/adaptors/UBSvgSubsetAdaptor.cpp index 546c6ed0..de2f1a3e 100644 --- a/src/adaptors/UBSvgSubsetAdaptor.cpp +++ b/src/adaptors/UBSvgSubsetAdaptor.cpp @@ -63,11 +63,6 @@ #include "core/UBPersistenceManager.h" #include "core/UBApplication.h" -#include "gui/UBTeacherGuideWidget.h" -#include "gui/UBDockTeacherGuideWidget.h" - -#include "interfaces/IDataStorage.h" - #include "document/UBDocumentContainer.h" #include "pdf/PDFRenderer.h" @@ -92,8 +87,6 @@ const QString tStrokeGroup = "strokeGroup"; const QString tGroups = "groups"; const QString aId = "id"; -QMap UBSvgSubsetAdaptor::additionalElementToStore; - QString UBSvgSubsetAdaptor::toSvgTransform(const QMatrix& matrix) { return QString("matrix(%1, %2, %3, %4, %5, %6)") @@ -228,17 +221,6 @@ void UBSvgSubsetAdaptor::setSceneUuid(UBDocumentProxy* proxy, const int pageInde } } -bool UBSvgSubsetAdaptor::addElementToBeStored(QString domName, IDataStorage *dataStorageClass) -{ - if(domName.isEmpty() || additionalElementToStore.contains(domName)){ - qWarning() << "Error adding the element that should persist"; - return false; - } - - additionalElementToStore.insert(domName,dataStorageClass); - return true; -} - QString UBSvgSubsetAdaptor::uniboardDocumentNamespaceUriFromVersion(int mFileVersion) { return mFileVersion >= 40200 ? UBSettings::uniboardDocumentNamespaceUri : sFormerUniboardDocumentNamespaceUri; @@ -323,54 +305,6 @@ UBGraphicsScene* UBSvgSubsetAdaptor::loadScene(UBDocumentProxy* proxy, const QBy return reader.loadScene(); } - -QString UBSvgSubsetAdaptor::readTeacherGuideNode(int sceneIndex) -{ - QString result; - - QString fileName = UBApplication::boardController->selectedDocument()->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.svg", sceneIndex); - QFile file(fileName); - file.open(QIODevice::ReadOnly); - QByteArray fileByteArray=file.readAll(); - file.close(); - QXmlStreamReader mXmlReader(fileByteArray); - - while (!mXmlReader.atEnd()) - { - mXmlReader.readNext(); - if (mXmlReader.isStartElement()) - { - if (mXmlReader.name() == "teacherBar" || mXmlReader.name() == "teacherGuide"){ - result.clear(); - result += ""; - result += "\n"; - } - else if (mXmlReader.name() == "media" || mXmlReader.name() == "link" || mXmlReader.name() == "title" || mXmlReader.name() == "comment" || mXmlReader.name() == "action") - { - result += "<" + mXmlReader.name().toString() + " "; - foreach(QXmlStreamAttribute attribute, mXmlReader.attributes()) - result += attribute.name().toString() + "=\"" + attribute.value().toString() + "\" "; - result += " />\n"; - } - else - { - // NOOP - } - } - else if (mXmlReader.isEndElement() && (mXmlReader.name() == "teacherBar" || mXmlReader.name() == "teacherGuide")){ - result += ""; - } - } - - if (mXmlReader.hasError()) - { - qWarning() << "error parsing Sankore file " << mXmlReader.errorString(); - } - - return result; -} - - UBSvgSubsetAdaptor::UBSvgSubsetReader::UBSvgSubsetReader(UBDocumentProxy* pProxy, const QByteArray& pXmlData) : mXmlReader(pXmlData) , mProxy(pProxy) @@ -1070,7 +1004,8 @@ void UBSvgSubsetAdaptor::UBSvgSubsetWriter::writeSvgElement() bool UBSvgSubsetAdaptor::UBSvgSubsetWriter::persistScene(int pageIndex) { - if (mScene->isModified() || (UBApplication::boardController->paletteManager()->teacherGuideDockWidget() && UBApplication::boardController->paletteManager()->teacherGuideDockWidget()->teacherGuideWidget()->isModified())) + Q_UNUSED(pageIndex); + if (mScene->isModified()) { //Creating dom structure to store information @@ -1108,7 +1043,6 @@ bool UBSvgSubsetAdaptor::UBSvgSubsetWriter::persistScene(int pageIndex) qSort(items.begin(), items.end(), itemZIndexComp); UBGraphicsStroke *openStroke = 0; - int nextStroke = 0; bool groupHoldsInfo = false; @@ -1121,32 +1055,12 @@ bool UBSvgSubsetAdaptor::UBSvgSubsetWriter::persistScene(int pageIndex) if(strokesGroupItem && strokesGroupItem->isVisible()){ // Add the polygons - //parsing number of polygons into one polygon - qDebug() << "parsing stroke number" << nextStroke++; - UBGraphicsPolygonItem *resultPoly = 0; - - foreach(QGraphicsItem* item, strokesGroupItem->childItems()) { + foreach(QGraphicsItem* item, strokesGroupItem->childItems()){ UBGraphicsPolygonItem* poly = qgraphicsitem_cast(item); - if (!poly) - continue; - if (!resultPoly) { - resultPoly = poly; - continue; + if(NULL != poly){ + polygonItemToSvgPolygon(poly, true); + items.removeOne(poly); } - - QPolygonF unitedPolygon = resultPoly->polygon().united(poly->polygon()); - resultPoly->setPolygon(unitedPolygon); - items.removeOne(poly); - } - if (resultPoly) { - resultPoly->setZValue(strokesGroupItem->zValue()); - //Claudio: the painter path simplification remove all the polygons overlap - QPainterPath painterPath; - painterPath.addPolygon(resultPoly->polygon()); - painterPath = painterPath.simplified(); - resultPoly->setPolygon(painterPath.toFillPolygon()); - polygonItemToSvgPolygon(resultPoly, false); - items.removeOne(resultPoly); } } @@ -1347,29 +1261,6 @@ bool UBSvgSubsetAdaptor::UBSvgSubsetWriter::persistScene(int pageIndex) openStroke = 0; } - QMap elements = getAdditionalElementToStore(); - QVector dataStorageItems; - - if(elements.value("teacherGuide")) - dataStorageItems = elements.value("teacherGuide")->save(pageIndex); - foreach(tIDataStorage* eachItem, dataStorageItems){ - if(eachItem->type == eElementType_START){ - mXmlWriter.writeStartElement(eachItem->name); - foreach(QString key,eachItem->attributes.keys()) - mXmlWriter.writeAttribute(key,eachItem->attributes.value(key)); - } - else if (eachItem->type == eElementType_END) - mXmlWriter.writeEndElement(); - else if (eachItem->type == eElementType_UNIQUE){ - mXmlWriter.writeStartElement(eachItem->name); - foreach(QString key,eachItem->attributes.keys()) - mXmlWriter.writeAttribute(key,eachItem->attributes.value(key)); - mXmlWriter.writeEndElement(); - } - else - qWarning() << "unknown type"; - } - //writing group data if (groupRoot.hasChildNodes()) { mXmlWriter.writeStartElement(tGroups); @@ -1423,18 +1314,16 @@ void UBSvgSubsetAdaptor::UBSvgSubsetWriter::persistGroupToDom(QGraphicsItem *gro QDomElement curGroupElement = groupDomDocument->createElement(tGroup); curGroupElement.setAttribute(aId, uuid); curParent->appendChild(curGroupElement); - foreach (QGraphicsItem *item, groupItem->childItems()) { QUuid tmpUuid = UBGraphicsScene::getPersonalUuid(item); if (!tmpUuid.isNull()) { if (item->type() == UBGraphicsGroupContainerItem::Type && item->childItems().count()) persistGroupToDom(item, curParent, groupDomDocument); - } - else { - QDomElement curSubElement = groupDomDocument->createElement(tElement); - - curSubElement.setAttribute(aId, tmpUuid); - curGroupElement.appendChild(curSubElement); + else { + QDomElement curSubElement = groupDomDocument->createElement(tElement); + curSubElement.setAttribute(aId, tmpUuid); + curGroupElement.appendChild(curSubElement); + } } } } @@ -1553,7 +1442,7 @@ void UBSvgSubsetAdaptor::UBSvgSubsetWriter::polygonItemToSvgPolygon(UBGraphicsPo QPolygonF polygon = polygonItem->polygon(); int pointsCount = polygon.size(); - if (polygonItem && pointsCount > 0) + if (pointsCount > 0) { mXmlWriter.writeStartElement("polygon"); @@ -2264,8 +2153,14 @@ void UBSvgSubsetAdaptor::UBSvgSubsetReader::graphicsItemFromSvg(QGraphicsItem* g QStringRef ubZValue = mXmlReader.attributes().value(mNamespaceUri, "z-value"); - if (!ubZValue.isNull()) - UBGraphicsItem::assignZValue(gItem, ubZValue.toString().toFloat()); + if (!ubZValue.isNull()){ + // FIX + // In the firsts zvalue implemenations values outside the boudaries have been used. + // No boundaries specified on documentation but to small values are not correctly handled. + qreal zValue = ubZValue.toString().toFloat(); + while(zValue < -999999) zValue /= 10.; + UBGraphicsItem::assignZValue(gItem, zValue); + } UBItem* ubItem = dynamic_cast(gItem); diff --git a/src/adaptors/UBSvgSubsetAdaptor.h b/src/adaptors/UBSvgSubsetAdaptor.h index cd241d7e..bff53db9 100644 --- a/src/adaptors/UBSvgSubsetAdaptor.h +++ b/src/adaptors/UBSvgSubsetAdaptor.h @@ -48,7 +48,6 @@ class UBGraphicsStroke; class UBPersistenceManager; class UBGraphicsTriangle; class UBGraphicsCache; -class IDataStorage; class UBGraphicsGroupContainerItem; class UBGraphicsStrokesGroup; @@ -68,13 +67,9 @@ class UBSvgSubsetAdaptor static QUuid sceneUuid(UBDocumentProxy* proxy, const int pageIndex); static void setSceneUuid(UBDocumentProxy* proxy, const int pageIndex, QUuid pUuid); - static bool addElementToBeStored(QString domName,IDataStorage* dataStorageClass); - static void convertPDFObjectsToImages(UBDocumentProxy* proxy); static void convertSvgImagesToImages(UBDocumentProxy* proxy); - static QMap getAdditionalElementToStore() { return additionalElementToStore;} - static const QString nsSvg; static const QString nsXLink; static const QString nsXHtml; @@ -101,10 +96,6 @@ class UBSvgSubsetAdaptor static QString toSvgTransform(const QMatrix& matrix); static QMatrix fromSvgTransform(const QString& transform); - static QMap additionalElementToStore; - - - class UBSvgSubsetReader { diff --git a/src/adaptors/UBThumbnailAdaptor.cpp b/src/adaptors/UBThumbnailAdaptor.cpp index 97c53852..a3b83791 100644 --- a/src/adaptors/UBThumbnailAdaptor.cpp +++ b/src/adaptors/UBThumbnailAdaptor.cpp @@ -31,10 +31,6 @@ #include "core/UBApplication.h" #include "core/UBSettings.h" - -#include "gui/UBDockTeacherGuideWidget.h" -#include "gui/UBTeacherGuideWidget.h" - #include "board/UBBoardController.h" #include "board/UBBoardPaletteManager.h" @@ -104,20 +100,8 @@ const QPixmap* UBThumbnailAdaptor::get(UBDocumentProxy* proxy, int pageIndex) return pix; } -void UBThumbnailAdaptor::updateDocumentToHandleZeroPage(UBDocumentProxy* proxy) -{ - if(UBSettings::settings()->teacherGuidePageZeroActivated->get().toBool()){ - QString fileName = proxy->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.svg", 0); - QFile file(fileName); - if(!file.exists()){ - UBPersistenceManager::persistenceManager()->persistDocumentScene(proxy,new UBGraphicsScene(proxy),0); - } - } -} - void UBThumbnailAdaptor::load(UBDocumentProxy* proxy, QList& list) { - updateDocumentToHandleZeroPage(proxy); generateMissingThumbnails(proxy); foreach(const QPixmap* pm, list){ @@ -135,7 +119,7 @@ void UBThumbnailAdaptor::persistScene(UBDocumentProxy* proxy, UBGraphicsScene* p QFile thumbFile(fileName); - if (pScene->isModified() || overrideModified || !thumbFile.exists() || UBApplication::boardController->paletteManager()->teacherGuideDockWidget()->teacherGuideWidget()->isModified()) + if (pScene->isModified() || overrideModified || !thumbFile.exists()) { qreal nominalWidth = pScene->nominalSize().width(); qreal nominalHeight = pScene->nominalSize().height(); @@ -167,12 +151,6 @@ void UBThumbnailAdaptor::persistScene(UBDocumentProxy* proxy, UBGraphicsScene* p pScene->render(&painter, imageRect, sceneRect, Qt::KeepAspectRatio); - if(UBApplication::boardController->paletteManager()->teacherGuideDockWidget() && 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); diff --git a/src/adaptors/UBThumbnailAdaptor.h b/src/adaptors/UBThumbnailAdaptor.h index 88c39bf7..92e03f13 100644 --- a/src/adaptors/UBThumbnailAdaptor.h +++ b/src/adaptors/UBThumbnailAdaptor.h @@ -44,7 +44,6 @@ public: private: static void generateMissingThumbnails(UBDocumentProxy* proxy); - static void updateDocumentToHandleZeroPage(UBDocumentProxy* proxy); UBThumbnailAdaptor() {} }; diff --git a/src/adaptors/UBWebPublisher.cpp b/src/adaptors/UBWebPublisher.cpp deleted file mode 100644 index a979515a..00000000 --- a/src/adaptors/UBWebPublisher.cpp +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (C) 2010-2013 Groupement d'Intérêt Public pour l'Education Numérique en Afrique (GIP ENA) - * - * This file is part of Open-Sankoré. - * - * Open-Sankoré 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, version 3 of the License, - * with a specific linking exception for the OpenSSL project's - * "OpenSSL" library (or with modified versions of it that use the - * same license as the "OpenSSL" library). - * - * Open-Sankoré 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 Open-Sankoré. If not, see . - */ - - - -#include "UBWebPublisher.h" - -#include "document/UBDocumentProxy.h" - -#include "adaptors/publishing/UBDocumentPublisher.h" - -#include "core/memcheck.h" - -UBWebPublisher::UBWebPublisher(QObject *parent) - : UBExportAdaptor(parent) -{ - // NOOP -} - - -UBWebPublisher::~UBWebPublisher() -{ - // NOOP -} - - -QString UBWebPublisher::exportName() -{ - return tr("Publish Document on Sankore Web"); -} - - -void UBWebPublisher::persist(UBDocumentProxy* pDocumentProxy) -{ - if (!pDocumentProxy) - return; - - UBDocumentPublisher* publisher = new UBDocumentPublisher(pDocumentProxy, this); // the publisher will self delete when publication finishes - publisher->publish(); - -} - - diff --git a/src/adaptors/UBWebPublisher.h b/src/adaptors/UBWebPublisher.h deleted file mode 100644 index 99409373..00000000 --- a/src/adaptors/UBWebPublisher.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (C) 2010-2013 Groupement d'Intérêt Public pour l'Education Numérique en Afrique (GIP ENA) - * - * This file is part of Open-Sankoré. - * - * Open-Sankoré 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, version 3 of the License, - * with a specific linking exception for the OpenSSL project's - * "OpenSSL" library (or with modified versions of it that use the - * same license as the "OpenSSL" library). - * - * Open-Sankoré 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 Open-Sankoré. If not, see . - */ - - - -#ifndef UBWEBPUBLISHER_H_ -#define UBWEBPUBLISHER_H_ - -#include - -#include "UBExportAdaptor.h" - -#include "frameworks/UBFileSystemUtils.h" -#include "ui_webPublishing.h" - -class UBDocumentProxy; -class UBServerXMLHttpRequest; - -class UBWebPublisher : public UBExportAdaptor -{ - Q_OBJECT; - - public: - UBWebPublisher(QObject *parent = 0); - virtual ~UBWebPublisher(); - - virtual QString exportName(); - - virtual void persist(UBDocumentProxy* pDocument); -}; - - -#endif /* UBWEBPUBLISHER_H_ */ diff --git a/src/adaptors/adaptors.pri b/src/adaptors/adaptors.pri index 4fc92ce9..33e7ba16 100644 --- a/src/adaptors/adaptors.pri +++ b/src/adaptors/adaptors.pri @@ -12,7 +12,6 @@ HEADERS += src/adaptors/UBExportAdaptor.h\ src/adaptors/UBImportImage.h \ src/adaptors/UBIniFileParser.h \ src/adaptors/UBExportWeb.h \ - src/adaptors/UBWebPublisher.h \ src/adaptors/UBImportCFF.h \ src/adaptors/UBExportCFF.h \ src/adaptors/UBCFFSubsetAdaptor.h @@ -35,7 +34,6 @@ SOURCES += src/adaptors/UBExportAdaptor.cpp\ src/adaptors/UBImportImage.cpp \ src/adaptors/UBIniFileParser.cpp \ src/adaptors/UBExportWeb.cpp \ - src/adaptors/UBWebPublisher.cpp \ src/adaptors/UBImportCFF.cpp \ src/adaptors/UBExportCFF.cpp \ src/adaptors/UBCFFSubsetAdaptor.cpp \ diff --git a/src/adaptors/publishing/UBDocumentPublisher.cpp b/src/adaptors/publishing/UBDocumentPublisher.cpp index 4edeffdf..19c34b5e 100644 --- a/src/adaptors/publishing/UBDocumentPublisher.cpp +++ b/src/adaptors/publishing/UBDocumentPublisher.cpp @@ -21,645 +21,9 @@ -#include - #include "UBDocumentPublisher.h" -#include "frameworks/UBPlatformUtils.h" -#include "frameworks/UBFileSystemUtils.h" -#include "frameworks/UBStringUtils.h" - -#include "network/UBNetworkAccessManager.h" -#include "network/UBServerXMLHttpRequest.h" - -#include "core/UBDocumentManager.h" -#include "core/UBApplication.h" -#include "core/UBPersistenceManager.h" -#include "core/UBApplicationController.h" - -#include "board/UBBoardController.h" - -#include "gui/UBMainWindow.h" - -#include "document/UBDocumentProxy.h" -#include "document/UBDocumentContainer.h" - -#include "domain/UBGraphicsWidgetItem.h" - -#include "globals/UBGlobals.h" - -THIRD_PARTY_WARNINGS_DISABLE -#include "quazip.h" -#include "quazipfile.h" -THIRD_PARTY_WARNINGS_ENABLE - -#include "adaptors/UBExportFullPDF.h" -#include "adaptors/UBExportDocument.h" -#include "adaptors/UBSvgSubsetAdaptor.h" - -#include "UBSvgSubsetRasterizer.h" - -#include "../../core/UBApplication.h" - -#include "core/memcheck.h" - - -UBDocumentPublisher::UBDocumentPublisher(UBDocumentProxy* pDocument, QObject *parent) - : QObject(parent) - , mSourceDocument(pDocument) - , mUsername("") - , mPassword("") - , bLoginCookieSet(false) -{ - init(); -} - - -UBDocumentPublisher::~UBDocumentPublisher() -{ -} - - -void UBDocumentPublisher::publish() -{ - //check that the username and password are stored on preferences - UBSettings* settings = UBSettings::settings(); - - if(settings->communityUsername().isEmpty() || settings->communityPassword().isEmpty()){ - UBApplication::showMessage(tr("Credentials has to not been filled out yet.")); - qDebug() << "trying to connect to community without the required credentials"; - return; - } - - mUsername = settings->communityUsername(); - mPassword = settings->communityPassword(); - - UBPublicationDlg dlg; - if(QDialog::Accepted == dlg.exec()) - { - mDocInfos.title = dlg.title(); - mDocInfos.description = dlg.description(); - - buildUbwFile(); - - UBApplication::showMessage(tr("Uploading Sankore File on Web.")); - - sendUbw(mUsername, mPassword); - } -} - -void UBDocumentPublisher::buildUbwFile() -{ - QDir d; - d.mkpath(UBFileSystemUtils::defaultTempDirPath()); - - QString tmpDir = UBFileSystemUtils::createTempDir(); - - if (UBFileSystemUtils::copyDir(mSourceDocument->persistencePath(), tmpDir)) - { - QString documentName = mSourceDocument->name(); - - mPublishingPath = tmpDir; - mPublishingSize = mSourceDocument->pageCount(); - - rasterizeScenes(); - - upgradeDocumentForPublishing(); - - UBExportFullPDF pdfExporter; - pdfExporter.setVerbode(false); - pdfExporter.persistsDocument(mSourceDocument, mPublishingPath + "/" + documentName + ".pdf"); - - UBExportDocument ubzExporter; - ubzExporter.setVerbode(false); - ubzExporter.persistsDocument(mSourceDocument, mPublishingPath + "/" + documentName + ".ubz"); - - // remove all useless files - - for (int pageIndex = 0; pageIndex < mPublishingSize; pageIndex++) { - QString filename = mPublishingPath + UBFileSystemUtils::digitFileFormat("/page%1.svg",pageIndex); - - QFile::remove(filename); - } - - UBFileSystemUtils::deleteDir(mPublishingPath + "/" + UBPersistenceManager::imageDirectory); - UBFileSystemUtils::deleteDir(mPublishingPath + "/" + UBPersistenceManager::objectDirectory); - UBFileSystemUtils::deleteDir(mPublishingPath + "/" + UBPersistenceManager::videoDirectory); - UBFileSystemUtils::deleteDir(mPublishingPath + "/" + UBPersistenceManager::audioDirectory); - - mTmpZipFile = UBFileSystemUtils::defaultTempDirPath() + "/" + UBStringUtils::toCanonicalUuid(QUuid::createUuid()) + ".ubw~"; - - QuaZip zip(mTmpZipFile); - zip.setFileNameCodec("UTF-8"); - if (!zip.open(QuaZip::mdCreate)) - { - qWarning() << "Export failed. Cause: zip.open(): " << zip.getZipError() << "," << mTmpZipFile; - QApplication::restoreOverrideCursor(); - return; - } - - QuaZipFile outFile(&zip); - - if (!UBFileSystemUtils::compressDirInZip(mPublishingPath, "", &outFile, true)) - { - qWarning("Export failed. compressDirInZip failed ..."); - zip.close(); - UBApplication::showMessage(tr("Export failed.")); - QApplication::restoreOverrideCursor(); - return; - } - - if (zip.getZipError() != 0) - { - qWarning("Export failed. Cause: zip.close(): %d", zip.getZipError()); - zip.close(); - UBApplication::showMessage(tr("Export failed.")); - QApplication::restoreOverrideCursor(); - return; - } - - zip.close(); - - } - else - { - UBApplication::showMessage(tr("Export canceled ...")); - QApplication::restoreOverrideCursor(); - } -} - -void UBDocumentPublisher::rasterizeScenes() -{ - - for (int pageIndex = 0; pageIndex < mPublishingSize; pageIndex++) - { - UBApplication::showMessage(tr("Converting page %1/%2 ...").arg(UBDocumentContainer::pageFromSceneIndex(pageIndex)).arg(mPublishingSize), true); - - UBDocumentProxy publishingDocument(mPublishingPath); - UBSvgSubsetRasterizer rasterizer(&publishingDocument, pageIndex); - - QString filename = mPublishingPath + UBFileSystemUtils::digitFileFormat("/page%1.jpg",pageIndex); - - rasterizer.rasterizeToFile(filename); - - } -} - - -void UBDocumentPublisher::updateGoogleMapApiKey() -{ - QDir widgestDir(mPublishingPath + "/" + UBPersistenceManager::widgetDirectory); - - QString uniboardWebGoogleMapApiKey = UBSettings::settings()->uniboardWebGoogleMapApiKey->get().toString(); - - foreach(QFileInfo dirInfo, widgestDir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot)) - { - QString config = UBFileSystemUtils::readTextFile(dirInfo.absoluteFilePath() + "/config.xml").toLower(); - - if (config.contains("google") && config.contains("map")) - { - QDir widgetDir(dirInfo.absoluteFilePath()); - - foreach(QFileInfo fileInfo, widgetDir.entryInfoList(QDir::Files | QDir::NoDotAndDotDot)) - { - QFile file(fileInfo.absoluteFilePath()); - - if (file.open(QIODevice::ReadWrite)) - { - QTextStream stream(&file); - QString content = stream.readAll(); - - if (content.contains("ABQIAAAA6vtVqAUu8kZ_eTz7c8kwSBT9UCAhw_xm0LNFHsWmQxTJAdp5lxSY_5r-lZriY_7sACaMnl80JcX6Og")) - { - content.replace("ABQIAAAA6vtVqAUu8kZ_eTz7c8kwSBT9UCAhw_xm0LNFHsWmQxTJAdp5lxSY_5r-lZriY_7sACaMnl80JcX6Og", - uniboardWebGoogleMapApiKey); - - file.resize(0); - file.write(content.toUtf8()); - } - file.close(); - } - } - } - } -} - - -void UBDocumentPublisher::upgradeDocumentForPublishing() -{ - for (int pageIndex = 0; pageIndex < mPublishingSize; pageIndex++) - { - UBDocumentProxy publishingDocument(mPublishingPath); - UBGraphicsScene *scene = UBSvgSubsetAdaptor::loadScene(&publishingDocument, pageIndex); - - QList widgets; - - foreach(QGraphicsItem* item, scene->items()){ - UBGraphicsW3CWidgetItem *widgetItem = dynamic_cast(item); - - if(widgetItem){ - generateWidgetPropertyScript(widgetItem, UBDocumentContainer::pageFromSceneIndex(pageIndex)); - widgets << widgetItem; - } - } - - QString filename = mPublishingPath + UBFileSystemUtils::digitFileFormat("/page%1.json",pageIndex); - - QFile jsonFile(filename); - if (jsonFile.open(QIODevice::WriteOnly | QIODevice::Truncate)) - { - jsonFile.write("{\n"); - jsonFile.write(QString(" \"scene\": {\n").toUtf8()); - jsonFile.write(QString(" \"x\": %1,\n").arg(scene->normalizedSceneRect().x()).toUtf8()); - jsonFile.write(QString(" \"y\": %1,\n").arg(scene->normalizedSceneRect().y()).toUtf8()); - jsonFile.write(QString(" \"width\": %1,\n").arg(scene->normalizedSceneRect().width()).toUtf8()); - jsonFile.write(QString(" \"height\": %1\n").arg(scene->normalizedSceneRect().height()).toUtf8()); - jsonFile.write(QString(" },\n").toUtf8()); - - jsonFile.write(QString(" \"widgets\": [\n").toUtf8()); - - bool first = true; - - foreach(UBGraphicsW3CWidgetItem* widget, widgets) - { - if (!first) - jsonFile.write(QString(" ,\n").toUtf8()); - jsonFile.write(QString(" {\n").toUtf8()); - jsonFile.write(QString(" \"uuid\": \"%1\",\n").arg(UBStringUtils::toCanonicalUuid(widget->uuid())).toUtf8()); - jsonFile.write(QString(" \"id\": \"%1\",\n").arg(widget->metadatas().id).toUtf8()); - - jsonFile.write(QString(" \"name\": \"%1\",\n").arg(widget->metadatas().name).toUtf8()); - jsonFile.write(QString(" \"description\": \"%1\",\n").arg(widget->metadatas().description).toUtf8()); - jsonFile.write(QString(" \"author\": \"%1\",\n").arg(widget->metadatas().author).toUtf8()); - jsonFile.write(QString(" \"authorEmail\": \"%1\",\n").arg(widget->metadatas().authorEmail).toUtf8()); - jsonFile.write(QString(" \"authorHref\": \"%1\",\n").arg(widget->metadatas().authorHref).toUtf8()); - jsonFile.write(QString(" \"version\": \"%1\",\n").arg(widget->metadatas().authorHref).toUtf8()); - - jsonFile.write(QString(" \"x\": %1,\n").arg(widget->sceneBoundingRect().x()).toUtf8()); - jsonFile.write(QString(" \"y\": %1,\n").arg(widget->sceneBoundingRect().y()).toUtf8()); - jsonFile.write(QString(" \"width\": %1,\n").arg(widget->sceneBoundingRect().width()).toUtf8()); - jsonFile.write(QString(" \"height\": %1,\n").arg(widget->sceneBoundingRect().height()).toUtf8()); - - jsonFile.write(QString(" \"nominalWidth\": %1,\n").arg(widget->boundingRect().width()).toUtf8()); - jsonFile.write(QString(" \"nominalHeight\": %1,\n").arg(widget->boundingRect().height()).toUtf8()); - - QString url = UBPersistenceManager::widgetDirectory + "/" + widget->uuid().toString() + ".wgt"; - jsonFile.write(QString(" \"src\": \"%1\",\n").arg(url).toUtf8()); - QString startFile = widget->mainHtmlFileName(); - jsonFile.write(QString(" \"startFile\": \"%1\",\n").arg(startFile).toUtf8()); - - QMap preferences = widget->UBGraphicsWidgetItem::preferences(); - - jsonFile.write(QString(" \"preferences\": {\n").toUtf8()); - - foreach(QString key, preferences.keys()) - { - QString sep = ","; - if (key == preferences.keys().last()) - sep = ""; - - jsonFile.write(QString(" \"%1\": \"%2\"%3\n") - .arg(key) - .arg(preferences.value(key)) - .arg(sep) - .toUtf8()); - } - jsonFile.write(QString(" },\n").toUtf8()); - - jsonFile.write(QString(" \"datastore\": {\n").toUtf8()); - - QMap datastoreEntries = widget->datastoreEntries(); - - foreach(QString entry, datastoreEntries.keys()) - { - QString sep = ","; - if (entry == datastoreEntries.keys().last()) - sep = ""; - - jsonFile.write(QString(" \"%1\": \"%2\"%3\n") - .arg(entry) - .arg(datastoreEntries.value(entry)) - .arg(sep) - .toUtf8()); - } - jsonFile.write(QString(" }\n").toUtf8()); - - jsonFile.write(QString(" }\n").toUtf8()); - - first = false; - } - - jsonFile.write(" ]\n"); - jsonFile.write("}\n"); - } - else - { - qWarning() << "Cannot open file" << filename << "for saving page state"; - } - - delete scene; - } - - updateGoogleMapApiKey(); -} - - -void UBDocumentPublisher::generateWidgetPropertyScript(UBGraphicsW3CWidgetItem *widgetItem, int pageNumber) -{ - - QMap preferences = widgetItem->UBGraphicsWidgetItem::preferences(); - QMap datastoreEntries = widgetItem->datastoreEntries(); - - QString startFileName = widgetItem->mainHtmlFileName(); - - if (!startFileName.startsWith("http://")) - { - QString startFilePath = mPublishingPath + "/" + UBPersistenceManager::widgetDirectory + "/" + widgetItem->uuid().toString() + ".wgt/" + startFileName; - - QFile startFile(startFilePath); - - if (startFile.exists()) - { - if (startFile.open(QIODevice::ReadWrite)) - { - QTextStream stream(&startFile); - QStringList lines; - - bool addedJs = false; - - QString line; - do - { - line = stream.readLine(); - if (!line.isNull()) - { - lines << line; - - if (!addedJs && line.contains("") ) // TODO UB 4.6, this is naive ... the HEAD tag may be on several lines - { - lines << ""; - lines << " "; - lines << ""; - - addedJs = true; - } - } - } - while (!line.isNull()); - - startFile.resize(0); - startFile.write(lines.join("\n").toUtf8()); // TODO UB 4.x detect real html encoding - - startFile.close(); - } - } - } - else{ - qWarning() << "Remote Widget start file, cannot inject widget preferences and datastore entries"; - } -} - -void UBDocumentPublisher::init() -{ - mCrlf=0x0d; - mCrlf+=0x0a; - mDocInfos.title = ""; - mDocInfos.description = ""; - - mpCookieJar = new QNetworkCookieJar(); - mpNetworkMgr = new QNetworkAccessManager(this); - - connect(mpNetworkMgr, SIGNAL(finished(QNetworkReply*)), this, SLOT(onFinished(QNetworkReply*))); -} - -void UBDocumentPublisher::onFinished(QNetworkReply *reply) -{ - QVariant cookieHeader = reply->rawHeader("Set-Cookie"); - // First we concatenate all the Set-Cookie values (the packet can contains many of them) - QStringList qslCookie = cookieHeader.toString().split("\n"); - QString qsCookieValue = qslCookie.at(0); - for (int i = 1; i < qslCookie.size(); i++) { - qsCookieValue += "; " +qslCookie.at(i); - } - - // Now we isolate every cookie value - QStringList qslCookieVals = qsCookieValue.split("; "); - - bool bTransferOk = false; - - for(int j = 0; j < qslCookieVals.size(); j++) - { - qDebug() << j; - if(qslCookieVals.at(j).startsWith("assetStatus")) - { - QStringList qslAsset = qslCookieVals.at(j).split("="); - if(qslAsset.at(1) == "UPLOADED") - { - bTransferOk = true; - break; - } - } - } - - if(bTransferOk) - { - UBApplication::showMessage(tr("Document uploaded correctly on the web.")); - } - else - { - UBApplication::showMessage(tr("Failed to upload document on the web.")); - } - - reply->deleteLater(); -} - -void UBDocumentPublisher::sendUbw(QString username, QString password) -{ - if (QFile::exists(mTmpZipFile)) - { - QFile f(mTmpZipFile); - if (f.open(QIODevice::ReadOnly)) - { - QFileInfo fi(f); - QByteArray ba = f.readAll(); - QString boundary,data, multipartHeader; - QByteArray datatoSend; - - boundary = "---WebKitFormBoundaryDKBTgA53MiyWrzLY"; - multipartHeader = "multipart/form-data; boundary="+boundary; - - data="--"+boundary+mCrlf; - data+="Content-Disposition: form-data; name=\"title\"" + mCrlf + mCrlf + mDocInfos.title + mCrlf; - data+="--"+boundary+mCrlf; - data+="Content-Disposition: form-data; name=\"description\"" + mCrlf + mCrlf + mDocInfos.description.remove("\n") + mCrlf; - data+="--"+boundary+mCrlf; - data+="Content-Disposition: form-data; name=\"file\"; filename=\""+ fi.fileName() +"\""+mCrlf; - data+="Content-Type: application/octet-stream"+mCrlf+mCrlf; - datatoSend=data.toAscii(); // convert data string to byte array for request - datatoSend += ba; - datatoSend += mCrlf; - datatoSend += QString("--%0--%1").arg(boundary).arg(mCrlf); - - QNetworkRequest request(QUrl(QString(DOCPUBLICATION_URL).toAscii().constData())); - - request.setHeader(QNetworkRequest::ContentTypeHeader, multipartHeader); - request.setHeader(QNetworkRequest::ContentLengthHeader,datatoSend.size()); - QString b64Auth = getBase64Of(QString("%0:%1").arg(username).arg(password)); - request.setRawHeader("Authorization", QString("Basic %0").arg(b64Auth).toAscii().constData()); - request.setRawHeader("Host", "planete.sankore.org"); - request.setRawHeader("Accept", "*/*"); - request.setRawHeader("Accept-Language", "en-US,*"); - - mpCookieJar->setCookiesFromUrl(mCookies, QUrl(DOCPUBLICATION_URL)); - mpNetworkMgr->setCookieJar(mpCookieJar); - - // Send the file - mpNetworkMgr->post(request,datatoSend); - } - } -} - -QString UBDocumentPublisher::getBase64Of(QString stringToEncode) -{ - return stringToEncode.toAscii().toBase64(); -} - -// --------------------------------------------------------- UBProxyLoginDlg::UBProxyLoginDlg(QWidget *parent, const char *name):QDialog(parent) , mpLayout(NULL) , mpUserLayout(NULL) diff --git a/src/adaptors/publishing/UBDocumentPublisher.h b/src/adaptors/publishing/UBDocumentPublisher.h index 5e8768bf..fbcb128a 100644 --- a/src/adaptors/publishing/UBDocumentPublisher.h +++ b/src/adaptors/publishing/UBDocumentPublisher.h @@ -27,10 +27,6 @@ #include #include -#include "ui_webPublishing.h" - -#define DOCPUBLICATION_URL "http://planete.sankore.org/xwiki/bin/view/CreateResources/UniboardUpload?xpage=plain&outputSyntax=plain" - typedef struct { QString title; @@ -85,58 +81,4 @@ private: QTextEdit* mpDescription; QDialogButtonBox* mpButtons; }; - - -class UBDocumentPublisher : public QObject -{ - Q_OBJECT; - -public: - explicit UBDocumentPublisher(UBDocumentProxy* sourceDocument, QObject *parent = 0); - virtual ~UBDocumentPublisher(); - - void publish(); - -signals: - - void loginDone(); - -protected: - - virtual void updateGoogleMapApiKey(); - virtual void rasterizeScenes(); - virtual void upgradeDocumentForPublishing(); - virtual void generateWidgetPropertyScript(UBGraphicsW3CWidgetItem *widgetItem, int pageNumber); - -private slots: - - void onFinished(QNetworkReply* reply); - -private: - - UBDocumentProxy *mSourceDocument; - - //UBDocumentProxy *mPublishingDocument; - QString mPublishingPath; - int mPublishingSize; - - - void init(); - void sendUbw(QString username, QString password); - QString getBase64Of(QString stringToEncode); - - QHBoxLayout* mpLayout; - QNetworkAccessManager* mpNetworkMgr; - QNetworkCookieJar* mpCookieJar; - QString mUsername; - QString mPassword; - QString mCrlf; - bool bLoginCookieSet; - - void buildUbwFile(); - QString mTmpZipFile; - QList mCookies; - sDocumentInfos mDocInfos; - -}; #endif // UBDOCUMENTPUBLISHER_H diff --git a/src/board/UBBoardController.cpp b/src/board/UBBoardController.cpp index d9f2bcc8..47d4ec08 100644 --- a/src/board/UBBoardController.cpp +++ b/src/board/UBBoardController.cpp @@ -48,8 +48,6 @@ #include "gui/UBKeyboardPalette.h" #include "gui/UBMagnifer.h" #include "gui/UBDockPaletteWidget.h" -#include "gui/UBDockTeacherGuideWidget.h" -#include "gui/UBTeacherGuideWidget.h" #include "domain/UBGraphicsPixmapItem.h" #include "domain/UBGraphicsItemUndoCommand.h" @@ -166,8 +164,6 @@ UBBoardController::~UBBoardController() int UBBoardController::currentPage() { - if(UBSettings::settings()->teacherGuidePageZeroActivated->get().toBool()) - return mActiveSceneIndex; return mActiveSceneIndex + 1; } @@ -340,7 +336,6 @@ void UBBoardController::setupToolbar() //-----------------------------------------------------------// UBApplication::app()->insertSpaceToToolbarBeforeAction(mMainWindow->boardToolBar, mMainWindow->actionBoard); - UBApplication::app()->insertSpaceToToolbarBeforeAction(mMainWindow->tutorialToolBar, mMainWindow->actionBoard); UBApplication::app()->decorateActionMenu(mMainWindow->actionMenu); @@ -348,7 +343,6 @@ void UBBoardController::setupToolbar() mMainWindow->webToolBar->hide(); mMainWindow->documentToolBar->hide(); - mMainWindow->tutorialToolBar->hide(); connectToolbar(); initToolbarTexts(); @@ -1559,66 +1553,74 @@ void UBBoardController::moveSceneToIndex(int source, int target) } } +void UBBoardController::fitUniqIems(const QUndoCommand *parent, QSet &itms) +{ + if (parent->childCount()) { + for (int i = 0; i < parent->childCount(); i++) { + fitUniqIems(parent->child(i), itms); + } + } + + // Undo command transaction macros. Process separatedly + if (parent->text() == UBSettings::undoCommandTransactionName) { + return; + } + + const UBAbstractUndoCommand *abstractCmd = static_cast(parent); + if(abstractCmd->getType() != UBAbstractUndoCommand::undotype_GRAPHICITEM) + return; + + const UBGraphicsItemUndoCommand *cmd = static_cast(parent); + + // go through all added and removed objects, for create list of unique objects + // grouped items will be deleted by groups, so we don't need do delete that items. + QSetIterator itAdded(cmd->GetAddedList()); + while (itAdded.hasNext()) + { + QGraphicsItem* item = itAdded.next(); + if( !itms.contains(item) && !(item->parentItem() && UBGraphicsGroupContainerItem::Type == item->parentItem()->type())) + itms.insert(item); + } + + QSetIterator itRemoved(cmd->GetRemovedList()); + while (itRemoved.hasNext()) + { + QGraphicsItem* item = itRemoved.next(); + if( !itms.contains(item) && !(item->parentItem() && UBGraphicsGroupContainerItem::Type == item->parentItem()->type())) + itms.insert(item); + } +} + void UBBoardController::ClearUndoStack() { -// The code has been removed because it leads to a strange error and because the final goal has never been -// reached on tests and sound a little bit strange. -// Strange error: item->scene() crashes the application because item doesn't implement scene() method. I'm -// not able to give all the steps to reproduce this error sistematically but is quite frequent (~ twice per utilisation hours) -// strange goal: if item is on the undocommand, the item->scene() is null and the item is not on the deleted scene item list then -// then it's deleted. - - // QSet uniqueItems; -// // go through all stack command -// for(int i = 0; i < UBApplication::undoStack->count(); i++) -// { - -// UBAbstractUndoCommand *abstractCmd = (UBAbstractUndoCommand*)UBApplication::undoStack->command(i); -// if(abstractCmd->getType() != UBAbstractUndoCommand::undotype_GRAPHICITEM) -// continue; - -// UBGraphicsItemUndoCommand *cmd = (UBGraphicsItemUndoCommand*)UBApplication::undoStack->command(i); - -// // go through all added and removed objects, for create list of unique objects -// // grouped items will be deleted by groups, so we don't need do delete that items. -// QSetIterator itAdded(cmd->GetAddedList()); -// while (itAdded.hasNext()) -// { -// QGraphicsItem* item = itAdded.next(); -// if( !uniqueItems.contains(item) && !(item->parentItem() && UBGraphicsGroupContainerItem::Type == item->parentItem()->type())) -// uniqueItems.insert(item); -// } - -// QSetIterator itRemoved(cmd->GetRemovedList()); -// while (itRemoved.hasNext()) -// { -// QGraphicsItem* item = itRemoved.next(); -// if( !uniqueItems.contains(item) && !(item->parentItem() && UBGraphicsGroupContainerItem::Type == item->parentItem()->type())) -// uniqueItems.insert(item); -// } -// } - -// // go through all unique items, and check, ot on scene, or not. -// // if not on scene, than item can be deleted - -// QSetIterator itUniq(uniqueItems); -// while (itUniq.hasNext()) -// { -// QGraphicsItem* item = itUniq.next(); -// UBGraphicsScene *scene = NULL; -// if (item->scene()) { -// scene = dynamic_cast(item->scene()); -// } -// if(!scene) -// { -// if (!mActiveScene->deleteItem(item)) -// delete item; -// } -// } + QSet uniqueItems; + // go through all stack command + for (int i = 0; i < UBApplication::undoStack->count(); i++) { + fitUniqIems(UBApplication::undoStack->command(i), uniqueItems); + } + + // go through all unique items, and check, if they are on scene, or not. + // if not on scene, than item can be deleted + QSetIterator itUniq(uniqueItems); + while (itUniq.hasNext()) + { + QGraphicsItem* item = itUniq.next(); + UBGraphicsScene *scene = NULL; + if (item->scene()) { + scene = dynamic_cast(item->scene()); + } + + if(!scene) + { + if (!mActiveScene->deleteItem(item)){ + delete item; + item = 0; + } + } + } // clear stack, and command list UBApplication::undoStack->clear(); - } void UBBoardController::adjustDisplayViews() @@ -1765,10 +1767,7 @@ void UBBoardController::lastWindowClosed() { if (!mCleanupDone) { - bool teacherGuideModified = false; - if(UBApplication::boardController->paletteManager()->teacherGuideDockWidget()) - teacherGuideModified = UBApplication::boardController->paletteManager()->teacherGuideDockWidget()->teacherGuideWidget()->isModified(); - if (selectedDocument()->pageCount() == 1 && (!mActiveScene || mActiveScene->isEmpty()) && !teacherGuideModified) + if (selectedDocument()->pageCount() == 1 && (!mActiveScene || mActiveScene->isEmpty())) { UBPersistenceManager::persistenceManager()->deleteDocument(selectedDocument()); } @@ -1863,7 +1862,7 @@ void UBBoardController::persistCurrentScene() if(UBPersistenceManager::persistenceManager() && selectedDocument() && mActiveScene && mActiveSceneIndex != mDeletingSceneIndex && (mActiveSceneIndex >= 0) && mActiveSceneIndex != mMovingSceneIndex - && (mActiveScene->isModified() || (UBApplication::boardController->paletteManager()->teacherGuideDockWidget() && UBApplication::boardController->paletteManager()->teacherGuideDockWidget()->teacherGuideWidget()->isModified()))) + && (mActiveScene->isModified())) { UBPersistenceManager::persistenceManager()->persistDocumentScene(selectedDocument(), mActiveScene, mActiveSceneIndex); updatePage(mActiveSceneIndex); @@ -1957,7 +1956,7 @@ void UBBoardController::notifyCache(bool visible) { if(visible) emit cacheEnabled(); - + mCacheWidgetIsEnabled = visible; } diff --git a/src/board/UBBoardController.h b/src/board/UBBoardController.h index 52270050..ce4fb7d2 100644 --- a/src/board/UBBoardController.h +++ b/src/board/UBBoardController.h @@ -160,6 +160,7 @@ class UBBoardController : public UBDocumentContainer void notifyPageChanged(); void displayMetaData(QMap metadatas); + void fitUniqIems(const QUndoCommand *parent, QSet &itms); void ClearUndoStack(); void setActiveDocumentScene(UBDocumentProxy* pDocumentProxy, int pSceneIndex = 0, bool forceReload = false); diff --git a/src/board/UBBoardPaletteManager.cpp b/src/board/UBBoardPaletteManager.cpp index cac33bde..c97e1952 100644 --- a/src/board/UBBoardPaletteManager.cpp +++ b/src/board/UBBoardPaletteManager.cpp @@ -40,8 +40,6 @@ #include "gui/UBWebToolsPalette.h" #include "gui/UBActionPalette.h" #include "gui/UBFavoriteToolPalette.h" -#include "gui/UBDockTeacherGuideWidget.h" - #include "web/UBWebPage.h" #include "web/UBWebController.h" @@ -92,7 +90,6 @@ UBBoardPaletteManager::UBBoardPaletteManager(QWidget* container, UBBoardControll , mpPageNavigWidget(NULL) , mpCachePropWidget(NULL) , mpDownloadWidget(NULL) - , mpTeacherGuideWidget(NULL) , mDownloadInProgress(false) { setupPalettes(); @@ -143,12 +140,6 @@ void UBBoardPaletteManager::setupDockPaletteWidgets() mLeftPalette->registerWidget(mpPageNavigWidget); mLeftPalette->addTab(mpPageNavigWidget); - if(UBSettings::settings()->teacherGuidePageZeroActivated->get().toBool() || UBSettings::settings()->teacherGuideLessonPagesActivated->get().toBool()){ - mpTeacherGuideWidget = new UBDockTeacherGuideWidget(); - mLeftPalette->registerWidget(mpTeacherGuideWidget); - mLeftPalette->addTab(mpTeacherGuideWidget); - } - mLeftPalette->connectSignals(); mLeftPalette->showTabWidget(0); @@ -186,14 +177,6 @@ void UBBoardPaletteManager::slot_changeMainMode(UBApplicationController::MainMod changeMode(eUBDockPaletteWidget_BOARD); } break; - - case UBApplicationController::Tutorial: - { - if (UBPlatformUtils::hasVirtualKeyboard() && mKeyboardPalette != NULL) - mKeyboardPalette->hide(); - } - break; - case UBApplicationController::Internet: changeMode(eUBDockPaletteWidget_WEB); break; @@ -335,10 +318,7 @@ void UBBoardPaletteManager::pagePaletteButtonReleased() mPagePalette = 0; QListpageActions; pageActions << UBApplication::mainWindow->actionNewPage; - UBBoardController* boardController = UBApplication::boardController; - if(UBApplication::documentController->pageCanBeDuplicated(UBDocumentContainer::pageFromSceneIndex(boardController->activeSceneIndex()))){ - pageActions << UBApplication::mainWindow->actionDuplicatePage; - } + pageActions << UBApplication::mainWindow->actionDuplicatePage; pageActions << UBApplication::mainWindow->actionImportPage; mPagePalette = new UBActionPalette(pageActions, Qt::Horizontal , mContainer); diff --git a/src/board/UBBoardPaletteManager.h b/src/board/UBBoardPaletteManager.h index 5f05af11..990771cf 100644 --- a/src/board/UBBoardPaletteManager.h +++ b/src/board/UBBoardPaletteManager.h @@ -47,7 +47,6 @@ class UBServerXMLHttpRequest; class UBKeyboardPalette; class UBMainWindow; class UBApplicationController; -class UBDockTeacherGuideWidget; class UBBoardPaletteManager : public QObject { @@ -71,8 +70,6 @@ class UBBoardPaletteManager : public QObject void setCurrentWebToolsPalette(UBWebToolsPalette *palette) {mWebToolsCurrentPalette = palette;} UBWebToolsPalette* mWebToolsCurrentPalette; - UBDockTeacherGuideWidget* teacherGuideDockWidget() { return mpTeacherGuideWidget;} - void processPalettersWidget(UBDockPalette *paletter, eUBDockPaletteWidgetMode mode); void changeMode(eUBDockPaletteWidgetMode newMode, bool isInit = false); void startDownloads(); @@ -142,7 +139,6 @@ class UBBoardPaletteManager : public QObject /** The download widget */ UBDockDownloadWidget* mpDownloadWidget; - UBDockTeacherGuideWidget* mpTeacherGuideWidget; bool mDownloadInProgress; diff --git a/src/board/UBBoardView.cpp b/src/board/UBBoardView.cpp index 50adc7f9..e59b189f 100644 --- a/src/board/UBBoardView.cpp +++ b/src/board/UBBoardView.cpp @@ -47,7 +47,6 @@ #include "gui/UBResources.h" #include "gui/UBMainWindow.h" #include "gui/UBThumbnailWidget.h" -#include "gui/UBTeacherGuideWidgetsTools.h" #include "board/UBBoardController.h" #include "board/UBBoardPaletteManager.h" @@ -552,7 +551,7 @@ Here we determines cases when items should to get mouse press event at pressing case UBGraphicsPixmapItem::Type: case UBGraphicsTextItem::Type: if (currentTool == UBStylusTool::Play) - return true; + return false; if ((currentTool == UBStylusTool::Selector) && item->isSelected()) return true; if ((currentTool == UBStylusTool::Selector) && item->parentItem() && item->parentItem()->isSelected()) @@ -560,10 +559,6 @@ Here we determines cases when items should to get mouse press event at pressing if (currentTool != UBStylusTool::Selector) return false; break; - case UBGraphicsItemType::StrokeItemType: - if (currentTool == UBStylusTool::Play) - return true; - break; case UBGraphicsGroupContainerItem::Type: // Groups shouldn't reacts on any presses and moves for Play tool. if(currentTool == UBStylusTool::Play) @@ -1330,6 +1325,7 @@ void UBBoardView::mouseReleaseEvent (QMouseEvent *event) movingItem = NULL; bReleaseIsNeed = false; } + if (mWidgetMoved) { mWidgetMoved = false; @@ -1417,6 +1413,7 @@ void UBBoardView::mouseReleaseEvent (QMouseEvent *event) UBDrawingController::drawingController ()->setStylusTool (UBStylusTool::Selector); + textItem->setTextInteractionFlags(Qt::TextEditorInteraction); textItem->setSelected (true); textItem->setFocus(); } @@ -1565,9 +1562,7 @@ void UBBoardView::dropEvent (QDropEvent *event) if (!event->source() || qobject_cast(event->source()) || qobject_cast(event->source()) - || qobject_cast(event->source()) - || qobject_cast(event->source()) - || qobject_cast(event->source())) { + || qobject_cast(event->source())) { mController->processMimeData (event->mimeData (), mapToScene (event->pos ())); event->acceptProposedAction(); } diff --git a/src/board/UBBoardView.h b/src/board/UBBoardView.h index ab020b6f..7d252c82 100644 --- a/src/board/UBBoardView.h +++ b/src/board/UBBoardView.h @@ -66,7 +66,6 @@ signals: void clickOnBoard(); void mouseReleased(); - protected: bool itemIsLocked(QGraphicsItem *item); diff --git a/src/board/UBFeaturesController.cpp b/src/board/UBFeaturesController.cpp index edb0bd60..68890f2a 100644 --- a/src/board/UBFeaturesController.cpp +++ b/src/board/UBFeaturesController.cpp @@ -59,6 +59,8 @@ const QString UBFeaturesController::webSearchPath = rootPath + "/Web search"; void UBFeaturesComputingThread::scanFS(const QUrl & currentPath, const QString & currVirtualPath, const QSet &pFavoriteSet) { // Q_ASSERT(QFileInfo(currentPath.toLocalFile()).exists()); + if(QFileInfo(currentPath.toLocalFile()).exists()) + return; QFileInfoList fileInfoList = UBFileSystemUtils::allElementsInDirectory(currentPath.toLocalFile()); diff --git a/src/core/UB.h b/src/core/UB.h index 69b1f263..493590c8 100644 --- a/src/core/UB.h +++ b/src/core/UB.h @@ -112,6 +112,7 @@ struct itemLayerType , Pointer , Cache , SelectedItem + , SelectionFrame }; }; @@ -156,7 +157,8 @@ struct UBGraphicsItemType groupContainerType, ToolWidgetItemType, GraphicsWidgetItemType, - UserTypesCount // this line must be the last line in this enum because it is types counter. + UserTypesCount, + SelectionFrameType// this line must be the last line in this enum because it is types counter. }; }; diff --git a/src/core/UBApplication.cpp b/src/core/UBApplication.cpp index 95abad24..8ba3c115 100644 --- a/src/core/UBApplication.cpp +++ b/src/core/UBApplication.cpp @@ -345,12 +345,9 @@ int UBApplication::exec(const QString& pFileToImport) mPreferencesController = new UBPreferencesController(mainWindow); connect(mainWindow->actionPreferences, SIGNAL(triggered()), mPreferencesController, SLOT(show())); - connect(mainWindow->actionTutorial, SIGNAL(triggered()), applicationController, SLOT(showTutorial())); - connect(mainWindow->actionTutorial, SIGNAL(triggered()), this, SLOT(stopScript())); connect(mainWindow->actionCheckUpdate, SIGNAL(triggered()), applicationController, SLOT(checkUpdateRequest())); - toolBarPositionChanged(UBSettings::settings()->appToolBarPositionedAtTop->get()); bool bUseMultiScreen = UBSettings::settings()->appUseMultiscreen->get().toBool(); @@ -444,7 +441,6 @@ void UBApplication::toolBarPositionChanged(QVariant topOrBottom) mainWindow->addToolBar(area, mainWindow->boardToolBar); mainWindow->addToolBar(area, mainWindow->webToolBar); mainWindow->addToolBar(area, mainWindow->documentToolBar); - mainWindow->addToolBar(area, mainWindow->tutorialToolBar); webController->showTabAtTop(topOrBottom.toBool()); @@ -457,7 +453,6 @@ void UBApplication::toolBarDisplayTextChanged(QVariant display) mainWindow->boardToolBar->setToolButtonStyle(toolButtonStyle); mainWindow->webToolBar->setToolButtonStyle(toolButtonStyle); mainWindow->documentToolBar->setToolButtonStyle(toolButtonStyle); - mainWindow->tutorialToolBar->setToolButtonStyle(toolButtonStyle); } @@ -539,7 +534,6 @@ void UBApplication::decorateActionMenu(QAction* action) mainWindow->actionCheckUpdate->setEnabled(false); menu->addSeparator(); - menu->addAction(mainWindow->actionTutorial); #ifndef Q_WS_X11 // No Podcast on Linux yet menu->addAction(mainWindow->actionPodcast); diff --git a/src/core/UBApplication.h b/src/core/UBApplication.h index 6f76c1db..1649d0fc 100644 --- a/src/core/UBApplication.h +++ b/src/core/UBApplication.h @@ -47,7 +47,7 @@ class UBMainWindow; class UBApplication : public QtSingleApplication { - Q_OBJECT; + Q_OBJECT public: diff --git a/src/core/UBApplicationController.cpp b/src/core/UBApplicationController.cpp index 49b2f698..cc08cf46 100644 --- a/src/core/UBApplicationController.cpp +++ b/src/core/UBApplicationController.cpp @@ -51,8 +51,6 @@ #include "gui/UBScreenMirror.h" #include "gui/UBMainWindow.h" -#include "gui/UBDockTeacherGuideWidget.h" -#include "gui/UBTeacherGuideWidget.h" #include "domain/UBGraphicsPixmapItem.h" @@ -344,7 +342,6 @@ void UBApplicationController::showBoard() { mMainWindow->webToolBar->hide(); mMainWindow->documentToolBar->hide(); - mMainWindow->tutorialToolBar->hide(); mMainWindow->boardToolBar->show(); if (mMainMode == Document) @@ -393,14 +390,12 @@ void UBApplicationController::showInternet() if (UBSettings::settings()->webUseExternalBrowser->get().toBool()) { showDesktop(true); - UBApplication::webController->show(UBWebController::WebBrowser); - // really no have emit mainModeChanged here ? potential problem with virtual keyboard ? + UBApplication::webController->show(); } else { mMainWindow->boardToolBar->hide(); mMainWindow->documentToolBar->hide(); - mMainWindow->tutorialToolBar->hide(); mMainWindow->webToolBar->show(); mMainMode = Internet; @@ -410,7 +405,7 @@ void UBApplicationController::showInternet() mMainWindow->show(); mUninoteController->hideWindow(); - UBApplication::webController->show(UBWebController::WebBrowser); + UBApplication::webController->show(); emit mainModeChanged(Internet); } @@ -421,7 +416,6 @@ void UBApplicationController::showDocument() { mMainWindow->webToolBar->hide(); mMainWindow->boardToolBar->hide(); - mMainWindow->tutorialToolBar->hide(); mMainWindow->documentToolBar->show(); mMainMode = Document; @@ -434,7 +428,7 @@ void UBApplicationController::showDocument() if (UBApplication::boardController) { - if (UBApplication::boardController->activeScene()->isModified() || (UBApplication::boardController->paletteManager()->teacherGuideDockWidget() && UBApplication::boardController->paletteManager()->teacherGuideDockWidget()->teacherGuideWidget()->isModified())) + if (UBApplication::boardController->activeScene()->isModified()) UBApplication::boardController->persistCurrentScene(); UBApplication::boardController->hide(); } @@ -477,42 +471,6 @@ void UBApplicationController::showDesktop(bool dontSwitchFrontProcess) } -void UBApplicationController::showTutorial() -{ - - if (UBApplication::boardController) - { - UBApplication::boardController->persistCurrentScene(); - UBApplication::boardController->hide(); - } - - if (UBSettings::settings()->webUseExternalBrowser->get().toBool()) - { - showDesktop(true); - UBApplication::webController->show(UBWebController::Tutorial); - - } - else{ - mMainWindow->webToolBar->hide(); - mMainWindow->boardToolBar->hide(); - mMainWindow->documentToolBar->hide(); - mMainWindow->tutorialToolBar->show(); - - - mMainMode = Tutorial; - - adaptToolBar(); - - mUninoteController->hideWindow(); - - UBApplication::webController->show(UBWebController::Tutorial); - - mirroringEnabled(false); - emit mainModeChanged(mMainMode); - } -} - - void UBApplicationController::checkUpdate() { // if(mHttp) @@ -590,10 +548,6 @@ void UBApplicationController::hideDesktop() { showDocument(); } - else if (mMainMode == Tutorial) - { - showTutorial(); - } mIsShowingDesktop = false; diff --git a/src/core/UBApplicationController.h b/src/core/UBApplicationController.h index b94655d6..9ae6283f 100644 --- a/src/core/UBApplicationController.h +++ b/src/core/UBApplicationController.h @@ -92,7 +92,7 @@ class UBApplicationController : public QObject enum MainMode { - Board = 0, Internet, Document, Tutorial, WebDocument + Board = 0, Internet, Document, WebDocument }; MainMode displayMode() @@ -136,8 +136,6 @@ class UBApplicationController : public QObject void actionCopy(); void actionPaste(); - void showTutorial(); - void checkUpdateRequest(); void checkUpdateAtLaunch(); diff --git a/src/core/UBDocumentManager.cpp b/src/core/UBDocumentManager.cpp index bfaa2368..17c2c9f5 100644 --- a/src/core/UBDocumentManager.cpp +++ b/src/core/UBDocumentManager.cpp @@ -29,7 +29,6 @@ #include "adaptors/UBExportDocument.h" #include "adaptors/UBExportWeb.h" #include "adaptors/UBExportCFF.h" -#include "adaptors/UBWebPublisher.h" #include "adaptors/UBImportDocument.h" #include "adaptors/UBImportPDF.h" #include "adaptors/UBImportImage.h" @@ -47,8 +46,6 @@ #include "UBSettings.h" #include "UBPersistenceManager.h" -#include "../adaptors/UBExportWeb.h" - #include "core/memcheck.h" UBDocumentManager* UBDocumentManager::sDocumentManager = 0; @@ -75,13 +72,9 @@ UBDocumentManager::UBDocumentManager(QObject *parent) UBExportCFF* cffExporter = new UBExportCFF(this); UBExportFullPDF* exportFullPdf = new UBExportFullPDF(this); UBExportDocument* exportDocument = new UBExportDocument(this); - UBWebPublisher* webPublished = new UBWebPublisher(this); mExportAdaptors.append(exportDocument); - mExportAdaptors.append(webPublished); mExportAdaptors.append(exportFullPdf); mExportAdaptors.append(cffExporter); -// UBExportWeb* exportWeb = new UBExportWeb(this); -// mExportAdaptors.append(exportWeb); UBImportDocument* documentImport = new UBImportDocument(this); mImportAdaptors.append(documentImport); @@ -149,7 +142,7 @@ UBDocumentProxy* UBDocumentManager::importFile(const QFile& pFile, const QString UBDocumentBasedImportAdaptor* importAdaptor = (UBDocumentBasedImportAdaptor*)adaptor; document = importAdaptor->importFile(pFile, pGroup); - + } else { diff --git a/src/core/UBPersistenceManager.cpp b/src/core/UBPersistenceManager.cpp index 9001d17d..5b061ff2 100644 --- a/src/core/UBPersistenceManager.cpp +++ b/src/core/UBPersistenceManager.cpp @@ -33,9 +33,6 @@ #include "core/UBSettings.h" #include "core/UBSetting.h" -#include "gui/UBDockTeacherGuideWidget.h" -#include "gui/UBTeacherGuideWidget.h" - #include "document/UBDocumentProxy.h" #include "adaptors/UBExportPDF.h" @@ -46,8 +43,6 @@ #include "board/UBBoardController.h" #include "board/UBBoardPaletteManager.h" -#include "interfaces/IDataStorage.h" - #include "core/memcheck.h" const QString UBPersistenceManager::imageDirectory = "images"; // added to UBPersistenceManager::mAllDirectories @@ -55,7 +50,6 @@ const QString UBPersistenceManager::objectDirectory = "objects"; // added to UBP const QString UBPersistenceManager::widgetDirectory = "widgets"; // added to UBPersistenceManager::mAllDirectories const QString UBPersistenceManager::videoDirectory = "videos"; // added to UBPersistenceManager::mAllDirectories const QString UBPersistenceManager::audioDirectory = "audios"; // added to -const QString UBPersistenceManager::teacherGuideDirectory = "teacherGuideObjects"; UBPersistenceManager * UBPersistenceManager::sSingleton = 0; @@ -69,7 +63,6 @@ UBPersistenceManager::UBPersistenceManager(QObject *pParent) mDocumentSubDirectories << widgetDirectory; mDocumentSubDirectories << videoDirectory; mDocumentSubDirectories << audioDirectory; - mDocumentSubDirectories << teacherGuideDirectory; documentProxies = allDocumentProxies(); emit proxyListChanged(); @@ -589,10 +582,6 @@ UBGraphicsScene* UBPersistenceManager::loadDocumentScene(UBDocumentProxy* proxy, return mSceneCache.value(proxy, sceneIndex); else { UBGraphicsScene* scene = UBSvgSubsetAdaptor::loadScene(proxy, sceneIndex); - if(!scene && UBSettings::settings()->teacherGuidePageZeroActivated->get().toBool()){ - createDocumentSceneAt(proxy,0); - scene = UBSvgSubsetAdaptor::loadScene(proxy, 0); - } if (scene) mSceneCache.insert(proxy, sceneIndex, scene); @@ -612,15 +601,10 @@ void UBPersistenceManager::persistDocumentScene(UBDocumentProxy* pDocumentProxy, QDir dir(pDocumentProxy->persistencePath()); dir.mkpath(pDocumentProxy->persistencePath()); - UBBoardPaletteManager* paletteManager = UBApplication::boardController->paletteManager(); - bool teacherGuideModified = false; - if(UBApplication::app()->boardController->currentPage() == pSceneIndex && paletteManager->teacherGuideDockWidget()) - teacherGuideModified = paletteManager->teacherGuideDockWidget()->teacherGuideWidget()->isModified(); - - if (pDocumentProxy->isModified() || teacherGuideModified) + if (pDocumentProxy->isModified()) UBMetadataDcSubsetAdaptor::persist(pDocumentProxy); - if (pScene->isModified() || teacherGuideModified) + if (pScene->isModified()) { UBSvgSubsetAdaptor::persistScene(pDocumentProxy, pScene, pSceneIndex); @@ -671,7 +655,6 @@ int UBPersistenceManager::sceneCount(const UBDocumentProxy* proxy) int pageIndex = 0; bool moreToProcess = true; - bool addedMissingZeroPage = false; while (moreToProcess) { @@ -680,27 +663,9 @@ int UBPersistenceManager::sceneCount(const UBDocumentProxy* proxy) QFile file(fileName); if (file.exists()) - { pageIndex++; - } else - { - if(UBSettings::settings()->teacherGuidePageZeroActivated->get().toBool() && pageIndex == 0){ - // the document has no zero file but doesn't means that it hasn't any file - // at all. Just importing a document without the first page using a configuartion - // that enables zero page. - pageIndex++; - addedMissingZeroPage = true; - } - else - moreToProcess = false; - } - } - - if(pageIndex == 1 && addedMissingZeroPage){ - // increment is done only to check if there are other pages than the missing zero page - // This situation means -> no pages on the document - return 0; + moreToProcess = false; } return pageIndex; @@ -761,7 +726,7 @@ bool UBPersistenceManager::addDirectoryContentToDocument(const QString& document foreach(QString dir, mDocumentSubDirectories) { qDebug() << "copying " << documentRootFolder << "/" << dir << " to " << pDocument->persistencePath() << "/" + dir; - + QDir srcDir(documentRootFolder + "/" + dir); if (srcDir.exists()) if (!UBFileSystemUtils::copyDir(documentRootFolder + "/" + dir, pDocument->persistencePath() + "/" + dir)) @@ -865,66 +830,8 @@ void UBPersistenceManager::purgeEmptyDocuments() } } -QString UBPersistenceManager::teacherGuideAbsoluteObjectPath(UBDocumentProxy* pDocumentProxy) -{ - return pDocumentProxy->persistencePath() + "/" + teacherGuideDirectory; -} - -QString UBPersistenceManager::addObjectToTeacherGuideDirectory(UBDocumentProxy* pDocumentProxy, QString pPath) -{ - QString path = UBFileSystemUtils::removeLocalFilePrefix(pPath); - QFileInfo fi(path); - QString uuid = QUuid::createUuid(); - - if (!fi.exists() || !pDocumentProxy) - return ""; - - QString fileName = UBPersistenceManager::teacherGuideDirectory + "/" + uuid + "." + fi.suffix(); - - QString destPath = pDocumentProxy->persistencePath() + "/" + fileName; - - if (!QFile::exists(destPath)){ - QDir dir; - dir.mkdir(pDocumentProxy->persistencePath() + "/" + UBPersistenceManager::teacherGuideDirectory); - - QFile source(path); - - source.copy(destPath); - } - - return destPath; -} - -QString UBPersistenceManager::addWidgetToTeacherGuideDirectory(UBDocumentProxy* pDocumentProxy, QString pPath) -{ - QString path = UBFileSystemUtils::removeLocalFilePrefix(pPath); - QFileInfo fi(path); - Q_ASSERT(fi.isDir()); - - int lastIndex = path.lastIndexOf("."); - QString extension(""); - if(lastIndex != -1) - extension = path.right(path.length() - lastIndex); - - QString uuid = QUuid::createUuid(); - - if (!fi.exists() || !pDocumentProxy) - return ""; - - QString directoryName = UBPersistenceManager::teacherGuideDirectory + "/" + uuid + extension; - QString destPath = pDocumentProxy->persistencePath() + "/" + directoryName; - - if (!QDir(destPath).exists()){ - QDir dir; - dir.mkdir(pDocumentProxy->persistencePath() + "/" + UBPersistenceManager::teacherGuideDirectory); - UBFileSystemUtils::copyDir(path,destPath); - } - - return destPath; -} - -bool UBPersistenceManager::addFileToDocument(UBDocumentProxy* pDocumentProxy, - QString path, +bool UBPersistenceManager::addFileToDocument(UBDocumentProxy* pDocumentProxy, + QString path, const QString& subdir, QUuid objectUuid, QString& destinationPath, @@ -975,12 +882,12 @@ bool UBPersistenceManager::addFileToDocument(UBDocumentProxy* pDocumentProxy, } else { - return false; + return false; } } -bool UBPersistenceManager::addGraphicsWidgteToDocument(UBDocumentProxy *pDocumentProxy, - QString path, +bool UBPersistenceManager::addGraphicsWidgteToDocument(UBDocumentProxy *pDocumentProxy, + QString path, QUuid objectUuid, QString& destinationPath) { diff --git a/src/core/UBPersistenceManager.h b/src/core/UBPersistenceManager.h index a8e17bff..77dd0bb9 100644 --- a/src/core/UBPersistenceManager.h +++ b/src/core/UBPersistenceManager.h @@ -90,10 +90,6 @@ class UBPersistenceManager : public QObject QString generateUniqueDocumentPath(); QString generateUniqueDocumentPath(const QString& baseFolder); - QString teacherGuideAbsoluteObjectPath(UBDocumentProxy* pDocumentProxy); - QString addObjectToTeacherGuideDirectory(UBDocumentProxy* proxy, QString pPath); - QString addWidgetToTeacherGuideDirectory(UBDocumentProxy* pDocumentProxy, QString pPath); - bool addDirectoryContentToDocument(const QString& documentRootFolder, UBDocumentProxy* pDocument); virtual void upgradeDocumentIfNeeded(UBDocumentProxy* pDocumentProxy); diff --git a/src/core/UBPreferencesController.cpp b/src/core/UBPreferencesController.cpp index b10e85cc..444f843b 100644 --- a/src/core/UBPreferencesController.cpp +++ b/src/core/UBPreferencesController.cpp @@ -57,10 +57,7 @@ UBPreferencesDialog::~UBPreferencesDialog() void UBPreferencesDialog::closeEvent(QCloseEvent* e) { - if(mPreferencesController->inputValuesConsistence()) - e->accept(); - else - e->ignore(); + e->accept(); } @@ -132,8 +129,6 @@ void UBPreferencesController::wire() connect(mPreferencesUI->useExternalBrowserCheckBox, SIGNAL(clicked(bool)), settings->webUseExternalBrowser, SLOT(setBool(bool))); connect(mPreferencesUI->displayBrowserPageCheckBox, SIGNAL(clicked(bool)), settings->webShowPageImmediatelyOnMirroredScreen, SLOT(setBool(bool))); - connect(mPreferencesUI->swapControlAndDisplayScreensCheckBox, SIGNAL(clicked(bool)), settings->swapControlAndDisplayScreens, SLOT(setBool(bool))); - connect(mPreferencesUI->swapControlAndDisplayScreensCheckBox, SIGNAL(clicked(bool)), UBApplication::applicationController->displayManager(), SLOT(reinitScreens(bool))); connect(mPreferencesUI->toolbarAtTopRadioButton, SIGNAL(clicked(bool)), this, SLOT(toolbarPositionChanged(bool))); connect(mPreferencesUI->toolbarAtBottomRadioButton, SIGNAL(clicked(bool)), this, SLOT(toolbarPositionChanged(bool))); @@ -176,12 +171,6 @@ void UBPreferencesController::wire() connect(mMarkerProperties->pressureSensitiveCheckBox, SIGNAL(clicked(bool)), settings, SLOT(setMarkerPressureSensitive(bool))); connect(mMarkerProperties->opacitySlider, SIGNAL(valueChanged(int)), this, SLOT(opacitySliderChanged(int))); - - //network - connect(mPreferencesUI->Username_textBox, SIGNAL(editingFinished()), this, SLOT(onCommunityUsernameChanged())); - connect(mPreferencesUI->Password_textEdit, SIGNAL(editingFinished()), this, SLOT(onCommunityPasswordChanged())); - connect(mPreferencesUI->PSCredentialsPersistenceCheckBox,SIGNAL(clicked()),this, SLOT(onCommunityPersistenceChanged())); - // about tab connect(mPreferencesUI->checkSoftwareUpdateAtLaunchCheckBox, SIGNAL(clicked(bool)), settings->appEnableAutomaticSoftwareUpdates, SLOT(setBool(bool))); } @@ -215,10 +204,6 @@ void UBPreferencesController::init() mPreferencesUI->verticalChoice->setChecked(settings->appToolBarOrientationVertical->get().toBool()); mPreferencesUI->horizontalChoice->setChecked(!settings->appToolBarOrientationVertical->get().toBool()); - mPreferencesUI->Username_textBox->setText(settings->communityUsername()); - mPreferencesUI->Password_textEdit->setText(settings->communityPassword()); - mPreferencesUI->swapControlAndDisplayScreensCheckBox->setChecked(settings->swapControlAndDisplayScreens->get().toBool()); - // pen tab mPenProperties->fineSlider->setValue(settings->boardPenFineWidth->get().toDouble() * sSliderRatio); mPenProperties->mediumSlider->setValue(settings->boardPenMediumWidth->get().toDouble() * sSliderRatio); @@ -233,66 +218,6 @@ void UBPreferencesController::init() mMarkerProperties->opacitySlider->setValue(settings->boardMarkerAlpha->get().toDouble() * 100); - //network - mPreferencesUI->PSCredentialsPersistenceCheckBox->setChecked(settings->getCommunityDataPersistence()); - persistanceCheckboxUpdate(); - -} - -void UBPreferencesController::onCommunityUsernameChanged() -{ - UBSettings* settings = UBSettings::settings(); - settings->setCommunityUsername(mPreferencesUI->Username_textBox->text()); - persistanceCheckboxUpdate(); -} - -void UBPreferencesController::onCommunityPasswordChanged() -{ - UBSettings* settings = UBSettings::settings(); - settings->setCommunityPassword(mPreferencesUI->Password_textEdit->text()); - persistanceCheckboxUpdate(); -} - -void UBPreferencesController::onCommunityPersistenceChanged() -{ - UBSettings::settings()->setCommunityPersistence(mPreferencesUI->PSCredentialsPersistenceCheckBox->isChecked()); -} - -void UBPreferencesController::persistanceCheckboxUpdate() -{ - bool checkBoxEnabled = mPreferencesUI->Username_textBox->text().length() || mPreferencesUI->Password_textEdit->text().length(); - mPreferencesUI->PSCredentialsPersistenceCheckBox->setEnabled(checkBoxEnabled); - mPreferencesUI->PSCredentialsPersistenceCheckBox->setStyleSheet(checkBoxEnabled ? "color:black;" : "color:lightgray;"); -} - - -bool UBPreferencesController::inputValuesConsistence() -{ - QString backgroundStyle = "QWidget {background-color: white}"; - mPreferencesUI->Username_textBox->setStyleSheet(backgroundStyle); - mPreferencesUI->Password_textEdit->setStyleSheet(backgroundStyle); - - QString username = mPreferencesUI->Username_textBox->text(); - QString password = mPreferencesUI->Password_textEdit->text(); - bool isConsistent = true; - if (username.length() + password.length()){ - backgroundStyle = "QWidget {background-color: magenta}"; - if(username.isEmpty()){ - isConsistent = false; - mPreferencesUI->mainTabWidget->setCurrentWidget(mPreferencesUI->networkTab); - mPreferencesUI->Username_textBox->setStyleSheet(backgroundStyle); - mPreferencesUI->Username_textBox->setFocus(); - mPreferencesUI->Username_textBox->setCursorPosition(0); - } - else if(password.isEmpty()){ - isConsistent = false; - mPreferencesUI->mainTabWidget->setCurrentWidget(mPreferencesUI->networkTab); - mPreferencesUI->Password_textEdit->setStyleSheet(backgroundStyle); - mPreferencesUI->Password_textEdit->setFocus(); - mPreferencesUI->Password_textEdit->setCursorPosition(0); - } - } - return isConsistent; } void UBPreferencesController::close() @@ -304,9 +229,6 @@ void UBPreferencesController::close() UBSettings::settings()->setProxyUsername(mPreferencesUI->proxyUsername->text()); UBSettings::settings()->setProxyPassword(mPreferencesUI->proxyPassword->text()); - if (!inputValuesConsistence()) - return; - mPreferencesWindow->accept(); } diff --git a/src/core/UBPreferencesController.h b/src/core/UBPreferencesController.h index 3ba0ae96..3827f4ba 100644 --- a/src/core/UBPreferencesController.h +++ b/src/core/UBPreferencesController.h @@ -57,13 +57,12 @@ protected: class UBPreferencesController : public QObject { - Q_OBJECT; + Q_OBJECT public: UBPreferencesController(QWidget *parent); virtual ~UBPreferencesController(); - bool inputValuesConsistence(); public slots: @@ -89,9 +88,6 @@ class UBPreferencesController : public QObject void toolbarPositionChanged(bool checked); void toolbarOrientationVertical(bool checked); void toolbarOrientationHorizontal(bool checked); - void onCommunityUsernameChanged(); - void onCommunityPasswordChanged(); - void onCommunityPersistenceChanged(); private slots: void adjustScreens(int screen); @@ -100,7 +96,6 @@ class UBPreferencesController : public QObject static qreal sSliderRatio; static qreal sMinPenWidth; static qreal sMaxPenWidth; - void persistanceCheckboxUpdate(); QDesktopWidget* mDesktop; }; diff --git a/src/core/UBSettings.cpp b/src/core/UBSettings.cpp index 73ba20a5..bc0a473d 100644 --- a/src/core/UBSettings.cpp +++ b/src/core/UBSettings.cpp @@ -51,14 +51,6 @@ QString UBSettings::documentSize = QString("Size"); QString UBSettings::documentIdentifer = QString("ID"); QString UBSettings::documentVersion = QString("Version"); QString UBSettings::documentUpdatedAt = QString("UpdatedAt"); -QString UBSettings::sessionTitle = QString("sessionTitle"); -QString UBSettings::sessionAuthors = QString("sessionAuthors"); -QString UBSettings::sessionObjectives = QString("sessionObjectives"); -QString UBSettings::sessionKeywords = QString("sessionKeywords"); -QString UBSettings::sessionGradeLevel = QString("sessionGradeLevel"); -QString UBSettings::sessionSubjects = QString("sessionSubjects"); -QString UBSettings::sessionType = QString("sessionType"); -QString UBSettings::sessionLicence = QString("sessionLicence"); QString UBSettings::documentDate = QString("date"); QString UBSettings::trashedDocumentGroupNamePrefix = QString("_Trash:"); @@ -66,6 +58,7 @@ QString UBSettings::trashedDocumentGroupNamePrefix = QString("_Trash:"); QString UBSettings::uniboardDocumentNamespaceUri = "http://uniboard.mnemis.com/document"; QString UBSettings::uniboardApplicationNamespaceUri = "http://uniboard.mnemis.com/application"; +QString UBSettings::undoCommandTransactionName = "UndoTransaction"; const int UBSettings::sDefaultFontPixelSize = 36; const char *UBSettings::sDefaultFontFamily = "Arial"; @@ -207,7 +200,7 @@ void UBSettings::ValidateKeyboardPaletteKeyBtnSize() void UBSettings::init() { - productWebUrl = new UBSetting(this, "App", "ProductWebAddress", "http://www.sankore.org"); + productWebUrl = new UBSetting(this, "App", "ProductWebAddress", "http://www.oe-f.org"); softwareHomeUrl = productWebUrl->get().toString(); @@ -405,8 +398,6 @@ void UBSettings::init() angleTolerance = new UBSetting(this, "App", "AngleTolerance", 4); historyLimit = new UBSetting(this, "Web", "HistoryLimit", 15); - teacherGuidePageZeroActivated = new UBSetting(this,"DockPalette","TeacherGuideActivatePageZero",true); - teacherGuideLessonPagesActivated = new UBSetting(this,"DockPalette","TeacherGuideActivateLessonPages",true); libIconSize = new UBSetting(this, "Library", "LibIconSize", defaultLibraryIconSize); diff --git a/src/core/UBSettings.h b/src/core/UBSettings.h index 74e89691..55307a16 100644 --- a/src/core/UBSettings.h +++ b/src/core/UBSettings.h @@ -179,15 +179,6 @@ class UBSettings : public QObject static QString documentVersion; static QString documentUpdatedAt; - static QString sessionTitle; - static QString sessionAuthors; - static QString sessionObjectives; - static QString sessionKeywords; - static QString sessionGradeLevel; - static QString sessionSubjects; - static QString sessionType; - static QString sessionLicence; - static QString documentDate; static QString trashedDocumentGroupNamePrefix; @@ -197,6 +188,8 @@ class UBSettings : public QObject static QString uniboardDocumentNamespaceUri; static QString uniboardApplicationNamespaceUri; + static QString undoCommandTransactionName; + static const int maxThumbnailWidth; static const int defaultThumbnailWidth; static const int defaultLibraryIconSize; @@ -367,8 +360,6 @@ class UBSettings : public QObject UBSetting* angleTolerance; UBSetting* historyLimit; - UBSetting* teacherGuidePageZeroActivated; - UBSetting* teacherGuideLessonPagesActivated; UBSetting* libIconSize; diff --git a/src/customWidgets/UBActionableWidget.cpp b/src/customWidgets/UBActionableWidget.cpp deleted file mode 100644 index ba334aca..00000000 --- a/src/customWidgets/UBActionableWidget.cpp +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright (C) 2010-2013 Groupement d'Intérêt Public pour l'Education Numérique en Afrique (GIP ENA) - * - * This file is part of Open-Sankoré. - * - * Open-Sankoré 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, version 3 of the License, - * with a specific linking exception for the OpenSSL project's - * "OpenSSL" library (or with modified versions of it that use the - * same license as the "OpenSSL" library). - * - * Open-Sankoré 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 Open-Sankoré. If not, see . - */ - - - -#include -#include - -#include "UBActionableWidget.h" - -#include "core/memcheck.h" - -UBActionableWidget::UBActionableWidget(QWidget *parent, const char *name):QWidget(parent) - , mShowActions(false) -{ - setObjectName(name); - mActions.clear(); - mCloseButtons.setIcon(QIcon(QPixmap(":images/close.svg"))); - mCloseButtons.setGeometry(0, 0, 2*ACTIONSIZE, ACTIONSIZE); - mCloseButtons.setVisible(false); - connect(&mCloseButtons, SIGNAL(clicked()), this, SLOT(onCloseClicked())); -} - -UBActionableWidget::~UBActionableWidget() -{ - -} - -void UBActionableWidget::addAction(eAction act) -{ - if(!mActions.contains(act)){ - mActions << act; - } -} - -void UBActionableWidget::removeAction(eAction act) -{ - if(mActions.contains(act)){ - mActions.remove(mActions.indexOf(act)); - } -} - -void UBActionableWidget::removeAllActions() -{ - mActions.clear(); -} - -void UBActionableWidget::setActionsVisible(bool bVisible) -{ - if(!mActions.empty() && mActions.contains(eAction_Close)){ - mCloseButtons.setVisible(bVisible); - } -} - -void UBActionableWidget::onCloseClicked() -{ - emit close(this); -} - -void UBActionableWidget::setActionsParent(QWidget *parent) -{ - if(mActions.contains(eAction_Close)){ - mCloseButtons.setParent(parent); - } -} - -void UBActionableWidget::unsetActionsParent() -{ - if(mActions.contains(eAction_Close)){ - mCloseButtons.setParent(this); - } -} diff --git a/src/customWidgets/UBActionableWidget.h b/src/customWidgets/UBActionableWidget.h deleted file mode 100644 index cdc8e767..00000000 --- a/src/customWidgets/UBActionableWidget.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (C) 2010-2013 Groupement d'Intérêt Public pour l'Education Numérique en Afrique (GIP ENA) - * - * This file is part of Open-Sankoré. - * - * Open-Sankoré 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, version 3 of the License, - * with a specific linking exception for the OpenSSL project's - * "OpenSSL" library (or with modified versions of it that use the - * same license as the "OpenSSL" library). - * - * Open-Sankoré 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 Open-Sankoré. If not, see . - */ - - - -#ifndef UBACTIONABLEWIDGET_H -#define UBACTIONABLEWIDGET_H - -#include -#include -#include -#include - -#define ACTIONSIZE 16 - -typedef enum{ - eAction_Close, - eAction_MoveUp, - eAction_MoveDown -}eAction; - -class UBActionableWidget : public QWidget -{ - Q_OBJECT -public: - UBActionableWidget(QWidget* parent=0, const char* name="UBActionableWidget"); - ~UBActionableWidget(); - void addAction(eAction act); - void removeAction(eAction act); - void removeAllActions(); - void setActionsVisible(bool bVisible); - -signals: - void close(QWidget* w); - -protected: - void setActionsParent(QWidget* parent); - void unsetActionsParent(); - QVector mActions; - QPushButton mCloseButtons; - -private slots: - void onCloseClicked(); - -private: - bool mShowActions; - -}; - -#endif // UBACTIONABLEWIDGET_H diff --git a/src/customWidgets/UBMediaWidget.cpp b/src/customWidgets/UBMediaWidget.cpp deleted file mode 100644 index fc57d6ed..00000000 --- a/src/customWidgets/UBMediaWidget.cpp +++ /dev/null @@ -1,368 +0,0 @@ -/* - * Copyright (C) 2010-2013 Groupement d'Intérêt Public pour l'Education Numérique en Afrique (GIP ENA) - * - * This file is part of Open-Sankoré. - * - * Open-Sankoré 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, version 3 of the License, - * with a specific linking exception for the OpenSSL project's - * "OpenSSL" library (or with modified versions of it that use the - * same license as the "OpenSSL" library). - * - * Open-Sankoré 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 Open-Sankoré. If not, see . - */ - - - -#include "core/UBApplication.h" -#include "globals/UBGlobals.h" -#include "UBMediaWidget.h" - -#include "core/memcheck.h" - -/** - * \brief Constructor - * @param type as the media type - * @param parent as the parent widget - * @param name as the object name - */ -UBMediaWidget::UBMediaWidget(eMediaType type, QWidget *parent, const char *name):UBActionableWidget(parent, name) - , mpMediaObject(NULL) - , mpVideoWidget(NULL) - , mpAudioOutput(NULL) - , mpLayout(NULL) - , mpSeekerLayout(NULL) - , mpPlayStopButton(NULL) - , mpPauseButton(NULL) - , mpSlider(NULL) - , mAutoUpdate(false) - , mGeneratingThumbnail(false) - , mBorder(5) - , mpMediaContainer(NULL) - , mMediaLayout(NULL) - , mpCover(NULL) -{ - SET_STYLE_SHEET(); - - addAction(eAction_Close); - mType = type; - mpLayout = new QVBoxLayout(this); - setLayout(mpLayout); - - mpPlayStopButton = new UBMediaButton(this); - mpPlayStopButton->setPixmap(QPixmap(":images/play.svg")); - mpPauseButton = new UBMediaButton(this); - mpPauseButton->setPixmap(QPixmap(":images/pause.svg")); - mpPauseButton->setEnabled(false); - mpSlider = new QSlider(this); - mpSlider->setOrientation(Qt::Horizontal); - mpSlider->setMinimum(0); - mpSlider->setMaximum(0); - - mpSeekerLayout = new QHBoxLayout(); - mpSeekerLayout->addWidget(mpPlayStopButton, 0); - mpSeekerLayout->addWidget(mpPauseButton, 0); - mpSeekerLayout->addWidget(mpSlider, 1); - mpSeekerLayout->setContentsMargins(0, 0, 0, 0); - - connect(mpPlayStopButton, SIGNAL(clicked()), this, SLOT(onPlayStopClicked())); - connect(mpPauseButton, SIGNAL(clicked()), this, SLOT(onPauseClicked())); - connect(mpSlider, SIGNAL(valueChanged(int)), this, SLOT(onSliderChanged(int))); -} - -/** - * \brief Destructor - */ -UBMediaWidget::~UBMediaWidget() -{ - unsetActionsParent(); - DELETEPTR(mpMediaObject); - DELETEPTR(mpSlider); - DELETEPTR(mpPauseButton); - DELETEPTR(mpPlayStopButton); - DELETEPTR(mpAudioOutput); - DELETEPTR(mpVideoWidget); - DELETEPTR(mpCover); - DELETEPTR(mpMediaContainer); - DELETEPTR(mpSeekerLayout); - DELETEPTR(mpLayout); -} - -/** - * \brief Set the media file - * @param filePath as the media file path - */ -void UBMediaWidget::setFile(const QString &filePath) -{ - Q_ASSERT("" != filePath); - mFilePath = filePath; - mpMediaObject = new Phonon::MediaObject(this); - mpMediaObject->setTickInterval(TICK_INTERVAL); - connect(mpMediaObject, SIGNAL(stateChanged(Phonon::State,Phonon::State)), this, SLOT(onStateChanged(Phonon::State,Phonon::State))); - connect(mpMediaObject, SIGNAL(totalTimeChanged(qint64)), this, SLOT(onTotalTimeChanged(qint64))); - connect(mpMediaObject, SIGNAL(tick(qint64)), this, SLOT(onTick(qint64))); - mpMediaObject->setCurrentSource(Phonon::MediaSource(filePath)); - createMediaPlayer(); -} - -/** - * \brief Get the media type - * @returns the media type - */ -eMediaType UBMediaWidget::mediaType() -{ - return mType; -} - -void UBMediaWidget::showEvent(QShowEvent* event) -{ - if(mType == eMediaType_Audio){ - return; - }else{ - if(!mpVideoWidget){ - mpVideoWidget = new Phonon::VideoWidget(this); - mMediaLayout->addStretch(1); - mMediaLayout->addWidget(mpVideoWidget); - mMediaLayout->addStretch(1); - Phonon::createPath(mpMediaObject, mpVideoWidget); - adaptSizeToVideo(); - mpMediaObject->play(); - mpMediaObject->stop(); - } - QWidget::showEvent(event); - } -} - -void UBMediaWidget::hideEvent(QHideEvent* event) -{ - if(mpMediaObject->state() == Phonon::PlayingState) - mpMediaObject->stop(); - UBActionableWidget::hideEvent(event); -} - -/** - * \brief Create the media player - */ -void UBMediaWidget::createMediaPlayer() -{ - mpMediaContainer = new QWidget(); - mpMediaContainer->setObjectName("UBMediaVideoContainer"); - mMediaLayout = new QHBoxLayout(); - mpMediaContainer->setLayout(mMediaLayout); - - if(eMediaType_Video == mType){ - mMediaLayout->setContentsMargins(10, 10, 10, 10); - if(isVisible()){ - mpVideoWidget = new Phonon::VideoWidget(this); - mMediaLayout->addStretch(1); - mMediaLayout->addWidget(mpVideoWidget); - mMediaLayout->addStretch(1); - Phonon::createPath(mpMediaObject, mpVideoWidget); - adaptSizeToVideo(); - } - mpAudioOutput = new Phonon::AudioOutput(Phonon::VideoCategory, this); - Phonon::createPath(mpMediaObject, mpAudioOutput); - }else if(eMediaType_Audio == mType){ - mMediaLayout->setContentsMargins(10, 10, 10, 10); - mpCover = new QLabel(mpMediaContainer); - //mpMediaContainer->setStyleSheet(QString("background: none;")); - setAudioCover(":images/libpalette/soundIcon.svg"); - mpCover->setScaledContents(true); - mMediaLayout->addStretch(1); - mMediaLayout->addWidget(mpCover); - mMediaLayout->addStretch(1); - mpAudioOutput = new Phonon::AudioOutput(Phonon::MusicCategory, this); - Phonon::createPath(mpMediaObject, mpAudioOutput); - } - mpLayout->addWidget(mpMediaContainer, 1); - mpLayout->addLayout(mpSeekerLayout, 0); - setActionsParent(mpMediaContainer); -} - -/** - * \brief Adapt the widget size to the video in order to keep the good aspect ratio - */ -void UBMediaWidget::adaptSizeToVideo() -{ - if(NULL != mpMediaContainer){ - int origW = mpMediaContainer->width(); - int origH = mpMediaContainer->height(); - int newW = width(); - float scaleFactor = (float)origW/(float)newW; - int newH = origH/scaleFactor; - resize(newW, height() + newH); - } -} - -/** - * \brief Handle the media state change notification - * @param newState as the new state - * @param oldState as the old state - */ -void UBMediaWidget::onStateChanged(Phonon::State newState, Phonon::State oldState) -{ - if(!mGeneratingThumbnail){ - if(Phonon::LoadingState == oldState && Phonon::StoppedState == newState){ - if(eMediaType_Video == mType){ - // We do that here to generate the thumbnail of the video - mGeneratingThumbnail = true; - mpMediaObject->play(); - mpMediaObject->pause(); - mGeneratingThumbnail = false; - } - }else if(Phonon::PlayingState == oldState && Phonon::PausedState == newState){ - mpPlayStopButton->setPixmap(QPixmap(":images/play.svg")); - mpPauseButton->setEnabled(false); - }else if((Phonon::PausedState == oldState && Phonon::PlayingState == newState) || - (Phonon::StoppedState == oldState && Phonon::PlayingState == newState)){ - mpPlayStopButton->setPixmap(QPixmap(":images/stop.svg")); - mpPauseButton->setEnabled(true); - }else if(Phonon::PlayingState == oldState && Phonon::StoppedState == newState){ - mpPlayStopButton->setPixmap(QPixmap(":images/play.svg")); - mpPauseButton->setEnabled(false); - mpSlider->setValue(0); - } - - } - // if(mType == eMediaType_Video) - // updateView(newState); -} - -/** - * \brief Handles the total time change notification - * @param total as the new total time - */ -void UBMediaWidget::onTotalTimeChanged(qint64 total) -{ - mpSlider->setMaximum(total); -} - -/** - * \brief Handles the tick notification - * @param currentTime as the current time - */ -void UBMediaWidget::onTick(qint64 currentTime) -{ - mAutoUpdate = true; - mpSlider->setValue((int)currentTime); - mAutoUpdate = false; -} - -/** - * \brief Handles the seeker value change notification - * @param value as the new seeker value - */ -void UBMediaWidget::onSliderChanged(int value) -{ - if(!mAutoUpdate){ - mpMediaObject->seek(value); - } -} - -/** - * \brief Toggle Play-Stop - */ -void UBMediaWidget::onPlayStopClicked() -{ - switch(mpMediaObject->state()){ - case Phonon::PlayingState: - mpMediaObject->stop(); - break; - - case Phonon::StoppedState: - case Phonon::PausedState: - mpMediaObject->play(); - break; - default: - break; - } -} - -/** - * \brief Pause the media - */ -void UBMediaWidget::onPauseClicked() -{ - mpMediaObject->pause(); -} - -/** - * Get the border - * @returns the actual border - */ -int UBMediaWidget::border() -{ - return mBorder; -} - -/** - * \brief Handles the resize event - * @param ev as the resize event - */ -void UBMediaWidget::resizeEvent(QResizeEvent* ev) -{ - Q_UNUSED(ev); -} - -/** - * \brief Set the audio cover - * @param coverPath as the cover image file path - */ -void UBMediaWidget::setAudioCover(const QString &coverPath) -{ - if(NULL != mpCover){ - mpCover->setPixmap(QPixmap(coverPath)); - } -} - -// ----------------------------------------------------------------------------------------------------------- -/** - * \brief Constructor - * @param parent as the parent widget - * @param name as the object name - */ -UBMediaButton::UBMediaButton(QWidget *parent, const char *name):QLabel(parent) - , mPressed(false) -{ - setObjectName(name); - resize(UBMEDIABUTTON_SIZE, UBMEDIABUTTON_SIZE); - setStyleSheet(QString("padding:0px 0px 0px 0px; margin:0px 0px 0px 0px;")); -} - -/** - * \brief Destructor - */ -UBMediaButton::~UBMediaButton() -{ - -} - -/** - * \brief Handles the mouse press notification - * @param ev as the mouse press event - */ -void UBMediaButton::mousePressEvent(QMouseEvent* ev) -{ - Q_UNUSED(ev); - mPressed = true; -} - -/** - * \brief Handles the mouse release notification - * @param ev as the mouse release event - */ -void UBMediaButton::mouseReleaseEvent(QMouseEvent* ev) -{ - Q_UNUSED(ev); - if(mPressed){ - mPressed = false; - emit clicked(); - } -} diff --git a/src/customWidgets/UBMediaWidget.h b/src/customWidgets/UBMediaWidget.h deleted file mode 100644 index 973b9226..00000000 --- a/src/customWidgets/UBMediaWidget.h +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Copyright (C) 2010-2013 Groupement d'Intérêt Public pour l'Education Numérique en Afrique (GIP ENA) - * - * This file is part of Open-Sankoré. - * - * Open-Sankoré 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, version 3 of the License, - * with a specific linking exception for the OpenSSL project's - * "OpenSSL" library (or with modified versions of it that use the - * same license as the "OpenSSL" library). - * - * Open-Sankoré 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 Open-Sankoré. If not, see . - */ - - - -#ifndef UBMEDIAWIDGET_H -#define UBMEDIAWIDGET_H - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include "UBActionableWidget.h" - -#define UBMEDIABUTTON_SIZE 32 -#define TICK_INTERVAL 1000 - -/** - * \brief The media type - */ -typedef enum{ - eMediaType_Video, - eMediaType_Audio -}eMediaType; - -class UBMediaButton : public QLabel -{ - Q_OBJECT -public: - UBMediaButton(QWidget* parent=0, const char* name="UBMediaButton"); - ~UBMediaButton(); - -signals: - void clicked(); - -protected: - void mousePressEvent(QMouseEvent* ev); - void mouseReleaseEvent(QMouseEvent* ev); - -private: - /** And indicator of the press event in progress */ - bool mPressed; -}; - -class UBMediaWidget : public UBActionableWidget -{ - Q_OBJECT -public: - UBMediaWidget(eMediaType type = eMediaType_Video, QWidget* parent=0, const char* name="UBMediaWidget"); - ~UBMediaWidget(); - void setFile(const QString& filePath); - eMediaType mediaType(); - int border(); - void setAudioCover(const QString& coverPath); - void setUrl(const QString& url){mUrl = url;} - QString url(){return mUrl;} - -protected: - void resizeEvent(QResizeEvent* ev); - void showEvent(QShowEvent* event); - void hideEvent(QHideEvent* event); - /** The current media file path */ - QString mFilePath; - -private slots: - void onPlayStopClicked(); - void onPauseClicked(); - void onStateChanged(Phonon::State newState, Phonon::State oldState); - void onTotalTimeChanged(qint64 total); - void onTick(qint64 currentTime); - void onSliderChanged(int value); - -private: - void createMediaPlayer(); - void adaptSizeToVideo(); - - /** The current media type */ - eMediaType mType; - /** The media object */ - Phonon::MediaObject* mpMediaObject; - /** The video renderer */ - Phonon::VideoWidget* mpVideoWidget; - /** The audio renderer */ - Phonon::AudioOutput* mpAudioOutput; - /** The principal layout of this widget */ - QVBoxLayout* mpLayout; - /** The seeker layout */ - QHBoxLayout* mpSeekerLayout; - /** The play-stop button */ - UBMediaButton* mpPlayStopButton; - /** The pause button */ - UBMediaButton* mpPauseButton; - /** The seeker slider */ - QSlider* mpSlider; - /** An indicator of the seeker auto update in progress */ - bool mAutoUpdate; - /** An indicator of the thumbnail generation in progress */ - bool mGeneratingThumbnail; - /** The border */ - int mBorder; - /** A widget that will contain the media */ - QWidget* mpMediaContainer; - /** The media layout */ - QHBoxLayout* mMediaLayout; - /** The audio cover */ - QLabel* mpCover; - /** The media url */ - QString mUrl; -}; - -#endif // UBMEDIAWIDGET_H diff --git a/src/customWidgets/customWidgets.pri b/src/customWidgets/customWidgets.pri deleted file mode 100644 index a3c64030..00000000 --- a/src/customWidgets/customWidgets.pri +++ /dev/null @@ -1,8 +0,0 @@ - -HEADERS += \ - src/customWidgets/UBMediaWidget.h \ - src/customWidgets/UBActionableWidget.h - -SOURCES += \ - src/customWidgets/UBMediaWidget.cpp \ - src/customWidgets/UBActionableWidget.cpp diff --git a/src/document/UBDocumentContainer.cpp b/src/document/UBDocumentContainer.cpp index b2ba4664..d0d669ea 100644 --- a/src/document/UBDocumentContainer.cpp +++ b/src/document/UBDocumentContainer.cpp @@ -62,11 +62,6 @@ void UBDocumentContainer::duplicatePages(QList& pageIndexes) bool UBDocumentContainer::movePageToIndex(int source, int target) { - if (source==0) - { - // Title page - cant be moved - return false; - } UBPersistenceManager::persistenceManager()->moveSceneToIndex(mCurrentDocument, source, target); deleteThumbPage(source); insertThumbPage(target); @@ -120,22 +115,17 @@ void UBDocumentContainer::reloadThumbnails() if (mCurrentDocument) { UBThumbnailAdaptor::load(mCurrentDocument, mDocumentThumbs); - qDebug() << "Reloading Thumbnails. new mDocumentThumbs size: " << mDocumentThumbs.size(); emit documentThumbnailsUpdated(this); } } int UBDocumentContainer::pageFromSceneIndex(int sceneIndex) { - if(UBSettings::settings()->teacherGuidePageZeroActivated->get().toBool()) - return sceneIndex; return sceneIndex+1; } int UBDocumentContainer::sceneIndexFromPage(int page) { - if(UBSettings::settings()->teacherGuidePageZeroActivated->get().toBool()) - return page; return page-1; } diff --git a/src/document/UBDocumentController.cpp b/src/document/UBDocumentController.cpp index d24282a4..44e26da4 100644 --- a/src/document/UBDocumentController.cpp +++ b/src/document/UBDocumentController.cpp @@ -1082,7 +1082,7 @@ void UBDocumentController::moveSceneToIndex(UBDocumentProxy* proxy, int source, { proxy->setMetaData(UBSettings::documentUpdatedAt, UBStringUtils::toUtcIsoDateTime(QDateTime::currentDateTime())); UBMetadataDcSubsetAdaptor::persist(proxy); - + mDocumentUI->thumbnailWidget->hightlightItem(target); } } @@ -1147,11 +1147,11 @@ void UBDocumentController::selectionChanged() else if(pageSelected){ QList selection = mDocumentUI->thumbnailWidget->selectedItems(); if(pageCount == 1) - mMainWindow->actionDuplicate->setEnabled(!trashSelected && pageCanBeDuplicated(UBDocumentContainer::pageFromSceneIndex(0))); + mMainWindow->actionDuplicate->setEnabled(!trashSelected); else{ for(int i = 0; i < selection.count() && !firstSceneSelected; i += 1){ if(dynamic_cast(selection.at(i))->sceneIndex() == 0){ - mMainWindow->actionDuplicate->setEnabled(!trashSelected && pageCanBeDuplicated(UBDocumentContainer::pageFromSceneIndex(0))); + mMainWindow->actionDuplicate->setEnabled(!trashSelected); firstSceneSelected = true; } } @@ -1630,32 +1630,6 @@ int UBDocumentController::getSelectedItemIndex() else return -1; } -bool UBDocumentController::pageCanBeMovedUp(int page) -{ - if(UBSettings::settings()->teacherGuidePageZeroActivated->get().toBool()) - return page >= 2; - else - return page >= 1; -} - -bool UBDocumentController::pageCanBeMovedDown(int page) -{ - if(UBSettings::settings()->teacherGuidePageZeroActivated->get().toBool()) - return page != 0 && page < selectedDocument()->pageCount() - 1; - else - return page < selectedDocument()->pageCount() - 1; -} - -bool UBDocumentController::pageCanBeDuplicated(int page) -{ - return page != 0; -} - -bool UBDocumentController::pageCanBeDeleted(int page) -{ - return page != 0; -} - void UBDocumentController::refreshDocumentThumbnailsView(UBDocumentContainer*) { QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); @@ -1668,9 +1642,9 @@ void UBDocumentController::refreshDocumentThumbnailsView(UBDocumentContainer*) QStringList labels; - if (proxy) + if (proxy) { - setDocument(proxy); + setDocument(proxy); for (int i = 0; i < selectedDocument()->pageCount(); i++) { @@ -1684,10 +1658,7 @@ void UBDocumentController::refreshDocumentThumbnailsView(UBDocumentContainer*) items << pixmapItem; int pageIndex = pageFromSceneIndex(i); - if(pageIndex) - labels << tr("Page %1").arg(pageIndex); - else - labels << tr("Title page"); + labels << tr("Page %1").arg(pageIndex); itemsPath.append(QUrl::fromLocalFile(proxy->persistencePath() + QString("/pages/%1").arg(UBDocumentContainer::pageFromSceneIndex(i)))); } diff --git a/src/document/UBDocumentController.h b/src/document/UBDocumentController.h index 75608f41..607e906a 100644 --- a/src/document/UBDocumentController.h +++ b/src/document/UBDocumentController.h @@ -59,10 +59,6 @@ class UBDocumentController : public UBDocumentContainer void deletePages(QList itemsToDelete); int getSelectedItemIndex(); - bool pageCanBeMovedUp(int page); - bool pageCanBeMovedDown(int page); - bool pageCanBeDuplicated(int page); - bool pageCanBeDeleted(int page); QString documentTrashGroupName(){ return mDocumentTrashGroupName;} QString defaultDocumentGroupName(){ return mDefaultDocumentGroupName;} diff --git a/src/document/UBDocumentProxy.cpp b/src/document/UBDocumentProxy.cpp index 82145959..894adcc2 100644 --- a/src/document/UBDocumentProxy.cpp +++ b/src/document/UBDocumentProxy.cpp @@ -57,16 +57,6 @@ void UBDocumentProxy::init() setUuid(QUuid::createUuid()); setDefaultDocumentSize(UBSettings::settings()->pageSize->get().toSize()); - - //teacherGuide metadata - setMetaData(UBSettings::sessionTitle,""); - setMetaData(UBSettings::sessionAuthors,""); - setMetaData(UBSettings::sessionObjectives,""); - setMetaData(UBSettings::sessionKeywords,""); - setMetaData(UBSettings::sessionGradeLevel,""); - setMetaData(UBSettings::sessionSubjects,""); - setMetaData(UBSettings::sessionType,""); - setMetaData(UBSettings::sessionLicence,""); } diff --git a/src/domain/UBAbstractUndoCommand.h b/src/domain/UBAbstractUndoCommand.h index 15c25ae3..a544c52b 100644 --- a/src/domain/UBAbstractUndoCommand.h +++ b/src/domain/UBAbstractUndoCommand.h @@ -44,7 +44,7 @@ class UBAbstractUndoCommand : public QUndoCommand undotype_GRAPHICSGROUPITEM = 6 }; - virtual UndoType getType() { return undotype_UNKNOWN; } + virtual UndoType getType() const { return undotype_UNKNOWN; } protected: virtual void undo(); diff --git a/src/domain/UBDocumentUndoCommand.cpp b/src/domain/UBDocumentUndoCommand.cpp deleted file mode 100644 index 880afcd6..00000000 --- a/src/domain/UBDocumentUndoCommand.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (C) 2010-2013 Groupement d'Intérêt Public pour l'Education Numérique en Afrique (GIP ENA) - * - * This file is part of Open-Sankoré. - * - * Open-Sankoré 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, version 3 of the License, - * with a specific linking exception for the OpenSSL project's - * "OpenSSL" library (or with modified versions of it that use the - * same license as the "OpenSSL" library). - * - * Open-Sankoré 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 Open-Sankoré. If not, see . - */ - - - -#include "UBDocumentUndoCommand.h" - -#include "document/UBDocumentProxy.h" -#include "UBGraphicsScene.h" - -#include "core/memcheck.h" - -UBDocumentUndoCommand::UBDocumentUndoCommand(UBDocumentProxy* pDocument, const QList& pOldScenes, - const QList& pNewScenes, const int& pActiveSceneIndex) - : mDocument(pDocument) - , mUndoScenes(pOldScenes) - , mRedoScenes(pNewScenes) - , mActiveSceneIndex(pActiveSceneIndex) -{ - // NOOP -} - -UBDocumentUndoCommand::~UBDocumentUndoCommand() -{ - // NOOP -} - -void UBDocumentUndoCommand::undo() -{ - // NOOP -} - -void UBDocumentUndoCommand::redo() -{ - // NOOP -} - diff --git a/src/domain/UBDocumentUndoCommand.h b/src/domain/UBDocumentUndoCommand.h deleted file mode 100644 index a839b153..00000000 --- a/src/domain/UBDocumentUndoCommand.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (C) 2010-2013 Groupement d'Intérêt Public pour l'Education Numérique en Afrique (GIP ENA) - * - * This file is part of Open-Sankoré. - * - * Open-Sankoré 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, version 3 of the License, - * with a specific linking exception for the OpenSSL project's - * "OpenSSL" library (or with modified versions of it that use the - * same license as the "OpenSSL" library). - * - * Open-Sankoré 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 Open-Sankoré. If not, see . - */ - - - -#ifndef UBDOCUMENTUNDOCOMMAND_H_ -#define UBDOCUMENTUNDOCOMMAND_H_ - -#include -#include "UBAbstractUndoCommand.h" - -class UBDocumentProxy; -class UBGraphicsScene; - -class UBDocumentUndoCommand: public UBAbstractUndoCommand -{ - public: - UBDocumentUndoCommand(UBDocumentProxy* pDocument, const QList& pOldScenes, - const QList& pNewScenes, const int& pActiveSceneIndex); - virtual ~UBDocumentUndoCommand(); - - virtual UndoType getType() { return undotype_DOCUMENT; }; - - protected: - - virtual void undo(); - virtual void redo(); - - private: - - UBDocumentProxy* mDocument; - QList mUndoScenes; - QList mRedoScenes; - int mActiveSceneIndex; -}; - -#endif /* UBDOCUMENTUNDOCOMMAND_H_ */ diff --git a/src/domain/UBGraphicsItemUndoCommand.cpp b/src/domain/UBGraphicsItemUndoCommand.cpp index daabe22b..36cb74d6 100644 --- a/src/domain/UBGraphicsItemUndoCommand.cpp +++ b/src/domain/UBGraphicsItemUndoCommand.cpp @@ -222,7 +222,7 @@ void UBGraphicsItemUndoCommand::redo() UBGraphicsPolygonItem *polygonItem = qgraphicsitem_cast(item); if (polygonItem) - { + { mScene->removeItem(polygonItem); mScene->removeItemFromDeletion(polygonItem); polygonItem->strokesGroup()->addToGroup(polygonItem); diff --git a/src/domain/UBGraphicsItemUndoCommand.h b/src/domain/UBGraphicsItemUndoCommand.h index f349938f..4e288f37 100644 --- a/src/domain/UBGraphicsItemUndoCommand.h +++ b/src/domain/UBGraphicsItemUndoCommand.h @@ -45,8 +45,8 @@ class UBGraphicsItemUndoCommand : public UBAbstractUndoCommand virtual ~UBGraphicsItemUndoCommand(); - QSet GetAddedList() { return mAddedItems; } - QSet GetRemovedList() { return mRemovedItems; } + QSet GetAddedList() const { return mAddedItems; } + QSet GetRemovedList() const { return mRemovedItems; } virtual UndoType getType() { return undotype_GRAPHICITEM; } diff --git a/src/domain/UBGraphicsScene.cpp b/src/domain/UBGraphicsScene.cpp index 844a5490..a00e2923 100644 --- a/src/domain/UBGraphicsScene.cpp +++ b/src/domain/UBGraphicsScene.cpp @@ -96,6 +96,7 @@ UBZLayerController::UBZLayerController(QGraphicsScene *scene) : scopeMap.insert(itemLayerType::Cache, ItemLayerTypeData( 1001300.0, 1001400.0 )); scopeMap.insert(itemLayerType::SelectedItem, ItemLayerTypeData( 1001000.0, 1001000.0 )); + scopeMap.insert(itemLayerType::SelectionFrame, ItemLayerTypeData( 1010000.0, 1010000.0 )); } qreal UBZLayerController::generateZLevel(itemLayerType::Enum key) @@ -1550,56 +1551,6 @@ UBGraphicsTextItem* UBGraphicsScene::addText(const QString& pString, const QPoin , UBSettings::settings()->isItalicFont()); } -UBGraphicsTextItem* UBGraphicsScene::textForObjectName(const QString& pString, const QString& objectName) -{ - UBGraphicsTextItem* textItem = 0; - bool found = false; - //looking for a previous such item text - for(int i=0; i < mFastAccessItems.count() && !found ; i += 1){ - UBGraphicsTextItem* currentItem = dynamic_cast(mFastAccessItems.at(i)); - if(currentItem && (currentItem->objectName() == objectName || currentItem->toPlainText() == pString)){ - // The second condition is necessary because the object name isn't stored. On reopeining the file we - // need another rule than the objectName - textItem = currentItem; - found=true; - if(currentItem->objectName() != objectName) - textItem->setObjectName(objectName); - } - } - if(!textItem){ - textItem = addTextWithFont(pString,QPointF(0,0) ,72,UBSettings::settings()->fontFamily(),true,false); - textItem->setObjectName(objectName); - textItem->setData(UBGraphicsItemData::ItemEditable,QVariant(false)); - textItem->adjustSize(); - textItem->setTextInteractionFlags(Qt::TextSelectableByMouse | Qt::TextSelectableByKeyboard); - textItem->setPlainText(pString); - } - else{ - textItem->setTextInteractionFlags(Qt::TextSelectableByMouse | Qt::TextSelectableByKeyboard); - if (pString == textItem->toPlainText()) - return textItem; - - QTextCursor curCursor = textItem->textCursor(); - QFont font = textItem->font(); - QColor color = curCursor.charFormat().foreground().color(); - - textItem->setPlainText(pString); - textItem->clearFocus(); - textItem->setFont(font); - - - QTextCharFormat format; - format.setForeground(QBrush(color)); - curCursor.mergeCharFormat(format); - textItem->setTextCursor(curCursor); - textItem->contentsChanged(); - - } - - textItem->clearFocus(); - return textItem; -} - UBGraphicsTextItem* UBGraphicsScene::addTextWithFont(const QString& pString, const QPointF& pTopLeft , int pointSize, const QString& fontFamily, bool bold, bool italic) { @@ -2306,6 +2257,16 @@ void UBGraphicsScene::keyReleaseEvent(QKeyEvent * keyEvent) QList si = selectedItems(); + if(keyEvent->matches(QKeySequence::SelectAll)){ + QListIterator itItems(this->mFastAccessItems); + + while (itItems.hasNext()) + itItems.next()->setSelected(true); + + keyEvent->accept(); + return; + } + if ((si.size() > 0) && (keyEvent->isAccepted())) { #ifdef Q_OS_MAC diff --git a/src/domain/UBGraphicsScene.h b/src/domain/UBGraphicsScene.h index 7a8b638d..2456e8b4 100644 --- a/src/domain/UBGraphicsScene.h +++ b/src/domain/UBGraphicsScene.h @@ -156,7 +156,6 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem UBGraphicsMediaItem* addAudio(const QUrl& pAudioFileUrl, bool shouldPlayAsap, const QPointF& pPos = QPointF(0, 0)); UBGraphicsSvgItem* addSvg(const QUrl& pSvgFileUrl, const QPointF& pPos = QPointF(0, 0), const QByteArray pData = QByteArray()); UBGraphicsTextItem* addText(const QString& pString, const QPointF& pTopLeft = QPointF(0, 0)); - UBGraphicsTextItem* textForObjectName(const QString& pString, const QString &objectName = "UBTGZeroPageSessionTitle"); UBGraphicsTextItem* addTextWithFont(const QString& pString, const QPointF& pTopLeft = QPointF(0, 0) , int pointSize = -1, const QString& fontFamily = "", bool bold = false, bool italic = false); @@ -362,8 +361,8 @@ public slots: void recolorAllItems(); - virtual void drawItems (QPainter * painter, int numItems, - QGraphicsItem * items[], const QStyleOptionGraphicsItem options[], QWidget * widget = 0); + virtual void drawItems (QPainter * painter, int numItems, + QGraphicsItem * items[], const QStyleOptionGraphicsItem options[], QWidget * widget = 0); QGraphicsItem* rootItem(QGraphicsItem* item) const; diff --git a/src/domain/UBGraphicsTextItem.cpp b/src/domain/UBGraphicsTextItem.cpp index b69632c1..8fc2cf8c 100644 --- a/src/domain/UBGraphicsTextItem.cpp +++ b/src/domain/UBGraphicsTextItem.cpp @@ -88,6 +88,8 @@ QVariant UBGraphicsTextItem::itemChange(GraphicsItemChange change, const QVarian void UBGraphicsTextItem::mousePressEvent(QGraphicsSceneMouseEvent *event) { + setTextInteractionFlags(Qt::TextEditorInteraction); + // scene()->itemAt(pos) returns 0 if pos is not over text, but over text item, but mouse press comes. // It is a cludge... if (UBStylusTool::Play == UBDrawingController::drawingController()->stylusTool()) @@ -144,7 +146,6 @@ void UBGraphicsTextItem::mousePressEvent(QGraphicsSceneMouseEvent *event) if (mMultiClickState == 1) { -// setTextInteractionFlags(Qt::TextEditorInteraction); QGraphicsTextItem::mousePressEvent(event); setFocus(); } @@ -213,9 +214,12 @@ void UBGraphicsTextItem::paint(QPainter *painter, const QStyleOptionGraphicsItem if (widget == UBApplication::boardController->controlView()->viewport() && !isSelected() && toPlainText().isEmpty()) { + QFontMetrics fm(font()); + setTextWidth(fm.width(mTypeTextHereLabel)); painter->setFont(font()); painter->setPen(UBSettings::paletteColor); painter->drawText(boundingRect(), Qt::AlignCenter, mTypeTextHereLabel); + setTextInteractionFlags(Qt::NoTextInteraction); } Delegate()->postpaint(painter, option, widget); @@ -246,10 +250,6 @@ void UBGraphicsTextItem::copyItemParameters(UBItem *copy) const cp->setData(UBGraphicsItemData::ItemLayerType, this->data(UBGraphicsItemData::ItemLayerType)); cp->setData(UBGraphicsItemData::ItemLocked, this->data(UBGraphicsItemData::ItemLocked)); cp->setData(UBGraphicsItemData::ItemEditable, data(UBGraphicsItemData::ItemEditable).toBool()); - // cp->setDefaultTextColor(this->defaultTextColor()); - // cp->setFont(this->font()); - // cp->setColorOnDarkBackground(this->colorOnDarkBackground()); - // cp->setColorOnLightBackground(this->colorOnLightBackground()); cp->setTextWidth(this->textWidth()); cp->setTextHeight(this->textHeight()); @@ -275,15 +275,9 @@ QPainterPath UBGraphicsTextItem::shape() const void UBGraphicsTextItem::setTextWidth(qreal width) { QFontMetrics fm(font()); - qreal strictMin = fm.height(); + qreal strictMin = 155; // the size of the font customization panel qreal newWidth = qMax(strictMin, width); - if (toPlainText().isEmpty()) - { - qreal minWidth = fm.width(mTypeTextHereLabel); - newWidth = qMax(minWidth, newWidth); - } - QGraphicsTextItem::setTextWidth(newWidth); } @@ -313,7 +307,7 @@ void UBGraphicsTextItem::contentsChanged() if (toPlainText().isEmpty()) { - setTextWidth(textWidth()); + resize(textWidth(),textHeight()); } } @@ -356,3 +350,9 @@ void UBGraphicsTextItem::documentSizeChanged(const QSizeF & newSize) { resize(newSize.width(), newSize.height()); } + +void UBGraphicsTextItem::setHtml(const QString &text) +{ + QGraphicsTextItem::setHtml(text); + setTextInteractionFlags(Qt::NoTextInteraction); +} diff --git a/src/domain/UBGraphicsTextItem.h b/src/domain/UBGraphicsTextItem.h index 06d4133b..637021e8 100644 --- a/src/domain/UBGraphicsTextItem.h +++ b/src/domain/UBGraphicsTextItem.h @@ -90,6 +90,7 @@ class UBGraphicsTextItem : public QGraphicsTextItem, public UBItem, public UBRes virtual void clearSource(){;} virtual void setUuid(const QUuid &pUuid); + void setHtml(const QString &text); signals: void textUndoCommandAdded(UBGraphicsTextItem *textItem); @@ -107,7 +108,6 @@ class UBGraphicsTextItem : public QGraphicsTextItem, public UBItem, public UBRes virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value); - private: qreal mTextHeight; int mMultiClickState; diff --git a/src/domain/UBGraphicsTextItemDelegate.cpp b/src/domain/UBGraphicsTextItemDelegate.cpp index fe76a9cf..86b196cb 100644 --- a/src/domain/UBGraphicsTextItemDelegate.cpp +++ b/src/domain/UBGraphicsTextItemDelegate.cpp @@ -132,7 +132,7 @@ void UBGraphicsTextItemDelegate::customize(QFontDialog &fontDialog) fontDialog.setStyleSheet("background-color: white;"); } - QListView *fontNameListView; + QListView *fontNameListView = NULL; QList listViews = fontDialog.findChildren(); if (listViews.count() > 0) { diff --git a/src/domain/UBSelectionFrame.cpp b/src/domain/UBSelectionFrame.cpp index b849fc62..c50e4c45 100644 --- a/src/domain/UBSelectionFrame.cpp +++ b/src/domain/UBSelectionFrame.cpp @@ -23,6 +23,7 @@ UBSelectionFrame::UBSelectionFrame() setLocalBrush(QBrush(UBSettings::paletteColor)); setPen(Qt::NoPen); setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Control)); + setData(UBGraphicsItemData::itemLayerType, QVariant(itemLayerType::SelectionFrame)); //Necessary to set if we want z value to be assigned correctly setFlags(QGraphicsItem::ItemSendsGeometryChanges | QGraphicsItem::ItemIsSelectable | ItemIsMovable); connect(UBApplication::boardController, SIGNAL(zoomChanged(qreal)), this, SLOT(onZoomChanged(qreal))); @@ -200,7 +201,7 @@ void UBSelectionFrame::mouseReleaseEvent(QGraphicsSceneMouseEvent */*event*/) mPressedPos = mLastMovedPos = mLastTranslateOffset = QPointF(); if (mOperationMode == om_moving || mOperationMode == om_rotating) { - UBApplication::undoStack->beginMacro("TransformationMacro"); + UBApplication::undoStack->beginMacro(UBSettings::undoCommandTransactionName); foreach (UBGraphicsItemDelegate *d, mEnclosedtems) { d->commitUndoStep(); } @@ -230,7 +231,7 @@ void UBSelectionFrame::onZoomChanged(qreal pZoom) void UBSelectionFrame::remove() { - UBApplication::undoStack->beginMacro("RemovingSelected"); + UBApplication::undoStack->beginMacro(UBSettings::undoCommandTransactionName); foreach (UBGraphicsItemDelegate *d, mEnclosedtems) { d->remove(true); } @@ -241,7 +242,7 @@ void UBSelectionFrame::remove() void UBSelectionFrame::duplicate() { - UBApplication::undoStack->beginMacro("RemovingSelected"); + UBApplication::undoStack->beginMacro(UBSettings::undoCommandTransactionName); foreach (UBGraphicsItemDelegate *d, mEnclosedtems) { d->duplicate(); } @@ -250,6 +251,34 @@ void UBSelectionFrame::duplicate() updateRect(); } +void UBSelectionFrame::increaseZlevelUp() +{ + foreach (QGraphicsItem *item, sortedByZ(scene()->selectedItems())) { + ubscene()->changeZLevelTo(item, UBZLayerController::up); + } +} + +void UBSelectionFrame::increaseZlevelTop() +{ + foreach (QGraphicsItem *item, sortedByZ(scene()->selectedItems())) { + ubscene()->changeZLevelTo(item, UBZLayerController::top); + } +} + +void UBSelectionFrame::increaseZlevelDown() +{ + foreach (QGraphicsItem *item, sortedByZ(scene()->selectedItems())) { + ubscene()->changeZLevelTo(item, UBZLayerController::down); + } +} + +void UBSelectionFrame::increaseZlevelBottom() +{ + foreach (QGraphicsItem *item, sortedByZ(scene()->selectedItems())) { + ubscene()->changeZLevelTo(item, UBZLayerController::bottom); + } +} + void UBSelectionFrame::translateItem(QGraphicsItem */*item*/, const QPointF &/*translatePoint*/) { } @@ -327,6 +356,20 @@ inline UBGraphicsScene *UBSelectionFrame::ubscene() return qobject_cast(scene()); } +QList UBSelectionFrame::sortedByZ(const QList &pItems) +{ + //select only items wiht the same z-level as item's one and push it to sortedItems QMultiMap + QMultiMap sortedItems; + foreach (QGraphicsItem *tmpItem, pItems) { + if (tmpItem->type() == Type) { + continue; + } + sortedItems.insert(tmpItem->data(UBGraphicsItemData::ItemOwnZValue).toReal(), tmpItem); + } + + return sortedItems.values(); +} + QList UBSelectionFrame::buttonsForFlags(UBGraphicsFlags fls) { qDebug() << "buttons for flags" << QString::number((int)fls, 2); @@ -351,15 +394,15 @@ QList UBSelectionFrame::buttonsForFlags(UBGraphicsFlags fls) { if (!mZOrderUpButton) { mZOrderUpButton = new DelegateButton(":/images/z_layer_up.svg", this, 0, Qt::BottomLeftSection); mZOrderUpButton->setShowProgressIndicator(true); - // connect(mZOrderUpButton, SIGNAL(clicked()), this, SLOT(increaseZLevelUp())); - // connect(mZOrderUpButton, SIGNAL(longClicked()), this, SLOT(increaseZlevelTop())); + connect(mZOrderUpButton, SIGNAL(clicked()), this, SLOT(increaseZlrfevelUp())); + connect(mZOrderUpButton, SIGNAL(longClicked()), this, SLOT(increaseZlevelTop())); } if (!mZOrderDownButton) { mZOrderDownButton = new DelegateButton(":/images/z_layer_down.svg", this, 0, Qt::BottomLeftSection); mZOrderDownButton->setShowProgressIndicator(true); - // connect(mZOrderDownButton, SIGNAL(clicked()), this, SLOT(increaseZLevelDown())); - // connect(mZOrderDownButton, SIGNAL(longClicked()), this, SLOT(increaseZlevelBottom())); + connect(mZOrderDownButton, SIGNAL(clicked()), this, SLOT(increaseZlevelDown())); + connect(mZOrderDownButton, SIGNAL(longClicked()), this, SLOT(increaseZlevelBottom())); } result << mZOrderUpButton; diff --git a/src/domain/UBSelectionFrame.h b/src/domain/UBSelectionFrame.h index 333ae7cc..18278c17 100644 --- a/src/domain/UBSelectionFrame.h +++ b/src/domain/UBSelectionFrame.h @@ -15,6 +15,7 @@ class UBSelectionFrame : public QObject, public QGraphicsRectItem public: enum {om_idle, om_moving, om_rotating} mOperationMode; + enum { Type = UBGraphicsItemType::PixmapItemType }; UBSelectionFrame(); @@ -29,6 +30,7 @@ public: void updateRect(); void updateScale(); bool isEmpty() const {return this->rect().isEmpty();} + virtual int type() const {return Type;} protected: void mousePressEvent(QGraphicsSceneMouseEvent *event); @@ -40,6 +42,10 @@ private slots: void onZoomChanged(qreal pZoom); void remove(); void duplicate(); + void increaseZlevelUp(); + void increaseZlevelTop(); + void increaseZlevelDown(); + void increaseZlevelBottom(); private: void translateItem(QGraphicsItem *item, const QPointF &translatePoint); @@ -49,6 +55,7 @@ private: inline int adjThickness() const {return mThickness * mAntiscaleRatio;} inline UBGraphicsScene* ubscene(); + QList sortedByZ(const QList &pItems); QList buttonsForFlags(UBGraphicsFlags fls); diff --git a/src/domain/domain.pri b/src/domain/domain.pri index 601e1f7d..93172f49 100644 --- a/src/domain/domain.pri +++ b/src/domain/domain.pri @@ -3,7 +3,6 @@ HEADERS += src/domain/UBGraphicsScene.h \ src/domain/UBGraphicsTextItemUndoCommand.h \ src/domain/UBGraphicsItemTransformUndoCommand.h \ src/domain/UBGraphicsPixmapItem.h \ - src/domain/UBDocumentUndoCommand.h \ src/domain/UBPageSizeUndoCommand.h \ src/domain/UBGraphicsProxyWidget.h \ src/domain/UBGraphicsSvgItem.h \ @@ -26,13 +25,12 @@ HEADERS += src/domain/UBGraphicsScene.h \ src/domain/UBGraphicsWidgetItemDelegate.h \ src/domain/UBGraphicsMediaItemDelegate.h \ src/domain/UBSelectionFrame.h - + SOURCES += src/domain/UBGraphicsScene.cpp \ src/domain/UBGraphicsItemUndoCommand.cpp \ src/domain/UBGraphicsTextItemUndoCommand.cpp \ src/domain/UBGraphicsItemTransformUndoCommand.cpp \ src/domain/UBGraphicsPixmapItem.cpp \ - src/domain/UBDocumentUndoCommand.cpp \ src/domain/UBPageSizeUndoCommand.cpp \ src/domain/UBGraphicsProxyWidget.cpp \ src/domain/UBGraphicsSvgItem.cpp \ diff --git a/src/frameworks/UBCryptoUtils.cpp b/src/frameworks/UBCryptoUtils.cpp index b5df8ccd..ea6b46f2 100644 --- a/src/frameworks/UBCryptoUtils.cpp +++ b/src/frameworks/UBCryptoUtils.cpp @@ -68,15 +68,21 @@ QString UBCryptoUtils::symetricEncrypt(const QString& clear) int paddingLength = 0; unsigned char *ciphertext = (unsigned char *)malloc(cipheredLength); - if(!EVP_EncryptInit_ex(&mAesEncryptContext, NULL, NULL, NULL, NULL)) + if(!EVP_EncryptInit_ex(&mAesEncryptContext, NULL, NULL, NULL, NULL)){ + free(ciphertext); return QString(); + } - if(!EVP_EncryptUpdate(&mAesEncryptContext, ciphertext, &cipheredLength, (unsigned char *)clearData.data(), clearData.length())) + if(!EVP_EncryptUpdate(&mAesEncryptContext, ciphertext, &cipheredLength, (unsigned char *)clearData.data(), clearData.length())){ + free(ciphertext); return QString(); + } /* update ciphertext with the final remaining bytes */ - if(!EVP_EncryptFinal_ex(&mAesEncryptContext, ciphertext + cipheredLength, &paddingLength)) + if(!EVP_EncryptFinal_ex(&mAesEncryptContext, ciphertext + cipheredLength, &paddingLength)){ + free(ciphertext); return QString(); + } QByteArray cipheredData((const char *)ciphertext, cipheredLength + paddingLength); @@ -94,14 +100,20 @@ QString UBCryptoUtils::symetricDecrypt(const QString& encrypted) int paddingLength = 0; unsigned char *plaintext = (unsigned char *)malloc(encryptedLength); - if(!EVP_DecryptInit_ex(&mAesDecryptContext, NULL, NULL, NULL, NULL)) + if(!EVP_DecryptInit_ex(&mAesDecryptContext, NULL, NULL, NULL, NULL)){ + free(plaintext); return QString(); + } - if(!EVP_DecryptUpdate(&mAesDecryptContext, plaintext, &encryptedLength, (const unsigned char *)encryptedData.data(), encryptedData.length())) + if(!EVP_DecryptUpdate(&mAesDecryptContext, plaintext, &encryptedLength, (const unsigned char *)encryptedData.data(), encryptedData.length())){ + free(plaintext); return QString(); + } - if(!EVP_DecryptFinal_ex(&mAesDecryptContext, plaintext + encryptedLength, &paddingLength)) + if(!EVP_DecryptFinal_ex(&mAesDecryptContext, plaintext + encryptedLength, &paddingLength)){ + free(plaintext); return QString(); + } int len = encryptedLength + paddingLength; QByteArray clearData((const char *)plaintext, len); diff --git a/src/frameworks/UBFileSystemUtils.cpp b/src/frameworks/UBFileSystemUtils.cpp index 49f37cbd..fb594057 100644 --- a/src/frameworks/UBFileSystemUtils.cpp +++ b/src/frameworks/UBFileSystemUtils.cpp @@ -27,8 +27,6 @@ #include "core/UBApplication.h" -#include "document/UBDocumentContainer.h" - #include "globals/UBGlobals.h" THIRD_PARTY_WARNINGS_DISABLE @@ -352,8 +350,7 @@ QString UBFileSystemUtils::normalizeFilePath(const QString& pFilePath) QString UBFileSystemUtils::digitFileFormat(const QString& s, int digit) { - int pageDigit = UBDocumentContainer::pageFromSceneIndex(digit); - return s.arg(pageDigit, 3, 10, QLatin1Char('0')); + return s.arg(digit, 3, 10, QLatin1Char('0')); } @@ -361,8 +358,7 @@ QString UBFileSystemUtils::thumbnailPath(const QString& path) { QFileInfo pathInfo(path); - return pathInfo.dir().absolutePath() + "/" + pathInfo.completeBaseName() - + ".thumbnail.png"; + return pathInfo.dir().absolutePath() + "/" + pathInfo.completeBaseName() + ".thumbnail.png"; } QString UBFileSystemUtils::extension(const QString& fileName) @@ -632,8 +628,7 @@ QString UBFileSystemUtils::getFirstExistingFileFromList(const QString& path, con } -bool UBFileSystemUtils::compressDirInZip(const QDir& pDir, const QString& pDestPath, - QuaZipFile *pOutZipFile, bool pRootDocumentFolder, UBProcessingProgressListener* progressListener) +bool UBFileSystemUtils::compressDirInZip(const QDir& pDir, const QString& pDestPath, QuaZipFile *pOutZipFile, bool pRootDocumentFolder, UBProcessingProgressListener* progressListener) { QFileInfoList files = pDir.entryInfoList(QDir::AllDirs | QDir::Files | QDir::NoDotAndDotDot); diff --git a/src/gui/UBDockTeacherGuideWidget.cpp b/src/gui/UBDockTeacherGuideWidget.cpp deleted file mode 100644 index 7a1401a9..00000000 --- a/src/gui/UBDockTeacherGuideWidget.cpp +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (C) 2010-2013 Groupement d'Intérêt Public pour l'Education Numérique en Afrique (GIP ENA) - * - * This file is part of Open-Sankoré. - * - * Open-Sankoré 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, version 3 of the License, - * with a specific linking exception for the OpenSSL project's - * "OpenSSL" library (or with modified versions of it that use the - * same license as the "OpenSSL" library). - * - * Open-Sankoré 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 Open-Sankoré. If not, see . - */ - - - -#include "core/UBApplication.h" -#include "globals/UBGlobals.h" - -#include "UBDockTeacherGuideWidget.h" -#include "UBTeacherGuideWidget.h" - -#include "core/memcheck.h" - - -UBDockTeacherGuideWidget::UBDockTeacherGuideWidget(QWidget* parent, const char* name): - UBDockPaletteWidget(parent,name) - , mpTeacherGuideWidget(NULL) -{ - mName = "TeacherGuide"; - mVisibleState = true; - SET_STYLE_SHEET(); - - mIconToLeft = QPixmap(":images/teacher_open.png"); - mIconToRight = QPixmap(":images/teacher_close.png"); - - mpLayout = new QVBoxLayout(this); - setLayout(mpLayout); - mpTeacherGuideWidget = new UBTeacherGuideWidget(this); - mpLayout->addWidget(mpTeacherGuideWidget); -} - -UBDockTeacherGuideWidget::~UBDockTeacherGuideWidget() -{ - DELETEPTR(mpTeacherGuideWidget); - DELETEPTR(mpLayout); -} - -UBTeacherGuideWidget* UBDockTeacherGuideWidget::teacherGuideWidget() -{ - return mpTeacherGuideWidget; -} diff --git a/src/gui/UBDockTeacherGuideWidget.h b/src/gui/UBDockTeacherGuideWidget.h deleted file mode 100644 index fe33410c..00000000 --- a/src/gui/UBDockTeacherGuideWidget.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (C) 2010-2013 Groupement d'Intérêt Public pour l'Education Numérique en Afrique (GIP ENA) - * - * This file is part of Open-Sankoré. - * - * Open-Sankoré 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, version 3 of the License, - * with a specific linking exception for the OpenSSL project's - * "OpenSSL" library (or with modified versions of it that use the - * same license as the "OpenSSL" library). - * - * Open-Sankoré 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 Open-Sankoré. If not, see . - */ - - - -#ifndef UBDOCKTEACHERGUIDEWIDGET_H -#define UBDOCKTEACHERGUIDEWIDGET_H - -class QVBoxLayout; -class UBTeacherGuideWidget; - -#include "UBDockPaletteWidget.h" - - -class UBDockTeacherGuideWidget : public UBDockPaletteWidget -{ - Q_OBJECT -public: - UBDockTeacherGuideWidget(QWidget* parent=0, const char* name="UBDockTeacherGuideWidget"); - ~UBDockTeacherGuideWidget(); - - bool visibleInMode(eUBDockPaletteWidgetMode mode){ return mode == eUBDockPaletteWidget_BOARD; } - - UBTeacherGuideWidget* teacherGuideWidget(); - -private: - QVBoxLayout* mpLayout; - UBTeacherGuideWidget* mpTeacherGuideWidget; -}; - -#endif // UBDOCKTEACHERGUIDEWIDGET_H diff --git a/src/gui/UBDocumentNavigator.cpp b/src/gui/UBDocumentNavigator.cpp index ccf5d518..11f5400d 100644 --- a/src/gui/UBDocumentNavigator.cpp +++ b/src/gui/UBDocumentNavigator.cpp @@ -52,6 +52,7 @@ UBDocumentNavigator::UBDocumentNavigator(QWidget *parent, const char *name):QGra , mNbColumns(1) , mThumbnailWidth(0) , mThumbnailMinWidth(100) + , mSelectedThumbnail(NULL) { setObjectName(name); mScene = new QGraphicsScene(this); @@ -78,9 +79,6 @@ UBDocumentNavigator::~UBDocumentNavigator() } } -#include "gui/UBDockTeacherGuideWidget.h" -#include "gui/UBTeacherGuideWidget.h" - /** * \brief Generate the thumbnails */ @@ -103,7 +101,7 @@ void UBDocumentNavigator::generateThumbnails(UBDocumentContainer* source) UBSceneThumbnailNavigPixmap* pixmapItem = new UBSceneThumbnailNavigPixmap(*pix, source->selectedDocument(), i); - QString label = pageIndex == 0 ? tr("Title page") : tr("Page %0").arg(pageIndex); + QString label = tr("Page %0").arg(pageIndex); UBThumbnailTextItem *labelItem = new UBThumbnailTextItem(label); UBImgTextThumbnailElement thumbWithText(pixmapItem, labelItem); @@ -113,7 +111,7 @@ void UBDocumentNavigator::generateThumbnails(UBDocumentContainer* source) mScene->addItem(pixmapItem); mScene->addItem(labelItem); } - + // Draw the items refreshScene(); } @@ -126,6 +124,7 @@ void UBDocumentNavigator::onScrollToSelectedPage(int index) if (c==index) { el.getThumbnail()->setSelected(true); + mSelectedThumbnail = el.getThumbnail(); } else { @@ -133,6 +132,7 @@ void UBDocumentNavigator::onScrollToSelectedPage(int index) } c++; } + centerOn(mSelectedThumbnail); } /** @@ -141,9 +141,6 @@ void UBDocumentNavigator::onScrollToSelectedPage(int index) */ void UBDocumentNavigator::updateSpecificThumbnail(int iPage) { - // Generate the new thumbnail - //UBGraphicsScene* pScene = UBApplication::boardController->activeScene(); - const QPixmap* pix = UBApplication::boardController->pageAt(iPage); UBSceneThumbnailNavigPixmap* newItem = new UBSceneThumbnailNavigPixmap(*pix, UBApplication::boardController->selectedDocument(), iPage); @@ -234,6 +231,9 @@ void UBDocumentNavigator::resizeEvent(QResizeEvent *event) // Update the thumbnails width mThumbnailWidth = (width() > mThumbnailMinWidth) ? width() - 2*border() : mThumbnailMinWidth; + if(mSelectedThumbnail) + centerOn(mSelectedThumbnail); + // Refresh the scene refreshScene(); } @@ -255,7 +255,7 @@ void UBDocumentNavigator::mousePressEvent(QMouseEvent *event) { // If we fall here we may have clicked on the label instead of the thumbnail UBThumbnailTextItem* pTextItem = dynamic_cast(pClickedItem); - if(NULL != pTextItem) + if(NULL != pTextItem) { for(int i = 0; i < mThumbsWithLabels.size(); i++) { diff --git a/src/gui/UBDocumentNavigator.h b/src/gui/UBDocumentNavigator.h index ad5fcf31..d323dbd6 100644 --- a/src/gui/UBDocumentNavigator.h +++ b/src/gui/UBDocumentNavigator.h @@ -59,7 +59,7 @@ protected: virtual void mouseReleaseEvent(QMouseEvent *event); private: - + void refreshScene(); int border(); @@ -76,6 +76,8 @@ private: int mThumbnailWidth; /** The current thumbnails minimum width */ int mThumbnailMinWidth; + /** The selected thumbnail */ + UBSceneThumbnailNavigPixmap* mSelectedThumbnail; }; - + #endif // UBDOCUMENTNAVIGATOR_H diff --git a/src/gui/UBDocumentThumbnailWidget.cpp b/src/gui/UBDocumentThumbnailWidget.cpp index 667e91f3..588eccb9 100644 --- a/src/gui/UBDocumentThumbnailWidget.cpp +++ b/src/gui/UBDocumentThumbnailWidget.cpp @@ -65,7 +65,7 @@ void UBDocumentThumbnailWidget::mouseMoveEvent(QMouseEvent *event) return; if ((event->pos() - mMousePressPos).manhattanLength() < QApplication::startDragDistance()) - return; + return; QList graphicsItems = items(mMousePressPos); @@ -76,21 +76,18 @@ void UBDocumentThumbnailWidget::mouseMoveEvent(QMouseEvent *event) if (sceneItem) { - int pageIndex = UBDocumentContainer::pageFromSceneIndex(sceneItem->sceneIndex()); - if(pageIndex != 0){ - QDrag *drag = new QDrag(this); - QList mimeDataItems; - foreach (QGraphicsItem *item, selectedItems()) - mimeDataItems.append(UBMimeDataItem(sceneItem->proxy(), mGraphicItems.indexOf(item))); + QDrag *drag = new QDrag(this); + QList mimeDataItems; + foreach (QGraphicsItem *item, selectedItems()) + mimeDataItems.append(UBMimeDataItem(sceneItem->proxy(), mGraphicItems.indexOf(item))); - UBMimeData *mime = new UBMimeData(mimeDataItems); - drag->setMimeData(mime); + UBMimeData *mime = new UBMimeData(mimeDataItems); + drag->setMimeData(mime); - drag->setPixmap(sceneItem->pixmap().scaledToWidth(100)); - drag->setHotSpot(QPoint(drag->pixmap().width()/2, drag->pixmap().height() / 2)); + drag->setPixmap(sceneItem->pixmap().scaledToWidth(100)); + drag->setHotSpot(QPoint(drag->pixmap().width()/2, drag->pixmap().height() / 2)); - drag->exec(Qt::MoveAction); - } + drag->exec(Qt::MoveAction); } UBThumbnailWidget::mouseMoveEvent(event); @@ -159,40 +156,31 @@ void UBDocumentThumbnailWidget::dragMoveEvent(QDragMoveEvent *event) QGraphicsItem *underlyingItem = itemAt(event->pos()); mClosestDropItem = dynamic_cast(underlyingItem); - int pageIndex = -1; - if(mClosestDropItem){ - pageIndex = UBDocumentContainer::pageFromSceneIndex(mClosestDropItem->sceneIndex()); - if(pageIndex == 0){ - event->acceptProposedAction(); - return; - } - } if (!mClosestDropItem) { foreach (UBSceneThumbnailPixmap *item, pixmapItems) { qreal scale = item->transform().m11(); QPointF itemCenter( - item->pos().x() + item->boundingRect().width() * scale / 2, - item->pos().y() + item->boundingRect().height() * scale / 2); + item->pos().x() + item->boundingRect().width() * scale / 2, + item->pos().y() + item->boundingRect().height() * scale / 2); int distance = (itemCenter.toPoint() - mapToScene(event->pos()).toPoint()).manhattanLength(); if (!mClosestDropItem || distance < minDistance) { mClosestDropItem = item; minDistance = distance; - pageIndex = UBDocumentContainer::pageFromSceneIndex(mClosestDropItem->sceneIndex()); } } } - if (mClosestDropItem && pageIndex != 0) + if (mClosestDropItem) { qreal scale = mClosestDropItem->transform().m11(); QPointF itemCenter( - mClosestDropItem->pos().x() + mClosestDropItem->boundingRect().width() * scale / 2, - mClosestDropItem->pos().y() + mClosestDropItem->boundingRect().height() * scale / 2); + mClosestDropItem->pos().x() + mClosestDropItem->boundingRect().width() * scale / 2, + mClosestDropItem->pos().y() + mClosestDropItem->boundingRect().height() * scale / 2); mDropIsRight = mapToScene(event->pos()).x() > itemCenter.x(); @@ -204,10 +192,10 @@ void UBDocumentThumbnailWidget::dragMoveEvent(QDragMoveEvent *event) } QRectF dropCaretRect( - mDropIsRight ? mClosestDropItem->pos().x() + mClosestDropItem->boundingRect().width() * scale + spacing() / 2 - 1 : mClosestDropItem->pos().x() - spacing() / 2 - 1, - mClosestDropItem->pos().y(), - 3, - mClosestDropItem->boundingRect().height() * scale); + mDropIsRight ? mClosestDropItem->pos().x() + mClosestDropItem->boundingRect().width() * scale + spacing() / 2 - 1 : mClosestDropItem->pos().x() - spacing() / 2 - 1, + mClosestDropItem->pos().y(), + 3, + mClosestDropItem->boundingRect().height() * scale); if (mDropCaretRectItem) mDropCaretRectItem->setRect(dropCaretRect); @@ -229,10 +217,6 @@ void UBDocumentThumbnailWidget::dropEvent(QDropEvent *event) if (mClosestDropItem) { int targetIndex = mDropIsRight ? mGraphicItems.indexOf(mClosestDropItem) + 1 : mGraphicItems.indexOf(mClosestDropItem); - if(UBDocumentContainer::pageFromSceneIndex(targetIndex) == 0){ - event->ignore(); - return; - } QList mimeDataItems; if (event->mimeData()->hasFormat(UBApplication::mimeTypeUniboardPage)) @@ -243,9 +227,9 @@ void UBDocumentThumbnailWidget::dropEvent(QDropEvent *event) } if (1 == mimeDataItems.count() && - (mimeDataItems.at(0).sceneIndex() == mGraphicItems.indexOf(mClosestDropItem) || - targetIndex == mimeDataItems.at(0).sceneIndex() || - targetIndex == mimeDataItems.at(0).sceneIndex() + 1)) + (mimeDataItems.at(0).sceneIndex() == mGraphicItems.indexOf(mClosestDropItem) || + targetIndex == mimeDataItems.at(0).sceneIndex() || + targetIndex == mimeDataItems.at(0).sceneIndex() + 1)) { return; } @@ -288,8 +272,8 @@ void UBDocumentThumbnailWidget::deleteDropCaret() } void UBDocumentThumbnailWidget::setGraphicsItems(const QList& pGraphicsItems, - const QList& pItemPaths, const QStringList pLabels, - const QString& pMimeType) + const QList& pItemPaths, const QStringList pLabels, + const QString& pMimeType) { deleteDropCaret(); diff --git a/src/gui/UBNavigatorPalette.cpp b/src/gui/UBNavigatorPalette.cpp deleted file mode 100644 index 6ad9505d..00000000 --- a/src/gui/UBNavigatorPalette.cpp +++ /dev/null @@ -1,153 +0,0 @@ -/* - * Copyright (C) 2010-2013 Groupement d'Intérêt Public pour l'Education Numérique en Afrique (GIP ENA) - * - * This file is part of Open-Sankoré. - * - * Open-Sankoré 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, version 3 of the License, - * with a specific linking exception for the OpenSSL project's - * "OpenSSL" library (or with modified versions of it that use the - * same license as the "OpenSSL" library). - * - * Open-Sankoré 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 Open-Sankoré. If not, see . - */ - - - -#include "UBNavigatorPalette.h" -#include "core/UBApplication.h" -#include "board/UBBoardController.h" - -#include "core/memcheck.h" - -/** - * \brief Constructor - * @param parent as the parent widget - * @param name as the object name - */ -UBNavigatorPalette::UBNavigatorPalette(QWidget *parent, const char *name): - UBDockPalette(eUBDockPaletteType_LEFT, parent, name) - , mNavigator(NULL) - , mLayout(NULL) - , mHLayout(NULL) - , mPageNbr(NULL) - , mClock(NULL) -{ - // Build the gui - mLayout = new QVBoxLayout(this); - mLayout->setContentsMargins(customMargin(), customMargin(), 2*border() + customMargin(), customMargin()); - setLayout(mLayout); - - mNavigator = new UBDocumentNavigator(this); - mNavigator->setStyleSheet(QString("background-color : transparent;")); - mLayout->addWidget(mNavigator, 1); - - mHLayout = new QHBoxLayout(); - mLayout->addLayout(mHLayout, 0); - - mPageNbr = new QLabel(this); - mClock = new QLabel(this); - mHLayout->addWidget(mPageNbr); - mHLayout->addWidget(mClock); - - // Configure the page number indicator - mPageNbr->setStyleSheet(QString("QLabel { color: white; background-color: transparent; border: none; font-family: Arial; font-weight: bold; font-size: 20px }")); - setPageNumber(0, 0); - mPageNbr->setAlignment(Qt::AlignHCenter); - - // Configure the clock - mClock->setStyleSheet(QString("QLabel {color: white; background-color: transparent; text-align: center; font-family: Arial; font-weight: bold; font-size: 20px}")); - mTimeFormat = QLocale::system().timeFormat(QLocale::ShortFormat); - mClock->setAlignment(Qt::AlignHCenter); - - //strip seconds - mTimeFormat = mTimeFormat.remove(":ss"); - mTimeFormat = mTimeFormat.remove(":s"); - mTimerID = startTimer(1000); - -} - -/** - * \brief Destructor - */ -UBNavigatorPalette::~UBNavigatorPalette() -{ - killTimer(mTimerID); - - if(NULL != mClock) - { - delete mClock; - mClock = NULL; - } - if(NULL != mPageNbr) - { - delete mPageNbr; - mPageNbr = NULL; - } - if(NULL != mHLayout) - { - delete mHLayout; - mHLayout = NULL; - } - if(NULL != mLayout) - { - delete mLayout; - mLayout = NULL; - } - if(NULL != mNavigator) - { - delete mNavigator; - mNavigator = NULL; - } -} - -/** - * \brief Set the current document in the navigator - * @param document as the given document - */ - -/** - * \brief Refresh the thumbnails widget - */ -void UBNavigatorPalette::refresh() -{ -} - -/** - * \brief Handle the resize event - * @param event as the resize event - */ -void UBNavigatorPalette::resizeEvent(QResizeEvent *event) -{ - UBDockPalette::resizeEvent(event); - if(NULL != mNavigator) - { - mNavigator->setMinimumHeight(height() - 2*border()); - } -} - -void UBNavigatorPalette::timerEvent(QTimerEvent *event) -{ - Q_UNUSED(event); - updateTime(); -} - -void UBNavigatorPalette::updateTime() -{ - if (mClock) - { - mClock->setText(QLocale::system().toString (QTime::currentTime(), mTimeFormat)); - } -} - -void UBNavigatorPalette::setPageNumber(int current, int total) -{ - mPageNbr->setText(QString("%1 / %2").arg(current).arg(total)); -} diff --git a/src/gui/UBNavigatorPalette.h b/src/gui/UBNavigatorPalette.h deleted file mode 100644 index b09cd08a..00000000 --- a/src/gui/UBNavigatorPalette.h +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (C) 2010-2013 Groupement d'Intérêt Public pour l'Education Numérique en Afrique (GIP ENA) - * - * This file is part of Open-Sankoré. - * - * Open-Sankoré 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, version 3 of the License, - * with a specific linking exception for the OpenSSL project's - * "OpenSSL" library (or with modified versions of it that use the - * same license as the "OpenSSL" library). - * - * Open-Sankoré 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 Open-Sankoré. If not, see . - */ - - - -#ifndef UBNAVIGATORPALETTE_H -#define UBNAVIGATORPALETTE_H - -#include -#include -#include -#include -#include -#include -#include - -#include "UBDockPalette.h" -#include "UBDocumentNavigator.h" -#include "document/UBDocumentProxy.h" - - -class UBNavigatorPalette : public UBDockPalette -{ - Q_OBJECT -public: - UBNavigatorPalette(QWidget* parent=0, const char* name="navigatorPalette"); - ~UBNavigatorPalette(); - - void setDocument(UBDocumentProxy* document); - void refresh(); - -public slots: - void setPageNumber(int current, int total); - -protected: - virtual void resizeEvent(QResizeEvent *event); - virtual void timerEvent(QTimerEvent *event); - -private: - void updateTime(); - - /** The thumbnails navigator widget */ - UBDocumentNavigator* mNavigator; - /** The layout */ - QVBoxLayout* mLayout; - QHBoxLayout* mHLayout; - QLabel* mPageNbr; - QLabel* mClock; - QString mTimeFormat; - int mTimerID; - -}; - - -#endif // UBNAVIGATORPALETTE_H diff --git a/src/gui/UBPageNavigationWidget.cpp b/src/gui/UBPageNavigationWidget.cpp index 9d1646ee..eca3c674 100644 --- a/src/gui/UBPageNavigationWidget.cpp +++ b/src/gui/UBPageNavigationWidget.cpp @@ -119,16 +119,6 @@ UBPageNavigationWidget::~UBPageNavigationWidget() } } - -/** - * \brief Refresh the thumbnails widget - */ -void UBPageNavigationWidget::refresh() -{ - // TOLIK!!! - // mNavigator->setDocument(UBApplication::boardController->activeDocument()); -} - /** * \brief Notify a timer event * @param event as the timer event @@ -145,9 +135,7 @@ void UBPageNavigationWidget::timerEvent(QTimerEvent *event) void UBPageNavigationWidget::updateTime() { if (mClock) - { mClock->setText(QLocale::system().toString (QTime::currentTime(), mTimeFormat)); - } } /** @@ -157,7 +145,7 @@ void UBPageNavigationWidget::updateTime() */ void UBPageNavigationWidget::setPageNumber(int current, int total) { - mPageNbr->setText(QString("%1 / %2").arg(current).arg(UBDocumentContainer::sceneIndexFromPage(total))); + mPageNbr->setText(QString("%1 / %2").arg(current).arg(total)); } /** diff --git a/src/gui/UBPageNavigationWidget.h b/src/gui/UBPageNavigationWidget.h index 1299a9f4..a9c22233 100644 --- a/src/gui/UBPageNavigationWidget.h +++ b/src/gui/UBPageNavigationWidget.h @@ -42,8 +42,6 @@ class UBPageNavigationWidget : public UBDockPaletteWidget public: UBPageNavigationWidget(QWidget* parent=0, const char* name="UBPageNavigationWidget"); ~UBPageNavigationWidget(); - //void setDocument(UBDocumentProxy* document); - void refresh(); bool visibleInMode(eUBDockPaletteWidgetMode mode) { diff --git a/src/gui/UBTeacherGuideWidget.cpp b/src/gui/UBTeacherGuideWidget.cpp deleted file mode 100644 index 09520118..00000000 --- a/src/gui/UBTeacherGuideWidget.cpp +++ /dev/null @@ -1,1291 +0,0 @@ -/* - * Copyright (C) 2010-2013 Groupement d'Intérêt Public pour l'Education Numérique en Afrique (GIP ENA) - * - * This file is part of Open-Sankoré. - * - * Open-Sankoré 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, version 3 of the License, - * with a specific linking exception for the OpenSSL project's - * "OpenSSL" library (or with modified versions of it that use the - * same license as the "OpenSSL" library). - * - * Open-Sankoré 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 Open-Sankoré. If not, see . - */ - - - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "UBTeacherGuideWidget.h" - -#include "adaptors/UBSvgSubsetAdaptor.h" - -#include "core/UBApplication.h" -#include "core/UBPersistenceManager.h" -#include "core/UBSettings.h" - -#include "globals/UBGlobals.h" - -#include "board/UBBoardController.h" -#include "board/UBBoardView.h" -#include "board/UBBoardPaletteManager.h" - -#include "gui/UBStylusPalette.h" -#include "gui/UBActionPalette.h" -#include "gui/UBMainWindow.h" - -#include "web/UBWebController.h" - -#include "document/UBDocumentProxy.h" -#include "document/UBDocumentController.h" - -#include "domain/UBGraphicsTextItem.h" - -#include "core/memcheck.h" - -#define UBTG_SEPARATOR_FIXED_HEIGHT 3 - -typedef enum { - eUBTGAddSubItemWidgetType_None, - eUBTGAddSubItemWidgetType_Action, - eUBTGAddSubItemWidgetType_Media, - eUBTGAddSubItemWidgetType_Url -} eUBTGAddSubItemWidgetType; - -/*************************************************************************** - * class UBTeacherGuideEditionWidget * - ***************************************************************************/ - -UBTeacherGuideEditionWidget::UBTeacherGuideEditionWidget(QWidget *parent, const char* name) : - QWidget(parent) - , mpLayout(NULL) - , mpDocumentTitle(NULL) - , mpPageNumberLabel(NULL) - , mpPageTitle(NULL) - , mpComment(NULL) - , mpSeparator(NULL) - , mpTreeWidget(NULL) - , mpRootWidgetItem(NULL) - , mpAddAnActionItem(NULL) - , mpAddAMediaItem(NULL) - , mpAddALinkItem(NULL) -{ - setObjectName(name); - - mpLayout = new QVBoxLayout(this); - mpPageNumberLabel = new QLabel(this); - mpPageNumberLabel->setAlignment(Qt::AlignRight); - mpPageNumberLabel->setObjectName("UBTGPageNumberLabel"); - mpLayout->addWidget(mpPageNumberLabel); - // tree basic configuration - - if (UBSettings::settings()->teacherGuidePageZeroActivated->get().toBool()) { - mpDocumentTitle = new QLabel(this); - mpDocumentTitle->setObjectName("UBTGPresentationDocumentTitle"); - mpLayout->addWidget(mpDocumentTitle); - } - - mpPageTitle = new UBTGAdaptableText(0, this); - mpPageTitle->setObjectName("UBTGEditionPageTitle"); - mpPageTitle->setPlaceHolderText(tr("Type title here ...")); - mpLayout->addWidget(mpPageTitle); - - mpComment = new UBTGAdaptableText(0, this); - mpComment->setObjectName("UBTGEditionComment"); - mpComment->setPlaceHolderText(tr("Type comment here ...")); - mpLayout->addWidget(mpComment); - - mpSeparator = new QFrame(this); - mpSeparator->setObjectName("UBTGSeparator"); - mpSeparator->setFixedHeight(UBTG_SEPARATOR_FIXED_HEIGHT); - mpLayout->addWidget(mpSeparator); - - mpTreeWidget = new QTreeWidget(this); - mpTreeWidget->setStyleSheet("selection-background-color:transparent; padding-bottom:5px; padding-top:5px;"); - mpLayout->addWidget(mpTreeWidget); - - mpRootWidgetItem = mpTreeWidget->invisibleRootItem(); - mpTreeWidget->setRootIsDecorated(false); - mpTreeWidget->setIndentation(0); - mpTreeWidget->setDropIndicatorShown(false); - mpTreeWidget->header()->close(); - mpTreeWidget->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - mpTreeWidget->setColumnCount(2); - mpTreeWidget->header()->setStretchLastSection(false); - mpTreeWidget->header()->setResizeMode(0, QHeaderView::Stretch); - mpTreeWidget->header()->setResizeMode(1, QHeaderView::Fixed); - mpTreeWidget->header()->setDefaultSectionSize(18); - mpTreeWidget->setSelectionMode(QAbstractItemView::NoSelection); - - connect(mpTreeWidget, SIGNAL(itemClicked(QTreeWidgetItem*,int)), this, SLOT(onAddItemClicked(QTreeWidgetItem*,int))); - connect(UBApplication::boardController, SIGNAL(activeSceneChanged()), this, SLOT(onActiveSceneChanged())); - -#ifdef Q_WS_MAC - // on mac and with the custom qt the widget on the tree are not automatically relocated when using the vertical scrollbar. To relocate them we link the valueChange signal of the vertical scrollbar witht a local signal to trig a change and a repaint of the tree widget - connect(mpTreeWidget->verticalScrollBar(),SIGNAL(valueChanged(int)),this,SLOT(onSliderMoved(int))); -#endif - - mpAddAnActionItem = new UBAddItem(tr("Add an action"), eUBTGAddSubItemWidgetType_Action, mpTreeWidget); - mpAddAMediaItem = new UBAddItem(tr("Add a media"), eUBTGAddSubItemWidgetType_Media, mpTreeWidget); - mpAddALinkItem = new UBAddItem(tr("Add a link"), eUBTGAddSubItemWidgetType_Url, mpTreeWidget); - - mpRootWidgetItem->addChild(mpAddAnActionItem); - mpRootWidgetItem->addChild(mpAddAMediaItem); - mpRootWidgetItem->addChild(mpAddALinkItem); - - if (UBSettings::settings()->teacherGuideLessonPagesActivated->get().toBool()) { - UBSvgSubsetAdaptor::addElementToBeStored(QString("teacherGuide"), this); - connect(UBApplication::boardController, SIGNAL(documentSet(UBDocumentProxy*)), this, SLOT(onActiveDocumentChanged())); - } -} - -UBTeacherGuideEditionWidget::~UBTeacherGuideEditionWidget() -{ - DELETEPTR(mpDocumentTitle); - DELETEPTR(mpPageNumberLabel); - DELETEPTR(mpPageTitle); - DELETEPTR(mpComment); - DELETEPTR(mpSeparator); - DELETEPTR(mpAddAnActionItem); - DELETEPTR(mpAddAMediaItem); - DELETEPTR(mpAddALinkItem); - DELETEPTR(mpTreeWidget); - DELETEPTR(mpLayout); -} - -#ifdef Q_WS_MAC -void UBTeacherGuideEditionWidget::onSliderMoved(int size) -{ - Q_UNUSED(size); - if(mpAddAMediaItem) - mpAddAMediaItem->setExpanded(true); -} -#endif -void UBTeacherGuideEditionWidget::showEvent(QShowEvent* event) -{ - setFocus(); - QWidget::showEvent(event); -} - -void UBTeacherGuideEditionWidget::onActiveDocumentChanged() -{ - int activeSceneIndex = UBApplication::boardController->activeSceneIndex(); - if (UBApplication::boardController->pageFromSceneIndex(activeSceneIndex) != 0) - load(UBSvgSubsetAdaptor::readTeacherGuideNode(activeSceneIndex)); -} - -void UBTeacherGuideEditionWidget::load(QString element) -{ - cleanData(); - QDomDocument doc("TeacherGuide"); - doc.setContent(element); - - for (QDomElement element = doc.documentElement().firstChildElement(); - !element.isNull(); element = element.nextSiblingElement()) { - QString tagName = element.tagName(); - if (tagName == "title") - mpPageTitle->setInitialText(element.attribute("value")); - else if (tagName == "comment") - mpComment->setInitialText(element.attribute("value")); - else if (tagName == "media") - onAddItemClicked(mpAddAMediaItem, 0, &element); - else if (tagName == "link") - onAddItemClicked(mpAddALinkItem, 0, &element); - else if (tagName == "action") - onAddItemClicked(mpAddAnActionItem, 0, &element); - } -} - -QVector UBTeacherGuideEditionWidget::save(int pageIndex) -{ - QVector result; - if (pageIndex != UBApplication::boardController->currentPage()) - return result; - tIDataStorage* data = new tIDataStorage(); - data->name = "teacherGuide"; - data->type = eElementType_START; - data->attributes.insert("version", "2.00"); - result << data; - - data = new tIDataStorage(); - data->name = "title"; - data->type = eElementType_UNIQUE; - data->attributes.insert("value", mpPageTitle->text()); - if (mpPageTitle->text().length()) - result << data; - - data = new tIDataStorage(); - data->name = "comment"; - data->type = eElementType_UNIQUE; - data->attributes.insert("value", mpComment->text()); - if (mpComment->text().length()) - result << data; - - QList children = getChildrenList(mpAddAnActionItem); - children << getChildrenList(mpAddAMediaItem); - children << getChildrenList(mpAddALinkItem); - - foreach(QTreeWidgetItem* widgetItem, children) { - tUBGEElementNode* node = dynamic_cast(mpTreeWidget->itemWidget( widgetItem, 0))->saveData(); - if (node) { - data = new tIDataStorage(); - data->name = node->name; - data->type = eElementType_UNIQUE; - foreach(QString currentKey, node->attributes.keys()) - data->attributes.insert(currentKey, node->attributes.value(currentKey)); - result << data; - } - } - - data = new tIDataStorage(); - data->name = "teacherGuide"; - data->type = eElementType_END; - result << data; - return result; -} - -void UBTeacherGuideEditionWidget::onActiveSceneChanged() -{ - int currentPage = UBApplication::boardController->currentPage(); - if (currentPage > 0) { - cleanData(); - load( UBSvgSubsetAdaptor::readTeacherGuideNode( UBApplication::boardController->activeSceneIndex())); - mpPageNumberLabel->setText(tr("Page: %0").arg(currentPage)); - UBDocumentProxy* documentProxy = UBApplication::boardController->selectedDocument(); - if (mpDocumentTitle) - mpDocumentTitle->setText(documentProxy->metaData(UBSettings::sessionTitle).toString()); - } -} - -void UBTeacherGuideEditionWidget::cleanData() -{ - mpPageTitle->resetText(); - mpComment->resetText(); - QList children = mpAddAnActionItem->takeChildren(); - children << mpAddAMediaItem->takeChildren(); - children << mpAddALinkItem->takeChildren(); - - foreach(QTreeWidgetItem* item, children) { - DELETEPTR(item); - } -} - -QList UBTeacherGuideEditionWidget::getChildrenList( QTreeWidgetItem* widgetItem) -{ - QList result; - for (int i = 0; i < widgetItem->childCount(); i += 1) - result << widgetItem->child(i); - return result; -} - -QVector UBTeacherGuideEditionWidget::getPageAndCommentData() -{ - QVector result; - tUBGEElementNode* pageTitle = new tUBGEElementNode(); - pageTitle->name = "pageTitle"; - pageTitle->attributes.insert("value", mpPageTitle->text()); - result << pageTitle; - - tUBGEElementNode* comment = new tUBGEElementNode(); - comment->name = "comment"; - comment->attributes.insert("value", mpComment->text()); - result << comment; - return result; -} - -QVector UBTeacherGuideEditionWidget::getData() -{ - QVector result; - QList children = getChildrenList(mpAddAnActionItem); - children << getChildrenList(mpAddAMediaItem); - children << getChildrenList(mpAddALinkItem); - result << getPageAndCommentData(); - foreach(QTreeWidgetItem* widgetItem, children) { - tUBGEElementNode* node = dynamic_cast(mpTreeWidget->itemWidget( widgetItem, 0))->saveData(); - if (node) - result << node; - } - return result; -} - -void UBTeacherGuideEditionWidget::onAddItemClicked(QTreeWidgetItem* widget, int column, QDomElement *element) -{ - int addSubItemWidgetType = widget->data(column, Qt::UserRole).toInt(); - if (addSubItemWidgetType != eUBTGAddSubItemWidgetType_None) { - QTreeWidgetItem* newWidgetItem = new QTreeWidgetItem(widget); - newWidgetItem->setData(column, Qt::UserRole, eUBTGAddSubItemWidgetType_None); - newWidgetItem->setData(1, Qt::UserRole, eUBTGAddSubItemWidgetType_None); - newWidgetItem->setIcon(1, QIcon(":images/close.svg")); - - switch (addSubItemWidgetType) { - case eUBTGAddSubItemWidgetType_Action: { - UBTGActionWidget* actionWidget = new UBTGActionWidget(widget); - if (element) - actionWidget->initializeWithDom(*element); - mpTreeWidget->setItemWidget(newWidgetItem, 0, actionWidget); - break; - } - case eUBTGAddSubItemWidgetType_Media: { - UBTGMediaWidget* mediaWidget = new UBTGMediaWidget(widget); - if (element) - mediaWidget->initializeWithDom(*element); - mpTreeWidget->setItemWidget(newWidgetItem,0, mediaWidget); - break; - } - case eUBTGAddSubItemWidgetType_Url: { - UBTGUrlWidget* urlWidget = new UBTGUrlWidget(); - if (element) - urlWidget->initializeWithDom(*element); - mpTreeWidget->setItemWidget(newWidgetItem, 0, urlWidget); - break; - } - default: - delete newWidgetItem; - qCritical() << "onAddItemClicked no action set"; - return; - } - - if (addSubItemWidgetType != eUBTGAddSubItemWidgetType_None && !widget->isExpanded()) - widget->setExpanded(true); - else { - //to update the tree and subtrees - widget->setExpanded(false); - widget->setExpanded(true); - } - } - else if (column == 1 && addSubItemWidgetType == eUBTGAddSubItemWidgetType_None) { - UBTGMediaWidget* media = dynamic_cast(mpTreeWidget->itemWidget(widget, 0)); - if (media) - media->removeSource(); - int index = mpTreeWidget->currentIndex().row(); - QTreeWidgetItem* toBeDeletedWidgetItem = widget->parent()->takeChild(index); - delete toBeDeletedWidgetItem; - } -} - -bool UBTeacherGuideEditionWidget::isModified() -{ - bool result = false; - result |= mpPageTitle->text().length() > 0; - result |= mpComment->text().length() > 0; - result |= mpAddAnActionItem->childCount() > 0; - result |= mpAddAMediaItem->childCount() > 0; - result |= mpAddALinkItem->childCount() > 0; - return result; -} - -/*************************************************************************** - * class UBTeacherGuidePresentationWidget * - ***************************************************************************/ -typedef enum { - tUBTGActionAssociateOnClickItem_NONE, - tUBTGActionAssociateOnClickItem_URL, - tUBTGActionAssociateOnClickItem_MEDIA, - tUBTGActionAssociateOnClickItem_EXPAND -} tUBTGActionAssociateOnClickItem; - -typedef enum { - tUBTGTreeWidgetItemRole_HasAnAction = Qt::UserRole, - tUBTGTreeWidgetItemRole_HasAnUrl -} tUBTGTreeWidgetItemRole; - -UBTeacherGuidePresentationWidget::UBTeacherGuidePresentationWidget(QWidget *parent, const char *name) : - QWidget(parent) - , mpPageTitle(NULL) - , mpComment(NULL) - , mpLayout(NULL) - , mpButtonTitleLayout(NULL) - , mpDocumentTitle(NULL) - , mpPageNumberLabel(NULL) - , mpSeparator(NULL) - , mpModePushButton(NULL) - , mpTreeWidget(NULL) - , mpRootWidgetItem(NULL) - , mpMediaSwitchItem(NULL) -{ - setObjectName(name); - - mpLayout = new QVBoxLayout(this); - setLayout(mpLayout); - mpPageNumberLabel = new QLabel(this); - mpPageNumberLabel->setAlignment(Qt::AlignRight); - mpPageNumberLabel->setObjectName("UBTGPageNumberLabel"); - - mpLayout->addWidget(mpPageNumberLabel); - - mpButtonTitleLayout = new QHBoxLayout(0); - - mpModePushButton = new QPushButton(this); - mpModePushButton->setIcon(QIcon(":images/teacherGuide/pencil.svg")); - mpModePushButton->setMaximumWidth(32); - mpModePushButton->installEventFilter(this); - - connect(mpModePushButton, SIGNAL(clicked()), parentWidget(), SLOT(changeMode())); - mpButtonTitleLayout->addWidget(mpModePushButton); - - if (UBSettings::settings()->teacherGuidePageZeroActivated->get().toBool()) { - mpDocumentTitle = new QLabel(this); - mpDocumentTitle->setObjectName("UBTGPresentationDocumentTitle"); - mpButtonTitleLayout->addWidget(mpDocumentTitle); - } - - mpLayout->addLayout(mpButtonTitleLayout); - - mpPageTitle = new UBTGAdaptableText(0, this); - mpPageTitle->setObjectName("UBTGPresentationPageTitle"); - mpPageTitle->setReadOnly(true); - mpPageTitle->setStyleSheet("background-color:transparent"); - mpLayout->addWidget(mpPageTitle); - - mpComment = new UBTGAdaptableText(0, this); - mpComment->setObjectName("UBTGPresentationComment"); - mpComment->setReadOnly(true); - mpComment->setStyleSheet("background-color:transparent"); - mpLayout->addWidget(mpComment); - - mpSeparator = new QFrame(this); - mpSeparator->setFixedHeight(UBTG_SEPARATOR_FIXED_HEIGHT); - mpSeparator->setObjectName("UBTGSepartor"); - mpLayout->addWidget(mpSeparator); - - mpTreeWidget = new UBTGDraggableTreeItem(this); - mpLayout->addWidget(mpTreeWidget); - - mpRootWidgetItem = mpTreeWidget->invisibleRootItem(); - mpTreeWidget->setDragEnabled(true); - mpTreeWidget->setRootIsDecorated(false); - mpTreeWidget->setIndentation(0); - mpTreeWidget->setDropIndicatorShown(false); - mpTreeWidget->header()->close(); - mpTreeWidget->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - mpTreeWidget->setStyleSheet("selection-background-color:transparent; padding-bottom:5px; padding-top:5px; "); - mpTreeWidget->setIconSize(QSize(24,24)); - connect(mpTreeWidget, SIGNAL(itemClicked(QTreeWidgetItem*,int)), this, SLOT(onAddItemClicked(QTreeWidgetItem*,int))); - connect(UBApplication::boardController, SIGNAL(activeSceneChanged()), this, SLOT(onActiveSceneChanged())); -#ifdef Q_WS_MAC - // on mac and with the custom qt the widget on the tree are not automatically relocated when using the vertical scrollbar. To relocate them we link the valueChange signal of the vertical scrollbar witht a local signal to trig a change and a repaint of the tree widget - connect(mpTreeWidget->verticalScrollBar(),SIGNAL(valueChanged(int)),this,SLOT(onSliderMoved(int))); -#endif -} - -UBTeacherGuidePresentationWidget::~UBTeacherGuidePresentationWidget() -{ - DELETEPTR(mpComment); - DELETEPTR(mpPageTitle); - DELETEPTR(mpPageNumberLabel); - DELETEPTR(mpSeparator); - DELETEPTR(mpMediaSwitchItem); - DELETEPTR(mpModePushButton); - DELETEPTR(mpDocumentTitle); - DELETEPTR(mpButtonTitleLayout); - DELETEPTR(mpTreeWidget); - DELETEPTR(mpLayout); -} - -#ifdef Q_WS_MAC -void UBTeacherGuidePresentationWidget::onSliderMoved(int size) -{ - Q_UNUSED(size); - if(mpMediaSwitchItem) - mpMediaSwitchItem->setExpanded(true); -} -#endif - -bool UBTeacherGuidePresentationWidget::eventFilter(QObject* object, QEvent* event) -{ - Q_UNUSED(object); - if (event->type() == QEvent::HoverEnter || event->type() == QEvent::HoverMove || event->type() == QEvent::HoverLeave) - return true; - return false; -} - -void UBTeacherGuidePresentationWidget::cleanData() -{ - mpPageTitle->showText(""); - mpComment->showText(""); - //tree clean - QList itemToRemove = mpRootWidgetItem->takeChildren(); - foreach(QTreeWidgetItem* eachItem, itemToRemove) { - DELETEPTR(eachItem); - } - // the mpMediaSwitchItem is deleted by the previous loop but the pointer is not set to zero - mpMediaSwitchItem = NULL; -} - -void UBTeacherGuidePresentationWidget::onActiveSceneChanged() -{ - cleanData(); - mpPageNumberLabel->setText(tr("Page: %0").arg(UBApplication::boardController->currentPage())); - UBDocumentProxy* documentProxy = UBApplication::boardController->selectedDocument(); - if (mpDocumentTitle) - mpDocumentTitle->setText( documentProxy->metaData(UBSettings::sessionTitle).toString()); -} - -void UBTeacherGuidePresentationWidget::createMediaButtonItem() -{ - if (!mpMediaSwitchItem) { - mpMediaSwitchItem = new QTreeWidgetItem(mpRootWidgetItem); - mpMediaSwitchItem->setText(0, "+"); - mpMediaSwitchItem->setExpanded(false); - mpMediaSwitchItem->setData(0, tUBTGTreeWidgetItemRole_HasAnAction, tUBTGActionAssociateOnClickItem_EXPAND); - mpMediaSwitchItem->setData(0, Qt::BackgroundRole, QVariant(QColor(200, 200, 200))); - mpMediaSwitchItem->setData(0, Qt::FontRole, QVariant(QFont(QApplication::font().family(), 16))); - mpMediaSwitchItem->setData(0, Qt::TextAlignmentRole, QVariant(Qt::AlignCenter)); - mpRootWidgetItem->addChild(mpMediaSwitchItem); - } -} - -void UBTeacherGuidePresentationWidget::showData( QVector data) -{ - cleanData(); - - foreach(tUBGEElementNode* element, data) { - if (element->name == "pageTitle") - mpPageTitle->showText(element->attributes.value("value")); - else if (element->name == "comment") - mpComment->showText(element->attributes.value("value")); - else if (element->name == "action") { - QTreeWidgetItem* newWidgetItem = new QTreeWidgetItem(mpRootWidgetItem); - newWidgetItem->setText(0, element->attributes.value("task")); - newWidgetItem->setFlags(Qt::ItemIsEnabled); - QString colorString = element->attributes.value("owner").toInt() == 0 ? "blue" : "green"; - UBTGAdaptableText* textWidget = new UBTGAdaptableText(newWidgetItem, 0); - textWidget->bottomMargin(14); - textWidget->setStyleSheet( "QWidget {background: #EEEEEE; border:none; color:" + colorString + ";}"); - textWidget->showText(element->attributes.value("task")); - textWidget->document()->setDefaultFont( QFont(QApplication::font().family(), 11)); - mpTreeWidget->setItemWidget(newWidgetItem, 0, textWidget); - - mpRootWidgetItem->addChild(newWidgetItem); - } - else if (element->name == "media") { - createMediaButtonItem(); - QTreeWidgetItem* newWidgetItem = new QTreeWidgetItem(mpMediaSwitchItem); - newWidgetItem->setIcon(0, QIcon( ":images/teacherGuide/" + element->attributes.value("mediaType") + "_24x24.svg")); - newWidgetItem->setText(0, element->attributes.value("title")); - newWidgetItem->setData(0, tUBTGTreeWidgetItemRole_HasAnAction, tUBTGActionAssociateOnClickItem_MEDIA); - newWidgetItem->setData(0, Qt::FontRole, QVariant(QFont(QApplication::font().family(), 11))); - QString mimeTypeString; -#ifdef Q_WS_WIN - mimeTypeString = QUrl::fromLocalFile(UBApplication::boardController->selectedDocument()->persistencePath()+ "/" + element->attributes.value("relativePath")).toString(); -#else - mimeTypeString = UBApplication::boardController->selectedDocument()->persistencePath() + "/" + element->attributes.value("relativePath"); -#endif - newWidgetItem->setData(0, TG_USER_ROLE_MIME_TYPE, mimeTypeString); - newWidgetItem->setFlags( Qt::ItemIsDragEnabled | Qt::ItemIsEnabled | Qt::ItemIsSelectable); - mpRootWidgetItem->addChild(newWidgetItem); - - QTreeWidgetItem* mediaItem = new QTreeWidgetItem(newWidgetItem); - mediaItem->setData(0, tUBTGTreeWidgetItemRole_HasAnAction, tUBTGActionAssociateOnClickItem_NONE); - qDebug() << element->attributes.value("mediaType"); - UBTGMediaWidget* mediaWidget = new UBTGMediaWidget(element->attributes.value("relativePath"), newWidgetItem,0,element->attributes.value("mediaType").contains("flash")); - newWidgetItem->setExpanded(false); - mpTreeWidget->setItemWidget(mediaItem, 0, mediaWidget); - } - else if (element->name == "link") { - createMediaButtonItem(); - QTreeWidgetItem* newWidgetItem = new QTreeWidgetItem( mpMediaSwitchItem); - newWidgetItem->setIcon(0, QIcon(":images/teacherGuide/link_24x24.svg")); - newWidgetItem->setText(0, element->attributes.value("title")); - newWidgetItem->setData(0, tUBTGTreeWidgetItemRole_HasAnAction, tUBTGActionAssociateOnClickItem_URL); - newWidgetItem->setData(0, tUBTGTreeWidgetItemRole_HasAnUrl, QVariant(element->attributes.value("url"))); - newWidgetItem->setData(0, Qt::FontRole, QVariant(QFont(QApplication::font().family(), 11))); - newWidgetItem->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable); - mpRootWidgetItem->addChild(newWidgetItem); - } - } -} - -void UBTeacherGuidePresentationWidget::onAddItemClicked(QTreeWidgetItem* widget, int column) -{ - int associateAction = widget->data(column, tUBTGTreeWidgetItemRole_HasAnAction).toInt(); - if (column == 0 && associateAction != tUBTGActionAssociateOnClickItem_NONE) { - switch (associateAction) { - case tUBTGActionAssociateOnClickItem_EXPAND: - widget->setExpanded(!widget->isExpanded()); - if (widget->isExpanded()) - mpMediaSwitchItem->setText(0, "-"); - else - mpMediaSwitchItem->setText(0, "+"); - break; - case tUBTGActionAssociateOnClickItem_URL: - widget->data(column, tUBTGTreeWidgetItemRole_HasAnUrl).toString(); - UBApplication::webController->loadUrl( QUrl( widget->data(column, tUBTGTreeWidgetItemRole_HasAnUrl).toString())); - break; - case tUBTGActionAssociateOnClickItem_MEDIA: - widget->setExpanded(!widget->isExpanded()); - break; - default: - qDebug() << "associateAction no action set " << associateAction; - } - } -} - -/*************************************************************************** - * class UBTeacherGuidePageZeroWidget * - ***************************************************************************/ -UBTeacherGuidePageZeroWidget::UBTeacherGuidePageZeroWidget(QWidget* parent, const char* name) : - QWidget(parent) - , mpLayout(NULL) - , mpButtonTitleLayout(NULL) - , mpContainerWidgetLayout(NULL) - , mpModePushButton(NULL) - , mpPageNumberLabel(NULL) - , mpScrollArea(NULL) - , mpContainerWidget(NULL) - , mpSessionTitle(NULL) - , mpSeparatorSessionTitle(NULL) - , mpAuthorsLabel(NULL) - , mpAuthors(NULL) - , mpSeparatorAuthors(NULL) - , mpCreationLabel(NULL) - , mpLastModifiedLabel(NULL) - , mpObjectivesLabel(NULL) - , mpObjectives(NULL) - , mpSeparatorObjectives(NULL) - , mpIndexLabel(NULL) - , mpKeywordsLabel(NULL) - , mpKeywords(NULL) - , mpSchoolLevelItemLabel(NULL) - , mpSchoolLevelBox(NULL) - , mpSchoolLevelValueLabel(NULL) - , mpSchoolSubjectsItemLabel(NULL) - , mpSchoolSubjectsBox(NULL) - , mpSchoolSubjectsValueLabel(NULL) - , mpSchoolTypeItemLabel(NULL) - , mpSchoolTypeBox(NULL) - , mpSchoolTypeValueLabel(NULL) - , mpSeparatorIndex(NULL) - , mpLicenceLabel(NULL) - , mpLicenceBox( NULL) - , mpLicenceIcon(NULL) - , mpLicenceLayout(NULL) - , mpSceneItemSessionTitle(NULL) -{ - setObjectName(name); - QString chapterStyle("QLabel {font-size:16px; font-weight:bold;}"); - mpLayout = new QVBoxLayout(0); - setLayout(mpLayout); - mpPageNumberLabel = new QLabel(this); - mpPageNumberLabel->setAlignment(Qt::AlignRight); - mpPageNumberLabel->setObjectName("UBTGPageNumberLabel"); - mpPageNumberLabel->setText(tr("Title page")); - mpLayout->addWidget(mpPageNumberLabel); - - mpScrollArea = new QScrollArea(); - mpScrollArea->setFocusPolicy(Qt::NoFocus); - mpContainerWidget = new QWidget(); - mpContainerWidget->setFocusPolicy(Qt::NoFocus); - mpContainerWidgetLayout = new QVBoxLayout(); - - mpLayout->addWidget(mpScrollArea); - mpScrollArea->setWidget(mpContainerWidget); - mpScrollArea->setWidgetResizable(true); - mpScrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - mpContainerWidget->setLayout(mpContainerWidgetLayout); - - mpButtonTitleLayout = new QHBoxLayout(0); - - mpModePushButton = new QPushButton(this); - mpModePushButton->setIcon(QIcon(":images/teacherGuide/pencil.svg")); - mpModePushButton->setMaximumWidth(32); - mpModePushButton->installEventFilter(this); - mpButtonTitleLayout->addWidget(mpModePushButton); - connect(mpModePushButton, SIGNAL(clicked()), this, SLOT(switchToMode())); - - mpSessionTitle = new UBTGAdaptableText(0, this, "UBTGSessionTitle"); - mpSessionTitle->setPlaceHolderText(tr("Type session title here ...")); - mpSessionTitle->setMaximumLength(1000); - mpButtonTitleLayout->addWidget(mpSessionTitle); - connect(this, SIGNAL(resized()), mpSessionTitle, SLOT(onTextChanged())); - - mpContainerWidgetLayout->addLayout(mpButtonTitleLayout); - - mpSeparatorSessionTitle = new QFrame(this); - mpSeparatorSessionTitle->setFixedHeight(UBTG_SEPARATOR_FIXED_HEIGHT); - mpSeparatorSessionTitle->setObjectName("UBTGSeparator"); - mpContainerWidgetLayout->addWidget(mpSeparatorSessionTitle); - - mpAuthorsLabel = new QLabel(this); - mpAuthorsLabel->setObjectName("UBTGZeroPageEditionModeTitle"); - mpAuthorsLabel->setText(tr("Author(s)")); - mpAuthorsLabel->setStyleSheet(chapterStyle); - mpContainerWidgetLayout->addWidget(mpAuthorsLabel); - - mpAuthors = new UBTGAdaptableText(0, this); - mpAuthors->setObjectName("UBTGZeroPageInputText"); - mpAuthors->setPlaceHolderText(tr("Type authors here ...")); - mpContainerWidgetLayout->addWidget(mpAuthors); - connect(this, SIGNAL(resized()), mpAuthors, SLOT(onTextChanged())); - - mpCreationLabel = new QLabel(this); - mpCreationLabel->setObjectName("UBTGZeroPageDateLabel"); - mpContainerWidgetLayout->addWidget(mpCreationLabel); - - mpLastModifiedLabel = new QLabel(this); - mpLastModifiedLabel->setObjectName("UBTGZeroPageDateLabel"); - mpContainerWidgetLayout->addWidget(mpLastModifiedLabel); - - mpSeparatorAuthors = new QFrame(this); - mpSeparatorAuthors->setFixedHeight(UBTG_SEPARATOR_FIXED_HEIGHT); - mpSeparatorAuthors->setObjectName("UBTGSeparator"); - mpContainerWidgetLayout->addWidget(mpSeparatorAuthors); - - mpObjectivesLabel = new QLabel(this); - mpObjectivesLabel->setObjectName("UBTGZeroPageEditionModeTitle"); - mpObjectivesLabel->setText(tr("Objective(s)")); - mpObjectivesLabel->setStyleSheet(chapterStyle); - mpContainerWidgetLayout->addWidget(mpObjectivesLabel); - - mpObjectives = new UBTGAdaptableText(0, this); - mpObjectives->setObjectName("UBTGZeroPageInputText"); - mpObjectives->setPlaceHolderText(tr("Type objectives here...")); - mpContainerWidgetLayout->addWidget(mpObjectives); - connect(this, SIGNAL(resized()), mpObjectives, SLOT(onTextChanged())); - - mpSeparatorObjectives = new QFrame(this); - mpSeparatorObjectives->setFixedHeight(UBTG_SEPARATOR_FIXED_HEIGHT); - mpSeparatorObjectives->setObjectName("UBTGSeparator"); - mpContainerWidgetLayout->addWidget(mpSeparatorObjectives); - - mpIndexLabel = new QLabel(this); - mpIndexLabel->setObjectName("UBTGZeroPageEditionModeTitle"); - mpIndexLabel->setText(tr("Resource indexing")); - mpIndexLabel->setStyleSheet(chapterStyle); - mpContainerWidgetLayout->addWidget(mpIndexLabel); - - mpKeywordsLabel = new QLabel(this); - mpKeywordsLabel->setObjectName("UBTGZeroPageItemLabel"); - mpKeywordsLabel->setText(tr("Keywords:")); - mpKeywordsLabel->setStyleSheet(chapterStyle); - mpContainerWidgetLayout->addWidget(mpKeywordsLabel); - mpKeywords = new UBTGAdaptableText(0, this); - mpKeywords->setPlaceHolderText(tr("Type keywords here ...")); - mpContainerWidgetLayout->addWidget(mpKeywords); - connect(this, SIGNAL(resized()), mpKeywords, SLOT(onTextChanged())); - - mpSchoolLevelItemLabel = new QLabel(this); - mpSchoolLevelItemLabel->setObjectName("UBTGZeroPageItemLabel"); - mpSchoolLevelItemLabel->setText(tr("Level:")); - mpSchoolLevelItemLabel->setStyleSheet(chapterStyle); - mpContainerWidgetLayout->addWidget(mpSchoolLevelItemLabel); - mpSchoolLevelBox = new QComboBox(this); - mpSchoolLevelBox->setMinimumHeight(22); - mpSchoolLevelBox->setMinimumWidth(LOWER_RESIZE_WIDTH); - mpSchoolLevelBox->setObjectName("DockPaletteWidgetComboBox"); - connect(mpSchoolLevelBox, SIGNAL(currentIndexChanged(QString)), this, SLOT(onSchoolLevelChanged(QString))); - mpContainerWidgetLayout->addWidget(mpSchoolLevelBox); - mpSchoolLevelValueLabel = new QLabel(this); - mpContainerWidgetLayout->addWidget(mpSchoolLevelValueLabel); - - mpSchoolSubjectsItemLabel = new QLabel(this); - mpSchoolSubjectsItemLabel->setObjectName("UBTGZeroPageItemLabel"); - mpSchoolSubjectsItemLabel->setText(tr("Subjects:")); - mpSchoolSubjectsItemLabel->setStyleSheet(chapterStyle); - mpContainerWidgetLayout->addWidget(mpSchoolSubjectsItemLabel); - mpSchoolSubjectsBox = new QComboBox(this); - mpSchoolSubjectsBox->setMinimumHeight(22); - mpSchoolSubjectsBox->setMinimumWidth(LOWER_RESIZE_WIDTH); - mpSchoolSubjectsBox->setObjectName("DockPaletteWidgetComboBox"); - mpContainerWidgetLayout->addWidget(mpSchoolSubjectsBox); - mpSchoolSubjectsValueLabel = new QLabel(this); - mpContainerWidgetLayout->addWidget(mpSchoolSubjectsValueLabel); - - mpSchoolTypeItemLabel = new QLabel(this); - mpSchoolTypeItemLabel->setObjectName("UBTGZeroPageItemLabel"); - mpSchoolTypeItemLabel->setText(tr("Type:")); - mpSchoolTypeItemLabel->setStyleSheet(chapterStyle); - mpContainerWidgetLayout->addWidget(mpSchoolTypeItemLabel); - mpSchoolTypeBox = new QComboBox(this); - mpSchoolTypeBox->setMinimumHeight(22); - mpSchoolTypeBox->setMinimumWidth(LOWER_RESIZE_WIDTH); - mpSchoolTypeBox->setObjectName("DockPaletteWidgetComboBox"); - mpContainerWidgetLayout->addWidget(mpSchoolTypeBox); - mpSchoolTypeValueLabel = new QLabel(this); - mpContainerWidgetLayout->addWidget(mpSchoolTypeValueLabel); - - mpSeparatorIndex = new QFrame(this); - mpSeparatorIndex->setFixedHeight(UBTG_SEPARATOR_FIXED_HEIGHT); - mpSeparatorIndex->setObjectName("UBTGSeparator"); - mpContainerWidgetLayout->addWidget(mpSeparatorIndex); - - mpLicenceLabel = new QLabel(this); - mpLicenceLabel->setObjectName("UBTGZeroPageItemLabel"); - mpLicenceLabel->setText(tr("Licence")); - mpLicenceLabel->setStyleSheet(chapterStyle); - mpContainerWidgetLayout->addWidget(mpLicenceLabel); - mpLicenceBox = new QComboBox(this); - mpLicenceBox->setMinimumHeight(22); - mpLicenceBox->setMinimumWidth(LOWER_RESIZE_WIDTH); - mpLicenceBox->setObjectName("DockPaletteWidgetComboBox"); - mpContainerWidgetLayout->addWidget(mpLicenceBox); - mpLicenceLayout = new QHBoxLayout(0); - mpLicenceIcon = new QLabel(this); - mpLicenceIcon->setMinimumWidth(LOWER_RESIZE_WIDTH/2); - mpLicenceLayout->addWidget(mpLicenceIcon); - mpLicenceValueLabel = new QLabel(this); - mpLicenceValueLabel->setMinimumWidth(LOWER_RESIZE_WIDTH/2); - mpLicenceLayout->addWidget(mpLicenceValueLabel); - mpContainerWidgetLayout->addLayout(mpLicenceLayout); - mpContainerWidgetLayout->addStretch(1); - - connect(UBApplication::boardController, SIGNAL(activeSceneChanged()), this, SLOT(onActiveSceneChanged())); - fillComboBoxes(); -} - -UBTeacherGuidePageZeroWidget::~UBTeacherGuidePageZeroWidget() -{ - DELETEPTR(mpPageNumberLabel); - DELETEPTR(mpSessionTitle); - DELETEPTR(mpSeparatorSessionTitle); - DELETEPTR(mpAuthorsLabel); - DELETEPTR(mpAuthors); - DELETEPTR(mpSeparatorAuthors); - DELETEPTR(mpCreationLabel); - DELETEPTR(mpLastModifiedLabel); - DELETEPTR(mpObjectivesLabel); - DELETEPTR(mpObjectives); - DELETEPTR(mpSeparatorObjectives); - DELETEPTR(mpIndexLabel); - DELETEPTR(mpKeywordsLabel); - DELETEPTR(mpKeywords); - DELETEPTR(mpSchoolLevelItemLabel); - DELETEPTR(mpSchoolLevelBox); - DELETEPTR(mpSchoolSubjectsItemLabel); - DELETEPTR(mpSchoolSubjectsBox); - DELETEPTR(mpSchoolTypeItemLabel); - DELETEPTR(mpSchoolTypeBox); - DELETEPTR(mpSeparatorIndex); - DELETEPTR(mpLicenceLabel); - DELETEPTR(mpLicenceBox); - DELETEPTR(mpLicenceValueLabel); - DELETEPTR(mpLicenceIcon); - DELETEPTR(mpModePushButton); - DELETEPTR(mpLicenceLayout); - DELETEPTR(mpButtonTitleLayout); - DELETEPTR(mpContainerWidgetLayout); - DELETEPTR(mpContainerWidget); - DELETEPTR(mpScrollArea); - DELETEPTR(mpLayout); -} - -bool UBTeacherGuidePageZeroWidget::eventFilter(QObject* object, QEvent* event) -{ - Q_UNUSED(object); - if (event->type() == QEvent::HoverEnter || event->type() == QEvent::HoverMove || event->type() == QEvent::HoverLeave) - return true; - return false; -} - -void UBTeacherGuidePageZeroWidget::fillComboBoxes() -{ - QString parametersConfigFilePath = UBSettings::settings()->applicationCustomizationDirectory() + "/teacherGuide/indexingParameters.xml"; - QFile parametersFile(parametersConfigFilePath); - if (!parametersFile.exists()) { - qCritical() << "UBTeacherGuidePageZeroEditionWidget fillComboBoxes file not found " << parametersConfigFilePath; - return; - } - - parametersFile.open(QFile::ReadOnly); - - QDomDocument doc; - doc.setContent(parametersFile.readAll()); - QDomElement rootElement = doc.elementsByTagName("teacherGuide").at(0).toElement(); - - QDomNodeList subjects = rootElement.elementsByTagName("subjects"); - for (int baseLevelCounter = 0; baseLevelCounter < subjects.count(); baseLevelCounter += 1) { - QDomNode subjectsForBaseLevel = subjects.at(baseLevelCounter); - QDomNodeList subjectsList = subjectsForBaseLevel.childNodes(); - QStringList subjectsRelatedToBaseLevel; - for (int j = 0; j < subjectsList.count(); j += 1) { - subjectsRelatedToBaseLevel.append(subjectsList.at(j).toElement().attribute("label")); - } - mSubjects.insert( subjectsForBaseLevel.toElement().attribute("baseLevel"), subjectsRelatedToBaseLevel); - } - - QDomNodeList gradeLevels = rootElement.elementsByTagName("gradeLevels").at(0).childNodes(); - for (int i = 0; i < gradeLevels.count(); i += 1) { - mGradeLevelsMap.insert(gradeLevels.at(i).toElement().attribute("label"), gradeLevels.at(i).toElement().attribute("baseLevel")); - mpSchoolLevelBox->addItem( gradeLevels.at(i).toElement().attribute("label")); - } - - QDomNodeList types = rootElement.elementsByTagName("types").at(0).childNodes(); - for (int i = 0; i < types.count(); i += 1) - mpSchoolTypeBox->addItem(types.at(i).toElement().attribute("label")); - - parametersFile.close(); - - QStringList licences; - licences << tr("Attribution-ShareAlike CC BY-SA") - << tr("Attribution CC BY") - << tr("Attribution-NoDerivs CC BY-ND") - << tr("Attribution-NonCommercial CC BY-NC") - << tr("Attribution-NonCommercial-NoDerivs CC BY-NC-ND") - << tr("Attribution-NonCommercial-ShareAlike CC BY-NC-SA") - << tr("Public domain") - << tr("Copyright"); - mpLicenceBox->addItems(licences); - QStringList licenceIconList; - licenceIconList << ":images/licenses/ccbysa.png" - << ":images/licenses/ccby.png" - << ":images/licenses/ccbynd.png" - << ":images/licenses/ccbync.png" - << ":images/licenses/ccbyncnd.png" - << ":images/licenses/ccbyncsa.png"; - for (int i = 0; i < licenceIconList.count(); i += 1) - mpLicenceBox->setItemData(i, licenceIconList.at(i)); -} - -void UBTeacherGuidePageZeroWidget::onSchoolLevelChanged(QString schoolLevel) -{ - QStringList subjects = mSubjects.value(mGradeLevelsMap.value(schoolLevel)); - mpSchoolSubjectsBox->clear(); - if (subjects.count()) { - mpSchoolSubjectsItemLabel->setEnabled(true); - mpSchoolSubjectsBox->setEnabled(true); - mpSchoolSubjectsBox->addItems(subjects); - } - else { - mpSchoolSubjectsItemLabel->setDisabled(true); - mpSchoolSubjectsBox->setDisabled(true); - } -} - -void UBTeacherGuidePageZeroWidget::onActiveSceneChanged() -{ - UBDocumentProxy* documentProxy = UBApplication::boardController->selectedDocument(); - if (documentProxy && UBApplication::boardController->currentPage() == 0) { - QDateTime creationDate = documentProxy->documentDate(); - mpCreationLabel->setText( tr("Created the:\n") + creationDate.toString(Qt::DefaultLocaleShortDate)); - QDateTime updatedDate = documentProxy->lastUpdate(); - mpLastModifiedLabel->setText( tr("Updated the:\n") + updatedDate.toString(Qt::DefaultLocaleShortDate)); - loadData(); - updateSceneTitle(); - } -} - -void UBTeacherGuidePageZeroWidget::hideEvent(QHideEvent * event) -{ - persistData(); - QWidget::hideEvent(event); -} - -void UBTeacherGuidePageZeroWidget::loadData() -{ - UBDocumentProxy* documentProxy = UBApplication::boardController->selectedDocument(); - mpSessionTitle->setText( documentProxy->metaData(UBSettings::sessionTitle).toString()); - mpAuthors->setText( documentProxy->metaData(UBSettings::sessionAuthors).toString()); - mpObjectives->setText( documentProxy->metaData(UBSettings::sessionObjectives).toString()); - mpKeywords->setText( documentProxy->metaData(UBSettings::sessionKeywords).toString()); - - int currentIndex = mpSchoolLevelBox->findText(documentProxy->metaData(UBSettings::sessionGradeLevel).toString()); - mpSchoolLevelBox->setCurrentIndex((currentIndex != -1) ? currentIndex : 0); - - currentIndex = mpSchoolSubjectsBox->findText(documentProxy->metaData(UBSettings::sessionSubjects).toString()); - mpSchoolSubjectsBox->setCurrentIndex((currentIndex != -1) ? currentIndex : 0); - - currentIndex = mpSchoolTypeBox->findText(documentProxy->metaData(UBSettings::sessionType).toString()); - mpSchoolTypeBox->setCurrentIndex((currentIndex != -1) ? currentIndex : 0); - - currentIndex = documentProxy->metaData(UBSettings::sessionLicence).toInt(); - mpLicenceBox->setCurrentIndex((currentIndex != -1) ? currentIndex : 0); -} - -void UBTeacherGuidePageZeroWidget::persistData() -{ - // check necessary because at document closing hide event is send after boardcontroller set - // to NULL - if (UBApplication::boardController) { - UBDocumentProxy* documentProxy = UBApplication::boardController->selectedDocument(); - documentProxy->setMetaData(UBSettings::sessionTitle, mpSessionTitle->text()); - documentProxy->setMetaData(UBSettings::sessionAuthors, mpAuthors->text()); - documentProxy->setMetaData(UBSettings::sessionObjectives, mpObjectives->text()); - documentProxy->setMetaData(UBSettings::sessionKeywords, mpKeywords->text()); - documentProxy->setMetaData(UBSettings::sessionGradeLevel, mpSchoolLevelBox->currentText()); - documentProxy->setMetaData(UBSettings::sessionSubjects, mpSchoolSubjectsBox->currentText()); - documentProxy->setMetaData(UBSettings::sessionType, mpSchoolTypeBox->currentText()); - documentProxy->setMetaData(UBSettings::sessionLicence, mpLicenceBox->currentIndex()); - } -} - -void UBTeacherGuidePageZeroWidget::updateSceneTitle() -{ - QString sessionTitle = mpSessionTitle->text(); - if (!sessionTitle.isEmpty()) - UBApplication::boardController->activeScene()->textForObjectName(mpSessionTitle->text()); -} - -void UBTeacherGuidePageZeroWidget::switchToMode(tUBTGZeroPageMode mode) -{ - if (mode == tUBTGZeroPageMode_EDITION) { - QString inputStyleSheet("QTextEdit { background: white; border-radius: 10px; border: 2px;}"); - mpModePushButton->hide(); - mpSessionTitle->setReadOnly(false); - mpSessionTitle->managePlaceholder(true); - mpSessionTitle->setStyleSheet(inputStyleSheet); - QFont titleFont(QApplication::font().family(), 11, -1); - mpSessionTitle->document()->setDefaultFont(titleFont); - mpAuthors->setReadOnly(false); - mpAuthors->managePlaceholder(false); - mpAuthors->setStyleSheet(inputStyleSheet); - mpObjectives->setReadOnly(false); - mpObjectives->managePlaceholder(false); - mpObjectives->setStyleSheet(inputStyleSheet); - mpKeywords->setReadOnly(false); - mpKeywords->managePlaceholder(false); - mpKeywords->setStyleSheet(inputStyleSheet); - mpSchoolLevelValueLabel->hide(); - mpSchoolLevelBox->show(); - mpSchoolSubjectsValueLabel->hide(); - mpSchoolSubjectsBox->show(); - mpSchoolTypeValueLabel->hide(); - mpSchoolTypeBox->show(); - mpLicenceIcon->hide(); - mpLicenceValueLabel->hide(); - mpLicenceBox->show(); - } - else { - QString inputStyleSheet( "QTextEdit { background: transparent; border: none;}"); - mpModePushButton->show(); - mpSessionTitle->showText(mpSessionTitle->text()); - mpSessionTitle->setStyleSheet(inputStyleSheet); - updateSceneTitle(); - QFont titleFont(QApplication::font().family(), 14, 1); - mpSessionTitle->document()->setDefaultFont(titleFont); - mpAuthors->setStyleSheet(inputStyleSheet); - mpAuthors->setTextColor(QColor(Qt::black)); - mpAuthors->showText(mpAuthors->text()); - mpObjectives->setStyleSheet(inputStyleSheet); - mpObjectives->setTextColor(QColor(Qt::black)); - mpObjectives->showText(mpObjectives->text()); - mpKeywords->setStyleSheet(inputStyleSheet); - mpKeywords->setTextColor(QColor(Qt::black)); - mpKeywords->showText(mpKeywords->text()); - mpSchoolLevelValueLabel->setText(mpSchoolLevelBox->currentText()); - mpSchoolLevelValueLabel->show(); - mpSchoolLevelBox->hide(); - mpSchoolSubjectsValueLabel->setText(mpSchoolSubjectsBox->currentText()); - mpSchoolSubjectsValueLabel->show(); - mpSchoolSubjectsBox->hide(); - mpSchoolTypeValueLabel->setText(mpSchoolTypeBox->currentText()); - mpSchoolTypeValueLabel->show(); - mpSchoolTypeBox->hide(); - mpLicenceValueLabel->setText(mpLicenceBox->currentText()); - QString licenceIconPath = mpLicenceBox->itemData(mpLicenceBox->currentIndex()).toString(); - if (!licenceIconPath.isEmpty()) { - mpLicenceIcon->setPixmap(QPixmap(licenceIconPath)); - mpLicenceIcon->show(); - } - mpLicenceValueLabel->show(); - mpLicenceBox->hide(); - persistData(); - } - update(); -} - -QVector UBTeacherGuidePageZeroWidget::getData() -{ - QVector result; - tUBGEElementNode* elementNode = new tUBGEElementNode(); - elementNode->name = "sessionTitle"; - elementNode->attributes.insert("value", mpSessionTitle->text()); - result << elementNode; - - elementNode = new tUBGEElementNode(); - elementNode->name = "authors"; - elementNode->attributes.insert("value", mpAuthors->text()); - result << elementNode; - - elementNode = new tUBGEElementNode(); - elementNode->name = "creationDate"; - elementNode->attributes.insert("value", mpCreationLabel->text()); - result << elementNode; - - elementNode = new tUBGEElementNode(); - elementNode->name = "lastModifiedDate"; - elementNode->attributes.insert("value", mpLastModifiedLabel->text()); - result << elementNode; - - elementNode = new tUBGEElementNode(); - elementNode->name = "goals"; - elementNode->attributes.insert("value", mpObjectives->text()); - result << elementNode; - - elementNode = new tUBGEElementNode(); - elementNode->name = "keywords"; - elementNode->attributes.insert("value", mpKeywords->text()); - result << elementNode; - - elementNode = new tUBGEElementNode(); - elementNode->name = "schoolLevel"; - elementNode->attributes.insert("value", mpSchoolLevelBox->currentText()); - result << elementNode; - - elementNode = new tUBGEElementNode(); - elementNode->name = "schoolBranch"; - elementNode->attributes.insert("value", mpSchoolSubjectsBox->currentText()); - result << elementNode; - - elementNode = new tUBGEElementNode(); - elementNode->name = "schoolType"; - elementNode->attributes.insert("value", mpSchoolTypeBox->currentText()); - result << elementNode; - - elementNode = new tUBGEElementNode(); - elementNode->name = "licence"; - elementNode->attributes.insert("value", QString("%1").arg(mpLicenceBox->currentIndex())); - result << elementNode; - return result; -} - -bool UBTeacherGuidePageZeroWidget::isModified() -{ - bool result = false; - result |= mpSessionTitle->text().length() > 0; - result |= mpAuthors->text().length() > 0; - result |= mpObjectives->text().length() > 0; - result |= mpKeywords->text().length() > 0; - result |= mpSchoolLevelBox->currentIndex() > 0; - result |= mpSchoolSubjectsBox->currentIndex() > 0; - result |= mpSchoolTypeBox->currentIndex() > 0; - result |= mpLicenceBox->currentIndex() > 0; - return result; -} - -void UBTeacherGuidePageZeroWidget::resizeEvent(QResizeEvent* ev) -{ - emit resized(); - QWidget::resizeEvent(ev); -} - -/*************************************************************************** - * class UBTeacherGuideWidget * - ***************************************************************************/ -UBTeacherGuideWidget::UBTeacherGuideWidget(QWidget* parent, const char* name) : - QStackedWidget(parent) - , mpPageZeroWidget(NULL) - , mpEditionWidget(NULL) - , mpPresentationWidget(NULL) - , mKeyboardActionFired(false) -{ - setObjectName(name); - if (UBSettings::settings()->teacherGuidePageZeroActivated->get().toBool()) { - mpPageZeroWidget = new UBTeacherGuidePageZeroWidget(this); - addWidget(mpPageZeroWidget); - } - if (UBSettings::settings()->teacherGuideLessonPagesActivated->get().toBool()) { - mpEditionWidget = new UBTeacherGuideEditionWidget(this); - addWidget(mpEditionWidget); - mpPresentationWidget = new UBTeacherGuidePresentationWidget(this); - addWidget(mpPresentationWidget); - } - - connect(UBApplication::boardController->controlView(), SIGNAL(clickOnBoard()), this, SLOT(showPresentationMode())); - connectToStylusPalette(); - connect(UBApplication::boardController, SIGNAL(activeSceneChanged()), this, SLOT(onActiveSceneChanged())); -} - -UBTeacherGuideWidget::~UBTeacherGuideWidget() -{ - DELETEPTR(mpPageZeroWidget); - DELETEPTR(mpEditionWidget); - DELETEPTR(mpPresentationWidget); -} - -void UBTeacherGuideWidget::onActiveSceneChanged() -{ - if (UBApplication::boardController->currentPage() == 0) { - if(mpPageZeroWidget->isModified()) - mpPageZeroWidget->switchToMode(tUBTGZeroPageMode_PRESENTATION); - else - mpPageZeroWidget->switchToMode(tUBTGZeroPageMode_EDITION); - - setCurrentWidget(mpPageZeroWidget); - } - else{ - if(mpEditionWidget->isModified()){ - mCurrentData = mpEditionWidget->getData(); - mpPresentationWidget->showData(mCurrentData); - setCurrentWidget(mpPresentationWidget); - } - else - setCurrentWidget(mpEditionWidget); - } - -} - -void UBTeacherGuideWidget::onTriggeredAction(bool checked) -{ - Q_UNUSED(checked); - if(!mKeyboardActionFired) - showPresentationMode(); - mKeyboardActionFired=false; -} - -void UBTeacherGuideWidget::onTriggeredKeyboardAction(bool checked) -{ - Q_UNUSED(checked); - mKeyboardActionFired = true; -} - -void UBTeacherGuideWidget::connectToStylusPalette() -{ - connect(UBApplication::mainWindow->actionPen, SIGNAL(triggered(bool)), this, SLOT(onTriggeredAction(bool))); - connect(UBApplication::mainWindow->actionEraser, SIGNAL(triggered(bool)), this, SLOT(onTriggeredAction(bool))); - connect(UBApplication::mainWindow->actionMarker, SIGNAL(triggered(bool)), this, SLOT(onTriggeredAction(bool))); - connect(UBApplication::mainWindow->actionPointer, SIGNAL(triggered(bool)), this, SLOT(onTriggeredAction(bool))); - connect(UBApplication::mainWindow->actionPlay, SIGNAL(triggered(bool)), this, SLOT(onTriggeredAction(bool))); - connect(UBApplication::mainWindow->actionZoomIn, SIGNAL(triggered(bool)), this, SLOT(onTriggeredAction(bool))); - connect(UBApplication::mainWindow->actionZoomOut, SIGNAL(triggered(bool)), this, SLOT(onTriggeredAction(bool))); - connect(UBApplication::mainWindow->actionCapture, SIGNAL(triggered(bool)), this, SLOT(onTriggeredAction(bool))); - connect(UBApplication::mainWindow->actionHand, SIGNAL(triggered(bool)), this, SLOT(onTriggeredAction(bool))); - connect(UBApplication::mainWindow->actionLine, SIGNAL(triggered(bool)), this, SLOT(onTriggeredAction(bool))); - connect(UBApplication::mainWindow->actionText, SIGNAL(triggered(bool)), this, SLOT(onTriggeredAction(bool))); - connect(UBApplication::mainWindow->actionSelector, SIGNAL(triggered(bool)), this, SLOT(onTriggeredAction(bool))); - connect(UBApplication::mainWindow->actionVirtualKeyboard, SIGNAL(triggered(bool)), this, SLOT(onTriggeredKeyboardAction(bool))); -} - -void UBTeacherGuideWidget::showPresentationMode() -{ - if (currentWidget() == mpPageZeroWidget) { - mCurrentData = mpPageZeroWidget->getData(); - mpPageZeroWidget->switchToMode(tUBTGZeroPageMode_PRESENTATION); - } - else if (currentWidget() == mpEditionWidget) { - mCurrentData = mpEditionWidget->getData(); - mpPresentationWidget->showData(mCurrentData); - setCurrentWidget(mpPresentationWidget); - } -} - -void UBTeacherGuideWidget::changeMode() -{ - if (currentWidget() == mpEditionWidget) - setCurrentWidget(mpPresentationWidget); - else - setCurrentWidget(mpEditionWidget); - -} - -bool UBTeacherGuideWidget::isModified() -{ - if (currentWidget() == mpPageZeroWidget) - return mpPageZeroWidget->isModified(); - else - return mpEditionWidget->isModified(); -} - diff --git a/src/gui/UBTeacherGuideWidget.h b/src/gui/UBTeacherGuideWidget.h deleted file mode 100644 index 5c445cec..00000000 --- a/src/gui/UBTeacherGuideWidget.h +++ /dev/null @@ -1,252 +0,0 @@ -/* - * Copyright (C) 2010-2013 Groupement d'Intérêt Public pour l'Education Numérique en Afrique (GIP ENA) - * - * This file is part of Open-Sankoré. - * - * Open-Sankoré 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, version 3 of the License, - * with a specific linking exception for the OpenSSL project's - * "OpenSSL" library (or with modified versions of it that use the - * same license as the "OpenSSL" library). - * - * Open-Sankoré 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 Open-Sankoré. If not, see . - */ - - - -#ifndef UBTEACHERGUIDEWIDGET_H -#define UBTEACHERGUIDEWIDGET_H - -class QTreeWidget; -class QHeaderView; -class QLabel; -class QVBoxLayout; -class QPushButton; -class UBDocumentProxy; -class UBGraphicsTextItem; -class QScrollArea; - -#include "UBTeacherGuideWidgetsTools.h" - -#include "interfaces/IDataStorage.h" - -typedef enum -{ - tUBTGZeroPageMode_EDITION, - tUBTGZeroPageMode_PRESENTATION -}tUBTGZeroPageMode; - -#define LOWER_RESIZE_WIDTH 50 - -/*************************************************************************** - * class UBTeacherGuideEditionWidget * - ***************************************************************************/ -class UBTeacherGuideEditionWidget : public QWidget , public IDataStorage -{ - Q_OBJECT -public: - explicit UBTeacherGuideEditionWidget(QWidget* parent = 0, const char* name="UBTeacherGuideEditionWidget"); - ~UBTeacherGuideEditionWidget(); - void cleanData(); - QVector getData(); - - void load(QString element); - QVector save(int pageIndex); - - bool isModified(); - -public slots: - void onAddItemClicked(QTreeWidgetItem* widget, int column, QDomElement* element = 0); - void onActiveSceneChanged(); - void showEvent(QShowEvent* event); - -private: - QList getChildrenList(QTreeWidgetItem* widgetItem); - QVector getPageAndCommentData(); - - QVBoxLayout* mpLayout; - QLabel* mpDocumentTitle; - QLabel* mpPageNumberLabel; - UBTGAdaptableText* mpPageTitle; - UBTGAdaptableText* mpComment; - QFrame* mpSeparator; - QTreeWidget* mpTreeWidget; - QTreeWidgetItem* mpRootWidgetItem; - UBAddItem* mpAddAnActionItem; - UBAddItem* mpAddAMediaItem; - UBAddItem* mpAddALinkItem; - -private slots: - void onActiveDocumentChanged(); -#ifdef Q_WS_MACX - void onSliderMoved(int size); -#endif -}; - - -/*************************************************************************** - * class UBTeacherGuidePresentationWidget * - ***************************************************************************/ -class UBTeacherGuidePresentationWidget : public QWidget -{ - Q_OBJECT -public: - explicit UBTeacherGuidePresentationWidget(QWidget* parent, const char* name = "UBTeacherGuidePresentationName"); - ~UBTeacherGuidePresentationWidget(); - void showData(QVectordata); - void cleanData(); - -public slots: - void onAddItemClicked(QTreeWidgetItem* widget, int column); - void onActiveSceneChanged(); - -private: - bool eventFilter(QObject* object, QEvent* event); - - void createMediaButtonItem(); - - UBTGAdaptableText* mpPageTitle; - UBTGAdaptableText* mpComment; - QVBoxLayout* mpLayout; - QHBoxLayout* mpButtonTitleLayout; - QLabel* mpDocumentTitle; - QLabel* mpPageNumberLabel; - QFrame* mpSeparator; - QPushButton* mpModePushButton; - UBTGDraggableTreeItem* mpTreeWidget; - QTreeWidgetItem* mpRootWidgetItem; - QTreeWidgetItem* mpMediaSwitchItem; - - -#ifdef Q_WS_MACX -private slots: - void onSliderMoved(int size); -#endif - -}; - -/*************************************************************************** - * class UBTeacherGuidePageZeroWidget * - ***************************************************************************/ -class UBTeacherGuidePageZeroWidget : public QWidget -{ - Q_OBJECT - -public: - explicit UBTeacherGuidePageZeroWidget(QWidget* parent, const char* name = "UBTeacherGuidePageZeroEditionWidget"); - ~UBTeacherGuidePageZeroWidget(); - - QVector getData(); - bool isModified(); - -signals: - void resized(); - -public slots: - void onActiveSceneChanged(); - void switchToMode(tUBTGZeroPageMode mode = tUBTGZeroPageMode_EDITION); - -protected: - void resizeEvent(QResizeEvent* ev); - -private: - void fillComboBoxes(); - void loadData(); - void hideEvent(QHideEvent* event); - bool eventFilter(QObject* object, QEvent* event); - void updateSceneTitle(); - - QVBoxLayout* mpLayout; - QHBoxLayout* mpButtonTitleLayout; - QVBoxLayout* mpContainerWidgetLayout; - QPushButton* mpModePushButton; - QLabel* mpPageNumberLabel; - - QScrollArea* mpScrollArea; - QWidget* mpContainerWidget; - - UBTGAdaptableText* mpSessionTitle; - QFrame* mpSeparatorSessionTitle; - - QLabel* mpAuthorsLabel; - UBTGAdaptableText* mpAuthors; - QFrame* mpSeparatorAuthors; - - QLabel* mpCreationLabel; - QLabel* mpLastModifiedLabel; - QLabel* mpObjectivesLabel; - UBTGAdaptableText* mpObjectives; - QFrame* mpSeparatorObjectives; - - QLabel* mpIndexLabel; - QLabel* mpKeywordsLabel; - UBTGAdaptableText* mpKeywords; - - QLabel* mpSchoolLevelItemLabel; - QComboBox* mpSchoolLevelBox; - QLabel* mpSchoolLevelValueLabel; - - QLabel* mpSchoolSubjectsItemLabel; - QComboBox* mpSchoolSubjectsBox; - QLabel* mpSchoolSubjectsValueLabel; - - QLabel* mpSchoolTypeItemLabel; - QComboBox* mpSchoolTypeBox; - QLabel* mpSchoolTypeValueLabel; - QFrame* mpSeparatorIndex; - - QLabel* mpLicenceLabel; - QComboBox* mpLicenceBox; - QLabel* mpLicenceValueLabel; - QLabel* mpLicenceIcon; - QHBoxLayout* mpLicenceLayout; - - UBGraphicsTextItem* mpSceneItemSessionTitle; - - QMap mGradeLevelsMap; - QMap mSubjects; - -private slots: - void onSchoolLevelChanged(QString schoolLevel); - void persistData(); -}; - -/*************************************************************************** - * class UBTeacherGuideWidget * - ***************************************************************************/ - -class UBTeacherGuideWidget : public QStackedWidget -{ - Q_OBJECT -public: - explicit UBTeacherGuideWidget(QWidget* parent = 0, const char* name="UBTeacherGuideWidget"); - ~UBTeacherGuideWidget(); - - bool isModified(); - -public slots: - void changeMode(); - void showPresentationMode(); - void connectToStylusPalette(); - void onActiveSceneChanged(); - -private: - UBTeacherGuidePageZeroWidget* mpPageZeroWidget; - UBTeacherGuideEditionWidget* mpEditionWidget; - UBTeacherGuidePresentationWidget* mpPresentationWidget; - QVectormCurrentData; - bool mKeyboardActionFired; - -private slots: - void onTriggeredAction(bool checked); - void onTriggeredKeyboardAction(bool checked); -}; - -#endif // UBTEACHERGUIDEWIDGET_H diff --git a/src/gui/UBTeacherGuideWidgetsTools.cpp b/src/gui/UBTeacherGuideWidgetsTools.cpp deleted file mode 100644 index 87c0c722..00000000 --- a/src/gui/UBTeacherGuideWidgetsTools.cpp +++ /dev/null @@ -1,724 +0,0 @@ -/* - * Copyright (C) 2010-2013 Groupement d'Intérêt Public pour l'Education Numérique en Afrique (GIP ENA) - * - * This file is part of Open-Sankoré. - * - * Open-Sankoré 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, version 3 of the License, - * with a specific linking exception for the OpenSSL project's - * "OpenSSL" library (or with modified versions of it that use the - * same license as the "OpenSSL" library). - * - * Open-Sankoré 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 Open-Sankoré. If not, see . - */ - - - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "UBTeacherGuideWidgetsTools.h" - -#include "core/UBPersistenceManager.h" -#include "core/UBApplication.h" - -#include "board/UBBoardController.h" - -#include "domain/UBGraphicsWidgetItem.h" - -#include "globals/UBGlobals.h" - -#include "frameworks/UBFileSystemUtils.h" - -#include "customWidgets/UBMediaWidget.h" - -#include "core/memcheck.h" - - -/*************************************************************************** - * class UBAddItem * - ***************************************************************************/ -UBAddItem::UBAddItem(const QString &string, int addSubItemWidgetType, QTreeWidget* parent): QTreeWidgetItem(parent) -{ - setIcon(0,QIcon(":images/increase.svg")); - setText(0,string); - setData(0,Qt::UserRole,QVariant(addSubItemWidgetType)); - setData(1,Qt::UserRole,QVariant(addSubItemWidgetType)); - setData(0,Qt::BackgroundRole,QVariant(QColor(200,200,200))); - setData(1,Qt::BackgroundRole,QVariant(QColor(200,200,200))); - setData(0,Qt::FontRole,QVariant(QFont(QApplication::font().family(),12))); -} - -UBAddItem::~UBAddItem() -{ - //NOOP -} - -/*************************************************************************** - * class UBTGActionWidget * - ***************************************************************************/ -UBTGActionWidget::UBTGActionWidget(QTreeWidgetItem* widget, QWidget* parent, const char* name) : QWidget(parent) - , mpLayout(NULL) - , mpOwner(NULL) - , mpTask(NULL) -{ - setObjectName(name); - SET_STYLE_SHEET(); - mpLayout = new QVBoxLayout(this); - mpOwner = new QComboBox(this); - mpOwner->setObjectName("DockPaletteWidgetComboBox"); - mpOwner->setMinimumHeight(22); - QStringList qslOwner; - qslOwner << tr("Teacher") << tr("Student"); - mpOwner->insertItems(0,qslOwner); - mpOwner->setCurrentIndex(0); - mpTask = new UBTGAdaptableText(widget,this); - mpTask->setPlaceHolderText(tr("Type task here ...")); - mpTask->setAcceptRichText(true); - mpTask->setObjectName("ActionWidgetTaskTextEdit"); - mpLayout->addWidget(mpOwner); - mpLayout->addWidget(mpTask); -} - -UBTGActionWidget::~UBTGActionWidget() -{ - DELETEPTR(mpOwner); - DELETEPTR(mpTask); - DELETEPTR(mpLayout); -} - -void UBTGActionWidget::initializeWithDom(QDomElement element) -{ - mpOwner->setCurrentIndex(element.attribute("owner").toInt()); - mpTask->setInitialText(element.attribute("task")); -} - -tUBGEElementNode* UBTGActionWidget::saveData() -{ - tUBGEElementNode* result = new tUBGEElementNode(); - result->name = "action"; - result->attributes.insert("owner",QString("%0").arg(mpOwner->currentIndex())); - result->attributes.insert("task",mpTask->text()); - return result; -} - -/*************************************************************************** - * class UBTGAdaptableText * - ***************************************************************************/ -UBTGAdaptableText::UBTGAdaptableText(QTreeWidgetItem* widget, QWidget* parent, const char* name):QTextEdit(parent) - , mBottomMargin(5) - , mpTreeWidgetItem(widget) - , mMinimumHeight(0) - , mHasPlaceHolder(false) - , mIsUpdatingSize(false) - , mMaximumLength(0) -{ - setObjectName(name); - connect(this,SIGNAL(textChanged()),this,SLOT(onTextChanged())); - setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - - mMinimumHeight = document()->size().height() + mBottomMargin; - setMinimumHeight(mMinimumHeight); - -} - -void UBTGAdaptableText::setMaximumLength(int length) -{ - mMaximumLength = length; -} - -void UBTGAdaptableText::setPlaceHolderText(QString text) -{ - mHasPlaceHolder = true; - - // the space addition is to make this string unique and check against it to know - // if we are talking about a typed string or the placeholder string - mPlaceHolderText = text + " "; - setPlainText(mPlaceHolderText); -} - -void UBTGAdaptableText::keyReleaseEvent(QKeyEvent* e) -{ - QTextEdit::keyReleaseEvent(e); - - if(mMaximumLength && toPlainText().length()>mMaximumLength){ - setPlainText(toPlainText().left(mMaximumLength)); - QTextCursor tc(document()); - tc.setPosition(mMaximumLength); - setTextCursor(tc); - } -} - -void UBTGAdaptableText::showEvent(QShowEvent* e) -{ - Q_UNUSED(e); - if(!mIsUpdatingSize && !hasFocus() && mHasPlaceHolder && toPlainText().isEmpty() && !isReadOnly()){ - setTextColor(QColor(Qt::lightGray)); - setPlainText(mPlaceHolderText); - } - else - // If the teacherguide is collapsed, don't updated the size. Or set the size as the expanded size - onTextChanged(); -} - -QString UBTGAdaptableText::text() -{ - QString result = toPlainText(); - if(mHasPlaceHolder && result == mPlaceHolderText) - return ""; - - return result; -} - -void UBTGAdaptableText::onTextChanged() -{ - qreal documentSize = document()->size().height(); - if(height() == documentSize + mBottomMargin){ - return; - } - mIsUpdatingSize = true; - - - if(documentSize < mMinimumHeight){ - setFixedHeight(mMinimumHeight); - } - else{ - setFixedHeight(documentSize+mBottomMargin); - } - - updateGeometry(); - //to trig a resize on the tree widget item - if(mpTreeWidgetItem){ - mpTreeWidgetItem->setDisabled(true); - mpTreeWidgetItem->setExpanded(true); - mpTreeWidgetItem->setDisabled(false); - setFocus(); - } - mIsUpdatingSize = false; -} - -void UBTGAdaptableText::setInitialText(const QString& text) -{ - setText(text); - setReadOnly(false); - onTextChanged(); -} - -void UBTGAdaptableText::resetText() -{ - if(mHasPlaceHolder && !mPlaceHolderText.isEmpty()){ - setTextColor(QColor(Qt::lightGray)); - setText(mPlaceHolderText); - } - else{ - setText(""); - setTextColor(QColor(Qt::black)); - } - onTextChanged(); -} - -void UBTGAdaptableText::showText(const QString & text) -{ - setText(text); - setReadOnly(true); - onTextChanged(); -} - -void UBTGAdaptableText::bottomMargin(int newValue) -{ - mBottomMargin = newValue; - onTextChanged(); -} - -void UBTGAdaptableText::focusInEvent(QFocusEvent* e) -{ - if(isReadOnly()){ - e->ignore(); - } - managePlaceholder(true); - QTextEdit::focusInEvent(e); -} - -void UBTGAdaptableText::focusOutEvent(QFocusEvent* e) -{ - managePlaceholder(false); - QTextEdit::focusOutEvent(e); -} - -void UBTGAdaptableText::insertFromMimeData(const QMimeData *source) -{ - QMimeData editedMimeData; - QTextDocument textDoc; - QString plainText; - - if (source->hasHtml()) - { - textDoc.setHtml(source->html()); - plainText += textDoc.toPlainText(); - } - if (source->hasText()) - if (textDoc.toPlainText() != source->text()) - plainText += source->text(); - if (source->hasUrls()) - { - foreach(QUrl url, source->urls()) - { - plainText += url.toString(); - } - } - - editedMimeData.setText(plainText); - QTextEdit::insertFromMimeData(&editedMimeData); -} - -void UBTGAdaptableText::managePlaceholder(bool focus) -{ - if(focus){ - if(toPlainText() == mPlaceHolderText){ - setTextColor(QColor(Qt::black)); - setPlainText(""); - setCursorToTheEnd(); - } - } - else{ - if(toPlainText().isEmpty()){ - setTextColor(QColor(Qt::lightGray)); - setPlainText(mPlaceHolderText); - } - } -} - -void UBTGAdaptableText::setCursorToTheEnd() -{ - QTextDocument* doc = document(); - if(NULL != doc){ - QTextBlock block = doc->lastBlock(); - QTextCursor cursor(doc); - cursor.setPosition(block.position() + block.length() - 1); - setTextCursor(cursor); - } -} - -/*************************************************************************** - * class UBTGDraggableWeb * - ***************************************************************************/ -UBDraggableWeb::UBDraggableWeb(QString& relativePath, QWidget* parent): QWebView(parent) - , mDragStartPosition(QPoint(-1,-1)) - , mDragStarted(false) - -{ - if(!relativePath.startsWith("file://")) - mRelativePath = QUrl::fromLocalFile(relativePath).toString(); - else - mRelativePath = relativePath; - //NOOP -} - -void UBDraggableWeb::mousePressEvent(QMouseEvent* event) -{ - mDragStartPosition = event->pos(); - mDragStarted = true; - QWebView::mousePressEvent(event); -} - -void UBDraggableWeb::mouseReleaseEvent(QMouseEvent* event) -{ - mDragStarted = false; - QWebView::mouseReleaseEvent(event); -} - -void UBDraggableWeb::mouseMoveEvent(QMouseEvent* event) -{ - if(mDragStarted && (event->pos() - mDragStartPosition).manhattanLength() > QApplication::startDragDistance()){ - QDrag *drag = new QDrag(this); - QMimeData *mimeData = new QMimeData; - QList urlList; - urlList << QUrl(mRelativePath); - mimeData->setUrls(urlList); - drag->setMimeData(mimeData); - - drag->exec(); - event->accept(); - mDragStarted = false; - } - else - QWebView::mouseMoveEvent(event); - -} - -/*************************************************************************** - * class UBTGMediaWidget * - ***************************************************************************/ -UBTGMediaWidget::UBTGMediaWidget(QTreeWidgetItem* widget, QWidget* parent,const char* name): QStackedWidget(parent) - , mpTreeWidgetItem(widget) - , mpDropMeWidget(NULL) - , mpWorkWidget(NULL) - , mpLayout(NULL) - , mpMediaLayout(NULL) - , mpTitle(NULL) - , mpMediaLabelWidget(NULL) - , mpMediaWidget(NULL) - , mpWebView(NULL) - , mMediaPath(QString("")) - , mIsPresentationMode(false) - , mIsInitializationMode(false) - , mMediaWidgetHeight(150) -{ - setObjectName(name); - mpDropMeWidget = new QLabel(); - mpDropMeWidget->setObjectName("UBTGMediaDropMeLabel"); - mpDropMeWidget->setText(tr("drop media here ...")); - mpDropMeWidget->setAlignment(Qt::AlignCenter); - setAcceptDrops(true); - addWidget(mpDropMeWidget); - - setMinimumHeight(250); -} - -UBTGMediaWidget::UBTGMediaWidget(QString mediaPath, QTreeWidgetItem* widget, QWidget* parent,bool forceFlashMediaType,const char* name): QStackedWidget(parent) - , mpTreeWidgetItem(widget) - , mpDropMeWidget(NULL) - , mpWorkWidget(NULL) - , mpLayout(NULL) - , mpMediaLayout(NULL) - , mpTitle(NULL) - , mpMediaLabelWidget(NULL) - , mpMediaWidget(NULL) - , mpWebView(NULL) - , mIsPresentationMode(true) - , mMediaType("") - , mIsInitializationMode(false) - , mMediaWidgetHeight(150) -{ - setObjectName(name); - mMediaPath = UBApplication::boardController->selectedDocument()->persistencePath()+ "/" + mediaPath; - setAcceptDrops(false); - createWorkWidget(forceFlashMediaType); - setFixedHeight(200); -} - -UBTGMediaWidget::~UBTGMediaWidget() -{ - DELETEPTR(mpTitle); - DELETEPTR(mpMediaLabelWidget); - DELETEPTR(mpMediaWidget); - DELETEPTR(mpWebView); - DELETEPTR(mpMediaLayout); - DELETEPTR(mpLayout); - - removeWidget(mpDropMeWidget); - DELETEPTR(mpDropMeWidget); - removeWidget(mpWorkWidget); - DELETEPTR(mpWorkWidget); -} - -void UBTGMediaWidget::initializeWithDom(QDomElement element) -{ - mIsInitializationMode = true; - setAcceptDrops(false); - mMediaPath = UBApplication::boardController->selectedDocument()->persistencePath() + "/" + element.attribute("relativePath"); - createWorkWidget(element.attribute("mediaType").contains("flash")); - setFixedHeight(200); - mpTitle->setInitialText(element.attribute("title")); - mIsInitializationMode = false; -} - -void UBTGMediaWidget::removeSource() -{ - QFileInfo fileInfo(mMediaPath); - if(fileInfo.isFile()) - QFile(mMediaPath).remove(); - else - UBFileSystemUtils::deleteDir(mMediaPath); -} - -void UBTGMediaWidget::hideEvent(QHideEvent* event) -{ - if(mpWebView) - mpWebView->page()->mainFrame()->setContent(UBGraphicsW3CWidgetItem::freezedWidgetPage().toAscii()); - QWidget::hideEvent(event); -} - -void UBTGMediaWidget::showEvent(QShowEvent* event) -{ - QWidget::showEvent(event); - if(mpWebView){ - QString indexPath = mMediaPath+"/index.htm"; - if(!QFile::exists(indexPath)) - indexPath += "l"; - mpWebView->load(QUrl::fromLocalFile(indexPath)); - } -} - -tUBGEElementNode* UBTGMediaWidget::saveData() -{ - if(!mpTitle) - return 0; - tUBGEElementNode* result = new tUBGEElementNode(); - QString relativePath = mMediaPath; - relativePath = relativePath.replace(UBApplication::boardController->selectedDocument()->persistencePath()+"/",""); - result->name = "media"; - result->attributes.insert("title",mpTitle->text()); - result->attributes.insert("relativePath",relativePath); - result->attributes.insert("mediaType",mMediaType); - return result; -} - -void UBTGMediaWidget::dragEnterEvent(QDragEnterEvent *event) -{ - event->accept(); -} - -void UBTGMediaWidget::createWorkWidget(bool forceFlashMediaType) -{ - QString mimeType = UBFileSystemUtils::mimeTypeFromFileName(mMediaPath); - bool setMedia = true; - UBDocumentProxy* proxyDocument = UBApplication::boardController->selectedDocument(); - if(mimeType.contains("audio") || mimeType.contains("video")){ - mMediaType = mimeType.contains("audio")? "audio":"movie"; - mpMediaWidget = new UBMediaWidget(mimeType.contains("audio")?eMediaType_Audio:eMediaType_Video); - if(mIsPresentationMode || mIsInitializationMode){ - mpMediaWidget->setFile(mMediaPath); - } - else{ - mMediaPath = UBPersistenceManager::persistenceManager()->addObjectToTeacherGuideDirectory(proxyDocument, mMediaPath); - mpMediaWidget->setFile(mMediaPath); - } - } - else if(mimeType.contains("image")){ - mMediaType = "image"; - if(!(mIsPresentationMode || mIsInitializationMode)) - mMediaPath = UBPersistenceManager::persistenceManager()->addObjectToTeacherGuideDirectory(proxyDocument, mMediaPath); - - mpMediaLabelWidget = new QLabel(); - QPixmap pixmap = QPixmap(mMediaPath); - pixmap = pixmap.scaledToHeight(mMediaWidgetHeight); - mpMediaLabelWidget->setPixmap(pixmap); - } - else if(mimeType.contains("widget") && !forceFlashMediaType){ - mMediaType = "w3c"; - if(!(mIsPresentationMode || mIsInitializationMode)){ - mMediaPath = UBPersistenceManager::persistenceManager()->addWidgetToTeacherGuideDirectory(proxyDocument, mMediaPath); - } - mpWebView = new UBDraggableWeb(mMediaPath); - mpWebView->setAcceptDrops(false); - mpWebView->settings()->setAttribute(QWebSettings::JavaEnabled, true); - mpWebView->settings()->setAttribute(QWebSettings::PluginsEnabled, true); - mpWebView->settings()->setAttribute(QWebSettings::LocalStorageDatabaseEnabled, true); - mpWebView->settings()->setAttribute(QWebSettings::OfflineWebApplicationCacheEnabled, true); - mpWebView->settings()->setAttribute(QWebSettings::OfflineStorageDatabaseEnabled, true); - mpWebView->settings()->setAttribute(QWebSettings::JavascriptCanAccessClipboard, true); - mpWebView->settings()->setAttribute(QWebSettings::DnsPrefetchEnabled, true); - QString indexPath = mMediaPath+"/index.htm"; - if(!QFile::exists(indexPath)) - indexPath += "l"; - mpWebView->load(QUrl::fromLocalFile(indexPath)); - } - else if(mimeType.contains("x-shockwave-flash") || forceFlashMediaType){ - mMediaType = "flash"; - if(!(mIsPresentationMode || mIsInitializationMode)){ - QDir baseW3CDirectory(UBPersistenceManager::persistenceManager()->teacherGuideAbsoluteObjectPath(proxyDocument)); - mMediaPath = UBGraphicsW3CWidgetItem::createNPAPIWrapperInDir(mMediaPath,baseW3CDirectory,mimeType,QSize(100,100),QUuid::createUuid()); - } - qDebug() << mMediaPath; - mpWebView = new UBDraggableWeb(mMediaPath); - mpWebView->setAcceptDrops(false); - mpWebView->settings()->setAttribute(QWebSettings::JavaEnabled, true); - mpWebView->settings()->setAttribute(QWebSettings::PluginsEnabled, true); - mpWebView->settings()->setAttribute(QWebSettings::LocalStorageDatabaseEnabled, true); - mpWebView->settings()->setAttribute(QWebSettings::OfflineWebApplicationCacheEnabled, true); - mpWebView->settings()->setAttribute(QWebSettings::OfflineStorageDatabaseEnabled, true); - mpWebView->settings()->setAttribute(QWebSettings::JavascriptCanAccessClipboard, true); - mpWebView->settings()->setAttribute(QWebSettings::DnsPrefetchEnabled, true); - QString indexPath = mMediaPath+"/index.htm"; - if(!QFile::exists(indexPath)) - indexPath += "l"; - mpWebView->load(QUrl::fromLocalFile(indexPath)); - } - else{ - qDebug() << "createWorkWidget mime type not handled" << mimeType; - setMedia=false; - } - - if(setMedia){ - setAcceptDrops(false); - mpWorkWidget = new QWidget(this); - if(!mIsPresentationMode){ - mpLayout = new QVBoxLayout(mpWorkWidget); - mpTitle = new UBTGAdaptableText(mpTreeWidgetItem,mpWorkWidget); - mpTitle->setPlaceHolderText(tr("Type title here...")); - mpLayout->addWidget(mpTitle); - mpMediaLayout = new QHBoxLayout; - mpLayout->addLayout(mpMediaLayout); - mpWorkWidget->setLayout(mpLayout); - } - else{ - mpMediaLayout = new QHBoxLayout(mpWorkWidget); - mpWorkWidget->setLayout(mpMediaLayout); - } - - mpMediaLayout->addStretch(1); - - if(mpMediaLabelWidget){ - mpMediaLabelWidget->setFixedHeight(mMediaWidgetHeight); - mpMediaLabelWidget->setParent(mpWorkWidget); - mpMediaLayout->addWidget(mpMediaLabelWidget); - } - else if (mpMediaWidget){ - mpMediaWidget->setFixedHeight(mMediaWidgetHeight); - mpMediaWidget->setParent(mpWorkWidget); - mpMediaLayout->addWidget(mpMediaWidget); - } - else if (mpWebView){ - mpWebView->setFixedHeight(mMediaWidgetHeight); - mpWebView->setParent(mpWorkWidget); - mpMediaLayout->addWidget(mpWebView); - mpWebView->show(); - } - mpMediaLayout->addStretch(1); - addWidget(mpWorkWidget); - setCurrentWidget(mpWorkWidget); - mpWorkWidget->show(); - - } -} - -void UBTGMediaWidget::parseMimeData(const QMimeData* pMimeData) -{ - if(pMimeData){ - if(pMimeData->hasText()){ - mMediaPath = QUrl::fromLocalFile(pMimeData->text()).toString(); - } - else if(pMimeData->hasUrls()){ - mMediaPath = pMimeData->urls().at(0).toString(); - } - else if(pMimeData->hasImage()){ - qDebug() << "Not yet implemented"; - } - } - else - qDebug() << "No mime data present"; - - createWorkWidget(); -} - -void UBTGMediaWidget::dropEvent(QDropEvent* event) -{ - parseMimeData(event->mimeData()); - event->accept(); -} - -void UBTGMediaWidget::mousePressEvent(QMouseEvent *event) -{ - if (!mIsPresentationMode) - event->ignore(); - else{ - QDrag *drag = new QDrag(this); - QMimeData *mimeData = new QMimeData(); - QList urlList; -#ifdef Q_WS_WIN - urlList << QUrl::fromLocalFile(mMediaPath); -#else - urlList << QUrl(mMediaPath); -#endif - mimeData->setUrls(urlList); - drag->setMimeData(mimeData); - - drag->exec(); - event->accept(); - } -} - - - -/*************************************************************************** - * class UBTGUrlWidget * - ***************************************************************************/ -UBTGUrlWidget::UBTGUrlWidget(QWidget* parent, const char* name ):QWidget(parent) - , mpLayout(NULL) - , mpTitle(NULL) - , mpUrl(NULL) -{ - setObjectName(name); - SET_STYLE_SHEET(); - mpLayout = new QVBoxLayout(this); - setLayout(mpLayout); - mpTitle = new QLineEdit(this); - mpTitle->setObjectName("UBTGLineEdit"); - mpTitle->setPlaceholderText(tr("Insert link title here...")); - mpUrl = new QLineEdit(this); - connect(mpUrl,SIGNAL(editingFinished()),this,SLOT(onUrlEditionFinished())); - mpUrl->setObjectName("UBTGLineEdit"); - mpUrl->setPlaceholderText("http://"); - mpLayout->addWidget(mpTitle); - mpLayout->addWidget(mpUrl); -} - -UBTGUrlWidget::~UBTGUrlWidget() -{ - DELETEPTR(mpTitle); - DELETEPTR(mpUrl); - DELETEPTR(mpLayout); -} - -void UBTGUrlWidget::onUrlEditionFinished() -{ - QString url = mpUrl->text(); - if(url.length() && !url.startsWith("http://") && !url.startsWith("https://") && !url.startsWith("ftp://") && !url.startsWith("sftp://") && !url.startsWith("http://")){ - mpUrl->setText("http://" + mpUrl->text()); - setFocus(); - } -} - -void UBTGUrlWidget::initializeWithDom(QDomElement element) -{ - mpTitle->setText(element.attribute("title")); - mpUrl->setText(element.attribute("url")); -} - -tUBGEElementNode* UBTGUrlWidget::saveData() -{ - tUBGEElementNode* result = new tUBGEElementNode(); - result->name = "link"; - result->attributes.insert("title",mpTitle->text()); - result->attributes.insert("url",mpUrl->text()); - return result; -} - - -/*************************************************************************** - * class UBTGDraggableTreeItem * - ***************************************************************************/ -UBTGDraggableTreeItem::UBTGDraggableTreeItem(QWidget* parent, const char* name) : QTreeWidget(parent) -{ - setObjectName(name); -} - -QMimeData* UBTGDraggableTreeItem::mimeData(const QList items) const -{ - QMimeData* result = new QMimeData(); - QList urls; - urls << QUrl(items.at(0)->data(0,TG_USER_ROLE_MIME_TYPE).toString()); - result->setUrls(urls); - return result; -} diff --git a/src/gui/UBTeacherGuideWidgetsTools.h b/src/gui/UBTeacherGuideWidgetsTools.h deleted file mode 100644 index ba944ddd..00000000 --- a/src/gui/UBTeacherGuideWidgetsTools.h +++ /dev/null @@ -1,220 +0,0 @@ -/* - * Copyright (C) 2010-2013 Groupement d'Intérêt Public pour l'Education Numérique en Afrique (GIP ENA) - * - * This file is part of Open-Sankoré. - * - * Open-Sankoré 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, version 3 of the License, - * with a specific linking exception for the OpenSSL project's - * "OpenSSL" library (or with modified versions of it that use the - * same license as the "OpenSSL" library). - * - * Open-Sankoré 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 Open-Sankoré. If not, see . - */ - - - -#ifndef UBTEACHERGUIDEWIDGETSTOOLS_H -#define UBTEACHERGUIDEWIDGETSTOOLS_H - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "customWidgets/UBMediaWidget.h" - -#define TG_USER_ROLE_MIME_TYPE (Qt::UserRole+50) - - -class QTreeWidget; -class QVBoxLayout; -class QComboBox; -class QTextEdit; -class QWidget; -class UBTGAdaptableText; -class QDomElement; -class UBMediaWidget; - -typedef struct -{ - QString name; - QMap attributes; -}tUBGEElementNode; - - -class iUBTGSaveData -{ -public: - virtual tUBGEElementNode* saveData() = 0; -}; - - -class UBAddItem : public QTreeWidgetItem -{ -public: - explicit UBAddItem(const QString &strings, int addSubItemWidgetType, QTreeWidget* parent = 0); - ~UBAddItem(); - -signals: - -public slots: -}; - -class UBTGActionWidget : public QWidget, public iUBTGSaveData -{ - Q_OBJECT - -public: - explicit UBTGActionWidget(QTreeWidgetItem* widget, QWidget* parent = 0,const char* name = "UBTGActionWidget"); - ~UBTGActionWidget(); - void update(); - tUBGEElementNode* saveData(); - void initializeWithDom(QDomElement element); - -private: - QVBoxLayout* mpLayout; - QComboBox* mpOwner; - UBTGAdaptableText* mpTask; - -protected: - QTreeWidgetItem* mpTreeWidgetItem; -}; - - -class UBTGAdaptableText : public QTextEdit -{ - Q_OBJECT -public: - explicit UBTGAdaptableText(QTreeWidgetItem* widget = 0, QWidget *parent = 0, const char* name = "UBTGAdaptableText"); - void showText(const QString & text); - void resetText(); - void bottomMargin(int newValue); - void setPlaceHolderText(QString text); - QString text(); - void setInitialText(const QString& text); - void setMaximumLength(int length); - void managePlaceholder(bool focus); - -public slots: - void onTextChanged(); - -protected: - void keyReleaseEvent(QKeyEvent* e); - void showEvent(QShowEvent* e); - void focusInEvent(QFocusEvent* e); - void focusOutEvent(QFocusEvent* e); - virtual void insertFromMimeData(const QMimeData *source); - -private: - void setCursorToTheEnd(); - int mBottomMargin; - QTreeWidgetItem* mpTreeWidgetItem; - int mMinimumHeight; - bool mHasPlaceHolder; - QString mPlaceHolderText; - bool mIsUpdatingSize; - int mMaximumLength; -}; - - -class UBDraggableWeb : public QWebView -{ - Q_OBJECT -public: - explicit UBDraggableWeb(QString& relativePath, QWidget* parent = 0); - -private: - void mousePressEvent(QMouseEvent* event); - void mouseMoveEvent(QMouseEvent* event); - void mouseReleaseEvent(QMouseEvent* event); - - QString mRelativePath; - QPoint mDragStartPosition; - bool mDragStarted; -}; - -class UBTGMediaWidget : public QStackedWidget , public iUBTGSaveData -{ - Q_OBJECT -public: - UBTGMediaWidget(QTreeWidgetItem* widget = 0, QWidget* parent = 0, const char* name = "UBTGMediaWidget"); - UBTGMediaWidget(QString mediaPath, QTreeWidgetItem* widget = 0, QWidget* parent = 0, bool forceFlashMediaType = false, const char *name = "UBTGMediaWidget"); - ~UBTGMediaWidget(); - tUBGEElementNode* saveData(); - void initializeWithDom(QDomElement element); - void removeSource(); - -protected: - void dragEnterEvent(QDragEnterEvent* event); - void dropEvent(QDropEvent* event); - void mousePressEvent(QMouseEvent* event); - void hideEvent(QHideEvent* event); - void showEvent(QShowEvent* event); - -private: - void parseMimeData(const QMimeData* pMimeData); - void createWorkWidget(bool forceFlashMediaType = false); - void updateSize(); - - QTreeWidgetItem* mpTreeWidgetItem; - QLabel* mpDropMeWidget; - QWidget* mpWorkWidget; - QVBoxLayout* mpLayout; - QHBoxLayout* mpMediaLayout; - UBTGAdaptableText* mpTitle; - QLabel* mpMediaLabelWidget; - UBMediaWidget* mpMediaWidget; - UBDraggableWeb* mpWebView; - QString mMediaPath; - bool mIsPresentationMode; - QString mMediaType; - bool mIsInitializationMode; - int mMediaWidgetHeight; -}; - - -class UBTGUrlWidget : public QWidget , public iUBTGSaveData -{ - Q_OBJECT -public: - UBTGUrlWidget(QWidget* parent = 0, const char* name = "UBTGUrlWidget"); - ~UBTGUrlWidget(); - tUBGEElementNode* saveData(); - void initializeWithDom(QDomElement element); - -public slots: - void onUrlEditionFinished(); - -private: - QVBoxLayout* mpLayout; - QLineEdit* mpTitle; - QLineEdit* mpUrl; -}; - -class UBTGDraggableTreeItem : public QTreeWidget -{ - Q_OBJECT -public: - UBTGDraggableTreeItem(QWidget* parent = 0, const char* name = "UBTGDraggableTreeItem"); - -private: - QMimeData* mimeData(const QList items) const; -}; - -#endif // UBTEACHERGUIDEWIDGETSTOOLS_H diff --git a/src/gui/UBThumbnailWidget.cpp b/src/gui/UBThumbnailWidget.cpp index 905fa15e..a6eba0ba 100644 --- a/src/gui/UBThumbnailWidget.cpp +++ b/src/gui/UBThumbnailWidget.cpp @@ -87,7 +87,7 @@ void UBThumbnailWidget::setGraphicsItems(const QList& pGraphicsI , const QStringList pLabels , const QString& pMimeType) { - Q_ASSERT(pItemsPaths.count() == pLabels.count()); + Q_ASSERT(pItemsPaths.count() == pLabels.count()); mGraphicItems = pGraphicsItems; mItemsPaths = pItemsPaths; mMimeType = pMimeType; @@ -103,8 +103,7 @@ void UBThumbnailWidget::setGraphicsItems(const QList& pGraphicsI foreach (QGraphicsItem* item, pGraphicsItems) { - if (item->scene() != &mThumbnailsScene) - { + if (item->scene() != &mThumbnailsScene){ mThumbnailsScene.addItem(item); } } @@ -767,7 +766,6 @@ UBSceneThumbnailNavigPixmap::UBSceneThumbnailNavigPixmap(const QPixmap& pix, UBD , bCanDelete(false) , bCanMoveUp(false) , bCanMoveDown(false) - , bCanDuplicate(false) { if(0 <= UBDocumentContainer::pageFromSceneIndex(pSceneIndex)){ setAcceptsHoverEvents(true); @@ -783,7 +781,16 @@ UBSceneThumbnailNavigPixmap::~UBSceneThumbnailNavigPixmap() void UBSceneThumbnailNavigPixmap::hoverEnterEvent(QGraphicsSceneHoverEvent *event) { event->accept(); - updateButtonsState(); + bButtonsVisible = true; + bCanDelete = true; + bCanMoveDown = false; + bCanMoveUp = false; + if(sceneIndex() < proxy()->pageCount() - 1) + bCanMoveDown = true; + if(sceneIndex() > 0) + bCanMoveUp = true; + if(proxy()->pageCount() == 1) + bCanDelete = false; update(); } @@ -806,10 +813,9 @@ void UBSceneThumbnailNavigPixmap::paint(QPainter *painter, const QStyleOptionGra painter->drawPixmap(0, 0, BUTTONSIZE, BUTTONSIZE, QPixmap(":images/close.svg")); else painter->drawPixmap(0, 0, BUTTONSIZE, BUTTONSIZE, QPixmap(":images/closeDisabled.svg")); - if(bCanDuplicate) - painter->drawPixmap(BUTTONSIZE + BUTTONSPACING, 0, BUTTONSIZE, BUTTONSIZE, QPixmap(":images/duplicate.svg")); - else - painter->drawPixmap(BUTTONSIZE + BUTTONSPACING, 0, BUTTONSIZE, BUTTONSIZE, QPixmap(":images/duplicateDisabled.svg")); + + painter->drawPixmap(BUTTONSIZE + BUTTONSPACING, 0, BUTTONSIZE, BUTTONSIZE, QPixmap(":images/duplicate.svg")); + if(bCanMoveUp) painter->drawPixmap(2*(BUTTONSIZE + BUTTONSPACING), 0, BUTTONSIZE, BUTTONSIZE, QPixmap(":images/moveUp.svg")); else @@ -828,8 +834,9 @@ void UBSceneThumbnailNavigPixmap::mousePressEvent(QGraphicsSceneMouseEvent *even // Here we check the position of the click and verify if it has to trig an action or not. if(bCanDelete && p.x() >= 0 && p.x() <= BUTTONSIZE && p.y() >= 0 && p.y() <= BUTTONSIZE) deletePage(); - if(bCanDuplicate && p.x() >= BUTTONSIZE + BUTTONSPACING && p.x() <= 2*BUTTONSIZE + BUTTONSPACING && p.y() >= 0 && p.y() <= BUTTONSIZE) + if(p.x() >= BUTTONSIZE + BUTTONSPACING && p.x() <= 2*BUTTONSIZE + BUTTONSPACING && p.y() >= 0 && p.y() <= BUTTONSIZE) duplicatePage(); + if(bCanMoveUp && p.x() >= 2*(BUTTONSIZE + BUTTONSPACING) && p.x() <= 3*BUTTONSIZE + 2*BUTTONSPACING && p.y() >= 0 && p.y() <= BUTTONSIZE) moveUpPage(); if(bCanMoveDown && p.x() >= 3*(BUTTONSIZE + BUTTONSPACING) && p.x() <= 4*BUTTONSIZE + 3*BUTTONSPACING && p.y() >= 0 && p.y() <= BUTTONSIZE) @@ -838,27 +845,6 @@ void UBSceneThumbnailNavigPixmap::mousePressEvent(QGraphicsSceneMouseEvent *even event->accept(); } -void UBSceneThumbnailNavigPixmap::updateButtonsState() -{ - - bCanDelete = false; - bCanMoveUp = false; - bCanMoveDown = false; - bCanDuplicate = false; - - if(proxy()){ - int pageIndex = UBDocumentContainer::pageFromSceneIndex(sceneIndex()); - UBDocumentController* documentController = UBApplication::documentController; - bCanDelete = documentController->pageCanBeDeleted(pageIndex); - bCanMoveUp = documentController->pageCanBeMovedUp(pageIndex); - bCanMoveDown = documentController->pageCanBeMovedDown(pageIndex); - bCanDuplicate = documentController->pageCanBeDuplicated(pageIndex); - } - - if(bCanDelete || bCanMoveUp || bCanMoveDown || bCanDuplicate) - bButtonsVisible = true; -} - void UBSceneThumbnailNavigPixmap::deletePage() { if(UBApplication::mainWindow->yesNoQuestion(QObject::tr("Remove Page"), QObject::tr("Are you sure you want to remove 1 page from the selected document '%0'?").arg(UBApplication::documentController->selectedDocument()->metaData(UBSettings::documentName).toString()))){ diff --git a/src/gui/UBThumbnailWidget.h b/src/gui/UBThumbnailWidget.h index 76a8a24e..97a493f8 100644 --- a/src/gui/UBThumbnailWidget.h +++ b/src/gui/UBThumbnailWidget.h @@ -311,7 +311,6 @@ class UBSceneThumbnailNavigPixmap : public UBSceneThumbnailPixmap void mousePressEvent(QGraphicsSceneMouseEvent *event); private: - void updateButtonsState(); void deletePage(); void duplicatePage(); void moveUpPage(); @@ -321,7 +320,6 @@ class UBSceneThumbnailNavigPixmap : public UBSceneThumbnailPixmap bool bCanDelete; bool bCanMoveUp; bool bCanMoveDown; - bool bCanDuplicate; }; class UBThumbnailVideo : public UBThumbnailPixmap diff --git a/src/gui/UBWebToolsPalette.cpp b/src/gui/UBWebToolsPalette.cpp index 797c4501..b5128f82 100644 --- a/src/gui/UBWebToolsPalette.cpp +++ b/src/gui/UBWebToolsPalette.cpp @@ -38,30 +38,22 @@ #include "core/memcheck.h" -UBWebToolsPalette::UBWebToolsPalette(QWidget *parent,bool tutorialMode=false) +UBWebToolsPalette::UBWebToolsPalette(QWidget *parent) : UBActionPalette(Qt::TopRightCorner, parent) { QList actions; - if (tutorialMode){ - actions << UBApplication::mainWindow->actionBoard; - } - else{ - actions << UBApplication::mainWindow->actionWebTrapFlash; - //actions << UBApplication::mainWindow->actionWebTrap; - - actions << UBApplication::mainWindow->actionWebCustomCapture; - actions << UBApplication::mainWindow->actionWebWindowCapture; - actions << UBApplication::mainWindow->actionWebOEmbed; - - //actions << UBApplication::mainWindow->actionEduMedia; - - actions << UBApplication::mainWindow->actionWebShowHideOnDisplay; - - if (UBPlatformUtils::hasVirtualKeyboard()) - { - actions << UBApplication::mainWindow->actionVirtualKeyboard; - } - } + + actions << UBApplication::mainWindow->actionWebTrapFlash; + + actions << UBApplication::mainWindow->actionWebCustomCapture; + actions << UBApplication::mainWindow->actionWebWindowCapture; + actions << UBApplication::mainWindow->actionWebOEmbed; + + actions << UBApplication::mainWindow->actionWebShowHideOnDisplay; + + if (UBPlatformUtils::hasVirtualKeyboard()) + actions << UBApplication::mainWindow->actionVirtualKeyboard; + setActions(actions); setButtonIconSize(QSize(42, 42)); adjustSizeAndPosition(); diff --git a/src/gui/UBWebToolsPalette.h b/src/gui/UBWebToolsPalette.h index 974d2f6e..39482860 100644 --- a/src/gui/UBWebToolsPalette.h +++ b/src/gui/UBWebToolsPalette.h @@ -32,7 +32,7 @@ class UBWebToolsPalette : public UBActionPalette Q_OBJECT; public: - UBWebToolsPalette(QWidget *parent,bool tutorialMode); + UBWebToolsPalette(QWidget *parent); virtual ~UBWebToolsPalette(); }; diff --git a/src/gui/gui.pri b/src/gui/gui.pri index 56f457ad..f941edfe 100644 --- a/src/gui/gui.pri +++ b/src/gui/gui.pri @@ -25,7 +25,6 @@ HEADERS += src/gui/UBThumbnailView.h \ src/gui/UBActionPalette.h \ src/gui/UBFavoriteToolPalette.h \ src/gui/UBKeyboardPalette.h \ - src/gui/UBNavigatorPalette.h \ src/gui/UBDocumentNavigator.h \ src/gui/UBDockPalette.h \ src/gui/UBPropertyPalette.h \ @@ -40,9 +39,6 @@ HEADERS += src/gui/UBThumbnailView.h \ src/gui/UBDockDownloadWidget.h \ src/gui/UBFeaturesWidget.h \ src/gui/UBFeaturesActionBar.h \ - src/gui/UBDockTeacherGuideWidget.h \ - src/gui/UBTeacherGuideWidget.h \ - src/gui/UBTeacherGuideWidgetsTools.h \ src/gui/UBMessagesDialog.h SOURCES += src/gui/UBThumbnailView.cpp \ src/gui/UBFloatingPalette.cpp \ @@ -71,7 +67,6 @@ SOURCES += src/gui/UBThumbnailView.cpp \ src/gui/UBActionPalette.cpp \ src/gui/UBFavoriteToolPalette.cpp \ src/gui/UBKeyboardPalette.cpp \ - src/gui/UBNavigatorPalette.cpp \ src/gui/UBDocumentNavigator.cpp \ src/gui/UBDockPalette.cpp \ src/gui/UBPropertyPalette.cpp \ @@ -86,9 +81,6 @@ SOURCES += src/gui/UBThumbnailView.cpp \ src/gui/UBDockDownloadWidget.cpp \ src/gui/UBFeaturesWidget.cpp \ src/gui/UBFeaturesActionBar.cpp \ - src/gui/UBDockTeacherGuideWidget.cpp \ - src/gui/UBTeacherGuideWidget.cpp \ - src/gui/UBTeacherGuideWidgetsTools.cpp \ src/gui/UBMessagesDialog.cpp win32:SOURCES += src/gui/UBKeyboardPalette_win.cpp macx:SOURCES += src/gui/UBKeyboardPalette_mac.cpp diff --git a/src/interfaces/IDataStorage.h b/src/interfaces/IDataStorage.h deleted file mode 100644 index 35921dbc..00000000 --- a/src/interfaces/IDataStorage.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (C) 2010-2013 Groupement d'Intérêt Public pour l'Education Numérique en Afrique (GIP ENA) - * - * This file is part of Open-Sankoré. - * - * Open-Sankoré 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, version 3 of the License, - * with a specific linking exception for the OpenSSL project's - * "OpenSSL" library (or with modified versions of it that use the - * same license as the "OpenSSL" library). - * - * Open-Sankoré 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 Open-Sankoré. If not, see . - */ - - - -#ifndef IDATASTORAGE_H -#define IDATASTORAGE_H - -#include -#include - -typedef enum -{ - eElementType_START, - eElementType_END, - eElementType_UNIQUE -}eElementType; - -typedef struct -{ - QString name; - QMap attributes; - eElementType type; -}tIDataStorage; - -class IDataStorage -{ -public: - //virtual void load(QString element) = 0; - virtual QVectorsave(int pageIndex) = 0 ; -}; -#endif // IDATASTORAGE_H diff --git a/src/interfaces/interfaces.pri b/src/interfaces/interfaces.pri deleted file mode 100644 index bac61bda..00000000 --- a/src/interfaces/interfaces.pri +++ /dev/null @@ -1,2 +0,0 @@ -HEADERS += \ - src/interfaces/IDataStorage.h diff --git a/src/web/UBWebController.cpp b/src/web/UBWebController.cpp index 7eaacecf..4701ccea 100644 --- a/src/web/UBWebController.cpp +++ b/src/web/UBWebController.cpp @@ -70,20 +70,6 @@ UBWebController::UBWebController(UBMainWindow* mainWindow) , mToolsPalettePositionned(false) , mDownloadViewIsVisible(false) { - connect(mMainWindow->actionWebTools, SIGNAL(toggled(bool)), this, SLOT(toggleWebToolsPalette(bool))); - - mStackedWidget = new QStackedWidget(); - mStackedWidget->addWidget(new QWidget(mStackedWidget)); - mStackedWidget->addWidget(new QWidget(mStackedWidget)); - - mMainWindow->addWebWidget(mStackedWidget); - - for (int i = 0; i < TotalNumberOfWebInstances; i += 1){ - mWebBrowserList[i] = 0; - mToolsPaletteList[i] = 0; - mToolsPalettePositionnedList[i] = false; - } - connect(&mOEmbedParser, SIGNAL(oembedParsed(QVector)), this, SLOT(onOEmbedParsed(QVector))); // TODO : Comment the next line to continue the Youtube button bugfix @@ -94,9 +80,6 @@ UBWebController::UBWebController(UBMainWindow* mainWindow) UBWebController::~UBWebController() { // NOOP - if (mStackedWidget) { - delete mStackedWidget; - } } void UBWebController::initialiazemOEmbedProviders() @@ -130,17 +113,15 @@ void UBWebController::webBrowserInstance() } else { - mCurrentWebBrowser = &mWebBrowserList[WebBrowser]; - mToolsCurrentPalette = &mToolsPaletteList[WebBrowser]; - mToolsPalettePositionned = mToolsPalettePositionnedList[WebBrowser]; - - if (!(*mCurrentWebBrowser)) + if (!mCurrentWebBrowser) { - (*mCurrentWebBrowser) = new WBBrowserWindow(mMainWindow->centralWidget(), mMainWindow); + mCurrentWebBrowser = new WBBrowserWindow(mMainWindow->centralWidget(), mMainWindow); - connect((*mCurrentWebBrowser), SIGNAL(activeViewChange(QWidget*)), this, SLOT(setSourceWidget(QWidget*))); + mMainWindow->addWebWidget(mCurrentWebBrowser); - WBBrowserWindow::downloadManager()->setParent((*mCurrentWebBrowser), Qt::Tool); + connect(mCurrentWebBrowser, SIGNAL(activeViewChange(QWidget*)), this, SLOT(setSourceWidget(QWidget*))); + + WBBrowserWindow::downloadManager()->setParent(mCurrentWebBrowser, Qt::Tool); UBApplication::app()->insertSpaceToToolbarBeforeAction(mMainWindow->webToolBar, mMainWindow->actionBoard, 32); UBApplication::app()->decorateActionMenu(mMainWindow->actionMenu); @@ -149,28 +130,21 @@ void UBWebController::webBrowserInstance() mMainWindow->actionBookmarks->setVisible(showAddBookmarkButtons); mMainWindow->actionAddBookmark->setVisible(showAddBookmarkButtons); - mStackedWidget->setCurrentIndex(WebBrowser); - if (mStackedWidget->currentWidget()) { - mStackedWidget->removeWidget(mStackedWidget->currentWidget()); - } - mStackedWidget->insertWidget(WebBrowser, (*mCurrentWebBrowser)); - showTabAtTop(UBSettings::settings()->appToolBarPositionedAtTop->get().toBool()); adaptToolBar(); - mTrapFlashController = new UBTrapFlashController((*mCurrentWebBrowser)); + mTrapFlashController = new UBTrapFlashController(mCurrentWebBrowser); - connect((*mCurrentWebBrowser), SIGNAL(activeViewPageChanged()), this, SLOT(activePageChanged())); + connect(mCurrentWebBrowser, SIGNAL(activeViewPageChanged()), this, SLOT(activePageChanged())); - (*mCurrentWebBrowser)->loadUrl(currentUrl); + mCurrentWebBrowser->loadUrl(currentUrl); - (*mCurrentWebBrowser)->tabWidget()->tabBar()->show(); - (*mCurrentWebBrowser)->tabWidget()->lineEdits()->show(); + mCurrentWebBrowser->tabWidget()->tabBar()->show(); + mCurrentWebBrowser->tabWidget()->lineEdits()->show(); } - mStackedWidget->setCurrentIndex(WebBrowser); - UBApplication::applicationController->setMirrorSourceWidget((*mCurrentWebBrowser)->paintWidget()); + UBApplication::applicationController->setMirrorSourceWidget(mCurrentWebBrowser->paintWidget()); mMainWindow->switchToWebWidget(); setupPalettes(); @@ -178,87 +152,16 @@ void UBWebController::webBrowserInstance() bool mirroring = UBSettings::settings()->webShowPageImmediatelyOnMirroredScreen->get().toBool(); UBApplication::mainWindow->actionWebShowHideOnDisplay->setChecked(mirroring); - (*mToolsCurrentPalette)->show(); + mToolsCurrentPalette->show(); } if (mDownloadViewIsVisible) WBBrowserWindow::downloadManager()->show(); } -void UBWebController::tutorialWebInstance() +void UBWebController::show() { - QLocale locale = QLocale(); - QString language = "_" + locale.name().left(2); - - QString tutorialHtmlIndexFile = 0; - QString tutorialPath = "/etc/Tutorial/tutorial" + language + "/index.html"; -#if defined(Q_WS_MAC) - tutorialHtmlIndexFile = QApplication::applicationDirPath()+ "/../Resources" + tutorialPath; -#else - tutorialHtmlIndexFile = QApplication::applicationDirPath() + tutorialPath; -#endif - - QUrl currentUrl = QUrl::fromLocalFile(tutorialHtmlIndexFile); - - if (UBSettings::settings()->webUseExternalBrowser->get().toBool()) - { - QDesktopServices::openUrl(currentUrl); - } - else - { - mCurrentWebBrowser = &mWebBrowserList[Tutorial]; - mToolsPalettePositionned = &mToolsPalettePositionnedList[Tutorial]; - - if (!(*mCurrentWebBrowser)) - { - (*mCurrentWebBrowser) = new WBBrowserWindow(mMainWindow->centralWidget(), mMainWindow, true); - connect((*mCurrentWebBrowser), SIGNAL(activeViewChange(QWidget*)), this, SLOT(setSourceWidget(QWidget*))); - - mStackedWidget->setCurrentIndex(Tutorial); - if (mStackedWidget->currentWidget()) { - mStackedWidget->removeWidget(mStackedWidget->currentWidget()); - } - mStackedWidget->insertWidget(Tutorial, (*mCurrentWebBrowser)); - adaptToolBar(); - - mTrapFlashController = new UBTrapFlashController((*mCurrentWebBrowser)); - - connect((*mCurrentWebBrowser), SIGNAL(activeViewPageChanged()), this, SLOT(activePageChanged())); - (*mCurrentWebBrowser)->loadUrl(currentUrl); - - (*mCurrentWebBrowser)->tabWidget()->tabBar()->hide(); - (*mCurrentWebBrowser)->tabWidget()->lineEdits()->hide(); - - } - else - (*mCurrentWebBrowser)->loadUrl(currentUrl); - - mStackedWidget->setCurrentIndex(Tutorial); - UBApplication::applicationController->setMirrorSourceWidget((*mCurrentWebBrowser)->paintWidget()); - mMainWindow->switchToWebWidget(); - screenLayoutChanged(); - - bool mirroring = UBSettings::settings()->webShowPageImmediatelyOnMirroredScreen->get().toBool(); - UBApplication::mainWindow->actionWebShowHideOnDisplay->setChecked(mirroring); - - } - -} - -void UBWebController::show(WebInstance type) -{ - switch(type) - { - case WebBrowser: - webBrowserInstance(); - break; - case Tutorial: - tutorialWebInstance(); - break; - default: - qCritical() << __FILE__ << " non supported web instance type " << QString::number(type) ; - break; - } + webBrowserInstance(); } void UBWebController::setSourceWidget(QWidget* pWidget) @@ -277,16 +180,14 @@ void UBWebController::trapFlash() void UBWebController::activePageChanged() { - if (mCurrentWebBrowser && (*mCurrentWebBrowser)->currentTabWebView()) + if (mCurrentWebBrowser && mCurrentWebBrowser->currentTabWebView()) { - if (mTrapFlashController && (*mCurrentWebBrowser)->currentTabWebView()->page()) - { - mTrapFlashController->updateTrapFlashFromPage((*mCurrentWebBrowser)->currentTabWebView()->page()->currentFrame()); - } + if (mTrapFlashController && mCurrentWebBrowser->currentTabWebView()->page()) + mTrapFlashController->updateTrapFlashFromPage(mCurrentWebBrowser->currentTabWebView()->page()->currentFrame()); mMainWindow->actionWebTrap->setChecked(false); - QUrl latestUrl = (*mCurrentWebBrowser)->currentTabWebView()->url(); + QUrl latestUrl = mCurrentWebBrowser->currentTabWebView()->url(); // TODO : Uncomment the next line to continue the youtube button bugfix //UBApplication::mainWindow->actionWebOEmbed->setEnabled(hasEmbeddedContent()); @@ -294,7 +195,7 @@ void UBWebController::activePageChanged() UBApplication::mainWindow->actionWebOEmbed->setEnabled(isOEmbedable(latestUrl)); UBApplication::mainWindow->actionEduMedia->setEnabled(isEduMedia(latestUrl)); - emit activeWebPageChanged((*mCurrentWebBrowser)->currentTabWebView()); + emit activeWebPageChanged(mCurrentWebBrowser->currentTabWebView()); } } @@ -302,7 +203,7 @@ bool UBWebController::hasEmbeddedContent() { bool bHasContent = false; if(mCurrentWebBrowser){ - QString html = (*mCurrentWebBrowser)->currentTabWebView()->webPage()->mainFrame()->toHtml(); + QString html = mCurrentWebBrowser->currentTabWebView()->webPage()->mainFrame()->toHtml(); // search the presence of "+oembed" QString query = "\\+oembed([^>]*)>"; @@ -334,12 +235,11 @@ QPixmap UBWebController::captureCurrentPage() QPixmap pix; if (mCurrentWebBrowser - && (*mCurrentWebBrowser) - && (*mCurrentWebBrowser)->currentTabWebView() - && (*mCurrentWebBrowser)->currentTabWebView()->page() - && (*mCurrentWebBrowser)->currentTabWebView()->page()->mainFrame()) + && mCurrentWebBrowser->currentTabWebView() + && mCurrentWebBrowser->currentTabWebView()->page() + && mCurrentWebBrowser->currentTabWebView()->page()->mainFrame()) { - QWebFrame* frame = (*mCurrentWebBrowser)->currentTabWebView()->page()->mainFrame(); + QWebFrame* frame = mCurrentWebBrowser->currentTabWebView()->page()->mainFrame(); QSize size = frame->contentsSize(); qDebug() << size; @@ -349,8 +249,8 @@ QPixmap UBWebController::captureCurrentPage() QVariant width = frame->evaluateJavaScript("document.getElementsByTagName('body')[0].clientWidth"); QVariant height = frame->evaluateJavaScript("document.getElementsByTagName('body')[0].clientHeight"); - QSize vieportSize = (*mCurrentWebBrowser)->currentTabWebView()->page()->viewportSize(); - (*mCurrentWebBrowser)->currentTabWebView()->page()->setViewportSize(frame->contentsSize()); + QSize vieportSize = mCurrentWebBrowser->currentTabWebView()->page()->viewportSize(); + mCurrentWebBrowser->currentTabWebView()->page()->setViewportSize(frame->contentsSize()); pix = QPixmap(frame->geometry().width(), frame->geometry().height()); { @@ -374,7 +274,7 @@ QPixmap UBWebController::captureCurrentPage() } - (*mCurrentWebBrowser)->currentTabWebView()->page()->setViewportSize(vieportSize); + mCurrentWebBrowser->currentTabWebView()->page()->setViewportSize(vieportSize); } return pix; @@ -383,10 +283,10 @@ QPixmap UBWebController::captureCurrentPage() void UBWebController::setupPalettes() { - if(!(*mToolsCurrentPalette)) + if(!mToolsCurrentPalette) { - (*mToolsCurrentPalette) = new UBWebToolsPalette(UBApplication::mainWindow, false); - UBApplication::boardController->paletteManager()->setCurrentWebToolsPalette(*mToolsCurrentPalette); + mToolsCurrentPalette = new UBWebToolsPalette(UBApplication::mainWindow); + UBApplication::boardController->paletteManager()->setCurrentWebToolsPalette(mToolsCurrentPalette); #ifndef Q_WS_WIN if (UBPlatformUtils::hasVirtualKeyboard() && UBApplication::boardController->paletteManager()->mKeyboardPalette) connect(UBApplication::boardController->paletteManager()->mKeyboardPalette, SIGNAL(closed()), @@ -402,15 +302,14 @@ void UBWebController::setupPalettes() connect(mMainWindow->actionWebShowHideOnDisplay, SIGNAL(toggled(bool)), this, SLOT(toogleMirroring(bool))); connect(mMainWindow->actionWebTrap, SIGNAL(toggled(bool)), this, SLOT(toggleWebTrap(bool))); - (*mToolsCurrentPalette)->hide(); - (*mToolsCurrentPalette)->adjustSizeAndPosition(); + mToolsCurrentPalette->hide(); + mToolsCurrentPalette->adjustSizeAndPosition(); if (controlView()){ - int left = controlView()->width() - 20 - (*mToolsCurrentPalette)->width(); - int top = (controlView()->height() - (*mToolsCurrentPalette)->height()) / 2; - mToolsPalettePositionnedList[mStackedWidget->currentIndex()] = true; - (*mToolsCurrentPalette)->setCustomPosition(true); - (*mToolsCurrentPalette)->move(left, top); + int left = controlView()->width() - 20 - mToolsCurrentPalette->width(); + int top = (controlView()->height() - mToolsCurrentPalette->height()) / 2; + mToolsCurrentPalette->setCustomPosition(true); + mToolsCurrentPalette->move(left, top); } mMainWindow->actionWebTools->trigger(); } @@ -419,17 +318,8 @@ void UBWebController::setupPalettes() void UBWebController::toggleWebTrap(bool checked) { - if (mCurrentWebBrowser - && (*mCurrentWebBrowser) - && (*mCurrentWebBrowser)->currentTabWebView()) - { - (*mCurrentWebBrowser)->currentTabWebView()->setIsTrapping(checked); - } -} - -void UBWebController::toggleWebToolsPalette(bool checked) -{ - (*mToolsCurrentPalette)->setVisible(checked); + if (mCurrentWebBrowser && mCurrentWebBrowser->currentTabWebView()) + mCurrentWebBrowser->currentTabWebView()->setIsTrapping(checked); } @@ -438,28 +328,26 @@ void UBWebController::captureWindow() QPixmap webPagePixmap = captureCurrentPage(); if (!webPagePixmap.isNull()) - { - emit imageCaptured(webPagePixmap, true, (*mCurrentWebBrowser)->currentTabWebView()->url()); - } + emit imageCaptured(webPagePixmap, true, mCurrentWebBrowser->currentTabWebView()->url()); } void UBWebController::customCapture() { - (*mToolsCurrentPalette)->setVisible(false); + mToolsCurrentPalette->setVisible(false); qApp->processEvents(); - UBCustomCaptureWindow customCaptureWindow((*mCurrentWebBrowser)); + UBCustomCaptureWindow customCaptureWindow(mCurrentWebBrowser); customCaptureWindow.show(); if (customCaptureWindow.execute(getScreenPixmap()) == QDialog::Accepted) { QPixmap selectedPixmap = customCaptureWindow.getSelectedPixmap(); - emit imageCaptured(selectedPixmap, false, (*mCurrentWebBrowser)->currentTabWebView()->url()); + emit imageCaptured(selectedPixmap, false, mCurrentWebBrowser->currentTabWebView()->url()); } - (*mToolsCurrentPalette)->setVisible(true); + mToolsCurrentPalette->setVisible(true); } @@ -505,27 +393,27 @@ void UBWebController::adaptToolBar() mMainWindow->actionWebReload->setVisible(highResolution); mMainWindow->actionStopLoading->setVisible(highResolution); - if(mCurrentWebBrowser && (*mCurrentWebBrowser) ) - (*mCurrentWebBrowser)->adaptToolBar(highResolution); + if(mCurrentWebBrowser ) + mCurrentWebBrowser->adaptToolBar(highResolution); } void UBWebController::showTabAtTop(bool attop) { - if (mCurrentWebBrowser && (*mCurrentWebBrowser)) - (*mCurrentWebBrowser)->showTabAtTop(attop); + if (mCurrentWebBrowser) + mCurrentWebBrowser->showTabAtTop(attop); } void UBWebController::captureoEmbed() { - if ( mCurrentWebBrowser && (*mCurrentWebBrowser) && (*mCurrentWebBrowser)->currentTabWebView()){ + if ( mCurrentWebBrowser && mCurrentWebBrowser->currentTabWebView()){ // TODO : Uncomment the next lines to continue the youtube button bugfix // getEmbeddableContent(); // And comment from here - QWebView* webView = (*mCurrentWebBrowser)->currentTabWebView(); + QWebView* webView = mCurrentWebBrowser->currentTabWebView(); QUrl currentUrl = webView->url(); if (isOEmbedable(currentUrl)) @@ -576,9 +464,9 @@ void UBWebController::getEmbeddableContent() { // Get the source code of the page if(mCurrentWebBrowser){ - QNetworkAccessManager* pNam = (*mCurrentWebBrowser)->currentTabWebView()->webPage()->networkAccessManager(); + QNetworkAccessManager* pNam = mCurrentWebBrowser->currentTabWebView()->webPage()->networkAccessManager(); if(NULL != pNam){ - QString html = (*mCurrentWebBrowser)->currentTabWebView()->webPage()->mainFrame()->toHtml(); + QString html = mCurrentWebBrowser->currentTabWebView()->webPage()->mainFrame()->toHtml(); mOEmbedParser.setNetworkAccessManager(pNam); // First, we have to check if there is some oembed content @@ -591,10 +479,9 @@ void UBWebController::getEmbeddableContent() void UBWebController::captureEduMedia() { - if (mCurrentWebBrowser && (*mCurrentWebBrowser) - && (*mCurrentWebBrowser)->currentTabWebView()) + if (mCurrentWebBrowser && mCurrentWebBrowser->currentTabWebView()) { - QWebView* webView = (*mCurrentWebBrowser)->currentTabWebView(); + QWebView* webView = mCurrentWebBrowser->currentTabWebView(); QUrl currentUrl = webView->url(); if (isEduMedia(currentUrl)) @@ -681,40 +568,31 @@ bool UBWebController::isEduMedia(const QUrl& pUrl) void UBWebController::loadUrl(const QUrl& url) { - bool webBrowserAlreadyInstanciated = dynamic_cast(mStackedWidget->widget(WebBrowser)) != NULL; UBApplication::applicationController->showInternet(); if (UBSettings::settings()->webUseExternalBrowser->get().toBool()) - { + QDesktopServices::openUrl(url); - } else - { - if (!webBrowserAlreadyInstanciated) { - (*mCurrentWebBrowser)->loadUrl(url); - } - else { - (*mCurrentWebBrowser)->loadUrlInNewTab(url); - } - } + mCurrentWebBrowser->loadUrlInNewTab(url); + + } QWebView* UBWebController::createNewTab() { - if (mCurrentWebBrowser && !(*mCurrentWebBrowser)) - { + if (mCurrentWebBrowser) UBApplication::applicationController->showInternet(); - } - return (*mCurrentWebBrowser)->createNewTab(); + return mCurrentWebBrowser->createNewTab(); } void UBWebController::copy() { - if (mCurrentWebBrowser && (*mCurrentWebBrowser) && (*mCurrentWebBrowser)->currentTabWebView()) + if (mCurrentWebBrowser && mCurrentWebBrowser->currentTabWebView()) { - QWebView* webView = (*mCurrentWebBrowser)->currentTabWebView(); + QWebView* webView = mCurrentWebBrowser->currentTabWebView(); QAction *act = webView->pageAction(QWebPage::Copy); if(act) act->trigger(); @@ -724,9 +602,9 @@ void UBWebController::copy() void UBWebController::paste() { - if (mCurrentWebBrowser && (*mCurrentWebBrowser) && (*mCurrentWebBrowser)->currentTabWebView()) + if (mCurrentWebBrowser && mCurrentWebBrowser->currentTabWebView()) { - QWebView* webView = (*mCurrentWebBrowser)->currentTabWebView(); + QWebView* webView = mCurrentWebBrowser->currentTabWebView(); QAction *act = webView->pageAction(QWebPage::Paste); if(act) act->trigger(); @@ -736,9 +614,9 @@ void UBWebController::paste() void UBWebController::cut() { - if (mCurrentWebBrowser && (*mCurrentWebBrowser) && (*mCurrentWebBrowser)->currentTabWebView()) + if (mCurrentWebBrowser && mCurrentWebBrowser->currentTabWebView()) { - QWebView* webView = (*mCurrentWebBrowser)->currentTabWebView(); + QWebView* webView = mCurrentWebBrowser->currentTabWebView(); QAction *act = webView->pageAction(QWebPage::Cut); if(act) act->trigger(); diff --git a/src/web/UBWebController.h b/src/web/UBWebController.h index 6bba430a..1f9cbbed 100644 --- a/src/web/UBWebController.h +++ b/src/web/UBWebController.h @@ -58,18 +58,9 @@ class UBWebController : public QObject QUrl currentPageUrl() const; - enum WebInstance - { - WebBrowser = 0, Tutorial, TotalNumberOfWebInstances - }; - - void show(WebInstance type = UBWebController::WebBrowser); + void show(); - WBBrowserWindow* GetCurrentWebBrowser() - { - if( mCurrentWebBrowser != NULL ) return *mCurrentWebBrowser; - else return NULL; - }; + WBBrowserWindow* GetCurrentWebBrowser(){return mCurrentWebBrowser;} protected: @@ -81,7 +72,6 @@ class UBWebController : public QObject void screenLayoutChanged(); void setSourceWidget(QWidget* pWidget); - void toggleWebToolsPalette(bool checked); void captureWindow(); void customCapture(); void toogleMirroring(bool checked); @@ -106,25 +96,19 @@ class UBWebController : public QObject private: void initialiazemOEmbedProviders(); - void tutorialWebInstance(); void webBrowserInstance(); void lookForEmbedContent(QString* pHtml, QString tag, QString attribute, QList* pList); void checkForOEmbed(QString* pHtml); - QStackedWidget *mStackedWidget; - UBMainWindow *mMainWindow; - WBBrowserWindow* mWebBrowserList[TotalNumberOfWebInstances]; - WBBrowserWindow** mCurrentWebBrowser; + WBBrowserWindow* mCurrentWebBrowser; QWidget* mBrowserWidget; UBTrapFlashController* mTrapFlashController; - UBWebToolsPalette** mToolsCurrentPalette; - UBWebToolsPalette* mToolsPaletteList[TotalNumberOfWebInstances]; + UBWebToolsPalette* mToolsCurrentPalette; bool mToolsPalettePositionned; - bool mToolsPalettePositionnedList[TotalNumberOfWebInstances]; bool mDownloadViewIsVisible; diff --git a/src/web/browser/WBBrowserWindow.cpp b/src/web/browser/WBBrowserWindow.cpp index 74286edc..82e41298 100644 --- a/src/web/browser/WBBrowserWindow.cpp +++ b/src/web/browser/WBBrowserWindow.cpp @@ -93,7 +93,7 @@ WBDownloadManager *WBBrowserWindow::sDownloadManager = 0; WBHistoryManager *WBBrowserWindow::sHistoryManager = 0; -WBBrowserWindow::WBBrowserWindow(QWidget *parent, Ui::MainWindow* uniboardMainWindow, bool isViewerWebInstance) +WBBrowserWindow::WBBrowserWindow(QWidget *parent, Ui::MainWindow* uniboardMainWindow) : QWidget(parent) , mWebToolBar(0) , mSearchToolBar(0) @@ -106,11 +106,8 @@ WBBrowserWindow::WBBrowserWindow(QWidget *parent, Ui::MainWindow* uniboardMainWi defaultSettings->setAttribute(QWebSettings::PluginsEnabled, true); setupMenu(); - if(!isViewerWebInstance) - setupToolBar(); - else{ - setupToolBarForTutorial(); - } + setupToolBar(); + QVBoxLayout *layout = new QVBoxLayout; layout->setSpacing(0); @@ -125,9 +122,8 @@ WBBrowserWindow::WBBrowserWindow(QWidget *parent, Ui::MainWindow* uniboardMainWi connect(mTabWidget, SIGNAL(setCurrentTitle(const QString &)), this, SLOT(slotUpdateWindowTitle(const QString &))); - if (!isViewerWebInstance) { - connect(mTabWidget, SIGNAL(loadProgress(int)), this, SLOT(slotLoadProgress(int))); - } + connect(mTabWidget, SIGNAL(loadProgress(int)), this, SLOT(slotLoadProgress(int))); + connect(mTabWidget, SIGNAL(loadFinished(bool)), this, SIGNAL(activeViewPageChanged())); @@ -150,10 +146,7 @@ WBBrowserWindow::~WBBrowserWindow() mTabWidget = NULL; } - if(mSearchToolBar){ - delete mSearchToolBar; - mSearchToolBar = NULL; - } + //Explanation mSearchToolBar has a parent so it's automatically freed } @@ -223,7 +216,7 @@ void WBBrowserWindow::setupToolBar() mHistoryForwardMenu = new QMenu(this); connect(mHistoryForwardMenu, SIGNAL(aboutToShow()), this, SLOT(aboutToShowForwardMenu())); connect(mHistoryForwardMenu, SIGNAL(triggered(QAction *)), this, SLOT(openActionUrl(QAction *))); - + foreach (QWidget* menuWidget, mUniboardMainWindow->actionWebForward->associatedWidgets()) { QToolButton *tb = qobject_cast(menuWidget); @@ -257,33 +250,6 @@ void WBBrowserWindow::setupToolBar() mWebToolBar->show(); } -void WBBrowserWindow::setupToolBarForTutorial() -{ - mWebToolBar = mUniboardMainWindow->tutorialToolBar; - - mTabWidget->addWebAction(mUniboardMainWindow->actionWebBack, QWebPage::Back); - mTabWidget->addWebAction(mUniboardMainWindow->actionWebForward, QWebPage::Forward); - - foreach (QWidget* menuWidget, mUniboardMainWindow->actionWebBack->associatedWidgets()) - { - QToolButton *tb = qobject_cast(menuWidget); - - if (tb && tb->menu()) - tb->setMenu(NULL); - } - - foreach (QWidget* menuWidget, mUniboardMainWindow->actionWebForward->associatedWidgets()) - { - QToolButton *tb = qobject_cast(menuWidget); - - if (tb && tb->menu()) - tb->setMenu(NULL); - } - - mWebToolBar->show(); -} - - void WBBrowserWindow::adaptToolBar(bool wideRes) { @@ -579,7 +545,7 @@ void WBBrowserWindow::aboutToShowBackMenu() if (historyLimit < 0) historyLimit = 0; - for (int i = history->backItems(historyCount).count() - 1; i >= historyLimit; --i) + for (int i = history->backItems(historyCount).count() - 1; i >= historyLimit; --i) { QWebHistoryItem item = history->backItems(historyCount).at(i); @@ -613,7 +579,7 @@ void WBBrowserWindow::aboutToShowForwardMenu() if (historyLimit > UBSettings::settings()->historyLimit->get().toReal()) historyLimit = UBSettings::settings()->historyLimit->get().toReal(); - for (int i = 0; i < historyLimit; ++i) + for (int i = 0; i < historyLimit; ++i) { QWebHistoryItem item = history->forwardItems(historyCount).at(i); @@ -636,7 +602,7 @@ void WBBrowserWindow::aboutToShowForwardMenu() void WBBrowserWindow::openActionUrl(QAction *action) { - QWebHistory *history = currentTabWebView()->history(); + QWebHistory *history = currentTabWebView()->history(); if (action->data() == "clear") { @@ -646,7 +612,7 @@ void WBBrowserWindow::openActionUrl(QAction *action) int offset = action->data().toInt(); if (offset < 0) - history->goToItem(history->backItems(-1*offset).first()); + history->goToItem(history->backItems(-1*offset).first()); else if (offset > 0) - history->goToItem(history->forwardItems(history->count() - offset + 1).back()); + history->goToItem(history->forwardItems(history->count() - offset + 1).back()); } diff --git a/src/web/browser/WBBrowserWindow.h b/src/web/browser/WBBrowserWindow.h index a26530a8..178d4945 100644 --- a/src/web/browser/WBBrowserWindow.h +++ b/src/web/browser/WBBrowserWindow.h @@ -88,7 +88,7 @@ class WBBrowserWindow : public QWidget Q_OBJECT; public: - WBBrowserWindow(QWidget *parent = 0, Ui::MainWindow* uniboardMainWindow = 0, bool isViewerWebInstance = false); + WBBrowserWindow(QWidget *parent = 0, Ui::MainWindow* uniboardMainWindow = 0); ~WBBrowserWindow(); QSize sizeHint() const; @@ -160,7 +160,6 @@ class WBBrowserWindow : public QWidget void setupMenu(); void setupToolBar(); - void setupToolBarForTutorial(); void updateStatusbarActionText(bool visible); QToolBar *mWebToolBar;