]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiWorkArea.h
Make a string translatable
[lyx.git] / src / frontends / qt4 / GuiWorkArea.h
index a33e158a5478efc5e4f283f4b5dd16d970b5792a..b22d2a5662924b1127bfce769c6c695bd9bb0f36 100644 (file)
@@ -13,9 +13,9 @@
 #ifndef WORKAREA_H
 #define WORKAREA_H
 
-#include "frontends/WorkArea.h"
+#include "ui_WorkAreaUi.h"
 
-#include "support/docstring.h"
+#include "frontends/WorkArea.h"
 
 #include <QAbstractScrollArea>
 #include <QTabBar>
@@ -33,6 +33,7 @@ class QWidget;
 namespace lyx {
 
 class Buffer;
+class FuncRequest;
 
 namespace frontend {
 
@@ -70,6 +71,8 @@ public:
        ///
        void redraw(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);
@@ -86,6 +89,9 @@ public:
        GuiView const & view() const;
        GuiView & view();
 
+       /// Current ratio between physical pixels and device-independent pixels
+       double pixelRatio() const;
+
 public Q_SLOTS:
        ///
        void stopBlinkingCursor();
@@ -97,6 +103,8 @@ Q_SIGNALS:
        void titleChanged(GuiWorkArea *);
        ///
        void busy(bool);
+       ///
+       void bufferViewChanged();
 
 private Q_SLOTS:
        /// Scroll the BufferView.
@@ -140,7 +148,8 @@ private:
        void mouseMoveEvent(QMouseEvent * ev);
        /// wheel event
        void wheelEvent(QWheelEvent * ev);
-       /// key press
+       /// key press event. It also knows how to handle ShortcutOverride events to
+       /// avoid code duplication.
        void keyPressEvent(QKeyEvent * ev);
        /// IM events
        void inputMethodEvent(QInputMethodEvent * ev);
@@ -184,6 +193,8 @@ private:
 }; // EmbeddedWorkArea
 
 
+class GuiWorkAreaContainer;
+
 /// A tabbed set of GuiWorkAreas.
 class TabWorkArea : public QTabWidget
 {
@@ -191,6 +202,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);
@@ -198,9 +213,9 @@ public:
        bool setCurrentWorkArea(GuiWorkArea *);
        GuiWorkArea * addWorkArea(Buffer & buffer, GuiView & view);
        bool removeWorkArea(GuiWorkArea *);
-       GuiWorkArea * currentWorkArea();
-       GuiWorkArea * workArea(Buffer & buffer);
-       GuiWorkArea * workArea(int index);
+       GuiWorkArea * currentWorkArea() const;
+       GuiWorkArea * workArea(Buffer & buffer) const;
+       GuiWorkArea * workArea(int index) const;
        void paintEvent(QPaintEvent *);
 
 Q_SIGNALS:
@@ -217,22 +232,34 @@ public Q_SLOTS:
        /// close the tab given by \c index
        void closeTab(int index);
        ///
+       void moveTab(int fromIndex, int toIndex);
+       ///
        void updateTabTexts();
-       
+
 private Q_SLOTS:
        ///
        void on_currentTabChanged(int index);
        ///
        void showContextMenu(const QPoint & pos);
-       ///
-       void moveTab(int fromIndex, int toIndex);
+       /// enable closing tab on middle-click
+       void mousePressEvent(QMouseEvent * me);
+       void mouseReleaseEvent(QMouseEvent * me);
        ///
        void mouseDoubleClickEvent(QMouseEvent * event);
+       ///
+       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);
+
        int clicked_tab_;
        ///
+       int midpressed_tab_;
+       ///
        QToolButton * closeBufferButton;
 }; // TabWorkArea
 
@@ -257,14 +284,37 @@ protected:
 private:
        ///
        QPoint dragStartPos_;
-       ///
-       int dragCurrentIndex_;
 
 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;
+
+private Q_SLOTS:
+       void updateDisplay();
+       void reload() const;
+       void ignore() const;
+
+protected:
+       void mouseDoubleClickEvent(QMouseEvent * event); //override
+
+public:
+       /// wa != 0
+       GuiWorkAreaContainer(GuiWorkArea * wa, QWidget * parent = 0);
+       /// non-null
+       GuiWorkArea * workArea() const { return wa_; }
+};
+
+
+
 } // namespace frontend
 } // namespace lyx