2020-08-25 16:05:56 +02:00
|
|
|
/* === This file is part of Calamares - <https://calamares.io> ===
|
2015-11-27 17:24:24 +01:00
|
|
|
*
|
2020-08-22 01:19:58 +02:00
|
|
|
* SPDX-FileCopyrightText: 2015-2016 Teo Mrnjavac <teo@kde.org>
|
|
|
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
2015-11-27 17:24:24 +01:00
|
|
|
*
|
2020-08-25 16:05:56 +02:00
|
|
|
* Calamares is Free Software: see the License-Identifier above.
|
2015-11-27 17:24:24 +01:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "DeviceInfoWidget.h"
|
|
|
|
|
2020-08-22 01:19:58 +02:00
|
|
|
#include "GlobalStorage.h"
|
|
|
|
#include "JobQueue.h"
|
2017-08-28 10:40:31 +02:00
|
|
|
#include "utils/CalamaresUtilsGui.h"
|
|
|
|
#include "utils/Logger.h"
|
2020-10-24 12:49:56 +02:00
|
|
|
#include "utils/QtCompat.h"
|
2017-08-28 10:40:31 +02:00
|
|
|
#include "utils/Retranslator.h"
|
2015-11-27 17:24:24 +01:00
|
|
|
|
|
|
|
#include <QDir>
|
|
|
|
#include <QHBoxLayout>
|
2020-08-22 01:19:58 +02:00
|
|
|
#include <QLabel>
|
2015-11-27 17:24:24 +01:00
|
|
|
|
|
|
|
DeviceInfoWidget::DeviceInfoWidget( QWidget* parent )
|
|
|
|
: QWidget( parent )
|
|
|
|
, m_ptIcon( new QLabel )
|
|
|
|
, m_ptLabel( new QLabel )
|
2017-08-29 20:00:48 +02:00
|
|
|
, m_tableType( PartitionTable::unknownTableType )
|
2015-11-27 17:24:24 +01:00
|
|
|
{
|
|
|
|
QHBoxLayout* mainLayout = new QHBoxLayout;
|
|
|
|
setLayout( mainLayout );
|
|
|
|
|
|
|
|
CalamaresUtils::unmarginLayout( mainLayout );
|
2020-08-22 01:19:58 +02:00
|
|
|
m_ptLabel->setObjectName( "deviceInfoLabel" );
|
|
|
|
m_ptIcon->setObjectName( "deviceInfoIcon" );
|
2015-11-27 17:24:24 +01:00
|
|
|
mainLayout->addWidget( m_ptIcon );
|
|
|
|
mainLayout->addWidget( m_ptLabel );
|
|
|
|
|
2015-11-27 20:36:23 +01:00
|
|
|
QSize iconSize = CalamaresUtils::defaultIconSize();
|
2015-11-27 17:24:24 +01:00
|
|
|
|
|
|
|
m_ptIcon->setMargin( 0 );
|
|
|
|
m_ptIcon->setFixedSize( iconSize );
|
2017-08-28 10:40:31 +02:00
|
|
|
m_ptIcon->setPixmap(
|
2020-08-22 01:19:58 +02:00
|
|
|
CalamaresUtils::defaultPixmap( CalamaresUtils::PartitionTable, CalamaresUtils::Original, iconSize ) );
|
2015-11-27 17:24:24 +01:00
|
|
|
|
|
|
|
QFontMetrics fm = QFontMetrics( QFont() );
|
2016-01-27 16:46:32 +01:00
|
|
|
m_ptLabel->setMinimumWidth( fm.boundingRect( "Amiga" ).width() + CalamaresUtils::defaultFontHeight() / 2 );
|
2015-11-27 17:24:24 +01:00
|
|
|
m_ptLabel->setAlignment( Qt::AlignCenter );
|
|
|
|
|
|
|
|
QPalette palette;
|
2020-10-24 12:49:56 +02:00
|
|
|
palette.setBrush( WindowText, QColor( "#4D4D4D" ) ); //dark grey
|
2015-11-27 17:24:24 +01:00
|
|
|
|
2015-11-27 20:36:23 +01:00
|
|
|
m_ptIcon->setAutoFillBackground( true );
|
|
|
|
m_ptLabel->setAutoFillBackground( true );
|
|
|
|
m_ptIcon->setPalette( palette );
|
2015-11-27 17:24:24 +01:00
|
|
|
m_ptLabel->setPalette( palette );
|
|
|
|
|
2019-08-29 15:02:12 +02:00
|
|
|
CALAMARES_RETRANSLATE_SLOT( &DeviceInfoWidget::retranslateUi )
|
2015-11-27 17:24:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
DeviceInfoWidget::setPartitionTableType( PartitionTable::TableType type )
|
|
|
|
{
|
2017-08-28 10:40:31 +02:00
|
|
|
m_tableType = type;
|
|
|
|
retranslateUi();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
DeviceInfoWidget::retranslateUi()
|
|
|
|
{
|
|
|
|
QString typeString = PartitionTable::tableTypeToName( m_tableType ).toUpper();
|
2015-11-27 20:36:23 +01:00
|
|
|
|
2015-11-27 17:24:24 +01:00
|
|
|
// fix up if the name shouldn't be uppercase:
|
2017-08-28 10:40:31 +02:00
|
|
|
switch ( m_tableType )
|
2015-11-27 17:24:24 +01:00
|
|
|
{
|
2016-01-27 16:46:32 +01:00
|
|
|
case PartitionTable::msdos:
|
|
|
|
case PartitionTable::msdos_sectorbased:
|
|
|
|
typeString = "MBR";
|
|
|
|
break;
|
2015-11-27 17:24:24 +01:00
|
|
|
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 = " ? ";
|
|
|
|
}
|
|
|
|
|
2015-11-27 20:36:23 +01:00
|
|
|
|
2016-01-28 13:01:50 +01:00
|
|
|
QString toolTipString = tr( "This device has a <strong>%1</strong> partition "
|
|
|
|
"table." )
|
2020-08-22 01:19:58 +02:00
|
|
|
.arg( typeString );
|
2015-11-27 20:36:23 +01:00
|
|
|
|
2017-08-28 10:40:31 +02:00
|
|
|
switch ( m_tableType )
|
2015-11-27 20:36:23 +01:00
|
|
|
{
|
|
|
|
case PartitionTable::loop:
|
2016-01-28 13:01:50 +01:00
|
|
|
toolTipString = tr( "This is a <strong>loop</strong> "
|
2015-11-27 20:36:23 +01:00
|
|
|
"device.<br><br>"
|
2016-01-28 13:01:50 +01:00
|
|
|
"It is a pseudo-device with no partition table "
|
|
|
|
"that makes a file accessible as a block device. "
|
2015-11-27 20:36:23 +01:00
|
|
|
"This kind of setup usually only contains a single filesystem." );
|
|
|
|
break;
|
|
|
|
case PartitionTable::unknownTableType:
|
|
|
|
toolTipString = tr( "This installer <strong>cannot detect a partition table</strong> on the "
|
|
|
|
"selected storage device.<br><br>"
|
|
|
|
"The device either has no partition "
|
|
|
|
"table, or the partition table is corrupted or of an unknown "
|
|
|
|
"type.<br>"
|
|
|
|
"This installer can create a new partition table for you, "
|
|
|
|
"either automatically, or through the manual partitioning "
|
|
|
|
"page." );
|
|
|
|
break;
|
|
|
|
case PartitionTable::gpt:
|
|
|
|
toolTipString += tr( "<br><br>This is the recommended partition table type for modern "
|
|
|
|
"systems which start from an <strong>EFI</strong> boot "
|
|
|
|
"environment." );
|
|
|
|
break;
|
|
|
|
case PartitionTable::msdos:
|
|
|
|
case PartitionTable::msdos_sectorbased:
|
|
|
|
toolTipString += tr( "<br><br>This partition table type is only advisable on older "
|
|
|
|
"systems which start from a <strong>BIOS</strong> boot "
|
2016-01-27 16:46:32 +01:00
|
|
|
"environment. GPT is recommended in most other cases.<br><br>"
|
|
|
|
"<strong>Warning:</strong> the MBR partition table "
|
2016-01-28 13:03:22 +01:00
|
|
|
"is an obsolete MS-DOS era standard.<br>"
|
2015-11-27 20:36:23 +01:00
|
|
|
"Only 4 <em>primary</em> partitions may be created, and of "
|
|
|
|
"those 4, one can be an <em>extended</em> partition, which "
|
2016-01-27 16:46:32 +01:00
|
|
|
"may in turn contain many <em>logical</em> partitions." );
|
2015-11-27 20:36:23 +01:00
|
|
|
}
|
|
|
|
|
2015-11-27 17:24:24 +01:00
|
|
|
m_ptLabel->setText( typeString );
|
2015-11-27 20:36:23 +01:00
|
|
|
m_ptLabel->setToolTip( toolTipString );
|
2015-11-27 17:24:24 +01:00
|
|
|
|
2017-08-28 10:40:31 +02:00
|
|
|
m_ptIcon->setToolTip( tr( "The type of <strong>partition table</strong> on the "
|
2020-08-22 01:19:58 +02:00
|
|
|
"selected storage device.<br><br>"
|
|
|
|
"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.<br>"
|
|
|
|
"This installer will keep the current partition table "
|
|
|
|
"unless you explicitly choose otherwise.<br>"
|
|
|
|
"If unsure, on modern systems GPT is preferred." ) );
|
2017-08-28 10:40:31 +02:00
|
|
|
}
|