1 /* === This file is part of Calamares - <https://calamares.io> ===
2  *
3  *   SPDX-FileCopyrightText: 2015-2016 Teo Mrnjavac <teo@kde.org>
4  *   SPDX-License-Identifier: GPL-3.0-or-later
5  *
6  *   Calamares is Free Software: see the License-Identifier above.
7  *
8  */
9 
10 
11 #include "BootInfoWidget.h"
12 #include "core/PartUtils.h"
13 
14 #include "utils/CalamaresUtilsGui.h"
15 #include "utils/QtCompat.h"
16 #include "utils/Retranslator.h"
17 
18 #include <QDir>
19 #include <QHBoxLayout>
20 #include <QLabel>
21 
BootInfoWidget(QWidget * parent)22 BootInfoWidget::BootInfoWidget( QWidget* parent )
23     : QWidget( parent )
24     , m_bootIcon( new QLabel )
25     , m_bootLabel( new QLabel )
26 {
27     m_bootIcon->setObjectName( "bootInfoIcon" );
28     m_bootLabel->setObjectName( "bootInfoLabel" );
29     QHBoxLayout* mainLayout = new QHBoxLayout;
30     setLayout( mainLayout );
31 
32     CalamaresUtils::unmarginLayout( mainLayout );
33 
34     mainLayout->addWidget( m_bootIcon );
35     mainLayout->addWidget( m_bootLabel );
36 
37     QSize iconSize = CalamaresUtils::defaultIconSize();
38 
39     m_bootIcon->setMargin( 0 );
40     m_bootIcon->setFixedSize( iconSize );
41     m_bootIcon->setPixmap(
42         CalamaresUtils::defaultPixmap( CalamaresUtils::BootEnvironment, CalamaresUtils::Original, iconSize ) );
43 
44     QFontMetrics fm = QFontMetrics( QFont() );
45     m_bootLabel->setMinimumWidth( fm.boundingRect( "BIOS" ).width() + CalamaresUtils::defaultFontHeight() / 2 );
46     m_bootLabel->setAlignment( Qt::AlignCenter );
47 
48     QPalette palette;
49     palette.setBrush( WindowText, QColor( "#4D4D4D" ) );  //dark grey
50 
51     m_bootIcon->setAutoFillBackground( true );
52     m_bootLabel->setAutoFillBackground( true );
53     m_bootIcon->setPalette( palette );
54     m_bootLabel->setPalette( palette );
55 
56     CALAMARES_RETRANSLATE( retranslateUi(); );
57 }
58 
59 void
retranslateUi()60 BootInfoWidget::retranslateUi()
61 {
62     m_bootIcon->setToolTip( tr( "The <strong>boot environment</strong> of this system.<br><br>"
63                                 "Older x86 systems only support <strong>BIOS</strong>.<br>"
64                                 "Modern systems usually use <strong>EFI</strong>, but "
65                                 "may also show up as BIOS if started in compatibility "
66                                 "mode." ) );
67 
68     QString bootToolTip;
69     if ( PartUtils::isEfiSystem() )
70     {
71         m_bootLabel->setText( "EFI " );
72         bootToolTip = tr( "This system was started with an <strong>EFI</strong> "
73                           "boot environment.<br><br>"
74                           "To configure startup from an EFI environment, this installer "
75                           "must deploy a boot loader application, like <strong>GRUB"
76                           "</strong> or <strong>systemd-boot</strong> on an <strong>"
77                           "EFI System Partition</strong>. This is automatic, unless "
78                           "you choose manual partitioning, in which case you must "
79                           "choose it or create it on your own." );
80     }
81     else
82     {
83         m_bootLabel->setText( "BIOS" );
84         bootToolTip = tr( "This system was started with a <strong>BIOS</strong> "
85                           "boot environment.<br><br>"
86                           "To configure startup from a BIOS environment, this installer "
87                           "must install a boot loader, like <strong>GRUB"
88                           "</strong>, either at the beginning of a partition or "
89                           "on the <strong>Master Boot Record</strong> near the "
90                           "beginning of the partition table (preferred). "
91                           "This is automatic, unless "
92                           "you choose manual partitioning, in which case you must "
93                           "set it up on your own." );
94     }
95     m_bootLabel->setToolTip( bootToolTip );
96 }
97