diff options
Diffstat (limited to 'src/widgets')
582 files changed, 8583 insertions, 27839 deletions
diff --git a/src/widgets/CMakeLists.txt b/src/widgets/CMakeLists.txt index f2bb1e58a1..417f6a2d8e 100644 --- a/src/widgets/CMakeLists.txt +++ b/src/widgets/CMakeLists.txt @@ -1,4 +1,5 @@ -# Generated from widgets.pro. +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause ##################################################################### ## Widgets Module: @@ -35,7 +36,7 @@ qt_internal_add_module(Widgets styles/qpixmapstyle.cpp styles/qpixmapstyle_p.h styles/qpixmapstyle_p_p.h styles/qproxystyle.cpp styles/qproxystyle.h styles/qproxystyle_p.h - styles/qstyle.cpp styles/qstyle.h + styles/qstyle.cpp styles/qstyle.h styles/qstyle_p.h styles/qstylefactory.cpp styles/qstylefactory.h styles/qstylehelper.cpp styles/qstylehelper_p.h styles/qstyleoption.cpp styles/qstyleoption.h @@ -67,6 +68,11 @@ qt_internal_add_module(Widgets GENERATE_CPP_EXPORTS ) +if(APPLE) + set_source_files_properties(kernel/qapplication.cpp + PROPERTIES SKIP_UNITY_BUILD_INCLUSION ON) +endif() + # Resources: set(qstyle_resource_files "styles/images/cdr-128.png" @@ -298,10 +304,6 @@ if(QT_FEATURE_reduce_relocations AND UNIX AND GCC) "LINKER:--dynamic-list=${CMAKE_CURRENT_LIST_DIR}/QtWidgets.dynlist") endif() -#### Keys ignored in scope 1:.:.:widgets.pro:<TRUE>: -# MODULE_CONFIG = "uic" -# QMAKE_LIBS = "$$QMAKE_LIBS_GUI" - ## Scopes: ##################################################################### @@ -682,15 +684,25 @@ qt_internal_extend_target(Widgets CONDITION QT_FEATURE_progressdialog dialogs/qprogressdialog.cpp dialogs/qprogressdialog.h ) -qt_internal_extend_target(Widgets CONDITION QT_FEATURE_wizard - SOURCES - dialogs/qwizard.cpp dialogs/qwizard.h -) +if(QT_FEATURE_wizard) + qt_internal_extend_target(Widgets CONDITION + SOURCES + dialogs/qwizard.cpp dialogs/qwizard.h + ) -qt_internal_extend_target(Widgets CONDITION QT_FEATURE_wizard AND WIN32 - SOURCES - dialogs/qwizard_win.cpp dialogs/qwizard_win_p.h -) + if(APPLE) + set_source_files_properties(dialogs/qwizard.cpp + PROPERTIES + COMPILE_FLAGS "-x objective-c++" + SKIP_PRECOMPILE_HEADERS ON + ) + endif() + + qt_internal_extend_target(Widgets CONDITION WIN32 + SOURCES + dialogs/qwizard_win.cpp dialogs/qwizard_win_p.h + ) +endif() qt_internal_extend_target(Widgets CONDITION QT_FEATURE_accessibility SOURCES @@ -760,6 +772,7 @@ qt_internal_extend_target(Widgets CONDITION QT_FEATURE_treewidget SOURCES itemviews/qtreewidget.cpp itemviews/qtreewidget.h itemviews/qtreewidget_p.h itemviews/qtreewidgetitemiterator.cpp itemviews/qtreewidgetitemiterator.h + itemviews/qtreewidgetitemiterator_p.h ) qt_internal_extend_target(Widgets CONDITION QT_FEATURE_graphicsview @@ -829,7 +842,11 @@ qt_internal_extend_target(Widgets CONDITION NOT QT_FEATURE_xcb ) -qt_internal_create_tracepoints(Widgets qtwidgets.tracepoints) +qt_internal_generate_tracepoints(Widgets widgets + SOURCES + kernel/qapplication.cpp +) + qt_internal_add_docs(Widgets doc/qtwidgets.qdocconf ) diff --git a/src/widgets/Qt6WidgetsMacros.cmake b/src/widgets/Qt6WidgetsMacros.cmake index aa8133ba47..b15d1fe81d 100644 --- a/src/widgets/Qt6WidgetsMacros.cmake +++ b/src/widgets/Qt6WidgetsMacros.cmake @@ -1,34 +1,6 @@ -#============================================================================= # Copyright 2005-2011 Kitware, Inc. -# All rights reserved. -# -# 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 Kitware, Inc. 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 -# HOLDER 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. -#============================================================================= +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause ###################################### # @@ -36,8 +8,6 @@ # ###################################### -include(CMakeParseArguments) - # qt6_wrap_ui(outfiles inputfile ... ) diff --git a/src/widgets/accessible/complexwidgets.cpp b/src/widgets/accessible/complexwidgets.cpp index ab543a79df..624090a2af 100644 --- a/src/widgets/accessible/complexwidgets.cpp +++ b/src/widgets/accessible/complexwidgets.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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 Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "complexwidgets_p.h" @@ -72,10 +36,12 @@ #endif #include <QDebug> -#ifndef QT_NO_ACCESSIBILITY +#if QT_CONFIG(accessibility) QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + QString qt_accStripAmp(const QString &text); QString qt_accHotKey(const QString &text); @@ -211,7 +177,7 @@ QAccessibleTabBar::QAccessibleTabBar(QWidget *w) QAccessibleTabBar::~QAccessibleTabBar() { - for (QAccessible::Id id : qAsConst(m_childInterfaces)) + for (QAccessible::Id id : std::as_const(m_childInterfaces)) QAccessible::deleteAccessibleInterface(id); } @@ -354,6 +320,16 @@ int QAccessibleComboBox::indexOfChild(const QAccessibleInterface *child) const return -1; } +QAccessibleInterface *QAccessibleComboBox::focusChild() const +{ + // The editable combobox is the focus proxy of its lineedit, so the + // lineedit itself never gets focus. But it is the accessible focus + // child of an editable combobox. + if (comboBox()->isEditable()) + return child(1); + return nullptr; +} + /*! \reimp */ QString QAccessibleComboBox::text(QAccessible::Text t) const { @@ -384,6 +360,17 @@ QString QAccessibleComboBox::text(QAccessible::Text t) const return str; } +QAccessible::State QAccessibleComboBox::state() const +{ + QAccessible::State s = QAccessibleWidget::state(); + + s.expandable = true; + s.expanded = isValid() && comboBox()->view()->isVisible(); + s.editable = comboBox()->isEditable(); + + return s; +} + QStringList QAccessibleComboBox::actionNames() const { return QStringList() << showMenuAction() << pressAction(); @@ -444,7 +431,7 @@ QAccessibleInterface *QAccessibleAbstractScrollArea::child(int index) const int QAccessibleAbstractScrollArea::childCount() const { - return accessibleChildren().count(); + return accessibleChildren().size(); } int QAccessibleAbstractScrollArea::indexOfChild(const QAccessibleInterface *child) const @@ -517,9 +504,9 @@ QAccessibleAbstractScrollArea::elementType(QWidget *widget) const return Self; if (widget == abstractScrollArea()->viewport()) return Viewport; - if (widget->objectName() == QLatin1String("qt_scrollarea_hcontainer")) + if (widget->objectName() == "qt_scrollarea_hcontainer"_L1) return HorizontalContainer; - if (widget->objectName() == QLatin1String("qt_scrollarea_vcontainer")) + if (widget->objectName() == "qt_scrollarea_vcontainer"_L1) return VerticalContainer; if (widget == abstractScrollArea()->cornerWidget()) return CornerWidget; @@ -542,4 +529,4 @@ QAccessibleScrollArea::QAccessibleScrollArea(QWidget *widget) QT_END_NAMESPACE -#endif // QT_NO_ACCESSIBILITY +#endif // QT_CONFIG(accessibility) diff --git a/src/widgets/accessible/complexwidgets_p.h b/src/widgets/accessible/complexwidgets_p.h index 335e257476..12535f21a0 100644 --- a/src/widgets/accessible/complexwidgets_p.h +++ b/src/widgets/accessible/complexwidgets_p.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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 Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef COMPLEXWIDGETS_H #define COMPLEXWIDGETS_H @@ -60,7 +24,7 @@ QT_BEGIN_NAMESPACE -#ifndef QT_NO_ACCESSIBILITY +#if QT_CONFIG(accessibility) class QAbstractButton; class QHeaderView; @@ -135,9 +99,12 @@ public: QAccessibleInterface *childAt(int x, int y) const override; int indexOfChild(const QAccessibleInterface *child) const override; QAccessibleInterface* child(int index) const override; + QAccessibleInterface* focusChild() const override; QString text(QAccessible::Text t) const override; + QAccessible::State state() const override; + // QAccessibleActionInterface QStringList actionNames() const override; QString localizedActionDescription(const QString &actionName) const override; @@ -149,7 +116,7 @@ protected: }; #endif // QT_CONFIG(combobox) -#endif // QT_NO_ACCESSIBILITY +#endif // QT_CONFIG(accessibility) QT_END_NAMESPACE diff --git a/src/widgets/accessible/itemviews.cpp b/src/widgets/accessible/itemviews.cpp index a7b536ae54..ae1de6cab4 100644 --- a/src/widgets/accessible/itemviews.cpp +++ b/src/widgets/accessible/itemviews.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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 Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "itemviews_p.h" @@ -52,7 +16,7 @@ #endif #include <private/qwidget_p.h> -#ifndef QT_NO_ACCESSIBILITY +#if QT_CONFIG(accessibility) QT_BEGIN_NAMESPACE @@ -115,7 +79,7 @@ bool QAccessibleTable::isValid() const QAccessibleTable::~QAccessibleTable() { - for (QAccessible::Id id : qAsConst(childToId)) + for (QAccessible::Id id : std::as_const(childToId)) QAccessible::deleteAccessibleInterface(id); } @@ -190,21 +154,21 @@ int QAccessibleTable::selectedCellCount() const { if (!view()->selectionModel()) return 0; - return view()->selectionModel()->selectedIndexes().count(); + return view()->selectionModel()->selectedIndexes().size(); } int QAccessibleTable::selectedColumnCount() const { if (!view()->selectionModel()) return 0; - return view()->selectionModel()->selectedColumns().count(); + return view()->selectionModel()->selectedColumns().size(); } int QAccessibleTable::selectedRowCount() const { if (!view()->selectionModel()) return 0; - return view()->selectionModel()->selectedRows().count(); + return view()->selectionModel()->selectedRows().size(); } QString QAccessibleTable::rowDescription(int row) const @@ -402,6 +366,85 @@ bool QAccessibleTable::unselectColumn(int column) return true; } +int QAccessibleTable::selectedItemCount() const +{ + return selectedCellCount(); +} + +QList<QAccessibleInterface*> QAccessibleTable::selectedItems() const +{ + return selectedCells(); +} + +bool QAccessibleTable::isSelected(QAccessibleInterface *childCell) const +{ + if (!childCell || childCell->parent() != this) { + qWarning() << "QAccessibleTable::isSelected: Accessible interface must be a direct child of the table interface."; + return false; + } + + const QAccessibleTableCellInterface *cell = childCell->tableCellInterface(); + if (cell) + return cell->isSelected(); + + return false; +} + +bool QAccessibleTable::select(QAccessibleInterface *childCell) +{ + if (!childCell || childCell->parent() != this) { + qWarning() << "QAccessibleTable::select: Accessible interface must be a direct child of the table interface."; + return false; + } + + if (!childCell->tableCellInterface()) { + qWarning() << "QAccessibleTable::select: Accessible interface doesn't implement table cell interface."; + return false; + } + + if (childCell->role() == QAccessible::Cell || childCell->role() == QAccessible::ListItem || childCell->role() == QAccessible::TreeItem) { + QAccessibleTableCell* cell = static_cast<QAccessibleTableCell*>(childCell); + cell->selectCell(); + return true; + } + + return false; +} + +bool QAccessibleTable::unselect(QAccessibleInterface *childCell) +{ + if (!childCell || childCell->parent() != this) { + qWarning() << "QAccessibleTable::select: Accessible interface must be a direct child of the table interface."; + return false; + } + + if (!childCell->tableCellInterface()) { + qWarning() << "QAccessibleTable::unselect: Accessible interface doesn't implement table cell interface."; + return false; + } + + if (childCell->role() == QAccessible::Cell || childCell->role() == QAccessible::ListItem || childCell->role() == QAccessible::TreeItem) { + QAccessibleTableCell* cell = static_cast<QAccessibleTableCell*>(childCell); + cell->unselectCell(); + return true; + } + + return false; +} + +bool QAccessibleTable::selectAll() +{ + view()->selectAll(); + return true; +} + +bool QAccessibleTable::clear() +{ + view()->selectionModel()->clearSelection(); + return true; +} + + QAccessible::Role QAccessibleTable::role() const { return m_role; @@ -409,7 +452,27 @@ QAccessible::Role QAccessibleTable::role() const QAccessible::State QAccessibleTable::state() const { - return QAccessible::State(); + QAccessible::State state; + const auto *w = view(); + + if (w->testAttribute(Qt::WA_WState_Visible) == false) + state.invisible = true; + if (w->focusPolicy() != Qt::NoFocus) + state.focusable = true; + if (w->hasFocus()) + state.focused = true; + if (!w->isEnabled()) + state.disabled = true; + if (w->isWindow()) { + if (w->windowFlags() & Qt::WindowSystemMenuHint) + state.movable = true; + if (w->minimumSize() != w->maximumSize()) + state.sizeable = true; + if (w->isActiveWindow()) + state.active = true; + } + + return state; } QAccessibleInterface *QAccessibleTable::childAt(int x, int y) const @@ -425,6 +488,15 @@ QAccessibleInterface *QAccessibleTable::childAt(int x, int y) const return nullptr; } +QAccessibleInterface *QAccessibleTable::focusChild() const +{ + QModelIndex index = view()->currentIndex(); + if (!index.isValid()) + return nullptr; + + return child(logicalIndex(index)); +} + int QAccessibleTable::childCount() const { if (!view()->model()) @@ -540,6 +612,8 @@ QAccessibleInterface *QAccessibleTable::child(int logicalIndex) const void *QAccessibleTable::interface_cast(QAccessible::InterfaceType t) { + if (t == QAccessible::SelectionInterface) + return static_cast<QAccessibleSelectionInterface*>(this); if (t == QAccessible::TableInterface) return static_cast<QAccessibleTableInterface*>(this); return nullptr; @@ -553,7 +627,7 @@ void QAccessibleTable::modelChange(QAccessibleTableModelChangeEvent *event) switch (event->modelChangeType()) { case QAccessibleTableModelChangeEvent::ModelReset: - for (QAccessible::Id id : qAsConst(childToId)) + for (QAccessible::Id id : std::as_const(childToId)) QAccessible::deleteAccessibleInterface(id); childToId.clear(); break; @@ -661,7 +735,7 @@ QModelIndex QAccessibleTree::indexFromLogical(int row, int column) const return QModelIndex(); const QTreeView *treeView = qobject_cast<const QTreeView*>(view()); - if (Q_UNLIKELY(row < 0 || column < 0 || treeView->d_func()->viewItems.count() <= row)) { + if (Q_UNLIKELY(row < 0 || column < 0 || treeView->d_func()->viewItems.size() <= row)) { qWarning() << "QAccessibleTree::indexFromLogical: invalid index: " << row << column << " for " << treeView; return QModelIndex(); } @@ -692,6 +766,20 @@ QAccessibleInterface *QAccessibleTree::childAt(int x, int y) const return child(i); } +QAccessibleInterface *QAccessibleTree::focusChild() const +{ + QModelIndex index = view()->currentIndex(); + if (!index.isValid()) + return nullptr; + + const QTreeView *treeView = qobject_cast<const QTreeView*>(view()); + int row = treeView->d_func()->viewIndex(index) + (horizontalHeader() ? 1 : 0); + int column = index.column(); + + int i = row * view()->model()->columnCount() + column; + return child(i); +} + int QAccessibleTree::childCount() const { const QTreeView *treeView = qobject_cast<const QTreeView*>(view()); @@ -700,7 +788,7 @@ int QAccessibleTree::childCount() const return 0; int hHeader = horizontalHeader() ? 1 : 0; - return (treeView->d_func()->viewItems.count() + hHeader)* view()->model()->columnCount(); + return (treeView->d_func()->viewItems.size() + hHeader)* view()->model()->columnCount(); } QAccessibleInterface *QAccessibleTree::child(int logicalIndex) const @@ -736,7 +824,7 @@ int QAccessibleTree::rowCount() const { const QTreeView *treeView = qobject_cast<const QTreeView*>(view()); Q_ASSERT(treeView); - return treeView->d_func()->viewItems.count(); + return treeView->d_func()->viewItems.size(); } int QAccessibleTree::indexOfChild(const QAccessibleInterface *iface) const @@ -1017,7 +1105,7 @@ void QAccessibleTableCell::unselectCell() //one cell is selected it cannot be unselected by the user if ((selectionMode != QAbstractItemView::MultiSelection) && (selectionMode != QAbstractItemView::ExtendedSelection) - && (view->selectionModel()->selectedIndexes().count() <= 1)) + && (view->selectionModel()->selectedIndexes().size() <= 1)) return; view->selectionModel()->select(m_index, QItemSelectionModel::Deselect); @@ -1248,4 +1336,4 @@ QHeaderView *QAccessibleTableHeaderCell::headerView() const QT_END_NAMESPACE -#endif // QT_NO_ACCESSIBILITY +#endif // QT_CONFIG(accessibility) diff --git a/src/widgets/accessible/itemviews_p.h b/src/widgets/accessible/itemviews_p.h index 683ae9c948..ddc97baba1 100644 --- a/src/widgets/accessible/itemviews_p.h +++ b/src/widgets/accessible/itemviews_p.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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 Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef ACCESSIBLE_ITEMVIEWS_H #define ACCESSIBLE_ITEMVIEWS_H @@ -62,12 +26,12 @@ QT_REQUIRE_CONFIG(itemviews); QT_BEGIN_NAMESPACE -#ifndef QT_NO_ACCESSIBILITY +#if QT_CONFIG(accessibility) class QAccessibleTableCell; class QAccessibleTableHeaderCell; -class QAccessibleTable :public QAccessibleTableInterface, public QAccessibleObject +class QAccessibleTable :public QAccessibleTableInterface, public QAccessibleSelectionInterface, public QAccessibleObject { public: explicit QAccessibleTable(QWidget *w); @@ -79,6 +43,7 @@ public: QRect rect() const override; QAccessibleInterface *childAt(int x, int y) const override; + QAccessibleInterface *focusChild() const override; int childCount() const override; int indexOfChild(const QAccessibleInterface *) const override; @@ -110,6 +75,15 @@ public: virtual bool unselectRow(int row) override; virtual bool unselectColumn(int column) override; + // QAccessibleSelectionInterface + virtual int selectedItemCount() const override; + virtual QList<QAccessibleInterface*> selectedItems() const override; + virtual bool isSelected(QAccessibleInterface *childCell) const override; + virtual bool select(QAccessibleInterface *childCell) override; + virtual bool unselect(QAccessibleInterface *childCell) override; + virtual bool selectAll() override; + virtual bool clear() override; + QAbstractItemView *view() const; void modelChange(QAccessibleTableModelChangeEvent *event) override; @@ -154,6 +128,7 @@ public: QAccessibleInterface *childAt(int x, int y) const override; + QAccessibleInterface *focusChild() const override; int childCount() const override; QAccessibleInterface *child(int index) const override; @@ -298,7 +273,7 @@ private: }; -#endif // QT_NO_ACCESSIBILITY +#endif // QT_CONFIG(accessibility) QT_END_NAMESPACE diff --git a/src/widgets/accessible/qaccessiblemenu.cpp b/src/widgets/accessible/qaccessiblemenu.cpp index 962a56170a..1d72a82456 100644 --- a/src/widgets/accessible/qaccessiblemenu.cpp +++ b/src/widgets/accessible/qaccessiblemenu.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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 Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qaccessiblemenu_p.h" @@ -48,7 +12,7 @@ #include <qstyle.h> #include <private/qwidget_p.h> -#ifndef QT_NO_ACCESSIBILITY +#if QT_CONFIG(accessibility) QT_BEGIN_NAMESPACE @@ -80,7 +44,7 @@ QMenu *QAccessibleMenu::menu() const int QAccessibleMenu::childCount() const { - return menu()->actions().count(); + return menu()->actions().size(); } QAccessibleInterface *QAccessibleMenu::childAt(int x, int y) const @@ -121,7 +85,7 @@ QAccessibleInterface *QAccessibleMenu::parent() const const QList<QObject *> associatedObjects = menuAction->associatedObjects(); parentCandidates.reserve(associatedObjects.size() + 1); parentCandidates << menu()->parentWidget() << associatedObjects; - for (QObject *object : qAsConst(parentCandidates)) { + for (QObject *object : std::as_const(parentCandidates)) { if (qobject_cast<QMenu*>(object) #if QT_CONFIG(menubar) || qobject_cast<QMenuBar*>(object) @@ -159,7 +123,7 @@ QMenuBar *QAccessibleMenuBar::menuBar() const int QAccessibleMenuBar::childCount() const { - return menuBar()->actions().count(); + return menuBar()->actions().size(); } QAccessibleInterface *QAccessibleMenuBar::child(int index) const @@ -393,5 +357,5 @@ QWidget *QAccessibleMenuItem::owner() const QT_END_NAMESPACE -#endif // QT_NO_ACCESSIBILITY +#endif // QT_CONFIG(accessibility) diff --git a/src/widgets/accessible/qaccessiblemenu_p.h b/src/widgets/accessible/qaccessiblemenu_p.h index 9acd2a42f9..8eb9a37e2d 100644 --- a/src/widgets/accessible/qaccessiblemenu_p.h +++ b/src/widgets/accessible/qaccessiblemenu_p.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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 Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QACCESSIBLEMENU_H #define QACCESSIBLEMENU_H @@ -57,7 +21,7 @@ QT_BEGIN_NAMESPACE -#ifndef QT_NO_ACCESSIBILITY +#if QT_CONFIG(accessibility) #if QT_CONFIG(menu) class QMenu; @@ -139,5 +103,5 @@ private: #endif // QT_CONFIG(menu) QT_END_NAMESPACE -#endif // QT_NO_ACCESSIBILITY +#endif // QT_CONFIG(accessibility) #endif // QACCESSIBLEMENU_H diff --git a/src/widgets/accessible/qaccessiblewidget.cpp b/src/widgets/accessible/qaccessiblewidget.cpp index ae545a5ce2..b0bb12ea86 100644 --- a/src/widgets/accessible/qaccessiblewidget.cpp +++ b/src/widgets/accessible/qaccessiblewidget.cpp @@ -1,45 +1,9 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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 Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qaccessiblewidget.h" -#ifndef QT_NO_ACCESSIBILITY +#if QT_CONFIG(accessibility) #include "qapplication.h" #if QT_CONFIG(groupbox) @@ -68,22 +32,9 @@ QT_BEGIN_NAMESPACE -static QList<QWidget*> childWidgets(const QWidget *widget) -{ - QList<QWidget*> widgets; - for (QObject *o : widget->children()) { - QWidget *w = qobject_cast<QWidget *>(o); - if (w && !w->isWindow() - && !qobject_cast<QFocusFrame*>(w) -#if QT_CONFIG(menu) - && !qobject_cast<QMenu*>(w) -#endif - && w->objectName() != QLatin1String("qt_rubberband") - && w->objectName() != QLatin1String("qt_spinbox_lineedit")) - widgets.append(w); - } - return widgets; -} +using namespace Qt::StringLiterals; + +QWidgetList _q_ac_childWidgets(const QWidget *widget); static QString buddyString(const QWidget *widget) { @@ -112,18 +63,18 @@ static QString buddyString(const QWidget *widget) /* This function will return the offset of the '&' in the text that would be preceding the accelerator character. If this text does not have an accelerator, -1 will be returned. */ -static int qt_accAmpIndex(const QString &text) +static qsizetype qt_accAmpIndex(const QString &text) { #ifndef QT_NO_SHORTCUT if (text.isEmpty()) return -1; - int fa = 0; - while ((fa = text.indexOf(QLatin1Char('&'), fa)) != -1) { + qsizetype fa = 0; + while ((fa = text.indexOf(u'&', fa)) != -1) { ++fa; - if (fa < text.length()) { + if (fa < text.size()) { // ignore "&&" - if (text.at(fa) == QLatin1Char('&')) { + if (text.at(fa) == u'&') { ++fa; continue; @@ -144,17 +95,17 @@ static int qt_accAmpIndex(const QString &text) QString qt_accStripAmp(const QString &text) { QString newText(text); - int ampIndex = qt_accAmpIndex(newText); + qsizetype ampIndex = qt_accAmpIndex(newText); if (ampIndex != -1) newText.remove(ampIndex, 1); - return newText.replace(QLatin1String("&&"), QLatin1String("&")); + return newText.replace("&&"_L1, "&"_L1); } QString qt_accHotKey(const QString &text) { #ifndef QT_NO_SHORTCUT - int ampIndex = qt_accAmpIndex(text); + qsizetype ampIndex = qt_accAmpIndex(text); if (ampIndex != -1) return QKeySequence(Qt::ALT).toString(QKeySequence::NativeText) + text.at(ampIndex + 1); #else @@ -285,7 +236,7 @@ void QAccessibleWidget::addControllingSignal(const QString &signal) QByteArray s = QMetaObject::normalizedSignature(signal.toLatin1()); if (Q_UNLIKELY(object()->metaObject()->indexOfSignal(s) < 0)) qWarning("Signal %s unknown in %s", s.constData(), object()->metaObject()->className()); - d->primarySignals << QLatin1String(s); + d->primarySignals << QLatin1StringView(s); } static inline bool isAncestor(const QObject *obj, const QObject *child) @@ -310,7 +261,7 @@ QAccessibleWidget::relations(QAccessible::Relation match /*= QAccessible::AllRel // first check for all siblings that are labels to us // ideally we would go through all objects and check, but that // will be too expensive - const QList<QWidget*> kids = childWidgets(parent); + const QList<QWidget*> kids = _q_ac_childWidgets(parent); for (QWidget *kid : kids) { if (QLabel *labelSibling = qobject_cast<QLabel*>(kid)) { if (labelSibling->buddy() == widget()) { @@ -333,14 +284,14 @@ QAccessibleWidget::relations(QAccessible::Relation match /*= QAccessible::AllRel if (match & QAccessible::Controlled) { QObjectList allReceivers; QObject *connectionObject = object(); - for (int sig = 0; sig < d->primarySignals.count(); ++sig) { + for (int sig = 0; sig < d->primarySignals.size(); ++sig) { const QObjectList receivers = connectionObject->d_func()->receiverList(d->primarySignals.at(sig).toLatin1()); allReceivers += receivers; } allReceivers.removeAll(object()); //### The object might connect to itself internally - for (int i = 0; i < allReceivers.count(); ++i) { + for (int i = 0; i < allReceivers.size(); ++i) { const QAccessible::Relation rel = QAccessible::Controlled; QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(allReceivers.at(i)); if (iface) @@ -361,7 +312,7 @@ QAccessibleInterface *QAccessibleWidget::parent() const QAccessibleInterface *QAccessibleWidget::child(int index) const { Q_ASSERT(widget()); - QWidgetList childList = childWidgets(widget()); + QWidgetList childList = _q_ac_childWidgets(widget()); if (index >= 0 && index < childList.size()) return QAccessible::queryAccessibleInterface(childList.at(index)); return nullptr; @@ -389,7 +340,7 @@ QAccessibleInterface *QAccessibleWidget::focusChild() const /*! \reimp */ int QAccessibleWidget::childCount() const { - QWidgetList cl = childWidgets(widget()); + QWidgetList cl = _q_ac_childWidgets(widget()); return cl.size(); } @@ -398,7 +349,7 @@ int QAccessibleWidget::indexOfChild(const QAccessibleInterface *child) const { if (!child) return -1; - QWidgetList cl = childWidgets(widget()); + QWidgetList cl = _q_ac_childWidgets(widget()); return cl.indexOf(qobject_cast<QWidget *>(child->object())); } @@ -532,4 +483,4 @@ void *QAccessibleWidget::interface_cast(QAccessible::InterfaceType t) QT_END_NAMESPACE -#endif //QT_NO_ACCESSIBILITY +#endif // QT_CONFIG(accessibility) diff --git a/src/widgets/accessible/qaccessiblewidget.h b/src/widgets/accessible/qaccessiblewidget.h index 7b915a99ac..c237e25d4a 100644 --- a/src/widgets/accessible/qaccessiblewidget.h +++ b/src/widgets/accessible/qaccessiblewidget.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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 Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QACCESSIBLEWIDGET_H #define QACCESSIBLEWIDGET_H @@ -46,7 +10,7 @@ QT_BEGIN_NAMESPACE -#ifndef QT_NO_ACCESSIBILITY +#if QT_CONFIG(accessibility) class QAccessibleWidgetPrivate; @@ -94,7 +58,7 @@ private: }; -#endif // QT_NO_ACCESSIBILITY +#endif // QT_CONFIG(accessibility) QT_END_NAMESPACE diff --git a/src/widgets/accessible/qaccessiblewidgetfactory.cpp b/src/widgets/accessible/qaccessiblewidgetfactory.cpp index 4c6a6fdecb..e13b7ebcf7 100644 --- a/src/widgets/accessible/qaccessiblewidgetfactory.cpp +++ b/src/widgets/accessible/qaccessiblewidgetfactory.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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 Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qaccessiblewidgets_p.h" #include "qaccessiblemenu_p.h" @@ -56,10 +20,12 @@ #include <qvariant.h> #include <qaccessible.h> -#ifndef QT_NO_ACCESSIBILITY +#if QT_CONFIG(accessibility) QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + QAccessibleInterface *qAccessibleFactory(const QString &classname, QObject *object) { QAccessibleInterface *iface = nullptr; @@ -77,154 +43,156 @@ QAccessibleInterface *qAccessibleFactory(const QString &classname, QObject *obje if (false) { #if QT_CONFIG(lineedit) - } else if (classname == QLatin1String("QLineEdit")) { - if (widget->objectName() == QLatin1String("qt_spinbox_lineedit")) + } else if (classname == "QLineEdit"_L1) { + if (widget->objectName() == "qt_spinbox_lineedit"_L1) iface = nullptr; else iface = new QAccessibleLineEdit(widget); #endif #if QT_CONFIG(combobox) - } else if (classname == QLatin1String("QComboBox")) { + } else if (classname == "QComboBox"_L1) { iface = new QAccessibleComboBox(widget); #endif #if QT_CONFIG(spinbox) - } else if (classname == QLatin1String("QAbstractSpinBox")) { + } else if (classname == "QAbstractSpinBox"_L1) { iface = new QAccessibleAbstractSpinBox(widget); - } else if (classname == QLatin1String("QSpinBox")) { + } else if (classname == "QSpinBox"_L1) { iface = new QAccessibleSpinBox(widget); - } else if (classname == QLatin1String("QDoubleSpinBox")) { + } else if (classname == "QDoubleSpinBox"_L1) { iface = new QAccessibleDoubleSpinBox(widget); #endif #if QT_CONFIG(scrollbar) - } else if (classname == QLatin1String("QScrollBar")) { + } else if (classname == "QScrollBar"_L1) { iface = new QAccessibleScrollBar(widget); #endif #if QT_CONFIG(slider) - } else if (classname == QLatin1String("QAbstractSlider")) { + } else if (classname == "QAbstractSlider"_L1) { iface = new QAccessibleAbstractSlider(widget); - } else if (classname == QLatin1String("QSlider")) { + } else if (classname == "QSlider"_L1) { iface = new QAccessibleSlider(widget); #endif #if QT_CONFIG(toolbutton) - } else if (classname == QLatin1String("QToolButton")) { + } else if (classname == "QToolButton"_L1) { iface = new QAccessibleToolButton(widget); #endif // QT_CONFIG(toolbutton) #if QT_CONFIG(abstractbutton) - } else if (classname == QLatin1String("QCheckBox") - || classname == QLatin1String("QRadioButton") - || classname == QLatin1String("QPushButton") - || classname == QLatin1String("QAbstractButton")) { + } else if (classname == "QCheckBox"_L1 + || classname == "QRadioButton"_L1 + || classname == "QPushButton"_L1 + || classname == "QAbstractButton"_L1) { iface = new QAccessibleButton(widget); #endif - } else if (classname == QLatin1String("QDialog")) { + } else if (classname == "QDialog"_L1) { iface = new QAccessibleWidget(widget, QAccessible::Dialog); - } else if (classname == QLatin1String("QMessageBox")) { - iface = new QAccessibleWidget(widget, QAccessible::AlertMessage); +#if QT_CONFIG(messagebox) + } else if (classname == "QMessageBox"_L1) { + iface = new QAccessibleMessageBox(widget); +#endif #if QT_CONFIG(mainwindow) - } else if (classname == QLatin1String("QMainWindow")) { + } else if (classname == "QMainWindow"_L1) { iface = new QAccessibleMainWindow(widget); #endif - } else if (classname == QLatin1String("QLabel") || classname == QLatin1String("QLCDNumber")) { + } else if (classname == "QLabel"_L1 || classname == "QLCDNumber"_L1) { iface = new QAccessibleDisplay(widget); #if QT_CONFIG(groupbox) - } else if (classname == QLatin1String("QGroupBox")) { + } else if (classname == "QGroupBox"_L1) { iface = new QAccessibleGroupBox(widget); #endif - } else if (classname == QLatin1String("QStatusBar")) { + } else if (classname == "QStatusBar"_L1) { iface = new QAccessibleDisplay(widget); #if QT_CONFIG(progressbar) - } else if (classname == QLatin1String("QProgressBar")) { + } else if (classname == "QProgressBar"_L1) { iface = new QAccessibleProgressBar(widget); #endif - } else if (classname == QLatin1String("QToolBar")) { + } else if (classname == "QToolBar"_L1) { iface = new QAccessibleWidget(widget, QAccessible::ToolBar, widget->windowTitle()); #if QT_CONFIG(menubar) - } else if (classname == QLatin1String("QMenuBar")) { + } else if (classname == "QMenuBar"_L1) { iface = new QAccessibleMenuBar(widget); #endif #if QT_CONFIG(menu) - } else if (classname == QLatin1String("QMenu")) { + } else if (classname == "QMenu"_L1) { iface = new QAccessibleMenu(widget); #endif #if QT_CONFIG(treeview) - } else if (classname == QLatin1String("QTreeView")) { + } else if (classname == "QTreeView"_L1) { iface = new QAccessibleTree(widget); #endif // QT_CONFIG(treeview) #if QT_CONFIG(itemviews) - } else if (classname == QLatin1String("QTableView") || classname == QLatin1String("QListView")) { + } else if (classname == "QTableView"_L1 || classname == "QListView"_L1) { iface = new QAccessibleTable(widget); // ### This should be cleaned up. We return the parent for the scrollarea to hide it. #endif // QT_CONFIG(itemviews) #if QT_CONFIG(tabbar) - } else if (classname == QLatin1String("QTabBar")) { + } else if (classname == "QTabBar"_L1) { iface = new QAccessibleTabBar(widget); #endif - } else if (classname == QLatin1String("QSizeGrip")) { + } else if (classname == "QSizeGrip"_L1) { iface = new QAccessibleWidget(widget, QAccessible::Grip); #if QT_CONFIG(splitter) - } else if (classname == QLatin1String("QSplitter")) { + } else if (classname == "QSplitter"_L1) { iface = new QAccessibleWidget(widget, QAccessible::Splitter); - } else if (classname == QLatin1String("QSplitterHandle")) { + } else if (classname == "QSplitterHandle"_L1) { iface = new QAccessibleWidget(widget, QAccessible::Grip); #endif #if QT_CONFIG(textedit) && !defined(QT_NO_CURSOR) - } else if (classname == QLatin1String("QTextEdit")) { + } else if (classname == "QTextEdit"_L1) { iface = new QAccessibleTextEdit(widget); - } else if (classname == QLatin1String("QPlainTextEdit")) { + } else if (classname == "QPlainTextEdit"_L1) { iface = new QAccessiblePlainTextEdit(widget); #endif - } else if (classname == QLatin1String("QTipLabel")) { + } else if (classname == "QTipLabel"_L1) { iface = new QAccessibleDisplay(widget, QAccessible::ToolTip); - } else if (classname == QLatin1String("QFrame")) { + } else if (classname == "QFrame"_L1) { iface = new QAccessibleWidget(widget, QAccessible::Border); #if QT_CONFIG(stackedwidget) - } else if (classname == QLatin1String("QStackedWidget")) { + } else if (classname == "QStackedWidget"_L1) { iface = new QAccessibleStackedWidget(widget); #endif #if QT_CONFIG(toolbox) - } else if (classname == QLatin1String("QToolBox")) { + } else if (classname == "QToolBox"_L1) { iface = new QAccessibleToolBox(widget); #endif #if QT_CONFIG(mdiarea) - } else if (classname == QLatin1String("QMdiArea")) { + } else if (classname == "QMdiArea"_L1) { iface = new QAccessibleMdiArea(widget); - } else if (classname == QLatin1String("QMdiSubWindow")) { + } else if (classname == "QMdiSubWindow"_L1) { iface = new QAccessibleMdiSubWindow(widget); #endif #if QT_CONFIG(dialogbuttonbox) - } else if (classname == QLatin1String("QDialogButtonBox")) { + } else if (classname == "QDialogButtonBox"_L1) { iface = new QAccessibleDialogButtonBox(widget); #endif #if QT_CONFIG(dial) - } else if (classname == QLatin1String("QDial")) { + } else if (classname == "QDial"_L1) { iface = new QAccessibleDial(widget); #endif #if QT_CONFIG(rubberband) - } else if (classname == QLatin1String("QRubberBand")) { + } else if (classname == "QRubberBand"_L1) { iface = new QAccessibleWidget(widget, QAccessible::Border); #endif #if QT_CONFIG(textbrowser) && !defined(QT_NO_CURSOR) - } else if (classname == QLatin1String("QTextBrowser")) { + } else if (classname == "QTextBrowser"_L1) { iface = new QAccessibleTextBrowser(widget); #endif #if QT_CONFIG(scrollarea) - } else if (classname == QLatin1String("QAbstractScrollArea")) { + } else if (classname == "QAbstractScrollArea"_L1) { iface = new QAccessibleAbstractScrollArea(widget); - } else if (classname == QLatin1String("QScrollArea")) { + } else if (classname == "QScrollArea"_L1) { iface = new QAccessibleScrollArea(widget); #endif #if QT_CONFIG(calendarwidget) - } else if (classname == QLatin1String("QCalendarWidget")) { + } else if (classname == "QCalendarWidget"_L1) { iface = new QAccessibleCalendarWidget(widget); #endif #if QT_CONFIG(dockwidget) - } else if (classname == QLatin1String("QDockWidget")) { + } else if (classname == "QDockWidget"_L1) { iface = new QAccessibleDockWidget(widget); #endif - } else if (classname == QLatin1String("QWidget")) { + } else if (classname == "QWidget"_L1) { iface = new QAccessibleWidget(widget); - } else if (classname == QLatin1String("QWindowContainer")) { + } else if (classname == "QWindowContainer"_L1) { iface = new QAccessibleWindowContainer(widget); } @@ -233,4 +201,4 @@ QAccessibleInterface *qAccessibleFactory(const QString &classname, QObject *obje QT_END_NAMESPACE -#endif // QT_NO_ACCESSIBILITY +#endif // QT_CONFIG(accessibility) diff --git a/src/widgets/accessible/qaccessiblewidgetfactory_p.h b/src/widgets/accessible/qaccessiblewidgetfactory_p.h index 5da609ddca..eb37b33ff7 100644 --- a/src/widgets/accessible/qaccessiblewidgetfactory_p.h +++ b/src/widgets/accessible/qaccessiblewidgetfactory_p.h @@ -1,44 +1,7 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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 Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include <QtWidgets/private/qtwidgetsglobal_p.h> -#include <QtGui/qaccessible.h> #ifndef QACCESSIBLEWIDGETFACTORY_H #define QACCESSIBLEWIDGETFACTORY_H @@ -56,6 +19,10 @@ QT_BEGIN_NAMESPACE +class QObject; +class QAccessibleInterface; +class QString; + QAccessibleInterface *qAccessibleFactory(const QString &classname, QObject *object); QT_END_NAMESPACE diff --git a/src/widgets/accessible/qaccessiblewidgets.cpp b/src/widgets/accessible/qaccessiblewidgets.cpp index d9ba34c145..ad41df3685 100644 --- a/src/widgets/accessible/qaccessiblewidgets.cpp +++ b/src/widgets/accessible/qaccessiblewidgets.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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 Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qaccessiblewidgets_p.h" #include "qabstracttextdocumentlayout.h" @@ -92,14 +56,16 @@ #include <QMenu> #endif -#ifndef QT_NO_ACCESSIBILITY +#if QT_CONFIG(accessibility) QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + QString qt_accStripAmp(const QString &text); QString qt_accHotKey(const QString &text); -QList<QWidget*> childWidgets(const QWidget *widget) +QWidgetList _q_ac_childWidgets(const QWidget *widget) { QList<QWidget*> widgets; if (!widget) @@ -114,8 +80,10 @@ QList<QWidget*> childWidgets(const QWidget *widget) #if QT_CONFIG(menu) && !qobject_cast<QMenu*>(w) #endif - && objectName != QLatin1String("qt_rubberband") - && objectName != QLatin1String("qt_qmainwindow_extended_splitter")) { + // Exclude widgets used as implementation details + && objectName != "qt_rubberband"_L1 + && objectName != "qt_qmainwindow_extended_splitter"_L1 + && objectName != "qt_spinbox_lineedit"_L1) { widgets.append(w); } } @@ -393,7 +361,7 @@ QAccessibleMdiArea::QAccessibleMdiArea(QWidget *widget) int QAccessibleMdiArea::childCount() const { - return mdiArea()->subWindowList().count(); + return mdiArea()->subWindowList().size(); } QAccessibleInterface *QAccessibleMdiArea::child(int index) const @@ -432,7 +400,7 @@ QString QAccessibleMdiSubWindow::text(QAccessible::Text textType) const { if (textType == QAccessible::Name) { QString title = mdiSubWindow()->windowTitle(); - title.replace(QLatin1String("[*]"), QLatin1String("")); + title.remove("[*]"_L1); return title; } return QAccessibleWidget::text(textType); @@ -570,7 +538,7 @@ QCalendarWidget *QAccessibleCalendarWidget::calendarWidget() const QAbstractItemView *QAccessibleCalendarWidget::calendarView() const { for (QObject *child : calendarWidget()->children()) { - if (child->objectName() == QLatin1String("qt_calendar_calendarview")) + if (child->objectName() == "qt_calendar_calendarview"_L1) return static_cast<QAbstractItemView *>(child); } return nullptr; @@ -579,7 +547,7 @@ QAbstractItemView *QAccessibleCalendarWidget::calendarView() const QWidget *QAccessibleCalendarWidget::navigationBar() const { for (QObject *child : calendarWidget()->children()) { - if (child->objectName() == QLatin1String("qt_calendar_navigationbar")) + if (child->objectName() == "qt_calendar_navigationbar"_L1) return static_cast<QWidget *>(child); } return nullptr; @@ -761,7 +729,7 @@ class AttributeFormatterRef { public: template <typename RHS> void operator=(RHS &&rhs) - { string += QLatin1String(key) + QLatin1Char(':') + std::forward<RHS>(rhs) + QLatin1Char(';'); } + { string += QLatin1StringView(key) + u':' + std::forward<RHS>(rhs) + u';'; } }; /*! @@ -769,7 +737,7 @@ public: \brief Small string-builder class that supports a map-like API to serialize key-value pairs. \code AttributeFormatter attrs; - attrs["foo"] = QLatinString("hello") + world + QLatin1Char('!'); + attrs["foo"] = QLatinString("hello") + world + u'!'; \endcode The key type is always \c{const char*}, and the right-hand-side can be any QStringBuilder expression. @@ -852,13 +820,13 @@ QString QAccessibleTextWidget::attributes(int offset, int *startOffset, int *end AttributeFormatter attrs; QString family = charFormatFont.families().value(0, QString()); if (!family.isEmpty()) { - family = family.replace(u'\\', QLatin1String("\\\\")); - family = family.replace(u':', QLatin1String("\\:")); - family = family.replace(u',', QLatin1String("\\,")); - family = family.replace(u'=', QLatin1String("\\=")); - family = family.replace(u';', QLatin1String("\\;")); - family = family.replace(u'\"', QLatin1String("\\\"")); - attrs["font-family"] = QLatin1Char('"') + family + QLatin1Char('"'); + family = family.replace(u'\\', "\\\\"_L1); + family = family.replace(u':', "\\:"_L1); + family = family.replace(u',', "\\,"_L1); + family = family.replace(u'=', "\\="_L1); + family = family.replace(u';', "\\;"_L1); + family = family.replace(u'\"', "\\\""_L1); + attrs["font-family"] = u'"' + family + u'"'; } int fontSize = int(charFormatFont.pointSize()); @@ -966,7 +934,7 @@ QString QAccessibleTextWidget::text(int startOffset, int endOffset) const cursor.setPosition(startOffset, QTextCursor::MoveAnchor); cursor.setPosition(endOffset, QTextCursor::KeepAnchor); - return cursor.selectedText().replace(QChar(QChar::ParagraphSeparator), QLatin1Char('\n')); + return cursor.selectedText().replace(QChar(QChar::ParagraphSeparator), u'\n'); } QPoint QAccessibleTextWidget::scrollBarPosition() const @@ -1105,8 +1073,8 @@ QAccessibleMainWindow::QAccessibleMainWindow(QWidget *widget) QAccessibleInterface *QAccessibleMainWindow::child(int index) const { - QList<QWidget*> kids = childWidgets(mainWindow()); - if (index >= 0 && index < kids.count()) { + QList<QWidget*> kids = _q_ac_childWidgets(mainWindow()); + if (index >= 0 && index < kids.size()) { return QAccessible::queryAccessibleInterface(kids.at(index)); } return nullptr; @@ -1114,13 +1082,13 @@ QAccessibleInterface *QAccessibleMainWindow::child(int index) const int QAccessibleMainWindow::childCount() const { - QList<QWidget*> kids = childWidgets(mainWindow()); - return kids.count(); + QList<QWidget*> kids = _q_ac_childWidgets(mainWindow()); + return kids.size(); } int QAccessibleMainWindow::indexOfChild(const QAccessibleInterface *iface) const { - QList<QWidget*> kids = childWidgets(mainWindow()); + QList<QWidget*> kids = _q_ac_childWidgets(mainWindow()); return kids.indexOf(static_cast<QWidget*>(iface->object())); } @@ -1133,7 +1101,7 @@ QAccessibleInterface *QAccessibleMainWindow::childAt(int x, int y) const if (!QRect(gp.x(), gp.y(), w->width(), w->height()).contains(x, y)) return nullptr; - const QWidgetList kids = childWidgets(mainWindow()); + const QWidgetList kids = _q_ac_childWidgets(mainWindow()); QPoint rp = mainWindow()->mapFromGlobal(QPoint(x, y)); for (QWidget *child : kids) { if (!child->isWindow() && !child->isHidden() && child->geometry().contains(rp)) { @@ -1152,4 +1120,4 @@ QMainWindow *QAccessibleMainWindow::mainWindow() const QT_END_NAMESPACE -#endif // QT_NO_ACCESSIBILITY +#endif // QT_CONFIG(accessibility) diff --git a/src/widgets/accessible/qaccessiblewidgets_p.h b/src/widgets/accessible/qaccessiblewidgets_p.h index 87f0b888a0..69bd84ea23 100644 --- a/src/widgets/accessible/qaccessiblewidgets_p.h +++ b/src/widgets/accessible/qaccessiblewidgets_p.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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 Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QACCESSIBLEWIDGETS_H #define QACCESSIBLEWIDGETS_H @@ -54,7 +18,7 @@ #include <QtWidgets/private/qtwidgetsglobal_p.h> #include <QtWidgets/qaccessiblewidget.h> -#ifndef QT_NO_ACCESSIBILITY +#if QT_CONFIG(accessibility) #include <QtCore/QPointer> #include <QtCore/QPair> @@ -319,7 +283,7 @@ public: }; #endif // QT_CONFIG(mainwindow) -#endif // QT_NO_ACCESSIBILITY +#endif // QT_CONFIG(accessibility) QT_END_NAMESPACE diff --git a/src/widgets/accessible/rangecontrols.cpp b/src/widgets/accessible/rangecontrols.cpp index 6c12b553b4..b172c10044 100644 --- a/src/widgets/accessible/rangecontrols.cpp +++ b/src/widgets/accessible/rangecontrols.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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 Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "rangecontrols_p.h" @@ -65,7 +29,9 @@ QT_BEGIN_NAMESPACE -#ifndef QT_NO_ACCESSIBILITY +using namespace Qt::StringLiterals; + +#if QT_CONFIG(accessibility) #if QT_CONFIG(spinbox) QAccessibleAbstractSpinBox::QAccessibleAbstractSpinBox(QWidget *w) @@ -253,7 +219,7 @@ QAccessibleSpinBox::QAccessibleSpinBox(QWidget *w) : QAccessibleAbstractSpinBox(w) { Q_ASSERT(spinBox()); - addControllingSignal(QLatin1String("valueChanged(int)")); + addControllingSignal("valueChanged(int)"_L1); } /*! @@ -270,7 +236,7 @@ QAccessibleDoubleSpinBox::QAccessibleDoubleSpinBox(QWidget *widget) : QAccessibleAbstractSpinBox(widget) { Q_ASSERT(qobject_cast<QDoubleSpinBox *>(widget)); - addControllingSignal(QLatin1String("valueChanged(double)")); + addControllingSignal("valueChanged(double)"_L1); } /*! @@ -307,7 +273,7 @@ QAccessibleScrollBar::QAccessibleScrollBar(QWidget *w) : QAccessibleAbstractSlider(w, QAccessible::ScrollBar) { Q_ASSERT(scrollBar()); - addControllingSignal(QLatin1String("valueChanged(int)")); + addControllingSignal("valueChanged(int)"_L1); } /*! Returns the scroll bar. */ @@ -342,7 +308,7 @@ QAccessibleSlider::QAccessibleSlider(QWidget *w) : QAccessibleAbstractSlider(w) { Q_ASSERT(slider()); - addControllingSignal(QLatin1String("valueChanged(int)")); + addControllingSignal("valueChanged(int)"_L1); } /*! Returns the slider. */ @@ -410,7 +376,7 @@ QAccessibleDial::QAccessibleDial(QWidget *widget) : QAccessibleAbstractSlider(widget, QAccessible::Dial) { Q_ASSERT(qobject_cast<QDial *>(widget)); - addControllingSignal(QLatin1String("valueChanged(int)")); + addControllingSignal("valueChanged(int)"_L1); } QString QAccessibleDial::text(QAccessible::Text textType) const @@ -427,6 +393,6 @@ QDial *QAccessibleDial::dial() const } #endif // QT_CONFIG(dial) -#endif // QT_NO_ACCESSIBILITY +#endif // QT_CONFIG(accessibility) QT_END_NAMESPACE diff --git a/src/widgets/accessible/rangecontrols_p.h b/src/widgets/accessible/rangecontrols_p.h index 1eada8e456..162cbbdb34 100644 --- a/src/widgets/accessible/rangecontrols_p.h +++ b/src/widgets/accessible/rangecontrols_p.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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 Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef RANGECONTROLS_H #define RANGECONTROLS_H @@ -56,7 +20,7 @@ QT_BEGIN_NAMESPACE -#ifndef QT_NO_ACCESSIBILITY +#if QT_CONFIG(accessibility) class QAbstractSpinBox; class QAbstractSlider; @@ -199,7 +163,7 @@ protected: }; #endif // QT_CONFIG(dial) -#endif // QT_NO_ACCESSIBILITY +#endif // QT_CONFIG(accessibility) QT_END_NAMESPACE diff --git a/src/widgets/accessible/simplewidgets.cpp b/src/widgets/accessible/simplewidgets.cpp index 3ecd938039..fbbbab857d 100644 --- a/src/widgets/accessible/simplewidgets.cpp +++ b/src/widgets/accessible/simplewidgets.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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 Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "simplewidgets_p.h" @@ -79,6 +43,9 @@ #ifndef QT_NO_PICTURE #include <QtGui/qpicture.h> #endif +#if QT_CONFIG(messagebox) +#include <qmessagebox.h> +#endif #include <qstyle.h> #include <qstyleoption.h> #include <qtextdocument.h> @@ -93,9 +60,11 @@ QT_BEGIN_NAMESPACE -#ifndef QT_NO_ACCESSIBILITY +using namespace Qt::StringLiterals; + +#if QT_CONFIG(accessibility) -extern QList<QWidget*> childWidgets(const QWidget *widget); +QWidgetList _q_ac_childWidgets(const QWidget *widget); QString qt_accStripAmp(const QString &text); QString qt_accHotKey(const QString &text); @@ -120,9 +89,9 @@ QAccessibleButton::QAccessibleButton(QWidget *w) // FIXME: The checkable state of the button is dynamic, // while we only update the controlling signal once :( if (button()->isCheckable()) - addControllingSignal(QLatin1String("toggled(bool)")); + addControllingSignal("toggled(bool)"_L1); else - addControllingSignal(QLatin1String("clicked()")); + addControllingSignal("clicked()"_L1); } /*! Returns the button. */ @@ -247,11 +216,9 @@ QStringList QAccessibleButton::actionNames() const names << toggleAction(); break; default: - if (button()->isCheckable()) { + if (button()->isCheckable()) names << toggleAction(); - } else { - names << pressAction(); - } + names << pressAction(); break; } } @@ -434,10 +401,10 @@ QAccessible::Role QAccessibleDisplay::role() const #if QT_CONFIG(label) QLabel *l = qobject_cast<QLabel*>(object()); if (l) { - if (!l->pixmap(Qt::ReturnByValue).isNull()) + if (!l->pixmap().isNull()) return QAccessible::Graphic; #ifndef QT_NO_PICTURE - if (!l->picture(Qt::ReturnByValue).isNull()) + if (!l->picture().isNull()) return QAccessible::Graphic; #endif #if QT_CONFIG(movie) @@ -562,7 +529,7 @@ QSize QAccessibleDisplay::imageSize() const #endif return QSize(); #if QT_CONFIG(label) - return label->pixmap(Qt::ReturnByValue).size(); + return label->pixmap().size(); #endif } @@ -575,7 +542,7 @@ QPoint QAccessibleDisplay::imagePosition() const #endif return QPoint(); #if QT_CONFIG(label) - if (label->pixmap(Qt::ReturnByValue).isNull()) + if (label->pixmap().isNull()) return QPoint(); return QPoint(label->mapToGlobal(label->pos())); @@ -638,7 +605,7 @@ QAccessibleGroupBox::relations(QAccessible::Relation match /* = QAccessible::All QAccessibleWidget::relations(match); if ((match & QAccessible::Labelled) && (!groupBox()->title().isEmpty())) { - const QList<QWidget*> kids = childWidgets(widget()); + const QList<QWidget*> kids = _q_ac_childWidgets(widget()); for (QWidget *kid : kids) { QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(kid); if (iface) @@ -687,8 +654,8 @@ QStringList QAccessibleGroupBox::keyBindingsForAction(const QString &) const QAccessibleLineEdit::QAccessibleLineEdit(QWidget *w, const QString &name) : QAccessibleWidget(w, QAccessible::EditableText, name) { - addControllingSignal(QLatin1String("textChanged(const QString&)")); - addControllingSignal(QLatin1String("returnPressed()")); + addControllingSignal("textChanged(const QString&)"_L1); + addControllingSignal("returnPressed()"_L1); } /*! Returns the line edit. */ @@ -705,7 +672,7 @@ QString QAccessibleLineEdit::text(QAccessible::Text t) const if (lineEdit()->echoMode() == QLineEdit::Normal) str = lineEdit()->text(); else if (lineEdit()->echoMode() != QLineEdit::NoEcho) - str = QString(lineEdit()->text().length(), QChar::fromLatin1('*')); + str = QString(lineEdit()->text().size(), QChar::fromLatin1('*')); break; default: break; @@ -811,7 +778,7 @@ void QAccessibleLineEdit::selection(int selectionIndex, int *startOffset, int *e return; *startOffset = lineEdit()->selectionStart(); - *endOffset = *startOffset + lineEdit()->selectedText().count(); + *endOffset = *startOffset + lineEdit()->selectedText().size(); } QString QAccessibleLineEdit::text(int startOffset, int endOffset) const @@ -884,7 +851,7 @@ void QAccessibleLineEdit::setSelection(int selectionIndex, int startOffset, int int QAccessibleLineEdit::characterCount() const { - return lineEdit()->text().count(); + return lineEdit()->text().size(); } void QAccessibleLineEdit::scrollToSubstring(int startIndex, int endIndex) @@ -985,6 +952,49 @@ QWindowContainer *QAccessibleWindowContainer::container() const return static_cast<QWindowContainer *>(widget()); } -#endif // QT_NO_ACCESSIBILITY +#if QT_CONFIG(messagebox) +/*! + \internal + Implements QAccessibleWidget for QMessageBox +*/ +QAccessibleMessageBox::QAccessibleMessageBox(QWidget *widget) + : QAccessibleWidget(widget, QAccessible::AlertMessage) +{ + Q_ASSERT(qobject_cast<QMessageBox *>(widget)); +} + +QMessageBox *QAccessibleMessageBox::messageBox() const +{ + return static_cast<QMessageBox *>(widget()); +} + +QString QAccessibleMessageBox::text(QAccessible::Text t) const +{ + QString str; + + switch (t) { + case QAccessible::Name: + str = QAccessibleWidget::text(t); + if (str.isEmpty()) // implies no title text is set + str = messageBox()->text(); + break; + case QAccessible::Description: + str = widget()->accessibleDescription(); + break; + case QAccessible::Value: + str = messageBox()->text(); + break; + case QAccessible::Help: + str = messageBox()->informativeText(); + break; + default: + break; + } + + return str; +} +#endif + +#endif // QT_CONFIG(accessibility) QT_END_NAMESPACE diff --git a/src/widgets/accessible/simplewidgets_p.h b/src/widgets/accessible/simplewidgets_p.h index dd1631d6a5..c9c03b00d8 100644 --- a/src/widgets/accessible/simplewidgets_p.h +++ b/src/widgets/accessible/simplewidgets_p.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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 Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef SIMPLEWIDGETS_H #define SIMPLEWIDGETS_H @@ -57,12 +21,13 @@ QT_BEGIN_NAMESPACE -#ifndef QT_NO_ACCESSIBILITY +#if QT_CONFIG(accessibility) class QAbstractButton; class QLineEdit; class QToolButton; class QGroupBox; +class QMessageBox; class QProgressBar; #if QT_CONFIG(abstractbutton) @@ -225,7 +190,19 @@ private: QWindowContainer *container() const; }; -#endif // QT_NO_ACCESSIBILITY +#if QT_CONFIG(messagebox) +class QAccessibleMessageBox : public QAccessibleWidget +{ +public: + explicit QAccessibleMessageBox(QWidget *widget); + + QString text(QAccessible::Text t) const override; + + QMessageBox *messageBox() const; +}; +#endif + +#endif // QT_CONFIG(accessibility) QT_END_NAMESPACE diff --git a/src/widgets/compat/removed_api.cpp b/src/widgets/compat/removed_api.cpp index 32f4e7c806..691cc2cc7f 100644 --- a/src/widgets/compat/removed_api.cpp +++ b/src/widgets/compat/removed_api.cpp @@ -1,50 +1,15 @@ -/**************************************************************************** -** -** Copyright (C) 2021 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Marc Mutz <marc.mutz@kdab.com> -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the QtCore module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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 Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#define QT_BUILD_REMOVED_API - -#include "qglobal.h" +// Copyright (C) 2021 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Marc Mutz <marc.mutz@kdab.com> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#define QT_WIDGETS_BUILD_REMOVED_API + +#include "qtwidgetsglobal.h" QT_USE_NAMESPACE -#if QT_REMOVED_SINCE(6, 3) +#if QT_WIDGETS_REMOVED_SINCE(6, 3) +#if QT_CONFIG(menu) #include "qmenu.h" QAction *QMenu::addAction(const QString &text) @@ -56,6 +21,7 @@ QAction *QMenu::addAction(const QIcon &icon, const QString &text) { return QWidget::addAction(icon, text); } +#endif #if !QT_CONFIG(shortcut) // the overloads taking QKeySequence as a trailing argument are deprecated, not removed, @@ -72,6 +38,7 @@ QAction *QMenu::addAction(const QIcon &icon, const QString &text, } #endif +#if QT_CONFIG(toolbar) #include "qtoolbar.h" QAction *QToolBar::addAction(const QString &text) @@ -95,7 +62,9 @@ QAction *QToolBar::addAction(const QIcon &icon, const QString &text, { return QWidget::addAction(icon, text, receiver, member); } +#endif +#if QT_CONFIG(menubar) #include "qmenubar.h" QAction *QMenuBar::addAction(const QString &text) @@ -107,8 +76,9 @@ QAction *QMenuBar::addAction(const QString &text, const QObject *receiver, const { return QWidget::addAction(text, receiver, member); } +#endif // #include <qotherheader.h> // // implement removed functions from qotherheader.h -#endif // QT_REMOVED_SINCE(6, 3) +#endif // QT_WIDGETS_REMOVED_SINCE(6, 3) diff --git a/src/widgets/configure.cmake b/src/widgets/configure.cmake index 650c35876d..f71ebef9d9 100644 --- a/src/widgets/configure.cmake +++ b/src/widgets/configure.cmake @@ -1,3 +1,6 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + #### Inputs @@ -42,7 +45,7 @@ qt_feature("style-stylesheet" PUBLIC SECTION "Styles" LABEL "QStyleSheetStyle" PURPOSE "Provides a widget style which is configurable via CSS." - CONDITION QT_FEATURE_style_windows AND QT_FEATURE_properties AND QT_FEATURE_cssparser + CONDITION QT_FEATURE_style_windows AND QT_FEATURE_cssparser ) qt_feature_definition("style-stylesheet" "QT_NO_STYLE_STYLESHEET" NEGATE VALUE "1") qt_feature("effects" PRIVATE @@ -355,7 +358,7 @@ qt_feature("textedit" PUBLIC SECTION "Widgets" LABEL "QTextEdit" PURPOSE "Supports rich text editing." - CONDITION QT_FEATURE_scrollarea AND QT_FEATURE_properties AND QT_FEATURE_widgettextcontrol + CONDITION QT_FEATURE_scrollarea AND QT_FEATURE_widgettextcontrol ) qt_feature_definition("textedit" "QT_NO_TEXTEDIT" NEGATE VALUE "1") qt_feature("syntaxhighlighter" PUBLIC @@ -468,7 +471,7 @@ qt_feature("wizard" PUBLIC SECTION "Dialogs" LABEL "QWizard" PURPOSE "Provides a framework for multi-page click-through dialogs." - CONDITION ( QT_FEATURE_dialog ) AND ( QT_FEATURE_pushbutton ) AND ( QT_FEATURE_properties ) AND ( QT_FEATURE_label ) + CONDITION ( QT_FEATURE_dialog ) AND ( QT_FEATURE_pushbutton ) AND ( QT_FEATURE_label ) ) qt_feature_definition("wizard" "QT_NO_WIZARD" NEGATE VALUE "1") qt_feature("listview" PUBLIC @@ -496,7 +499,7 @@ qt_feature("datawidgetmapper" PUBLIC SECTION "ItemViews" LABEL "QDataWidgetMapper" PURPOSE "Provides mapping between a section of a data model to widgets." - CONDITION QT_FEATURE_itemviews AND QT_FEATURE_properties + CONDITION QT_FEATURE_itemviews ) qt_feature_definition("datawidgetmapper" "QT_NO_DATAWIDGETMAPPER" NEGATE VALUE "1") qt_feature("columnview" PUBLIC diff --git a/src/widgets/dialogs/images/qtlogo-64.png b/src/widgets/dialogs/images/qtlogo-64.png Binary files differindex 39a4a26f39..e40b5c6fc8 100644 --- a/src/widgets/dialogs/images/qtlogo-64.png +++ b/src/widgets/dialogs/images/qtlogo-64.png diff --git a/src/widgets/dialogs/qcolordialog.cpp b/src/widgets/dialogs/qcolordialog.cpp index 9db8d5687c..1bb65e6c24 100644 --- a/src/widgets/dialogs/qcolordialog.cpp +++ b/src/widgets/dialogs/qcolordialog.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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 Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qcolordialog.h" @@ -75,17 +39,31 @@ #include "private/qdialog_p.h" +#include <qpa/qplatformintegration.h> +#include <qpa/qplatformservices.h> +#include <private/qguiapplication_p.h> + #include <algorithm> QT_BEGIN_NAMESPACE -namespace { +using namespace Qt::StringLiterals; + +namespace QtPrivate { class QColorLuminancePicker; class QColorPicker; class QColorShower; class QWellArray; +class QColorWell; class QColorPickingEventFilter; -} // unnamed namespace +} // namespace QtPrivate + +using QColorLuminancePicker = QtPrivate::QColorLuminancePicker; +using QColorPicker = QtPrivate::QColorPicker; +using QColorShower = QtPrivate::QColorShower; +using QWellArray = QtPrivate::QWellArray; +using QColorWell = QtPrivate::QColorWell; +using QColorPickingEventFilter = QtPrivate::QColorPickingEventFilter; class QColorDialogPrivate : public QDialogPrivate { @@ -122,6 +100,7 @@ public: void showAlpha(bool b); bool isAlphaVisible() const; void retranslateStrings(); + bool supportsColorPicking() const; void _q_addCustom(); void _q_setCustom(int index, QRgb color); @@ -179,7 +158,7 @@ private: //////////// QWellArray BEGIN -namespace { +namespace QtPrivate { class QWellArray : public QWidget { @@ -494,7 +473,7 @@ void QWellArray::keyPressEvent(QKeyEvent* e) return; } -} +} // namespace QtPrivate //////////// QWellArray END @@ -584,7 +563,7 @@ static inline void rgb2hsv(QRgb rgb, int &h, int &s, int &v) c.getHsv(&h, &s, &v); } -namespace { +namespace QtPrivate { class QColorWell : public QWellArray { @@ -734,9 +713,13 @@ private: bool crossVisible; }; +} // namespace QtPrivate + static int pWidth = 220; static int pHeight = 200; +namespace QtPrivate { + class QColorLuminancePicker : public QWidget { Q_OBJECT @@ -1197,8 +1180,8 @@ QColorShower::QColorShower(QColorDialog *parent) #else gl->addWidget(lab, 0, 0, 1, -1); #endif - connect(lab, SIGNAL(colorDropped(QRgb)), this, SIGNAL(newCol(QRgb))); - connect(lab, SIGNAL(colorDropped(QRgb)), this, SLOT(setRgb(QRgb))); + connect(lab, &QColorShowLabel::colorDropped, this, &QColorShower::newCol); + connect(lab, &QColorShowLabel::colorDropped, this, &QColorShower::setRgb); hEd = new QColSpinBox(this); hEd->setRange(0, 359); @@ -1302,12 +1285,13 @@ QColorShower::QColorShower(QColorDialog *parent) alphaLab->hide(); lblHtml = new QLabel(this); htEd = new QLineEdit(this); + htEd->setObjectName("qt_colorname_lineedit"); #ifndef QT_NO_SHORTCUT lblHtml->setBuddy(htEd); #endif #if QT_CONFIG(regularexpression) - QRegularExpression regExp(QStringLiteral("#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})")); + QRegularExpression regExp(QStringLiteral("#?([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})")); QRegularExpressionValidator *validator = new QRegularExpressionValidator(regExp, this); htEd->setValidator(validator); #else @@ -1324,20 +1308,20 @@ QColorShower::QColorShower(QColorDialog *parent) gl->addWidget(htEd, 5, 2, 1, /*colspan=*/ 3); #endif - connect(hEd, SIGNAL(valueChanged(int)), this, SLOT(hsvEd())); - connect(sEd, SIGNAL(valueChanged(int)), this, SLOT(hsvEd())); - connect(vEd, SIGNAL(valueChanged(int)), this, SLOT(hsvEd())); + connect(hEd, &QSpinBox::valueChanged, this, &QColorShower::hsvEd); + connect(sEd, &QSpinBox::valueChanged, this, &QColorShower::hsvEd); + connect(vEd, &QSpinBox::valueChanged, this, &QColorShower::hsvEd); - connect(rEd, SIGNAL(valueChanged(int)), this, SLOT(rgbEd())); - connect(gEd, SIGNAL(valueChanged(int)), this, SLOT(rgbEd())); - connect(bEd, SIGNAL(valueChanged(int)), this, SLOT(rgbEd())); - connect(alphaEd, SIGNAL(valueChanged(int)), this, SLOT(rgbEd())); - connect(htEd, SIGNAL(textEdited(QString)), this, SLOT(htmlEd())); + connect(rEd, &QSpinBox::valueChanged, this, &QColorShower::rgbEd); + connect(gEd, &QSpinBox::valueChanged, this, &QColorShower::rgbEd); + connect(bEd, &QSpinBox::valueChanged, this, &QColorShower::rgbEd); + connect(alphaEd, &QSpinBox::valueChanged, this, &QColorShower::rgbEd); + connect(htEd, &QLineEdit::textChanged, this, &QColorShower::htmlEd); retranslateStrings(); } -} // unnamed namespace +} // namespace QtPrivate inline QRgb QColorDialogPrivate::currentColor() const { return cs->currentColor(); } inline int QColorDialogPrivate::currentAlpha() const { return cs->currentAlpha(); } @@ -1400,11 +1384,20 @@ void QColorShower::hsvEd() void QColorShower::htmlEd() { - QColor c; QString t = htEd->text(); - c.setNamedColor(t); + if (t.isEmpty()) + return; + + if (!t.startsWith(QStringLiteral("#"))) { + t = QStringLiteral("#") + t; + QSignalBlocker blocker(htEd); + htEd->setText(t); + } + + QColor c = QColor::fromString(t); if (!c.isValid()) return; + curCol = qRgba(c.red(), c.green(), c.blue(), currentAlpha()); rgb2hsv(curCol, hue, sat, val); @@ -1566,7 +1559,9 @@ QColor QColorDialogPrivate::grabScreenColor(const QPoint &p) QScreen *screen = QGuiApplication::screenAt(p); if (!screen) screen = QGuiApplication::primaryScreen(); - const QPixmap pixmap = screen->grabWindow(0, p.x(), p.y(), 1, 1); + const QRect screenRect = screen->geometry(); + const QPixmap pixmap = + screen->grabWindow(0, p.x() - screenRect.x(), p.y() - screenRect.y(), 1, 1); const QImage i = pixmap.toImage(); return i.pixel(0, 0); } @@ -1605,6 +1600,20 @@ void QColorDialogPrivate::_q_newStandard(int r, int c) void QColorDialogPrivate::_q_pickScreenColor() { Q_Q(QColorDialog); + + auto *platformServices = QGuiApplicationPrivate::platformIntegration()->services(); + if (platformServices->hasCapability(QPlatformServices::Capability::ColorPicking)) { + if (auto *colorPicker = platformServices->colorPicker(q->windowHandle())) { + q->connect(colorPicker, &QPlatformServiceColorPicker::colorPicked, q, + [q, colorPicker](const QColor &color) { + colorPicker->deleteLater(); + q->setCurrentColor(color); + }); + colorPicker->pickColor(); + return; + } + } + if (!colorPickingEventFilter) colorPickingEventFilter = new QColorPickingEventFilter(this, q); q->installEventFilter(colorPickingEventFilter); @@ -1633,16 +1642,18 @@ void QColorDialogPrivate::_q_pickScreenColor() addCusBt->setDisabled(true); buttons->setDisabled(true); - screenColorPickerButton->setDisabled(true); - - const QPoint globalPos = QCursor::pos(); - q->setCurrentColor(grabScreenColor(globalPos)); - updateColorLabelText(globalPos); + if (screenColorPickerButton) { + screenColorPickerButton->setDisabled(true); + const QPoint globalPos = QCursor::pos(); + q->setCurrentColor(grabScreenColor(globalPos)); + updateColorLabelText(globalPos); + } } void QColorDialogPrivate::updateColorLabelText(const QPoint &globalPos) { - lblScreenColorInfo->setText(QColorDialog::tr("Cursor at %1, %2\nPress ESC to cancel") + if (lblScreenColorInfo) + lblScreenColorInfo->setText(QColorDialog::tr("Cursor at %1, %2\nPress ESC to cancel") .arg(globalPos.x()) .arg(globalPos.y())); } @@ -1659,7 +1670,7 @@ void QColorDialogPrivate::releaseColorPicking() #endif q->releaseKeyboard(); q->setMouseTracking(false); - lblScreenColorInfo->setText(QLatin1String("\n")); + lblScreenColorInfo->setText("\n"_L1); addCusBt->setDisabled(false); buttons->setDisabled(false); screenColorPickerButton->setDisabled(false); @@ -1724,12 +1735,16 @@ void QColorDialogPrivate::initWidgets() leftLay->addWidget(standard); #if !defined(QT_SMALL_COLORDIALOG) - // The screen color picker button - screenColorPickerButton = new QPushButton(); - leftLay->addWidget(screenColorPickerButton); - lblScreenColorInfo = new QLabel(QLatin1String("\n")); - leftLay->addWidget(lblScreenColorInfo); - q->connect(screenColorPickerButton, SIGNAL(clicked()), SLOT(_q_pickScreenColor())); + if (supportsColorPicking()) { + screenColorPickerButton = new QPushButton(); + leftLay->addWidget(screenColorPickerButton); + lblScreenColorInfo = new QLabel("\n"_L1); + leftLay->addWidget(lblScreenColorInfo); + q->connect(screenColorPickerButton, SIGNAL(clicked()), SLOT(_q_pickScreenColor())); + } else { + screenColorPickerButton = nullptr; + lblScreenColorInfo = nullptr; + } #endif leftLay->addStretch(); @@ -1782,7 +1797,7 @@ void QColorDialogPrivate::initWidgets() pickLay->addLayout(cLay); cp = new QColorPicker(q); - cp->setFrameStyle(QFrame::Panel + QFrame::Sunken); + cp->setFrameStyle(QFrame::Panel | QFrame::Sunken); #if defined(QT_SMALL_COLORDIALOG) cp->hide(); @@ -1866,12 +1881,22 @@ void QColorDialogPrivate::retranslateStrings() lblBasicColors->setText(QColorDialog::tr("&Basic colors")); lblCustomColors->setText(QColorDialog::tr("&Custom colors")); addCusBt->setText(QColorDialog::tr("&Add to Custom Colors")); - screenColorPickerButton->setText(QColorDialog::tr("&Pick Screen Color")); +#if !defined(QT_SMALL_COLORDIALOG) + if (screenColorPickerButton) + screenColorPickerButton->setText(QColorDialog::tr("&Pick Screen Color")); +#endif } cs->retranslateStrings(); } +bool QColorDialogPrivate::supportsColorPicking() const +{ + const auto integration = QGuiApplicationPrivate::platformIntegration(); + return integration->hasCapability(QPlatformIntegration::ScreenWindowGrabbing) + || integration->services()->hasCapability(QPlatformServices::Capability::ColorPicking); +} + bool QColorDialogPrivate::canBeNativeDialog() const { // Don't use Q_Q here! This function is called from ~QDialog, @@ -1885,12 +1910,10 @@ bool QColorDialogPrivate::canBeNativeDialog() const return false; } - QLatin1String staticName(QColorDialog::staticMetaObject.className()); - QLatin1String dynamicName(q->metaObject()->className()); - return (staticName == dynamicName); + return strcmp(QColorDialog::staticMetaObject.className(), q->metaObject()->className()) == 0; } -static const Qt::WindowFlags DefaultWindowFlags = +static const Qt::WindowFlags qcd_DefaultWindowFlags = Qt::Dialog | Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint; @@ -1950,7 +1973,7 @@ QColorDialog::QColorDialog(QWidget *parent) \a initial color. */ QColorDialog::QColorDialog(const QColor &initial, QWidget *parent) - : QDialog(*new QColorDialogPrivate, parent, DefaultWindowFlags) + : QDialog(*new QColorDialogPrivate, parent, qcd_DefaultWindowFlags) { Q_D(QColorDialog); d->init(initial); @@ -2117,10 +2140,13 @@ void QColorDialog::setVisible(bool visible) d->selectedQColor = QColor(); if (d->nativeDialogInUse) { - d->setNativeDialogVisible(visible); - // Set WA_DontShowOnScreen so that QDialog::setVisible(visible) below - // updates the state correctly, but skips showing the non-native version: - setAttribute(Qt::WA_DontShowOnScreen); + if (d->setNativeDialogVisible(visible)) { + // Set WA_DontShowOnScreen so that QDialog::setVisible(visible) below + // updates the state correctly, but skips showing the non-native version: + setAttribute(Qt::WA_DontShowOnScreen); + } else { + d->initWidgets(); + } } else { setAttribute(Qt::WA_DontShowOnScreen, false); } @@ -2213,7 +2239,6 @@ void QColorDialogPrivate::updateColorPicking(const QPoint &globalPos) // otherwise it is not possible to pre-select a custom cell for assignment. setCurrentColor(color, ShowColor); updateColorLabelText(globalPos); - } bool QColorDialogPrivate::handleColorPickingMouseMove(QMouseEvent *e) diff --git a/src/widgets/dialogs/qcolordialog.h b/src/widgets/dialogs/qcolordialog.h index 271c25f2dc..2031c413a9 100644 --- a/src/widgets/dialogs/qcolordialog.h +++ b/src/widgets/dialogs/qcolordialog.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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 Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QCOLORDIALOG_H #define QCOLORDIALOG_H diff --git a/src/widgets/dialogs/qdialog.cpp b/src/widgets/dialogs/qdialog.cpp index 8b018969c8..f29f1dfded 100644 --- a/src/widgets/dialogs/qdialog.cpp +++ b/src/widgets/dialogs/qdialog.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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 Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include <QtWidgets/qtwidgetsglobal.h> #if QT_CONFIG(colordialog) @@ -70,7 +34,7 @@ #include <qpa/qplatformtheme.h> #include "private/qdialog_p.h" #include "private/qguiapplication_p.h" -#ifndef QT_NO_ACCESSIBILITY +#if QT_CONFIG(accessibility) #include "qaccessible.h" #endif @@ -134,6 +98,9 @@ QPlatformDialogHelper *QDialogPrivate::platformHelper() const bool QDialogPrivate::canBeNativeDialog() const { + if (QCoreApplication::testAttribute(Qt::AA_DontUseNativeDialogs)) + return false; + QDialogPrivate *ncThis = const_cast<QDialogPrivate *>(this); QDialog *dialog = ncThis->q_func(); const int type = themeDialogType(dialog); @@ -232,14 +199,6 @@ QVariant QDialogPrivate::styleHint(QPlatformDialogHelper::StyleHint hint) const return QPlatformDialogHelper::defaultStyleHint(hint); } -void QDialogPrivate::deletePlatformHelper() -{ - delete m_platformHelper; - m_platformHelper = nullptr; - m_platformHelperCreated = false; - nativeDialogInUse = false; -} - /*! \class QDialog \brief The QDialog class is the base class of dialog windows. @@ -380,8 +339,7 @@ void QDialogPrivate::deletePlatformHelper() \snippet dialogs/dialogs.cpp 0 - \sa QDialogButtonBox, QTabWidget, QWidget, QProgressDialog, - {fowler}{GUI Design Handbook: Dialogs, Standard}, {Extension Example}, + \sa QDialogButtonBox, QTabWidget, QWidget, QProgressDialog, {Extension Example}, {Standard Dialogs Example} */ @@ -784,35 +742,41 @@ void QDialog::closeEvent(QCloseEvent *e) void QDialog::setVisible(bool visible) { Q_D(QDialog); - if (!testAttribute(Qt::WA_DontShowOnScreen) && d->canBeNativeDialog() && d->setNativeDialogVisible(visible)) + d->setVisible(visible); +} + +void QDialogPrivate::setVisible(bool visible) +{ + Q_Q(QDialog); + if (!q->testAttribute(Qt::WA_DontShowOnScreen) && canBeNativeDialog() && setNativeDialogVisible(visible)) return; // We should not block windows by the invisible modal dialog // if a platform-specific dialog is implemented as an in-process // Qt window, because in this case it will also be blocked. - const bool dontBlockWindows = testAttribute(Qt::WA_DontShowOnScreen) - && d->styleHint(QPlatformDialogHelper::DialogIsQtWindow).toBool(); + const bool dontBlockWindows = q->testAttribute(Qt::WA_DontShowOnScreen) + && styleHint(QPlatformDialogHelper::DialogIsQtWindow).toBool(); Qt::WindowModality oldModality; bool wasModalitySet; if (dontBlockWindows) { - oldModality = windowModality(); - wasModalitySet = testAttribute(Qt::WA_SetWindowModality); - setWindowModality(Qt::NonModal); + oldModality = q->windowModality(); + wasModalitySet = q->testAttribute(Qt::WA_SetWindowModality); + q->setWindowModality(Qt::NonModal); } if (visible) { - if (testAttribute(Qt::WA_WState_ExplicitShowHide) && !testAttribute(Qt::WA_WState_Hidden)) + if (q->testAttribute(Qt::WA_WState_ExplicitShowHide) && !q->testAttribute(Qt::WA_WState_Hidden)) return; - QWidget::setVisible(visible); + q->QWidget::setVisible(visible); // Window activation might be prevented. We can't test isActiveWindow here, // as the window will be activated asynchronously by the window manager. - if (!testAttribute(Qt::WA_ShowWithoutActivating)) { - QWidget *fw = window()->focusWidget(); + if (!q->testAttribute(Qt::WA_ShowWithoutActivating)) { + QWidget *fw = q->window()->focusWidget(); if (!fw) - fw = this; + fw = q; /* The following block is to handle a special case, and does not @@ -825,14 +789,14 @@ void QDialog::setVisible(bool visible) have to use [widget*]->setFocus() themselves... */ #if QT_CONFIG(pushbutton) - if (d->mainDef && fw->focusPolicy() == Qt::NoFocus) { + if (mainDef && fw->focusPolicy() == Qt::NoFocus) { QWidget *first = fw; while ((first = first->nextInFocusChain()) != fw && first->focusPolicy() == Qt::NoFocus) ; - if (first != d->mainDef && qobject_cast<QPushButton*>(first)) - d->mainDef->setFocus(); + if (first != mainDef && qobject_cast<QPushButton*>(first)) + mainDef->setFocus(); } - if (!d->mainDef && isWindow()) { + if (!mainDef && q->isWindow()) { QWidget *w = fw; while ((w = w->nextInFocusChain()) != fw) { QPushButton *pb = qobject_cast<QPushButton *>(w); @@ -849,38 +813,38 @@ void QDialog::setVisible(bool visible) } } -#ifndef QT_NO_ACCESSIBILITY - QAccessibleEvent event(this, QAccessible::DialogStart); +#if QT_CONFIG(accessibility) + QAccessibleEvent event(q, QAccessible::DialogStart); QAccessible::updateAccessibility(&event); #endif } else { - if (testAttribute(Qt::WA_WState_ExplicitShowHide) && testAttribute(Qt::WA_WState_Hidden)) + if (q->testAttribute(Qt::WA_WState_ExplicitShowHide) && q->testAttribute(Qt::WA_WState_Hidden)) return; -#ifndef QT_NO_ACCESSIBILITY - if (isVisible()) { - QAccessibleEvent event(this, QAccessible::DialogEnd); +#if QT_CONFIG(accessibility) + if (q->isVisible()) { + QAccessibleEvent event(q, QAccessible::DialogEnd); QAccessible::updateAccessibility(&event); } #endif // Reimplemented to exit a modal event loop when the dialog is hidden. - QWidget::setVisible(visible); - if (d->eventLoop) - d->eventLoop->exit(); + q->QWidget::setVisible(visible); + if (eventLoop) + eventLoop->exit(); } if (dontBlockWindows) { - setWindowModality(oldModality); - setAttribute(Qt::WA_SetWindowModality, wasModalitySet); + q->setWindowModality(oldModality); + q->setAttribute(Qt::WA_SetWindowModality, wasModalitySet); } #if QT_CONFIG(pushbutton) const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme(); - if (d->mainDef && isActiveWindow() + if (mainDef && q->isActiveWindow() && theme->themeHint(QPlatformTheme::DialogSnapToDefaultButton).toBool()) - QCursor::setPos(d->mainDef->mapToGlobal(d->mainDef->rect().center())); + QCursor::setPos(mainDef->mapToGlobal(mainDef->rect().center())); #endif } diff --git a/src/widgets/dialogs/qdialog.h b/src/widgets/dialogs/qdialog.h index 8c50642a64..4d11fe2d8d 100644 --- a/src/widgets/dialogs/qdialog.h +++ b/src/widgets/dialogs/qdialog.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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 Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QDIALOG_H #define QDIALOG_H diff --git a/src/widgets/dialogs/qdialog_p.h b/src/widgets/dialogs/qdialog_p.h index 7c7e8f89a7..878049557a 100644 --- a/src/widgets/dialogs/qdialog_p.h +++ b/src/widgets/dialogs/qdialog_p.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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 Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QDIALOG_P_H #define QDIALOG_P_H @@ -87,10 +51,11 @@ public: {} ~QDialogPrivate(); + virtual void setVisible(bool visible); + QWindow *transientParentWindow() const; bool setNativeDialogVisible(bool visible); QVariant styleHint(QPlatformDialogHelper::StyleHint hint) const; - void deletePlatformHelper(); #if QT_CONFIG(pushbutton) QPointer<QPushButton> mainDef; diff --git a/src/widgets/dialogs/qerrormessage.cpp b/src/widgets/dialogs/qerrormessage.cpp index ba57faa898..5a6d529fc2 100644 --- a/src/widgets/dialogs/qerrormessage.cpp +++ b/src/widgets/dialogs/qerrormessage.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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 Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qerrormessage.h" @@ -62,17 +26,17 @@ QT_BEGIN_NAMESPACE -namespace { -struct Message { - QString content; - QString type; -}; -} +using namespace Qt::StringLiterals; class QErrorMessagePrivate : public QDialogPrivate { Q_DECLARE_PUBLIC(QErrorMessage) public: + struct Message { + QString content; + QString type; + }; + QPushButton * ok; QCheckBox * again; QTextEdit * errors; @@ -86,8 +50,46 @@ public: bool isMessageToBeShown(const QString &message, const QString &type) const; bool nextPending(); void retranslateStrings(); + + void setVisible(bool) override; + +private: + void initHelper(QPlatformDialogHelper *) override; + void helperPrepareShow(QPlatformDialogHelper *) override; }; + +void QErrorMessagePrivate::initHelper(QPlatformDialogHelper *helper) +{ + Q_Q(QErrorMessage); + auto *messageDialogHelper = static_cast<QPlatformMessageDialogHelper *>(helper); + QObject::connect(messageDialogHelper, &QPlatformMessageDialogHelper::checkBoxStateChanged, q, + [this](Qt::CheckState state) { + again->setCheckState(state); + } + ); + QObject::connect(messageDialogHelper, &QPlatformMessageDialogHelper::clicked, q, + [this](QPlatformDialogHelper::StandardButton, QPlatformDialogHelper::ButtonRole) { + Q_Q(QErrorMessage); + q->accept(); + } + ); +} + +void QErrorMessagePrivate::helperPrepareShow(QPlatformDialogHelper *helper) +{ + Q_Q(QErrorMessage); + auto *messageDialogHelper = static_cast<QPlatformMessageDialogHelper *>(helper); + QSharedPointer<QMessageDialogOptions> options = QMessageDialogOptions::create(); + options->setText(currentMessage); + options->setWindowTitle(q->windowTitle()); + options->setText(QErrorMessage::tr("An error occurred")); + options->setInformativeText(currentMessage); + options->setStandardIcon(QMessageDialogOptions::Critical); + options->setCheckBox(again->text(), again->checkState()); + messageDialogHelper->setOptions(options); +} + namespace { class QErrorMessageTextView : public QTextEdit { @@ -183,16 +185,28 @@ static QString msgType2i18nString(QtMsgType t) return QCoreApplication::translate("QErrorMessage", messages[t]); } -static void jump(QtMsgType t, const QMessageLogContext & /*context*/, const QString &m) +static QtMessageHandler originalMessageHandler = nullptr; + +static void jump(QtMsgType t, const QMessageLogContext &context, const QString &m) { + const auto forwardToOriginalHandler = qScopeGuard([&] { + if (originalMessageHandler) + originalMessageHandler(t, context, m); + }); + if (!qtMessageHandler) return; - QString rich = QLatin1String("<p><b>") + msgType2i18nString(t) + QLatin1String("</b></p>") + auto *defaultCategory = QLoggingCategory::defaultCategory(); + if (context.category && defaultCategory + && qstrcmp(context.category, defaultCategory->categoryName()) != 0) + return; + + QString rich = "<p><b>"_L1 + msgType2i18nString(t) + "</b></p>"_L1 + Qt::convertFromPlainText(m, Qt::WhiteSpaceNormal); // ### work around text engine quirk - if (rich.endsWith(QLatin1String("</p>"))) + if (rich.endsWith("</p>"_L1)) rich.chop(4); if (!metFatal) { @@ -212,6 +226,10 @@ static void jump(QtMsgType t, const QMessageLogContext & /*context*/, const QStr /*! Constructs and installs an error handler window with the given \a parent. + + The default \l{Qt::WindowModality} {window modality} of the dialog + depends on the platform. The window modality can be overridden via + setWindowModality() before calling showMessage(). */ QErrorMessage::QErrorMessage(QWidget * parent) @@ -219,6 +237,10 @@ QErrorMessage::QErrorMessage(QWidget * parent) { Q_D(QErrorMessage); +#if defined(Q_OS_MACOS) + setWindowModality(parent ? Qt::WindowModal : Qt::ApplicationModal); +#endif + d->icon = new QLabel(this); d->errors = new QErrorMessageTextView(this); d->again = new QCheckBox(this); @@ -235,7 +257,7 @@ QErrorMessage::QErrorMessage(QWidget * parent) grid->setRowStretch(0, 42); #if QT_CONFIG(messagebox) - d->icon->setPixmap(QMessageBox::standardIcon(QMessageBox::Information)); + d->icon->setPixmap(style()->standardPixmap(QStyle::SP_MessageBoxInformation)); d->icon->setAlignment(Qt::AlignHCenter | Qt::AlignTop); #endif d->again->setChecked(true); @@ -253,10 +275,12 @@ QErrorMessage::~QErrorMessage() { if (this == qtMessageHandler) { qtMessageHandler = nullptr; - QtMessageHandler tmp = qInstallMessageHandler(nullptr); - // in case someone else has later stuck in another... - if (tmp != jump) - qInstallMessageHandler(tmp); + QtMessageHandler currentMessagHandler = qInstallMessageHandler(nullptr); + if (currentMessagHandler != jump) + qInstallMessageHandler(currentMessagHandler); + else + qInstallMessageHandler(originalMessageHandler); + originalMessageHandler = nullptr; } } @@ -276,8 +300,12 @@ void QErrorMessage::done(int a) } d->currentMessage.clear(); d->currentType.clear(); - if (!d->nextPending()) { - QDialog::done(a); + + QDialog::done(a); + + if (d->nextPending()) { + show(); + } else { if (this == qtMessageHandler && metFatal) exit(1); } @@ -288,6 +316,12 @@ void QErrorMessage::done(int a) Returns a pointer to a QErrorMessage object that outputs the default Qt messages. This function creates such an object, if there isn't one already. + + The object will only output log messages of QLoggingCategory::defaultCategory(). + + The object will forward all messages to the original message handler. + + \sa qInstallMessageHandler */ QErrorMessage * QErrorMessage::qtHandler() @@ -296,7 +330,7 @@ QErrorMessage * QErrorMessage::qtHandler() qtMessageHandler = new QErrorMessage(nullptr); qAddPostRoutine(deleteStaticcQErrorMessage); // clean up qtMessageHandler->setWindowTitle(QCoreApplication::applicationName()); - qInstallMessageHandler(jump); + originalMessageHandler = qInstallMessageHandler(jump); } return qtMessageHandler; } @@ -324,6 +358,7 @@ bool QErrorMessagePrivate::nextPending() #endif currentMessage = std::move(message); currentType = std::move(type); + again->setChecked(true); return true; } } @@ -369,6 +404,23 @@ void QErrorMessage::showMessage(const QString &message, const QString &type) show(); } +void QErrorMessagePrivate::setVisible(bool visible) +{ + Q_Q(QErrorMessage); + if (q->testAttribute(Qt::WA_WState_ExplicitShowHide) && q->testAttribute(Qt::WA_WState_Hidden) != visible) + return; + + if (canBeNativeDialog()) + setNativeDialogVisible(visible); + + // Update WA_DontShowOnScreen based on whether the native dialog was shown, + // so that QDialog::setVisible(visible) below updates the QWidget state correctly, + // but skips showing the non-native version. + q->setAttribute(Qt::WA_DontShowOnScreen, nativeDialogInUse); + + QDialogPrivate::setVisible(visible); +} + /*! \reimp */ diff --git a/src/widgets/dialogs/qerrormessage.h b/src/widgets/dialogs/qerrormessage.h index 220694e54e..55f0ac058e 100644 --- a/src/widgets/dialogs/qerrormessage.h +++ b/src/widgets/dialogs/qerrormessage.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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 Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QERRORMESSAGE_H #define QERRORMESSAGE_H diff --git a/src/widgets/dialogs/qfiledialog.cpp b/src/widgets/dialogs/qfiledialog.cpp index 935cfeb409..c83c5e64d8 100644 --- a/src/widgets/dialogs/qfiledialog.cpp +++ b/src/widgets/dialogs/qfiledialog.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2020 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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 Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #define QT_NO_URL_CAST_FROM_STRING @@ -88,6 +52,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + Q_GLOBAL_STATIC(QUrl, lastVisitedDir) /*! @@ -167,9 +133,10 @@ Q_GLOBAL_STATIC(QUrl, lastVisitedDir) By default, a platform-native file dialog will be used if the platform has one. In that case, the widgets which would otherwise be used to construct the dialog will not be instantiated, so related accessors such as layout() and - itemDelegate() will return null. You can set the \l DontUseNativeDialog option to - ensure that the widget-based implementation will be used instead of the - native dialog. + itemDelegate() will return null. Also, not all platforms show file dialogs + with a title bar, so be aware that the caption text might not be visible to + the user. You can set the \l DontUseNativeDialog option to ensure that the + widget-based implementation will be used instead of the native dialog. \sa QDir, QFileInfo, QFile, QColorDialog, QFontDialog, {Standard Dialogs Example}, {Qt Widgets - Application Example} @@ -226,7 +193,7 @@ Q_GLOBAL_STATIC(QUrl, lastVisitedDir) \value DontConfirmOverwrite Don't ask for confirmation if an existing file is selected. By default confirmation is requested. - Note: This opption is not supported on macOS when using the + Note: This option is not supported on macOS when using the native file dialog. \value DontUseNativeDialog Don't use the native file dialog. By @@ -451,6 +418,7 @@ QByteArray QFileDialog::saveState() const int version = 4; QByteArray data; QDataStream stream(&data, QIODevice::WriteOnly); + stream.setVersion(QDataStream::Qt_5_0); stream << qint32(QFileDialogMagic); stream << qint32(version); @@ -485,6 +453,7 @@ bool QFileDialog::restoreState(const QByteArray &state) Q_D(QFileDialog); QByteArray sd = state; QDataStream stream(&sd, QIODevice::ReadOnly); + stream.setVersion(QDataStream::Qt_5_0); if (stream.atEnd()) return false; QStringList history; @@ -562,7 +531,6 @@ void QFileDialogPrivate::initHelper(QPlatformDialogHelper *h) QObject::connect(h, SIGNAL(directoryEntered(QUrl)), d, SLOT(_q_nativeEnterDirectory(QUrl))); QObject::connect(h, SIGNAL(filterSelected(QString)), d, SIGNAL(filterSelected(QString))); static_cast<QPlatformFileDialogHelper *>(h)->setOptions(options); - nativeDialogInUse = true; } void QFileDialogPrivate::helperPrepareShow(QPlatformDialogHelper *) @@ -683,7 +651,7 @@ void QFileDialogPrivate::retranslateStrings() if (proxyModel) abstractModel = proxyModel; #endif - int total = qMin(abstractModel->columnCount(QModelIndex()), actions.count() + 1); + int total = qMin(abstractModel->columnCount(QModelIndex()), actions.size() + 1); for (int i = 1; i < total; ++i) { actions.at(i - 1)->setText(QFileDialog::tr("Show ") + abstractModel->headerData(i, Qt::Horizontal, Qt::DisplayRole).toString()); } @@ -704,7 +672,7 @@ void QFileDialogPrivate::emitFilesSelected(const QStringList &files) { Q_Q(QFileDialog); emit q->filesSelected(files); - if (files.count() == 1) + if (files.size() == 1) emit q->fileSelected(files.first()); } @@ -721,9 +689,7 @@ bool QFileDialogPrivate::canBeNativeDialog() const return false; } - QLatin1String staticName(QFileDialog::staticMetaObject.className()); - QLatin1String dynamicName(q->metaObject()->className()); - return (staticName == dynamicName); + return strcmp(QFileDialog::staticMetaObject.className(), q->metaObject()->className()) == 0; } bool QFileDialogPrivate::usingWidgets() const @@ -798,8 +764,10 @@ void QFileDialog::setOptions(Options options) d->options->setOptions(QFileDialogOptions::FileDialogOptions(int(options))); - if ((options & DontUseNativeDialog) && !d->usingWidgets()) + if (options & DontUseNativeDialog) { + d->nativeDialogInUse = false; d->createWidgets(); + } if (d->usingWidgets()) { if (changed & DontResolveSymlinks) @@ -962,10 +930,10 @@ void QFileDialog::setDirectory(const QString &directory) d->qFileDialogUi->newFolderButton->setEnabled(d->model->flags(root) & Qt::ItemIsDropEnabled); if (root != d->rootIndex()) { #if QT_CONFIG(fscompleter) - if (directory.endsWith(QLatin1Char('/'))) + if (directory.endsWith(u'/')) d->completer->setCompletionPrefix(newDirectory); else - d->completer->setCompletionPrefix(newDirectory + QLatin1Char('/')); + d->completer->setCompletionPrefix(newDirectory + u'/'); #endif d->setRootIndex(root); } @@ -1064,7 +1032,7 @@ static inline QString fileFromPath(const QString &rootPath, QString path) if (path.at(0) == QDir::separator() #ifdef Q_OS_WIN //On Windows both cases can happen - || path.at(0) == QLatin1Char('/') + || path.at(0) == u'/' #endif ) { path.remove(0, 1); @@ -1088,8 +1056,8 @@ void QFileDialog::selectFile(const QString &filename) if (QFileInfo(filename).isRelative()) { url = d->options->initialDirectory(); QString path = url.path(); - if (!path.endsWith(QLatin1Char('/'))) - path += QLatin1Char('/'); + if (!path.endsWith(u'/')) + path += u'/'; url.setPath(path + filename); } else { url = QUrl::fromLocalFile(filename); @@ -1138,7 +1106,7 @@ void QFileDialog::selectUrl(const QUrl &url) #ifdef Q_OS_UNIX Q_AUTOTEST_EXPORT QString qt_tildeExpansion(const QString &path) { - if (!path.startsWith(QLatin1Char('~'))) + if (!path.startsWith(u'~')) return path; int separatorPosition = path.indexOf(QDir::separator()); if (separatorPosition < 0) @@ -1184,7 +1152,7 @@ QStringList QFileDialogPrivate::typedFiles() const Q_Q(const QFileDialog); QStringList files; QString editText = lineEdit()->text(); - if (!editText.contains(QLatin1Char('"'))) { + if (!editText.contains(u'"')) { #ifdef Q_OS_UNIX const QString prefix = q->directory().absolutePath() + QDir::separator(); if (QFile::exists(prefix + editText)) @@ -1198,7 +1166,7 @@ QStringList QFileDialogPrivate::typedFiles() const } else { // " is used to separate files like so: "file1" "file2" "file3" ... // ### need escape character for filenames with quotes (") - QStringList tokens = editText.split(QLatin1Char('\"')); + QStringList tokens = editText.split(u'\"'); for (int i=0; i<tokens.size(); ++i) { if ((i % 2) == 0) continue; // Every even token is a separator @@ -1250,8 +1218,9 @@ QStringList QFileDialogPrivate::addDefaultSuffixToFiles(const QStringList &files QFileInfo info(name); // if the filename has no suffix, add the default suffix const QString defaultSuffix = options->defaultSuffix(); - if (!defaultSuffix.isEmpty() && !info.isDir() && name.lastIndexOf(QLatin1Char('.')) == -1) - name += QLatin1Char('.') + defaultSuffix; + if (!defaultSuffix.isEmpty() && !info.isDir() && !info.fileName().contains(u'.')) + name += u'.' + defaultSuffix; + if (info.isAbsolute()) { files.append(name); } else { @@ -1259,8 +1228,8 @@ QStringList QFileDialogPrivate::addDefaultSuffixToFiles(const QStringList &files // This check is needed since we might be at the root directory // and on Windows it already ends with slash. QString path = rootPath(); - if (!path.endsWith(QLatin1Char('/'))) - path += QLatin1Char('/'); + if (!path.endsWith(u'/')) + path += u'/'; path += name; files.append(path); } @@ -1277,8 +1246,12 @@ QList<QUrl> QFileDialogPrivate::addDefaultSuffixToUrls(const QList<QUrl> &urlsTo QUrl url = urlsToFix.at(i); // if the filename has no suffix, add the default suffix const QString defaultSuffix = options->defaultSuffix(); - if (!defaultSuffix.isEmpty() && !url.path().endsWith(QLatin1Char('/')) && url.path().lastIndexOf(QLatin1Char('.')) == -1) - url.setPath(url.path() + QLatin1Char('.') + defaultSuffix); + if (!defaultSuffix.isEmpty()) { + const QString urlPath = url.path(); + const auto idx = urlPath.lastIndexOf(u'/'); + if (idx != (urlPath.size() - 1) && !QStringView{urlPath}.mid(idx + 1).contains(u'.')) + url.setPath(urlPath + u'.' + defaultSuffix); + } urls.append(url); } return urls; @@ -1299,12 +1272,9 @@ QStringList QFileDialog::selectedFiles() const QStringList files; const QList<QUrl> userSelectedFiles = d->userSelectedFiles(); files.reserve(userSelectedFiles.size()); - for (const QUrl &file : userSelectedFiles) { - if (file.isLocalFile() || file.isEmpty()) - files.append(file.toLocalFile()); - else - files.append(file.toString()); - } + for (const QUrl &file : userSelectedFiles) + files.append(file.toString(QUrl::PreferLocalFile)); + if (files.isEmpty() && d->usingWidgets()) { const FileMode fm = fileMode(); if (fm != ExistingFile && fm != ExistingFiles) @@ -1345,9 +1315,9 @@ QStringList qt_make_filter_list(const QString &filter) if (filter.isEmpty()) return QStringList(); - QString sep(QLatin1String(";;")); - if (!filter.contains(sep) && filter.contains(QLatin1Char('\n'))) - sep = QLatin1Char('\n'); + auto sep = ";;"_L1; + if (!filter.contains(sep) && filter.contains(u'\n')) + sep = "\n"_L1; return filter.split(sep); } @@ -1383,7 +1353,7 @@ QStringList qt_strip_filters(const QStringList &filters) #if QT_CONFIG(regularexpression) QStringList strippedFilters; static const QRegularExpression r(QString::fromLatin1(QPlatformFileDialogHelper::filterRegExp)); - const int numFilters = filters.count(); + const int numFilters = filters.size(); strippedFilters.reserve(numFilters); for (int i = 0; i < numFilters; ++i) { QString filterName; @@ -1422,7 +1392,7 @@ void QFileDialog::setNameFilters(const QStringList &filters) { Q_D(QFileDialog); QStringList cleanedFilters; - const int numFilters = filters.count(); + const int numFilters = filters.size(); cleanedFilters.reserve(numFilters); for (int i = 0; i < numFilters; ++i) { cleanedFilters << filters[i].simplified(); @@ -1548,8 +1518,8 @@ static QString nameFilterForMime(const QString &mimeType) if (mime.isDefault()) { return QFileDialog::tr("All files (*)"); } else { - const QString patterns = mime.globPatterns().join(QLatin1Char(' ')); - return mime.comment() + QLatin1String(" (") + patterns + QLatin1Char(')'); + const QString patterns = mime.globPatterns().join(u' '); + return mime.comment() + " ("_L1 + patterns + u')'; } } return QString(); @@ -1892,7 +1862,7 @@ void QFileDialogComboBox::setHistory(const QStringList &paths) //On windows the popup display the "C:\", convert to nativeSeparators const QUrl url = idx.isValid() ? QUrl::fromLocalFile(QDir::toNativeSeparators(idx.data(QFileSystemModel::FilePathRole).toString())) - : QUrl(QLatin1String("file:")); + : QUrl("file:"_L1); if (url.isValid()) list.append(url); urlModel->setUrls(list); @@ -2077,7 +2047,8 @@ QString QFileDialog::labelText(DialogLabel label) const then a default caption will be used. On Windows, and \macos, this static function will use the - native file dialog and not a QFileDialog. + native file dialog and not a QFileDialog. Note that the \macos native file + dialog does not show a title bar. On Windows the dialog will spin a blocking modal event loop that will not dispatch any QTimers, and if \a parent is not \nullptr then it will position @@ -2188,7 +2159,8 @@ QUrl QFileDialog::getOpenFileUrl(QWidget *parent, then a default caption will be used. On Windows, and \macos, this static function will use the - native file dialog and not a QFileDialog. + native file dialog and not a QFileDialog. Note that the \macos native file + dialog does not show a title bar. On Windows the dialog will spin a blocking modal event loop that will not dispatch any QTimers, and if \a parent is not \nullptr then it will position @@ -2219,12 +2191,8 @@ QStringList QFileDialog::getOpenFileNames(QWidget *parent, filter, selectedFilter, options, schemes); QStringList fileNames; fileNames.reserve(selectedUrls.size()); - for (const QUrl &url : selectedUrls) { - if (url.isLocalFile() || url.isEmpty()) - fileNames << url.toLocalFile(); - else - fileNames << url.toString(); - } + for (const QUrl &url : selectedUrls) + fileNames.append(url.toString(QUrl::PreferLocalFile)); return fileNames; } @@ -2328,20 +2296,14 @@ void QFileDialog::getOpenFileContent(const QString &nameFilter, const std::funct openFileImpl.reset(); }; - auto qtFilterStringToWebAcceptString = [](const QString &qtString) { - // The Qt and Web name filter string formats are similar, but - // not identical. - return qtString.toStdString(); // ### TODO - }; - - QWasmLocalFileAccess::openFile(qtFilterStringToWebAcceptString(nameFilter), fileDialogClosed, acceptFile, fileContentReady); + QWasmLocalFileAccess::openFile(nameFilter.toStdString(), fileDialogClosed, acceptFile, fileContentReady); }; (*openFileImpl)(); #else QFileDialog *dialog = new QFileDialog(); dialog->setFileMode(QFileDialog::ExistingFile); - dialog->selectNameFilter(nameFilter); + dialog->setNameFilter(nameFilter); auto fileSelected = [=](const QString &fileName) { QByteArray fileContent; @@ -2383,7 +2345,7 @@ void QFileDialog::getOpenFileContent(const QString &nameFilter, const std::funct void QFileDialog::saveFileContent(const QByteArray &fileContent, const QString &fileNameHint) { #ifdef Q_OS_WASM - QWasmLocalFileAccess::saveFile(fileContent.constData(), fileContent.size(), fileNameHint.toStdString()); + QWasmLocalFileAccess::saveFile(fileContent, fileNameHint.toStdString()); #else QFileDialog *dialog = new QFileDialog(); dialog->setAcceptMode(QFileDialog::AcceptSave); @@ -2553,6 +2515,8 @@ QUrl QFileDialog::getSaveFileUrl(QWidget *parent, to pass \l{QFileDialog::}{DontUseNativeDialog} to display files using a QFileDialog. + Note that the \macos native file dialog does not show a title bar. + On Unix/X11, the normal behavior of the file dialog is to resolve and follow symlinks. For example, if \c{/usr/tmp} is a symlink to \c{/var/tmp}, the file dialog will change to \c{/var/tmp} after entering \c{/usr/tmp}. If @@ -2697,6 +2661,32 @@ void QFileDialog::done(int result) d->signalToDisconnectOnClose.clear(); } +bool QFileDialogPrivate::itemAlreadyExists(const QString &fileName) +{ +#if QT_CONFIG(messagebox) + Q_Q(QFileDialog); + const QString msg = QFileDialog::tr("%1 already exists.\nDo you want to replace it?").arg(fileName); + using B = QMessageBox; + const auto res = B::warning(q, q->windowTitle(), msg, B::Yes | B::No, B::No); + return res == B::Yes; +#endif + return false; +} + +void QFileDialogPrivate::itemNotFound(const QString &fileName, QFileDialog::FileMode mode) +{ +#if QT_CONFIG(messagebox) + Q_Q(QFileDialog); + const QString message = mode == QFileDialog::Directory + ? QFileDialog::tr("%1\nDirectory not found.\n" + "Please verify the correct directory name was given.") + : QFileDialog::tr("%1\nFile not found.\nPlease verify the " + "correct file name was given."); + + QMessageBox::warning(q, q->windowTitle(), message.arg(fileName)); +#endif // QT_CONFIG(messagebox) +} + /*! \reimp */ @@ -2708,7 +2698,7 @@ void QFileDialog::accept() if (urls.isEmpty()) return; d->_q_emitUrlsSelected(urls); - if (urls.count() == 1) + if (urls.size() == 1) d->_q_emitUrlSelected(urls.first()); QDialog::accept(); return; @@ -2720,25 +2710,22 @@ void QFileDialog::accept() QString lineEditText = d->lineEdit()->text(); // "hidden feature" type .. and then enter, and it will move up a dir // special case for ".." - if (lineEditText == QLatin1String("..")) { + if (lineEditText == ".."_L1) { d->_q_navigateToParent(); const QSignalBlocker blocker(d->qFileDialogUi->fileNameEdit); d->lineEdit()->selectAll(); return; } - switch (fileMode()) { + const auto mode = fileMode(); + switch (mode) { case Directory: { QString fn = files.first(); QFileInfo info(fn); if (!info.exists()) info = QFileInfo(d->getEnvironmentVariable(fn)); if (!info.exists()) { -#if QT_CONFIG(messagebox) - QString message = tr("%1\nDirectory not found.\nPlease verify the " - "correct directory name was given."); - QMessageBox::warning(this, windowTitle(), message.arg(info.fileName())); -#endif // QT_CONFIG(messagebox) + d->itemNotFound(info.fileName(), mode); return; } if (info.isDir()) { @@ -2758,7 +2745,7 @@ void QFileDialog::accept() if (!info.exists()) { int maxNameLength = d->maxNameLength(info.path()); - if (maxNameLength >= 0 && info.fileName().length() > maxNameLength) + if (maxNameLength >= 0 && info.fileName().size() > maxNameLength) return; } @@ -2766,17 +2753,11 @@ void QFileDialog::accept() if (!info.exists() || testOption(DontConfirmOverwrite) || acceptMode() == AcceptOpen) { d->emitFilesSelected(QStringList(fn)); QDialog::accept(); -#if QT_CONFIG(messagebox) } else { - if (QMessageBox::warning(this, windowTitle(), - tr("%1 already exists.\nDo you want to replace it?") - .arg(info.fileName()), - QMessageBox::Yes | QMessageBox::No, QMessageBox::No) - == QMessageBox::Yes) { + if (d->itemAlreadyExists(info.fileName())) { d->emitFilesSelected(QStringList(fn)); QDialog::accept(); } -#endif } return; } @@ -2788,11 +2769,7 @@ void QFileDialog::accept() if (!info.exists()) info = QFileInfo(d->getEnvironmentVariable(file)); if (!info.exists()) { -#if QT_CONFIG(messagebox) - QString message = tr("%1\nFile not found.\nPlease verify the " - "correct file name was given."); - QMessageBox::warning(this, windowTitle(), message.arg(info.fileName())); -#endif // QT_CONFIG(messagebox) + d->itemNotFound(info.fileName(), mode); return; } if (info.isDir()) { @@ -2811,37 +2788,37 @@ void QFileDialog::accept() void QFileDialogPrivate::saveSettings() { Q_Q(QFileDialog); - QSettings settings(QSettings::UserScope, QLatin1String("QtProject")); - settings.beginGroup(QLatin1String("FileDialog")); + QSettings settings(QSettings::UserScope, u"QtProject"_s); + settings.beginGroup("FileDialog"); if (usingWidgets()) { - settings.setValue(QLatin1String("sidebarWidth"), qFileDialogUi->splitter->sizes().constFirst()); - settings.setValue(QLatin1String("shortcuts"), QUrl::toStringList(qFileDialogUi->sidebar->urls())); - settings.setValue(QLatin1String("treeViewHeader"), qFileDialogUi->treeView->header()->saveState()); + settings.setValue("sidebarWidth", qFileDialogUi->splitter->sizes().constFirst()); + settings.setValue("shortcuts", QUrl::toStringList(qFileDialogUi->sidebar->urls())); + settings.setValue("treeViewHeader", qFileDialogUi->treeView->header()->saveState()); } QStringList historyUrls; const QStringList history = q->history(); historyUrls.reserve(history.size()); for (const QString &path : history) historyUrls << QUrl::fromLocalFile(path).toString(); - settings.setValue(QLatin1String("history"), historyUrls); - settings.setValue(QLatin1String("lastVisited"), lastVisitedDir()->toString()); + settings.setValue("history", historyUrls); + settings.setValue("lastVisited", lastVisitedDir()->toString()); const QMetaEnum &viewModeMeta = q->metaObject()->enumerator(q->metaObject()->indexOfEnumerator("ViewMode")); - settings.setValue(QLatin1String("viewMode"), QLatin1String(viewModeMeta.key(q->viewMode()))); - settings.setValue(QLatin1String("qtVersion"), QLatin1String(QT_VERSION_STR)); + settings.setValue("viewMode", QLatin1StringView(viewModeMeta.key(q->viewMode()))); + settings.setValue("qtVersion", QT_VERSION_STR ""_L1); } bool QFileDialogPrivate::restoreFromSettings() { Q_Q(QFileDialog); - QSettings settings(QSettings::UserScope, QLatin1String("QtProject")); - if (!settings.childGroups().contains(QLatin1String("FileDialog"))) + QSettings settings(QSettings::UserScope, u"QtProject"_s); + if (!settings.childGroups().contains("FileDialog"_L1)) return false; - settings.beginGroup(QLatin1String("FileDialog")); + settings.beginGroup("FileDialog"); - q->setDirectoryUrl(lastVisitedDir()->isEmpty() ? settings.value(QLatin1String("lastVisited")).toUrl() : *lastVisitedDir()); + q->setDirectoryUrl(lastVisitedDir()->isEmpty() ? settings.value("lastVisited").toUrl() : *lastVisitedDir()); - QByteArray viewModeStr = settings.value(QLatin1String("viewMode")).toString().toLatin1(); + QByteArray viewModeStr = settings.value("viewMode").toString().toLatin1(); const QMetaEnum &viewModeMeta = q->metaObject()->enumerator(q->metaObject()->indexOfEnumerator("ViewMode")); bool ok = false; int viewMode = viewModeMeta.keyToValue(viewModeStr.constData(), &ok); @@ -2849,21 +2826,21 @@ bool QFileDialogPrivate::restoreFromSettings() viewMode = QFileDialog::List; q->setViewMode(static_cast<QFileDialog::ViewMode>(viewMode)); - sidebarUrls = QUrl::fromStringList(settings.value(QLatin1String("shortcuts")).toStringList()); - headerData = settings.value(QLatin1String("treeViewHeader")).toByteArray(); + sidebarUrls = QUrl::fromStringList(settings.value("shortcuts").toStringList()); + headerData = settings.value("treeViewHeader").toByteArray(); if (!usingWidgets()) return true; QStringList history; - const auto urlStrings = settings.value(QLatin1String("history")).toStringList(); + const auto urlStrings = settings.value("history").toStringList(); for (const QString &urlStr : urlStrings) { QUrl url(urlStr); if (url.isLocalFile()) history << url.toLocalFile(); } - return restoreWidgetState(history, settings.value(QLatin1String("sidebarWidth"), -1).toInt()); + return restoreWidgetState(history, settings.value("sidebarWidth", -1).toInt()); } #endif // settings @@ -2879,8 +2856,8 @@ bool QFileDialogPrivate::restoreWidgetState(QStringList &history, int splitterPo if (!qFileDialogUi->splitter->restoreState(splitterState)) return false; QList<int> list = qFileDialogUi->splitter->sizes(); - if (list.count() >= 2 && (list.at(0) == 0 || list.at(1) == 0)) { - for (int i = 0; i < list.count(); ++i) + if (list.size() >= 2 && (list.at(0) == 0 || list.at(1) == 0)) { + for (int i = 0; i < list.size(); ++i) list[i] = qFileDialogUi->splitter->widget(i)->sizeHint().width(); qFileDialogUi->splitter->setSizes(list); } @@ -2903,7 +2880,7 @@ bool QFileDialogPrivate::restoreWidgetState(QStringList &history, int splitterPo if (proxyModel) abstractModel = proxyModel; #endif - int total = qMin(abstractModel->columnCount(QModelIndex()), actions.count() + 1); + int total = qMin(abstractModel->columnCount(QModelIndex()), actions.size() + 1); for (int i = 1; i < total; ++i) actions.at(i - 1)->setChecked(!headerView->isSectionHidden(i)); @@ -2945,8 +2922,8 @@ void QFileDialogPrivate::init(const QFileDialogArgs &args) // Try to restore from the FileDialog settings group; if it fails, fall back // to the pre-5.5 QByteArray serialized settings. if (!restoreFromSettings()) { - const QSettings settings(QSettings::UserScope, QLatin1String("QtProject")); - q->restoreState(settings.value(QLatin1String("Qt/filedialog")).toByteArray()); + const QSettings settings(QSettings::UserScope, u"QtProject"_s); + q->restoreState(settings.value("Qt/filedialog").toByteArray()); } #endif @@ -2982,13 +2959,11 @@ void QFileDialogPrivate::createWidgets() model = new QFileSystemModel(q); model->setIconProvider(&defaultIconProvider); model->setFilter(options->filter()); - model->setObjectName(QLatin1String("qt_filesystem_model")); + model->setObjectName("qt_filesystem_model"_L1); if (QPlatformFileDialogHelper *helper = platformFileDialogHelper()) model->setNameFilterDisables(helper->defaultNameFilterDisables()); else model->setNameFilterDisables(false); - if (nativeDialogInUse) - deletePlatformHelper(); model->d_func()->disableRecursiveSort = true; QFileDialog::connect(model, SIGNAL(fileRenamed(QString,QString,QString)), q, SLOT(_q_fileRenamed(QString,QString,QString))); QFileDialog::connect(model, SIGNAL(rootPathChanged(QString)), @@ -3001,7 +2976,7 @@ void QFileDialogPrivate::createWidgets() qFileDialogUi->setupUi(q); QList<QUrl> initialBookmarks; - initialBookmarks << QUrl(QLatin1String("file:")) + initialBookmarks << QUrl("file:"_L1) << QUrl::fromLocalFile(QDir::homePath()); qFileDialogUi->sidebar->setModelAndUrls(model, initialBookmarks); QFileDialog::connect(qFileDialogUi->sidebar, SIGNAL(goToUrl(QUrl)), @@ -3059,10 +3034,10 @@ void QFileDialogPrivate::createWidgets() qFileDialogUi->treeView->setModel(model); QHeaderView *treeHeader = qFileDialogUi->treeView->header(); QFontMetrics fm(q->font()); - treeHeader->resizeSection(0, fm.horizontalAdvance(QLatin1String("wwwwwwwwwwwwwwwwwwwwwwwwww"))); - treeHeader->resizeSection(1, fm.horizontalAdvance(QLatin1String("128.88 GB"))); - treeHeader->resizeSection(2, fm.horizontalAdvance(QLatin1String("mp3Folder"))); - treeHeader->resizeSection(3, fm.horizontalAdvance(QLatin1String("10/29/81 02:02PM"))); + treeHeader->resizeSection(0, fm.horizontalAdvance("wwwwwwwwwwwwwwwwwwwwwwwwww"_L1)); + treeHeader->resizeSection(1, fm.horizontalAdvance("128.88 GB"_L1)); + treeHeader->resizeSection(2, fm.horizontalAdvance("mp3Folder"_L1)); + treeHeader->resizeSection(3, fm.horizontalAdvance("10/29/81 02:02PM"_L1)); treeHeader->setContextMenuPolicy(Qt::ActionsContextMenu); QActionGroup *showActionGroup = new QActionGroup(q); @@ -3109,8 +3084,8 @@ void QFileDialogPrivate::createWidgets() // Try to restore from the FileDialog settings group; if it fails, fall back // to the pre-5.5 QByteArray serialized settings. if (!restoreFromSettings()) { - const QSettings settings(QSettings::UserScope, QLatin1String("QtProject")); - q->restoreState(settings.value(QLatin1String("Qt/filedialog")).toByteArray()); + const QSettings settings(QSettings::UserScope, u"QtProject"_s); + q->restoreState(settings.value("Qt/filedialog").toByteArray()); } #endif @@ -3296,7 +3271,7 @@ void QFileDialogPrivate::createMenuActions() // ### TODO add Desktop & Computer actions QAction *goToParent = new QAction(q); - goToParent->setObjectName(QLatin1String("qt_goto_parent_action")); + goToParent->setObjectName("qt_goto_parent_action"_L1); #ifndef QT_NO_SHORTCUT goToParent->setShortcut(Qt::CTRL | Qt::Key_Up); #endif @@ -3305,21 +3280,21 @@ void QFileDialogPrivate::createMenuActions() renameAction = new QAction(q); renameAction->setEnabled(false); - renameAction->setObjectName(QLatin1String("qt_rename_action")); + renameAction->setObjectName("qt_rename_action"_L1); QObject::connect(renameAction, SIGNAL(triggered()), q, SLOT(_q_renameCurrent())); deleteAction = new QAction(q); deleteAction->setEnabled(false); - deleteAction->setObjectName(QLatin1String("qt_delete_action")); + deleteAction->setObjectName("qt_delete_action"_L1); QObject::connect(deleteAction, SIGNAL(triggered()), q, SLOT(_q_deleteCurrent())); showHiddenAction = new QAction(q); - showHiddenAction->setObjectName(QLatin1String("qt_show_hidden_action")); + showHiddenAction->setObjectName("qt_show_hidden_action"_L1); showHiddenAction->setCheckable(true); QObject::connect(showHiddenAction, SIGNAL(triggered()), q, SLOT(_q_showHidden())); newFolderAction = new QAction(q); - newFolderAction->setObjectName(QLatin1String("qt_new_folder_action")); + newFolderAction->setObjectName("qt_new_folder_action"_L1); QObject::connect(newFolderAction, SIGNAL(triggered()), q, SLOT(_q_createDirectory())); } @@ -3359,7 +3334,7 @@ void QFileDialogPrivate::_q_pathChanged(const QString &newPath) if (currentHistoryLocation < 0 || currentHistory.value(currentHistoryLocation).path != newNativePath) { if (currentHistoryLocation >= 0) saveHistorySelection(); - while (currentHistoryLocation >= 0 && currentHistoryLocation + 1 < currentHistory.count()) { + while (currentHistoryLocation >= 0 && currentHistoryLocation + 1 < currentHistory.size()) { currentHistory.removeLast(); } currentHistory.append({newNativePath, PersistentModelIndexList()}); @@ -3514,23 +3489,26 @@ void QFileDialogPrivate::_q_showContextMenu(const QPoint &position) QModelIndex index = view->indexAt(position); index = mapToSource(index.sibling(index.row(), 0)); - QMenu menu(view); + QMenu *menu = new QMenu(view); + menu->setAttribute(Qt::WA_DeleteOnClose); + if (index.isValid()) { // file context menu const bool ro = model && model->isReadOnly(); QFile::Permissions p(index.parent().data(QFileSystemModel::FilePermissions).toInt()); renameAction->setEnabled(!ro && p & QFile::WriteUser); - menu.addAction(renameAction); + menu->addAction(renameAction); deleteAction->setEnabled(!ro && p & QFile::WriteUser); - menu.addAction(deleteAction); - menu.addSeparator(); + menu->addAction(deleteAction); + menu->addSeparator(); } - menu.addAction(showHiddenAction); + menu->addAction(showHiddenAction); if (qFileDialogUi->newFolderButton->isVisible()) { newFolderAction->setEnabled(qFileDialogUi->newFolderButton->isEnabled()); - menu.addAction(newFolderAction); + menu->addAction(newFolderAction); } - menu.exec(view->viewport()->mapToGlobal(position)); + menu->popup(view->viewport()->mapToGlobal(position)); + #endif // QT_CONFIG(menu) } @@ -3565,7 +3543,7 @@ void QFileDialogPrivate::_q_deleteCurrent() return; QModelIndexList list = qFileDialogUi->listView->selectionModel()->selectedRows(); - for (int i = list.count() - 1; i >= 0; --i) { + for (int i = list.size() - 1; i >= 0; --i) { QPersistentModelIndex index = list.at(i); if (index == qFileDialogUi->listView->rootIndex()) continue; @@ -3615,13 +3593,13 @@ void QFileDialogPrivate::_q_deleteCurrent() void QFileDialogPrivate::_q_autoCompleteFileName(const QString &text) { - if (text.startsWith(QLatin1String("//")) || text.startsWith(QLatin1Char('\\'))) { + if (text.startsWith("//"_L1) || text.startsWith(u'\\')) { qFileDialogUi->listView->selectionModel()->clearSelection(); return; } const QStringList multipleFiles = typedFiles(); - if (multipleFiles.count() > 0) { + if (multipleFiles.size() > 0) { QModelIndexList oldFiles = qFileDialogUi->listView->selectionModel()->selectedRows(); QList<QModelIndex> newFiles; for (const auto &file : multipleFiles) { @@ -3629,11 +3607,11 @@ void QFileDialogPrivate::_q_autoCompleteFileName(const QString &text) if (oldFiles.removeAll(idx) == 0) newFiles.append(idx); } - for (const auto &newFile : qAsConst(newFiles)) + for (const auto &newFile : std::as_const(newFiles)) select(newFile); if (lineEdit()->hasFocus()) { auto *sm = qFileDialogUi->listView->selectionModel(); - for (const auto &oldFile : qAsConst(oldFiles)) + for (const auto &oldFile : std::as_const(oldFiles)) sm->select(oldFile, QItemSelectionModel::Toggle | QItemSelectionModel::Rows); } } @@ -3657,7 +3635,7 @@ void QFileDialogPrivate::_q_updateOkButton() const QStringList files = q->selectedFiles(); QString lineEditText = lineEdit()->text(); - if (lineEditText.startsWith(QLatin1String("//")) || lineEditText.startsWith(QLatin1Char('\\'))) { + if (lineEditText.startsWith("//"_L1) || lineEditText.startsWith(u'\\')) { button->setEnabled(true); updateOkButtonText(); return; @@ -3665,7 +3643,7 @@ void QFileDialogPrivate::_q_updateOkButton() if (files.isEmpty()) { enableButton = false; - } else if (lineEditText == QLatin1String("..")) { + } else if (lineEditText == ".."_L1) { isOpenDirectory = true; } else { switch (fileMode) { @@ -3687,10 +3665,10 @@ void QFileDialogPrivate::_q_updateOkButton() if (info.isDir()) { fileDir = info.canonicalFilePath(); } else { - fileDir = fn.mid(0, fn.lastIndexOf(QLatin1Char('/'))); - fileName = fn.mid(fileDir.length() + 1); + fileDir = fn.mid(0, fn.lastIndexOf(u'/')); + fileName = fn.mid(fileDir.size() + 1); } - if (lineEditText.contains(QLatin1String(".."))) { + if (lineEditText.contains(".."_L1)) { fileDir = info.canonicalFilePath(); fileName = info.fileName(); } @@ -3706,7 +3684,7 @@ void QFileDialogPrivate::_q_updateOkButton() } if (!idx.isValid()) { int maxLength = maxNameLength(fileDir); - enableButton = maxLength < 0 || fileName.length() <= maxLength; + enableButton = maxLength < 0 || fileName.size() <= maxLength; } break; } @@ -3782,6 +3760,8 @@ void QFileDialogPrivate::_q_enterDirectory(const QModelIndex &index) */ void QFileDialogPrivate::_q_goToDirectory(const QString &path) { + enum { UrlRole = Qt::UserRole + 1 }; + #if QT_CONFIG(messagebox) Q_Q(QFileDialog); #endif @@ -3829,14 +3809,14 @@ void QFileDialogPrivate::_q_useNameFilter(int index) QStringList newNameFilters = QPlatformFileDialogHelper::cleanFilterList(nameFilter); if (q_func()->acceptMode() == QFileDialog::AcceptSave) { QString newNameFilterExtension; - if (newNameFilters.count() > 0) + if (newNameFilters.size() > 0) newNameFilterExtension = QFileInfo(newNameFilters.at(0)).suffix(); QString fileName = lineEdit()->text(); const QString fileNameExtension = QFileInfo(fileName).suffix(); if (!fileNameExtension.isEmpty() && !newNameFilterExtension.isEmpty()) { - const int fileNameExtensionLength = fileNameExtension.count(); - fileName.replace(fileName.count() - fileNameExtensionLength, + const int fileNameExtensionLength = fileNameExtension.size(); + fileName.replace(fileName.size() - fileNameExtensionLength, fileNameExtensionLength, newNameFilterExtension); qFileDialogUi->listView->clearSelection(); lineEdit()->setText(fileName); @@ -3864,12 +3844,12 @@ void QFileDialogPrivate::_q_selectionChanged() continue; allFiles.append(index.data().toString()); } - if (allFiles.count() > 1) - for (int i = 0; i < allFiles.count(); ++i) { - allFiles.replace(i, QString(QLatin1Char('"') + allFiles.at(i) + QLatin1Char('"'))); + if (allFiles.size() > 1) + for (qsizetype i = 0; i < allFiles.size(); ++i) { + allFiles.replace(i, QString(u'"' + allFiles.at(i) + u'"')); } - QString finalFiles = allFiles.join(QLatin1Char(' ')); + QString finalFiles = allFiles.join(u' '); if (!finalFiles.isEmpty() && !lineEdit()->hasFocus() && lineEdit()->isVisible()) lineEdit()->setText(finalFiles); else @@ -3993,11 +3973,11 @@ bool QFileDialogPrivate::itemViewKeyboardEvent(QKeyEvent *event) { QString QFileDialogPrivate::getEnvironmentVariable(const QString &string) { #ifdef Q_OS_UNIX - if (string.size() > 1 && string.startsWith(QLatin1Char('$'))) { + if (string.size() > 1 && string.startsWith(u'$')) { return QString::fromLocal8Bit(qgetenv(QStringView{string}.mid(1).toLatin1().constData())); } #else - if (string.size() > 2 && string.startsWith(QLatin1Char('%')) && string.endsWith(QLatin1Char('%'))) { + if (string.size() > 2 && string.startsWith(u'%') && string.endsWith(u'%')) { return QString::fromLocal8Bit(qgetenv(QStringView{string}.mid(1, string.size() - 2).toLatin1().constData())); } #endif @@ -4027,18 +4007,18 @@ void QFileDialogComboBox::showPopup() idx = idx.parent(); } // add "my computer" - list.append(QUrl(QLatin1String("file:"))); + list.append(QUrl("file:"_L1)); urlModel->addUrls(list, 0); idx = model()->index(model()->rowCount() - 1, 0); // append history QList<QUrl> urls; - for (int i = 0; i < m_history.count(); ++i) { + for (int i = 0; i < m_history.size(); ++i) { QUrl path = QUrl::fromLocalFile(m_history.at(i)); if (!urls.contains(path)) urls.prepend(path); } - if (urls.count() > 0) { + if (urls.size() > 0) { model()->insertRow(model()->rowCount()); idx = model()->index(model()->rowCount()-1, 0); // ### TODO maybe add a horizontal line before this @@ -4184,12 +4164,12 @@ QString QFSCompleter::pathFromIndex(const QModelIndex &index) const if (!currentLocation.isEmpty() && path.startsWith(currentLocation)) { #if defined(Q_OS_UNIX) if (currentLocation == QDir::separator()) - return path.mid(currentLocation.length()); + return path.remove(0, currentLocation.size()); #endif - if (currentLocation.endsWith(QLatin1Char('/'))) - return path.mid(currentLocation.length()); + if (currentLocation.endsWith(u'/')) + return path.remove(0, currentLocation.size()); else - return path.mid(currentLocation.length()+1); + return path.remove(0, currentLocation.size()+1); } return index.data(QFileSystemModel::FilePathRole).toString(); } @@ -4202,9 +4182,9 @@ QStringList QFSCompleter::splitPath(const QString &path) const QString pathCopy = QDir::toNativeSeparators(path); QChar sep = QDir::separator(); #if defined(Q_OS_WIN) - if (pathCopy == QLatin1String("\\") || pathCopy == QLatin1String("\\\\")) + if (pathCopy == "\\"_L1 || pathCopy == "\\\\"_L1) return QStringList(pathCopy); - QString doubleSlash(QLatin1String("\\\\")); + QString doubleSlash("\\\\"_L1); if (pathCopy.startsWith(doubleSlash)) pathCopy = pathCopy.mid(2); else @@ -4237,11 +4217,11 @@ QStringList QFSCompleter::splitPath(const QString &path) const #endif #if defined(Q_OS_WIN) - bool startsFromRoot = !parts.isEmpty() && parts[0].endsWith(QLatin1Char(':')); + bool startsFromRoot = !parts.isEmpty() && parts[0].endsWith(u':'); #else bool startsFromRoot = pathCopy[0] == sep; #endif - if (parts.count() == 1 || (parts.count() > 1 && !startsFromRoot)) { + if (parts.size() == 1 || (parts.size() > 1 && !startsFromRoot)) { const QFileSystemModel *dirModel; if (proxyModel) dirModel = qobject_cast<const QFileSystemModel *>(proxyModel->sourceModel()); @@ -4249,14 +4229,12 @@ QStringList QFSCompleter::splitPath(const QString &path) const dirModel = sourceModel; QString currentLocation = QDir::toNativeSeparators(dirModel->rootPath()); #if defined(Q_OS_WIN) - if (currentLocation.endsWith(QLatin1Char(':'))) + if (currentLocation.endsWith(u':')) currentLocation.append(sep); #endif if (currentLocation.contains(sep) && path != currentLocation) { QStringList currentLocationList = splitPath(currentLocation); - while (!currentLocationList.isEmpty() - && parts.count() > 0 - && parts.at(0) == QLatin1String("..")) { + while (!currentLocationList.isEmpty() && parts.size() > 0 && parts.at(0) == ".."_L1) { parts.removeFirst(); currentLocationList.removeLast(); } diff --git a/src/widgets/dialogs/qfiledialog.h b/src/widgets/dialogs/qfiledialog.h index 73136c3707..970bddb359 100644 --- a/src/widgets/dialogs/qfiledialog.h +++ b/src/widgets/dialogs/qfiledialog.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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 Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QFILEDIALOG_H #define QFILEDIALOG_H diff --git a/src/widgets/dialogs/qfiledialog.ui b/src/widgets/dialogs/qfiledialog.ui index e4b4aad6ce..f275e20c63 100644 --- a/src/widgets/dialogs/qfiledialog.ui +++ b/src/widgets/dialogs/qfiledialog.ui @@ -1,43 +1,8 @@ -<?xml version="1.0" encoding="UTF-8"?> <ui version="4.0"> - <comment>********************************************************************* -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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 Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -*********************************************************************</comment> +<comment> +* Copyright (C) 2016 The Qt Company Ltd. +* SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +</comment> <class>QFileDialog</class> <widget class="QDialog" name="QFileDialog"> <property name="geometry"> diff --git a/src/widgets/dialogs/qfiledialog_p.h b/src/widgets/dialogs/qfiledialog_p.h index 28750ca22c..c2111415f5 100644 --- a/src/widgets/dialogs/qfiledialog_p.h +++ b/src/widgets/dialogs/qfiledialog_p.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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 Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QFILEDIALOG_P_H #define QFILEDIALOG_P_H @@ -110,8 +74,6 @@ struct QFileDialogArgs QFileDialog::Options options = {}; }; -#define UrlRole (Qt::UserRole + 1) - class Q_WIDGETS_EXPORT QFileDialogPrivate : public QDialogPrivate { Q_DECLARE_PUBLIC(QFileDialog) @@ -182,7 +144,7 @@ public: { #if defined(Q_OS_WIN) QString n(path); - n.replace(QLatin1Char('\\'), QLatin1Char('/')); + n.replace(u'\\', u'/'); return n; #else // the compile should optimize away this return path; @@ -295,6 +257,8 @@ private: virtual void helperPrepareShow(QPlatformDialogHelper *) override; virtual void helperDone(QDialog::DialogCode, QPlatformDialogHelper *) override; + void itemNotFound(const QString &fileName, QFileDialog::FileMode mode); + bool itemAlreadyExists(const QString &fileName); Q_DISABLE_COPY_MOVE(QFileDialogPrivate) }; diff --git a/src/widgets/dialogs/qfilesystemmodel.h b/src/widgets/dialogs/qfilesystemmodel.h index a90b9479ca..9bf7f25945 100644 --- a/src/widgets/dialogs/qfilesystemmodel.h +++ b/src/widgets/dialogs/qfilesystemmodel.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2020 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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 Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include <QtGui/QFileSystemModel> diff --git a/src/widgets/dialogs/qfontdialog.cpp b/src/widgets/dialogs/qfontdialog.cpp index f1c844df5e..45853e153f 100644 --- a/src/widgets/dialogs/qfontdialog.cpp +++ b/src/widgets/dialogs/qfontdialog.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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 Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qwindowdefs.h" #include "qfontdialog.h" @@ -63,6 +27,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + class QFontListView : public QListView { Q_OBJECT @@ -103,7 +69,7 @@ QFontListView::QFontListView(QWidget *parent) setEditTriggers(NoEditTriggers); } -static const Qt::WindowFlags DefaultWindowFlags = +static const Qt::WindowFlags qfd_DefaultWindowFlags = Qt::Dialog | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint; QFontDialogPrivate::QFontDialogPrivate() @@ -153,7 +119,7 @@ QFontDialogPrivate::~QFontDialogPrivate() \sa getFont() */ QFontDialog::QFontDialog(QWidget *parent) - : QDialog(*new QFontDialogPrivate, parent, DefaultWindowFlags) + : QDialog(*new QFontDialogPrivate, parent, qfd_DefaultWindowFlags) { Q_D(QFontDialog); d->init(); @@ -228,7 +194,7 @@ void QFontDialogPrivate::init() sampleEdit->setAlignment(Qt::AlignCenter); // Note that the sample text is *not* translated with tr(), as the // characters used depend on the charset encoding. - sampleEdit->setText(QLatin1String("AaBbYyZz")); + sampleEdit->setText("AaBbYyZz"_L1); hbox->addWidget(sampleEdit); writingSystemCombo = new QComboBox(q); @@ -326,7 +292,7 @@ void QFontDialogPrivate::init() familyList->setFocus(); retranslateStrings(); - sampleEdit->setObjectName(QLatin1String("qt_fontDialog_sampleEdit")); + sampleEdit->setObjectName("qt_fontDialog_sampleEdit"_L1); } /*! @@ -424,7 +390,7 @@ bool QFontDialog::eventFilter(QObject *o , QEvent *e) { Q_D(QFontDialog); if (e->type() == QEvent::KeyPress) { - QKeyEvent *k = (QKeyEvent *)e; + QKeyEvent *k = static_cast<QKeyEvent *>(e); if (o == d->sizeEdit && (k->key() == Qt::Key_Up || k->key() == Qt::Key_Down || @@ -460,10 +426,12 @@ bool QFontDialog::eventFilter(QObject *o , QEvent *e) void QFontDialogPrivate::initHelper(QPlatformDialogHelper *h) { - QFontDialog *d = q_func(); - QObject::connect(h, SIGNAL(currentFontChanged(QFont)), d, SIGNAL(currentFontChanged(QFont))); - QObject::connect(h, SIGNAL(fontSelected(QFont)), d, SIGNAL(fontSelected(QFont))); - static_cast<QPlatformFontDialogHelper *>(h)->setOptions(options); + Q_Q(QFontDialog); + auto *fontDialogHelper = static_cast<QPlatformFontDialogHelper *>(h); + fontDialogHelper->setOptions(options); + fontDialogHelper->setCurrentFont(q->currentFont()); + QObject::connect(h, SIGNAL(currentFontChanged(QFont)), q, SIGNAL(currentFontChanged(QFont))); + QObject::connect(h, SIGNAL(fontSelected(QFont)), q, SIGNAL(fontSelected(QFont))); } void QFontDialogPrivate::helperPrepareShow(QPlatformDialogHelper *) @@ -583,20 +551,20 @@ void QFontDialogPrivate::updateStyles() } } if (!found && first) { - if (cstyle.contains(QLatin1String("Italic"))) { - cstyle.replace(QLatin1String("Italic"), QLatin1String("Oblique")); + if (cstyle.contains("Italic"_L1)) { + cstyle.replace("Italic"_L1, "Oblique"_L1); first = false; goto redo; - } else if (cstyle.contains(QLatin1String("Oblique"))) { - cstyle.replace(QLatin1String("Oblique"), QLatin1String("Italic")); + } else if (cstyle.contains("Oblique"_L1)) { + cstyle.replace("Oblique"_L1, "Italic"_L1); first = false; goto redo; - } else if (cstyle.contains(QLatin1String("Regular"))) { - cstyle.replace(QLatin1String("Regular"), QLatin1String("Normal")); + } else if (cstyle.contains("Regular"_L1)) { + cstyle.replace("Regular"_L1, "Normal"_L1); first = false; goto redo; - } else if (cstyle.contains(QLatin1String("Normal"))) { - cstyle.replace(QLatin1String("Normal"), QLatin1String("Regular")); + } else if (cstyle.contains("Normal"_L1)) { + cstyle.replace("Normal"_L1, "Regular"_L1); first = false; goto redo; } @@ -822,8 +790,11 @@ void QFontDialog::setCurrentFont(const QFont &font) d->strikeout->setChecked(font.strikeOut()); d->underline->setChecked(font.underline()); d->updateFamilies(); - if (QPlatformFontDialogHelper *helper = d->platformFontDialogHelper()) - helper->setCurrentFont(font); + + if (d->nativeDialogInUse) { + if (QPlatformFontDialogHelper *helper = d->platformFontDialogHelper()) + helper->setCurrentFont(font); + } } /*! @@ -836,8 +807,11 @@ void QFontDialog::setCurrentFont(const QFont &font) QFont QFontDialog::currentFont() const { Q_D(const QFontDialog); - if (const QPlatformFontDialogHelper *helper = d->platformFontDialogHelper()) - return helper->currentFont(); + + if (d->nativeDialogInUse) { + if (const QPlatformFontDialogHelper *helper = d->platformFontDialogHelper()) + return helper->currentFont(); + } return d->sampleEdit->font(); } @@ -996,7 +970,6 @@ void QFontDialog::setVisible(bool visible) // updates the state correctly, but skips showing the non-native version: setAttribute(Qt::WA_DontShowOnScreen, true); } else { - d->nativeDialogInUse = false; setAttribute(Qt::WA_DontShowOnScreen, false); } QDialog::setVisible(visible); @@ -1043,9 +1016,7 @@ bool QFontDialogPrivate::canBeNativeDialog() const return false; } - QLatin1String staticName(QFontDialog::staticMetaObject.className()); - QLatin1String dynamicName(q->metaObject()->className()); - return (staticName == dynamicName); + return strcmp(QFontDialog::staticMetaObject.className(), q->metaObject()->className()) == 0; } QT_END_NAMESPACE diff --git a/src/widgets/dialogs/qfontdialog.h b/src/widgets/dialogs/qfontdialog.h index ae1320e779..56f719796b 100644 --- a/src/widgets/dialogs/qfontdialog.h +++ b/src/widgets/dialogs/qfontdialog.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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 Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QFONTDIALOG_H #define QFONTDIALOG_H diff --git a/src/widgets/dialogs/qfontdialog_p.h b/src/widgets/dialogs/qfontdialog_p.h index 73c17c3708..4b3b45a9be 100644 --- a/src/widgets/dialogs/qfontdialog_p.h +++ b/src/widgets/dialogs/qfontdialog_p.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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 Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QFONTDIALOG_P_H #define QFONTDIALOG_P_H diff --git a/src/widgets/dialogs/qfscompleter_p.h b/src/widgets/dialogs/qfscompleter_p.h index be46f5be43..3981e8a3af 100644 --- a/src/widgets/dialogs/qfscompleter_p.h +++ b/src/widgets/dialogs/qfscompleter_p.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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 Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QFSCOMPLETOR_P_H #define QFSCOMPLETOR_P_H diff --git a/src/widgets/dialogs/qinputdialog.cpp b/src/widgets/dialogs/qinputdialog.cpp index 7569367768..89ea6e6746 100644 --- a/src/widgets/dialogs/qinputdialog.cpp +++ b/src/widgets/dialogs/qinputdialog.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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 Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qinputdialog.h" @@ -74,8 +38,7 @@ static const char *candidateSignal(int which) case NumCandidateSignals: break; }; - Q_UNREACHABLE(); - return nullptr; + Q_UNREACHABLE_RETURN(nullptr); } static const char *signalForMember(const char *member) @@ -118,9 +81,7 @@ private slots: private: void keyPressEvent(QKeyEvent *event) override { if ((event->key() == Qt::Key_Return || event->key() == Qt::Key_Enter) && !hasAcceptableInput()) { -#ifndef QT_NO_PROPERTIES setProperty("value", property("value")); -#endif } else { QSpinBox::keyPressEvent(event); } @@ -153,9 +114,7 @@ private slots: private: void keyPressEvent(QKeyEvent *event) override { if ((event->key() == Qt::Key_Return || event->key() == Qt::Key_Enter) && !hasAcceptableInput()) { -#ifndef QT_NO_PROPERTIES setProperty("value", property("value")); -#endif } else { QDoubleSpinBox::keyPressEvent(event); } diff --git a/src/widgets/dialogs/qinputdialog.h b/src/widgets/dialogs/qinputdialog.h index d3c95ccd23..51264af76f 100644 --- a/src/widgets/dialogs/qinputdialog.h +++ b/src/widgets/dialogs/qinputdialog.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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 Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QINPUTDIALOG_H #define QINPUTDIALOG_H diff --git a/src/widgets/dialogs/qmessagebox.cpp b/src/widgets/dialogs/qmessagebox.cpp index 09c14f1ec1..cb985ff145 100644 --- a/src/widgets/dialogs/qmessagebox.cpp +++ b/src/widgets/dialogs/qmessagebox.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2021 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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 Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include <QtWidgets/qmessagebox.h> @@ -64,6 +28,7 @@ #include <QtGui/qfontmetrics.h> #include <QtGui/qclipboard.h> #include "private/qabstractbutton_p.h" +#include <QtGui/qpa/qplatformtheme.h> #ifdef Q_OS_WIN # include <QtCore/qt_windows.h> @@ -72,6 +37,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + #if defined(Q_OS_WIN) HMENU qt_getWindowsSystemMenu(const QWidget *w) { @@ -221,6 +188,8 @@ public: int layoutMinimumWidth(); void retranslateStrings(); + void setVisible(bool visible) override; + static int showOldMessageBox(QWidget *parent, QMessageBox::Icon icon, const QString &title, const QString &text, int button0, int button1, int button2); @@ -237,6 +206,7 @@ public: QMessageBox::StandardButtons buttons, QMessageBox::StandardButton defaultButton); static QPixmap standardIcon(QMessageBox::Icon icon, QMessageBox *mb); + static QMessageBox::StandardButton standardButtonForRole(QMessageBox::ButtonRole role); QLabel *label; QMessageBox::Icon icon; @@ -270,16 +240,16 @@ void QMessageBoxPrivate::init(const QString &title, const QString &text) Q_Q(QMessageBox); label = new QLabel; - label->setObjectName(QLatin1String("qt_msgbox_label")); + label->setObjectName("qt_msgbox_label"_L1); label->setTextInteractionFlags(Qt::TextInteractionFlags(q->style()->styleHint(QStyle::SH_MessageBox_TextInteractionFlags, nullptr, q))); label->setAlignment(Qt::AlignVCenter | Qt::AlignLeft); label->setOpenExternalLinks(true); iconLabel = new QLabel(q); - iconLabel->setObjectName(QLatin1String("qt_msgboxex_icon_label")); + iconLabel->setObjectName("qt_msgboxex_icon_label"_L1); iconLabel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); buttonBox = new QDialogButtonBox; - buttonBox->setObjectName(QLatin1String("qt_msgbox_buttonbox")); + buttonBox->setObjectName("qt_msgbox_buttonbox"_L1); buttonBox->setCenterButtons(q->style()->styleHint(QStyle::SH_MessageBox_CenterButtons, nullptr, q)); QObject::connect(buttonBox, SIGNAL(clicked(QAbstractButton*)), q, SLOT(_q_buttonClicked(QAbstractButton*))); @@ -302,7 +272,7 @@ void QMessageBoxPrivate::setupLayout() Q_Q(QMessageBox); delete q->layout(); QGridLayout *grid = new QGridLayout; - bool hasIcon = !iconLabel->pixmap(Qt::ReturnByValue).isNull(); + const bool hasIcon = !iconLabel->pixmap().isNull(); if (hasIcon) grid->addWidget(iconLabel, 0, 0, 2, 1, Qt::AlignTop); @@ -548,10 +518,11 @@ void QMessageBoxPrivate::_q_clicked(QPlatformDialogHelper::StandardButton button A message box displays a primary \l{QMessageBox::text}{text} to alert the user to a situation, an \l{QMessageBox::informativeText} - {informative text} to further explain the alert or to ask the user - a question, and an optional \l{QMessageBox::detailedText} - {detailed text} to provide even more data if the user requests - it. A message box can also display an \l{QMessageBox::icon} {icon} + {informative text} to further explain the situation, and an optional + \l{QMessageBox::detailedText} {detailed text} to provide even more data + if the user requests it. + + A message box can also display an \l{QMessageBox::icon} {icon} and \l{QMessageBox::standardButtons} {standard buttons} for accepting a user response. @@ -577,27 +548,21 @@ void QMessageBoxPrivate::_q_clicked(QPlatformDialogHelper::StandardButton button \image msgbox1.png A better approach than just alerting the user to an event is to - also ask the user what to do about it. Store the question in the - \l{QMessageBox::informativeText} {informative text} property, and - set the \l{QMessageBox::standardButtons} {standard buttons} + also ask the user what to do about it. + + Set the \l{QMessageBox::standardButtons} {standard buttons} property to the set of buttons you want as the set of user responses. The buttons are specified by combining values from StandardButtons using the bitwise OR operator. The display order for the buttons is platform-dependent. For example, on Windows, \uicontrol{Save} is displayed to the left of \uicontrol{Cancel}, whereas on - Mac OS, the order is reversed. - - Mark one of your standard buttons to be your + \macos, the order is reversed. Mark one of your standard buttons to be your \l{QMessageBox::defaultButton()} {default button}. - \snippet code/src_gui_dialogs_qmessagebox.cpp 6 + The \l{QMessageBox::informativeText} {informative text} property can + be used to add additional context to help the user choose the appropriate action. - This is the approach recommended in the - \l{http://developer.apple.com/library/mac/documentation/UserExperience/Conceptual/AppleHIGuidelines/Windows/Windows.html#//apple_ref/doc/uid/20000961-BABCAJID} - {\macos Guidelines}. Similar guidelines apply for the other - platforms, but note the different ways the - \l{QMessageBox::informativeText} {informative text} is handled for - different platforms. + \snippet code/src_gui_dialogs_qmessagebox.cpp 6 \image msgbox2.png @@ -606,10 +571,10 @@ void QMessageBoxPrivate::_q_clicked(QPlatformDialogHelper::StandardButton button \snippet code/src_gui_dialogs_qmessagebox.cpp 7 - To give the user more information to help him answer the question, - set the \l{QMessageBox::detailedText} {detailed text} property. If - the \l{QMessageBox::detailedText} {detailed text} property is set, - the \uicontrol{Show Details...} button will be shown. + To give the user more information to help them choose the appropriate, + action, set the \l{QMessageBox::detailedText} {detailed text} property. + Depending on the platform the \l{QMessageBox::detailedText} {detailed text}, + may require the user to click a \uicontrol{Show Details...} button to be shown. \image msgbox3.png @@ -749,8 +714,7 @@ void QMessageBoxPrivate::_q_clicked(QPlatformDialogHelper::StandardButton button When an escape button can't be determined using these rules, pressing \uicontrol Esc has no effect. - \sa QDialogButtonBox, {fowler}{GUI Design Handbook: Message Box}, {Standard Dialogs Example}, - {Qt Widgets - Application Example} + \sa QDialogButtonBox, {Standard Dialogs Example}, {Qt Widgets - Application Example} */ /*! @@ -813,14 +777,21 @@ void QMessageBoxPrivate::_q_clicked(QPlatformDialogHelper::StandardButton button */ /*! - Constructs a message box with no text and no buttons. \a parent is - passed to the QDialog constructor. + Constructs an \l{Qt::ApplicationModal} {application modal} message box with no text and no buttons. + \a parent is passed to the QDialog constructor. + + The window modality can be overridden via setWindowModality() before calling show(). + + \note Using open() or exec() to show the message box affects the window modality. + Please see the detailed documentation for each function for more information. On \macos, if you want your message box to appear as a Qt::Sheet of its \a parent, set the message box's \l{setWindowModality()} {window modality} to Qt::WindowModal or use open(). Otherwise, the message box will be a standard dialog. + \sa setWindowTitle(), setText(), setIcon(), setStandardButtons(), setWindowModality() + */ QMessageBox::QMessageBox(QWidget *parent) : QDialog(*new QMessageBoxPrivate, parent, Qt::MSWindowsFixedSizeDialogHint | Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint) @@ -830,20 +801,22 @@ QMessageBox::QMessageBox(QWidget *parent) } /*! - Constructs a message box with the given \a icon, \a title, \a - text, and standard \a buttons. Standard or custom buttons can be + Constructs an \l{Qt::ApplicationModal} {application modal} message box with the given \a icon, + \a title, \a text, and standard \a buttons. Standard or custom buttons can be added at any time using addButton(). The \a parent and \a f arguments are passed to the QDialog constructor. - The message box is an \l{Qt::ApplicationModal} {application modal} - dialog box. + The window modality can be overridden via setWindowModality() before calling show(). + + \note Using open() or exec() to show the message box affects the window modality. + Please see the detailed documentation for each function for more information. On \macos, if \a parent is not \nullptr and you want your message box to appear as a Qt::Sheet of that parent, set the message box's \l{setWindowModality()} {window modality} to Qt::WindowModal (default). Otherwise, the message box will be a standard dialog. - \sa setWindowTitle(), setText(), setIcon(), setStandardButtons() + \sa setWindowTitle(), setText(), setIcon(), setStandardButtons(), setWindowModality() */ QMessageBox::QMessageBox(Icon icon, const QString &title, const QString &text, StandardButtons buttons, QWidget *parent, @@ -878,13 +851,45 @@ void QMessageBox::addButton(QAbstractButton *button, ButtonRole role) if (!button) return; removeButton(button); - d->options->addButton(button->text(), static_cast<QPlatformDialogHelper::ButtonRole>(role), - button); + + if (button->text().isEmpty()) { + if (auto *platformTheme = QGuiApplicationPrivate::platformTheme()) { + if (auto standardButton = QMessageBoxPrivate::standardButtonForRole(role)) + button->setText(platformTheme->standardButtonText(standardButton)); + } + + if (button->text().isEmpty()) { + qWarning() << "Cannot add" << button << "without title"; + return; + } + } + + // Add button to native dialog helper, unless it's the details button, + // since we don't do any plumbing for the button's action in that case. + if (button != d->detailsButton) { + d->options->addButton(button->text(), + static_cast<QPlatformDialogHelper::ButtonRole>(role), button); + } d->buttonBox->addButton(button, (QDialogButtonBox::ButtonRole)role); d->customButtonList.append(button); d->autoAddOkButton = false; } +QMessageBox::StandardButton QMessageBoxPrivate::standardButtonForRole(QMessageBox::ButtonRole role) +{ + switch (role) { + case QMessageBox::AcceptRole: return QMessageBox::Ok; + case QMessageBox::RejectRole: return QMessageBox::Cancel; + case QMessageBox::DestructiveRole: return QMessageBox::Discard; + case QMessageBox::HelpRole: return QMessageBox::Help; + case QMessageBox::ApplyRole: return QMessageBox::Apply; + case QMessageBox::YesRole: return QMessageBox::Yes; + case QMessageBox::NoRole: return QMessageBox::No; + case QMessageBox::ResetRole: return QMessageBox::Reset; + default: return QMessageBox::NoButton; + } +} + /*! \since 4.2 \overload @@ -1066,14 +1071,14 @@ void QMessageBoxPrivate::detectEscapeButton() // If there is only one button, make it the escape button const QList<QAbstractButton *> buttons = buttonBox->buttons(); - if (buttons.count() == 1) { + if (buttons.size() == 1) { detectedEscapeButton = buttons.first(); return; } // If there are two buttons and one of them is the "Show Details..." // button, then make the other one the escape button - if (buttons.count() == 2 && detailsButton) { + if (buttons.size() == 2 && detailsButton) { auto idx = buttons.indexOf(detailsButton); if (idx != -1) { detectedEscapeButton = buttons.at(1 - idx); @@ -1223,6 +1228,9 @@ QCheckBox* QMessageBox::checkBox() const \property QMessageBox::text \brief the message box text to be displayed. + The text should be a brief sentence or phrase that describes the situation, + ideally formulated as a neutral statement, or a call-to-action question. + The text will be interpreted either as a plain text or as rich text, depending on the text format setting (\l QMessageBox::textFormat). The default setting is Qt::AutoText, i.e., the message box will try @@ -1321,7 +1329,7 @@ void QMessageBox::setIcon(Icon icon) QPixmap QMessageBox::iconPixmap() const { Q_D(const QMessageBox); - return d->iconLabel->pixmap(Qt::ReturnByValue); + return d->iconLabel->pixmap(); } void QMessageBox::setIconPixmap(const QPixmap &pixmap) @@ -1496,21 +1504,21 @@ void QMessageBox::keyPressEvent(QKeyEvent *e) #if defined(Q_OS_WIN) if (e == QKeySequence::Copy) { - const QLatin1String separator("---------------------------\n"); + const auto separator = "---------------------------\n"_L1; QString textToCopy; - textToCopy += separator + windowTitle() + QLatin1Char('\n') + separator // title - + d->label->text() + QLatin1Char('\n') + separator; // text + textToCopy += separator + windowTitle() + u'\n' + separator // title + + d->label->text() + u'\n' + separator; // text if (d->informativeLabel) - textToCopy += d->informativeLabel->text() + QLatin1Char('\n') + separator; + textToCopy += d->informativeLabel->text() + u'\n' + separator; const QList<QAbstractButton *> buttons = d->buttonBox->buttons(); for (const auto *button : buttons) - textToCopy += button->text() + QLatin1String(" "); - textToCopy += QLatin1Char('\n') + separator; + textToCopy += button->text() + " "_L1; + textToCopy += u'\n' + separator; #if QT_CONFIG(textedit) if (d->detailsText) - textToCopy += d->detailsText->text() + QLatin1Char('\n') + separator; + textToCopy += d->detailsText->text() + u'\n' + separator; #endif QGuiApplication::clipboard()->setText(textToCopy); return; @@ -1557,6 +1565,23 @@ void QMessageBox::open(QObject *receiver, const char *member) QDialog::open(); } +void QMessageBoxPrivate::setVisible(bool visible) +{ + Q_Q(QMessageBox); + if (q->testAttribute(Qt::WA_WState_ExplicitShowHide) && q->testAttribute(Qt::WA_WState_Hidden) != visible) + return; + + if (canBeNativeDialog()) + setNativeDialogVisible(visible); + + // Update WA_DontShowOnScreen based on whether the native dialog was shown, + // so that QDialog::setVisible(visible) below updates the QWidget state correctly, + // but skips showing the non-native version. + q->setAttribute(Qt::WA_DontShowOnScreen, nativeDialogInUse); + + QDialogPrivate::setVisible(visible); +} + /*! \since 4.5 @@ -1599,7 +1624,7 @@ void QMessageBox::showEvent(QShowEvent *e) d->detectEscapeButton(); d->updateSize(); -#ifndef QT_NO_ACCESSIBILITY +#if QT_CONFIG(accessibility) QAccessibleEvent event(this, QAccessible::Alert); QAccessible::updateAccessibility(&event); #endif @@ -1813,7 +1838,7 @@ void QMessageBox::about(QWidget *parent, const QString &title, const QString &te } #endif - QMessageBox *msgBox = new QMessageBox(title, text, Information, 0, 0, 0, parent + QMessageBox *msgBox = new QMessageBox(Information, title, text, NoButton, parent #ifdef Q_OS_MAC , Qt::WindowTitleHint | Qt::WindowSystemMenuHint #endif @@ -1871,7 +1896,7 @@ void QMessageBox::aboutQt(QWidget *parent, const QString &title) translatedTextAboutQtCaption = QMessageBox::tr( "<h3>About Qt</h3>" "<p>This program uses Qt version %1.</p>" - ).arg(QLatin1String(QT_VERSION_STR)); + ).arg(QT_VERSION_STR ""_L1); //: Leave this text untranslated or include a verbatim copy of it below //: and note that it is the authoritative version in case of doubt. const QString translatedTextAboutQtText = QMessageBox::tr( @@ -1896,7 +1921,7 @@ void QMessageBox::aboutQt(QWidget *parent, const QString &title) "<p>Qt and the Qt logo are trademarks of The Qt Company Ltd.</p>" "<p>Qt is The Qt Company Ltd product developed as an open source " "project. See <a href=\"http://%3/\">%3</a> for more information.</p>" - ).arg(QStringLiteral("2021"), + ).arg(QLatin1String(QT_COPYRIGHT_YEAR), QStringLiteral("qt.io/licensing"), QStringLiteral("qt.io")); QMessageBox *msgBox = new QMessageBox(parent); @@ -1905,7 +1930,7 @@ void QMessageBox::aboutQt(QWidget *parent, const QString &title) msgBox->setText(translatedTextAboutQtCaption); msgBox->setInformativeText(translatedTextAboutQtText); - QPixmap pm(QLatin1String(":/qt-project.org/qmessagebox/images/qtlogo-64.png")); + QPixmap pm(":/qt-project.org/qmessagebox/images/qtlogo-64.png"_L1); if (!pm.isNull()) msgBox->setIconPixmap(pm); @@ -2539,10 +2564,9 @@ void QMessageBox::setDetailedText(const QString &text) \since 4.2 - Infromative text can be used to expand upon the text() to give more - information to the user. On the Mac, this text appears in small - system font below the text(). On other platforms, it is simply - appended to the existing text. + Informative text can be used to expand upon the text() to give more + information to the user, for example describing the consequences of + the situation, or suggestion alternative solutions. By default, this property contains an empty string. @@ -2566,7 +2590,7 @@ void QMessageBox::setInformativeText(const QString &text) } else { if (!d->informativeLabel) { QLabel *label = new QLabel; - label->setObjectName(QLatin1String("qt_msgbox_informativelabel")); + label->setObjectName("qt_msgbox_informativelabel"_L1); label->setTextInteractionFlags(Qt::TextInteractionFlags(style()->styleHint(QStyle::SH_MessageBox_TextInteractionFlags, nullptr, this))); label->setAlignment(Qt::AlignTop | Qt::AlignLeft); label->setOpenExternalLinks(true); @@ -2658,10 +2682,19 @@ void QMessageBoxPrivate::initHelper(QPlatformDialogHelper *h) Q_Q(QMessageBox); QObject::connect(h, SIGNAL(clicked(QPlatformDialogHelper::StandardButton,QPlatformDialogHelper::ButtonRole)), q, SLOT(_q_clicked(QPlatformDialogHelper::StandardButton,QPlatformDialogHelper::ButtonRole))); + + auto *messageDialogHelper = static_cast<QPlatformMessageDialogHelper *>(h); + QObject::connect(messageDialogHelper, &QPlatformMessageDialogHelper::checkBoxStateChanged, q, + [this](Qt::CheckState state) { + if (checkbox) + checkbox->setCheckState(state); + } + ); + static_cast<QPlatformMessageDialogHelper *>(h)->setOptions(options); } -static QMessageDialogOptions::Icon helperIcon(QMessageBox::Icon i) +static QMessageDialogOptions::StandardIcon helperIcon(QMessageBox::Icon i) { switch (i) { case QMessageBox::NoIcon: @@ -2693,8 +2726,11 @@ void QMessageBoxPrivate::helperPrepareShow(QPlatformDialogHelper *) #if QT_CONFIG(textedit) options->setDetailedText(q->detailedText()); #endif - options->setIcon(helperIcon(q->icon())); + options->setStandardIcon(helperIcon(q->icon())); + options->setIconPixmap(q->iconPixmap()); options->setStandardButtons(helperStandardButtons(q)); + if (checkbox) + options->setCheckBox(checkbox->text(), checkbox->checkState()); } void QMessageBoxPrivate::helperDone(QDialog::DialogCode code, QPlatformDialogHelper *) @@ -2773,6 +2809,25 @@ QPixmap QMessageBox::standardIcon(Icon icon) \sa show(), result() */ +/*! + \macro QT_REQUIRE_VERSION(int argc, char **argv, const char *version) + \relates <QMessageBox> + + This macro can be used to ensure that the application is run + with a recent enough version of Qt. This is especially useful + if your application depends on a specific bug fix introduced in a + bug-fix release (for example, 6.1.2). + + The \a argc and \a argv parameters are the \c main() function's + \c argc and \c argv parameters. The \a version parameter is a + string literal that specifies which version of Qt the application + requires (for example, "6.1.2"). + + Example: + + \snippet code/src_gui_dialogs_qmessagebox.cpp 4 +*/ + QT_END_NAMESPACE #include "moc_qmessagebox.cpp" diff --git a/src/widgets/dialogs/qmessagebox.h b/src/widgets/dialogs/qmessagebox.h index e8aef44981..cf8821bbd0 100644 --- a/src/widgets/dialogs/qmessagebox.h +++ b/src/widgets/dialogs/qmessagebox.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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 Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QMESSAGEBOX_H #define QMESSAGEBOX_H @@ -70,7 +34,7 @@ class Q_WIDGETS_EXPORT QMessageBox : public QDialog public: enum Icon { - // keep this in sync with QMessageDialogOptions::Icon + // keep this in sync with QMessageDialogOptions::StandardIcon NoIcon = 0, Information = 1, Warning = 2, @@ -313,7 +277,7 @@ public: Q_SIGNALS: void buttonClicked(QAbstractButton *button); -#ifdef Q_CLANG_QDOC +#ifdef Q_QDOC public Q_SLOTS: int exec() override; #endif diff --git a/src/widgets/dialogs/qmessagebox.qrc b/src/widgets/dialogs/qmessagebox.qrc deleted file mode 100644 index de217773ec..0000000000 --- a/src/widgets/dialogs/qmessagebox.qrc +++ /dev/null @@ -1,5 +0,0 @@ -<!DOCTYPE RCC><RCC version="1.0"> -<qresource prefix="/qt-project.org/qmessagebox"> - <file>images/qtlogo-64.png</file> -</qresource> -</RCC> diff --git a/src/widgets/dialogs/qprogressdialog.cpp b/src/widgets/dialogs/qprogressdialog.cpp index 448acfc7f9..59d44cd8d5 100644 --- a/src/widgets/dialogs/qprogressdialog.cpp +++ b/src/widgets/dialogs/qprogressdialog.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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 Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qprogressdialog.h" @@ -251,8 +215,7 @@ void QProgressDialogPrivate::_q_disconnectOnClose() \image fusion-progressdialog.png A progress dialog shown in the Fusion widget style. - \sa QDialog, QProgressBar, {fowler}{GUI Design Handbook: Progress Indicator}, - {Find Files Example}, {Pixelator Example} + \sa QDialog, QProgressBar, {Pixelator Example} */ diff --git a/src/widgets/dialogs/qprogressdialog.h b/src/widgets/dialogs/qprogressdialog.h index 74adb6bd84..132dffa480 100644 --- a/src/widgets/dialogs/qprogressdialog.h +++ b/src/widgets/dialogs/qprogressdialog.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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 Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QPROGRESSDIALOG_H #define QPROGRESSDIALOG_H diff --git a/src/widgets/dialogs/qsidebar.cpp b/src/widgets/dialogs/qsidebar.cpp index 296542a187..b52c7e8c9e 100644 --- a/src/widgets/dialogs/qsidebar.cpp +++ b/src/widgets/dialogs/qsidebar.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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 Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qsidebar_p.h" @@ -53,6 +17,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + void QSideBarDelegate::initStyleOption(QStyleOptionViewItem *option, const QModelIndex &index) const { @@ -82,7 +48,7 @@ QUrlModel::QUrlModel(QObject *parent) : QStandardItemModel(parent), showFullPath */ QStringList QUrlModel::mimeTypes() const { - return QStringList(QLatin1String("text/uri-list")); + return QStringList("text/uri-list"_L1); } /*! @@ -245,9 +211,9 @@ void QUrlModel::addUrls(const QList<QUrl> &list, int row, bool move) if (row == -1) row = rowCount(); row = qMin(row, rowCount()); - for (int i = list.count() - 1; i >= 0; --i) { + for (int i = list.size() - 1; i >= 0; --i) { QUrl url = list.at(i); - if (!url.isValid() || url.scheme() != QLatin1String("file")) + if (!url.isValid() || url.scheme() != "file"_L1) continue; //this makes sure the url is clean const QString cleanUrl = QDir::cleanPath(url.toLocalFile()); @@ -325,7 +291,7 @@ void QUrlModel::setFileSystemModel(QFileSystemModel *model) void QUrlModel::dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight) { QModelIndex parent = topLeft.parent(); - for (int i = 0; i < watching.count(); ++i) { + for (int i = 0; i < watching.size(); ++i) { QModelIndex index = watching.at(i).index; if (index.model() && topLeft.model()) { Q_ASSERT(index.model() == topLeft.model()); @@ -346,7 +312,7 @@ void QUrlModel::dataChanged(const QModelIndex &topLeft, const QModelIndex &botto void QUrlModel::layoutChanged() { QStringList paths; - const int numPaths = watching.count(); + const int numPaths = watching.size(); paths.reserve(numPaths); for (int i = 0; i < numPaths; ++i) paths.append(watching.at(i).path); @@ -451,7 +417,7 @@ void QSidebar::showContextMenu(const QPoint &position) connect(action, SIGNAL(triggered()), this, SLOT(removeEntry())); actions.append(action); } - if (actions.count() > 0) + if (actions.size() > 0) QMenu::exec(actions, mapToGlobal(position)); } #endif // QT_CONFIG(menu) @@ -465,7 +431,7 @@ void QSidebar::removeEntry() { QList<QModelIndex> idxs = selectionModel()->selectedIndexes(); QList<QPersistentModelIndex> indexes; - const int numIndexes = idxs.count(); + const int numIndexes = idxs.size(); indexes.reserve(numIndexes); for (int i = 0; i < numIndexes; i++) indexes.append(idxs.at(i)); @@ -504,7 +470,7 @@ void QSidebar::focusInEvent(QFocusEvent *event) bool QSidebar::event(QEvent * event) { if (event->type() == QEvent::KeyRelease) { - QKeyEvent* ke = (QKeyEvent*) event; + QKeyEvent *ke = static_cast<QKeyEvent *>(event); if (ke->key() == Qt::Key_Delete) { removeEntry(); return true; diff --git a/src/widgets/dialogs/qsidebar_p.h b/src/widgets/dialogs/qsidebar_p.h index 7f06f0b679..74805e4f2d 100644 --- a/src/widgets/dialogs/qsidebar_p.h +++ b/src/widgets/dialogs/qsidebar_p.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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 Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QSIDEBAR_H #define QSIDEBAR_H diff --git a/src/widgets/dialogs/qwizard.cpp b/src/widgets/dialogs/qwizard.cpp index e584db0f15..d6287717d9 100644 --- a/src/widgets/dialogs/qwizard.cpp +++ b/src/widgets/dialogs/qwizard.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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 Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qwizard.h" #include <QtWidgets/private/qtwidgetsglobal_p.h> @@ -54,7 +18,7 @@ #include "qlineedit.h" #endif #include <qpointer.h> -#include "qpainter.h" +#include "qstylepainter.h" #include "qwindow.h" #include "qpushbutton.h" #include "qset.h" @@ -65,9 +29,8 @@ #include "qstyleoption.h" #include "qvarlengtharray.h" #if defined(Q_OS_MACOS) -#include <QtCore/QMetaMethod> -#include <QtGui/QGuiApplication> -#include <qpa/qplatformnativeinterface.h> +#include <AppKit/AppKit.h> +#include <QtGui/private/qcoregraphics_p.h> #elif QT_CONFIG(style_windowsvista) #include "qwizard_win_p.h" #include "qtimer.h" @@ -81,6 +44,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + // These fudge terms were needed a few places to obtain pixel-perfect results const int GapBetweenLogoAndRightEdge = 5; const int ModernHeaderTopMargin = 2; @@ -163,8 +128,7 @@ static const char *changed_signal(int which) case 6: return SIGNAL(valueChanged(int)); }; static_assert(7 == NFallbackDefaultProperties); - Q_UNREACHABLE(); - return nullptr; + Q_UNREACHABLE_RETURN(nullptr); } class QWizardDefaultProperty @@ -206,7 +170,7 @@ QWizardField::QWizardField(QWizardPage *page, const QString &spec, QObject *obje : page(page), name(spec), mandatory(false), object(object), property(property), changedSignal(changedSignal) { - if (name.endsWith(QLatin1Char('*'))) { + if (name.endsWith(u'*')) { name.chop(1); mandatory = true; } @@ -215,7 +179,7 @@ QWizardField::QWizardField(QWizardPage *page, const QString &spec, QObject *obje void QWizardField::resolve(const QList<QWizardDefaultProperty> &defaultPropertyTable) { if (property.isEmpty()) - findProperty(defaultPropertyTable.constData(), defaultPropertyTable.count()); + findProperty(defaultPropertyTable.constData(), defaultPropertyTable.size()); initialValue = object->property(property); } @@ -254,11 +218,11 @@ public: bool extension = false; bool sideWidget = false; - bool operator==(const QWizardLayoutInfo &other); - inline bool operator!=(const QWizardLayoutInfo &other) { return !operator==(other); } + bool operator==(const QWizardLayoutInfo &other) const; + inline bool operator!=(const QWizardLayoutInfo &other) const { return !operator==(other); } }; -bool QWizardLayoutInfo::operator==(const QWizardLayoutInfo &other) +bool QWizardLayoutInfo::operator==(const QWizardLayoutInfo &other) const { return topLevelMarginLeft == other.topLevelMarginLeft && topLevelMarginRight == other.topLevelMarginRight @@ -363,8 +327,7 @@ void QWizardHeader::setup(const QWizardLayoutInfo &info, const QString &title, { bool modern = ((info.wizStyle == QWizard::ModernStyle) #if QT_CONFIG(style_windowsvista) - || ((info.wizStyle == QWizard::AeroStyle - && QVistaHelper::vistaState() == QVistaHelper::Classic) || vistaDisabled()) + || vistaDisabled() #endif ); @@ -383,7 +346,7 @@ void QWizardHeader::setup(const QWizardLayoutInfo &info, const QString &title, logoLabel->setPixmap(logo); subTitleLabel->setTextFormat(subTitleFormat); - subTitleLabel->setText(QLatin1String("Pq\nPq")); + subTitleLabel->setText("Pq\nPq"_L1); int desiredSubTitleHeight = subTitleLabel->sizeHint().height(); subTitleLabel->setText(subTitle); @@ -420,7 +383,7 @@ void QWizardHeader::setup(const QWizardLayoutInfo &info, const QString &title, void QWizardHeader::paintEvent(QPaintEvent * /* event */) { - QPainter painter(this); + QStylePainter painter(this); painter.drawPixmap(0, 0, bannerPixmap); int x = width() - 2; @@ -451,8 +414,8 @@ public: } QSize minimumSizeHint() const override { - if (!pixmap(Qt::ReturnByValue).isNull()) - return pixmap(Qt::ReturnByValue).deviceIndependentSize().toSize(); + if (!pixmap().isNull()) + return pixmap().deviceIndependentSize().toSize(); return QFrame::minimumSizeHint(); } @@ -570,7 +533,6 @@ public: void updatePixmap(QWizard::WizardPixmap which); #if QT_CONFIG(style_windowsvista) bool vistaDisabled() const; - bool isVistaThemeEnabled(QVistaHelper::VistaState state) const; bool handleAeroStyleChange(); #endif bool isVistaThemeEnabled() const; @@ -639,7 +601,7 @@ public: QPointer<QShortcut> vistaNextShortcut; # endif bool vistaInitPending = true; - QVistaHelper::VistaState vistaState = QVistaHelper::Dirty; + bool vistaDirty = true; bool vistaStateChanged = false; bool inHandleAeroStyleChange = false; #endif @@ -729,10 +691,10 @@ void QWizardPrivate::reset() if (current != -1) { q->currentPage()->hide(); cleanupPagesNotInHistory(); - for (int i = history.count() - 1; i >= 0; --i) + for (int i = history.size() - 1; i >= 0; --i) q->cleanupPage(history.at(i)); history.clear(); - for (QWizardPage *page : qAsConst(pageMap)) + for (QWizardPage *page : std::as_const(pageMap)) page->d_func()->initialized = false; current = -1; @@ -766,7 +728,7 @@ void QWizardPrivate::addField(const QWizardField &field) return; } - fieldIndexMap.insert(myField.name, fields.count()); + fieldIndexMap.insert(myField.name, fields.size()); fields += myField; if (myField.mandatory && !myField.changedSignal.isEmpty()) QObject::connect(myField.object, myField.changedSignal, @@ -923,7 +885,7 @@ QWizardLayoutInfo QWizardPrivate::layoutInfoForCurrentPage() info.wizStyle = wizStyle; if (info.wizStyle == QWizard::AeroStyle #if QT_CONFIG(style_windowsvista) - && (QVistaHelper::vistaState() == QVistaHelper::Classic || vistaDisabled()) + && vistaDisabled() #endif ) info.wizStyle = QWizard::ModernStyle; @@ -1049,7 +1011,7 @@ void QWizardPrivate::recreateLayout(const QWizardLayoutInfo &info) if (aero) { // ### hardcoded for now: - titleFont = QFont(QLatin1String("Segoe UI"), 12); + titleFont = QFont("Segoe UI"_L1, 12); QPalette pal(titleLabel->palette()); pal.setColor(QPalette::Text, QColor(0x00, 0x33, 0x99)); titleLabel->setPalette(pal); @@ -1365,11 +1327,11 @@ static QString object_name_for_button(QWizard::WizardButton which) { switch (which) { case QWizard::CommitButton: - return QLatin1String("qt_wizard_") + QLatin1String("commit"); + return u"qt_wizard_commit"_s; case QWizard::FinishButton: - return QLatin1String("qt_wizard_") + QLatin1String("finish"); + return u"qt_wizard_finish"_s; case QWizard::CancelButton: - return QLatin1String("qt_wizard_") + QLatin1String("cancel"); + return u"qt_wizard_cancel"_s; case QWizard::BackButton: case QWizard::NextButton: case QWizard::HelpButton: @@ -1377,15 +1339,14 @@ static QString object_name_for_button(QWizard::WizardButton which) case QWizard::CustomButton2: case QWizard::CustomButton3: // Make navigation buttons detectable as passive interactor in designer - return QLatin1String("__qt__passive_wizardbutton") + QString::number(which); + return "__qt__passive_wizardbutton"_L1 + QString::number(which); case QWizard::Stretch: case QWizard::NoButton: //case QWizard::NStandardButtons: //case QWizard::NButtons: ; } - Q_UNREACHABLE(); - return QString(); + Q_UNREACHABLE_RETURN(QString()); } bool QWizardPrivate::ensureButton(QWizard::WizardButton which) const @@ -1459,10 +1420,10 @@ void QWizardPrivate::updateButtonTexts() void QWizardPrivate::updateButtonLayout() { if (buttonsHaveCustomLayout) { - QVarLengthArray<QWizard::WizardButton, QWizard::NButtons> array(buttonsCustomLayout.count()); - for (int i = 0; i < buttonsCustomLayout.count(); ++i) + QVarLengthArray<QWizard::WizardButton, QWizard::NButtons> array(buttonsCustomLayout.size()); + for (int i = 0; i < buttonsCustomLayout.size(); ++i) array[i] = buttonsCustomLayout.at(i); - setButtonLayout(array.constData(), array.count()); + setButtonLayout(array.constData(), array.size()); } else { // Positions: // Help Stretch Custom1 Custom2 Custom3 Cancel Back Next Commit Finish Cancel Help @@ -1556,13 +1517,6 @@ bool QWizardPrivate::vistaDisabled() const return v.isValid() && v.toBool(); } -bool QWizardPrivate::isVistaThemeEnabled(QVistaHelper::VistaState state) const -{ - return wizStyle == QWizard::AeroStyle - && QVistaHelper::vistaState() == state - && !vistaDisabled(); -} - bool QWizardPrivate::handleAeroStyleChange() { Q_Q(QWizard); @@ -1586,25 +1540,17 @@ bool QWizardPrivate::handleAeroStyleChange() if (isVistaThemeEnabled()) { const int topOffset = vistaHelper->topOffset(q); const int topPadding = vistaHelper->topPadding(q); - if (isVistaThemeEnabled(QVistaHelper::VistaAero)) { - if (isWindow) { - vistaHelper->setDWMTitleBar(QVistaHelper::ExtendedTitleBar); - q->installEventFilter(vistaHelper); - } - q->setMouseTracking(true); - antiFlickerWidget->move(0, vistaHelper->titleBarSize() + topOffset); - vistaHelper->backButton()->move( - 0, topOffset // ### should ideally work without the '+ 1' - - qMin(topOffset, topPadding + 1)); - vistaMargins = true; - vistaHelper->backButton()->show(); - } else { - if (isWindow) - vistaHelper->setDWMTitleBar(QVistaHelper::NormalTitleBar); - q->setMouseTracking(true); - antiFlickerWidget->move(0, topOffset); - vistaHelper->backButton()->move(0, -1); // ### should ideally work with (0, 0) + if (isWindow) { + vistaHelper->setDWMTitleBar(QVistaHelper::ExtendedTitleBar); + q->installEventFilter(vistaHelper); } + q->setMouseTracking(true); + antiFlickerWidget->move(0, vistaHelper->titleBarSize() + topOffset); + vistaHelper->backButton()->move( + 0, topOffset // ### should ideally work without the '+ 1' + - qMin(topOffset, topPadding + 1)); + vistaMargins = true; + vistaHelper->backButton()->show(); if (isWindow) vistaHelper->setTitleBarIconAndCaptionVisible(false); QObject::connect( @@ -1633,8 +1579,7 @@ bool QWizardPrivate::handleAeroStyleChange() bool QWizardPrivate::isVistaThemeEnabled() const { #if QT_CONFIG(style_windowsvista) - return isVistaThemeEnabled(QVistaHelper::VistaAero) - || isVistaThemeEnabled(QVistaHelper::VistaBasic); + return wizStyle == QWizard::AeroStyle && !vistaDisabled(); #else return false; #endif @@ -1679,15 +1624,15 @@ void QWizardPrivate::_q_updateButtonStates() const QWizardPage *page = q->currentPage(); bool complete = page && page->isComplete(); - btn.back->setEnabled(history.count() > 1 - && !q->page(history.at(history.count() - 2))->isCommitPage() + btn.back->setEnabled(history.size() > 1 + && !q->page(history.at(history.size() - 2))->isCommitPage() && (!canFinish || !(opts & QWizard::DisabledBackButtonOnLastPage))); btn.next->setEnabled(canContinue && complete); btn.commit->setEnabled(canContinue && complete); btn.finish->setEnabled(canFinish && complete); const bool backButtonVisible = buttonLayoutContains(QWizard::BackButton) - && (history.count() > 1 || !(opts & QWizard::NoBackButtonOnStartPage)) + && (history.size() > 1 || !(opts & QWizard::NoBackButtonOnStartPage)) && (canContinue || !(opts & QWizard::NoBackButtonOnLastPage)); bool commitPage = page && page->isCommitPage(); btn.back->setVisible(backButtonVisible); @@ -1759,23 +1704,19 @@ void QWizardPrivate::setStyle(QStyle *style) } #ifdef Q_OS_MACOS - QPixmap QWizardPrivate::findDefaultBackgroundPixmap() { - QGuiApplication *app = qobject_cast<QGuiApplication *>(QCoreApplication::instance()); - if (!app) - return QPixmap(); - QPlatformNativeInterface *platformNativeInterface = app->platformNativeInterface(); - int at = platformNativeInterface->metaObject()->indexOfMethod("defaultBackgroundPixmapForQWizard()"); - if (at == -1) - return QPixmap(); - QMetaMethod defaultBackgroundPixmapForQWizard = platformNativeInterface->metaObject()->method(at); - QPixmap result; - if (!defaultBackgroundPixmapForQWizard.invoke(platformNativeInterface, Q_RETURN_ARG(QPixmap, result))) - return QPixmap(); - return result; -} + auto *keyboardAssistantURL = [NSWorkspace.sharedWorkspace + URLForApplicationWithBundleIdentifier:@"com.apple.KeyboardSetupAssistant"]; + auto *keyboardAssistantBundle = [NSBundle bundleWithURL:keyboardAssistantURL]; + auto *assistantBackground = [keyboardAssistantBundle imageForResource:@"Background"]; + auto size = QSizeF::fromCGSize(assistantBackground.size); + static const QSizeF expectedSize(242, 414); + if (size == expectedSize) + return qt_mac_toQPixmap(assistantBackground, size); + return QPixmap(); +} #endif #if QT_CONFIG(style_windowsvista) @@ -1791,13 +1732,6 @@ void QWizardAntiFlickerWidget::paintEvent(QPaintEvent *) painter.fillRect(0, buttonLayoutTop, width(), height() - buttonLayoutTop, brush); painter.setPen(QPen(QBrush(QColor(223, 223, 223)), 0)); // ### hardcoded for now painter.drawLine(0, buttonLayoutTop, width(), buttonLayoutTop); - if (wizardPrivate->isVistaThemeEnabled(QVistaHelper::VistaBasic)) { - if (window()->isActiveWindow()) - painter.setPen(QPen(QBrush(QColor(169, 191, 214)), 0)); // ### hardcoded for now - else - painter.setPen(QPen(QBrush(QColor(182, 193, 204)), 0)); // ### hardcoded for now - painter.drawLine(0, 0, width(), 0); - } } } #endif @@ -2262,7 +2196,7 @@ void QWizard::setPage(int theid, QWizardPage *page) page->setParent(d->pageFrame); QList<QWizardField> &pendingFields = page->d_func()->pendingFields; - for (int i = 0; i < pendingFields.count(); ++i) + for (int i = 0; i < pendingFields.size(); ++i) d->addField(pendingFields.at(i)); pendingFields.clear(); @@ -2303,11 +2237,11 @@ void QWizard::removePage(int id) QWizardPage *removedPage = nullptr; // update startItem accordingly - if (d->pageMap.count() > 0) { // only if we have any pages + if (d->pageMap.size() > 0) { // only if we have any pages if (d->start == id) { const int firstId = d->pageMap.constBegin().key(); if (firstId == id) { - if (d->pageMap.count() > 1) + if (d->pageMap.size() > 1) d->start = (++d->pageMap.constBegin()).key(); // secondId else d->start = -1; // removing the last page @@ -2330,7 +2264,7 @@ void QWizard::removePage(int id) removedPage = d->pageMap.take(id); d->history.removeOne(id); d->_q_updateButtonStates(); - } else if (d->history.count() == 1) { + } else if (d->history.size() == 1) { // Case 3: removing the current page which is the first (and only) one in the history d->reset(); removedPage = d->pageMap.take(id); @@ -2353,7 +2287,7 @@ void QWizard::removePage(int id) d->pageVBoxLayout->removeWidget(removedPage); - for (int i = d->fields.count() - 1; i >= 0; --i) { + for (int i = d->fields.size() - 1; i >= 0; --i) { if (d->fields.at(i).page == removedPage) { removedPage->d_func()->pendingFields += d->fields.at(i); d->removeFieldAt(i); @@ -2431,7 +2365,7 @@ void QWizard::setStartId(int theid) Q_D(QWizard); int newStart = theid; if (theid == -1) - newStart = d->pageMap.count() ? d->pageMap.constBegin().key() : -1; + newStart = d->pageMap.size() ? d->pageMap.constBegin().key() : -1; if (d->start == newStart) { d->startSetByUser = theid != -1; @@ -2740,7 +2674,7 @@ void QWizard::setButtonLayout(const QList<WizardButton> &layout) { Q_D(QWizard); - for (int i = 0; i < layout.count(); ++i) { + for (int i = 0; i < layout.size(); ++i) { WizardButton button1 = layout.at(i); if (button1 == NoButton || button1 == Stretch) @@ -2881,7 +2815,7 @@ void QWizard::setPixmap(WizardPixmap which, const QPixmap &pixmap) Returns the pixmap set for role \a which. By default, the only pixmap that is set is the BackgroundPixmap on - \macos version 10.13 and earlier. + \macos. \sa QWizardPage::pixmap(), {Elements of a Wizard Page} */ @@ -2925,7 +2859,7 @@ void QWizard::setDefaultProperty(const char *className, const char *property, const char *changedSignal) { Q_D(QWizard); - for (int i = d->defaultPropertyTable.count() - 1; i >= 0; --i) { + for (int i = d->defaultPropertyTable.size() - 1; i >= 0; --i) { if (qstrcmp(d->defaultPropertyTable.at(i).className, className) == 0) { d->defaultPropertyTable.remove(i); break; @@ -3105,7 +3039,7 @@ QSize QWizard::sizeHint() const void QWizard::back() { Q_D(QWizard); - int n = d->history.count() - 2; + int n = d->history.size() - 2; if (n < 0) return; d->switchToPage(d->history.at(n), QWizardPrivate::Backward); @@ -3142,6 +3076,42 @@ void QWizard::next() } /*! + Sets currentId to \a id, without visiting the pages between currentId and \a id. + + Returns without page change, if + \list + \li wizard holds no pages + \li current page is invalid + \li given page equals currentId() + \li given page is out of range + \endlist + + Note: If pages have been forward skipped and \a id is 0, page visiting history + will be deleted +*/ + +void QWizard::setCurrentId(int id) +{ + Q_D(QWizard); + + if (d->current == -1) + return; + + if (currentId() == id) + return; + + if (!validateCurrentPage()) + return; + + if (id < 0 || Q_UNLIKELY(!d->pageMap.contains(id))) { + qWarning("QWizard::setCurrentId: No such page: %d", id); + return; + } + + d->switchToPage(id, (id < currentId()) ? QWizardPrivate::Backward : QWizardPrivate::Forward); +} + +/*! Restarts the wizard at the start page. This function is called automatically when the wizard is shown. @@ -3171,12 +3141,7 @@ bool QWizard::event(QEvent *event) #if QT_CONFIG(style_windowsvista) else if (event->type() == QEvent::Show && d->vistaInitPending) { d->vistaInitPending = false; - // Do not force AeroStyle when in Classic theme. - // Note that d->handleAeroStyleChange() needs to be called in any case as it does some - // necessary initialization, like ensures that the Aero specific back button is hidden if - // Aero theme isn't active. - if (QVistaHelper::vistaState() != QVistaHelper::Classic) - d->wizStyle = AeroStyle; + d->wizStyle = AeroStyle; d->handleAeroStyleChange(); } else if (d->isVistaThemeEnabled()) { @@ -3206,8 +3171,7 @@ void QWizard::resizeEvent(QResizeEvent *event) #if QT_CONFIG(style_windowsvista) if (d->isVistaThemeEnabled()) { heightOffset = d->vistaHelper->topOffset(this); - if (d->isVistaThemeEnabled(QVistaHelper::VistaAero)) - heightOffset += d->vistaHelper->titleBarSize(); + heightOffset += d->vistaHelper->titleBarSize(); } #endif d->antiFlickerWidget->resize(event->size().width(), event->size().height() - heightOffset); @@ -3229,16 +3193,11 @@ void QWizard::paintEvent(QPaintEvent * event) if (backgroundPixmap.isNull()) return; - QPainter painter(this); + QStylePainter painter(this); painter.drawPixmap(0, (height() - backgroundPixmap.height()) / 2, backgroundPixmap); } #if QT_CONFIG(style_windowsvista) else if (d->isVistaThemeEnabled()) { - if (d->isVistaThemeEnabled(QVistaHelper::VistaBasic)) { - QPainter painter(this); - QColor color = d->vistaHelper->basicWindowFrameColor(); - painter.fillRect(0, 0, width(), QVistaHelper::topOffset(this), color); - } d->vistaHelper->paintEvent(event); } #else @@ -3246,7 +3205,7 @@ void QWizard::paintEvent(QPaintEvent * event) #endif } -#if defined(Q_OS_WIN) || defined(Q_CLANG_QDOC) +#if defined(Q_OS_WIN) || defined(Q_QDOC) /*! \reimp */ @@ -3257,12 +3216,12 @@ bool QWizard::nativeEvent(const QByteArray &eventType, void *message, qintptr *r if (d->isVistaThemeEnabled() && eventType == "windows_generic_MSG") { MSG *windowsMessage = static_cast<MSG *>(message); const bool winEventResult = d->vistaHelper->handleWinEvent(windowsMessage, result); - if (QVistaHelper::vistaState() != d->vistaState) { + if (d->vistaDirty) { // QTBUG-78300: When Qt::AA_NativeWindows is set, delay further // window creation until after the platform window creation events. if (windowsMessage->message == WM_GETICON) { d->vistaStateChanged = true; - d->vistaState = QVistaHelper::vistaState(); + d->vistaDirty = false; setWizardStyle(AeroStyle); } } @@ -3668,7 +3627,7 @@ bool QWizardPage::isComplete() const return true; const QList<QWizardField> &wizardFields = d->wizard->d_func()->fields; - for (int i = wizardFields.count() - 1; i >= 0; --i) { + for (int i = wizardFields.size() - 1; i >= 0; --i) { const QWizardField &field = wizardFields.at(i); if (field.page == this && field.mandatory) { QVariant value = field.object->property(field.property); diff --git a/src/widgets/dialogs/qwizard.h b/src/widgets/dialogs/qwizard.h index 8e058aa93b..0ec973b0d2 100644 --- a/src/widgets/dialogs/qwizard.h +++ b/src/widgets/dialogs/qwizard.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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 Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QWIZARD_H #define QWIZARD_H @@ -59,7 +23,7 @@ class Q_WIDGETS_EXPORT QWizard : public QDialog Q_PROPERTY(Qt::TextFormat titleFormat READ titleFormat WRITE setTitleFormat) Q_PROPERTY(Qt::TextFormat subTitleFormat READ subTitleFormat WRITE setSubTitleFormat) Q_PROPERTY(int startId READ startId WRITE setStartId) - Q_PROPERTY(int currentId READ currentId NOTIFY currentIdChanged) + Q_PROPERTY(int currentId READ currentId WRITE setCurrentId NOTIFY currentIdChanged) public: enum WizardButton { @@ -181,13 +145,14 @@ Q_SIGNALS: public Q_SLOTS: void back(); void next(); + void setCurrentId(int id); void restart(); protected: bool event(QEvent *event) override; void resizeEvent(QResizeEvent *event) override; void paintEvent(QPaintEvent *event) override; -#if defined(Q_OS_WIN) || defined(Q_CLANG_QDOC) +#if defined(Q_OS_WIN) || defined(Q_QDOC) bool nativeEvent(const QByteArray &eventType, void *message, qintptr *result) override; #endif void done(int result) override; diff --git a/src/widgets/dialogs/qwizard_win.cpp b/src/widgets/dialogs/qwizard_win.cpp index 24aa24de20..b7788061f1 100644 --- a/src/widgets/dialogs/qwizard_win.cpp +++ b/src/widgets/dialogs/qwizard_win.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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 Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include <QtWidgets/private/qtwidgetsglobal_p.h> @@ -60,6 +24,7 @@ #include <vssym32.h> #include <dwmapi.h> +// ### move to qmargins.h Q_DECLARE_METATYPE(QMargins) #ifndef WM_DWMCOMPOSITIONCHANGED @@ -68,9 +33,7 @@ Q_DECLARE_METATYPE(QMargins) QT_BEGIN_NAMESPACE -int QVistaHelper::instanceCount = 0; int QVistaHelper::m_devicePixelRatio = 1; -QVistaHelper::VistaState QVistaHelper::cachedVistaState = QVistaHelper::Dirty; /****************************************************************************** ** QVistaBackButton @@ -153,18 +116,14 @@ QVistaHelper::QVistaHelper(QWizard *wizard) , backButton_(0) { QVistaHelper::m_devicePixelRatio = wizard->devicePixelRatio(); - if (instanceCount++ == 0) - cachedVistaState = Dirty; + backButton_ = new QVistaBackButton(wizard); backButton_->hide(); iconSpacing = QStyleHelper::dpiScaled(7, wizard); } -QVistaHelper::~QVistaHelper() -{ - --instanceCount; -} +QVistaHelper::~QVistaHelper() = default; void QVistaHelper::updateCustomMargins(bool vistaMargins) { @@ -185,25 +144,6 @@ void QVistaHelper::updateCustomMargins(bool vistaMargins) } } -bool QVistaHelper::isCompositionEnabled() -{ - BOOL bEnabled; - return SUCCEEDED(DwmIsCompositionEnabled(&bEnabled)) && bEnabled; -} - -bool QVistaHelper::isThemeActive() -{ - return IsThemeActive(); -} - -QVistaHelper::VistaState QVistaHelper::vistaState() -{ - if (instanceCount == 0 || cachedVistaState == Dirty) - cachedVistaState = - isCompositionEnabled() ? VistaAero : isThemeActive() ? VistaBasic : Classic; - return cachedVistaState; -} - void QVistaHelper::disconnectBackButton() { if (backButton_) // Leave QStyleSheetStyle's connections on destroyed() intact. @@ -224,18 +164,16 @@ QColor QVistaHelper::basicWindowFrameColor() bool QVistaHelper::setDWMTitleBar(TitleBarChangeType type) { - bool value = false; - if (vistaState() == VistaAero) { - MARGINS mar = {0, 0, 0, 0}; - if (type == NormalTitleBar) - mar.cyTopHeight = 0; - else - mar.cyTopHeight = (titleBarSize() + topOffset(wizard)) * QVistaHelper::m_devicePixelRatio; - if (const HWND wizardHandle = wizardHWND()) - if (SUCCEEDED(DwmExtendFrameIntoClientArea(wizardHandle, &mar))) - value = true; + MARGINS mar = {0, 0, 0, 0}; + if (type == NormalTitleBar) + mar.cyTopHeight = 0; + else + mar.cyTopHeight = (titleBarSize() + topOffset(wizard)) * QVistaHelper::m_devicePixelRatio; + if (const HWND wizardHandle = wizardHWND()) { + if (SUCCEEDED(DwmExtendFrameIntoClientArea(wizardHandle, &mar))) + return true; } - return value; + return false; } Q_GUI_EXPORT HICON qt_pixmapToWinHICON(const QPixmap &); @@ -271,7 +209,7 @@ void QVistaHelper::drawTitleBar(QPainter *painter) const bool isWindow = wizard->isWindow(); const HDC hdc = QVistaHelper::backingStoreDC(wizard, &origin); - if (vistaState() == VistaAero && isWindow) + if (isWindow) drawBlackRect(QRect(0, 0, wizard->width(), titleBarSize() + topOffset(wizard)), hdc); // The button is positioned in QWizardPrivate::handleAeroStyleChange(), @@ -286,15 +224,9 @@ void QVistaHelper::drawTitleBar(QPainter *painter) font = QApplication::font("QMdiSubWindowTitleBar"); const QFontMetrics fontMetrics(font); const QRect brect = fontMetrics.boundingRect(text); - int textHeight = brect.height(); - int textWidth = brect.width(); - int glowOffset = 0; - - if (vistaState() == VistaAero) { - glowOffset = glowSize(wizard); - textHeight += 2 * glowOffset; - textWidth += 2 * glowOffset; - } + const int glowOffset = glowSize(wizard); + int textHeight = brect.height() + 2 * glowOffset; + int textWidth = brect.width() + 2 * glowOffset; const int titleLeft = (wizard->layoutDirection() == Qt::LeftToRight ? titleOffset() - glowOffset @@ -401,11 +333,8 @@ void QVistaHelper::mouseEvent(QEvent *event) bool QVistaHelper::handleWinEvent(MSG *message, qintptr *result) { - if (message->message == WM_THEMECHANGED || message->message == WM_DWMCOMPOSITIONCHANGED) - cachedVistaState = Dirty; - bool status = false; - if (wizard->wizardStyle() == QWizard::AeroStyle && vistaState() == VistaAero) { + if (wizard->wizardStyle() == QWizard::AeroStyle) { status = winEvent(message, result); if (message->message == WM_NCPAINT) wizard->update(); @@ -418,8 +347,6 @@ void QVistaHelper::resizeEvent(QResizeEvent * event) Q_UNUSED(event); rtTop = QRect (0, 0, wizard->width(), frameSize()); int height = captionSize() + topOffset(wizard); - if (vistaState() == VistaBasic) - height -= titleBarSize(); rtTitle = QRect (0, frameSize(), wizard->width(), height); } @@ -458,7 +385,7 @@ void QVistaHelper::mouseMoveEvent(QMouseEvent *event) } wizard->setGeometry(rect); - } else if (vistaState() == VistaAero) { + } else { setMouseCursor(event->pos()); } event->ignore(); @@ -476,11 +403,10 @@ void QVistaHelper::mousePressEvent(QMouseEvent *event) if (rtTitle.contains(event->pos())) { change = movePosition; } else if (rtTop.contains(event->pos())) - change = (vistaState() == VistaAero) ? resizeTop : movePosition; + change = resizeTop; if (change != noChange) { - if (vistaState() == VistaAero) - setMouseCursor(event->pos()); + setMouseCursor(event->pos()); pressed = true; pressedPos = event->pos(); } else { @@ -494,8 +420,7 @@ void QVistaHelper::mouseReleaseEvent(QMouseEvent *event) if (pressed) { pressed = false; wizard->releaseMouse(); - if (vistaState() == VistaAero) - setMouseCursor(event->pos()); + setMouseCursor(event->pos()); } event->ignore(); } @@ -583,112 +508,88 @@ HWND QVistaHelper::wizardHWND() const return 0; } -bool QVistaHelper::drawTitleText(QPainter *painter, const QString &text, const QRect &rect, HDC hdc) +void QVistaHelper::drawTitleText(QPainter *painter, const QString &text, const QRect &rect, HDC hdc) { - bool value = false; - if (vistaState() == VistaAero) { - const QRect rectDp = QRect(rect.topLeft() * QVistaHelper::m_devicePixelRatio, - rect.size() * QVistaHelper::m_devicePixelRatio); - const HANDLE hTheme = OpenThemeData(GetDesktopWindow(), L"WINDOW"); - if (!hTheme) return false; - // Set up a memory DC and bitmap that we'll draw into - HDC dcMem; - HBITMAP bmp; - BITMAPINFO dib; - ZeroMemory(&dib, sizeof(dib)); - dcMem = CreateCompatibleDC(hdc); - - dib.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); - dib.bmiHeader.biWidth = rectDp.width(); - dib.bmiHeader.biHeight = -rectDp.height(); - dib.bmiHeader.biPlanes = 1; - dib.bmiHeader.biBitCount = 32; - dib.bmiHeader.biCompression = BI_RGB; - - bmp = CreateDIBSection(hdc, &dib, DIB_RGB_COLORS, NULL, NULL, 0); - - // Set up the DC - const LOGFONT captionLogFont = getCaptionLogFont(hTheme); - const HFONT hCaptionFont = CreateFontIndirect(&captionLogFont); - auto hOldBmp = reinterpret_cast<HBITMAP>(SelectObject(dcMem, (HGDIOBJ) bmp)); - auto hOldFont = reinterpret_cast<HFONT>(SelectObject(dcMem, (HGDIOBJ) hCaptionFont)); - - // Draw the text! - DTTOPTS dto; - memset(&dto, 0, sizeof(dto)); - dto.dwSize = sizeof(dto); - const UINT uFormat = DT_SINGLELINE|DT_CENTER|DT_VCENTER|DT_NOPREFIX; - RECT rctext ={0,0, rectDp.width(), rectDp.height()}; - - dto.dwFlags = DTT_COMPOSITED|DTT_GLOWSIZE; - dto.iGlowSize = glowSize(wizard); - - DrawThemeTextEx(hTheme, dcMem, 0, 0, reinterpret_cast<LPCWSTR>(text.utf16()), -1, uFormat, &rctext, &dto ); - BitBlt(hdc, rectDp.left(), rectDp.top(), rectDp.width(), rectDp.height(), dcMem, 0, 0, SRCCOPY); - SelectObject(dcMem, (HGDIOBJ) hOldBmp); - SelectObject(dcMem, (HGDIOBJ) hOldFont); - DeleteObject(bmp); - DeleteObject(hCaptionFont); - DeleteDC(dcMem); - //ReleaseDC(hwnd, hdc); - } else if (vistaState() == VistaBasic) { - painter->drawText(rect, text); - } - return value; -} + Q_UNUSED(painter); -bool QVistaHelper::drawBlackRect(const QRect &rect, HDC hdc) -{ - bool value = false; - if (vistaState() == VistaAero) { - // Set up a memory DC and bitmap that we'll draw into - const QRect rectDp = QRect(rect.topLeft() * QVistaHelper::m_devicePixelRatio, + const QRect rectDp = QRect(rect.topLeft() * QVistaHelper::m_devicePixelRatio, + rect.size() * QVistaHelper::m_devicePixelRatio); + const HANDLE hTheme = OpenThemeData(GetDesktopWindow(), L"WINDOW"); + if (!hTheme) + return; + // Set up a memory DC and bitmap that we'll draw into + HDC dcMem; + HBITMAP bmp; + BITMAPINFO dib; + ZeroMemory(&dib, sizeof(dib)); + dcMem = CreateCompatibleDC(hdc); + + dib.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); + dib.bmiHeader.biWidth = rectDp.width(); + dib.bmiHeader.biHeight = -rectDp.height(); + dib.bmiHeader.biPlanes = 1; + dib.bmiHeader.biBitCount = 32; + dib.bmiHeader.biCompression = BI_RGB; + + bmp = CreateDIBSection(hdc, &dib, DIB_RGB_COLORS, NULL, NULL, 0); + + // Set up the DC + const LOGFONT captionLogFont = getCaptionLogFont(hTheme); + const HFONT hCaptionFont = CreateFontIndirect(&captionLogFont); + auto hOldBmp = reinterpret_cast<HBITMAP>(SelectObject(dcMem, (HGDIOBJ) bmp)); + auto hOldFont = reinterpret_cast<HFONT>(SelectObject(dcMem, (HGDIOBJ) hCaptionFont)); + + // Draw the text! + DTTOPTS dto; + memset(&dto, 0, sizeof(dto)); + dto.dwSize = sizeof(dto); + const UINT uFormat = DT_SINGLELINE|DT_CENTER|DT_VCENTER|DT_NOPREFIX; + RECT rctext ={0,0, rectDp.width(), rectDp.height()}; + + dto.dwFlags = DTT_COMPOSITED|DTT_GLOWSIZE; + dto.iGlowSize = glowSize(wizard); + + DrawThemeTextEx(hTheme, dcMem, 0, 0, reinterpret_cast<LPCWSTR>(text.utf16()), -1, uFormat, &rctext, &dto ); + BitBlt(hdc, rectDp.left(), rectDp.top(), rectDp.width(), rectDp.height(), dcMem, 0, 0, SRCCOPY); + SelectObject(dcMem, (HGDIOBJ) hOldBmp); + SelectObject(dcMem, (HGDIOBJ) hOldFont); + DeleteObject(bmp); + DeleteObject(hCaptionFont); + DeleteDC(dcMem); + //ReleaseDC(hwnd, hdc); +} + +void QVistaHelper::drawBlackRect(const QRect &rect, HDC hdc) +{ + // Set up a memory DC and bitmap that we'll draw into + const QRect rectDp = QRect(rect.topLeft() * QVistaHelper::m_devicePixelRatio, rect.size() * QVistaHelper::m_devicePixelRatio); - HDC dcMem; - HBITMAP bmp; - BITMAPINFO dib; - ZeroMemory(&dib, sizeof(dib)); - dcMem = CreateCompatibleDC(hdc); - - dib.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); - dib.bmiHeader.biWidth = rectDp.width(); - dib.bmiHeader.biHeight = -rectDp.height(); - dib.bmiHeader.biPlanes = 1; - dib.bmiHeader.biBitCount = 32; - dib.bmiHeader.biCompression = BI_RGB; - - bmp = CreateDIBSection(hdc, &dib, DIB_RGB_COLORS, NULL, NULL, 0); - auto hOldBmp = reinterpret_cast<HBITMAP>(SelectObject(dcMem, (HGDIOBJ) bmp)); - - BitBlt(hdc, rectDp.left(), rectDp.top(), rectDp.width(), rectDp.height(), dcMem, 0, 0, SRCCOPY); - SelectObject(dcMem, (HGDIOBJ) hOldBmp); - - DeleteObject(bmp); - DeleteDC(dcMem); - } - return value; -} + HDC dcMem; + HBITMAP bmp; + BITMAPINFO dib; + ZeroMemory(&dib, sizeof(dib)); + dcMem = CreateCompatibleDC(hdc); -#ifndef Q_CC_MSVC -static inline int getWindowBottomMargin() -{ - return GetSystemMetrics(SM_CYSIZEFRAME); -} -#else -// QTBUG-36192, GetSystemMetrics(SM_CYSIZEFRAME) returns bogus values -// for MSVC2012 which leads to the custom margin having no effect since -// that only works when removing the entire margin. -static inline int getWindowBottomMargin() -{ - RECT rect = {0, 0, 0, 0}; - AdjustWindowRectEx(&rect, WS_POPUP | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_THICKFRAME | WS_DLGFRAME, FALSE, 0); - return qAbs(rect.bottom); + dib.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); + dib.bmiHeader.biWidth = rectDp.width(); + dib.bmiHeader.biHeight = -rectDp.height(); + dib.bmiHeader.biPlanes = 1; + dib.bmiHeader.biBitCount = 32; + dib.bmiHeader.biCompression = BI_RGB; + + bmp = CreateDIBSection(hdc, &dib, DIB_RGB_COLORS, NULL, NULL, 0); + auto hOldBmp = reinterpret_cast<HBITMAP>(SelectObject(dcMem, (HGDIOBJ) bmp)); + + BitBlt(hdc, rectDp.left(), rectDp.top(), rectDp.width(), rectDp.height(), dcMem, 0, 0, SRCCOPY); + SelectObject(dcMem, (HGDIOBJ) hOldBmp); + + DeleteObject(bmp); + DeleteDC(dcMem); } -#endif // Q_CC_MSVC int QVistaHelper::frameSizeDp() { - return getWindowBottomMargin(); + return GetSystemMetrics(SM_CYSIZEFRAME); } int QVistaHelper::captionSizeDp() @@ -714,8 +615,6 @@ int QVistaHelper::glowSize(const QPaintDevice *device) int QVistaHelper::topOffset(const QPaintDevice *device) { - if (vistaState() != VistaAero) - return titleBarSize() + 3; static const int aeroOffset = QStyleHelper::dpiScaled(13, device); return aeroOffset + titleBarSize(); } diff --git a/src/widgets/dialogs/qwizard_win_p.h b/src/widgets/dialogs/qwizard_win_p.h index a8799e4b86..45f26a1ebf 100644 --- a/src/widgets/dialogs/qwizard_win_p.h +++ b/src/widgets/dialogs/qwizard_win_p.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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 Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QWIZARD_WIN_P_H #define QWIZARD_WIN_P_H @@ -100,8 +64,6 @@ public: void disconnectBackButton(); void hideBackButton() { if (backButton_) backButton_->hide(); } QColor basicWindowFrameColor(); - enum VistaState { VistaAero, VistaBasic, Classic, Dirty }; - static VistaState vistaState(); static int titleBarSize() { return QVistaHelper::titleBarSizeDp() / QVistaHelper::m_devicePixelRatio; } static int titleBarSizeDp() { return QVistaHelper::frameSizeDp() + QVistaHelper::captionSizeDp(); } static int topPadding(const QPaintDevice *device) { // padding under text @@ -113,8 +75,8 @@ public: private: HWND wizardHWND() const; - bool drawTitleText(QPainter *painter, const QString &text, const QRect &rect, HDC hdc); - static bool drawBlackRect(const QRect &rect, HDC hdc); + void drawTitleText(QPainter *painter, const QString &text, const QRect &rect, HDC hdc); + static void drawBlackRect(const QRect &rect, HDC hdc); static int frameSize() { return QVistaHelper::frameSizeDp() / QVistaHelper::m_devicePixelRatio; } static int frameSizeDp(); @@ -138,10 +100,6 @@ private: void mouseReleaseEvent(QMouseEvent *event); bool eventFilter(QObject *obj, QEvent *event) override; - static int instanceCount; - static VistaState cachedVistaState; - static bool isCompositionEnabled(); - static bool isThemeActive(); enum Changes { resizeTop, movePosition, noChange } change; QPoint pressedPos; bool pressed; diff --git a/src/widgets/doc/images/msgbox1.png b/src/widgets/doc/images/msgbox1.png Binary files differindex 1380e20a5f..ded1d295b6 100644 --- a/src/widgets/doc/images/msgbox1.png +++ b/src/widgets/doc/images/msgbox1.png diff --git a/src/widgets/doc/images/msgbox2.png b/src/widgets/doc/images/msgbox2.png Binary files differindex e7946996e4..9afd3282f3 100644 --- a/src/widgets/doc/images/msgbox2.png +++ b/src/widgets/doc/images/msgbox2.png diff --git a/src/widgets/doc/images/msgbox3.png b/src/widgets/doc/images/msgbox3.png Binary files differindex bd81f4d4da..50a4a124c4 100644 --- a/src/widgets/doc/images/msgbox3.png +++ b/src/widgets/doc/images/msgbox3.png diff --git a/src/widgets/doc/images/msgbox4.png b/src/widgets/doc/images/msgbox4.png Binary files differindex dbe6701cdd..337b3553e9 100644 --- a/src/widgets/doc/images/msgbox4.png +++ b/src/widgets/doc/images/msgbox4.png diff --git a/src/widgets/doc/qtwidgets.qdocconf b/src/widgets/doc/qtwidgets.qdocconf index 4659478c38..a63a2f5f2d 100644 --- a/src/widgets/doc/qtwidgets.qdocconf +++ b/src/widgets/doc/qtwidgets.qdocconf @@ -26,7 +26,7 @@ qhp.QtWidgets.subprojects.classes.sortPages = true tagfile = ../../../doc/qtwidgets/qtwidgets.tags -depends += qtcore qtgui qtdoc qtsql qtdesigner qtquick qmake qtcmake qtsvg qtlinguist +depends += qtcore qtgui qtdoc qtsql qtdesigner qtquick qmake qtcmake qtsvg qtlinguist qthelp headerdirs += .. @@ -61,3 +61,6 @@ imagedirs += images \ navigation.landingpage = "Qt Widgets" navigation.cppclassespage = "Qt Widgets C++ Classes" manifestmeta.highlighted.names = "QtWidgets/Qt Widgets - Application Example" + +# Fail the documentation build if there are more warnings than the limit +warninglimit = 0 diff --git a/src/widgets/doc/snippets/CMakeLists.txt b/src/widgets/doc/snippets/CMakeLists.txt index ebf9b38dc2..b1a89e1f66 100644 --- a/src/widgets/doc/snippets/CMakeLists.txt +++ b/src/widgets/doc/snippets/CMakeLists.txt @@ -1,4 +1,7 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + #! [cmake_use] -find_package(Qt6 COMPONENTS Widgets REQUIRED) +find_package(Qt6 REQUIRED COMPONENTS Widgets) target_link_libraries(mytarget PRIVATE Qt6::Widgets) #! [cmake_use] diff --git a/src/widgets/doc/snippets/cmake-macros/examples.cmake b/src/widgets/doc/snippets/cmake-macros/examples.cmake index e1f9f6a277..d18f2fffb8 100644 --- a/src/widgets/doc/snippets/cmake-macros/examples.cmake +++ b/src/widgets/doc/snippets/cmake-macros/examples.cmake @@ -1,3 +1,6 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + #! [qt_wrap_ui] set(SOURCES mainwindow.cpp main.cpp) qt_wrap_ui(SOURCES mainwindow.ui) diff --git a/src/widgets/doc/snippets/code/doc_src_layout.cpp b/src/widgets/doc/snippets/code/doc_src_layout.cpp index 3cf5ffbef4..816a59725a 100644 --- a/src/widgets/doc/snippets/code/doc_src_layout.cpp +++ b/src/widgets/doc/snippets/code/doc_src_layout.cpp @@ -1,52 +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: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 //! [0] #ifndef CARD_H diff --git a/src/widgets/doc/snippets/code/doc_src_model-view-programming.cpp b/src/widgets/doc/snippets/code/doc_src_model-view-programming.cpp index 74d235e344..f63578f66e 100644 --- a/src/widgets/doc/snippets/code/doc_src_model-view-programming.cpp +++ b/src/widgets/doc/snippets/code/doc_src_model-view-programming.cpp @@ -1,52 +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: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 //! [0] QAbstractItemModel *model = index.model(); diff --git a/src/widgets/doc/snippets/code/doc_src_qt4-mainwindow.cpp b/src/widgets/doc/snippets/code/doc_src_qt4-mainwindow.cpp index 133acf657a..7ac3577648 100644 --- a/src/widgets/doc/snippets/code/doc_src_qt4-mainwindow.cpp +++ b/src/widgets/doc/snippets/code/doc_src_qt4-mainwindow.cpp @@ -1,52 +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: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 //! [0] MainWindow::MainWindow(QWidget *parent) diff --git a/src/widgets/doc/snippets/code/doc_src_qt4-styles.cpp b/src/widgets/doc/snippets/code/doc_src_qt4-styles.cpp index e288b66b86..3620c261a5 100644 --- a/src/widgets/doc/snippets/code/doc_src_qt4-styles.cpp +++ b/src/widgets/doc/snippets/code/doc_src_qt4-styles.cpp @@ -1,52 +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: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 //! [0] const QStyleOptionFocusRect *focusRectOption = diff --git a/src/widgets/doc/snippets/code/doc_src_styles.cpp b/src/widgets/doc/snippets/code/doc_src_styles.cpp index 3536be6e7b..72382217a2 100644 --- a/src/widgets/doc/snippets/code/doc_src_styles.cpp +++ b/src/widgets/doc/snippets/code/doc_src_styles.cpp @@ -1,52 +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: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 //! [0] opt.initFrom(q); diff --git a/src/widgets/doc/snippets/code/doc_src_stylesheet.cpp b/src/widgets/doc/snippets/code/doc_src_stylesheet.cpp index 749d62a588..91851f8f07 100644 --- a/src/widgets/doc/snippets/code/doc_src_stylesheet.cpp +++ b/src/widgets/doc/snippets/code/doc_src_stylesheet.cpp @@ -1,52 +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: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 //! [21] qApp->setStyleSheet("QPushButton { color: white }"); @@ -98,7 +51,7 @@ qApp->setStyleSheet("ns--MyPushButton { background: yellow; }"); void CustomWidget::paintEvent(QPaintEvent *) { QStyleOption opt; - opt.init(this); + opt.initFrom(this); QPainter p(this); style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this); } diff --git a/src/widgets/doc/snippets/code/doc_src_stylesheet.qdoc b/src/widgets/doc/snippets/code/doc_src_stylesheet.qdoc index b0d042566f..d505040590 100644 --- a/src/widgets/doc/snippets/code/doc_src_stylesheet.qdoc +++ b/src/widgets/doc/snippets/code/doc_src_stylesheet.qdoc @@ -1,52 +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: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 //! [0] QLineEdit { background: yellow } @@ -1896,3 +1849,6 @@ QTableView::indicator:unchecked { * { widget-animation-duration: 100 } //! [162] +//! [163] +QLineEdit { placeholder-text-color: #800000ff } /* semi-transparent blue */ +//! [163] diff --git a/src/widgets/doc/snippets/code/src_gui_dialogs_qfiledialog.cpp b/src/widgets/doc/snippets/code/src_gui_dialogs_qfiledialog.cpp index ed6043564b..197c23f247 100644 --- a/src/widgets/doc/snippets/code/src_gui_dialogs_qfiledialog.cpp +++ b/src/widgets/doc/snippets/code/src_gui_dialogs_qfiledialog.cpp @@ -1,52 +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: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 //! [0] fileName = QFileDialog::getOpenFileName(this, @@ -157,5 +110,7 @@ QFileDialog::getOpenFileContent("Images (*.png *.xpm *.jpg)", fileContentReady) //! [16] QByteArray imageData; // obtained from e.g. QImage::save() -QFileDialog::saveFile("myimage.png", imageData); +QFileDialog::saveFileContent(imageData, "myimage.png"); // with filename hint +// OR +QFileDialog::saveFileContent(imageData); // no filename hint //! [16] diff --git a/src/widgets/doc/snippets/code/src_gui_dialogs_qfontdialog.cpp b/src/widgets/doc/snippets/code/src_gui_dialogs_qfontdialog.cpp index 2c13131ae6..ae6b69cbe8 100644 --- a/src/widgets/doc/snippets/code/src_gui_dialogs_qfontdialog.cpp +++ b/src/widgets/doc/snippets/code/src_gui_dialogs_qfontdialog.cpp @@ -1,52 +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: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 //! [0] bool ok; diff --git a/src/widgets/doc/snippets/code/src_gui_dialogs_qmessagebox.cpp b/src/widgets/doc/snippets/code/src_gui_dialogs_qmessagebox.cpp index 82f916581e..014a9dfeb0 100644 --- a/src/widgets/doc/snippets/code/src_gui_dialogs_qmessagebox.cpp +++ b/src/widgets/doc/snippets/code/src_gui_dialogs_qmessagebox.cpp @@ -1,52 +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: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 //! [0] int ret = QMessageBox::warning(this, tr("My Application"), diff --git a/src/widgets/doc/snippets/code/src_gui_dialogs_qwizard.cpp b/src/widgets/doc/snippets/code/src_gui_dialogs_qwizard.cpp index 1274827799..328b99e108 100644 --- a/src/widgets/doc/snippets/code/src_gui_dialogs_qwizard.cpp +++ b/src/widgets/doc/snippets/code/src_gui_dialogs_qwizard.cpp @@ -1,52 +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: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 //! [0] int LicenseWizard::nextId() const diff --git a/src/widgets/doc/snippets/code/src_gui_effects_qgraphicseffect.cpp b/src/widgets/doc/snippets/code/src_gui_effects_qgraphicseffect.cpp index 60d7cc1d71..3fd61f5c72 100644 --- a/src/widgets/doc/snippets/code/src_gui_effects_qgraphicseffect.cpp +++ b/src/widgets/doc/snippets/code/src_gui_effects_qgraphicseffect.cpp @@ -1,52 +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: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 //! [0] MyGraphicsOpacityEffect::draw(QPainter *painter) diff --git a/src/widgets/doc/snippets/code/src_gui_graphicsview_qgraphicsgridlayout.cpp b/src/widgets/doc/snippets/code/src_gui_graphicsview_qgraphicsgridlayout.cpp index 9f64299190..3b46c54bad 100644 --- a/src/widgets/doc/snippets/code/src_gui_graphicsview_qgraphicsgridlayout.cpp +++ b/src/widgets/doc/snippets/code/src_gui_graphicsview_qgraphicsgridlayout.cpp @@ -1,63 +1,15 @@ -/**************************************************************************** -** -** 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: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 //! [0] QGraphicsScene scene; QGraphicsWidget *textEdit = scene.addWidget(new QTextEdit); QGraphicsWidget *pushButton = scene.addWidget(new QPushButton); -QGraphicsGridLayout *layout = new QGraphicsGridLayout; -layout->addItem(textEdit, 0, 0); -layout->addItem(pushButton, 0, 1); - QGraphicsWidget *form = new QGraphicsWidget; -form->setLayout(layout); scene.addItem(form); + +QGraphicsGridLayout *layout = new QGraphicsGridLayout(form); +layout->addItem(textEdit, 0, 0); +layout->addItem(pushButton, 0, 1); //! [0] diff --git a/src/widgets/doc/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp b/src/widgets/doc/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp index ebca9d5368..e9e8b95847 100644 --- a/src/widgets/doc/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp +++ b/src/widgets/doc/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp @@ -1,52 +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: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 //! [0] class SimpleItem : public QGraphicsItem diff --git a/src/widgets/doc/snippets/code/src_gui_graphicsview_qgraphicslinearlayout.cpp b/src/widgets/doc/snippets/code/src_gui_graphicsview_qgraphicslinearlayout.cpp index 22a283675b..cc3b1678d0 100644 --- a/src/widgets/doc/snippets/code/src_gui_graphicsview_qgraphicslinearlayout.cpp +++ b/src/widgets/doc/snippets/code/src_gui_graphicsview_qgraphicslinearlayout.cpp @@ -1,63 +1,15 @@ -/**************************************************************************** -** -** 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: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 //! [0] QGraphicsScene scene; QGraphicsWidget *textEdit = scene.addWidget(new QTextEdit); QGraphicsWidget *pushButton = scene.addWidget(new QPushButton); -QGraphicsLinearLayout *layout = new QGraphicsLinearLayout; -layout->addItem(textEdit); -layout->addItem(pushButton); - QGraphicsWidget *form = new QGraphicsWidget; -form->setLayout(layout); scene.addItem(form); + +QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(form); +layout->addItem(textEdit); +layout->addItem(pushButton); //! [0] diff --git a/src/widgets/doc/snippets/code/src_gui_graphicsview_qgraphicsproxywidget.cpp b/src/widgets/doc/snippets/code/src_gui_graphicsview_qgraphicsproxywidget.cpp index 52f452112b..b8cb7b493c 100644 --- a/src/widgets/doc/snippets/code/src_gui_graphicsview_qgraphicsproxywidget.cpp +++ b/src/widgets/doc/snippets/code/src_gui_graphicsview_qgraphicsproxywidget.cpp @@ -1,52 +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: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 //! [0] int main(int argc, char **argv) @@ -70,9 +23,8 @@ QGroupBox *groupBox = new QGroupBox("Contact Details"); QLabel *numberLabel = new QLabel("Telephone number"); QLineEdit *numberEdit = new QLineEdit; -QFormLayout *layout = new QFormLayout; +QFormLayout *layout = new QFormLayout(groupBox); layout->addRow(numberLabel, numberEdit); -groupBox->setLayout(layout); QGraphicsScene scene; QGraphicsProxyWidget *proxy = scene.addWidget(groupBox); diff --git a/src/widgets/doc/snippets/code/src_gui_graphicsview_qgraphicsscene.cpp b/src/widgets/doc/snippets/code/src_gui_graphicsview_qgraphicsscene.cpp index f052435b06..d80271cfe2 100644 --- a/src/widgets/doc/snippets/code/src_gui_graphicsview_qgraphicsscene.cpp +++ b/src/widgets/doc/snippets/code/src_gui_graphicsview_qgraphicsscene.cpp @@ -1,52 +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: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 //! [0] QGraphicsScene scene; diff --git a/src/widgets/doc/snippets/code/src_gui_graphicsview_qgraphicssceneevent.cpp b/src/widgets/doc/snippets/code/src_gui_graphicsview_qgraphicssceneevent.cpp index d508a95f1e..7ddcf5938a 100644 --- a/src/widgets/doc/snippets/code/src_gui_graphicsview_qgraphicssceneevent.cpp +++ b/src/widgets/doc/snippets/code/src_gui_graphicsview_qgraphicssceneevent.cpp @@ -1,52 +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: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 //! [0] diff --git a/src/widgets/doc/snippets/code/src_gui_graphicsview_qgraphicsview.cpp b/src/widgets/doc/snippets/code/src_gui_graphicsview_qgraphicsview.cpp index 35cb6b2168..9f48c4e06b 100644 --- a/src/widgets/doc/snippets/code/src_gui_graphicsview_qgraphicsview.cpp +++ b/src/widgets/doc/snippets/code/src_gui_graphicsview_qgraphicsview.cpp @@ -1,52 +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: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 //! [0] QGraphicsScene scene; diff --git a/src/widgets/doc/snippets/code/src_gui_graphicsview_qgraphicswidget.cpp b/src/widgets/doc/snippets/code/src_gui_graphicsview_qgraphicswidget.cpp index e078e87844..58ef7a33de 100644 --- a/src/widgets/doc/snippets/code/src_gui_graphicsview_qgraphicswidget.cpp +++ b/src/widgets/doc/snippets/code/src_gui_graphicsview_qgraphicswidget.cpp @@ -1,52 +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: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 //! [0] void MyGroupBoxWidget::initStyleOption(QStyleOption *option) const diff --git a/src/widgets/doc/snippets/code/src_gui_image_qpixmapfilter.cpp b/src/widgets/doc/snippets/code/src_gui_image_qpixmapfilter.cpp index 183b091927..386daa2a0c 100644 --- a/src/widgets/doc/snippets/code/src_gui_image_qpixmapfilter.cpp +++ b/src/widgets/doc/snippets/code/src_gui_image_qpixmapfilter.cpp @@ -1,52 +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: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 //! [0] QPixmapColorizeFilter *myFilter = new QPixmapColorFilter; diff --git a/src/widgets/doc/snippets/code/src_gui_itemviews_qabstractitemview.cpp b/src/widgets/doc/snippets/code/src_gui_itemviews_qabstractitemview.cpp index a650bf81e8..e260476e3f 100644 --- a/src/widgets/doc/snippets/code/src_gui_itemviews_qabstractitemview.cpp +++ b/src/widgets/doc/snippets/code/src_gui_itemviews_qabstractitemview.cpp @@ -1,52 +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: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 //! [0] void MyView::resizeEvent(QResizeEvent *event) { diff --git a/src/widgets/doc/snippets/code/src_gui_itemviews_qdatawidgetmapper.cpp b/src/widgets/doc/snippets/code/src_gui_itemviews_qdatawidgetmapper.cpp index cc1568cb9d..c9b9193b2a 100644 --- a/src/widgets/doc/snippets/code/src_gui_itemviews_qdatawidgetmapper.cpp +++ b/src/widgets/doc/snippets/code/src_gui_itemviews_qdatawidgetmapper.cpp @@ -1,52 +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: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 //! [0] QDataWidgetMapper *mapper = new QDataWidgetMapper; diff --git a/src/widgets/doc/snippets/code/src_gui_itemviews_qitemeditorfactory.cpp b/src/widgets/doc/snippets/code/src_gui_itemviews_qitemeditorfactory.cpp index 30ba269ce6..d314c88fd9 100644 --- a/src/widgets/doc/snippets/code/src_gui_itemviews_qitemeditorfactory.cpp +++ b/src/widgets/doc/snippets/code/src_gui_itemviews_qitemeditorfactory.cpp @@ -1,52 +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: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 //! [0] Q_PROPERTY(QColor color READ color WRITE setColor USER true) diff --git a/src/widgets/doc/snippets/code/src_gui_itemviews_qtablewidget.cpp b/src/widgets/doc/snippets/code/src_gui_itemviews_qtablewidget.cpp index c40152ff49..6be31be6d8 100644 --- a/src/widgets/doc/snippets/code/src_gui_itemviews_qtablewidget.cpp +++ b/src/widgets/doc/snippets/code/src_gui_itemviews_qtablewidget.cpp @@ -1,52 +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: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 //! [0] setCellWidget(row, column, new QLineEdit); diff --git a/src/widgets/doc/snippets/code/src_gui_itemviews_qtreewidget.cpp b/src/widgets/doc/snippets/code/src_gui_itemviews_qtreewidget.cpp index f1e3b6ea45..55136f1d37 100644 --- a/src/widgets/doc/snippets/code/src_gui_itemviews_qtreewidget.cpp +++ b/src/widgets/doc/snippets/code/src_gui_itemviews_qtreewidget.cpp @@ -1,52 +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: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 //! [0] QTreeWidget *treeWidget = new QTreeWidget(); diff --git a/src/widgets/doc/snippets/code/src_gui_kernel_qapplication.cpp b/src/widgets/doc/snippets/code/src_gui_kernel_qapplication.cpp index a7bce6d378..a31e720fb1 100644 --- a/src/widgets/doc/snippets/code/src_gui_kernel_qapplication.cpp +++ b/src/widgets/doc/snippets/code/src_gui_kernel_qapplication.cpp @@ -1,52 +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: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 //! [0] QCoreApplication* createApplication(int &argc, char *argv[]) diff --git a/src/widgets/doc/snippets/code/src_gui_kernel_qformlayout.cpp b/src/widgets/doc/snippets/code/src_gui_kernel_qformlayout.cpp index a2ac780a82..ab20b9da2e 100644 --- a/src/widgets/doc/snippets/code/src_gui_kernel_qformlayout.cpp +++ b/src/widgets/doc/snippets/code/src_gui_kernel_qformlayout.cpp @@ -1,63 +1,17 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE: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 //! [0] -QFormLayout *formLayout = new QFormLayout; +QFormLayout *formLayout = new QFormLayout(this); formLayout->addRow(tr("&Name:"), nameLineEdit); formLayout->addRow(tr("&Email:"), emailLineEdit); formLayout->addRow(tr("&Age:"), ageSpinBox); -setLayout(formLayout); //! [0] //! [1] +QGridLayout *gridLayout = new QGridLayout(this); + nameLabel = new QLabel(tr("&Name:")); nameLabel->setBuddy(nameLineEdit); @@ -67,14 +21,12 @@ emailLabel->setBuddy(emailLineEdit); ageLabel = new QLabel(tr("&Name:")); ageLabel->setBuddy(ageSpinBox); -QGridLayout *gridLayout = new QGridLayout; gridLayout->addWidget(nameLabel, 0, 0); gridLayout->addWidget(nameLineEdit, 0, 1); gridLayout->addWidget(emailLabel, 1, 0); gridLayout->addWidget(emailLineEdit, 1, 1); gridLayout->addWidget(ageLabel, 2, 0); gridLayout->addWidget(ageSpinBox, 2, 1); -setLayout(gridLayout); //! [1] diff --git a/src/widgets/doc/snippets/code/src_gui_kernel_qlayout.cpp b/src/widgets/doc/snippets/code/src_gui_kernel_qlayout.cpp index c55834ebfb..60b669a228 100644 --- a/src/widgets/doc/snippets/code/src_gui_kernel_qlayout.cpp +++ b/src/widgets/doc/snippets/code/src_gui_kernel_qlayout.cpp @@ -1,52 +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: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 //! [0] static void paintLayout(QPainter *painter, QLayoutItem *item) diff --git a/src/widgets/doc/snippets/code/src_gui_kernel_qlayoutitem.cpp b/src/widgets/doc/snippets/code/src_gui_kernel_qlayoutitem.cpp index dd0f860c01..fe857d1047 100644 --- a/src/widgets/doc/snippets/code/src_gui_kernel_qlayoutitem.cpp +++ b/src/widgets/doc/snippets/code/src_gui_kernel_qlayoutitem.cpp @@ -1,52 +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: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 //! [0] int MyLayout::heightForWidth(int w) const diff --git a/src/widgets/doc/snippets/code/src_gui_kernel_qwidget.cpp b/src/widgets/doc/snippets/code/src_gui_kernel_qwidget.cpp index f2db73226b..8f0c296873 100644 --- a/src/widgets/doc/snippets/code/src_gui_kernel_qwidget.cpp +++ b/src/widgets/doc/snippets/code/src_gui_kernel_qwidget.cpp @@ -1,52 +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: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 //! [0] w->setWindowState(w->windowState() ^ Qt::WindowFullScreen); diff --git a/src/widgets/doc/snippets/code/src_gui_painting_qdrawutil.cpp b/src/widgets/doc/snippets/code/src_gui_painting_qdrawutil.cpp index 6f39086c8d..75af4fcc62 100644 --- a/src/widgets/doc/snippets/code/src_gui_painting_qdrawutil.cpp +++ b/src/widgets/doc/snippets/code/src_gui_painting_qdrawutil.cpp @@ -1,52 +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: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 //! [0] QFrame frame: diff --git a/src/widgets/doc/snippets/code/src_gui_qproxystyle.cpp b/src/widgets/doc/snippets/code/src_gui_qproxystyle.cpp index 636a0f52a8..a2f3e4d8f9 100644 --- a/src/widgets/doc/snippets/code/src_gui_qproxystyle.cpp +++ b/src/widgets/doc/snippets/code/src_gui_qproxystyle.cpp @@ -1,52 +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: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 //! [1] #include "textedit.h" diff --git a/src/widgets/doc/snippets/code/src_gui_styles_qstyle.cpp b/src/widgets/doc/snippets/code/src_gui_styles_qstyle.cpp index bb3f62969a..d4b8a45b36 100644 --- a/src/widgets/doc/snippets/code/src_gui_styles_qstyle.cpp +++ b/src/widgets/doc/snippets/code/src_gui_styles_qstyle.cpp @@ -1,52 +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: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 //! [0] ./myapplication -style windows diff --git a/src/widgets/doc/snippets/code/src_gui_styles_qstyleoption.cpp b/src/widgets/doc/snippets/code/src_gui_styles_qstyleoption.cpp index 26f9ace28d..44cb0b35eb 100644 --- a/src/widgets/doc/snippets/code/src_gui_styles_qstyleoption.cpp +++ b/src/widgets/doc/snippets/code/src_gui_styles_qstyleoption.cpp @@ -1,52 +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: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 //! [0] int MyStyle::styleHint(StyleHint stylehint, const QStyleOption *opt, diff --git a/src/widgets/doc/snippets/code/src_gui_util_qcompleter.cpp b/src/widgets/doc/snippets/code/src_gui_util_qcompleter.cpp index 7d003e4886..4c95c05b26 100644 --- a/src/widgets/doc/snippets/code/src_gui_util_qcompleter.cpp +++ b/src/widgets/doc/snippets/code/src_gui_util_qcompleter.cpp @@ -1,52 +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: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 //! [0] QStringList wordList; diff --git a/src/widgets/doc/snippets/code/src_gui_widgets_qabstractbutton.cpp b/src/widgets/doc/snippets/code/src_gui_widgets_qabstractbutton.cpp index bc171824af..099f0708ec 100644 --- a/src/widgets/doc/snippets/code/src_gui_widgets_qabstractbutton.cpp +++ b/src/widgets/doc/snippets/code/src_gui_widgets_qabstractbutton.cpp @@ -1,52 +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: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 //! [0] QPushButton *button = new QPushButton(tr("Ro&ck && Roll"), this); diff --git a/src/widgets/doc/snippets/code/src_gui_widgets_qabstractspinbox.cpp b/src/widgets/doc/snippets/code/src_gui_widgets_qabstractspinbox.cpp index c8a4c29f91..bb5badea38 100644 --- a/src/widgets/doc/snippets/code/src_gui_widgets_qabstractspinbox.cpp +++ b/src/widgets/doc/snippets/code/src_gui_widgets_qabstractspinbox.cpp @@ -1,52 +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: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 //! [0] QSpinBox *spinBox = new QSpinBox(this); diff --git a/src/widgets/doc/snippets/code/src_gui_widgets_qcalendarwidget.cpp b/src/widgets/doc/snippets/code/src_gui_widgets_qcalendarwidget.cpp index 763a5cb1fb..712a84ac2a 100644 --- a/src/widgets/doc/snippets/code/src_gui_widgets_qcalendarwidget.cpp +++ b/src/widgets/doc/snippets/code/src_gui_widgets_qcalendarwidget.cpp @@ -1,52 +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: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 //! [0] QCalendarWidget *calendar; diff --git a/src/widgets/doc/snippets/code/src_gui_widgets_qcheckbox.cpp b/src/widgets/doc/snippets/code/src_gui_widgets_qcheckbox.cpp index e076cada9a..c62f73dfca 100644 --- a/src/widgets/doc/snippets/code/src_gui_widgets_qcheckbox.cpp +++ b/src/widgets/doc/snippets/code/src_gui_widgets_qcheckbox.cpp @@ -1,52 +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: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 //! [0] QCheckBox *checkbox = new QCheckBox("C&ase sensitive", this); diff --git a/src/widgets/doc/snippets/code/src_gui_widgets_qdatetimeedit.cpp b/src/widgets/doc/snippets/code/src_gui_widgets_qdatetimeedit.cpp index 085acc422a..c70a3017b3 100644 --- a/src/widgets/doc/snippets/code/src_gui_widgets_qdatetimeedit.cpp +++ b/src/widgets/doc/snippets/code/src_gui_widgets_qdatetimeedit.cpp @@ -1,52 +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: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 //! [0] QDateTimeEdit *dateEdit = new QDateTimeEdit(QDate::currentDate()); diff --git a/src/widgets/doc/snippets/code/src_gui_widgets_qdockwidget.cpp b/src/widgets/doc/snippets/code/src_gui_widgets_qdockwidget.cpp index bf3c549cb6..99fff8bdeb 100644 --- a/src/widgets/doc/snippets/code/src_gui_widgets_qdockwidget.cpp +++ b/src/widgets/doc/snippets/code/src_gui_widgets_qdockwidget.cpp @@ -1,52 +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: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 //! [0] QDockWidget *dockWidget = qobject_cast<QDockWidget*>(parentWidget()); diff --git a/src/widgets/doc/snippets/code/src_gui_widgets_qframe.cpp b/src/widgets/doc/snippets/code/src_gui_widgets_qframe.cpp index ec01bc0d81..0aac71ff4a 100644 --- a/src/widgets/doc/snippets/code/src_gui_widgets_qframe.cpp +++ b/src/widgets/doc/snippets/code/src_gui_widgets_qframe.cpp @@ -1,52 +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: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 //! [0] QLabel label(...); diff --git a/src/widgets/doc/snippets/code/src_gui_widgets_qgroupbox.cpp b/src/widgets/doc/snippets/code/src_gui_widgets_qgroupbox.cpp index e1f707672e..1298147de1 100644 --- a/src/widgets/doc/snippets/code/src_gui_widgets_qgroupbox.cpp +++ b/src/widgets/doc/snippets/code/src_gui_widgets_qgroupbox.cpp @@ -1,52 +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: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 //! [0] g->setTitle("&User information"); diff --git a/src/widgets/doc/snippets/code/src_gui_widgets_qlabel.cpp b/src/widgets/doc/snippets/code/src_gui_widgets_qlabel.cpp index 9f3ca992bf..5e4cc64198 100644 --- a/src/widgets/doc/snippets/code/src_gui_widgets_qlabel.cpp +++ b/src/widgets/doc/snippets/code/src_gui_widgets_qlabel.cpp @@ -1,52 +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: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 //! [0] QLabel *label = new QLabel(this); diff --git a/src/widgets/doc/snippets/code/src_gui_widgets_qlineedit.cpp b/src/widgets/doc/snippets/code/src_gui_widgets_qlineedit.cpp index 5b293e6533..5017678af4 100644 --- a/src/widgets/doc/snippets/code/src_gui_widgets_qlineedit.cpp +++ b/src/widgets/doc/snippets/code/src_gui_widgets_qlineedit.cpp @@ -1,52 +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: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 //! [0] void LineEdit::contextMenuEvent(QContextMenuEvent *event) diff --git a/src/widgets/doc/snippets/code/src_gui_widgets_qmainwindow.cpp b/src/widgets/doc/snippets/code/src_gui_widgets_qmainwindow.cpp index 7bff9ce8d9..878daffcf7 100644 --- a/src/widgets/doc/snippets/code/src_gui_widgets_qmainwindow.cpp +++ b/src/widgets/doc/snippets/code/src_gui_widgets_qmainwindow.cpp @@ -1,52 +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: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 //! [0] void MyMainWindow::closeEvent(QCloseEvent *event) diff --git a/src/widgets/doc/snippets/code/src_gui_widgets_qmenu.cpp b/src/widgets/doc/snippets/code/src_gui_widgets_qmenu.cpp index da3fd28056..b0b0500fab 100644 --- a/src/widgets/doc/snippets/code/src_gui_widgets_qmenu.cpp +++ b/src/widgets/doc/snippets/code/src_gui_widgets_qmenu.cpp @@ -1,52 +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: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 //! [0] exec(QCursor::pos()); @@ -81,7 +34,7 @@ exec(e->globalPos()); //! [6] QMenu menu; QAction *at = actions[0]; // Assumes actions is not empty -for (QAction *a : qAsConst(actions)) +for (QAction *a : std::as_const(actions)) menu.addAction(a); menu.exec(pos, at); //! [6] diff --git a/src/widgets/doc/snippets/code/src_gui_widgets_qmenubar.cpp b/src/widgets/doc/snippets/code/src_gui_widgets_qmenubar.cpp index b52b0064ad..d096336cf7 100644 --- a/src/widgets/doc/snippets/code/src_gui_widgets_qmenubar.cpp +++ b/src/widgets/doc/snippets/code/src_gui_widgets_qmenubar.cpp @@ -1,52 +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: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 //! [0] menubar->addMenu(fileMenu); diff --git a/src/widgets/doc/snippets/code/src_gui_widgets_qplaintextedit.cpp b/src/widgets/doc/snippets/code/src_gui_widgets_qplaintextedit.cpp index 4f86f2ae31..f0593aa6de 100644 --- a/src/widgets/doc/snippets/code/src_gui_widgets_qplaintextedit.cpp +++ b/src/widgets/doc/snippets/code/src_gui_widgets_qplaintextedit.cpp @@ -1,52 +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: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 //! [0] void MyQPlainTextEdit::contextMenuEvent(QContextMenuEvent *event) diff --git a/src/widgets/doc/snippets/code/src_gui_widgets_qpushbutton.cpp b/src/widgets/doc/snippets/code/src_gui_widgets_qpushbutton.cpp index a64d085ba2..35827bcba2 100644 --- a/src/widgets/doc/snippets/code/src_gui_widgets_qpushbutton.cpp +++ b/src/widgets/doc/snippets/code/src_gui_widgets_qpushbutton.cpp @@ -1,52 +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: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 //! [0] QPushButton *button = new QPushButton("&Download", this); diff --git a/src/widgets/doc/snippets/code/src_gui_widgets_qradiobutton.cpp b/src/widgets/doc/snippets/code/src_gui_widgets_qradiobutton.cpp index 85ba1c300a..96d0fe018b 100644 --- a/src/widgets/doc/snippets/code/src_gui_widgets_qradiobutton.cpp +++ b/src/widgets/doc/snippets/code/src_gui_widgets_qradiobutton.cpp @@ -1,52 +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: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 //! [0] QRadioButton *button = new QRadioButton("Search from the &cursor", this); diff --git a/src/widgets/doc/snippets/code/src_gui_widgets_qrubberband.cpp b/src/widgets/doc/snippets/code/src_gui_widgets_qrubberband.cpp index c63d675b35..e6f6ab0c0a 100644 --- a/src/widgets/doc/snippets/code/src_gui_widgets_qrubberband.cpp +++ b/src/widgets/doc/snippets/code/src_gui_widgets_qrubberband.cpp @@ -1,52 +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: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 //! [0] void Widget::mousePressEvent(QMouseEvent *event) diff --git a/src/widgets/doc/snippets/code/src_gui_widgets_qscrollarea.cpp b/src/widgets/doc/snippets/code/src_gui_widgets_qscrollarea.cpp index 328b5fbd57..b05258883a 100644 --- a/src/widgets/doc/snippets/code/src_gui_widgets_qscrollarea.cpp +++ b/src/widgets/doc/snippets/code/src_gui_widgets_qscrollarea.cpp @@ -1,52 +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: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 //! [0] QLabel *imageLabel = new QLabel; diff --git a/src/widgets/doc/snippets/code/src_gui_widgets_qspinbox.cpp b/src/widgets/doc/snippets/code/src_gui_widgets_qspinbox.cpp index aab9bee62a..d660d605a1 100644 --- a/src/widgets/doc/snippets/code/src_gui_widgets_qspinbox.cpp +++ b/src/widgets/doc/snippets/code/src_gui_widgets_qspinbox.cpp @@ -1,52 +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: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 //! [0] sb->setPrefix("$"); diff --git a/src/widgets/doc/snippets/code/src_gui_widgets_qsplashscreen.cpp b/src/widgets/doc/snippets/code/src_gui_widgets_qsplashscreen.cpp index 91aa8a9c4e..fa7d25da4d 100644 --- a/src/widgets/doc/snippets/code/src_gui_widgets_qsplashscreen.cpp +++ b/src/widgets/doc/snippets/code/src_gui_widgets_qsplashscreen.cpp @@ -1,52 +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: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 //! [0] QPixmap pixmap(":/splash.png"); diff --git a/src/widgets/doc/snippets/code/src_gui_widgets_qsplitter.cpp b/src/widgets/doc/snippets/code/src_gui_widgets_qsplitter.cpp index 3e30b38521..cab65b35f3 100644 --- a/src/widgets/doc/snippets/code/src_gui_widgets_qsplitter.cpp +++ b/src/widgets/doc/snippets/code/src_gui_widgets_qsplitter.cpp @@ -1,52 +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: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 //! [0] QWidget *widget = splitter->widget(index); diff --git a/src/widgets/doc/snippets/code/src_gui_widgets_qstatusbar.cpp b/src/widgets/doc/snippets/code/src_gui_widgets_qstatusbar.cpp index 1f8edacff4..8f5db27c9f 100644 --- a/src/widgets/doc/snippets/code/src_gui_widgets_qstatusbar.cpp +++ b/src/widgets/doc/snippets/code/src_gui_widgets_qstatusbar.cpp @@ -1,52 +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: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 //! [0] statusBar()->addWidget(new MyReadWriteIndication); diff --git a/src/widgets/doc/snippets/code/src_gui_widgets_qtextbrowser.cpp b/src/widgets/doc/snippets/code/src_gui_widgets_qtextbrowser.cpp index 2c17a0761b..96faf13299 100644 --- a/src/widgets/doc/snippets/code/src_gui_widgets_qtextbrowser.cpp +++ b/src/widgets/doc/snippets/code/src_gui_widgets_qtextbrowser.cpp @@ -1,52 +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: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 //! [0] backaction.setToolTip(browser.historyTitle(-1)); diff --git a/src/widgets/doc/snippets/code/src_gui_widgets_qtextedit.cpp b/src/widgets/doc/snippets/code/src_gui_widgets_qtextedit.cpp index cace028c68..4ee48a545d 100644 --- a/src/widgets/doc/snippets/code/src_gui_widgets_qtextedit.cpp +++ b/src/widgets/doc/snippets/code/src_gui_widgets_qtextedit.cpp @@ -1,52 +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: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 //! [0] void MyTextEdit::contextMenuEvent(QContextMenuEvent *event) diff --git a/src/widgets/doc/snippets/code/src_widgets_util_qscroller.cpp b/src/widgets/doc/snippets/code/src_widgets_util_qscroller.cpp index 2b3d825266..03e2a710a4 100644 --- a/src/widgets/doc/snippets/code/src_widgets_util_qscroller.cpp +++ b/src/widgets/doc/snippets/code/src_widgets_util_qscroller.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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 Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2018 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only //! [0] QWidget *w = ...; diff --git a/src/widgets/doc/snippets/code/src_widgets_widgets_qmainwindow.cpp b/src/widgets/doc/snippets/code/src_widgets_widgets_qmainwindow.cpp index 8ebaaf3991..f9f9c6c338 100644 --- a/src/widgets/doc/snippets/code/src_widgets_widgets_qmainwindow.cpp +++ b/src/widgets/doc/snippets/code/src_widgets_widgets_qmainwindow.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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 Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2018 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only //! [0] void MainWindow::createMenus() diff --git a/src/widgets/doc/snippets/common-table-model/model.cpp b/src/widgets/doc/snippets/common-table-model/model.cpp index 2f6e9f1144..5dcec124bb 100644 --- a/src/widgets/doc/snippets/common-table-model/model.cpp +++ b/src/widgets/doc/snippets/common-table-model/model.cpp @@ -1,52 +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: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 /* model.cpp diff --git a/src/widgets/doc/snippets/common-table-model/model.h b/src/widgets/doc/snippets/common-table-model/model.h index 5f152e0e78..cc994bd8e1 100644 --- a/src/widgets/doc/snippets/common-table-model/model.h +++ b/src/widgets/doc/snippets/common-table-model/model.h @@ -1,52 +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: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 MODEL_H #define MODEL_H diff --git a/src/widgets/doc/snippets/customstyle/customstyle.cpp b/src/widgets/doc/snippets/customstyle/customstyle.cpp index 0f1d5f4b9b..74de2705be 100644 --- a/src/widgets/doc/snippets/customstyle/customstyle.cpp +++ b/src/widgets/doc/snippets/customstyle/customstyle.cpp @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** Copyright ( |