starting HFControls

This commit is contained in:
danteruiz 2019-08-28 13:10:55 -07:00
parent bb5e62dafd
commit 2a6252584f
7 changed files with 116 additions and 39 deletions

View file

@ -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})

View file

@ -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
}
}

View file

@ -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
}
}
}

View file

@ -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
}
}

View file

@ -0,0 +1,31 @@
#include "LauncherWindow.h"
#include <iostream>
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";
}
}

View file

@ -0,0 +1,10 @@
#include <QQuickView>
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;
};

View file

@ -1,10 +1,11 @@
#include <iostream>
#include <QGuiApplication>
#include <QQuickView>
#include <QString>
#include <QtPlugin>
#include <QResource>
#include <QFileInfo>
#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();
}