def reset_addressbar(*, store=False): """ Restore the address bar to its original address and color (it could have changed because of a hover event). Optionally, store the original address in the clipboard. AB03 """ if self.current['address']: self.address_bar.set_txt_color(self.current['address'], color=QColor(0, 0, 0)) if store: clipboard(self.current['address'])
def on_link_click(qurl): """ Callback for connection. Reads the 'paste' attribute to know if a middle click requested to open on a new tab. BRW01 BRW12 VID01 CB03 """ # required for 'open in new tab if not in this instance' qurl = do_redirect(qurl) # BRW12 # 'play' and 'save' should only happen from inside the webkit and # if the user started the action; handle here, not in 'navigate' if 'play' in self.attr: print("PLAYING") GLOBAL_VID_PLAY.play(qurl) # VID01 self.attr.clear('play') return if 'save' in self.attr: clipboard(qurl) # CB02 self.attr.clear('save') return instance = extract_instance(qurl.toString()) target_prefix = get_options()['sites'][instance]['prefix'] # if the prefixes don't match, we're requesting a new instance # TAB04 TAB05 if 'paste' in self.attr or self.attr.prefix != target_prefix: mainwin().add_tab(qurl, scripting=('open_scripted' in self.attr)) self.attr.clear('paste') else: self.navigate(qurl) # BRW01 if 'open_scripted' in self.attr: self.attr.clear('open_scripted')
def new_tab_from_clipboard(self): """ One-use callback for QShortcut. Reads the content of the PRIMARY clipboard and navigates to it on a new tab. """ url = clipboard() if url is not None: self.add_tab(url)