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

preferencesAboutTextFull
shibakaneki 13 years ago
commit f1d17b1a1d
  1. 16
      resources/library/interactive/WebBrowser.wgt/css/main.css
  2. 52
      resources/library/interactive/WebBrowser.wgt/index.html
  3. 4
      resources/library/interactive/Wikipedia.wgt/config.xml
  4. 140
      resources/library/interactive/Wikipedia.wgt/css/master.css
  5. 129
      resources/library/interactive/Wikipedia.wgt/index.html
  6. 5
      resources/library/interactive/Wikipedia.wgt/nbproject/private/private.properties
  7. 4
      resources/library/interactive/Wikipedia.wgt/nbproject/private/private.xml
  8. 7
      resources/library/interactive/Wikipedia.wgt/nbproject/project.properties
  9. 9
      resources/library/interactive/Wikipedia.wgt/nbproject/project.xml
  10. 44
      resources/library/interactive/Wiktionary.wgt/css/master.css
  11. 128
      resources/library/interactive/Wiktionary.wgt/index.html
  12. 5
      resources/library/interactive/Wiktionary.wgt/nbproject/private/private.properties
  13. 7
      resources/library/interactive/Wiktionary.wgt/nbproject/project.properties
  14. 9
      resources/library/interactive/Wiktionary.wgt/nbproject/project.xml
  15. 18
      src/core/UBApplicationController.cpp
  16. 3
      src/desktop/UBDesktopAnnotationController.cpp
  17. 23
      src/document/UBDocumentController.cpp
  18. 266
      src/gui/UBDocumentNavigator.cpp
  19. 3
      src/gui/UBDocumentNavigator.h
  20. 25
      src/gui/UBMainWindow.cpp
  21. 3
      src/gui/UBMainWindow.h

@ -179,4 +179,20 @@ body{
width:193px;
background-image:url(../imgs/right.png);
background-repeat:no-repeat;
}
.popupWordInfo{
position: absolute;
display: none;
width: 100px;
height: 17px;
top: 0;
left: 0;
text-align: center;
border: 1px solid #B9B9B9;
background-color: #eaebeb;
color: black;
font-family: Verdana,Arial,Helvetica,sans-serif;
font-size: small;
z-index: 100;
}

@ -22,6 +22,7 @@
$(document).ready(function(){
//var resizer; // Timer
//var resizerIndex;
var popupFlag = false;
var currentHistory = 0;
var references = new Array();
var globalWidth = 850;
@ -37,7 +38,8 @@
var resizer; // Timer
var resizerIndex;
var popupText = $("<div id='popupWordInfo' class='popupWordInfo'></div>").appendTo("body");
resizerIndex = 0;
if(window.sankore){
@ -66,7 +68,53 @@
$("#search-button").trigger("click");
}
});
$("#search-button").mouseover(function(evt){
popupFlag = true;
popupText.css("top", evt.pageY + 5)
.css("left", evt.pageX + 13)
.css({width:"100px"})
.text("Go to the site")
.show("fast", function(){
if(!popupFlag)
popupText.hide();
});
});
$("#back-button").mouseover(function(evt){
popupFlag = true;
popupText.css("top", evt.pageY + 5)
.css("left", evt.pageX + 13)
.css({width:"90px"})
.text("Previous site")
.show("fast", function(){
if(!popupFlag)
popupText.hide();
});
});
$("#forward-button").mouseover(function(evt){
popupFlag = true;
popupText.css("top", evt.pageY + 5)
.css("left", evt.pageX + 13)
.css({width:"70px"})
.text("Next site")
.show("fast", function(){
if(!popupFlag)
popupText.hide();
});
});
$("#search-button, #back-button, #forward-button").mousemove(function(evt){
popupText.css("top", evt.pageY + 5)
.css("left", evt.pageX + 13);
});
$("#search-button, #back-button, #forward-button").mouseout(function(evt){
popupText.hide();
popupFlag = false;
});
$("#textbox").keypress(function(e) {
if(e.keyCode == 13) {
$("#search-button").trigger("click");

@ -3,8 +3,8 @@
xmlns:ub="http://uniboard.mnemis.com/widgets"
identifier="http://uniboard.mnemis.com/widgets/wikipedia"
version="1.2"
width="350"
height="450"
width="370"
height="400"
ub:resizable = "true">
<name>Wikipedia</name>

@ -1,70 +1,70 @@
body{
font-family:helvetica, arial, sans-serif;
font-size:12px;
font-family:helvetica, arial, sans-serif;
font-size:12px;
}
.on-the-right{
width:0px;
position:absolute;
top:0;
overflow:visible;
margin-left:100%;
width:0px;
position:absolute;
top:0;
overflow:visible;
margin-left:100%;
}
.toolbar{
background-image:url(../images/toolbarBody.png);
padding-left:4px;
border:1px solid #cccccc;
border-bottom:1px solid #ffffff;
position:relative;
background-image:url(../images/toolbarBody.png);
padding-left:4px;
border:1px solid #cccccc;
border-bottom:1px solid #ffffff;
position:relative;
}
.toolbar>div>.button{
width:29px;
height:24px;
float:left;
margin-right:4px;
margin-top:0px;
cursor:pointer;
width:29px;
height:24px;
float:left;
margin-right:4px;
margin-top:0px;
cursor:pointer;
}
#toolbar-down{
font-size:18px;
font-weight:bold;
color:#333333;
text-align:center;
font-family:helvetica, arial, sans-serif;
text-shadow: #ffffff 0px 1px 1px;
font-size:18px;
font-weight:bold;
color:#333333;
text-align:center;
font-family:helvetica, arial, sans-serif;
text-shadow: #ffffff 0px 1px 1px;
}
#url{
height:20px;
float:left;
border:1px solid #b9b9b9;
padding-right:4%;
width:80%;
height:20px;
float:left;
border:1px solid #b9b9b9;
padding-right:4%;
width:80%;
}
#left-field{
float:left;
float:left;
}
#right-field{
float:right;
float:right;
}
#center-field{
display:block-inline;
position:relative;
display:block-inline;
position:relative;
}
#center-field.min{
margin-right:6px;
margin-right:6px;
}
#center-field.full{
margin-right:78px;
margin-left:65px;
margin-right:78px;
margin-left:65px;
}
#web-canevas {
@ -79,20 +79,20 @@ body{
}
.toolbar-body {
display: table;
width: 100%;
height: 37px;
display: table;
width: 100%;
height: 37px;
/* IE hacks */
position: relative !ie7;
/* IE hacks */
position: relative !ie7;
}
.toolbar-body>div {
display: table-cell;
vertical-align: middle;
display: table-cell;
vertical-align: middle;
/* IE hacks */
position: absolute !ie7;
top: 50% !ie7;
/* IE hacks */
position: absolute !ie7;
top: 50% !ie7;
}
#toolbar-button-back{ background-image:url(../images/toolbarButtonBack.png) }
@ -101,19 +101,49 @@ body{
#toolbar-button-languages{ background-image:url(../images/toolbarButtonLanguages.png) }
#toolbar-button-search{
width:22px;
height:22px;
position:relative;
margin-left:-22px;
background-image:url(../images/toolbarButtonSearch.png);
background-repeat:no-repeat;
background-position:center center;
float: left;
width:22px;
height:22px;
position:relative;
margin-left:-32px;
background-image:url(../images/toolbarButtonSearch.png);
background-repeat:no-repeat;
background-position:center center;
border: 1px solid #B9B9B9;
-webkit-border-radius: 5px;
border-radius: 5px;
-webkit-box-shadow: #dadada -1px 0 4px;
box-shadow: #dadada -1px 0 4px;
}
#toolbar-button-search:hover{
border: 1px solid #666666;
}
#toolbar-button-languages{
width:66px;
width:66px;
}
#toolbar-button-back{
margin-right:0px;
margin-right:0px;
}
.popupWordInfo{
position: absolute;
display: none;
width: 100px;
height: 17px;
top: 0;
left: 0;
text-align: center;
border: 1px solid #B9B9B9;
background-color: #eaebeb;
color: black;
font-family: Verdana,Arial,Helvetica,sans-serif;
-webkit-border-radius: 5px;
border-radius: 5px;
-webkit-box-shadow: #dadada -1px 0 4px;
box-shadow: #dadada -1px 0 4px;
z-index: 100;
font-family: Arial,Helvetica,sans-serif;
}

