VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIMenuBar.cpp@ 100347

Last change on this file since 100347 was 98103, checked in by vboxsync, 21 months ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.0 KB
Line 
1/* $Id: UIMenuBar.cpp 98103 2023-01-17 14:15:46Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - UIMenuBar class implementation.
4 */
5
6/*
7 * Copyright (C) 2010-2023 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * SPDX-License-Identifier: GPL-3.0-only
26 */
27
28/* Qt includes: */
29#include <QPainter>
30#include <QPaintEvent>
31#include <QPixmapCache>
32
33/* GUI includes: */
34#include "UICommon.h"
35#include "UIDesktopWidgetWatchdog.h"
36#include "UIImageTools.h"
37#include "UIMenuBar.h"
38
39
40UIMenuBar::UIMenuBar(QWidget *pParent /* = 0 */)
41 : QMenuBar(pParent)
42 , m_fShowBetaLabel(false)
43{
44 /* Check for beta versions: */
45 if (uiCommon().showBetaLabel())
46 m_fShowBetaLabel = true;
47}
48
49void UIMenuBar::paintEvent(QPaintEvent *pEvent)
50{
51 /* Call to base-class: */
52 QMenuBar::paintEvent(pEvent);
53
54 /* Draw BETA label if necessary: */
55 if (m_fShowBetaLabel)
56 {
57 QPixmap betaLabel;
58 const QString key("vbox:betaLabel");
59 if (!QPixmapCache::find(key, &betaLabel))
60 {
61 betaLabel = ::betaLabel(QSize(80, 16), this);
62 QPixmapCache::insert(key, betaLabel);
63 }
64 QSize s = size();
65 QPainter painter(this);
66 painter.setClipRect(pEvent->rect());
67 const double dDpr = UIDesktopWidgetWatchdog::devicePixelRatio(this);
68 painter.drawPixmap(s.width() - betaLabel.width() / dDpr - 10, (height() - betaLabel.height() / dDpr) / 2, betaLabel);
69 }
70}
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette