Advertisement
KukuRuzo

fix win flash

May 30th, 2024
649
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.25 KB | None | 0 0
  1.  
  2.  
  3. diff --git a/src/mainwin.cpp b/src/mainwin.cpp
  4. index 29a96a49..0ddd8b93 100644
  5. --- a/src/mainwin.cpp
  6. +++ b/src/mainwin.cpp
  7. @@ -551,6 +551,7 @@ MainWin::MainWin(bool _onTop, bool _asTool, PsiCon *psi) :
  8.      reinitAutoHide();
  9.  #ifdef USE_TASKBARNOTIFIER
  10.      d->taskBarNotifier = new TaskBarNotifier(this);
  11. +    d->taskBarNotifier->enableFlashWindow(d->allInOne && PsiOptions::instance()->getOption("options.ui.flash-windows").toBool());
  12.  #endif
  13.  }
  14.  
  15. @@ -589,10 +590,12 @@ void MainWin::optionChanged(const QString &option)
  16.      if (option == toolbarsStateOptionPath) {
  17.          loadToolbarsState();
  18.      } else if (option == "options.ui.contactlist.css") {
  19. -        const QString css = PsiOptions::instance()->getOption("options.ui.contactlist.css").toString();
  20. +        const QString css = PsiOptions::instance()->getOption(option).toString();
  21.          if (!css.isEmpty()) {
  22.              setStyleSheet(css);
  23.          }
  24. +    } else if (d->allInOne && option == "options.ui.flash-windows") {
  25. +        d->taskBarNotifier->enableFlashWindow(PsiOptions::instance()->getOption(option).toBool());
  26.      }
  27.  }
  28.  
  29. diff --git a/src/widgets/taskbarnotifier.cpp b/src/widgets/taskbarnotifier.cpp
  30. index 908d7173..2343492e 100644
  31. --- a/src/widgets/taskbarnotifier.cpp
  32. +++ b/src/widgets/taskbarnotifier.cpp
  33. @@ -71,6 +71,9 @@ public:
  34.  #ifdef USE_DBUS
  35.      void setDesktopPath(const QString &appName);
  36.  #endif
  37. +#ifdef Q_OS_WIN
  38. +    void setFlashWindow(bool enabled);
  39. +#endif
  40.  private:
  41.  #ifdef Q_OS_WIN
  42.      void  setTaskBarIcon(const HICON &icon = {});
  43. @@ -92,6 +95,7 @@ private:
  44.  #ifdef Q_OS_WIN
  45.      HWND  hwnd_;
  46.      HICON icon_;
  47. +    bool flashWindow_ = false;
  48.  #else
  49.      QImage *image_;
  50.  #endif
  51. @@ -222,6 +226,11 @@ void TaskBarNotifier::Private::sendDBusSignal(bool isVisible, uint number)
  52.  }
  53.  
  54.  #elif defined(Q_OS_WIN)
  55. +void TaskBarNotifier::Private::setFlashWindow(bool enabled)
  56. +{
  57. +    flashWindow_ = enabled;
  58. +}
  59. +
  60.  void TaskBarNotifier::Private::setTaskBarIcon(const HICON &icon)
  61.  {
  62.      if (icon_)
  63. @@ -286,7 +295,10 @@ void TaskBarNotifier::Private::doFlashTaskbarIcon()
  64.      FLASHWINFO fi;
  65.      fi.cbSize    = sizeof(FLASHWINFO);
  66.      fi.hwnd      = hwnd_;
  67. -    fi.dwFlags   = (urgent_) ? FLASHW_ALL | FLASHW_TIMER : FLASHW_STOP;
  68. +    if(urgent_)
  69. +        fi.dwFlags   = ((flashWindow_) ? FLASHW_ALL : FLASHW_TRAY) | FLASHW_TIMER;
  70. +    else
  71. +        fi.dwFlags   = FLASHW_STOP;
  72.      fi.uCount    = 0;
  73.      fi.dwTimeout = 0;
  74.      FlashWindowEx(&fi);
  75. @@ -306,3 +318,13 @@ void TaskBarNotifier::setIconCountCaption(int count) { d->setIconCount(count); }
  76.  void TaskBarNotifier::removeIconCountCaption() { d->restoreDefaultIcon(); }
  77.  
  78.  bool TaskBarNotifier::isActive() { return d->active(); }
  79. +
  80. +void TaskBarNotifier::enableFlashWindow(bool enabled)
  81. +{
  82. +#ifdef Q_OS_WIN
  83. +    if(d)
  84. +        d->setFlashWindow(enabled);
  85. +#else
  86. +    Q_UNUSED(enabled);
  87. +#endif
  88. +}
  89. diff --git a/src/widgets/taskbarnotifier.h b/src/widgets/taskbarnotifier.h
  90. index 11525360..6312970c 100644
  91. --- a/src/widgets/taskbarnotifier.h
  92. +++ b/src/widgets/taskbarnotifier.h
  93. @@ -31,6 +31,7 @@ public:
  94.      void setIconCountCaption(int count);
  95.      void removeIconCountCaption();
  96.      bool isActive();
  97. +    void enableFlashWindow(bool enabled);
  98.  
  99.  private:
  100.      class Private;
  101.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement