feat: Enhance URL conversion and bridge script handling for improved drag-and-drop functionality
Some checks are pending
Tests & Quality Checks / Test on Python 3.11 (push) Waiting to run
Tests & Quality Checks / Test on Python 3.12 (push) Waiting to run
Tests & Quality Checks / Test on Python 3.11-1 (push) Waiting to run
Tests & Quality Checks / Test on Python 3.12-1 (push) Waiting to run
Tests & Quality Checks / Test on Python 3.10 (push) Waiting to run
Tests & Quality Checks / Test on Python 3.11-2 (push) Waiting to run
Tests & Quality Checks / Test on Python 3.12-2 (push) Waiting to run
Tests & Quality Checks / Build Artifacts (push) Blocked by required conditions
Tests & Quality Checks / Build Artifacts-1 (push) Blocked by required conditions

This commit is contained in:
claudi 2026-04-14 14:12:51 +02:00
parent 9edadc2c16
commit cbd8ed0186
4 changed files with 275 additions and 37 deletions

View file

@ -79,13 +79,13 @@
function installDragHandler() {
console.log('[Intercept] Installing dragstart handler, have', angularDragHandlers.length, 'Angular handlers');
if (angularDragHandlers.length === 0) {
console.warn('[Intercept] No Angular handlers found yet, will retry in 1s...');
setTimeout(installDragHandler, 1000);
return;
}
// Only install once, even if called multiple times
if (dragHandlerInstalled) {
console.log('[Intercept] Handler already installed, skipping');
@ -122,7 +122,7 @@
// Intercept any drag with URLs that match our configured mappings
if (currentDragUrls.length > 0) {
var shouldIntercept = false;
// Check each URL against configured URL mappings
// Intercept if ANY URL matches
if (window.webdropConfig && window.webdropConfig.urlMappings) {
@ -148,14 +148,14 @@
}
}
}
if (shouldIntercept) {
console.log('%c[Intercept] PREVENTING browser drag, using Qt for ' + currentDragUrls.length + ' file(s)',
'background: #F44336; color: white; font-weight: bold; padding: 4px 8px;');
e.preventDefault();
e.stopPropagation();
ensureChannel(function() {
if (window.bridge && typeof window.bridge.start_file_drag === 'function') {
console.log('%c[Intercept] → Qt: start_file_drag with ' + currentDragUrls.length + ' file(s)', 'color: #9C27B0; font-weight: bold;');
@ -165,7 +165,7 @@
console.error('[Intercept] bridge.start_file_drag not available!');
}
});
currentDragUrls = [];
return false;
}
@ -176,12 +176,12 @@
console.log('[Intercept] dragstart handler installed ✓');
}
// Wait for Angular to register its listeners, then install our handler
// Start checking after 3 seconds (give Angular time to load), then retry for up to 30 seconds
var installRetries = 0;
var maxRetries = 27; // 3 initial + 27 retries * 1s = 30s total
function scheduleInstall() {
if (dragHandlerInstalled) return; // Already done
installRetries++;
@ -193,7 +193,7 @@
console.warn('[Intercept] Gave up waiting for Angular handlers after 30s');
}
}
setTimeout(scheduleInstall, 3000);
// ============================================================================