1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-20 10:46:35 +01:00

[SpeedDial] Fix issues with loading a missing preview on load

Missing previews are now loaded after the page has been loaded (from
JavaScript code), instead of loading being started on generating
initial script (from C++ code)
This commit is contained in:
nowrep 2014-02-03 23:50:53 +01:00
parent 1a5fc6a1a1
commit cb99a3154e
2 changed files with 21 additions and 17 deletions

View File

@ -26,7 +26,8 @@ span.reload {width: 16px;height: 16px;position: absolute;%LEFT_STR%: 92%;top: 0p
span.reload:hover {border-color: grey; border-radius: 4px;} span.reload:hover {border-color: grey; border-radius: 4px;}
#overlay-edit {width: 380px;max-height: 265px;border-width: 20px;margin-%LEFT_STR%:auto;margin-%RIGHT_STR%: auto;margin-top: 100px;-webkit-border-image: url(%BOX-BORDER%) 25;-webkit-box-shadow: 0px 5px 80px #505050;border-radius:10px;} #overlay-edit {width: 380px;max-height: 265px;border-width: 20px;margin-%LEFT_STR%:auto;margin-%RIGHT_STR%: auto;margin-top: 100px;-webkit-border-image: url(%BOX-BORDER%) 25;-webkit-box-shadow: 0px 5px 80px #505050;border-radius:10px;}
#overlay-edit img {display: block;margin-%LEFT_STR%: auto;margin-%RIGHT_STR%: auto;width:231px;} #overlay-edit img {display: block;margin-%LEFT_STR%: auto;margin-%RIGHT_STR%: auto;max-width:231px;max-height:131px;}
#overlay-edit img[src*=".gif"] {width:54px;height:55px;}
#overlay-edit .buttonbox input {margin-%RIGHT_STR%:0px;margin-%LEFT_STR%:3px;} #overlay-edit .buttonbox input {margin-%RIGHT_STR%:0px;margin-%LEFT_STR%:3px;}
.formTable {width: 350px;margin-%LEFT_STR%: auto;margin-%RIGHT_STR%: auto;margin-top: 15px;} .formTable {width: 350px;margin-%LEFT_STR%: auto;margin-%RIGHT_STR%: auto;margin-top: 15px;}
@ -157,7 +158,7 @@ function onReloadClick(box) {
return; return;
$(img).attr('src', LOADING_IMAGE); $(img).attr('src', LOADING_IMAGE);
speeddial.loadThumbnail(url); external.speedDial.loadThumbnail(url);
} }
function boxEdited() { function boxEdited() {
@ -167,7 +168,7 @@ function boxEdited() {
var box = document.getElementById('quickdial').getElementsByTagName('div')[editingId]; var box = document.getElementById('quickdial').getElementsByTagName('div')[editingId];
var a = box.getElementsByTagName('a')[0]; var a = box.getElementsByTagName('a')[0];
var originalUrl = a.getAttribute('href'); var originalUrl = a.getAttribute('href');
setBoxUrl(editingId, speeddial.urlFromUserInput($('#formUrl').attr("value"))); setBoxUrl(editingId, external.speedDial.urlFromUserInput($('#formUrl').attr("value")));
setBoxTitle(editingId, $('#formTitle').attr("value")); setBoxTitle(editingId, $('#formTitle').attr("value"));
var changedUrl = a.getAttribute('href'); var changedUrl = a.getAttribute('href');
var fetchTitleChecked = document.getElementById('fetchTitle').checked; var fetchTitleChecked = document.getElementById('fetchTitle').checked;
@ -178,13 +179,13 @@ function boxEdited() {
$('#fadeOverlay').fadeOut("slow", function() { $('#fadeOverlay').fadeOut("slow", function() {
$("#fadeOverlay").remove(); $("#fadeOverlay").remove();
speeddial.loadThumbnail(a.getAttribute('href'), fetchTitleChecked); external.speedDial.loadThumbnail(a.getAttribute('href'), fetchTitleChecked);
speeddial.removeImageForUrl(a.getAttribute('href')); external.speedDial.removeImageForUrl(a.getAttribute('href'));
}); });
} else { } else {
hideEditBox(); hideEditBox();
} }
speeddial.changed(allPages()); external.speedDial.changed(allPages());
} }
function allPages() { function allPages() {
@ -235,6 +236,10 @@ function addBox(url, title, img_source) {
document.getElementById("quickdial").appendChild(div); document.getElementById("quickdial").appendChild(div);
if (img_source == LOADING_IMAGE) {
external.speedDial.loadThumbnail(url);
}
return div; return div;
} }
@ -264,7 +269,7 @@ function setTitleToUrl(url, title) {
span.innerText = title; span.innerText = title;
} }
speeddial.changed(allPages()); external.speedDial.changed(allPages());
} }
function setImageToUrl(url, img_source) { function setImageToUrl(url, img_source) {
@ -307,8 +312,8 @@ function removeBox(id) {
document.getElementById("quickdial").removeChild(box); document.getElementById("quickdial").removeChild(box);
alignPage(); alignPage();
speeddial.removeImageForUrl(url); external.speedDial.removeImageForUrl(url);
speeddial.changed(allPages()); external.speedDial.changed(allPages());
} }
function alignPage() { function alignPage() {
@ -338,7 +343,7 @@ function alignPage() {
} }
function bgImageSel() { function bgImageSel() {
var img = speeddial.getOpenFileName(); var img = external.speedDial.getOpenFileName();
if (img) { if (img) {
document.getElementById('BgImgHold').value = img; document.getElementById('BgImgHold').value = img;
} }
@ -349,11 +354,11 @@ function saveSettings() {
DIAL_WIDTH = parseInt($('#SdSize').val()); DIAL_WIDTH = parseInt($('#SdSize').val());
SD_CNTR = ($('#SdCntrToggle').attr('checked') ? 1 : 0 ); SD_CNTR = ($('#SdCntrToggle').attr('checked') ? 1 : 0 );
speeddial.setBackgroundImage($('#BgImgHold').val()); external.speedDial.setBackgroundImage($('#BgImgHold').val());
speeddial.setBackgroundImageSize($('#BgImgSelSiz').val()); external.speedDial.setBackgroundImageSize($('#BgImgSelSiz').val());
speeddial.setPagesInRow(MAX_PAGES_ROW); external.speedDial.setPagesInRow(MAX_PAGES_ROW);
speeddial.setSdSize(DIAL_WIDTH); external.speedDial.setSdSize(DIAL_WIDTH);
speeddial.setSdCentered(SD_CNTR); external.speedDial.setSdCentered(SD_CNTR);
alignPage(); alignPage();
} }
@ -430,7 +435,7 @@ $("#quickdial").sortable({
opacity: 0.8, opacity: 0.8,
distance: 40, distance: 40,
update: function(event, ui) { update: function(event, ui) {
speeddial.changed(allPages()); external.speedDial.changed(allPages());
} }
}); });
</script> </script>

View File

@ -214,7 +214,6 @@ QString SpeedDial::initialScript()
QString imgSource = m_thumbnailsDir + QCryptographicHash::hash(page.url.toUtf8(), QCryptographicHash::Md4).toHex() + ".png"; QString imgSource = m_thumbnailsDir + QCryptographicHash::hash(page.url.toUtf8(), QCryptographicHash::Md4).toHex() + ".png";
if (!QFile(imgSource).exists()) { if (!QFile(imgSource).exists()) {
loadThumbnail(page.url);
imgSource = "qrc:html/loading.gif"; imgSource = "qrc:html/loading.gif";
if (page.url.isEmpty()) { if (page.url.isEmpty()) {