obs-StreamFX/source/ui/ui-about-entry.cpp
Michael Fabian 'Xaymar' Dirks decca6e906 ui/about: Use auto-generated credits for "About StreamFX"
As contributors and translators always increase in number and never decrease, it was getting difficult to thank everyone properly with every update. So instead of manually writing each entry we should take advantage of the power of automation and use APIs to gather this information properly. As long as the user is not actively hiding their profile, they will be thanked properly.

This also includes a potential fix for the problem with multi-lingual text in the About StreamFX window.
2023-04-05 18:51:54 +02:00

65 lines
2.1 KiB
C++

/*
* Modern effects for a modern Streamer
* Copyright (C) 2020 Michael Fabian Dirks
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "ui-about-entry.hpp"
constexpr std::string_view i18n_role_contributor = "UI.About.Role.Contributor";
constexpr std::string_view i18n_role_translator = "UI.About.Role.Translator";
constexpr std::string_view i18n_role_supporter = "UI.About.Role.Supporter";
streamfx::ui::about_entry::about_entry(QWidget* parent, const streamfx::ui::about::entry& entry)
: QWidget(parent), _link()
{
setupUi(this);
name->setText(QString::fromStdString(entry.name));
switch (entry.role) {
case streamfx::ui::about::role_type::NONE:
title->setText(QString::fromStdString(entry.role_custom));
break;
case streamfx::ui::about::role_type::CONTRIBUTOR:
title->setText(D_TRANSLATE(i18n_role_contributor.data()));
break;
case streamfx::ui::about::role_type::TRANSLATOR:
title->setText(D_TRANSLATE(i18n_role_translator.data()));
break;
case streamfx::ui::about::role_type::SUPPORTER:
title->setText(D_TRANSLATE(i18n_role_supporter.data()));
break;
default:
break;
}
if (!entry.link.empty()) {
this->setCursor(Qt::PointingHandCursor);
_link = QUrl(QString::fromUtf8(entry.link.c_str()));
}
}
streamfx::ui::about_entry::~about_entry() {}
void streamfx::ui::about_entry::mousePressEvent(QMouseEvent* event)
{
if (_link.isEmpty())
return;
if (event->button() == Qt::LeftButton) {
QDesktopServices::openUrl(_link);
}
}