Skip to content

Commit

Permalink
Work with destructors
Browse files Browse the repository at this point in the history
  • Loading branch information
Vitozz committed May 15, 2024
1 parent 7e60d35 commit af7c543
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
6 changes: 6 additions & 0 deletions src/mainwin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,12 @@ MainWin::~MainWin()
delete d->tray;
d->tray = nullptr;
}
#ifdef USE_TASKBARNOTIFIER
if (d->taskBarNotifier) {
delete d->taskBarNotifier;
d->taskBarNotifier = nullptr;
}
#endif

saveToolbarsState();

Expand Down
14 changes: 7 additions & 7 deletions src/widgets/taskbarnotifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class TaskBarNotifier::Private {
void setIconCount(uint count = 0);
void restoreDefaultIcon();
#ifdef USE_DBUS
~Private() = default;
void setDesktopPath(const QString &appName);
#elif defined(Q_OS_WINDOWS)
~Private();
Expand Down Expand Up @@ -217,27 +218,24 @@ QImage TaskBarNotifier::Private::makeIconCaption(const QImage &image, const QStr
HICON TaskBarNotifier::Private::getHICONfromQImage(const QImage &image) const
{
if (image.isNull())
return nullptr;
return {};
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
auto p = QPixmap::fromImage(image);
return QtWin::toHICON(p);
#else
return image.toHICON();
#endif
return nullptr;
return {};
}

void TaskBarNotifier::Private::doFlashTaskbarIcon()
{
const int count = 0;
const int speed = 0;

FLASHWINFO fi;
fi.cbSize = sizeof(FLASHWINFO);
fi.hwnd = hwnd_;
fi.dwFlags = (urgent_) ? FLASHW_ALL | FLASHW_TIMER : FLASHW_STOP;
fi.uCount = count;
fi.dwTimeout = speed;
fi.uCount = 0;
fi.dwTimeout = 0;
FlashWindowEx(&fi);
}

Expand All @@ -256,6 +254,8 @@ TaskBarNotifier::TaskBarNotifier(QWidget *parent)
#endif
}

TaskBarNotifier::~TaskBarNotifier() = default;

void TaskBarNotifier::setIconCountCaption(uint count, const QImage &icon)
{
#ifdef Q_OS_WINDOWS
Expand Down
3 changes: 2 additions & 1 deletion src/widgets/taskbarnotifier.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ class QWidget;
class TaskBarNotifier {
public:
explicit TaskBarNotifier(QWidget *parent = nullptr);
void setIconCountCaption(uint count, const QImage &icon = QImage());
~TaskBarNotifier();
void setIconCountCaption(uint count, const QImage &icon = {});
void removeIconCountCaption();
bool isActive();

Expand Down

0 comments on commit af7c543

Please sign in to comment.