#include "clipboard.h"

#include <QClipboard>
#include <QApplication>
#include <QDebug>

Clipboard::Clipboard(QObject *parent) : QObject(parent)
{
    QClipboard *selectClip = QApplication::clipboard();
    connect(selectClip, &QClipboard::selectionChanged, [selectClip, this]() {
        clipText = selectClip->text(QClipboard::Mode::Selection);
        if(!scribeWordsDisabled && !clipText.trimmed().isEmpty())
        {
           emit selectWords();
        }
    });
}

QString Clipboard::getClipText()
{
    return clipText;
}

void Clipboard::onScribeWordsDisabled()
{
    scribeWordsDisabled = true;
}

void Clipboard::onScribeWordsIsabled()
{
    scribeWordsDisabled = false;
}
