Copy to FindBuffer added by Cmd+E on OS X.
This commit is contained in:
		
							parent
							
								
									a89185565a
								
							
						
					
					
						commit
						e015a8299e
					
				
					 4 changed files with 50 additions and 0 deletions
				
			
		| 
						 | 
					@ -1471,6 +1471,10 @@ void HistoryInner::keyPressEvent(QKeyEvent *e) {
 | 
				
			||||||
		_widget->onListEscapePressed();
 | 
							_widget->onListEscapePressed();
 | 
				
			||||||
	} else if (e == QKeySequence::Copy && !_selected.isEmpty()) {
 | 
						} else if (e == QKeySequence::Copy && !_selected.isEmpty()) {
 | 
				
			||||||
		copySelectedText();
 | 
							copySelectedText();
 | 
				
			||||||
 | 
					#ifdef Q_OS_MAC
 | 
				
			||||||
 | 
						} else if (e->key() == Qt::Key_E && e->modifiers().testFlag(Qt::ControlModifier)) {
 | 
				
			||||||
 | 
							setToClipboard(getSelectedText(), QClipboard::FindBuffer);
 | 
				
			||||||
 | 
					#endif // Q_OS_MAC
 | 
				
			||||||
	} else if (e == QKeySequence::Delete) {
 | 
						} else if (e == QKeySequence::Delete) {
 | 
				
			||||||
		int32 selectedForForward, selectedForDelete;
 | 
							int32 selectedForForward, selectedForDelete;
 | 
				
			||||||
		getSelectionState(selectedForForward, selectedForDelete);
 | 
							getSelectionState(selectedForForward, selectedForDelete);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -345,6 +345,13 @@ void FlatInput::keyPressEvent(QKeyEvent *e) {
 | 
				
			||||||
		emit cancelled();
 | 
							emit cancelled();
 | 
				
			||||||
	} else if (e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter) {
 | 
						} else if (e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter) {
 | 
				
			||||||
		emit submitted(ctrl && shift);
 | 
							emit submitted(ctrl && shift);
 | 
				
			||||||
 | 
					#ifdef Q_OS_MAC
 | 
				
			||||||
 | 
						} else if (e->key() == Qt::Key_E && e->modifiers().testFlag(Qt::ControlModifier)) {
 | 
				
			||||||
 | 
							auto selected = selectedText();
 | 
				
			||||||
 | 
							if (!selected.isEmpty() && echoMode() == QLineEdit::Normal) {
 | 
				
			||||||
 | 
								QApplication::clipboard()->setText(selected, QClipboard::FindBuffer);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					#endif // Q_OS_MAC
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1229,6 +1236,14 @@ void InputArea::InputAreaInner::keyPressEvent(QKeyEvent *e) {
 | 
				
			||||||
		e->ignore();
 | 
							e->ignore();
 | 
				
			||||||
	} else if (f()->_customUpDown && (e->key() == Qt::Key_Up || e->key() == Qt::Key_Down)) {
 | 
						} else if (f()->_customUpDown && (e->key() == Qt::Key_Up || e->key() == Qt::Key_Down)) {
 | 
				
			||||||
		e->ignore();
 | 
							e->ignore();
 | 
				
			||||||
 | 
					#ifdef Q_OS_MAC
 | 
				
			||||||
 | 
						} else if (e->key() == Qt::Key_E && e->modifiers().testFlag(Qt::ControlModifier)) {
 | 
				
			||||||
 | 
							auto cursor = textCursor();
 | 
				
			||||||
 | 
							int start = cursor.selectionStart(), end = cursor.selectionEnd();
 | 
				
			||||||
 | 
							if (end > start) {
 | 
				
			||||||
 | 
								QApplication::clipboard()->setText(f()->getText(start, end), QClipboard::FindBuffer);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					#endif // Q_OS_MAC
 | 
				
			||||||
	} else {
 | 
						} else {
 | 
				
			||||||
		QTextCursor tc(textCursor());
 | 
							QTextCursor tc(textCursor());
 | 
				
			||||||
		if (enter && ctrl) {
 | 
							if (enter && ctrl) {
 | 
				
			||||||
| 
						 | 
					@ -1944,6 +1959,14 @@ void InputField::InputFieldInner::keyPressEvent(QKeyEvent *e) {
 | 
				
			||||||
		e->ignore();
 | 
							e->ignore();
 | 
				
			||||||
	} else if (f()->_customUpDown && (e->key() == Qt::Key_Up || e->key() == Qt::Key_Down)) {
 | 
						} else if (f()->_customUpDown && (e->key() == Qt::Key_Up || e->key() == Qt::Key_Down)) {
 | 
				
			||||||
		e->ignore();
 | 
							e->ignore();
 | 
				
			||||||
 | 
					#ifdef Q_OS_MAC
 | 
				
			||||||
 | 
						} else if (e->key() == Qt::Key_E && e->modifiers().testFlag(Qt::ControlModifier)) {
 | 
				
			||||||
 | 
							auto cursor = textCursor();
 | 
				
			||||||
 | 
							int start = cursor.selectionStart(), end = cursor.selectionEnd();
 | 
				
			||||||
 | 
							if (end > start) {
 | 
				
			||||||
 | 
								QApplication::clipboard()->setText(f()->getText(start, end), QClipboard::FindBuffer);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					#endif // Q_OS_MAC
 | 
				
			||||||
	} else {
 | 
						} else {
 | 
				
			||||||
		QTextCursor tc(textCursor());
 | 
							QTextCursor tc(textCursor());
 | 
				
			||||||
		if (enter && ctrl) {
 | 
							if (enter && ctrl) {
 | 
				
			||||||
| 
						 | 
					@ -2338,6 +2361,13 @@ void MaskedInputField::keyPressEvent(QKeyEvent *e) {
 | 
				
			||||||
		emit cancelled();
 | 
							emit cancelled();
 | 
				
			||||||
	} else if (e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter) {
 | 
						} else if (e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter) {
 | 
				
			||||||
		emit submitted(ctrl && shift);
 | 
							emit submitted(ctrl && shift);
 | 
				
			||||||
 | 
					#ifdef Q_OS_MAC
 | 
				
			||||||
 | 
						} else if (e->key() == Qt::Key_E && e->modifiers().testFlag(Qt::ControlModifier)) {
 | 
				
			||||||
 | 
							auto selected = selectedText();
 | 
				
			||||||
 | 
							if (!selected.isEmpty() && echoMode() == QLineEdit::Normal) {
 | 
				
			||||||
 | 
								QApplication::clipboard()->setText(selected, QClipboard::FindBuffer);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					#endif // Q_OS_MAC
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -304,6 +304,13 @@ void FlatLabel::keyPressEvent(QKeyEvent *e) {
 | 
				
			||||||
			onCopySelectedText();
 | 
								onCopySelectedText();
 | 
				
			||||||
			e->accept();
 | 
								e->accept();
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					#ifdef Q_OS_MAC
 | 
				
			||||||
 | 
						} else if (e->key() == Qt::Key_E && e->modifiers().testFlag(Qt::ControlModifier)) {
 | 
				
			||||||
 | 
							auto selection = _selection.empty() ? (_contextMenu ? _savedSelection : _selection) : _selection;
 | 
				
			||||||
 | 
							if (!selection.empty()) {
 | 
				
			||||||
 | 
								QApplication::clipboard()->setText(_text.originalText(selection, _contextExpandLinksMode), QClipboard::FindBuffer);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					#endif // Q_OS_MAC
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1337,6 +1337,15 @@ void FlatTextarea::keyPressEvent(QKeyEvent *e) {
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	} else if (e->key() == Qt::Key_Search || e == QKeySequence::Find) {
 | 
						} else if (e->key() == Qt::Key_Search || e == QKeySequence::Find) {
 | 
				
			||||||
		e->ignore();
 | 
							e->ignore();
 | 
				
			||||||
 | 
					#ifdef Q_OS_MAC
 | 
				
			||||||
 | 
						} else if (e->key() == Qt::Key_E && e->modifiers().testFlag(Qt::ControlModifier)) {
 | 
				
			||||||
 | 
							auto cursor = textCursor();
 | 
				
			||||||
 | 
							int start = cursor.selectionStart(), end = cursor.selectionEnd();
 | 
				
			||||||
 | 
							if (end > start) {
 | 
				
			||||||
 | 
								TagList tags;
 | 
				
			||||||
 | 
								QApplication::clipboard()->setText(getTextPart(start, end, &tags), QClipboard::FindBuffer);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					#endif // Q_OS_MAC
 | 
				
			||||||
	} else {
 | 
						} else {
 | 
				
			||||||
		QTextCursor tc(textCursor());
 | 
							QTextCursor tc(textCursor());
 | 
				
			||||||
		if (enter && ctrl) {
 | 
							if (enter && ctrl) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue