// Claim the selection. void ScintillaQt::ClaimSelection() { bool isSel = !sel.Empty(); if (isSel) { QClipboard *cb = QApplication::clipboard(); // If we support X11 style selection then make it available now. if (cb->supportsSelection()) { SelectionText text; CopySelectionRange(&text); if (text.s) cb->setMimeData(mimeSelection(text), QClipboard::Selection); } primarySelection = true; } else primarySelection = false; emit qsb->QSCN_SELCHANGED(isSel); }
//------------------------------------------------------------------------------ // void XxCopyLabel::mousePressEvent( QMouseEvent* event ) { QClipboard *cb = QkApplication::clipboard(); cb->setText( _fulltext, cb->supportsSelection() ? QClipboard::Selection : QClipboard::Clipboard ); QLabel::mousePressEvent( event ); }
void copyToClipboard(const QString &text) { QClipboard *cb = QApplication::clipboard(); cb->setText(text, QClipboard::Clipboard); if(cb->supportsSelection()) { cb->setText(text, QClipboard::Selection); } }
// The ctor. QsciScintillaBase::QsciScintillaBase(QWidget *parent) : QAbstractScrollArea(parent), preeditPos(-1), preeditNrBytes(0) #if QT_VERSION >= 0x050000 , clickCausedFocus(false) #endif { connect(verticalScrollBar(), SIGNAL(valueChanged(int)), SLOT(handleVSb(int))); connect(horizontalScrollBar(), SIGNAL(valueChanged(int)), SLOT(handleHSb(int))); setAcceptDrops(true); setFocusPolicy(Qt::WheelFocus); setAttribute(Qt::WA_KeyCompression); setAttribute(Qt::WA_InputMethodEnabled); #if QT_VERSION >= 0x050100 setInputMethodHints( Qt::ImhNoAutoUppercase|Qt::ImhNoPredictiveText|Qt::ImhMultiLine); #elif QT_VERSION >= 0x040600 setInputMethodHints(Qt::ImhNoAutoUppercase|Qt::ImhNoPredictiveText); #endif viewport()->setBackgroundRole(QPalette::Base); viewport()->setMouseTracking(true); //viewport()->setAttribute(Qt::WA_NoSystemBackground); //viewport()->setAutoFillBackground(false); //viewport()->setAttribute(Qt::WA_OpaquePaintEvent); // QPainter p( viewport() ); // p.setCompositionMode( QPainter::CompositionMode_Clear ); // p.fillRect( viewport()->rect(), Qt::transparent ); triple_click.setSingleShot(true); #if (QT_VERSION >= 0x040200 && QT_VERSION < 0x050000 && defined(Q_OS_MAC)) || (QT_VERSION >= 0x050200 && defined(Q_OS_OSX)) initialiseRectangularPasteboardMime(); #endif sci = new QsciScintillaQt(this); SendScintilla(SCI_SETCARETPERIOD, QApplication::cursorFlashTime() / 2); // Make sure the lexers are linked in. if (!lexersLinked) { Scintilla_LinkLexers(); lexersLinked = true; } QClipboard *cb = QApplication::clipboard(); if (cb->supportsSelection()) connect(cb, SIGNAL(selectionChanged()), SLOT(handleSelection())); // Add it to the pool. poolList.append(this); }
void GwtCallback::setGlobalMouseSelection(QString selection) { #ifdef Q_OS_LINUX QClipboard* clipboard = QApplication::clipboard(); if (clipboard->supportsSelection()) clipboard->setText(selection, QClipboard::Selection); s_globalMouseSelection = selection; #endif }
void KviTopicWidget::copy() { QClipboard * c = QApplication::clipboard(); if(!c) return; if(c->supportsSelection()) c->setText(m_szTopic,QClipboard::Selection); c->setText(m_szTopic,QClipboard::Clipboard); }
void MythUITextEdit::PasteTextFromClipboard(QClipboard::Mode mode) { QClipboard *clipboard = QApplication::clipboard(); if (!clipboard->supportsSelection()) mode = QClipboard::Clipboard; if (clipboard) InsertText(clipboard->text(mode)); }
void CoordinateCapture::copy() { QClipboard *myClipboard = QApplication::clipboard(); //if we are on x11 system put text into selection ready for middle button pasting if ( myClipboard->supportsSelection() ) { myClipboard->setText( mpUserCrsEdit->text() + "," + mpCanvasEdit->text(), QClipboard::Selection ); } myClipboard->setText( mpUserCrsEdit->text() + "," + mpCanvasEdit->text(), QClipboard::Clipboard ); }
// The ctor. QsciScintillaBase::QsciScintillaBase(QWidget *parent, const char *name, WFlags f) : QWidget(parent, name, f) { QGridLayout *layout = new QGridLayout(this, 2, 2); txtarea = new QWidget(this, 0, WRepaintNoErase|WResizeNoErase); txtarea->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); txtarea->setMouseTracking(true); txtarea->setAcceptDrops(true); txtarea->setFocusPolicy(WheelFocus); txtarea->setFocusProxy(this); layout->addWidget(txtarea, 0, 0); vsb = new QScrollBar(Vertical, this); layout->addWidget(vsb, 0, 1); connect(vsb, SIGNAL(valueChanged(int)), SLOT(handleVSb(int))); hsb = new QScrollBar(Horizontal, this); layout->addWidget(hsb, 1, 0); connect(hsb, SIGNAL(valueChanged(int)), SLOT(handleHSb(int))); txtarea->installEventFilter(this); setFocusPolicy(WheelFocus); // FIXME: QMacPasteboardMime isn't in Qt v5 yet. #if QT_VERSION >= 0x040200 && defined(Q_OS_MAC) && QT_VERSION < 0x050000 RectangularPasteboardMime::initialise(); #endif sci = new QsciScintillaQt(this); SendScintilla(SCI_SETCARETPERIOD, QApplication::cursorFlashTime() / 2); // Make sure the lexers are linked in. if (!lexersLinked) { Scintilla_LinkLexers(); lexersLinked = true; } QClipboard *cb = QApplication::clipboard(); if (cb->supportsSelection()) connect(cb, SIGNAL(selectionChanged()), SLOT(handleSelection())); // Add it to the pool. poolList.append(this); }
// Handle a mouse button press. void QsciScintillaBase::mousePressEvent(QMouseEvent *e) { setFocus(); QSCI_SCI_NAMESPACE(Point) pt(e->x(), e->y()); if (e->button() == Qt::LeftButton) { unsigned clickTime; // It is a triple click if the timer is running and the mouse hasn't // moved too much. if (triple_click.isActive() && (e->globalPos() - triple_click_at).manhattanLength() < QApplication::startDragDistance()) clickTime = sci->lastClickTime + QSCI_SCI_NAMESPACE(Platform)::DoubleClickTime() - 1; else clickTime = sci->lastClickTime + QSCI_SCI_NAMESPACE(Platform)::DoubleClickTime() + 1; triple_click.stop(); // Scintilla uses the Alt modifier to initiate rectangular selection. // However the GTK port (under X11, not Windows) uses the Control // modifier (by default, although it is configurable). It does this // because most X11 window managers hijack Alt-drag to move the window. // We do the same, except that (for the moment at least) we don't allow // the modifier to be configured. bool shift = e->modifiers() & Qt::ShiftModifier; bool ctrl = e->modifiers() & Qt::ControlModifier; #if defined(Q_OS_MAC) || defined(Q_OS_WIN) bool alt = e->modifiers() & Qt::AltModifier; #else bool alt = ctrl; #endif sci->ButtonDown(pt, clickTime, shift, ctrl, alt); } else if (e->button() == Qt::MidButton) { QClipboard *cb = QApplication::clipboard(); if (cb->supportsSelection()) { int pos = sci->PositionFromLocation(pt); sci->sel.Clear(); sci->SetSelection(pos, pos); sci->pasteFromClipboard(QClipboard::Selection); } } }
void Clipboard::setText(const QString& text) { QClipboard* clipboard = QApplication::clipboard(); clipboard->setText(text, QClipboard::Clipboard); if (clipboard->supportsSelection()) { clipboard->setText(text, QClipboard::Selection); } if (config()->get("security/clearclipboard").toBool()) { int timeout = config()->get("security/clearclipboardtimeout").toInt(); if (timeout > 0) { m_lastCopied = text; m_timer->start(timeout * 1000); } } }
NS_IMETHODIMP nsClipboard::SupportsSelectionClipboard(bool *_retval) { NS_ENSURE_ARG_POINTER(_retval); QClipboard *cb = QGuiApplication::clipboard(); if (cb->supportsSelection()) { *_retval = true; // we support the selection clipboard } else { *_retval = false; } return NS_OK; }
NS_IMETHODIMP nsClipboard::SupportsSelectionClipboard(PRBool *_retval) { NS_ENSURE_ARG_POINTER(_retval); QClipboard *cb = QApplication::clipboard(); if (cb->supportsSelection()) { *_retval = PR_TRUE; // we support the selection clipboard } else { *_retval = PR_FALSE; } return NS_OK; }
void CoordinateCapture::copy() { QClipboard *myClipboard = QApplication::clipboard(); //if we are on x11 system put text into selection ready for middle button pasting if ( myClipboard->supportsSelection() ) { myClipboard->setText( mpUserCrsEdit->text() + "," + mpCanvasEdit->text(), QClipboard::Selection ); //QString myMessage = tr("Clipboard contents set to: "); //statusBar()->showMessage(myMessage + myClipboard->text(QClipboard::Selection)); } else { //user has an inferior operating system.... myClipboard->setText( mpUserCrsEdit->text() + "," + mpCanvasEdit->text(), QClipboard::Clipboard ); //QString myMessage = tr("Clipboard contents set to: "); //statusBar()->showMessage(myMessage + myClipboard->text(QClipboard::Clipboard)); } }
void Clipboard::clearClipboard() { QClipboard* clipboard = QApplication::clipboard(); if (!clipboard) { qWarning("Unable to access the clipboard."); return; } if (clipboard->text(QClipboard::Clipboard) == m_lastCopied) { clipboard->clear(QClipboard::Clipboard); } if (clipboard->supportsSelection() && (clipboard->text(QClipboard::Selection) == m_lastCopied)) { clipboard->clear(QClipboard::Selection); } m_lastCopied.clear(); }
// The ctor. QsciScintillaBase::QsciScintillaBase(QWidget *parent) : QAbstractScrollArea(parent) { connect(verticalScrollBar(), SIGNAL(valueChanged(int)), SLOT(handleVSb(int))); connect(horizontalScrollBar(), SIGNAL(valueChanged(int)), SLOT(handleHSb(int))); setAcceptDrops(true); setFocusPolicy(Qt::WheelFocus); setAttribute(Qt::WA_KeyCompression); viewport()->setBackgroundRole(QPalette::Base); viewport()->setMouseTracking(true); viewport()->setAttribute(Qt::WA_NoSystemBackground); triple_click.setSingleShot(true); sci = new ScintillaQt(this); curseurs = new QMap<int, Curseur*>; lockedLines = new QList<int>; SendScintilla(SCI_SETCARETPERIOD, QApplication::cursorFlashTime() / 2); // Make sure the lexers are linked in. if (!lexersLinked) { Scintilla_LinkLexers(); lexersLinked = true; } QClipboard *cb = QApplication::clipboard(); if (cb->supportsSelection()) connect(cb, SIGNAL(selectionChanged()), SLOT(handleSelection())); // Add it to the pool. poolList.append(this); }
void db_base::pem2clipboard() { long l; const char *p; QString msg; QClipboard *cb = QApplication::clipboard(); BIO *bio = BIO_new(BIO_s_mem()); if (!currentIdx.isValid()) return; pki_base *pki = static_cast<pki_base*>(currentIdx.internalPointer()); pki->pem(bio); openssl_error(); l = BIO_get_mem_data(bio, &p); msg = QString::fromUtf8(p, l); BIO_free(bio); if (cb->supportsSelection()) cb->setText(msg, QClipboard::Selection); else cb->setText(msg); }
// Handle a mouse button press. void QsciScintillaBase::mousePressEvent(QMouseEvent *e) { setFocus(); Point pt(e->x(), e->y()); if (e->button() == Qt::LeftButton) { unsigned clickTime; // It is a triple click if the timer is running and the mouse hasn't // moved too much. if (triple_click.isActive() && (e->globalPos() - triple_click_at).manhattanLength() < QApplication::startDragDistance()) clickTime = sci->lastClickTime + Platform::DoubleClickTime() - 1; else clickTime = sci->lastClickTime + Platform::DoubleClickTime() + 1; triple_click.stop(); bool shift = e->modifiers() & Qt::ShiftModifier; bool ctrl = e->modifiers() & Qt::ControlModifier; bool alt = e->modifiers() & Qt::AltModifier; sci->ButtonDown(pt, clickTime, shift, ctrl, alt); } else if (e->button() == Qt::MidButton) { QClipboard *cb = QApplication::clipboard(); if (cb->supportsSelection()) { int pos = sci->PositionFromLocation(pt); sci->SetSelection(pos, pos); sci->pasteFromClipboard(QClipboard::Selection); } } }
void toMain::editEnable ( toEditWidget *edit ) { toMain * main = ( toMain * ) qApp->mainWidget(); if ( main ) main->editEnable ( edit, edit->openEnabled(), edit->saveEnabled(), edit->printEnabled(), edit->undoEnabled(), edit->redoEnabled(), edit->cutEnabled(), edit->copyEnabled(), edit->pasteEnabled(), edit->searchEnabled(), edit->selectAllEnabled(), edit->readAllEnabled() ); #if QT_VERSION >= 300 // Set Selection Mode on X11 QClipboard *clip = qApp->clipboard(); if ( clip->supportsSelection() ) clip->setSelectionMode ( true ); #endif }
void KviIrcView::mouseReleaseEvent(QMouseEvent *e) { if(m_pSelectionInitLine) { killTimer(m_iSelectTimer); m_iSelectTimer = 0; KviIrcViewLine *tempLine=getVisibleLineAt(e->pos().y()); if(tempLine) { m_pSelectionEndLine = tempLine; int iTmp=getVisibleCharIndexAt(m_pSelectionEndLine, e->pos().x(), e->pos().y()); if(iTmp > -1) m_iSelectionEndCharIndex = iTmp; } //check if selection is bottom to top or viceversa KviIrcViewLine *init, *end; int initChar, endChar; if(m_pSelectionInitLine->uIndex == m_pSelectionEndLine->uIndex) { init=m_pSelectionInitLine; end=m_pSelectionEndLine; if(m_iSelectionInitCharIndex<=m_iSelectionEndCharIndex) { //one line ltor selection initChar=m_iSelectionInitCharIndex; endChar=m_iSelectionEndCharIndex; } else { //one line rtol selection initChar=m_iSelectionEndCharIndex; endChar=m_iSelectionInitCharIndex; } } else if(m_pSelectionInitLine->uIndex < m_pSelectionEndLine->uIndex) { //multi line uptobottom selection init=m_pSelectionInitLine; end=m_pSelectionEndLine; initChar=m_iSelectionInitCharIndex; endChar=m_iSelectionEndCharIndex; } else { //multi line bottomtotop selection end=m_pSelectionInitLine; init=m_pSelectionEndLine; initChar=m_iSelectionEndCharIndex; endChar=m_iSelectionInitCharIndex; } tempLine = init; QString szSelectionText; while(tempLine) { if(KVI_OPTION_BOOL(KviOption_boolRequireControlToCopy) && !m_bCtrlPressed) break; if(tempLine->uIndex == init->uIndex) { if(tempLine->uIndex == end->uIndex) { //selection starts and ends in this line if(m_bShiftPressed) { bool bStarted=false; KviIrcViewLineChunk *pC; for(unsigned int i=0;i<tempLine->uChunkCount; i++) { pC = &tempLine->pChunks[i]; if(bStarted) { if(endChar >= (pC->iTextStart + pC->iTextLen)) { //the entire chunk is included addControlCharacter(pC, szSelectionText); szSelectionText.append(tempLine->szText.mid(pC->iTextStart, pC->iTextLen)); } else { //ends in this chunk addControlCharacter(pC, szSelectionText); szSelectionText.append(tempLine->szText.mid(pC->iTextStart, endChar-pC->iTextStart)); break; } } else { if(initChar <= (pC->iTextStart + pC->iTextLen)) { //starts in this chunk addControlCharacter(pC, szSelectionText); if((endChar-initChar) > pC->iTextLen) { //don't end in this chunk szSelectionText.append(tempLine->szText.mid(initChar, pC->iTextLen-(initChar-pC->iTextStart))); bStarted=true; } else { //ends in this chunk szSelectionText.append(tempLine->szText.mid(initChar, endChar-initChar)); break; } } } } } else { szSelectionText.append(tempLine->szText.mid(initChar, endChar-initChar)); } break; } else { // the first line of a multi line selection if(m_bShiftPressed) { bool bStarted=false; KviIrcViewLineChunk *pC; for(unsigned int i=0;i<tempLine->uChunkCount; i++) { pC = &tempLine->pChunks[i]; if(bStarted) { //the entire chunk is included addControlCharacter(pC, szSelectionText); szSelectionText.append(tempLine->szText.mid(pC->iTextStart, pC->iTextLen)); } else { if(initChar <= (pC->iTextStart + pC->iTextLen)) { //starts in this chunk addControlCharacter(pC, szSelectionText); szSelectionText.append(tempLine->szText.mid(initChar, pC->iTextLen-(initChar-pC->iTextStart))); bStarted=true; } } } } else { szSelectionText.append(tempLine->szText.mid(initChar)); } szSelectionText.append("\n"); } } else { if(tempLine->uIndex == end->uIndex) { // the last line of a multi line selection if(m_bShiftPressed) { KviIrcViewLineChunk *pC; for(unsigned int i=0;i<tempLine->uChunkCount; i++) { pC = &tempLine->pChunks[i]; if(endChar >= (pC->iTextStart + pC->iTextLen)) { //the entire chunk is included addControlCharacter(pC, szSelectionText); szSelectionText.append(tempLine->szText.mid(pC->iTextStart, pC->iTextLen)); } else { //ends in this chunk addControlCharacter(pC, szSelectionText); szSelectionText.append(tempLine->szText.mid(pC->iTextStart, endChar-pC->iTextStart)); break; } } } else { szSelectionText.append(tempLine->szText.left(endChar)); } break; } else { //a middle line of a multi line selection if(m_bShiftPressed) { KviIrcViewLineChunk *pC; for(unsigned int i=0;i<tempLine->uChunkCount; i++) { pC = &tempLine->pChunks[i]; //the entire chunk is included addControlCharacter(pC, szSelectionText); szSelectionText.append(tempLine->szText.mid(pC->iTextStart, pC->iTextLen)); } } else { szSelectionText.append(tempLine->szText); } szSelectionText.append("\n"); } } tempLine = tempLine->pNext; } QClipboard * c = QApplication::clipboard(); if(c && !szSelectionText.isEmpty()) { // copy to both! c->setText(szSelectionText,QClipboard::Clipboard); if(c->supportsSelection()) c->setText(szSelectionText,QClipboard::Selection); } m_pSelectionInitLine = 0; m_pSelectionEndLine = 0; m_iSelectionInitCharIndex=0; m_iSelectionEndCharIndex=0; } if(m_bMouseIsDown) { m_bMouseIsDown = false; m_bShiftPressed = false; m_bCtrlPressed = false; // Insert the lines blocked while selecting while(KviIrcViewLine * l = m_pMessagesStoppedWhileSelecting->first()) { m_pMessagesStoppedWhileSelecting->removeFirst(); appendLine(l,false); } repaint(); } }
ClipSaver (elMundo& mundoParaSalvar) : elSalvador(mundoParaSalvar) { if (!theClipboard) { theClipboard = QApplication::clipboard(); clipMode = theClipboard->supportsSelection() ? QClipboard::Selection : QClipboard::Clipboard; } }