From 2a6252584f23920d5f867cf3281b8610a0f27685 Mon Sep 17 00:00:00 2001 From: danteruiz Date: Wed, 28 Aug 2019 13:10:55 -0700 Subject: [PATCH] starting HFControls --- launchers/qt/CMakeLists.txt | 4 ++- .../qt/resources/qml/HFControls/HFButton.qml | 30 +++++++++++++++++ .../resources/qml/HFControls/HFTextField.qml | 27 ++++++++++++++++ launchers/qt/resources/qml/root.qml | 32 +++---------------- launchers/qt/src/LauncherWindow.cpp | 31 ++++++++++++++++++ launchers/qt/src/LauncherWindow.h | 10 ++++++ launchers/qt/src/main.cpp | 21 ++++++------ 7 files changed, 116 insertions(+), 39 deletions(-) create mode 100644 launchers/qt/resources/qml/HFControls/HFButton.qml create mode 100644 launchers/qt/resources/qml/HFControls/HFTextField.qml create mode 100644 launchers/qt/src/LauncherWindow.cpp create mode 100644 launchers/qt/src/LauncherWindow.h diff --git a/launchers/qt/CMakeLists.txt b/launchers/qt/CMakeLists.txt index d95ff79aa8..2f5e9131c1 100644 --- a/launchers/qt/CMakeLists.txt +++ b/launchers/qt/CMakeLists.txt @@ -30,7 +30,9 @@ foreach(plugin ${Qt5Gui_PLUGINS}) endforeach() set(src_files - src/main.cpp) + src/main.cpp + src/LauncherWindow.h + src/LauncherWindow.cpp) add_executable(${PROJECT_NAME} ${src_files}) diff --git a/launchers/qt/resources/qml/HFControls/HFButton.qml b/launchers/qt/resources/qml/HFControls/HFButton.qml new file mode 100644 index 0000000000..3e44d74c7e --- /dev/null +++ b/launchers/qt/resources/qml/HFControls/HFButton.qml @@ -0,0 +1,30 @@ +import QtQuick 2.3 +import QtQuick.Controls 2.1 + +Button { + id: control + property string backgroundColor: "#00000000" + property string borderColor: "#FFFFFF" + property string textColor: "#FFFFFF" + property int backgroundOpacity: 1 + property int backgroundRadius: 1 + property int backgroundWidth: 2 + background: Rectangle { + implicitWidth: 100 + implicitHeight: 40 + color: control.backgroundColor + opacity: control.backgroundOpacity + border.color: control.borderColor + border.width: control.backgroundWidth + radius: control.backgroundRadius + } + + contentItem: Text { + text: control.text + font: control.font + color: control.textColor + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + elide: Text.ElideRight + } +} diff --git a/launchers/qt/resources/qml/HFControls/HFTextField.qml b/launchers/qt/resources/qml/HFControls/HFTextField.qml new file mode 100644 index 0000000000..b9317451d5 --- /dev/null +++ b/launchers/qt/resources/qml/HFControls/HFTextField.qml @@ -0,0 +1,27 @@ +import QtQuick 2.3 +import QtQuick.Controls 2.1 + +TextField { + id: control + color: "#FFFFFF" + font.family: "Graphik Medium" + font.pixelSize: 22 + verticalAlignment: TextInput.AlignVCenter + horizontalAlignment: TextInput.AlignLeft + placeholderText: "PlaceHolder" + echoMode: TextInput.Password + property string seperatorColor: "#FFFFFF" + background: Item { + anchors.fill: parent + Rectangle { + anchors { + bottom: parent.bottom + left: parent.left + leftMargin: 7 + right: parent.right + } + height: 1 + color: control.seperatorColor + } + } +} diff --git a/launchers/qt/resources/qml/root.qml b/launchers/qt/resources/qml/root.qml index 462c8bef00..13e2770636 100644 --- a/launchers/qt/resources/qml/root.qml +++ b/launchers/qt/resources/qml/root.qml @@ -2,6 +2,7 @@ import QtQuick 2.3 import QtQuick.Controls 2.1 +import "HFControls" Image { id: root width: 515 @@ -23,11 +24,10 @@ Image { color: "#FFFFFF" } - TextField { + HFTextField { id: textField - background: Rectangle { - color: "#00000000" - } + width: 150 + height: 50 anchors { left: root.left leftMargin: 40 @@ -38,21 +38,8 @@ Image { placeholderText: "Organization" } - Rectangle { - id: seperator - anchors { - left: textField.left - right: textField.right - top: textField.bottom - topMargin: 1 - } - height: 1 - color: "#FFFFFF" - } - - - Button { + HFButton { anchors { left: root.left leftMargin: 40 @@ -61,15 +48,6 @@ Image { } id: button text: "NEXT" - background: Rectangle { - implicitWidth: 100 - implicitHeight: 40 - color: "#00000000" - opacity: 1 - border.color: "#FFFFFF" - border.width: 4 - radius: 2 - } } diff --git a/launchers/qt/src/LauncherWindow.cpp b/launchers/qt/src/LauncherWindow.cpp new file mode 100644 index 0000000000..433d67a5fe --- /dev/null +++ b/launchers/qt/src/LauncherWindow.cpp @@ -0,0 +1,31 @@ +#include "LauncherWindow.h" + +#include + +void LauncherWindow::keyPressEvent(QKeyEvent* event) { + QQuickView::keyPressEvent(event); + if (!event->isAccepted()) { + std::cout << "Key press event\n"; + } +} + +void LauncherWindow::mousePressEvent(QMouseEvent* event) { + QQuickView::mousePressEvent(event); + if (!event->isAccepted()) { + std::cout << "mouse press event\n"; + } +} + +void LauncherWindow::mouseReleaseEvent(QMouseEvent* event) { + QQuickView::mouseReleaseEvent(event); + if (!event->isAccepted()) { + std::cout << "mouse release event\n"; + } +} + +void LauncherWindow::mouseMoveEvent(QMouseEvent* event) { + QQuickView::mouseMoveEvent(event); + if (!event->isAccepted()) { + std::cout << "mouse move event\n"; + } +} diff --git a/launchers/qt/src/LauncherWindow.h b/launchers/qt/src/LauncherWindow.h new file mode 100644 index 0000000000..903b0397dc --- /dev/null +++ b/launchers/qt/src/LauncherWindow.h @@ -0,0 +1,10 @@ +#include + + +class LauncherWindow : public QQuickView { +public: + void keyPressEvent(QKeyEvent* event) override; + void mousePressEvent(QMouseEvent* event) override; + void mouseReleaseEvent(QMouseEvent* event) override; + void mouseMoveEvent(QMouseEvent* event) override; +}; diff --git a/launchers/qt/src/main.cpp b/launchers/qt/src/main.cpp index 947ee242c6..1a0d9339c0 100644 --- a/launchers/qt/src/main.cpp +++ b/launchers/qt/src/main.cpp @@ -1,10 +1,11 @@ #include #include -#include #include #include #include #include + +#include "LauncherWindow.h" //Q_IMPORT_PLUGIN(QCocoaIntegrationPlugin); Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin); Q_IMPORT_PLUGIN(QtQuick2Plugin); @@ -12,10 +13,7 @@ Q_IMPORT_PLUGIN(QtQuickControls2Plugin); Q_IMPORT_PLUGIN(QtQuickTemplates2Plugin); int main(int argc, char *argv[]) { - QString name { "QtExamples" }; - - - std::cout << "Hello world\n"; + QString name { "HQLauncher" }; QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QCoreApplication::setOrganizationName(name); @@ -24,12 +22,13 @@ int main(int argc, char *argv[]) QString resourceBinaryLocation = QGuiApplication::applicationDirPath() + "/resources.rcc"; QResource::registerResource(resourceBinaryLocation); - QQuickView view; - view.setFlags(Qt::FramelessWindowHint); - view.setSource(QUrl("qrc:/qml/root.qml")); - if (view.status() == QQuickView::Error) + LauncherWindow launcherWindow; + launcherWindow.setFlags(Qt::FramelessWindowHint); + launcherWindow.setSource(QUrl("qrc:/qml/root.qml")); + if (launcherWindow.status() == QQuickView::Error) { return -1; - view.setResizeMode(QQuickView::SizeRootObjectToView); - view.show(); + } + launcherWindow.setResizeMode(QQuickView::SizeRootObjectToView); + launcherWindow.show(); return app.exec(); }