#include <QString>
#include <QStringList>
#include <QTextDocument>
+#include <QTimer>
#include <boost/crc.hpp>
namespace frontend {
-static QMimeData const * read_clipboard()
+static QMimeData const * read_clipboard()
{
LYXERR(Debug::CLIPBOARD, "Getting Clipboard");
QMimeData const * source =
}
-QByteArray CacheMimeData::data(QString const & mimeType) const
+QByteArray CacheMimeData::data(QString const & mimeType) const
{
return read_clipboard()->data(mimeType);
}
connect(qApp->clipboard(), SIGNAL(dataChanged()),
this, SLOT(on_dataChanged()));
// initialize clipboard status.
- on_dataChanged();
+ update();
}
image.save(toqstr(filename.absFileName()), "JPEG");
else
LATTEST(false);
-
+
return filename;
}
-
+
// get mime for type
QString mime;
switch (type) {
case WmfGraphicsType: mime = wmfMimeType(); break;
default: LASSERT(false, return FileName());
}
-
+
// get data
if (!cache_.hasFormat(mime))
return FileName();
<< filename.absFileName() << " for writing");
return FileName();
}
-
+
// write the (LinkBack) PDF data
f.write(ar);
if (type == LinkBackGraphicsType) {
case LyXTextType:
return cache_.hasFormat(lyxMimeType());
case PlainTextType:
- return cache_.hasText();
+ return cache_.hasText();
case HtmlTextType:
return cache_.hasHtml();
case LaTeXTextType:
#else
return false;
#endif // Q_OS_MAC
-
+
// get mime data
QStringList const & formats = cache_.formats();
LYXERR(Debug::CLIPBOARD, "We found " << formats.size() << " formats");
case PdfGraphicsType: mime = pdfMimeType(); break;
default: LASSERT(false, return false);
}
-
+
return cache_.hasFormat(mime);
}
bool GuiClipboard::hasInternal() const
{
// Windows and Mac OS X does not have the concept of ownership;
- // the clipboard is a fully global resource so all applications
+ // the clipboard is a fully global resource so all applications
// are notified of changes. However, on Windows ownership is
// emulated by Qt through the OleIsCurrentClipboard() API, while
// on Mac OS X we deal with this issue by ourself.
void GuiClipboard::on_dataChanged()
+{
+ update();
+#if defined(Q_OS_WIN) || defined(Q_CYGWIN_WIN)
+ // Retry on Windows (#10109)
+ if (cache_.formats().count() == 0) {
+ QTimer::singleShot(100, this, SLOT(update()));
+ }
+#endif
+}
+
+void GuiClipboard::update()
{
//Note: we do not really need to run cache_.update() unless the
//data has been changed *and* the GuiClipboard has been queried.