OSDN Git Service

It's 2011 now.
[qt-creator-jp/qt-creator-jp.git] / src / plugins / coreplugin / versiondialog.cpp
1 /**************************************************************************
2 **
3 ** This file is part of Qt Creator
4 **
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
6 **
7 ** Contact: Nokia Corporation (qt-info@nokia.com)
8 **
9 ** No Commercial Usage
10 **
11 ** This file contains pre-release code and may not be distributed.
12 ** You may use this file in accordance with the terms and conditions
13 ** contained in the Technology Preview License Agreement accompanying
14 ** this package.
15 **
16 ** GNU Lesser General Public License Usage
17 **
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file.  Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Nokia gives you certain additional
26 ** rights.  These rights are described in the Nokia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** If you have questions regarding the use of this file, please contact
30 ** Nokia at qt-info@nokia.com.
31 **
32 **************************************************************************/
33
34 #include "versiondialog.h"
35
36 #include "coreconstants.h"
37 #include "icore.h"
38
39 #include <utils/qtcassert.h>
40
41 #include <QtCore/QDate>
42 #include <QtCore/QFile>
43 #include <QtCore/QSysInfo>
44
45 #include <QtGui/QDialogButtonBox>
46 #include <QtGui/QGridLayout>
47 #include <QtGui/QLabel>
48 #include <QtGui/QPushButton>
49 #include <QtGui/QTextBrowser>
50
51 using namespace Core;
52 using namespace Core::Internal;
53 using namespace Core::Constants;
54
55 VersionDialog::VersionDialog(QWidget *parent)
56     : QDialog(parent)
57 {
58     // We need to set the window icon explicitly here since for some reason the
59     // application icon isn't used when the size of the dialog is fixed (at least not on X11/GNOME)
60     setWindowIcon(QIcon(QLatin1String(Constants::ICON_QTLOGO_128)));
61
62     setWindowTitle(tr("About Qt Creator"));
63     setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
64     QGridLayout *layout = new QGridLayout(this);
65     layout->setSizeConstraint(QLayout::SetFixedSize);
66
67     QString version = QLatin1String(IDE_VERSION_LONG);
68
69     QString ideVersionDescription;
70 #ifdef IDE_VERSION_DESCRIPTION
71     ideVersionDescription = tr("(%1)").arg(QLatin1String(IDE_VERSION_DESCRIPTION_STR));
72 #endif
73
74     QString ideRev;
75 #ifdef IDE_REVISION
76      //: This gets conditionally inserted as argument %8 into the description string.
77      ideRev = tr("From revision %1<br/>").arg(QString::fromLatin1(IDE_REVISION_STR).left(10));
78 #endif
79
80      const QString description = tr(
81         "<h3>Qt Creator %1 %8</h3>"
82         "Based on Qt %2 (%3 bit)<br/>"
83         "<br/>"
84         "Built on %4 at %5<br />"
85         "<br/>"
86         "%9"
87         "<br/>"
88         "Copyright 2008-%6 %7. All rights reserved.<br/>"
89         "<br/>"
90         "The program is provided AS IS with NO WARRANTY OF ANY KIND, "
91         "INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A "
92         "PARTICULAR PURPOSE.<br/>")
93         .arg(version, 
94              QLatin1String(QT_VERSION_STR), QString::number(QSysInfo::WordSize),
95              QLatin1String(__DATE__), QLatin1String(__TIME__), QLatin1String(IDE_YEAR),
96              (QLatin1String(IDE_AUTHOR)), ideVersionDescription,
97              ideRev);
98
99     QLabel *copyRightLabel = new QLabel(description);
100     copyRightLabel->setWordWrap(true);
101     copyRightLabel->setOpenExternalLinks(true);
102     copyRightLabel->setTextInteractionFlags(Qt::TextBrowserInteraction);
103
104     QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Close);
105     QPushButton *closeButton = buttonBox->button(QDialogButtonBox::Close);
106     QTC_ASSERT(closeButton, /**/);
107     buttonBox->addButton(closeButton, QDialogButtonBox::ButtonRole(QDialogButtonBox::RejectRole | QDialogButtonBox::AcceptRole));
108     connect(buttonBox , SIGNAL(rejected()), this, SLOT(reject()));
109
110     QLabel *logoLabel = new QLabel;
111     logoLabel->setPixmap(QPixmap(QLatin1String(Constants::ICON_QTLOGO_128)));
112     layout->addWidget(logoLabel , 0, 0, 1, 1);
113     layout->addWidget(copyRightLabel, 0, 1, 4, 4);
114     layout->addWidget(buttonBox, 4, 0, 1, 5);
115 }