]> git.lyx.org Git - features.git/blobdiff - src/frontends/qt4/GuiClipboard.h
Fix #6597: LyX Appears frozen if the process holding the clipboard is frozen
[features.git] / src / frontends / qt4 / GuiClipboard.h
index d0552a828136292e6e9aafd2ced55dc513d43f72..5e1327352df3bdf45deb6414a51765d4fdf3bd74 100644 (file)
 
 #include "frontends/Clipboard.h"
 
+#include <QMimeData>
 #include <QObject>
+#include <QStringList>
 
 namespace lyx {
 namespace frontend {
 
 class QMacPasteboardMimeGraphics;
 
+/**
+ *  \class CacheMimeData 
+ * 
+ *  This class is used in order to query the clipboard only once on 
+ *  startup and once each time the contents of the clipboard changes.
+ */
+class CacheMimeData : public QMimeData
+{
+       Q_OBJECT
+public:
+       // LyX calls "on_dataChanged" on startup, so it is not necessary to
+       // query the clipboard here.
+       CacheMimeData()
+       {}
+
+       /// reads the clipboard and updates the cached_formats_
+       void update();
+       /// returns the cached list of formats supported by the object
+       virtual QStringList formats() const { return cached_formats_; }
+       /// reads the clipboard and returns the data
+       QByteArray data(QString const & mimeType) const;
+
+private:
+       /// the cached list of formats supported by the object
+       QStringList cached_formats_;
+};
+
+
 /**
  * The Qt4 version of the Clipboard.
  */
@@ -57,6 +87,9 @@ private:
        bool text_clipboard_empty_;
        bool has_lyx_contents_;
        bool has_graphics_contents_;
+       /// the cached mime data used to describe the information
+       /// that can be stored in the clipboard
+       CacheMimeData cache_;
 };
 
 QString const lyxMimeType();