| 1 |
// Copyright (C) 2016 The Qt Company Ltd. |
| 2 |
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
| 3 |
#include <QtWidgets> |
| 4 |
|
| 5 |
int main(int argc, char**argv) |
| 6 |
{ |
| 7 |
QApplication app(argc, argv); |
| 8 |
|
| 9 |
QWidget window; |
| 10 |
window.show(); |
| 11 |
|
| 12 |
QSystemTrayIcon systrayIcon(&window); |
| 13 |
|
| 14 |
|
| 15 |
enum Iconset { Square, // square icons, reccomended size (18 device-independent pixels or less) |
| 16 |
Rectangular, // rectangular icons, good size |
| 17 |
PowerOfTwo, // standard pow-2 icons, not optimized for the OS X menu bar |
| 18 |
Small, // Not enough pixels |
| 19 |
UnreasonablyLarge // please do something reasonable with my unreasonably large pixmap |
| 20 |
}; |
| 21 |
|
| 22 |
// Select icon set and load images |
| 23 |
Iconset iconset = Square; |
| 24 |
QIcon icon; |
| 25 |
switch (iconset) { |
| 26 |
case Square: |
| 27 |
icon.addFile(":/macsystray36x36.png"); |
| 28 |
icon.addFile(":/macsystray18x18.png"); |
| 29 |
break; |
| 30 |
case Rectangular: |
| 31 |
icon.addFile(":/macsystray50x30.png"); |
| 32 |
icon.addFile(":/macsystray25x15.png"); |
| 33 |
break; |
| 34 |
case PowerOfTwo: |
| 35 |
icon.addFile(":/macsystray16x16.png"); |
| 36 |
icon.addFile(":/macsystray32x32.png"); |
| 37 |
icon.addFile(":/macsystray64x64.png"); |
| 38 |
break; |
| 39 |
case Small: |
| 40 |
icon.addFile(":/macsystray16x16.png"); |
| 41 |
case UnreasonablyLarge: |
| 42 |
icon.addFile(":/macsystray64x64.png"); |
| 43 |
break; |
| 44 |
} |
| 45 |
|
| 46 |
systrayIcon.setIcon(icon); |
| 47 |
systrayIcon.show(); |
| 48 |
|
| 49 |
return app.exec(); |
| 50 |
} |