PageRenderTime 51ms CodeModel.GetById 22ms RepoModel.GetById 1ms app.codeStats 0ms

/src/gui/doc/snippets/code/src_gui_util_qdesktopservices.cpp

https://gitlab.com/f3822/qtbase
C++ | 174 lines | 24 code | 14 blank | 136 comment | 0 complexity | 3a8491a89d387edc2c4726ac80c3b99d MD5 | raw file
  1. /****************************************************************************
  2. **
  3. ** Copyright (C) 2016 The Qt Company Ltd.
  4. ** Contact: https://www.qt.io/licensing/
  5. **
  6. ** This file is part of the documentation of the Qt Toolkit.
  7. **
  8. ** $QT_BEGIN_LICENSE:BSD$
  9. ** Commercial License Usage
  10. ** Licensees holding valid commercial Qt licenses may use this file in
  11. ** accordance with the commercial license agreement provided with the
  12. ** Software or, alternatively, in accordance with the terms contained in
  13. ** a written agreement between you and The Qt Company. For licensing terms
  14. ** and conditions see https://www.qt.io/terms-conditions. For further
  15. ** information use the contact form at https://www.qt.io/contact-us.
  16. **
  17. ** BSD License Usage
  18. ** Alternatively, you may use this file under the terms of the BSD license
  19. ** as follows:
  20. **
  21. ** "Redistribution and use in source and binary forms, with or without
  22. ** modification, are permitted provided that the following conditions are
  23. ** met:
  24. ** * Redistributions of source code must retain the above copyright
  25. ** notice, this list of conditions and the following disclaimer.
  26. ** * Redistributions in binary form must reproduce the above copyright
  27. ** notice, this list of conditions and the following disclaimer in
  28. ** the documentation and/or other materials provided with the
  29. ** distribution.
  30. ** * Neither the name of The Qt Company Ltd nor the names of its
  31. ** contributors may be used to endorse or promote products derived
  32. ** from this software without specific prior written permission.
  33. **
  34. **
  35. ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  36. ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  37. ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  38. ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  39. ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  40. ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  41. ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  42. ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  43. ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  44. ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  45. ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
  46. **
  47. ** $QT_END_LICENSE$
  48. **
  49. ****************************************************************************/
  50. #include <QDesktopServices>
  51. #include <QObject>
  52. #include <QStandardPaths>
  53. #include <QUrl>
  54. namespace src_gui_util_qdesktopservices {
  55. //! [0]
  56. class MyHelpHandler : public QObject
  57. {
  58. Q_OBJECT
  59. public:
  60. // ...
  61. public slots:
  62. void showHelp(const QUrl &url);
  63. };
  64. //! [0]
  65. void wrapper0() {
  66. MyHelpHandler *helpInstance = nullptr;
  67. //! [setUrlHandler]
  68. QDesktopServices::setUrlHandler("help", helpInstance, "showHelp");
  69. //! [setUrlHandler]
  70. } // wrapper
  71. /* comment wrapper 1
  72. //! [1]
  73. mailto:user@foo.com?subject=Test&body=Just a test
  74. //! [1]
  75. */ // comment wrapper 1
  76. void wrapper1() {
  77. //! [2]
  78. QDesktopServices::openUrl(QUrl("file:///C:/Program Files", QUrl::TolerantMode));
  79. //! [2]
  80. }
  81. /* comment wrapper 2
  82. //! [3]
  83. <key>LSApplicationQueriesSchemes</key>
  84. <array>
  85. <string>https</string>
  86. </array>
  87. //! [3]
  88. //! [4]
  89. <key>CFBundleURLTypes</key>
  90. <array>
  91. <dict>
  92. <key>CFBundleURLSchemes</key>
  93. <array>
  94. <string>myapp</string>
  95. </array>
  96. </dict>
  97. </array>
  98. //! [4]
  99. */ // comment wrapper 2
  100. void wrapper3() {
  101. //! [6]
  102. QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) +
  103. "/data/organization/application";
  104. //! [6]
  105. } // wrapper3
  106. /* comment wrapper 3
  107. //! [7]
  108. <key>com.apple.developer.associated-domains</key>
  109. <array>
  110. <string>applinks:your.domain.com</string>
  111. </array>
  112. //! [7]
  113. //! [8]
  114. {
  115. "applinks": {
  116. "apps": [],
  117. "details": [{
  118. "appIDs" : [ "ABCDE12345.com.example.app" ],
  119. "components": [{
  120. "/": "/help",
  121. "?": { "topic": "?*"}
  122. }]
  123. }]
  124. }
  125. }
  126. //! [8]
  127. //! [9]
  128. <intent-filter>
  129. <action android:name="android.intent.action.VIEW" />
  130. <category android:name="android.intent.category.DEFAULT" />
  131. <category android:name="android.intent.category.BROWSABLE" />
  132. <data android:scheme="https" android:host="your.domain.com" android:port="1337" android:path="/help"/>
  133. </intent-filter>
  134. //! [9]
  135. //! [10]
  136. <intent-filter android:autoVerify="true">
  137. //! [10]
  138. //! [11]
  139. [{
  140. "relation": ["delegate_permission/common.handle_all_urls"],
  141. "target": {
  142. "namespace": "android_app",
  143. "package_name": "com.example.app",
  144. "sha256_cert_fingerprints":
  145. ["14:6D:E9:83:C5:73:06:50:D8:EE:B9:95:2F:34:FC:64:16:A0:83:42:E6:1D:BE:A8:8A:04:96:B2:3F:CF:44:E5"]
  146. }
  147. }]
  148. //! [11]
  149. */ // comment wrapper 3
  150. } // src_gui_util_qdesktopservices