add sidepanel; become go app

This commit is contained in:
Dan Ballard 2018-09-17 14:21:57 -07:00
commit bcb844977b
8 changed files with 256 additions and 0 deletions

73
.gitignore vendored Normal file
View File

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

6
BlueBox.qml Normal file
View File

@ -0,0 +1,6 @@
import QtQuick 2.0
Box {
color: "#157efb"
}

17
Box.qml Normal file
View File

@ -0,0 +1,17 @@
import QtQuick 2.0
Rectangle {
id: root
width: 64
height: 64
color: "#ffffff"
border.color: Qt.darker(color, 1.2)
property alias text: label.text
property color fontColor: '#1f1f1f'
Text {
id: label
anchors.centerIn: parent
font.pixelSize: 14
color: root.fontColor
}
}

16
main.cpp Normal file
View File

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

44
main.go Normal file
View File

@ -0,0 +1,44 @@
package main
import (
"os"
"github.com/therecipe/qt/core"
"github.com/therecipe/qt/gui"
"github.com/therecipe/qt/qml"
"github.com/therecipe/qt/quickcontrols2"
)
func main() {
// enable high dpi scaling
// useful for devices with high pixel density displays
// such as smartphones, retina displays, ...
core.QCoreApplication_SetAttribute(core.Qt__AA_EnableHighDpiScaling, true)
// needs to be called once before you can start using QML
gui.NewQGuiApplication(len(os.Args), os.Args)
// use the material style
// the other inbuild styles are:
// Default, Fusion, Imagine, Universal
quickcontrols2.QQuickStyle_SetStyle("Material")
// create the qml application engine
engine := qml.NewQQmlApplicationEngine(nil)
// load the embeeded qml file
// created by either qtrcc or qtdeploy
//engine.Load(core.NewQUrl3("qrc:./Box.qml", 0))
//engine.Load(core.NewQUrl3("qrc:./BlueBox.qml", 0))
//engine.Load(core.NewQUrl3("qrc:./main.qml", 0))
engine.Load(core.NewQUrl3("qrc:/main.qml", 0))
// you can also load a local file like this instead:
//engine.Load(core.QUrl_FromLocalFile("./qml/main.qml"))
// start the main Qt event loop
// and block until app.Exit() is called
// or the window is closed by the user
gui.QGuiApplication_Exec()
}

65
main.qml Normal file
View File

@ -0,0 +1,65 @@
import QtQuick 2.9
import QtQuick.Window 2.2
Window {
visible: true
width: 1024
height: 800
title: qsTr("Hello World")
ListView {
id: "navColumn"
height: parent.height
width: 300
anchors.top: parent.top
anchors.left: parent.left
anchors.margins: 2
clip: true
model: groups
delegate: groupsDelegate
section.property: "type"
section.delegate: groupsSectionDelegate
highlight: Rectangle { color: "lightsteelblue"; radius: 5 }
}
Component {
id: groupsDelegate
Item {
width: ListView.view.width
height: 40
Column {
Text { text: '<b>' + title + '</b>' }
Text { text: groupid }
}
}
}
Component {
id: groupsSectionDelegate
BlueBox {
width: ListView.view.width
height: 20
text: section
fontColor: '#e0e0e0'
}
}
ListModel {
id: "groups"
ListElement {type: "group"; title: "Work Friends"; groupid: "710829b408e8b368273cbc20b07f1c0d"}
ListElement {type: "group"; title: "Cwtch Dev"; groupid: "a219b9740fc76367833cbc20b07d1cee" }
ListElement {type: "group"; title: "Gaming Squad"; groupid: "930829b408e8b364563cbc20b07a6560" }
ListElement {type: "bulletin"; title: "Vancouver Listings"; groupid: "890a47403e87368273cbc2ebf7f1cdc"}
ListElement {type: "bulletin"; title: "Game Discussions"; groupid: "cc45892408123879273ec2a435cc4234"}
}
}

7
qml.qrc Normal file
View File

@ -0,0 +1,7 @@
<RCC>
<qresource prefix="/">
<file>main.qml</file>
<file>BlueBox.qml</file>
<file>Box.qml</file>
</qresource>
</RCC>

28
qtCwtchBulletin.pro Normal file
View File

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