Example #1
0
def _paste_and_go(window, in_current_tab=True):
    c = QApplication.clipboard()
    for mode in QClipboard.Mode.Clipboard, QClipboard.Mode.Selection:
        text = c.text(mode).strip()
        if text:
            if text.partition(':')[0].lower() in {
                    'file', 'http', 'https', 'about', 'chrome'
            }:
                qurl = QUrl.fromUserInput(text)
                if qurl.isValid() and not qurl.isEmpty():
                    window.open_url(qurl, in_current_tab=in_current_tab)
                    return
    window.show_status_message(_('No URL in clipboard'), 2, 'success')
Example #2
0
def parse_url(url_or_path):
    return QUrl.fromUserInput(url_or_path, os.getcwd())