Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import QtQuick 2.0
- import QtQuick.XmlListModel 2.0
- import Ubuntu.Components.ListItems 0.1 as ListItem
- import Ubuntu.Components.Popups 0.1 as Popups
- import Ubuntu.Components.Extras.Browser 0.1 as Browser
- import Ubuntu.Components 0.1
- import "components"
- import "qml"
- MainView {
- objectName: "mainView"
- applicationName: "com.ubuntu.developer.enderlance.Chemistry"
- width: units.gu(50)
- height: units.gu(75)
- headerColor: "#464646"
- backgroundColor: "#2A2A2B"
- footerColor: "#2A2A2B"
- Component
- {
- id: popupInfo
- Popups.Dialog
- {
- id: popupInfoDialog
- title: "Credits"
- text: "App by Brendan Wilson\nContact: belancew@gmail.com\nDatabase by Tyler Raber"
- Button
- {
- id: loginButton
- text: "Back"
- color: "green"
- onClicked:
- {
- PopupUtils.close(popupInfoDialog)
- }
- }
- }
- }
- Component {
- id: popupWiki
- /*
- Popups.Popover {
- id: popupWikiPrompt
- anchors.centerIn: parent
- ListItem.Standard {
- text: "Wikipedia"
- onClicked: {
- PopupUtils.close(popupWikiPrompt)
- stack.push(elementWiki)
- elementWiki.visible = true
- wikiView.url = elementLink.text
- print(wikiView.url)
- }
- }
- }*/
- Popups.Dialog {
- id: popupWikiPrompt
- anchors.centerIn: parent
- title: "Wikipedia"
- text: "This will take you the wikipedia page for the element you have selected. \n Do you wish to continue?"
- Button {
- color: "green"
- text: "Continue"
- onClicked: {
- stack.push(elementWiki)
- elementWiki.visible = true
- wikiView.url = elementLink.text
- PopupUtils.close(popupWikiPrompt)
- }
- }
- Button {
- color: "red"
- text: "Go back"
- onClicked: {
- PopupUtils.close(popupWikiPrompt)
- }
- }
- }
- }
- ToolbarItems
- {
- id: toolbar
- ToolbarButton
- {
- id: infoButton
- text: i18n.tr("Info")
- iconSource: Qt.resolvedUrl("icons/info.png")
- onTriggered:
- {
- PopupUtils.open(popupInfo)
- }
- }
- /*
- ToolbarButton {
- id: shareButton
- text: "Share"
- iconSource: Qt.resolvedUrl("icons/share.png")
- onTriggered: {
- PopupUtils.open(popupShare)
- }
- }
- */
- }
- ToolbarItems {
- id: elementToolbar
- ToolbarButton {
- text: i18n.tr("Info")
- iconSource: Qt.resolvedUrl("icons/info.png")
- onTriggered:
- {
- PopupUtils.open(popupInfo)
- }
- }
- ToolbarButton {
- id: wikiButton
- text: "Wikipedia"
- iconSource: Qt.resolvedUrl("icons/share.png")
- onTriggered: {
- PopupUtils.open(popupWiki)
- }
- }
- }
- PageStack {
- id: stack
- Component.onCompleted: stack.push(mainMenu)
- Page {
- id: mainMenu
- tools: toolbar
- title: i18n.tr("Chemistry")
- Column {
- spacing: units.gu(1)
- anchors {
- margins: units.gu(2)
- fill: parent
- }
- Button {
- objectName: "ptebutton"
- width: parent.width
- text: i18n.tr("Periodic Table of the Elements")
- onClicked: {
- stack.push(ptepage)
- ptepage.visible = true
- }
- }
- Button {
- objectName: "tepButton"
- width: parent.width
- text: "Table of Elementary Particles"
- onClicked: {
- stack.push(tableElementaryParticles)
- tableElementaryParticles.visible = true
- }
- }
- Button {
- objectName: "tempbutton"
- width: parent.width
- visible: false
- enabled: false
- text: i18n.tr("Temperature Room")
- onClicked: {
- stack.push(temperatureRoom)
- temperatureRoom.visible = true
- }
- }
- }
- }
- Page {
- id: ptepage
- title: "Elements"
- tools: toolbar
- visible: false
- ListView {
- id: ptelistview
- height: parent.height
- anchors.fill: parent
- model: PTEList {q: "*"}
- delegate: ListItem.SingleValue {
- text: model.element
- progression: true
- //iconSource: "http://envirochem.us/images/periodic/shellmodel/"+symbol+".gif"
- onClicked: {
- print("Clicked "+element)
- stack.push(singleElementInfo)
- elementName.text = element
- elementLink.text = "https://en.m.wikipedia.org/wiki/"+element
- print(elementLink.text)
- singleElementInfo.visible = true
- elementDataNumber.text = number.toString()
- print("Element Number: "+elementDataNumber.text)
- }
- }
- }
- }
- Page {
- id: singleElementInfo
- title: elementName.text
- visible: false
- tools: elementToolbar
- ListView {
- id: singleElementListView
- model: PTEList { id: list; q: ("AtomicNumber="+elementDataNumber.text) }
- anchors.fill: parent
- delegate: ElementInfoBox {
- anchors.top: parent.top
- wikipediav: "en.m.wikipedia.org/wiki/"+element;
- namev: element
- symbolv: symbol
- densityv: density
- weightv: weight
- categoryv: category
- numberv: number
- }
- }
- }
- Page {
- id: elementWiki
- //title: "Wikipedia - "+elementName.text
- visible: false
- Column {
- spacing: units.gu(1)
- anchors.fill: parent
- Browser.UbuntuWebView {
- id: wikiView
- anchors.fill: parent
- height: parent.height
- width: parent.width
- url: elementLink.text
- onLoadingChanged:
- {
- loadProgressBar.visible = loading
- }
- onLoadProgressChanged:
- {
- loadProgressBar.value = loadProgress
- }
- }
- ProgressBar
- {
- anchors.top: parent.top
- id: loadProgressBar
- height: units.gu(1)
- width: parent.width
- minimumValue: 0
- maximumValue: 100
- }
- }
- }
- }
- Page {
- id: tableElementaryParticles
- title: "Elementary Particles"
- visible: false
- ListView {
- model: TEPList {q: "*"}
- delegate: ListItem.Subtitled {
- text: quark
- }
- }
- }
- Page {
- id: temperatureRoom
- title: "Temperature Control"
- visible: false
- Slider {
- id: tempSlider
- anchors.top: parent.top
- maximumValue: 6000
- minimumValue: 0
- value: 293
- live: true
- }
- ListView {
- id: tempListView
- model: PTEList { q: "*" }
- delegate: ListItem.Subtitled {
- text: element
- subText: temperature.text
- }
- Text {
- id: temperature
- text: ""
- visible: false
- }
- }
- }
- Text {
- id: elementName
- text: ""
- visible: false
- }
- Text {
- id: elementLink
- text: ""
- visible: false
- }
- Text {
- id: elementDataNumber
- text: "1"
- visible: false
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement