window-basic-about.cpp 3.2 KB

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