VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/VBoxAboutDlg.cpp@ 35740

Last change on this file since 35740 was 34781, checked in by vboxsync, 13 years ago

FE/Qt4: 5395: Crash if 'about' box is open during VM shutdown - should be fixed, VBoxAboutDlg refactoring.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.7 KB
RevLine 
[26719]1/* $Id: VBoxAboutDlg.cpp 34781 2010-12-07 14:06:16Z vboxsync $ */
[12582]2/** @file
3 *
4 * VBox frontends: Qt GUI ("VirtualBox"):
5 * VBoxAboutDlg class implementation
6 */
7
8/*
[34781]9 * Copyright (C) 2006-2010 Oracle Corporation
[12582]10 *
11 * This file is part of VirtualBox Open Source Edition (OSE), as
12 * available from http://www.virtualbox.org. This file is free software;
13 * you can redistribute it and/or modify it under the terms of the GNU
14 * General Public License (GPL) as published by the Free Software
15 * Foundation, in version 2 as it comes in the "COPYING" file of the
16 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
17 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
18 */
19
[25526]20#ifdef VBOX_WITH_PRECOMPILED_HEADERS
21# include "precomp.h"
22#else /* !VBOX_WITH_PRECOMPILED_HEADERS */
[34781]23/* Global includes */
24# include <QDir>
25# include <QEvent>
26# include <QPainter>
27# include <iprt/path.h>
28# include <VBox/version.h> /* VBOX_VENDOR */
[12582]29
[34781]30/* Local includes */
31# include "VBoxAboutDlg.h"
32# include "VBoxGlobal.h"
[25526]33#endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
[12582]34
[34781]35VBoxAboutDlg::VBoxAboutDlg(QWidget *pParent, const QString &strVersion)
36 : QIWithRetranslateUI2<QIDialog>(pParent, Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowSystemMenuHint)
37 , m_strVersion(strVersion)
[12582]38{
[34781]39 /* Delete dialog on close: */
40 setAttribute(Qt::WA_DeleteOnClose);
[23368]41
[34781]42 /* Choose default image: */
43 QString strPath(":/about.png");
44
45 /* Branding: Use a custom about splash picture if set: */
46 QString strSplash = vboxGlobal().brandingGetKey("UI/AboutSplash");
47 if (vboxGlobal().brandingIsActive() && !strSplash.isEmpty())
[23431]48 {
[23432]49 char szExecPath[1024];
[34781]50 RTPathExecDir(szExecPath, 1024);
51 QString strTmpPath = QString("%1/%2").arg(szExecPath).arg(strSplash);
52 if (QFile::exists(strTmpPath))
53 strPath = strTmpPath;
[23431]54 }
55
[34781]56 /* Assign image: */
57 m_bgImage.load(strPath);
58
59 /* Translate: */
60 retranslateUi();
[12582]61}
62
[34781]63bool VBoxAboutDlg::event(QEvent *pEvent)
[12582]64{
[34781]65 if (pEvent->type() == QEvent::Polish)
66 setFixedSize(m_bgImage.size());
67 if (pEvent->type() == QEvent::WindowDeactivate)
68 close();
69 return QIDialog::event(pEvent);
[12582]70}
71
[34781]72void VBoxAboutDlg::paintEvent(QPaintEvent* /* pEvent */)
[12582]73{
[34781]74 QPainter painter(this);
75 painter.drawPixmap(0, 0, m_bgImage);
76 painter.setFont(font());
77
78 /* Branding: Set a different text color (because splash also could be white),
79 otherwise use white as default color: */
80 QString strColor = vboxGlobal().brandingGetKey("UI/AboutTextColor");
81 if (!strColor.isEmpty())
82 painter.setPen(QColor(strColor).name());
83 else
84 painter.setPen(Qt::black);
[12582]85#if VBOX_OSE
[34781]86 painter.drawText(QRect(0, 400, 600, 32),
87 Qt::AlignCenter | Qt::AlignVCenter | Qt::TextWordWrap,
88 m_strAboutText);
[12582]89#else /* VBOX_OSE */
[34781]90 painter.drawText(QRect(271, 370, 360, 72),
91 Qt::AlignLeft | Qt::AlignBottom | Qt::TextWordWrap,
92 m_strAboutText);
[12582]93#endif /* VBOX_OSE */
94}
95
[34781]96void VBoxAboutDlg::mouseReleaseEvent(QMouseEvent* /* pEvent */)
[12582]97{
[34781]98 /* Close the dialog on mouse button release: */
99 close();
100}
[23368]101
[34781]102void VBoxAboutDlg::retranslateUi()
103{
104 setWindowTitle(tr("VirtualBox - About"));
105 QString strAboutText = tr("VirtualBox Graphical User Interface");
106#ifdef VBOX_BLEEDING_EDGE
107 QString strVersionText = "EXPERIMENTAL build %1 - " + QString(VBOX_BLEEDING_EDGE);
108#else
109 QString strVersionText = tr("Version %1");
110#endif
[12582]111#if VBOX_OSE
[34781]112 m_strAboutText = strAboutText + " " + strVersionText.arg(m_strVersion) + "\n" +
113 QString("%1 2004-" VBOX_C_YEAR " " VBOX_VENDOR).arg(QChar(0xa9));
[12582]114#else /* VBOX_OSE */
[34781]115 m_strAboutText = strAboutText + "\n" + strVersionText.arg(m_strVersion);
[12582]116#endif /* VBOX_OSE */
117}
118
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use