SVN: PLDLiveInstaller/trunk: DiskListWidget.cpp DiskListWidget.h PLDLiveInstaller.cpp PLDLiveInstall...

shadzik shadzik at pld-linux.org
Mon Jan 17 02:01:33 CET 2011


Author: shadzik
Date: Mon Jan 17 02:01:32 2011
New Revision: 12057

Modified:
   PLDLiveInstaller/trunk/DiskListWidget.cpp
   PLDLiveInstaller/trunk/DiskListWidget.h
   PLDLiveInstaller/trunk/PLDLiveInstaller.cpp
   PLDLiveInstaller/trunk/PLDLiveInstaller.h
   PLDLiveInstaller/trunk/Version.h
Log:
- version 0.24
- ensure we have:
  + enough ram
  + enough drive space
  + ac plugged in to power source
- clear samePartition and partitionNotBIgEnough info when "Back" was clicked


Modified: PLDLiveInstaller/trunk/DiskListWidget.cpp
==============================================================================
--- PLDLiveInstaller/trunk/DiskListWidget.cpp	(original)
+++ PLDLiveInstaller/trunk/DiskListWidget.cpp	Mon Jan 17 02:01:32 2011
@@ -6,6 +6,7 @@
 #include <Solid/DeviceInterface>
 #include <Solid/StorageDrive>
 #include <Solid/Block>
+#include <Solid/StorageVolume>
 	
 DiskListWidget::DiskListWidget( QWidget *parent )
   : QListWidget( parent )
@@ -21,6 +22,7 @@
 {
     //setCurrentItem(NULL);
     setSelectionMode(QAbstractItemView::SingleSelection);
+    isBiggerThanThreeGB = false;
     
     if (diskListAlreadyOnList.size() <= 0)
     {
@@ -41,6 +43,13 @@
 	//qDebug() << "TUTAJ!!" << device.as<Solid::StorageDrive>()->size()/1024/1024;
 	//if(device.as<Solid::StorageDrive>()->size()/1024/1024 >= 6144)
 	//{
+	  
+	  if(device.is<Solid::StorageVolume>())
+	  {
+	    if(device.as<Solid::StorageVolume>()->size()/1024/1024 >= 3072)
+	      isBiggerThanThreeGB = true;
+	  }
+	  
 	  QString dev = device.as<Solid::Block>()->device();
 	
 	  if (solidDevice.contains(dev))

Modified: PLDLiveInstaller/trunk/DiskListWidget.h
==============================================================================
--- PLDLiveInstaller/trunk/DiskListWidget.h	(original)
+++ PLDLiveInstaller/trunk/DiskListWidget.h	Mon Jan 17 02:01:32 2011
@@ -24,6 +24,7 @@
 public:
     DiskListWidget( QWidget * parent = 0 );
     QListWidgetItem *listitem;
+    bool isBiggerThanThreeGB;
     QHash<QString,Solid::Device> * devhash, * parthash;
     virtual ~DiskListWidget();
     

Modified: PLDLiveInstaller/trunk/PLDLiveInstaller.cpp
==============================================================================
--- PLDLiveInstaller/trunk/PLDLiveInstaller.cpp	(original)
+++ PLDLiveInstaller/trunk/PLDLiveInstaller.cpp	Mon Jan 17 02:01:32 2011
@@ -27,10 +27,8 @@
 #include <KTitleWidget>
 #include <KVBox>
 #include <kworkspace/kworkspace.h>
+#include <Solid/AcAdapter>
 #include <Solid/Device>
-#include <Solid/DeviceInterface>
-#include <Solid/StorageDrive>
-#include <Solid/StorageVolume>
 #include <Solid/StorageAccess>
 #include <Solid/Block>
 
@@ -88,8 +86,38 @@
   KRun::runCommand("partitionmanager", this);
 }
 
-QWidget * PLDLiveInstaller::startWidget()
+void PLDLiveInstaller::isACPlugged(bool state)
 {
+  if(state)
+  {
+    acImageChecked->setVisible(true);
+    acImageNotChecked->setVisible(false);
+  }
+  else
+  {
+    acImageChecked->setVisible(false);
+    acImageNotChecked->setVisible(true);
+  }
+}
+
+int PLDLiveInstaller::getMemoryAmount()
+{ 
+  QFile meminfo("/proc/meminfo");	 
+  if (!meminfo.open(QIODevice::ReadOnly | QIODevice::Text))	 
+    return 1;	 
+
+  QString totalMem = meminfo.readLine();
+  totalMem.remove(QRegExp("^MemTotal:[ \t]+"));
+  totalMem.remove(QRegExp("[ \t]+(kB).*"));
+  int totalMemInt = totalMem.toInt()/1024; // MM
+  
+  //qDebug() << "Total Mem:" << totalMemInt;	 
+
+  return totalMemInt;
+}
+
+QWidget * PLDLiveInstaller::startWidget()
+{ 
     KTitleWidget *titleWidget = new KTitleWidget(this);
     titleWidget->setText(i18n("<html><p align=\"center\"><font size=\"10\"><b>Install PLD Linux</b></font><br /><br />"
 	  "<font size=\"5\"><b>To set up the installation of PLD Linux, click Next</b></font>"
@@ -104,17 +132,106 @@
     ));
     text->setAlignment(Qt::AlignCenter);
     text->setWordWrap(true);
+    text->setFixedHeight(200);
+    
+    QLabel *bestResults = new QLabel;
+    bestResults->setText("<b>For best results, please ensure:</b>");
+    bestResults->setFixedHeight(40);
+    
+    acImageChecked = new QLabel;
+    acImageChecked->setPixmap(KIcon("button_more").pixmap(16));
+    acImageChecked->setFixedWidth(20);
+    acImageChecked->setVisible(false);
+    
+    acImageNotChecked = new QLabel;
+    acImageNotChecked->setPixmap(KIcon("button_fewer").pixmap(16));
+    acImageNotChecked->setFixedWidth(20);
+    acImageNotChecked->setVisible(false);
+    
+    bool isPlugged = false;
+    
+    const QList<Solid::Device> list_ac = Solid::Device::listFromType(Solid::DeviceInterface::AcAdapter, QString());
+    foreach(Solid::Device device_ac, list_ac)
+    {
+      Solid::AcAdapter *ac = device_ac.as<Solid::AcAdapter>();
+      isPlugged |= ac->isPlugged();
+      connect(ac, SIGNAL(plugStateChanged(bool,const QString &)), this, SLOT(isACPlugged(bool)), Qt::UniqueConnection);
+    }
+    
+    isACPlugged(isPlugged);
+    
+    qDebug() << "AC is plugged:" << isPlugged;
+    
+    QLabel *acAdapterText = new QLabel;
+    acAdapterText->setText("that you are plugged in to a power source");
+    acAdapterText->setFixedHeight(30);
+    
+    QHBoxLayout *acadapter = new QHBoxLayout;
+    acadapter->addWidget(acImageChecked);
+    acadapter->addWidget(acImageNotChecked);
+    acadapter->addWidget(acAdapterText);
+    
+    QLabel *ramText = new QLabel;
+    ramText->setText("that you have a least 1GB of RAM");
+    ramText->setFixedHeight(30);
+    
+    QLabel *ramImageChecked = new QLabel;
+    ramImageChecked->setPixmap(KIcon("button_more").pixmap(16));
+    ramImageChecked->setFixedWidth(20);
+    ramImageChecked->setVisible(false);
+    
+    QLabel *ramImageNotChecked = new QLabel;
+    ramImageNotChecked->setPixmap(KIcon("button_fewer").pixmap(16));
+    ramImageNotChecked->setFixedWidth(20);
+    ramImageNotChecked->setVisible(true);
+    
+    if(getMemoryAmount() >= 990)
+    {
+      ramImageChecked->setVisible(true);
+      ramImageNotChecked->setVisible(false);
+    }
+    
+    QHBoxLayout *ramLayout = new QHBoxLayout;
+    ramLayout->addWidget(ramImageChecked);
+    ramLayout->addWidget(ramImageNotChecked);
+    ramLayout->addWidget(ramText);
+    
+    QLabel *driveText = new QLabel;
+    driveText->setText("that you have at least 3GB available drive space");
+    driveText->setFixedHeight(30);
+    
+    QLabel *driveImageChecked = new QLabel;
+    driveImageChecked->setPixmap(KIcon("button_more").pixmap(16));
+    driveImageChecked->setFixedWidth(20);
+    driveImageChecked->setVisible(false);
+    
+    QLabel *driveImageNotChecked = new QLabel;
+    driveImageNotChecked->setPixmap(KIcon("button_fewer").pixmap(16));
+    driveImageNotChecked->setFixedWidth(20);
+    driveImageNotChecked->setVisible(true);
+    
+    if(isBiggerThanThreeGB)
+    {
+      driveImageChecked->setVisible(true);
+      driveImageNotChecked->setVisible(false);
+    }
+    
+    QHBoxLayout *driveLayout = new QHBoxLayout;
+    driveLayout->addWidget(driveImageChecked);
+    driveLayout->addWidget(driveImageNotChecked);
+    driveLayout->addWidget(driveText);
     
     QVBoxLayout *textLayout = new QVBoxLayout;
     textLayout->addWidget(text);
-    
-    QVBoxLayout *buttonBoxLayout = new QVBoxLayout;
-    buttonBoxLayout->setAlignment(Qt::AlignCenter);
+    textLayout->addWidget(bestResults);
+    textLayout->addLayout(acadapter);
+    textLayout->addLayout(ramLayout);
+    textLayout->addLayout(driveLayout);
+    textLayout->addStretch();
    
     QVBoxLayout *layout = new QVBoxLayout;
     layout->addWidget(titleWidget);
     layout->addLayout(textLayout);
-    layout->addLayout(buttonBoxLayout);
     layout->setMargin(30);
     
     QWidget *widget = new QWidget;
@@ -315,6 +432,9 @@
     diskListWidget->setIconSize(QSize(48,48));
     connect(diskListWidget, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(isDiskItemSelected()));
     diskListWidget->refresh();
+    
+    isBiggerThanThreeGB = false;
+    isBiggerThanThreeGB = diskListWidget->isBiggerThanThreeGB;
 
     KPushButton *refresh = new KPushButton(KIcon("view-refresh"), i18n("Refresh list"), buttonBox);
     refresh->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
@@ -1902,6 +2022,10 @@
       partDescr->clear();
       selRoot.clear();
       selSwap.clear();
+      devSizeInfoIcon->setVisible(false);
+      devSizeInfo->setVisible(false);
+      samePartTwiceIcon->setVisible(false);
+      samePartTwice->setVisible(false);
     }
     
     KAssistantDialog::back();

Modified: PLDLiveInstaller/trunk/PLDLiveInstaller.h
==============================================================================
--- PLDLiveInstaller/trunk/PLDLiveInstaller.h	(original)
+++ PLDLiveInstaller/trunk/PLDLiveInstaller.h	Mon Jan 17 02:01:32 2011
@@ -50,6 +50,7 @@
     Solid::Device selectedBlockDev, destPartition, destSwap;
     QLabel *selectPartitionPageText, *installationText, *installationHeader, *failText;
     QLabel *devSizeInfo, *devSizeInfoIcon, *samePartTwice, *samePartTwiceIcon;
+    QLabel *acImageChecked, *acImageNotChecked;
     QStringList availablePartitions, fsTypes, formatOpts;
     KComboBox * rootPart,* swapPart, * fs;
     QRadioButton *autoLogin, *noAutoLogin, *entireDisk, *notEntireDisk;
@@ -75,6 +76,8 @@
     void rereadPartitionTable(QString device);
     void destroyPartitionTable(QString device);
     void createPartitionTable(QString device);
+    int getMemoryAmount();
+    bool isBiggerThanThreeGB;
     
 public:
     PLDLiveInstaller( QWidget * parent = 0 );
@@ -97,6 +100,7 @@
     void checkPwMatch();
     void startPM();
     void enablePMbutton(bool state);
+    void isACPlugged(bool state);
 };
 
 #endif // PLDLiveInstaller_H

Modified: PLDLiveInstaller/trunk/Version.h
==============================================================================
--- PLDLiveInstaller/trunk/Version.h	(original)
+++ PLDLiveInstaller/trunk/Version.h	Mon Jan 17 02:01:32 2011
@@ -1,3 +1,3 @@
-#define	VERSION "0.23"
+#define	VERSION "0.24"
 #define VERSION_STR "Version " VERSION
 #define KDEVER "4.5"


More information about the pld-cvs-commit mailing list