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_label.text()), unicode( self.det_msg.toPlainText()))) self.copy_button.setText(_('Copied'))
def decodeAndCopy(self, url): if url.startswith("https://slack-redir.net/link?url="): url_param = parse_qs(urlsplit(url).query).get('url') decodedURL = url_param[0] if url_param else url else: decodedURL = url QApplication.clipboard().setText(decodedURL)
def copy_to_clipboard(self): rows = {i.row() for i in self.selectedIndexes()} words = {self.model().word_for_row(r) for r in rows} words.discard(None) words = sorted({w[0] for w in words}, key=sort_key) if words: QApplication.clipboard().setText('\n'.join(words))
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)
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_label.text()), unicode(self.det_msg.toPlainText()))) self.copy_button.setText(_('Copied'))
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).toPyObject().level) + msg items.append(msg) if items: QApplication.clipboard().setText('\n'.join(items))
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)
def _copyItemToClipboard(self): """Callback for item menu.""" if self._current_item is None: return dp = getattr(self._current_item, '_dp', None) if dp and dp.archived: path = dp.fullpath.replace(" ", "\\ ") QApplication.clipboard().setText(path, QClipboard.Clipboard) QApplication.clipboard().setText(path, QClipboard.Selection)
def copy_to_clipboard(self, *args): d = QTextDocument() d.setHtml(self.msg_label.text()) QApplication.clipboard().setText( u'calibre, version %s (%s, isfrozen: %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'))
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).toPyObject().level) + msg items.append(msg) if items: QApplication.clipboard().setText('\n'.join(items))
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)
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')))
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
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)))
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))
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)
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)))
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() if hasattr(w, "textCursor"): cr = w.textCursor() cr.insertText(c) w.setTextCursor(cr) elif hasattr(w, "insert"): if hasattr(w, "no_popup"): oval = w.no_popup w.no_popup = True w.insert(c) if hasattr(w, "no_popup"): w.no_popup = oval
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
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)
def paste_isbn(self): text = unicode(QApplication.clipboard().text()).strip() if not text or not check_isbn(text): d = ISBNDialog(self, text) if not d.exec_(): return text = d.text() if not text: return vals = self.current_val vals['isbn'] = text self.current_val = vals
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_()
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_()
def __init__(self, *args): QWidget.__init__(self, *args) # 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._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) QObject.connect(self._qa_plot_all, SIGNAL("toggled(bool)"), self._displayAllImages) self._closing = False self._qa_load_clipboard = None self._clipboard_mode = QClipboard.Clipboard QObject.connect(QApplication.clipboard(), SIGNAL("changed(QClipboard::Mode)"), self._checkClipboardPath) # populate the menu self._repopulateMenu()
def __init__(self, *args): QWidget.__init__(self, *args) # 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._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) QObject.connect(self._qa_plot_all, SIGNAL("toggled(bool)"), self._displayAllImages) self._closing = False self._qa_load_clipboard = None self._clipboard_mode = QClipboard.Clipboard QObject.connect(QApplication.clipboard(), SIGNAL("changed(QClipboard::Mode)"), self._checkClipboardPath) # populate the menu self._repopulateMenu()
def copy_to_clipboard(self): cb = QApplication.clipboard() cb.setText(unicode(self.context_item.text()))
def paste_from_clipboard(self): cb = QApplication.clipboard() self.context_item.setText(cb.text())
def copy_to_clipboard(self): QApplication.clipboard().setText(''.join(self.log.plain_text))
def copy_to_clipboard(self): QApplication.clipboard().setText(self.text_results)
def copy_to_clipboard(self, char_code): c = QApplication.clipboard() c.setText(chr(char_code))
def copy_item_to_clipboard(self, val): cb = QApplication.clipboard() cb.clear() cb.setText(val)
def _loadClipboardPath(self): try: path = QApplication.clipboard().text(self._clipboard_mode) except: return self.loadImage(path)
def __init__(self, gui, icon, do_user_config, qaction, us): QDialog.__init__(self, gui) self.gui = gui self.do_user_config = do_user_config self.qaction = qaction self.us = us self.clip = QApplication.clipboard() self.main_gui = calibre_main() self.urllib_thread = UrlLibThread(self.us) self.kill_servers_thread = KillServersThread(self.us) self.us.check_finished = True self.pxmp = QPixmap() self.pxmp.load('images/icon_connected.png') self.icon_connected = QIcon(self.pxmp) self.setStyleSheet(""" QDialog { background-color: white; } QPushButton { font-size: 16px; border-style: solid; border-color: red; font-family:'BitstreamVeraSansMono',Consolas,monospace; text-transform: uppercase; } QPushButton#arrow { border-width: 16px; border-right-color:white; padding: -10px; color:red; } QPushButton#url { background-color: red; min-width: 460px; color: white; text-align: left; } QPushButton#url:hover { background-color: white; color: red; } QPushButton#share { background-color: red; color: white; margin-right: 10px; } QPushButton#share:hover { background-color: white; color: red; } QPushButton#url2 { color: #222; text-align: left; } QPushButton#url2:hover { color: red; } """) self.ll = QVBoxLayout() #self.ll.setSpacing(1) self.l = QHBoxLayout() self.l.setSpacing(0) self.l.setMargin(0) #self.l.setContentsMargins(0,0,0,0) self.w = QWidget() self.w.setLayout(self.l) self.setLayout(self.ll) self.setWindowIcon(icon) self.lets_share_button = QPushButton() self.lets_share_button.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding) self.lets_share_button.setObjectName("share") self.lets_share_button.clicked.connect(self.lets_share) self.stop_share_button = QPushButton() self.stop_share_button.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding) self.stop_share_button.setObjectName("share") self.stop_share_button.clicked.connect(self.stop_share) self.l.addWidget(self.lets_share_button) self.l.addWidget(self.stop_share_button) if self.us.button_state == "start": self.lets_share_button.show() self.stop_share_button.hide() self.lets_share_button.setText(self.us.share_button_text) else: self.lets_share_button.hide() self.stop_share_button.show() self.stop_share_button.setText(self.us.share_button_text) self.url_label = QPushButton() self.url_label.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding) self.url_label.setObjectName("url") self.url_label.clicked.connect(self.open_url) self.l.addWidget(self.url_label) self.arrow_button = QPushButton("_____") self.arrow_button.setObjectName("arrow") self.l.addWidget(self.arrow_button) self.ll.addWidget(self.w) self.ll.addSpacing(10) self.chat_button = QPushButton("Chat room: https://chat.memoryoftheworld.org") #self.chat_button.hovered.connect(self.setCursorToHand) self.chat_button.setObjectName("url2") self.chat_button.setToolTip('Meetings every thursday at 23:59 (central eruopean time)') self.chat_button.clicked.connect(functools.partial(self.open_url2, "https://chat.memoryoftheworld.org")) self.ll.addWidget(self.chat_button) self.about_project_button = QPushButton('Public Library: http://www.memoryoftheworld.org') self.about_project_button.setObjectName("url2") self.about_project_button.setToolTip('When everyone is librarian, library is everywhere.') self.about_project_button.clicked.connect(functools.partial(self.open_url2, "http://www.memoryoftheworld.org")) self.ll.addWidget(self.about_project_button) #self.debug_log = QListWidget() #self.ll.addWidget(self.debug_log) #self.debug_log.addItem("Initiatied!") self.upgrade_button = QPushButton('Please download and upgrade from {0} to {1} version of plugin.'.format(self.us.running_version, self.us.latest_version)) self.upgrade_button.setObjectName("url2") self.upgrade_button.setToolTip('Running latest version you make developers happy') self.upgrade_button.clicked.connect(functools.partial(self.open_url2, self.us.plugin_url)) version_list = [self.us.running_version, self.us.latest_version] version_list.sort(key=lambda s: map(int, s.split('.'))) if self.us.running_version != self.us.latest_version: if self.us.running_version == version_list[0]: self.ll.addSpacing(20) self.ll.addWidget(self.upgrade_button) self.resize(self.sizeHint()) self.se = open("lsb.log", "w+b") self.so = self.se sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', 0) os.dup2(self.so.fileno(), sys.stdout.fileno()) os.dup2(self.se.fileno(), sys.stderr.fileno()) self.timer = QTimer() self.timer.timeout.connect(self.check_and_render) self.timer_period = 300 self.timer.start(self.timer_period) self.error_log = ""
def copyQuoted(self, str): mark = '> ' quote = mark + str.replace('\n', '\n' + mark) QApplication.clipboard().setText(quote)
def copy(self, x): if self.selected_text: QApplication.clipboard().setText(self.selected_text)
def copy_to_clipboard(self): QApplication.clipboard().setText(self.log.toPlainText())
def bd_copy_link(self, url): if url: QApplication.clipboard().setText(url)
def copy_to_clipboard(self): QApplication.clipboard().setText(self.as_text)