]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiWorkArea.h
Use <cstdint> instead of <boost/cstdint.hpp>
[lyx.git] / src / frontends / qt4 / GuiWorkArea.h
index aa407e13c0141d6046be1b02a9fcc9b53e33926d..22e8bfdc0a32cc0589ee605230d714520baf8490 100644 (file)
@@ -16,6 +16,7 @@
 #include "ui_WorkAreaUi.h"
 
 #include "frontends/WorkArea.h"
+#include "frontends/KeySymbol.h"
 
 #include <QAbstractScrollArea>
 #include <QTabBar>
@@ -26,10 +27,6 @@ class QDropEvent;
 class QToolButton;
 class QWidget;
 
-#ifdef CursorShape
-#undef CursorShape
-#endif
-
 namespace lyx {
 
 class Buffer;
@@ -63,19 +60,14 @@ public:
        /// is GuiView in fullscreen mode?
        bool isFullScreen() const;
        ///
-       void scheduleRedraw();
-       ///
        BufferView & bufferView();
        ///
        BufferView const & bufferView() const;
        ///
-       void redraw(bool update_metrics);
+       void scheduleRedraw(bool update_metrics);
 
        /// return true if the key is part of a shortcut
        bool queryKeySym(KeySymbol const & key, KeyModifier mod) const;
-       /// Process Key pressed event.
-       /// This needs to be public because it is accessed externally by GuiView.
-       void processKeySym(KeySymbol const & key, KeyModifier mod);
 
        bool inDialogMode() const;
        void setDialogMode(bool mode);
@@ -83,8 +75,6 @@ public:
        ///
        GuiCompleter & completer();
 
-       Qt::CursorShape cursorShape() const;
-
        /// Return the GuiView this workArea belongs to
        GuiView const & view() const;
        GuiView & view();
@@ -93,10 +83,13 @@ public:
        double pixelRatio() const;
 
 public Q_SLOTS:
+       /// Process Key pressed event.
+       /// This needs to be public because it is accessed externally by GuiView.
+       void processKeySym(KeySymbol const & key, KeyModifier mod);
        ///
-       void stopBlinkingCursor();
+       void stopBlinkingCaret();
        ///
-       void startBlinkingCursor();
+       void startBlinkingCaret();
 
 Q_SIGNALS:
        ///
@@ -105,6 +98,8 @@ Q_SIGNALS:
        void busy(bool);
        ///
        void bufferViewChanged();
+       /// send key event to CompressorProxy
+       void compressKeySym(KeySymbol sym, KeyModifier mod, bool isAutoRepeat);
 
 private Q_SLOTS:
        /// Scroll the BufferView.
@@ -115,8 +110,8 @@ private Q_SLOTS:
        void scrollTo(int value);
        /// timer to limit triple clicks
        void doubleClickTimeout();
-       /// toggle the cursor's visibility
-       void toggleCursor();
+       /// toggle the caret's visibility
+       void toggleCaret();
        /// close this work area.
        /// Slot for Buffer::closing signal.
        void close();
@@ -165,6 +160,23 @@ private:
 }; // GuiWorkArea
 
 
+/// CompressorProxy adapted from Kuba Ober https://stackoverflow.com/a/21006207
+class CompressorProxy : public QObject
+{
+    Q_OBJECT
+       bool emitCheck(bool isAutoRepeat);
+       bool flag_;
+       // input: event to compress
+       Q_SLOT void slot(KeySymbol sym, KeyModifier mod, bool isAutoRepeat);
+       // output: compressed event
+    Q_SIGNAL void signal(KeySymbol sym, KeyModifier mod);
+public:
+    // No default constructor, since the proxy must be a child of the
+    // target object.
+       explicit CompressorProxy(GuiWorkArea * wa);
+};
+
+
 class EmbeddedWorkArea : public GuiWorkArea
 {
        Q_OBJECT
@@ -193,6 +205,8 @@ private:
 }; // EmbeddedWorkArea
 
 
+class GuiWorkAreaContainer;
+
 /// A tabbed set of GuiWorkAreas.
 class TabWorkArea : public QTabWidget
 {
@@ -200,6 +214,10 @@ class TabWorkArea : public QTabWidget
 public:
        TabWorkArea(QWidget * parent = 0);
 
+       /// hide QTabWidget methods
+       GuiWorkAreaContainer * currentWidget() const;
+       GuiWorkAreaContainer * widget(int index) const;
+
        ///
        void setFullScreen(bool full_screen);
        void showBar(bool show);
@@ -207,10 +225,9 @@ public:
        bool setCurrentWorkArea(GuiWorkArea *);
        GuiWorkArea * addWorkArea(Buffer & buffer, GuiView & view);
        bool removeWorkArea(GuiWorkArea *);
-       GuiWorkArea * currentWorkArea();
-       GuiWorkArea * workArea(Buffer & buffer);
-       GuiWorkArea const * workArea(int index) const;
-       GuiWorkArea * workArea(int index);
+       GuiWorkArea * currentWorkArea() const;
+       GuiWorkArea * workArea(Buffer & buffer) const;
+       GuiWorkArea * workArea(int index) const;
        void paintEvent(QPaintEvent *);
 
 Q_SIGNALS:
@@ -230,7 +247,7 @@ public Q_SLOTS:
        void moveTab(int fromIndex, int toIndex);
        ///
        void updateTabTexts();
-       
+
 private Q_SLOTS:
        ///
        void on_currentTabChanged(int index);
@@ -245,6 +262,9 @@ private Q_SLOTS:
        int indexOfWorkArea(GuiWorkArea * w) const;
 
 private:
+       using QTabWidget::addTab;
+       using QTabWidget::insertTab;
+
        /// true if position is a tab (rather than the blank space in tab bar)
        bool posIsTab(QPoint position);
 
@@ -256,36 +276,10 @@ private:
 }; // TabWorkArea
 
 
-class DragTabBar : public QTabBar
-{
-       Q_OBJECT
-public:
-       ///
-       DragTabBar(QWidget * parent = 0);
-
-protected:
-       ///
-       void mousePressEvent(QMouseEvent * event);
-       ///
-       void mouseMoveEvent(QMouseEvent * event);
-       ///
-       void dragEnterEvent(QDragEnterEvent * event);
-       ///
-       void dropEvent(QDropEvent * event);
-
-private:
-       ///
-       QPoint dragStartPos_;
-
-Q_SIGNALS:
-       ///
-       void tabMoveRequested(int fromIndex, int toIndex);
-};
-
-
 class GuiWorkAreaContainer : public QWidget, public Ui::WorkAreaUi
 {
        Q_OBJECT
+       // non-null
        GuiWorkArea * const wa_;
        void dispatch(FuncRequest f) const;
 
@@ -298,8 +292,9 @@ protected:
        void mouseDoubleClickEvent(QMouseEvent * event); //override
 
 public:
-       ///
+       /// wa != 0
        GuiWorkAreaContainer(GuiWorkArea * wa, QWidget * parent = 0);
+       /// non-null
        GuiWorkArea * workArea() const { return wa_; }
 };