AddFolderSheet.qml 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /****************************************************************************
  2. **
  3. ** Copyright (C) 2012 Róbert Márki
  4. **
  5. ** This file is part of Web Feeds.
  6. **
  7. ** Web Feeds is free software: you can redistribute it and/or modify
  8. ** it under the terms of the GNU General Public License as published by
  9. ** the Free Software Foundation, either version 3 of the License, or
  10. ** (at your option) any later version.
  11. **
  12. ** Web Feeds is distributed in the hope that it will be useful,
  13. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. ** GNU General Public License for more details.
  16. **
  17. ** You should have received a copy of the GNU General Public License
  18. ** along with Web Feeds. If not, see <http://www.gnu.org/licenses/>.
  19. ****************************************************************************/
  20. import QtQuick 1.1
  21. import com.nokia.meego 1.0
  22. import WebFeeds 1.0
  23. import NewsBlur 1.0
  24. import "../../../../shared/qml" as Shared
  25. import "../../../../shared/qml/UIConstants.js" as UIConstants
  26. CommonNewsBlurSheet {
  27. id: root
  28. acceptButtonText: qsTr("Add")
  29. rejectButtonText: qsTr("Cancel")
  30. title: qsTr("Add folder")
  31. busyText: qsTr("Adding folder")
  32. function updateAcceptButtonStatus() {
  33. root.acceptButton.enabled = nameField.text.length;
  34. }
  35. Connections {
  36. target: root.service
  37. onFolderAddingFinished: root.onFolderAddingFinished(result)
  38. }
  39. function onFolderAddingFinished(result) {
  40. if((result == NewsBlurEnum.SreNoError)
  41. || (result == NewsBlurEnum.SreAborted)) {
  42. root.close();
  43. return;
  44. }
  45. root.busy = false;
  46. if(result == NewsBlurEnum.SreNetworkError)
  47. root.showMessage(qsTr("Network error"));
  48. else
  49. root.showMessage(qsTr("Failed to add the folder"));
  50. }
  51. onAccepted: {
  52. root.busy = true;
  53. root.open();
  54. root.service.addFolder(root.pageItem, nameField.text);
  55. }
  56. onRejected: {
  57. if(root.busy) {
  58. root.open();
  59. root.service.abortAddFolder(root.pageItem);
  60. }
  61. }
  62. contentItem: Column {
  63. anchors.fill: parent
  64. anchors.leftMargin: UIConstants.DEFAULT_MARGIN
  65. anchors.rightMargin: UIConstants.DEFAULT_MARGIN
  66. spacing: UIConstants.DEFAULT_HALF_MARGIN
  67. Label {
  68. text: qsTr("Name")
  69. font.family: UIConstants.FONT_FAMILY_LIGHT
  70. }
  71. Shared.TextField {
  72. id: nameField
  73. width: parent.width
  74. onTextChanged: {
  75. root.updateAcceptButtonStatus();
  76. }
  77. platformSipAttributes: SipAttributes {
  78. actionKeyEnabled: root.acceptButton.enabled
  79. actionKeyLabel: root.acceptButtonText
  80. actionKeyHighlighted: true
  81. }
  82. Keys.onReturnPressed: {
  83. if(root.acceptButton.enabled)
  84. root.accept();
  85. }
  86. }
  87. Connections {
  88. target: root
  89. onStatusChanged: {
  90. if(root.status == DialogStatus.Open) {
  91. nameField.forceActiveFocus();
  92. nameField.platformOpenSoftwareInputPanel();
  93. }
  94. }
  95. }
  96. }
  97. }