integration.cpp 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. // This file is part of Desktop App Toolkit,
  2. // a set of libraries for developing nice desktop applications.
  3. //
  4. // For license and copyright information please follow this link:
  5. // https://github.com/desktop-app/legal/blob/master/LEGAL
  6. //
  7. #include "ui/integration.h"
  8. #include "ui/gl/gl_detection.h"
  9. #include "ui/text/text_custom_emoji.h"
  10. #include "ui/text/text_entity.h"
  11. #include "ui/toast/toast.h"
  12. #include "ui/basic_click_handlers.h"
  13. #include "base/platform/base_platform_info.h"
  14. namespace Ui {
  15. namespace {
  16. Integration *IntegrationInstance = nullptr;
  17. } // namespace
  18. void Integration::Set(not_null<Integration*> instance) {
  19. IntegrationInstance = instance;
  20. #ifdef DESKTOP_APP_USE_ANGLE
  21. GL::ConfigureANGLE();
  22. #endif
  23. }
  24. Integration &Integration::Instance() {
  25. Expects(IntegrationInstance != nullptr);
  26. return *IntegrationInstance;
  27. }
  28. bool Integration::Exists() {
  29. return (IntegrationInstance != nullptr);
  30. }
  31. void Integration::textActionsUpdated() {
  32. }
  33. void Integration::activationFromTopPanel() {
  34. }
  35. bool Integration::screenIsLocked() {
  36. return false;
  37. }
  38. std::shared_ptr<ClickHandler> Integration::createLinkHandler(
  39. const EntityLinkData &data,
  40. const Text::MarkedContext &context) {
  41. switch (data.type) {
  42. case EntityType::CustomUrl:
  43. return !data.data.isEmpty()
  44. ? std::make_shared<UrlClickHandler>(data.data, false)
  45. : nullptr;
  46. case EntityType::Email:
  47. case EntityType::Url:
  48. return !data.data.isEmpty()
  49. ? std::make_shared<UrlClickHandler>(
  50. data.data,
  51. data.shown == EntityLinkShown::Full)
  52. : nullptr;
  53. }
  54. return nullptr;
  55. }
  56. // bool Integration::allowClickHandlerActivation(
  57. // const std::shared_ptr<ClickHandler> &handler,
  58. // const ClickContext &context) {
  59. // return true;
  60. // }
  61. bool Integration::handleUrlClick(
  62. const QString &url,
  63. const QVariant &context) {
  64. return false;
  65. }
  66. bool Integration::copyPreOnClick(const QVariant &context) {
  67. Toast::Show(u"Code copied to clipboard."_q);
  68. return true;
  69. }
  70. QString Integration::convertTagToMimeTag(const QString &tagId) {
  71. return tagId;
  72. }
  73. const Emoji::One *Integration::defaultEmojiVariant(const Emoji::One *emoji) {
  74. return emoji;
  75. }
  76. rpl::producer<> Integration::forcePopupMenuHideRequests() {
  77. return rpl::never<rpl::empty_value>();
  78. }
  79. QString Integration::phraseContextCopyText() {
  80. return "Copy text";
  81. }
  82. QString Integration::phraseContextCopyEmail() {
  83. return "Copy email";
  84. }
  85. QString Integration::phraseContextCopyLink() {
  86. return "Copy link";
  87. }
  88. QString Integration::phraseContextCopySelected() {
  89. return "Copy to clipboard";
  90. }
  91. QString Integration::phraseFormattingTitle() {
  92. return "Formatting";
  93. }
  94. QString Integration::phraseFormattingLinkCreate() {
  95. return "Create link";
  96. }
  97. QString Integration::phraseFormattingLinkEdit() {
  98. return "Edit link";
  99. }
  100. QString Integration::phraseFormattingClear() {
  101. return "Plain text";
  102. }
  103. QString Integration::phraseFormattingBold() {
  104. return "Bold";
  105. }
  106. QString Integration::phraseFormattingItalic() {
  107. return "Italic";
  108. }
  109. QString Integration::phraseFormattingUnderline() {
  110. return "Underline";
  111. }
  112. QString Integration::phraseFormattingStrikeOut() {
  113. return "Strike-through";
  114. }
  115. QString Integration::phraseFormattingBlockquote() {
  116. return "Quote";
  117. }
  118. QString Integration::phraseFormattingMonospace() {
  119. return "Monospace";
  120. }
  121. QString Integration::phraseFormattingSpoiler() {
  122. return "Spoiler";
  123. }
  124. QString Integration::phraseButtonOk() {
  125. return "OK";
  126. }
  127. QString Integration::phraseButtonClose() {
  128. return "Close";
  129. }
  130. QString Integration::phraseButtonCancel() {
  131. return "Cancel";
  132. }
  133. QString Integration::phrasePanelCloseWarning() {
  134. return "Warning";
  135. }
  136. QString Integration::phrasePanelCloseUnsaved() {
  137. return "Changes that you made may not be saved.";
  138. }
  139. QString Integration::phrasePanelCloseAnyway() {
  140. return "Close anyway";
  141. }
  142. QString Integration::phraseBotSharePhone() {
  143. return "Do you want to share your phone number with this bot?";
  144. }
  145. QString Integration::phraseBotSharePhoneTitle() {
  146. return "Phone number";
  147. }
  148. QString Integration::phraseBotSharePhoneConfirm() {
  149. return "Share";
  150. }
  151. QString Integration::phraseBotAllowWrite() {
  152. return "Do you want to allow this bot to write you?";
  153. }
  154. QString Integration::phraseBotAllowWriteTitle() {
  155. return "Allow write";
  156. }
  157. QString Integration::phraseBotAllowWriteConfirm() {
  158. return "Allow";
  159. }
  160. QString Integration::phraseQuoteHeaderCopy() {
  161. return "copy";
  162. }
  163. } // namespace Ui