File indexing completed on 2024-03-24 17:22:04

0001 /***************************************************************************
0002  *   Copyright (C) 2011 by Daniel Nicoletti                                *
0003  *   dantti12@gmail.com                                                    *
0004  *                                                                         *
0005  *   This program is free software; you can redistribute it and/or modify  *
0006  *   it under the terms of the GNU General Public License as published by  *
0007  *   the Free Software Foundation; either version 2 of the License, or     *
0008  *   (at your option) any later version.                                   *
0009  *                                                                         *
0010  *   This program is distributed in the hope that it will be useful,       *
0011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
0012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
0013  *   GNU General Public License for more details.                          *
0014  *                                                                         *
0015  *   You should have received a copy of the GNU General Public License     *
0016  *   along with this program; see the file COPYING. If not, write to       *
0017  *   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,  *
0018  *   Boston, MA 02110-1301, USA.                                           *
0019  ***************************************************************************/
0020 
0021 #include "InfoWidget.h"
0022 #include "ui_InfoWidget.h"
0023 
0024 
0025 #include <QTextBrowser>
0026 #include <QLoggingCategory>
0027 
0028 InfoWidget::InfoWidget(QWidget *parent) :
0029     QWidget(parent),
0030     ui(new Ui::InfoWidget)
0031 {
0032     ui->setupUi(this);
0033     ui->iconL->setPixmap(QIcon::fromTheme(QLatin1String("dialog-warning")).pixmap(128, 128));
0034 }
0035 
0036 InfoWidget::~InfoWidget()
0037 {
0038     delete ui;
0039 }
0040 
0041 void InfoWidget::setIcon(const QIcon &icon)
0042 {
0043     ui->iconL->setPixmap(icon.pixmap(128, 128));
0044 }
0045 
0046 void InfoWidget::setDescription(const QString &description)
0047 {
0048     ui->descriptionL->setText(description);
0049 }
0050 
0051 void InfoWidget::setDetails(const QString &details)
0052 {
0053     if (!details.isEmpty()) {
0054         auto browser = new QTextBrowser(this);
0055         browser->setFrameShape(QFrame::NoFrame);
0056         browser->setFrameShadow(QFrame::Plain);
0057         browser->setStyleSheet(QLatin1String("QTextEdit {\nbackground-color: transparent;\n};"));
0058         browser->setText(details);
0059         ui->descriptionLayout->addWidget(browser);
0060         ui->descriptionLayout->insertSpacing(0, 20);
0061     }
0062 }
0063 
0064 void InfoWidget::addWidget(QWidget *widget)
0065 {
0066     if (widget) {
0067         ui->descriptionLayout->insertSpacing(0, 20);
0068         ui->descriptionLayout->addWidget(widget);
0069     }
0070 }
0071 
0072 void InfoWidget::reset()
0073 {
0074     ui->iconL->setPixmap(QIcon::fromTheme(QLatin1String("dialog-information")).pixmap(128, 128));
0075     setWindowTitle(QLatin1String(""));
0076     setDescription(QLatin1String(""));
0077     setDetails(QLatin1String(""));
0078 }
0079 
0080 #include "moc_InfoWidget.cpp"