window-basic-about.cpp 3.3 KB

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