@ -13,7 +13,8 @@
<script type="text/javascript" src="script/superfish.js"></script>
<script type="text/javascript">
var popupFlag = false
var browsing = false;
var lang = 'en';
var internalChange = false;
@ -37,24 +38,26 @@
},
index:-1
}
$(document).ready(function() {
var ubHistoryList = "";
var ubHistoryIndex = "";
var popupText = $("<div id='popupWordInfo' class='popupWordInfo'></div>").appendTo("body");
lang = navigator.userAgent.split(";");
lang = (navigator.language || navigator.systemLanguage ||
navigator.userLanguage || 'en').substr(0, 2).toLowerCase();
$("#current-language").text(lang.charAt(0).toUpperCase() + lang.substr(1));
if(window.sankore){
toolbar.state = loadPref("historyState", "begin");
ubHistoryList = loadPref("historyList", "");
ubHistoryIndex = loadPref("historyIndex", "-1");
}
if(ubHistoryList !== "") {
appHistory.list = ubHistoryList.split(",");
appHistory.index = parseInt(ubHistoryIndex);
@ -62,22 +65,22 @@
} else {
wikiReq("");
}
$(window).resize();
$("#languages-dropdown>li>ul>li").each(function(){
$(this).click(function(){
languagesHandler($(this).text());
$("#current-language").text(lang.charAt(0).toUpperCase() + lang.substr(1));
});
});
$("#languages-dropdown").superfish({
dropShadows:false,
speed:1,
delay:100
});
$("#url")
.change(function(){
if(!toolbar.loading){
@ -90,42 +93,92 @@
$("#url").change();
};
});
$("#url").val(appHistory.list[appHistory.index]);
$("#toolbar-button-search").click(function(){
$("#url").trigger("change");
});
$("#toolbar-button-search").mouseover(function(evt){
popupFlag = true;
popupText.text("Search")
.css("top", evt.pageY + 5)
.css("left", evt.pageX + 13)
.css({width:"70px"})
.show("fast", function(){
if(!popupFlag)
popupText.hide();
});
});
$("#toolbar-button-search, #toolbar-button-back, #toolbar-button-forward").mousemove(function(evt){
popupText.css("top", evt.pageY + 5)
.css("left", evt.pageX + 13);
});
$("#toolbar-button-search, #toolbar-button-back, #toolbar-button-forward").mouseout(function(evt){
popupFlag = false;
popupText.hide();
});
$("#url").val(appHistory.list[appHistory.index]);
if($("#url").val().length > 0)
$("#url").change();
$("#toolbar-button-back").click(function(){
browsing = true;
appHistory.back();
});
$("#toolbar-button-back").mouseover(function(evt){
popupFlag = true;
popupText.text("Previous word")
.css("top", evt.pageY + 5)
.css("left", evt.pageX + 13)
.css({width:"100px"})
.show("fast", function(){
if(!popupFlag)
popupText.hide();
});
});
$("#toolbar-button-forward").click(function(){
browsing = true;
appHistory.forward();
});
$("#toolbar-button-forward").mouseover(function(evt){
popupFlag = true;
popupText.text("Next word")
.css("top", evt.pageY + 5)
.css("left", evt.pageX + 13)
.css({width:"70px"})
.show("fast", function(){
if(!popupFlag)
popupText.hide();
});
});
$("#toolbar-button-home").click(function(){
});
});
$(window).resize(function(){
$("#web-browser").height($(window).height() - $("#toolbar").height() - 2);
$("#web-browser").width($(window).width() - 2);
if($(window).width() < 280){
window.resizeTo(280, $(window).height());
}
});
function wikiReq(kword){
var textBoxInput = "";
textBoxInput = remacc(kword.replace(/ /g,'+'));
textBoxInput = textBoxInput.replace(textBoxInput.charAt(0),textBoxInput.charAt(0).toUpperCase());
if(toolbar.state == "begin"){
$('#web-browser').attr('src',"");
@ -137,25 +190,25 @@
$('#toolbar-button-search').css("background-image", "url(images/toolbarLoading.jpg)");
toolbar.loading = true;
}
function hideLoading(){
$('#toolbar-button-search').css("background-image", "url(images/toolbarButtonSearch.png)");
toolbar.loading = false;
// History
if(appHistory.list[appHistory.index] !== $("#url").val() && !browsing && $("#url").val().length > 0){
appHistory.list = appHistory.list.slice(0, appHistory.index+1);
appHistory.list[appHistory.index+1] = $("#url").val();
appHistory.index = appHistory.list.length-1;
}
if(window.sankore && $("#web-browser").attr("src") !== ""){
savePref("historyState", "started");
savePref("historyList", appHistory.list.toString());
savePref("historyIndex", appHistory.index)
}
}
String.prototype.accnt = function(){
var cnt = 0;
var acnt = this;
@ -167,7 +220,7 @@
cnt++;
return cnt;
}
String.prototype.renlacc = function(){
var torem = this;
torem = torem.split('');
@ -184,9 +237,9 @@
document.title = toascout;
return toascout;
}
function remacc(kword){
var countarr = new Array();
var c = '';
var text=kword;
@ -201,21 +254,21 @@
textout = textout.join('\n');
return textout;
}
function loadPref(name, defaultValue){
var pref = defaultValue;
if (sankore.preference(name) !== "") {
pref = sankore.preference(name);
};
return pref;
};
function savePref(name, value){
sankore.setPreference(name, String(value));
};
function languagesHandler(language){
switch(language){
case "Deutsch":
@ -250,7 +303,7 @@
break;
}
};
</script>
</head>
<body style="overflow:hidden; margin: 0px; width:100%; height:100%; position:absolute; background:#ffffff">
@ -274,9 +327,9 @@
</div>
<div id="center-field" class="full">
<input type="text" id="url" alt="url"/>
<div class="on-the-right">
<div id="toolbar-button-search"></div>
</div>
<div class="on-the-right">
<div id="toolbar-button-search"></div>
</div>
</div> <!--center-field-->
<div id="right-field">
<div id="toolbar-button-languages" class="button" alt="languages button">

@ -1,5 +0,0 @@
copy.src.files=false
copy.src.target=
index.file=index.html
run.as=LOCAL
url=http://localhost/Wikipedia.wgt/

@ -1,4 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project-private xmlns="http://www.netbeans.org/ns/project-private/1">
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/1"/>
</project-private>

@ -1,7 +0,0 @@
include.path=${php.global.include.path}
php.version=PHP_5
source.encoding=UTF-8
src.dir=.
tags.asp=false
tags.short=true
web.root=.

@ -1,9 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://www.netbeans.org/ns/project/1">
<type>org.netbeans.modules.php.project</type>
<configuration>
<data xmlns="http://www.netbeans.org/ns/php-project/1">
<name>Wikipedia.wgt</name>
</data>
</configuration>
</project>

@ -101,13 +101,23 @@ body{
#toolbar-button-languages{ background-image:url(../images/toolbarButtonLanguages.png) }
#toolbar-button-search{
width:22px;
height:22px;
position:relative;
margin-left:-22px;
background-image:url(../images/toolbarButtonSearch.png);
background-repeat:no-repeat;
background-position:center center;
float: left;
width:22px;
height:22px;
position:relative;
margin-left:-32px;
background-image:url(../images/toolbarButtonSearch.png);
background-repeat:no-repeat;
background-position:center center;
border: 1px solid #B9B9B9;
-webkit-border-radius: 5px;
border-radius: 5px;
-webkit-box-shadow: #dadada -1px 0 4px;
box-shadow: #dadada -1px 0 4px;
}
#toolbar-button-search:hover{
border: 1px solid #666666;
}
#toolbar-button-languages{
@ -116,4 +126,24 @@ body{
#toolbar-button-back{
margin-right:0px;
}
.popupWordInfo{
position: absolute;
display: none;
width: 100px;
height: 17px;
top: 0;
left: 0;
text-align: center;
border: 1px solid #B9B9B9;
background-color: #eaebeb;
color: black;
font-family: Verdana,Arial,Helvetica,sans-serif;
-webkit-border-radius: 5px;
border-radius: 5px;
-webkit-box-shadow: #dadada -1px 0 4px;
box-shadow: #dadada -1px 0 4px;
z-index: 100;
font-family: Arial,Helvetica,sans-serif;
}

