mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-24 12:08:50 +03:00
Try to make windows notifications prettier
This commit is contained in:
parent
791cb660b5
commit
4142703990
5 changed files with 35 additions and 12 deletions
|
@ -15,7 +15,7 @@ echo %DATE%
|
||||||
|
|
||||||
|
|
||||||
call "C:/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/VC/Auxiliary/Build/vcvarsall.bat" x64
|
call "C:/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/VC/Auxiliary/Build/vcvarsall.bat" x64
|
||||||
cmake -G "Visual Studio 17 2022" -A x64 -S. -Bbuild -DHUNTER_ROOT="C:\hunter" -DHUNTER_ENABLED=ON -DBUILD_SHARED_LIBS=OFF -DUSE_BUNDLED_OPENSSL=ON -DUSE_BUNDLED_KDSINGLEAPPLICATION=ON -DCMAKE_BUILD_TYPE=Release -DHUNTER_CONFIGURATION_TYPES=Release
|
cmake -G "Visual Studio 17 2022" -A x64 -S. -Bbuild -DHUNTER_ROOT="C:\hunter" -DHUNTER_ENABLED=ON -DBUILD_SHARED_LIBS=OFF -DUSE_BUNDLED_OPENSSL=ON -DUSE_BUNDLED_KDSINGLEAPPLICATION=ON -DKDSingleApplication_STATIC=ON -DCMAKE_BUILD_TYPE=Release -DHUNTER_CONFIGURATION_TYPES=Release
|
||||||
cmake --build build --config Release
|
cmake --build build --config Release
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -647,14 +647,14 @@ if(APPLE)
|
||||||
endif()
|
endif()
|
||||||
elseif(WIN32)
|
elseif(WIN32)
|
||||||
file(DOWNLOAD
|
file(DOWNLOAD
|
||||||
"https://raw.githubusercontent.com/mohabouje/WinToast/41ed1c58d5dce0ee9c01dbdeac05be45358d4f57/src/wintoastlib.cpp"
|
"https://raw.githubusercontent.com/mohabouje/WinToast/v1.3.0/src/wintoastlib.cpp"
|
||||||
${PROJECT_SOURCE_DIR}/src/wintoastlib.cpp
|
${PROJECT_SOURCE_DIR}/src/wintoastlib.cpp
|
||||||
EXPECTED_HASH SHA256=1A1A7CE41C1052B12946798F4A6C67CE1FAD209C967F5ED4D720B173527E2073)
|
EXPECTED_HASH SHA256=1ddf8ee2604e1757d383a2f60d4d597c4f5d9496369e6a22586cedf4af77ca8f)
|
||||||
|
|
||||||
file(DOWNLOAD
|
file(DOWNLOAD
|
||||||
"https://raw.githubusercontent.com/mohabouje/WinToast/41ed1c58d5dce0ee9c01dbdeac05be45358d4f57/src/wintoastlib.h"
|
"https://raw.githubusercontent.com/mohabouje/WinToast/v1.3.0/include/wintoastlib.h"
|
||||||
${PROJECT_SOURCE_DIR}/src/wintoastlib.h
|
${PROJECT_SOURCE_DIR}/src/wintoastlib.h
|
||||||
EXPECTED_HASH SHA256=b4481023c5782733795838be22bf1a75f45d87458cd4d9a5a75f664a146eea11)
|
EXPECTED_HASH SHA256=08cb30d28db9c851d3d4259ae6108ce7dafa966957df6735a06cd55e0716fded)
|
||||||
|
|
||||||
set(SRC_FILES ${SRC_FILES} src/notifications/ManagerWin.cpp src/wintoastlib.cpp src/wintoastlib.h)
|
set(SRC_FILES ${SRC_FILES} src/notifications/ManagerWin.cpp src/wintoastlib.cpp src/wintoastlib.h)
|
||||||
else()
|
else()
|
||||||
|
|
|
@ -93,8 +93,10 @@ public:
|
||||||
|
|
||||||
#if defined(Q_OS_WINDOWS)
|
#if defined(Q_OS_WINDOWS)
|
||||||
private:
|
private:
|
||||||
void
|
void systemPostNotification(const QString &line1,
|
||||||
systemPostNotification(const QString &line1, const QString &line2, const QString &iconPath);
|
const QString &line2,
|
||||||
|
const QString &iconPath,
|
||||||
|
const QString &bodyImagePath);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// these slots are platform specific (D-Bus only)
|
// these slots are platform specific (D-Bus only)
|
||||||
|
|
|
@ -114,7 +114,8 @@ NotificationsManager::postNotification(const mtx::responses::Notification ¬if
|
||||||
|
|
||||||
if (hasMarkup_) {
|
if (hasMarkup_) {
|
||||||
if (hasImages_ &&
|
if (hasImages_ &&
|
||||||
mtx::accessors::msg_type(notification.event) == mtx::events::MessageType::Image) {
|
(mtx::accessors::msg_type(notification.event) == mtx::events::MessageType::Image ||
|
||||||
|
mtx::accessors::msg_type(notification.event) == mtx::events::MessageType::Image)) {
|
||||||
MxcImageProvider::download(
|
MxcImageProvider::download(
|
||||||
QString::fromStdString(mtx::accessors::url(notification.event))
|
QString::fromStdString(mtx::accessors::url(notification.event))
|
||||||
.remove(QStringLiteral("mxc://")),
|
.remove(QStringLiteral("mxc://")),
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
|
|
||||||
#include "Cache.h"
|
#include "Cache.h"
|
||||||
#include "EventAccessors.h"
|
#include "EventAccessors.h"
|
||||||
|
#include "MxcImageProvider.h"
|
||||||
#include "Utils.h"
|
#include "Utils.h"
|
||||||
|
|
||||||
using namespace WinToastLib;
|
using namespace WinToastLib;
|
||||||
|
@ -34,9 +35,9 @@ init()
|
||||||
{
|
{
|
||||||
isInitialized = true;
|
isInitialized = true;
|
||||||
|
|
||||||
WinToast::instance()->setAppName(L"Nheko");
|
|
||||||
WinToast::instance()->setAppUserModelId(
|
WinToast::instance()->setAppUserModelId(
|
||||||
WinToast::configureAUMI(L"NhekoReborn", L"in.nheko.Nheko"));
|
WinToast::configureAUMI(L"NhekoReborn", L"in.nheko.Nheko"));
|
||||||
|
WinToast::instance()->setAppName(L"Nheko");
|
||||||
if (!WinToast::instance()->initialize())
|
if (!WinToast::instance()->initialize())
|
||||||
std::wcout << "Your system is not compatible with toast notifications\n";
|
std::wcout << "Your system is not compatible with toast notifications\n";
|
||||||
}
|
}
|
||||||
|
@ -61,20 +62,35 @@ NotificationsManager::postNotification(const mtx::responses::Notification ¬if
|
||||||
}
|
}
|
||||||
|
|
||||||
return template_.arg(utils::stripReplyFallbacks(notification.event, {}, {}).quoted_body);
|
return template_.arg(utils::stripReplyFallbacks(notification.event, {}, {}).quoted_body);
|
||||||
};
|
}();
|
||||||
|
|
||||||
auto iconPath = QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + room_name +
|
auto iconPath = QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + room_name +
|
||||||
"-room-avatar.png";
|
"-room-avatar.png";
|
||||||
if (!icon.save(iconPath))
|
if (!icon.save(iconPath))
|
||||||
iconPath.clear();
|
iconPath.clear();
|
||||||
|
|
||||||
systemPostNotification(room_name, formatNotification(), iconPath);
|
if (mtx::accessors::msg_type(notification.event) == mtx::events::MessageType::Image ||
|
||||||
|
mtx::accessors::msg_type(notification.event) == mtx::events::MessageType::Image) {
|
||||||
|
MxcImageProvider::download(
|
||||||
|
QString::fromStdString(mtx::accessors::url(notification.event))
|
||||||
|
.remove(QStringLiteral("mxc://")),
|
||||||
|
QSize(200, 80),
|
||||||
|
[this, room_name, formatNotification, iconPath](QString, QSize, QImage, QString imgPath) {
|
||||||
|
if (imgPath.isEmpty())
|
||||||
|
systemPostNotification(room_name, formatNotification, iconPath, "");
|
||||||
|
else
|
||||||
|
systemPostNotification(room_name, formatNotification, iconPath, imgPath);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
systemPostNotification(room_name, formatNotification, iconPath, "");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
NotificationsManager::systemPostNotification(const QString &line1,
|
NotificationsManager::systemPostNotification(const QString &line1,
|
||||||
const QString &line2,
|
const QString &line2,
|
||||||
const QString &iconPath)
|
const QString &iconPath,
|
||||||
|
const QString &bodyImagePath)
|
||||||
{
|
{
|
||||||
if (!isInitialized)
|
if (!isInitialized)
|
||||||
init();
|
init();
|
||||||
|
@ -85,6 +101,10 @@ NotificationsManager::systemPostNotification(const QString &line1,
|
||||||
|
|
||||||
if (!iconPath.isNull())
|
if (!iconPath.isNull())
|
||||||
templ.setImagePath(iconPath.toStdWString());
|
templ.setImagePath(iconPath.toStdWString());
|
||||||
|
if (!bodyImagePath.isNull())
|
||||||
|
templ.setHeroImagePath(bodyImagePath.toStdWString(), true);
|
||||||
|
|
||||||
|
templ.setAudioPath(WinToastTemplate::IM);
|
||||||
|
|
||||||
WinToast::instance()->showToast(templ, new CustomHandler());
|
WinToast::instance()->showToast(templ, new CustomHandler());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue