fdc2cc4c2a1c85fe02edb5600c7e7342b64ae151
[dhcpcd-ui] / src / dhcpcd-qt / dhcpcd-about.cpp
1 /*
2  * dhcpcd-qt
3  * Copyright 2014-2015 Roy Marples <roy@marples.name>
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  *
14  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24  * SUCH DAMAGE.
25  */
26
27 #include <QDialog>
28 #include <QHBoxLayout>
29 #include <QIcon>
30 #include <QLabel>
31 #include <QPixmap>
32 #include <QPushButton>
33 #include <QSpacerItem>
34 #include <QVBoxLayout>
35
36 #include "config.h"
37 #include "dhcpcd-about.h"
38 #include "dhcpcd-qt.h"
39
40 DhcpcdAbout::DhcpcdAbout(DhcpcdQt *parent)
41     : QDialog(parent)
42 {
43         this->parent = parent;
44         QVBoxLayout *layout;
45         resize(300, 200);
46         setWindowIcon(DhcpcdQt::getIcon("status", "network-transmit-receive"));
47         setWindowTitle(tr("About Network Configurator"));
48         QPoint p = QCursor::pos();
49         move(p.x(), p.y());
50
51         layout = new QVBoxLayout(this);
52
53         QIcon icon = DhcpcdQt::getIcon("status", "network-transmit-receive");
54         QPixmap picon = icon.pixmap(32, 32);
55         iconLabel = new QLabel(this);
56         iconLabel->setAlignment(Qt::AlignCenter);
57         iconLabel->setPixmap(picon);
58         layout->addWidget(iconLabel);
59
60         aboutLabel = new QLabel("<h1>Network Configurator "  VERSION "</h1>", this);
61         aboutLabel->setAlignment(Qt::AlignCenter);
62         layout->addWidget(aboutLabel);
63         partLabel = new QLabel(tr("Part of the dhcpcd project"), this);
64         partLabel->setAlignment(Qt::AlignCenter);
65         layout->addWidget(partLabel);
66         copyrightLabel = new QLabel("Copyright (c) 2009-2015 Roy Marples", this);
67         copyrightLabel->setAlignment(Qt::AlignCenter);
68         layout->addWidget(copyrightLabel);
69         urlLabel = new QLabel(
70             "<a href=\"http://roy.marples.name/projects/dhcpcd\">"
71             "dhcpcd Website"
72             "</a>",
73             this);
74         urlLabel->setAlignment(Qt::AlignCenter);
75         urlLabel->setOpenExternalLinks(true);
76         layout->addWidget(urlLabel);
77
78         QHBoxLayout *hbox = new QHBoxLayout();
79         layout->addLayout(hbox);
80         hbox->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Expanding));
81         closeButton = new QPushButton(tr("Close"));
82         closeButton->setIcon(QIcon::fromTheme("window-close"));
83         hbox->addWidget(closeButton);
84         connect(closeButton, SIGNAL(clicked()), this, SLOT(close()));
85 }
86
87 void DhcpcdAbout::closeEvent(QCloseEvent *e)
88 {
89
90         parent->dialogClosed(this);
91         QDialog::closeEvent(e);
92 }