@ -1,4 +1,3 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml">
<head>
@ -13,7 +12,8 @@
<script type="text/javascript" src="script/superfish.js"></script>
<script type="text/javascript">
var popupFlag = false;
var browsing = false;
var mode = 'wiki';
var lang = 'en';
@ -38,25 +38,27 @@
},
index:-1
}
$(document).ready(function() {
var ubHistoryList = "";
var ubHistoryIndex = "";
var popupText = $("<div id='popupWordInfo' class='popupWordInfo'></div>").appendTo("body");
lang = navigator.userAgent.split(";");
lang = (navigator.language || navigator.systemLanguage ||
navigator.userLanguage || 'en').substr(0, 2).toLowerCase();
$("#current-language").text(lang.charAt(0).toUpperCase() + lang.substr(1));
if(window.sankore){
toolbar.state = loadPref("historyState", "begin");
ubHistoryList = loadPref("historyList", "");
ubHistoryIndex = loadPref("historyIndex", "-1");
//window.resizeTo(350, 450);
}
if(ubHistoryList !== "") {
appHistory.list = ubHistoryList.split(",");
appHistory.index = parseInt(ubHistoryIndex);
@ -64,22 +66,22 @@
} else {
wikiReq("");
}
$(window).resize();
$("#languages-dropdown>li>ul>li").each(function(){
$(this).click(function(){
languagesHandler($(this).text());
$("#current-language").text(lang.charAt(0).toUpperCase() + lang.substr(1));
});
});
$("#languages-dropdown").superfish({
dropShadows:false,
speed:1,
delay:100
});
$("#url")
.change(function(){
if(!toolbar.loading){
@ -92,26 +94,76 @@
$("#url").change();
};
});
$("#url").val(appHistory.list[appHistory.index]);
if($("#url").val().length > 0)
$("#url").change();
$("#toolbar-button-search").click(function(){
$("#url").trigger("change");
});
$("#toolbar-button-search").mouseover(function(evt){
popupFlag = true;
popupText.text("Search")
.css("top", evt.pageY + 5)
.css("left", evt.pageX + 13)
.css({width:"70px"})
.show("fast", function(){
if(!popupFlag)
popupText.hide();
});
});
$("#toolbar-button-search, #toolbar-button-back, #toolbar-button-forward").mousemove(function(evt){
popupText.css("top", evt.pageY + 5)
.css("left", evt.pageX + 13);
});
$("#toolbar-button-search, #toolbar-button-back, #toolbar-button-forward").mouseout(function(evt){
popupFlag = false;
popupText.hide();
});
$("#toolbar-button-back").click(function(){
browsing = true;
appHistory.back();
});
$("#toolbar-button-back").mouseover(function(evt){
popupFlag = true;
popupText.text("Previous word")
.css("top", evt.pageY + 5)
.css("left", evt.pageX + 13)
.css({width:"100px"})
.show("fast", function(){
if(!popupFlag)
popupText.hide();
});
});
$("#toolbar-button-forward").click(function(){
browsing = true;
appHistory.forward();
});
$("#toolbar-button-forward").mouseover(function(evt){
popupFlag = true;
popupText.text("Next word")
.css("top", evt.pageY + 5)
.css("left", evt.pageX + 13)
.css({width:"70px"})
.show("fast", function(){
if(!popupFlag)
popupText.hide();
});
});
$("#toolbar-button-home").click(function(){
});
});
$(window).resize(function(){
if($(window).width() < 300){
@ -121,15 +173,15 @@
$("#web-browser").width($(window).width() - 2);
} else
$("#web-browser").height($(window).height() - $("#toolbar").height() - 2);
});
function wikiReq(kword){
var textBoxInput = "";
textBoxInput = remacc(kword.replace(/ /g,'_'));
textBoxInput = textBoxInput.replace(textBoxInput.charAt(0),textBoxInput.charAt(0).toLowerCase());
if(toolbar.state == "begin"){
$('#web-browser').attr('src',"");
@ -141,25 +193,25 @@
$('#toolbar-button-search').css("background-image", "url(images/toolbarLoading.jpg)");
toolbar.loading = true;
}
function hideLoading(){
$('#toolbar-button-search').css("background-image", "url(images/toolbarButtonSearch.png)");
toolbar.loading = false;
// History
if(appHistory.list[appHistory.index] !== $("#url").val() && !browsing && $("#url").val().length > 0){
appHistory.list = appHistory.list.slice(0, appHistory.index+1);
appHistory.list[appHistory.index+1] = $("#url").val();
appHistory.index = appHistory.list.length-1;
}
if(window.sankore && $("#web-browser").attr("src") !== ""){
savePref("historyState", "started");
savePref("historyList", appHistory.list.toString());
savePref("historyIndex", appHistory.index)
}
}
String.prototype.accnt = function(){
var cnt = 0;
var acnt = this;
@ -171,7 +223,7 @@
cnt++;
return cnt;
}
String.prototype.renlacc = function(){
var torem = this;
torem = torem.split('');
@ -188,9 +240,9 @@
document.title = toascout;
return toascout;
}
function remacc(kword){
var countarr = new Array();
var c = '';
var text=kword;
@ -205,21 +257,21 @@
textout = textout.join('\n');
return textout;
}
function loadPref(name, defaultValue){
var pref = defaultValue;
if (sankore.preference(name) !== "") {
pref = sankore.preference(name);
};
return pref;
};
function savePref(name, value){
sankore.setPreference(name, String(value));
};
function languagesHandler(language){
switch(language){
case "Deutsch":
@ -254,7 +306,7 @@
break;
}
};
</script>
</head>
<body style="overflow:hidden; margin: 0px; width:100%; height:100%; position:absolute; background:#ffffff">
@ -278,9 +330,9 @@
</div>
<div id="center-field" class="full">
<input type="text" id="url" alt="url"/>
<div class="on-the-right">
<div id="toolbar-button-search"></div>
</div>
<div class="on-the-right">
<div id="toolbar-button-search"></div>
</div>
</div> <!--center-field-->
<div id="right-field">
<div id="toolbar-button-languages" class="button" alt="languages button">

@ -1,5 +0,0 @@
copy.src.files=false
copy.src.target=
index.file=index.html
run.as=LOCAL
url=http://localhost/Wiktionary.wgt/

@ -1,7 +0,0 @@
include.path=${php.global.include.path}
php.version=PHP_53
source.encoding=UTF-8
src.dir=.
tags.asp=false
tags.short=true
web.root=.

@ -1,9 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://www.netbeans.org/ns/project/1">
<type>org.netbeans.modules.php.project</type>
<configuration>
<data xmlns="http://www.netbeans.org/ns/php-project/1">
<name>Wiktionary.wgt</name>
</data>
</configuration>
</project>

@ -520,7 +520,7 @@ void UBApplicationController::ftpCommandFinished(int id, bool error)
}
else{
QString responseString = QString(mFtp->readAll());
if (!responseString.isEmpty() && responseString.contains("version:") && responseString.contains("url:")){
if (!responseString.isEmpty() && responseString.contains("version") && responseString.contains("url")){
mFtp->close();
downloadJsonFinished(responseString);
}
@ -539,23 +539,9 @@ void UBApplicationController::downloadJsonFinished(QString currentJson)
UBVersion jsonVersion (scriptValue.property("version").toString().left(4));
if (installedVersion.isValid() && jsonVersion.isValid() && jsonVersion > installedVersion) {
QMessageBox msgBox;
msgBox.setText (tr ("New update available, would you go to the web page ?"));
msgBox.setStandardButtons (QMessageBox::Ok | QMessageBox::Cancel);
msgBox.setDefaultButton (QMessageBox::Ok);
int ret = msgBox.exec();
switch (ret) {
case QMessageBox::Ok: {
if (UBApplication::mainWindow->yesNoQuestion(tr("Update available"), tr ("New update available, would you go to the web page ?"))){
QUrl url(scriptValue.property ("url").toString());
QDesktopServices::openUrl (url);
break;
}
case QMessageBox::Cancel:
// do nothing
break;
default:
// should never be reached
break;
}
}
else {

@ -433,7 +433,10 @@ void UBDesktopAnnotationController::customCapture()
UBCustomCaptureWindow customCaptureWindow(mDesktopPalette);
// need to show the window before execute it to avoid some glitch on windows.
#ifndef Q_WS_WIN // Working only without this call on win32 desktop mode
customCaptureWindow.show();
#endif
if (customCaptureWindow.execute(getScreenPixmap()) == QDialog::Accepted)
{

@ -476,7 +476,6 @@ void UBDocumentController::showKeyboard(bool show)
mKeyboardPalette->setVisible(show);
}
// mPaletteManager->showVirtualKeyboard(show);
}
void UBDocumentController::setupPalettes()
@ -640,10 +639,7 @@ void UBDocumentController::deleteSelectedItem()
}
}
if (QMessageBox::question( 0, tr("Remove Page"),
tr("Are you sure you want to remove %n page(s) from the selected document '%1'?", "", sceneIndexes.count())
.arg(proxy->metaData(UBSettings::documentName).toString()),
QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes)
if(UBApplication::mainWindow->yesNoQuestion(tr("Remove Page"), tr("Are you sure you want to remove %n page(s) from the selected document '%1'?", "", sceneIndexes.count()).arg(proxy->metaData(UBSettings::documentName).toString())))
{
UBPersistenceManager::persistenceManager()->deleteDocumentScenes(proxy, sceneIndexes);
proxy->setMetaData(UBSettings::documentUpdatedAt, UBStringUtils::toUtcIsoDateTime(QDateTime::currentDateTime()));
@ -668,9 +664,7 @@ void UBDocumentController::deleteSelectedItem()
if (proxyTi && proxyTi->proxy() && proxyTi->parent())
{
if (QMessageBox::question( 0, tr("Remove Document"),
tr("Are you sure you want to remove the document '%1'?").arg(proxyTi->proxy()->metaData(UBSettings::documentName).toString()),
QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes)
if(UBApplication::mainWindow->yesNoQuestion(tr("Remove Document"), tr("Are you sure you want to remove the document '%1'?").arg(proxyTi->proxy()->metaData(UBSettings::documentName).toString())))
{
if (proxyTi->parent() == mTrashTi)
{
@ -737,9 +731,7 @@ void UBDocumentController::deleteSelectedItem()
{
if (groupTi == mTrashTi)
{
if (QMessageBox::question( 0, tr("Empty Trash"),
tr("Are you sure you want to empty trash?"),
QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes)
if(UBApplication::mainWindow->yesNoQuestion(tr("Empty Trash"), tr("Are you sure you want to empty trash?")))
{
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
QList<UBDocumentProxyTreeItem*> toBeDeleted;
@ -769,9 +761,7 @@ void UBDocumentController::deleteSelectedItem()
}
else
{
if (QMessageBox::question( 0, tr("Remove Folder"),
tr("Are you sure you want to remove the folder '%1' and all its content?").arg(groupTi->groupName()),
QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes)
if(UBApplication::mainWindow->yesNoQuestion(tr("Remove Folder"), tr("Are you sure you want to remove the folder '%1' and all its content?").arg(groupTi->groupName())))
{
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
@ -1483,11 +1473,10 @@ bool UBDocumentController::isOKToOpenDocument(UBDocumentProxy* proxy)
}
else
{
if (QMessageBox::question( 0, tr("Open Document"),
if (UBApplication::mainWindow->yesNoQuestion(tr("Open Document"),
tr("The document '%1' has been generated with a newer version of Sankore (%2). By opening it, you may lose some information. Do you want to proceed?")
.arg(proxy->metaData(UBSettings::documentName).toString())
.arg(docVersion),
QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes)
.arg(docVersion)))
{
return true;
}

@ -37,13 +37,13 @@
* @param name as the object name
*/
UBDocumentNavigator::UBDocumentNavigator(QWidget *parent, const char *name):QGraphicsView(parent)
, mScene(NULL)
, mCrntItem(NULL)
, mCrntDoc(NULL)
, mNbColumns(1)
, mThumbnailWidth(0)
, mThumbnailMinWidth(100)
, bNavig(false)
, mScene(NULL)
, mCrntItem(NULL)
, mCrntDoc(NULL)
, mNbColumns(1)
, mThumbnailWidth(0)
, mThumbnailMinWidth(100)
, bNavig(false)
{
setObjectName(name);
mScene = new QGraphicsScene(this);
@ -54,6 +54,7 @@ UBDocumentNavigator::UBDocumentNavigator(QWidget *parent, const char *name):QGra
setFrameShadow(QFrame::Plain);
connect(UBApplication::boardController, SIGNAL(activeSceneChanged()), this, SLOT(addNewPage()));
connect(UBApplication::boardController, SIGNAL(setDocOnPageNavigator(UBDocumentProxy*)), this, SLOT(generateThumbnails()));
connect(mScene, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged()));
}
@ -64,14 +65,14 @@ UBDocumentNavigator::~UBDocumentNavigator()
{
if(NULL != mCrntItem)
{
delete mCrntItem;
mCrntItem = NULL;
delete mCrntItem;
mCrntItem = NULL;
}
if(NULL != mScene)
{
delete mScene;
mScene = NULL;
delete mScene;
mScene = NULL;
}
}
@ -85,8 +86,8 @@ void UBDocumentNavigator::setDocument(UBDocumentProxy *document)
// content and add all the pages of the given document.
if(document)
{
mCrntDoc = document;
generateThumbnails();
mCrntDoc = document;
generateThumbnails();
}
}
@ -105,20 +106,19 @@ void UBDocumentNavigator::generateThumbnails()
for(int i = 0; i < thumbs.count(); i++)
{
QPixmap pix = thumbs.at(i);
QGraphicsPixmapItem* pixmapItem = new UBSceneThumbnailPixmap(pix, mCrntDoc, i);
QPixmap pix = thumbs.at(i);
QGraphicsPixmapItem* pixmapItem = new UBSceneThumbnailPixmap(pix, mCrntDoc, i);
// Get the selected item
// Get the selected item
if(UBApplication::boardController->activeSceneIndex() == i)
{
selection = pixmapItem;
mCrntItem = dynamic_cast<UBSceneThumbnailPixmap*>(pixmapItem);
mCrntItem->setSelected(true);
}
items << pixmapItem;
labels << tr("Page %0").arg(i + 1);
//itemsPath.append(QUrl::fromLocalFile(mCrntDoc->persistencePath() + QString("/pages/%0").arg(i + 1)));
{
selection = pixmapItem;
mCrntItem = dynamic_cast<UBSceneThumbnailPixmap*>(pixmapItem);
mCrntItem->setSelected(true);
}
items << pixmapItem;
labels << tr("Page %0").arg(i + 1);
}
// Draw the items
@ -136,27 +136,27 @@ void UBDocumentNavigator::updateSpecificThumbnail(int iPage)
if(NULL != pScene)
{
// Save the current state of the scene
pScene->setModified(true);
UBSvgSubsetAdaptor::persistScene(mCrntDoc,pScene, iPage);
UBThumbnailAdaptor::persistScene(mCrntDoc->persistencePath(), pScene, iPage);
// Load it
QList<QPixmap> thumbs = UBThumbnailAdaptor::load(mCrntDoc);
QPixmap pix = thumbs.at(iPage);
QGraphicsPixmapItem* pixmapItem = new UBSceneThumbnailPixmap(pix, mCrntDoc, iPage);
if(pixmapItem)
{
// Get the old thumbnail
QGraphicsItem* pItem = mThumbnails.at(iPage);
if(NULL != pItem)
{
mScene->removeItem(pItem);
mScene->addItem(pixmapItem);
mThumbnails.replace(iPage, pixmapItem);
}
}
// Save the current state of the scene
pScene->setModified(true);
UBSvgSubsetAdaptor::persistScene(mCrntDoc,pScene, iPage);
UBThumbnailAdaptor::persistScene(mCrntDoc->persistencePath(), pScene, iPage);
// Load it
QList<QPixmap> thumbs = UBThumbnailAdaptor::load(mCrntDoc);
QPixmap pix = thumbs.at(iPage);
QGraphicsPixmapItem* pixmapItem = new UBSceneThumbnailPixmap(pix, mCrntDoc, iPage);
if(pixmapItem)
{
// Get the old thumbnail
QGraphicsItem* pItem = mThumbnails.at(iPage);
if(NULL != pItem)
{
mScene->removeItem(pItem);
mScene->addItem(pixmapItem);
mThumbnails.replace(iPage, pixmapItem);
}
}
}
}
@ -171,10 +171,10 @@ void UBDocumentNavigator::addNewPage()
if(!bNavig)
{
generateThumbnails();
if(NULL != mCrntItem)
{
if(NULL != mCrntItem)
{
mCrntItem->setSelected(true);
}
}
}
}
@ -190,24 +190,24 @@ void UBDocumentNavigator::setGraphicsItems(QList<QGraphicsItem *> items, QString
// First, clear the actual thumbnails
foreach(QGraphicsItem* it, mScene->items())
{
mScene->removeItem(it);
delete it;
mScene->removeItem(it);
delete it;
}
// Add the new thumbnails
foreach(QGraphicsItem* it, items)
{
mScene->addItem(it);
mScene->addItem(it);
}
// Add the labels
mLabels.clear();
foreach(QString lb, labels)
{
UBThumbnailTextItem *labelItem = new UBThumbnailTextItem(lb);
mScene->addItem(labelItem);
UBThumbnailTextItem *labelItem = new UBThumbnailTextItem(lb);
mScene->addItem(labelItem);
mLabels << labelItem;
mLabels << labelItem;
}
// Refresh the scene
@ -223,71 +223,71 @@ void UBDocumentNavigator::refreshScene()
if(mLabels.size() > 0)
{
QFontMetrics fm(mLabels.at(0)->font());
labelSpacing = UBSettings::thumbnailSpacing + fm.height();
QFontMetrics fm(mLabels.at(0)->font());
labelSpacing = UBSettings::thumbnailSpacing + fm.height();
}
qreal thumbnailHeight = mThumbnailWidth / UBSettings::minScreenRatio;
for(int i = 0; i < mThumbnails.size(); i++)
{
// Get the item
QGraphicsItem* item = mThumbnails.at(i);
// Compute the scale factor
qreal scaleWidth = mThumbnailWidth / item->boundingRect().width();
qreal scaleHeight = thumbnailHeight / item->boundingRect().height();
qreal scaleFactor = qMin(scaleWidth, scaleHeight);
UBThumbnail* pix = dynamic_cast<UBThumbnail*>(item);
if(pix)
{
scaleFactor = qMin(scaleFactor, 1.0);
}
QTransform transform;
transform.scale(scaleFactor, scaleFactor);
// Apply the scaling
item->setTransform(transform);
item->setFlag(QGraphicsItem::ItemIsSelectable, true);
int columnIndex = i % mNbColumns;
int rowIndex = i / mNbColumns;
if(pix)
{
pix->setColumn(columnIndex);
pix->setRow(rowIndex);
}
int w = item->boundingRect().width();
int h = item->boundingRect().height();
QPointF pos( border() + (mThumbnailWidth - w * scaleFactor) / 2 + columnIndex * (mThumbnailWidth + border()),
border() + rowIndex * (thumbnailHeight + border() + labelSpacing) + (thumbnailHeight - h * scaleFactor) / 2);
item->setPos(pos);
// Add the labels "Page x"
if(mLabels.size() > i)
{
QFontMetrics fm(mLabels.at(i)->font(), this);
QString elidedText = fm.elidedText(mLab.at(i), Qt::ElideRight, mThumbnailWidth);
mLabels.at(i)->setPlainText(elidedText);
mLabels.at(i)->setWidth(fm.width(elidedText) + 2 * mLabels.at(i)->document()->documentMargin());
pos.setY(pos.y() + (thumbnailHeight + h * scaleFactor) / 2 + 5); // What is this 5 ??
qreal labelWidth = fm.width(elidedText);
pos.setX(border() + (mThumbnailWidth - labelWidth) / 2 + columnIndex * (mThumbnailWidth + border()));
mLabels.at(i)->setPos(pos);
}
// Get the item
QGraphicsItem* item = mThumbnails.at(i);
// Compute the scale factor
qreal scaleWidth = mThumbnailWidth / item->boundingRect().width();
qreal scaleHeight = thumbnailHeight / item->boundingRect().height();
qreal scaleFactor = qMin(scaleWidth, scaleHeight);
UBThumbnail* pix = dynamic_cast<UBThumbnail*>(item);
if(pix)
{
scaleFactor = qMin(scaleFactor, 1.0);
}
QTransform transform;
transform.scale(scaleFactor, scaleFactor);
// Apply the scaling
item->setTransform(transform);
item->setFlag(QGraphicsItem::ItemIsSelectable, true);
int columnIndex = i % mNbColumns;
int rowIndex = i / mNbColumns;
if(pix)
{
pix->setColumn(columnIndex);
pix->setRow(rowIndex);
}
int w = item->boundingRect().width();
int h = item->boundingRect().height();
QPointF pos( border() + (mThumbnailWidth - w * scaleFactor) / 2 + columnIndex * (mThumbnailWidth + border()),
border() + rowIndex * (thumbnailHeight + border() + labelSpacing) + (thumbnailHeight - h * scaleFactor) / 2);
item->setPos(pos);
// Add the labels "Page x"
if(mLabels.size() > i)
{
QFontMetrics fm(mLabels.at(i)->font(), this);
QString elidedText = fm.elidedText(mLab.at(i), Qt::ElideRight, mThumbnailWidth);
mLabels.at(i)->setPlainText(elidedText);
mLabels.at(i)->setWidth(fm.width(elidedText) + 2 * mLabels.at(i)->document()->documentMargin());
pos.setY(pos.y() + (thumbnailHeight + h * scaleFactor) / 2 + 5); // What is this 5 ??
qreal labelWidth = fm.width(elidedText);
pos.setX(border() + (mThumbnailWidth - labelWidth) / 2 + columnIndex * (mThumbnailWidth + border()));
mLabels.at(i)->setPos(pos);
}
}
QScrollBar *vertScrollBar = verticalScrollBar();
int scrollBarThickness = 0;
if (vertScrollBar && vertScrollBar->isVisible())
scrollBarThickness = vertScrollBar->width();
scrollBarThickness = vertScrollBar->width();
}
/**
@ -347,12 +347,12 @@ void UBDocumentNavigator::resizeEvent(QResizeEvent *event)
mThumbnailWidth = (width() > mThumbnailMinWidth) ? width() - 2*border() : mThumbnailMinWidth;
// Update the scene rect
// QRect sceneRect;
// sceneRect.setWidth(width() - 2*border());
// sceneRect.setHeight(height() - 2*border());
// sceneRect.moveLeft(border());
// sceneRect.moveTop(border());
// scene()->setSceneRect(sceneRect);
// QRect sceneRect;
// sceneRect.setWidth(width() - 2*border());
// sceneRect.setHeight(height() - 2*border());
// sceneRect.moveLeft(border());
// sceneRect.moveTop(border());
// scene()->setSceneRect(sceneRect);
// Refresh the scene
refreshScene();
@ -367,20 +367,20 @@ void UBDocumentNavigator::mousePressEvent(QMouseEvent *event)
QGraphicsItem* pClickedItem = itemAt(event->pos());
if(NULL != pClickedItem)
{
bNavig = true;
// First, select the clicked item
UBSceneThumbnailPixmap* pCrntItem = dynamic_cast<UBSceneThumbnailPixmap*>(pClickedItem);
if(NULL == pCrntItem)
{
// If we fall here we may have clicked on the label instead of the thumbnail
UBThumbnailTextItem* pTextItem = dynamic_cast<UBThumbnailTextItem*>(pClickedItem);
if(NULL != pTextItem)
{
pCrntItem = dynamic_cast<UBSceneThumbnailPixmap*>(mThumbnails.at(mLabels.indexOf(pTextItem)));
}
}
bNavig = true;
// First, select the clicked item
UBSceneThumbnailPixmap* pCrntItem = dynamic_cast<UBSceneThumbnailPixmap*>(pClickedItem);
if(NULL == pCrntItem)
{
// If we fall here we may have clicked on the label instead of the thumbnail
UBThumbnailTextItem* pTextItem = dynamic_cast<UBThumbnailTextItem*>(pClickedItem);
if(NULL != pTextItem)
{
pCrntItem = dynamic_cast<UBSceneThumbnailPixmap*>(mThumbnails.at(mLabels.indexOf(pTextItem)));
}
}
else
{
if(NULL != mCrntItem && mCrntItem != pCrntItem)
@ -398,7 +398,7 @@ void UBDocumentNavigator::mousePressEvent(QMouseEvent *event)
emit changeCurrentPage();
refreshScene();
}
bNavig = false;
bNavig = false;
}
}
@ -412,7 +412,7 @@ int UBDocumentNavigator::selectedPageNumber()
if(NULL != mCrntItem)
{
nbr = mThumbnails.indexOf(mCrntItem);
nbr = mThumbnails.indexOf(mCrntItem);
}
return nbr;
@ -432,6 +432,6 @@ UBDocumentProxy* UBDocumentNavigator::currentDoc()
*/
void UBDocumentNavigator::onSelectionChanged()
{
// QList<QGraphicsItem*> qlItems = mScene->selectedItems();
// qDebug() << "The number of selected items is " << qlItems.count();
// QList<QGraphicsItem*> qlItems = mScene->selectedItems();
// qDebug() << "The number of selected items is " << qlItems.count();
}

@ -51,13 +51,14 @@ protected:
private slots:
void addNewPage();
void onSelectionChanged();
void generateThumbnails();
private:
void setGraphicsItems(QList<QGraphicsItem*> items, QStringList labels);
void refreshScene();
void updateSpecificThumbnail(int iPage);
int border();
void generateThumbnails();
/** The scene */
QGraphicsScene* mScene;

@ -119,11 +119,11 @@ void UBMainWindow::keyPressEvent(QKeyEvent *event)
*/
}
void UBMainWindow::closeEvent(QCloseEvent *event)
{
event->ignore();
emit closeEvent_Signal(event);
}
void UBMainWindow::closeEvent(QCloseEvent *event)
{
event->ignore();
emit closeEvent_Signal(event);
}
void UBMainWindow::onExportDone()
{
@ -138,3 +138,18 @@ void UBMainWindow::onExportDone()
actionOpen->setEnabled(true);
actionDocumentAdd->setEnabled(true);
}
bool UBMainWindow::yesNoQuestion(QString windowTitle, QString text)
{
QMessageBox messageBox;
messageBox.setParent(this);
messageBox.setWindowFlags(Qt::Dialog);
messageBox.setWindowTitle(windowTitle);
messageBox.setText(text);
QPushButton* yesButton = messageBox.addButton(tr("Yes"),QMessageBox::YesRole);
messageBox.addButton(tr("No"),QMessageBox::NoRole);
messageBox.setIcon(QMessageBox::Question);
messageBox.exec();
return messageBox.clickedButton() == yesButton;
}

@ -41,8 +41,9 @@ class UBMainWindow : public QMainWindow, public Ui::MainWindow
void addDocumentsWidget(QWidget *pWidget);
void switchToDocumentsWidget();
bool yesNoQuestion(QString windowTitle, QString text);
signals:
signals:
void closeEvent_Signal( QCloseEvent *event );
public slots:

Loading…
Cancel
Save