Skip to content

Commit

Permalink
fixed dpkg get packages
Browse files Browse the repository at this point in the history
  • Loading branch information
oguzhaninan committed Feb 27, 2018
1 parent 3b626b9 commit 34bad95
Show file tree
Hide file tree
Showing 4 changed files with 151 additions and 146 deletions.
7 changes: 4 additions & 3 deletions stacer-core/Tools/package_tool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ QStringList PackageTool::getDpkgPackages()
try {
packageList = CommandUtil::exec("bash", {"-c", "dpkg --get-selections 2> /dev/null"})
.trimmed()
.split("\n");
.split('\n')
.filter(QRegExp("\\s+install$"));

for (int i = 0; i < packageList.count(); ++i)
packageList[i] = packageList.at(i).split(QRegExp("\\s+")).first();
Expand Down Expand Up @@ -66,7 +67,7 @@ QStringList PackageTool::getRpmPackages()
try {
packageList = CommandUtil::exec("bash", {"-c", "rpm -qa 2> /dev/null"})
.trimmed()
.split("\n");
.split('\n');

} catch(QString &ex) {
qCritical() << ex;
Expand Down Expand Up @@ -126,7 +127,7 @@ QStringList PackageTool::getPacmanPackages()
try {
packageList = CommandUtil::exec("bash", {"-c", "pacman -Q 2> /dev/null"})
.trimmed()
.split("\n");
.split('\n');

for (int i = 0; i < packageList.count(); ++i)
packageList[i] = packageList.at(i).split(QRegExp("\\s+")).first();
Expand Down
4 changes: 2 additions & 2 deletions stacer/Managers/tool_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ QFileInfoList ToolManager::getPackageCaches() const

void ToolManager::uninstallPackages(const QStringList &packages)
{
uninstallStarted();
emit uninstallStarted();

switch (PackageTool::currentPackageTool) {
case PackageTool::PackageTools::APT:
Expand All @@ -100,7 +100,7 @@ void ToolManager::uninstallPackages(const QStringList &packages)
break;
}

uninstallFinished();
emit uninstallFinished();
}

/******************
Expand Down
13 changes: 6 additions & 7 deletions stacer/Pages/Uninstaller/uninstaller_page.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,20 @@ void UninstallerPage::init()

QtConcurrent::run(this, &UninstallerPage::loadPackages);

connect(tm, &ToolManager::uninstallFinished, this, &UninstallerPage::loadPackages);
connect(tm, &ToolManager::uninstallStarted, this, &UninstallerPage::uninstallStarted);
connect(tm, &ToolManager::uninstallFinished, this, &UninstallerPage::loadPackages);
}

void UninstallerPage::loadPackages()
{
uninstallStarted();
emit uninstallStarted();

// clear items
ui->packagesList->clear();

QIcon icon(QString(":/static/themes/%1/img/package.svg").arg(AppManager::ins()->getThemeName()));
for (const QString &package : tm->getPackages())
{
QStringList packages = tm->getPackages();
for (const QString &package : packages) {
QListWidgetItem *item = new QListWidgetItem(QIcon::fromTheme(package, icon), QString(" %1").arg(package));

item->setCheckState(Qt::Unchecked);
Expand All @@ -52,7 +52,6 @@ void UninstallerPage::loadPackages()

ui->packagesList->setEnabled(true);
ui->packageSearch->setEnabled(true);
ui->uninstallBtn->show();
ui->packageSearch->clear();

ui->loading->hide();
Expand All @@ -65,6 +64,7 @@ void UninstallerPage::setAppCount()
ui->packagesTitle->setText(tr("System Installed Packages (%1)").arg(count));

ui->notFoundWidget->setVisible(! count);
ui->uninstallBtn->setVisible(count);
ui->packagesList->setVisible(count);
}

Expand All @@ -87,8 +87,7 @@ void UninstallerPage::on_uninstallBtn_clicked()
{
QStringList selectedPackages = getSelectedPackages();

if(! selectedPackages.isEmpty())
{
if(! selectedPackages.isEmpty()) {
QtConcurrent::run([selectedPackages]() -> void {
ToolManager::ins()->uninstallPackages(selectedPackages);
});
Expand Down
Loading

0 comments on commit 34bad95

Please sign in to comment.