Ignore:
Timestamp:
05/15/13 16:58:00 (11 months ago)
Author:
Ales Erjavec <ales.erjavec@…>
Branch:
default
Message:

Handle QFileOpenEvent request events.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Orange/OrangeCanvas/main.py

    r11518 r11522  
    121121    log.debug("Starting CanvasApplicaiton with argv = %r.", qt_argv) 
    122122    app = CanvasApplication(qt_argv) 
     123 
     124    # intercept any QFileOpenEvent requests until the main window is 
     125    # fully initialized 
     126    open_requests = [] 
     127    app.fileOpenRequest.connect(open_requests.append) 
    123128 
    124129    # Note: config.init must be called after the QApplication constructor 
     
    231236    canvas_window.raise_() 
    232237 
    233     if want_welcome and not args: 
     238    if want_welcome and not args and not open_requests: 
    234239        # Process events to make sure the canvas_window layout has 
    235240        # a chance to activate (the welcome dialog is modal and will 
     
    242247                 args[0]) 
    243248        canvas_window.load_scheme(args[0]) 
     249    elif open_requests: 
     250        log.info("Loading a scheme from an `QFileOpenEvent` for %r", 
     251                 open_requests[-1]) 
     252        canvas_window.load_scheme(open_requests[-1].toLocalFile()) 
     253 
     254    app.fileOpenRequest.connect(canvas_window.open_scheme_file) 
    244255 
    245256    stdout_redirect = \ 
Note: See TracChangeset for help on using the changeset viewer.