1 | /* $Id: VBoxAboutDlg.cpp 28800 2010-04-27 08:22:32Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | *
|
---|
4 | * VBox frontends: Qt GUI ("VirtualBox"):
|
---|
5 | * VBoxAboutDlg class implementation
|
---|
6 | */
|
---|
7 |
|
---|
8 | /*
|
---|
9 | * Copyright (C) 2006-2009 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 | #include "VBoxAboutDlg.h"
|
---|
24 | #include "VBoxGlobal.h"
|
---|
25 |
|
---|
26 | #include <iprt/path.h>
|
---|
27 | #include <VBox/version.h> /* VBOX_VENDOR */
|
---|
28 |
|
---|
29 | /* Qt includes */
|
---|
30 | #include <QDir>
|
---|
31 | #include <QEvent>
|
---|
32 | #include <QPainter>
|
---|
33 | #endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
|
---|
34 |
|
---|
35 | VBoxAboutDlg::VBoxAboutDlg (QWidget* aParent, const QString &aVersion)
|
---|
36 | : QIWithRetranslateUI2 <QIDialog> (aParent, Qt::CustomizeWindowHint |
|
---|
37 | Qt::WindowTitleHint | Qt::WindowSystemMenuHint),
|
---|
38 | mVersion (aVersion)
|
---|
39 | {
|
---|
40 | retranslateUi();
|
---|
41 |
|
---|
42 | QString sPath (":/about.png");
|
---|
43 | /* Branding: Use a custom about splash picture if set */
|
---|
44 | QString sSplash = vboxGlobal().brandingGetKey ("UI/AboutSplash");
|
---|
45 | if (vboxGlobal().brandingIsActive() && !sSplash.isEmpty())
|
---|
46 | {
|
---|
47 | char szExecPath[1024];
|
---|
48 | RTPathExecDir (szExecPath, 1024);
|
---|
49 | QString tmpPath = QString ("%1/%2").arg (szExecPath).arg (sSplash);
|
---|
50 | if (QFile::exists (tmpPath))
|
---|
51 | sPath = tmpPath;
|
---|
52 | }
|
---|
53 |
|
---|
54 | mBgImage.load (sPath);
|
---|
55 | }
|
---|
56 |
|
---|
57 | bool VBoxAboutDlg::event (QEvent *aEvent)
|
---|
58 | {
|
---|
59 | if (aEvent->type() == QEvent::Polish)
|
---|
60 | setFixedSize (mBgImage.size());
|
---|
61 | return QIDialog::event (aEvent);
|
---|
62 | }
|
---|
63 |
|
---|
64 | void VBoxAboutDlg::retranslateUi()
|
---|
65 | {
|
---|
66 | setWindowTitle (tr ("VirtualBox - About"));
|
---|
67 | QString aboutText = tr ("VirtualBox Graphical User Interface");
|
---|
68 | #ifdef VBOX_BLEEDING_EDGE
|
---|
69 | QString versionText = "EXPERIMENTAL build %1 - " + QString(VBOX_BLEEDING_EDGE);
|
---|
70 | #else
|
---|
71 | QString versionText = tr ("Version %1");
|
---|
72 | #endif
|
---|
73 | #if VBOX_OSE
|
---|
74 | mAboutText = aboutText + " " + versionText.arg (mVersion) + "\n" +
|
---|
75 | QString ("%1 2004-" VBOX_C_YEAR " " VBOX_VENDOR).arg (QChar (0xa9));
|
---|
76 | #else /* VBOX_OSE */
|
---|
77 | mAboutText = aboutText + "\n" +
|
---|
78 | versionText.arg (mVersion);
|
---|
79 | #endif /* VBOX_OSE */
|
---|
80 | }
|
---|
81 |
|
---|
82 | void VBoxAboutDlg::paintEvent (QPaintEvent * /* aEvent */)
|
---|
83 | {
|
---|
84 | QPainter painter (this);
|
---|
85 | painter.drawPixmap (0, 0, mBgImage);
|
---|
86 | painter.setFont (font());
|
---|
87 |
|
---|
88 | /* Branding: Set a different text color (because splash also could be white),
|
---|
89 | otherwise use white as default color */
|
---|
90 | QString sColor = vboxGlobal().brandingGetKey("UI/AboutTextColor");
|
---|
91 | if (!sColor.isEmpty())
|
---|
92 | painter.setPen (QColor(sColor).name());
|
---|
93 | else
|
---|
94 | painter.setPen (Qt::black);
|
---|
95 | #if VBOX_OSE
|
---|
96 | painter.drawText (QRect (0, 400, 600, 32),
|
---|
97 | Qt::AlignCenter | Qt::AlignVCenter | Qt::TextWordWrap,
|
---|
98 | mAboutText);
|
---|
99 | #else /* VBOX_OSE */
|
---|
100 | painter.drawText (QRect (271, 370, 360, 72),
|
---|
101 | Qt::AlignLeft | Qt::AlignBottom | Qt::TextWordWrap,
|
---|
102 | mAboutText);
|
---|
103 | #endif /* VBOX_OSE */
|
---|
104 | }
|
---|
105 |
|
---|
106 | void VBoxAboutDlg::mouseReleaseEvent (QMouseEvent * /* aEvent */)
|
---|
107 | {
|
---|
108 | /* close the dialog on mouse button release */
|
---|
109 | accept();
|
---|
110 | }
|
---|
111 |
|
---|