Browse Source

Initial commit

Denis V. Dedkov 7 years ago
commit
f2f55a2830
9 changed files with 298 additions and 0 deletions
  1. 73 0
      .gitignore
  2. 11 0
      HomeForm.qml
  3. 69 0
      MenuBackButton.qml
  4. 11 0
      SettingsForm.qml
  5. 16 0
      main.cpp
  6. 69 0
      main.qml
  7. 28 0
      nooLight.pro
  8. 9 0
      qml.qrc
  9. 12 0
      qtquickcontrols2.conf

+ 73 - 0
.gitignore

@@ -0,0 +1,73 @@
+# This file is used to ignore files which are generated
+# ----------------------------------------------------------------------------
+
+*~
+*.autosave
+*.a
+*.core
+*.moc
+*.o
+*.obj
+*.orig
+*.rej
+*.so
+*.so.*
+*_pch.h.cpp
+*_resource.rc
+*.qm
+.#*
+*.*#
+core
+!core/
+tags
+.DS_Store
+.directory
+*.debug
+Makefile*
+*.prl
+*.app
+moc_*.cpp
+ui_*.h
+qrc_*.cpp
+Thumbs.db
+*.res
+*.rc
+/.qmake.cache
+/.qmake.stash
+
+# qtcreator generated files
+*.pro.user*
+
+# xemacs temporary files
+*.flc
+
+# Vim temporary files
+.*.swp
+
+# Visual Studio generated files
+*.ib_pdb_index
+*.idb
+*.ilk
+*.pdb
+*.sln
+*.suo
+*.vcproj
+*vcproj.*.*.user
+*.ncb
+*.sdf
+*.opensdf
+*.vcxproj
+*vcxproj.*
+
+# MinGW generated files
+*.Debug
+*.Release
+
+# Python byte code
+*.pyc
+
+# Binaries
+# --------
+*.dll
+*.exe
+

+ 11 - 0
HomeForm.qml

@@ -0,0 +1,11 @@
+import QtQuick 2.0
+import QtQuick.Controls 2.0
+
+Page {
+    title: qsTr("Home")
+
+    Label {
+        text: qsTr("You are on the home page.")
+        anchors.centerIn: parent
+    }
+}

+ 69 - 0
MenuBackButton.qml

@@ -0,0 +1,69 @@
+import QtQuick 2.0
+
+Item {
+    id: root
+    signal clicked()
+    signal back()
+
+    MouseArea {
+        id: ma
+
+        anchors.fill: parent
+        anchors.margins: -8
+    }
+
+    Rectangle {
+        id: bar1
+        x: 0
+        y: root.height / 6
+        width: root.height
+        height: root.height / 9
+        antialiasing: true
+    }
+
+    Rectangle {
+        id: bar2
+        x: 0
+        y: root.height / 2 - height / 2
+        width: root.height
+        height: root.height / 9
+        antialiasing: true
+    }
+
+    Rectangle {
+        id: bar3
+        x: 0
+        y: root.height / 2 + height * 2
+        width: root.height
+        height: root.height / 9
+        antialiasing: true
+    }
+
+    property int animationDuration: 450
+
+    state: "menu"
+    states: [
+        State {
+            name: "menu"
+            PropertyChanges { target: ma; onClicked: root.clicked() }
+        },
+
+        State {
+            name: "back"
+            PropertyChanges { target: root; rotation: 180 }
+            PropertyChanges { target: bar1; rotation: 45; width: root.height / 3 * 2; x: root.height / 2; y: root.height / 4 }
+            PropertyChanges { target: bar2; width: root.height / 6 * 5 + 1; x: root.height / 9 }
+            PropertyChanges { target: bar3; rotation: -45; width: root.height / 3 * 2; x: root.height / 2; y: root.height / 3 * 2 }
+            PropertyChanges { target: ma; onClicked: root.back() }
+        }
+    ]
+
+    transitions: [
+        Transition {
+            RotationAnimation { target: root; direction: RotationAnimation.Clockwise; duration: animationDuration; easing.type: Easing.InOutQuad }
+            PropertyAnimation { target: bar1; properties: "rotation, width, x, y"; duration: animationDuration; easing.type: Easing.InOutQuad }
+            PropertyAnimation { target: bar2; properties: "rotation, width, x, y"; duration: animationDuration; easing.type: Easing.InOutQuad }
+            PropertyAnimation { target: bar3; properties: "rotation, width, x, y"; duration: animationDuration; easing.type: Easing.InOutQuad }
+        }
+    ]
+}

+ 11 - 0
SettingsForm.qml

@@ -0,0 +1,11 @@
+import QtQuick 2.0
+import QtQuick.Controls 2.2
+
+Page {
+    title: qsTr("Settings")
+
+    Label {
+        text: qsTr("You are on Settings Page")
+        anchors.centerIn: parent
+    }
+}

+ 16 - 0
main.cpp

@@ -0,0 +1,16 @@
+#include <QGuiApplication>
+#include <QQmlApplicationEngine>
+
+int main(int argc, char *argv[])
+{
+    QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
+
+    QGuiApplication app(argc, argv);
+
+    QQmlApplicationEngine engine;
+    engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
+    if (engine.rootObjects().isEmpty())
+        return -1;
+
+    return app.exec();
+}

+ 69 - 0
main.qml

@@ -0,0 +1,69 @@
+import QtQuick 2.9
+import QtQuick.Controls 2.2
+
+ApplicationWindow {
+    id: window
+    visible: true
+    width: 640
+    height: 480
+    title: qsTr("Stack")
+
+    header: ToolBar {
+        contentHeight: 36
+
+        MenuBackButton {
+            id: menuButton
+
+            anchors.verticalCenter: parent.verticalCenter
+            anchors.left: parent.left
+            anchors.leftMargin: 8
+
+            width: 24
+            height: 24
+
+            state: stackView.depth > 1 ? "back" : "menu"
+
+            onClicked: {
+                drawer.open()
+            }
+
+            onBack: {
+                stackView.pop()
+            }
+        }
+
+        Label {
+            text: stackView.currentItem.title
+            anchors.centerIn: parent
+        }
+    }
+
+    Drawer {
+        id: drawer
+        width: window.width * 0.66
+        height: window.height
+
+        Column {
+            anchors.fill: parent
+
+            ItemDelegate {
+                text: qsTr("Settings")
+                width: parent.width
+                onClicked: {
+                    if (stackView.depth > 1) {
+                        stackView.pop()
+                    }
+
+                    stackView.push("SettingsForm.qml")
+                    drawer.close()
+                }
+            }
+        }
+    }
+
+    StackView {
+        id: stackView
+        initialItem: "HomeForm.qml"
+        anchors.fill: parent
+    }
+}

+ 28 - 0
nooLight.pro

@@ -0,0 +1,28 @@
+QT += quick
+CONFIG += c++11
+
+# The following define makes your compiler emit warnings if you use
+# any feature of Qt which as been marked deprecated (the exact warnings
+# depend on your compiler). Please consult the documentation of the
+# deprecated API in order to know how to port your code away from it.
+DEFINES += QT_DEPRECATED_WARNINGS
+
+# You can also make your code fail to compile if you use deprecated APIs.
+# In order to do so, uncomment the following line.
+# You can also select to disable deprecated APIs only up to a certain version of Qt.
+#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
+
+SOURCES += main.cpp
+
+RESOURCES += qml.qrc
+
+# Additional import path used to resolve QML modules in Qt Creator's code model
+QML_IMPORT_PATH =
+
+# Additional import path used to resolve QML modules just for Qt Quick Designer
+QML_DESIGNER_IMPORT_PATH =
+
+# Default rules for deployment.
+qnx: target.path = /tmp/$${TARGET}/bin
+else: unix:!android: target.path = /opt/$${TARGET}/bin
+!isEmpty(target.path): INSTALLS += target

+ 9 - 0
qml.qrc

@@ -0,0 +1,9 @@
+<RCC>
+    <qresource prefix="/">
+        <file>main.qml</file>
+        <file>qtquickcontrols2.conf</file>
+        <file>HomeForm.qml</file>
+        <file>SettingsForm.qml</file>
+        <file>MenuBackButton.qml</file>
+    </qresource>
+</RCC>

+ 12 - 0
qtquickcontrols2.conf

@@ -0,0 +1,12 @@
+; This file can be edited to change the style of the application
+; Read "Qt Quick Controls 2 Configuration File" for details:
+; http://doc.qt.io/qt-5/qtquickcontrols2-configuration.html
+
+[Controls]
+Style=Universal
+
+[Universal]
+Theme=Dark
+;Accent=Steel
+;Foreground=Brown
+;Background=Steel