SVN: PLDLiveInstaller/trunk: PLDLiveInstaller.cpp PLDLiveInstaller.h
shadzik
shadzik at pld-linux.org
Thu Jan 13 15:11:12 CET 2011
Author: shadzik
Date: Thu Jan 13 15:11:12 2011
New Revision: 12037
Modified:
PLDLiveInstaller/trunk/PLDLiveInstaller.cpp
PLDLiveInstaller/trunk/PLDLiveInstaller.h
Log:
- add void destroyPartitionTable(QString)
- use freedesktop device icon standard instead of selecting icons ourself (lots of redundand code removed)
Modified: PLDLiveInstaller/trunk/PLDLiveInstaller.cpp
==============================================================================
--- PLDLiveInstaller/trunk/PLDLiveInstaller.cpp (original)
+++ PLDLiveInstaller/trunk/PLDLiveInstaller.cpp Thu Jan 13 15:11:12 2011
@@ -130,35 +130,35 @@
setValid(selectDiskPage, true);
selectedDisk = diskListWidget->currentItem();
selectedBlockDev = diskListWidget->devhash->value(selectedDisk->text());
- selHDDBus = selectedBlockDev.as<Solid::StorageDrive>()->bus();
- qDebug() << "selHDDBus..." << selHDDBus;
defHDDimage->setVisible(false);
- switch (selHDDBus)
- {
- case Solid::StorageDrive::Usb: //CompactFlash
- HDDimageUSB->setVisible(true);
- HDDimageHD->setVisible(false);
- break;
- default:
- HDDimageHD->setVisible(true);
- HDDimageUSB->setVisible(false);
- break;
- }
+ HDDimage->setPixmap(KIcon(selectedBlockDev.icon()).pixmap(128));
+ HDDimage->setVisible(true);
}
void PLDLiveInstaller::rereadPartitionTable(QString device)
{
qDebug() << "Re-reading partition table for" << device;
QStringList args;
- args.append("blockdev");
args.append("--rereadpt");
args.append(device);
QProcess * blockdev = new QProcess(this);
- blockdev->start("chroot", args);
+ blockdev->start("blockdev", args);
blockdev->waitForFinished();
blockdev->deleteLater();
}
+void PLDLiveInstaller::destroyPartitionTable(QString device)
+{
+ qDebug() << "Destroying Partition Table on" << device;
+ QStringList args;
+ args.append("if=/dev/zero bs=512 count=1");
+ args.append("of=" + device);
+ QProcess * dd = new QProcess(this);
+ dd->start("dd", args);
+ dd->waitForFinished();
+ dd->deleteLater();
+}
+
void PLDLiveInstaller::isRootPartitionSelected(int pos)
{
qDebug() << "rootPart Position: " << pos;
@@ -315,20 +315,13 @@
defHDDimage->setAlignment(Qt::AlignLeft);
defHDDimage->setVisible(true);
- HDDimageHD = new QLabel;
- HDDimageHD->setPixmap(KIcon("drive-harddisk").pixmap(128));
- HDDimageHD->setAlignment(Qt::AlignLeft);
- HDDimageHD->setVisible(false);
-
- HDDimageUSB = new QLabel;
- HDDimageUSB->setPixmap(KIcon("drive-removable-media-usb").pixmap(128));
- HDDimageUSB->setAlignment(Qt::AlignLeft);
- HDDimageUSB->setVisible(false);
+ HDDimage = new QLabel;
+ HDDimage->setAlignment(Qt::AlignLeft);
+ HDDimage->setVisible(false);
QHBoxLayout *imageLayout = new QHBoxLayout;
imageLayout->addWidget(defHDDimage);
- imageLayout->addWidget(HDDimageHD);
- imageLayout->addWidget(HDDimageUSB);
+ imageLayout->addWidget(HDDimage);
QLabel *text = new QLabel(this);
text->setText(i18n("<html><p align=\"left\">"
@@ -412,23 +405,16 @@
"<font size=\"5\"><b>Select partitions where you want PLD Linux<br/> to install and click Next.</b></font>"
"</p></html>"));
- partImageHD = new QLabel;
- partImageHD->setPixmap(KIcon("drive-harddisk").pixmap(128));
- partImageHD->setAlignment(Qt::AlignLeft);
- partImageHD->setVisible(false);
-
- partImageUSB = new QLabel;
- partImageUSB->setPixmap(KIcon("drive-removable-media-usb").pixmap(128));
- partImageUSB->setAlignment(Qt::AlignLeft);
- partImageUSB->setVisible(false);
+ partImage = new QLabel;
+ partImage->setAlignment(Qt::AlignLeft);
+ partImage->setVisible(true);
partDescr = new QLabel;
partDescr->setVisible(true);
partDescr->setAlignment(Qt::AlignLeft);
QVBoxLayout *imageLayout = new QVBoxLayout;
- imageLayout->addWidget(partImageHD);
- imageLayout->addWidget(partImageUSB);
+ imageLayout->addWidget(partImage);
imageLayout->addWidget(partDescr);
selectPartitionPageText = new QLabel(this);
@@ -1909,19 +1895,7 @@
availablePartitions.append(part);
qDebug() << dev << "has partition: " << part;
}
- //selHDDBus = selectedBlockDev.as<Solid::StorageDrive>()->bus();
- qDebug() << "SelHDDBus #2..." << selHDDBus;
- switch (selHDDBus)
- {
- case Solid::StorageDrive::Usb: //CompactFlash
- partImageUSB->setVisible(true);
- partImageHD->setVisible(false);
- break;
- default:
- partImageHD->setVisible(true);
- partImageUSB->setVisible(false);
- break;
- }
+ partImage->setPixmap(KIcon(selectedBlockDev.icon()).pixmap(128));
availablePartitions.removeDuplicates();
qDebug() << "Partitions: " << availablePartitions;
if(rootPart->count()>0)
Modified: PLDLiveInstaller/trunk/PLDLiveInstaller.h
==============================================================================
--- PLDLiveInstaller/trunk/PLDLiveInstaller.h (original)
+++ PLDLiveInstaller/trunk/PLDLiveInstaller.h Thu Jan 13 15:11:12 2011
@@ -55,7 +55,7 @@
QRadioButton *autoLogin, *noAutoLogin, *entireDisk, *notEntireDisk;
int rootPartPos, swapPartPos, pbarVal;
bool isPartBigEnough, installBootLoader, pwMatch, userSet, doFormat;
- QLabel *defHDDimage, *HDDimageHD, *HDDimageUSB, *partImageHD, *partImageUSB, *partDescr;
+ QLabel *defHDDimage, *HDDimage, *partImage, *partDescr;
QString selFS, selUser, selPasswd, selHostname, failReason, selRoot, selSwap, selCred;
int isMounted(Solid::Device partition);
bool mountDev(Solid::Device partition), umountDev(Solid::Device partition);
@@ -73,7 +73,7 @@
void toggleService(QString service, bool action);
qlonglong curSizeArray[256];
void rereadPartitionTable(QString device);
- Solid::StorageDrive::Bus selHDDBus;
+ void destroyPartitionTable(QString device);
public:
PLDLiveInstaller( QWidget * parent = 0 );
More information about the pld-cvs-commit
mailing list