| 1 | /* |
| 2 | * Copyright (C) 2016 Damir Porobic <https://github.com/damirporobic> |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or modify |
| 5 | * it under the terms of the GNU General Public License as published by |
| 6 | * the Free Software Foundation; either version 2 of the License, or |
| 7 | * (at your option) any later version. |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this program; if not, write to the Free Software |
| 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 17 | * Boston, MA 02110-1301, USA. |
| 18 | * |
| 19 | */ |
| 20 | |
| 21 | #include "AboutDialog.h" |
| 22 | |
| 23 | AboutDialog::AboutDialog(QWidget* parent) : QDialog(parent), |
| 24 | mMainLayout(new QVBoxLayout), |
| 25 | mHeaderLayout(new QHBoxLayout), |
| 26 | mTabWidget(new QTabWidget), |
| 27 | mAboutTab(new AboutTab), |
| 28 | mVersionTab(new VersionTab), |
| 29 | mAuthorTab(new AuthorTab), |
| 30 | mDonateTab(new DonateTab), |
| 31 | mContactTab(new ContactTab), |
| 32 | mCloseButton(new QPushButton) |
| 33 | { |
| 34 | setWindowTitle(tr("About ") + QApplication::applicationName()); |
| 35 | |
| 36 | createHeader(); |
| 37 | |
| 38 | mTabWidget->addTab(mAboutTab, tr("About")); |
| 39 | mTabWidget->addTab(mVersionTab, tr("Version")); |
| 40 | mTabWidget->addTab(mAuthorTab, tr("Author")); |
| 41 | mTabWidget->addTab(mDonateTab, tr("Donate")); |
| 42 | mTabWidget->addTab(mContactTab, tr("Contact")); |
| 43 | mTabWidget->setMinimumSize(mTabWidget->sizeHint()); |
| 44 | |
| 45 | mCloseButton->setText(tr("Close")); |
| 46 | connect(mCloseButton, &QPushButton::clicked, this, &AboutDialog::close); |
| 47 | |
| 48 | mMainLayout->addLayout(mHeaderLayout); |
| 49 | mMainLayout->addWidget(mTabWidget); |
| 50 | mMainLayout->addWidget(mCloseButton, 1, Qt::AlignRight); |
| 51 | |
| 52 | setLayout(mMainLayout); |
| 53 | |
| 54 | setFixedSize(sizeHint() + QSize(10, 0)); |
| 55 | } |
| 56 | |
| 57 | AboutDialog::~AboutDialog() |
| 58 | { |
| 59 | delete mMainLayout; |
| 60 | delete mCloseButton; |
| 61 | delete mAboutTab; |
| 62 | delete mVersionTab; |
| 63 | delete mAuthorTab; |
| 64 | delete mDonateTab; |
| 65 | } |
| 66 | |
| 67 | void AboutDialog::createHeader() |
| 68 | { |
| 69 | auto pixmap = QPixmap(QLatin1String(":/icons/ksnip")); |
| 70 | auto scaledPixmap = pixmap.scaled(64, 64, Qt::KeepAspectRatio, Qt::SmoothTransformation); |
| 71 | auto label = new QLabel(); |
| 72 | mHeaderLayout = new QHBoxLayout(); |
| 73 | label->setPixmap(scaledPixmap); |
| 74 | label->setAlignment(Qt::AlignLeft | Qt::AlignVCenter); |
| 75 | mHeaderLayout->addWidget(label); |
| 76 | label = new QLabel(QLatin1String("<h2>") + QApplication::applicationName() + QLatin1String("</h2>")); |
| 77 | label->setAlignment(Qt::AlignLeft | Qt::AlignVCenter); |
| 78 | mHeaderLayout->addWidget(label); |
| 79 | mHeaderLayout->setAlignment(Qt::AlignLeft); |
| 80 | } |