瀏覽代碼

portrait checks

David 9 年之前
父節點
當前提交
aa28738627
共有 2 個文件被更改,包括 14 次插入16 次删除
  1. 4 2
      main.cpp
  2. 10 14
      main.qml

+ 4 - 2
main.cpp

@@ -7,11 +7,13 @@ int main(int argc, char *argv[])
     QApplication app(argc, argv);
 
     QQmlApplicationEngine engine;
-    engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
+
     QScreen *screen = QApplication::screens().at(0);
+    bool portrait = screen->availableSize().height() > screen->availableSize().width();
 
-    if (screen->availableSize().height() > screen->availableSize().width())
+    if (portrait)
         QGuiApplication::setOverrideCursor(QCursor(Qt::BlankCursor));
 
+    engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
     return app.exec();
 }

+ 10 - 14
main.qml

@@ -8,12 +8,12 @@ import "components" as Comps
 
 
 ApplicationWindow {
+    property bool portrait: Screen.height > Screen.width ? true : false
     id: aw
     visible: true
-    width: 600
-    height: 960
-    visibility: Screen.height > Screen.width ? "FullScreen" : "Windowed"
-
+    width: portrait ? 600 : 1280
+    height: portrait ? 960 : 720
+    visibility: portrait ? "FullScreen" : "Windowed"
     color: "#fffffe"
 
     Comps.WebSocket {
@@ -24,15 +24,15 @@ ApplicationWindow {
         id: item1
 
         transformOrigin: Item.Center
-        rotation: Screen.height > Screen.width ? 90 : 0
+        rotation: aw.portrait ? 90 : 0
         property alias mouseArea1: mouseArea1
         property alias button3: button3
         property int curImage: 1
         property variant pregs: []
 
         property string curPDF: "EBA"
-        width: parent.height
-        height: parent.width
+        width: aw.portrait ? parent.height : parent.width
+        height: aw.portrait ? parent.width : parent.height
         anchors.horizontalCenter: parent.horizontalCenter
         anchors.verticalCenter: parent.verticalCenter
         onCurPDFChanged: {
@@ -170,13 +170,9 @@ ApplicationWindow {
                         if (ctx === null )
                             ctx = canvas.getContext("2d");
 
-
                         if ( region === undefined || region.width > 150 || region.height > 150 ) {
-                            console.log("Full", region.width, region.height);
-                            if (canvas.isImageLoaded(curImageUrl)) {
-                                ctx.drawImage(curImageUrl, 0, 0, canvas.width,
-                                              canvas.height)
-                            }
+                            if (canvas.isImageLoaded(curImageUrl))
+                                ctx.drawImage(curImageUrl, 0, 0, canvas.width, canvas.height)
                             var j = 0
                             for (j = 0; j < points_array.length; j++) {
                                 if (points_array[j].points.length <= 1)
@@ -212,7 +208,7 @@ ApplicationWindow {
                         if (!socket.isOpen)
                             return
                         var point = { x: mouse.x, y: mouse.y }
-                        if (distance(last_point, point) <= 61) //distance returns squared dsitance
+                        if (distance(last_point, point) <= 31) //distance returns squared dsitance
                             return;
                         last_point = point
                         canvas.add_point(point)