diff --git a/src/modules/partition/CMakeLists.txt b/src/modules/partition/CMakeLists.txt index 8cd038e31..4bc9de989 100644 --- a/src/modules/partition/CMakeLists.txt +++ b/src/modules/partition/CMakeLists.txt @@ -35,6 +35,7 @@ calamares_add_plugin( partition gui/CreatePartitionDialog.cpp gui/EditExistingPartitionDialog.cpp gui/AlongsidePage.cpp + gui/DeviceInfoWidget.cpp gui/PartitionPage.cpp gui/PartitionPreview.cpp gui/PartitionSizeController.cpp diff --git a/src/modules/partition/gui/DeviceInfoWidget.cpp b/src/modules/partition/gui/DeviceInfoWidget.cpp new file mode 100644 index 000000000..c26f53a51 --- /dev/null +++ b/src/modules/partition/gui/DeviceInfoWidget.cpp @@ -0,0 +1,130 @@ +/* === 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->addWidget( m_ptIcon ); + mainLayout->addWidget( m_ptLabel ); + + bool isEfi = false; + if ( QDir( "/sys/firmware/efi/efivars" ).exists() ) + isEfi = true; + + if ( isEfi ) + m_bootLabel->setText( "EFI " ); + else + m_bootLabel->setText( "BIOS" ); + + QSize iconSize = QSize( CalamaresUtils::defaultFontHeight(), + CalamaresUtils::defaultFontHeight() ); + + 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() +2 ); + m_bootLabel->setMinimumWidth( fm.boundingRect( "BIOS" ).width() +2 ); + m_ptLabel->setAlignment( Qt::AlignCenter ); + m_bootLabel->setAlignment( Qt::AlignCenter ); + + QPalette palette; + palette.setBrush( QPalette::Foreground, QColor( "#4D4D4D" ) ); //dark grey + + 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, BIOS boot, 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." ) ); +} + + +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 = " ? "; + } + + m_ptLabel->setText( typeString ); +} + diff --git a/src/modules/partition/gui/DeviceInfoWidget.h b/src/modules/partition/gui/DeviceInfoWidget.h new file mode 100644 index 000000000..016691e84 --- /dev/null +++ b/src/modules/partition/gui/DeviceInfoWidget.h @@ -0,0 +1,44 @@ +/* === 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 . + */ + + +#ifndef DEVICEINFOWIDGET_H +#define DEVICEINFOWIDGET_H + +#include + +#include + +class QLabel; + +class DeviceInfoWidget : public QWidget +{ + Q_OBJECT +public: + explicit DeviceInfoWidget( QWidget* parent = nullptr ); + + void setPartitionTableType( PartitionTable::TableType type ); + +private: + QLabel* m_bootIcon; + QLabel* m_bootLabel; + QLabel* m_ptIcon; + QLabel* m_ptLabel; +}; + +#endif // DEVICEINFOWIDGET_H