diff --git a/src/singletons/Settings.hpp b/src/singletons/Settings.hpp index f54de6c65..1e4830030 100644 --- a/src/singletons/Settings.hpp +++ b/src/singletons/Settings.hpp @@ -195,6 +195,59 @@ public: QStringSetting cachePath = {"/cache/path", ""}; + /// Timeout buttons + QStringSetting timeoutDurationPerUnit1 = { + "/timeouts/timeoutDurationPerUnit1", "1"}; + QStringSetting timeoutDurationUnit1 = {"/timeouts/timeoutDurationUnit1", + "s"}; + IntSetting timeoutDurationInSec1 = {"/timeouts/timeoutDurationInSec1", 1}; + + QStringSetting timeoutDurationPerUnit2 = { + "/timeouts/timeoutDurationPerUnit2", "30"}; + QStringSetting timeoutDurationUnit2 = {"/timeouts/timeoutDurationUnit2", + "s"}; + IntSetting timeoutDurationInSec2 = {"/timeouts/timeoutDurationInSec1", 30}; + + QStringSetting timeoutDurationPerUnit3 = { + "/timeouts/timeoutDurationPerUnit3", "1"}; + QStringSetting timeoutDurationUnit3 = {"/timeouts/timeoutDurationUnit3", + "m"}; + IntSetting timeoutDurationInSec3 = {"/timeouts/timeoutDurationInSec3", 60}; + + QStringSetting timeoutDurationPerUnit4 = { + "/timeouts/timeoutDurationPerUnit4", "5"}; + QStringSetting timeoutDurationUnit4 = {"/timeouts/timeoutDurationUnit4", + "s"}; + IntSetting timeoutDurationInSec4 = {"/timeouts/timeoutDurationInSec4", 300}; + + QStringSetting timeoutDurationPerUnit5 = { + "/timeouts/timeoutDurationPerUnit5", "30"}; + QStringSetting timeoutDurationUnit5 = {"/timeouts/timeoutDurationUnit5", + "m"}; + IntSetting timeoutDurationInSec5 = {"/timeouts/timeoutDurationInSec5", + 1800}; + + QStringSetting timeoutDurationPerUnit6 = { + "/timeouts/timeoutDurationPerUnit6", "1"}; + QStringSetting timeoutDurationUnit6 = {"/timeouts/timeoutDurationUnit6", + "h"}; + IntSetting timeoutDurationInSec6 = {"/timeouts/timeoutDurationInSec6", + 3600}; + + QStringSetting timeoutDurationPerUnit7 = { + "/timeouts/timeoutDurationPerUnit7", "1"}; + QStringSetting timeoutDurationUnit7 = {"/timeouts/timeoutDurationUnit7", + "d"}; + IntSetting timeoutDurationInSec7 = {"/timeouts/timeoutDurationInSec7", + 86400}; + + QStringSetting timeoutDurationPerUnit8 = { + "/timeouts/timeoutDurationPerUnit8", "1"}; + QStringSetting timeoutDurationUnit8 = {"/timeouts/timeoutDurationUnit8", + "w"}; + IntSetting timeoutDurationInSec8 = {"/timeouts/timeoutDurationInSec8", + 604800}; + private: void updateModerationActions(); }; diff --git a/src/widgets/dialogs/UserInfoPopup.cpp b/src/widgets/dialogs/UserInfoPopup.cpp index f326d9cc9..80ccdcf0f 100644 --- a/src/widgets/dialogs/UserInfoPopup.cpp +++ b/src/widgets/dialogs/UserInfoPopup.cpp @@ -8,6 +8,7 @@ #include "providers/twitch/PartialTwitchUser.hpp" #include "providers/twitch/TwitchChannel.hpp" #include "singletons/Resources.hpp" +#include "singletons/Settings.hpp" #include "util/LayoutCreator.hpp" #include "util/PostToThread.hpp" #include "widgets/Label.hpp" @@ -366,6 +367,9 @@ void UserInfoPopup::updateUserData() this->loadAvatar(QUrl(obj.value("logo").toString())); + this->loadProfileBanner( + QUrl(obj.value("profile_banner").toString())); + return Success; }); @@ -450,6 +454,31 @@ void UserInfoPopup::loadAvatar(const QUrl &url) }); } +void UserInfoPopup::loadProfileBanner(const QUrl &url) +{ + QNetworkRequest req(url); + static auto manager = new QNetworkAccessManager(); + auto *reply = manager->get(req); + + QObject::connect(reply, &QNetworkReply::finished, this, [=] { + if (reply->error() == QNetworkReply::NoError) + { + const auto data = reply->readAll(); + + // might want to cache the banner image + QPixmap banner; + banner.loadFromData(data); + this->ui_.profileBanner = + banner.scaled(600, 200, Qt::KeepAspectRatio); + } + else + { + QPixmap emptyBanner; + this->ui_.profileBanner = emptyBanner; + } + }); +} + // // TimeoutWidget // @@ -464,7 +493,7 @@ UserInfoPopup::TimeoutWidget::TimeoutWidget() QColor color2(255, 255, 255, 0); int buttonWidth = 24; - int buttonWidth2 = 32; + int buttonWidth2 = 40; int buttonHeight = 32; layout->setSpacing(16); @@ -515,14 +544,7 @@ UserInfoPopup::TimeoutWidget::TimeoutWidget() auto a = hbox.emplace(); a->getLabel().setText(std::get<0>(item)); - if (std::get<0>(item).length() > 1) - { - a->setScaleIndependantSize(buttonWidth2, buttonHeight); - } - else - { - a->setScaleIndependantSize(buttonWidth, buttonHeight); - } + a->setScaleIndependantSize(buttonWidth2, buttonHeight); a->setBorderColor(color1); QObject::connect(a.getElement(), &EffectLabel2::leftClicked, @@ -536,24 +558,38 @@ UserInfoPopup::TimeoutWidget::TimeoutWidget() addButton(Unban, "unban", getApp()->resources->buttons.unban); - addTimeouts("sec", {{"1", 1}}); - addTimeouts("min", { - {"1", 1 * 60}, - {"5", 5 * 60}, - {"10", 10 * 60}, - }); - addTimeouts("hour", { - {"1", 1 * 60 * 60}, - {"4", 4 * 60 * 60}, - }); - addTimeouts("days", { - {"1", 1 * 60 * 60 * 24}, - {"3", 3 * 60 * 60 * 24}, - }); - addTimeouts("weeks", { - {"1", 1 * 60 * 60 * 24 * 7}, - {"2", 2 * 60 * 60 * 24 * 7}, - }); + addTimeouts("Timeouts", + {{getSettings()->timeoutDurationPerUnit1.getValue() + + getSettings()->timeoutDurationUnit1.getValue(), + getSettings()->timeoutDurationInSec1.getValue()}, + + {getSettings()->timeoutDurationPerUnit2.getValue() + + getSettings()->timeoutDurationUnit2.getValue(), + getSettings()->timeoutDurationInSec2.getValue()}, + + {getSettings()->timeoutDurationPerUnit3.getValue() + + getSettings()->timeoutDurationUnit3.getValue(), + getSettings()->timeoutDurationInSec3.getValue()}, + + {getSettings()->timeoutDurationPerUnit4.getValue() + + getSettings()->timeoutDurationUnit4.getValue(), + getSettings()->timeoutDurationInSec4.getValue()}, + + {getSettings()->timeoutDurationPerUnit5.getValue() + + getSettings()->timeoutDurationUnit5.getValue(), + getSettings()->timeoutDurationInSec5.getValue()}, + + {getSettings()->timeoutDurationPerUnit6.getValue() + + getSettings()->timeoutDurationUnit6.getValue(), + getSettings()->timeoutDurationInSec6.getValue()}, + + {getSettings()->timeoutDurationPerUnit7.getValue() + + getSettings()->timeoutDurationUnit7.getValue(), + getSettings()->timeoutDurationInSec7.getValue()}, + + {getSettings()->timeoutDurationPerUnit8.getValue() + + getSettings()->timeoutDurationUnit8.getValue(), + getSettings()->timeoutDurationInSec8.getValue()}}); addButton(Ban, "ban", getApp()->resources->buttons.ban); } diff --git a/src/widgets/dialogs/UserInfoPopup.hpp b/src/widgets/dialogs/UserInfoPopup.hpp index 59437d3da..8699f8dde 100644 --- a/src/widgets/dialogs/UserInfoPopup.hpp +++ b/src/widgets/dialogs/UserInfoPopup.hpp @@ -29,6 +29,7 @@ private: void updateUserData(); void loadAvatar(const QUrl &url); + void loadProfileBanner(const QUrl &url); bool isMod_; bool isBroadcaster_; @@ -42,8 +43,9 @@ private: struct { Button *avatarButton = nullptr; - // RippleEffectLabel2 *viewLogs = nullptr; + // RippleEffectLabel2 *viewLogs = nullptr; + QPixmap profileBanner; Label *nameLabel = nullptr; Label *viewCountLabel = nullptr; Label *followerCountLabel = nullptr;