source: calamares/trunk/fuentes/src/modules/welcome/checker/CheckItemWidget.cpp @ 7538

Last change on this file since 7538 was 7538, checked in by kbut, 13 months ago

sync with github

File size: 2.2 KB
Line 
1/* === This file is part of Calamares - <https://github.com/calamares> ===
2 *
3 *   Copyright 2014-2015, Teo Mrnjavac <teo@kde.org>
4 *   Copyright 2017, Adriaan de Groot <groot@kde.org>
5 *
6 *   Calamares is free software: you can redistribute it and/or modify
7 *   it under the terms of the GNU General Public License as published by
8 *   the Free Software Foundation, either version 3 of the License, or
9 *   (at your option) any later version.
10 *
11 *   Calamares is distributed in the hope that it will be useful,
12 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
13 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 *   GNU General Public License for more details.
15 *
16 *   You should have received a copy of the GNU General Public License
17 *   along with Calamares. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#include "CheckItemWidget.h"
21
22#include "utils/CalamaresUtilsGui.h"
23#include "utils/Logger.h"
24
25#include <QBoxLayout>
26
27static inline void setCondition( QLabel* label, CalamaresUtils::ImageType t )
28{
29    label->setPixmap( CalamaresUtils::defaultPixmap( t,
30                                                    CalamaresUtils::Original,
31                                                    QSize( label->height(), label->height() ) ) );
32}
33
34CheckItemWidget::CheckItemWidget( bool checked,
35                                  bool required,
36                                  QWidget* parent )
37    : QWidget( parent )
38{
39    QBoxLayout* mainLayout = new QHBoxLayout;
40    setLayout( mainLayout );
41
42    m_iconLabel = new QLabel( this );
43    mainLayout->addWidget( m_iconLabel );
44    m_iconLabel->setFixedSize( CalamaresUtils::defaultIconSize() );
45    m_textLabel = new QLabel( this );
46    mainLayout->addWidget( m_textLabel );
47    m_textLabel->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred );
48
49    if ( checked )
50        // Condition is satisfied
51        setCondition( m_iconLabel, CalamaresUtils::StatusOk );
52    else
53        if ( required )
54            setCondition( m_iconLabel, CalamaresUtils::StatusError );
55        else
56            setCondition( m_iconLabel, CalamaresUtils::StatusWarning );
57}
58
59
60void
61CheckItemWidget::setText( const QString& text )
62{
63    m_textLabel->setText( text );
64}
Note: See TracBrowser for help on using the repository browser.