source: calamares/trunk/fuentes/src/modules/partition/gui/DeviceInfoWidget.cpp @ 7538

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

sync with github

File size: 6.1 KB
Line 
1/* === This file is part of Calamares - <https://github.com/calamares> ===
2 *
3 *   Copyright 2015-2016, Teo Mrnjavac <teo@kde.org>
4 *
5 *   Calamares is free software: you can redistribute it and/or modify
6 *   it under the terms of the GNU General Public License as published by
7 *   the Free Software Foundation, either version 3 of the License, or
8 *   (at your option) any later version.
9 *
10 *   Calamares is distributed in the hope that it will be useful,
11 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
12 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 *   GNU General Public License for more details.
14 *
15 *   You should have received a copy of the GNU General Public License
16 *   along with Calamares. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19
20#include "DeviceInfoWidget.h"
21
22#include "utils/CalamaresUtilsGui.h"
23#include "utils/Logger.h"
24#include "utils/Retranslator.h"
25#include "JobQueue.h"
26#include "GlobalStorage.h"
27
28#include <QDir>
29#include <QLabel>
30#include <QHBoxLayout>
31
32DeviceInfoWidget::DeviceInfoWidget( QWidget* parent )
33    : QWidget( parent )
34    , m_ptIcon( new QLabel )
35    , m_ptLabel( new QLabel )
36    , m_tableType( PartitionTable::unknownTableType )
37{
38    QHBoxLayout* mainLayout = new QHBoxLayout;
39    setLayout( mainLayout );
40
41    CalamaresUtils::unmarginLayout( mainLayout );
42    m_ptLabel->setObjectName("deviceInfoLabel");
43    m_ptIcon->setObjectName("deviceInfoIcon");
44    mainLayout->addWidget( m_ptIcon );
45    mainLayout->addWidget( m_ptLabel );
46
47    QSize iconSize = CalamaresUtils::defaultIconSize();
48
49    m_ptIcon->setMargin( 0 );
50    m_ptIcon->setFixedSize( iconSize );
51    m_ptIcon->setPixmap(
52        CalamaresUtils::defaultPixmap( CalamaresUtils::PartitionTable,
53                                       CalamaresUtils::Original,
54                                       iconSize ) );
55
56    QFontMetrics fm = QFontMetrics( QFont() );
57    m_ptLabel->setMinimumWidth( fm.boundingRect( "Amiga" ).width() + CalamaresUtils::defaultFontHeight() / 2 );
58    m_ptLabel->setAlignment( Qt::AlignCenter );
59
60    QPalette palette;
61    palette.setBrush( QPalette::Foreground, QColor( "#4D4D4D" ) ); //dark grey
62
63    m_ptIcon->setAutoFillBackground( true );
64    m_ptLabel->setAutoFillBackground( true );
65    m_ptIcon->setPalette( palette );
66    m_ptLabel->setPalette( palette );
67
68    CALAMARES_RETRANSLATE( retranslateUi(); )
69}
70
71
72void
73DeviceInfoWidget::setPartitionTableType( PartitionTable::TableType type )
74{
75    m_tableType = type;
76    retranslateUi();
77}
78
79void
80DeviceInfoWidget::retranslateUi()
81{
82    QString typeString = PartitionTable::tableTypeToName( m_tableType ).toUpper();
83
84    // fix up if the name shouldn't be uppercase:
85    switch ( m_tableType )
86    {
87    case PartitionTable::msdos:
88    case PartitionTable::msdos_sectorbased:
89        typeString = "MBR";
90        break;
91    case PartitionTable::loop:
92        typeString = "loop";
93        break;
94    case PartitionTable::mac:
95        typeString = "Mac";
96        break;
97    case PartitionTable::amiga:
98        typeString = "Amiga";
99        break;
100    case PartitionTable::sun:
101        typeString = "Sun";
102        break;
103    case PartitionTable::unknownTableType:
104        typeString = " ? ";
105    }
106
107
108    QString toolTipString = tr( "This device has a <strong>%1</strong> partition "
109                                "table." )
110                            .arg( typeString );
111
112    switch ( m_tableType )
113    {
114    case PartitionTable::loop:
115        toolTipString = tr( "This is a <strong>loop</strong> "
116                            "device.<br><br>"
117                            "It is a pseudo-device with no partition table "
118                            "that makes a file accessible as a block device. "
119                            "This kind of setup usually only contains a single filesystem." );
120        break;
121    case PartitionTable::unknownTableType:
122        toolTipString = tr( "This installer <strong>cannot detect a partition table</strong> on the "
123                            "selected storage device.<br><br>"
124                            "The device either has no partition "
125                            "table, or the partition table is corrupted or of an unknown "
126                            "type.<br>"
127                            "This installer can create a new partition table for you, "
128                            "either automatically, or through the manual partitioning "
129                            "page." );
130        break;
131    case PartitionTable::gpt:
132        toolTipString += tr( "<br><br>This is the recommended partition table type for modern "
133                             "systems which start from an <strong>EFI</strong> boot "
134                             "environment." );
135        break;
136    case PartitionTable::msdos:
137    case PartitionTable::msdos_sectorbased:
138        toolTipString += tr( "<br><br>This partition table type is only advisable on older "
139                             "systems which start from a <strong>BIOS</strong> boot "
140                             "environment. GPT is recommended in most other cases.<br><br>"
141                             "<strong>Warning:</strong> the MBR partition table "
142                             "is an obsolete MS-DOS era standard.<br>"
143                             "Only 4 <em>primary</em> partitions may be created, and of "
144                             "those 4, one can be an <em>extended</em> partition, which "
145                             "may in turn contain many <em>logical</em> partitions." );
146    }
147
148    m_ptLabel->setText( typeString );
149    m_ptLabel->setToolTip( toolTipString );
150
151    m_ptIcon->setToolTip( tr( "The type of <strong>partition table</strong> on the "
152                            "selected storage device.<br><br>"
153                            "The only way to change the partition table type is to "
154                            "erase and recreate the partition table from scratch, "
155                            "which destroys all data on the storage device.<br>"
156                            "This installer will keep the current partition table "
157                            "unless you explicitly choose otherwise.<br>"
158                            "If unsure, on modern systems GPT is preferred." ) );
159}
Note: See TracBrowser for help on using the repository browser.