refactor: WlClipbaord::empty use QProcess

This commit is contained in:
sithlord48 2025-11-17 21:59:01 -05:00 committed by Chris Rizzitello
parent ab4feaa037
commit 4ebf5ff479

View file

@ -236,15 +236,18 @@ bool WlClipboard::empty()
if (!m_open) { if (!m_open) {
return false; return false;
} }
auto cmd = new QProcess(this);
cmd->setProgram(s_copyApp);
m_runningWlCopies.append(cmd);
connect(cmd, &QProcess::finished, this, [&] { m_runningWlCopies.removeAll(cmd); });
std::vector<const char *> args; QStringList args = {s_noNewLine, ""};
if (m_useClipboard) { if (!m_useClipboard)
args = {"wl-copy", nullptr}; args.prepend(s_isPrimary);
} else {
args = {"wl-copy", "-p", nullptr};
}
bool success = executeCommandWithInput(args, ""); cmd->setArguments(args);
cmd->start();
bool success = cmd->waitForStarted(100);
if (success) { if (success) {
// Update ownership and cache only if command succeeded // Update ownership and cache only if command succeeded