fixed toasts for all platforms

This commit is contained in:
apa420 2018-08-29 23:39:02 +02:00
parent 01ca055763
commit 5555c41d7e
4 changed files with 13 additions and 7 deletions

View file

@ -1,6 +1,9 @@
#include "DownloadManager.hpp" #include "DownloadManager.hpp"
#include "singletons/Paths.hpp"
#include <QDesktopServices> #include <QDesktopServices>
#include <QDir>
namespace chatterino { namespace chatterino {
@ -20,10 +23,8 @@ void DownloadManager::setFile(QString fileURL, const QString &channelName)
QString filePath = fileURL; QString filePath = fileURL;
QString saveFilePath; QString saveFilePath;
QStringList filePathList = filePath.split('/'); QStringList filePathList = filePath.split('/');
saveFilePath = QString( saveFilePath =
QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + getPaths()->twitchProfileAvatars + "/twitch/" + channelName + ".png";
"2/cache/profileAvatars/twitch/" + channelName + ".png");
QNetworkRequest request; QNetworkRequest request;
request.setUrl(QUrl(fileURL)); request.setUrl(QUrl(fileURL));
reply = manager->get(request); reply = manager->get(request);

View file

@ -130,6 +130,8 @@ void Paths::initSubDirectories()
this->cacheDirectory_ = makePath("Cache"); this->cacheDirectory_ = makePath("Cache");
this->messageLogDirectory = makePath("Logs"); this->messageLogDirectory = makePath("Logs");
this->miscDirectory = makePath("Misc"); this->miscDirectory = makePath("Misc");
this->twitchProfileAvatars = makePath("ProfileAvatars");
QDir().mkdir(this->twitchProfileAvatars + "/twitch");
} }
Paths *getPaths() Paths *getPaths()

View file

@ -28,6 +28,9 @@ public:
// Hash of QCoreApplication::applicationFilePath() // Hash of QCoreApplication::applicationFilePath()
QString applicationFilePathHash; QString applicationFilePathHash;
// Profile avatars for twitch <appDataDirectory>/cache/twitch
QString twitchProfileAvatars;
bool createFolder(const QString &folderPath); bool createFolder(const QString &folderPath);
bool isPortable(); bool isPortable();

View file

@ -105,7 +105,7 @@ public:
void Toasts::sendWindowsNotification(const QString &channelName, Platform p) void Toasts::sendWindowsNotification(const QString &channelName, Platform p)
{ {
WinToastLib::WinToastTemplate templ = WinToastLib::WinToastTemplate( WinToastLib::WinToastTemplate templ = WinToastLib::WinToastTemplate(
WinToastLib::WinToastTemplate::ImageAndText02); WinToastLib::WinToastTemplate::ImageAndText03);
QString str = channelName + " is live!"; QString str = channelName + " is live!";
std::string utf8_text = str.toUtf8().constData(); std::string utf8_text = str.toUtf8().constData();
std::wstring widestr = std::wstring(utf8_text.begin(), utf8_text.end()); std::wstring widestr = std::wstring(utf8_text.begin(), utf8_text.end());
@ -115,8 +115,8 @@ void Toasts::sendWindowsNotification(const QString &channelName, Platform p)
WinToastLib::WinToastTemplate::SecondLine); WinToastLib::WinToastTemplate::SecondLine);
QString Path; QString Path;
if (p == Platform::Twitch) { if (p == Platform::Twitch) {
Path = Path = getPaths()->cacheDirectory() + "/" + Path = getPaths()->twitchProfileAvatars + "/twitch/" + channelName +
"profileAvatars/twitch/" + channelName + ".png"; ".png";
} }
std::string temp_Utf8 = Path.toUtf8().constData(); std::string temp_Utf8 = Path.toUtf8().constData();
std::wstring imagePath = std::wstring(temp_Utf8.begin(), temp_Utf8.end()); std::wstring imagePath = std::wstring(temp_Utf8.begin(), temp_Utf8.end());