1 | /* $Id: VBoxAboutDlg.cpp 37762 2011-07-04 12:55:46Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | *
|
---|
4 | * VBox frontends: Qt GUI ("VirtualBox"):
|
---|
5 | * VBoxAboutDlg class implementation
|
---|
6 | */
|
---|
7 |
|
---|
8 | /*
|
---|
9 | * Copyright (C) 2006-2010 Oracle Corporation
|
---|
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 |
|
---|
20 | #ifdef VBOX_WITH_PRECOMPILED_HEADERS
|
---|
21 | # include "precomp.h"
|
---|
22 | #else /* !VBOX_WITH_PRECOMPILED_HEADERS */
|
---|
23 | /* Global includes */
|
---|
24 | # include <QDir>
|
---|
25 | # include <QEvent>
|
---|
26 | # include <QPainter>
|
---|
27 | # include <iprt/path.h>
|
---|
28 | # include <VBox/version.h> /* VBOX_VENDOR */
|
---|
29 |
|
---|
30 | /* Local includes */
|
---|
31 | # include "VBoxAboutDlg.h"
|
---|
32 | # include "VBoxGlobal.h"
|
---|
33 | #endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
|
---|
34 |
|
---|
35 | VBoxAboutDlg::VBoxAboutDlg(QWidget *pParent, const QString &strVersion)
|
---|
36 | : QIWithRetranslateUI2<QIDialog>(pParent, Qt::CustomizeWindowHint | Qt::WindowTitleHint)
|
---|
37 | , m_strVersion(strVersion)
|
---|
38 | {
|
---|
39 | /* Delete dialog on close: */
|
---|
40 | setAttribute(Qt::WA_DeleteOnClose);
|
---|
41 |
|
---|
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())
|
---|
48 | {
|
---|
49 | char szExecPath[1024];
|
---|
50 | RTPathExecDir(szExecPath, 1024);
|
---|
51 | QString strTmpPath = QString("%1/%2").arg(szExecPath).arg(strSplash);
|
---|
52 | if (QFile::exists(strTmpPath))
|
---|
53 | strPath = strTmpPath;
|
---|
54 | }
|
---|
55 |
|
---|
56 | /* Assign image: */
|
---|
57 | m_bgImage.load(strPath);
|
---|
58 |
|
---|
59 | /* Translate: */
|
---|
60 | retranslateUi();
|
---|
61 | }
|
---|
62 |
|
---|
63 | bool VBoxAboutDlg::event(QEvent *pEvent)
|
---|
64 | {
|
---|
65 | if (pEvent->type() == QEvent::Polish)
|
---|
66 | setFixedSize(m_bgImage.size());
|
---|
67 | if (pEvent->type() == QEvent::WindowDeactivate)
|
---|
68 | close();
|
---|
69 | return QIDialog::event(pEvent);
|
---|
70 | }
|
---|
71 |
|
---|
72 | void VBoxAboutDlg::paintEvent(QPaintEvent* /* pEvent */)
|
---|
73 | {
|
---|
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);
|
---|
85 | #if VBOX_OSE
|
---|
86 | painter.drawText(QRect(0, 400, 600, 32),
|
---|
87 | Qt::AlignCenter | Qt::AlignVCenter | Qt::TextWordWrap,
|
---|
88 | m_strAboutText);
|
---|
89 | #else /* VBOX_OSE */
|
---|
90 | painter.drawText(QRect(271, 370, 360, 72),
|
---|
91 | Qt::AlignLeft | Qt::AlignBottom | Qt::TextWordWrap,
|
---|
92 | m_strAboutText);
|
---|
93 | #endif /* VBOX_OSE */
|
---|
94 | }
|
---|
95 |
|
---|
96 | void VBoxAboutDlg::mouseReleaseEvent(QMouseEvent* /* pEvent */)
|
---|
97 | {
|
---|
98 | /* Close the dialog on mouse button release: */
|
---|
99 | close();
|
---|
100 | }
|
---|
101 |
|
---|
102 | void 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
|
---|
111 | #if VBOX_OSE
|
---|
112 | m_strAboutText = strAboutText + " " + strVersionText.arg(m_strVersion) + "\n" +
|
---|
113 | QString("%1 2004-" VBOX_C_YEAR " " VBOX_VENDOR).arg(QChar(0xa9));
|
---|
114 | #else /* VBOX_OSE */
|
---|
115 | m_strAboutText = strAboutText + "\n" + strVersionText.arg(m_strVersion);
|
---|
116 | #endif /* VBOX_OSE */
|
---|
117 | }
|
---|
118 |
|
---|