qt 6.5.1 original
35
tests/manual/cocoa/qsystemtrayicon/CMakeLists.txt
Normal file
@ -0,0 +1,35 @@
|
||||
# Copyright (C) 2022 The Qt Company Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
#####################################################################
|
||||
## qsystemtrayicon Binary:
|
||||
#####################################################################
|
||||
|
||||
qt_internal_add_manual_test(qsystemtrayicon
|
||||
GUI
|
||||
SOURCES
|
||||
main.cpp
|
||||
INCLUDE_DIRECTORIES
|
||||
.
|
||||
LIBRARIES
|
||||
Qt::Gui
|
||||
Qt::Widgets
|
||||
)
|
||||
|
||||
# Resources:
|
||||
set(icons_resource_files
|
||||
"macsystray16x16.png"
|
||||
"macsystray18x18.png"
|
||||
"macsystray25x15.png"
|
||||
"macsystray32x32.png"
|
||||
"macsystray36x36.png"
|
||||
"macsystray50x30.png"
|
||||
"macsystray64x64.png"
|
||||
)
|
||||
|
||||
qt_internal_add_resource(qsystemtrayicon "icons"
|
||||
PREFIX
|
||||
"/"
|
||||
FILES
|
||||
${icons_resource_files}
|
||||
)
|
11
tests/manual/cocoa/qsystemtrayicon/icons.qrc
Normal file
@ -0,0 +1,11 @@
|
||||
<RCC>
|
||||
<qresource prefix="/">
|
||||
<file>macsystray18x18.png</file>
|
||||
<file>macsystray36x36.png</file>
|
||||
<file>macsystray25x15.png</file>
|
||||
<file>macsystray50x30.png</file>
|
||||
<file>macsystray16x16.png</file>
|
||||
<file>macsystray32x32.png</file>
|
||||
<file>macsystray64x64.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
BIN
tests/manual/cocoa/qsystemtrayicon/macsystray16x16.png
Normal file
After Width: | Height: | Size: 101 B |
BIN
tests/manual/cocoa/qsystemtrayicon/macsystray18x18.png
Normal file
After Width: | Height: | Size: 108 B |
BIN
tests/manual/cocoa/qsystemtrayicon/macsystray25x15.png
Normal file
After Width: | Height: | Size: 109 B |
BIN
tests/manual/cocoa/qsystemtrayicon/macsystray32x32.png
Normal file
After Width: | Height: | Size: 117 B |
BIN
tests/manual/cocoa/qsystemtrayicon/macsystray36x36.png
Normal file
After Width: | Height: | Size: 151 B |
BIN
tests/manual/cocoa/qsystemtrayicon/macsystray50x30.png
Normal file
After Width: | Height: | Size: 167 B |
BIN
tests/manual/cocoa/qsystemtrayicon/macsystray64x64.png
Normal file
After Width: | Height: | Size: 204 B |
50
tests/manual/cocoa/qsystemtrayicon/main.cpp
Normal file
@ -0,0 +1,50 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
#include <QtWidgets>
|
||||
|
||||
int main(int argc, char**argv)
|
||||
{
|
||||
QApplication app(argc, argv);
|
||||
|
||||
QWidget window;
|
||||
window.show();
|
||||
|
||||
QSystemTrayIcon systrayIcon(&window);
|
||||
|
||||
|
||||
enum Iconset { Square, // square icons, reccomended size (18 device-independent pixels or less)
|
||||
Rectangular, // rectangular icons, good size
|
||||
PowerOfTwo, // standard pow-2 icons, not optimized for the OS X menu bar
|
||||
Small, // Not enough pixels
|
||||
UnreasonablyLarge // please do something reasonable with my unreasonably large pixmap
|
||||
};
|
||||
|
||||
// Select icon set and load images
|
||||
Iconset iconset = Square;
|
||||
QIcon icon;
|
||||
switch (iconset) {
|
||||
case Square:
|
||||
icon.addFile(":/macsystray36x36.png");
|
||||
icon.addFile(":/macsystray18x18.png");
|
||||
break;
|
||||
case Rectangular:
|
||||
icon.addFile(":/macsystray50x30.png");
|
||||
icon.addFile(":/macsystray25x15.png");
|
||||
break;
|
||||
case PowerOfTwo:
|
||||
icon.addFile(":/macsystray16x16.png");
|
||||
icon.addFile(":/macsystray32x32.png");
|
||||
icon.addFile(":/macsystray64x64.png");
|
||||
break;
|
||||
case Small:
|
||||
icon.addFile(":/macsystray16x16.png");
|
||||
case UnreasonablyLarge:
|
||||
icon.addFile(":/macsystray64x64.png");
|
||||
break;
|
||||
}
|
||||
|
||||
systrayIcon.setIcon(icon);
|
||||
systrayIcon.show();
|
||||
|
||||
return app.exec();
|
||||
}
|
7
tests/manual/cocoa/qsystemtrayicon/qsystemtrayicon.pro
Normal file
@ -0,0 +1,7 @@
|
||||
TEMPLATE = app
|
||||
TARGET = qsystemtrayicon
|
||||
INCLUDEPATH += .
|
||||
QT += widgets
|
||||
|
||||
SOURCES += main.cpp
|
||||
RESOURCES += icons.qrc
|