• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

IJHack / QtPass / 25827655541

13 May 2026 09:32PM UTC coverage: 29.068% (-0.02%) from 29.083%
25827655541

push

github

web-flow
cleanup: drop AS_CONST macro + qApp deprecation pragmas (#1472)

Two small mechanical refactors that simplify the source without
changing behaviour.

(a) AS_CONST macro removal
--------------------------

src/helpers.h defined a single macro:

    #if __cplusplus >= 201703L
    #  define AS_CONST(x) std::as_const(x)
    #else
    #  define AS_CONST(x) qAsConst(x)
    #endif

The whole repo now requires C++17 (src/src.pro and tests/tests.pri both
say c++17; CLAUDE.md states "this repository enforces C++17 for all
builds"), so the macro is just an alias for std::as_const. It was used
in two places — switch them to std::as_const directly and delete
helpers.h. Also drop the now-unused #include "helpers.h" from
passworddialog.cpp (it had never used the macro).

(b) qApp deprecation pragmas
----------------------------

Two call sites used the qApp macro inside `#pragma GCC diagnostic
ignored "-Wdeprecated-declarations"` blocks (qApp is deprecated in Qt
6.0+). Replace qApp with QApplication::instance() so the deprecation
warning has nothing to fire on, and remove the surrounding pragma
push/pop blocks (~12 lines) — including the MSVC `#pragma warning`
variants.

No functional change. Tests:
- tst_util: 124/124
- tst_storemodel: 33/33
- tst_filecontent: 21/21
- doxygen: zero warnings from our code

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

1 of 5 new or added lines in 4 files covered. (20.0%)

3 existing lines in 2 files now uncovered.

1956 of 6729 relevant lines covered (29.07%)

26.91 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/trayicon.cpp
1
// SPDX-FileCopyrightText: 2015 Anne Jan Brouwer
2
// SPDX-License-Identifier: GPL-3.0-or-later
3
#include "trayicon.h"
4
#include <QAction>
5
#include <QApplication>
6
#include <QMainWindow>
7
#include <QMenu>
8

9
#ifdef QT_DEBUG
10
#include "debughelper.h"
11
#endif
12

13
/**
14
 * @brief TrayIcon::TrayIcon use a (system) tray icon with a nice QtPass logo on
15
 * it (currently) only Quits.
16
 * @param parent
17
 */
18
TrayIcon::TrayIcon(QMainWindow *parent) {
×
19
  parentwin = parent;
×
20

21
  if (QSystemTrayIcon::isSystemTrayAvailable()) {
×
22
    createActions();
×
23
    createTrayIcon();
×
24

25
    sysTrayIcon->setIcon(
×
26
        QIcon::fromTheme("qtpass-tray", QIcon(":/artwork/icon.png")));
×
27

28
    sysTrayIcon->show();
×
29

30
    QObject::connect(sysTrayIcon, &QSystemTrayIcon::activated, this,
×
31
                     &TrayIcon::iconActivated);
×
32

33
    isAllocated = true;
×
34
  }
35
#ifdef QT_DEBUG
36
  // NOLINTNEXTLINE(readability/braces)
37
  else {
38
    dbg() << "No tray icon for this OS possibly also not show options?";
39
  }
40
#endif
41
}
×
42

43
/**
44
 * @brief TrayIcon::getIsAllocated return if TrayIcon is allocated
45
 */
46
auto TrayIcon::getIsAllocated() -> bool { return isAllocated; }
×
47

48
/**
49
 * @brief TrayIcon::createActions setup the signals.
50
 */
51
void TrayIcon::createActions() {
×
52
  showAction = new QAction(tr("&Show"), this);
×
53
  connect(showAction, &QAction::triggered, parentwin, &QWidget::show);
×
54
  hideAction = new QAction(tr("&Hide"), this);
×
55
  connect(hideAction, &QAction::triggered, parentwin, &QWidget::hide);
×
56

57
  minimizeAction = new QAction(tr("Mi&nimize"), this);
×
58
  connect(minimizeAction, &QAction::triggered, parentwin,
×
59
          &QWidget::showMinimized);
×
60
  maximizeAction = new QAction(tr("Ma&ximize"), this);
×
61
  connect(maximizeAction, &QAction::triggered, parentwin,
×
62
          &QWidget::showMaximized);
×
63
  restoreAction = new QAction(tr("&Restore"), this);
×
64
  connect(restoreAction, &QAction::triggered, parentwin, &QWidget::showNormal);
×
65

66
  quitAction = new QAction(tr("&Quit"), this);
×
NEW
67
  connect(quitAction, &QAction::triggered, QApplication::instance(),
×
NEW
68
          &QApplication::quit);
×
UNCOV
69
}
×
70

71
/**
72
 * @brief TrayIcon::createTrayIcon set up menu.
73
 */
74
void TrayIcon::createTrayIcon() {
×
75
  trayIconMenu = new QMenu(this);
×
76
  trayIconMenu->addAction(showAction);
×
77
  trayIconMenu->addAction(hideAction);
×
78
  trayIconMenu->addAction(minimizeAction);
×
79
  trayIconMenu->addAction(maximizeAction);
×
80
  trayIconMenu->addAction(restoreAction);
×
81
  trayIconMenu->addSeparator();
×
82
  trayIconMenu->addAction(quitAction);
×
83

84
  sysTrayIcon = new QSystemTrayIcon(this);
×
85
  sysTrayIcon->setContextMenu(trayIconMenu);
×
86
}
×
87

88
/**
89
 * @brief TrayIcon::showHideParent toggle app visibility.
90
 */
91
void TrayIcon::showHideParent() {
×
92
  if (parentwin->isVisible()) {
×
93
    parentwin->hide();
×
94
  } else {
95
    parentwin->show();
×
96
  }
97
}
×
98

99
/**
100
 * @brief TrayIcon::iconActivated you clicked on the trayicon.
101
 * @param reason
102
 */
103
void TrayIcon::iconActivated(QSystemTrayIcon::ActivationReason reason) {
×
104
  switch (reason) {
×
105
  case QSystemTrayIcon::Trigger:
×
106
  case QSystemTrayIcon::DoubleClick:
107
    showHideParent();
×
108
    break;
×
109
  case QSystemTrayIcon::MiddleClick:
×
110
    showMessage("test", "test msg", 1000);
×
111
    break;
×
112
  default: {
×
113
  }
114
  }
115
}
×
116

117
/**
118
 * @brief TrayIcon::showMessage show a systray message for notification.
119
 * @param title
120
 * @param msg
121
 * @param time
122
 */
123
void TrayIcon::showMessage(const QString &title, const QString &msg, int time) {
×
124
  sysTrayIcon->showMessage(title, msg, QSystemTrayIcon::Information, time);
×
125
}
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc