Skip to content

Commit

Permalink
Fixed build with Windows OS
Browse files Browse the repository at this point in the history
  • Loading branch information
Vitozz committed May 17, 2024
1 parent fdda4a8 commit 3ab9c28
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions src/widgets/taskbarnotifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,37 +72,41 @@ class TaskBarNotifier::Private {
void setDesktopPath(const QString &appName);
#endif
private:
QIcon setImageCountCaption(uint count = 0);
#ifdef USE_DBUS
bool checkDBusSeviceAvailable();
void sendDBusSignal(bool isVisible, uint number = 0);
#elif defined(Q_OS_WIN)
#ifdef Q_OS_WIN
void setTaskBarIcon(const HICON &icon = {});
HICON makeIconCaption(const QString &number) const;
HICON getHICONfromQImage(const QImage &image) const;
void doFlashTaskbarIcon();
#else
QIcon setImageCountCaption(uint count = 0);
#ifdef USE_DBUS
bool checkDBusSeviceAvailable();
void sendDBusSignal(bool isVisible, uint number = 0);
#endif
#endif

private:
bool urgent_ = false;
bool active_ = false;
QWidget *parent_;
QImage *image_;
int devicePixelRatio_;
#ifdef Q_OS_WIN
HWND hwnd_;
HICON icon_;
#else
QImage *image_;
#endif
int devicePixelRatio_;
};

TaskBarNotifier::Private::~Private()
{
#ifdef Q_OS_WIN
if (icon_)
DestroyIcon(icon_);
#endif
#else
if (image_)
delete image_;
#endif
}

bool TaskBarNotifier::Private::active() const { return active_; }
Expand Down Expand Up @@ -145,13 +149,15 @@ void TaskBarNotifier::Private::restoreDefaultIcon()
void TaskBarNotifier::Private::setParent(QWidget *parent)
{
parent_ = parent;
image_ = new QImage(parent->windowIcon().pixmap({ 128, 128 }).toImage());
devicePixelRatio_ = parent->devicePixelRatio();
#ifdef Q_OS_WIN
hwnd_ = reinterpret_cast<HWND>(parent->winId()));
hwnd_ = reinterpret_cast<HWND>(parent->winId());
#else
image_ = new QImage(parent->windowIcon().pixmap({ 128, 128 }).toImage());
#endif
}

#ifndef Q_OS_WIN
QIcon TaskBarNotifier::Private::setImageCountCaption(uint count)
{
auto imSize = image_->size() * devicePixelRatio_;
Expand Down Expand Up @@ -184,6 +190,7 @@ QIcon TaskBarNotifier::Private::setImageCountCaption(uint count)
p.end();
return QIcon(QPixmap::fromImage(img));
}
#endif

#ifdef USE_DBUS
bool TaskBarNotifier::Private::checkDBusSeviceAvailable()
Expand Down

0 comments on commit 3ab9c28

Please sign in to comment.