push for now
This commit is contained in:
+2
-3
@@ -256,7 +256,7 @@ SOURCES += \
|
|||||||
src/util/FunctionEventFilter.cpp \
|
src/util/FunctionEventFilter.cpp \
|
||||||
src/controllers/notifications/NotificationModel.cpp \
|
src/controllers/notifications/NotificationModel.cpp \
|
||||||
src/singletons/Toasts.cpp \
|
src/singletons/Toasts.cpp \
|
||||||
src/singletons/DownloadManager.cpp
|
src/common/DownloadManager.cpp
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
src/Application.hpp \
|
src/Application.hpp \
|
||||||
@@ -458,9 +458,8 @@ HEADERS += \
|
|||||||
src/util/FormatTime.hpp \
|
src/util/FormatTime.hpp \
|
||||||
src/util/FunctionEventFilter.hpp \
|
src/util/FunctionEventFilter.hpp \
|
||||||
src/controllers/notifications/NotificationModel.hpp \
|
src/controllers/notifications/NotificationModel.hpp \
|
||||||
src/controllers/notifications/NotificationPhrase.hpp \
|
|
||||||
src/singletons/Toasts.hpp \
|
src/singletons/Toasts.hpp \
|
||||||
src/singletons/DownloadManager.hpp
|
src/common/DownloadManager.hpp
|
||||||
|
|
||||||
RESOURCES += \
|
RESOURCES += \
|
||||||
resources/resources.qrc \
|
resources/resources.qrc \
|
||||||
|
|||||||
+2
-3
@@ -12,7 +12,6 @@
|
|||||||
#include "providers/ffz/FfzEmotes.hpp"
|
#include "providers/ffz/FfzEmotes.hpp"
|
||||||
#include "providers/twitch/PubsubClient.hpp"
|
#include "providers/twitch/PubsubClient.hpp"
|
||||||
#include "providers/twitch/TwitchServer.hpp"
|
#include "providers/twitch/TwitchServer.hpp"
|
||||||
#include "singletons/DownloadManager.hpp"
|
|
||||||
#include "singletons/Fonts.hpp"
|
#include "singletons/Fonts.hpp"
|
||||||
#include "singletons/Logging.hpp"
|
#include "singletons/Logging.hpp"
|
||||||
#include "singletons/NativeMessaging.hpp"
|
#include "singletons/NativeMessaging.hpp"
|
||||||
@@ -46,8 +45,8 @@ Application::Application(Settings &_settings, Paths &_paths)
|
|||||||
, fonts(&this->emplace<Fonts>())
|
, fonts(&this->emplace<Fonts>())
|
||||||
, emotes(&this->emplace<Emotes>())
|
, emotes(&this->emplace<Emotes>())
|
||||||
, windows(&this->emplace<WindowManager>())
|
, windows(&this->emplace<WindowManager>())
|
||||||
|
|
||||||
, toasts(&this->emplace<Toasts>())
|
, toasts(&this->emplace<Toasts>())
|
||||||
|
|
||||||
, accounts(&this->emplace<AccountController>())
|
, accounts(&this->emplace<AccountController>())
|
||||||
, commands(&this->emplace<CommandController>())
|
, commands(&this->emplace<CommandController>())
|
||||||
, highlights(&this->emplace<HighlightController>())
|
, highlights(&this->emplace<HighlightController>())
|
||||||
@@ -57,7 +56,7 @@ Application::Application(Settings &_settings, Paths &_paths)
|
|||||||
, moderationActions(&this->emplace<ModerationActions>())
|
, moderationActions(&this->emplace<ModerationActions>())
|
||||||
, twitch2(&this->emplace<TwitchServer>())
|
, twitch2(&this->emplace<TwitchServer>())
|
||||||
, logging(&this->emplace<Logging>())
|
, logging(&this->emplace<Logging>())
|
||||||
, downloads(&this->emplace<DownloadManager>())
|
|
||||||
{
|
{
|
||||||
this->instance = this;
|
this->instance = this;
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ class Settings;
|
|||||||
class Fonts;
|
class Fonts;
|
||||||
class Resources;
|
class Resources;
|
||||||
class Toasts;
|
class Toasts;
|
||||||
class DownloadManager;
|
|
||||||
|
|
||||||
class Application
|
class Application
|
||||||
{
|
{
|
||||||
@@ -59,7 +58,6 @@ public:
|
|||||||
Emotes *const emotes{};
|
Emotes *const emotes{};
|
||||||
WindowManager *const windows{};
|
WindowManager *const windows{};
|
||||||
Toasts *const toasts{};
|
Toasts *const toasts{};
|
||||||
DownloadManager *const downloads{};
|
|
||||||
|
|
||||||
AccountController *const accounts{};
|
AccountController *const accounts{};
|
||||||
CommandController *const commands{};
|
CommandController *const commands{};
|
||||||
|
|||||||
@@ -0,0 +1,80 @@
|
|||||||
|
#include "DownloadManager.hpp"
|
||||||
|
|
||||||
|
#include <QDesktopServices>
|
||||||
|
|
||||||
|
namespace chatterino {
|
||||||
|
|
||||||
|
DownloadManager::DownloadManager(QObject *parent)
|
||||||
|
: QObject(parent)
|
||||||
|
{
|
||||||
|
manager = new QNetworkAccessManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
DownloadManager::~DownloadManager()
|
||||||
|
{
|
||||||
|
manager->deleteLater();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DownloadManager::setFile(QString fileURL, const QString &channelName)
|
||||||
|
{
|
||||||
|
QString filePath = fileURL;
|
||||||
|
QString saveFilePath;
|
||||||
|
QStringList filePathList = filePath.split('/');
|
||||||
|
// QString fileName = filePathList.at(filePathList.count() - 1);
|
||||||
|
saveFilePath = QString(
|
||||||
|
QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) +
|
||||||
|
"2/cache/profileAvatars/twitch/" + channelName + ".png");
|
||||||
|
|
||||||
|
QNetworkRequest request;
|
||||||
|
request.setUrl(QUrl(fileURL));
|
||||||
|
reply = manager->get(request);
|
||||||
|
|
||||||
|
file = new QFile;
|
||||||
|
file->setFileName(saveFilePath);
|
||||||
|
file->open(QIODevice::WriteOnly);
|
||||||
|
|
||||||
|
connect(reply, SIGNAL(downloadProgress(qint64, qint64)), this,
|
||||||
|
SLOT(onDownloadProgress(qint64, qint64)));
|
||||||
|
connect(manager, SIGNAL(finished(QNetworkReply *)), this,
|
||||||
|
SLOT(onFinished(QNetworkReply *)));
|
||||||
|
connect(reply, SIGNAL(readyRead()), this, SLOT(onReadyRead()));
|
||||||
|
connect(reply, SIGNAL(finished()), this, SLOT(onReplyFinished()));
|
||||||
|
}
|
||||||
|
|
||||||
|
void DownloadManager::onDownloadProgress(qint64 bytesRead, qint64 bytesTotal)
|
||||||
|
{
|
||||||
|
qDebug(QString::number(bytesRead).toLatin1() + " - " +
|
||||||
|
QString::number(bytesTotal).toLatin1());
|
||||||
|
}
|
||||||
|
|
||||||
|
void DownloadManager::onFinished(QNetworkReply *reply)
|
||||||
|
{
|
||||||
|
switch (reply->error()) {
|
||||||
|
case QNetworkReply::NoError: {
|
||||||
|
qDebug("file is downloaded successfully.");
|
||||||
|
} break;
|
||||||
|
default: {
|
||||||
|
qDebug(reply->errorString().toLatin1());
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (file->isOpen()) {
|
||||||
|
file->close();
|
||||||
|
file->deleteLater();
|
||||||
|
}
|
||||||
|
emit downloadComplete();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DownloadManager::onReadyRead()
|
||||||
|
{
|
||||||
|
file->write(reply->readAll());
|
||||||
|
}
|
||||||
|
|
||||||
|
void DownloadManager::onReplyFinished()
|
||||||
|
{
|
||||||
|
if (file->isOpen()) {
|
||||||
|
file->close();
|
||||||
|
file->deleteLater();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} // namespace chatterino
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "Application.hpp"
|
||||||
|
|
||||||
|
#include <QFile>
|
||||||
|
#include <QNetworkAccessManager>
|
||||||
|
#include <QNetworkReply>
|
||||||
|
#include <QNetworkRequest>
|
||||||
|
#include <QObject>
|
||||||
|
#include <QStringList>
|
||||||
|
|
||||||
|
namespace chatterino {
|
||||||
|
|
||||||
|
class DownloadManager : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit DownloadManager(QObject *parent = 0);
|
||||||
|
virtual ~DownloadManager();
|
||||||
|
void setFile(QString fileURL, const QString &channelName);
|
||||||
|
|
||||||
|
private:
|
||||||
|
QNetworkAccessManager *manager;
|
||||||
|
QNetworkReply *reply;
|
||||||
|
QFile *file;
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void onDownloadProgress(qint64, qint64);
|
||||||
|
void onFinished(QNetworkReply *);
|
||||||
|
void onReadyRead();
|
||||||
|
void onReplyFinished();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void downloadComplete();
|
||||||
|
};
|
||||||
|
} // namespace chatterino
|
||||||
@@ -146,6 +146,8 @@ public:
|
|||||||
false};
|
false};
|
||||||
BoolSetting notificationToast = {"/notifications/enableToast", false};
|
BoolSetting notificationToast = {"/notifications/enableToast", false};
|
||||||
BoolSetting notificationDot = {"/notifications/enableDot", false};
|
BoolSetting notificationDot = {"/notifications/enableDot", false};
|
||||||
|
BoolSetting notificationSplitheaderHighlight = {
|
||||||
|
"/notifications/enableSplitheaderHighlight", false};
|
||||||
|
|
||||||
/// External tools
|
/// External tools
|
||||||
// Streamlink
|
// Streamlink
|
||||||
|
|||||||
+30
-74
@@ -1,6 +1,7 @@
|
|||||||
#include "Toasts.hpp"
|
#include "Toasts.hpp"
|
||||||
|
|
||||||
#include "Application.hpp"
|
#include "Application.hpp"
|
||||||
|
#include "common/DownloadManager.hpp"
|
||||||
#include "common/NetworkRequest.hpp"
|
#include "common/NetworkRequest.hpp"
|
||||||
#include "controllers/notifications/NotificationController.hpp"
|
#include "controllers/notifications/NotificationController.hpp"
|
||||||
#include "providers/twitch/TwitchChannel.hpp"
|
#include "providers/twitch/TwitchChannel.hpp"
|
||||||
@@ -15,7 +16,6 @@
|
|||||||
|
|
||||||
#include <QDesktopServices>
|
#include <QDesktopServices>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
//#include <QtNetwork>
|
|
||||||
#include <QNetworkAccessManager>
|
#include <QNetworkAccessManager>
|
||||||
#include <QNetworkReply>
|
#include <QNetworkReply>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
@@ -32,15 +32,38 @@ bool Toasts::isEnabled()
|
|||||||
|
|
||||||
void Toasts::sendChannelNotification(const QString &channelName, Platform p)
|
void Toasts::sendChannelNotification(const QString &channelName, Platform p)
|
||||||
{
|
{
|
||||||
|
// Fetch user profile avatar
|
||||||
|
if (p == Platform::Twitch) {
|
||||||
|
QFileInfo check_file(
|
||||||
|
QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) +
|
||||||
|
"2/cache/profileAvatars/twitch/" + channelName + ".png");
|
||||||
|
if (check_file.exists() && check_file.isFile()) {
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
|
this->sendWindowsNotification(channelName, p);
|
||||||
sendWindowsNotification(channelName, p);
|
|
||||||
return;
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
// OSX
|
// OSX
|
||||||
|
|
||||||
// LINUX
|
// LINUX
|
||||||
|
|
||||||
|
} else {
|
||||||
|
this->fetchChannelAvatar(
|
||||||
|
channelName, [this, channelName, p](QString avatarLink) {
|
||||||
|
DownloadManager *manager = new DownloadManager();
|
||||||
|
manager->setFile(avatarLink, channelName);
|
||||||
|
manager->connect(
|
||||||
|
manager, &DownloadManager::downloadComplete,
|
||||||
|
[this, channelName, p]() {
|
||||||
|
#ifdef Q_OS_WIN
|
||||||
|
this->sendWindowsNotification(channelName, p);
|
||||||
|
#endif
|
||||||
|
// OSX
|
||||||
|
|
||||||
|
// LINUX
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
@@ -84,29 +107,6 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
void Toasts::sendWindowsNotification(const QString &channelName, Platform p)
|
void Toasts::sendWindowsNotification(const QString &channelName, Platform p)
|
||||||
{
|
|
||||||
// Fetch user profile avatar
|
|
||||||
if (p == Platform::Twitch) {
|
|
||||||
QFileInfo check_file(
|
|
||||||
QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) +
|
|
||||||
"2/cache/profileAvatars/twitch/" + channelName + ".png");
|
|
||||||
if (check_file.exists() && check_file.isFile()) {
|
|
||||||
qDebug() << " OMEGA2NAM ";
|
|
||||||
this->sendActualWindowsNotification(channelName, p);
|
|
||||||
} else {
|
|
||||||
qDebug() << " OMEGA1NAM ";
|
|
||||||
this->fetchChannelAvatar(
|
|
||||||
channelName, [this, channelName, p](QString avatarLink) {
|
|
||||||
qDebug() << " OMEGANAM " << avatarLink;
|
|
||||||
this->sendActualWindowsNotification(channelName, p);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
qDebug() << " YOU'RE TOO SLOW! ";
|
|
||||||
}
|
|
||||||
|
|
||||||
void Toasts::sendActualWindowsNotification(const QString &channelName,
|
|
||||||
Platform p)
|
|
||||||
{
|
{
|
||||||
WinToastLib::WinToastTemplate templ = WinToastLib::WinToastTemplate(
|
WinToastLib::WinToastTemplate templ = WinToastLib::WinToastTemplate(
|
||||||
WinToastLib::WinToastTemplate::ImageAndText02);
|
WinToastLib::WinToastTemplate::ImageAndText02);
|
||||||
@@ -145,51 +145,7 @@ void Toasts::sendActualWindowsNotification(const QString &channelName,
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
/*
|
|
||||||
void Toasts::fetchChannelAvatar(const QString &channelName,
|
|
||||||
std::function<void(QString)> successCallback)
|
|
||||||
{
|
|
||||||
QString requestUrl("https://api.twitch.tv/kraken/users?login=" +
|
|
||||||
channelName);
|
|
||||||
NetworkRequest request(requestUrl, NetworkRequestType::Put);
|
|
||||||
request.setCaller(QThread::currentThread());
|
|
||||||
request.makeAuthorizedV5(getDefaultClientID());
|
|
||||||
request.setTimeout(30000);
|
|
||||||
request.onSuccess([successCallback](auto result) -> Outcome {
|
|
||||||
auto root = result.parseJson();
|
|
||||||
if (!root.value("users").isArray()) {
|
|
||||||
Log("API Error while getting user id, users is not an array");
|
|
||||||
successCallback("");
|
|
||||||
return Failure;
|
|
||||||
}
|
|
||||||
auto users = root.value("users").toArray();
|
|
||||||
if (users.size() != 1) {
|
|
||||||
Log("API Error while getting user id, users array size is not 1");
|
|
||||||
successCallback("");
|
|
||||||
return Failure;
|
|
||||||
}
|
|
||||||
if (!users[0].isObject()) {
|
|
||||||
Log("API Error while getting user id, first user is not an object");
|
|
||||||
successCallback("");
|
|
||||||
return Failure;
|
|
||||||
}
|
|
||||||
auto firstUser = users[0].toObject();
|
|
||||||
auto avatar = firstUser.value("logo");
|
|
||||||
if (!avatar.isString()) {
|
|
||||||
Log("API Error: while getting user logo, first user object `logo` "
|
|
||||||
"key "
|
|
||||||
"is not a "
|
|
||||||
"string");
|
|
||||||
successCallback("");
|
|
||||||
return Failure;
|
|
||||||
}
|
|
||||||
successCallback(avatar.toString());
|
|
||||||
return Success;
|
|
||||||
});
|
|
||||||
|
|
||||||
request.execute();
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
void Toasts::fetchChannelAvatar(const QString channelName,
|
void Toasts::fetchChannelAvatar(const QString channelName,
|
||||||
std::function<void(QString)> successCallback)
|
std::function<void(QString)> successCallback)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,13 +2,7 @@
|
|||||||
|
|
||||||
#include "Application.hpp"
|
#include "Application.hpp"
|
||||||
#include "common/Singleton.hpp"
|
#include "common/Singleton.hpp"
|
||||||
/*
|
|
||||||
#ifdef Q_OS_WIN
|
|
||||||
|
|
||||||
#include "wintoastlib.h"
|
|
||||||
|
|
||||||
#endif
|
|
||||||
*/
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
enum class Platform : uint8_t;
|
enum class Platform : uint8_t;
|
||||||
@@ -22,7 +16,6 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void sendWindowsNotification(const QString &channelName, Platform p);
|
void sendWindowsNotification(const QString &channelName, Platform p);
|
||||||
void sendActualWindowsNotification(const QString &channelName, Platform p);
|
|
||||||
static void fetchChannelAvatar(
|
static void fetchChannelAvatar(
|
||||||
const QString channelName,
|
const QString channelName,
|
||||||
std::function<void(QString)> successCallback);
|
std::function<void(QString)> successCallback);
|
||||||
|
|||||||
@@ -41,6 +41,9 @@ NotificationPage::NotificationPage()
|
|||||||
settings.append(
|
settings.append(
|
||||||
this->createCheckBox("Red dot next to live splits",
|
this->createCheckBox("Red dot next to live splits",
|
||||||
getApp()->settings->notificationDot));
|
getApp()->settings->notificationDot));
|
||||||
|
settings.append(this->createCheckBox(
|
||||||
|
"Change color of Splitheader (click to remove)",
|
||||||
|
getApp()->settings->notificationSplitheaderHighlight));
|
||||||
|
|
||||||
settings->addStretch(1);
|
settings->addStretch(1);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -549,7 +549,21 @@ void SplitHeader::themeChangedEvent()
|
|||||||
getApp()->resources->buttons.menuLight);
|
getApp()->resources->buttons.menuLight);
|
||||||
}
|
}
|
||||||
|
|
||||||
this->titleLabel->setPalette(palette);
|
// this->titleLabel->setPalette(palette);
|
||||||
|
auto darkPalette = palette;
|
||||||
|
darkPalette.setColor(QPalette::Window, QColor(53, 53, 53));
|
||||||
|
darkPalette.setColor(QPalette::WindowText, Qt::white);
|
||||||
|
darkPalette.setColor(QPalette::Base, QColor(25, 25, 25));
|
||||||
|
darkPalette.setColor(QPalette::AlternateBase, QColor(53, 53, 53));
|
||||||
|
darkPalette.setColor(QPalette::ToolTipBase, Qt::white);
|
||||||
|
darkPalette.setColor(QPalette::ToolTipText, Qt::white);
|
||||||
|
darkPalette.setColor(QPalette::Text, Qt::white);
|
||||||
|
darkPalette.setColor(QPalette::Button, QColor(53, 53, 53));
|
||||||
|
darkPalette.setColor(QPalette::ButtonText, Qt::white);
|
||||||
|
darkPalette.setColor(QPalette::BrightText, Qt::red);
|
||||||
|
darkPalette.setColor(QPalette::Link, QColor(42, 130, 218));
|
||||||
|
|
||||||
|
this->titleLabel->setPalette(darkPalette);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SplitHeader::menuMoveSplit()
|
void SplitHeader::menuMoveSplit()
|
||||||
|
|||||||
Reference in New Issue
Block a user