diff --git a/qml/Main.qml b/qml/Main.qml index 60b47e5..1ba3406 100644 --- a/qml/Main.qml +++ b/qml/Main.qml @@ -33,12 +33,6 @@ Item { value: page.orientation } - Binding { - target: util - property: "allowGestures" - value: !vkb.active && !menu.showing && !urlWindow.show && !aboutDialog.show && !layoutWindow.show - } - Item { id: page @@ -215,6 +209,7 @@ Item { fontPointSize: util.fontSize opacity: (util.keyboardMode == Util.KeyboardFade && vkb.active) ? 0.3 : 1.0 + allowGestures: !vkb.active && !menu.showing && !urlWindow.show && !aboutDialog.show && !layoutWindow.show Behavior on opacity { NumberAnimation { duration: textrender.duration; easing.type: Easing.InOutQuad } diff --git a/textrender.cpp b/textrender.cpp index 4a87fa2..cac79fe 100644 --- a/textrender.cpp +++ b/textrender.cpp @@ -27,7 +27,8 @@ Util* TextRender::sUtil = 0; TextRender::TextRender(QQuickItem *parent) : QQuickPaintedItem(parent), - newSelection(true) + newSelection(true), + iAllowGestures(true) { setFlag(ItemHasContents); @@ -299,7 +300,7 @@ void TextRender::updateTermSize() void TextRender::mousePress(float eventX, float eventY) { - if(!sUtil->allowGestures()) + if (!allowGestures()) return; dragOrigin = QPointF(eventX, eventY); @@ -310,7 +311,7 @@ void TextRender::mouseMove(float eventX, float eventY) { QPointF eventPos(eventX, eventY); - if(!sUtil->allowGestures()) + if (!allowGestures()) return; if(sUtil->dragMode() == Util::DragScroll) { @@ -326,7 +327,7 @@ void TextRender::mouseRelease(float eventX, float eventY) QPointF eventPos(eventX, eventY); const int reqDragLength = 140; - if(!sUtil->allowGestures()) + if (!allowGestures()) return; if(sUtil->dragMode() == Util::DragGestures) { @@ -403,6 +404,19 @@ QSize TextRender::cursorPixelSize() return QSize(iFontWidth, iFontHeight); } +bool TextRender::allowGestures() +{ + return iAllowGestures; +} + +void TextRender::setAllowGestures(bool allow) +{ + if (iAllowGestures != allow) { + iAllowGestures = allow; + emit allowGesturesChanged(); + } +} + QPointF TextRender::scrollBackBuffer(QPointF now, QPointF last) { int xdist = qAbs(now.x() - last.x()); diff --git a/textrender.h b/textrender.h index b2be163..d8fa5a1 100644 --- a/textrender.h +++ b/textrender.h @@ -33,6 +33,7 @@ class TextRender : public QQuickPaintedItem Q_PROPERTY(int fontHeight READ fontHeight NOTIFY fontSizeChanged) Q_PROPERTY(int fontPointSize READ fontPointSize WRITE setFontPointSize NOTIFY fontSizeChanged) Q_PROPERTY(bool showBufferScrollIndicator READ showBufferScrollIndicator WRITE setShowBufferScrollIndicator NOTIFY showBufferScrollIndicatorChanged) + Q_PROPERTY(bool allowGestures READ allowGestures WRITE setAllowGestures NOTIFY allowGesturesChanged) Q_OBJECT public: @@ -54,9 +55,13 @@ class TextRender : public QQuickPaintedItem Q_INVOKABLE QPoint cursorPixelPos(); Q_INVOKABLE QSize cursorPixelSize(); + bool allowGestures(); + void setAllowGestures(bool allow); + signals: void fontSizeChanged(); void showBufferScrollIndicatorChanged(); + void allowGesturesChanged(); public slots: void redraw(); @@ -97,6 +102,7 @@ private slots: int iFontHeight; int iFontDescent; bool iShowBufferScrollIndicator; + bool iAllowGestures; static Terminal *sTerm; static Util *sUtil; diff --git a/util.cpp b/util.cpp index ed136cd..9d503be 100644 --- a/util.cpp +++ b/util.cpp @@ -36,7 +36,6 @@ Util::Util(QSettings *settings, QObject *parent) : QObject(parent), - iAllowGestures(false), iSettings(settings), iWindow(0), iTerm(0) diff --git a/util.h b/util.h index 0bf0f41..74e4775 100644 --- a/util.h +++ b/util.h @@ -29,7 +29,6 @@ class QQuickView; class Util : public QObject { Q_OBJECT - Q_PROPERTY(bool allowGestures READ allowGestures WRITE setAllowGestures NOTIFY allowGesturesChanged) Q_PROPERTY(QString windowTitle READ windowTitle NOTIFY windowTitleChanged) Q_PROPERTY(int windowOrientation READ windowOrientation WRITE setWindowOrientation NOTIFY windowOrientationChanged) Q_PROPERTY(bool canPaste READ canPaste NOTIFY clipboardOrSelectionChanged) @@ -103,9 +102,6 @@ class Util : public QObject void bellAlert(); - bool allowGestures() { return iAllowGestures; } - void setAllowGestures(bool a) { if(iAllowGestures!=a) { iAllowGestures=a; emit allowGesturesChanged(); } } - QString fontFamily(); int dragMode(); @@ -134,7 +130,6 @@ class Util : public QObject signals: void visualBell(); - void allowGesturesChanged(); void notify(QString msg); void clipboardOrSelectionChanged(); void windowTitleChanged(); @@ -150,8 +145,6 @@ class Util : public QObject private: Q_DISABLE_COPY(Util) - bool iAllowGestures; - QString iCurrentWinTitle; QSettings* iSettings;