[PC-BSD Commits] r19962 - pcbsd/current/src-qt4/about-gui

svn at pcbsd.org svn at pcbsd.org
Fri Oct 26 05:06:24 PDT 2012


Author: yurkis
Date: 2012-10-26 12:06:24 +0000 (Fri, 26 Oct 2012)
New Revision: 19962

Modified:
   pcbsd/current/src-qt4/about-gui/mainwindow.cpp
   pcbsd/current/src-qt4/about-gui/mainwindow.h
Log:
Quick changes for pkgng support (about gui)

Modified: pcbsd/current/src-qt4/about-gui/mainwindow.cpp
===================================================================
--- pcbsd/current/src-qt4/about-gui/mainwindow.cpp	2012-10-26 11:55:02 UTC (rev 19961)
+++ pcbsd/current/src-qt4/about-gui/mainwindow.cpp	2012-10-26 12:06:24 UTC (rev 19962)
@@ -44,7 +44,15 @@
     {"XFCE", "xfce-"}
 };
 
+const SComponent DEComponentsNG[]={
+    {"KDE", "kde-workspace"},
+    {"Gnome", "gnome-desktop"},
+    {"LXDE", "lxde-meta"},
+    {"XFCE", "XFCE"}
+};
+
 const int DEComponents_size = sizeof(DEComponents) / sizeof(SComponent);
+const int DEComponentsNG_size = sizeof(DEComponentsNG) / sizeof(SComponent);
 
 ////////////////////////////////////////////////////////////////////////////
 MainWindow::MainWindow(QWidget *parent) :
@@ -105,6 +113,32 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////
+bool MainWindow::checkNG()
+{
+    return QFile::exists("/usr/local/sbin/pkg2ng");
+}
+
+////////////////////////////////////////////////////////////////////////////
+bool MainWindow::checkNGPackage(QString name, QString &outVer)
+{
+    outVer="";
+    QStringList out = Utils::runShellCommand(QString("pkg info -f ") + name);
+    if (!out.size())
+        return false;
+    for (int i=0; i<out.size(); i++)
+    {
+        if (out[i].contains("Version"))
+        {
+            outVer = out[i];
+            outVer.replace("Version        : ","");
+            qDebug()<<out[i];
+            break;
+        }
+    }
+    return ( outVer.length() > 0 );
+}
+
+////////////////////////////////////////////////////////////////////////////
 void MainWindow::slotSingleInstance()
 {
     this->hide();
@@ -131,14 +165,36 @@
 
     ui->WaitTextLabel->setVisible(true);
     ui->DEList->clear();
-    pkginfo = new QProcess(this);
-    pkginfo->setProcessChannelMode(QProcess::MergedChannels);
-    connect( pkginfo, SIGNAL(readyRead()), this, SLOT(slotReadPkg() ) );
-    connect( pkginfo, SIGNAL(finished ( int, QProcess::ExitStatus)), this, SLOT(slotPackagesFinished(int, QProcess::ExitStatus)));
-    pkginfo->start("pkg_info");
 
+    if (!checkNG())
+    {
+        pkginfo = new QProcess(this);
+        pkginfo->setProcessChannelMode(QProcess::MergedChannels);
+        connect( pkginfo, SIGNAL(readyRead()), this, SLOT(slotReadPkg() ) );
+        connect( pkginfo, SIGNAL(finished ( int, QProcess::ExitStatus)), this, SLOT(slotPackagesFinished(int, QProcess::ExitStatus)));
+        pkginfo->start("pkg_info");
+    }
+    else
+    {
+        for(int i=0 ; i<DEComponentsNG_size; i++)
+        {
+            QString ver;
+            if (checkNGPackage(DEComponentsNG[i].Prefix, ver))
+            {
+                QTreeWidgetItem* item = new QTreeWidgetItem(ui->DEList);
+                item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
+                QFont font = item->font(0);
+                font.setBold(true);
+                item->setFont(0, font);
+                item->setText(0, DEComponentsNG[i].Name);
+                item->setText(1, ver);
+
+                ui->DEList->addTopLevelItem(item);
+            }
+        }//for all DEs
+    }//if pkgng installed
+
     ui->MainStack->setCurrentIndex(1);
-    //MainStack-
 }
 
 ////////////////////////////////////////////////////////////////////////////

Modified: pcbsd/current/src-qt4/about-gui/mainwindow.h
===================================================================
--- pcbsd/current/src-qt4/about-gui/mainwindow.h	2012-10-26 11:55:02 UTC (rev 19961)
+++ pcbsd/current/src-qt4/about-gui/mainwindow.h	2012-10-26 12:06:24 UTC (rev 19962)
@@ -40,6 +40,9 @@
     explicit MainWindow(QWidget *parent = 0);
     ~MainWindow();
     
+    bool checkNG();
+    bool checkNGPackage(QString name, QString& outVer);
+
 public slots:
     void slotSingleInstance();
     void slotPackagesFinished(int exitCode, QProcess::ExitStatus exitStatus );
@@ -49,7 +52,7 @@
 
     void on_BackButton_clicked();
 
-    void slotReadPkg();
+    void slotReadPkg();    
 
 private:
     Ui::MainWindow *ui;



More information about the Commits mailing list