Typica is a free program for professional coffee roasters. https://typica.us
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

webview.cpp 1.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /*541:*/
  2. #line 50 "./webview.w"
  3. #include "webview.h"
  4. /*542:*/
  5. #line 57 "./webview.w"
  6. TypicaWebView::TypicaWebView():QWebView()
  7. {
  8. page()->setLinkDelegationPolicy(QWebPage::DelegateExternalLinks);
  9. connect(page(),SIGNAL(linkClicked(QUrl)),this,SLOT(linkDelegate(QUrl)));
  10. }
  11. /*:542*//*543:*/
  12. #line 73 "./webview.w"
  13. void TypicaWebView::linkDelegate(const QUrl&url)
  14. {
  15. if(url.scheme()=="typica")
  16. {
  17. QString address(url.toEncoded());
  18. /*544:*/
  19. #line 91 "./webview.w"
  20. if(address=="typica://aboutqt")
  21. {
  22. QMessageBox::aboutQt(this);
  23. return;
  24. }
  25. /*:544*/
  26. #line 79 "./webview.w"
  27. /*545:*/
  28. #line 100 "./webview.w"
  29. if(address.startsWith("typica://script/"))
  30. {
  31. emit scriptLinkClicked(address.remove(0,16));
  32. return;
  33. }
  34. /*:545*/
  35. #line 80 "./webview.w"
  36. }
  37. else
  38. {
  39. QDesktopServices::openUrl(url);
  40. }
  41. }
  42. /*:543*//*546:*/
  43. #line 112 "./webview.w"
  44. void TypicaWebView::load(const QString&url)
  45. {
  46. QWebView::load(QUrl(url));
  47. }
  48. void TypicaWebView::print()
  49. {
  50. QPrinter*printer= new QPrinter(QPrinter::HighResolution);
  51. QPrintDialog printDialog(printer,NULL);
  52. if(printDialog.exec()==QDialog::Accepted)
  53. {
  54. QWebView::print(printer);
  55. }
  56. }
  57. void TypicaWebView::setHtml(const QString&html,const QUrl&baseUrl)
  58. {
  59. QWebView::setHtml(html,baseUrl);
  60. }
  61. void TypicaWebView::setContent(QIODevice*device)
  62. {
  63. QSettings settings;
  64. device->reset();
  65. QByteArray content= device->readAll();
  66. QUrl baseDir= QUrl("file://"+settings.value("config").toString()+"/");
  67. QWebView::setContent(content,"application/xhtml+xml",baseDir);
  68. }
  69. QString TypicaWebView::saveXml()
  70. {
  71. return page()->currentFrame()->documentElement().toOuterXml();
  72. }
  73. /*:546*//*552:*/
  74. #line 205 "./webview.w"
  75. QWebElement TypicaWebView::documentElement()
  76. {
  77. return page()->mainFrame()->documentElement();
  78. }
  79. QWebElement TypicaWebView::findFirstElement(const QString&selector)
  80. {
  81. return page()->mainFrame()->findFirstElement(selector);
  82. }
  83. /*:552*/
  84. #line 53 "./webview.w"
  85. /*:541*/