mirror-chatterino2/src/util/Clipboard.cpp
Alexey Kutepov 00414eb779 Synchronize Clipboard with Primary Selection on Linux when copying (#1502)
* Introduce crossPlatformCopy()

It sets the text of the clipboard and also syncs it with the selection
clipboard if it is supported. Such behaviour is pretty common for X11
application on Unix-like Operating Systems.

* Fix clang-format remarks

* Fix weird clang-format config discrepancy between my machine and CI

* Remove clipboard argument from crossPlatformCopy

* Fix clang-format remarks
2020-01-24 21:36:51 +01:00

17 lines
342 B
C++

#include "util/Clipboard.hpp"
#include <QApplication>
namespace chatterino {
void crossPlatformCopy(const QString &text)
{
auto clipboard = QApplication::clipboard();
clipboard->setText(text);
if (clipboard->supportsSelection())
{
clipboard->setText(text, QClipboard::Selection);
}
}
} // namespace chatterino