Skip to content

Commit

Permalink
Move allowGestures as property of TextRender
Browse files Browse the repository at this point in the history
  • Loading branch information
pvuorela committed Jun 27, 2016
1 parent 7b45173 commit bc973f6
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 18 deletions.
7 changes: 1 addition & 6 deletions qml/Main.qml
Expand Up @@ -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

Expand Down Expand Up @@ -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 }
Expand Down
22 changes: 18 additions & 4 deletions textrender.cpp
Expand Up @@ -27,7 +27,8 @@ Util* TextRender::sUtil = 0;

TextRender::TextRender(QQuickItem *parent) :
QQuickPaintedItem(parent),
newSelection(true)
newSelection(true),
iAllowGestures(true)
{
setFlag(ItemHasContents);

Expand Down Expand Up @@ -299,7 +300,7 @@ void TextRender::updateTermSize()

void TextRender::mousePress(float eventX, float eventY)
{
if(!sUtil->allowGestures())
if (!allowGestures())
return;

dragOrigin = QPointF(eventX, eventY);
Expand All @@ -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) {
Expand All @@ -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) {
Expand Down Expand Up @@ -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());
Expand Down
6 changes: 6 additions & 0 deletions textrender.h
Expand Up @@ -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:
Expand All @@ -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();
Expand Down Expand Up @@ -97,6 +102,7 @@ private slots:
int iFontHeight;
int iFontDescent;
bool iShowBufferScrollIndicator;
bool iAllowGestures;

static Terminal *sTerm;
static Util *sUtil;
Expand Down
1 change: 0 additions & 1 deletion util.cpp
Expand Up @@ -36,7 +36,6 @@

Util::Util(QSettings *settings, QObject *parent) :
QObject(parent),
iAllowGestures(false),
iSettings(settings),
iWindow(0),
iTerm(0)
Expand Down
7 changes: 0 additions & 7 deletions util.h
Expand Up @@ -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)
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -134,7 +130,6 @@ class Util : public QObject

signals:
void visualBell();
void allowGesturesChanged();
void notify(QString msg);
void clipboardOrSelectionChanged();
void windowTitleChanged();
Expand All @@ -150,8 +145,6 @@ class Util : public QObject
private:
Q_DISABLE_COPY(Util)

bool iAllowGestures;

QString iCurrentWinTitle;

QSettings* iSettings;
Expand Down

0 comments on commit bc973f6

Please sign in to comment.