Advertisement
EnderLance

uScience.qml

Feb 25th, 2014
310
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import QtQuick 2.0
  2. import QtQuick.XmlListModel 2.0
  3. import Ubuntu.Components.ListItems 0.1 as ListItem
  4. import Ubuntu.Components.Popups 0.1 as Popups
  5. import Ubuntu.Components.Extras.Browser 0.1 as Browser
  6. import Ubuntu.Components 0.1
  7. import "components"
  8. import "qml"
  9.  
  10. MainView {
  11.     objectName: "mainView"
  12.  
  13.     applicationName: "com.ubuntu.developer.enderlance.Chemistry"
  14.  
  15.     width: units.gu(50)
  16.     height: units.gu(75)
  17.  
  18.     headerColor: "#464646"
  19.     backgroundColor: "#2A2A2B"
  20.     footerColor: "#2A2A2B"
  21.  
  22.     Component
  23.     {
  24.         id: popupInfo
  25.  
  26.         Popups.Dialog
  27.         {
  28.             id: popupInfoDialog
  29.  
  30.             title: "Credits"
  31.             text: "App by Brendan Wilson\nContact: belancew@gmail.com\nDatabase by Tyler Raber"
  32.  
  33.             Button
  34.             {
  35.                 id: loginButton
  36.  
  37.                 text: "Back"
  38.                 color: "green"
  39.                 onClicked:
  40.                 {
  41.                     PopupUtils.close(popupInfoDialog)
  42.                 }
  43.             }
  44.         }
  45.     }
  46.  
  47.     Component {
  48.         id: popupWiki
  49.  
  50.         /*
  51.         Popups.Popover {
  52.             id: popupWikiPrompt
  53.  
  54.             anchors.centerIn: parent
  55.  
  56.             ListItem.Standard {
  57.                 text: "Wikipedia"
  58.  
  59.                 onClicked: {
  60.                     PopupUtils.close(popupWikiPrompt)
  61.                     stack.push(elementWiki)
  62.                     elementWiki.visible = true
  63.                     wikiView.url = elementLink.text
  64.                     print(wikiView.url)
  65.                 }
  66.             }
  67.         }*/
  68.  
  69.         Popups.Dialog {
  70.             id: popupWikiPrompt
  71.  
  72.             anchors.centerIn: parent
  73.  
  74.             title: "Wikipedia"
  75.             text: "This will take you the wikipedia page for the element you have selected. \n Do you wish to continue?"
  76.  
  77.             Button {
  78.                 color: "green"
  79.                 text: "Continue"
  80.  
  81.                 onClicked: {
  82.                     stack.push(elementWiki)
  83.                     elementWiki.visible = true
  84.                     wikiView.url = elementLink.text
  85.                     PopupUtils.close(popupWikiPrompt)
  86.                 }
  87.             }
  88.  
  89.             Button {
  90.                 color: "red"
  91.                 text: "Go back"
  92.  
  93.                 onClicked: {
  94.                     PopupUtils.close(popupWikiPrompt)
  95.                 }
  96.             }
  97.         }
  98.     }
  99.  
  100.     ToolbarItems
  101.     {
  102.         id: toolbar
  103.         ToolbarButton
  104.         {
  105.             id: infoButton
  106.             text: i18n.tr("Info")
  107.  
  108.             iconSource: Qt.resolvedUrl("icons/info.png")
  109.  
  110.             onTriggered:
  111.             {
  112.                 PopupUtils.open(popupInfo)
  113.             }
  114.         }
  115.  
  116.         /*
  117.         ToolbarButton {
  118.             id: shareButton
  119.             text: "Share"
  120.  
  121.             iconSource: Qt.resolvedUrl("icons/share.png")
  122.  
  123.             onTriggered: {
  124.                 PopupUtils.open(popupShare)
  125.             }
  126.         }
  127.         */
  128.     }
  129.  
  130.     ToolbarItems {
  131.         id: elementToolbar
  132.  
  133.         ToolbarButton {
  134.             text: i18n.tr("Info")
  135.  
  136.             iconSource: Qt.resolvedUrl("icons/info.png")
  137.  
  138.             onTriggered:
  139.             {
  140.                 PopupUtils.open(popupInfo)
  141.             }
  142.         }
  143.  
  144.         ToolbarButton {
  145.             id: wikiButton
  146.             text: "Wikipedia"
  147.  
  148.             iconSource: Qt.resolvedUrl("icons/share.png")
  149.  
  150.             onTriggered: {
  151.                 PopupUtils.open(popupWiki)
  152.             }
  153.         }
  154.     }
  155.  
  156.     PageStack {
  157.         id: stack
  158.  
  159.         Component.onCompleted: stack.push(mainMenu)
  160.  
  161.         Page {
  162.             id: mainMenu
  163.  
  164.             tools: toolbar
  165.  
  166.             title: i18n.tr("Chemistry")
  167.  
  168.             Column {
  169.                 spacing: units.gu(1)
  170.                 anchors {
  171.                     margins: units.gu(2)
  172.                     fill: parent
  173.                 }
  174.  
  175.                 Button {
  176.                     objectName: "ptebutton"
  177.                     width: parent.width
  178.  
  179.                     text: i18n.tr("Periodic Table of the Elements")
  180.  
  181.                     onClicked: {
  182.                         stack.push(ptepage)
  183.                         ptepage.visible = true
  184.                     }
  185.                 }
  186.  
  187.                 Button {
  188.                     objectName: "tepButton"
  189.                     width: parent.width
  190.  
  191.                     text: "Table of Elementary Particles"
  192.  
  193.                     onClicked: {
  194.                         stack.push(tableElementaryParticles)
  195.                         tableElementaryParticles.visible = true
  196.                     }
  197.                 }
  198.  
  199.                 Button {
  200.                     objectName: "tempbutton"
  201.                     width: parent.width
  202.  
  203.                     visible: false
  204.                     enabled: false
  205.  
  206.                     text: i18n.tr("Temperature Room")
  207.  
  208.                     onClicked: {
  209.                         stack.push(temperatureRoom)
  210.                         temperatureRoom.visible = true
  211.                     }
  212.                 }
  213.             }
  214.         }
  215.  
  216.         Page {
  217.             id: ptepage
  218.  
  219.             title: "Elements"
  220.  
  221.             tools: toolbar
  222.  
  223.             visible: false
  224.  
  225.             ListView {
  226.                 id: ptelistview
  227.  
  228.                 height: parent.height
  229.  
  230.                 anchors.fill: parent
  231.  
  232.                 model: PTEList {q: "*"}
  233.  
  234.                 delegate: ListItem.SingleValue {
  235.                     text: model.element
  236.                     progression: true
  237.                     //iconSource: "http://envirochem.us/images/periodic/shellmodel/"+symbol+".gif"
  238.                     onClicked: {
  239.                         print("Clicked "+element)
  240.                         stack.push(singleElementInfo)
  241.                         elementName.text = element
  242.                         elementLink.text = "https://en.m.wikipedia.org/wiki/"+element
  243.                         print(elementLink.text)
  244.                         singleElementInfo.visible = true
  245.                         elementDataNumber.text = number.toString()
  246.                         print("Element Number: "+elementDataNumber.text)
  247.                     }
  248.                 }
  249.             }
  250.         }
  251.  
  252.         Page {
  253.             id: singleElementInfo
  254.  
  255.             title: elementName.text
  256.  
  257.             visible: false
  258.  
  259.             tools: elementToolbar
  260.  
  261.             ListView {
  262.                 id: singleElementListView
  263.  
  264.                 model: PTEList { id: list; q: ("AtomicNumber="+elementDataNumber.text) }
  265.  
  266.                 anchors.fill: parent
  267.  
  268.                 delegate: ElementInfoBox {
  269.                     anchors.top: parent.top
  270.                     wikipediav: "en.m.wikipedia.org/wiki/"+element;
  271.                     namev: element
  272.                     symbolv: symbol
  273.                     densityv: density
  274.                     weightv: weight
  275.                     categoryv: category
  276.                     numberv: number
  277.                 }
  278.             }
  279.         }
  280.  
  281.         Page {
  282.             id: elementWiki
  283.  
  284.             //title: "Wikipedia - "+elementName.text
  285.  
  286.             visible: false
  287.  
  288.             Column {
  289.  
  290.                 spacing: units.gu(1)
  291.  
  292.                 anchors.fill: parent
  293.  
  294.                 Browser.UbuntuWebView {
  295.                     id: wikiView
  296.  
  297.                     anchors.fill: parent
  298.  
  299.                     height: parent.height
  300.                     width: parent.width
  301.  
  302.                     url: elementLink.text
  303.  
  304.                     onLoadingChanged:
  305.                     {
  306.                         loadProgressBar.visible = loading
  307.                     }
  308.  
  309.                     onLoadProgressChanged:
  310.                     {
  311.                         loadProgressBar.value = loadProgress
  312.                     }
  313.                 }
  314.  
  315.                 ProgressBar
  316.                 {
  317.                     anchors.top: parent.top
  318.                     id: loadProgressBar
  319.                     height: units.gu(1)
  320.                     width: parent.width
  321.                     minimumValue: 0
  322.                     maximumValue: 100
  323.                 }
  324.             }
  325.  
  326.         }
  327.     }
  328.  
  329.     Page {
  330.         id: tableElementaryParticles
  331.  
  332.         title: "Elementary Particles"
  333.  
  334.         visible: false
  335.  
  336.         ListView {
  337.  
  338.             model: TEPList {q: "*"}
  339.  
  340.             delegate: ListItem.Subtitled {
  341.                 text: quark
  342.             }
  343.         }
  344.     }
  345.  
  346.     Page {
  347.         id: temperatureRoom
  348.  
  349.         title: "Temperature Control"
  350.  
  351.         visible: false
  352.  
  353.         Slider {
  354.             id: tempSlider
  355.             anchors.top: parent.top
  356.             maximumValue: 6000
  357.             minimumValue: 0
  358.             value: 293
  359.             live: true
  360.  
  361.         }
  362.  
  363.         ListView {
  364.  
  365.             id: tempListView
  366.  
  367.             model: PTEList { q: "*" }
  368.  
  369.             delegate: ListItem.Subtitled {
  370.                 text: element
  371.                 subText: temperature.text
  372.  
  373.  
  374.             }
  375.  
  376.  
  377.             Text {
  378.                 id: temperature
  379.                 text: ""
  380.                 visible: false
  381.             }
  382.         }
  383.  
  384.     }
  385.  
  386.     Text {
  387.         id: elementName
  388.         text: ""
  389.         visible: false
  390.     }
  391.  
  392.     Text {
  393.         id: elementLink
  394.         text: ""
  395.         visible: false
  396.     }
  397.  
  398.     Text {
  399.         id: elementDataNumber
  400.         text: "1"
  401.         visible: false
  402.     }
  403. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement