Advertisement
Guest User

Untitled

a guest
Feb 12th, 2014
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.62 KB | None | 0 0
  1. import QtQuick 2.0
  2. import Ubuntu.Components 0.1
  3. import Ubuntu.Components.Popups 0.1
  4. import Communi 3.1
  5.  
  6. Page{
  7. id: page
  8. property IrcBuffer serverBuffer
  9. property alias bufferModel: bufferListView.bufferModel
  10. property alias currentBuffer: bufferListView.currentBuffer
  11. property IrcChannel currentChannel: currentBuffer ? currentBuffer.toChannel() : null
  12. title: currentBuffer.name
  13. tools: chatToolbars
  14.  
  15. TopicLabel {
  16. id: topicLabel
  17. width: parent.width
  18. visible: currentChannel
  19. channel: currentChannel
  20. anchors.top: parent.top
  21. }
  22. //thetext that is recived
  23. Item{
  24. width: parent.width
  25. anchors.top: topicLabel.bottom
  26. anchors.bottom: textEntry.top
  27. Repeater {
  28. anchors.fill: parent
  29. model: bufferModel
  30. delegate: TextBrowser {
  31. anchors.fill: parent
  32. buffer: model.buffer
  33. visible: buffer == currentBuffer
  34. }
  35. }
  36. }
  37. TextEntry {
  38. id: textEntry
  39. width: parent.width
  40. height: parent.height / 12
  41. buffer: currentBuffer
  42. enabled: currentBuffer
  43. anchors.bottom: parent.bottom
  44. onMessageSent: currentBuffer.receiveMessage(message)
  45. Connections {
  46. target: page
  47. onCurrentBufferChanged: {
  48. if (page.visible && currentBuffer)
  49. textEntry.forceActiveFocus()
  50. }
  51. }
  52. }
  53.  
  54. Connections {
  55. target: bufferModel
  56. onAdded: currentBuffer = buffer
  57. onAboutToBeRemoved: {
  58. var idx = bufferModel.indexOf(buffer)
  59. currentBuffer = bufferModel.get(idx + 1) || bufferModel.get(Math.max(0, idx - 1))
  60. }
  61. }
  62.  
  63. //Different channels that are open/
  64. BufferListView {
  65. id: bufferListView
  66. width: parent.width
  67. height: parent.height - window.header.height
  68. y: Math.round(window.header.hight)
  69. visible: false
  70. onClosed: {
  71. if (buffer === serverBuffer) {
  72. bufferModel.quit()
  73. } else {
  74. if (buffer.channel)
  75. buffer.part(qsTr("Ubuntu Touch Port of Communi %1 ").arg(irc.version()))
  76. bufferModel.remove(buffer)
  77. }
  78. }
  79. }
  80. //Component{
  81. //Query and look up users to PM
  82. UserListView {
  83. id: userPage
  84. width: page.width
  85. height: parent.height - window.header.height
  86. y: units.gu(12)
  87. visible: false
  88. channel: currentChannel
  89. onQueried: currentBuffer = currentBuffer.model.add(user.name)
  90. }
  91.  
  92. ToolbarItems{
  93. id:chatToolbars
  94. ToolbarButton{
  95. text: qsTr("Users")
  96. iconSource: "/usr/share/icons/ubuntu-mobile/actions/scalable/contact.svg"
  97. onTriggered: pageStack.push(userPage)
  98. }
  99. ToolbarButton{
  100. text: "Channels"
  101. iconSource: "/usr/share/icons/ubuntu-mobile/actions/scalable/messages.svg"
  102. onTriggered: pageStack.push(bufferListView)
  103. }
  104. ToolbarButton {
  105. text: qsTr("Settings")
  106. iconSource: "/usr/share/icons/ubuntu-mobile/actions/scalable/settings.svg"
  107. onTriggered: pageStack.push(settingsPage)
  108. }
  109.  
  110. ToolbarButton {
  111. text: qsTr("Close")
  112. iconSource: "/usr/share/icons/ubuntu-mobile/actions/scalable/close.svg"
  113. enabled: !!bufferListView.currentBuffer
  114. onTriggered: bufferListView.closed(currentBuffer)
  115. }
  116. }
  117. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement