Repository: amlwwalker/got-qt Branch: master Commit: cd91aa500579 Files: 69 Total size: 40.9 MB Directory structure: gitextract_trt6ky9i/ ├── .gitignore ├── LICENSE.txt ├── MAKEFILE.md ├── Makefile ├── README.md ├── cuiinterface/ │ ├── interface.go │ ├── main.go │ └── objects.go ├── logic/ │ ├── logic.go │ └── objects.go └── qt/ ├── android/ │ ├── AndroidManifest.xml │ └── src/ │ └── org/ │ └── qtproject/ │ └── example/ │ └── notification/ │ └── NotificationClient.java ├── configfiles/ │ └── config.json ├── contactModel.go ├── darwin/ │ └── Contents/ │ ├── Info.plist │ └── Resources/ │ └── icons.icns ├── got-qt-darwin-amd64 ├── hotloadWatcher.go ├── interface.go ├── main.go ├── main.go.bak ├── notificationHandler.go └── qml/ ├── elements/ │ ├── FilePicker.qml │ ├── PressAndHoldButton.qml │ ├── TextButton.qml │ ├── Toast.qml │ └── utils.js ├── loader-production.qml ├── loader.qml └── pages/ ├── BusyIndicatorPage.qml ├── ButtonPage.qml ├── CheckBoxPage.qml ├── ComboBoxPage.qml ├── DelegatePage.qml ├── DialPage.qml ├── DrawerPage.qml ├── FramePage.qml ├── GroupBoxPage.qml ├── Header.qml ├── MenuPage.qml ├── PageIndicatorPage.qml ├── PopupPage.qml ├── ProgressBarPage.qml ├── RadioButtonPage.qml ├── RangeSliderPage.qml ├── ScrollBarPage.qml ├── ScrollIndicatorPage.qml ├── ScrollablePage.qml ├── SliderPage.qml ├── SpinBoxPage.qml ├── StackViewPage.qml ├── SwipeViewPage.qml ├── SwitchPage.qml ├── TabBarPage.qml ├── TextAreaPage.qml ├── TextFieldPage.qml ├── ToolTipPage.qml ├── TumblerPage.qml ├── _asynchronousPage.qml ├── _calculatorPage.qml ├── _clockPage.qml ├── _contactsPage.qml ├── _downloadsPage.qml ├── _filelistPage.qml ├── _fruitsPage.qml ├── _fruitsPage2.qml ├── _loginPage.qml ├── _searchPage.qml └── _toastPage.qml ================================================ FILE CONTENTS ================================================ ================================================ FILE: .gitignore ================================================ #osx file .DS_Store #directories deploy/ #file extensions *.o *.qmlc *.cpp *.h *.qrc #file prefixes moc*.* rcc*.* #packr files *-packr.go *cgo* #binary files ./got-qt ./cuiinterface/cuiinterface ================================================ FILE: LICENSE.txt ================================================ MIT License Copyright (c) 2018 Alex Walker [@amlwwalker] Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: MAKEFILE.md ================================================ ## Automated Setup and Building I have added a makefile to this project to ease configuration. ### Instructions #### Pre requisite * Clone this directory: ` git clone git@github.com:amlwwalker/got-qt.git $(GOPATH)/src/github.com/amlwwalker/got-qt` * Go to the directory: `cd $(GOPATH)/src/github.com/amlwwalker/got-qt` #### Installation * Run setup to install qt5 `make setup` * Run install to install **therecipe/qt** and **got-qt**: `make install` #### Creating your project * It will automatically create a directory for projects at `$(GOPATH)/src/github.com/got-qt-projects` * all projects created using this makefile will end up here * Run make to create a new project, setting the project name as an argument: `make createproject PROJECTNAME=testproject` * Go to your project directory, `cd $(GOPATH)/src/github.com/got-qt-projects/testproject` * Build the console app: `make console`. The binary will appear inside cuiinterface * Build the gui app (only configured for OSX so far): `make build` * Run the binary in development (hotloading) mode: `make darwinhotload` for OSX, or `make lxhotload` for linux. (Not tested on Windows). * You can now edit qml and it will hot load in your new project. #### Device building When building for devices such as Android or iOS(untested), hotloading must be disabled. ### Updating the production loader qml file At this point this is quite crude. So that you can be certain you will get the latest qml changes when hotloading is disabled, that you have copied loader.qml to loader-production.qml and updated the paths to the compiled paths. More information [in the Readme under the production section](https://github.com/amlwwalker/got-qt/#production) ================================================ FILE: Makefile ================================================ # Borrowed from: # https://github.com/silven/go-example/blob/master/Makefile # https://vic.demuzere.be/articles/golang-makefile-crosscompile/ BINARY = got-qt # Symlink into GOPATH GITHUB_USERNAME=amlwwalker GOT_QT_PROJECTS=got-qt-projects CONSOLE_DIR=cuiinterface GUI_DIR=qt DEV_SOURCE=${GOPATH}/src/github.com # BUILD_DIR=${DEV_SOURCE}/${GOT_QT_PROJECTS}/${BINARY} CURRENT_DIR=$(shell pwd) #install parameters GOT_QT_REPO=git@github.com:amlwwalker/got-qt.git # Build the project all: clean console darwin #linux windows hardinstall: setup install setup: #install everything including qt brew install qt5 #configure the setup for this install: #first go to build dir cd ${DEV_SOURCE}; \ #now make a directory to store the got-qt mkdir ${GITHUB_USERNAME}; \ #now clone got-qt into there git clone ${GOT_QT_REPO} ${GITHUB_USERNAME}/ \ mkdir 0xAX; \ #you will need notifier for notifications git clone git@github.com:0xAX/notificator.git 0xAX; \ go get -u github.com/gobuffalo/packr/...; \ #you will need packr for configuration files go get github.com/radovskyb/watcher; \ #you will need watcher by radovskyb for hotloading go get -u -v github.com/therecipe/qt/cmd/...; \ #now make sure the user has therecipe/qt installed $GOPATH/bin/qtsetup; #var topLevel = filepath.Join(os.Getenv("GOPATH"), "src", "github.com", "amlwwalker", "got-qt", "qt", "qml") createproject: #pass this PROJECTNAME, e.g: make createproject PROJECTNAME=testproject #create the directory in github.com cd ${DEV_SOURCE}; \ mkdir -p ${GOT_QT_PROJECTS}/${PROJECTNAME}; \ cd ${GOT_QT_PROJECTS}/${PROJECTNAME}; \ rsync -av --exclude=".git" ${DEV_SOURCE}/${GITHUB_USERNAME}/got-qt/* . ; \ sed -i.bak s/"got-qt"/"${PROJECTNAME}"/g qt/main.go; \ sed -i.bak s/"amlwwalker"/"${GOT_QT_PROJECTS}"/g qt/main.go; console: cd ${CONSOLE_DIR}; \ go build -o consoleApp; \ cd - >/dev/null build: cd ${GUI_DIR}; \ qtdeploy build desktop; \ cd - >/dev/null darwinhotload: cd ${GUI_DIR}; \ deploy/darwin/${GUI_DIR}.app/Contents/MacOS/${GUI_DIR} lxhotload: cd ${GUI_DIR}; \ deploy/linux/${GUI_DIR}.sh ================================================ FILE: README.md ================================================ ## Got-qt GUI Framework ## Quick Start! * To use the hotloading feature a configuration file is compiled into the binary using [packr](https://github.com/gobuffalo/packr). * If you are using the [makefile for automation](MAKEFILE.md), running `make install` should setup everything up for you, including packr. * Once installation is successful, to build the config.json into the binary, just run `packr` from within the qt directory of this repository. Any time you change the config.json file, found in configfiles/ you will need to re run packr. * I have intentionally excluded packr files from the git repository as they can get large and are easily generated. ## General Overview If you are not interested in manual building and general information (everything below here), you can proceed to [automated building](MAKEFILE.md) ## More background This is a framework to make desktop/mobile applications in Go with a GUI written in Qt Qml. Both of these languages are cross platform. Go is an open source programming language, Qt is licensed under [LGPL license](https://www1.qt.io/qt-licensing-terms/). In some instances you will need to buy a commercial Qt license - for instance a statically compiled, commercial app, would need a commerical Qt license. The license for my work here however, is under [MIT license](LICENSE.txt). Home | Menu | Console UI | Android :-------------------------:|:-------------------------:|:-------------------------: |:-------------------------: | | | It uses the Material framework from Google for the UI in Qml, and uses Go as a backend. It demonstrates making pages in Qml, interfacing with the backend Go code, and receving messages from the backend. I.e everything you need to build a desktop app, all ready to go. I built this because I was building desktop apps in Go, with Guis. For every change I made, i had to recompile the go code even if I was just changing the UI code. This takes a long time. It _can_ be sped up, however I wanted to develop my UI faster. I could have used qt-creator, however it was another IDE, I just wanted an easy way to build desktop apps with Go. So I added hotloading to the qml files. You can download the [demo OSX app here.](qtapp.zip) * [Follow me on twitter](https://twitter.com/amlwwalker) * [Read the medium post](https://medium.com/@_whitesilence/building-compiled-fast-cross-platform-desktop-apps-in-go-with-qml-a5bb347f4ce9) ##### Watch the [youtube video](https://youtu.be/38gvNBT6VlM) ##### Please note this is in early stages ### What I wanted: * Wanted to make desktop applications that were as easy to use for anyone who could use a computer. (No web app, no console app etc etc) * Wanted to write it in a cross platform language so that I would only need to write it once * Use a language I was already familiar with * From research, there were a few options for the UI, for instance HTML/CSS/JS. However this required use of the installed default web browser and I didn't want to rely on that, but also it meant that the UI files had to be shipped around with the application. Felt a little messy and like using the wrong tool for the job. Besides, its slow :) * Qml seemed very well documented and when I discovered the work of [therecipe](https://github.com/therecipe/qt) I felt like I was solving alot of problems related to cross platform app development in one go. * With go compiling the qml into the application as binary, the UI is very fast. * The Go Material UI theme is included in QT which sped up UI development. This is a combination of a lot of work done by alot of people around the web. I am very pleased that I have now, what I think, is a very workable framework for building apps cross platform. ## Installation I am assuming you are a Go developer already and have Go installed with your GOPATH set, etc etc... I am using MacOS so I will put steps for that, however I am linking to where to find installation instructions more generally. I do however hope you are not a Windows developer... Your paths, your consoles, your docker installations... all will have caveats... ### Installing QT You can install QT by following the instructions [for regular installation](https://github.com/therecipe/qt/wiki/Installation#regular-installation), however in essence : `brew install qt5` This will install the packaged version of Qt. Its a sort of minimal version to get Qt working easily for OSX. However it is not the official version and does not have support for iOS or Android. That's fine as I am using the docker containers to build for other platforms, but it will lead to a minor step you have to take when building for other platforms ### Installing Qt Go-Binding You can install Qt binding by following [these instructions](https://github.com/therecipe/qt/wiki/Installation-on-macOS#installing-binding), however in essence: * `go get -u -v github.com/therecipe/qt/cmd/...` * `$GOPATH/bin/qtsetup` ### Installing Material theme Luckily Qt comes with the theme installed! No need to do anything here! ### Test everything, * Because we will later want to cross compile for other OS except OSX, we cannot set a global path to Qt as it will affect the build later for other OS. So before compiling, make sure you have run `export QT_DIR=/usr/local/opt/qt` in the current terminal session. You will need to re run this for each new terminal session otherwise the **build will fail**. You can run the example code found [here](https://github.com/therecipe/qt/wiki/Getting-Started#starting-application), but in essence, put the following in your `$GOPATH/src` somewhere and run `qtdeploy test desktop` ``` package main import ( "github.com/therecipe/qt/widgets" "os" ) func main() { // Create application app := widgets.NewQApplication(len(os.Args), os.Args) // Create main window window := widgets.NewQMainWindow(nil, 0) window.SetWindowTitle("Hello World Example") window.SetMinimumSize2(200, 200) // Create main layout layout := widgets.NewQVBoxLayout() // Create main widget and set the layout mainWidget := widgets.NewQWidget(nil, 0) mainWidget.SetLayout(layout) // Create a line edit and add it to the layout input := widgets.NewQLineEdit(nil) input.SetPlaceholderText("1. write something") layout.AddWidget(input, 0, 0) // Create a button and add it to the layout button := widgets.NewQPushButton2("2. click me", nil) layout.AddWidget(button, 0, 0) // Connect event for button button.ConnectClicked(func(checked bool) { widgets.QMessageBox_Information(nil, "OK", input.Text(), widgets.QMessageBox__Ok, widgets.QMessageBox__Ok) }) // Set main widget as the central widget of the window window.SetCentralWidget(mainWidget) // Show the window window.Show() // Execute app app.Exec() } ``` If you get a window appear once the compilation completes (it may take a moment) then everything is working and you can continue. If you have any issues, read the [wiki page](https://github.com/therecipe/qt/wiki/Getting-Started#starting-application). ### Installing this project Now your environment is ready, to make app development easy, you can use this project Got-qt. For the sake of argument, I am setting an env var for the project name so I can refer to it elsewhere. prerequisite. So that the instructions are general for all platforms: * MacOS:`export OSTYPE=darwin` * Windows:`export OSTYPE=windows` * Android:`export OSTYPE=android` * `export PROJECTNAME=myproject` * `cd $GOPATH/src/amlwwalker` * `git clone https://github.com/amlwwalker/got-qt` * `cp -r got-qt $PROJECTNAME` * `cd $PROJECTNAME` * Update the path in qt/main.go stored as the variable `topLevel` to the new path of your project. This is an absolute build path currently set to this project, as opposed to yours. * Remember to update any paths to backend business logic in your own projects, otherwise will only know about logic in this project * `cd qt` `#Need to compile from within here` * `qtdeploy test desktop` At this stage, the application will build and run. It will take a bit of time. If you get the sample app appearing then great, compilation has been successful. ### Help/Demo * (Tip: Turn on english subtitles) [To see the above process in action, I have added a youtube video here to give you an idea](https://youtu.be/T96KOy4sTJ8) **Read on for how to develop apps efficiently and easily** ## Using the framework Reasons to use this * Fast setup of cross platform GUI apps with a Go backend * Efficient developing. Compiling QML and Go requires C bindings which is slow * Good code management. This projects demonstrates decoupling of backend logic from frontend allowing headless, web-based, console, or gui applications to all share the same logic, yet not know about each other. There is a configuration file that tells the application whether to run in hotloading mode. If it is run in hotloading mode, then it will continually monitor changes to its own qml files and update the user interface immediately. Makes for real time development. * In the case of hotloading, the app must be run directly from the terminal. This is so that it can detect local configuration. Double clicking the app in Finder runs it under the Finder's environment which is not the same as the developers and will therefore not have hotloading enabled. * Run with `GOPATH/src/$USER/$PROJECTNAME/deploy/darwin/got-qt/Contents/MacOS/got-qt` * This will allow it to detect the config for hotloading and QML will update in realtime. My recommended approach is to build your UI using this in QML, then decide how it needs to interface with the Go code (backend). Once you know those requirements, you can add in the listeners in the Go code and have basic interaction with the front end, proving to your self you have two way comms. Use this two way comms to set the needed bridge connections up, but forget about functionality for now. Just confirm you have the commnunication working. Then, move to building a console UI. There is a demonstration console UI using the amazing [gocui](https://github.com/jroimartin/gocui). Its a very straight forward way of building great console applications in Go. I recommend this for a few reasons: * Building apps with console UI's compile much faster than with GUIs * Building a console app allows you to work out what logic you are going to require, with the intent of keeping it seperate from the UI - I.e better architecture. * It is educational as to how frontends and backends communicate, which is useful when designing your GUI. For instance, how are you going to handle processes that take a long time, the user needs to be notified. They also shouldn't experience lock up. How do you handle these things. The directory `cuiinterface` shows how this decoupling of the console UI works. Whats great is because nothing else knows about anything in this directory, it won't get compiled into the application when the GUI is compiled. I recommend this same structure for all your UIs (i.e each having its own directory and nothing else knows about it). Once the console UI you have built demonstrates the functionality required by the go code, you can then wire up your GUI to the same functions (as the two UI's are just top level interfaces to the backend), and save yourself a lot of compilation time. ## Steps ### Development 1. In config.json, make sure that hotloading is set to true * **Please Note** hotloading must be disabled when in production mode and on mobile devices 2. Make sure you have run `packr` in the `qt/` directory Whenever a change to config.json is made 2. Run the application with `GOPATH/src/$USER/$PROJECTNAME/deploy/darwin/got-qt/Contents/MacOS/got-qt` 3. Navigate with your editor of choice to `qml/` - this is where all the UI files are kept. 4. For now you will be editing loader.qml. This file is configured for hotloading. loader-production.qml is for when the code is to be compiled into the application for deployment. This is necessary because the finder app runs under a different user space to you. 5. Start editing loader.qml. You will see the UI update as you save. * You can edit any of the files under pages/elements and they will be updated automatically. * Notice on occasion restarts of the app (but not recompilation) will be required if you break the qml it cannot rebuild it. Just quit and restart easy. **NOTICE** If you import new libraries into your qml, then in this case a recompile will be required as those libraries won't have been compiled into the application, this only needs to happen once per new library imported however. Shouldn't be too frequent. ### Production 6. When you are ready for production: * copy loader.qml to `loader-production.qml` * Update any relative path in `loader-production.qml` to a qrc path so that the app knows how to find the compiled qml, e.g: * Update any relative path to a qml file to a qrc path. ##### Relative: ``` ListElement { title: "Contacts"; source: "pages/_contactsPage.qml" } ListElement { title: "Files"; source: "pages/_filelistPage.qml" } ListElement { title: "Downloads"; source: "pages/_downloadsPage.qml" } ``` ##### Qrc: ``` ListElement { title: "Contacts"; source: "qrc:/qml/pages/_contactsPage.qml" } ListElement { title: "Files"; source: "qrc:/qml/pages/_filelistPage.qml" } ListElement { title: "Downloads"; source: "qrc:/qml/pages/_downloadsPage.qml" } ``` (this step will in time be improved, its a bit annoying to have to do with a find/replace, but ListElements can't have dynamic paths in qml) * set hotloading to false in config.json and recompile. You can recompile now with `qtdeploy build desktop` * Navigate in Finder to your `deploy/$(OSTYPE)` directory and double click the application. It should start up with your changes with your changes compiled in. ### Cross Compilation Using [therecipe/qt](https://github.com/therecipe/qt/wiki/Deploying-macOS-to-Windows-32-bit) tools and using docker, its very easy to cross compile for different platforms, but in essence: * Install docker for your [platform i.e OSX](https://docs.docker.com/docker-for-mac/install/#download-docker-for-mac) * Pull the docker container for the platform you want to cross compile for `docker pull therecipe/qt:windows_32_shared` * Build for the platform `qtdeploy -docker build windows_32_shared` * You can follow the instructions for different devices such as linux, [here](https://github.com/therecipe/qt/wiki/Deploying-macOS-to-Linux). Other devices are documented there aswell. ##### NOTICE: I have only cross compiled for windows and android, but the steps should be the same for other platforms if you have docker installed. * You will have the application build in `deploy/platform` directory in `qt/` ##### NOTICE: When cross compiling, to be in a terminal session where you did not run `export QT_DIR=/usr/local/opt/qt` first ### Device Specific Setup #### Android In the android/ directory there is the configuration to setup the android app. There is an AndroidManifest.xml where things like the App Name, and the device permissions live. Inside android/res/drawable there is an icon.png file that will set the app icon. #### OSX Inside the darwin directory, there is Contents/Resources. Inside here you can create the app icon. To do so, you need to put the icon files inside icons.iconset directory (keeping the names for the files the same), where you can put the icon. Then from inside darwin/Contents/Resources, run `iconutil -c icns icons.iconset` to generate the icons.icns file which will be used for the app icon. The info.plist file contains the configuration for OSX. ## To do * Tidy up hotloading. * iOS untested * Create a Windows Installer because otherwise the end user has to see a whole load of messy qml files as part of the application. ================================================ FILE: cuiinterface/interface.go ================================================ package main import ( "fmt" "github.com/jroimartin/gocui" "log" "strconv" ) type fn func(g *gocui.Gui, v *gocui.View) error var controls = map[string]fn{} //holder for the functions that the UI controls fire func searchField(g *gocui.Gui, v *gocui.View) error { maxX, maxY := g.Size() if v, err := g.SetView("search", maxX/2-30, maxY/2, maxX/2+30, maxY/2+2); err != nil { if err != gocui.ErrUnknownView { updateView(g, "logs", err.Error()) return nil } v.Editable = true if _, err := g.SetCurrentView("search"); err != nil { updateView(g, "logs", err.Error()) return nil } } return nil } func clearView(g *gocui.Gui, view string) { g.Update(func(g *gocui.Gui) error { v, err := g.View(view) if err != nil { return err } v.Clear() return nil }) } func updateView(g *gocui.Gui, view, message string) error { g.Update(func(g *gocui.Gui) error { v, err := g.View(view) if err != nil { return err } fmt.Fprintln(v, message) //scroll the window if necessary cursorDown(g, v) return nil }) return nil } func (c *UIControl) ExternalLogUpdate(message string) { updateView(c.gui, "logs", message) } func (c *UIControl) login(g *gocui.Gui, v *gocui.View) error { updateView(g, "logs", "logging in") return nil } func (c *UIControl) searchContact(g *gocui.Gui, v *gocui.View) error { //we don't need to set the msg view //because its going to take input var l string var err error defer delView("search", g, v) _, cy := v.Cursor() if l, err = v.Line(cy); err != nil { l = "" //no value searched for... return nil } updateView(g, "logs", "searching for "+l+"...") c.logic.SearchForMatches(l, func(p float64, indeterminate bool) { //if indeterminate is true, it means the logic //has no idea how long it is going to take //so cant have progressive update the UI if indeterminate { updateView(c.gui, "logs", "process takes time....") } else { updateView(c.gui, "logs", "processing: "+strconv.FormatFloat(p, 'f', 6, 64)) } if p == 1.0 { //we have knowledge the process was complete, we can do anything with it for _, v := range c.logic.People { //the people in the list will be as a result of this function updateView(c.gui, "logs", "found: "+v.Email) updateView(c.gui, "contacts", v.Email) } } }) return nil } func (c *UIControl) Init() { g, err := gocui.NewGui(gocui.OutputNormal) c.gui = g if err != nil { log.Panicln(err) } defer g.Close() g.Cursor = true g.SetManagerFunc(c.layout) if err := c.keybindings(g); err != nil { updateView(c.gui, "logs", "cannot bind keys "+err.Error()) } if err := g.MainLoop(); err != nil && err != gocui.ErrQuit { updateView(c.gui, "logs", "main loop errord "+err.Error()) } } func (c *UIControl) layout(g *gocui.Gui) error { maxX, maxY := g.Size() if v, err := g.SetView("controls", 0, 0, 30, maxY); err != nil { if err != gocui.ErrUnknownView { return err } v.Title = "Controls" v.Highlight = true v.SelBgColor = gocui.ColorGreen v.SelFgColor = gocui.ColorBlack controls["4. Search Contact"] = searchField controls["1. login"] = c.login for k, _ := range controls { fmt.Fprintln(v, k) } } if v, err := g.SetView("contacts", 30, 0, 60, maxY); err != nil { if err != gocui.ErrUnknownView { return err } v.Title = "Contacts" v.Highlight = true v.SelBgColor = gocui.ColorGreen v.SelFgColor = gocui.ColorBlack if _, err := g.SetCurrentView("controls"); err != nil { return err } } if v, err := g.SetView("files", 60, 0, maxX, maxY); err != nil { if err != gocui.ErrUnknownView { return err } v.Title = "Files" v.Highlight = true v.SelBgColor = gocui.ColorGreen v.SelFgColor = gocui.ColorBlack fmt.Fprintln(v, "sample.txt") fmt.Fprintln(v, "accounts.pdf") fmt.Fprintln(v, "design.svg") if _, err := g.SetCurrentView("controls"); err != nil { return err } } if v, err := g.SetView("logs", 0, 15, maxX, maxY-1); err != nil { if err != gocui.ErrUnknownView { return err } v.Title = "Logs" v.SelBgColor = gocui.ColorGreen v.SelFgColor = gocui.ColorBlack fmt.Fprintln(v, "loading...") fmt.Fprintln(v, "loading complete") if _, err := g.SetCurrentView("controls"); err != nil { return err } } return nil } func nextView(g *gocui.Gui, v *gocui.View) error { if v == nil || v.Name() == "controls" { updateView(g, "logs", "setting view to contacts") _, err := g.SetCurrentView("contacts") return err } else if v.Name() == "contacts" { updateView(g, "logs", "setting view to files") _, err := g.SetCurrentView("files") return err } updateView(g, "logs", "setting view to controls") _, err := g.SetCurrentView("controls") return err } func cursorDown(g *gocui.Gui, v *gocui.View) error { if v != nil { cx, cy := v.Cursor() if err := v.SetCursor(cx, cy+1); err != nil { ox, oy := v.Origin() if err := v.SetOrigin(ox, oy+1); err != nil { return err } } } return nil } func cursorUp(g *gocui.Gui, v *gocui.View) error { if v != nil { ox, oy := v.Origin() cx, cy := v.Cursor() if err := v.SetCursor(cx, cy-1); err != nil && oy > 0 { if err := v.SetOrigin(ox, oy-1); err != nil { return err } } } return nil } func getControl(g *gocui.Gui, v *gocui.View) error { var l string var err error _, cy := v.Cursor() if l, err = v.Line(cy); err != nil { l = "" } for i, _ := range controls { if l == i { //need a helper functon to know what to do with the view controls[i](g, v) break } } return nil } func getLine(g *gocui.Gui, v *gocui.View) error { var l string var err error _, cy := v.Cursor() if l, err = v.Line(cy); err != nil { l = "" } maxX, maxY := g.Size() if v, err := g.SetView("msg", maxX/2-30, maxY/2, maxX/2+30, maxY/2+2); err != nil { if err != gocui.ErrUnknownView { return err } fmt.Fprintln(v, l) if _, err := g.SetCurrentView("msg"); err != nil { return err } } return nil } func delMsg(g *gocui.Gui, v *gocui.View) error { return delView("msg", g, v) } func delView(view string, g *gocui.Gui, v *gocui.View) error { if err := g.DeleteView(view); err != nil { return err } if _, err := g.SetCurrentView("controls"); err != nil { return err } return nil } func quit(g *gocui.Gui, v *gocui.View) error { return gocui.ErrQuit } func (c *UIControl) keybindings(g *gocui.Gui) error { //main window bindings if err := g.SetKeybinding("controls", gocui.KeyCtrlSpace, gocui.ModNone, nextView); err != nil { return err } if err := g.SetKeybinding("controls", gocui.KeyArrowDown, gocui.ModNone, cursorDown); err != nil { return err } if err := g.SetKeybinding("controls", gocui.KeyArrowUp, gocui.ModNone, cursorUp); err != nil { return err } if err := g.SetKeybinding("controls", gocui.KeyEnter, gocui.ModNone, getControl); err != nil { return err } //side window bindings if err := g.SetKeybinding("contacts", gocui.KeyCtrlSpace, gocui.ModNone, nextView); err != nil { return err } if err := g.SetKeybinding("contacts", gocui.KeyArrowDown, gocui.ModNone, cursorDown); err != nil { return err } if err := g.SetKeybinding("contacts", gocui.KeyArrowUp, gocui.ModNone, cursorUp); err != nil { return err } if err := g.SetKeybinding("contacts", gocui.KeyEnter, gocui.ModNone, getLine); err != nil { return err } //msg box binding if err := g.SetKeybinding("msg", gocui.KeyEnter, gocui.ModNone, delMsg); err != nil { return err } if err := g.SetKeybinding("search", gocui.KeyEnter, gocui.ModNone, c.searchContact); err != nil { return err } if err := g.SetKeybinding("files", gocui.KeyCtrlSpace, gocui.ModNone, nextView); err != nil { return err } if err := g.SetKeybinding("files", gocui.KeyArrowDown, gocui.ModNone, cursorDown); err != nil { return err } if err := g.SetKeybinding("files", gocui.KeyArrowUp, gocui.ModNone, cursorUp); err != nil { return err } //all windows if err := g.SetKeybinding("", gocui.KeyCtrlC, gocui.ModNone, quit); err != nil { return err } return nil } ================================================ FILE: cuiinterface/main.go ================================================ package main import ( "github.com/amlwwalker/got-qt/logic" ) func main() { cui := &UIControl{} //pointer to logic, so needs starting update cui.logic = &logic.LogicInterface{} cui.logic.ConfigureLogic() cui.Init() //init the UI } // end of main ================================================ FILE: cuiinterface/objects.go ================================================ package main import ( "github.com/amlwwalker/got-qt/logic" "github.com/jroimartin/gocui" ) type UIControl struct { Views map[string]*gocui.View gui *gocui.Gui logic *logic.LogicInterface } ================================================ FILE: logic/logic.go ================================================ package logic import ( "time" ) //handles the interface between any go functions //and the qml func (l *LogicInterface) ConfigureLogic() { l.People = make(map[string]*Person) } func (l *LogicInterface) SearchForMatches(regex string, informant func(float64, bool)) { //if search takes a while then the informant can alert the front end var p Person p.FirstName = "Alex" p.LastName = "Walker" p.Email = "alex@walker.com" //just demoing using async if things are slow go func() { time.Sleep(1 * time.Second) informant(0.1, true) //we don't know how long this will take time.Sleep(1 * time.Second) informant(0.4, true) //we don't know how long this will take time.Sleep(1 * time.Second) informant(0.7, true) //we don't know how long this will take time.Sleep(1 * time.Second) //the informant knows whatever it was doing is ready whenit is sent a 1.0 value l.People[p.Email] = &p informant(1.0, true) //we don't know how long this will take }() } ================================================ FILE: logic/objects.go ================================================ package logic import () //this handles interfacing with any business logic occuring elsewhere type LogicInterface struct { People map[string]*Person } type Person struct { FirstName string LastName string Email string } ================================================ FILE: qt/android/AndroidManifest.xml ================================================ ================================================ FILE: qt/android/src/org/qtproject/example/notification/NotificationClient.java ================================================ /**************************************************************************** ** ** Copyright (C) 2016 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtAndroidExtras module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and The Qt Company. For licensing terms ** and conditions see https://www.qt.io/terms-conditions. For further ** information use the contact form at https://www.qt.io/contact-us. ** ** BSD License Usage ** Alternatively, you may use this file under the terms of the BSD license ** as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are ** met: ** * Redistributions of source code must retain the above copyright ** notice, this list of conditions and the following disclaimer. ** * Redistributions in binary form must reproduce the above copyright ** notice, this list of conditions and the following disclaimer in ** the documentation and/or other materials provided with the ** distribution. ** * Neither the name of The Qt Company Ltd nor the names of its ** contributors may be used to endorse or promote products derived ** from this software without specific prior written permission. ** ** ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." ** ** $QT_END_LICENSE$ ** ****************************************************************************/ package org.qtproject.example.notification; import android.app.Notification; import android.app.NotificationManager; import android.content.Context; public class NotificationClient extends org.qtproject.qt5.android.bindings.QtActivity { private static NotificationManager m_notificationManager; private static Notification.Builder m_builder; private static NotificationClient m_instance; public NotificationClient() { m_instance = this; } public static void notify(String s) { if (m_notificationManager == null) { m_notificationManager = (NotificationManager)m_instance.getSystemService(Context.NOTIFICATION_SERVICE); m_builder = new Notification.Builder(m_instance); m_builder.setSmallIcon(R.drawable.icon); m_builder.setContentTitle("Message from Wingit!"); } m_builder.setContentText(s); m_notificationManager.notify(1, m_builder.build()); } } ================================================ FILE: qt/configfiles/config.json ================================================ { "hotload": true, "host": "", "port": "", "mode": "deploy", "version": "0.1", "author": "Alex Walker", "path": "/Users/alex/", "verbose": true, "loadFrom": "~/", "date": "02-04-2018" } ================================================ FILE: qt/contactModel.go ================================================ package main import "github.com/therecipe/qt/core" const ( FirstName = int(core.Qt__UserRole) + 1<= len(m.People()) { return core.NewQVariant() } var p = m.People()[index.Row()] switch role { case FirstName: { return core.NewQVariant14(p.FirstName()) } case LastName: { return core.NewQVariant14(p.LastName()) } case Email: { return core.NewQVariant14(p.Email()) } default: { return core.NewQVariant() } } } func (m *PersonModel) rowCount(parent *core.QModelIndex) int { return len(m.People()) } func (m *PersonModel) columnCount(parent *core.QModelIndex) int { return 1 } func (m *PersonModel) roleNames() map[int]*core.QByteArray { return m.Roles() } func (m *PersonModel) addPerson(p *Person) { m.BeginInsertRows(core.NewQModelIndex(), len(m.People()), len(m.People())) m.SetPeople(append(m.People(), p)) m.EndInsertRows() } func (m *PersonModel) editPerson(row int, firstName string, lastName string, email string) { var p = m.People()[row] if firstName != "" { p.SetFirstName(firstName) } if lastName != "" { p.SetLastName(lastName) } if lastName != "" { p.SetLastName(email) } var pIndex = m.Index(row, 0, core.NewQModelIndex()) m.DataChanged(pIndex, pIndex, []int{FirstName, LastName, Email}) } func (m *PersonModel) removePerson(row int) { m.BeginRemoveRows(core.NewQModelIndex(), row, row) m.SetPeople(append(m.People()[:row], m.People()[row+1:]...)) m.EndRemoveRows() } ================================================ FILE: qt/darwin/Contents/Info.plist ================================================ NSPrincipalClass NSApplication CFBundleIconFile icons.icns CFBundleDisplayName Got-Qt CFBundleName Got-Qt CFBundlePackageType APPL CFBundleGetInfoString Created by Alex Walker CFBundleSignature ???? CFBundleExecutable qt CFBundleIdentifier com.ident.qt NOTE This file was created by me. ================================================ FILE: qt/got-qt-darwin-amd64 ================================================ [File too large to display: 40.7 MB] ================================================ FILE: qt/hotloadWatcher.go ================================================ package main import ( "fmt" "github.com/radovskyb/watcher" "log" "path/filepath" "time" ) type HotLoader struct { Loader *func(p string) blackList map[string]bool } func (h *HotLoader) initBlacklist(extensions ...string) { h.blackList = make(map[string]bool) for _, v := range extensions { h.blackList[v] = true } } func (h *HotLoader) checkBlacklist(fileName string, dir bool) bool { if h.blackList[filepath.Ext(fileName)] == true { //ignore this file return true } if dir { //consider changes to a dir itself as ignore //ignore raw directory changes return true } return false } func (h *HotLoader) handleEvent(event watcher.Event) bool { if h.checkBlacklist(event.Name(), event.IsDir()) { //its blacklisted return true } fmt.Println("event occured " + event.Name() + ", type: " + event.Op.String() + ", path: " + event.Path) return false } func (h *HotLoader) startWatcher(loader func(string)) { h.initBlacklist(".qmlc", ".cpp", ".h", ".qrc", ".go", ".java") w := watcher.New() w.IgnoreHiddenFiles(true) // SetMaxEvents to 1 to allow at most 1 event's to be received // on the Event channel per watching cycle. // // If SetMaxEvents is not set, the default is to send all events. w.SetMaxEvents(1) // Only notify rename and move events. // w.FilterOps(watcher.Rename, watcher.Move) go func() { for { select { case event := <-w.Event: if !h.handleEvent(event) { fmt.Println("file type OK") fmt.Println("loader: ", loader) loader(event.Path) } case err := <-w.Error: fmt.Println("error: ", err.Error()) case <-w.Closed: return } } }() // Watch this folder for changes. if err := w.AddRecursive("."); err != nil { log.Fatalln(err) } // Print a list of all of the files and folders currently // being watched and their paths. // for path, f := range w.WatchedFiles() { // if !h.checkBlacklist(f.Name()) { // fmt.Printf("%s: %s\n", path, f.Name()) // } // } fmt.Println() // Trigger 2 events after watcher started. // go func() { // w.Wait() // w.TriggerEvent(watcher.Create, nil) // w.TriggerEvent(watcher.Remove, nil) // }() // Start the watching process - it'll check for changes every 100ms. if err := w.Start(time.Millisecond * 100); err != nil { log.Fatalln(err) } } ================================================ FILE: qt/interface.go ================================================ package main import ( "fmt" "github.com/amlwwalker/got-qt/logic" "github.com/therecipe/qt/core" "github.com/therecipe/qt/gui" "time" ) type QmlBridge struct { core.QObject hotLoader HotLoader business BusinessInterface //messages to qml _ func(p string) `signal:"updateLoader"` _ func(author, mode, date, host, version, port string, hotload bool) `signal:"updateSettings"` _ func(data string) `signal:"sendTime"` _ func(c float64, indeterminate bool) `signal:"updateProcessStatus"` //requests from qml _ func(number1, number2 string) string `slot:"calculator"` _ func() `slot:"startAsynchronousProcess"` _ func(regex string) `slot:"searchFor"` } //setup functions to communicate between front end and back end func (q *QmlBridge) OpenWithDefaultApplication() { fmt.Println("starting desktop services") url := core.QUrl_FromLocalFile("/") gui.QDesktopServices_OpenUrl(url) fmt.Println("opened url ", url) } //example of receiving data from frontend and returning a result func (q *QmlBridge) ConfigureBridge(config Config) { //1. configure the hotloader q.business = BusinessInterface{} q.business.configureInterface() q.hotLoader = HotLoader{} //may not need it, specified in main.go //2. Configure signals //configure calculator q.ConnectCalculator(func(number1, number2 string) string { return addingNumbers(number1, number2) }) q.ConnectStartAsynchronousProcess(func() { //inform process has started //so this needs to be signaled to start a long process. //the frontend will assume a value of 1.0 is process complete q.UpdateProcessStatus(0.0, false) q.business.startAsynchronousRoutine(q.UpdateProcessStatus) }) q.ConnectSearchFor(func(regex string) { //in here we are going to add matches to the search model //that way the front end will be updated live //inform front end work has begun q.UpdateProcessStatus(0.0, true) q.business.searchForMatches(regex, q.UpdateProcessStatus) }) //example signalling the frontend with settings go func() { //send the settings to the front end after a period of time time.Sleep(5 * time.Second) fmt.Println("updating settings with ", config) q.UpdateSettings(config.Author, config.Mode, config.Date, config.Host, config.Version, config.Port, config.Hotload) }() //example of external function signalling the front end q.sendCurrentTime() q.business.demo() } //example of sending data to the frontend via a signal func (q *QmlBridge) sendCurrentTime() { go func() { for t := range time.NewTicker(time.Second * 1).C { q.SendTime(t.Format(time.ANSIC)) } }() } //example of handling a receive from frontend via slot func addingNumbers(number1, number2 string) string { fmt.Println("addingNumbers") return number1 + number1 + number2 + number2 } //this handles interfacing with any business logic occuring elsewhere type BusinessInterface struct { pModel *PersonModel sModel *PersonModel fModel *PersonModel logic *logic.LogicInterface } //handles the interface between the backend architecture //and the bridge func (b *BusinessInterface) configureInterface() { b.pModel = NewPersonModel(nil) b.sModel = NewPersonModel(nil) b.fModel = NewPersonModel(nil) //pointer so needs starting update b.logic = &logic.LogicInterface{} b.logic.ConfigureLogic() } func (b *BusinessInterface) searchForMatches(regex string, informant func(float64, bool)) { //can do any preprocessing before it goes to the backend modelUpdater := func(c float64, indeterminate bool) { //if the logic is complete, then we need to update our model //with the search results //otherwise just inform the front end if 1.0 == c { //complete //but also needs to know when its complete // because if it is, then need to update the model for _, v := range b.logic.People { var p = NewPerson(nil) p.SetFirstName(v.FirstName) p.SetLastName(v.LastName) p.SetEmail(v.Email) b.sModel.AddPerson(p) } } //updates the front end informant(c, true) //we don't know how long it will take } b.logic.SearchForMatches(regex, modelUpdater) } //the interface needs to know how to inform the front end on progress //so takes a function that takes a value that the front end will use func (b *BusinessInterface) startAsynchronousRoutine(informant func(float64, bool)) { //on a go routine, count up to 10 //each tick, inform the front end of your percentage progress //when it reaches ten, inform the front end it is complete go func() { var c float64 c = 0.0 for c < 1.0 { informant(c, false) //we know how long this process will take time.Sleep(1 * time.Second) c = c + 0.1 } return }() } func (b *BusinessInterface) demo() { var p = NewPerson(nil) p.SetFirstName("john") p.SetLastName("doe") p.SetEmail("john@doe.com") //add the person to the PersonModel b.pModel.SetPeople([]*Person{p}) //make changes on a routine //to demo updates go func() { fmt.Println("3 seconds to adding new people") time.Sleep(3 * time.Second) //add person for i := 0; i < 3; i++ { var p = NewPerson(nil) p.SetFirstName("hello") p.SetLastName("world") p.SetEmail("hello@world.com") b.pModel.AddPerson(p) } fmt.Println("3 seconds to editing people") time.Sleep(3 * time.Second) //edit person (demo not changing a field by leaving it blank (see the model code)) b.pModel.EditPerson(1, "bob", "", "bob@gmail.com") b.pModel.EditPerson(3, "", "john", "john@hotmail.com") fmt.Println("3 seconds to remove person") time.Sleep(3 * time.Second) //remove person b.pModel.RemovePerson(2) }() } ================================================ FILE: qt/main.go ================================================ package main import ( "encoding/json" "fmt" "github.com/therecipe/qt/core" "github.com/therecipe/qt/quick" "github.com/therecipe/qt/widgets" "github.com/gobuffalo/packr" //for compiled files "os" "path/filepath" "strings" ) type Config struct { Author string `"json":"author"` Date string `"json":"date"` Mode string `"json":"mode"` Host string `"json":"host"` Version string `"json":"version"` Port string `"json":"port"` Hotload bool `"json":"hotload"` } func LoadConfiguration() (error, Config) { var config Config //lets compile the config.json file into the binary so its easily accessible box := packr.NewBox("./configfiles") if configFile, err := box.MustBytes("config.json"); err != nil { return err, config } else { json.Unmarshal(configFile, &config) return nil, config } } func main() { //0. set any required env vars for qt os.Setenv("QT_QUICK_CONTROLS_STYLE", "material") //set style to material os.Setenv("QML_DISABLE_DISK_CACHE", "true") //disable caching files //1. the hotloader needs a path to the qml files highest directory // change this if you are working elsewhere var topLevel = filepath.Join(os.Getenv("GOPATH"), "src", "github.com", "amlwwalker", "got-qt", "qt", "qml") //2. load the configuration file _, config := LoadConfiguration() //3. Create a bridge to the frontend var qmlBridge = NewQmlBridge(nil) qmlBridge.ConfigureBridge(config) // turn on high definition scaling core.QCoreApplication_SetAttribute(core.Qt__AA_EnableHighDpiScaling, true) //4. Configure the qml binding and create an application widgets.NewQApplication(len(os.Args), os.Args) //create a view var view = quick.NewQQuickView(nil) view.SetTitle("got-qt") qmlBridge.OpenWithDefaultApplication() //try and open a default directory //configure the view to know about the bridge //this needs to happen before anything happens on another thread //else the thread might beat the context property to setup view.RootContext().SetContextProperty("QmlBridge", qmlBridge) view.RootContext().SetContextProperty("ContactsModel", qmlBridge.business.pModel) view.RootContext().SetContextProperty("SearchModel", qmlBridge.business.sModel) view.RootContext().SetContextProperty("FilesModel", qmlBridge.business.fModel) //5. Configure hotloading //configure the loader to handle updating qml live loader := func(p string) { fmt.Println("changed:", p) view.SetSource(core.NewQUrl()) view.Engine().ClearComponentCache() view.SetSource(core.NewQUrl3(topLevel+"/loader.qml", 0)) if !strings.Contains(p, "/loader.qml") { relativePath := strings.Replace(p, topLevel+"/", "", -1) qmlBridge.UpdateLoader(relativePath) } } var notifier NotificationHandler notifier.Initialise() //decide whether to enable hotloading (must be disabled for deployment) if !config.Hotload { fmt.Println("compiling qml into binary...") view.SetSource(core.NewQUrl3("qrc:/qml/loader-production.qml", 0)) notifier.Push("Hotloading", "Disabled") } else { view.SetSource(core.NewQUrl3(topLevel+"/loader.qml", 0)) go qmlBridge.hotLoader.startWatcher(loader) notifier.Push("Hotloading", "Enabled") } //6. Complete setup, and start the UI view.SetResizeMode(quick.QQuickView__SizeRootObjectToView) view.Show() widgets.QApplication_Exec() } ================================================ FILE: qt/main.go.bak ================================================ package main import ( "encoding/json" "fmt" "github.com/therecipe/qt/core" "github.com/therecipe/qt/quick" "github.com/therecipe/qt/widgets" "os" "path/filepath" "strings" ) type Config struct { Author string `"json":"author"` Date string `"json":"date"` Mode string `"json":"mode"` Host string `"json":"host"` Version string `"json":"version"` Port string `"json":"port"` Hotload bool `"json":"hotload"` } func LoadConfiguration(file string) (error, Config) { var config Config configFile, err := os.Open(file) defer configFile.Close() if err != nil { fmt.Println(err.Error()) return err, config } jsonParser := json.NewDecoder(configFile) jsonParser.Decode(&config) return nil, config } func main() { //0. set any required env vars for qt os.Setenv("QT_QUICK_CONTROLS_STYLE", "material") //set style to material os.Setenv("QML_DISABLE_DISK_CACHE", "true") //disable caching files //1. the hotloader needs a path to the qml files highest directory // change this if you are working elsewhere var topLevel = filepath.Join(os.Getenv("GOPATH"), "src", "github.com", "", "got-qt", "qt", "qml") //2. load the configuration file _, config := LoadConfiguration("config.json") //3. Create a bridge to the frontend var qmlBridge = NewQmlBridge(nil) qmlBridge.ConfigureBridge(config) // turn on high definition scaling core.QCoreApplication_SetAttribute(core.Qt__AA_EnableHighDpiScaling, true) //4. Configure the qml binding and create an application widgets.NewQApplication(len(os.Args), os.Args) //create a view var view = quick.NewQQuickView(nil) view.SetTitle("Got-Qt") //configure the view to know about the bridge //this needs to happen before anything happens on another thread //else the thread might beat the context property to setup view.RootContext().SetContextProperty("QmlBridge", qmlBridge) view.RootContext().SetContextProperty("ContactsModel", qmlBridge.business.pModel) view.RootContext().SetContextProperty("SearchModel", qmlBridge.business.sModel) view.RootContext().SetContextProperty("FilesModel", qmlBridge.business.fModel) //5. Configure hotloading //configure the loader to handle updating qml live loader := func(p string) { fmt.Println("changed:", p) view.SetSource(core.NewQUrl()) view.Engine().ClearComponentCache() view.SetSource(core.NewQUrl3(topLevel+"/loader.qml", 0)) if !strings.Contains(p, "/loader.qml") { relativePath := strings.Replace(p, topLevel+"/", "", -1) qmlBridge.UpdateLoader(relativePath) } } //decide whether to enable hotloading (must be disabled for deployment) if !config.Hotload { fmt.Println("compiling qml into binary...") view.SetSource(core.NewQUrl3("qrc:/qml/loader-production.qml", 0)) } else { view.SetSource(core.NewQUrl3(topLevel+"/loader.qml", 0)) go qmlBridge.hotLoader.startWatcher(loader) } //6. Complete setup, and start the UI view.SetResizeMode(quick.QQuickView__SizeRootObjectToView) view.Show() widgets.QApplication_Exec() } ================================================ FILE: qt/notificationHandler.go ================================================ package main import ( "github.com/0xAX/notificator" //for desktop "github.com/therecipe/qt/androidextras" "github.com/therecipe/qt/core" "runtime" "fmt" ) type NotificationHandler struct { AndroidNotifier *NotificationClient DesktopNotifier *notificator.Notificator } type NotificationClient struct { core.QObject _ func() `constructor:"init"` _ string `property:"notification"` _ func(string) `slot:"updateAndroidNotification"` } func (n *NotificationHandler) Initialise() { n.AndroidNotifier = NewNotificationClient(nil) n.AndroidNotifier.ConnectNotificationChanged(n.AndroidNotifier.updateAndroidNotification) //initialise the notifiers n.DesktopNotifier = notificator.New(notificator.Options{ DefaultIcon: "", AppName: "WingIt", }) } func (n *NotificationHandler) Push(title, message string) { switch runtime.GOOS { case "android": //in this case, we are notifying on android // notificationClient = NewNotificationClient(view) // view.Engine().RootContext().SetContextProperty("notificationClient", notificationClient) fmt.Println("setting android notification") n.AndroidNotifier.SetNotification(message) default: //notifying on desktop n.DesktopNotifier.Push(title, message, "", notificator.UR_CRITICAL) } } func (c *NotificationClient) init() { c.ConnectNotificationChanged(c.updateAndroidNotification) } func (c *NotificationClient) updateAndroidNotification(n string) { fmt.Println("string is ", n) var err = androidextras.QAndroidJniObject_CallStaticMethodVoid2Caught( "org/qtproject/example/notification/NotificationClient", "notify", "(Ljava/lang/String;)V", n, ) if err != nil { println(err.Error()) } } ================================================ FILE: qt/qml/elements/FilePicker.qml ================================================ import QtQuick 2.0 import QtQuick.Controls 1.4 as OldControls import QtQuick.Controls 2.1 import Qt.labs.folderlistmodel 2.1 import QtQuick.Window 2.0 import "utils.js" as Utils Item { id:picker signal fileSelected(string fileName) readonly property real textmargin: Utils.dp(Screen.pixelDensity, 8) readonly property real textSize: Utils.dp(Screen.pixelDensity, 16) readonly property real headerTextSize: Utils.dp(Screen.pixelDensity, 12) readonly property real buttonHeight: Utils.dp(Screen.pixelDensity, 24) readonly property real rowHeight: Utils.dp(Screen.pixelDensity, 36) readonly property real toolbarHeight: Utils.dp(Screen.pixelDensity, 48) property bool showDotAndDotDot: false property bool showHidden: true property bool showDirsFirst: true property string folder: "file:///~/" property string nameFilters: "*.*" function currentFolder() { return folderListModel.folder; } function isFolder(fileName) { return folderListModel.isFolder(folderListModel.indexOf(folderListModel.folder + "/" + fileName)); } function canMoveUp() { return folderListModel.folder.toString() !== "file:///"; } function onItemClick(fileName) { console.log('clicked on ' + fileName) if(!isFolder(fileName)) { fileSelected(fileName) return; } if(fileName === ".." && canMoveUp()) { folderListModel.folder = folderListModel.parentFolder } else if(fileName !== ".") { if(folderListModel.folder.toString() === "file:///") { folderListModel.folder += fileName } else { folderListModel.folder += "/" + fileName } } } Rectangle { id: toolbar anchors.right: parent.right anchors.left: parent.left anchors.top: parent.top height: toolbarHeight color: Utils.backgroundColor() Button { id: button text: ".." anchors.right: parent.right anchors.rightMargin: buttonHeight anchors.bottom: parent.bottom anchors.top: parent.top enabled: canMoveUp() flat: true onClicked: { if(canMoveUp) { folderListModel.folder = folderListModel.parentFolder } } } Text { id: filePath text: folderListModel.folder.toString().replace("file:///", "►").replace(new RegExp("/",'g'), "►") renderType: Text.NativeRendering elide: Text.ElideMiddle anchors.right: button.left font.italic: true font.bold: true verticalAlignment: Text.AlignVCenter anchors.left: parent.left anchors.leftMargin: buttonHeight anchors.bottom: parent.bottom anchors.top: parent.top font.pixelSize: textSize } } FolderListModel { id: folderListModel showDotAndDotDot: picker.showDotAndDotDot showHidden: picker.showHidden showDirsFirst: picker.showDirsFirst folder: picker.folder nameFilters: picker.nameFilters } OldControls.TableView { id: view anchors.top: toolbar.bottom anchors.right: parent.right anchors.bottom: parent.bottom anchors.left: parent.left model: folderListModel headerDelegate:headerDelegate rowDelegate: Rectangle { height: rowHeight } OldControls.TableViewColumn { title: qsTr("FileName") role: "fileName" resizable: true delegate: fileDelegate } Component { id: fileDelegate Item { height: rowHeight Rectangle { anchors.fill: parent MouseArea { anchors.fill: parent onClicked: { onItemClick(fileNameText.text) } } Text { id: fileNameText height: width anchors.left: image.right anchors.top: parent.top anchors.bottom: parent.bottom anchors.right: parent.right text: styleData.value !== undefined ? styleData.value : "" verticalAlignment: Text.AlignVCenter } Image { id: image height: buttonHeight width: height anchors.left: parent.left anchors.leftMargin: textmargin anchors.verticalCenter: parent.verticalCenter source: isFolder(fileNameText.text) ? "qrc:/qml/images/FA/white/png/22/folder.png" : "qrc:/qml/images/FA/white/png/22/file.png" } } } } Component { id: headerDelegate Rectangle { height: rowHeight color: Utils.textAltColor() border.color: Utils.textAltColor() Text { anchors.verticalCenter: parent.verticalCenter anchors.horizontalCenter: parent.horizontalCenter height: headerTextSize font.bold: true elide: Text.ElideMiddle color: Utils.primaryColor() text: styleData.value !== undefined ? styleData.value : "" } } } } } ================================================ FILE: qt/qml/elements/PressAndHoldButton.qml ================================================ /**************************************************************************** ** ** Copyright (C) 2015 The Qt Company Ltd. ** Contact: http://www.qt.io/licensing/ ** ** This file is part of the examples of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are ** met: ** * Redistributions of source code must retain the above copyright ** notice, this list of conditions and the following disclaimer. ** * Redistributions in binary form must reproduce the above copyright ** notice, this list of conditions and the following disclaimer in ** the documentation and/or other materials provided with the ** distribution. ** * Neither the name of The Qt Company Ltd nor the names of its ** contributors may be used to endorse or promote products derived ** from this software without specific prior written permission. ** ** ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." ** ** $QT_END_LICENSE$ ** ****************************************************************************/ import QtQuick 2.6 Image { id: container property int repeatDelay: 300 property int repeatDuration: 75 property bool pressed: false signal clicked scale: pressed ? 0.9 : 1 function release() { autoRepeatClicks.stop() container.pressed = false } SequentialAnimation on pressed { id: autoRepeatClicks running: false PropertyAction { target: container; property: "pressed"; value: true } ScriptAction { script: container.clicked() } PauseAnimation { duration: repeatDelay } SequentialAnimation { loops: Animation.Infinite ScriptAction { script: container.clicked() } PauseAnimation { duration: repeatDuration } } } MouseArea { anchors.fill: parent onPressed: autoRepeatClicks.start() onReleased: container.release() onCanceled: container.release() } } ================================================ FILE: qt/qml/elements/TextButton.qml ================================================ /**************************************************************************** ** ** Copyright (C) 2015 The Qt Company Ltd. ** Contact: http://www.qt.io/licensing/ ** ** This file is part of the examples of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are ** met: ** * Redistributions of source code must retain the above copyright ** notice, this list of conditions and the following disclaimer. ** * Redistributions in binary form must reproduce the above copyright ** notice, this list of conditions and the following disclaimer in ** the documentation and/or other materials provided with the ** distribution. ** * Neither the name of The Qt Company Ltd nor the names of its ** contributors may be used to endorse or promote products derived ** from this software without specific prior written permission. ** ** ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." ** ** $QT_END_LICENSE$ ** ****************************************************************************/ import QtQuick 2.6 Rectangle { id: container property alias text: label.text signal clicked width: label.width + 20; height: label.height + 6 smooth: true radius: 10 gradient: Gradient { GradientStop { id: gradientStop; position: 0.0; color: palette.light } GradientStop { position: 1.0; color: palette.button } } SystemPalette { id: palette } MouseArea { id: mouseArea anchors.fill: parent onClicked: { container.clicked() } } Text { id: label anchors.centerIn: parent } states: State { name: "pressed" when: mouseArea.pressed PropertyChanges { target: gradientStop; color: palette.dark } } } ================================================ FILE: qt/qml/elements/Toast.qml ================================================ import QtQuick 2.6 import QtQuick.Layouts 1.3 import QtQuick.Controls 2.0 import QtQuick.Controls.Material 2.0 Popup { id: popup bottomMargin: 80 background: Rectangle{ color: "#ddd" radius: 3 } height: 40 modal: true focus: true closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutsideParent Timer { id: toastTimer interval: 3000 repeat: false onTriggered: { popup.close() } } // toastTimer Label { id: toastLabel leftPadding: 16 rightPadding: 16 font.pixelSize: 14 color: "black" horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter } // toastLabel onAboutToShow: { toastTimer.start() } function start(toastText) { toastLabel.text = toastText if(!toastTimer.running) { open() } else { toastTimer.restart() } } // function start } // popup toastPopup ================================================ FILE: qt/qml/elements/utils.js ================================================ function dp(pixelDensity,x) { return (pixelDensity * 25.4 < 120) ? x : x*(pixelDensity * 25.4/160); } function baseColor() { return "#f26e35" } function primaryColor() { return "#d04828" } function textColor() { return "#434f4d" } function textAltColor() { return "#a6aaa2" } function backgroundColor() { return "#e7e8e9" } function backgroundAltColor() { return "#ffefde" } ================================================ FILE: qt/qml/loader-production.qml ================================================ import QtQuick 2.6 import QtQuick.Layouts 1.3 import QtQuick.Controls 2.0 import QtQuick.Controls.Material 2.0 import QtQuick.Controls.Universal 2.0 import Qt.labs.settings 1.0 import "elements" Item { id: window width: 360 height: 520 visible: true Settings { id: settings property string style: "Default" } ColumnLayout { width: parent.width anchors.fill: parent ToolBar { id: toolbar Material.foreground: "white" Material.background: Material.BlueGrey z: 100 anchors.left: parent.left anchors.right: parent.right anchors.top: parent.top RowLayout { spacing: 20 anchors.fill: parent ToolButton { contentItem: Image { fillMode: Image.Pad horizontalAlignment: Image.AlignHCenter verticalAlignment: Image.AlignVCenter source: "images/drawer.png" //stackView.depth > 1 ? "images/back.png" : "images/drawer.png" } onClicked: { //if (stackView.depth > 1) { // stackView.pop() // listView.currentIndex = -1 //} else { // drawer.open() //} drawer.open() } } Label { id: titleLabel text: listView.currentItem ? listView.currentItem.text : "My App" font.pixelSize: 20 elide: Label.ElideRight horizontalAlignment: Qt.AlignHCenter verticalAlignment: Qt.AlignVCenter Layout.fillWidth: true } ToolButton { id: settingsViewer contentItem: Image { fillMode: Image.Pad horizontalAlignment: Image.AlignHCenter verticalAlignment: Image.AlignVCenter source: "qrc:/qml/images/menu.png" } onClicked: optionsMenu.open() Menu { id: optionsMenu MenuItem { text: "Settings" onTriggered: settingsPopup.open() } MenuItem { text: "About" onTriggered: aboutDialog.open() } MenuItem { text: "Log Out" onTriggered: logoutDialog.open() } } } } } Toast { //a toast that everyone can use id: globalToast x: parent.width / 10 y: (parent.height * 4) / 5 width: (parent.width * 4) / 5 } BusyIndicator { id: loadingIndicator visible: true z: 100 readonly property int size: Math.min(footer.availableWidth, footer.availableHeight) / 5 width: size height: size anchors.horizontalCenter: parent.horizontalCenter anchors.bottom: footer.top Material.accent: Material.BlueGrey } ToolBar { id: footer Material.foreground: "white" Material.background: Material.BlueGrey z: 100 anchors.left: parent.left anchors.right: parent.right anchors.bottom: parent.bottom RowLayout { spacing: 20 anchors.fill: parent Label { id: footerLabel text: "" visible: true font.pixelSize: 16 elide: Label.ElideRight horizontalAlignment: Qt.AlignHCenter verticalAlignment: Qt.AlignVCenter Layout.fillWidth: true } ProgressBar { id: progressIndicator value: 0.0 indeterminate: false visible: false z: 100 width: parent.width anchors.horizontalCenter: parent.horizontalCenter Material.accent: Material.Grey } Connections { target: QmlBridge //Progress bar update onUpdateProcessStatus: { //initialise the viewing footerLabel.visible = false progressIndicator.visible = true progressIndicator.indeterminate = indeterminate //set the progress value (only useful when determinate) progressIndicator.value = c if (c.toFixed(2) == 1.0) { //process complete progressIndicator.visible = false footerLabel.text = "process complete" footerLabel.visible = true } } } } } //content holder StackView { id: stackView Layout.fillWidth: true Layout.fillHeight: true anchors.margins: 10 Connections { target: QmlBridge //hotloading: onUpdateLoader: { stackView.clear() stackView.push(p) footerLabel.text = "detected change to: " + p loadingIndicator.visible = true } } //animates the loader for 1 second when respawning a page for effect PropertyAnimation { running: true target: loadingIndicator property: 'visible' to: false duration: 2000 } initialItem: Pane { id: pane Image { id: logo width: pane.availableWidth / 2 height: pane.availableHeight / 2 anchors.centerIn: parent anchors.verticalCenterOffset: -50 fillMode: Image.PreserveAspectFit source: "qrc:/qml/images/qt-logo.png" } Label { text: "Qt is a set of controls that can be used to build complete interfaces in Qt Quick." anchors.margins: 20 anchors.top: logo.bottom anchors.left: parent.left anchors.right: parent.right horizontalAlignment: Label.AlignHCenter verticalAlignment: Label.AlignVCenter wrapMode: Label.Wrap } } onCurrentItemChanged: currentItem.anchors.fill = this } } //menu Drawer { id: drawer width: Math.min(window.width, window.height) / 3 * 2 height: window.height dragMargin: stackView.depth > 1 ? 0 : undefined ListView { id: listView currentIndex: -1 anchors.fill: parent delegate: ItemDelegate { width: parent.width text: model.title highlighted: ListView.isCurrentItem onClicked: { if (listView.currentIndex != index) { listView.currentIndex = index stackView.push(model.source) titleLabel.text = model.title } drawer.close() } } model: ListModel { //application ListElement { title: "Contacts"; source: "qrc:/qml/pages/_contactsPage.qml" } ListElement { title: "Files"; source: "qrc:/qml/pages/_filelistPage.qml" } ListElement { title: "Downloads"; source: "qrc:/qml/pages/_downloadsPage.qml" } ListElement { title: "Search"; source: "qrc:/qml/pages/_searchPage.qml" } ListElement { title: "Login"; source: "qrc:/qml/pages/_loginPage.qml" } ListElement { title: "Calulator"; source: "qrc:/qml/pages/_calculatorPage.qml" } ListElement { title: "Clock"; source: "qrc:/qml/pages/_clockPage.qml" } ListElement { title: "Toast"; source: "qrc:/qml/pages/_toastPage.qml" } ListElement { title: "Dark Fruit"; source: "qrc:/qml/pages/_fruitsPage.qml" } ListElement { title: "Light Fruit"; source: "qrc:/qml/pages/_fruitsPage2.qml" } ListElement { title: "Asynchronous Loading"; source: "qrc:/qml/pages/_asynchronousPage.qml" } //demos ListElement { title: "BusyIndicator"; source: "qrc:/qml/pages/BusyIndicatorPage.qml" } ListElement { title: "Button"; source: "qrc:/qml/pages/ButtonPage.qml" } ListElement { title: "CheckBox"; source: "qrc:/qml/pages/CheckBoxPage.qml" } ListElement { title: "ComboBox"; source: "qrc:/qml/pages/ComboBoxPage.qml" } ListElement { title: "Dial"; source: "qrc:/qml/pages/DialPage.qml" } ListElement { title: "Delegates"; source: "qrc:/qml/pages/DelegatePage.qml" } ListElement { title: "Drawer"; source: "qrc:/qml/pages/DrawerPage.qml" } ListElement { title: "Frame"; source: "qrc:/qml/pages/FramePage.qml" } ListElement { title: "GroupBox"; source: "qrc:/qml/pages/GroupBoxPage.qml" } ListElement { title: "Menu"; source: "qrc:/qml/pages/MenuPage.qml" } ListElement { title: "PageIndicator"; source: "qrc:/qml/pages/PageIndicatorPage.qml" } ListElement { title: "Popup"; source: "qrc:/qml/pages/PopupPage.qml" } ListElement { title: "ProgressBar"; source: "qrc:/qml/pages/ProgressBarPage.qml" } ListElement { title: "RadioButton"; source: "qrc:/qml/pages/RadioButtonPage.qml" } ListElement { title: "RangeSlider"; source: "qrc:/qml/pages/RangeSliderPage.qml" } ListElement { title: "ScrollBar"; source: "qrc:/qml/pages/ScrollBarPage.qml" } ListElement { title: "ScrollIndicator"; source: "qrc:/qml/pages/ScrollIndicatorPage.qml" } ListElement { title: "Slider"; source: "qrc:/qml/pages/SliderPage.qml" } ListElement { title: "SpinBox"; source: "qrc:/qml/pages/SpinBoxPage.qml" } ListElement { title: "StackView"; source: "qrc:/qml/pages/StackViewPage.qml" } ListElement { title: "SwipeView"; source: "qrc:/qml/pages/SwipeViewPage.qml" } ListElement { title: "Switch"; source: "qrc:/qml/pages/SwitchPage.qml" } ListElement { title: "TabBar"; source: "qrc:/qml/pages/TabBarPage.qml" } ListElement { title: "TextArea"; source: "qrc:/qml/pages/TextAreaPage.qml" } ListElement { title: "TextField"; source: "qrc:/qml/pages/TextFieldPage.qml" } ListElement { title: "ToolTip"; source: "qrc:/qml/pages/ToolTipPage.qml" } ListElement { title: "Tumbler"; source: "qrc:/qml/pages/TumblerPage.qml" } } ScrollIndicator.vertical: ScrollIndicator { } } } Popup { id: notificationPopup x: (window.width - width) / 2 y: window.height / 6 width: Math.min(window.width, window.height) / 3 * 2 height: settingsColumn.implicitHeight + topPadding + bottomPadding modal: true focus: true contentItem: Text { id: notifcationText text: "" } } Popup { id: settingsPopup x: (window.width - width) / 2 y: window.height / 6 width: Math.min(window.width, window.height) / 3 * 2 height: settingsColumn.implicitHeight + topPadding + bottomPadding modal: true focus: true contentItem: ColumnLayout { id: settingsColumn spacing: 20 Label { text: "Configuration" font.bold: true } RowLayout { spacing: 10 GridLayout { id: grid columns: 2 Text { text: "Hotloading"; font.bold: true; } Text { id: hotloading; text: "waiting"; color: "red" } Text { text: "Version"; font.bold: true; } Text { id: host; text: "waiting"; color: "red" } } Connections { target: QmlBridge onUpdateSettings: { footerLabel.text = version hotloading.text = hotload } } //ComboBox { // id: styleBox // property int styleIndex: -1 // model: ["Default", "Material", "Universal"] // Component.onCompleted: { // styleIndex = find(settings.style, Qt.MatchFixedString) // if (styleIndex !== -1) // currentIndex = styleIndex // } // Layout.fillWidth: true //} } //Label { // text: "Restart required" // color: "#e41e25" // opacity: styleBox.currentIndex !== styleBox.styleIndex ? 1.0 : 0.0 // horizontalAlignment: Label.AlignHCenter // verticalAlignment: Label.AlignVCenter // Layout.fillWidth: true // Layout.fillHeight: true //} RowLayout { spacing: 10 Button { id: okButton text: "Ok" onClicked: { //settings.style = styleBox.displayText settingsPopup.close() } Material.foreground: Material.primary Material.background: "transparent" Material.elevation: 0 Layout.preferredWidth: 0 Layout.fillWidth: true } Button { id: cancelButton text: "Cancel" onClicked: { //styleBox.currentIndex = styleBox.styleIndex settingsPopup.close() } Material.background: "transparent" Material.elevation: 0 Layout.preferredWidth: 0 Layout.fillWidth: true } } } } Popup { id: logoutDialog modal: true focus: true x: (window.width - width) / 2 y: window.height / 6 width: Math.min(window.width, window.height) / 3 * 2 contentHeight: logoutColumn.height Column { id: logoutColumn spacing: 20 Label { text: "Logout" font.bold: true } Label { width: logoutDialog.availableWidth text: "Logging out is really only necessary if you share a computer with others. If you want to continue, click logout below otherwise click elsewhere on the window" wrapMode: Label.Wrap font.pixelSize: 12 } Button { id: searchButton text: "Logout" width: logoutDialog.availableWidth onClicked: function() { console.log('logging out') } } } } Popup { id: aboutDialog modal: true focus: true x: (window.width - width) / 2 y: window.height / 6 width: Math.min(window.width, window.height) / 3 * 2 contentHeight: aboutColumn.height Column { id: aboutColumn spacing: 20 Label { text: "About" font.bold: true } Label { width: aboutDialog.availableWidth text: "The Qt Quick Controls 2 module delivers the next generation user interface controls based on Qt Quick." wrapMode: Label.Wrap font.pixelSize: 12 } Label { width: aboutDialog.availableWidth text: "In comparison to the desktop-oriented Qt Quick Controls 1, Qt Quick Controls 2 " + "are an order of magnitude simpler, lighter and faster, and are primarily targeted " + "towards embedded and mobile platforms." wrapMode: Label.Wrap font.pixelSize: 12 } } } } ================================================ FILE: qt/qml/loader.qml ================================================ import QtQuick 2.6 import QtQuick.Layouts 1.3 import QtQuick.Controls 2.0 import QtQuick.Controls.Material 2.0 import QtQuick.Controls.Universal 2.0 import Qt.labs.settings 1.0 import "elements" Item { id: window width: 480 height: 620 visible: true Settings { id: settings property string style: "Default" } ColumnLayout { width: parent.width anchors.fill: parent ToolBar { id: toolbar Material.foreground: "white" Material.background: Material.BlueGrey z: 100 anchors.left: parent.left anchors.right: parent.right anchors.top: parent.top RowLayout { spacing: 20 anchors.fill: parent ToolButton { contentItem: Image { fillMode: Image.Pad horizontalAlignment: Image.AlignHCenter verticalAlignment: Image.AlignVCenter source: "images/drawer.png" //stackView.depth > 1 ? "images/back.png" : "images/drawer.png" } onClicked: { //if (stackView.depth > 1) { // stackView.pop() // listView.currentIndex = -1 //} else { // drawer.open() //} drawer.open() } } Label { id: titleLabel text: listView.currentItem ? listView.currentItem.text : "My App" font.pixelSize: 20 elide: Label.ElideRight horizontalAlignment: Qt.AlignHCenter verticalAlignment: Qt.AlignVCenter Layout.fillWidth: true } ToolButton { id: settingsViewer contentItem: Image { fillMode: Image.Pad horizontalAlignment: Image.AlignHCenter verticalAlignment: Image.AlignVCenter source: "qrc:/qml/images/menu.png" } onClicked: optionsMenu.open() Menu { id: optionsMenu MenuItem { text: "Settings" onTriggered: settingsPopup.open() } MenuItem { text: "About" onTriggered: aboutDialog.open() } MenuItem { text: "Log Out" onTriggered: logoutDialog.open() } } } } } Toast { //a toast that everyone can use id: globalToast x: parent.width / 10 y: (parent.height * 4) / 5 width: (parent.width * 4) / 5 } BusyIndicator { id: loadingIndicator visible: true z: 100 readonly property int size: Math.min(footer.availableWidth, footer.availableHeight) / 5 width: size height: size anchors.horizontalCenter: parent.horizontalCenter anchors.bottom: footer.top Material.accent: Material.BlueGrey } ToolBar { id: footer Material.foreground: "white" Material.background: Material.BlueGrey z: 100 anchors.left: parent.left anchors.right: parent.right anchors.bottom: parent.bottom RowLayout { spacing: 20 anchors.fill: parent Label { id: footerLabel text: "" visible: true font.pixelSize: 16 elide: Label.ElideRight horizontalAlignment: Qt.AlignHCenter verticalAlignment: Qt.AlignVCenter Layout.fillWidth: true } ProgressBar { id: progressIndicator value: 0.0 indeterminate: false visible: false z: 100 width: parent.width anchors.horizontalCenter: parent.horizontalCenter Material.accent: Material.Grey } Connections { target: QmlBridge //Progress bar update onUpdateProcessStatus: { //initialise the viewing footerLabel.visible = false progressIndicator.visible = true progressIndicator.indeterminate = indeterminate //set the progress value (only useful when determinate) progressIndicator.value = c if (c.toFixed(2) == 1.0) { //process complete progressIndicator.visible = false footerLabel.text = "process complete" footerLabel.visible = true } } } } } //content holder StackView { id: stackView Layout.fillWidth: true Layout.fillHeight: true anchors.margins: 10 Connections { target: QmlBridge //hotloading: onUpdateLoader: { stackView.clear() stackView.push(p) footerLabel.text = "detected change to: " + p loadingIndicator.visible = true } } //animates the loader for 1 second when respawning a page for effect PropertyAnimation { running: true target: loadingIndicator property: 'visible' to: false duration: 2000 } initialItem: Pane { id: pane Image { id: logo width: pane.availableWidth / 2 height: pane.availableHeight / 2 anchors.centerIn: parent anchors.verticalCenterOffset: -50 fillMode: Image.PreserveAspectFit source: "qrc:/qml/images/qt-logo.png" } Label { text: "Qt is a set of controls that can be used to build complete interfaces in Qt Quick." anchors.margins: 20 anchors.top: logo.bottom anchors.left: parent.left anchors.right: parent.right horizontalAlignment: Label.AlignHCenter verticalAlignment: Label.AlignVCenter wrapMode: Label.Wrap } } //onCurrentItemChanged: currentItem.anchors.fill = this } } //menu Drawer { id: drawer width: Math.min(window.width, window.height) / 3 * 2 height: window.height dragMargin: stackView.depth > 1 ? 0 : undefined ListView { id: listView currentIndex: -1 anchors.fill: parent delegate: ItemDelegate { width: parent.width text: model.title highlighted: ListView.isCurrentItem onClicked: { if (listView.currentIndex != index) { listView.currentIndex = index stackView.push(model.source) titleLabel.text = model.title } drawer.close() } } model: ListModel { //application ListElement { title: "Contacts"; source: "pages/_contactsPage.qml" } ListElement { title: "Files"; source: "pages/_filelistPage.qml" } ListElement { title: "Downloads"; source: "pages/_downloadsPage.qml" } ListElement { title: "Search"; source: "pages/_searchPage.qml" } ListElement { title: "Login"; source: "pages/_loginPage.qml" } ListElement { title: "Calulator"; source: "pages/_calculatorPage.qml" } ListElement { title: "Clock"; source: "pages/_clockPage.qml" } ListElement { title: "Toast"; source: "pages/_toastPage.qml" } ListElement { title: "Dark Fruit"; source: "pages/_fruitsPage.qml" } ListElement { title: "Light Fruit"; source: "pages/_fruitsPage2.qml" } ListElement { title: "Asynchronous Loading"; source: "pages/_asynchronousPage.qml" } //demos ListElement { title: "BusyIndicator"; source: "pages/BusyIndicatorPage.qml" } ListElement { title: "Button"; source: "pages/ButtonPage.qml" } ListElement { title: "CheckBox"; source: "pages/CheckBoxPage.qml" } ListElement { title: "ComboBox"; source: "pages/ComboBoxPage.qml" } ListElement { title: "Dial"; source: "pages/DialPage.qml" } ListElement { title: "Delegates"; source: "pages/DelegatePage.qml" } ListElement { title: "Drawer"; source: "pages/DrawerPage.qml" } ListElement { title: "Frame"; source: "pages/FramePage.qml" } ListElement { title: "GroupBox"; source: "pages/GroupBoxPage.qml" } ListElement { title: "Menu"; source: "pages/MenuPage.qml" } ListElement { title: "PageIndicator"; source: "pages/PageIndicatorPage.qml" } ListElement { title: "Popup"; source: "pages/PopupPage.qml" } ListElement { title: "ProgressBar"; source: "pages/ProgressBarPage.qml" } ListElement { title: "RadioButton"; source: "pages/RadioButtonPage.qml" } ListElement { title: "RangeSlider"; source: "pages/RangeSliderPage.qml" } ListElement { title: "ScrollBar"; source: "pages/ScrollBarPage.qml" } ListElement { title: "ScrollIndicator"; source: "pages/ScrollIndicatorPage.qml" } ListElement { title: "Slider"; source: "pages/SliderPage.qml" } ListElement { title: "SpinBox"; source: "pages/SpinBoxPage.qml" } ListElement { title: "StackView"; source: "pages/StackViewPage.qml" } ListElement { title: "SwipeView"; source: "pages/SwipeViewPage.qml" } ListElement { title: "Switch"; source: "pages/SwitchPage.qml" } ListElement { title: "TabBar"; source: "pages/TabBarPage.qml" } ListElement { title: "TextArea"; source: "pages/TextAreaPage.qml" } ListElement { title: "TextField"; source: "pages/TextFieldPage.qml" } ListElement { title: "ToolTip"; source: "pages/ToolTipPage.qml" } ListElement { title: "Tumbler"; source: "pages/TumblerPage.qml" } } ScrollIndicator.vertical: ScrollIndicator { } } } Popup { id: notificationPopup x: (window.width - width) / 2 y: window.height / 6 width: Math.min(window.width, window.height) / 3 * 2 height: settingsColumn.implicitHeight + topPadding + bottomPadding modal: true focus: true contentItem: Text { id: notifcationText text: "" } } Popup { id: settingsPopup x: (window.width - width) / 2 y: window.height / 6 width: Math.min(window.width, window.height) / 3 * 2 height: settingsColumn.implicitHeight + topPadding + bottomPadding modal: true focus: true contentItem: ColumnLayout { id: settingsColumn spacing: 20 Label { text: "Configuration" font.bold: true } RowLayout { spacing: 10 GridLayout { id: grid columns: 2 Text { text: "Hotloading"; font.bold: true; } Text { id: hotloading; text: "waiting"; color: "red" } Text { text: "Version"; font.bold: true; } Text { id: host; text: "waiting"; color: "red" } } Connections { target: QmlBridge onUpdateSettings: { footerLabel.text = version hotloading.text = hotload } } //ComboBox { // id: styleBox // property int styleIndex: -1 // model: ["Default", "Material", "Universal"] // Component.onCompleted: { // styleIndex = find(settings.style, Qt.MatchFixedString) // if (styleIndex !== -1) // currentIndex = styleIndex // } // Layout.fillWidth: true //} } //Label { // text: "Restart required" // color: "#e41e25" // opacity: styleBox.currentIndex !== styleBox.styleIndex ? 1.0 : 0.0 // horizontalAlignment: Label.AlignHCenter // verticalAlignment: Label.AlignVCenter // Layout.fillWidth: true // Layout.fillHeight: true //} RowLayout { spacing: 10 Button { id: okButton text: "Ok" onClicked: { //settings.style = styleBox.displayText settingsPopup.close() } Material.foreground: Material.primary Material.background: "transparent" Material.elevation: 0 Layout.preferredWidth: 0 Layout.fillWidth: true } Button { id: cancelButton text: "Cancel" onClicked: { //styleBox.currentIndex = styleBox.styleIndex settingsPopup.close() } Material.background: "transparent" Material.elevation: 0 Layout.preferredWidth: 0 Layout.fillWidth: true } } } } Popup { id: logoutDialog modal: true focus: true x: (window.width - width) / 2 y: window.height / 6 width: Math.min(window.width, window.height) / 3 * 2 contentHeight: logoutColumn.height Column { id: logoutColumn spacing: 20 Label { text: "Logout" font.bold: true } Label { width: logoutDialog.availableWidth text: "Logging out is really only necessary if you share a computer with others. If you want to continue, click logout below otherwise click elsewhere on the window" wrapMode: Label.Wrap font.pixelSize: 12 } Button { id: searchButton text: "Logout" width: logoutDialog.availableWidth onClicked: function() { console.log('logging out') } } } } Popup { id: aboutDialog modal: true focus: true x: (window.width - width) / 2 y: window.height / 6 width: Math.min(window.width, window.height) / 3 * 2 contentHeight: aboutColumn.height Column { id: aboutColumn spacing: 20 Label { text: "About" font.bold: true } Label { width: aboutDialog.availableWidth text: "The Qt Quick Controls 2 module delivers the next generation user interface controls based on Qt Quick." wrapMode: Label.Wrap font.pixelSize: 12 } Label { width: aboutDialog.availableWidth text: "In comparison to the desktop-oriented Qt Quick Controls 1, Qt Quick Controls 2 " + "are an order of magnitude simpler, lighter and faster, and are primarily targeted " + "towards embedded and mobile platforms." wrapMode: Label.Wrap font.pixelSize: 12 } } } } ================================================ FILE: qt/qml/pages/BusyIndicatorPage.qml ================================================ /**************************************************************************** ** ** Copyright (C) 2015 The Qt Company Ltd. ** Contact: http://www.qt.io/licensing/ ** ** This file is part of the examples of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are ** met: ** * Redistributions of source code must retain the above copyright ** notice, this list of conditions and the following disclaimer. ** * Redistributions in binary form must reproduce the above copyright ** notice, this list of conditions and the following disclaimer in ** the documentation and/or other materials provided with the ** distribution. ** * Neither the name of The Qt Company Ltd nor the names of its ** contributors may be used to endorse or promote products derived ** from this software without specific prior written permission. ** ** ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." ** ** $QT_END_LICENSE$ ** ****************************************************************************/ import QtQuick 2.6 import QtQuick.Controls 2.0 ScrollablePage { id: page Column { spacing: 40 width: parent.width Label { width: parent.width wrapMode: Label.Wrap horizontalAlignment: Qt.AlignHCenter text: "BusyIndicator is used to indicate activity while content is being loaded," + " or when the UI is blocked waiting for a resource to become available." } BusyIndicator { readonly property int size: Math.min(page.availableWidth, page.availableHeight) / 5 width: size height: size anchors.horizontalCenter: parent.horizontalCenter } } } ================================================ FILE: qt/qml/pages/ButtonPage.qml ================================================ /**************************************************************************** ** ** Copyright (C) 2015 The Qt Company Ltd. ** Contact: http://www.qt.io/licensing/ ** ** This file is part of the examples of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are ** met: ** * Redistributions of source code must retain the above copyright ** notice, this list of conditions and the following disclaimer. ** * Redistributions in binary form must reproduce the above copyright ** notice, this list of conditions and the following disclaimer in ** the documentation and/or other materials provided with the ** distribution. ** * Neither the name of The Qt Company Ltd nor the names of its ** contributors may be used to endorse or promote products derived ** from this software without specific prior written permission. ** ** ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." ** ** $QT_END_LICENSE$ ** ****************************************************************************/ import QtQuick 2.6 import QtQuick.Controls 2.0 ScrollablePage { id: page readonly property int itemWidth: Math.max(button.implicitWidth, Math.min(button.implicitWidth * 2, page.availableWidth / 3)) Column { spacing: 40 width: parent.width Label { width: parent.width wrapMode: Label.Wrap horizontalAlignment: Qt.AlignHCenter text: "Button presents a push-button that can be pushed or clicked by the user. " + "Buttons are normally used to perform an action, or to answer a question." } Column { spacing: 20 anchors.horizontalCenter: parent.horizontalCenter Button { text: "First" width: itemWidth } Button { id: button text: "Second" width: itemWidth highlighted: true } Button { text: "Third" enabled: false width: itemWidth } } } } ================================================ FILE: qt/qml/pages/CheckBoxPage.qml ================================================ /**************************************************************************** ** ** Copyright (C) 2015 The Qt Company Ltd. ** Contact: http://www.qt.io/licensing/ ** ** This file is part of the examples of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are ** met: ** * Redistributions of source code must retain the above copyright ** notice, this list of conditions and the following disclaimer. ** * Redistributions in binary form must reproduce the above copyright ** notice, this list of conditions and the following disclaimer in ** the documentation and/or other materials provided with the ** distribution. ** * Neither the name of The Qt Company Ltd nor the names of its ** contributors may be used to endorse or promote products derived ** from this software without specific prior written permission. ** ** ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." ** ** $QT_END_LICENSE$ ** ****************************************************************************/ import QtQuick 2.6 import QtQuick.Controls 2.0 ScrollablePage { id: page Column { spacing: 40 width: parent.width Label { width: parent.width wrapMode: Label.Wrap horizontalAlignment: Qt.AlignHCenter text: "A checkbox presents an option button that can be toggled on or off. " + "Check boxes are typically used to select one or more options from a set of options." } Column { spacing: 20 anchors.horizontalCenter: parent.horizontalCenter CheckBox { text: "First" checked: true } CheckBox { text: "Second" } CheckBox { text: "Third" checked: true enabled: false } } } } ================================================ FILE: qt/qml/pages/ComboBoxPage.qml ================================================ /**************************************************************************** ** ** Copyright (C) 2015 The Qt Company Ltd. ** Contact: http://www.qt.io/licensing/ ** ** This file is part of the examples of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are ** met: ** * Redistributions of source code must retain the above copyright ** notice, this list of conditions and the following disclaimer. ** * Redistributions in binary form must reproduce the above copyright ** notice, this list of conditions and the following disclaimer in ** the documentation and/or other materials provided with the ** distribution. ** * Neither the name of The Qt Company Ltd nor the names of its ** contributors may be used to endorse or promote products derived ** from this software without specific prior written permission. ** ** ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." ** ** $QT_END_LICENSE$ ** ****************************************************************************/ import QtQuick 2.6 import QtQuick.Controls 2.0 ScrollablePage { id: page Column { spacing: 40 width: parent.width Label { width: parent.width wrapMode: Label.Wrap horizontalAlignment: Qt.AlignHCenter text: "ComboBox is a combined button and popup list. It presents " + "a list of options to the user that occupies minimal screen space." } ComboBox { model: ["First", "Second", "Third"] width: Math.max(implicitWidth, Math.min(implicitWidth * 2, page.availableWidth / 3)) anchors.horizontalCenter: parent.horizontalCenter } } } ================================================ FILE: qt/qml/pages/DelegatePage.qml ================================================ /**************************************************************************** ** ** Copyright (C) 2016 The Qt Company Ltd. ** Contact: http://www.qt.io/licensing/ ** ** This file is part of the examples of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are ** met: ** * Redistributions of source code must retain the above copyright ** notice, this list of conditions and the following disclaimer. ** * Redistributions in binary form must reproduce the above copyright ** notice, this list of conditions and the following disclaimer in ** the documentation and/or other materials provided with the ** distribution. ** * Neither the name of The Qt Company Ltd nor the names of its ** contributors may be used to endorse or promote products derived ** from this software without specific prior written permission. ** ** ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." ** ** $QT_END_LICENSE$ ** ****************************************************************************/ import QtQuick 2.6 import QtQuick.Layouts 1.1 import QtQuick.Controls 2.0 Pane { padding: 0 property var delegateComponentMap: { "ItemDelegate": itemDelegateComponent, "SwipeDelegate": swipeDelegateComponent, "CheckDelegate": checkDelegateComponent, "RadioDelegate": radioDelegateComponent, "SwitchDelegate": switchDelegateComponent } Component { id: itemDelegateComponent ItemDelegate { text: labelText width: parent.width } } Component { id: swipeDelegateComponent SwipeDelegate { id: swipeDelegate text: labelText width: parent.width onClicked: if (swipe.complete) view.model.remove(ourIndex) Component { id: removeComponent Rectangle { color: swipeDelegate.swipe.complete && swipeDelegate.pressed ? "#333" : "#444" width: parent.width height: parent.height clip: true Label { font.pixelSize: swipeDelegate.font.pixelSize text: "Remove" color: "white" anchors.centerIn: parent } } } swipe.left: removeComponent swipe.right: removeComponent } } Component { id: checkDelegateComponent CheckDelegate { text: labelText width: parent.width } } ButtonGroup { id: radioButtonGroup } Component { id: radioDelegateComponent RadioDelegate { text: labelText ButtonGroup.group: radioButtonGroup } } Component { id: switchDelegateComponent SwitchDelegate { text: labelText } } ColumnLayout { id: column spacing: 40 anchors.fill: parent anchors.topMargin: 20 Label { Layout.fillWidth: true wrapMode: Label.Wrap horizontalAlignment: Qt.AlignHCenter text: "Delegate controls are used as delegates in views such as ListView." } ListView { id: listView Layout.fillWidth: true Layout.fillHeight: true clip: true model: ListModel { ListElement { type: "RadioDelegate"; text: "RadioDelegate" } ListElement { type: "RadioDelegate"; text: "RadioDelegate" } ListElement { type: "RadioDelegate"; text: "RadioDelegate" } ListElement { type: "SwipeDelegate"; text: "SwipeDelegate" } ListElement { type: "SwipeDelegate"; text: "SwipeDelegate" } ListElement { type: "SwipeDelegate"; text: "SwipeDelegate" } ListElement { type: "CheckDelegate"; text: "CheckDelegate" } ListElement { type: "CheckDelegate"; text: "CheckDelegate" } ListElement { type: "CheckDelegate"; text: "CheckDelegate" } ListElement { type: "RadioDelegate"; text: "RadioDelegate" } ListElement { type: "RadioDelegate"; text: "RadioDelegate" } ListElement { type: "RadioDelegate"; text: "RadioDelegate" } ListElement { type: "SwitchDelegate"; text: "SwitchDelegate" } ListElement { type: "SwitchDelegate"; text: "SwitchDelegate" } ListElement { type: "SwitchDelegate"; text: "SwitchDelegate" } } section.property: "type" section.delegate: Pane { width: listView.width height: sectionLabel.implicitHeight + 20 Label { id: sectionLabel text: section anchors.centerIn: parent } } delegate: Loader { id: delegateLoader width: listView.width sourceComponent: delegateComponentMap[text] property string labelText: text property ListView view: listView property int ourIndex: index // Can't find a way to do this in the SwipeDelegate component itself, // so do it here instead. ListView.onRemove: SequentialAnimation { PropertyAction { target: delegateLoader property: "ListView.delayRemove" value: true } NumberAnimation { target: item property: "height" to: 0 easing.type: Easing.InOutQuad } PropertyAction { target: delegateLoader property: "ListView.delayRemove" value: false } } } } } } ================================================ FILE: qt/qml/pages/DialPage.qml ================================================ /**************************************************************************** ** ** Copyright (C) 2015 The Qt Company Ltd. ** Contact: http://www.qt.io/licensing/ ** ** This file is part of the examples of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are ** met: ** * Redistributions of source code must retain the above copyright ** notice, this list of conditions and the following disclaimer. ** * Redistributions in binary form must reproduce the above copyright ** notice, this list of conditions and the following disclaimer in ** the documentation and/or other materials provided with the ** distribution. ** * Neither the name of The Qt Company Ltd nor the names of its ** contributors may be used to endorse or promote products derived ** from this software without specific prior written permission. ** ** ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." ** ** $QT_END_LICENSE$ ** ****************************************************************************/ import QtQuick 2.6 import QtQuick.Controls 2.0 ScrollablePage { id: page Column { spacing: 40 width: parent.width Label { width: parent.width wrapMode: Label.Wrap horizontalAlignment: Qt.AlignHCenter text: "Alex: The Dial is similar to a traditional dial knob that is found on devices such as " + "stereos or industrial equipment. It allows the user to specify a value within a range." } Dial { value: 0.5 anchors.horizontalCenter: parent.horizontalCenter } } } ================================================ FILE: qt/qml/pages/DrawerPage.qml ================================================ /**************************************************************************** ** ** Copyright (C) 2015 The Qt Company Ltd. ** Contact: http://www.qt.io/licensing/ ** ** This file is part of the examples of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are ** met: ** * Redistributions of source code must retain the above copyright ** notice, this list of conditions and the following disclaimer. ** * Redistributions in binary form must reproduce the above copyright ** notice, this list of conditions and the following disclaimer in ** the documentation and/or other materials provided with the ** distribution. ** * Neither the name of The Qt Company Ltd nor the names of its ** contributors may be used to endorse or promote products derived ** from this software without specific prior written permission. ** ** ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." ** ** $QT_END_LICENSE$ ** ****************************************************************************/ import QtQuick 2.6 import QtQuick.Controls 2.0 Pane { id: pane Column { spacing: 40 width: parent.width Label { width: parent.width wrapMode: Label.Wrap horizontalAlignment: Qt.AlignHCenter text: "Drawer provides a swipe-based side panel, similar to those often used " + "in touch interfaces to provide a central location for navigation." } Button { text: "Open" anchors.horizontalCenter: parent.horizontalCenter width: Math.max(implicitWidth, Math.min(implicitWidth * 2, pane.availableWidth / 3)) onClicked: drawer.open() } } Image { source: "qrc:/images/arrow.png" anchors.left: parent.left anchors.bottom: parent.bottom } } ================================================ FILE: qt/qml/pages/FramePage.qml ================================================ /**************************************************************************** ** ** Copyright (C) 2015 The Qt Company Ltd. ** Contact: http://www.qt.io/licensing/ ** ** This file is part of the examples of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are ** met: ** * Redistributions of source code must retain the above copyright ** notice, this list of conditions and the following disclaimer. ** * Redistributions in binary form must reproduce the above copyright ** notice, this list of conditions and the following disclaimer in ** the documentation and/or other materials provided with the ** distribution. ** * Neither the name of The Qt Company Ltd nor the names of its ** contributors may be used to endorse or promote products derived ** from this software without specific prior written permission. ** ** ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." ** ** $QT_END_LICENSE$ ** ****************************************************************************/ import QtQuick 2.6 import QtQuick.Controls 2.0 ScrollablePage { id: page readonly property int itemWidth: Math.max(button.implicitWidth, Math.min(button.implicitWidth * 3, page.availableWidth / 3 * 2)) Column { spacing: 40 width: parent.width Label { width: parent.width wrapMode: Label.Wrap horizontalAlignment: Qt.AlignHCenter text: "Frame is used to layout a logical group of controls together, within a visual frame." } Frame { anchors.horizontalCenter: parent.horizontalCenter Column { spacing: 20 width: page.itemWidth RadioButton { text: "First" checked: true width: parent.width } RadioButton { id: button text: "Second" width: parent.width } RadioButton { text: "Third" width: parent.width } } } } } ================================================ FILE: qt/qml/pages/GroupBoxPage.qml ================================================ /**************************************************************************** ** ** Copyright (C) 2015 The Qt Company Ltd. ** Contact: http://www.qt.io/licensing/ ** ** This file is part of the examples of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are ** met: ** * Redistributions of source code must retain the above copyright ** notice, this list of conditions and the following disclaimer. ** * Redistributions in binary form must reproduce the above copyright ** notice, this list of conditions and the following disclaimer in ** the documentation and/or other materials provided with the ** distribution. ** * Neither the name of The Qt Company Ltd nor the names of its ** contributors may be used to endorse or promote products derived ** from this software without specific prior written permission. ** ** ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." ** ** $QT_END_LICENSE$ ** ****************************************************************************/ import QtQuick 2.6 import QtQuick.Controls 2.0 ScrollablePage { id: page readonly property int itemWidth: Math.max(button.implicitWidth, Math.min(button.implicitWidth * 3, page.availableWidth / 3 * 2)) Column { spacing: 40 width: parent.width Label { width: parent.width wrapMode: Label.Wrap horizontalAlignment: Qt.AlignHCenter text: "A GroupBox provides a frame, a title on top of it, and a logical group of controls within that frame." } GroupBox { title: "Title" anchors.horizontalCenter: parent.horizontalCenter Column { spacing: 20 width: page.itemWidth RadioButton { text: "First" checked: true width: parent.width } RadioButton { id: button text: "Second" width: parent.width } RadioButton { text: "Third" width: parent.width } } } } } ================================================ FILE: qt/qml/pages/Header.qml ================================================ Header.qml ================================================ FILE: qt/qml/pages/MenuPage.qml ================================================ /**************************************************************************** ** ** Copyright (C) 2015 The Qt Company Ltd. ** Contact: http://www.qt.io/licensing/ ** ** This file is part of the examples of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are ** met: ** * Redistributions of source code must retain the above copyright ** notice, this list of conditions and the following disclaimer. ** * Redistributions in binary form must reproduce the above copyright ** notice, this list of conditions and the following disclaimer in ** the documentation and/or other materials provided with the ** distribution. ** * Neither the name of The Qt Company Ltd nor the names of its ** contributors may be used to endorse or promote products derived ** from this software without specific prior written permission. ** ** ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." ** ** $QT_END_LICENSE$ ** ****************************************************************************/ import QtQuick 2.6 import QtQuick.Controls 2.0 ScrollablePage { id: page Column { spacing: 40 width: parent.width Label { width: parent.width wrapMode: Label.Wrap horizontalAlignment: Qt.AlignHCenter text: "Menu can be used either as a context menu, or as a popup menu." } Button { id: button text: "Open" anchors.horizontalCenter: parent.horizontalCenter width: Math.max(implicitWidth, Math.min(implicitWidth * 2, page.availableWidth / 3)) onClicked: optionsMenu.open() } } } ================================================ FILE: qt/qml/pages/PageIndicatorPage.qml ================================================ /**************************************************************************** ** ** Copyright (C) 2015 The Qt Company Ltd. ** Contact: http://www.qt.io/licensing/ ** ** This file is part of the examples of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are ** met: ** * Redistributions of source code must retain the above copyright ** notice, this list of conditions and the following disclaimer. ** * Redistributions in binary form must reproduce the above copyright ** notice, this list of conditions and the following disclaimer in ** the documentation and/or other materials provided with the ** distribution. ** * Neither the name of The Qt Company Ltd nor the names of its ** contributors may be used to endorse or promote products derived ** from this software without specific prior written permission. ** ** ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." ** ** $QT_END_LICENSE$ ** ****************************************************************************/ import QtQuick 2.6 import QtQuick.Controls 2.0 ScrollablePage { id: page Column { spacing: 40 width: parent.width Label { width: parent.width wrapMode: Label.Wrap horizontalAlignment: Qt.AlignHCenter text: "PageIndicator is used to indicate the currently active page in a container of pages." } PageIndicator { count: 5 currentIndex: 2 anchors.horizontalCenter: parent.horizontalCenter } } } ================================================ FILE: qt/qml/pages/PopupPage.qml ================================================ /**************************************************************************** ** ** Copyright (C) 2015 The Qt Company Ltd. ** Contact: http://www.qt.io/licensing/ ** ** This file is part of the examples of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are ** met: ** * Redistributions of source code must retain the above copyright ** notice, this list of conditions and the following disclaimer. ** * Redistributions in binary form must reproduce the above copyright ** notice, this list of conditions and the following disclaimer in ** the documentation and/or other materials provided with the ** distribution. ** * Neither the name of The Qt Company Ltd nor the names of its ** contributors may be used to endorse or promote products derived ** from this software without specific prior written permission. ** ** ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." ** ** $QT_END_LICENSE$ ** ****************************************************************************/ import QtQuick 2.6 import QtQuick.Controls 2.0 ScrollablePage { id: page Column { spacing: 40 width: parent.width Label { width: parent.width wrapMode: Label.Wrap horizontalAlignment: Qt.AlignHCenter text: "Popup is used to display modal or modeless content that overlays other " + "application content. In this example, the settings are shown in a popup." } Button { id: button text: "Open" anchors.horizontalCenter: parent.horizontalCenter width: Math.max(implicitWidth, Math.min(implicitWidth * 2, page.availableWidth / 3)) onClicked: settingsPopup.open() } } } ================================================ FILE: qt/qml/pages/ProgressBarPage.qml ================================================ /**************************************************************************** ** ** Copyright (C) 2015 The Qt Company Ltd. ** Contact: http://www.qt.io/licensing/ ** ** This file is part of the examples of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are ** met: ** * Redistributions of source code must retain the above copyright ** notice, this list of conditions and the following disclaimer. ** * Redistributions in binary form must reproduce the above copyright ** notice, this list of conditions and the following disclaimer in ** the documentation and/or other materials provided with the ** distribution. ** * Neither the name of The Qt Company Ltd nor the names of its ** contributors may be used to endorse or promote products derived ** from this software without specific prior written permission. ** ** ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." ** ** $QT_END_LICENSE$ ** ****************************************************************************/ import QtQuick 2.6 import QtQuick.Controls 2.0 ScrollablePage { id: page readonly property int itemWidth: Math.max(bar.implicitWidth, page.availableWidth / 3) Column { spacing: 40 width: parent.width Label { width: parent.width wrapMode: Label.Wrap horizontalAlignment: Qt.AlignHCenter text: "ProgressBar indicates the progress of an operation. It can be set in an " + "indeterminate mode to indicate that the length of the operation is unknown." } ProgressBar { id: bar value: 0.5 width: itemWidth anchors.horizontalCenter: parent.horizontalCenter } ProgressBar { indeterminate: true width: itemWidth anchors.horizontalCenter: parent.horizontalCenter } } } ================================================ FILE: qt/qml/pages/RadioButtonPage.qml ================================================ /**************************************************************************** ** ** Copyright (C) 2015 The Qt Company Ltd. ** Contact: http://www.qt.io/licensing/ ** ** This file is part of the examples of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are ** met: ** * Redistributions of source code must retain the above copyright ** notice, this list of conditions and the following disclaimer. ** * Redistributions in binary form must reproduce the above copyright ** notice, this list of conditions and the following disclaimer in ** the documentation and/or other materials provided with the ** distribution. ** * Neither the name of The Qt Company Ltd nor the names of its ** contributors may be used to endorse or promote products derived ** from this software without specific prior written permission. ** ** ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." ** ** $QT_END_LICENSE$ ** ****************************************************************************/ import QtQuick 2.6 import QtQuick.Controls 2.0 ScrollablePage { id: page Column { spacing: 40 width: parent.width Label { width: parent.width wrapMode: Label.Wrap horizontalAlignment: Qt.AlignHCenter text: "RadioButton presents an option button that can be toggled on or off. " + "Radio buttons are typically used to select one option from a set of options." } Column { spacing: 20 anchors.horizontalCenter: parent.horizontalCenter RadioButton { text: "First" } RadioButton { text: "Second" checked: true } RadioButton { text: "Third" enabled: false } } } } ================================================ FILE: qt/qml/pages/RangeSliderPage.qml ================================================ /**************************************************************************** ** ** Copyright (C) 2015 The Qt Company Ltd. ** Contact: http://www.qt.io/licensing/ ** ** This file is part of the examples of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are ** met: ** * Redistributions of source code must retain the above copyright ** notice, this list of conditions and the following disclaimer. ** * Redistributions in binary form must reproduce the above copyright ** notice, this list of conditions and the following disclaimer in ** the documentation and/or other materials provided with the ** distribution. ** * Neither the name of The Qt Company Ltd nor the names of its ** contributors may be used to endorse or promote products derived ** from this software without specific prior written permission. ** ** ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." ** ** $QT_END_LICENSE$ ** ****************************************************************************/ import QtQuick 2.6 import QtQuick.Controls 2.0 ScrollablePage { id: page readonly property int itemWidth: Math.max(slider.implicitWidth, Math.min(slider.implicitWidth * 2, page.availableWidth / 3)) Column { spacing: 40 width: parent.width Label { width: parent.width wrapMode: Label.Wrap horizontalAlignment: Qt.AlignHCenter text: "RangeSlider is used to select a range specified by two values, by sliding each handle along a track." } RangeSlider { id: slider first.value: 0.25 second.value: 0.75 width: itemWidth anchors.horizontalCenter: parent.horizontalCenter } RangeSlider { orientation: Qt.Vertical first.value: 0.25 second.value: 0.75 height: itemWidth anchors.horizontalCenter: parent.horizontalCenter } } } ================================================ FILE: qt/qml/pages/ScrollBarPage.qml ================================================ /**************************************************************************** ** ** Copyright (C) 2015 The Qt Company Ltd. ** Contact: http://www.qt.io/licensing/ ** ** This file is part of the examples of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are ** met: ** * Redistributions of source code must retain the above copyright ** notice, this list of conditions and the following disclaimer. ** * Redistributions in binary form must reproduce the above copyright ** notice, this list of conditions and the following disclaimer in ** the documentation and/or other materials provided with the ** distribution. ** * Neither the name of The Qt Company Ltd nor the names of its ** contributors may be used to endorse or promote products derived ** from this software without specific prior written permission. ** ** ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." ** ** $QT_END_LICENSE$ ** ****************************************************************************/ import QtQuick 2.6 import QtQuick.Controls 2.0 Flickable { id: flickable contentHeight: pane.height Pane { id: pane width: flickable.width height: flickable.height * 1.25 Column { id: column spacing: 40 width: parent.width Label { width: parent.width wrapMode: Label.Wrap horizontalAlignment: Qt.AlignHCenter text: "ScrollBar is an interactive bar that can be used to scroll to a specific position. " + "A scroll bar can be either vertical or horizontal, and can be attached to any Flickable, " + "such as ListView and GridView." } Image { rotation: 90 source: "qrc:/images/arrows.png" anchors.horizontalCenter: parent.horizontalCenter } } } ScrollBar.vertical: ScrollBar { } } ================================================ FILE: qt/qml/pages/ScrollIndicatorPage.qml ================================================ /**************************************************************************** ** ** Copyright (C) 2015 The Qt Company Ltd. ** Contact: http://www.qt.io/licensing/ ** ** This file is part of the examples of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are ** met: ** * Redistributions of source code must retain the above copyright ** notice, this list of conditions and the following disclaimer. ** * Redistributions in binary form must reproduce the above copyright ** notice, this list of conditions and the following disclaimer in ** the documentation and/or other materials provided with the ** distribution. ** * Neither the name of The Qt Company Ltd nor the names of its ** contributors may be used to endorse or promote products derived ** from this software without specific prior written permission. ** ** ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." ** ** $QT_END_LICENSE$ ** ****************************************************************************/ import QtQuick 2.6 import QtQuick.Controls 2.0 Flickable { id: flickable contentHeight: pane.height Pane { id: pane width: flickable.width height: flickable.height * 1.25 Column { id: column spacing: 40 width: parent.width Label { width: parent.width wrapMode: Label.Wrap horizontalAlignment: Qt.AlignHCenter text: "ScrollIndicator is a non-interactive indicator that indicates the current scroll position. " + "A scroll indicator can be either vertical or horizontal, and can be attached to any Flickable, " + "such as ListView and GridView." } Image { rotation: 90 source: "qrc:/images/arrows.png" anchors.horizontalCenter: parent.horizontalCenter } } } ScrollIndicator.vertical: ScrollIndicator { } } ================================================ FILE: qt/qml/pages/ScrollablePage.qml ================================================ /**************************************************************************** ** ** Copyright (C) 2016 The Qt Company Ltd. ** Contact: http://www.qt.io/licensing/ ** ** This file is part of the examples of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are ** met: ** * Redistributions of source code must retain the above copyright ** notice, this list of conditions and the following disclaimer. ** * Redistributions in binary form must reproduce the above copyright ** notice, this list of conditions and the following disclaimer in ** the documentation and/or other materials provided with the ** distribution. ** * Neither the name of The Qt Company Ltd nor the names of its ** contributors may be used to endorse or promote products derived ** from this software without specific prior written permission. ** ** ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." ** ** $QT_END_LICENSE$ ** ****************************************************************************/ import QtQuick 2.6 import QtQuick.Controls 2.0 Page { id: page default property alias content: pane.contentItem Flickable { anchors.fill: parent contentHeight: pane.implicitHeight flickableDirection: Flickable.AutoFlickIfNeeded Pane { id: pane width: parent.width } ScrollIndicator.vertical: ScrollIndicator { } } } ================================================ FILE: qt/qml/pages/SliderPage.qml ================================================ /**************************************************************************** ** ** Copyright (C) 2015 The Qt Company Ltd. ** Contact: http://www.qt.io/licensing/ ** ** This file is part of the examples of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are ** met: ** * Redistributions of source code must retain the above copyright ** notice, this list of conditions and the following disclaimer. ** * Redistributions in binary form must reproduce the above copyright ** notice, this list of conditions and the following disclaimer in ** the documentation and/or other materials provided with the ** distribution. ** * Neither the name of The Qt Company Ltd nor the names of its ** contributors may be used to endorse or promote products derived ** from this software without specific prior written permission. ** ** ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." ** ** $QT_END_LICENSE$ ** ****************************************************************************/ import QtQuick 2.6 import QtQuick.Controls 2.0 ScrollablePage { id: page readonly property int itemWidth: Math.max(slider.implicitWidth, Math.min(slider.implicitWidth * 2, page.availableWidth / 3)) Column { spacing: 40 width: parent.width Label { width: parent.width wrapMode: Label.Wrap horizontalAlignment: Qt.AlignHCenter text: "Slider is used to select a value by sliding a handle along a track." } Slider { id: slider value: 0.5 width: itemWidth anchors.horizontalCenter: parent.horizontalCenter } Slider { orientation: Qt.Vertical value: 0.5 height: itemWidth anchors.horizontalCenter: parent.horizontalCenter } } } ================================================ FILE: qt/qml/pages/SpinBoxPage.qml ================================================ /**************************************************************************** ** ** Copyright (C) 2015 The Qt Company Ltd. ** Contact: http://www.qt.io/licensing/ ** ** This file is part of the examples of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are ** met: ** * Redistributions of source code must retain the above copyright ** notice, this list of conditions and the following disclaimer. ** * Redistributions in binary form must reproduce the above copyright ** notice, this list of conditions and the following disclaimer in ** the documentation and/or other materials provided with the ** distribution. ** * Neither the name of The Qt Company Ltd nor the names of its ** contributors may be used to endorse or promote products derived ** from this software without specific prior written permission. ** ** ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." ** ** $QT_END_LICENSE$ ** ****************************************************************************/ import QtQuick 2.6 import QtQuick.Controls 2.0 ScrollablePage { id: page readonly property int itemWidth: Math.max(box.implicitWidth, Math.min(box.implicitWidth * 2, pane.availableWidth / 3)) Column { spacing: 40 width: parent.width Label { width: parent.width wrapMode: Label.Wrap horizontalAlignment: Qt.AlignHCenter text: "SpinBox allows the user to choose an integer value by clicking the up or down indicator buttons, " + "by pressing up or down on the keyboard, or by entering a text value in the input field." } SpinBox { id: box value: 50 width: itemWidth anchors.horizontalCenter: parent.horizontalCenter editable: true } } } ================================================ FILE: qt/qml/pages/StackViewPage.qml ================================================ /**************************************************************************** ** ** Copyright (C) 2015 The Qt Company Ltd. ** Contact: http://www.qt.io/licensing/ ** ** This file is part of the examples of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are ** met: ** * Redistributions of source code must retain the above copyright ** notice, this list of conditions and the following disclaimer. ** * Redistributions in binary form must reproduce the above copyright ** notice, this list of conditions and the following disclaimer in ** the documentation and/or other materials provided with the ** distribution. ** * Neither the name of The Qt Company Ltd nor the names of its ** contributors may be used to endorse or promote products derived ** from this software without specific prior written permission. ** ** ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." ** ** $QT_END_LICENSE$ ** ****************************************************************************/ import QtQuick 2.6 import QtQuick.Controls 2.0 StackView { id: stackView initialItem: page Component { id: page Pane { id: pane width: parent ? parent.width : 0 // TODO: fix null parent on destruction Column { spacing: 40 width: parent.width Label { width: parent.width wrapMode: Label.Wrap horizontalAlignment: Qt.AlignHCenter text: "StackView provides a stack-based navigation model which can be used with a set of interlinked pages. " + "Items are pushed onto the stack as the user navigates deeper into the material, and popped off again " + "when he chooses to go back." } Button { id: button text: "Push" anchors.horizontalCenter: parent.horizontalCenter width: Math.max(button.implicitWidth, Math.min(button.implicitWidth * 2, pane.availableWidth / 3)) onClicked: stackView.push(page) } Button { text: "Pop" enabled: stackView.depth > 1 width: Math.max(button.implicitWidth, Math.min(button.implicitWidth * 2, pane.availableWidth / 3)) anchors.horizontalCenter: parent.horizontalCenter onClicked: stackView.pop() } } } } } ================================================ FILE: qt/qml/pages/SwipeViewPage.qml ================================================ /**************************************************************************** ** ** Copyright (C) 2015 The Qt Company Ltd. ** Contact: http://www.qt.io/licensing/ ** ** This file is part of the examples of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are ** met: ** * Redistributions of source code must retain the above copyright ** notice, this list of conditions and the following disclaimer. ** * Redistributions in binary form must reproduce the above copyright ** notice, this list of conditions and the following disclaimer in ** the documentation and/or other materials provided with the ** distribution. ** * Neither the name of The Qt Company Ltd nor the names of its ** contributors may be used to endorse or promote products derived ** from this software without specific prior written permission. ** ** ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." ** ** $QT_END_LICENSE$ ** ****************************************************************************/ import QtQuick 2.6 import QtQuick.Controls 2.0 Pane { id: pane SwipeView { id: view currentIndex: 1 anchors.fill: parent Repeater { model: 3 Pane { width: view.width height: view.height Column { spacing: 40 width: parent.width Label { width: parent.width wrapMode: Label.Wrap horizontalAlignment: Qt.AlignHCenter text: "SwipeView provides a navigation model that simplifies horizontal paged scrolling. " + "The page indicator on the bottom shows which is the presently active page." } Image { source: "qrc:/images/arrows.png" anchors.horizontalCenter: parent.horizontalCenter } } } } } PageIndicator { count: view.count currentIndex: view.currentIndex anchors.bottom: parent.bottom anchors.horizontalCenter: parent.horizontalCenter } } ================================================ FILE: qt/qml/pages/SwitchPage.qml ================================================ /**************************************************************************** ** ** Copyright (C) 2015 The Qt Company Ltd. ** Contact: http://www.qt.io/licensing/ ** ** This file is part of the examples of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are ** met: ** * Redistributions of source code must retain the above copyright ** notice, this list of conditions and the following disclaimer. ** * Redistributions in binary form must reproduce the above copyright ** notice, this list of conditions and the following disclaimer in ** the documentation and/or other materials provided with the ** distribution. ** * Neither the name of The Qt Company Ltd nor the names of its ** contributors may be used to endorse or promote products derived ** from this software without specific prior written permission. ** ** ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." ** ** $QT_END_LICENSE$ ** ****************************************************************************/ import QtQuick 2.6 import QtQuick.Controls 2.0 ScrollablePage { id: page Column { spacing: 40 width: parent.width Label { width: parent.width wrapMode: Label.Wrap horizontalAlignment: Qt.AlignHCenter text: "Switch is an option button that can be dragged or toggled on or off. " + "Switches are typically used to select between two states." } Column { spacing: 20 anchors.horizontalCenter: parent.horizontalCenter Switch { text: "First" } Switch { text: "Second" checked: true } Switch { text: "Third" enabled: false } } } } ================================================ FILE: qt/qml/pages/TabBarPage.qml ================================================ /**************************************************************************** ** ** Copyright (C) 2015 The Qt Company Ltd. ** Contact: http://www.qt.io/licensing/ ** ** This file is part of the examples of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are ** met: ** * Redistributions of source code must retain the above copyright ** notice, this list of conditions and the following disclaimer. ** * Redistributions in binary form must reproduce the above copyright ** notice, this list of conditions and the following disclaimer in ** the documentation and/or other materials provided with the ** distribution. ** * Neither the name of The Qt Company Ltd nor the names of its ** contributors may be used to endorse or promote products derived ** from this software without specific prior written permission. ** ** ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." ** ** $QT_END_LICENSE$ ** ****************************************************************************/ import QtQuick 2.6 import QtQuick.Controls 2.0 Page { id: page SwipeView { id: swipeView anchors.fill: parent currentIndex: tabBar.currentIndex Repeater { model: 3 Pane { width: swipeView.width height: swipeView.height Column { spacing: 40 width: parent.width Label { width: parent.width wrapMode: Label.Wrap horizontalAlignment: Qt.AlignHCenter text: "TabBar is a bar with icons or text which allows the user" + "to switch between different subtasks, views, or modes." } Image { source: "qrc:/images/arrows.png" anchors.horizontalCenter: parent.horizontalCenter } } } } } footer: TabBar { id: tabBar currentIndex: swipeView.currentIndex TabButton { text: "First" } TabButton { text: "Second" } TabButton { text: "Third" } } } ================================================ FILE: qt/qml/pages/TextAreaPage.qml ================================================ /**************************************************************************** ** ** Copyright (C) 2015 The Qt Company Ltd. ** Contact: http://www.qt.io/licensing/ ** ** This file is part of the examples of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are ** met: ** * Redistributions of source code must retain the above copyright ** notice, this list of conditions and the following disclaimer. ** * Redistributions in binary form must reproduce the above copyright ** notice, this list of conditions and the following disclaimer in ** the documentation and/or other materials provided with the ** distribution. ** * Neither the name of The Qt Company Ltd nor the names of its ** contributors may be used to endorse or promote products derived ** from this software without specific prior written permission. ** ** ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." ** ** $QT_END_LICENSE$ ** ****************************************************************************/ import QtQuick 2.6 import QtQuick.Controls 2.0 ScrollablePage { id: page Column { spacing: 40 width: parent.width Label { width: parent.width wrapMode: Label.Wrap horizontalAlignment: Qt.AlignHCenter text: "TextArea is a multi-line text editor." } TextArea { width: Math.max(implicitWidth, Math.min(implicitWidth * 3, pane.availableWidth / 3)) anchors.horizontalCenter: parent.horizontalCenter wrapMode: TextArea.Wrap text: "TextArea\n...\n...\n..." } } } ================================================ FILE: qt/qml/pages/TextFieldPage.qml ================================================ /**************************************************************************** ** ** Copyright (C) 2015 The Qt Company Ltd. ** Contact: http://www.qt.io/licensing/ ** ** This file is part of the examples of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are ** met: ** * Redistributions of source code must retain the above copyright ** notice, this list of conditions and the following disclaimer. ** * Redistributions in binary form must reproduce the above copyright ** notice, this list of conditions and the following disclaimer in ** the documentation and/or other materials provided with the ** distribution. ** * Neither the name of The Qt Company Ltd nor the names of its ** contributors may be used to endorse or promote products derived ** from this software without specific prior written permission. ** ** ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." ** ** $QT_END_LICENSE$ ** ****************************************************************************/ import QtQuick 2.6 import QtQuick.Controls 2.0 ScrollablePage { id: page Column { spacing: 40 width: parent.width Label { width: parent.width wrapMode: Label.Wrap horizontalAlignment: Qt.AlignHCenter text: "TextField is a single-line text editor." } TextField { id: field placeholderText: "TextField" width: Math.max(implicitWidth, Math.min(implicitWidth * 2, pane.availableWidth / 3)) anchors.horizontalCenter: parent.horizontalCenter } } } ================================================ FILE: qt/qml/pages/ToolTipPage.qml ================================================ /**************************************************************************** ** ** Copyright (C) 2016 The Qt Company Ltd. ** Contact: http://www.qt.io/licensing/ ** ** This file is part of the examples of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are ** met: ** * Redistributions of source code must retain the above copyright ** notice, this list of conditions and the following disclaimer. ** * Redistributions in binary form must reproduce the above copyright ** notice, this list of conditions and the following disclaimer in ** the documentation and/or other materials provided with the ** distribution. ** * Neither the name of The Qt Company Ltd nor the names of its ** contributors may be used to endorse or promote products derived ** from this software without specific prior written permission. ** ** ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." ** ** $QT_END_LICENSE$ ** ****************************************************************************/ import QtQuick 2.6 import QtQuick.Controls 2.0 ScrollablePage { id: page Column { spacing: 40 width: parent.width Label { width: parent.width wrapMode: Label.Wrap horizontalAlignment: Qt.AlignHCenter text: "A tool tip is a short piece of text that informs the user of a control's function." } Button { text: "Tip" anchors.horizontalCenter: parent.horizontalCenter width: Math.max(implicitWidth, Math.min(implicitWidth * 2, pane.availableWidth / 3)) ToolTip.timeout: 5000 ToolTip.visible: pressed ToolTip.text: "This is a tool tip." } } } ================================================ FILE: qt/qml/pages/TumblerPage.qml ================================================ /**************************************************************************** ** ** Copyright (C) 2015 The Qt Company Ltd. ** Contact: http://www.qt.io/licensing/ ** ** This file is part of the examples of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are ** met: ** * Redistributions of source code must retain the above copyright ** notice, this list of conditions and the following disclaimer. ** * Redistributions in binary form must reproduce the above copyright ** notice, this list of conditions and the following disclaimer in ** the documentation and/or other materials provided with the ** distribution. ** * Neither the name of The Qt Company Ltd nor the names of its ** contributors may be used to endorse or promote products derived ** from this software without specific prior written permission. ** ** ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." ** ** $QT_END_LICENSE$ ** ****************************************************************************/ import QtQuick 2.6 import QtQuick.Controls 2.0 ScrollablePage { id: page Column { spacing: 40 width: parent.width Label { width: parent.width wrapMode: Label.Wrap horizontalAlignment: Qt.AlignHCenter text: "Tumbler is used to select a value by spinning a wheel." } Tumbler { model: 10 visibleItemCount: 5 anchors.horizontalCenter: parent.horizontalCenter } } } ================================================ FILE: qt/qml/pages/_asynchronousPage.qml ================================================ import QtQuick 2.6 import QtQuick.Controls 2.0 import "../elements" ScrollablePage { id: page Column { spacing: 40 width: parent.width Label { width: parent.width wrapMode: Label.Wrap horizontalAlignment: Qt.AlignHCenter text: "This page demos using a progress bar (found on the layout page) to update the UI of the progres of a backend process (for instance downloading a file)" } Button { id: button text: "Start Process" anchors.horizontalCenter: parent.horizontalCenter width: Math.max(implicitWidth, Math.min(implicitWidth * 2, page.availableWidth / 3)) onClicked: function() { globalToast.open() globalToast.start("beginning process") QmlBridge.startAsynchronousProcess() } } } } ================================================ FILE: qt/qml/pages/_calculatorPage.qml ================================================ import QtQuick 2.6 import QtQuick.Layouts 1.1 import QtQuick.Controls 2.0 import QtQuick.Controls.Material 2.0 Pane { padding: 0 Column { spacing: 40 width: parent.width Label { width: parent.width wrapMode: Label.Wrap horizontalAlignment: Qt.AlignHCenter text: "This page demonstrates a simple calculator, using Go to add two values together. The answer is returned to the UI" } Row { id: row anchors.left: parent.left anchors.right: parent.right TextField { id: prefix placeholderText: "10" horizontalAlignment: Qt.AlignHCenter width: (row.width/2) - 10 } Label { wrapMode: Label.Wrap horizontalAlignment: Qt.AlignHCenter text: " + " } TextField { id: suffix placeholderText: "5" horizontalAlignment: Qt.AlignHCenter width: (row.width/2) - 10 } } Button { width: parent.width text: "Get Result!" onClicked: function() { console.log('updating answer') answer.text = QmlBridge.calculator(Number(suffix.text), Number(prefix.text)) } } Label { id: answer width: parent.width wrapMode: Label.Wrap horizontalAlignment: Qt.AlignHCenter text: "" } } } ================================================ FILE: qt/qml/pages/_clockPage.qml ================================================ import QtQuick 2.6 import QtQuick.Layouts 1.1 import QtQuick.Controls 2.0 import QtQuick.Controls.Material 2.0 Pane { padding: 0 id: page Column { spacing: 40 width: parent.width Label { width: parent.width wrapMode: Label.Wrap horizontalAlignment: Qt.AlignHCenter text: "Demonstrates receving information from Go backend" } GroupBox { title: "Clock" anchors.horizontalCenter: parent.horizontalCenter Column { spacing: 20 width: page.itemWidth Text { id: clock color: "black" font.pointSize: 16 opacity: 0.75 Connections { target: QmlBridge onSendTime: { clock.text = data } } } } } } } ================================================ FILE: qt/qml/pages/_contactsPage.qml ================================================ import QtQuick 2.6 import QtQuick.Layouts 1.1 import QtQuick.Controls 2.0 import QtQuick.Controls.Material 2.0 import QtQuick.Dialogs 1.0 import "../elements" Pane { id: pane padding: 0 property var delegateComponentMap: { "ItemDelegate": itemDelegateComponent } Component { id: itemDelegateComponent ItemDelegate { text: labelText width: parent.width Material.foreground: Material.BlueGrey ToolTip.timeout: 5000 ToolTip.visible: hovered ToolTip.text: "Click to choose a file, or drag a file here, to send" MouseArea { anchors.fill: parent cursorShape: Qt.PointingHandCursor acceptedButtons: Qt.LeftButton | Qt.RightButton onClicked: { console.log("Click") if (mouse.button == Qt.LeftButton) { console.log("Left") fPicker.visible = true } else if (mouse.button == Qt.RightButton) { fileDialog.open() footerLabel.text = "Clicked on " + labelText } } } Popup { id: fPicker visible: false modal: true focus: true width: window.height / 3 * 2 x: (window.width - width) / 2 y: -200 contentHeight: 400 FilePicker { anchors.fill: parent showDotAndDotDot: true onFileSelected: { } } } DropArea { id: drg anchors.fill: parent onDropped: { //ctrl.processFileForSharing(ctrl.pendingFile) //badgeArea.color = "transparent" //badge.color = Colors.color.steelblue //badge.text = ctrl.person(index).len } onEntered: { console.log("hello world") //badge.color = "white" //badge.text = FontAwesome.icons.fa_upload //badgeArea.color = Colors.color.balanced //ctrl.pendingFile = drag.urls.toString() //ctrl.pendingContact = txt.text } onExited: { //badgeArea.color = "transparent" //badge.color = Colors.color.steelblue //badge.text = ctrl.person(index).len } } } } ColumnLayout { spacing: 10 anchors.fill: parent anchors.topMargin: 20 Label { Layout.fillWidth: true wrapMode: Label.Wrap padding: 20 topPadding: 0 horizontalAlignment: Qt.AlignHLeft text: "These are your contacts.
" } ListView { id: listView Layout.fillWidth: true Layout.fillHeight: true clip: true model: ContactsModel delegate: Loader { id: delegateLoader width: listView.width sourceComponent: delegateComponentMap["ItemDelegate"] property string labelText: email property ListView view: listView property int ourIndex: index // Can't find a way to do this in the SwipeDelegate component itself, // so do it here instead. ListView.onRemove: SequentialAnimation { PropertyAction { target: delegateLoader property: "ListView.delayRemove" value: true } NumberAnimation { target: item property: "height" to: 0 easing.type: Easing.InOutQuad } PropertyAction { target: delegateLoader property: "ListView.delayRemove" value: false } } } } } } ================================================ FILE: qt/qml/pages/_downloadsPage.qml ================================================ import QtQuick 2.6 import QtQuick.Layouts 1.1 import QtQuick.Controls 2.0 import QtQuick.Controls.Material 2.0 Pane { padding: 0 property var delegateComponentMap: { "ItemDelegate": itemDelegateComponent } Component { id: itemDelegateComponent ItemDelegate { text: labelText width: parent.width Material.foreground: Material.BlueGrey MouseArea { anchors.fill: parent cursorShape: Qt.PointingHandCursor onClicked: { footerLabel.text = "Clicked on " + labelText } } ToolTip.timeout: 5000 ToolTip.visible: hovered ToolTip.text: "Click to open the file" } } ColumnLayout { spacing: 10 anchors.fill: parent anchors.topMargin: 20 Label { Layout.fillWidth: true wrapMode: Label.Wrap padding: 20 topPadding: 0 horizontalAlignment: Qt.AlignHLeft text: "These are files you have downloaded.
" onLinkActivated: Qt.openUrlExternally(link) MouseArea { anchors.fill: parent acceptedButtons: Qt.NoButton cursorShape: parent.hoveredLink ? Qt.PointingHandCursor : Qt.ArrowCursor } } ListView { id: listView Layout.fillWidth: true Layout.fillHeight: true clip: true spacing: 2 model: ListModel { ListElement { type: "ItemDelegate"; text: "item1.pdf" } ListElement { type: "ItemDelegate"; text: "item2.exe" } ListElement { type: "ItemDelegate"; text: "item3.md" } } section.property: "type" delegate: Loader { id: delegateLoader width: listView.width sourceComponent: delegateComponentMap[type] property string labelText: text property ListView view: listView property int ourIndex: index // Can't find a way to do this in the SwipeDelegate component itself, // so do it here instead. ListView.onRemove: SequentialAnimation { PropertyAction { target: delegateLoader property: "ListView.delayRemove" value: true } NumberAnimation { target: item property: "height" to: 0 easing.type: Easing.InOutQuad } PropertyAction { target: delegateLoader property: "ListView.delayRemove" value: false } } } } } } ================================================ FILE: qt/qml/pages/_filelistPage.qml ================================================ import QtQuick 2.6 import QtQuick.Layouts 1.1 import QtQuick.Controls 2.0 import QtQuick.Controls.Material 2.0 Pane { padding: 0 property var delegateComponentMap: { "ItemDelegate": itemDelegateComponent } Component { id: itemDelegateComponent ItemDelegate { text: labelText width: parent.width Material.foreground: Material.BlueGrey MouseArea { anchors.fill: parent cursorShape: Qt.PointingHandCursor onClicked: { footerLabel.text = "Clicked on " + labelText } } ToolTip.timeout: 5000 ToolTip.visible: hovered ToolTip.text: "Click to download the file" } } ColumnLayout { spacing: 10 anchors.fill: parent anchors.topMargin: 20 Label { Layout.fillWidth: true wrapMode: Label.Wrap padding: 20 topPadding: 0 horizontalAlignment: Qt.AlignHLeft text: "These are file sent to you.
" } ListView { id: listView Layout.fillWidth: true Layout.fillHeight: true clip: true spacing: 2 model: ListModel { ListElement { type: "ItemDelegate"; text: "domination.pdf" } ListElement { type: "ItemDelegate"; text: "megolomania.exe" } ListElement { type: "ItemDelegate"; text: "bankvault.md" } } section.property: "type" delegate: Loader { id: delegateLoader width: listView.width sourceComponent: delegateComponentMap[type] property string labelText: text property ListView view: listView property int ourIndex: index // Can't find a way to do this in the SwipeDelegate component itself, // so do it here instead. ListView.onRemove: SequentialAnimation { PropertyAction { target: delegateLoader property: "ListView.delayRemove" value: true } NumberAnimation { target: item property: "height" to: 0 easing.type: Easing.InOutQuad } PropertyAction { target: delegateLoader property: "ListView.delayRemove" value: false } } } } } } ================================================ FILE: qt/qml/pages/_fruitsPage.qml ================================================ import QtQuick 2.6 import QtQuick.Layouts 1.1 import QtQuick.Controls 2.0 import QtQuick.Controls.Material 2.0 import "../elements" import "../images" Rectangle { id: container width: 500; height: 400 color: "#343434" // The model: ListModel { id: fruitModel ListElement { name: "Apple"; cost: 2.45 attributes: [ ListElement { description: "Core" }, ListElement { description: "Deciduous" } ] } ListElement { name: "Banana"; cost: 1.95 attributes: [ ListElement { description: "Tropical" }, ListElement { description: "Seedless" } ] } ListElement { name: "Cumquat"; cost: 3.25 attributes: [ ListElement { description: "Citrus" } ] } ListElement { name: "Durian"; cost: 9.95 attributes: [ ListElement { description: "Tropical" }, ListElement { description: "Smelly" } ] } } // The delegate for each fruit in the model: Component { id: listDelegate Item { id: delegateItem width: listView.width - 10 height: 55 clip: true Row { anchors.verticalCenter: parent.verticalCenter spacing: 10 Column { Image { source: "../images/FA/white/png/22/arrow-up.png" MouseArea { anchors.fill: parent; onClicked: fruitModel.move(index, index-1, 1) } } Image { source: "../images/FA/white/png/22/arrow-down.png" MouseArea { anchors.fill: parent; onClicked: fruitModel.move(index, index+1, 1) } } } Column { anchors.verticalCenter: parent.verticalCenter Text { text: name font.pixelSize: 15 color: "white" } Row { spacing: 5 Repeater { model: attributes Text { text: description; color: "White" } } } } } Row { anchors.verticalCenter: parent.verticalCenter anchors.right: parent.right spacing: 10 PressAndHoldButton { anchors.verticalCenter: parent.verticalCenter source: "../images/FA/white/png/22/minus.png" onClicked: fruitModel.setProperty(index, "cost", cost + 0.25) } Text { id: costText anchors.verticalCenter: parent.verticalCenter text: '$' + Number(cost).toFixed(2) font.pixelSize: 15 color: "white" font.bold: true } PressAndHoldButton { anchors.verticalCenter: parent.verticalCenter source: "../images/FA/white/png/22/plus.png" onClicked: fruitModel.setProperty(index, "cost", Math.max(0,cost-0.25)) } Image { source: "../images/FA/white/png/22/remove.png" MouseArea { anchors.fill:parent; onClicked: fruitModel.remove(index) } } } // Animate adding and removing of items: ListView.onAdd: SequentialAnimation { PropertyAction { target: delegateItem; property: "height"; value: 0 } NumberAnimation { target: delegateItem; property: "height"; to: 55; duration: 250; easing.type: Easing.InOutQuad } } ListView.onRemove: SequentialAnimation { PropertyAction { target: delegateItem; property: "ListView.delayRemove"; value: true } NumberAnimation { target: delegateItem; property: "height"; to: 0; duration: 250; easing.type: Easing.InOutQuad } // Make sure delayRemove is set back to false so that the item can be destroyed PropertyAction { target: delegateItem; property: "ListView.delayRemove"; value: false } } } } // The view: ListView { id: listView anchors.fill: parent; anchors.margins: 20 model: fruitModel delegate: listDelegate } Row { anchors { left: parent.left; bottom: parent.bottom; margins: 20 } spacing: 10 TextButton { text: "Add an item" onClicked: { fruitModel.append({ "name": "Pizza Margarita", "cost": 5.95, "attributes": [{"description": "Cheese"}, {"description": "Tomato"}] }) } } TextButton { text: "Remove all items" onClicked: fruitModel.clear() } } } ================================================ FILE: qt/qml/pages/_fruitsPage2.qml ================================================ import QtQuick 2.6 import QtQuick.Layouts 1.1 import QtQuick.Controls 2.0 import QtQuick.Controls.Material 2.0 import "../elements" import "../images" Rectangle { id: container width: 500; height: 400 // The model: ListModel { id: fruitModel ListElement { name: "Apple"; cost: 2.45 attributes: [ ListElement { description: "Core" }, ListElement { description: "Deciduous" } ] } ListElement { name: "Banana"; cost: 1.95 attributes: [ ListElement { description: "Tropical" }, ListElement { description: "Seedless" } ] } ListElement { name: "Cumquat"; cost: 3.25 attributes: [ ListElement { description: "Citrus" } ] } ListElement { name: "Durian"; cost: 9.95 attributes: [ ListElement { description: "Tropical" }, ListElement { description: "Smelly" } ] } } // The delegate for each fruit in the model: Component { id: listDelegate Item { id: delegateItem width: listView.width - 10 height: 55 clip: true Row { anchors.verticalCenter: parent.verticalCenter spacing: 10 Column { Image { source: "../images/FA-PNG/black/png/22/arrow-up.png" MouseArea { anchors.fill: parent; onClicked: fruitModel.move(index, index-1, 1) } } Image { source: "../images/FA-PNG/black/png/22/arrow-down.png" MouseArea { anchors.fill: parent; onClicked: fruitModel.move(index, index+1, 1) } } } Column { anchors.verticalCenter: parent.verticalCenter Text { text: name font.pixelSize: 15 color: "#333" } Row { spacing: 5 Repeater { model: attributes Text { text: description; color: "#333" } } } } } Row { anchors.verticalCenter: parent.verticalCenter anchors.right: parent.right spacing: 10 PressAndHoldButton { anchors.verticalCenter: parent.verticalCenter source: "../images/FA-PNG/black/png/22/minus.png" onClicked: fruitModel.setProperty(index, "cost", cost - 0.25) } Text { id: costText anchors.verticalCenter: parent.verticalCenter text: '$' + Number(cost).toFixed(2) font.pixelSize: 15 color: "#333" font.bold: true } PressAndHoldButton { anchors.verticalCenter: parent.verticalCenter source: "../images/FA-PNG/black/png/22/plus.png" onClicked: fruitModel.setProperty(index, "cost", Math.max(0,cost + 0.25)) } Image { source: "../images/FA-PNG/black/png/22/remove.png" MouseArea { anchors.fill:parent; onClicked: fruitModel.remove(index) } } } // Animate adding and removing of items: ListView.onAdd: SequentialAnimation { PropertyAction { target: delegateItem; property: "height"; value: 0 } NumberAnimation { target: delegateItem; property: "height"; to: 55; duration: 250; easing.type: Easing.InOutQuad } } ListView.onRemove: SequentialAnimation { PropertyAction { target: delegateItem; property: "ListView.delayRemove"; value: true } NumberAnimation { target: delegateItem; property: "height"; to: 0; duration: 250; easing.type: Easing.InOutQuad } // Make sure delayRemove is set back to false so that the item can be destroyed PropertyAction { target: delegateItem; property: "ListView.delayRemove"; value: false } } } } // The view: ListView { id: listView anchors.fill: parent; anchors.margins: 20 model: fruitModel delegate: listDelegate } } ================================================ FILE: qt/qml/pages/_loginPage.qml ================================================ import QtQuick 2.6 import QtQuick.Controls 2.0 ScrollablePage { id: page Column { spacing: 40 width: parent.width Label { width: parent.width wrapMode: Label.Wrap horizontalAlignment: Qt.AlignHCenter text: "Login using Google Authentication. Make sure you have created an account first here: website.co.uk" onLinkActivated: Qt.openUrlExternally(link) MouseArea { anchors.fill: parent acceptedButtons: Qt.NoButton cursorShape: parent.hoveredLink ? Qt.PointingHandCursor : Qt.ArrowCursor } } Button { id: button text: "Login" anchors.horizontalCenter: parent.horizontalCenter width: Math.max(implicitWidth, Math.min(implicitWidth * 2, page.availableWidth / 3)) onClicked: function() { globalToast.open() globalToast.start("Attempting to log in") } } } } ================================================ FILE: qt/qml/pages/_searchPage.qml ================================================ import QtQuick 2.6 import QtQuick.Layouts 1.1 import QtQuick.Controls 2.0 import QtQuick.Controls.Material 2.0 Pane { padding: 0 property var delegateComponentMap: { "ItemDelegate": itemDelegateComponent } Component { id: itemDelegateComponent ItemDelegate { text: labelText width: parent.width Material.foreground: Material.BlueGrey MouseArea { anchors.fill: parent cursorShape: Qt.PointingHandCursor onClicked: { footerLabel.text = "Clicked on " + labelText } } ToolTip.timeout: 5000 ToolTip.visible: hovered ToolTip.text: "Click to add contact to your contacts" } } ColumnLayout { spacing: 10 anchors.fill: parent anchors.topMargin: 20 Label { Layout.fillWidth: true wrapMode: Label.Wrap horizontalAlignment: Qt.AlignHCenter padding: 20 topPadding: 0 text: "Search for new contacts here. Click on a search result to add them to your contacts" } TextField { id: searchContactField Layout.fillWidth: true placeholderText: "James Bond" horizontalAlignment: Qt.AlignHCenter Keys.onReturnPressed: { console.log("the user is searching for " + searchContactField.text) footerLabel.text = "searching for " + searchContactField.text searchContactField.text = "" } background: Rectangle { border.color: "grey" radius: 2 } } Button { id: searchButton text: "Search" Layout.fillWidth: true onClicked: function() { footerLabel.text = "searching for " + searchContactField.text searchContactField.text = "" QmlBridge.searchFor(searchContactField.text) } } ListView { id: listView Layout.fillWidth: true Layout.fillHeight: true clip: true spacing: 2 model: SearchModel delegate: Loader { id: delegateLoader width: listView.width sourceComponent: delegateComponentMap["ItemDelegate"] property string labelText: email property ListView view: listView property int ourIndex: index } } } } ================================================ FILE: qt/qml/pages/_toastPage.qml ================================================ import QtQuick 2.6 import QtQuick.Controls 2.0 ScrollablePage { id: page Column { spacing: 40 width: parent.width Label { width: parent.width wrapMode: Label.Wrap horizontalAlignment: Qt.AlignHCenter text: "This page demos a toast element" } Button { id: button text: "Show Toast" anchors.horizontalCenter: parent.horizontalCenter width: Math.max(implicitWidth, Math.min(implicitWidth * 2, page.availableWidth / 3)) onClicked: function() { globalToast.open() globalToast.start("hello from toast") } } } }