Typica is a free program for professional coffee roasters. https://typica.us
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

abouttypica.w 2.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. @** A Window for Displaying Information About Typica.
  2. \noindent The About window for an application typically displays a few pieces
  3. of information: The application logo, name, and version number, copyright and
  4. license information, and other assorted information. In Typica this also
  5. includes a list of the people and companies that have provided financial
  6. assistance toward the ongoing development of the software and information that
  7. others can use to help in this way. Some of this information would benefit
  8. from existing as a link which can open an external application such as a web
  9. browser or email client.
  10. @(abouttypica.h@>=
  11. #include <QMainWindow>
  12. #include <QWebView>
  13. #include <QFile>
  14. #include <QtDebug>
  15. #include <QMessageBox>
  16. #include <QDesktopServices>
  17. #ifndef AboutTypicaHeader
  18. #define AboutTypicaHeader
  19. class AboutTypica : public QMainWindow
  20. {
  21. Q_OBJECT
  22. public:
  23. AboutTypica();
  24. public slots:
  25. void linkClicked(const QUrl &url);
  26. };
  27. #endif
  28. @ The implementation is in a separate file.
  29. @(abouttypica.cpp@>=
  30. #include "abouttypica.h"
  31. @<AboutTypica implementation@>@;
  32. @ The information provided here comes from a set of HTML documents stored as
  33. compiled resources and presented in a set of |QWebView| instances accessible
  34. through a set of tabs.
  35. @<AboutTypica implementation@>=
  36. AboutTypica::AboutTypica() : QMainWindow(NULL)
  37. {
  38. QFile aboutFile(":/resources/html/about.html");
  39. aboutFile.open(QIODevice::ReadOnly);
  40. QByteArray content = aboutFile.readAll();
  41. QWebView *banner = new QWebView;
  42. banner->setHtml(content, QUrl("qrc:/resources/html/about.html"));
  43. aboutFile.close();
  44. setCentralWidget(banner);
  45. QWebPage *page = banner->page();
  46. page->setLinkDelegationPolicy(QWebPage::DelegateExternalLinks);
  47. connect(page, SIGNAL(linkClicked(QUrl)), this, SLOT(linkClicked(QUrl)));
  48. }
  49. @ In order to display the About Qt window, we detect a special URL from a link
  50. clicked in the about box.
  51. @<AboutTypica implementation@>=
  52. void AboutTypica::linkClicked(const QUrl &url)
  53. {
  54. if(url.scheme() == "typica")
  55. {
  56. QString address(url.toEncoded());
  57. if(address == "typica://aboutqt")
  58. {
  59. QMessageBox::aboutQt(this);
  60. }
  61. else
  62. {
  63. qDebug() << "Unexpected link. Got: " << address;
  64. }
  65. }
  66. else
  67. {
  68. QDesktopServices::openUrl(url);
  69. }
  70. }