mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
Made 8 customizable timeout buttons
changed fixed timeout buttons to be read from settings
This commit is contained in:
parent
d3aa3694f2
commit
e64f37d288
3 changed files with 119 additions and 28 deletions
|
@ -195,6 +195,59 @@ public:
|
||||||
|
|
||||||
QStringSetting cachePath = {"/cache/path", ""};
|
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:
|
private:
|
||||||
void updateModerationActions();
|
void updateModerationActions();
|
||||||
};
|
};
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
#include "providers/twitch/PartialTwitchUser.hpp"
|
#include "providers/twitch/PartialTwitchUser.hpp"
|
||||||
#include "providers/twitch/TwitchChannel.hpp"
|
#include "providers/twitch/TwitchChannel.hpp"
|
||||||
#include "singletons/Resources.hpp"
|
#include "singletons/Resources.hpp"
|
||||||
|
#include "singletons/Settings.hpp"
|
||||||
#include "util/LayoutCreator.hpp"
|
#include "util/LayoutCreator.hpp"
|
||||||
#include "util/PostToThread.hpp"
|
#include "util/PostToThread.hpp"
|
||||||
#include "widgets/Label.hpp"
|
#include "widgets/Label.hpp"
|
||||||
|
@ -366,6 +367,9 @@ void UserInfoPopup::updateUserData()
|
||||||
|
|
||||||
this->loadAvatar(QUrl(obj.value("logo").toString()));
|
this->loadAvatar(QUrl(obj.value("logo").toString()));
|
||||||
|
|
||||||
|
this->loadProfileBanner(
|
||||||
|
QUrl(obj.value("profile_banner").toString()));
|
||||||
|
|
||||||
return Success;
|
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
|
// TimeoutWidget
|
||||||
//
|
//
|
||||||
|
@ -464,7 +493,7 @@ UserInfoPopup::TimeoutWidget::TimeoutWidget()
|
||||||
QColor color2(255, 255, 255, 0);
|
QColor color2(255, 255, 255, 0);
|
||||||
|
|
||||||
int buttonWidth = 24;
|
int buttonWidth = 24;
|
||||||
int buttonWidth2 = 32;
|
int buttonWidth2 = 40;
|
||||||
int buttonHeight = 32;
|
int buttonHeight = 32;
|
||||||
|
|
||||||
layout->setSpacing(16);
|
layout->setSpacing(16);
|
||||||
|
@ -515,14 +544,7 @@ UserInfoPopup::TimeoutWidget::TimeoutWidget()
|
||||||
auto a = hbox.emplace<EffectLabel2>();
|
auto a = hbox.emplace<EffectLabel2>();
|
||||||
a->getLabel().setText(std::get<0>(item));
|
a->getLabel().setText(std::get<0>(item));
|
||||||
|
|
||||||
if (std::get<0>(item).length() > 1)
|
a->setScaleIndependantSize(buttonWidth2, buttonHeight);
|
||||||
{
|
|
||||||
a->setScaleIndependantSize(buttonWidth2, buttonHeight);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
a->setScaleIndependantSize(buttonWidth, buttonHeight);
|
|
||||||
}
|
|
||||||
a->setBorderColor(color1);
|
a->setBorderColor(color1);
|
||||||
|
|
||||||
QObject::connect(a.getElement(), &EffectLabel2::leftClicked,
|
QObject::connect(a.getElement(), &EffectLabel2::leftClicked,
|
||||||
|
@ -536,24 +558,38 @@ UserInfoPopup::TimeoutWidget::TimeoutWidget()
|
||||||
|
|
||||||
addButton(Unban, "unban", getApp()->resources->buttons.unban);
|
addButton(Unban, "unban", getApp()->resources->buttons.unban);
|
||||||
|
|
||||||
addTimeouts("sec", {{"1", 1}});
|
addTimeouts("Timeouts",
|
||||||
addTimeouts("min", {
|
{{getSettings()->timeoutDurationPerUnit1.getValue() +
|
||||||
{"1", 1 * 60},
|
getSettings()->timeoutDurationUnit1.getValue(),
|
||||||
{"5", 5 * 60},
|
getSettings()->timeoutDurationInSec1.getValue()},
|
||||||
{"10", 10 * 60},
|
|
||||||
});
|
{getSettings()->timeoutDurationPerUnit2.getValue() +
|
||||||
addTimeouts("hour", {
|
getSettings()->timeoutDurationUnit2.getValue(),
|
||||||
{"1", 1 * 60 * 60},
|
getSettings()->timeoutDurationInSec2.getValue()},
|
||||||
{"4", 4 * 60 * 60},
|
|
||||||
});
|
{getSettings()->timeoutDurationPerUnit3.getValue() +
|
||||||
addTimeouts("days", {
|
getSettings()->timeoutDurationUnit3.getValue(),
|
||||||
{"1", 1 * 60 * 60 * 24},
|
getSettings()->timeoutDurationInSec3.getValue()},
|
||||||
{"3", 3 * 60 * 60 * 24},
|
|
||||||
});
|
{getSettings()->timeoutDurationPerUnit4.getValue() +
|
||||||
addTimeouts("weeks", {
|
getSettings()->timeoutDurationUnit4.getValue(),
|
||||||
{"1", 1 * 60 * 60 * 24 * 7},
|
getSettings()->timeoutDurationInSec4.getValue()},
|
||||||
{"2", 2 * 60 * 60 * 24 * 7},
|
|
||||||
});
|
{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);
|
addButton(Ban, "ban", getApp()->resources->buttons.ban);
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,7 @@ private:
|
||||||
void updateUserData();
|
void updateUserData();
|
||||||
|
|
||||||
void loadAvatar(const QUrl &url);
|
void loadAvatar(const QUrl &url);
|
||||||
|
void loadProfileBanner(const QUrl &url);
|
||||||
bool isMod_;
|
bool isMod_;
|
||||||
bool isBroadcaster_;
|
bool isBroadcaster_;
|
||||||
|
|
||||||
|
@ -42,8 +43,9 @@ private:
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
Button *avatarButton = nullptr;
|
Button *avatarButton = nullptr;
|
||||||
// RippleEffectLabel2 *viewLogs = nullptr;
|
|
||||||
|
|
||||||
|
// RippleEffectLabel2 *viewLogs = nullptr;
|
||||||
|
QPixmap profileBanner;
|
||||||
Label *nameLabel = nullptr;
|
Label *nameLabel = nullptr;
|
||||||
Label *viewCountLabel = nullptr;
|
Label *viewCountLabel = nullptr;
|
||||||
Label *followerCountLabel = nullptr;
|
Label *followerCountLabel = nullptr;
|
||||||
|
|
Loading…
Reference in a new issue