window-basic-about.cpp 3.3 KB

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