Example #1
0
 def startDrag(self, dropActions):
     """Reimplement Qt Method - handle drag event"""
     data = QMimeData()
     data.setUrls([QUrl(fname) for fname in self.get_selected_filenames()])
     drag = QDrag(self)
     drag.setMimeData(data)
     drag.exec_()
Example #2
0
 def go_to(self, url_or_text):
     """Go to page *address*"""
     if is_text_string(url_or_text):
         url = QUrl(url_or_text)
     else:
         url = url_or_text
     self.webview.load(url)
Example #3
0
 def handle_link_clicks(self, url):
     url = to_text_string(url.toString())
     if url == "spy://tutorial":
         self.show_tutorial()
     elif url.startswith('http'):
         programs.start_file(url)
     else:
         self.rich_text.webview.load(QUrl(url))
Example #4
0
def start_file(filename):
    """Generalized os.startfile for all platforms supported by Qt
    (this function is simply wrapping QDesktopServices.openUrl)
    Returns True if successfull, otherwise returns False."""
    from spyderlib.qt.QtGui import QDesktopServices
    from spyderlib.qt.QtCore import QUrl
    url = QUrl()
    url.setUrl(filename)
    return QDesktopServices.openUrl(url)
Example #5
0
def start_file(filename):
    """Generalized os.startfile for all platforms supported by Qt
    (this function is simply wrapping QDesktopServices.openUrl)
    Returns True if successfull, otherwise returns False."""
    from spyderlib.qt.QtGui import QDesktopServices
    from spyderlib.qt.QtCore import QUrl

    # We need to use setUrl instead of setPath because this is the only
    # cross-platform way to open external files. setPath fails completely on
    # Mac and doesn't open non-ascii files on Linux.
    # Fixes Issue 740
    url = QUrl()
    url.setUrl(filename)
    return QDesktopServices.openUrl(url)
Example #6
0
 def text_to_url(self, text):
     """Convert text address into QUrl object"""
     if text.startswith('/'):
         text = text[1:]
     return QUrl(self.home_url.toString() + text + '.html')
Example #7
0
 def is_valid(self, qstr=None):
     """Return True if string is valid"""
     if qstr is None:
         qstr = self.currentText()
     return QUrl(qstr).isValid()
Example #8
0
 def text_to_url(self, text):
     """Convert text address into QUrl object"""
     return QUrl(text)
Example #9
0
 def set_home_url(self, text):
     """Set home URL"""
     self.home_url = QUrl(text)