/** Show Event: * When the dialog is shown, try to extract a URL from the clipboard * and paste it in the Edit box. * showEvent can happen not only on exec() but I think it's cool to * actualize the URL on showEvent (eg. change virtual desktop...) **/ void OpenUrlDialog::showEvent( QShowEvent *ev ) { (void) ev; bShouldEnqueue = false; edit->setFocus( Qt::OtherFocusReason ); if( !lastUrl.isEmpty() && edit->text().isEmpty() ) { /* The text should not have been changed, excepted if the user has clicked Cancel before */ edit->setText( lastUrl ); } else edit->clear(); if( bClipboard ) { QClipboard *clipboard = QApplication::clipboard(); assert( clipboard != NULL ); QString txt = clipboard->text( QClipboard::Selection ).trimmed(); if( txt.isEmpty() || ( !txt.contains("://") && !QFile::exists(txt) ) ) txt = clipboard->text( QClipboard::Clipboard ).trimmed(); if( txt.contains( "://" ) || QFile::exists( txt ) ) edit->setText( txt ); } }
QgsFeatureList QgsClipboard::copyOf( const QgsFields &fields ) { QgsDebugMsg( "returning clipboard." ); if ( !mUseSystemClipboard ) return mFeatureClipboard; QClipboard *cb = QApplication::clipboard(); #ifndef Q_OS_WIN QString text = cb->text( QClipboard::Selection ); #else QString text = cb->text( QClipboard::Clipboard ); #endif QStringList values = text.split( "\n" ); if ( values.isEmpty() || text.isEmpty() ) return mFeatureClipboard; QgsFeatureList features; foreach ( QString row, values ) { // Assume that it's just WKT for now. QgsGeometry* geometry = QgsGeometry::fromWkt( row ); if ( !geometry ) continue; QgsFeature* feature = new QgsFeature(); if ( !fields.isEmpty() ) feature->setFields( &fields, true ); feature->setGeometry( geometry ); features.append( QgsFeature( *feature ) ); }
/** * Get selection from clipboard * */ void clip_mch_request_selection(VimClipboard *cbd) { QClipboard *clip = QApplication::clipboard(); if ( clip->text((QClipboard::Mode)cbd->clipboardMode).size() == 0 ) { return; } QByteArray text = VimWrapper::convertTo(clip->text( (QClipboard::Mode)cbd->clipboardMode)); if ( text.isEmpty() ) { // This should not happen, but if it does vim // behaves badly so lets be extra carefull return; } char_u *buffer; buffer = lalloc( text.size(), TRUE); if (buffer == NULL) return; for (int i = 0; i < text.size(); ++i) { buffer[i] = text[i]; } clip_yank_selection(MAUTO, buffer, text.size(), cbd); vim_free(buffer); }
QString wzGetSelection() { QString aText; QClipboard *clipboard = QApplication::clipboard(); aText = clipboard->text(QClipboard::Selection); // try X11 specific buffer first if (aText.isEmpty()) aText = clipboard->text(QClipboard::Clipboard); // if not, try generic clipboard return aText; }
// The hack for Windows: periodically check for clipboard changes void ImodClipboard::clipHackTimeout() { QClipboard *cb = QApplication::clipboard(); //cb->setSelectionMode(false); if (cb->text() == mSavedClipboard) return; mSavedClipboard = cb->text(); clipboardChanged(); }
int main(int argc, char **argv) { QApplication app(argc, argv); QClipboard *board = QApplication::clipboard(); #ifdef Q_OS_WINCE return (board->text() == QLatin1String("testString.!")) ? 0 : 1; #else return (board->text() == app.arguments().at(1)) ? 0 : 1; #endif }
void QtCalculator::display_selected(){ if(calc_display->Button() == LeftButton){ if(calc_display->isLit()){ QClipboard *cb = QApplication::clipboard(); cb->setText(calc_display->text()); selection_timer->start(100); } else{ selection_timer->stop(); } invertColors(); } else{ QClipboard *cb = QApplication::clipboard(); CALCAMNT result; result = (CALCAMNT) cb->text().toDouble(); // printf("%Lg\n",result); last_input = PASTE; DISPLAY_AMOUNT = result; UpdateDisplay(); } }
QString GlobalConfigWidget::getClipboard() { QClipboard *clipboard = QApplication::clipboard(); switch( Settings::value( Settings::GlobalClipboardMode ) ) { case 1: case 3: return clipboard->text( QClipboard::Selection ); case 2: case 4: return clipboard->text( QClipboard::Clipboard ); default: return QString(); } }
// The clipboard changed - check for window ID and OK or ERROR // NOTE: on Windows, Qt 3 needed to exit with ::exit instead of // QApplication::exit, otherwise it would hang for a long time or until the // timeout occurred. It complains in Qt 4 about deleting an object during its // event handler, but qapp::exit seems fine now. void ImodSendEvent::clipboardChanged() { QClipboard *cb = QApplication::clipboard(); //cb->setSelectionMode(false); QString text = cb->text(); if (debugOut) fprintf(stderr, "Imodsendevent - clipboard = %s\n", LATIN1(text)); // Ignore if empty text, no spaces, starting space, or wrong ID if (text.isEmpty()) return; int index = text.indexOf(" "); if (index <= 0) return; if ((text.left(index)).toInt() != winID) return; // If OK, just exit; if ERROR, give message and exit with error status if (text.mid(index + 1) == "OK") { QApplication::exit(0); return; } if (text.mid(index + 1) != "ERROR") return; fprintf(stderr, "ERROR: imodsendevent - message received but error occurred " "executing it\n"); QApplication::exit(3); }
void VDirectoryTree::copySelectedDirectories(bool p_isCut) { QList<QTreeWidgetItem *> items = selectedItems(); if (items.isEmpty()) { return; } QJsonArray dirs; for (int i = 0; i < items.size(); ++i) { VDirectory *dir = getVDirectory(items[i]); dirs.append(dir->fetchPath()); } QJsonObject clip; clip[ClipboardConfig::c_magic] = getNewMagic(); clip[ClipboardConfig::c_type] = (int)ClipboardOpType::CopyDir; clip[ClipboardConfig::c_isCut] = p_isCut; clip[ClipboardConfig::c_dirs] = dirs; QClipboard *clipboard = QApplication::clipboard(); clipboard->setText(QJsonDocument(clip).toJson(QJsonDocument::Compact)); qDebug() << "copied directories info" << clipboard->text(); int cnt = dirs.size(); g_mainWin->showStatusMessage(tr("%1 %2 %3") .arg(cnt) .arg(cnt > 1 ? tr("folders") : tr("folder")) .arg(p_isCut ? tr("cut") : tr("copied"))); }
void SnippetCompleter::replaceClipboardVariable(QString &snippetContent) { if (snippetContent.contains("%clipboard")) { QClipboard *clipboard = QApplication::clipboard(); snippetContent.replace("%clipboard", clipboard->text()); } }
void MainWindow::on_actionPaste_FEN_triggered() { if (!view->ready) return; QClipboard *clipboard = QApplication::clipboard(); std::string originalText = clipboard->text().toUtf8().constData(); cBoard boardCopy = view->gameManager.board; if (!(view->gameManager.board.setBoard(originalText))) { QMessageBox msgBox; msgBox.setText("Invalid FEN"); msgBox.setIcon(QMessageBox::Warning); msgBox.setStandardButtons(QMessageBox::Ok); msgBox.setDefaultButton(QMessageBox::Ok); msgBox.exec(); view->gameManager.board = boardCopy; } else { view->display->updateSelected(-1); view->display->updateFromToIndicators(-1,-1); view->gameManager.moveHistory.clear(); } view->display->setPos(view->gameManager.board.currentPos); updateToPlayLabel(); if (view->checkGameState()) return; }
void Plot::paste() { QLocale l; QClipboard *clipboard = QApplication::clipboard(); QString text = clipboard->text(); if(!text.isEmpty()) { QList<QString> items = text.split('\n'); QList<float> values; for(int i = 0; i < items.count(); i++) { values.append(l.toFloat(items[i])); } this->detachItems(); // Insert new curves curve = new QwtPlotCurve( "y = sin(x)" ); curve->setRenderHint( QwtPlotItem::RenderAntialiased ); curve->setLegendAttribute( QwtPlotCurve::LegendShowLine, true ); curve->setPen( Qt::red ); curve->attach( this ); Data* data = new Data(&values); curve->setData(data); setAxisScale( yLeft, data->yMin, data->yMax); setAxisScale( xBottom, data->xMin, data->xMax); QwtPlotGrid* grid = new QwtPlotGrid(); grid->setPen(Qt::black, 0.1, Qt::DashLine); grid->attach(this); } }
/** * Checks if the action \a pMsg is available. This is for enabling/disabling * the corresponding buttons or menu items for this action. */ bool EditorView::onHasMsg(const char* pMsg) const { if (strcmp(pMsg,"Run")==0) return true; if (strcmp(pMsg,"DebugStart")==0) return true; if (strcmp(pMsg,"DebugStop")==0) return true; if (strcmp(pMsg,"SaveAs")==0) return true; if (strcmp(pMsg,"Print")==0) return true; if (strcmp(pMsg,"PrintPreview")==0) return true; if (strcmp(pMsg,"PrintPdf")==0) return true; if (strcmp(pMsg,"Save")==0) { return d->textEdit->document()->isModified(); } else if (strcmp(pMsg,"Cut")==0) { bool canWrite = !d->textEdit->isReadOnly(); return (canWrite && (d->textEdit->textCursor().hasSelection())); } else if (strcmp(pMsg,"Copy")==0) { return ( d->textEdit->textCursor().hasSelection() ); } else if (strcmp(pMsg,"Paste")==0) { QClipboard *cb = QApplication::clipboard(); QString text; // Copy text from the clipboard (paste) text = cb->text(); bool canWrite = !d->textEdit->isReadOnly(); return ( !text.isEmpty() && canWrite ); } else if (strcmp(pMsg,"Undo")==0) { return d->textEdit->document()->isUndoAvailable (); } else if (strcmp(pMsg,"Redo")==0) { return d->textEdit->document()->isRedoAvailable (); } return false; }
void ItemList::tick_clipboard() { PasspotPlugin *plugin = dynamic_cast<PasspotPlugin*>(get_plugin().pointer()); assert(NULL != plugin); QClipboard *board = QApplication::clipboard(); assert(NULL != board); const bool clipboard_changed = (_clipboard_hash != hash(board->text())); --_clipboard_countdown; if (!clipboard_changed && _clipboard_countdown > 0) { QString msg = _clipboard_status + QString(tr(" %1秒")).arg(_clipboard_countdown); plugin->show_status(msg, _clipboard_countdown * 1000); return; } if (clipboard_changed) { plugin->show_status(tr("剪贴板已经被覆盖"), 5000); } else { board->setText(QString()); plugin->show_status(tr("剪贴板已经被清空"), 5000); } _clipboard_hash = 0; _clipboard_countdown = 0; _clipboard_status.clear(); if (NULL != _clipboard_timer) _clipboard_timer->stop(); }
void MyLineEdit::PasteFromClipboard() { QClipboard *clipboard = QApplication::clipboard(); QString text = clipboard->text(); if (parameterContainer) { QString type = GetType(objectName()); if (type == QString("vect3") || type == QString("logvect3")) { QStringList numbersStr = text.split(' '); if (numbersStr.length() == 3) { QString nameVect = parameterName.left(parameterName.length() - 2); QString lineEditNameX, lineEditNameY, lineEditNameZ; if (type == QString("vect3")) { lineEditNameX = QString("vect3_%1_x").arg(nameVect); lineEditNameY = QString("vect3_%1_y").arg(nameVect); lineEditNameZ = QString("vect3_%1_z").arg(nameVect); } else if (type == QString("logvect3")) { lineEditNameX = QString("logvect3_%1_x").arg(nameVect); lineEditNameY = QString("logvect3_%1_y").arg(nameVect); lineEditNameZ = QString("logvect3_%1_z").arg(nameVect); } MyLineEdit *lineEditX = parent()->findChild<MyLineEdit *>(lineEditNameX); MyLineEdit *lineEditY = parent()->findChild<MyLineEdit *>(lineEditNameY); MyLineEdit *lineEditZ = parent()->findChild<MyLineEdit *>(lineEditNameZ); if (lineEditX) lineEditX->setText(numbersStr[0]); if (lineEditY) lineEditY->setText(numbersStr[1]); if (lineEditZ) lineEditZ->setText(numbersStr[2]); } emit editingFinished(); } if (type == QString("vect4")) { QStringList numbersStr = text.split(' '); if (numbersStr.length() == 4) { QString nameVect = parameterName.left(parameterName.length() - 2); QString lineEditNameX = QString("vect4_%1_x").arg(nameVect); QString lineEditNameY = QString("vect4_%1_y").arg(nameVect); QString lineEditNameZ = QString("vect4_%1_z").arg(nameVect); QString lineEditNameW = QString("vect4_%1_w").arg(nameVect); MyLineEdit *lineEditX = parent()->findChild<MyLineEdit *>(lineEditNameX); MyLineEdit *lineEditY = parent()->findChild<MyLineEdit *>(lineEditNameY); MyLineEdit *lineEditZ = parent()->findChild<MyLineEdit *>(lineEditNameZ); MyLineEdit *lineEditW = parent()->findChild<MyLineEdit *>(lineEditNameW); if (lineEditX) lineEditX->setText(numbersStr[0]); if (lineEditY) lineEditY->setText(numbersStr[1]); if (lineEditZ) lineEditZ->setText(numbersStr[2]); if (lineEditW) lineEditW->setText(numbersStr[3]); } emit editingFinished(); } } }
bool RKConsole::eventFilter (QObject *, QEvent *e) { if (e->type () == QEvent::KeyPress) { QKeyEvent *k = (QKeyEvent *)e; return handleKeyPress (k); } else if (e->type () == QEvent::MouseButtonPress){ QMouseEvent *m = (QMouseEvent *)e; if (m->button() == Qt::RightButton) { doPopupMenu (m->globalPos ()); return (true); } return (false); } else if (e->type () == QEvent::MouseButtonRelease){ QMouseEvent *m = (QMouseEvent *)e; if (m->button() == Qt::MidButton) { QClipboard *cb = QApplication::clipboard (); submitBatch (cb->text (QClipboard::Selection)); return (true); } /* else if (m->button () == Qt::LeftButton) { // prevent cursor from leaving last line uint para=0; uint p=0; view->cursorPosition (¶, &p); if (para != doc->numLines () - 1) { int y = view->y (); view->setCursorPosition (doc->numLines() -1, p); int y2 = view->y (); qDebug ("%d, %d", y, y2); view->scroll (0, y - y2); } } */ // not good, yet: always jumps to bottom of view return (false); } else { return false; } }
void Main::paste_word() { QClipboard *clip = QApplication::clipboard(); QString text = clip->text(); ui.paraula->setText(text); treballaBuscar(); }
int QUimTextUtil::acquireClipboardText( enum UTextOrigin origin, int former_req_len, int latter_req_len, char **former, char **latter ) { QClipboard *cb = QApplication::clipboard(); QString text = cb->text( QClipboard::Clipboard ); int len, offset, newline; if ( text.isNull() ) return -1; len = text.length(); /* Cursor position is assumed to be at the end */ switch ( origin ) { case UTextOrigin_Cursor: case UTextOrigin_End: offset = 0; if ( former_req_len >= 0 ) { if ( former_req_len < len ) offset = len - former_req_len; } else { if (! ( ~former_req_len & ( ~UTextExtent_Line | ~UTextExtent_Full ) ) ) return -1; if ( former_req_len == UTextExtent_Line && ( ( newline = text.lastIndexOf( '\n' ) ) != -1 ) ) offset = newline + 1; } *former = strdup( text.mid( offset, len - offset ).toUtf8().data() ); *latter = 0; break; case UTextOrigin_Beginning: *former = 0; offset = 0; if ( latter_req_len >= 0 ) { if ( latter_req_len < len ) offset = len - latter_req_len; } else { if (! ( ~latter_req_len & ( ~UTextExtent_Line | ~UTextExtent_Full ) ) ) return -1; if ( latter_req_len == UTextExtent_Line && ( ( newline = text.indexOf( '\n' ) ) != -1 ) ) offset = len - newline; } *latter = strdup( text.left( len - offset ).toUtf8().data() ); break; case UTextOrigin_Unspecified: default: return -1; } return 0; }
void QWinTerminalImpl::pasteClipboard (void) { QClipboard *clipboard = QApplication::clipboard(); QStringList commands = clipboard->text().split("\n"); for (int i = 0; i < commands.size (); i++) { this->sendText(commands.at (i)); } }
QString MainWindow::getHtmlFromClipboard() { QClipboard *clipboard = QApplication::clipboard(); QString subType="html"; QString html=clipboard->text(subType, QClipboard::Clipboard); return html; }
void Util::paste(const QListWidget *w) { QClipboard *cb = QApplication::clipboard(); QStringList lst = cb->text().split("\n"); const int size = lst.size(); for (int i=0; i<size; ++i) Util::addItem(w, lst[i]); }
void MythUITextEdit::PasteTextFromClipboard(QClipboard::Mode mode) { QClipboard *clipboard = QApplication::clipboard(); if (!clipboard->supportsSelection()) mode = QClipboard::Clipboard; if (clipboard) InsertText(clipboard->text(mode)); }
void DesignDocumentView::fromClipboard() { QClipboard *clipboard = QApplication::clipboard(); fromText(clipboard->text()); QStringList imports = arrayToStringList(clipboard->mimeData()->data(QLatin1String("QmlDesigner::imports"))); // foreach (const QString &importString, imports) { // Import import(Import::createLibraryImport(); // model()->addImport(import); //### imports // } }
void AddJobDialog::pasteActionTriggered(void) { if(QAction *action = dynamic_cast<QAction*>(QObject::sender())) { QClipboard *clipboard = QApplication::clipboard(); QLineEdit *lineEdit = reinterpret_cast<QLineEdit*>(action->data().value<void*>()); QString text = clipboard->text(); if(!text.isEmpty()) lineEdit->setText(text); } }
bool WidgetLeds::isLedFrameInClipboard() const { QClipboard *clipboard = QApplication::clipboard(); LedFrame lf; if (lf.fromText(clipboard->text())) return true; return false; }
void AddFriendForm::setIdFromClipboard() { QClipboard* clipboard = QApplication::clipboard(); QString id = clipboard->text().trimmed(); if (Core::getInstance()->isReady() && !id.isEmpty() && ToxId::isToxId(id)) { if (!ToxId(id).isSelf()) toxId.setText(id); } }
///Create a call from the clipboard content void SFLPhoneView::paste() { QClipboard* cb = QApplication::clipboard(); const QMimeData* data = cb->mimeData(); if (data->hasFormat(MIME_PHONENUMBER)) { m_pEventManager->typeString(data->data(MIME_PHONENUMBER)); } else { m_pEventManager->typeString(cb->text()); } }
/** * Pastes value from previously defined variable to selected cell. */ void DatasetEditWidget::pasteCell(){ QClipboard* clipboard = QApplication::clipboard(); QModelIndex index = ui->tableView->currentIndex(); bool ok = false; double editVal = clipboard->text().toDouble(&ok); if(ok){ model->viewModel()->setData(index, editVal, Qt::EditRole); model->setSaved(false); ui->tableView->update(index); } }
void CommunObject::copy2clipboard(const QString& results) { qDebug() << "copy2clipboard: " << results; //if (results == "") return false; QClipboard* clipboard = QGuiApplication::clipboard(); clipboard->setText(results); const QString originalText = clipboard->text(); // debug emit sendStatus("Clipboard text: " + originalText); }