diff --git a/app/app.pro b/app/app.pro index 6a317d17..708f2a64 100644 --- a/app/app.pro +++ b/app/app.pro @@ -1,4 +1,4 @@ -QT += core quick network quickcontrols2 +QT += core quick network quickcontrols2 svg CONFIG += c++11 unix:!macx { diff --git a/app/streaming/session.cpp b/app/streaming/session.cpp index f8ea6f8b..5819dc1a 100644 --- a/app/streaming/session.cpp +++ b/app/streaming/session.cpp @@ -19,11 +19,16 @@ #define SDL_OS_FULLSCREEN_FLAG SDL_WINDOW_FULLSCREEN #endif +#define ICON_SIZE 32 + #include #include #include #include +#include +#include +#include CONNECTION_LISTENER_CALLBACKS Session::k_ConnCallbacks = { Session::clStageStarting, @@ -615,6 +620,25 @@ void Session::exec() SDL_SetWindowSize(m_Window, width, height); } + QSvgRenderer svgIconRenderer(QString(":/res/moonlight.svg")); + QImage svgImage(ICON_SIZE, ICON_SIZE, QImage::Format_RGBA8888); + svgImage.fill(0); + + QPainter svgPainter(&svgImage); + svgIconRenderer.render(&svgPainter); + SDL_Surface* iconSurface = SDL_CreateRGBSurfaceWithFormatFrom((void*)svgImage.constBits(), + svgImage.width(), + svgImage.height(), + 32, + 4 * svgImage.width(), + SDL_PIXELFORMAT_RGBA32); +#ifdef Q_OS_WIN32 + // Other platforms seem to preserve our Qt icon when creating a new window + if (iconSurface != nullptr) { + SDL_SetWindowIcon(m_Window, iconSurface); + } +#endif + #ifndef QT_DEBUG // Capture the mouse by default on release builds only. // This prevents the mouse from becoming trapped inside @@ -741,6 +765,9 @@ DispatchDeferredCleanup: SDL_AtomicUnlock(&m_DecoderLock); SDL_DestroyWindow(m_Window); + if (iconSurface != nullptr) { + SDL_FreeSurface(iconSurface); + } SDL_QuitSubSystem(SDL_INIT_VIDEO); SDL_assert(!SDL_WasInit(SDL_INIT_VIDEO));