2015-02-07 00:32:25 +00:00
/*************************************************************************
* Copyright ( C ) 2010 by Volker Lanz < vl @ fidra . de > *
2016-03-02 18:33:40 +00:00
* Copyright ( C ) 2016 by Andrius Š tikonas < andrius @ stikonas . eu > *
2015-02-07 00:32:25 +00:00
* *
* This program 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 . *
* *
* This program 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 this program . If not , see < http : //www.gnu.org/licenses/>.*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
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
}