mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-08 16:13:56 +02:00
Use QClipboard::supportsSelection instead of ifdefs
This commit is contained in:
parent
620639ef83
commit
5c8820d5d8
4 changed files with 10 additions and 13 deletions
|
@ -1503,13 +1503,13 @@ void InnerWidget::mouseActionFinish(const QPoint &screenPos, Qt::MouseButton but
|
||||||
_mouseSelectType = TextSelectType::Letters;
|
_mouseSelectType = TextSelectType::Letters;
|
||||||
//_widget->noSelectingScroll(); // TODO
|
//_widget->noSelectingScroll(); // TODO
|
||||||
|
|
||||||
#if defined Q_OS_UNIX && !defined Q_OS_MAC
|
if (QGuiApplication::clipboard()->supportsSelection()
|
||||||
if (_selectedItem && _selectedText.from != _selectedText.to) {
|
&& _selectedItem
|
||||||
|
&& _selectedText.from != _selectedText.to) {
|
||||||
TextUtilities::SetClipboardText(
|
TextUtilities::SetClipboardText(
|
||||||
_selectedItem->selectedText(_selectedText),
|
_selectedItem->selectedText(_selectedText),
|
||||||
QClipboard::Selection);
|
QClipboard::Selection);
|
||||||
}
|
}
|
||||||
#endif // Q_OS_UNIX && !Q_OS_MAC
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void InnerWidget::updateSelected() {
|
void InnerWidget::updateSelected() {
|
||||||
|
|
|
@ -1382,8 +1382,9 @@ void HistoryInner::mouseActionFinish(
|
||||||
_widget->noSelectingScroll();
|
_widget->noSelectingScroll();
|
||||||
_widget->updateTopBarSelection();
|
_widget->updateTopBarSelection();
|
||||||
|
|
||||||
#if defined Q_OS_UNIX && !defined Q_OS_MAC
|
if (QGuiApplication::clipboard()->supportsSelection()
|
||||||
if (!_selected.empty() && _selected.cbegin()->second != FullSelection) {
|
&& !_selected.empty()
|
||||||
|
&& _selected.cbegin()->second != FullSelection) {
|
||||||
const auto [item, selection] = *_selected.cbegin();
|
const auto [item, selection] = *_selected.cbegin();
|
||||||
if (const auto view = item->mainView()) {
|
if (const auto view = item->mainView()) {
|
||||||
TextUtilities::SetClipboardText(
|
TextUtilities::SetClipboardText(
|
||||||
|
@ -1391,7 +1392,6 @@ void HistoryInner::mouseActionFinish(
|
||||||
QClipboard::Selection);
|
QClipboard::Selection);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif // Q_OS_UNIX && !Q_OS_MAC
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void HistoryInner::mouseReleaseEvent(QMouseEvent *e) {
|
void HistoryInner::mouseReleaseEvent(QMouseEvent *e) {
|
||||||
|
|
|
@ -2222,16 +2222,15 @@ void ListWidget::mouseActionFinish(
|
||||||
_mouseSelectType = TextSelectType::Letters;
|
_mouseSelectType = TextSelectType::Letters;
|
||||||
//_widget->noSelectingScroll(); // #TODO select scroll
|
//_widget->noSelectingScroll(); // #TODO select scroll
|
||||||
|
|
||||||
#if defined Q_OS_UNIX && !defined Q_OS_MAC
|
if (QGuiApplication::clipboard()->supportsSelection()
|
||||||
if (_selectedTextItem
|
&& _selectedTextItem
|
||||||
&& _selectedTextRange.from != _selectedTextRange.to) {
|
&& _selectedTextRange.from != _selectedTextRange.to) {
|
||||||
if (const auto view = viewForItem(_selectedTextItem)) {
|
if (const auto view = viewForItem(_selectedTextItem)) {
|
||||||
TextUtilities::SetClipboardText(
|
TextUtilities::SetClipboardText(
|
||||||
view->selectedText(_selectedTextRange),
|
view->selectedText(_selectedTextRange),
|
||||||
QClipboard::Selection);
|
QClipboard::Selection);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif // Q_OS_UNIX && !Q_OS_MAC
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ListWidget::mouseActionUpdate() {
|
void ListWidget::mouseActionUpdate() {
|
||||||
|
|
|
@ -2118,11 +2118,9 @@ void ListWidget::mouseActionFinish(
|
||||||
//_widget->noSelectingScroll(); // #TODO scroll by drag
|
//_widget->noSelectingScroll(); // #TODO scroll by drag
|
||||||
//_widget->updateTopBarSelection();
|
//_widget->updateTopBarSelection();
|
||||||
|
|
||||||
#if defined Q_OS_UNIX && !defined Q_OS_MAC
|
//if (QGuiApplication::clipboard()->supportsSelection() && hasSelectedText()) { // #TODO linux clipboard
|
||||||
//if (hasSelectedText()) { // #TODO linux clipboard
|
|
||||||
// TextUtilities::SetClipboardText(_selected.cbegin()->first->selectedText(_selected.cbegin()->second), QClipboard::Selection);
|
// TextUtilities::SetClipboardText(_selected.cbegin()->first->selectedText(_selected.cbegin()->second), QClipboard::Selection);
|
||||||
//}
|
//}
|
||||||
#endif // Q_OS_UNIX && !Q_OS_MAC
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ListWidget::applyDragSelection() {
|
void ListWidget::applyDragSelection() {
|
||||||
|
|
Loading…
Add table
Reference in a new issue