Esempio n. 1
0
    def on_copyAction_triggered(self):
        cur = self.listmodel.fileByIndex(self.currentItem())

        if not cur:
            return

        err, host, port, _ = ts3lib.getServerConnectInfo(self.schid)

        if err == ERROR_ok:
            url = ("[URL=ts3file://{address}?port={port}&channel={cid}&"
                   "path={path}&filename={fname}&isDir={isdir}&"
                   "size={size}&fileDateTime={date}]{fname}[/URL]").format(
                       address=host,
                       port=port,
                       cid=self.cid,
                       path=QUrl.toPercentEncoding(cur.path),
                       fname=cur.name,
                       isdir=1 if cur.isDirectory else 0,
                       size=cur.size,
                       date=int(cur.datetime.timestamp()))

            QApplication.clipboard().setText(url)
        else:
            self.showError(self._tr("Error getting server connection info"),
                           err)
Esempio n. 2
0
 def mouseReleaseEvent(self, e):
     QPlainTextEdit.mouseReleaseEvent(self, e)
     if e.button() == Qt.LeftButton:
         self.textCursor().setCharFormat(self.selformat)
         self.seltext = self.textCursor().selectedText()
         self.setTextCursor(self.selcursor)
     elif e.button() == Qt.RightButton:
         if self.seltext == "":
             self.textCursor().insertText(QApplication.clipboard().text())
         else:
             self.textCursor().insertText(self.seltext)
             QApplication.clipboard().setText(self.seltext)
Esempio n. 3
0
    def on_copyAction_triggered(self):
        cur = self.listmodel.fileByIndex(self.currentItem())

        if not cur:
            return

        err, host, port, _ = ts3lib.getServerConnectInfo(self.schid)

        if err == ERROR_ok:
            url = ("[URL=ts3file://{address}?port={port}&channel={cid}&"
                   "path={path}&filename={fname}&isDir={isdir}&"
                   "size={size}&fileDateTime={date}]{fname}[/URL]").format(
                   address=host, port=port, cid=self.cid,
                   path=QUrl.toPercentEncoding(cur.path), fname=cur.name,
                   isdir=1 if cur.isDirectory else 0, size=cur.size,
                   date=int(cur.datetime.timestamp()))

            QApplication.clipboard().setText(url)
        else:
            self.showError(self._tr("Error getting server connection info"),
                           err)
Esempio n. 4
0
 def __init__(self):
   self.clipboard = QApplication.clipboard()
   self.action = QAction("Copy to clipboard", None)
   clementine.ui.AddAction("song_menu", self.action)
   self.action.connect("activated()", self.CopyToClipboard)