2020-09-16 00:35:12 +01:00
/*
SPDX - FileCopyrightText : 2010 Volker Lanz < vl @ fidra . de >
SPDX - FileCopyrightText : 2014 - 2016 Andrius Š tikonas < andrius @ stikonas . eu >
SPDX - FileCopyrightText : 2016 Chantara Tith < tith . chantara @ gmail . com >
SPDX - FileCopyrightText : 2019 Yuri Chornoivan < yurchor @ ukr . net >
SPDX - License - Identifier : GPL - 3.0 - or - later
*/
2010-01-29 11:25:28 +00:00
# include "gui/createpartitiontabledialog.h"
# include "gui/createpartitiontablewidget.h"
2016-01-12 00:12:49 +00:00
# include <core/device.h>
2010-01-29 11:25:28 +00:00
2014-05-17 03:06:58 +01:00
# include <QDialogButtonBox>
# include <QPushButton>
2010-01-29 11:25:28 +00:00
2014-05-18 21:41:48 +01:00
# include <KLocalizedString>
# include <KMessageBox>
2010-02-11 22:26:51 +00:00
# include <config.h>
2010-01-29 11:25:28 +00:00
CreatePartitionTableDialog : : CreatePartitionTableDialog ( QWidget * parent , const Device & d ) :
2015-07-13 15:17:41 +01:00
QDialog ( parent ) ,
m_DialogWidget ( new CreatePartitionTableWidget ( this ) ) ,
m_Device ( d )
2010-01-29 11:25:28 +00:00
{
2015-07-13 15:17:41 +01:00
QVBoxLayout * mainLayout = new QVBoxLayout ( this ) ;
setLayout ( mainLayout ) ;
mainLayout - > addWidget ( & widget ( ) ) ;
setWindowTitle ( xi18nc ( " @title:window " , " Create a New Partition Table on <filename>%1</filename> " , device ( ) . deviceNode ( ) ) ) ;
dialogButtonBox = new QDialogButtonBox ;
createButton = dialogButtonBox - > addButton ( QDialogButtonBox : : Ok ) ;
2016-07-18 02:21:14 +01:00
createButton - > setText ( xi18nc ( " @action:button " , " Create &New Partition Table " ) ) ;
2015-07-13 15:17:41 +01:00
cancelButton = dialogButtonBox - > addButton ( QDialogButtonBox : : Cancel ) ;
mainLayout - > addWidget ( dialogButtonBox ) ;
2010-04-11 19:06:47 +01:00
2016-05-22 20:03:49 +01:00
connect ( & widget ( ) . radioMSDOS ( ) , & QRadioButton : : toggled , this , & CreatePartitionTableDialog : : onMSDOSToggled ) ;
2016-05-18 22:23:59 +01:00
connect ( dialogButtonBox , & QDialogButtonBox : : accepted , this , & CreatePartitionTableDialog : : accept ) ;
connect ( dialogButtonBox , & QDialogButtonBox : : rejected , this , & CreatePartitionTableDialog : : reject ) ;
2010-01-29 11:25:28 +00:00
}
2010-02-24 11:32:12 +00:00
PartitionTable : : TableType CreatePartitionTableDialog : : type ( ) const
2010-01-29 11:25:28 +00:00
{
2015-07-13 15:17:41 +01:00
if ( widget ( ) . radioGPT ( ) . isChecked ( ) )
return PartitionTable : : gpt ;
2010-02-01 16:32:45 +00:00
2015-07-13 15:17:41 +01:00
if ( widget ( ) . radioMSDOS ( ) . isChecked ( ) & & Config : : useCylinderAlignment ( ) = = true )
return PartitionTable : : msdos ;
2010-02-01 16:32:45 +00:00
2015-07-13 15:17:41 +01:00
return PartitionTable : : msdos_sectorbased ;
2010-01-29 11:25:28 +00:00
}
2010-04-11 19:06:47 +01:00
void CreatePartitionTableDialog : : onMSDOSToggled ( bool on )
{
2016-06-10 19:04:05 +01:00
if ( on & & device ( ) . totalLogical ( ) > 0xffffffff ) {
2015-07-13 15:17:41 +01:00
if ( KMessageBox : : warningContinueCancel ( this ,
xi18nc ( " @info " ,
" <para>Do you really want to create an MS-Dos partition table on <filename>%1</filename>?</para> "
" <para>This device has more than 2^32 sectors. That is the most the MS-Dos partition table type supports, so you will not be able to use the whole device.</para> " , device ( ) . deviceNode ( ) ) ,
2016-07-18 02:21:14 +01:00
xi18nc ( " @title:window " , " Really Create MS-Dos Partition Table Type? " ) ,
KGuiItem ( xi18nc ( " @action:button " , " Create MS-Dos Type " ) , QStringLiteral ( " arrow-right " ) ) ,
2015-07-13 15:17:41 +01:00
KStandardGuiItem : : cancel ( ) , QStringLiteral ( " reallyCreateMSDOSOnLargeDevice " ) ) = = KMessageBox : : Cancel ) {
widget ( ) . radioGPT ( ) . setChecked ( true ) ;
}
}
2010-08-08 13:36:05 +01:00
}