diff options
Diffstat (limited to 'src/plugins/platforms/windows/qwindowsmenu.cpp')
-rw-r--r-- | src/plugins/platforms/windows/qwindowsmenu.cpp | 73 |
1 files changed, 14 insertions, 59 deletions
diff --git a/src/plugins/platforms/windows/qwindowsmenu.cpp b/src/plugins/platforms/windows/qwindowsmenu.cpp index d20edd685e..79deeeaea2 100644 --- a/src/plugins/platforms/windows/qwindowsmenu.cpp +++ b/src/plugins/platforms/windows/qwindowsmenu.cpp @@ -1,47 +1,12 @@ -/**************************************************************************** -** -** Copyright (C) 2017 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) 2017 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 "qwindowsmenu.h" #include "qwindowscontext.h" #include "qwindowswindow.h" #include <QtGui/qwindow.h> +#include <QtGui/private/qpixmap_win_p.h> #include <QtCore/qdebug.h> #include <QtCore/qvariant.h> #include <QtCore/qmetaobject.h> @@ -56,7 +21,7 @@ QT_BEGIN_NAMESPACE \brief Windows native menu bar \list - \li \l{https://msdn.microsoft.com/de-de/library/windows/desktop/ms647553(v=vs.85).aspx#_win32_Menu_Creation_Functions}, + \li \l{https://docs.microsoft.com/en-us/windows/win32/menurc/about-menus}, \e{About Menus} \endlist @@ -65,15 +30,14 @@ QT_BEGIN_NAMESPACE Qt Widgets, either the containers or the items might be deleted first. \internal - \ingroup qt-lighthouse-win */ static uint nextId = 1; -// Find a QPlatformMenu[Item]* in a vector of QWindowsMenu[Item], where -// QVector::indexOf() cannot be used since it wants a QWindowsMenu[Item]* +// Find a QPlatformMenu[Item]* in a list of QWindowsMenu[Item], where +// QList::indexOf() cannot be used since it wants a QWindowsMenu[Item]* template <class Derived, class Needle> -static int indexOf(const QVector<Derived *> &v, const Needle *needle) +static int indexOf(const QList<Derived *> &v, const Needle *needle) { for (int i = 0, size = v.size(); i < size; ++i) { if (v.at(i) == needle) @@ -82,9 +46,9 @@ static int indexOf(const QVector<Derived *> &v, const Needle *needle) return -1; } -// Helper for inserting a QPlatformMenu[Item]* into a vector of QWindowsMenu[Item]. +// Helper for inserting a QPlatformMenu[Item]* into a list of QWindowsMenu[Item]. template <class Derived, class Base> -static int insertBefore(QVector<Derived *> *v, Base *newItemIn, const Base *before = nullptr) +static int insertBefore(QList<Derived *> *v, Base *newItemIn, const Base *before = nullptr) { int index = before ? indexOf(*v, before) : -1; if (index != -1) { @@ -176,7 +140,7 @@ static QWindowsMenu *findMenuByHandle(const Menu *menu, HMENU hMenu) } template <class MenuType> -static int findNextVisibleEntry(const QVector<MenuType *> &entries, int pos) +static int findNextVisibleEntry(const QList<MenuType *> &entries, int pos) { for (int i = pos, size = entries.size(); i < size; ++i) { if (entries.at(i)->isVisible()) @@ -266,8 +230,6 @@ void QWindowsMenuItem::setIcon(const QIcon &icon) updateBitmap(); } -Q_GUI_EXPORT HBITMAP qt_pixmapToWinHBITMAP(const QPixmap &p, int hbitmapFormat = 0); - void QWindowsMenuItem::updateBitmap() { freeBitmap(); @@ -445,7 +407,7 @@ QString QWindowsMenuItem::nativeText() const QString result = m_text; #if QT_CONFIG(shortcut) if (!m_shortcut.isEmpty()) { - result += QLatin1Char('\t'); + result += u'\t'; result += m_shortcut.toString(QKeySequence::NativeText); } #endif @@ -794,20 +756,13 @@ QWindowsMenuBar *QWindowsMenuBar::menuBarOf(const QWindow *notYetCreatedWindow) ? qobject_cast<QWindowsMenuBar *>(menuBarV.value<QObject *>()) : nullptr; } -static inline void forceNcCalcSize(HWND hwnd) -{ - // Force WM_NCCALCSIZE to adjust margin: Does not appear to work? - SetWindowPos(hwnd, nullptr, 0, 0, 0, 0, - SWP_FRAMECHANGED | SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_NOOWNERZORDER); -} - void QWindowsMenuBar::install(QWindowsWindow *window) { const HWND hwnd = window->handle(); const BOOL result = SetMenu(hwnd, m_hMenuBar); if (result) { window->setMenuBar(this); - forceNcCalcSize(hwnd); + QWindowsContext::forceNcCalcSize(hwnd); } } @@ -817,7 +772,7 @@ void QWindowsMenuBar::removeFromWindow() const HWND hwnd = window->handle(); SetMenu(hwnd, nullptr); window->setMenuBar(nullptr); - forceNcCalcSize(hwnd); + QWindowsContext::forceNcCalcSize(hwnd); } } @@ -870,7 +825,7 @@ void QWindowsMenuBar::redraw() const #ifndef QT_NO_DEBUG_STREAM template <class M> /* Menu[Item] */ -static void formatTextSequence(QDebug &d, const QVector<M *> &v) +static void formatTextSequence(QDebug &d, const QList<M *> &v) { if (const int size = v.size()) { d << '[' << size << "]("; |