]> git.lyx.org Git - features.git/blob - src/frontends/qt/GuiSelection.h
Fix broken Apple speller interface
[features.git] / src / frontends / qt / GuiSelection.h
1 // -*- C++ -*-
2 /**
3  * \file qt/GuiSelection.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author unknown
8  * \author John Levon
9  * \author Abdelrazak Younes
10  *
11  * Full author contact details are available in file CREDITS.
12  */
13
14 #ifndef GUISELECTION_H
15 #define GUISELECTION_H
16
17 #include "frontends/Selection.h"
18
19 #include <QObject>
20
21 namespace lyx {
22 namespace frontend {
23
24 /**
25  * The Qt version of the Selection.
26  */
27 class GuiSelection : public QObject, public Selection
28 {
29         Q_OBJECT
30 public:
31         GuiSelection();
32         virtual ~GuiSelection() {}
33
34         /** Selection overloaded methods
35          */
36         //@{
37         bool supported() const override { return selection_supported_; }
38         void haveSelection(bool own) override;
39         docstring const get() const override;
40         void put(docstring const & str) override;
41         bool empty() const override;
42         //@}
43
44 private Q_SLOTS:
45         void on_dataChanged();
46
47 private:
48         // Direct call clipboard()->text(QClipboard::Selection) inside onDataChanged causes
49         // selection to be obtained. Now imagine the some LyX instance A, when making selection -
50         // each change triggers onDataChange in all others instances for each mouse
51         // or keyboard move. This in turn causes many calls of requestSelection in A
52         // which interferes with the selecting itself. As a result middle button pasting
53         // for more instances don't work and debugging is a hell. So we just schedule
54         // obtaining of selection on the time empty() is actually called.
55         mutable bool schedule_check_;
56         bool const selection_supported_;
57 };
58
59 } // namespace frontend
60 } // namespace lyx
61
62 #endif // GUISELECTION_H