window-basic-about.cpp 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. #include "window-basic-about.hpp"
  2. #include "window-basic-main.hpp"
  3. #include "qt-wrappers.hpp"
  4. #include <string>
  5. #include <util/util.hpp>
  6. #include <util/platform.h>
  7. #include <platform.hpp>
  8. OBSAbout::OBSAbout(QWidget *parent)
  9. : QDialog(parent),
  10. ui(new Ui::OBSAbout)
  11. {
  12. ui->setupUi(this);
  13. QString bitness;
  14. if(sizeof(void*) == 4)
  15. bitness = " (32 bit)";
  16. else if(sizeof(void*) == 8)
  17. bitness = " (64 bit)";
  18. ui->version->setText(
  19. QString::number(LIBOBS_API_MAJOR_VER) + "." +
  20. QString::number(LIBOBS_API_MINOR_VER) + "." +
  21. QString::number(LIBOBS_API_PATCH_VER) +
  22. bitness);
  23. ui->contribute->setText(QTStr("About.Contribute"));
  24. ui->donate->setText("<a href='https://obsproject.com/donate'>" +
  25. QTStr("About.Donate") + "</a>");
  26. ui->donate->setTextInteractionFlags(Qt::TextBrowserInteraction);
  27. ui->donate->setOpenExternalLinks(true);
  28. ui->getInvolved->setText("<a href='https://github.com/obsproject/obs-studio/blob/master/CONTRIBUTING.rst'>" +
  29. QTStr("About.GetInvolved") + "</a>");
  30. ui->getInvolved->setTextInteractionFlags(Qt::TextBrowserInteraction);
  31. ui->getInvolved->setOpenExternalLinks(true);
  32. ui->about->setText("<a href='#'>" + QTStr("About") + "</a>");
  33. ui->authors->setText("<a href='#'>" + QTStr("About.Authors") + "</a>");
  34. ui->license->setText("<a href='#'>" + QTStr("About.License") + "</a>");
  35. ui->textBrowser->hide();
  36. ui->name->setProperty("themeID", "aboutName");
  37. ui->version->setProperty("themeID", "aboutVersion");
  38. ui->about->setProperty("themeID", "aboutHLayout");
  39. ui->authors->setProperty("themeID", "aboutHLayout");
  40. ui->license->setProperty("themeID", "aboutHLayout");
  41. ui->info->setProperty("themeID", "aboutInfo");
  42. connect(ui->about, SIGNAL(clicked()), this, SLOT(ShowAbout()));
  43. connect(ui->authors, SIGNAL(clicked()), this, SLOT(ShowAuthors()));
  44. connect(ui->license, SIGNAL(clicked()), this, SLOT(ShowLicense()));
  45. }
  46. void OBSAbout::ShowAbout()
  47. {
  48. ui->textBrowser->hide();
  49. ui->info->show();
  50. ui->contribute->show();
  51. ui->donate->show();
  52. ui->getInvolved->show();
  53. }
  54. void OBSAbout::ShowAuthors()
  55. {
  56. std::string path;
  57. QString error = "Error! File could not be read.\n\n \
  58. Go to: https://github.com/obsproject/obs-studio/blob/master/AUTHORS";
  59. if (!GetDataFilePath("authors/AUTHORS", path)) {
  60. ui->textBrowser->setPlainText(error);
  61. return;
  62. }
  63. ui->textBrowser->setPlainText(QString::fromStdString(path));
  64. BPtr<char> text = os_quick_read_utf8_file(path.c_str());
  65. if (!text || !*text) {
  66. ui->textBrowser->setPlainText(error);
  67. return;
  68. }
  69. ui->textBrowser->setPlainText(QT_UTF8(text));
  70. ui->info->hide();
  71. ui->contribute->hide();
  72. ui->donate->hide();
  73. ui->getInvolved->hide();
  74. ui->textBrowser->show();
  75. }
  76. void OBSAbout::ShowLicense()
  77. {
  78. std::string path;
  79. QString error = "Error! File could not be read.\n\n \
  80. Go to: https://github.com/obsproject/obs-studio/blob/master/COPYING";
  81. if (!GetDataFilePath("license/gplv2.txt", path)) {
  82. ui->textBrowser->setPlainText(error);
  83. return;
  84. }
  85. BPtr<char> text = os_quick_read_utf8_file(path.c_str());
  86. if (!text || !*text) {
  87. ui->textBrowser->setPlainText(error);
  88. return;
  89. }
  90. ui->textBrowser->setPlainText(QT_UTF8(text));
  91. ui->info->hide();
  92. ui->contribute->hide();
  93. ui->donate->hide();
  94. ui->getInvolved->hide();
  95. ui->textBrowser->show();
  96. }