Abdelrazak Younes wrote:
Jürgen Spitzmüller wrote:
Abdelrazak Younes wrote:
And not even compiled... here is another one that compiles and seems to
work fine.
This looks very sensible.
I asked the reporters on bugzilla for testing, to assure the this
fixes the bug.
Note that there might be a need for a similar fix in GuiSelection.
And here is an updated patch for that.
Abdel.
Index: GuiClipboard.cpp
===================================================================
--- GuiClipboard.cpp (revision 20564)
+++ GuiClipboard.cpp (working copy)
@@ -35,6 +35,15 @@
namespace lyx {
namespace frontend {
+GuiClipboard::GuiClipboard()
+{
+ connect(qApp->clipboard(), SIGNAL(dataChanged()),
+ this, SLOT(on_dataChanged()));
+ // initialize clipboard status.
+ on_dataChanged();
+}
+
+
string const GuiClipboard::getAsLyX() const
{
LYXERR(Debug::ACTION) << "GuiClipboard::getAsLyX(): `";
@@ -109,16 +118,27 @@
}
+void GuiClipboard::on_dataChanged()
+{
+ text_clipboard_empty_ = qApp->clipboard()->
+ text(QClipboard::Clipboard).isEmpty();
+
+ has_lyx_contents_ = hasLyXContents();
+}
+
+
bool GuiClipboard::empty() const
{
// We need to check both the plaintext and the LyX version of the
// clipboard. The plaintext version is empty if the LyX version
- // contains only one inset, and the LyX version is empry if the
+ // contains only one inset, and the LyX version is empty if the
// clipboard does not come from LyX.
- if (!qApp->clipboard()->text(QClipboard::Clipboard).isEmpty())
+ if (!text_clipboard_empty_)
return false;
- return !hasLyXContents();
+ return !has_lyx_contents_;
}
} // namespace frontend
} // namespace lyx
+
+#include "GuiClipboard_moc.cpp"
Index: GuiClipboard.h
===================================================================
--- GuiClipboard.h (revision 20564)
+++ GuiClipboard.h (working copy)
@@ -16,15 +16,19 @@
#include "frontends/Clipboard.h"
+#include <QObject>
+
namespace lyx {
namespace frontend {
/**
* The Qt4 version of the Clipboard.
*/
-class GuiClipboard: public Clipboard
+class GuiClipboard: public QObject, public Clipboard
{
+ Q_OBJECT
public:
+ GuiClipboard();
virtual ~GuiClipboard() {}
/** Clipboard overloaded methods
@@ -37,6 +41,13 @@
bool isInternal() const;
bool empty() const;
//@}
+
+private Q_SLOTS:
+ void on_dataChanged();
+
+private:
+ bool text_clipboard_empty_;
+ bool has_lyx_contents_;
};
} // namespace frontend
Index: GuiSelection.cpp
===================================================================
--- GuiSelection.cpp (revision 20564)
+++ GuiSelection.cpp (working copy)
@@ -30,6 +30,16 @@
namespace lyx {
namespace frontend {
+GuiSelection::GuiSelection()
+ : selection_supported_(qApp->clipboard()->supportsSelection())
+{
+ connect(qApp->clipboard(), SIGNAL(dataChanged()),
+ this, SLOT(on_dataChanged()));
+ // initialize clipboard status.
+ on_dataChanged();
+}
+
+
void GuiSelection::haveSelection(bool own)
{
if (!qApp->clipboard()->supportsSelection())
@@ -78,13 +88,22 @@
}
+void GuiSelection::on_dataChanged()
+{
+ text_selection_empty_ = qApp->clipboard()->
+ text(QClipboard::Selection).isEmpty();
+}
+
+
bool GuiSelection::empty() const
{
- if (!qApp->clipboard()->supportsSelection())
+ if (!selection_supported_)
return true;
- return qApp->clipboard()->text(QClipboard::Selection).isEmpty();
+ return text_selection_empty_;
}
} // namespace frontend
} // namespace lyx
+
+#include "GuiSelection_moc.cpp"
Index: GuiSelection.h
===================================================================
--- GuiSelection.h (revision 20564)
+++ GuiSelection.h (working copy)
@@ -16,15 +16,19 @@
#include "frontends/Selection.h"
+#include <QObject>
+
namespace lyx {
namespace frontend {
/**
* The Qt4 version of the Selection.
*/
-class GuiSelection : public Selection
+class GuiSelection : public QObject, public Selection
{
+ Q_OBJECT
public:
+ GuiSelection();
virtual ~GuiSelection() {}
/** Selection overloaded methods
@@ -35,6 +39,13 @@
void put(docstring const & str);
bool empty() const;
//@}
+
+private Q_SLOTS:
+ void on_dataChanged();
+
+private:
+ bool text_selection_empty_;
+ bool const selection_supported_;
};
} // namespace frontend
Index: Makefile.am
===================================================================
--- Makefile.am (revision 20564)
+++ Makefile.am (working copy)
@@ -35,10 +35,8 @@
DockView.h \
Dialogs.cpp \
FileDialog.cpp \
- GuiClipboard.h GuiClipboard.cpp \
GuiFontLoader.h GuiFontLoader.cpp \
GuiFontMetrics.h GuiFontMetrics.cpp \
- GuiSelection.h GuiSelection.cpp \
KeySymbol.cpp \
QLMenubar.cpp QLMenubar.h \
QBox.cpp QBox.h \
Index: Makefile.dialogs
===================================================================
--- Makefile.dialogs (revision 20564)
+++ Makefile.dialogs (working copy)
@@ -80,7 +80,9 @@
LyXFileDialog.cpp LyXFileDialog.h \
FloatPlacement.cpp FloatPlacement.h \
GuiApplication.cpp GuiApplication.h \
+ GuiClipboard.h GuiClipboard.cpp \
GuiImplementation.cpp GuiImplementation.h \
+ GuiSelection.h GuiSelection.cpp \
GuiView.cpp GuiView.h \
GuiWorkArea.cpp GuiWorkArea.h \
IconPalette.cpp IconPalette.h \