Skip to content

Commit

Permalink
fix for window drag bug on ubuntu, only tested on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
unknown authored and unknown committed Feb 3, 2016
1 parent fce88a8 commit 6289e18
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 263 deletions.
2 changes: 2 additions & 0 deletions .gitignore
@@ -0,0 +1,2 @@
*.user
*.user.*
5 changes: 5 additions & 0 deletions main.cpp
Expand Up @@ -31,6 +31,7 @@
#include <QtQml>
#include "clipboardAdapter.h"
#include "filter.h"
#include "oscursor.h"

int main(int argc, char *argv[])
{
Expand All @@ -41,6 +42,10 @@ int main(int argc, char *argv[])
qmlRegisterType<clipboardAdapter>("moneroComponents", 1, 0, "Clipboard");

QQmlApplicationEngine engine;

OSCursor cursor;
engine.rootContext()->setContextProperty("globalCursor", &cursor);

engine.rootContext()->setContextProperty("applicationDirectory", QApplication::applicationDirPath());
engine.load(QUrl(QStringLiteral("qrc:///main.qml")));
QObject *rootObject = engine.rootObjects().first();
Expand Down
22 changes: 13 additions & 9 deletions main.qml
Expand Up @@ -355,17 +355,17 @@ ApplicationWindow {
"images/resize.png"
}

property int previousX: 0
property int previousY: 0
property var previousPosition
onPressed: {
previousX = mouseX
previousY = mouseY
previousPosition = globalCursor.getPosition()
}

onPositionChanged: {
if(!pressed) return
var dx = previousX - mouseX
var dy = previousY - mouseY
var pos = globalCursor.getPosition()
//var delta = previousPosition - pos
var dx = previousPosition.x - pos.x
var dy = previousPosition.y - pos.y

if(appWindow.width - dx > parent.maxWidth)
appWindow.width -= dx
Expand All @@ -374,6 +374,7 @@ ApplicationWindow {
if(appWindow.height - dy > parent.maxHeight)
appWindow.height -= dy
else appWindow.height = parent.maxHeight
previousPosition = pos
}
}

Expand All @@ -390,13 +391,16 @@ ApplicationWindow {
property var previousPosition
anchors.fill: parent
propagateComposedEvents: true
onPressed: previousPosition = Qt.point(mouseX, mouseY)
onPressed: previousPosition = globalCursor.getPosition()
onPositionChanged: {
if (pressedButtons == Qt.LeftButton) {
var dx = mouseX - previousPosition.x
var dy = mouseY - previousPosition.y
var pos = globalCursor.getPosition()
var dx = pos.x - previousPosition.x
var dy = pos.y - previousPosition.y

appWindow.x += dx
appWindow.y += dy
previousPosition = pos
}
}
}
Expand Down
9 changes: 6 additions & 3 deletions monero-core.pro
Expand Up @@ -4,12 +4,14 @@ QT += qml quick widgets

HEADERS += \
filter.h \
clipboardAdapter.h
clipboardAdapter.h \
oscursor.h


SOURCES += main.cpp \
filter.cpp \
clipboardAdapter.cpp
clipboardAdapter.cpp \
oscursor.cpp

lupdate_only {
SOURCES = *.qml \
Expand Down Expand Up @@ -53,5 +55,6 @@ QML_IMPORT_PATH =
include(deployment.pri)

DISTFILES += \
wizard/WizardManageWalletUI.qml
wizard/WizardManageWalletUI.qml \
.gitignore

251 changes: 0 additions & 251 deletions monero-core.pro.user

This file was deleted.

10 changes: 10 additions & 0 deletions oscursor.cpp
@@ -0,0 +1,10 @@
#include "oscursor.h"
#include <QCursor>
OSCursor::OSCursor(QObject *parent)
: QObject(parent)
{
}
QPoint OSCursor::getPosition() const
{
return QCursor::pos();
}
25 changes: 25 additions & 0 deletions oscursor.h
@@ -0,0 +1,25 @@
#ifndef OSCURSOR_H
#define OSCURSOR_H


#include <QObject>
#include <QString>
#include <QPoint>
class OSCursor : public QObject
{
Q_OBJECT
//QObject();
public:
//QObject(QObject* aParent);
//OSCursor();
explicit OSCursor(QObject *parent = 0);
Q_INVOKABLE QPoint getPosition() const;
};

//OSCursor::OSCursor() : QObject(NULL){

//}


//Q_DECLARE_METATYPE(OSCursor)
#endif // OSCURSOR_H

0 comments on commit 6289e18

Please sign in to comment.