-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathaboutqtdialog.cpp
More file actions
131 lines (118 loc) · 4.68 KB
/
aboutqtdialog.cpp
File metadata and controls
131 lines (118 loc) · 4.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#include "aboutqtdialog.h"
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QPainter>
#include <QStyleOption>
#include <QKeyEvent>
#include <QPushButton>
#include <utils/customborderstorage.h>
#include <utils/stylestorage.h>
#include <utils/graphicseffectsstorage.h>
#include <utils/widgetmanager.h>
#include <utils/customlabel.h>
#include <definitions/resources.h>
#include <definitions/menuicons.h>
#include <definitions/customborder.h>
#include <definitions/graphicseffects.h>
#include <definitions/stylesheets.h>
#ifdef Q_WS_MAC
# include <utils/macutils.h>
#endif
AboutQtDialog::AboutQtDialog() : QWidget(NULL)
{
setWindowTitle(tr("About Qt"));
StyleStorage::staticStorage(RSR_STORAGE_STYLESHEETS)->insertAutoStyle(this, STS_PLUGINMANAGER_ABOUT_QT);
CustomBorderContainer *border = CustomBorderStorage::staticStorage(RSR_STORAGE_CUSTOMBORDER)->addBorder(this, CBS_DIALOG);
if (border)
{
border->setAttribute(Qt::WA_DeleteOnClose, true);
border->setResizable(false);
border->setMinimizeButtonVisible(false);
border->setMaximizeButtonVisible(false);
}
else
{
setAttribute(Qt::WA_DeleteOnClose, true);
setWindowFlags(Qt::Dialog | Qt::WindowTitleHint);
}
#ifdef Q_WS_MAC
setWindowGrowButtonEnabled(this->window(), false);
#endif
// creating layouts and items
// main layout
setLayout(new QVBoxLayout(this));
layout()->setContentsMargins(8, 18, 8, 6);
layout()->setSpacing(14);
// text and icon layout
QHBoxLayout * textLayout = new QHBoxLayout;
textLayout->setSpacing(6);
CustomLabel * icon = new CustomLabel(this);
IconStorage::staticStorage(RSR_STORAGE_MENUICONS)->insertAutoIcon(icon, MNI_PLUGINMANAGER_ABOUT_QT, 0, 0, "pixmap");
icon->setAlignment(Qt::AlignHCenter | Qt::AlignTop);
icon->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::MinimumExpanding);
textLayout->addWidget(icon);
QVBoxLayout * captLayout = new QVBoxLayout;
captLayout->setSpacing(8);
CustomLabel * caption = new CustomLabel(this);
caption->setObjectName("caption");
caption->setText(tr("About Qt"));
CustomLabel * text = new CustomLabel(this);
text->setTextFormat(Qt::RichText);
text->setWordWrap(true);
text->setMaximumWidth(350);
text->setOpenExternalLinks(true);
text->setObjectName("lblAboutQtText");
GraphicsEffectsStorage::staticStorage(RSR_STORAGE_GRAPHICSEFFECTS)->installGraphicsEffect(text, GFX_LABELS);
QString localizedText = tr("<p>This program uses Qt version %1.</p>"
"<p>Qt is a C++ toolkit for cross-platform application "
"development.</p>"
"<p>Qt provides single-source portability across MS Windows, "
"Mac OS X, Linux, and all major commercial Unix variants. "
"Qt is also available for embedded devices as Qt for Embedded Linux "
"and Qt for Windows CE.</p>"
"<p>Qt licensed under the GNU LGPL version 2.1 is appropriate for the "
"development of Qt applications (proprietary or open source) provided "
"you can comply with the terms and conditions of the GNU LGPL version "
"2.1.</p>"
"<p>Please see <a href=\"http://qt.nokia.com/products/licensing\">qt.nokia.com/products/licensing</a> "
"for an overview of Qt licensing.</p>"
"<p>Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).</p>"
"<p>Qt is a Nokia product. See <a href=\"http://qt.nokia.com/\">qt.nokia.com</a> "
"for more information.</p>").arg(QLatin1String(QT_VERSION_STR));
// adding shadow (it's a rich text)
text->setText(localizedText);
captLayout->addWidget(caption);
captLayout->addWidget(text);
textLayout->addItem(captLayout);
// button layout
QHBoxLayout * buttonLayout = new QHBoxLayout;
buttonLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding));
QPushButton * okButton = new QPushButton(this);
okButton->setDefault(true);
okButton->setAutoDefault(false);
okButton->setText(tr("OK"));
connect(okButton, SIGNAL(clicked()), (parentWidget() ? parentWidget() : this), SLOT(close()));
buttonLayout->addWidget(okButton);
layout()->addItem(textLayout);
layout()->addItem(buttonLayout);
}
void AboutQtDialog::paintEvent(QPaintEvent * pe)
{
QStyleOption opt;
opt.init(this);
QPainter p(this);
p.setClipRect(pe->rect());
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
}
void AboutQtDialog::keyPressEvent(QKeyEvent * ke)
{
if (ke->key() == Qt::Key_Escape)
(parentWidget() ? parentWidget() : (QWidget*)this)->close();
}
void AboutQtDialog::aboutQt()
{
AboutQtDialog * dialog = new AboutQtDialog;
WidgetManager::showActivateRaiseWindow(dialog->window());
dialog->window()->adjustSize();
WidgetManager::alignWindow(dialog->window(), Qt::AlignCenter);
}