~ubuntu-branches/ubuntu/raring/virtualbox-ose/raring

« back to all changes in this revision

Viewing changes to src/VBox/Frontends/VirtualBox/src/VBoxAboutDlg.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Felix Geyer
  • Date: 2011-01-30 23:27:25 UTC
  • mfrom: (0.3.12 upstream)
  • Revision ID: james.westby@ubuntu.com-20110130232725-2ouajjd2ggdet0zd
Tags: 4.0.2-dfsg-1ubuntu1
* Merge from Debian unstable, remaining changes:
  - Add Apport hook.
    - debian/virtualbox-ose.files/source_virtualbox-ose.py
    - debian/virtualbox-ose.install
  - Drop *-source packages.
* Drop ubuntu-01-fix-build-gcc45.patch, fixed upstream.
* Drop ubuntu-02-as-needed.patch, added to the Debian package.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* $Id: VBoxAboutDlg.cpp $ */
 
1
/* $Id: VBoxAboutDlg.cpp 34781 2010-12-07 14:06:16Z vboxsync $ */
2
2
/** @file
3
3
 *
4
4
 * VBox frontends: Qt GUI ("VirtualBox"):
6
6
 */
7
7
 
8
8
/*
9
 
 * Copyright (C) 2006-2009 Oracle Corporation
 
9
 * Copyright (C) 2006-2010 Oracle Corporation
10
10
 *
11
11
 * This file is part of VirtualBox Open Source Edition (OSE), as
12
12
 * available from http://www.virtualbox.org. This file is free software;
20
20
#ifdef VBOX_WITH_PRECOMPILED_HEADERS
21
21
# include "precomp.h"
22
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>
 
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
33
#endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
34
34
 
35
 
VBoxAboutDlg::VBoxAboutDlg (QWidget* aParent, const QString &aVersion)
36
 
    : QIWithRetranslateUI2 <QIDialog> (aParent, Qt::CustomizeWindowHint |
37
 
                                       Qt::WindowTitleHint | Qt::WindowSystemMenuHint),
38
 
    mVersion (aVersion)
 
35
VBoxAboutDlg::VBoxAboutDlg(QWidget *pParent, const QString &strVersion)
 
36
    : QIWithRetranslateUI2<QIDialog>(pParent, Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowSystemMenuHint)
 
37
    , m_strVersion(strVersion)
39
38
{
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())
 
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())
46
48
    {
47
49
        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;
 
50
        RTPathExecDir(szExecPath, 1024);
 
51
        QString strTmpPath = QString("%1/%2").arg(szExecPath).arg(strSplash);
 
52
        if (QFile::exists(strTmpPath))
 
53
            strPath = strTmpPath;
52
54
    }
53
55
 
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);
 
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();
62
100
}
63
101
 
64
102
void VBoxAboutDlg::retranslateUi()
65
103
{
66
 
    setWindowTitle (tr ("VirtualBox - About"));
67
 
    QString aboutText =  tr ("VirtualBox Graphical User Interface");
 
104
    setWindowTitle(tr("VirtualBox - About"));
 
105
    QString strAboutText =  tr("VirtualBox Graphical User Interface");
68
106
#ifdef VBOX_BLEEDING_EDGE
69
 
    QString versionText = "EXPERIMENTAL build %1 - " + QString(VBOX_BLEEDING_EDGE);
 
107
    QString strVersionText = "EXPERIMENTAL build %1 - " + QString(VBOX_BLEEDING_EDGE);
70
108
#else
71
 
    QString versionText = tr ("Version %1");
 
109
    QString strVersionText = tr("Version %1");
72
110
#endif
73
111
#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();
 
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 */
110
117
}
111
118