SelectShapesOP::~SelectShapesOP() { clearClipboard(); m_selection->clear(); m_selection->release(); }
void SoXipImageOverlayManager::loadOverlays() { // When the patient changes clearClipboard(); // Remove all the geometries from the switch mShapeSwitch->removeAllChildren(); mShapeSwitch->whichChild.setValue(-1); mCurrentSlice = -1; if( mImageData ) { SbString overlayStr = mImageData->getProperty( "overlays" ); SoNodeList nodes = XipOverlayUtils::loadOverlaysFromString( overlayStr.getString(), overlayStr.getLength(), TRUE ); for( int i = 0; i < nodes.getLength(); ++ i ) { if( !nodes[i]->isOfType( SoXipShapeList::getClassTypeId() ) ) { SoDebugError::post( __FILE__, "Invalid overlay node found in Dicom. Ignored." ); continue ; } mShapeSwitch->addChild( nodes[i] ); } } updateSliceMap(); }
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/ void cpaste() /* Paste: called either from te.c */ { /* or from le.c */ if (!cpopen || cpempt) { /* so have to work in any LE mode */ if (cb_new_data) fromClipboard(); } else clearClipboard(); //<- clear system Clipboard to avoid inconsistency if (cpempt) exc(E_NOOP); // (when 1st paste resets cpopen, and second one int oldTx = Lwnd? Lx:Tx; // gets data from Clipboard instead of LCtxt) cptinit(true); cpclose(); TxTop(LCtxt); if (qTxBottom(LCtxt)) return; // // In entering-argument mode, paste only the content of first line (disabling // full-line paste) and silently ignore the rest; the same when block selected // (only when it is 1-character wide, "tall cursor" mode) // if (leARGmode) pasteFromLCtxt(false); else if (BlockMark) { if (BlockTx != Tx) exc(E_BLOCKOUT); else { static comdesc cpPaste = { LE_PASTE, pasteFromClbuf, 0 }; int len = TxRead(LCtxt, clbuf); if (len == 0) return; if (clbuf[0] == CpSCH_NEW_LINE) cclen = aftotc(clbuf+1, len-1, ccbuf); else cclen = aftotc(clbuf, len, ccbuf); tallblockop(&cpPaste); } } else { pasteFromLCtxt(true); // First stored line may be pasted either as line while(!qTxBottom(LCtxt)){ // or as characters, exit LE mode for the rest of if (Lwnd) ExitLEmode(); // save buffer (if paste isn't finished) and move Tx = oldTx; Ty++; // cursor to saved position one line below, rinse pasteFromLCtxt(true); // and repeat pasting. } } }
/** * @brief MainWindow::readyRead */ void MainWindow::readyRead(bool finished = false) { QString output = ui->textBrowser->document()->toPlainText(); QString error = process->readAllStandardError(); if (error.size() > 0) { ui->textBrowser->setTextColor(Qt::red); output += error; } else { output += process->readAllStandardOutput(); if (finished && currentAction == GPG) { if (useClipboard) { QClipboard *clip = QApplication::clipboard(); QStringList tokens = output.split("\n"); clip->setText(tokens[0]); ui->statusBar->showMessage(tr("Password copied to clipboard"), 3000); if (useAutoclear) { QTimer::singleShot(1000*autoclearSeconds, this, SLOT(clearClipboard())); } if (hidePassword) { tokens.pop_front(); output = tokens.join("\n"); } if (hideContent) { output = tr("Content hidden"); } } } } output.replace(QRegExp("((http|https|ftp)\\://[a-zA-Z0-9\\-\\.]+\\.[a-zA-Z]{2,3}(:[a-zA-Z0-9]*)?/?([a-zA-Z0-9\\-\\._\\?\\,\\'/\\\\+&%\\$#\\=~])*)"), "<a href=\"\\1\">\\1</a>"); output.replace(QRegExp("\n"), "<br />"); ui->textBrowser->setHtml(output); }
void Clipboard::cleanup() { if (m_timer->isActive()) { m_timer->stop(); clearClipboard(); } }
Clipboard::Clipboard(QObject* parent) : QObject(parent) , m_timer(new QTimer(this)) { m_timer->setSingleShot(true); connect(m_timer, SIGNAL(timeout()), SLOT(clearClipboard())); connect(qApp, SIGNAL(aboutToQuit()), SLOT(cleanup())); }
bool SelectShapesOP::clear() { if (DrawRectangleOP::clear()) return true; clearClipboard(); m_selection->clear(); m_firstPos.setInvalid(); return false; }
bool SelectShapesOP::onKeyDown(int keyCode) { if (DrawRectangleOP::onKeyDown(keyCode)) return true; if (keyCode == WXK_DELETE) { m_shapeImpl->removeShapeSelection(); clear(); } else if (wxGetKeyState(WXK_CONTROL_X)) { clearClipboard(); m_selection->traverse(FetchAllVisitor<IShape>(m_clipboard)); for (size_t i = 0, n = m_clipboard.size(); i < n; ++i) m_clipboard[i]->retain(); m_shapeImpl->removeShapeSelection(); } else if (m_lastCtrlPress && (keyCode == 'c' || keyCode == 'C')/*wxGetKeyState(WXK_CONTROL_C)*/) { clearClipboard(); std::vector<PolygonShape*> polys; m_selection->traverse(FetchAllVisitor<PolygonShape>(polys)); for (size_t i = 0, n = polys.size(); i < n; ++i) m_clipboard.push_back(polys[i]->clone()); } else if (wxGetKeyState(WXK_CONTROL_V)) { for (size_t i = 0, n = m_clipboard.size(); i < n; ++i) { m_shapeImpl->insertShape(m_clipboard[i]->clone()); m_editPanel->Refresh(); } } m_lastCtrlPress = keyCode == WXK_CONTROL; return false; }
/** * @brief MainWindow::processFinished * @param exitCode * @param exitStatus */ void MainWindow::processFinished(int exitCode, QProcess::ExitStatus exitStatus) { if (exitStatus != QProcess::NormalExit || exitCode > 0) { ui->textBrowser->setTextColor(Qt::red); } readyRead(); enableUiElements(true); if (currentAction == GPG && useClipboard) { //Copy first line to clipboard QClipboard *clip = QApplication::clipboard(); QStringList tokens = ui->textBrowser->document()->toPlainText().split("\n",QString::SkipEmptyParts); clip->setText(tokens[0]); ui->statusBar->showMessage(tr("Password copied to clipboard"), 3000); if (useAutoclear) { QTimer::singleShot(1000*autoclearSeconds, this, SLOT(clearClipboard())); } } }
void restoreClipboard(){ //恢复剪贴板 if(clipExistData){ qDebug()<<"restore clipboard"; // qApp->clipboard()->clear();//没有这一句,粘贴板恢复几次程序就会莫名其妙的崩溃,得益于OleFlushClipboard API的介绍 //尽管加了clear()程序几乎不崩溃了,但偶尔会输出QClipboard::clear: Failed to clear data on clipboard后崩溃 // if (::OleSetClipboard(NULL) != S_OK) { // qErrnoWarning("QClipboard::clear: Failed to clear data on clipboard"); // return; // } if(clearClipboard()){ qDebug()<<"恢复剪贴板success"; qApp->clipboard()->setMimeData(backupClipData);//恢复剪贴板数据 }else{ qDebug()<<"恢复剪贴板失败"; } } }
void getSelectedText(){ //unHook(); backupClipboard(); //模拟发送ctrl+c复制选择的text进粘贴板 qDebug()<<"准备selected to clipboard"; //qApp->clipboard()->clear(); if(clearClipboard()){ POINT pt; GetCursorPos(&pt);//获得当前鼠标位置 HWND hwnd=WindowFromPoint(pt);//获得鼠标所在的窗口句柄 QChar buffer[128]; GetClassName(hwnd,(WCHAR*) buffer, 128); QString winclassname=QString::fromRawData(buffer,128); qDebug()<<"当前窗口"<<hwnd<<winclassname; if(winclassname.contains("Internet Explorer")){//ie以及ie内核的浏览器比如360安全浏览器,不支持发送ctrl+c(划译时不行,但是双击是可以) qDebug("ie内核"); PostMessage(hwnd,WM_COMMAND,0x0001000f,0);//使用spy截获的消息 // }else if(winclassname.contains("TXGuiFoundation")){ // qDebug()<<"QQ聊天窗口"; // SendMessage(hwnd,WM_CHAR,49,49); }else{ // keybd_event(VK_CONTROL, 0, 0, 0); // 按下 Ctrl // keybd_event('C', 0, 0, 0); // 按下 C // keybd_event('C', 0, KEYEVENTF_KEYUP, 0); // 放开 C // keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0); // 放开 Ctrl // int bScan=::MapVirtualKey('C',0); // qDebug()<<0x1D<<0x2e<<::MapVirtualKey(VK_CONTROL,0)<<::MapVirtualKey('C',0); //SendMessage(hwnd,WM_CAPTURECHANGED,0x0,0x0); keybd_event(VK_CONTROL, 0x1D, KEYEVENTF_EXTENDEDKEY, 1); // 按下 Ctrl keybd_event('C', 0x2E, 0,1); // 按下 C //Sleep(10); //PostMessage(hwnd,WM_PAINT,0x0,0x0);//使用spy截获的消息 keybd_event('C', 0x2E, KEYEVENTF_KEYUP, 1); // 放开 C keybd_event(VK_CONTROL,0x1D, KEYEVENTF_EXTENDEDKEY|KEYEVENTF_KEYUP, 1); // 放开 Ctrl } int iTimeOut=0; while (!qApp->clipboard()->mimeData()->hasText()){//判断剪贴簿内容是否为文字格式 Sleep(10); qApp->processEvents(); qDebug()<<"wait clip ok"<<iTimeOut<<qApp->clipboard()->text(); iTimeOut ++; if (iTimeOut > 2){ break; } } //qDebug()<<"wait clip ok"<<iTimeOut; if(qApp->clipboard()->mimeData()->hasText()){ //qDebug()<<"粘贴板内容"<<qApp->clipboard()->text(); DICT::querySelectedText(qApp->clipboard()->text()); } } restoreClipboard(); // setHook(); }