summaryrefslogtreecommitdiffstats
path: root/examples/dbus
diff options
context:
space:
mode:
Diffstat (limited to 'examples/dbus')
-rw-r--r--examples/dbus/CMakeLists.txt18
-rw-r--r--examples/dbus/chat/CMakeLists.txt39
-rw-r--r--examples/dbus/chat/chat.cpp170
-rw-r--r--examples/dbus/chat/chat.h71
-rw-r--r--examples/dbus/chat/chat.pro2
-rw-r--r--examples/dbus/chat/chatsetnickname.ui149
-rw-r--r--examples/dbus/complexpingpong/CMakeLists.txt37
-rw-r--r--examples/dbus/complexpingpong/complexping.cpp91
-rw-r--r--examples/dbus/complexpingpong/complexping.h60
-rw-r--r--examples/dbus/complexpingpong/complexpong.cpp71
-rw-r--r--examples/dbus/complexpingpong/complexpong.h62
-rw-r--r--examples/dbus/complexpingpong/ping-common.h51
-rw-r--r--examples/dbus/dbus.pro3
-rw-r--r--examples/dbus/doc/images/dbus-chat-example.pngbin38530 -> 0 bytes
-rw-r--r--examples/dbus/doc/images/dbus-chat-example.webpbin0 -> 17556 bytes
-rw-r--r--examples/dbus/doc/src/chat.qdoc35
-rw-r--r--examples/dbus/doc/src/complexpingpong.qdoc33
-rw-r--r--examples/dbus/doc/src/listnames.qdoc39
-rw-r--r--examples/dbus/doc/src/pingpong.qdoc31
-rw-r--r--examples/dbus/listnames/CMakeLists.txt31
-rw-r--r--examples/dbus/listnames/listnames.cpp105
-rw-r--r--examples/dbus/listnames/listnames.pro8
-rw-r--r--examples/dbus/pingpong/CMakeLists.txt43
-rw-r--r--examples/dbus/pingpong/ping-common.h51
-rw-r--r--examples/dbus/pingpong/ping.cpp72
-rw-r--r--examples/dbus/pingpong/pong.cpp83
-rw-r--r--examples/dbus/pingpong/pong.h63
-rw-r--r--examples/dbus/pingpong/pong.pro2
-rw-r--r--examples/dbus/remotecontrolledcar/CMakeLists.txt14
-rw-r--r--examples/dbus/remotecontrolledcar/car/CMakeLists.txt41
-rw-r--r--examples/dbus/remotecontrolledcar/car/car.cpp79
-rw-r--r--examples/dbus/remotecontrolledcar/car/car.h69
-rw-r--r--examples/dbus/remotecontrolledcar/car/car.pro2
-rw-r--r--examples/dbus/remotecontrolledcar/car/main.cpp57
-rw-r--r--examples/dbus/remotecontrolledcar/common/car.xml (renamed from examples/dbus/remotecontrolledcar/car/car.xml)3
-rw-r--r--examples/dbus/remotecontrolledcar/controller/CMakeLists.txt55
-rw-r--r--examples/dbus/remotecontrolledcar/controller/car.xml11
-rw-r--r--examples/dbus/remotecontrolledcar/controller/connected.svg4
-rw-r--r--examples/dbus/remotecontrolledcar/controller/connecting.svg4
-rw-r--r--examples/dbus/remotecontrolledcar/controller/controller.cpp126
-rw-r--r--examples/dbus/remotecontrolledcar/controller/controller.h73
-rw-r--r--examples/dbus/remotecontrolledcar/controller/controller.pro4
-rw-r--r--examples/dbus/remotecontrolledcar/controller/controller.ui64
-rw-r--r--examples/dbus/remotecontrolledcar/controller/down.svg3
-rw-r--r--examples/dbus/remotecontrolledcar/controller/icons.qrc10
-rw-r--r--examples/dbus/remotecontrolledcar/controller/left.svg3
-rw-r--r--examples/dbus/remotecontrolledcar/controller/main.cpp51
-rw-r--r--examples/dbus/remotecontrolledcar/controller/right.svg3
-rw-r--r--examples/dbus/remotecontrolledcar/controller/up.svg3
-rw-r--r--examples/dbus/remotecontrolledcar/doc/images/remotecontrolledcar-car-example.pngbin8833 -> 0 bytes
-rw-r--r--examples/dbus/remotecontrolledcar/doc/images/remotecontrolledcar-car-example.webpbin0 -> 8346 bytes
-rw-r--r--examples/dbus/remotecontrolledcar/doc/src/dbus-remotecontrolledcar.qdoc33
-rw-r--r--examples/dbus/remotecontrolledcar/remotecontrolledcar.pro2
53 files changed, 439 insertions, 1695 deletions
diff --git a/examples/dbus/CMakeLists.txt b/examples/dbus/CMakeLists.txt
index d61f1db460..79caaf949d 100644
--- a/examples/dbus/CMakeLists.txt
+++ b/examples/dbus/CMakeLists.txt
@@ -1,12 +1,16 @@
-if(NOT TARGET Qt::DBus)
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+if(NOT TARGET Qt6::DBus)
return()
endif()
-qt_internal_add_example(listnames)
-qt_internal_add_example(pingpong)
-if(QT_FEATURE_process)
- qt_internal_add_example(complexpingpong)
+if(NOT ANDROID)
+ qt_internal_add_example(pingpong)
+ if(QT_FEATURE_process)
+ qt_internal_add_example(complexpingpong)
+ endif()
endif()
-if(TARGET Qt::Widgets)
+if(TARGET Qt6::Widgets)
qt_internal_add_example(chat)
- add_subdirectory(remotecontrolledcar)
+ qt_internal_add_example(remotecontrolledcar)
endif()
diff --git a/examples/dbus/chat/CMakeLists.txt b/examples/dbus/chat/CMakeLists.txt
index b72138b87c..472d893dee 100644
--- a/examples/dbus/chat/CMakeLists.txt
+++ b/examples/dbus/chat/CMakeLists.txt
@@ -1,20 +1,15 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
cmake_minimum_required(VERSION 3.16)
project(chat LANGUAGES CXX)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/dbus/chat")
-
find_package(Qt6 REQUIRED COMPONENTS Core DBus Gui Widgets)
+qt_standard_project_setup()
+
set(chat_SRCS)
qt_add_dbus_interface(chat_SRCS
org.example.chat.xml
@@ -31,7 +26,6 @@ qt_add_dbus_adaptor(chat_SRCS
qt_add_executable(chat
chat.cpp chat.h
chatmainwindow.ui
- chatsetnickname.ui
${chat_SRCS}
)
@@ -40,15 +34,22 @@ set_target_properties(chat PROPERTIES
MACOSX_BUNDLE TRUE
)
-target_link_libraries(chat PUBLIC
- Qt::Core
- Qt::DBus
- Qt::Gui
- Qt::Widgets
+target_link_libraries(chat PRIVATE
+ Qt6::Core
+ Qt6::DBus
+ Qt6::Gui
+ Qt6::Widgets
)
install(TARGETS chat
- 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 chat
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/dbus/chat/chat.cpp b/examples/dbus/chat/chat.cpp
index 7855457a82..cced911955 100644
--- a/examples/dbus/chat/chat.cpp
+++ b/examples/dbus/chat/chat.cpp
@@ -1,54 +1,8 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QApplication>
+#include <QInputDialog>
#include <QMessageBox>
#include "chat.h"
@@ -56,105 +10,69 @@
#include "chat_interface.h"
ChatMainWindow::ChatMainWindow()
- : m_nickname(QLatin1String("nickname"))
{
setupUi(this);
- sendButton->setEnabled(false);
- connect(messageLineEdit, SIGNAL(textChanged(QString)),
- this, SLOT(textChangedSlot(QString)));
- connect(sendButton, SIGNAL(clicked(bool)), this, SLOT(sendClickedSlot()));
- connect(actionChangeNickname, SIGNAL(triggered(bool)), this, SLOT(changeNickname()));
- connect(actionAboutQt, SIGNAL(triggered(bool)), this, SLOT(aboutQt()));
- connect(qApp, SIGNAL(lastWindowClosed()), this, SLOT(exiting()));
+ connect(messageLineEdit, &QLineEdit::textChanged, this,
+ [this](const QString &newText) { sendButton->setEnabled(!newText.isEmpty()); });
+ connect(sendButton, &QPushButton::clicked, this, [this]() {
+ emit message(m_nickname, messageLineEdit->text());
+ messageLineEdit->clear();
+ });
+ connect(actionChangeNickname, &QAction::triggered,
+ this, &ChatMainWindow::changeNickname);
+ connect(actionAboutQt, &QAction::triggered, this, [this]() { QMessageBox::aboutQt(this); });
+ connect(qApp, &QApplication::lastWindowClosed, this,
+ [this]() { emit action(m_nickname, tr("leaves the chat")); });
// add our D-Bus interface and connect to D-Bus
new ChatAdaptor(this);
- QDBusConnection::sessionBus().registerObject("/", this);
-
- org::example::chat *iface;
- iface = new org::example::chat(QString(), QString(), QDBusConnection::sessionBus(), this);
- //connect(iface, SIGNAL(message(QString,QString)), this, SLOT(messageSlot(QString,QString)));
- QDBusConnection::sessionBus().connect(QString(), QString(), "org.example.chat", "message", this, SLOT(messageSlot(QString,QString)));
- connect(iface, SIGNAL(action(QString,QString)), this, SLOT(actionSlot(QString,QString)));
-
- NicknameDialog dialog;
- dialog.cancelButton->setVisible(false);
- dialog.exec();
- m_nickname = dialog.nickname->text().trimmed();
- emit action(m_nickname, QLatin1String("joins the chat"));
-}
-ChatMainWindow::~ChatMainWindow()
-{
-}
+ auto connection = QDBusConnection::sessionBus();
+ connection.registerObject("/", this);
-void ChatMainWindow::rebuildHistory()
-{
- QString history = m_messages.join( QLatin1String("\n" ) );
- chatHistory->setPlainText(history);
-}
+ using org::example::chat;
-void ChatMainWindow::messageSlot(const QString &nickname, const QString &text)
-{
- QString msg( QLatin1String("<%1> %2") );
- msg = msg.arg(nickname, text);
- m_messages.append(msg);
+ auto *iface = new chat({}, {}, connection, this);
+ connect(iface, &chat::message, this, [this](const QString &nickname, const QString &text) {
+ displayMessage(tr("<%1> %2").arg(nickname, text));
+ });
+ connect(iface, &chat::action, this, [this](const QString &nickname, const QString &text) {
+ displayMessage(tr("* %1 %2").arg(nickname, text));
+ });
- if (m_messages.count() > 100)
- m_messages.removeFirst();
- rebuildHistory();
+ if (!changeNickname(true))
+ QMetaObject::invokeMethod(qApp, &QApplication::quit, Qt::QueuedConnection);
}
-void ChatMainWindow::actionSlot(const QString &nickname, const QString &text)
+void ChatMainWindow::displayMessage(const QString &message)
{
- QString msg( QLatin1String("* %1 %2") );
- msg = msg.arg(nickname, text);
- m_messages.append(msg);
+ m_messages.append(message);
if (m_messages.count() > 100)
m_messages.removeFirst();
- rebuildHistory();
-}
-
-void ChatMainWindow::textChangedSlot(const QString &newText)
-{
- sendButton->setEnabled(!newText.isEmpty());
-}
-void ChatMainWindow::sendClickedSlot()
-{
- //emit message(m_nickname, messageLineEdit->text());
- QDBusMessage msg = QDBusMessage::createSignal("/", "org.example.chat", "message");
- msg << m_nickname << messageLineEdit->text();
- QDBusConnection::sessionBus().send(msg);
- messageLineEdit->setText(QString());
+ auto history = m_messages.join(QLatin1String("\n"));
+ chatHistory->setPlainText(history);
}
-void ChatMainWindow::changeNickname()
+bool ChatMainWindow::changeNickname(bool initial)
{
- NicknameDialog dialog(this);
- if (dialog.exec() == QDialog::Accepted) {
- QString old = m_nickname;
- m_nickname = dialog.nickname->text().trimmed();
- emit action(old, QString("is now known as %1").arg(m_nickname));
+ auto newNickname = QInputDialog::getText(this, tr("Set nickname"), tr("New nickname:"));
+ newNickname = newNickname.trimmed();
+
+ if (!newNickname.isEmpty()) {
+ auto old = m_nickname;
+ m_nickname = newNickname;
+
+ if (initial)
+ emit action(m_nickname, tr("joins the chat"));
+ else
+ emit action(old, tr("is now known as %1").arg(m_nickname));
+ return true;
}
-}
-
-void ChatMainWindow::aboutQt()
-{
- QMessageBox::aboutQt(this);
-}
-
-void ChatMainWindow::exiting()
-{
- emit action(m_nickname, QLatin1String("leaves the chat"));
-}
-NicknameDialog::NicknameDialog(QWidget *parent)
- : QDialog(parent)
-{
- setupUi(this);
+ return false;
}
int main(int argc, char **argv)
diff --git a/examples/dbus/chat/chat.h b/examples/dbus/chat/chat.h
index 444d6c9d80..f7706eeeba 100644
--- a/examples/dbus/chat/chat.h
+++ b/examples/dbus/chat/chat.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef CHAT_H
#define CHAT_H
@@ -54,7 +7,6 @@
#include <QStringList>
#include "ui_chatmainwindow.h"
-#include "ui_chatsetnickname.h"
class ChatMainWindow: public QMainWindow, Ui::ChatMainWindow
{
@@ -63,29 +15,16 @@ class ChatMainWindow: public QMainWindow, Ui::ChatMainWindow
QStringList m_messages;
public:
ChatMainWindow();
- ~ChatMainWindow();
- void rebuildHistory();
+private:
+ void displayMessage(const QString &message);
signals:
void message(const QString &nickname, const QString &text);
void action(const QString &nickname, const QString &text);
private slots:
- void messageSlot(const QString &nickname, const QString &text);
- void actionSlot(const QString &nickname, const QString &text);
- void textChangedSlot(const QString &newText);
- void sendClickedSlot();
- void changeNickname();
- void aboutQt();
- void exiting();
-};
-
-class NicknameDialog: public QDialog, public Ui::NicknameDialog
-{
- Q_OBJECT
-public:
- NicknameDialog(QWidget *parent = nullptr);
+ bool changeNickname(bool initial = false);
};
#endif // CHAT_H
diff --git a/examples/dbus/chat/chat.pro b/examples/dbus/chat/chat.pro
index 93d3178177..2b4630d5f1 100644
--- a/examples/dbus/chat/chat.pro
+++ b/examples/dbus/chat/chat.pro
@@ -2,7 +2,7 @@ QT += dbus widgets
HEADERS += chat.h
SOURCES += chat.cpp
-FORMS += chatmainwindow.ui chatsetnickname.ui
+FORMS += chatmainwindow.ui
DBUS_ADAPTORS += org.example.chat.xml
DBUS_INTERFACES += org.example.chat.xml
diff --git a/examples/dbus/chat/chatsetnickname.ui b/examples/dbus/chat/chatsetnickname.ui
deleted file mode 100644
index fb9894e09f..0000000000
--- a/examples/dbus/chat/chatsetnickname.ui
+++ /dev/null
@@ -1,149 +0,0 @@
-<ui version="4.0" >
- <author></author>
- <comment></comment>
- <exportmacro></exportmacro>
- <class>NicknameDialog</class>
- <widget class="QDialog" name="NicknameDialog" >
- <property name="geometry" >
- <rect>
- <x>0</x>
- <y>0</y>
- <width>396</width>
- <height>105</height>
- </rect>
- </property>
- <property name="sizePolicy" >
- <sizepolicy>
- <hsizetype>1</hsizetype>
- <vsizetype>1</vsizetype>
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="windowTitle" >
- <string>Set nickname</string>
- </property>
- <layout class="QVBoxLayout" >
- <property name="margin" >
- <number>9</number>
- </property>
- <property name="spacing" >
- <number>6</number>
- </property>
- <item>
- <layout class="QVBoxLayout" >
- <property name="margin" >
- <number>0</number>
- </property>
- <property name="spacing" >
- <number>6</number>
- </property>
- <item>
- <widget class="QLabel" name="label" >
- <property name="sizePolicy" >
- <sizepolicy>
- <hsizetype>1</hsizetype>
- <vsizetype>1</vsizetype>
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text" >
- <string>New nickname:</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLineEdit" name="nickname" />
- </item>
- </layout>
- </item>
- <item>
- <layout class="QHBoxLayout" >
- <property name="margin" >
- <number>0</number>
- </property>
- <property name="spacing" >
- <number>6</number>
- </property>
- <item>
- <spacer>
- <property name="orientation" >
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" >
- <size>
- <width>131</width>
- <height>31</height>
- </size>
- </property>
- </spacer>
- </item>
- <item>
- <widget class="QPushButton" name="okButton" >
- <property name="text" >
- <string>OK</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="cancelButton" >
- <property name="text" >
- <string>Cancel</string>
- </property>
- </widget>
- </item>
- <item>
- <spacer>
- <property name="orientation" >
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" >
- <size>
- <width>40</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
- </item>
- </layout>
- </widget>
- <pixmapfunction></pixmapfunction>
- <resources/>
- <connections>
- <connection>
- <sender>okButton</sender>
- <signal>clicked()</signal>
- <receiver>NicknameDialog</receiver>
- <slot>accept()</slot>
- <hints>
- <hint type="sourcelabel" >
- <x>278</x>
- <y>253</y>
- </hint>
- <hint type="destinationlabel" >
- <x>96</x>
- <y>254</y>
- </hint>
- </hints>
- </connection>
- <connection>
- <sender>cancelButton</sender>
- <signal>clicked()</signal>
- <receiver>NicknameDialog</receiver>
- <slot>reject()</slot>
- <hints>
- <hint type="sourcelabel" >
- <x>369</x>
- <y>253</y>
- </hint>
- <hint type="destinationlabel" >
- <x>179</x>
- <y>282</y>
- </hint>
- </hints>
- </connection>
- </connections>
-</ui>
diff --git a/examples/dbus/complexpingpong/CMakeLists.txt b/examples/dbus/complexpingpong/CMakeLists.txt
index 7302d7b591..da4ca95288 100644
--- a/examples/dbus/complexpingpong/CMakeLists.txt
+++ b/examples/dbus/complexpingpong/CMakeLists.txt
@@ -1,20 +1,17 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
cmake_minimum_required(VERSION 3.16)
project(complexpingpong LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
+if (ANDROID)
+ message(FATAL_ERROR "This project cannot be built on Android.")
endif()
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/dbus/complexpingpong")
-
find_package(Qt6 REQUIRED COMPONENTS Core DBus)
+qt_standard_project_setup()
+
qt_add_executable(complexping
complexping.cpp complexping.h
ping-common.h
@@ -35,7 +32,21 @@ target_link_libraries(complexpong PRIVATE
)
install(TARGETS complexping complexpong
- 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 complexping
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
+)
+install(SCRIPT ${deploy_script})
+
+qt_generate_deploy_app_script(
+ TARGET complexpong
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/dbus/complexpingpong/complexping.cpp b/examples/dbus/complexpingpong/complexping.cpp
index 8878083ee9..9651183c92 100644
--- a/examples/dbus/complexpingpong/complexping.cpp
+++ b/examples/dbus/complexpingpong/complexping.cpp
@@ -1,105 +1,62 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "ping-common.h"
#include "complexping.h"
#include <QCoreApplication>
+#include <QDBusInterface>
#include <QDBusReply>
#include <QDBusServiceWatcher>
-#include <QFile>
#include <QDebug>
#include <QProcess>
-#include <stdio.h>
+#include <iostream>
+#include <string>
void Ping::start(const QString &name)
{
if (name != SERVICE_NAME)
return;
- // open stdin for reading
- qstdin.open(stdin, QIODevice::ReadOnly);
-
+ auto connection = QDBusConnection::sessionBus();
// find our remote
- iface = new QDBusInterface(SERVICE_NAME, "/", "org.example.QtDBus.ComplexPong.Pong",
- QDBusConnection::sessionBus(), this);
+ auto iface = new QDBusInterface(SERVICE_NAME, "/", "org.example.QtDBus.ComplexPong.Pong",
+ connection, this);
if (!iface->isValid()) {
- fprintf(stderr, "%s\n",
- qPrintable(QDBusConnection::sessionBus().lastError().message()));
+ qWarning().noquote() << connection.lastError().message();
QCoreApplication::instance()->quit();
}
connect(iface, SIGNAL(aboutToQuit()), QCoreApplication::instance(), SLOT(quit()));
+ std::string s;
+
while (true) {
- printf("Ask your question: ");
+ std::cout << qPrintable(tr("Ask your question: ")) << std::flush;
+
+ std::getline(std::cin, s);
+ auto line = QString::fromStdString(s).trimmed();
- QString line = QString::fromLocal8Bit(qstdin.readLine()).trimmed();
if (line.isEmpty()) {
iface->call("quit");
return;
} else if (line == "value") {
QVariant reply = iface->property("value");
if (!reply.isNull())
- printf("value = %s\n", qPrintable(reply.toString()));
+ std::cout << "value = " << qPrintable(reply.toString()) << std::endl;
} else if (line.startsWith("value=")) {
iface->setProperty("value", line.mid(6));
} else {
QDBusReply<QDBusVariant> reply = iface->call("query", line);
- if (reply.isValid())
- printf("Reply was: %s\n", qPrintable(reply.value().variant().toString()));
+ if (reply.isValid()) {
+ std::cout << qPrintable(tr("Reply was: %1").arg(reply.value().variant().toString()))
+ << std::endl;
+ }
}
if (iface->lastError().isValid())
- fprintf(stderr, "Call failed: %s\n", qPrintable(iface->lastError().message()));
+ qWarning().noquote() << tr("Call failed: %1").arg(iface->lastError().message());
}
}
@@ -108,9 +65,11 @@ int main(int argc, char **argv)
QCoreApplication app(argc, argv);
if (!QDBusConnection::sessionBus().isConnected()) {
- fprintf(stderr, "Cannot connect to the D-Bus session bus.\n"
+ qWarning().noquote() << QCoreApplication::translate(
+ "complexping",
+ "Cannot connect to the D-Bus session bus.\n"
"To start it, run:\n"
- "\teval `dbus-launch --auto-syntax`\n");
+ "\teval `dbus-launch --auto-syntax`");
return 1;
}
diff --git a/examples/dbus/complexpingpong/complexping.h b/examples/dbus/complexpingpong/complexping.h
index 98a4332f38..fd566a9bab 100644
--- a/examples/dbus/complexpingpong/complexping.h
+++ b/examples/dbus/complexpingpong/complexping.h
@@ -1,68 +1,16 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef COMPLEXPING_H
#define COMPLEXPING_H
#include <QtCore/QObject>
-#include <QtCore/QFile>
-#include <QtDBus/QDBusInterface>
-class Ping: public QObject
+class Ping : public QObject
{
Q_OBJECT
public slots:
- void start(const QString &);
-public:
- QFile qstdin;
- QDBusInterface *iface;
+ void start(const QString &name);
};
#endif
diff --git a/examples/dbus/complexpingpong/complexpong.cpp b/examples/dbus/complexpingpong/complexpong.cpp
index 6b3430bc94..088b452b30 100644
--- a/examples/dbus/complexpingpong/complexpong.cpp
+++ b/examples/dbus/complexpingpong/complexpong.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "ping-common.h"
#include "complexpong.h"
@@ -54,12 +7,8 @@
#include <QCoreApplication>
#include <QDBusConnection>
#include <QDBusError>
-#include <QTimer>
+#include <QDebug>
-#include <stdio.h>
-#include <stdlib.h>
-
-// the property
QString Pong::value() const
{
return m_value;
@@ -72,7 +21,8 @@ void Pong::setValue(const QString &newValue)
void Pong::quit()
{
- QTimer::singleShot(0, QCoreApplication::instance(), &QCoreApplication::quit);
+ QMetaObject::invokeMethod(QCoreApplication::instance(), &QCoreApplication::quit,
+ Qt::QueuedConnection);
}
QDBusVariant Pong::query(const QString &query)
@@ -101,12 +51,13 @@ int main(int argc, char **argv)
Pong *pong = new Pong(&obj);
QObject::connect(&app, &QCoreApplication::aboutToQuit, pong, &Pong::aboutToQuit);
pong->setProperty("value", "initial value");
- QDBusConnection::sessionBus().registerObject("/", &obj);
- if (!QDBusConnection::sessionBus().registerService(SERVICE_NAME)) {
- fprintf(stderr, "%s\n",
- qPrintable(QDBusConnection::sessionBus().lastError().message()));
- exit(1);
+ auto connection = QDBusConnection::sessionBus();
+ connection.registerObject("/", &obj);
+
+ if (!connection.registerService(SERVICE_NAME)) {
+ qWarning().noquote() << connection.lastError().message();
+ return 1;
}
app.exec();
diff --git a/examples/dbus/complexpingpong/complexpong.h b/examples/dbus/complexpingpong/complexpong.h
index c116d447c6..b9328c399e 100644
--- a/examples/dbus/complexpingpong/complexpong.h
+++ b/examples/dbus/complexpingpong/complexpong.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef COMPLEXPONG_H
#define COMPLEXPONG_H
@@ -55,23 +8,26 @@
#include <QtDBus/QDBusAbstractAdaptor>
#include <QtDBus/QDBusVariant>
-class Pong: public QDBusAbstractAdaptor
+class Pong : public QDBusAbstractAdaptor
{
Q_OBJECT
Q_CLASSINFO("D-Bus Interface", "org.example.QtDBus.ComplexPong.Pong")
Q_PROPERTY(QString value READ value WRITE setValue)
public:
- QString m_value;
QString value() const;
void setValue(const QString &newValue);
- Pong(QObject *obj) : QDBusAbstractAdaptor(obj)
- { }
+ Pong(QObject *obj) : QDBusAbstractAdaptor(obj) { }
+
signals:
void aboutToQuit();
+
public slots:
QDBusVariant query(const QString &query);
Q_NOREPLY void quit();
+
+private:
+ QString m_value;
};
#endif
diff --git a/examples/dbus/complexpingpong/ping-common.h b/examples/dbus/complexpingpong/ping-common.h
index f35a33f513..0a5f586941 100644
--- a/examples/dbus/complexpingpong/ping-common.h
+++ b/examples/dbus/complexpingpong/ping-common.h
@@ -1,51 +1,4 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#define SERVICE_NAME "org.example.QtDBus.PingExample"
diff --git a/examples/dbus/dbus.pro b/examples/dbus/dbus.pro
index 1b2164c4ae..627f362b38 100644
--- a/examples/dbus/dbus.pro
+++ b/examples/dbus/dbus.pro
@@ -1,8 +1,7 @@
requires(qtHaveModule(dbus))
TEMPLATE = subdirs
-SUBDIRS = listnames \
- pingpong
+SUBDIRS = pingpong
qtConfig(process): SUBDIRS += complexpingpong
diff --git a/examples/dbus/doc/images/dbus-chat-example.png b/examples/dbus/doc/images/dbus-chat-example.png
deleted file mode 100644
index ad66d08950..0000000000
--- a/examples/dbus/doc/images/dbus-chat-example.png
+++ /dev/null
Binary files differ
diff --git a/examples/dbus/doc/images/dbus-chat-example.webp b/examples/dbus/doc/images/dbus-chat-example.webp
new file mode 100644
index 0000000000..82f651a50c
--- /dev/null
+++ b/examples/dbus/doc/images/dbus-chat-example.webp
Binary files differ
diff --git a/examples/dbus/doc/src/chat.qdoc b/examples/dbus/doc/src/chat.qdoc
index f643af10d3..fdbc2f30ae 100644
--- a/examples/dbus/doc/src/chat.qdoc
+++ b/examples/dbus/doc/src/chat.qdoc
@@ -1,41 +1,18 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\example chat
- \title D-Bus Chat Example
+ \title D-Bus Chat
+ \examplecategory {Connectivity}
\ingroup examples-dbus
\brief Demonstrates communication among instances of an application.
\e Chat is a \l{Qt D-Bus} example which demonstrates a simple chat system
- among instances of an application. Users connect and send message to
+ among instances of an application. Users connect and send messages to
each other.
- \image dbus-chat-example.png
+ \image dbus-chat-example.webp
\include examples-run.qdocinc
*/
diff --git a/examples/dbus/doc/src/complexpingpong.qdoc b/examples/dbus/doc/src/complexpingpong.qdoc
index d09708c0ff..84fccdf561 100644
--- a/examples/dbus/doc/src/complexpingpong.qdoc
+++ b/examples/dbus/doc/src/complexpingpong.qdoc
@@ -1,37 +1,14 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\example complexpingpong
- \title D-Bus Complex Ping Pong Example
+ \title D-Bus Complex Ping Pong
+ \examplecategory {Connectivity}
\ingroup examples-dbus
\brief Demonstrates usage of the Qt D-Bus typesystem.
- \e{Complex Ping Pong Example} demonstrates the use of \l{Qt D-Bus}
+ \e{Complex Ping Pong} example demonstrates the use of \l{Qt D-Bus}
typesystem with QDBusVariant and QDBusReply. The example consists of the
main application \c complexping which starts the other application, \c
complexpong. Entering keywords such as \c hello and \c ping is handled by
diff --git a/examples/dbus/doc/src/listnames.qdoc b/examples/dbus/doc/src/listnames.qdoc
deleted file mode 100644
index 40be61b527..0000000000
--- a/examples/dbus/doc/src/listnames.qdoc
+++ /dev/null
@@ -1,39 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \example listnames
- \title D-Bus List Names Example
- \ingroup examples-dbus
- \brief Shows how to access the D-Bus bus daemon service.
-
- \e{List Names} is a command-line example which shows how to
- access the \l{Qt D-Bus} bus daemon service. The example prints various
- information about the bus daemon service.
-
- \include examples-run.qdocinc
-*/
diff --git a/examples/dbus/doc/src/pingpong.qdoc b/examples/dbus/doc/src/pingpong.qdoc
index 28ef737d38..1ab0ec62fe 100644
--- a/examples/dbus/doc/src/pingpong.qdoc
+++ b/examples/dbus/doc/src/pingpong.qdoc
@@ -1,33 +1,10 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\example pingpong
- \title D-Bus Ping Pong Example
+ \title D-Bus Ping Pong
+ \examplecategory {Connectivity}
\ingroup examples-dbus
\brief Demonstrates a simple message system using D-Bus.
diff --git a/examples/dbus/listnames/CMakeLists.txt b/examples/dbus/listnames/CMakeLists.txt
deleted file mode 100644
index 784a2c5dd4..0000000000
--- a/examples/dbus/listnames/CMakeLists.txt
+++ /dev/null
@@ -1,31 +0,0 @@
-cmake_minimum_required(VERSION 3.16)
-project(listnames LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/dbus/listnames")
-
-find_package(Qt6 REQUIRED COMPONENTS Core DBus)
-
-qt_add_executable(listnames
- listnames.cpp
-)
-
-target_link_libraries(listnames PUBLIC
- Qt::Core
- Qt::DBus
-)
-
-install(TARGETS listnames
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/dbus/listnames/listnames.cpp b/examples/dbus/listnames/listnames.cpp
deleted file mode 100644
index fcd0e060a4..0000000000
--- a/examples/dbus/listnames/listnames.cpp
+++ /dev/null
@@ -1,105 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QCoreApplication>
-#include <QDBusConnection>
-#include <QDBusConnectionInterface>
-#include <QDBusInterface>
-#include <QDBusReply>
-#include <QDebug>
-#include <QStringList>
-
-void method1()
-{
- qDebug() << "Method 1:";
-
- QDBusReply<QStringList> reply = QDBusConnection::sessionBus().interface()->registeredServiceNames();
- if (!reply.isValid()) {
- qDebug() << "Error:" << reply.error().message();
- exit(1);
- }
- const QStringList values = reply.value();
- for (const QString &name : values)
- qDebug() << name;
-}
-
-void method2()
-{
- qDebug() << "Method 2:";
-
- QDBusConnection bus = QDBusConnection::sessionBus();
- QDBusInterface dbus_iface("org.freedesktop.DBus", "/org/freedesktop/DBus",
- "org.freedesktop.DBus", bus);
- qDebug() << dbus_iface.call("ListNames").arguments().at(0);
-}
-
-void method3()
-{
- qDebug() << "Method 3:";
- qDebug() << QDBusConnection::sessionBus().interface()->registeredServiceNames().value();
-}
-
-int main(int argc, char **argv)
-{
- QCoreApplication app(argc, argv);
-
- if (!QDBusConnection::sessionBus().isConnected()) {
- fprintf(stderr, "Cannot connect to the D-Bus session bus.\n"
- "To start it, run:\n"
- "\teval `dbus-launch --auto-syntax`\n");
- return 1;
- }
-
- method1();
- method2();
- method3();
-
- return 0;
-}
diff --git a/examples/dbus/listnames/listnames.pro b/examples/dbus/listnames/listnames.pro
deleted file mode 100644
index ed130f7374..0000000000
--- a/examples/dbus/listnames/listnames.pro
+++ /dev/null
@@ -1,8 +0,0 @@
-QT -= gui
-QT += dbus
-win32:CONFIG += console
-
-SOURCES += listnames.cpp
-
-target.path = $$[QT_INSTALL_EXAMPLES]/dbus/listnames
-INSTALLS += target
diff --git a/examples/dbus/pingpong/CMakeLists.txt b/examples/dbus/pingpong/CMakeLists.txt
index 652f784a63..d159ad9ba4 100644
--- a/examples/dbus/pingpong/CMakeLists.txt
+++ b/examples/dbus/pingpong/CMakeLists.txt
@@ -1,42 +1,53 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
cmake_minimum_required(VERSION 3.16)
project(pingpong LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
+if (ANDROID)
+ message(FATAL_ERROR "This project cannot be built on Android.")
endif()
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/dbus/pingpong")
-
find_package(Qt6 REQUIRED COMPONENTS Core DBus)
+qt_standard_project_setup()
+
qt_add_executable(ping
ping.cpp
ping-common.h
)
-target_link_libraries(ping PUBLIC
+target_link_libraries(ping PRIVATE
Qt6::Core
Qt6::DBus
)
qt_add_executable(pong
ping-common.h
- pong.cpp pong.h
+ pong.cpp
)
-target_link_libraries(pong PUBLIC
+target_link_libraries(pong PRIVATE
Qt6::Core
Qt6::DBus
)
install(TARGETS ping pong
- 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 ping
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
+)
+install(SCRIPT ${deploy_script})
+
+qt_generate_deploy_app_script(
+ TARGET pong
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/dbus/pingpong/ping-common.h b/examples/dbus/pingpong/ping-common.h
index f35a33f513..0a5f586941 100644
--- a/examples/dbus/pingpong/ping-common.h
+++ b/examples/dbus/pingpong/ping-common.h
@@ -1,51 +1,4 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#define SERVICE_NAME "org.example.QtDBus.PingExample"
diff --git a/examples/dbus/pingpong/ping.cpp b/examples/dbus/pingpong/ping.cpp
index 64c1fe6bbf..a217107835 100644
--- a/examples/dbus/pingpong/ping.cpp
+++ b/examples/dbus/pingpong/ping.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "ping-common.h"
@@ -55,32 +8,33 @@
#include <QDBusInterface>
#include <QDBusReply>
-#include <stdio.h>
+#include <iostream>
int main(int argc, char **argv)
{
QCoreApplication app(argc, argv);
- if (!QDBusConnection::sessionBus().isConnected()) {
- fprintf(stderr, "Cannot connect to the D-Bus session bus.\n"
- "To start it, run:\n"
- "\teval `dbus-launch --auto-syntax`\n");
+ auto connection = QDBusConnection::sessionBus();
+
+ if (!connection.isConnected()) {
+ qWarning("Cannot connect to the D-Bus session bus.\n"
+ "To start it, run:\n"
+ "\teval `dbus-launch --auto-syntax`\n");
return 1;
}
- QDBusInterface iface(SERVICE_NAME, "/", "", QDBusConnection::sessionBus());
+ QDBusInterface iface(SERVICE_NAME, "/");
if (iface.isValid()) {
QDBusReply<QString> reply = iface.call("ping", argc > 1 ? argv[1] : "");
if (reply.isValid()) {
- printf("Reply was: %s\n", qPrintable(reply.value()));
+ std::cout << "Reply was: " << qPrintable(reply.value()) << std::endl;
return 0;
}
- fprintf(stderr, "Call failed: %s\n", qPrintable(reply.error().message()));
+ qWarning("Call failed: %s\n", qPrintable(reply.error().message()));
return 1;
}
- fprintf(stderr, "%s\n",
- qPrintable(QDBusConnection::sessionBus().lastError().message()));
+ qWarning("%s\n", qPrintable(connection.lastError().message()));
return 1;
}
diff --git a/examples/dbus/pingpong/pong.cpp b/examples/dbus/pingpong/pong.cpp
index 37f6261142..ed8c90195e 100644
--- a/examples/dbus/pingpong/pong.cpp
+++ b/examples/dbus/pingpong/pong.cpp
@@ -1,67 +1,23 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "ping-common.h"
-#include "pong.h"
+#include <QObject>
#include <QCoreApplication>
#include <QDBusConnection>
#include <QDBusError>
-#include <QTimer>
-#include <stdio.h>
-#include <stdlib.h>
+class Pong : public QObject
+{
+ Q_OBJECT
+public slots:
+ QString ping(const QString &arg);
+};
QString Pong::ping(const QString &arg)
{
- QMetaObject::invokeMethod(QCoreApplication::instance(), "quit");
+ QMetaObject::invokeMethod(QCoreApplication::instance(), &QCoreApplication::quit);
return QString("ping(\"%1\") got called").arg(arg);
}
@@ -69,22 +25,25 @@ int main(int argc, char **argv)
{
QCoreApplication app(argc, argv);
- if (!QDBusConnection::sessionBus().isConnected()) {
- fprintf(stderr, "Cannot connect to the D-Bus session bus.\n"
- "To start it, run:\n"
- "\teval `dbus-launch --auto-syntax`\n");
+ auto connection = QDBusConnection::sessionBus();
+
+ if (!connection.isConnected()) {
+ qWarning("Cannot connect to the D-Bus session bus.\n"
+ "To start it, run:\n"
+ "\teval `dbus-launch --auto-syntax`\n");
return 1;
}
- if (!QDBusConnection::sessionBus().registerService(SERVICE_NAME)) {
- fprintf(stderr, "%s\n",
- qPrintable(QDBusConnection::sessionBus().lastError().message()));
+ if (!connection.registerService(SERVICE_NAME)) {
+ qWarning("%s\n", qPrintable(connection.lastError().message()));
exit(1);
}
Pong pong;
- QDBusConnection::sessionBus().registerObject("/", &pong, QDBusConnection::ExportAllSlots);
+ connection.registerObject("/", &pong, QDBusConnection::ExportAllSlots);
app.exec();
return 0;
}
+
+#include "pong.moc"
diff --git a/examples/dbus/pingpong/pong.h b/examples/dbus/pingpong/pong.h
deleted file mode 100644
index 0b22f37eb7..0000000000
--- a/examples/dbus/pingpong/pong.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef PONG_H
-#define PONG_H
-
-#include <QtCore/QObject>
-
-class Pong: public QObject
-{
- Q_OBJECT
-public slots:
- Q_SCRIPTABLE QString ping(const QString &arg);
-};
-
-#endif
diff --git a/examples/dbus/pingpong/pong.pro b/examples/dbus/pingpong/pong.pro
index bc78730534..1307e70805 100644
--- a/examples/dbus/pingpong/pong.pro
+++ b/examples/dbus/pingpong/pong.pro
@@ -1,7 +1,7 @@
QT -= gui
QT += dbus
-HEADERS += ping-common.h pong.h
+HEADERS += ping-common.h
SOURCES += pong.cpp
target.path = $$[QT_INSTALL_EXAMPLES]/dbus/pingpong
diff --git a/examples/dbus/remotecontrolledcar/CMakeLists.txt b/examples/dbus/remotecontrolledcar/CMakeLists.txt
index 259d3a0470..fdca3256ad 100644
--- a/examples/dbus/remotecontrolledcar/CMakeLists.txt
+++ b/examples/dbus/remotecontrolledcar/CMakeLists.txt
@@ -1,2 +1,12 @@
-qt_internal_add_example(car)
-qt_internal_add_example(controller)
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+cmake_minimum_required(VERSION 3.16)
+project(remotecontrolledcar LANGUAGES CXX)
+
+find_package(Qt6 REQUIRED COMPONENTS Core DBus Gui Widgets)
+
+qt_standard_project_setup()
+
+add_subdirectory(car)
+add_subdirectory(controller)
diff --git a/examples/dbus/remotecontrolledcar/car/CMakeLists.txt b/examples/dbus/remotecontrolledcar/car/CMakeLists.txt
index 05960b953d..24bbdb669c 100644
--- a/examples/dbus/remotecontrolledcar/car/CMakeLists.txt
+++ b/examples/dbus/remotecontrolledcar/car/CMakeLists.txt
@@ -1,23 +1,11 @@
-cmake_minimum_required(VERSION 3.16)
-project(car LANGUAGES CXX)
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
set(CMAKE_INCLUDE_CURRENT_DIR ON)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/dbus/remotecontrolledcar/car")
-
-find_package(Qt6 REQUIRED COMPONENTS Core DBus Gui Widgets)
-
set(car_SRCS)
qt_add_dbus_adaptor(car_SRCS
- car.xml
+ ../common/car.xml
qobject.h
"" # empty parent_class value on purpose to not pass -l flag
car_adaptor
@@ -34,15 +22,22 @@ set_target_properties(car PROPERTIES
MACOSX_BUNDLE TRUE
)
-target_link_libraries(car PUBLIC
- Qt::Core
- Qt::DBus
- Qt::Gui
- Qt::Widgets
+target_link_libraries(car PRIVATE
+ Qt6::Core
+ Qt6::DBus
+ Qt6::Gui
+ Qt6::Widgets
)
install(TARGETS car
- 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 car
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/dbus/remotecontrolledcar/car/car.cpp b/examples/dbus/remotecontrolledcar/car/car.cpp
index 2de4e6447a..0920658281 100644
--- a/examples/dbus/remotecontrolledcar/car/car.cpp
+++ b/examples/dbus/remotecontrolledcar/car/car.cpp
@@ -1,67 +1,19 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "car.h"
#include <QtWidgets/QtWidgets>
-#include <qmath.h>
+#include <cmath>
QRectF Car::boundingRect() const
{
return QRectF(-35, -81, 70, 115);
}
-Car::Car() : color(Qt::green), wheelsAngle(0), speed(0)
+Car::Car()
{
startTimer(1000 / 33);
- setFlag(QGraphicsItem::ItemIsMovable, true);
- setFlag(QGraphicsItem::ItemIsFocusable, true);
+ setFlags(ItemIsMovable | ItemIsFocusable);
}
void Car::accelerate()
@@ -134,12 +86,31 @@ void Car::timerEvent(QTimerEvent *event)
const qreal axelDistance = 54;
qreal wheelsAngleRads = qDegreesToRadians(wheelsAngle);
- qreal turnDistance = ::cos(wheelsAngleRads) * axelDistance * 2;
+ qreal turnDistance = std::cos(wheelsAngleRads) * axelDistance * 2;
qreal turnRateRads = wheelsAngleRads / turnDistance; // rough estimate
qreal turnRate = qRadiansToDegrees(turnRateRads);
qreal rotation = speed * turnRate;
setTransform(QTransform().rotate(rotation), true);
setTransform(QTransform::fromTranslate(0, -speed), true);
+
+ if (!scene()->views().isEmpty()) {
+ QRect viewRect = scene()->views().at(0)->sceneRect().toRect();
+ QTransform fx = transform();
+ qreal dx = fx.dx();
+ qreal dy = fx.dy();
+ while (dx < viewRect.left() - 10)
+ dx += viewRect.width();
+ while (dy < viewRect.top() - 10)
+ dy += viewRect.height();
+ while (dx > viewRect.right() + 10)
+ dx -= viewRect.width();
+ while (dy > viewRect.bottom() + 10)
+ dy -= viewRect.width();
+ setTransform(QTransform(fx.m11(), fx.m12(), fx.m13(),
+ fx.m21(), fx.m22(), fx.m23(),
+ dx, dy, fx.m33()));
+ }
+
update();
}
diff --git a/examples/dbus/remotecontrolledcar/car/car.h b/examples/dbus/remotecontrolledcar/car/car.h
index e843786e5b..5a1e199ae0 100644
--- a/examples/dbus/remotecontrolledcar/car/car.h
+++ b/examples/dbus/remotecontrolledcar/car/car.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef CAR_H
#define CAR_H
@@ -59,25 +12,23 @@ class Car : public QGraphicsObject
Q_OBJECT
public:
Car();
- QRectF boundingRect() const;
+ QRectF boundingRect() const override;
-public Q_SLOTS:
+public slots:
void accelerate();
void decelerate();
void turnLeft();
void turnRight();
-Q_SIGNALS:
- void crashed();
-
protected:
- void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = nullptr);
- void timerEvent(QTimerEvent *event);
+ void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
+ QWidget *widget = nullptr) override;
+ void timerEvent(QTimerEvent *event) override;
private:
- QBrush color;
- qreal wheelsAngle; // used when applying rotation
- qreal speed; // delta movement along the body axis
+ QBrush color = Qt::green;
+ qreal wheelsAngle = 0; // used when applying rotation
+ qreal speed = 0; // delta movement along the body axis
};
#endif // CAR_H
diff --git a/examples/dbus/remotecontrolledcar/car/car.pro b/examples/dbus/remotecontrolledcar/car/car.pro
index 5e354e3d0b..4c0f2a1eb9 100644
--- a/examples/dbus/remotecontrolledcar/car/car.pro
+++ b/examples/dbus/remotecontrolledcar/car/car.pro
@@ -1,6 +1,6 @@
QT += dbus widgets
-DBUS_ADAPTORS += car.xml
+DBUS_ADAPTORS += ../common/car.xml
HEADERS += car.h
SOURCES += car.cpp main.cpp
diff --git a/examples/dbus/remotecontrolledcar/car/main.cpp b/examples/dbus/remotecontrolledcar/car/main.cpp
index 463add47cf..81b8cdfc20 100644
--- a/examples/dbus/remotecontrolledcar/car/main.cpp
+++ b/examples/dbus/remotecontrolledcar/car/main.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "car.h"
#include "car_adaptor.h"
@@ -63,18 +16,18 @@ int main(int argc, char *argv[])
scene.setSceneRect(-500, -500, 1000, 1000);
scene.setItemIndexMethod(QGraphicsScene::NoIndex);
- Car *car = new Car();
+ auto car = new Car();
scene.addItem(car);
QGraphicsView view(&scene);
view.setRenderHint(QPainter::Antialiasing);
view.setBackgroundBrush(Qt::darkGray);
view.setWindowTitle(QT_TRANSLATE_NOOP(QGraphicsView, "Qt DBus Controlled Car"));
- view.resize(400, 300);
+ view.resize(view.sizeHint());
view.show();
new CarInterfaceAdaptor(car);
- QDBusConnection connection = QDBusConnection::sessionBus();
+ auto connection = QDBusConnection::sessionBus();
connection.registerObject("/Car", car);
connection.registerService("org.example.CarExample");
diff --git a/examples/dbus/remotecontrolledcar/car/car.xml b/examples/dbus/remotecontrolledcar/common/car.xml
index 6d8c9d19f2..ea9a000bb8 100644
--- a/examples/dbus/remotecontrolledcar/car/car.xml
+++ b/examples/dbus/remotecontrolledcar/common/car.xml
@@ -6,6 +6,5 @@
<method name="decelerate"/>
<method name="turnLeft"/>
<method name="turnRight"/>
- <signal name="crashed"/>
</interface>
-</node> \ No newline at end of file
+</node>
diff --git a/examples/dbus/remotecontrolledcar/controller/CMakeLists.txt b/examples/dbus/remotecontrolledcar/controller/CMakeLists.txt
index 6fc18b4751..a0c1aea7c5 100644
--- a/examples/dbus/remotecontrolledcar/controller/CMakeLists.txt
+++ b/examples/dbus/remotecontrolledcar/controller/CMakeLists.txt
@@ -1,46 +1,53 @@
-cmake_minimum_required(VERSION 3.16)
-project(controller LANGUAGES CXX)
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
set(CMAKE_INCLUDE_CURRENT_DIR ON)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/dbus/remotecontrolledcar/controller")
-
-find_package(Qt6 REQUIRED COMPONENTS Core DBus Gui Widgets)
-
set(controller_SRCS)
qt_add_dbus_interface(controller_SRCS
- car.xml
+ ../common/car.xml
car_interface
)
qt_add_executable(controller
- controller.cpp controller.h controller.ui
+ controller.cpp controller.h
main.cpp
${controller_SRCS}
)
+qt_add_resources(controller
+ PREFIX
+ "/"
+ FILES
+ down.svg
+ left.svg
+ right.svg
+ up.svg
+ connected.svg
+ connecting.svg
+)
+
set_target_properties(controller PROPERTIES
WIN32_EXECUTABLE TRUE
MACOSX_BUNDLE TRUE
)
-target_link_libraries(controller PUBLIC
- Qt::Core
- Qt::DBus
- Qt::Gui
- Qt::Widgets
+target_link_libraries(controller PRIVATE
+ Qt6::Core
+ Qt6::DBus
+ Qt6::Gui
+ Qt6::Widgets
)
install(TARGETS controller
- 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 controller
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/dbus/remotecontrolledcar/controller/car.xml b/examples/dbus/remotecontrolledcar/controller/car.xml
deleted file mode 100644
index 6d8c9d19f2..0000000000
--- a/examples/dbus/remotecontrolledcar/controller/car.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
- "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
-<node name="/com/trollech/examples/car">
- <interface name="org.example.Examples.CarInterface">
- <method name="accelerate"/>
- <method name="decelerate"/>
- <method name="turnLeft"/>
- <method name="turnRight"/>
- <signal name="crashed"/>
- </interface>
-</node> \ No newline at end of file
diff --git a/examples/dbus/remotecontrolledcar/controller/connected.svg b/examples/dbus/remotecontrolledcar/controller/connected.svg
new file mode 100644
index 0000000000..a3616b769e
--- /dev/null
+++ b/examples/dbus/remotecontrolledcar/controller/connected.svg
@@ -0,0 +1,4 @@
+<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path fill-rule="evenodd" clip-rule="evenodd" d="M19 11C19 11.5523 19.4477 12 20 12C20.5523 12 21 11.5523 21 11V10.8478C21 8.11075 19.7088 5.53404 17.5163 3.89561C17.0739 3.56501 16.4472 3.65565 16.1166 4.09805C15.786 4.54046 15.8767 5.1671 16.3191 5.4977C18.0064 6.75857 19 8.74149 19 10.8478V11ZM4 12C4.55228 12 5 11.5523 5 11V10.8478C5 8.74149 5.99363 6.75857 7.68091 5.4977C8.12331 5.1671 8.21395 4.54046 7.88335 4.09805C7.55275 3.65565 6.92611 3.56501 6.4837 3.89561C4.29117 5.53404 3 8.11075 3 10.8478V11C3 11.5523 3.44772 12 4 12ZM7.10555 19.5528C7.35253 19.0588 7.95321 18.8586 8.44719 19.1055C10.6837 20.2238 13.3162 20.2238 15.5528 19.1056C16.0467 18.8586 16.6474 19.0588 16.8944 19.5528C17.1414 20.0468 16.9412 20.6474 16.4472 20.8944C13.6476 22.2942 10.3523 22.2942 7.55276 20.8944C7.05878 20.6474 6.85856 20.0467 7.10555 19.5528Z" fill="black"/>
+<path id="Layer02" fill-rule="evenodd" clip-rule="evenodd" d="M13 5C13 5.55228 12.5523 6 12 6C11.4477 6 11 5.55228 11 5C11 4.44772 11.4477 4 12 4C12.5523 4 13 4.44772 13 5ZM15 5C15 6.65685 13.6569 8 12 8C10.3431 8 9 6.65685 9 5C9 3.34315 10.3431 2 12 2C13.6569 2 15 3.34315 15 5ZM5 17C5.55228 17 6 16.5523 6 16C6 15.4477 5.55228 15 5 15C4.44772 15 4 15.4477 4 16C4 16.5523 4.44772 17 5 17ZM5 19C6.65685 19 8 17.6569 8 16C8 14.3431 6.65685 13 5 13C3.34315 13 2 14.3431 2 16C2 17.6569 3.34315 19 5 19ZM19 17C19.5523 17 20 16.5523 20 16C20 15.4477 19.5523 15 19 15C18.4477 15 18 15.4477 18 16C18 16.5523 18.4477 17 19 17ZM19 19C20.6569 19 22 17.6569 22 16C22 14.3431 20.6569 13 19 13C17.3431 13 16 14.3431 16 16C16 17.6569 17.3431 19 19 19Z" fill="black"/>
+</svg>
diff --git a/examples/dbus/remotecontrolledcar/controller/connecting.svg b/examples/dbus/remotecontrolledcar/controller/connecting.svg
new file mode 100644
index 0000000000..4097d0b276
--- /dev/null
+++ b/examples/dbus/remotecontrolledcar/controller/connecting.svg
@@ -0,0 +1,4 @@
+<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path id="Layer01" d="M14 12C14 13.1046 13.1046 14 12 14C10.8954 14 10 13.1046 10 12C10 10.8954 10.8954 10 12 10C13.1046 10 14 10.8954 14 12Z" fill="#0D0D0D"/>
+<path id="Layer02" fill-rule="evenodd" clip-rule="evenodd" d="M3 12C3 14.2728 3.94193 16.5032 5.71196 18.2978C6.09978 18.691 6.09543 19.3241 5.70223 19.712C5.30902 20.0998 4.67587 20.0954 4.28805 19.7022C2.18112 17.5661 1 14.8427 1 12C1 9.15729 2.18112 6.43389 4.28805 4.29777C4.67587 3.90457 5.30902 3.90022 5.70223 4.28804C6.09543 4.67587 6.09978 5.30902 5.71195 5.70223C3.94193 7.49678 3 9.72715 3 12ZM8.80201 14.404C8.27734 13.6971 7.99902 12.8569 7.99902 12C7.99902 11.1431 8.27734 10.3029 8.80201 9.596C9.13117 9.15252 9.0385 8.52617 8.59502 8.19701C8.15154 7.86785 7.5252 7.96052 7.19604 8.404C6.41969 9.44998 5.99902 10.7067 5.99902 12C5.99902 13.2933 6.41969 14.55 7.19604 15.596C7.5252 16.0395 8.15154 16.1321 8.59502 15.803C9.0385 15.4738 9.13117 14.8475 8.80201 14.404ZM15.197 14.404C15.7217 13.6971 16 12.8569 16 12C16 11.1431 15.7217 10.3029 15.197 9.596C14.8679 9.15252 14.9605 8.52617 15.404 8.19701C15.8475 7.86785 16.4738 7.96052 16.803 8.404C17.5793 9.44998 18 10.7067 18 12C18 13.2933 17.5793 14.55 16.803 15.596C16.4738 16.0395 15.8475 16.1321 15.404 15.803C14.9605 15.4738 14.8679 14.8475 15.197 14.404ZM18.2871 18.2978C20.0571 16.5032 20.999 14.2728 20.999 12C20.999 9.72715 20.0571 7.49678 18.2871 5.70223C17.8992 5.30902 17.9036 4.67587 18.2968 4.28804C18.69 3.90022 19.3232 3.90457 19.711 4.29777C21.8179 6.43389 22.999 9.15729 22.999 12C22.999 14.8427 21.8179 17.5661 19.711 19.7022C19.3231 20.0954 18.69 20.0998 18.2968 19.712C17.9036 19.3241 17.8992 18.691 18.2871 18.2978Z" fill="#0D0D0D"/>
+</svg>
diff --git a/examples/dbus/remotecontrolledcar/controller/controller.cpp b/examples/dbus/remotecontrolledcar/controller/controller.cpp
index cb2e7591d8..ccff2b1743 100644
--- a/examples/dbus/remotecontrolledcar/controller/controller.cpp
+++ b/examples/dbus/remotecontrolledcar/controller/controller.cpp
@@ -1,92 +1,58 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtWidgets>
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "controller.h"
-#include "car_interface.h"
+#include <QGridLayout>
+#include <QHBoxLayout>
+
+using org::example::Examples::CarInterface;
-Controller::Controller(QWidget *parent)
- : QWidget(parent)
+Controller::Controller(QWidget *parent) : QWidget(parent)
{
- ui.setupUi(this);
- car = new org::example::Examples::CarInterface("org.example.CarExample", "/Car",
- QDBusConnection::sessionBus(), this);
+ car = new CarInterface("org.example.CarExample", "/Car", QDBusConnection::sessionBus(), this);
+
+ accelerate = new QPushButton(QIcon(":up.svg"), "", this);
+ accelerate->setFixedSize(80, 64);
+ accelerate->setIconSize(QSize(44, 44));
+ decelerate = new QPushButton(QIcon(":down.svg"), "", this);
+ decelerate->setFixedSize(80, 64);
+ decelerate->setIconSize(QSize(44, 44));
+ left = new QPushButton(QIcon(":left.svg"), "", this);
+ left->setFixedSize(64, 80);
+ left->setIconSize(QSize(44, 44));
+ right = new QPushButton(QIcon(":right.svg"), "", this);
+ right->setFixedSize(64, 80);
+ right->setIconSize(QSize(44, 44));
+
+ status = new QLabel(this);
+ statusSymbol = new QLabel(this);
+ statusSymbol->setFixedHeight(24);
+
+ QGridLayout *layout = new QGridLayout(this);
+ layout->addWidget(accelerate, 1, 1);
+ layout->addWidget(left, 2, 0);
+ layout->addWidget(right, 2, 2);
+ layout->addWidget(decelerate, 3, 1);
+
+ QHBoxLayout *statusLayout = new QHBoxLayout();
+ statusLayout->addWidget(status);
+ statusLayout->addWidget(statusSymbol);
+ layout->addLayout(statusLayout, 0, 1, 1, 2, Qt::AlignTop | Qt::AlignRight);
+
+ connect(accelerate, &QPushButton::clicked, car, &CarInterface::accelerate);
+ connect(decelerate, &QPushButton::clicked, car, &CarInterface::decelerate);
+ connect(left, &QPushButton::clicked, car, &CarInterface::turnLeft);
+ connect(right, &QPushButton::clicked, car, &CarInterface::turnRight);
+
startTimer(1000);
}
void Controller::timerEvent(QTimerEvent *event)
{
Q_UNUSED(event);
- if (car->isValid())
- ui.label->setText("connected");
- else
- ui.label->setText("disconnected");
-}
-
-void Controller::on_accelerate_clicked()
-{
- car->accelerate();
-}
-void Controller::on_decelerate_clicked()
-{
- car->decelerate();
-}
-
-void Controller::on_left_clicked()
-{
- car->turnLeft();
-}
-
-void Controller::on_right_clicked()
-{
- car->turnRight();
+ static QPixmap connectedIcon = QPixmap::fromImage(QImage(":connected.svg"));
+ static QPixmap connectingIcon = QPixmap::fromImage(QImage(":connecting.svg"));
+ status->setText(car->isValid() ? tr("connected") : tr("searching..."));
+ statusSymbol->setPixmap(car->isValid() ? connectedIcon : connectingIcon);
}
diff --git a/examples/dbus/remotecontrolledcar/controller/controller.h b/examples/dbus/remotecontrolledcar/controller/controller.h
index 87359661ba..8df4ed2d1e 100644
--- a/examples/dbus/remotecontrolledcar/controller/controller.h
+++ b/examples/dbus/remotecontrolledcar/controller/controller.h
@@ -1,57 +1,13 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef CONTROLLER_H
#define CONTROLLER_H
-#include "ui_controller.h"
+#include <QWidget>
+#include <QPushButton>
+#include <QLabel>
+
#include "car_interface.h"
class Controller : public QWidget
@@ -59,20 +15,19 @@ class Controller : public QWidget
Q_OBJECT
public:
- Controller(QWidget *parent = nullptr);
+ explicit Controller(QWidget *parent = nullptr);
protected:
- void timerEvent(QTimerEvent *event);
-
-private slots:
- void on_accelerate_clicked();
- void on_decelerate_clicked();
- void on_left_clicked();
- void on_right_clicked();
+ void timerEvent(QTimerEvent *event) override;
private:
- Ui::Controller ui;
org::example::Examples::CarInterface *car;
+ QPushButton *accelerate;
+ QPushButton *decelerate;
+ QPushButton *left;
+ QPushButton *right;
+ QLabel *statusSymbol;
+ QLabel *status;
};
#endif
diff --git a/examples/dbus/remotecontrolledcar/controller/controller.pro b/examples/dbus/remotecontrolledcar/controller/controller.pro
index 07767141f4..ce16f21f36 100644
--- a/examples/dbus/remotecontrolledcar/controller/controller.pro
+++ b/examples/dbus/remotecontrolledcar/controller/controller.pro
@@ -1,9 +1,9 @@
QT += dbus widgets
-DBUS_INTERFACES += car.xml
-FORMS += controller.ui
+DBUS_INTERFACES += ../common/car.xml
HEADERS += controller.h
SOURCES += main.cpp controller.cpp
+RESOURCES += icons.qrc
# Work-around CI issue. Not needed in user code.
CONFIG += no_batch
diff --git a/examples/dbus/remotecontrolledcar/controller/controller.ui b/examples/dbus/remotecontrolledcar/controller/controller.ui
deleted file mode 100644
index 379015bf30..0000000000
--- a/examples/dbus/remotecontrolledcar/controller/controller.ui
+++ /dev/null
@@ -1,64 +0,0 @@
-<ui version="4.0" >
- <class>Controller</class>
- <widget class="QWidget" name="Controller" >
- <property name="geometry" >
- <rect>
- <x>0</x>
- <y>0</y>
- <width>255</width>
- <height>111</height>
- </rect>
- </property>
- <property name="windowTitle" >
- <string>Controller</string>
- </property>
- <layout class="QGridLayout" >
- <property name="margin" >
- <number>9</number>
- </property>
- <property name="spacing" >
- <number>6</number>
- </property>
- <item row="1" column="1" >
- <widget class="QLabel" name="label" >
- <property name="text" >
- <string>Controller</string>
- </property>
- <property name="alignment" >
- <set>Qt::AlignCenter</set>
- </property>
- </widget>
- </item>
- <item row="2" column="1" >
- <widget class="QPushButton" name="decelerate" >
- <property name="text" >
- <string>Decelerate</string>
- </property>
- </widget>
- </item>
- <item row="0" column="1" >
- <widget class="QPushButton" name="accelerate" >
- <property name="text" >
- <string>Accelerate</string>
- </property>
- </widget>
- </item>
- <item row="1" column="2" >
- <widget class="QPushButton" name="right" >
- <property name="text" >
- <string>Right</string>
- </property>
- </widget>
- </item>
- <item row="1" column="0" >
- <widget class="QPushButton" name="left" >
- <property name="text" >
- <string>Left</string>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- <resources/>
- <connections/>
-</ui>
diff --git a/examples/dbus/remotecontrolledcar/controller/down.svg b/examples/dbus/remotecontrolledcar/controller/down.svg
new file mode 100644
index 0000000000..f9a417b65e
--- /dev/null
+++ b/examples/dbus/remotecontrolledcar/controller/down.svg
@@ -0,0 +1,3 @@
+<svg width="55" height="55" viewBox="0 0 55 55" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path fill-rule="evenodd" clip-rule="evenodd" d="M49.7455 16.7129C48.8505 15.8179 47.3995 15.8179 46.5046 16.7129L27.5 35.7174L8.49547 16.7129C7.60052 15.8179 6.14952 15.8179 5.25456 16.7129C4.35961 17.6078 4.35961 19.0588 5.25456 19.9538L25.8796 40.5788C26.7745 41.4737 28.2255 41.4737 29.1205 40.5788L49.7455 19.9538C50.6404 19.0588 50.6404 17.6078 49.7455 16.7129Z" fill="black"/>
+</svg>
diff --git a/examples/dbus/remotecontrolledcar/controller/icons.qrc b/examples/dbus/remotecontrolledcar/controller/icons.qrc
new file mode 100644
index 0000000000..0aad87cf32
--- /dev/null
+++ b/examples/dbus/remotecontrolledcar/controller/icons.qrc
@@ -0,0 +1,10 @@
+<RCC>
+ <qresource prefix="/">
+ <file>connected.svg</file>
+ <file>connecting.svg</file>
+ <file>down.svg</file>
+ <file>left.svg</file>
+ <file>right.svg</file>
+ <file>up.svg</file>
+ </qresource>
+</RCC>
diff --git a/examples/dbus/remotecontrolledcar/controller/left.svg b/examples/dbus/remotecontrolledcar/controller/left.svg
new file mode 100644
index 0000000000..12d6420f48
--- /dev/null
+++ b/examples/dbus/remotecontrolledcar/controller/left.svg
@@ -0,0 +1,3 @@
+<svg width="55" height="55" viewBox="0 0 55 55" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path fill-rule="evenodd" clip-rule="evenodd" d="M38.2871 5.25453C39.1821 6.14948 39.1821 7.60048 38.2871 8.49543L19.2826 27.5L38.2871 46.5045C39.1821 47.3995 39.1821 48.8505 38.2871 49.7454C37.3922 50.6404 35.9412 50.6404 35.0462 49.7454L14.4212 29.1204C13.5263 28.2255 13.5263 26.7745 14.4212 25.8795L35.0462 5.25453C35.9412 4.35958 37.3922 4.35958 38.2871 5.25453Z" fill="black"/>
+</svg>
diff --git a/examples/dbus/remotecontrolledcar/controller/main.cpp b/examples/dbus/remotecontrolledcar/controller/main.cpp
index 4aeff8635e..7d91048729 100644
--- a/examples/dbus/remotecontrolledcar/controller/main.cpp
+++ b/examples/dbus/remotecontrolledcar/controller/main.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QtWidgets>
diff --git a/examples/dbus/remotecontrolledcar/controller/right.svg b/examples/dbus/remotecontrolledcar/controller/right.svg
new file mode 100644
index 0000000000..26a39a74ca
--- /dev/null
+++ b/examples/dbus/remotecontrolledcar/controller/right.svg
@@ -0,0 +1,3 @@
+<svg width="55" height="55" viewBox="0 0 55 55" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path fill-rule="evenodd" clip-rule="evenodd" d="M16.7129 5.25453C15.8179 6.14948 15.8179 7.60048 16.7129 8.49543L35.7174 27.5L16.7129 46.5045C15.8179 47.3995 15.8179 48.8505 16.7129 49.7454C17.6078 50.6404 19.0588 50.6404 19.9538 49.7454L40.5788 29.1204C41.4737 28.2255 41.4737 26.7745 40.5788 25.8795L19.9538 5.25453C19.0588 4.35958 17.6078 4.35958 16.7129 5.25453Z" fill="black"/>
+</svg>
diff --git a/examples/dbus/remotecontrolledcar/controller/up.svg b/examples/dbus/remotecontrolledcar/controller/up.svg
new file mode 100644
index 0000000000..ea5f1bfcfb
--- /dev/null
+++ b/examples/dbus/remotecontrolledcar/controller/up.svg
@@ -0,0 +1,3 @@
+<svg width="55" height="55" viewBox="0 0 55 55" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path fill-rule="evenodd" clip-rule="evenodd" d="M49.7455 38.2871C48.8505 39.1821 47.3995 39.1821 46.5046 38.2871L27.5 19.2826L8.49547 38.2871C7.60052 39.1821 6.14952 39.1821 5.25456 38.2871C4.35961 37.3922 4.35961 35.9412 5.25456 35.0462L25.8796 14.4212C26.7745 13.5263 28.2255 13.5263 29.1205 14.4212L49.7455 35.0462C50.6404 35.9412 50.6404 37.3922 49.7455 38.2871Z" fill="black"/>
+</svg>
diff --git a/examples/dbus/remotecontrolledcar/doc/images/remotecontrolledcar-car-example.png b/examples/dbus/remotecontrolledcar/doc/images/remotecontrolledcar-car-example.png
deleted file mode 100644
index 7e08340c80..0000000000
--- a/examples/dbus/remotecontrolledcar/doc/images/remotecontrolledcar-car-example.png
+++ /dev/null
Binary files differ
diff --git a/examples/dbus/remotecontrolledcar/doc/images/remotecontrolledcar-car-example.webp b/examples/dbus/remotecontrolledcar/doc/images/remotecontrolledcar-car-example.webp
new file mode 100644
index 0000000000..958b466e9f
--- /dev/null
+++ b/examples/dbus/remotecontrolledcar/doc/images/remotecontrolledcar-car-example.webp
Binary files differ
diff --git a/examples/dbus/remotecontrolledcar/doc/src/dbus-remotecontrolledcar.qdoc b/examples/dbus/remotecontrolledcar/doc/src/dbus-remotecontrolledcar.qdoc
index e18f963103..94c914b642 100644
--- a/examples/dbus/remotecontrolledcar/doc/src/dbus-remotecontrolledcar.qdoc
+++ b/examples/dbus/remotecontrolledcar/doc/src/dbus-remotecontrolledcar.qdoc
@@ -1,40 +1,17 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\example remotecontrolledcar
- \title D-Bus Remote Controlled Car Example
+ \title D-Bus Remote Controlled Car
+ \examplecategory {Connectivity}
\ingroup examples-dbus
\brief Shows how to use Qt D-Bus to control a car from another application.
The Remote Controlled Car example shows how to use \l{Qt D-Bus} to control
one application from another.
- \image remotecontrolledcar-car-example.png
+ \image remotecontrolledcar-car-example.webp
\include examples-run.qdocinc
*/
diff --git a/examples/dbus/remotecontrolledcar/remotecontrolledcar.pro b/examples/dbus/remotecontrolledcar/remotecontrolledcar.pro
index 2a1fddb500..dd275b1099 100644
--- a/examples/dbus/remotecontrolledcar/remotecontrolledcar.pro
+++ b/examples/dbus/remotecontrolledcar/remotecontrolledcar.pro
@@ -1,3 +1,3 @@
TEMPLATE = subdirs
SUBDIRS = car \
- controller
+ controller