/* === This file is part of Calamares - === * * Copyright 2015, Teo Mrnjavac * * Calamares is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Calamares is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Calamares. If not, see . */ #include "DeviceInfoWidget.h" #include #include #include #include #include #include DeviceInfoWidget::DeviceInfoWidget( QWidget* parent ) : QWidget( parent ) , m_bootIcon( new QLabel ) , m_bootLabel( new QLabel ) , m_ptIcon( new QLabel ) , m_ptLabel( new QLabel ) { QHBoxLayout* mainLayout = new QHBoxLayout; setLayout( mainLayout ); CalamaresUtils::unmarginLayout( mainLayout ); mainLayout->addWidget( m_bootIcon ); mainLayout->addWidget( m_bootLabel ); mainLayout->addSpacing( CalamaresUtils::defaultFontHeight() / 4 ); mainLayout->addWidget( m_ptIcon ); mainLayout->addWidget( m_ptLabel ); QSize iconSize = CalamaresUtils::defaultIconSize(); m_bootIcon->setMargin( 0 ); m_bootIcon->setFixedSize( iconSize ); m_bootIcon->setPixmap( CalamaresUtils::defaultPixmap( CalamaresUtils::BootEnvironment, CalamaresUtils::Original, iconSize ) ); m_ptIcon->setMargin( 0 ); m_ptIcon->setFixedSize( iconSize ); m_ptIcon->setPixmap( CalamaresUtils::defaultPixmap( CalamaresUtils::PartitionTable, CalamaresUtils::Original, iconSize ) ); QFontMetrics fm = QFontMetrics( QFont() ); m_ptLabel->setMinimumWidth( fm.boundingRect( "MSDOS" ).width() + CalamaresUtils::defaultFontHeight() / 2 ); m_bootLabel->setMinimumWidth( fm.boundingRect( "BIOS" ).width() + CalamaresUtils::defaultFontHeight() / 2 ); m_ptLabel->setAlignment( Qt::AlignCenter ); m_bootLabel->setAlignment( Qt::AlignCenter ); QPalette palette; palette.setBrush( QPalette::Foreground, QColor( "#4D4D4D" ) ); //dark grey m_ptIcon->setAutoFillBackground( true ); m_bootIcon->setAutoFillBackground( true ); m_ptLabel->setAutoFillBackground( true ); m_bootLabel->setAutoFillBackground( true ); m_ptIcon->setPalette( palette ); m_bootIcon->setPalette( palette ); m_ptLabel->setPalette( palette ); m_bootLabel->setPalette( palette ); m_bootIcon->setToolTip( tr( "The boot environment of this system.

" "Older x86 systems only support BIOS.
" "Modern systems usually use EFI, but " "may also show up as BIOS if the boot " "environment runs in compatibility mode.
" "Relevant entries in the system setup utility " "include: CSM, compatibility support module, " "Legacy boot mode, BIOS mode, etc." ) ); m_ptIcon->setToolTip( tr( "The type of partition table currently " "present on the selected storage device.

" "Common values on x86-compatible systems include " "GPT and MSDOS.
" "Some systems may use other, less common partition table " "types, like BSD or Sun.
" "The only way to change the partition table type is to " "erase and recreate the partition table from scratch, " "which destroys all data on the storage device.
" "This installer will keep the current partition table " "unless you explicitly choose otherwise.
" "If unsure, on modern systems GPT is preferred." ) ); bool isEfi = false; if ( QDir( "/sys/firmware/efi/efivars" ).exists() ) isEfi = true; QString bootToolTip; if ( isEfi ) { m_bootLabel->setText( "EFI " ); bootToolTip = tr( "This system was started with an EFI " "boot environment.

" "Most consumer systems nowadays use EFI, along with a " "GPT partition table.
" "Current versions of other operating systems, like Windows " "and Mac OS X also support EFI, and dual boot is possible.
" "In order to boot from an EFI environment, this installer " "must deploy a boot loader application, like GRUB" " or systemd-boot on an " "EFI System Partition. This is automatic, unless " "you choose manual partitioning, in which case you must " "choose it or create it on your own." ); } else { m_bootLabel->setText( "BIOS" ); bootToolTip = tr( "This system was started with a BIOS " "boot environment.

" "Older systems which do not support EFI start from BIOS.
" "New systems that support EFI can also start in BIOS mode " "through a compatibility layer, sometimes known as " "CSM, Legacy boot mode or BIOS mode. On such systems " "EFI should be preferred, unless you wish to dual boot " "with an old operating system, like Windows XP. In that " "case, a MSDOS partition table should also be used instead " "of GPT.
" "In order to boot from a BIOS environment, this installer " "must install a boot loader, like GRUB" ", either at the beginning of a partition or " "on the Master Boot Record near the " "beginning of the partition table (preferred). " "This is automatic, unless " "you choose manual partitioning, in which case you must " "set it up on your own." ); } m_bootLabel->setToolTip( bootToolTip ); } void DeviceInfoWidget::setPartitionTableType( PartitionTable::TableType type ) { QString typeString = PartitionTable::tableTypeToName( type ).toUpper(); // fix up if the name shouldn't be uppercase: switch ( type ) { case PartitionTable::loop: typeString = "loop"; break; case PartitionTable::mac: typeString = "Mac"; break; case PartitionTable::amiga: typeString = "Amiga"; break; case PartitionTable::sun: typeString = "Sun"; break; case PartitionTable::unknownTableType: typeString = " ? "; } QString toolTipString = tr( "The selected storage device has a partition " "table. The partition table type is %1." ) .arg( typeString ); switch ( type ) { case PartitionTable::loop: toolTipString = tr( "The selected storage device is a loop " "device.

" "This is not an actual partition table, it is " "a pseudo-device that makes a file accessible as a block device. " "This kind of setup usually only contains a single filesystem." ); break; case PartitionTable::unknownTableType: toolTipString = tr( "This installer cannot detect a partition table on the " "selected storage device.

" "The device either has no partition " "table, or the partition table is corrupted or of an unknown " "type.
" "This installer can create a new partition table for you, " "either automatically, or through the manual partitioning " "page." ); break; case PartitionTable::gpt: toolTipString += tr( "

This is the recommended partition table type for modern " "systems which start from an EFI boot " "environment." ); break; case PartitionTable::msdos: case PartitionTable::msdos_sectorbased: toolTipString += tr( "

This partition table type is only advisable on older " "systems which start from a BIOS boot " "environment. For most uses GPT should be preferred " "instead.
" "Warning: the MSDOS partition table " "is an obsolete standard with important drawbacks.
" "Only 4 primary partitions may be created, and of " "those 4, one can be an extended partition, which " "may in turn contain many logical partitions." "
For compatibility reasons, it is recommended for a " "setup based on an MSDOS partition table to have a " "separate boot partition. This installer can create " "the boot partition for you automatically, or you may " "set it up yourself on the manual partitioning page." ); } m_ptLabel->setText( typeString ); m_ptLabel->setToolTip( toolTipString ); }