summaryrefslogtreecommitdiffstats
path: root/examples/widgets/desktop/systray
diff options
context:
space:
mode:
Diffstat (limited to 'examples/widgets/desktop/systray')
-rw-r--r--examples/widgets/desktop/systray/CMakeLists.txt31
-rw-r--r--examples/widgets/desktop/systray/doc/images/systemtray-editor.pngbin25407 -> 16137 bytes
-rw-r--r--examples/widgets/desktop/systray/doc/images/systemtray-example.pngbin47588 -> 49858 bytes
-rw-r--r--examples/widgets/desktop/systray/doc/src/systray.qdoc1
-rw-r--r--examples/widgets/desktop/systray/images/bad.pngbin2496 -> 2101 bytes
-rw-r--r--examples/widgets/desktop/systray/images/heart.pngbin25780 -> 1834 bytes
-rw-r--r--examples/widgets/desktop/systray/images/trash.pngbin12128 -> 1285 bytes
-rw-r--r--examples/widgets/desktop/systray/main.cpp12
8 files changed, 23 insertions, 21 deletions
diff --git a/examples/widgets/desktop/systray/CMakeLists.txt b/examples/widgets/desktop/systray/CMakeLists.txt
index b83a567dd4..c42469bf59 100644
--- a/examples/widgets/desktop/systray/CMakeLists.txt
+++ b/examples/widgets/desktop/systray/CMakeLists.txt
@@ -4,16 +4,10 @@
cmake_minimum_required(VERSION 3.16)
project(systray LANGUAGES CXX)
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/desktop/systray")
-
find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
+qt_standard_project_setup()
+
qt_add_executable(systray
main.cpp
window.cpp window.h
@@ -24,10 +18,10 @@ set_target_properties(systray PROPERTIES
MACOSX_BUNDLE TRUE
)
-target_link_libraries(systray PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
+target_link_libraries(systray PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Widgets
)
# Resources:
@@ -45,7 +39,14 @@ qt_add_resources(systray "systray"
)
install(TARGETS systray
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION .
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+)
+
+qt_generate_deploy_app_script(
+ TARGET systray
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/widgets/desktop/systray/doc/images/systemtray-editor.png b/examples/widgets/desktop/systray/doc/images/systemtray-editor.png
index f7c23db28a..5537c09fde 100644
--- a/examples/widgets/desktop/systray/doc/images/systemtray-editor.png
+++ b/examples/widgets/desktop/systray/doc/images/systemtray-editor.png
Binary files differ
diff --git a/examples/widgets/desktop/systray/doc/images/systemtray-example.png b/examples/widgets/desktop/systray/doc/images/systemtray-example.png
index 98b5c8133e..f2f9f73031 100644
--- a/examples/widgets/desktop/systray/doc/images/systemtray-example.png
+++ b/examples/widgets/desktop/systray/doc/images/systemtray-example.png
Binary files differ
diff --git a/examples/widgets/desktop/systray/doc/src/systray.qdoc b/examples/widgets/desktop/systray/doc/src/systray.qdoc
index 5c4350383d..b0dff58e31 100644
--- a/examples/widgets/desktop/systray/doc/src/systray.qdoc
+++ b/examples/widgets/desktop/systray/doc/src/systray.qdoc
@@ -4,6 +4,7 @@
/*!
\example desktop/systray
\title System Tray Icon Example
+ \examplecategory {Desktop}
\ingroup examples-widgets
\brief The System Tray Icon example shows how to add an icon with a menu
and popup messages to a desktop environment's system tray.
diff --git a/examples/widgets/desktop/systray/images/bad.png b/examples/widgets/desktop/systray/images/bad.png
index c8701a241a..b09de85869 100644
--- a/examples/widgets/desktop/systray/images/bad.png
+++ b/examples/widgets/desktop/systray/images/bad.png
Binary files differ
diff --git a/examples/widgets/desktop/systray/images/heart.png b/examples/widgets/desktop/systray/images/heart.png
index cee1302b7d..5d466b1b89 100644
--- a/examples/widgets/desktop/systray/images/heart.png
+++ b/examples/widgets/desktop/systray/images/heart.png
Binary files differ
diff --git a/examples/widgets/desktop/systray/images/trash.png b/examples/widgets/desktop/systray/images/trash.png
index 4c24db926d..454074f9f2 100644
--- a/examples/widgets/desktop/systray/images/trash.png
+++ b/examples/widgets/desktop/systray/images/trash.png
Binary files differ
diff --git a/examples/widgets/desktop/systray/main.cpp b/examples/widgets/desktop/systray/main.cpp
index d01f813d2f..37f6809a33 100644
--- a/examples/widgets/desktop/systray/main.cpp
+++ b/examples/widgets/desktop/systray/main.cpp
@@ -10,15 +10,15 @@
int main(int argc, char *argv[])
{
- Q_INIT_RESOURCE(systray);
-
QApplication app(argc, argv);
if (!QSystemTrayIcon::isSystemTrayAvailable()) {
- QMessageBox::critical(nullptr, QObject::tr("Systray"),
- QObject::tr("I couldn't detect any system tray "
- "on this system."));
- return 1;
+ auto choice = QMessageBox::critical(nullptr, QObject::tr("Systray"),
+ QObject::tr("I couldn't detect any system tray on this system."),
+ QMessageBox::Close | QMessageBox::Ignore);
+ if (choice == QMessageBox::Close)
+ return 1;
+ // Otherwise "lurk": if a system tray is started later, the icon will appear.
}
QApplication::setQuitOnLastWindowClosed(false);