Commit 001528da authored by shibakaneki's avatar shibakaneki

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

parents 805edd5b 0d4d6024
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
id="http://uniboard.mnemis.com/widgets/calculator" id="http://uniboard.mnemis.com/widgets/calculator"
version="1.1" version="1.1"
width="200" width="200"
height="295" height="300"
ub:resizable="false"> ub:resizable="false">
<name>Calculator</name> <name>Calculator</name>
<content src="index.html"/> <content src="index.html"/>
......
...@@ -4,6 +4,7 @@ html, body{ ...@@ -4,6 +4,7 @@ html, body{
margin: 0; margin: 0;
padding: 0; padding: 0;
border-radius: 50px; border-radius: 50px;
overflow: hidden;
} }
.without_radius{ .without_radius{
...@@ -283,7 +284,6 @@ body{ ...@@ -283,7 +284,6 @@ body{
#wgt_name{ #wgt_name{
height: 44px; height: 44px;
width: 300px;
margin: 10px 10px 0 10px; margin: 10px 10px 0 10px;
padding: 0; padding: 0;
float: left; float: left;
...@@ -292,9 +292,8 @@ body{ ...@@ -292,9 +292,8 @@ body{
color: #8c5730; color: #8c5730;
} }
#wgt_reload, #wgt_edit, #wgt_display{ #wgt_reload, #wgt_edit, #wgt_display, #wgt_help{
cursor: pointer; cursor: pointer;
width: 80px;
height: 44px; height: 44px;
margin: 10px 10px 0 0; margin: 10px 10px 0 0;
float: right; float: right;
...@@ -304,7 +303,6 @@ body{ ...@@ -304,7 +303,6 @@ body{
} }
#wgt_display{ #wgt_display{
width: 100px;
padding-left: 40px; padding-left: 40px;
background-image: url(../img/slate-edit.png); background-image: url(../img/slate-edit.png);
background-repeat: no-repeat; background-repeat: no-repeat;
...@@ -313,7 +311,6 @@ body{ ...@@ -313,7 +311,6 @@ body{
} }
#wgt_edit{ #wgt_edit{
width: 100px;
padding-left: 40px; padding-left: 40px;
background-image: url(../img/slate-edit.png); background-image: url(../img/slate-edit.png);
background-repeat: no-repeat; background-repeat: no-repeat;
...@@ -398,3 +395,27 @@ body{ ...@@ -398,3 +395,27 @@ body{
color: white !important; color: white !important;
background-image: url(../img/ar_down_white.png) !important; background-image: url(../img/ar_down_white.png) !important;
} }
.pad_help{
background-image: url(../img/slate-help-white.png) !important;
}
#wgt_help{
padding-left: 32px;
background-image: url(../img/slate-help.png);
background-repeat: no-repeat;
background-position: top 0;
}
#help{
width: 100%;
height: 100%;
overflow: auto;
display: none;
background-color: #ccc;
padding: 5px;
}
.open{
}
\ No newline at end of file
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
lang = sankore.locale().substr(0,2); lang = sankore.locale().substr(0,2);
} else } else
lang = "en"; lang = "en";
lang = "fr";
if(lang == "en"){ if(lang == "en"){
if(window.sankore) if(window.sankore)
sankore.enableDropOnWidget(false); sankore.enableDropOnWidget(false);
...@@ -51,6 +52,7 @@ ...@@ -51,6 +52,7 @@
<td class="b_top_left">&nbsp;</td> <td class="b_top_left">&nbsp;</td>
<td class="b_top_center"> <td class="b_top_center">
<div id="wgt_name"></div> <div id="wgt_name"></div>
<div id="wgt_help"></div>
<div id="wgt_reload"></div> <div id="wgt_reload"></div>
<div id="wgt_display" class="selected"></div> <div id="wgt_display" class="selected"></div>
<div id="wgt_edit"></div> <div id="wgt_edit"></div>
...@@ -66,6 +68,7 @@ ...@@ -66,6 +68,7 @@
<tr> <tr>
<td class="b_center_left">&nbsp;</td> <td class="b_center_left">&nbsp;</td>
<td> <td>
<div id="help"></div>
<div id="data"> <div id="data">
</div> </div>
......
...@@ -8,7 +8,9 @@ var sankoreLang = { ...@@ -8,7 +8,9 @@ var sankoreLang = {
reload: "Reload", reload: "Reload",
slate: "Wood", slate: "Wood",
pad: "Pad", pad: "Pad",
none: "None" none: "None",
help: "Help",
help_content: "This is an example of help content ..."
}; };
//main function //main function
...@@ -18,6 +20,8 @@ function start(){ ...@@ -18,6 +20,8 @@ function start(){
$("#wgt_edit").text(sankoreLang.edit); $("#wgt_edit").text(sankoreLang.edit);
$("#wgt_name").text(sankoreLang.wgt_name); $("#wgt_name").text(sankoreLang.wgt_name);
$("#wgt_reload").text(sankoreLang.reload); $("#wgt_reload").text(sankoreLang.reload);
$("#wgt_help").text(sankoreLang.help);
$("#help").html(sankoreLang.help_content);
$(".style_select option[value='1']").text(sankoreLang.slate); $(".style_select option[value='1']").text(sankoreLang.slate);
$(".style_select option[value='2']").text(sankoreLang.pad); $(".style_select option[value='2']").text(sankoreLang.pad);
$(".style_select option[value='3']").text(sankoreLang.none); $(".style_select option[value='3']").text(sankoreLang.none);
...@@ -39,6 +43,21 @@ function start(){ ...@@ -39,6 +43,21 @@ function start(){
} }
} }
$("#wgt_help").click(function(){
var tmp = $(this);
if($(this).hasClass("open")){
$("#help").slideUp("100", function(){
tmp.removeClass("open");
$("#data").show();
});
} else {
$("#data").hide();
$("#help").slideDown("100", function(){
tmp.addClass("open");
});
}
});
$("#wgt_reload").click(function(){ $("#wgt_reload").click(function(){
if($("#wgt_display").hasClass("selected")){ if($("#wgt_display").hasClass("selected")){
$("#wgt_edit").trigger("click"); $("#wgt_edit").trigger("click");
...@@ -312,7 +331,7 @@ function exportData(){ ...@@ -312,7 +331,7 @@ function exportData(){
} }
if(window.sankore) if(window.sankore)
sankore.setPreference("associer", JSON.stringify(array_to_export)); sankore.setPreference("associer", JSON.stringify(array_to_export));
} }
//import //import
...@@ -618,6 +637,7 @@ function changeStyle(val){ ...@@ -618,6 +637,7 @@ function changeStyle(val){
$(".b_bottom_left").removeClass("bbl_pad").removeClass("without_back"); $(".b_bottom_left").removeClass("bbl_pad").removeClass("without_back");
$(".b_bottom_center").removeClass("bbc_pad").removeClass("without_back"); $(".b_bottom_center").removeClass("bbc_pad").removeClass("without_back");
$("#wgt_reload").removeClass("pad_color").removeClass("pad_reload"); $("#wgt_reload").removeClass("pad_color").removeClass("pad_reload");
$("#wgt_help").removeClass("pad_color").removeClass("pad_help");
$("#wgt_edit").removeClass("pad_color").removeClass("pad_edit"); $("#wgt_edit").removeClass("pad_color").removeClass("pad_edit");
$("#wgt_display").removeClass("pad_color").removeClass("pad_edit"); $("#wgt_display").removeClass("pad_color").removeClass("pad_edit");
$("#wgt_name").removeClass("pad_color"); $("#wgt_name").removeClass("pad_color");
...@@ -634,6 +654,7 @@ function changeStyle(val){ ...@@ -634,6 +654,7 @@ function changeStyle(val){
$(".b_bottom_left").addClass("bbl_pad").removeClass("without_back"); $(".b_bottom_left").addClass("bbl_pad").removeClass("without_back");
$(".b_bottom_center").addClass("bbc_pad").removeClass("without_back"); $(".b_bottom_center").addClass("bbc_pad").removeClass("without_back");
$("#wgt_reload").addClass("pad_color").addClass("pad_reload"); $("#wgt_reload").addClass("pad_color").addClass("pad_reload");
$("#wgt_help").addClass("pad_color").addClass("pad_help");
$("#wgt_edit").addClass("pad_color").addClass("pad_edit"); $("#wgt_edit").addClass("pad_color").addClass("pad_edit");
$("#wgt_display").addClass("pad_color").addClass("pad_edit"); $("#wgt_display").addClass("pad_color").addClass("pad_edit");
$("#wgt_name").addClass("pad_color"); $("#wgt_name").addClass("pad_color");
...@@ -649,6 +670,7 @@ function changeStyle(val){ ...@@ -649,6 +670,7 @@ function changeStyle(val){
$(".b_bottom_right").addClass("without_back").removeClass("bbr_pad"); $(".b_bottom_right").addClass("without_back").removeClass("bbr_pad");
$(".b_bottom_left").addClass("without_back").removeClass("bbl_pad"); $(".b_bottom_left").addClass("without_back").removeClass("bbl_pad");
$(".b_bottom_center").addClass("without_back").removeClass("bbc_pad"); $(".b_bottom_center").addClass("without_back").removeClass("bbc_pad");
$("#wgt_help").addClass("pad_color").addClass("pad_help");
$("#wgt_reload").addClass("pad_color").addClass("pad_reload"); $("#wgt_reload").addClass("pad_color").addClass("pad_reload");
$("#wgt_edit").addClass("pad_color").addClass("pad_edit"); $("#wgt_edit").addClass("pad_color").addClass("pad_edit");
$("#wgt_display").addClass("pad_color").addClass("pad_edit"); $("#wgt_display").addClass("pad_color").addClass("pad_edit");
......
...@@ -10,18 +10,19 @@ ...@@ -10,18 +10,19 @@
<script type="text/javascript" src="../../js/jquery-ui-1.8.9.custom.min.js"></script> <script type="text/javascript" src="../../js/jquery-ui-1.8.9.custom.min.js"></script>
<script type="text/javascript" src="js/script.js"></script> <script type="text/javascript" src="js/script.js"></script>
<script type="text/javascript"> <script type="text/javascript">
$(document).ready(function(){ $(document).ready(function(){
sankore.enableDropOnWidget(false); sankore.enableDropOnWidget(false);
start(); start();
}); });
</script> </script>
</head> </head>
<body> <body>
<table class="body_table" cellpadding=0 cellspacing=0> <table class="body_table" cellpadding=0 cellspacing=0>
<tr style="height: 54px;"> <tr style="height: 54px;">
<td class="b_top_left">&nbsp;</td> <td class="b_top_left">&nbsp;</td>
<td class="b_top_center"> <td class="b_top_center">
<div id="wgt_name"></div> <div id="wgt_name"></div>
<div id="wgt_help"></div>
<div id="wgt_reload"></div> <div id="wgt_reload"></div>
<div id="wgt_display" class="selected"></div> <div id="wgt_display" class="selected"></div>
<div id="wgt_edit"></div> <div id="wgt_edit"></div>
...@@ -37,6 +38,7 @@ ...@@ -37,6 +38,7 @@
<tr> <tr>
<td class="b_center_left">&nbsp;</td> <td class="b_center_left">&nbsp;</td>
<td> <td>
<div id="help"></div>
<div id="data"> <div id="data">
</div> </div>
......
...@@ -8,7 +8,9 @@ var sankoreLang = { ...@@ -8,7 +8,9 @@ var sankoreLang = {
reload: "Recharger", reload: "Recharger",
slate: "ardoise", slate: "ardoise",
pad: "tablette", pad: "tablette",
none: "aucun" none: "aucun",
help: "aide",
help_content: "Ceci est un exemple de contenu de l'aide ..."
}; };
//main function //main function
...@@ -18,6 +20,8 @@ function start(){ ...@@ -18,6 +20,8 @@ function start(){
$("#wgt_edit").text(sankoreLang.edit); $("#wgt_edit").text(sankoreLang.edit);
$("#wgt_name").text(sankoreLang.wgt_name); $("#wgt_name").text(sankoreLang.wgt_name);
$("#wgt_reload").text(sankoreLang.reload); $("#wgt_reload").text(sankoreLang.reload);
$("#wgt_help").text(sankoreLang.help);
$("#help").html(sankoreLang.help_content);
$(".style_select option[value='1']").text(sankoreLang.slate); $(".style_select option[value='1']").text(sankoreLang.slate);
$(".style_select option[value='2']").text(sankoreLang.pad); $(".style_select option[value='2']").text(sankoreLang.pad);
$(".style_select option[value='3']").text(sankoreLang.none); $(".style_select option[value='3']").text(sankoreLang.none);
...@@ -39,6 +43,21 @@ function start(){ ...@@ -39,6 +43,21 @@ function start(){
} }
} }
$("#wgt_help").click(function(){
var tmp = $(this);
if($(this).hasClass("open")){
$("#help").slideUp("100", function(){
tmp.removeClass("open");
$("#data").show();
});
} else {
$("#data").hide();
$("#help").slideDown("100", function(){
tmp.addClass("open");
});
}
});
$("#wgt_reload").click(function(){ $("#wgt_reload").click(function(){
if($("#wgt_display").hasClass("selected")){ if($("#wgt_display").hasClass("selected")){
$("#wgt_edit").trigger("click"); $("#wgt_edit").trigger("click");
...@@ -613,6 +632,7 @@ function changeStyle(val){ ...@@ -613,6 +632,7 @@ function changeStyle(val){
$(".b_bottom_left").removeClass("bbl_pad").removeClass("without_back"); $(".b_bottom_left").removeClass("bbl_pad").removeClass("without_back");
$(".b_bottom_center").removeClass("bbc_pad").removeClass("without_back"); $(".b_bottom_center").removeClass("bbc_pad").removeClass("without_back");
$("#wgt_reload").removeClass("pad_color").removeClass("pad_reload"); $("#wgt_reload").removeClass("pad_color").removeClass("pad_reload");
$("#wgt_help").removeClass("pad_color").removeClass("pad_help");
$("#wgt_edit").removeClass("pad_color").removeClass("pad_edit"); $("#wgt_edit").removeClass("pad_color").removeClass("pad_edit");
$("#wgt_display").removeClass("pad_color").removeClass("pad_edit"); $("#wgt_display").removeClass("pad_color").removeClass("pad_edit");
$("#wgt_name").removeClass("pad_color"); $("#wgt_name").removeClass("pad_color");
...@@ -629,6 +649,7 @@ function changeStyle(val){ ...@@ -629,6 +649,7 @@ function changeStyle(val){
$(".b_bottom_left").addClass("bbl_pad").removeClass("without_back"); $(".b_bottom_left").addClass("bbl_pad").removeClass("without_back");
$(".b_bottom_center").addClass("bbc_pad").removeClass("without_back"); $(".b_bottom_center").addClass("bbc_pad").removeClass("without_back");
$("#wgt_reload").addClass("pad_color").addClass("pad_reload"); $("#wgt_reload").addClass("pad_color").addClass("pad_reload");
$("#wgt_help").addClass("pad_color").addClass("pad_help");
$("#wgt_edit").addClass("pad_color").addClass("pad_edit"); $("#wgt_edit").addClass("pad_color").addClass("pad_edit");
$("#wgt_display").addClass("pad_color").addClass("pad_edit"); $("#wgt_display").addClass("pad_color").addClass("pad_edit");
$("#wgt_name").addClass("pad_color"); $("#wgt_name").addClass("pad_color");
...@@ -644,6 +665,7 @@ function changeStyle(val){ ...@@ -644,6 +665,7 @@ function changeStyle(val){
$(".b_bottom_right").addClass("without_back").removeClass("bbr_pad"); $(".b_bottom_right").addClass("without_back").removeClass("bbr_pad");
$(".b_bottom_left").addClass("without_back").removeClass("bbl_pad"); $(".b_bottom_left").addClass("without_back").removeClass("bbl_pad");
$(".b_bottom_center").addClass("without_back").removeClass("bbc_pad"); $(".b_bottom_center").addClass("without_back").removeClass("bbc_pad");
$("#wgt_help").addClass("pad_color").addClass("pad_help");
$("#wgt_reload").addClass("pad_color").addClass("pad_reload"); $("#wgt_reload").addClass("pad_color").addClass("pad_reload");
$("#wgt_edit").addClass("pad_color").addClass("pad_edit"); $("#wgt_edit").addClass("pad_color").addClass("pad_edit");
$("#wgt_display").addClass("pad_color").addClass("pad_edit"); $("#wgt_display").addClass("pad_color").addClass("pad_edit");
...@@ -760,5 +782,4 @@ function onDropTarget(obj, event) { ...@@ -760,5 +782,4 @@ function onDropTarget(obj, event) {
event.cancelBubble = true; event.cancelBubble = true;
} }
return false; return false;
} }
\ No newline at end of file
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
<td class="b_top_left">&nbsp;</td> <td class="b_top_left">&nbsp;</td>
<td class="b_top_center"> <td class="b_top_center">
<div id="wgt_name"></div> <div id="wgt_name"></div>
<div id="wgt_help"></div>
<div id="wgt_reload"></div> <div id="wgt_reload"></div>
<div id="wgt_display" class="selected"></div> <div id="wgt_display" class="selected"></div>
<div id="wgt_edit"></div> <div id="wgt_edit"></div>
...@@ -37,6 +38,7 @@ ...@@ -37,6 +38,7 @@
<tr> <tr>
<td class="b_center_left">&nbsp;</td> <td class="b_center_left">&nbsp;</td>
<td> <td>
<div id="help"></div>
<div id="data"> <div id="data">
</div> </div>
......
...@@ -11,6 +11,7 @@ var sankoreLang = { ...@@ -11,6 +11,7 @@ var sankoreLang = {
none: "Нет" none: "Нет"
}; };
//main function //main function
function start(){ function start(){
...@@ -18,6 +19,8 @@ function start(){ ...@@ -18,6 +19,8 @@ function start(){
$("#wgt_edit").text(sankoreLang.edit); $("#wgt_edit").text(sankoreLang.edit);
$("#wgt_name").text(sankoreLang.wgt_name); $("#wgt_name").text(sankoreLang.wgt_name);
$("#wgt_reload").text(sankoreLang.reload); $("#wgt_reload").text(sankoreLang.reload);
$("#wgt_help").text(sankoreLang.help);
$("#help").html(sankoreLang.help_content);
$(".style_select option[value='1']").text(sankoreLang.slate); $(".style_select option[value='1']").text(sankoreLang.slate);
$(".style_select option[value='2']").text(sankoreLang.pad); $(".style_select option[value='2']").text(sankoreLang.pad);
$(".style_select option[value='3']").text(sankoreLang.none); $(".style_select option[value='3']").text(sankoreLang.none);
...@@ -39,6 +42,21 @@ function start(){ ...@@ -39,6 +42,21 @@ function start(){
} }
} }
$("#wgt_help").click(function(){
var tmp = $(this);
if($(this).hasClass("open")){
$("#help").slideUp("100", function(){
tmp.removeClass("open");
$("#data").show();
});
} else {
$("#data").hide();
$("#help").slideDown("100", function(){
tmp.addClass("open");
});
}
});
$("#wgt_reload").click(function(){ $("#wgt_reload").click(function(){
if($("#wgt_display").hasClass("selected")){ if($("#wgt_display").hasClass("selected")){
$("#wgt_edit").trigger("click"); $("#wgt_edit").trigger("click");
...@@ -613,6 +631,7 @@ function changeStyle(val){ ...@@ -613,6 +631,7 @@ function changeStyle(val){
$(".b_bottom_left").removeClass("bbl_pad").removeClass("without_back"); $(".b_bottom_left").removeClass("bbl_pad").removeClass("without_back");
$(".b_bottom_center").removeClass("bbc_pad").removeClass("without_back"); $(".b_bottom_center").removeClass("bbc_pad").removeClass("without_back");
$("#wgt_reload").removeClass("pad_color").removeClass("pad_reload"); $("#wgt_reload").removeClass("pad_color").removeClass("pad_reload");
$("#wgt_help").removeClass("pad_color").removeClass("pad_help");
$("#wgt_edit").removeClass("pad_color").removeClass("pad_edit"); $("#wgt_edit").removeClass("pad_color").removeClass("pad_edit");
$("#wgt_display").removeClass("pad_color").removeClass("pad_edit"); $("#wgt_display").removeClass("pad_color").removeClass("pad_edit");
$("#wgt_name").removeClass("pad_color"); $("#wgt_name").removeClass("pad_color");
...@@ -629,6 +648,7 @@ function changeStyle(val){ ...@@ -629,6 +648,7 @@ function changeStyle(val){
$(".b_bottom_left").addClass("bbl_pad").removeClass("without_back"); $(".b_bottom_left").addClass("bbl_pad").removeClass("without_back");
$(".b_bottom_center").addClass("bbc_pad").removeClass("without_back"); $(".b_bottom_center").addClass("bbc_pad").removeClass("without_back");
$("#wgt_reload").addClass("pad_color").addClass("pad_reload"); $("#wgt_reload").addClass("pad_color").addClass("pad_reload");
$("#wgt_help").addClass("pad_color").addClass("pad_help");
$("#wgt_edit").addClass("pad_color").addClass("pad_edit"); $("#wgt_edit").addClass("pad_color").addClass("pad_edit");
$("#wgt_display").addClass("pad_color").addClass("pad_edit"); $("#wgt_display").addClass("pad_color").addClass("pad_edit");
$("#wgt_name").addClass("pad_color"); $("#wgt_name").addClass("pad_color");
...@@ -644,6 +664,7 @@ function changeStyle(val){ ...@@ -644,6 +664,7 @@ function changeStyle(val){
$(".b_bottom_right").addClass("without_back").removeClass("bbr_pad"); $(".b_bottom_right").addClass("without_back").removeClass("bbr_pad");
$(".b_bottom_left").addClass("without_back").removeClass("bbl_pad"); $(".b_bottom_left").addClass("without_back").removeClass("bbl_pad");
$(".b_bottom_center").addClass("without_back").removeClass("bbc_pad"); $(".b_bottom_center").addClass("without_back").removeClass("bbc_pad");
$("#wgt_help").addClass("pad_color").addClass("pad_help");
$("#wgt_reload").addClass("pad_color").addClass("pad_reload"); $("#wgt_reload").addClass("pad_color").addClass("pad_reload");
$("#wgt_edit").addClass("pad_color").addClass("pad_edit"); $("#wgt_edit").addClass("pad_color").addClass("pad_edit");
$("#wgt_display").addClass("pad_color").addClass("pad_edit"); $("#wgt_display").addClass("pad_color").addClass("pad_edit");
...@@ -760,5 +781,4 @@ function onDropTarget(obj, event) { ...@@ -760,5 +781,4 @@ function onDropTarget(obj, event) {
event.cancelBubble = true; event.cancelBubble = true;
} }
return false; return false;
} }
\ No newline at end of file
...@@ -47,8 +47,6 @@ if(window.sankore){ ...@@ -47,8 +47,6 @@ if(window.sankore){
word = sankoreLang.example; word = sankoreLang.example;
} }
var doCheckWord = true;
// array of dom elements // array of dom elements
var letters = []; var letters = [];
...@@ -67,10 +65,13 @@ var widget_padding = 0; ...@@ -67,10 +65,13 @@ var widget_padding = 0;
var min_view_width = 400; var min_view_width = 400;
$(document).ready(function(){ $(document).ready(function(){
if(sankore.preference("ord_words_style","")){ if(window.sankore){
changeStyle(sankore.preference("ord_words_style","")); if(sankore.preference("ord_words_style","")){
$(".style_select").val(sankore.preference("ord_words_style","")); changeStyle(sankore.preference("ord_words_style",""));
} else $(".style_select").val(sankore.preference("ord_words_style",""));
} else
changeStyle("3")
} else
changeStyle("3") changeStyle("3")
$("#wgt_display").text(sankoreLang.view); $("#wgt_display").text(sankoreLang.view);
$("#wgt_edit").text(sankoreLang.edit); $("#wgt_edit").text(sankoreLang.edit);
...@@ -300,7 +301,7 @@ turns the widget into the view mode ...@@ -300,7 +301,7 @@ turns the widget into the view mode
function modeView() function modeView()
{ {
if( editMode ){ if( editMode ){
word = $( "#mp_word input:text" ).attr( "value" ); word = $( "#mp_word .wgt_cont" ).val();
} }
wgtState = false; wgtState = false;
...@@ -360,14 +361,15 @@ function modeEdit() ...@@ -360,14 +361,15 @@ function modeEdit()
{ {
editMode = true; editMode = true;
wgtState = true; wgtState = true;
$( "#mp_word").css( "margin-left", 0 ).empty().append('<input value="'+word+'">'); $( "#mp_word").sortable( "destroy" );
$( "#mp_word").css( "margin-left", 0 ).empty().append('<textarea class="wgt_cont">'+word+'</textarea>');
} }
if (window.widget) { if (window.widget) {
window.widget.onleave = function(){ window.widget.onleave = function(){
sankore.setPreference("ord_words_style", $(".style_select").find("option:selected").val()); sankore.setPreference("ord_words_style", $(".style_select").find("option:selected").val());
if($( "#mp_word input:text" ).attr( "value" )) if($( "#mp_word .wgt_cont" ).val())
{ {
modeView(); modeView();
var str = ""; var str = "";
......
...@@ -47,8 +47,6 @@ if(window.sankore){ ...@@ -47,8 +47,6 @@ if(window.sankore){
word = sankoreLang.example; word = sankoreLang.example;
} }
var doCheckWord = true;
// array of dom elements // array of dom elements
var letters = []; var letters = [];
...@@ -67,10 +65,13 @@ var widget_padding = 0; ...@@ -67,10 +65,13 @@ var widget_padding = 0;
var min_view_width = 400; var min_view_width = 400;
$(document).ready(function(){ $(document).ready(function(){
if(sankore.preference("ord_words_style","")){ if(window.sankore){
changeStyle(sankore.preference("ord_words_style","")); if(sankore.preference("ord_words_style","")){
$(".style_select").val(sankore.preference("ord_words_style","")); changeStyle(sankore.preference("ord_words_style",""));
} else $(".style_select").val(sankore.preference("ord_words_style",""));
} else
changeStyle("3")
} else
changeStyle("3") changeStyle("3")
$("#wgt_display").text(sankoreLang.view); $("#wgt_display").text(sankoreLang.view);
$("#wgt_edit").text(sankoreLang.edit); $("#wgt_edit").text(sankoreLang.edit);
...@@ -300,7 +301,7 @@ turns the widget into the view mode ...@@ -300,7 +301,7 @@ turns the widget into the view mode
function modeView() function modeView()
{ {
if( editMode ){ if( editMode ){
word = $( "#mp_word input:text" ).attr( "value" ); word = $( "#mp_word .wgt_cont" ).val();
} }
wgtState = false; wgtState = false;
...@@ -360,14 +361,15 @@ function modeEdit() ...@@ -360,14 +361,15 @@ function modeEdit()
{ {
editMode = true; editMode = true;
wgtState = true; wgtState = true;
$( "#mp_word").css( "margin-left", 0 ).empty().append('<input value="'+word+'">'); $( "#mp_word").sortable( "destroy" );
$( "#mp_word").css( "margin-left", 0 ).empty().append('<textarea class="wgt_cont">'+word+'</textarea>');
} }
if (window.widget) { if (window.widget) {
window.widget.onleave = function(){ window.widget.onleave = function(){
sankore.setPreference("ord_words_style", $(".style_select").find("option:selected").val()); sankore.setPreference("ord_words_style", $(".style_select").find("option:selected").val());
if($( "#mp_word input:text" ).attr( "value" )) if($( "#mp_word .wgt_cont" ).val())
{ {
modeView(); modeView();
var str = ""; var str = "";
......
...@@ -65,12 +65,14 @@ var widget_padding = 0; ...@@ -65,12 +65,14 @@ var widget_padding = 0;
var min_view_width = 400; var min_view_width = 400;
$(document).ready(function(){ $(document).ready(function(){
if(window.sankore) if(window.sankore){
if(sankore.preference("ord_words_style","")){ if(sankore.preference("ord_words_style","")){
changeStyle(sankore.preference("ord_words_style","")); changeStyle(sankore.preference("ord_words_style",""));
$(".style_select").val(sankore.preference("ord_words_style","")); $(".style_select").val(sankore.preference("ord_words_style",""));
} else } else
changeStyle("3") changeStyle("3")
} else
changeStyle("3")
$("#wgt_display").text(sankoreLang.view); $("#wgt_display").text(sankoreLang.view);
$("#wgt_edit").text(sankoreLang.edit); $("#wgt_edit").text(sankoreLang.edit);
$("#wgt_display, #wgt_edit").click(function(event){ $("#wgt_display, #wgt_edit").click(function(event){
...@@ -299,7 +301,7 @@ turns the widget into the view mode ...@@ -299,7 +301,7 @@ turns the widget into the view mode
function modeView() function modeView()
{ {
if( editMode ){ if( editMode ){
word = $( "#mp_word input:text" ).attr( "value" ); word = $( "#mp_word .wgt_cont" ).val();
} }
wgtState = false; wgtState = false;
...@@ -359,14 +361,15 @@ function modeEdit() ...@@ -359,14 +361,15 @@ function modeEdit()
{ {
editMode = true; editMode = true;
wgtState = true; wgtState = true;
$( "#mp_word").css( "margin-left", 0 ).empty().append('<input value="'+word+'">'); $( "#mp_word").sortable( "destroy" );
$( "#mp_word").css( "margin-left", 0 ).empty().append('<textarea class="wgt_cont">'+word+'</textarea>');
} }
if (window.widget) { if (window.widget) {
window.widget.onleave = function(){ window.widget.onleave = function(){
sankore.setPreference("ord_words_style", $(".style_select").find("option:selected").val()); sankore.setPreference("ord_words_style", $(".style_select").find("option:selected").val());
if($( "#mp_word input:text" ).attr( "value" )) if($( "#mp_word .wgt_cont" ).val())
{ {
modeView(); modeView();
var str = ""; var str = "";
......
...@@ -12,7 +12,7 @@ body{ ...@@ -12,7 +12,7 @@ body{
.letter{ .letter{
min-width: 30px; min-width: 30px;
max-width: 500px; max-width: 600px;
height: 40px; height: 40px;
overflow: hidden; overflow: hidden;
border: solid 1px #ccc; border: solid 1px #ccc;
...@@ -43,11 +43,12 @@ body{ ...@@ -43,11 +43,12 @@ body{
text-align: center; text-align: center;
} }
#mp_word input{ #mp_word .wgt_cont{
font: 32px tahoma; font: 32px tahoma;
letter-spacing: 0.1em; letter-spacing: 0.1em;
width: 98%; width: 98%;
overflow: auto; min-height: 200px;
resize: vertical;
} }
#mp_msg{ #mp_msg{
......
...@@ -107,7 +107,6 @@ ...@@ -107,7 +107,6 @@
function imageDragging(e){ function imageDragging(e){
e.dataTransfer.setData("text/plain",$(this).find("input:hidden").eq(0).val()); e.dataTransfer.setData("text/plain",$(this).find("input:hidden").eq(0).val());
// alert($(this).find("input:hidden").eq(0).val());
} }
function imageDragleave(e){ function imageDragleave(e){
...@@ -235,15 +234,12 @@ ...@@ -235,15 +234,12 @@
function createMetaData(parent){ function createMetaData(parent){
var meta = ""; var meta = "";
//alert($(this).find("input:hidden").eq(0).val()); //alert($(this).find("input:hidden").eq(0).val());
meta = "<metadata><data><key>Type</key><value>Image</value></data><data><key>Url</key><value>" + meta = "<metadata><data><key>Type</key><value>Audio</value></data><data><key>Url</key><value>" +
parent.find("input:hidden").eq(0).val() + parent.find("input:hidden").eq(0).val() +
"</value></data><data><key>Content</key><value>" + "</value></data><data><key>Content</key><value>" +
parent.find("input:hidden").eq(1).val() + parent.find("input:hidden").eq(1).val() +
"</value></data><data><key>Height</key><value>" + "</value></data><data><key>Height</key><value>n/a</value></data>"+
parent.find("input:hidden").eq(2).val() + "<data><key>Width</key><value>n/a</value></data><data><key>Title</key><value>" +
"</value></data><data><key>Width</key><value>" +
parent.find("input:hidden").eq(3).val() +
"</value></data><data><key>Title</key><value>" +
parent.find("input:hidden").eq(4).val() + parent.find("input:hidden").eq(4).val() +
"</value></data></metadata>"; "</value></data></metadata>";
return meta; return meta;
......
...@@ -234,16 +234,12 @@ ...@@ -234,16 +234,12 @@
function createMetaData(parent){ function createMetaData(parent){
var meta = ""; var meta = "";
//alert($(this).find("input:hidden").eq(0).val()); meta = "<metadata><data><key>Type</key><value>Flash</value></data><data><key>Url</key><value>" +
meta = "<metadata><data><key>Type</key><value>Image</value></data><data><key>Url</key><value>" +
parent.find("input:hidden").eq(0).val() + parent.find("input:hidden").eq(0).val() +
"</value></data><data><key>Content</key><value>" + "</value></data><data><key>Content</key><value>" +
parent.find("input:hidden").eq(1).val() + parent.find("input:hidden").eq(1).val() +
"</value></data><data><key>Height</key><value>" + "</value></data><data><key>Height</key><value>n/a</value></data>"+
parent.find("input:hidden").eq(2).val() + "<data><key>Width</key><value>n/a</value></data><data><key>Title</key><value>" +
"</value></data><data><key>Width</key><value>" +
parent.find("input:hidden").eq(3).val() +
"</value></data><data><key>Title</key><value>" +
parent.find("input:hidden").eq(4).val() + parent.find("input:hidden").eq(4).val() +
"</value></data></metadata>"; "</value></data></metadata>";
return meta; return meta;
......
...@@ -22,10 +22,10 @@ ...@@ -22,10 +22,10 @@
for (var i = 0; i < 8; i++) { for (var i = 0; i < 8; i++) {
if (i * limit < totalResults) { if (i * limit < totalResults) {
var link = $("<a class='pager_button'></a>").attr('href', 'javascript:gotoPage('+i+');').html(i+1).appendTo(pagesDiv); var link = $("<a class='pager_button'></a>").attr('href', 'javascript:gotoPage('+i+');').html(i+1).appendTo(pagesDiv);
if (curPage == i) { if (curPage == i) {
link.addClass('active'); link.addClass('active');
} }
} }
} }
...@@ -50,59 +50,65 @@ ...@@ -50,59 +50,65 @@
} }
function searchFail(jqXHR, textStatus, errorThrown) { function searchFail(jqXHR, textStatus, errorThrown) {
alert('Impossible to connect to Planete Sankore: ' + textStatus + ' ' + errorThrown); alert('Impossible to connect to Planete Sankore: ' + textStatus + ' ' + errorThrown);
} }
function searchComplete(json) { function searchComplete(json) {
// Grab our content div, clear it. // Grab our content div, clear it.
var totalResults = json.totalResults; var totalResults = json.totalResults;
var contentDiv = $('#searchResult').empty(); var contentDiv = $('#searchResult').empty();
// Loop through our results, printing them to the page. // Loop through our results, printing them to the page.
var results = json.rows; var results = json.rows;
for (var i = 0; i < results.length; i++) { for (var i = 0; i < results.length; i++) {
// For each result write it's title and image to the screen // For each result write it's title and image to the screen
var result = results[i]; var result = results[i];
var imgContainer = $("<div class='imgContainer' draggable='true'>"); var imgContainer = $("<div class='imgContainer' draggable='true'>");
//var title = document.createElement('div'); //var title = document.createElement('div');
var iUrl = $("<input type='hidden'/>"); var iUrl = $("<input type='hidden'/>");
var iContent = $("<input type='hidden'/>"); var iContent = $("<input type='hidden'/>");
var iHeight = $("<input type='hidden'/>"); var iHeight = $("<input type='hidden'/>");
var iWidth = $("<input type='hidden'/>"); var iWidth = $("<input type='hidden'/>");
var iTitle = $("<input type='hidden'/>"); var iTitle = $("<input type='hidden'/>");
// We use titleNoFormatting so that no HTML tags are left in the // We use titleNoFormatting so that no HTML tags are left in the
// title // title
//title.innerHTML = result.title; //title.innerHTML = result.title;
var newImg = document.createElement('img'); var newImg = document.createElement('img');
// There is also a result.file property which has the escaped version // There is also a result.file property which has the escaped version
if (thumbnails) { if (thumbnails) {
newImg.src = result.file; newImg.src = result.file;
} else { if(result.height >= result.width)
newImg.src = "./images/thumbnail_icon.png"; newImg.height = minHeight;
} else{
var imgWidth = (result.tbWidth > minWidth)?result.tbWidth:minWidth; newImg.width = minWidth;
var imgHeight = (result.tbHeight > minHeight)?result.tbHeight:minHeight; //newImg.style.margin = (120 - result.height)/2 + "px 0";
imgContainer.width(imgWidth).height(imgHeight); }
imgContainer.append($(newImg)); } else {
iUrl.attr("value", result.file); newImg.src = "./images/thumbnail_icon.png";
iContent.attr("value", result.title); }
iHeight.attr("value", result.height); var imgWidth = (result.tbWidth > minWidth)?result.tbWidth:minWidth;
iWidth.attr("value", result.width); var imgHeight = (result.tbHeight > minHeight)?result.tbHeight:minHeight;
iTitle.attr("value",result.title); imgContainer.width(imgWidth).height(imgHeight);
//imgContainer.append($(title)); imgContainer.append($(newImg));
imgContainer.append(iUrl); iUrl.attr("value", result.file);
imgContainer.append(iContent); iContent.attr("value", result.title);
imgContainer.append(iHeight); iHeight.attr("value", result.height);
imgContainer.append(iWidth); iWidth.attr("value", result.width);
imgContainer.append(iTitle); iTitle.attr("value",result.title);
//imgContainer.append($(title));
imgContainer.append(iUrl);
imgContainer.append(iContent);
imgContainer.append(iHeight);
imgContainer.append(iWidth);
imgContainer.append(iTitle);
// Put our title + image in the content // Put our title + image in the content
imgContainer.appendTo(contentDiv); imgContainer.appendTo(contentDiv);
} }
// Now add links to additional pages of search results. // Now add links to additional pages of search results.
addPaginationLinks(totalResults); addPaginationLinks(totalResults);
} }
function imageDragging(e){ function imageDragging(e){
...@@ -166,9 +172,9 @@ ...@@ -166,9 +172,9 @@
filtersDisplayed = true; filtersDisplayed = true;
} }
}); });
*/ */
/*togglePages.click(function(event){ /*togglePages.click(function(event){
if(mode){ if(mode){
hide = false; hide = false;
$("#search, #disclaimer").slideDown('slow', function(){ $("#search, #disclaimer").slideDown('slow', function(){
...@@ -204,10 +210,10 @@ ...@@ -204,10 +210,10 @@
}); });
( (
$(".imgContainer").live("click",function(){ $(".imgContainer").live("click",function(){
sankore.sendFileMetadata(createMetaData($(this))); sankore.sendFileMetadata(createMetaData($(this)));
})); }));
/*$(window).resize(function(){ /*$(window).resize(function(){
disclaimer.width($("body").width()-20); disclaimer.width($("body").width()-20);
search.width($("body").width()-20); search.width($("body").width()-20);
toggleIcon.css("margin-left",(togglePages.width()/2 - 7)); toggleIcon.css("margin-left",(togglePages.width()/2 - 7));
...@@ -216,21 +222,21 @@ ...@@ -216,21 +222,21 @@
}); });
function gotoPage(i) { function gotoPage(i) {
runSearch(currentTerm, i); runSearch(currentTerm, i);
} }
// launching the search on planete sankore // launching the search on planete sankore
function runSearch(term, index) { function runSearch(term, index) {
currentTerm = term; currentTerm = term;
currentIndex = index; currentIndex = index;
var start = index * limit; var start = index * limit;
var url = "http://planete.sankore.org/xwiki/bin/view/Search/Resources?xpage=plain&category=" + category + "&level=&sort=title&dir=ASC&terms=" + escape(term) + "&start=" + start + "&limit=" + limit; var url = "http://planete.sankore.org/xwiki/bin/view/Search/Resources?xpage=plain&category=" + category + "&level=&sort=title&dir=ASC&terms=" + escape(term) + "&start=" + start + "&limit=" + limit;
$.ajax({ $.ajax({
url: url, url: url,
success: searchComplete, success: searchComplete,
error: searchFail, error: searchFail,
dataType: "json" dataType: "json"
}); });
} }
function createMetaData(parent){ function createMetaData(parent){
......
...@@ -203,7 +203,7 @@ ...@@ -203,7 +203,7 @@
}); });
( (
$(".imgContainer").live("click",function(){ $(".imgContainer").live("click",function(){
sankore.sendFileMetadata(createMetaData($(this))); sankore.sendFileMetadata(createMetaData($(this)));
})); }));
/*$(window).resize(function(){ /*$(window).resize(function(){
...@@ -235,15 +235,12 @@ ...@@ -235,15 +235,12 @@
function createMetaData(parent){ function createMetaData(parent){
var meta = ""; var meta = "";
//alert($(this).find("input:hidden").eq(0).val()); //alert($(this).find("input:hidden").eq(0).val());
meta = "<metadata><data><key>Type</key><value>Image</value></data><data><key>Url</key><value>" + meta = "<metadata><data><key>Type</key><value>Video</value></data><data><key>Url</key><value>" +
parent.find("input:hidden").eq(0).val() + parent.find("input:hidden").eq(0).val() +
"</value></data><data><key>Content</key><value>" + "</value></data><data><key>Content</key><value>" +
parent.find("input:hidden").eq(1).val() + parent.find("input:hidden").eq(1).val() +
"</value></data><data><key>Height</key><value>" + "</value></data><data><key>Height</key><value>n/a</value></data>"+
parent.find("input:hidden").eq(2).val() + "<data><key>Width</key><value>n/a</value></data><data><key>Title</key><value>" +
"</value></data><data><key>Width</key><value>" +
parent.find("input:hidden").eq(3).val() +
"</value></data><data><key>Title</key><value>" +
parent.find("input:hidden").eq(4).val() + parent.find("input:hidden").eq(4).val() +
"</value></data></metadata>"; "</value></data></metadata>";
return meta; return meta;
......
...@@ -1078,7 +1078,7 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::persistCurrentScene() ...@@ -1078,7 +1078,7 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::persistCurrentScene()
{ {
if (mCurrentScene != 0 && mCurrentScene->isModified()) if (mCurrentScene != 0 && mCurrentScene->isModified())
{ {
UBThumbnailAdaptor::persistScene(mProxy->persistencePath(), mCurrentScene, mProxy->pageCount() - 1); UBThumbnailAdaptor::persistScene(mProxy, mCurrentScene, mProxy->pageCount() - 1);
UBSvgSubsetAdaptor::persistScene(mProxy, mCurrentScene, mProxy->pageCount() - 1); UBSvgSubsetAdaptor::persistScene(mProxy, mCurrentScene, mProxy->pageCount() - 1);
mCurrentScene->setModified(false); mCurrentScene->setModified(false);
...@@ -1102,7 +1102,7 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::persistScenes() ...@@ -1102,7 +1102,7 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::persistScenes()
UBSvgSubsetAdaptor::persistScene(mProxy, mCurrentScene, i); UBSvgSubsetAdaptor::persistScene(mProxy, mCurrentScene, i);
UBGraphicsScene *tmpScene = UBSvgSubsetAdaptor::loadScene(mProxy, i); UBGraphicsScene *tmpScene = UBSvgSubsetAdaptor::loadScene(mProxy, i);
tmpScene->setModified(true); tmpScene->setModified(true);
UBThumbnailAdaptor::persistScene(mProxy->persistencePath(), tmpScene, i); UBThumbnailAdaptor::persistScene(mProxy, tmpScene, i);
delete tmpScene; delete tmpScene;
mCurrentScene->setModified(false); mCurrentScene->setModified(false);
......
...@@ -56,6 +56,8 @@ ...@@ -56,6 +56,8 @@
#include "interfaces/IDataStorage.h" #include "interfaces/IDataStorage.h"
#include "document/UBDocumentContainer.h"
#include "pdf/PDFRenderer.h" #include "pdf/PDFRenderer.h"
#include "core/memcheck.h" #include "core/memcheck.h"
...@@ -313,7 +315,7 @@ QString UBSvgSubsetAdaptor::readTeacherGuideNode(int sceneIndex) ...@@ -313,7 +315,7 @@ QString UBSvgSubsetAdaptor::readTeacherGuideNode(int sceneIndex)
{ {
QString result; QString result;
QString fileName = UBApplication::boardController->activeDocument()->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.svg", sceneIndex); QString fileName = UBApplication::boardController->selectedDocument()->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.svg", sceneIndex);
QFile file(fileName); QFile file(fileName);
file.open(QIODevice::ReadOnly); file.open(QIODevice::ReadOnly);
QByteArray fileByteArray=file.readAll(); QByteArray fileByteArray=file.readAll();
......
This diff is collapsed.
/* /*
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or * the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef UBTHUMBNAILADAPTOR_H #ifndef UBTHUMBNAILADAPTOR_H
#define UBTHUMBNAILADAPTOR_H #define UBTHUMBNAILADAPTOR_H
#include <QtCore> #include <QtCore>
class UBDocument; class UBDocument;
class UBDocumentProxy; class UBDocumentProxy;
class UBGraphicsScene; class UBGraphicsScene;
class UBThumbnailAdaptor //static class class UBThumbnailAdaptor //static class
{ {
Q_DECLARE_TR_FUNCTIONS(UBThumbnailAdaptor) Q_DECLARE_TR_FUNCTIONS(UBThumbnailAdaptor)
private: UBThumbnailAdaptor() {} public:
public: static QUrl thumbnailUrl(UBDocumentProxy* proxy, int pageIndex);
static void persistScene(const QString& pDocPath, UBGraphicsScene* pScene, int pageIndex, bool overrideModified = false);
static void persistScene(UBDocumentProxy* proxy, UBGraphicsScene* pScene, int pageIndex, bool overrideModified = false);
static void generateMissingThumbnails(UBDocumentProxy* proxy);
static QList<QPixmap> load(UBDocumentProxy* proxy); static const QPixmap* get(UBDocumentProxy* proxy, int index);
static QPixmap load(UBDocumentProxy* proxy, int index); static void load(UBDocumentProxy* proxy, QList<const QPixmap*>& list);
static QUrl thumbnailUrl(UBDocumentProxy* proxy, int pageIndex); private:
}; static void generateMissingThumbnails(UBDocumentProxy* proxy);
#endif // UBTHUMBNAILADAPTOR_H UBThumbnailAdaptor() {}
};
#endif // UBTHUMBNAILADAPTOR_H
/* /*
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or * the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef UBDOCUMENTPUBLISHER_H #ifndef UBDOCUMENTPUBLISHER_H
#define UBDOCUMENTPUBLISHER_H #define UBDOCUMENTPUBLISHER_H
#include <QtGui> #include <QtGui>
#include <QtNetwork> #include <QtNetwork>
#include "ui_webPublishing.h" #include "ui_webPublishing.h"
#define DOCPUBLICATION_URL "http://planete.sankore.org/xwiki/bin/view/CreateResources/UniboardUpload?xpage=plain&outputSyntax=plain" #define DOCPUBLICATION_URL "http://planete.sankore.org/xwiki/bin/view/CreateResources/UniboardUpload?xpage=plain&outputSyntax=plain"
typedef struct typedef struct
{ {
QString title; QString title;
QString description; QString description;
} sDocumentInfos; } sDocumentInfos;
class UBDocumentProxy; class UBDocumentProxy;
class UBServerXMLHttpRequest; class UBServerXMLHttpRequest;
class UBGraphicsW3CWidgetItem; class UBGraphicsW3CWidgetItem;
class QWebView; class QWebView;
class UBProxyLoginDlg : public QDialog class UBProxyLoginDlg : public QDialog
{ {
Q_OBJECT Q_OBJECT
public: public:
UBProxyLoginDlg(QWidget* parent=0, const char* name="ProxyLoginDlg"); UBProxyLoginDlg(QWidget* parent=0, const char* name="ProxyLoginDlg");
~UBProxyLoginDlg(); ~UBProxyLoginDlg();
QString username(){return mpUsername->text();} QString username(){return mpUsername->text();}
QString password(){return mpPassword->text();} QString password(){return mpPassword->text();}
private: private:
QVBoxLayout* mpLayout; QVBoxLayout* mpLayout;
QHBoxLayout* mpUserLayout; QHBoxLayout* mpUserLayout;
QHBoxLayout* mpPasswordLayout; QHBoxLayout* mpPasswordLayout;
QDialogButtonBox* mpButtons; QDialogButtonBox* mpButtons;
QLabel* mpUserLabel; QLabel* mpUserLabel;
QLabel* mpPasswordLabel; QLabel* mpPasswordLabel;
QLineEdit* mpUsername; QLineEdit* mpUsername;
QLineEdit* mpPassword; QLineEdit* mpPassword;
}; };
class UBPublicationDlg : public QDialog class UBPublicationDlg : public QDialog
{ {
Q_OBJECT Q_OBJECT
public: public:
UBPublicationDlg(QWidget* parent=0, const char* name="UBPublicationDlg"); UBPublicationDlg(QWidget* parent=0, const char* name="UBPublicationDlg");
~UBPublicationDlg(); ~UBPublicationDlg();
QString title(){return mpTitle->text();} QString title(){return mpTitle->text();}
QString description(){return mpDescription->document()->toPlainText();} QString description(){return mpDescription->document()->toPlainText();}
private slots: private slots:
void onTextChanged(); void onTextChanged();
private: private:
QVBoxLayout* mpLayout; QVBoxLayout* mpLayout;
QHBoxLayout* mpTitleLayout; QHBoxLayout* mpTitleLayout;
QLabel* mpTitleLabel; QLabel* mpTitleLabel;
QLineEdit* mpTitle; QLineEdit* mpTitle;
QLabel* mpDescLabel; QLabel* mpDescLabel;
QTextEdit* mpDescription; QTextEdit* mpDescription;
QDialogButtonBox* mpButtons; QDialogButtonBox* mpButtons;
}; };
class UBDocumentPublisher : public QObject class UBDocumentPublisher : public QObject
{ {
Q_OBJECT; Q_OBJECT;
public: public:
explicit UBDocumentPublisher(UBDocumentProxy* sourceDocument, QObject *parent = 0); explicit UBDocumentPublisher(UBDocumentProxy* sourceDocument, QObject *parent = 0);
virtual ~UBDocumentPublisher(); virtual ~UBDocumentPublisher();
void publish(); void publish();
signals: signals:
void loginDone(); void loginDone();
protected: protected:
virtual void updateGoogleMapApiKey(); virtual void updateGoogleMapApiKey();
virtual void rasterizeScenes(); virtual void rasterizeScenes();
virtual void upgradeDocumentForPublishing(); virtual void upgradeDocumentForPublishing();
virtual void generateWidgetPropertyScript(UBGraphicsW3CWidgetItem *widgetItem, int pageNumber); virtual void generateWidgetPropertyScript(UBGraphicsW3CWidgetItem *widgetItem, int pageNumber);
private slots: private slots:
void onFinished(QNetworkReply* reply); void onFinished(QNetworkReply* reply);
private: private:
UBDocumentProxy *mSourceDocument; UBDocumentProxy *mSourceDocument;
UBDocumentProxy *mPublishingDocument;
void init(); //UBDocumentProxy *mPublishingDocument;
void sendUbw(QString username, QString password); QString mPublishingPath;
QString getBase64Of(QString stringToEncode); int mPublishingSize;
QHBoxLayout* mpLayout;
QNetworkAccessManager* mpNetworkMgr; void init();
QNetworkCookieJar* mpCookieJar; void sendUbw(QString username, QString password);
QString mUsername; QString getBase64Of(QString stringToEncode);
QString mPassword;
QString mCrlf; QHBoxLayout* mpLayout;
bool bLoginCookieSet; QNetworkAccessManager* mpNetworkMgr;
QNetworkCookieJar* mpCookieJar;
void buildUbwFile(); QString mUsername;
QString mTmpZipFile; QString mPassword;
QList<QNetworkCookie> mCookies; QString mCrlf;
sDocumentInfos mDocInfos; bool bLoginCookieSet;
}; void buildUbwFile();
#endif // UBDOCUMENTPUBLISHER_H QString mTmpZipFile;
QList<QNetworkCookie> mCookies;
sDocumentInfos mDocInfos;
};
#endif // UBDOCUMENTPUBLISHER_H
...@@ -346,7 +346,7 @@ QString UBWidgetUniboardAPI::pageThumbnail(const int pageNumber) ...@@ -346,7 +346,7 @@ QString UBWidgetUniboardAPI::pageThumbnail(const int pageNumber)
if (UBApplication::boardController->activeScene() != mScene) if (UBApplication::boardController->activeScene() != mScene)
return ""; return "";
UBDocumentProxy *doc = UBApplication::boardController->activeDocument(); UBDocumentProxy *doc = UBApplication::boardController->selectedDocument();
if (!doc) if (!doc)
return ""; return "";
......
This diff is collapsed.
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include <QtGui> #include <QtGui>
#include <QObject> #include <QObject>
#include "document/UBDocumentContainer.h"
class UBMainWindow; class UBMainWindow;
class UBApplication; class UBApplication;
...@@ -40,7 +41,7 @@ class UBGraphicsWidgetItem; ...@@ -40,7 +41,7 @@ class UBGraphicsWidgetItem;
class UBBoardPaletteManager; class UBBoardPaletteManager;
class UBBoardController : public QObject class UBBoardController : public UBDocumentContainer
{ {
Q_OBJECT Q_OBJECT
...@@ -50,7 +51,7 @@ class UBBoardController : public QObject ...@@ -50,7 +51,7 @@ class UBBoardController : public QObject
void init(); void init();
void setupLayout(); void setupLayout();
UBDocumentProxy* activeDocument() const;
UBGraphicsScene* activeScene() const; UBGraphicsScene* activeScene() const;
int activeSceneIndex() const; int activeSceneIndex() const;
QSize displayViewport(); QSize displayViewport();
...@@ -60,14 +61,6 @@ class UBBoardController : public QObject ...@@ -60,14 +61,6 @@ class UBBoardController : public QObject
int currentPage(); int currentPage();
int pageFromSceneIndex(int sceneIndex);
int sceneIndexFromPage(int page);
UBDocumentProxy* activeDocument()
{
return mActiveDocument;
}
QWidget* controlContainer() QWidget* controlContainer()
{ {
return mControlContainer; return mControlContainer;
...@@ -158,10 +151,17 @@ class UBBoardController : public QObject ...@@ -158,10 +151,17 @@ class UBBoardController : public QObject
void displayMetaData(QMap<QString, QString> metadatas); void displayMetaData(QMap<QString, QString> metadatas);
void ClearUndoStack(); void ClearUndoStack();
void emitScrollSignal() { emit scrollToSelectedPage(); }
void setActiveDocumentScene(UBDocumentProxy* pDocumentProxy, int pSceneIndex = 0, bool forceReload = false);
void setActiveDocumentScene(int pSceneIndex);
void moveSceneToIndex(int source, int target);
void duplicateScene(int index);
void deleteScene(int index);
bool cacheIsVisible() {return mCacheWidgetIsEnabled;}
public slots: public slots:
void setActiveDocumentScene(UBDocumentProxy* pDocumentProxy, int pSceneIndex = 0);
void showDocumentsDialog(); void showDocumentsDialog();
void showKeyboard(bool show); void showKeyboard(bool show);
void togglePodcast(bool checked); void togglePodcast(bool checked);
...@@ -222,14 +222,12 @@ class UBBoardController : public QObject ...@@ -222,14 +222,12 @@ class UBBoardController : public QObject
void freezeW3CWidget(QGraphicsItem* item, bool freeze); void freezeW3CWidget(QGraphicsItem* item, bool freeze);
void startScript(); void startScript();
void stopScript(); void stopScript();
bool cacheIsVisible();
signals: signals:
void newPageAdded(); void newPageAdded();
void activeSceneWillBePersisted(); void activeSceneWillBePersisted();
void activeSceneWillChange(); void activeSceneWillChange();
void activeSceneChanged(); void activeSceneChanged();
void activeDocumentChanged();
void zoomChanged(qreal pZoomFactor); void zoomChanged(qreal pZoomFactor);
void systemScaleFactorChanged(qreal pSystemScaleFactor); void systemScaleFactorChanged(qreal pSystemScaleFactor);
void penColorChanged(); void penColorChanged();
...@@ -238,10 +236,9 @@ class UBBoardController : public QObject ...@@ -238,10 +236,9 @@ class UBBoardController : public QObject
void cacheEnabled(); void cacheEnabled();
void cacheDisabled(); void cacheDisabled();
void pageChanged(); void pageChanged();
void setDocOnPageNavigator(UBDocumentProxy* doc);
void documentReorganized(int index); void documentReorganized(int index);
void displayMetadata(QMap<QString, QString> metadata); void displayMetadata(QMap<QString, QString> metadata);
void scrollToSelectedPage(); void pageSelectionChanged(int index);
protected: protected:
void setupViews(); void setupViews();
...@@ -263,7 +260,6 @@ class UBBoardController : public QObject ...@@ -263,7 +260,6 @@ class UBBoardController : public QObject
void adjustDisplayViews(); void adjustDisplayViews();
UBMainWindow *mMainWindow; UBMainWindow *mMainWindow;
UBDocumentProxy* mActiveDocument;
UBGraphicsScene* mActiveScene; UBGraphicsScene* mActiveScene;
int mActiveSceneIndex; int mActiveSceneIndex;
UBBoardPaletteManager *mPaletteManager; UBBoardPaletteManager *mPaletteManager;
......
...@@ -134,8 +134,6 @@ void UBBoardPaletteManager::setupDockPaletteWidgets() ...@@ -134,8 +134,6 @@ void UBBoardPaletteManager::setupDockPaletteWidgets()
//------------------------------------------------// //------------------------------------------------//
// Create the widgets for the dock palettes // Create the widgets for the dock palettes
mpPageNavigWidget = new UBPageNavigationWidget();
#ifdef USE_WEB_WIDGET #ifdef USE_WEB_WIDGET
mpLibWidget = new UBLibWidget(); mpLibWidget = new UBLibWidget();
#endif #endif
...@@ -352,7 +350,7 @@ void UBBoardPaletteManager::pagePaletteButtonReleased() ...@@ -352,7 +350,7 @@ void UBBoardPaletteManager::pagePaletteButtonReleased()
QList<QAction*>pageActions; QList<QAction*>pageActions;
pageActions << UBApplication::mainWindow->actionNewPage; pageActions << UBApplication::mainWindow->actionNewPage;
UBBoardController* boardController = UBApplication::boardController; UBBoardController* boardController = UBApplication::boardController;
if(UBApplication::documentController->pageCanBeDuplicated(boardController->pageFromSceneIndex(boardController->activeSceneIndex()))) if(UBApplication::documentController->pageCanBeDuplicated(UBDocumentContainer::pageFromSceneIndex(boardController->activeSceneIndex())))
pageActions << UBApplication::mainWindow->actionDuplicatePage; pageActions << UBApplication::mainWindow->actionDuplicatePage;
pageActions << UBApplication::mainWindow->actionImportPage; pageActions << UBApplication::mainWindow->actionImportPage;
...@@ -568,7 +566,7 @@ void UBBoardPaletteManager::activeSceneChanged() ...@@ -568,7 +566,7 @@ void UBBoardPaletteManager::activeSceneChanged()
if (mpPageNavigWidget) if (mpPageNavigWidget)
{ {
mpPageNavigWidget->setPageNumber(UBApplication::boardController->pageFromSceneIndex(pageIndex), activeScene->document()->pageCount()); mpPageNavigWidget->setPageNumber(UBDocumentContainer::pageFromSceneIndex(pageIndex), activeScene->document()->pageCount());
} }
if (mZoomPalette) if (mZoomPalette)
......
...@@ -1040,6 +1040,7 @@ UBBoardView::mouseReleaseEvent (QMouseEvent *event) ...@@ -1040,6 +1040,7 @@ UBBoardView::mouseReleaseEvent (QMouseEvent *event)
mMouseButtonIsPressed = false; mMouseButtonIsPressed = false;
mPendingStylusReleaseEvent = false; mPendingStylusReleaseEvent = false;
mTabletStylusIsPressed = false; mTabletStylusIsPressed = false;
movingItem = NULL;
mLongPressTimer.stop(); mLongPressTimer.stop();
} }
......
...@@ -562,7 +562,7 @@ void UBLibraryController::removeBackground() ...@@ -562,7 +562,7 @@ void UBLibraryController::removeBackground()
UBGraphicsScene* UBLibraryController::activeScene() UBGraphicsScene* UBLibraryController::activeScene()
{ {
if (mBoardController->activeDocument()) if (mBoardController->selectedDocument())
return mBoardController->activeScene(); return mBoardController->activeScene();
return 0; return 0;
......
...@@ -20,6 +20,23 @@ ...@@ -20,6 +20,23 @@
#define UB_MAX_ZOOM 15 #define UB_MAX_ZOOM 15
struct UBMimeType
{
enum Enum
{
RasterImage = 0,
VectorImage,
AppleWidget,
W3CWidget,
Video,
Audio,
Flash,
PDF,
UniboardTool,
UNKNOWN
};
};
struct UBStylusTool struct UBStylusTool
{ {
enum Enum enum Enum
......
...@@ -317,8 +317,6 @@ int UBApplication::exec(const QString& pFileToImport) ...@@ -317,8 +317,6 @@ int UBApplication::exec(const QString& pFileToImport)
connect(mainWindow->actionHideApplication, SIGNAL(triggered()), this, SLOT(showMinimized())); connect(mainWindow->actionHideApplication, SIGNAL(triggered()), this, SLOT(showMinimized()));
#endif #endif
connect(documentController, SIGNAL(movedToIndex(int)), boardController, SIGNAL(documentReorganized(int)));
mPreferencesController = new UBPreferencesController(mainWindow); mPreferencesController = new UBPreferencesController(mainWindow);
connect(mainWindow->actionPreferences, SIGNAL(triggered()), mPreferencesController, SLOT(show())); connect(mainWindow->actionPreferences, SIGNAL(triggered()), mPreferencesController, SLOT(show()));
......
...@@ -63,7 +63,6 @@ UBApplicationController::UBApplicationController(UBBoardView *pControlView, UBBo ...@@ -63,7 +63,6 @@ UBApplicationController::UBApplicationController(UBBoardView *pControlView, UBBo
, mControlView(pControlView) , mControlView(pControlView)
, mDisplayView(pDisplayView) , mDisplayView(pDisplayView)
, mMirror(0) , mMirror(0)
, mFtp(0)
, mMainMode(Board) , mMainMode(Board)
, mDisplayManager(0) , mDisplayManager(0)
, mAutomaticCheckForUpdates(false) , mAutomaticCheckForUpdates(false)
...@@ -120,7 +119,6 @@ UBApplicationController::~UBApplicationController() ...@@ -120,7 +119,6 @@ UBApplicationController::~UBApplicationController()
delete mBlackScene; delete mBlackScene;
delete mMirror; delete mMirror;
if (mFtp) delete mFtp;
if (mHttp) delete mHttp; if (mHttp) delete mHttp;
} }
...@@ -340,8 +338,7 @@ void UBApplicationController::showBoard() ...@@ -340,8 +338,7 @@ void UBApplicationController::showBoard()
int selectedSceneIndex = UBApplication::documentController->getSelectedItemIndex(); int selectedSceneIndex = UBApplication::documentController->getSelectedItemIndex();
if (selectedSceneIndex != -1) if (selectedSceneIndex != -1)
{ {
UBApplication::boardController->setActiveDocumentScene(UBApplication::documentController->getCurrentDocument(), selectedSceneIndex); UBApplication::boardController->setActiveDocumentScene(UBApplication::documentController->selectedDocument(), selectedSceneIndex, true);
UBApplication::boardController->emitScrollSignal();
} }
} }
...@@ -522,42 +519,27 @@ void UBApplicationController::showSankoreEditor() ...@@ -522,42 +519,27 @@ void UBApplicationController::showSankoreEditor()
emit mainModeChanged(mMainMode); emit mainModeChanged(mMainMode);
} }
void UBApplicationController::runCheckUpdate(int id, bool error)
{
Q_UNUSED(id);
if(!error){
if(mFtp!=NULL)
delete mFtp;
mFtp = new QFtp(this);
connect(mFtp, SIGNAL(commandFinished(int,bool)), this, SLOT(ftpCommandFinished(int,bool)));
mFtp->connectToHost("91.121.248.138",21);
mFtp->login("anonymous", "anonymous");
mFtp->get("update.json",0);
}
}
void UBApplicationController::checkUpdate() void UBApplicationController::checkUpdate()
{ {
//TODO change this when upgrade the qt version if(mHttp)
// networkAccessible : NetworkAccessibility not yet available
if(mHttp)
delete mHttp; delete mHttp;
QUrl url("http://www.google.com"); QUrl url("http://ftp.open-sankore.org/update.json");
mHttp = new QHttp(url.host()); mHttp = new QHttp(url.host());
connect(mHttp, SIGNAL(requestFinished(int,bool)), this, SLOT(runCheckUpdate(int,bool))); connect(mHttp, SIGNAL(requestFinished(int,bool)), this, SLOT(updateRequestFinished(int,bool)));
mHttp->get(url.path()); mHttp->get(url.path());
} }
void UBApplicationController::ftpCommandFinished(int id, bool error) void UBApplicationController::updateRequestFinished(int id, bool error)
{ {
if (error){ if (error){
qWarning() << "ftp command id" << id << "return the error: " << mFtp->errorString(); qWarning() << "http command id" << id << "return the error: " << mHttp->errorString();
mFtp->close(); mHttp->close();
} }
else{ else{
QString responseString = QString(mFtp->readAll()); QString responseString = QString(mHttp->readAll());
qDebug() << responseString;
if (!responseString.isEmpty() && responseString.contains("version") && responseString.contains("url")){ if (!responseString.isEmpty() && responseString.contains("version") && responseString.contains("url")){
mFtp->close(); mHttp->close();
downloadJsonFinished(responseString); downloadJsonFinished(responseString);
} }
} }
......
...@@ -134,8 +134,7 @@ class UBApplicationController : public QObject ...@@ -134,8 +134,7 @@ class UBApplicationController : public QObject
void checkUpdateAtLaunch(); void checkUpdateAtLaunch();
private slots: private slots:
void ftpCommandFinished(int id, bool error); void updateRequestFinished(int id, bool error);
void runCheckUpdate(int id, bool error);
protected: protected:
...@@ -152,7 +151,6 @@ class UBApplicationController : public QObject ...@@ -152,7 +151,6 @@ class UBApplicationController : public QObject
UBScreenMirror* mMirror; UBScreenMirror* mMirror;
int mInitialHScroll, mInitialVScroll; int mInitialHScroll, mInitialVScroll;
QFtp* mFtp;
private: private:
......
...@@ -608,10 +608,10 @@ void UBPersistenceManager::persistDocumentScene(UBDocumentProxy* pDocumentProxy, ...@@ -608,10 +608,10 @@ void UBPersistenceManager::persistDocumentScene(UBDocumentProxy* pDocumentProxy,
if (pScene->isModified()) if (pScene->isModified())
{ {
UBThumbnailAdaptor::persistScene(pDocumentProxy->persistencePath(), pScene, pSceneIndex);
UBSvgSubsetAdaptor::persistScene(pDocumentProxy, pScene, pSceneIndex); UBSvgSubsetAdaptor::persistScene(pDocumentProxy, pScene, pSceneIndex);
UBThumbnailAdaptor::persistScene(pDocumentProxy, pScene, pSceneIndex);
pScene->setModified(false); pScene->setModified(false);
} }
......
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "UBDocumentContainer.h"
#include "adaptors/UBThumbnailAdaptor.h"
#include "core/UBPersistenceManager.h"
#include "core/memcheck.h"
UBDocumentContainer::UBDocumentContainer(QObject * parent)
:QObject(parent)
,mCurrentDocument(NULL)
{}
UBDocumentContainer::~UBDocumentContainer()
{
foreach(const QPixmap* pm, mDocumentThumbs)
delete pm;
}
void UBDocumentContainer::setDocument(UBDocumentProxy* document, bool forceReload)
{
if (mCurrentDocument != document || forceReload)
{
mCurrentDocument = document;
reloadThumbnails();
emit documentSet(mCurrentDocument);
}
}
void UBDocumentContainer::duplicatePages(QList<int>& pageIndexes)
{
int offset = 0;
foreach(int sceneIndex, pageIndexes)
{
UBPersistenceManager::persistenceManager()->duplicateDocumentScene(mCurrentDocument, sceneIndex + offset);
insertThumbPage(sceneIndex + offset);
offset++;
}
emit documentThumbnailsUpdated(this);
}
void UBDocumentContainer::movePageToIndex(int source, int target)
{
UBPersistenceManager::persistenceManager()->moveSceneToIndex(mCurrentDocument, source, target);
deleteThumbPage(source);
insertThumbPage(target);
emit documentThumbnailsUpdated(this);
}
void UBDocumentContainer::deletePages(QList<int>& pageIndexes)
{
UBPersistenceManager::persistenceManager()->deleteDocumentScenes(mCurrentDocument, pageIndexes);
int offset = 0;
foreach(int index, pageIndexes)
{
deleteThumbPage(index - offset);
offset++;
}
emit documentThumbnailsUpdated(this);
}
void UBDocumentContainer::addPage(int index)
{
UBPersistenceManager::persistenceManager()->createDocumentSceneAt(mCurrentDocument, index);
insertThumbPage(index);
emit documentThumbnailsUpdated(this);
}
void UBDocumentContainer::updatePage(int index)
{
updateThumbPage(index);
emit documentThumbnailsUpdated(this);
}
void UBDocumentContainer::deleteThumbPage(int index)
{
mDocumentThumbs.removeAt(index);
emit documentPageDeleted(index);
}
void UBDocumentContainer::updateThumbPage(int index)
{
mDocumentThumbs[index] = UBThumbnailAdaptor::get(mCurrentDocument, index);
emit documentPageUpdated(index);
}
void UBDocumentContainer::insertThumbPage(int index)
{
mDocumentThumbs.insert(index, UBThumbnailAdaptor::get(mCurrentDocument, index));
emit documentPageAdded(index);
}
void UBDocumentContainer::reloadThumbnails()
{
if (mCurrentDocument)
{
UBThumbnailAdaptor::load(mCurrentDocument, mDocumentThumbs);
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;
}
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef UBDOCUMENTCONTAINER_H_
#define UBDOCUMENTCONTAINER_H_
#include <QtGui>
#include "UBDocumentProxy.h"
class UBDocumentContainer : public QObject
{
Q_OBJECT
public:
UBDocumentContainer(QObject * parent = 0);
virtual ~UBDocumentContainer();
void setDocument(UBDocumentProxy* document, bool forceReload = false);
UBDocumentProxy* selectedDocument(){return mCurrentDocument;}
int pageCount(){return mDocumentThumbs.size();}
const QPixmap* pageAt(int index){return mDocumentThumbs[index];}
static int pageFromSceneIndex(int sceneIndex);
static int sceneIndexFromPage(int sceneIndex);
void duplicatePages(QList<int>& pageIndexes);
void movePageToIndex(int source, int target);
void deletePages(QList<int>& pageIndexes);
void addPage(int index);
void updatePage(int index);
private:
void deleteThumbPage(int index);
void updateThumbPage(int index);
void insertThumbPage(int index);
UBDocumentProxy* mCurrentDocument;
QList<const QPixmap*> mDocumentThumbs;
protected:
void reloadThumbnails();
signals:
void documentSet(UBDocumentProxy* document);
void documentPageAdded(int index);
void documentPageDeleted(int index);
void documentPageUpdated(int index);
void documentThumbnailsUpdated(UBDocumentContainer* source);
};
#endif /* UBDOCUMENTPROXY_H_ */
This diff is collapsed.
/* /*
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or * the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef UBDOCUMENTCONTROLLER_H_ #ifndef UBDOCUMENTCONTROLLER_H_
#define UBDOCUMENTCONTROLLER_H_ #define UBDOCUMENTCONTROLLER_H_
#include <QtGui> #include <QtGui>
#include "document/UBDocumentContainer.h"
namespace Ui
{ namespace Ui
class documents; {
} class documents;
}
#include "gui/UBMessageWindow.h"
#include "gui/UBMessageWindow.h"
class UBGraphicsScene;
class QDialog; class UBGraphicsScene;
class UBDocumentProxy; class QDialog;
class UBBoardController; class UBDocumentProxy;
class UBThumbnailsScene; class UBBoardController;
class UBDocumentGroupTreeItem; class UBThumbnailsScene;
class UBDocumentProxyTreeItem; class UBDocumentGroupTreeItem;
class UBMainWindow; class UBDocumentProxyTreeItem;
class UBDocumentToolsPalette; class UBMainWindow;
class UBDocumentToolsPalette;
class UBDocumentController : public QObject
{ class UBDocumentController : public UBDocumentContainer
Q_OBJECT; {
Q_OBJECT;
public:
UBDocumentController(UBMainWindow* mainWindow); public:
virtual ~UBDocumentController(); UBDocumentController(UBMainWindow* mainWindow);
virtual ~UBDocumentController();
void closing();
QWidget* controlView(); void closing();
UBDocumentProxyTreeItem* findDocument(UBDocumentProxy* proxy); QWidget* controlView();
bool addFileToDocument(UBDocumentProxy* document); UBDocumentProxyTreeItem* findDocument(UBDocumentProxy* proxy);
UBDocumentProxy* getCurrentDocument() { return mCurrentDocument; }; bool addFileToDocument(UBDocumentProxy* document);
void deletePages(QList<QGraphicsItem*> itemsToDelete); void deletePages(QList<QGraphicsItem*> itemsToDelete);
int getSelectedItemIndex(); int getSelectedItemIndex();
bool pageCanBeMovedUp(int page); bool pageCanBeMovedUp(int page);
bool pageCanBeMovedDown(int page); bool pageCanBeMovedDown(int page);
bool pageCanBeDuplicated(int page); bool pageCanBeDuplicated(int page);
bool pageCanBeDeleted(int page); bool pageCanBeDeleted(int page);
signals: signals:
void refreshThumbnails(); //void refreshThumbnails();
void exportDone(); void exportDone();
void movedToIndex(int index); //void movedToIndex(int index);
public slots: public slots:
void createNewDocument(); void createNewDocument();
void createNewDocumentGroup(); void createNewDocumentGroup();
void deleteSelectedItem(); void deleteSelectedItem();
void renameSelectedItem(); void renameSelectedItem();
void openSelectedItem(); void openSelectedItem();
void duplicateSelectedItem(); void duplicateSelectedItem();
void importFile(); void importFile();
void moveSceneToIndex(UBDocumentProxy* proxy, int source, int target); void moveSceneToIndex(UBDocumentProxy* proxy, int source, int target);
void selectDocument(UBDocumentProxy* proxy, bool setAsCurrentDocument = true); void selectDocument(UBDocumentProxy* proxy, bool setAsCurrentDocument = true);
void show(); void show();
void hide(); void hide();
void showMessage(const QString& message, bool showSpinningWheel); void showMessage(const QString& message, bool showSpinningWheel);
void hideMessage(); void hideMessage();
void toggleDocumentToolsPalette(); void toggleDocumentToolsPalette();
void cut(); void cut();
void copy(); void copy();
void paste(); void paste();
void focusChanged(QWidget *old, QWidget *current); void focusChanged(QWidget *old, QWidget *current);
void reloadThumbs(); //void reloadThumbs();
protected: protected:
virtual void setupViews(); virtual void setupViews();
virtual void setupToolbar(); virtual void setupToolbar();
void setupPalettes(); void setupPalettes();
bool isOKToOpenDocument(UBDocumentProxy* proxy); bool isOKToOpenDocument(UBDocumentProxy* proxy);
UBGraphicsScene* activeScene(); UBDocumentProxy* selectedDocumentProxy();
UBDocumentProxy* selectedDocumentProxy(); UBDocumentProxyTreeItem* selectedDocumentProxyTreeItem();
UBDocumentProxyTreeItem* selectedDocumentProxyTreeItem(); UBDocumentGroupTreeItem* selectedDocumentGroupTreeItem();
UBDocumentGroupTreeItem* selectedDocumentGroupTreeItem(); QStringList allGroupNames();
QStringList allGroupNames();
enum LastSelectedElementType
enum LastSelectedElementType {
{ None = 0, Folder, Document, Page
None = 0, Folder, Document, Page };
};
LastSelectedElementType mSelectionType;
LastSelectedElementType mSelectionType;
private:
private: QWidget *mParentWidget;
QWidget *mParentWidget; UBBoardController *mBoardController;
UBBoardController *mBoardController; Ui::documents* mDocumentUI;
Ui::documents* mDocumentUI; UBMainWindow* mMainWindow;
UBMainWindow* mMainWindow; QWidget *mDocumentWidget;
QWidget *mDocumentWidget; QPointer<UBMessageWindow> mMessageWindow;
QPointer<UBMessageWindow> mMessageWindow; QAction* mAddFolderOfImagesAction;
QAction* mAddFolderOfImagesAction; QAction* mAddFileToDocumentAction;
QAction* mAddFileToDocumentAction; QAction* mAddImagesAction;
QAction* mAddImagesAction; bool mIsClosing;
bool mIsClosing; UBDocumentToolsPalette *mToolsPalette;
UBDocumentToolsPalette *mToolsPalette; bool mToolsPalettePositionned;
bool mToolsPalettePositionned; UBDocumentGroupTreeItem* mTrashTi;
UBDocumentGroupTreeItem* mTrashTi;
UBDocumentProxy* mCurrentDocument; private slots:
QList<QPixmap> mDocumentThumbs; void documentZoomSliderValueChanged (int value);
void loadDocumentProxies();
private slots: void itemSelectionChanged();
void documentZoomSliderValueChanged (int value); void exportDocument();
void loadDocumentProxies(); void itemChanged(QTreeWidgetItem * item, int column);
void itemSelectionChanged(); void thumbnailViewResized();
void refreshDocumentThumbnailsView(); void pageSelectionChanged();
void exportDocument(); void selectionChanged();
void itemChanged(QTreeWidgetItem * item, int column); void documentSceneChanged(UBDocumentProxy* proxy, int pSceneIndex);
void thumbnailViewResized(); void pageDoubleClicked(QGraphicsItem* item, int index);
void pageSelectionChanged(); void pageClicked(QGraphicsItem* item, int index);
void selectionChanged(); void itemClicked(QTreeWidgetItem * item, int column );
void documentSceneChanged(UBDocumentProxy* proxy, int pSceneIndex); void addToDocument();
void pageDoubleClicked(QGraphicsItem* item, int index); void addDocumentInTree(UBDocumentProxy* pDocument);
void pageClicked(QGraphicsItem* item, int index); void updateDocumentInTree(UBDocumentProxy* pDocument);
void itemClicked(QTreeWidgetItem * item, int column ); void addFolderOfImages();
void addToDocument(); void addFileToDocument();
void addDocumentInTree(UBDocumentProxy* pDocument); void addImages();
void updateDocumentInTree(UBDocumentProxy* pDocument);
void addFolderOfImages(); void refreshDocumentThumbnailsView(UBDocumentContainer* source);
void addFileToDocument(); };
void addImages();
};
#endif /* UBDOCUMENTCONTROLLER_H_ */
#endif /* UBDOCUMENTCONTROLLER_H_ */
This diff is collapsed.
/* /*
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or * the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef UBDOCUMENTPROXY_H_ #ifndef UBDOCUMENTPROXY_H_
#define UBDOCUMENTPROXY_H_ #define UBDOCUMENTPROXY_H_
#include <QtGui> #include <QtGui>
#include "frameworks/UBStringUtils.h" #include "frameworks/UBStringUtils.h"
#include "core/UBSettings.h" #include "core/UBSettings.h"
class UBGraphicsScene; class UBGraphicsScene;
class UBDocumentProxy : public QObject class UBDocumentProxy : public QObject
{ {
Q_OBJECT; Q_OBJECT
public: friend class UBPersistenceManager;
UBDocumentProxy(); public:
UBDocumentProxy(const QString& pPersistencePath);
UBDocumentProxy();
virtual ~UBDocumentProxy(); UBDocumentProxy(const QString& pPersistencePath);
QString persistencePath() const; virtual ~UBDocumentProxy();
void setPersistencePath(const QString& pPersistencePath); QString persistencePath() const;
void setMetaData(const QString& pKey , const QVariant& pValue); void setPersistencePath(const QString& pPersistencePath);
QVariant metaData(const QString& pKey) const;
QHash<QString, QVariant> metaDatas() const; void setMetaData(const QString& pKey , const QVariant& pValue);
QVariant metaData(const QString& pKey) const;
QString name() const; QHash<QString, QVariant> metaDatas() const;
QString groupName() const;
QDateTime documentDate(); QString name() const;
QString groupName() const;
QDateTime lastUpdate(); QDateTime documentDate();
QDateTime lastUpdate();
QSize defaultDocumentSize() const;
void setDefaultDocumentSize(QSize pSize);
void setDefaultDocumentSize(int pWidth, int pHeight); QSize defaultDocumentSize() const;
void setDefaultDocumentSize(QSize pSize);
QUuid uuid() const; void setDefaultDocumentSize(int pWidth, int pHeight);
void setUuid(const QUuid& uuid);
QUuid uuid() const;
bool isModified() const; void setUuid(const QUuid& uuid);
int pageCount(); bool isModified() const;
void setPageCount(int pPageCount);
int incPageCount(); int pageCount();
int decPageCount();
protected:
signals: void setPageCount(int pPageCount);
void defaultDocumentSizeChanged(); int incPageCount();
int decPageCount();
private:
signals:
void init(); void defaultDocumentSizeChanged();
QString mPersistencePath; private:
QHash<QString, QVariant> mMetaDatas; void init();
bool mIsModified; QString mPersistencePath;
int mPageCount; QHash<QString, QVariant> mMetaDatas;
}; bool mIsModified;
inline bool operator==(const UBDocumentProxy &proxy1, const UBDocumentProxy &proxy2) int mPageCount;
{
return proxy1.persistencePath() == proxy2.persistencePath(); };
}
inline bool operator==(const UBDocumentProxy &proxy1, const UBDocumentProxy &proxy2)
inline uint qHash(const UBDocumentProxy &key) {
{ return proxy1.persistencePath() == proxy2.persistencePath();
return qHash(key.persistencePath()); }
}
inline uint qHash(const UBDocumentProxy &key)
{
#endif /* UBDOCUMENTPROXY_H_ */ return qHash(key.persistencePath());
}
#endif /* UBDOCUMENTPROXY_H_ */
HEADERS += src/document/UBDocumentController.h \ HEADERS += src/document/UBDocumentController.h \
src/document/UBDocumentContainer.h \
src/document/UBDocumentProxy.h src/document/UBDocumentProxy.h
SOURCES += src/document/UBDocumentController.cpp \ SOURCES += src/document/UBDocumentController.cpp \
src/document/UBDocumentContainer.cpp \
src/document/UBDocumentProxy.cpp src/document/UBDocumentProxy.cpp
\ No newline at end of file
...@@ -544,7 +544,6 @@ void UBGraphicsDelegateFrame::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) ...@@ -544,7 +544,6 @@ void UBGraphicsDelegateFrame::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
if(isResizing()){ if(isResizing()){
mResizing = false; mResizing = false;
} }
mDelegate->setButtonsVisible(true);
} }
......
...@@ -38,8 +38,6 @@ UBGraphicsMediaItem::UBGraphicsMediaItem(const QUrl& pMediaFileUrl, QGraphicsIte ...@@ -38,8 +38,6 @@ UBGraphicsMediaItem::UBGraphicsMediaItem(const QUrl& pMediaFileUrl, QGraphicsIte
{ {
update(); update();
QString s = pMediaFileUrl.toLocalFile();
mMediaObject = new Phonon::MediaObject(this); mMediaObject = new Phonon::MediaObject(this);
if (pMediaFileUrl.toLocalFile().contains("videos")) if (pMediaFileUrl.toLocalFile().contains("videos"))
{ {
...@@ -142,8 +140,8 @@ void UBGraphicsMediaItem::clearSource() ...@@ -142,8 +140,8 @@ void UBGraphicsMediaItem::clearSource()
{ {
QString path = mediaFileUrl().toLocalFile(); QString path = mediaFileUrl().toLocalFile();
//if path is absolute clean duplicated path string //if path is absolute clean duplicated path string
if (!path.contains(UBApplication::boardController->activeDocument()->persistencePath())) if (!path.contains(UBApplication::boardController->selectedDocument()->persistencePath()))
path = UBApplication::boardController->activeDocument()->persistencePath() + "/" + path; path = UBApplication::boardController->selectedDocument()->persistencePath() + "/" + path;
if (!UBFileSystemUtils::deleteFile(path)) if (!UBFileSystemUtils::deleteFile(path))
qDebug() << "cannot delete file: " << path; qDebug() << "cannot delete file: " << path;
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include "core/UBApplication.h" #include "core/UBApplication.h"
#include "board/UBBoardController.h" #include "board/UBBoardController.h"
#include "document/UBDocumentContainer.h"
#include "globals/UBGlobals.h" #include "globals/UBGlobals.h"
...@@ -334,7 +335,7 @@ QString UBFileSystemUtils::normalizeFilePath(const QString& pFilePath) ...@@ -334,7 +335,7 @@ QString UBFileSystemUtils::normalizeFilePath(const QString& pFilePath)
QString UBFileSystemUtils::digitFileFormat(const QString& s, int digit) QString UBFileSystemUtils::digitFileFormat(const QString& s, int digit)
{ {
int pageDigit = UBApplication::boardController->pageFromSceneIndex(digit); int pageDigit = UBDocumentContainer::pageFromSceneIndex(digit);
return s.arg(pageDigit, 3, 10, QLatin1Char('0')); return s.arg(pageDigit, 3, 10, QLatin1Char('0'));
} }
...@@ -534,6 +535,59 @@ QString UBFileSystemUtils::fileExtensionFromMimeType(const QString& pMimeType) ...@@ -534,6 +535,59 @@ QString UBFileSystemUtils::fileExtensionFromMimeType(const QString& pMimeType)
} }
UBMimeType::Enum UBFileSystemUtils::mimeTypeFromString(const QString& typeString)
{
UBMimeType::Enum type = UBMimeType::UNKNOWN;
if (typeString == "image/jpeg"
|| typeString == "image/png"
|| typeString == "image/gif"
|| typeString == "image/tiff"
|| typeString == "image/bmp")
{
type = UBMimeType::RasterImage;
}
else if (typeString == "image/svg+xml")
{
type = UBMimeType::VectorImage;
}
else if (typeString == "application/vnd.apple-widget")
{
type = UBMimeType::AppleWidget;
}
else if (typeString == "application/widget")
{
type = UBMimeType::W3CWidget;
}
else if (typeString.startsWith("video/"))
{
type = UBMimeType::Video;
}
else if (typeString.startsWith("audio/"))
{
type = UBMimeType::Audio;
}
else if (typeString.startsWith("application/x-shockwave-flash"))
{
type = UBMimeType::Flash;
}
else if (typeString.startsWith("application/pdf"))
{
type = UBMimeType::PDF;
}
else if (typeString.startsWith("application/vnd.mnemis-uniboard-tool"))
{
type = UBMimeType::UniboardTool;
}
return type;
}
UBMimeType::Enum UBFileSystemUtils::mimeTypeFromUrl(const QUrl& url)
{
return mimeTypeFromString(mimeTypeFromFileName(url.toString()));
}
QString UBFileSystemUtils::getFirstExistingFileFromList(const QString& path, const QStringList& files) QString UBFileSystemUtils::getFirstExistingFileFromList(const QString& path, const QStringList& files)
{ {
......
...@@ -18,6 +18,8 @@ ...@@ -18,6 +18,8 @@
#include <QtCore> #include <QtCore>
#include "core/UB.h"
class QuaZipFile; class QuaZipFile;
class UBProcessingProgressListener; class UBProcessingProgressListener;
...@@ -57,6 +59,10 @@ class UBFileSystemUtils ...@@ -57,6 +59,10 @@ class UBFileSystemUtils
static QString fileExtensionFromMimeType(const QString& pMimeType); static QString fileExtensionFromMimeType(const QString& pMimeType);
static UBMimeType::Enum mimeTypeFromString(const QString& typeString);
static UBMimeType::Enum mimeTypeFromUrl(const QUrl& url);
static QString normalizeFilePath(const QString& pFilePath); static QString normalizeFilePath(const QString& pFilePath);
static QString extension(const QString& filaname); static QString extension(const QString& filaname);
......
This diff is collapsed.
/* /*
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or * the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef UBDOCUMENTNAVIGATOR_H #ifndef UBDOCUMENTNAVIGATOR_H
#define UBDOCUMENTNAVIGATOR_H #define UBDOCUMENTNAVIGATOR_H
#include <QResizeEvent> #include <QResizeEvent>
#include <QGraphicsView> #include <QGraphicsView>
#include <QGraphicsScene> #include <QGraphicsScene>
#include <QMouseEvent> #include <QMouseEvent>
#include <QThread> #include <QThread>
#include "document/UBDocumentProxy.h" #include "document/UBDocumentProxy.h"
#include "UBThumbnailWidget.h" #include "document/UBDocumentContainer.h"
#include "UBThumbnailWidget.h"
#define NO_PAGESELECTED -1
#define NO_PAGESELECTED -1
class UBDocumentNavigator : public QGraphicsView
{ class UBDocumentNavigator : public QGraphicsView
Q_OBJECT {
public: Q_OBJECT
UBDocumentNavigator(QWidget* parent=0, const char* name="documentNavigator"); public:
~UBDocumentNavigator(); UBDocumentNavigator(QWidget* parent=0, const char* name="documentNavigator");
~UBDocumentNavigator();
void setDocument(UBDocumentProxy* document);
void setNbColumns(int nbColumns); void setNbColumns(int nbColumns);
int nbColumns(); int nbColumns();
void setThumbnailMinWidth(int width); void setThumbnailMinWidth(int width);
int thumbnailMinWidth(); int thumbnailMinWidth();
int selectedPageNumber();
UBDocumentProxy* currentDoc(); public slots:
void onScrollToSelectedPage(int index);// { if (mCrntItem) centerOn(mCrntItem); }
signals: void generateThumbnails(UBDocumentContainer* source);
void changeCurrentPage(); void updateSpecificThumbnail(int iPage);
public slots: protected:
void onMovedToIndex(int index); virtual void resizeEvent(QResizeEvent *event);
void onScrollToSelectedPage() { centerOn(mCrntItem); } virtual void mousePressEvent(QMouseEvent *event);
virtual void mouseReleaseEvent(QMouseEvent *event);
protected:
virtual void resizeEvent(QResizeEvent *event); private:
virtual void mousePressEvent(QMouseEvent *event);
void refreshScene();
private slots: int border();
void addNewPage();
void onSelectionChanged();
void generateThumbnails(); /** The scene */
QGraphicsScene* mScene;
private: /** The current selected item */
void refreshScene(); //UBSceneThumbnailNavigPixmap* mCrntItem;
void updateSpecificThumbnail(int iPage); /** The list of current thumbnails with labels*/
int border(); QList<UBImgTextThumbnailElement> mThumbsWithLabels;
/** The current number of columns */
int mNbColumns;
/** The scene */ /** The current thumbnails width */
QGraphicsScene* mScene; int mThumbnailWidth;
/** The current selected item */ /** The current thumbnails minimum width */
UBSceneThumbnailNavigPixmap* mCrntItem; int mThumbnailMinWidth;
/** The current document */ };
UBDocumentProxy* mCrntDoc;
/** The list of current thumbnails with labels*/ #endif // UBDOCUMENTNAVIGATOR_H
QList<UBImgTextThumbnailElement> mThumbsWithLabels;
/** The current number of columns */
int mNbColumns;
/** The current thumbnails width */
int mThumbnailWidth;
/** The current thumbnails minimum width */
int mThumbnailMinWidth;
/** A flag indicating that a thumbnail refresh is in progress */
bool bNavig;
};
#endif // UBDOCUMENTNAVIGATOR_H
This diff is collapsed.
This diff is collapsed.
...@@ -362,27 +362,52 @@ void UBFeaturesWidget::onDisplayMetadata( QMap<QString,QString> metadata ) ...@@ -362,27 +362,52 @@ void UBFeaturesWidget::onDisplayMetadata( QMap<QString,QString> metadata )
{ {
QString previewImageUrl; QString previewImageUrl;
previewImageUrl = ":images/libpalette/loading.png"; switch (UBFileSystemUtils::mimeTypeFromUrl(QUrl(metadata["Url"])))
{
case UBMimeType::RasterImage:
case UBMimeType::VectorImage:
{
previewImageUrl = ":images/libpalette/loading.png";
if (!imageGatherer) if (!imageGatherer)
imageGatherer = new UBDownloadHttpFile(0, this); imageGatherer = new UBDownloadHttpFile(0, this);
connect(imageGatherer, SIGNAL(downloadFinished(int, bool, QUrl, QString, QByteArray, QPointF, QSize, bool)), this, SLOT(onPreviewLoaded(int, bool, QUrl, QString, QByteArray, QPointF, QSize, bool))); connect(imageGatherer, SIGNAL(downloadFinished(int, bool, QUrl, QString, QByteArray, QPointF, QSize, bool)), this, SLOT(onPreviewLoaded(int, bool, QUrl, QString, QByteArray, QPointF, QSize, bool)));
// We send here the request and store its reply in order to be able to cancel it if needed // We send here the request and store its reply in order to be able to cancel it if needed
imageGatherer->get(QUrl(metadata["Url"]), QPoint(0,0), QSize(), false); imageGatherer->get(QUrl(metadata["Url"]), QPoint(0,0), QSize(), false);
} break;
case UBMimeType::Audio:
{
previewImageUrl = ":images/libpalette/soundIcon.svg";
}break;
case UBMimeType::Video:
{
previewImageUrl = ":images/libpalette/movieIcon.svg";
}break;
case UBMimeType::Flash:
{
previewImageUrl = ":images/libpalette/FlashIcon.svg";
}break;
}
UBFeature feature( QString(), QPixmap(previewImageUrl), QString(), metadata["Url"], FEATURE_ITEM ); UBFeature feature( QString(), QPixmap(previewImageUrl), QString(), metadata["Url"], FEATURE_ITEM );
feature.setMetadata( metadata ); feature.setMetadata( metadata );
featureProperties->showElement( feature ); featureProperties->showElement( feature );
switchToProperties(); switchToProperties();
mActionBar->setCurrentState( IN_PROPERTIES ); mActionBar->setCurrentState( IN_PROPERTIES );
} }
void UBFeaturesWidget::onPreviewLoaded(int id, bool pSuccess, QUrl sourceUrl, QString pContentTypeHeader, QByteArray pData, QPointF pPos, QSize pSize, bool isBackground) void UBFeaturesWidget::onPreviewLoaded(int id, bool pSuccess, QUrl sourceUrl, QString pContentTypeHeader, QByteArray pData, QPointF pPos, QSize pSize, bool isBackground)
{ {
Q_UNUSED(id);
Q_UNUSED(pSuccess);
Q_UNUSED(isBackground);
Q_UNUSED(pSize);
Q_UNUSED(pPos);
QImage img; QImage img;
img.loadFromData(pData); img.loadFromData(pData);
QPixmap pix = QPixmap::fromImage(img); QPixmap pix = QPixmap::fromImage(img);
...@@ -779,6 +804,7 @@ void UBFeatureProperties::setOrigPixmap(QPixmap &pix) ...@@ -779,6 +804,7 @@ void UBFeatureProperties::setOrigPixmap(QPixmap &pix)
void UBFeatureProperties::setThumbnail(QPixmap &pix) void UBFeatureProperties::setThumbnail(QPixmap &pix)
{ {
mpThumbnail->setPixmap(pix.scaledToWidth(THUMBNAIL_WIDTH)); mpThumbnail->setPixmap(pix.scaledToWidth(THUMBNAIL_WIDTH));
adaptSize();
} }
void UBFeatureProperties::adaptSize() void UBFeatureProperties::adaptSize()
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -245,7 +245,7 @@ void UBTeacherGuideEditionWidget::onActiveSceneChanged() ...@@ -245,7 +245,7 @@ void UBTeacherGuideEditionWidget::onActiveSceneChanged()
cleanData(); cleanData();
load(UBSvgSubsetAdaptor::readTeacherGuideNode(UBApplication::boardController->activeSceneIndex())); load(UBSvgSubsetAdaptor::readTeacherGuideNode(UBApplication::boardController->activeSceneIndex()));
mpPageNumberLabel->setText(tr("Page: %0").arg(currentPage)); mpPageNumberLabel->setText(tr("Page: %0").arg(currentPage));
UBDocumentProxy* documentProxy = UBApplication::boardController->activeDocument(); UBDocumentProxy* documentProxy = UBApplication::boardController->selectedDocument();
if(mpDocumentTitle) if(mpDocumentTitle)
mpDocumentTitle->setText(documentProxy->metaData(UBSettings::sessionTitle).toString()); mpDocumentTitle->setText(documentProxy->metaData(UBSettings::sessionTitle).toString());
} }
...@@ -483,7 +483,7 @@ void UBTeacherGuidePresentationWidget::onActiveSceneChanged() ...@@ -483,7 +483,7 @@ void UBTeacherGuidePresentationWidget::onActiveSceneChanged()
{ {
cleanData(); cleanData();
mpPageNumberLabel->setText(tr("Page: %0").arg(UBApplication::boardController->currentPage())); mpPageNumberLabel->setText(tr("Page: %0").arg(UBApplication::boardController->currentPage()));
UBDocumentProxy* documentProxy = UBApplication::boardController->activeDocument(); UBDocumentProxy* documentProxy = UBApplication::boardController->selectedDocument();
if(mpDocumentTitle) if(mpDocumentTitle)
mpDocumentTitle->setText(documentProxy->metaData(UBSettings::sessionTitle).toString()); mpDocumentTitle->setText(documentProxy->metaData(UBSettings::sessionTitle).toString());
} }
...@@ -535,9 +535,9 @@ void UBTeacherGuidePresentationWidget::showData(QVector<tUBGEElementNode*> data) ...@@ -535,9 +535,9 @@ void UBTeacherGuidePresentationWidget::showData(QVector<tUBGEElementNode*> data)
newWidgetItem->setData(0,Qt::FontRole, QVariant(QFont(QApplication::font().family(),11))); newWidgetItem->setData(0,Qt::FontRole, QVariant(QFont(QApplication::font().family(),11)));
QString mimeTypeString; QString mimeTypeString;
#ifdef Q_WS_WIN #ifdef Q_WS_WIN
mimeTypeString = QUrl::fromLocalFile(UBApplication::boardController->activeDocument()->persistencePath()+ "/" + element->attributes.value("relativePath")).toString(); mimeTypeString = QUrl::fromLocalFile(UBApplication::boardController->selectedDocument()->persistencePath()+ "/" + element->attributes.value("relativePath")).toString();
#else #else
mimeTypeString = UBApplication::boardController->activeDocument()->persistencePath()+ "/" + element->attributes.value("relativePath"); mimeTypeString = UBApplication::boardController->selectedDocument()->persistencePath()+ "/" + element->attributes.value("relativePath");
#endif #endif
newWidgetItem->setData(0, TG_USER_ROLE_MIME_TYPE, mimeTypeString); newWidgetItem->setData(0, TG_USER_ROLE_MIME_TYPE, mimeTypeString);
newWidgetItem->setFlags(Qt::ItemIsDragEnabled | Qt::ItemIsEnabled | Qt::ItemIsSelectable); newWidgetItem->setFlags(Qt::ItemIsDragEnabled | Qt::ItemIsEnabled | Qt::ItemIsSelectable);
...@@ -882,7 +882,7 @@ void UBTeacherGuidePageZeroWidget::onSchoolLevelChanged(QString schoolLevel) ...@@ -882,7 +882,7 @@ void UBTeacherGuidePageZeroWidget::onSchoolLevelChanged(QString schoolLevel)
void UBTeacherGuidePageZeroWidget::onActiveSceneChanged() void UBTeacherGuidePageZeroWidget::onActiveSceneChanged()
{ {
UBDocumentProxy* documentProxy = UBApplication::boardController->activeDocument(); UBDocumentProxy* documentProxy = UBApplication::boardController->selectedDocument();
if(documentProxy && UBApplication::boardController->currentPage() == 0){ if(documentProxy && UBApplication::boardController->currentPage() == 0){
QDateTime creationDate = documentProxy->documentDate(); QDateTime creationDate = documentProxy->documentDate();
mpCreationLabel->setText(tr("Created the:\n") + creationDate.toString(Qt::DefaultLocaleShortDate)); mpCreationLabel->setText(tr("Created the:\n") + creationDate.toString(Qt::DefaultLocaleShortDate));
...@@ -901,7 +901,7 @@ void UBTeacherGuidePageZeroWidget::hideEvent ( QHideEvent * event ) ...@@ -901,7 +901,7 @@ void UBTeacherGuidePageZeroWidget::hideEvent ( QHideEvent * event )
void UBTeacherGuidePageZeroWidget::loadData() void UBTeacherGuidePageZeroWidget::loadData()
{ {
UBDocumentProxy* documentProxy = UBApplication::boardController->activeDocument(); UBDocumentProxy* documentProxy = UBApplication::boardController->selectedDocument();
mpSessionTitle->setText(documentProxy->metaData(UBSettings::sessionTitle).toString()); mpSessionTitle->setText(documentProxy->metaData(UBSettings::sessionTitle).toString());
mpAuthors->setText(documentProxy->metaData(UBSettings::sessionAuthors).toString()); mpAuthors->setText(documentProxy->metaData(UBSettings::sessionAuthors).toString());
mpObjectives->setText(documentProxy->metaData(UBSettings::sessionObjectives).toString()); mpObjectives->setText(documentProxy->metaData(UBSettings::sessionObjectives).toString());
...@@ -925,7 +925,7 @@ void UBTeacherGuidePageZeroWidget::persistData() ...@@ -925,7 +925,7 @@ void UBTeacherGuidePageZeroWidget::persistData()
// check necessary because at document closing hide event is send after boardcontroller set // check necessary because at document closing hide event is send after boardcontroller set
// to NULL // to NULL
if(UBApplication::boardController){ if(UBApplication::boardController){
UBDocumentProxy* documentProxy = UBApplication::boardController->activeDocument(); UBDocumentProxy* documentProxy = UBApplication::boardController->selectedDocument();
documentProxy->setMetaData(UBSettings::sessionTitle,mpSessionTitle->text()); documentProxy->setMetaData(UBSettings::sessionTitle,mpSessionTitle->text());
documentProxy->setMetaData(UBSettings::sessionAuthors, mpAuthors->text()); documentProxy->setMetaData(UBSettings::sessionAuthors, mpAuthors->text());
documentProxy->setMetaData(UBSettings::sessionObjectives,mpObjectives->text()); documentProxy->setMetaData(UBSettings::sessionObjectives,mpObjectives->text());
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment