Example #1
0
 def copy_cover(self):
     idx = self.currentIndex()
     pmap = self.model().cover_pixmap(idx)
     if pmap is None and idx.row() == 0:
         pmap = self.model().cc
     if pmap is not None:
         QApplication.clipboard().setPixmap(pmap)
Example #2
0
 def copy_to_clipboard(self, *args):
     QApplication.clipboard().setText(
             'calibre, version %s\n%s: %s\n\n%s' %
             (__version__, unicode_type(self.windowTitle()),
                 unicode_type(self.msg_label.text()),
                 unicode_type(self.det_msg.toPlainText())))
     self.copy_button.setText(_('Copied'))
Example #3
0
def copy_url(window, *args, **kwargs):
    if window.current_tab is not None:
        qurl = window.current_tab.url()
        if not qurl.isEmpty():
            QApplication.clipboard().setText(qurl.toString())
            window.show_status_message(_('Copied: ') + qurl.toString(), 2, 'success')
        window.statusBar()
        return True
Example #4
0
 def copy(self):
     # Workaround Qt replacing nbsp with normal spaces on copy
     c = self.textCursor()
     if not c.hasSelection():
         return
     md = QMimeData()
     md.setText(self.selected_text)
     QApplication.clipboard().setMimeData(md)
Example #5
0
 def copy_to_clipboard(self, *args):
     QApplication.clipboard().setText(
             'calibre, version %s\n%s: %s\n\n%s' %
             (__version__, unicode(self.windowTitle()),
                 unicode(self.msg.text()),
                 unicode(self.det_msg.toPlainText())))
     if hasattr(self, 'ctc_button'):
         self.ctc_button.setText(_('Copied'))
Example #6
0
 def copy_to_clipboard(self, *args):
     QApplication.clipboard().setText(
         '%s, version %s\n%s: %s\n\n%s' %
         (appname, str_version, self.windowTitle(),
          self.msg.text(),
          self.det_msg.toPlainText()))
     if hasattr(self, 'ctc_button'):
         self.ctc_button.setText(_('Copied'))
Example #7
0
 def copy_to_clipboard(self):
     items = []
     for item in (self.items.item(i) for i in xrange(self.items.count())):
         msg = unicode(item.text())
         msg = prefix_for_level(item.data(Qt.UserRole).level) + msg
         items.append(msg)
     if items:
         QApplication.clipboard().setText('\n'.join(items))
Example #8
0
 def copy_to_clipboard(self, *args):
     d = QTextDocument()
     d.setHtml(self.msg_label.text())
     QApplication.clipboard().setText(
             u'calibre, version %s (%s, embedded-python: %s)\n%s: %s\n\n%s' %
             (__version__, sys.platform, isfrozen,
                 unicode(self.windowTitle()), unicode(d.toPlainText()),
                 unicode(self.det_msg.toPlainText())))
     if hasattr(self, 'ctc_button'):
         self.ctc_button.setText(_('Copied'))
Example #9
0
 def keyPressEvent(self, ev):
     if ev.matches(QKeySequence.Copy):
         from .commands.open import Open
         cmd, rest = self.text().partition(' ')[::2]
         if cmd in Open.names and rest.strip():
             QApplication.clipboard().setText(rest)
             ev.accept()
             return
     k = ev.key()
     mods = ev.modifiers()
     if k in (Qt.Key_V, Qt.Key_S) and mods & Qt.CTRL and mods & Qt.SHIFT:
         text = QApplication.clipboard().text(k == Qt.Key_S)
         if text:
             self.setText(text)
     return QLineEdit.keyPressEvent(self, ev)
Example #10
0
def copy_all(text_browser):
    mf = getattr(text_browser, 'details', text_browser)
    c = QApplication.clipboard()
    md = QMimeData()
    md.setText(mf.toPlainText())
    md.setHtml(mf.toHtml())
    c.setMimeData(md)
Example #11
0
 def selection_changed(self):
     # Workaround Qt replacing nbsp with normal spaces on copy
     clipboard = QApplication.clipboard()
     if clipboard.supportsSelection() and self.textCursor().hasSelection():
         md = QMimeData()
         md.setText(self.selected_text)
         clipboard.setMimeData(md, clipboard.Selection)
Example #12
0
 def char_selected(self, c):
     if QApplication.keyboardModifiers() & Qt.CTRL:
         self.hide()
     if self.parent() is None or self.parent().focusWidget() is None:
         QApplication.clipboard().setText(c)
         return
     self.parent().activateWindow()
     w = self.parent().focusWidget()
     e = QInputMethodEvent('', [])
     e.setCommitString(c)
     if hasattr(w, 'no_popup'):
         oval = w.no_popup
         w.no_popup = True
     QApplication.sendEvent(w, e)
     if hasattr(w, 'no_popup'):
         w.no_popup = oval
Example #13
0
 def copy_metadata(self):
     rows = self.gui.library_view.selectionModel().selectedRows()
     if not rows or len(rows) == 0:
         return error_dialog(self.gui,
                             _('Cannot copy metadata'),
                             _('No books selected'),
                             show=True)
     if len(rows) > 1:
         return error_dialog(
             self.gui,
             _('Cannot copy metadata'),
             _('Multiple books selected, can only copy from one book at a time.'
               ),
             show=True)
     db = self.gui.current_db
     book_id = db.id(rows[0].row())
     mi = db.new_api.get_metadata(book_id)
     md = QMimeData()
     md.setText(unicode(mi))
     md.setData('application/calibre-book-metadata',
                bytearray(metadata_to_opf(mi, default_lang='und')))
     img = db.new_api.cover(book_id, as_image=True)
     if img:
         md.setImageData(img)
     c = QApplication.clipboard()
     c.setMimeData(md)
Example #14
0
    def copy_to_clipboard(self, *args):
        '''
        Store window contents to system clipboard
        '''
        modifiers = Application.keyboardModifiers()
        if bool(modifiers & Qt.AltModifier):
            contents = self.html_wv.page().currentFrame().toHtml()
            #contents = BeautifulSoup(str(contents)).prettify()
            QApplication.clipboard().setText(contents)
        else:
            contents = self.html_wv.page().currentFrame().toPlainText()
            QApplication.clipboard().setText(unicode(contents))

        if hasattr(self, 'ctc_button'):
            self.ctc_button.setText('Copied')
            self.ctc_button.setIcon(QIcon(I('ok.png')))
Example #15
0
 def selection_changed(self):
     # Workaround Qt replacing nbsp with normal spaces on copy
     clipboard = QApplication.clipboard()
     if clipboard.supportsSelection() and self.textCursor().hasSelection():
         md = QMimeData()
         md.setText(self.selected_text)
         clipboard.setMimeData(md, clipboard.Selection)
Example #16
0
 def rightMenu(self, position):
     menu = QtWidgets.QMenu()
     pasteAction = menu.addAction(i18n("Paste"))
     pasteAction.triggered.connect(self.paste)
     if not QApplication.clipboard().mimeData().hasText():
         pasteAction.setEnabled(False)
     menu.exec_(self.mapToGlobal(position))
Example #17
0
 def __call__(self, cmd, rest, window):
     if cmd == 'copyurl':
         QApplication.clipboard().setText(rest)
         return
     rest = rest.strip()
     if rest.startswith('http://') or rest.startswith('https://') or rest.startswith('vise:'):
         is_search = False
     else:
         is_search = rest.strip() and (' ' in rest or '.' not in rest.strip('.'))
     url = search_engine(rest) if is_search else parse_url(rest)
     if cmd in {'open', 'topen', 'tabopen'}:
         window.open_url(url, in_current_tab=cmd == 'open', switch_to_tab=True)
     else:
         window = QApplication.instance().new_window(is_private=cmd.startswith('p'))
         window.show()
         window.open_url(url, in_current_tab=True)
Example #18
0
    def setupEditActions(self):
        tb = QToolBar(self)
        tb.setWindowTitle("Edit Actions")
        self.addToolBar(tb)

        menu = QMenu("&Edit", self)
        self.menuBar().addMenu(menu)

        self.actionUndo = QAction("&Undo", self, shortcut=QKeySequence.Undo)
        tb.addAction(self.actionUndo)
        menu.addAction(self.actionUndo)

        self.actionRedo = QAction("&Redo", self, priority=QAction.LowPriority, shortcut=QKeySequence.Redo)
        tb.addAction(self.actionRedo)
        menu.addAction(self.actionRedo)
        menu.addSeparator()

        self.actionCut = QAction("Cu&t", self, priority=QAction.LowPriority, shortcut=QKeySequence.Cut)
        tb.addAction(self.actionCut)
        menu.addAction(self.actionCut)

        self.actionCopy = QAction("&Copy", self, priority=QAction.LowPriority, shortcut=QKeySequence.Copy)
        tb.addAction(self.actionCopy)
        menu.addAction(self.actionCopy)

        self.actionPaste = QAction("&Paste", self, priority=QAction.LowPriority,
                shortcut=QKeySequence.Paste, enabled=(len(QApplication.clipboard().text()) != 0))
        tb.addAction(self.actionPaste)
        menu.addAction(self.actionPaste)
Example #19
0
 def char_selected(self, c):
     if QApplication.keyboardModifiers() & Qt.CTRL:
         self.hide()
     if self.parent() is None or self.parent().focusWidget() is None:
         QApplication.clipboard().setText(c)
         return
     self.parent().activateWindow()
     w = self.parent().focusWidget()
     e = QInputMethodEvent('', [])
     e.setCommitString(c)
     if hasattr(w, 'no_popup'):
         oval = w.no_popup
         w.no_popup = True
     QApplication.sendEvent(w, e)
     if hasattr(w, 'no_popup'):
         w.no_popup = oval
Example #20
0
 def clipboard_changed(self):
     text = QApplication.clipboard().text()
     if text.startswith("https://www.youtube.com"):
         if text.find('&'):
             text = text.split('&')[0]
         self.text_output.setText("Copied URL: " + text)
         self.url_edit.setText(text)
         self.check_url()
Example #21
0
def show_font_face_rule_for_font_file(file_data, added_name, parent=None):
    try:
        fm = FontMetadata(BytesIO(file_data)).to_dict()
    except UnsupportedFont:
        return
    pp = _('Change this to the relative path to: %s') % added_name
    rule = '''@font-face {{
  src: url({pp});
  font-family: "{ff}";
  font-weight: {w};
  font-style: {sy};
  font-stretch: {st};
  }}'''.format(pp=pp, ff=fm['font-family'], w=fm['font-weight'], sy=fm['font-style'], st=fm['font-stretch'])
    QApplication.clipboard().setText(rule)
    QMessageBox.information(parent, _('Font file added'), _(
        'The font file <b>{}</b> has been added. The text for the CSS @font-face rule for this file has been copied'
        ' to the clipboard. You should paste it into whichever CSS file you want to add this font to.').format(added_name))
Example #22
0
 def clipboardChanged(self):
     text = QApplication.clipboard().text()
     if len(self.copied_items) == 0 or self.copied_items[0] != text:
         self.copied_items.insert(0, text)
         if len(self.copied_items) == MAX + 1:
             self.copied_items.pop(MAX)
         self.current_clip = 0
         self.textLabel.setText(self.copied_items[0])
Example #23
0
 def copy_to_clipboard_degree_minute(self):
     """Copy degree_minute to clipboard."""
     cb = QApplication.clipboard()
     cb.clear()
     cb.setText(self.lat_dm_degree_lineEdit.text() + "º " +
                self.lat_dm_minute_lineEdit.text() + "\'" + ", " +
                self.lon_dm_degree_lineEdit.text() + "º " +
                self.lon_dm_minute_lineEdit.text() + "\'")
Example #24
0
def copy_all(web_view):
    web_view = getattr(web_view, 'details', web_view)
    mf = web_view.page().mainFrame()
    c = QApplication.clipboard()
    md = QMimeData()
    md.setText(mf.toPlainText())
    md.setHtml(mf.toHtml())
    c.setMimeData(md)
Example #25
0
	def clipboardChanged(self):
	    
	    global username

	    text = QApplication.clipboard().text()
	    cript = putInFiles(text)
	    self.listWidget.addItem(cript)
	    self.listWidget.update()
Example #26
0
 def _checkClipboardPath(self, mode=QClipboard.Clipboard):
     if self._qa_load_clipboard:
         self._clipboard_mode = mode
         try:
             path = str(QApplication.clipboard().text(mode))
         except:
             path = None
         self._qa_load_clipboard.setEnabled(
             bool(path and os.path.isfile(path)))
Example #27
0
 def paste(self):
     clipboard = QApplication.clipboard()
     md = clipboard.mimeData()
     if md.hasImage():
         img = QImage(md.imageData())
         if not img.isNull():
             self.undo_stack.push(Replace(img, _("Paste image"), self))
     else:
         error_dialog(self, _("No image"), _("No image available in the clipboard"), show=True)
Example #28
0
    def keyPressEvent(self, event):
        if event.key() == Qt.Key_V and event.modifiers() & Qt.ControlModifier:
            text = QApplication.clipboard().text()
            self.insertPlainText(text)
        else:
            QTextEdit.keyPressEvent(self, event)

        if event.key() == Qt.Key_Space:
            self.submit()
Example #29
0
 def pasted(self, checked):
     clipboard = QApplication.clipboard()
     mime = clipboard.mimeData()
     if mime.hasImage():
         pixmap = clipboard.pixmap()
         byteArray = QByteArray()
         buffer = QBuffer(byteArray)
         pixmap.save(buffer, "PNG")
         self.call("setClipboard", str(byteArray.toBase64(), sys.stdout.encoding))
Example #30
0
 def keyPressEvent(self, ev):
     if not self.view.handle_key(ev):
         if ev.key() in (Qt.Key_Enter, Qt.Key_Return):
             return  # The enter key is used by the search box, so prevent it closing the dialog
         if ev.key() == Qt.Key_Slash:
             return self.search.setFocus(Qt.OtherFocusReason)
         if ev.matches(QKeySequence.Copy):
             text = self.view.view.left.selected_text + self.view.view.right.selected_text
             if text:
                 QApplication.clipboard().setText(text)
             return
         if ev.matches(QKeySequence.FindNext):
             self.sbn.click()
             return
         if ev.matches(QKeySequence.FindPrevious):
             self.sbp.click()
             return
         return Dialog.keyPressEvent(self, ev)
Example #31
0
 def keyPressEvent(self, ev):
     if not self.view.handle_key(ev):
         if ev.key() in (Qt.Key_Enter, Qt.Key_Return):
             return  # The enter key is used by the search box, so prevent it closing the dialog
         if ev.key() == Qt.Key_Slash:
             return self.search.setFocus(Qt.OtherFocusReason)
         if ev.matches(QKeySequence.Copy):
             text = self.view.view.left.selected_text + self.view.view.right.selected_text
             if text:
                 QApplication.clipboard().setText(text)
             return
         if ev.matches(QKeySequence.FindNext):
             self.sbn.click()
             return
         if ev.matches(QKeySequence.FindPrevious):
             self.sbp.click()
             return
         return Dialog.keyPressEvent(self, ev)
Example #32
0
 def copy_to_clipboard_degree_minute_second(self):
     """Copy degree_minute_second to clipboard."""
     cb = QApplication.clipboard()
     cb.clear()
     cb.setText(self.lat_dms_degree_lineEdit.text() + "º " +
                self.lat_dms_minute_lineEdit.text() + "'" +
                self.lat_dms_second_lineEdit.text() + "\" " + ", " +
                self.lon_dms_degree_lineEdit.text() + "º " +
                self.lon_dms_minute_lineEdit.text() + "'" +
                self.lon_dms_second_lineEdit.text() + "\" ")
Example #33
0
 def paste(self):
     clipboard = QApplication.clipboard()
     md = clipboard.mimeData()
     if md.hasImage():
         img = QImage(md.imageData())
         if not img.isNull():
             self.undo_stack.push(Replace(img, _('Paste image'), self))
     else:
         error_dialog(self, _('No image'), _(
             'No image available in the clipboard'), show=True)
Example #34
0
 def copy(self):
     if not self.is_valid:
         return
     clipboard = QApplication.clipboard()
     if not self.has_selection or self.selection_state.rect is None:
         clipboard.setImage(self.current_image)
     else:
         trim = Trim(self)
         clipboard.setImage(trim.after_image)
         trim.before_image = trim.after_image = None
Example #35
0
 def copy(self):
     if not self.is_valid:
         return
     clipboard = QApplication.clipboard()
     if not self.has_selection or self.selection_state.rect is None:
         clipboard.setImage(self.current_image)
     else:
         trim = Trim(self)
         clipboard.setImage(trim.after_image)
         trim.before_image = trim.after_image = None
Example #36
0
    def __init__(self, *args):
        QWidget.__init__(self, *args)
        self.mainwin = None
        # init layout
        self._lo = QVBoxLayout(self)
        self._lo.setContentsMargins(0, 0, 0, 0)
        self._lo.setSpacing(0)
        # init internal state
        self._currier = PersistentCurrier()
        self._z0 = 0  # z-depth of first image, the rest count down from it
        self._updating_imap = False
        self._locked_display_range = False
        self._imagecons = []
        self._imagecon_loadorder = []
        self._center_image = None
        self._plot = None
        self._border_pen = None
        self._drawing_key = None
        self._load_image_dialog = None
        self._label_color = None
        self._label_bg_brush = None
        self._model_imagecons = set()
        # init menu and standard actions
        self._menu = QMenu("&Image", self)
        qag = QActionGroup(self)
        # exclusive controls for plotting topmost or all images
        self._qa_plot_top = qag.addAction("Display topmost image only")
        self._qa_plot_all = qag.addAction("Display all images")
        self._qa_plot_top.setCheckable(True)
        self._qa_plot_all.setCheckable(True)
        self._qa_plot_top.setChecked(True)
        self._qa_plot_all.toggled[bool].connect(self._displayAllImages)
        self._closing = False

        self._qa_load_clipboard = None
        self._clipboard_mode = QClipboard.Clipboard
        QApplication.clipboard().changed[QClipboard.Mode].connect(
            self._checkClipboardPath)
        # populate the menu
        self._repopulateMenu()
        self.signalShowMessage = None
        self.signalShowErrorMessage = None
Example #37
0
def _paste_and_go(window, in_current_tab=True):
    c = QApplication.clipboard()
    for mode in c.Clipboard, c.Selection:
        text = c.text(mode).strip()
        if text:
            if text.partition(':')[0].lower() in {'file', 'http', 'https', 'about'}:
                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 #38
0
 def cellItemClicked(self, action):
     item = action.data()
     if action.objectName() == 'cell_copy':
         clipboard = QApplication.clipboard()
         clipboard.setText(item.text(), QClipboard.Clipboard)
     elif action.objectName() == 'delete_entry':
         response = self.window.confirmChange()
         if (response == 1024):
             id = int(item.text())
             self.storage.deletePassword(id)
             item.tableWidget().removeRow(item.row())
Example #39
0
 def onCopy(self):
     if self.ui.addySelect.count() == 0:
         mess = "Nothing to copy. Load/Refresh addresses first."
         myPopUp_sb(self.caller, QMessageBox.Warning, 'PET4L - no address', mess)
         return
     cb = QApplication.clipboard()
     cb.clear(mode=cb.Clipboard)
     ct = self.ui.addySelect.currentText()
     addy = ct.split("  --  ")[1].split("   ")[0].strip()
     cb.setText(addy, mode=cb.Clipboard)
     myPopUp_sb(self.caller, QMessageBox.Information, 'PET4L - copied', "address copied to the clipboard")
Example #40
0
 def copy_signature(self):
     if not self.signature_output.text():
         return
     cb = QApplication.clipboard()
     cb.clear(mode=cb.Clipboard)
     cb.setText(self.signature_output.text(), mode=cb.Clipboard)
     msg = QtWidgets.QMessageBox()
     msg.setIcon(QtWidgets.QMessageBox.Information)
     msg.setText("Signature Has Copied to Your Clipboard")
     msg.setWindowTitle("Done")
     msg.exec_()
Example #41
0
def output_clipboard(ctx, cmdline):
    """
	Return an action whose text is set to the clipboard's current contents
	"""
    clip = QApplication.clipboard().text()
    action = ctx.new_action()

    # Make sure we don't cause weirdness if the clipboard is empty or an image
    if clip != "":
        action.text = clip

    return action
Example #42
0
    def cb_menu(self):
      """handle menu item presses"""

      t = self.sender().text()
      if t=='Connect':
        cd = ConnectDialog(self)
        if cd.exec_():
          (self.args.host,self.pword,self.args.ssl,self.args.noverify) = cd.get()
          self.start_thread()
      elif t=='Reconnect':
        self.start_thread()
      elif t=='Disconnect':
        if self.worker:
          self.worker.event_close.set()
          self.connected = False
      elif t=='Copy HTML':
        QApplication.clipboard().setText(self.chatpane.toHtml())
      elif t=='Copy Plaintext':
        QApplication.clipboard().setText(self.chatpane.toPlainText())
      elif t=='Quit':
        QtWidgets.qApp.quit()
Example #43
0
 def contextMenuEvent(self, ev):
     self.parent().normalize_state()
     menu = self.createStandardContextMenu()
     menu.setAttribute(Qt.WidgetAttribute.WA_DeleteOnClose)
     ac = menu.addAction(_('Paste and &search'))
     ac.setEnabled(bool(QApplication.clipboard().text()))
     ac.setIcon(QIcon(I('search.png')))
     ac.triggered.connect(self.paste_and_search)
     for action in menu.actions():
         if action.text().startswith(_('&Paste') + '\t'):
             menu.insertAction(action, ac)
             break
     else:
         menu.addAction(ac)
     menu.addSeparator()
     if self.as_url is not None:
         url = self.as_url(self.text())
         if url:
             menu.addAction(_('Copy search as URL'), lambda : QApplication.clipboard().setText(url))
     menu.addAction(_('&Clear search history')).triggered.connect(self.clear_history)
     menu.exec_(ev.globalPos())
    def copyResultToClipBoard(self, which):
        cb = QApplication.clipboard()
        cb.clear(mode=cb.Clipboard)
        if which == CoordinatorDockWidget.SideLeft:
            content = self.resultLeft.text()
        elif which == CoordinatorDockWidget.SideRight:
            content = self.resultRight.text()
        else:
            content = "%s\t%s" % (self.resultLeft.text(),
                                  self.resultRight.text())

        cb.setText(content, mode=cb.Clipboard)
Example #45
0
    def cb_menu(self):
      """handle menu item presses"""

      t = self.sender().text()
      if t=='Connect':
        cd = ConnectDialog(self)
        if cd.exec_():
          (self.args.host,self.pword,self.args.ssl,self.args.noverify) = cd.get()
          self.start_thread()
      elif t=='Reconnect':
        self.start_thread()
      elif t=='Disconnect':
        if self.worker:
          self.worker.event_close.set()
          self.connected = False
      elif t=='Copy HTML':
        QApplication.clipboard().setText(self.chatpane.toHtml())
      elif t=='Copy Plaintext':
        QApplication.clipboard().setText(self.chatpane.toPlainText())
      elif t=='Quit':
        QtWidgets.qApp.quit()
Example #46
0
def _paste_and_go(window, in_current_tab=True):
    c = QApplication.clipboard()
    for mode in c.Clipboard, c.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')
    def copy_to_clipboard(self):
        from calibre.gui2 import error_dialog, info_dialog
        from calibre.ebooks.metadata.meta import get_metadata

        # Get currently selected books
        rows = self.gui.library_view.selectionModel().selectedRows()
        if not rows or len(rows) == 0:
            return error_dialog(self.gui,
                                'Cannot update metadata',
                                'No books selected',
                                show=True)
        # Map the rows to book ids
        ids = list(map(self.gui.library_view.model().id, rows))
        db = self.db.new_api

        isbn_counter = 0
        error_counter = 0

        clipboard_export = []

        for book_id in ids:
            # print(book_id)
            mi = db.get_metadata(book_id, get_cover=False, cover_as_data=False)
            identifiers = mi.identifiers
            if "isbn" in identifiers.keys():
                clipboard_export.append(identifiers["isbn"])
                # print(identifiers["isbn"])
                isbn_counter += 1
            else:
                # print("No ISBN in entry")
                error_counter += 1
        QApplication.clipboard().setText(os.linesep.join(clipboard_export))

        info_dialog(
            self,
            'Success',
            'Copied {} ISBNs to clipboard, encountered {} errors'.format(
                isbn_counter, error_counter),
            show=True)
Example #48
0
 def contextMenuEvent(self, ev):
     self.parent().normalize_state()
     menu = self.createStandardContextMenu()
     menu.setAttribute(Qt.WA_DeleteOnClose)
     for action in menu.actions():
         if action.text().startswith(_('&Paste') + '\t'):
             break
     ac = menu.addAction(_('Paste and &search'))
     ac.setEnabled(bool(QApplication.clipboard().text()))
     ac.setIcon(QIcon(I('search.png')))
     ac.triggered.connect(self.paste_and_search)
     menu.insertAction(action, ac)
     menu.exec_(ev.globalPos())
Example #49
0
 def __call__(self, cmd, rest, window):
     if cmd == 'copyurl':
         QApplication.clipboard().setText(rest)
         return
     rest = rest.strip()
     if rest.startswith('http://') or rest.startswith(
             'https://') or rest.startswith('vise:') or rest.startswith(
                 'chrome://'):
         is_search = False
     else:
         is_search = rest.strip() and (' ' in rest
                                       or '.' not in rest.strip('.'))
     url = search_engine(rest) if is_search else parse_url(rest)
     if cmd in {'open', 'topen', 'tabopen'}:
         window.open_url(url,
                         in_current_tab=cmd == 'open',
                         switch_to_tab=True)
     else:
         window = QApplication.instance().new_window(
             is_private=cmd.startswith('p'))
         window.show()
         window.open_url(url, in_current_tab=True)
def copyContent(self, col):
    mimeType = 'application/x-qt-windows-mime;value="Csv"'
    clipboard = QApplication.clipboard()
    mimeData = clipboard.mimeData()
    if (mimeType in mimeData.formats()):  # 엑셀에서 복사해온 텍스트인지 확인
        text = clipboard.text()
        content = text.split("\n")
        #복사해온 텍스트 행이 기존 테이블에 있는 행과 비교시 적거나 같을 때만 붙여넣기
        if (self.classListWidget.currentRow() == 0
                and self.classListWidget.rowCount() >= len(content) - 1):
            for i in range(0, len(content) - 1):
                item = QTableWidgetItem(str(content[i]))
                self.classListWidget.setItem(i, col, item)
Example #51
0
 def contextMenuEvent(self, ev):
     self.parent().normalize_state()
     menu = self.createStandardContextMenu()
     menu.setAttribute(Qt.WA_DeleteOnClose)
     for action in menu.actions():
         if action.text().startswith(_('&Paste') + '\t'):
             break
     ac = menu.addAction(_('Paste and &search'))
     ac.setEnabled(bool(QApplication.clipboard().text()))
     ac.setIcon(QIcon(I('search.png')))
     ac.triggered.connect(self.paste_and_search)
     menu.insertAction(action, ac)
     menu.exec_(ev.globalPos())
Example #52
0
 def show_debug_info(self):
     info = self.device.device_debug_info()
     d = QDialog(self)
     d.l = l = QVBoxLayout()
     d.setLayout(l)
     d.v = v = QPlainTextEdit()
     d.setWindowTitle(self.device.get_gui_name())
     v.setPlainText(info)
     v.setMinimumWidth(400)
     v.setMinimumHeight(350)
     l.addWidget(v)
     bb = d.bb = QDialogButtonBox(QDialogButtonBox.Close)
     bb.accepted.connect(d.accept)
     bb.rejected.connect(d.reject)
     l.addWidget(bb)
     bb.addButton(_('Copy to clipboard'), bb.ActionRole)
     bb.clicked.connect(lambda :
             QApplication.clipboard().setText(v.toPlainText()))
     d.exec_()
Example #53
0
 def copy_metadata(self):
     rows = self.gui.library_view.selectionModel().selectedRows()
     if not rows or len(rows) == 0:
         return error_dialog(self.gui, _('Cannot copy metadata'),
                             _('No books selected'), show=True)
     if len(rows) > 1:
         return error_dialog(self.gui, _('Cannot copy metadata'),
                             _('Multiple books selected, can only copy from one book at a time.'), show=True)
     db = self.gui.current_db
     book_id = db.id(rows[0].row())
     mi = db.new_api.get_metadata(book_id)
     md = QMimeData()
     md.setText(unicode(mi))
     md.setData('application/calibre-book-metadata', bytearray(metadata_to_opf(mi, default_lang='und')))
     img = db.new_api.cover(book_id, as_image=True)
     if img:
         md.setImageData(img)
     c = QApplication.clipboard()
     c.setMimeData(md)
Example #54
0
 def paste_metadata(self):
     rows = self.gui.library_view.selectionModel().selectedRows()
     if not rows or len(rows) == 0:
         return error_dialog(self.gui, _('Cannot paste metadata'),
                             _('No books selected'), show=True)
     c = QApplication.clipboard()
     md = c.mimeData()
     if not md.hasFormat('application/calibre-book-metadata'):
         return error_dialog(self.gui, _('Cannot paste metadata'),
                             _('No copied metadata available'), show=True)
     if len(rows) > 1:
         if not confirm(_(
                 'You are pasting metadata onto <b>multiple books</b> ({num_of_books}). Are you'
                 ' sure you want to do that?').format(num_of_books=len(rows)), 'paste-onto-multiple', parent=self.gui):
             return
     data = bytes(md.data('application/calibre-book-metadata'))
     mi = OPF(BytesIO(data), populate_spine=False, read_toc=False, try_to_guess_cover=False).to_book_metadata()
     mi.application_id = mi.uuid_id = None
     exclude = set(tweaks['exclude_fields_on_paste'])
     paste_cover = 'cover' not in exclude
     cover = md.imageData() if paste_cover else None
     exclude.discard('cover')
     for field in exclude:
         mi.set_null(field)
     db = self.gui.current_db
     book_ids = {db.id(r.row()) for r in rows}
     title_excluded = 'title' in exclude
     authors_excluded = 'authors' in exclude
     for book_id in book_ids:
         if title_excluded:
             mi.title = db.new_api.field_for('title', book_id)
         if authors_excluded:
             mi.authors = db.new_api.field_for('authors', book_id)
         db.new_api.set_metadata(book_id, mi, ignore_errors=True)
     if cover:
         db.new_api.set_cover({book_id: cover for book_id in book_ids})
     self.refresh_books_after_metadata_edit(book_ids)
Example #55
0
 def paste_from_clipboard(self):
     cb = QApplication.clipboard()
     self.context_item.setText(cb.text())
Example #56
0
 def copy_to_clipboard(self):
     cb = QApplication.clipboard()
     cb.setText(unicode(self.context_item.text()))
Example #57
0
 def copy_to_clipboard(self):
     QApplication.clipboard().setText(self.text_results)
Example #58
0
 def copy(self, x):
     if self.selected_text:
         QApplication.clipboard().setText(self.selected_text)