diff options
Diffstat (limited to 'examples')
1811 files changed, 12762 insertions, 84085 deletions
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index a4fb347ba5..2bc1e4d378 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -1,36 +1,39 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + qt_examples_build_begin(EXTERNAL_BUILD) add_subdirectory(corelib) add_subdirectory(embedded) add_subdirectory(qpa) -if(TARGET Qt::DBus) +if(TARGET Qt6::DBus) add_subdirectory(dbus) endif() -if(TARGET Qt::Network) +if(TARGET Qt6::Network) add_subdirectory(network) endif() -if(TARGET Qt::Test) +if(TARGET Qt6::Test) add_subdirectory(qtestlib) endif() -if(TARGET Qt::Concurrent) +if(TARGET Qt6::Concurrent) add_subdirectory(qtconcurrent) endif() -if(TARGET Qt::Sql) +if(TARGET Qt6::Sql) add_subdirectory(sql) endif() -if(TARGET Qt::Widgets) +if(TARGET Qt6::Widgets) add_subdirectory(widgets) endif() -if(TARGET Qt::Xml) +if(TARGET Qt6::Xml) add_subdirectory(xml) endif() -if(TARGET Qt::Gui) +if(TARGET Qt6::Gui) add_subdirectory(gui) endif() -if(QT_FEATURE_opengl AND TARGET Qt::Gui) +if(QT_FEATURE_opengl AND TARGET Qt6::Gui) add_subdirectory(opengl) endif() -if(QT_FEATURE_vulkan AND TARGET Qt::Gui) +if(QT_FEATURE_vulkan AND TARGET Qt6::Gui) add_subdirectory(vulkan) endif() diff --git a/examples/corelib/CMakeLists.txt b/examples/corelib/CMakeLists.txt index 08b44649b7..638db2dda9 100644 --- a/examples/corelib/CMakeLists.txt +++ b/examples/corelib/CMakeLists.txt @@ -1,10 +1,17 @@ -# Generated from corelib.pro. +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause add_subdirectory(ipc) add_subdirectory(mimetypes) add_subdirectory(serialization) add_subdirectory(tools) add_subdirectory(platform) +if(QT_FEATURE_permissions) + add_subdirectory(permissions) +endif() if(QT_FEATURE_thread) add_subdirectory(threads) endif() +if(QT_FEATURE_widgets) + add_subdirectory(bindableproperties) +endif() diff --git a/examples/corelib/bindableproperties/CMakeLists.txt b/examples/corelib/bindableproperties/CMakeLists.txt new file mode 100644 index 0000000000..c6d9076fd8 --- /dev/null +++ b/examples/corelib/bindableproperties/CMakeLists.txt @@ -0,0 +1,2 @@ +qt_internal_add_example(bindablesubscription) +qt_internal_add_example(subscription) diff --git a/examples/corelib/bindableproperties/bindableproperties.pro b/examples/corelib/bindableproperties/bindableproperties.pro new file mode 100644 index 0000000000..fab8d8107a --- /dev/null +++ b/examples/corelib/bindableproperties/bindableproperties.pro @@ -0,0 +1,4 @@ +TEMPLATE = subdirs +SUBDIRS = \ + bindablesubscription \ + subscription diff --git a/examples/corelib/bindableproperties/bindablesubscription/CMakeLists.txt b/examples/corelib/bindableproperties/bindablesubscription/CMakeLists.txt new file mode 100644 index 0000000000..c4a2e5fcfc --- /dev/null +++ b/examples/corelib/bindableproperties/bindablesubscription/CMakeLists.txt @@ -0,0 +1,50 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +cmake_minimum_required(VERSION 3.16) +project(bindablesubscription LANGUAGES CXX) + +if(NOT DEFINED INSTALL_EXAMPLESDIR) + set(INSTALL_EXAMPLESDIR "examples") +endif() + +set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/corelib/bindableproperties/bindablesubscription") + +find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets) + +qt_standard_project_setup() + +qt_add_executable(bindablesubscription + ../shared/subscriptionwindow.cpp ../shared/subscriptionwindow.h ../shared/subscriptionwindow.ui + main.cpp + bindablesubscription.cpp bindablesubscription.h + bindableuser.cpp bindableuser.h +) + +target_link_libraries(bindablesubscription PRIVATE + Qt6::Core + Qt6::Gui + Qt6::Widgets +) + +# Resources: +set(countries_resource_files + "../shared/finland.png" + "../shared/germany.png" + "../shared/norway.png" +) + +qt_add_resources(bindablesubscription "countries" + PREFIX + "/" + BASE + "../shared" + FILES + ${countries_resource_files} +) + +install(TARGETS bindablesubscription + RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" + BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" + LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" +) diff --git a/examples/corelib/bindableproperties/bindablesubscription/bindablesubscription.cpp b/examples/corelib/bindableproperties/bindablesubscription/bindablesubscription.cpp new file mode 100644 index 0000000000..a52b68f85b --- /dev/null +++ b/examples/corelib/bindableproperties/bindablesubscription/bindablesubscription.cpp @@ -0,0 +1,51 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause + +#include "bindablesubscription.h" +#include "bindableuser.h" + +//! [binding-expressions] + +BindableSubscription::BindableSubscription(BindableUser *user) : m_user(user) +{ + Q_ASSERT(user); + + m_price.setBinding([this] { return qRound(calculateDiscount() * m_duration * basePrice()); }); + + m_isValid.setBinding([this] { + return m_user->country() != BindableUser::Country::AnyCountry && m_user->age() > 12; + }); +} + +//! [binding-expressions] + +//! [set-duration] + +void BindableSubscription::setDuration(Duration newDuration) +{ + m_duration = newDuration; +} + +//! [set-duration] + +double BindableSubscription::calculateDiscount() const +{ + switch (m_duration) { + case Monthly: + return 1; + case Quarterly: + return 0.9; + case Yearly: + return 0.6; + } + Q_ASSERT(false); + return -1; +} + +int BindableSubscription::basePrice() const +{ + if (m_user->country() == BindableUser::Country::AnyCountry) + return 0; + + return (m_user->country() == BindableUser::Country::Norway) ? 100 : 80; +} diff --git a/examples/corelib/bindableproperties/bindablesubscription/bindablesubscription.h b/examples/corelib/bindableproperties/bindablesubscription/bindablesubscription.h new file mode 100644 index 0000000000..3406693b94 --- /dev/null +++ b/examples/corelib/bindableproperties/bindablesubscription/bindablesubscription.h @@ -0,0 +1,44 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause + +#ifndef BINDABLESUBSCRIPTION_H +#define BINDABLESUBSCRIPTION_H + +#include <QPointer> +#include <QProperty> + +class BindableUser; + +//! [bindable-subscription-class] + +class BindableSubscription +{ +public: + enum Duration { Monthly = 1, Quarterly = 3, Yearly = 12 }; + + BindableSubscription(BindableUser *user); + BindableSubscription(const BindableSubscription &) = delete; + + int price() const { return m_price; } + QBindable<int> bindablePrice() { return &m_price; } + + Duration duration() const { return m_duration; } + void setDuration(Duration newDuration); + QBindable<Duration> bindableDuration() { return &m_duration; } + + bool isValid() const { return m_isValid; } + QBindable<bool> bindableIsValid() { return &m_isValid; } + +private: + double calculateDiscount() const; + int basePrice() const; + + BindableUser *m_user; + QProperty<Duration> m_duration { Monthly }; + QProperty<int> m_price { 0 }; + QProperty<bool> m_isValid { false }; +}; + +//! [bindable-subscription-class] + +#endif // BNDABLESUBSCRIPTION_H diff --git a/examples/corelib/bindableproperties/bindablesubscription/bindablesubscription.pro b/examples/corelib/bindableproperties/bindablesubscription/bindablesubscription.pro new file mode 100644 index 0000000000..321a1226c4 --- /dev/null +++ b/examples/corelib/bindableproperties/bindablesubscription/bindablesubscription.pro @@ -0,0 +1,22 @@ +QT += widgets +TARGET = bindablesubscription + +SOURCES += main.cpp \ + bindablesubscription.cpp \ + bindableuser.cpp \ + ../shared/subscriptionwindow.cpp + +target.path = $$[QT_INSTALL_EXAMPLES]/corelib/bindableproperties/bindablesubscription +INSTALLS += target + +FORMS += \ + ../shared/subscriptionwindow.ui + +HEADERS += \ + bindablesubscription.h \ + bindableuser.h \ + ../shared/subscriptionwindow.h + +RESOURCES += \ + ../shared/countries.qrc + diff --git a/examples/corelib/bindableproperties/bindablesubscription/bindableuser.cpp b/examples/corelib/bindableproperties/bindablesubscription/bindableuser.cpp new file mode 100644 index 0000000000..9cc3b7a4a6 --- /dev/null +++ b/examples/corelib/bindableproperties/bindablesubscription/bindableuser.cpp @@ -0,0 +1,18 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause + +#include "bindableuser.h" + +//! [bindable-user-setters] + +void BindableUser::setCountry(Country country) +{ + m_country = country; +} + +void BindableUser::setAge(int age) +{ + m_age = age; +} + +//! [bindable-user-setters] diff --git a/examples/corelib/bindableproperties/bindablesubscription/bindableuser.h b/examples/corelib/bindableproperties/bindablesubscription/bindableuser.h new file mode 100644 index 0000000000..d172a7cb22 --- /dev/null +++ b/examples/corelib/bindableproperties/bindablesubscription/bindableuser.h @@ -0,0 +1,36 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause + +#ifndef BINDABLEUSER_H +#define BINDABLEUSER_H + +#include <QLocale> +#include <QProperty> + +//! [bindable-user-class] + +class BindableUser +{ +public: + using Country = QLocale::Territory; + +public: + BindableUser() = default; + BindableUser(const BindableUser &) = delete; + + Country country() const { return m_country; } + void setCountry(Country country); + QBindable<Country> bindableCountry() { return &m_country; } + + int age() const { return m_age; } + void setAge(int age); + QBindable<int> bindableAge() { return &m_age; } + +private: + QProperty<Country> m_country { QLocale::AnyTerritory }; + QProperty<int> m_age { 0 }; +}; + +//! [bindable-user-class] + +#endif // BINDABLEUSER_H diff --git a/examples/corelib/bindableproperties/bindablesubscription/main.cpp b/examples/corelib/bindableproperties/bindablesubscription/main.cpp new file mode 100644 index 0000000000..6cf73c1337 --- /dev/null +++ b/examples/corelib/bindableproperties/bindablesubscription/main.cpp @@ -0,0 +1,72 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause + +#include "../shared/subscriptionwindow.h" +#include "bindablesubscription.h" +#include "bindableuser.h" + +#include <QApplication> +#include <QButtonGroup> +#include <QLabel> +#include <QPushButton> +#include <QRadioButton> +#include <QSpinBox> + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + BindableUser user; + BindableSubscription subscription(&user); + + SubscriptionWindow w; + + // Initialize subscription data + QRadioButton *monthly = w.findChild<QRadioButton *>("btnMonthly"); + QObject::connect(monthly, &QRadioButton::clicked, [&] { + subscription.setDuration(BindableSubscription::Monthly); + }); + QRadioButton *quarterly = w.findChild<QRadioButton *>("btnQuarterly"); + QObject::connect(quarterly, &QRadioButton::clicked, [&] { + subscription.setDuration(BindableSubscription::Quarterly); + }); + QRadioButton *yearly = w.findChild<QRadioButton *>("btnYearly"); + QObject::connect(yearly, &QRadioButton::clicked, [&] { + subscription.setDuration(BindableSubscription::Yearly); + }); + + // Initialize user data + QPushButton *germany = w.findChild<QPushButton *>("btnGermany"); + QObject::connect(germany, &QPushButton::clicked, [&] { + user.setCountry(BindableUser::Country::Germany); + }); + QPushButton *finland = w.findChild<QPushButton *>("btnFinland"); + QObject::connect(finland, &QPushButton::clicked, [&] { + user.setCountry(BindableUser::Country::Finland); + }); + QPushButton *norway = w.findChild<QPushButton *>("btnNorway"); + QObject::connect(norway, &QPushButton::clicked, [&] { + user.setCountry(BindableUser::Country::Norway); + }); + + QSpinBox *ageSpinBox = w.findChild<QSpinBox *>("ageSpinBox"); + QObject::connect(ageSpinBox, &QSpinBox::valueChanged, [&](int value) { + user.setAge(value); + }); + + QLabel *priceDisplay = w.findChild<QLabel *>("priceDisplay"); + + // Track price changes +//! [update-ui] + auto priceChangeHandler = subscription.bindablePrice().subscribe([&] { + QLocale lc{QLocale::AnyLanguage, user.country()}; + priceDisplay->setText(lc.toCurrencyString(subscription.price() / subscription.duration())); + }); + + auto priceValidHandler = subscription.bindableIsValid().subscribe([&] { + priceDisplay->setEnabled(subscription.isValid()); + }); +//! [update-ui] + + w.show(); + return a.exec(); +} diff --git a/examples/corelib/bindableproperties/doc/images/bindable_properties_example.png b/examples/corelib/bindableproperties/doc/images/bindable_properties_example.png Binary files differnew file mode 100644 index 0000000000..f38261a217 --- /dev/null +++ b/examples/corelib/bindableproperties/doc/images/bindable_properties_example.png diff --git a/examples/corelib/bindableproperties/doc/src/bindableproperties.qdoc b/examples/corelib/bindableproperties/doc/src/bindableproperties.qdoc new file mode 100644 index 0000000000..e63662dfbb --- /dev/null +++ b/examples/corelib/bindableproperties/doc/src/bindableproperties.qdoc @@ -0,0 +1,178 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only + +/*! + \example bindableproperties + \title Bindable Properties Example + \brief Demonstrates how the usage of bindable properties can simplify + your C++ code. + + In this example we will demonstrate two approaches for expressing the + relationships between different objects depending on each other: + signal/slot connection-based and bindable property-based. For this + purpose we will consider a subscription service model to calculate the + cost of the subscription. + + \image bindable_properties_example.png + + \section1 Modeling Subscription System with Signal/Slot Approach + + Let's first consider the usual pre-Qt 6 implementation. + To model the subscription service the \c Subscription class is used: + + \snippet bindableproperties/subscription/subscription.h subscription-class + + It stores the information about the subscription and provides corresponding + getters, setters, and notifier signals for informing the listeners about the + subscription information changes. It also keeps a pointer to an instance of + the \c User class. + + The price of the subscription is calculated based on the duration of the + subscription: + + \snippet bindableproperties/subscription/subscription.cpp calculate-discount + + And user's location: + + \snippet bindableproperties/subscription/subscription.cpp calculate-base-price + + When the price changes, the \c priceChanged() signal is emitted, to notify the + listeners about the change: + + \snippet bindableproperties/subscription/subscription.cpp calculate-price + + Similarly, when the duration of the subscription changes, the \c durationChanged() + signal is emitted. + + \snippet bindableproperties/subscription/subscription.cpp set-duration + + \note Both methods need to check if the data is actually changed and + only then emit the signals. \c setDuration() also needs to recalculate + the price when the duration has changed. + + The \c Subscription is not valid unless the user has a valid country and + age, so the validity is updated in the following way: + + \snippet bindableproperties/subscription/subscription.cpp update-validity + + The \c User class is simple: it stores country and age of the user and + provides the corresponding getters, setters, and notifier signals: + + \snippet bindableproperties/subscription/user.h user-class + + \snippet bindableproperties/subscription/user.cpp user-setters + + In the \c main() function we initialize instances of \c User and + \c Subscription: + + \snippet bindableproperties/subscription/main.cpp init + + And do the proper signal-slot connections to update the \c user and + \c subscription data when UI elements change. That is straightforward, + so we will skip this part. + + Next, we connect to \c Subscription::priceChanged() to update the price + in the UI when the price changes. + + \snippet bindableproperties/subscription/main.cpp connect-price-changed + + We also connect to \c Subscription::isValidChanged() to disable the price + display if the subscription isn't valid. + + \snippet bindableproperties/subscription/main.cpp connect-validity-changed + + Because the subscription price and validity also depend on the user's + country and age, we also need to connect to the \c User::countryChanged() + and \c User::ageChanged() signals and update \c subscription accordingly. + + \snippet bindableproperties/subscription/main.cpp connect-user + + This works, but there are some problems: + + \list + \li There's a lot of boilerplate code for the signal-slot connections + in order to properly track changes to both \c user and \c subscription. + If any of the dependencies of the price changes, we need to remember to emit the + corresponding notifier signals, recalculate the price, and update it in + the UI. + \li If more dependencies for price calculation are added in the future, we'll + need to add more signal-slot connections and make sure all the dependencies + are properly updated whenever any of them changes. The overall complexity + will grow, and the code will become harder to maintain. + \li The \c Subscription and \c User classes depend on the metaobject system + to be able to use the signal/slot mechanism. + \endlist + + Can we do better? + + \section1 Modeling Subscription System with Bindbable Properties + + Now let's see how the \l {Qt Bindable Properties} can help to solve the + same problem. First, let's have a look at the \c BindableSubscription class, + which is similar to the \c Subscription class, but is implemented using + bindable properties: + + \snippet bindableproperties/bindablesubscription/bindablesubscription.h bindable-subscription-class + + The first difference we can notice, is that the data fields are now wrapped + inside \l QProperty classes, and the notifier signals (and as a consequence the + dependency from the metaobject system) are gone, and new methods returning a + \l QBindable for each \l QProperty are added instead. The \c calculatePrice() + and \c updateValidty() methods are also removed. We'll see below why they aren't + needed anymore. + + The \c BindableUser class differs from the \c User class in a similar way: + + \snippet bindableproperties/bindablesubscription/bindableuser.h bindable-user-class + + The second difference is in the implementation of these classes. First of + all, the dependencies between \c subscription and \c user are now tracked via + binding expressions: + + \snippet bindableproperties/bindablesubscription/bindablesubscription.cpp binding-expressions + + Behind the scenes the bindable properties track the dependency changes and + update the property's value whenever a change is detected. So if, for example, + user's country or age is changed, subscription's price and validity will be + updated automatically. + + Another difference is that the setters are now trivial: + + \snippet bindableproperties/bindablesubscription/bindablesubscription.cpp set-duration + + \snippet bindableproperties/bindablesubscription/bindableuser.cpp bindable-user-setters + + There's no need to check inside the setters if the property's value has + actually changed, \l QProperty already does that. The dependent properties + will be notified about the change only if the value has actually changed. + + The code for updating the information about the price in the UI is also + simplified: + + \snippet bindableproperties/bindablesubscription/main.cpp update-ui + + We subscribe to changes via \c bindablePrice() and \c bindableIsValid() + and update the price display accordingly when any of these properties + changes the value. The subscriptions will stay alive as long as the + corresponding handlers are alive. + + Also note that the copy constructors of both \c BindableSubscription and + \c BindableUser are disabled, since it's not defined what should happen + with their bindings when copying. + + As you can see, the code became much simpler, and the problems mentioned + above are solved: + + \list + \li The boilerplate code for the signal-slot connections is removed, the + dependencies are now tracked automatically. + \li The code is easier to maintain. Adding more dependencies in the future + will only require adding the corresponding bindable properties and setting + the binding expressions that reflect the relationships between each other. + \li The \c Subscription and \c User classes don't depend on the metaobject + system anymore. Of course, you can still expose them to the metaobject + system and add \l {Q_PROPERTY}s if you need, and have the advantages of + bindable properties both in \c C++ and \c QML code. You can use the + \l QObjectBindableProperty class for that. + \endlist +*/ diff --git a/examples/corelib/bindableproperties/shared/countries.qrc b/examples/corelib/bindableproperties/shared/countries.qrc new file mode 100644 index 0000000000..cdf6312ebb --- /dev/null +++ b/examples/corelib/bindableproperties/shared/countries.qrc @@ -0,0 +1,7 @@ +<RCC> + <qresource prefix="/"> + <file>germany.png</file> + <file>norway.png</file> + <file>finland.png</file> + </qresource> +</RCC> diff --git a/examples/corelib/bindableproperties/shared/finland.png b/examples/corelib/bindableproperties/shared/finland.png Binary files differnew file mode 100644 index 0000000000..92653289c1 --- /dev/null +++ b/examples/corelib/bindableproperties/shared/finland.png diff --git a/examples/corelib/bindableproperties/shared/germany.png b/examples/corelib/bindableproperties/shared/germany.png Binary files differnew file mode 100644 index 0000000000..efc389f52a --- /dev/null +++ b/examples/corelib/bindableproperties/shared/germany.png diff --git a/examples/corelib/bindableproperties/shared/norway.png b/examples/corelib/bindableproperties/shared/norway.png Binary files differnew file mode 100644 index 0000000000..daee6c3c15 --- /dev/null +++ b/examples/corelib/bindableproperties/shared/norway.png diff --git a/examples/corelib/bindableproperties/shared/subscriptionwindow.cpp b/examples/corelib/bindableproperties/shared/subscriptionwindow.cpp new file mode 100644 index 0000000000..0e17283d40 --- /dev/null +++ b/examples/corelib/bindableproperties/shared/subscriptionwindow.cpp @@ -0,0 +1,16 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause + +#include "subscriptionwindow.h" +#include "ui_subscriptionwindow.h" + +SubscriptionWindow::SubscriptionWindow(QWidget *parent) + : QWidget(parent), ui(new Ui::SubscriptionWindow) +{ + ui->setupUi(this); +} + +SubscriptionWindow::~SubscriptionWindow() +{ + delete ui; +} diff --git a/examples/corelib/bindableproperties/shared/subscriptionwindow.h b/examples/corelib/bindableproperties/shared/subscriptionwindow.h new file mode 100644 index 0000000000..75f6a1eb83 --- /dev/null +++ b/examples/corelib/bindableproperties/shared/subscriptionwindow.h @@ -0,0 +1,29 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause + +#ifndef SUBSCRIPTIONWINDOW_H +#define SUBSCRIPTIONWINDOW_H + +#include <QWidget> + +QT_BEGIN_NAMESPACE +namespace Ui { +class SubscriptionWindow; +} +QT_END_NAMESPACE + +class User; + +class SubscriptionWindow : public QWidget +{ + Q_OBJECT + +public: + explicit SubscriptionWindow(QWidget *parent = nullptr); + ~SubscriptionWindow(); + +private: + Ui::SubscriptionWindow *ui; +}; + +#endif // SUBSCRIPTIONWINDOW_H diff --git a/examples/corelib/bindableproperties/shared/subscriptionwindow.ui b/examples/corelib/bindableproperties/shared/subscriptionwindow.ui new file mode 100644 index 0000000000..7bc2931373 --- /dev/null +++ b/examples/corelib/bindableproperties/shared/subscriptionwindow.ui @@ -0,0 +1,280 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>SubscriptionWindow</class> + <widget class="QWidget" name="SubscriptionWindow"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>639</width> + <height>269</height> + </rect> + </property> + <property name="windowTitle"> + <string>Subscription</string> + </property> + <layout class="QHBoxLayout" name="horizontalLayout_5"> + <item> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_4" stretch="0,0,0,0"> + <item> + <spacer name="horizontalSpacer_3"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QPushButton" name="btnGermany"> + <property name="toolTip"> + <string>Germany</string> + </property> + <property name="text"> + <string/> + </property> + <property name="icon"> + <iconset> + <normaloff>:/germany.png</normaloff>:/germany.png</iconset> + </property> + <property name="iconSize"> + <size> + <width>32</width> + <height>32</height> + </size> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="btnNorway"> + <property name="toolTip"> + <string>Norway</string> + </property> + <property name="text"> + <string/> + </property> + <property name="icon"> + <iconset> + <normaloff>:/norway.png</normaloff>:/norway.png</iconset> + </property> + <property name="iconSize"> + <size> + <width>32</width> + <height>32</height> + </size> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="btnFinland"> + <property name="toolTip"> + <string>Finland</string> + </property> + <property name="text"> + <string/> + </property> + <property name="icon"> + <iconset> + <normaloff>:/finland.png</normaloff>:/finland.png</iconset> + </property> + <property name="iconSize"> + <size> + <width>32</width> + <height>32</height> + </size> + </property> + </widget> + </item> + </layout> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QLabel" name="ageLabel"> + <property name="font"> + <font> + <pointsize>14</pointsize> + <weight>75</weight> + <bold>true</bold> + </font> + </property> + <property name="text"> + <string>Age</string> + </property> + <property name="margin"> + <number>3</number> + </property> + </widget> + </item> + <item> + <widget class="QSpinBox" name="ageSpinBox"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>80</width> + <height>0</height> + </size> + </property> + <property name="value"> + <number>0</number> + </property> + </widget> + </item> + <item> + <spacer name="horizontalSpacer"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + </layout> + </item> + <item> + <spacer name="verticalSpacer"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>40</height> + </size> + </property> + </spacer> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_2"> + <item> + <widget class="QLabel" name="intervalLabel"> + <property name="font"> + <font> + <pointsize>14</pointsize> + <weight>75</weight> + <bold>true</bold> + </font> + </property> + <property name="text"> + <string>Interval</string> + </property> + <property name="margin"> + <number>3</number> + </property> + </widget> + </item> + <item> + <widget class="QRadioButton" name="btnMonthly"> + <property name="text"> + <string>Monthly</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="QRadioButton" name="btnQuarterly"> + <property name="text"> + <string>Quarterly</string> + </property> + </widget> + </item> + <item> + <widget class="QRadioButton" name="btnYearly"> + <property name="text"> + <string>Yearly</string> + </property> + </widget> + </item> + </layout> + </item> + <item> + <spacer name="verticalSpacer_2"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>40</height> + </size> + </property> + </spacer> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_3"> + <item> + <widget class="QLabel" name="priceLabel"> + <property name="font"> + <font> + <pointsize>14</pointsize> + <weight>75</weight> + <bold>true</bold> + </font> + </property> + <property name="text"> + <string>Price/month</string> + </property> + <property name="margin"> + <number>3</number> + </property> + </widget> + </item> + <item> + <widget class="QLabel" name="priceDisplay"> + <property name="text"> + <string>0.0</string> + </property> + </widget> + </item> + <item> + <spacer name="horizontalSpacer_2"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + </layout> + </item> + <item> + <spacer name="verticalSpacer_3"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>40</height> + </size> + </property> + </spacer> + </item> + </layout> + </item> + </layout> + </widget> + <resources/> + <connections/> +</ui> diff --git a/examples/corelib/bindableproperties/subscription/CMakeLists.txt b/examples/corelib/bindableproperties/subscription/CMakeLists.txt new file mode 100644 index 0000000000..0dd027fc24 --- /dev/null +++ b/examples/corelib/bindableproperties/subscription/CMakeLists.txt @@ -0,0 +1,50 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +cmake_minimum_required(VERSION 3.16) +project(subscription LANGUAGES CXX) + +if(NOT DEFINED INSTALL_EXAMPLESDIR) + set(INSTALL_EXAMPLESDIR "examples") +endif() + +set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/corelib/bindableproperties/subscription") + +find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets) + +qt_standard_project_setup() + +qt_add_executable(subscription + ../shared/subscriptionwindow.cpp ../shared/subscriptionwindow.h ../shared/subscriptionwindow.ui + main.cpp + subscription.cpp subscription.h + user.cpp user.h +) + +target_link_libraries(subscription PRIVATE + Qt6::Core + Qt6::Gui + Qt6::Widgets +) + +# Resources: +set(countries_resource_files + "../shared/finland.png" + "../shared/germany.png" + "../shared/norway.png" +) + +qt_add_resources(subscription "countries" + PREFIX + "/" + BASE + "../shared" + FILES + ${countries_resource_files} +) + +install(TARGETS subscription + RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" + BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" + LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" +) diff --git a/examples/corelib/bindableproperties/subscription/main.cpp b/examples/corelib/bindableproperties/subscription/main.cpp new file mode 100644 index 0000000000..1f41486728 --- /dev/null +++ b/examples/corelib/bindableproperties/subscription/main.cpp @@ -0,0 +1,92 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause + +#include "../shared/subscriptionwindow.h" +#include "subscription.h" +#include "user.h" + +#include <QApplication> +#include <QButtonGroup> +#include <QLabel> +#include <QPushButton> +#include <QRadioButton> +#include <QSpinBox> + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + +//! [init] + User user; + Subscription subscription(&user); +//! [init] + + SubscriptionWindow w; + + // Initialize subscription data + QRadioButton *monthly = w.findChild<QRadioButton *>("btnMonthly"); + QObject::connect(monthly, &QRadioButton::clicked, &subscription, [&] { + subscription.setDuration(Subscription::Monthly); + }); + QRadioButton *quarterly = w.findChild<QRadioButton *>("btnQuarterly"); + QObject::connect(quarterly, &QRadioButton::clicked, &subscription, [&] { + subscription.setDuration(Subscription::Quarterly); + }); + QRadioButton *yearly = w.findChild<QRadioButton *>("btnYearly"); + QObject::connect(yearly, &QRadioButton::clicked, &subscription, [&] { + subscription.setDuration(Subscription::Yearly); + }); + + // Initialize user data + QPushButton *germany = w.findChild<QPushButton *>("btnGermany"); + QObject::connect(germany, &QPushButton::clicked, &user, [&] { + user.setCountry(User::Country::Germany); + }); + QPushButton *finland = w.findChild<QPushButton *>("btnFinland"); + QObject::connect(finland, &QPushButton::clicked, &user, [&] { + user.setCountry(User::Country::Finland); + }); + QPushButton *norway = w.findChild<QPushButton *>("btnNorway"); + QObject::connect(norway, &QPushButton::clicked, &user, [&] { + user.setCountry(User::Country::Norway); + }); + + QSpinBox *ageSpinBox = w.findChild<QSpinBox *>("ageSpinBox"); + QObject::connect(ageSpinBox, &QSpinBox::valueChanged, &user, [&](int value) { + user.setAge(value); + }); + + // Initialize price data + QLabel *priceDisplay = w.findChild<QLabel *>("priceDisplay"); + priceDisplay->setText(QString::number(subscription.price())); + priceDisplay->setEnabled(subscription.isValid()); + + // Track the price changes + +//! [connect-price-changed] + QObject::connect(&subscription, &Subscription::priceChanged, [&] { + QLocale lc{QLocale::AnyLanguage, user.country()}; + priceDisplay->setText(lc.toCurrencyString(subscription.price() / subscription.duration())); + }); +//! [connect-price-changed] + +//! [connect-validity-changed] + QObject::connect(&subscription, &Subscription::isValidChanged, [&] { + priceDisplay->setEnabled(subscription.isValid()); + }); +//! [connect-validity-changed] + +//! [connect-user] + QObject::connect(&user, &User::countryChanged, [&] { + subscription.calculatePrice(); + subscription.updateValidity(); + }); + + QObject::connect(&user, &User::ageChanged, [&] { + subscription.updateValidity(); + }); +//! [connect-user] + + w.show(); + return a.exec(); +} diff --git a/examples/corelib/bindableproperties/subscription/subscription.cpp b/examples/corelib/bindableproperties/subscription/subscription.cpp new file mode 100644 index 0000000000..5d040f76d9 --- /dev/null +++ b/examples/corelib/bindableproperties/subscription/subscription.cpp @@ -0,0 +1,79 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause + +#include "subscription.h" +#include "user.h" + +Subscription::Subscription(User *user) : m_user(user) +{ + Q_ASSERT(user); +} + +//! [calculate-price] + +void Subscription::calculatePrice() +{ + const auto oldPrice = m_price; + + m_price = qRound(calculateDiscount() * m_duration * basePrice()); + if (m_price != oldPrice) + emit priceChanged(); +} + +//! [calculate-price] + +//! [set-duration] + +void Subscription::setDuration(Duration newDuration) +{ + if (newDuration != m_duration) { + m_duration = newDuration; + calculatePrice(); + emit durationChanged(); + } +} + +//! [set-duration] + +//! [calculate-discount] + +double Subscription::calculateDiscount() const +{ + switch (m_duration) { + case Monthly: + return 1; + case Quarterly: + return 0.9; + case Yearly: + return 0.6; + } + Q_ASSERT(false); + return -1; +} + +//! [calculate-discount] + +//! [calculate-base-price] + +int Subscription::basePrice() const +{ + if (m_user->country() == User::Country::AnyTerritory) + return 0; + + return (m_user->country() == User::Country::Norway) ? 100 : 80; +} + +//! [calculate-base-price] + +//! [update-validity] + +void Subscription::updateValidity() +{ + bool isValid = m_isValid; + m_isValid = m_user->country() != User::Country::AnyTerritory && m_user->age() > 12; + + if (m_isValid != isValid) + emit isValidChanged(); +} + +//! [update-validity] diff --git a/examples/corelib/bindableproperties/subscription/subscription.h b/examples/corelib/bindableproperties/subscription/subscription.h new file mode 100644 index 0000000000..8f0d34e948 --- /dev/null +++ b/examples/corelib/bindableproperties/subscription/subscription.h @@ -0,0 +1,48 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause + +#ifndef SUBSCRIPTION_H +#define SUBSCRIPTION_H + +#include <QObject> +#include <QPointer> + +class User; + +//! [subscription-class] + +class Subscription : public QObject +{ + Q_OBJECT +public: + enum Duration { Monthly = 1, Quarterly = 3, Yearly = 12 }; + + Subscription(User *user); + + void calculatePrice(); + int price() const { return m_price; } + + Duration duration() const { return m_duration; } + void setDuration(Duration newDuration); + + bool isValid() const { return m_isValid; } + void updateValidity(); + +signals: + void priceChanged(); + void durationChanged(); + void isValidChanged(); + +private: + double calculateDiscount() const; + int basePrice() const; + + QPointer<User> m_user; + Duration m_duration = Monthly; + int m_price = 0; + bool m_isValid = false; +}; + +//! [subscription-class] + +#endif // SUBSCRIPTION_H diff --git a/examples/corelib/bindableproperties/subscription/subscription.pro b/examples/corelib/bindableproperties/subscription/subscription.pro new file mode 100644 index 0000000000..68910904bb --- /dev/null +++ b/examples/corelib/bindableproperties/subscription/subscription.pro @@ -0,0 +1,22 @@ +QT += widgets +TARGET = subscription + +SOURCES += main.cpp \ + subscription.cpp \ + user.cpp \ + ../shared/subscriptionwindow.cpp + +target.path = $$[QT_INSTALL_EXAMPLES]/corelib/bindableproperties/subscription +INSTALLS += target + +FORMS += \ + ../shared/subscriptionwindow.ui + +HEADERS += \ + subscription.h \ + user.h \ + ../shared/subscriptionwindow.h + +RESOURCES += \ + ../shared/countries.qrc + diff --git a/examples/corelib/bindableproperties/subscription/user.cpp b/examples/corelib/bindableproperties/subscription/user.cpp new file mode 100644 index 0000000000..575bcb13ee --- /dev/null +++ b/examples/corelib/bindableproperties/subscription/user.cpp @@ -0,0 +1,24 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause + +#include "user.h" + +//! [user-setters] + +void User::setCountry(Country country) +{ + if (m_country != country) { + m_country = country; + emit countryChanged(); + } +} + +void User::setAge(int age) +{ + if (m_age != age) { + m_age = age; + emit ageChanged(); + } +} + +//! [user-setters] diff --git a/examples/corelib/bindableproperties/subscription/user.h b/examples/corelib/bindableproperties/subscription/user.h new file mode 100644 index 0000000000..dd32a4fe23 --- /dev/null +++ b/examples/corelib/bindableproperties/subscription/user.h @@ -0,0 +1,36 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause + +#ifndef USER_H +#define USER_H + +#include <QLocale> +#include <QObject> + +//! [user-class] + +class User : public QObject +{ + Q_OBJECT + +public: + using Country = QLocale::Territory; + +public: + Country country() const { return m_country; } + void setCountry(Country country); + + int age() const { return m_age; } + void setAge(int age); + +signals: + void countryChanged(); + void ageChanged(); + +private: + Country m_country { QLocale::AnyTerritory }; + int m_age { 0 }; +}; + +//! [user-class] +#endif // USER_H diff --git a/examples/corelib/ipc/CMakeLists.txt b/examples/corelib/ipc/CMakeLists.txt index 214fa4c553..d1cfc7bc1b 100644 --- a/examples/corelib/ipc/CMakeLists.txt +++ b/examples/corelib/ipc/CMakeLists.txt @@ -1,12 +1,13 @@ -# Generated from ipc.pro. +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause -if(NOT TARGET Qt::Widgets) +if(NOT TARGET Qt6::Widgets) return() endif() if(QT_FEATURE_sharedmemory) qt_internal_add_example(sharedmemory) endif() -if(QT_FEATURE_localserver AND TARGET Qt::Network) +if(QT_FEATURE_localserver AND TARGET Qt6::Network) qt_internal_add_example(localfortuneserver) qt_internal_add_example(localfortuneclient) endif() diff --git a/examples/corelib/ipc/doc/src/localfortuneclient.qdoc b/examples/corelib/ipc/doc/src/localfortuneclient.qdoc index 0ccc1f3a4e..f7fa46c932 100644 --- a/examples/corelib/ipc/doc/src/localfortuneclient.qdoc +++ b/examples/corelib/ipc/doc/src/localfortuneclient.qdoc @@ -1,29 +1,5 @@ -/**************************************************************************** -** -** 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 ipc/localfortuneclient diff --git a/examples/corelib/ipc/doc/src/localfortuneserver.qdoc b/examples/corelib/ipc/doc/src/localfortuneserver.qdoc index 8d44c99617..281fd3b4be 100644 --- a/examples/corelib/ipc/doc/src/localfortuneserver.qdoc +++ b/examples/corelib/ipc/doc/src/localfortuneserver.qdoc @@ -1,29 +1,5 @@ -/**************************************************************************** -** -** 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 ipc/localfortuneserver diff --git a/examples/corelib/ipc/doc/src/sharedmemory.qdoc b/examples/corelib/ipc/doc/src/sharedmemory.qdoc index fb2ae21812..7ea4ffb25d 100644 --- a/examples/corelib/ipc/doc/src/sharedmemory.qdoc +++ b/examples/corelib/ipc/doc/src/sharedmemory.qdoc @@ -1,29 +1,5 @@ -/**************************************************************************** -** -** 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 ipc/sharedmemory diff --git a/examples/corelib/ipc/localfortuneclient/CMakeLists.txt b/examples/corelib/ipc/localfortuneclient/CMakeLists.txt index e989a8e87f..b3337e1f46 100644 --- a/examples/corelib/ipc/localfortuneclient/CMakeLists.txt +++ b/examples/corelib/ipc/localfortuneclient/CMakeLists.txt @@ -1,38 +1,34 @@ -# Generated from localfortuneclient.pro. +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause cmake_minimum_required(VERSION 3.16) project(localfortuneclient 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") + set(INSTALL_EXAMPLESDIR "examples") endif() set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/corelib/ipc/localfortuneclient") -find_package(Qt6 COMPONENTS Core) -find_package(Qt6 COMPONENTS Gui) -find_package(Qt6 COMPONENTS Network) -find_package(Qt6 COMPONENTS Widgets) +find_package(Qt6 REQUIRED COMPONENTS Core Gui Network Widgets) + +qt_standard_project_setup() qt_add_executable(localfortuneclient client.cpp client.h main.cpp ) + set_target_properties(localfortuneclient PROPERTIES WIN32_EXECUTABLE TRUE MACOSX_BUNDLE TRUE ) -target_link_libraries(localfortuneclient PUBLIC - Qt::Core - Qt::Gui - Qt::Network - Qt::Widgets + +target_link_libraries(localfortuneclient PRIVATE + Qt6::Core + Qt6::Gui + Qt6::Network + Qt6::Widgets ) install(TARGETS localfortuneclient diff --git a/examples/corelib/ipc/localfortuneclient/client.cpp b/examples/corelib/ipc/localfortuneclient/client.cpp index 1ab0c34d6c..31f8cf475b 100644 --- a/examples/corelib/ipc/localfortuneclient/client.cpp +++ b/examples/corelib/ipc/localfortuneclient/client.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> #include <QtNetwork> diff --git a/examples/corelib/ipc/localfortuneclient/client.h b/examples/corelib/ipc/localfortuneclient/client.h index 7248428440..c7275252fe 100644 --- a/examples/corelib/ipc/localfortuneclient/client.h +++ b/examples/corelib/ipc/localfortuneclient/client.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 CLIENT_H #define CLIENT_H diff --git a/examples/corelib/ipc/localfortuneclient/main.cpp b/examples/corelib/ipc/localfortuneclient/main.cpp index ed5cf4c569..3c2a7b284c 100644 --- a/examples/corelib/ipc/localfortuneclient/main.cpp +++ b/examples/corelib/ipc/localfortuneclient/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 <QApplication> diff --git a/examples/corelib/ipc/localfortuneserver/CMakeLists.txt b/examples/corelib/ipc/localfortuneserver/CMakeLists.txt index 85ec67238a..411fc04eb5 100644 --- a/examples/corelib/ipc/localfortuneserver/CMakeLists.txt +++ b/examples/corelib/ipc/localfortuneserver/CMakeLists.txt @@ -1,38 +1,34 @@ -# Generated from localfortuneserver.pro. +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause cmake_minimum_required(VERSION 3.16) project(localfortuneserver 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") + set(INSTALL_EXAMPLESDIR "examples") endif() set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/corelib/ipc/localfortuneserver") -find_package(Qt6 COMPONENTS Core) -find_package(Qt6 COMPONENTS Gui) -find_package(Qt6 COMPONENTS Network) -find_package(Qt6 COMPONENTS Widgets) +find_package(Qt6 REQUIRED COMPONENTS Core Gui Network Widgets) + +qt_standard_project_setup() qt_add_executable(localfortuneserver main.cpp server.cpp server.h ) + set_target_properties(localfortuneserver PROPERTIES WIN32_EXECUTABLE TRUE MACOSX_BUNDLE TRUE ) -target_link_libraries(localfortuneserver PUBLIC - Qt::Core - Qt::Gui - Qt::Network - Qt::Widgets + +target_link_libraries(localfortuneserver PRIVATE + Qt6::Core + Qt6::Gui + Qt6::Network + Qt6::Widgets ) install(TARGETS localfortuneserver diff --git a/examples/corelib/ipc/localfortuneserver/main.cpp b/examples/corelib/ipc/localfortuneserver/main.cpp index 430005a1d3..291a6b3f22 100644 --- a/examples/corelib/ipc/localfortuneserver/main.cpp +++ b/examples/corelib/ipc/localfortuneserver/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 <QApplication> diff --git a/examples/corelib/ipc/localfortuneserver/server.cpp b/examples/corelib/ipc/localfortuneserver/server.cpp index 9be5ed5051..bfdf425f5d 100644 --- a/examples/corelib/ipc/localfortuneserver/server.cpp +++ b/examples/corelib/ipc/localfortuneserver/server.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 "server.h" diff --git a/examples/corelib/ipc/localfortuneserver/server.h b/examples/corelib/ipc/localfortuneserver/server.h index 6b90ba5932..26e4792347 100644 --- a/examples/corelib/ipc/localfortuneserver/server.h +++ b/examples/corelib/ipc/localfortuneserver/server.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 SERVER_H #define SERVER_H diff --git a/examples/corelib/ipc/sharedmemory/CMakeLists.txt b/examples/corelib/ipc/sharedmemory/CMakeLists.txt index c98caf79f8..21f5ff339b 100644 --- a/examples/corelib/ipc/sharedmemory/CMakeLists.txt +++ b/examples/corelib/ipc/sharedmemory/CMakeLists.txt @@ -1,36 +1,33 @@ -# Generated from sharedmemory.pro. +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause cmake_minimum_required(VERSION 3.16) project(sharedmemory 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") + set(INSTALL_EXAMPLESDIR "examples") endif() set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/corelib/ipc/sharedmemory") -find_package(Qt6 COMPONENTS Core) -find_package(Qt6 COMPONENTS Gui) -find_package(Qt6 COMPONENTS Widgets) +find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets) + +qt_standard_project_setup() qt_add_executable(sharedmemory dialog.cpp dialog.h dialog.ui main.cpp ) + set_target_properties(sharedmemory PROPERTIES WIN32_EXECUTABLE TRUE MACOSX_BUNDLE TRUE ) -target_link_libraries(sharedmemory PUBLIC - Qt::Core - Qt::Gui - Qt::Widgets + +target_link_libraries(sharedmemory PRIVATE + Qt6::Core + Qt6::Gui + Qt6::Widgets ) install(TARGETS sharedmemory diff --git a/examples/corelib/ipc/sharedmemory/dialog.cpp b/examples/corelib/ipc/sharedmemory/dialog.cpp index 4e999d1bcf..b656cc0c67 100644 --- a/examples/corelib/ipc/sharedmemory/dialog.cpp +++ b/examples/corelib/ipc/sharedmemory/dialog.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 "dialog.h" #include <QFileDialog> @@ -136,8 +89,13 @@ void Dialog::loadFromFile() int size = buffer.size(); if (!sharedMemory.create(size)) { - ui.label->setText(tr("Unable to create shared memory segment.")); - return; + if (sharedMemory.error() == QSharedMemory::AlreadyExists) { + sharedMemory.attach(); + } else { + ui.label->setText(tr("Unable to create or attach to shared memory segment: %1") + .arg(sharedMemory.errorString())); + return; + } } sharedMemory.lock(); char *to = (char*)sharedMemory.data(); diff --git a/examples/corelib/ipc/sharedmemory/dialog.h b/examples/corelib/ipc/sharedmemory/dialog.h index 693333256c..0f8abaa8b6 100644 --- a/examples/corelib/ipc/sharedmemory/dialog.h +++ b/examples/corelib/ipc/sharedmemory/dialog.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 DIALOG_H #define DIALOG_H diff --git a/examples/corelib/ipc/sharedmemory/main.cpp b/examples/corelib/ipc/sharedmemory/main.cpp index 080f92c001..bf5bd457ae 100644 --- a/examples/corelib/ipc/sharedmemory/main.cpp +++ b/examples/corelib/ipc/sharedmemory/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 <QApplication> #include "dialog.h" diff --git a/examples/corelib/mimetypes/CMakeLists.txt b/examples/corelib/mimetypes/CMakeLists.txt index 3124006aaa..9ba3873bf4 100644 --- a/examples/corelib/mimetypes/CMakeLists.txt +++ b/examples/corelib/mimetypes/CMakeLists.txt @@ -1,5 +1,6 @@ -# Generated from mimetypes.pro. +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause -if(TARGET Qt::Widgets) +if(TARGET Qt6::Widgets) qt_internal_add_example(mimetypebrowser) endif() diff --git a/examples/corelib/mimetypes/doc/src/mimetypebrowser.qdoc b/examples/corelib/mimetypes/doc/src/mimetypebrowser.qdoc index 7b204db51a..17c8d765a8 100644 --- a/examples/corelib/mimetypes/doc/src/mimetypebrowser.qdoc +++ b/examples/corelib/mimetypes/doc/src/mimetypebrowser.qdoc @@ -1,29 +1,5 @@ -/**************************************************************************** -** -** 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 mimetypes/mimetypebrowser diff --git a/examples/corelib/mimetypes/mimetypebrowser/CMakeLists.txt b/examples/corelib/mimetypes/mimetypebrowser/CMakeLists.txt index 313676fa8e..c03ccae085 100644 --- a/examples/corelib/mimetypes/mimetypebrowser/CMakeLists.txt +++ b/examples/corelib/mimetypes/mimetypebrowser/CMakeLists.txt @@ -1,37 +1,34 @@ -# Generated from mimetypebrowser.pro. +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause cmake_minimum_required(VERSION 3.16) project(mimetypebrowser 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") + set(INSTALL_EXAMPLESDIR "examples") endif() set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/corelib/mimetypes/mimetypebrowser") -find_package(Qt6 COMPONENTS Core) -find_package(Qt6 COMPONENTS Gui) -find_package(Qt6 COMPONENTS Widgets) +find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets) + +qt_standard_project_setup() qt_add_executable(mimetypebrowser main.cpp mainwindow.cpp mainwindow.h mimetypemodel.cpp mimetypemodel.h ) + set_target_properties(mimetypebrowser PROPERTIES WIN32_EXECUTABLE TRUE MACOSX_BUNDLE FALSE ) -target_link_libraries(mimetypebrowser PUBLIC - Qt::Core - Qt::Gui - Qt::Widgets + +target_link_libraries(mimetypebrowser PRIVATE + Qt6::Core + Qt6::Gui + Qt6::Widgets ) install(TARGETS mimetypebrowser diff --git a/examples/corelib/mimetypes/mimetypebrowser/main.cpp b/examples/corelib/mimetypes/mimetypebrowser/main.cpp index 679d97dc7b..9aaad7b836 100644 --- a/examples/corelib/mimetypes/mimetypebrowser/main.cpp +++ b/examples/corelib/mimetypes/mimetypebrowser/main.cpp @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: http://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) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause #include "mainwindow.h" diff --git a/examples/corelib/mimetypes/mimetypebrowser/mainwindow.cpp b/examples/corelib/mimetypes/mimetypebrowser/mainwindow.cpp index 7315523f98..07cb3872d4 100644 --- a/examples/corelib/mimetypes/mimetypebrowser/mainwindow.cpp +++ b/examples/corelib/mimetypes/mimetypebrowser/mainwindow.cpp @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: http://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) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause #include "mainwindow.h" #include "mimetypemodel.h" diff --git a/examples/corelib/mimetypes/mimetypebrowser/mainwindow.h b/examples/corelib/mimetypes/mimetypebrowser/mainwindow.h index 978cdec4f4..4554d0873d 100644 --- a/examples/corelib/mimetypes/mimetypebrowser/mainwindow.h +++ b/examples/corelib/mimetypes/mimetypebrowser/mainwindow.h @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: http://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) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause #ifndef MAINWINDOW_H #define MAINWINDOW_H diff --git a/examples/corelib/mimetypes/mimetypebrowser/mimetypemodel.cpp b/examples/corelib/mimetypes/mimetypebrowser/mimetypemodel.cpp index 64732ba980..3598bb542e 100644 --- a/examples/corelib/mimetypes/mimetypebrowser/mimetypemodel.cpp +++ b/examples/corelib/mimetypes/mimetypebrowser/mimetypemodel.cpp @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: http://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) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause #include "mimetypemodel.h" diff --git a/examples/corelib/mimetypes/mimetypebrowser/mimetypemodel.h b/examples/corelib/mimetypes/mimetypebrowser/mimetypemodel.h index 6c537f4001..b1c84a7797 100644 --- a/examples/corelib/mimetypes/mimetypebrowser/mimetypemodel.h +++ b/examples/corelib/mimetypes/mimetypebrowser/mimetypemodel.h @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: http://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) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause #ifndef MIMETYPEMODEL_H #define MIMETYPEMODEL_H diff --git a/examples/corelib/permissions/CMakeLists.txt b/examples/corelib/permissions/CMakeLists.txt new file mode 100644 index 0000000000..39a207b1ce --- /dev/null +++ b/examples/corelib/permissions/CMakeLists.txt @@ -0,0 +1,47 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +cmake_minimum_required(VERSION 3.16) +project(permissions LANGUAGES CXX) + +if(NOT DEFINED INSTALL_EXAMPLESDIR) + set(INSTALL_EXAMPLESDIR "examples") +endif() + +set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/corelib/permissions") + +find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets) + +qt_standard_project_setup() + +qt_add_executable(permissions + MANUAL_FINALIZATION + main.cpp + android/AndroidManifest.xml +) + +set_target_properties(permissions PROPERTIES + MACOSX_BUNDLE TRUE + MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/Info.plist" + MACOSX_BUNDLE_GUI_IDENTIFIER "io.qt.examples.permissions" + QT_ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android" +) + +target_link_libraries(permissions PRIVATE + Qt6::Core + Qt6::Gui + Qt6::Widgets +) + +install(TARGETS permissions + RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" + BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" + LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" +) + +if(APPLE AND NOT CMAKE_GENERATOR STREQUAL "Xcode") + add_custom_command(TARGET permissions + POST_BUILD COMMAND codesign -s - permissions.app) +endif() + +qt_finalize_executable(permissions) diff --git a/examples/corelib/permissions/Info.plist b/examples/corelib/permissions/Info.plist new file mode 100644 index 0000000000..57625d03dc --- /dev/null +++ b/examples/corelib/permissions/Info.plist @@ -0,0 +1,59 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>CFBundleInfoDictionaryVersion</key> + <string>6.0</string> + <key>CFBundlePackageType</key> + <string>APPL</string> + + <key>CFBundleName</key> + <string>${MACOSX_BUNDLE_BUNDLE_NAME}</string> + <key>CFBundleIdentifier</key> + <string>${MACOSX_BUNDLE_GUI_IDENTIFIER}</string> + <key>CFBundleExecutable</key> + <string>${MACOSX_BUNDLE_EXECUTABLE_NAME}</string> + + <key>CFBundleVersion</key> + <string>${MACOSX_BUNDLE_BUNDLE_VERSION}</string> + <key>CFBundleShortVersionString</key> + <string>${MACOSX_BUNDLE_SHORT_VERSION_STRING}</string> + + <key>LSMinimumSystemVersion</key> + <string>${CMAKE_OSX_DEPLOYMENT_TARGET}</string> + + <key>NSHumanReadableCopyright</key> + <string>${MACOSX_BUNDLE_COPYRIGHT}</string> + + <key>CFBundleIconFile</key> + <string>${MACOSX_BUNDLE_ICON_FILE}</string> + + <key>CFBundleDevelopmentRegion</key> + <string>English</string> + + <key>NSSupportsAutomaticGraphicsSwitching</key> + <true/> + + <key>NSBluetoothAlwaysUsageDescription</key> + <string>Testing BluetoothAlways</string> + <key>NSCalendarsUsageDescription</key> + <string>Testing Calendars</string> + <key>NSCameraUsageDescription</key> + <string>Testing Camera</string> + <key>NSContactsUsageDescription</key> + <string>Testing Contacts</string> + <key>NSHealthShareUsageDescription</key> + <string>Testing HealthShare</string> + <key>NSHealthUpdateUsageDescription</key> + <string>Testing HealthUpdate</string> + <key>NSLocationUsageDescription</key> + <string>Testing Location on macOS</string> + <key>NSLocationWhenInUseUsageDescription</key> + <string>Testing Location when in use on iOS</string> + <key>NSLocationAlwaysAndWhenInUseUsageDescription</key> + <string>Testing Location always and when in use on iOS</string> + <key>NSMicrophoneUsageDescription</key> + <string>Testing Microphone</string> + +</dict> +</plist> diff --git a/examples/corelib/permissions/android/AndroidManifest.xml b/examples/corelib/permissions/android/AndroidManifest.xml new file mode 100644 index 0000000000..557ec8007e --- /dev/null +++ b/examples/corelib/permissions/android/AndroidManifest.xml @@ -0,0 +1,53 @@ +<?xml version="1.0"?> +<manifest xmlns:android="http://schemas.android.com/apk/res/android" + package="org.qtproject.example" + android:installLocation="auto" + android:versionCode="-- %%INSERT_VERSION_CODE%% --" + android:versionName="-- %%INSERT_VERSION_NAME%% --"> + <uses-permission android:name="android.permission.CAMERA" /> + <uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" /> + <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> + <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> + <uses-permission android:name="android.permission.RECORD_AUDIO" /> + <uses-permission android:name="android.permission.BLUETOOTH" /> + <uses-permission android:name="android.permission.READ_CONTACTS" /> + <uses-permission android:name="android.permission.WRITE_CONTACTS" /> + <uses-permission android:name="android.permission.READ_CALENDAR" /> + <uses-permission android:name="android.permission.WRITE_CALENDAR" /> + <!-- %%INSERT_PERMISSIONS --> + <!-- %%INSERT_FEATURES --> + <supports-screens + android:anyDensity="true" + android:largeScreens="true" + android:normalScreens="true" + android:smallScreens="true" /> + <application + android:name="org.qtproject.qt.android.bindings.QtApplication" + android:hardwareAccelerated="true" + android:label="-- %%INSERT_APP_NAME%% --" + android:requestLegacyExternalStorage="true" + android:allowNativeHeapPointerTagging="false" + android:allowBackup="true" + android:fullBackupOnly="false"> + <activity + android:name="org.qtproject.qt.android.bindings.QtActivity" + android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|layoutDirection|locale|fontScale|keyboard|keyboardHidden|navigation|mcc|mnc|density" + android:label="-- %%INSERT_APP_NAME%% --" + android:launchMode="singleTop" + android:screenOrientation="unspecified" + android:exported="true"> + <intent-filter> + <action android:name="android.intent.action.MAIN" /> + <category android:name="android.intent.category.LAUNCHER" /> + </intent-filter> + + <meta-data + android:name="android.app.lib_name" + android:value="-- %%INSERT_APP_LIB_NAME%% --" /> + + <meta-data + android:name="android.app.extract_android_style" + android:value="minimal" /> + </activity> + </application> +</manifest> diff --git a/examples/corelib/permissions/main.cpp b/examples/corelib/permissions/main.cpp new file mode 100644 index 0000000000..913aed2fec --- /dev/null +++ b/examples/corelib/permissions/main.cpp @@ -0,0 +1,87 @@ +// Copyright (C) 2022 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause + +#include <QtCore/qmetaobject.h> +#include <QtWidgets/qapplication.h> +#include <QtWidgets/qwidget.h> +#include <QtWidgets/qpushbutton.h> +#include <QtWidgets/qlayout.h> +#include <QtWidgets/qmessagebox.h> + +#if !QT_CONFIG(permissions) +#error "This example requires the permissions feature, which is not enabled on this platform" +#endif + +#include <QtCore/qpermissions.h> + +class PermissionWidget : public QWidget +{ + Q_OBJECT +public: + explicit PermissionWidget(QWidget *parent = nullptr) : QWidget(parent) + { + QVBoxLayout *layout = new QVBoxLayout(this); + + static const QPermission permissions[] = { + QCameraPermission{}, + QMicrophonePermission{}, + QBluetoothPermission{}, + QContactsPermission{}, + QCalendarPermission{}, + QLocationPermission{} + }; + + for (auto permission : permissions) { + auto permissionName = QString::fromLatin1(permission.type().name()); + QPushButton *button = new QPushButton(permissionName.sliced(1, permissionName.length() - 11)); + connect(button, &QPushButton::clicked, this, &PermissionWidget::buttonClicked); + button->setProperty("permission", QVariant::fromValue(permission)); + layout->addWidget(button); + } + + QPalette pal = palette(); + pal.setBrush(QPalette::Window, QGradient(QGradient::HappyAcid)); + setPalette(pal); + } + +private: + void buttonClicked() + { + auto *button = static_cast<QPushButton*>(sender()); + + auto permission = button->property("permission").value<QPermission>(); + Q_ASSERT(permission.type().isValid()); + + switch (qApp->checkPermission(permission)) { + case Qt::PermissionStatus::Undetermined: + qApp->requestPermission(permission, this, + [button](const QPermission &permission) { + Q_UNUSED(permission); + emit button->clicked(); // Try again + } + ); + return; + case Qt::PermissionStatus::Denied: + QMessageBox::warning(this, button->text(), + tr("Permission is needed to use %1. Please grant permission "\ + "to this application in the system settings.").arg(button->text())); + return; + case Qt::PermissionStatus::Granted: + break; // Proceed + } + + // All good, can use the feature + QMessageBox::information(this, button->text(), + tr("Accessing %1").arg(button->text())); + } +}; + +int main(int argc, char **argv) +{ + QApplication app(argc, argv); + PermissionWidget widget; + widget.show(); + return app.exec(); +} + +#include "main.moc" diff --git a/examples/corelib/platform/CMakeLists.txt b/examples/corelib/platform/CMakeLists.txt index 1a10578a1f..8eeda13095 100644 --- a/examples/corelib/platform/CMakeLists.txt +++ b/examples/corelib/platform/CMakeLists.txt @@ -1,3 +1,6 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + if(ANDROID) add_subdirectory(androidnotifier) endif() diff --git a/examples/corelib/platform/androidnotifier/CMakeLists.txt b/examples/corelib/platform/androidnotifier/CMakeLists.txt index fa5a7ce023..e5271edd79 100644 --- a/examples/corelib/platform/androidnotifier/CMakeLists.txt +++ b/examples/corelib/platform/androidnotifier/CMakeLists.txt @@ -1,55 +1,55 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + cmake_minimum_required(VERSION 3.16) project(androidnotifier LANGUAGES CXX) -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(CMAKE_AUTOMOC ON) -set(CMAKE_AUTORCC ON) -set(CMAKE_AUTOUIC ON) +if(NOT ANDROID) + message(FATAL_ERROR "Example only works on Android") +endif() if(NOT DEFINED INSTALL_EXAMPLESDIR) - set(INSTALL_EXAMPLESDIR "examples") + set(INSTALL_EXAMPLESDIR "examples") endif() -find_package(QT NAMES Qt6 Qt5 COMPONENTS Widgets REQUIRED) -find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Widgets REQUIRED) +find_package(Qt6 REQUIRED COMPONENTS Widgets) + +qt_standard_project_setup() set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/corelib/platform/androidnotifier") -set(PROJECT_SOURCES - main.cpp - notificationclient.cpp - notificationclient.h +qt_add_executable(androidnotifier + MANUAL_FINALIZATION + main.cpp + notificationclient.cpp + notificationclient.h + android/src/org/qtproject/example/androidnotifier/NotificationClient.java + android/AndroidManifest.xml ) -if(ANDROID) - qt_add_executable(androidnotifier - MANUAL_FINALIZATION - ${PROJECT_SOURCES}) - target_link_libraries(androidnotifier PRIVATE Qt${QT_VERSION_MAJOR}::Widgets) - - set_property(TARGET androidnotifier APPEND PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR - ${CMAKE_CURRENT_SOURCE_DIR}/android) - - if(QT_VERSION_MAJOR EQUAL 6) - qt_finalize_executable(androidnotifier) - endif() - - set(qml_resource_files - "images/happy.png" - "images/sad.png" - ) - - qt6_add_resources(androidnotifier "main" - PREFIX - "/" - FILES - ${qml_resource_files} - ) - - install(TARGETS androidnotifier - RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" - BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" - LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" - ) -endif() +target_link_libraries(androidnotifier PRIVATE + Qt6::Widgets +) + +set_property(TARGET androidnotifier APPEND PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR + ${CMAKE_CURRENT_SOURCE_DIR}/android) + +qt_finalize_executable(androidnotifier) + +set(qml_resource_files + "images/happy.png" + "images/sad.png" +) + +qt_add_resources(androidnotifier "main" + PREFIX + "/" + FILES + ${qml_resource_files} +) + +install(TARGETS androidnotifier + RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" + BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" + LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" +) diff --git a/examples/corelib/platform/androidnotifier/android/AndroidManifest.xml b/examples/corelib/platform/androidnotifier/android/AndroidManifest.xml index 4850a8e8e6..b2d9cc7680 100644 --- a/examples/corelib/platform/androidnotifier/android/AndroidManifest.xml +++ b/examples/corelib/platform/androidnotifier/android/AndroidManifest.xml @@ -23,13 +23,16 @@ android:hardwareAccelerated="true" android:label="Qt Notifier" android:requestLegacyExternalStorage="true" - android:icon="@drawable/icon"> + android:icon="@drawable/icon" + android:allowBackup="true" + android:fullBackupOnly="false"> <activity android:name="org.qtproject.qt.android.bindings.QtActivity" android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|layoutDirection|locale|fontScale|keyboard|keyboardHidden|navigation|mcc|mnc|density" android:label="Qt Notifier" android:launchMode="singleTop" - android:screenOrientation="unspecified"> + android:screenOrientation="unspecified" + android:exported="true"> <intent-filter> <action android:name="android.intent.action.MAIN"/> <category android:name="android.intent.category.LAUNCHER"/> diff --git a/examples/corelib/platform/androidnotifier/android/src/org/qtproject/example/androidnotifier/NotificationClient.java b/examples/corelib/platform/androidnotifier/android/src/org/qtproject/example/androidnotifier/NotificationClient.java index c43513b17a..4cd6c959f6 100644 --- a/examples/corelib/platform/androidnotifier/android/src/org/qtproject/example/androidnotifier/NotificationClient.java +++ b/examples/corelib/platform/androidnotifier/android/src/org/qtproject/example/androidnotifier/NotificationClient.java @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2021 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) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause package org.qtproject.example.androidnotifier; diff --git a/examples/corelib/platform/androidnotifier/doc/src/androidnotifier-example.qdoc b/examples/corelib/platform/androidnotifier/doc/src/androidnotifier-example.qdoc index b1e4243d56..186be9ec5a 100644 --- a/examples/corelib/platform/androidnotifier/doc/src/androidnotifier-example.qdoc +++ b/examples/corelib/platform/androidnotifier/doc/src/androidnotifier-example.qdoc @@ -1,33 +1,10 @@ -/**************************************************************************** -** -** Copyright (C) 2021 The Qt Company Ltd. -** Contact: http://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) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only /*! \title Qt Android Notifier \example platform/androidnotifier + \examplecategory {Mobile} \brief Demonstrates calling Java code from Qt in an Android application. \image androidnotifier.png @@ -71,7 +48,7 @@ The call to the Java meethod use \l QJniObject which relies on the Java Native Interface (JNI) APIs to communicate with Java. Also, in the previous snippet, - we are passing the app's context object which the the static Java code can use + we are passing the app's context object, which the static Java code can use to tap into the app's specific properties and APIs. To make sure our smiley buttons do what they are supposed to, we add the diff --git a/examples/corelib/platform/androidnotifier/main.cpp b/examples/corelib/platform/androidnotifier/main.cpp index 8b2e937351..33e77c7018 100644 --- a/examples/corelib/platform/androidnotifier/main.cpp +++ b/examples/corelib/platform/androidnotifier/main.cpp @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2021 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) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause #include "notificationclient.h" diff --git a/examples/corelib/platform/androidnotifier/notificationclient.cpp b/examples/corelib/platform/androidnotifier/notificationclient.cpp index b2093234b9..af1cb7322a 100644 --- a/examples/corelib/platform/androidnotifier/notificationclient.cpp +++ b/examples/corelib/platform/androidnotifier/notificationclient.cpp @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2021 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 AN |