[PC-BSD Commits] r12107 - pcbsd/current/src-qt4/pc-controlpanel
svn at pcbsd.org
svn at pcbsd.org
Thu Aug 11 17:11:07 PDT 2011
Author: yurkis
Date: 2011-08-11 17:11:07 -0700 (Thu, 11 Aug 2011)
New Revision: 12107
Modified:
pcbsd/current/src-qt4/pc-controlpanel/deinfo.cpp
pcbsd/current/src-qt4/pc-controlpanel/deinfo.h
pcbsd/current/src-qt4/pc-controlpanel/grouplist.cpp
pcbsd/current/src-qt4/pc-controlpanel/grouplist.h
pcbsd/current/src-qt4/pc-controlpanel/item.cpp
pcbsd/current/src-qt4/pc-controlpanel/item.h
pcbsd/current/src-qt4/pc-controlpanel/mainwnd.cpp
pcbsd/current/src-qt4/pc-controlpanel/mainwnd.h
pcbsd/current/src-qt4/pc-controlpanel/mainwnd.ui
pcbsd/current/src-qt4/pc-controlpanel/pbiinfo.cpp
pcbsd/current/src-qt4/pc-controlpanel/pbiinfo.h
Log:
Last functional ubdate for pc-controlpanel till 9.0 release. 1. Now window is disabled while items refresh. 2. application automatically reload items on pbi install/uninstall or items set changed. 3. some internal changes (some object turnet to singleton). PS Sorry for adding string after translation freeze
Modified: pcbsd/current/src-qt4/pc-controlpanel/deinfo.cpp
===================================================================
--- pcbsd/current/src-qt4/pc-controlpanel/deinfo.cpp 2011-08-11 18:57:53 UTC (rev 12106)
+++ pcbsd/current/src-qt4/pc-controlpanel/deinfo.cpp 2011-08-12 00:11:07 UTC (rev 12107)
@@ -106,3 +106,10 @@
}
return NULL;
}
+
+///////////////////////////////////////////////////////////////////////////////
+CSingleDEList& CSingleDEList::getRef()
+{
+ static CSingleDEList instance;
+ return instance;
+}
Modified: pcbsd/current/src-qt4/pc-controlpanel/deinfo.h
===================================================================
--- pcbsd/current/src-qt4/pc-controlpanel/deinfo.h 2011-08-11 18:57:53 UTC (rev 12106)
+++ pcbsd/current/src-qt4/pc-controlpanel/deinfo.h 2011-08-12 00:11:07 UTC (rev 12107)
@@ -90,4 +90,14 @@
QVector <CDEInfo> mvDE;
};
+///////////////////////////////////////////////////////
+// Singleton object for DE list
+class CSingleDEList:public CDEList
+{
+public:
+ static CSingleDEList& getRef();
+};
+
+static CSingleDEList& InstalledDEList = CSingleDEList::getRef();
+
#endif // DEINFO_F
Modified: pcbsd/current/src-qt4/pc-controlpanel/grouplist.cpp
===================================================================
--- pcbsd/current/src-qt4/pc-controlpanel/grouplist.cpp 2011-08-11 18:57:53 UTC (rev 12106)
+++ pcbsd/current/src-qt4/pc-controlpanel/grouplist.cpp 2011-08-12 00:11:07 UTC (rev 12107)
@@ -39,8 +39,7 @@
}
///////////////////////////////////////////////////////////////////////////////
-int QGroupList::read(QString Path, CInstalledPBI* PBIs,
- const QVector<QString>& vEnabledDE, const CDEInfo& CurrentDE)
+int QGroupList::read(QString Path, const QVector<QString>& vEnabledDE)
{
clear();
QDir dir(Path);
@@ -52,8 +51,7 @@
{
QCPItem* anItem = new QCPItem;
- if (anItem->read(dir.absoluteFilePath(DirList[i]), PBIs,
- vEnabledDE, CurrentDE))
+ if (anItem->read(dir.absoluteFilePath(DirList[i]), vEnabledDE))
addItem(anItem);
else
delete anItem;
Modified: pcbsd/current/src-qt4/pc-controlpanel/grouplist.h
===================================================================
--- pcbsd/current/src-qt4/pc-controlpanel/grouplist.h 2011-08-11 18:57:53 UTC (rev 12106)
+++ pcbsd/current/src-qt4/pc-controlpanel/grouplist.h 2011-08-12 00:11:07 UTC (rev 12107)
@@ -36,11 +36,10 @@
explicit QGroupList(QWidget *parent = 0);
//! Read category list
- int read(QString Path, CInstalledPBI* PBIs,
- const QVector<QString>& vEnabledDE, const CDEInfo& CurrentDE);
+ int read(QString Path, const QVector<QString>& vEnabledDE);
//! Set name filter string
- bool setFilter(const QString& filetrString);
+ bool setFilter(const QString& filetrString);
void setDisplayDEName(bool isDisplay);
Modified: pcbsd/current/src-qt4/pc-controlpanel/item.cpp
===================================================================
--- pcbsd/current/src-qt4/pc-controlpanel/item.cpp 2011-08-11 18:57:53 UTC (rev 12106)
+++ pcbsd/current/src-qt4/pc-controlpanel/item.cpp 2011-08-12 00:11:07 UTC (rev 12107)
@@ -49,22 +49,24 @@
const QString DEFAULT_ICON_LOCATION = PREFIX + "/share/pcbsd/pc-controlpanel/icons/";
const char* const DEFAULT_ICON = "preferences-other.png";
-QCPItem::QCPItem():misValid(false), misMsgBox(false), mPBIs(NULL)
+QCPItem::QCPItem():misValid(false), misMsgBox(false)
{
}
///////////////////////////////////////////////////////////////////////////////
-bool QCPItem::read(QString FileName, CInstalledPBI* pPBIList,
- const QVector<QString>& vEnabledDE, const CDEInfo& CurrentDE)
+bool QCPItem::read(QString FileName, const QVector<QString>& vEnabledDE)
{
QString Str;
bool isPBISoftware = false;
misValid= false;
misSubstFound = false;
- misUseXDG = CurrentDE.misXDG;
+ misUseXDG = false;
+ if (InstalledDEList.active())
+ misUseXDG = InstalledDEList.active()->misXDG;
+
misXDGLaunch = false;
- mPBIs = pPBIList;
+
SPBIInfo PBIInfo;
mvEnabledDE = vEnabledDE;
@@ -96,11 +98,9 @@
Str= Reader.value(PBI_NAME_FIELD).toString();
if (Str.length())
- {
- if (!mPBIs)
+ {
+ if (!InstalledPBIs.findByName(Str, PBIInfo, Qt::CaseInsensitive))
return false;
- if (!mPBIs->findByName(Str, PBIInfo, Qt::CaseInsensitive))
- return false;
/*if (!getPBIPath(Str, mPBIPath))
return false;*/
mPBIPath = PBIInfo.mPrefix;
Modified: pcbsd/current/src-qt4/pc-controlpanel/item.h
===================================================================
--- pcbsd/current/src-qt4/pc-controlpanel/item.h 2011-08-11 18:57:53 UTC (rev 12106)
+++ pcbsd/current/src-qt4/pc-controlpanel/item.h 2011-08-12 00:11:07 UTC (rev 12107)
@@ -44,8 +44,7 @@
*
* @return TRUE if success and item is visible
*/
- bool read(QString FileName, CInstalledPBI* pPBIList,
- const QVector<QString>& vEnabledDE, const CDEInfo& CurrentDE);
+ bool read(QString FileName, const QVector<QString>& vEnabledDE);
/**
* Check for valid data
@@ -93,10 +92,8 @@
bool misXDGLaunch;
QString mRequiredDE;
bool misSubstFound;
- QVector<QString> mvEnabledDE;
+ QVector<QString> mvEnabledDE;
- CInstalledPBI* mPBIs;
-
bool getLocalizedField(const QSettings& Reader,
const QString& FieldName,
QString& RetVal);
Modified: pcbsd/current/src-qt4/pc-controlpanel/mainwnd.cpp
===================================================================
--- pcbsd/current/src-qt4/pc-controlpanel/mainwnd.cpp 2011-08-11 18:57:53 UTC (rev 12106)
+++ pcbsd/current/src-qt4/pc-controlpanel/mainwnd.cpp 2011-08-12 00:11:07 UTC (rev 12107)
@@ -36,6 +36,8 @@
#define TOOLS_DIR ITEMS_PREFIX + "tools"
#define DE_DIR ITEMS_PREFIX + "de"
+#define PBI_INSTALLED_DIRECTORY "/var/db/pbi/installed"
+
static QString DETEXT;
///////////////////////////////////////////////////////////////////////////////
@@ -46,18 +48,30 @@
ui->setupUi(this);
setupGroups();
- mDEList.refresh();
- if (mDEList.active())
+ InstalledDEList.refresh();
+ if (InstalledDEList.active())
{
- mCurrentDE = *mDEList.active();
+ mCurrentDE = *InstalledDEList.active();
mvEnabledDE.push_back(mCurrentDE.mName);
- }
+ }
DETEXT = tr("Desktop environment");
DEChoiseMenu = new QMenu("", this);
setupDEChooser();
fillGroups();
+
+ mDirWatcher.addPath(PBI_INSTALLED_DIRECTORY);
+ mDirWatcher.addPath(SOFTWARE_DIR);
+ mDirWatcher.addPath(SYSTEM_DIR);
+ mDirWatcher.addPath(HARDWARE_DIR);
+ mDirWatcher.addPath(NETWORKING_DIR);
+ mDirWatcher.addPath(TOOLS_DIR);
+ mDirWatcher.addPath(DE_DIR);
+
+ QObject::connect(&mDirWatcher, SIGNAL(directoryChanged(const QString &)),
+ this, SLOT(onDirectoryChanged(const QString &)));
+
}
///////////////////////////////////////////////////////////////////////////////
@@ -105,40 +119,39 @@
{
bool isVisible;
- CInstalledPBI InstalledPBIs;
- InstalledPBIs.refresh();
+ ui->centralWidget->setEnabled(false);
+ ui->statusBar->showMessage(tr("Reading items..."));
+ QApplication::processEvents();
- CDEInfo DEInfo;
- isVisible = (bool)SoftwareList->read(SOFTWARE_DIR, &InstalledPBIs,
- mvEnabledDE, mCurrentDE);
+ InstalledPBIs.refresh();
+
+ isVisible = (bool)SoftwareList->read(SOFTWARE_DIR, mvEnabledDE);
ui->SoftwareGBox->setVisible(isVisible);
ui->SoftwareLine->setVisible(isVisible);
- isVisible = (bool)SystemList->read(SYSTEM_DIR, &InstalledPBIs,
- mvEnabledDE, mCurrentDE);
+ isVisible = (bool)SystemList->read(SYSTEM_DIR, mvEnabledDE);
ui->SystemGBox->setVisible(isVisible);
ui->SystemLine->setVisible(isVisible);
- isVisible = (bool)HardwareList->read(HARDWARE_DIR, &InstalledPBIs,
- mvEnabledDE, mCurrentDE);
+ isVisible = (bool)HardwareList->read(HARDWARE_DIR, mvEnabledDE);
ui->HardwareGBox->setVisible(isVisible);
ui->HardwareLine->setVisible(isVisible);
- isVisible = (bool)NetworkingList->read(NETWORKING_DIR, &InstalledPBIs,
- mvEnabledDE, mCurrentDE);
+ isVisible = (bool)NetworkingList->read(NETWORKING_DIR, mvEnabledDE);
ui->NetworkingGBox->setVisible(isVisible);
ui->NetworkingLine->setVisible(isVisible);
- isVisible = (bool)ToolsList->read(TOOLS_DIR, &InstalledPBIs,
- mvEnabledDE, mCurrentDE);
+ isVisible = (bool)ToolsList->read(TOOLS_DIR, mvEnabledDE);
ui->ToolsGBox->setVisible(isVisible);
ui->ToolsLine->setVisible(isVisible);
- isVisible = (bool)DEList->read(DE_DIR, &InstalledPBIs,
- mvEnabledDE, mCurrentDE);
+ isVisible = (bool)DEList->read(DE_DIR, mvEnabledDE);
ui->DEGBox->setVisible(isVisible);
- ui->DELine->setVisible(isVisible);
+ ui->DELine->setVisible(isVisible);
+
+ ui->statusBar->clearMessage();
+ ui->centralWidget->setEnabled(true);
}
///////////////////////////////////////////////////////////////////////////////
@@ -203,18 +216,18 @@
DEChoiseMenu->addAction(ui->actionXFCE);
DEChoiseMenu->addAction(ui->actionLXDE);
DEChoiseMenu->addAction(ui->actionEnlightenment);
- DEChoiseMenu->addAction(ui->actionUnsupported);
+ DEChoiseMenu->addAction(ui->actionUnsupported);
ui->DEChooserButton->setMenu(DEChoiseMenu);
- QString Current = tr("(current)");
- QString Unsupported= tr("Unsupported DE");
+ QString Current = tr("(current)");
+ QString Unsupported= tr("Unsupported DE");
#define SETUP_ACTION(action_name, DEName)\
- if (mDEList.byName(DEName))\
+ if (InstalledDEList.byName(DEName))\
{\
ui->action_name->setVisible(true);\
- if (mDEList.byName(DEName)->misActive){\
+ if (InstalledDEList.byName(DEName)->misActive){\
ui->action_name->setText(QString(DEName) + Current);\
ui->DEChooserButton->setIcon(ui->action_name->icon());}\
else\
@@ -229,7 +242,7 @@
#undef SETUP_ACTION
- if (!mDEList.active())
+ if (!InstalledDEList.active())
{
ui->actionUnsupported->setText(Unsupported + Current);
ui->DEChooserButton->setIcon(ui->actionUnsupported->icon());
@@ -238,7 +251,7 @@
else
ui->actionUnsupported->setVisible(false);
- ui->DEChooserButton->setVisible(mDEList.size()>1);
+ ui->DEChooserButton->setVisible(InstalledDEList.size()>1);
}
@@ -248,9 +261,9 @@
ui->DEChooserButton->setIcon(ui->actionAll->icon());
mvEnabledDE.clear();
- for (int i=0; i<mDEList.size(); i++)
+ for (int i=0; i<InstalledDEList.size(); i++)
{
- mvEnabledDE.push_back(mDEList[i].mName);
+ mvEnabledDE.push_back(InstalledDEList[i].mName);
}
ui->DEGBox->setTitle(DETEXT + " " + tr ("(All installed)"));
@@ -361,6 +374,7 @@
on_toolButton_2_clicked();
}
+///////////////////////////////////////////////////////////////////////////////
void MainWnd::slotSingleInstance()
{
this->hide();
@@ -368,3 +382,10 @@
this->activateWindow();
this->raise();
}
+
+///////////////////////////////////////////////////////////////////////////////
+void MainWnd::onDirectoryChanged(const QString& path)
+{
+ //Refresh if items or installed pbis dir was changed
+ on_toolButton_2_clicked();
+}
Modified: pcbsd/current/src-qt4/pc-controlpanel/mainwnd.h
===================================================================
--- pcbsd/current/src-qt4/pc-controlpanel/mainwnd.h 2011-08-11 18:57:53 UTC (rev 12106)
+++ pcbsd/current/src-qt4/pc-controlpanel/mainwnd.h 2011-08-12 00:11:07 UTC (rev 12107)
@@ -26,6 +26,7 @@
#define MAINWND_H
#include <QMainWindow>
+#include <QFileSystemWatcher>
#include "grouplist.h"
@@ -57,12 +58,14 @@
QGroupList* HardwareList;
QGroupList* DEList;
+ QFileSystemWatcher mDirWatcher;
+
void setupGroups();
void setupGroup(QGroupList** List, QWidget* Parrent);
void fillGroups();
void setupDEChooser();
- CDEList mDEList;
+ //CDEList mDEList;
QMenu* DEChoiseMenu;
QVector<QString> mvEnabledDE;
@@ -80,6 +83,8 @@
void on_toolButton_2_clicked();
void on_lineEdit_textChanged( QString );
void on_itemActivated ( QListWidgetItem* item );
+
+ void onDirectoryChanged(const QString & path);
};
#endif // MAINWND_H
Modified: pcbsd/current/src-qt4/pc-controlpanel/mainwnd.ui
===================================================================
--- pcbsd/current/src-qt4/pc-controlpanel/mainwnd.ui 2011-08-11 18:57:53 UTC (rev 12106)
+++ pcbsd/current/src-qt4/pc-controlpanel/mainwnd.ui 2011-08-12 00:11:07 UTC (rev 12107)
@@ -108,8 +108,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>589</width>
- <height>348</height>
+ <width>581</width>
+ <height>331</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
@@ -266,7 +266,7 @@
<x>0</x>
<y>0</y>
<width>603</width>
- <height>18</height>
+ <height>23</height>
</rect>
</property>
</widget>
Modified: pcbsd/current/src-qt4/pc-controlpanel/pbiinfo.cpp
===================================================================
--- pcbsd/current/src-qt4/pc-controlpanel/pbiinfo.cpp 2011-08-11 18:57:53 UTC (rev 12106)
+++ pcbsd/current/src-qt4/pc-controlpanel/pbiinfo.cpp 2011-08-12 00:11:07 UTC (rev 12107)
@@ -120,3 +120,11 @@
}//for
return false;
}
+
+///////////////////////////////////////////////////////////////////////////////
+CSingleInstalledPBI& CSingleInstalledPBI::getRef()
+{
+ static CSingleInstalledPBI instance;
+ return instance;
+}
+
Modified: pcbsd/current/src-qt4/pc-controlpanel/pbiinfo.h
===================================================================
--- pcbsd/current/src-qt4/pc-controlpanel/pbiinfo.h 2011-08-11 18:57:53 UTC (rev 12106)
+++ pcbsd/current/src-qt4/pc-controlpanel/pbiinfo.h 2011-08-12 00:11:07 UTC (rev 12107)
@@ -71,4 +71,13 @@
protected:
};
+//! Singletone object with installed pbi
+class CSingleInstalledPBI: public CInstalledPBI
+{
+public:
+ static CSingleInstalledPBI& getRef();
+};
+
+//! singletone instance with installed pbi list
+static CSingleInstalledPBI& InstalledPBIs = CSingleInstalledPBI::getRef();
#endif // PBIINFO_H
More information about the Commits
mailing list