Advertisement
KukuRuzo

psi patch

Apr 27th, 2024 (edited)
800
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 10.25 KB | None | 0 0
  1. diff --git a/src/mainwin.cpp b/src/mainwin.cpp
  2. index 1b2a8897..f4b26f6c 100644
  3. --- a/src/mainwin.cpp
  4. +++ b/src/mainwin.cpp
  5. @@ -70,9 +70,6 @@
  6.  #include <QVBoxLayout>
  7.  #include <QtAlgorithms>
  8.  #ifdef Q_OS_WIN
  9. -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
  10. -#include "widgets/thumbnailtoolbar.h"
  11. -#endif
  12.  #include <windows.h>
  13.  #endif
  14.  #ifdef HAVE_X11
  15. @@ -158,9 +155,6 @@ public:
  16.  
  17.  #ifdef Q_OS_WIN
  18.      DWORD deactivationTickCount;
  19. -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
  20. -    QPointer<PsiThumbnailToolBar> thumbnailToolBar_;
  21. -#endif
  22.  #endif
  23.  
  24.      void        registerActions();
  25. @@ -533,10 +527,6 @@ MainWin::MainWin(bool _onTop, bool _asTool, PsiCon *psi) :
  26.      });
  27.      d->eventNotifier->hide();
  28.  
  29. -#if defined(Q_OS_WIN) && QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
  30. -    updateWinTaskbar(_asTool);
  31. -#endif
  32. -
  33.      connect(qApp, SIGNAL(dockActivated()), SLOT(dockActivated()));
  34.      qApp->installEventFilter(this);
  35.  
  36. @@ -742,9 +732,6 @@ void MainWin::setWindowOpts(bool _onTop, bool _asTool)
  37.  
  38.      setWindowFlags(flags);
  39.      show();
  40. -#if defined(Q_OS_WIN) && QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
  41. -    updateWinTaskbar(_asTool);
  42. -#endif
  43.  }
  44.  
  45.  void MainWin::setUseDock(bool use)
  46. @@ -1363,6 +1350,10 @@ void MainWin::closeEvent(QCloseEvent *e)
  47.          trayHide();
  48.          e->ignore();
  49.          return;
  50. +    } else if (!quitOnClose) { //Minimize window to taskbar if there is no trayicon and quit-on-close option is disabled
  51. +        setWindowState(windowState() | Qt::WindowMinimized);
  52. +        e->ignore();
  53. +        return;
  54.      }
  55.  
  56.      if (!askQuit()) {
  57. @@ -1465,30 +1456,6 @@ bool MainWin::nativeEvent(const QByteArray &eventType, MSG *msg, long *result)
  58.      }
  59.      return false;
  60.  }
  61. -
  62. -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
  63. -void MainWin::updateWinTaskbar(bool enabled)
  64. -{
  65. -    if (!enabled) {
  66. -        if (!d->thumbnailToolBar_) {
  67. -            d->thumbnailToolBar_ = new PsiThumbnailToolBar(this, windowHandle());
  68. -            connect(d->thumbnailToolBar_, &PsiThumbnailToolBar::openOptions, this, &MainWin::doOptions);
  69. -            connect(d->thumbnailToolBar_, &PsiThumbnailToolBar::setOnline, this,
  70. -                    [this]() { d->getAction("status_online")->trigger(); });
  71. -            connect(d->thumbnailToolBar_, &PsiThumbnailToolBar::setOffline, this,
  72. -                    [this]() { d->getAction("status_offline")->trigger(); });
  73. -            connect(d->thumbnailToolBar_, &PsiThumbnailToolBar::runActiveEvent, this, &MainWin::doRecvNextEvent);
  74. -            connect(d->psi->contactList(), &PsiContactList::queueChanged, this, [this]() {
  75. -                d->thumbnailToolBar_->updateToolBar(d->nextAmount > 0);
  76. -                if (!isActiveWindow() && d->allInOne)
  77. -                    qApp->alert(this, 0);
  78. -            });
  79. -        }
  80. -    } else {
  81. -        delete d->thumbnailToolBar_;
  82. -    }
  83. -}
  84. -#endif
  85.  #endif
  86.  
  87.  void MainWin::updateCaption()
  88. @@ -1645,12 +1612,21 @@ void MainWin::updateReadNext(PsiIcon *anim, int amount)
  89.          d->eventNotifier->hide();
  90.          d->eventNotifier->setText("");
  91.          d->eventNotifier->setPsiIcon("");
  92. +        if(d->allInOne) // set window header icon accordig to status
  93. +            setWindowIcon(PsiIconset::instance()->statusPtr(d->lastStatus)->icon());
  94.      } else {
  95.          d->eventNotifier->setPsiIcon(anim);
  96.          d->eventNotifier->setText(QString("<b>") + numEventsString(d->nextAmount) + "</b>");
  97.          d->eventNotifier->show();
  98.          // make sure it shows
  99.          // qApp->processEvents();
  100. +        // Hack. If All-in-one mode is enabled there is no reacton on incoming events
  101. +        // so we have to flash taskbar icon by qApp->alert
  102. +        // and change window header icon according to status
  103. +        if(d->allInOne) {
  104. +            setWindowIcon(anim->icon());
  105. +            qApp->alert(this, 0);
  106. +        }
  107.      }
  108.  
  109.      updateTray();
  110. diff --git a/src/mainwin.h b/src/mainwin.h
  111. index e5a104ff..fe61532d 100644
  112. --- a/src/mainwin.h
  113. +++ b/src/mainwin.h
  114. @@ -189,10 +189,6 @@ private:
  115.  
  116.      void buildStatusMenu(GlobalStatusMenu *statusMenu);
  117.  
  118. -#if defined(Q_OS_WIN) && QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
  119. -    void updateWinTaskbar(bool enabled);
  120. -#endif
  121. -
  122.  private:
  123.      class Private;
  124.      Private *d;
  125. diff --git a/src/options/opt_application.cpp b/src/options/opt_application.cpp
  126. index 618252cb..d8459cba 100644
  127. --- a/src/options/opt_application.cpp
  128. +++ b/src/options/opt_application.cpp
  129. @@ -272,7 +272,7 @@ void OptionsTabApplication::doEnableQuitOnClose(Qt::CheckState state)
  130.      const auto enabled = state != Qt::Unchecked;
  131.  #endif
  132.      OptApplicationUI *d = static_cast<OptApplicationUI *>(w);
  133. -    d->ck_quitOnClose->setEnabled(enabled);
  134. +    //d->ck_quitOnClose->setEnabled(enabled);
  135.      d->ck_dockToolMW->setEnabled(enabled);
  136.  #ifdef Q_OS_WIN
  137.      d->ck_dockDCstyle->setEnabled(enabled);
  138. diff --git a/src/widgets/CMakeLists.txt b/src/widgets/CMakeLists.txt
  139. index 06436cb4..28de63ab 100644
  140. --- a/src/widgets/CMakeLists.txt
  141. +++ b/src/widgets/CMakeLists.txt
  142. @@ -62,19 +62,6 @@ set(HEADERS
  143.      stretchwidget.h
  144.  )
  145.  
  146. -if(WIN32 AND (${QT_DEFAULT_MAJOR_VERSION} LESS_EQUAL 5))
  147. -    find_package(Qt${QT_DEFAULT_MAJOR_VERSION} COMPONENTS WinExtras REQUIRED)
  148. -    list(APPEND QT_LIBRARIES
  149. -        Qt${QT_DEFAULT_MAJOR_VERSION}::WinExtras
  150. -    )
  151. -    list(APPEND SOURCES
  152. -        thumbnailtoolbar.cpp
  153. -    )
  154. -    list(APPEND HEADERS
  155. -        thumbnailtoolbar.h
  156. -    )
  157. -endif()
  158. -
  159.  set(FORMS
  160.      fancypopup.ui
  161.      grepshortcutkeydialog.ui
  162. diff --git a/src/widgets/thumbnailtoolbar.cpp b/src/widgets/thumbnailtoolbar.cpp
  163. deleted file mode 100644
  164. index ae83f143..00000000
  165. --- a/src/widgets/thumbnailtoolbar.cpp
  166. +++ /dev/null
  167. @@ -1,64 +0,0 @@
  168. -/*
  169. - * thumbnailtoolbar.cpp - Thumbnail Toolbar Widget
  170. - * Copyright (C) 2021  Vitaly Tonkacheyev
  171. - *
  172. - * This library is free software; you can redistribute it and/or
  173. - * modify it under the terms of the GNU Lesser General Public
  174. - * License as published by the Free Software Foundation; either
  175. - * version 2.1 of the License, or (at your option) any later version.
  176. - *
  177. - * This library is distributed in the hope that it will be useful,
  178. - * but WITHOUT ANY WARRANTY; without even the implied warranty of
  179. - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  180. - * Lesser General Public License for more details.
  181. - *
  182. - * You should have received a copy of the GNU Lesser General Public License
  183. - * along with this program.  If not, see <https://www.gnu.org/licenses/>.
  184. - *
  185. - */
  186. -
  187. -#include "thumbnailtoolbar.h"
  188. -#include "iconset.h"
  189. -
  190. -#include <QWinThumbnailToolButton>
  191. -#include <QWindow>
  192. -
  193. -PsiThumbnailToolBar::PsiThumbnailToolBar(QObject *parent, QWindow *parentWindow) :
  194. -    QWinThumbnailToolBar(parent), optionsBtn_(new QWinThumbnailToolButton(this)),
  195. -    onlineStatusBtn_(new QWinThumbnailToolButton(this)), offlineStatusBtn_(new QWinThumbnailToolButton(this)),
  196. -    eventsBtn_(new QWinThumbnailToolButton(this)), taskbarBtn_(new QWinTaskbarButton(this))
  197. -{
  198. -    // ToolTips
  199. -    optionsBtn_->setToolTip(tr("Options"));
  200. -    onlineStatusBtn_->setToolTip(tr("Online"));
  201. -    offlineStatusBtn_->setToolTip(tr("Offline"));
  202. -    eventsBtn_->setToolTip(tr("Show Next Event"));
  203. -    // Icons
  204. -    optionsBtn_->setIcon(IconsetFactory::iconPtr("psi/options")->icon());
  205. -    onlineStatusBtn_->setIcon(IconsetFactory::iconPtr("status/online")->icon());
  206. -    offlineStatusBtn_->setIcon(IconsetFactory::iconPtr("status/offline")->icon());
  207. -    eventsBtn_->setIcon(IconsetFactory::iconPtr("psi/events")->icon());
  208. -    // Set dismiss
  209. -    optionsBtn_->setDismissOnClick(true);
  210. -    onlineStatusBtn_->setDismissOnClick(true);
  211. -    offlineStatusBtn_->setDismissOnClick(true);
  212. -    eventsBtn_->setDismissOnClick(true);
  213. -
  214. -    updateToolBar(false);
  215. -
  216. -    connect(optionsBtn_, &QWinThumbnailToolButton::clicked, this, &PsiThumbnailToolBar::openOptions);
  217. -    connect(onlineStatusBtn_, &QWinThumbnailToolButton::clicked, this, &PsiThumbnailToolBar::setOnline);
  218. -    connect(offlineStatusBtn_, &QWinThumbnailToolButton::clicked, this, &PsiThumbnailToolBar::setOffline);
  219. -    connect(eventsBtn_, &QWinThumbnailToolButton::clicked, this, [this]() {
  220. -        if (eventsBtn_->isEnabled())
  221. -            emit runActiveEvent();
  222. -    });
  223. -    addButton(eventsBtn_);
  224. -    addButton(onlineStatusBtn_);
  225. -    addButton(offlineStatusBtn_);
  226. -    addButton(optionsBtn_);
  227. -    setWindow(parentWindow);
  228. -    taskbarBtn_->setWindow(parentWindow);
  229. -}
  230. -
  231. -void PsiThumbnailToolBar::updateToolBar(bool hasEvents) { eventsBtn_->setEnabled(hasEvents); }
  232. diff --git a/src/widgets/thumbnailtoolbar.h b/src/widgets/thumbnailtoolbar.h
  233. deleted file mode 100644
  234. index d3ae87f8..00000000
  235. --- a/src/widgets/thumbnailtoolbar.h
  236. +++ /dev/null
  237. @@ -1,47 +0,0 @@
  238. -/*
  239. - * thumbnailtoolbar.h - Thumbnail Toolbar Widget
  240. - * Copyright (C) 2021  Vitaly Tonkacheyev
  241. - *
  242. - * This library is free software; you can redistribute it and/or
  243. - * modify it under the terms of the GNU Lesser General Public
  244. - * License as published by the Free Software Foundation; either
  245. - * version 2.1 of the License, or (at your option) any later version.
  246. - *
  247. - * This library is distributed in the hope that it will be useful,
  248. - * but WITHOUT ANY WARRANTY; without even the implied warranty of
  249. - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  250. - * Lesser General Public License for more details.
  251. - *
  252. - * You should have received a copy of the GNU Lesser General Public License
  253. - * along with this program.  If not, see <https://www.gnu.org/licenses/>.
  254. - *
  255. - */
  256. -#ifndef THUMBNAIL_TOOLBAR_H
  257. -#define THUMBNAIL_TOOLBAR_H
  258. -
  259. -#include <QObject>
  260. -#include <QWinTaskbarButton>
  261. -#include <QWinThumbnailToolBar>
  262. -
  263. -class QWindow;
  264. -
  265. -class PsiThumbnailToolBar : public QWinThumbnailToolBar {
  266. -    Q_OBJECT
  267. -public:
  268. -    explicit PsiThumbnailToolBar(QObject *parent = 0, QWindow *parentWindow = 0);
  269. -    void updateToolBar(bool hasEvents);
  270. -
  271. -signals:
  272. -    void openOptions();
  273. -    void setOnline();
  274. -    void setOffline();
  275. -    void runActiveEvent();
  276. -
  277. -private:
  278. -    QWinThumbnailToolButton *optionsBtn_;
  279. -    QWinThumbnailToolButton *onlineStatusBtn_;
  280. -    QWinThumbnailToolButton *offlineStatusBtn_;
  281. -    QWinThumbnailToolButton *eventsBtn_;
  282. -    QWinTaskbarButton       *taskbarBtn_;
  283. -};
  284. -#endif // THUMBNAIL_TOOLBAR_H
  285.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement