diff options
Diffstat (limited to 'src/widgets/kernel/qwhatsthis.cpp')
-rw-r--r-- | src/widgets/kernel/qwhatsthis.cpp | 70 |
1 files changed, 12 insertions, 58 deletions
diff --git a/src/widgets/kernel/qwhatsthis.cpp b/src/widgets/kernel/qwhatsthis.cpp index 7ca50f9dab..c80f37267f 100644 --- a/src/widgets/kernel/qwhatsthis.cpp +++ b/src/widgets/kernel/qwhatsthis.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 "qwhatsthis.h" #include "qpointer.h" @@ -56,7 +20,7 @@ #include <qpa/qplatformtheme.h> #include "private/qtextdocumentlayout_p.h" #include "qdebug.h" -#ifndef QT_NO_ACCESSIBILITY +#if QT_CONFIG(accessibility) #include "qaccessible.h" #endif @@ -133,8 +97,6 @@ QT_BEGIN_NAMESPACE \sa QToolTip */ -Q_CORE_EXPORT void qDeleteInEventHandler(QObject *o); - class QWhatsThat : public QWidget { Q_OBJECT @@ -146,7 +108,6 @@ public: static QWhatsThat *instance; protected: - void showEvent(QShowEvent *e) override; void mousePressEvent(QMouseEvent*) override; void mouseReleaseEvent(QMouseEvent*) override; void mouseMoveEvent(QMouseEvent*) override; @@ -159,7 +120,6 @@ private: QString text; QTextDocument* doc; QString anchor; - QPixmap background; }; QWhatsThat *QWhatsThat::instance = nullptr; @@ -218,8 +178,8 @@ QWhatsThat::QWhatsThat(const QString& txt, QWidget* parent, QWidget *showTextFor sw = 300; r = fontMetrics().boundingRect(0, 0, sw, 1000, - Qt::AlignLeft + Qt::AlignTop - + Qt::TextWordWrap + Qt::TextExpandTabs, + Qt::AlignLeft | Qt::AlignTop + | Qt::TextWordWrap | Qt::TextExpandTabs, text); } shadowWidth = dropShadow() ? 0 : 6; @@ -233,11 +193,6 @@ QWhatsThat::~QWhatsThat() delete doc; } -void QWhatsThat::showEvent(QShowEvent *) -{ - background = QGuiApplication::primaryScreen()->grabWindow(0, x(), y(), width(), height()); -} - void QWhatsThat::mousePressEvent(QMouseEvent* e) { pressed = true; @@ -297,7 +252,6 @@ void QWhatsThat::paintEvent(QPaintEvent*) if (drawShadow) r.adjust(0, 0, -shadowWidth, -shadowWidth); QPainter p(this); - p.drawPixmap(0, 0, background); p.setPen(QPen(palette().toolTipText(), 0)); p.setBrush(palette().toolTipBase()); p.drawRect(r); @@ -333,7 +287,7 @@ void QWhatsThat::paintEvent(QPaintEvent*) } else { - p.drawText(r, Qt::AlignLeft + Qt::AlignTop + Qt::TextWordWrap + Qt::TextExpandTabs, text); + p.drawText(r, Qt::AlignLeft | Qt::AlignTop | Qt::TextWordWrap | Qt::TextExpandTabs, text); } } @@ -402,7 +356,7 @@ QWhatsThisPrivate::QWhatsThisPrivate() QGuiApplication::setOverrideCursor(Qt::WhatsThisCursor); #endif } -#ifndef QT_NO_ACCESSIBILITY +#if QT_CONFIG(accessibility) QAccessibleEvent event(this, QAccessible::ContextHelpStart); QAccessible::updateAccessibility(&event); #endif @@ -417,7 +371,7 @@ QWhatsThisPrivate::~QWhatsThisPrivate() #ifndef QT_NO_CURSOR QGuiApplication::restoreOverrideCursor(); #endif -#ifndef QT_NO_ACCESSIBILITY +#if QT_CONFIG(accessibility) QAccessibleEvent event(this, QAccessible::ContextHelpEnd); QAccessible::updateAccessibility(&event); #endif @@ -464,7 +418,7 @@ bool QWhatsThisPrivate::eventFilter(QObject *o, QEvent *e) break; case QEvent::KeyPress: { - QKeyEvent* kev = (QKeyEvent*)e; + QKeyEvent *kev = static_cast<QKeyEvent *>(e); #if QT_CONFIG(shortcut) if (kev->matches(QKeySequence::Cancel)) { QWhatsThis::leaveWhatsThisMode(); @@ -508,9 +462,9 @@ QWhatsThisAction::QWhatsThisAction(QObject *parent) : QAction(tr("What's This?") setIcon(p); #endif setCheckable(true); - connect(this, SIGNAL(triggered()), this, SLOT(actionTriggered())); + connect(this, &QWhatsThisAction::triggered, this, &QWhatsThisAction::actionTriggered); #ifndef QT_NO_SHORTCUT - setShortcut(Qt::ShiftModifier + Qt::Key_F1); + setShortcut(Qt::ShiftModifier | Qt::Key_F1); #endif } @@ -654,7 +608,7 @@ void QWhatsThis::showText(const QPoint &pos, const QString &text, QWidget *w) */ void QWhatsThis::hideText() { - qDeleteInEventHandler(QWhatsThat::instance); + delete QWhatsThat::instance; } /*! |