diff --git a/PkSession/AbstractIsRunning.cpp b/PkSession/AbstractIsRunning.cpp index be1f3cc..2dc5c15 100644 --- a/PkSession/AbstractIsRunning.cpp +++ b/PkSession/AbstractIsRunning.cpp @@ -1,57 +1,59 @@ /*************************************************************************** - * Copyright (C) 2009-2011 by Daniel Nicoletti * + * Copyright (C) 2009-2018 by Daniel Nicoletti * * dantti12@gmail.com * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; see the file COPYING. If not, write to * * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * * Boston, MA 02110-1301, USA. * ***************************************************************************/ #include "AbstractIsRunning.h" #include #include +Q_DECLARE_LOGGING_CATEGORY(APPER_SESSION) + using namespace PackageKit; AbstractIsRunning::AbstractIsRunning(QObject *parent) : QObject(parent) { } AbstractIsRunning::~AbstractIsRunning() { } void AbstractIsRunning::increaseRunning() { m_running++; -// kDebug(); + qCDebug(APPER_SESSION) << "Increase running" << m_running; } void AbstractIsRunning::decreaseRunning() { m_running--; -// kDebug(); + qCDebug(APPER_SESSION) << "Decrease running" << m_running; if (!isRunning()) { -// kDebug() << "Is not Running anymore"; + qCDebug(APPER_SESSION) << "All tasks completed"; emit close(); } } bool AbstractIsRunning::isRunning() const { return m_running > 0; } diff --git a/PkSession/CMakeLists.txt b/PkSession/CMakeLists.txt index 5c9cb3a..b5b9c23 100644 --- a/PkSession/CMakeLists.txt +++ b/PkSession/CMakeLists.txt @@ -1,58 +1,57 @@ # CMakeLists for Apper PackageKit Session Interface set(pksession_SRCS AbstractIsRunning.cpp FilesModel.cpp IntroDialog.cpp ReviewChanges.cpp SessionTask.cpp PkInterface.cpp PkInstallPackageNames.cpp PkSearchFile.cpp PkIsInstalled.cpp PkInstallMimeTypes.cpp PkInstallGStreamerResources.cpp PkInstallFontconfigResources.cpp PkInstallPlasmaResources.cpp PkInstallPackageFiles.cpp PkInstallProvideFiles.cpp PkInstallCatalogs.cpp PkRemovePackageByFiles.cpp PkInstallPrinterDrivers.cpp PkSession.cpp main.cpp ) qt5_add_dbus_adaptor(pksession_SRCS org.freedesktop.PackageKit.xml PkInterface.h PkInterface ) ki18n_wrap_ui(pksession_SRCS IntroDialog.ui ReviewChanges.ui SessionTask.ui ) add_executable(apper-pk-session ${pksession_SRCS} ) target_link_libraries(apper-pk-session + Qt5::XmlPatterns KF5::WidgetsAddons KF5::KIOFileWidgets KF5::IconThemes KF5::DBusAddons ${PackageKitQt5_LIBRARIES} apper_private ) -qt5_use_modules(apper-pk-session Core XmlPatterns) - set_target_properties(apper-pk-session PROPERTIES INSTALL_RPATH ${CMAKE_INSTALL_FULL_LIBDIR}/apper) install(TARGETS apper-pk-session DESTINATION ${CMAKE_INSTALL_LIBEXECDIR}) include(MacroDBusAddActivationService) dbus_add_activation_service(org.freedesktop.PackageKit.service.in) diff --git a/PkSession/FilesModel.cpp b/PkSession/FilesModel.cpp index b63e78a..9cbb9e6 100644 --- a/PkSession/FilesModel.cpp +++ b/PkSession/FilesModel.cpp @@ -1,179 +1,179 @@ /*************************************************************************** - * Copyright (C) 2009-2010 by Daniel Nicoletti * + * Copyright (C) 2009-2018 by Daniel Nicoletti * * dantti12@gmail.com * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; see the file COPYING. If not, write to * * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * * Boston, MA 02110-1301, USA. * ***************************************************************************/ #include "FilesModel.h" #include #include #include #include #include #include #include #include #include #include Q_DECLARE_LOGGING_CATEGORY(APPER_SESSION) FilesModel::FilesModel(const QStringList &files, const QStringList &mimes, QObject *parent) -: QStandardItemModel(parent), - m_mimes(mimes) + : QStandardItemModel(parent) + , m_mimes(mimes) { if (!files.isEmpty()) { QList urls; for (const QString &file : files) { urls << QUrl(file); } insertFiles(urls); } else if (!mimes.isEmpty()) { QMimeDatabase db; // we are searching for mimetypes for (const QString &mimeName : mimes) { QMimeType mime = db.mimeTypeForName(mimeName); if (mime.isValid()) { auto item = new QStandardItem(mimeName); item->setData(mimeName); item->setIcon(KIconLoader::global()->loadMimeTypeIcon(mime.iconName(), KIconLoader::Desktop)); appendRow(item); } } } } bool FilesModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) { Q_UNUSED(action) Q_UNUSED(row) Q_UNUSED(column) Q_UNUSED(parent) bool ret = false; if (data->hasUrls()) { ret = insertFiles(data->urls()); } return ret; } bool FilesModel::insertFiles(const QList &urls) { bool ret = false; for (const QUrl &url : urls) { - QString path = QUrl::fromPercentEncoding(url.path().toUtf8()); + const QString path = QUrl::fromPercentEncoding(url.path().toLatin1()); if (files().contains(path)) { continue; } QFileInfo fileInfo(path); QStandardItem *item = 0; if (fileInfo.isFile()) { QMimeDatabase db; QMimeType mime = db.mimeTypeForFile(path, QMimeDatabase::MatchContent); qCDebug(APPER_SESSION) << url << mime.name(); for (const QString &mimeType : qAsConst(m_mimes)) { if (mime.name() == mimeType) { ret = true; -/* kDebug() << "Found Supported Mime" << mimeType << mime->iconName();*/ + qCDebug(APPER_SESSION) << "Found Supported Mime" << mimeType << mime.iconName(); item = new QStandardItem(fileInfo.fileName()); item->setData(path); item->setToolTip(path); item->setIcon(KIconLoader::global()->loadMimeTypeIcon(mime.iconName(), KIconLoader::Desktop)); break; } } if (ret == false && m_mimes.isEmpty()) { - if (mime.name() == "application/x-desktop") { + if (mime.name() == QLatin1String("application/x-desktop")) { auto service = new KService(path); item = new QStandardItem(service->name()); item->setData(true, Qt::UserRole); item->setIcon(KIconLoader::global()->loadMimeTypeIcon(service->icon(), KIconLoader::Desktop)); } else { item = new QStandardItem(fileInfo.fileName()); item->setIcon(KIconLoader::global()->loadMimeTypeIcon(mime.iconName(), KIconLoader::Desktop)); } item->setData(path); item->setToolTip(path); } else if (ret == false && !m_mimes.isEmpty()) { item = new QStandardItem(fileInfo.fileName()); item->setData(path); item->setToolTip(path); item->setEnabled(false); item->setIcon(KIconLoader::global()->loadIcon("dialog-cancel", KIconLoader::Desktop)); } } else if (m_mimes.isEmpty()) { // It's not a file but we don't have a mime so it's ok item = new QStandardItem(fileInfo.fileName()); item->setData(path); item->setToolTip(path); item->setIcon(KIconLoader::global()->loadIcon("unknown", KIconLoader::Desktop)); } if (item) { appendRow(item); } } return ret; } QStringList FilesModel::mimeTypes() const { return { QStringLiteral("text/uri-list") }; } Qt::DropActions FilesModel::supportedDropActions() const { return Qt::CopyAction | Qt::MoveAction | Qt::LinkAction; } Qt::ItemFlags FilesModel::flags(const QModelIndex &index) const { Q_UNUSED(index) return Qt::ItemIsEnabled | Qt::ItemIsDropEnabled; } QStringList FilesModel::files() const { QStringList ret; for (int i = 0; i < rowCount(); ++i) { if (item(i)->isEnabled()) { ret << item(i)->data().toString(); } } return ret; } bool FilesModel::onlyApplications() const { for (int i = 0; i < rowCount(); ++i) { // UserRole is true if it is an application if (item(i)->isEnabled() == true && item(i)->data(Qt::UserRole).toBool() == false) { return false; // there is something that is not an app } } return true; } -#include "FilesModel.moc" +#include "moc_FilesModel.cpp" diff --git a/PkSession/PkInstallCatalogs.cpp b/PkSession/PkInstallCatalogs.cpp index 4ceeef1..74a3abb 100644 --- a/PkSession/PkInstallCatalogs.cpp +++ b/PkSession/PkInstallCatalogs.cpp @@ -1,273 +1,273 @@ /*************************************************************************** * Copyright (C) 2009-2011 by Daniel Nicoletti * * dantti12@gmail.com * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; see the file COPYING. If not, write to * * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * * Boston, MA 02110-1301, USA. * ***************************************************************************/ #include "PkInstallCatalogs.h" #include "IntroDialog.h" #include "FilesModel.h" #include #include #include #include #include #include Q_DECLARE_LOGGING_CATEGORY(APPER_SESSION) PkInstallCatalogs::PkInstallCatalogs(uint xid, const QStringList &files, const QString &interaction, const QDBusMessage &message, QWidget *parent) : SessionTask(xid, interaction, message, parent), m_interaction(interaction), m_message(message) { setWindowTitle(i18n("Install Packages Catalogs")); // Find out how many packages PackageKit is able to resolve QFile file("/etc/PackageKit/PackageKit.conf"); QRegExp rx("\\s*MaximumItemsToResolve=(\\d+)", Qt::CaseSensitive); if (file.open(QIODevice::ReadOnly | QIODevice::Text)) { QTextStream in(&file); while (!in.atEnd()) { if (rx.indexIn(in.readLine()) != -1) { m_maxResolve = rx.capturedTexts()[1].toInt(); break; } } } - QStringList mimes; - mimes << "application/x-catalog"; - mimes << "text/plain"; + const QStringList mimes{ + QLatin1String("application/x-catalog"), QLatin1String("text/plain") + }; m_introDialog = new IntroDialog(this); m_introDialog->acceptDrops(i18n("You can drop more catalogs in here")); m_model = new FilesModel(files, mimes, this); connect(m_model, &FilesModel::rowsInserted, this, &PkInstallCatalogs::modelChanged); m_introDialog->setModel(m_model); setMainWidget(m_introDialog); modelChanged(); } PkInstallCatalogs::~PkInstallCatalogs() { } void PkInstallCatalogs::modelChanged() { - QStringList files = m_model->files(); + const QStringList files = m_model->files(); enableButtonOk(!files.isEmpty()); QString description; if (files.isEmpty()) { description = i18n("No supported catalog was found"); } else { description = i18np("Do you want to install this catalog?", "Do you want to install these catalogs?", files.size()); } m_introDialog->setDescription(description); QString title; // this will come from DBus interface if (parentTitle.isNull()) { title = i18np("An application wants to install a catalog", "An application wants to install catalogs", files.size()); } else { title = i18np("The application %2 wants to install a catalog", "The application %2 wants to install catalogs", files.size(), parentTitle); } setTitle(title); } void PkInstallCatalogs::search() { - QString distroId = Daemon::global()->distroID(); - QStringList parts = distroId.split(';'); + const QString distroId = Daemon::global()->distroID(); + const QStringList parts = distroId.split(QLatin1Char(';')); if (parts.size() != 3) { sendErrorFinished(Failed, "invalid distribution id, please fill a bug against you distribution backend"); return; } - QString distro = parts.at(0); - QString version = parts.at(1); - QString arch = parts.at(2); + const QString distro = parts.at(0); + const QString version = parts.at(1); + const QString arch = parts.at(2); QStringList rxActions; Transaction::Roles roles = Daemon::global()->roles(); if (roles & Transaction::RoleResolve) { - rxActions << "InstallPackages"; + rxActions << QLatin1String("InstallPackages"); } if (roles & Transaction::RoleWhatProvides) { - rxActions << "InstallProvides"; + rxActions << QLatin1String("InstallProvides"); } if (roles & Transaction::RoleSearchFile) { - rxActions << "InstallFiles"; + rxActions << QLatin1String("InstallFiles"); } if (rxActions.isEmpty()) { if (showWarning()) { // TODO display a nicer message informing of already installed ones setInfo(i18n("Not supported"), i18n("Your backend does not support any of the needed " "methods to install a catalog")); } sendErrorFinished(Failed, "not supported by backend"); return; } // matches at the beginning of line installPackages or InstallProvides or installFiles and capture it // matches an optional set of parenthesis // matches *%1* and or *%2* and or *%3* // matches after '=' but ';' at the end QString pattern; pattern = QString( "^(%1)(?:\\((?:.*%2[^;]*(?:;(?:.*%3[^;]*(?:;(?:.*%4[^;]*)?)?)?)?)?\\))?=(.*[^;$])").arg(rxActions.join("|")).arg(distro).arg(version).arg(arch); QRegExp rx(pattern, Qt::CaseInsensitive); QStringList filesFailedToOpen; const QStringList files = m_model->files(); if (!files.isEmpty()) { for (const QString &file : files) { QFile catalog(file); if (catalog.open(QIODevice::ReadOnly | QIODevice::Text)) { QTextStream in(&catalog); while (!in.atEnd()) { if (rx.indexIn(in.readLine()) != -1) { if (rx.cap(1).compare(QLatin1String("InstallPackages"), Qt::CaseInsensitive) == 0) { m_installPackages.append(rx.cap(2).split(';')); } else if (rx.cap(1).compare(QLatin1String("InstallProvides"), Qt::CaseInsensitive) == 0) { m_installProvides.append(rx.cap(2).split(';')); } else if (rx.cap(1).compare(QLatin1String("InstallFiles"), Qt::CaseInsensitive) == 0) { m_installFiles.append(rx.cap(2).split(QLatin1Char(';'))); } } } } else { filesFailedToOpen << file; } } } else { setInfo(i18n("Catalog not found"), i18n("Could not find a catalog to install")); return; } if (showWarning() && filesFailedToOpen.size()) { // TODO display a nicer message informing of already installed ones KMessageBox::sorry(this, i18np("Catalog %2 failed to open", "Catalogs %2 failed to open", filesFailedToOpen.size(), filesFailedToOpen.join(",")), i18n("Failed to open")); } if (m_installPackages.isEmpty() && m_installProvides.isEmpty() && m_installFiles.isEmpty()) { setInfo(i18n("Catalog is Empty"), i18n("Could not find any package to install in this catalog")); } else { // Start resolving searchFinished(PkTransaction::Success); } } void PkInstallCatalogs::searchFinished(PkTransaction::ExitStatus status) { if (status == PkTransaction::Success) { if (!m_installPackages.isEmpty()) { // Continue resolving Install Packages QStringList resolve; int count = 0; while (!m_installPackages.isEmpty() && count < m_maxResolve) { // Remove the items from the list so next call we have less resolve.append(m_installPackages.takeFirst()); ++count; } qCDebug(APPER_SESSION) << "m_installPackages" << m_maxResolve << m_installPackages.size() << resolve.size(); auto transaction = new PkTransaction(this); Transaction *t; t = Daemon::resolve(resolve, Transaction::FilterNotInstalled | Transaction::FilterArch | Transaction::FilterNewest); transaction->setupTransaction(t); setTransaction(Transaction::RoleResolve, transaction); connect(transaction, &PkTransaction::finished, this, &PkInstallCatalogs::searchFinished, Qt::UniqueConnection); connect(transaction, &PkTransaction::package, this, &PkInstallCatalogs::addPackage); } else if (!m_installProvides.isEmpty()) { // Continue resolving Install Provides QStringList provides; int count = 0; while (!m_installProvides.isEmpty() && count < m_maxResolve) { // Remove the items from the list so next call we have less provides.append(m_installProvides.takeFirst()); ++count; } qCDebug(APPER_SESSION) << "m_installProvides" << m_maxResolve << m_installProvides.size() << provides.size(); auto transaction = new PkTransaction(this); Transaction *t; t = Daemon::whatProvides(provides, Transaction::FilterNotInstalled | Transaction::FilterArch | Transaction::FilterNewest); transaction->setupTransaction(t); setTransaction(Transaction::RoleWhatProvides, transaction); connect(transaction, &PkTransaction::finished, this, &PkInstallCatalogs::searchFinished, Qt::UniqueConnection); connect(transaction, &PkTransaction::package, this, &PkInstallCatalogs::addPackage); } else if (!m_installFiles.isEmpty()) { // Continue resolving Install Packages QStringList files; int count = 0; while (!m_installFiles.isEmpty() && count < m_maxResolve) { // Remove the items from the list so next call we have less files.append(m_installFiles.takeFirst()); ++count; } qCDebug(APPER_SESSION) << "m_installFiles" << m_maxResolve << m_installFiles.size() << files.size(); auto transaction = new PkTransaction(this); Transaction *t; t = Daemon::searchFiles(files, Transaction::FilterNotInstalled | Transaction::FilterArch | Transaction::FilterNewest); transaction->setupTransaction(t); setTransaction(Transaction::RoleSearchFile, transaction); connect(transaction, &PkTransaction::finished, this, &PkInstallCatalogs::searchFinished, Qt::UniqueConnection); connect(transaction, &PkTransaction::package, this, &PkInstallCatalogs::addPackage); } else { // we are done resolving SessionTask::searchFinished(status); } } else { // we got an error... SessionTask::searchFinished(status); } } #include "PkInstallCatalogs.moc" diff --git a/PkSession/PkInstallPackageFiles.cpp b/PkSession/PkInstallPackageFiles.cpp index 5022e9a..93e4581 100644 --- a/PkSession/PkInstallPackageFiles.cpp +++ b/PkSession/PkInstallPackageFiles.cpp @@ -1,126 +1,126 @@ /*************************************************************************** - * Copyright (C) 2008-2011 by Daniel Nicoletti * + * Copyright (C) 2008-2018 by Daniel Nicoletti * * dantti12@gmail.com * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; see the file COPYING. If not, write to * * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * * Boston, MA 02110-1301, USA. * ***************************************************************************/ #include "PkInstallPackageFiles.h" #include "IntroDialog.h" #include "FilesModel.h" #include #include #include Q_DECLARE_LOGGING_CATEGORY(APPER_SESSION) PkInstallPackageFiles::PkInstallPackageFiles(uint xid, const QStringList &files, const QString &interaction, const QDBusMessage &message, QWidget *parent) : SessionTask(xid, interaction, message, parent) { setWindowTitle(i18n("Install Packages Files")); -// if (Daemon::global()->roles() & Transaction::RoleInstallFiles) { + if (Daemon::global()->roles() & Transaction::RoleInstallFiles) { m_introDialog = new IntroDialog(this); m_introDialog->acceptDrops(i18n("You can drop more files in here")); m_model = new FilesModel(files, Daemon::global()->mimeTypes(), this); m_introDialog->setModel(m_model); connect(m_model, &FilesModel::rowsInserted, this, &PkInstallPackageFiles::modelChanged); setMainWidget(m_introDialog); modelChanged(); -// } else { -// setError(i18n("Not Supported"), -// i18n("Your current backend does not support installing files")); -// } + } else { + setError(i18n("Not Supported"), + i18n("Your current backend does not support installing files")); + } } PkInstallPackageFiles::~PkInstallPackageFiles() { } void PkInstallPackageFiles::modelChanged() { - QStringList files = m_model->files(); + const QStringList files = m_model->files(); enableButtonOk(!files.isEmpty()); QString description; if (files.isEmpty()) { description = i18n("No supported files were provided"); } else { description = i18np("Press Continue if you want to install this file", "Press Continue if you want to install these files", files.size()); } m_introDialog->setDescription(description); QString title; // this will come from DBus interface if (parentTitle.isNull()) { title = i18np("An application wants to install a package", "An application wants to install packages", files.size()); } else { title = i18np("The application %2 wants to install a package", "The application %2 wants to install packages", files.size(), parentTitle); } setTitle(title); } void PkInstallPackageFiles::commit() { auto transaction = new PkTransaction(this); setTransaction(Transaction::RoleInstallFiles, transaction); connect(transaction, &PkTransaction::finished, this, &PkInstallPackageFiles::transactionFinished, Qt::UniqueConnection); transaction->installFiles(m_model->files()); } void PkInstallPackageFiles::transactionFinished(PkTransaction::ExitStatus status) { qCDebug(APPER_SESSION) << "Finished."; switch (status) { case PkTransaction::Success : if (showFinished()) { setFinish(i18n("Installation Complete"), i18np("File was installed successfully", "Files were installed successfully", m_model->files().count())); } finishTaskOk(); break; case PkTransaction::Cancelled : sendErrorFinished(Cancelled, "Aborted"); break; case PkTransaction::Failed : if (showWarning()) { setError(i18n("Failed to install files"), i18n("Could not install files")); } sendErrorFinished(Failed, i18n("Could not install files")); break; } } #include "PkInstallPackageFiles.moc" diff --git a/PkSession/PkInterface.cpp b/PkSession/PkInterface.cpp index 1e60143..57de96b 100644 --- a/PkSession/PkInterface.cpp +++ b/PkSession/PkInterface.cpp @@ -1,204 +1,193 @@ /*************************************************************************** * Copyright (C) 2008-2011 by Daniel Nicoletti * * dantti12@gmail.com * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; see the file COPYING. If not, write to * * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * * Boston, MA 02110-1301, USA. * ***************************************************************************/ #include "PkInterface.h" #include "packagekitadaptor.h" #include //#include #include "SessionTask.h" #include "PkInstallPackageNames.h" #include "PkInstallMimeTypes.h" #include "PkInstallGStreamerResources.h" #include "PkInstallFontconfigResources.h" #include "PkInstallPlasmaResources.h" #include "PkInstallPackageFiles.h" #include "PkInstallProvideFiles.h" #include "PkInstallCatalogs.h" #include "PkRemovePackageByFiles.h" #include "PkInstallPrinterDrivers.h" #include "PkIsInstalled.h" #include "PkSearchFile.h" #include #include Q_DECLARE_LOGGING_CATEGORY(APPER_SESSION) using namespace PackageKit; PkInterface::PkInterface(QObject *parent) : AbstractIsRunning(parent) { if (!Daemon::isRunning()) { QTimer timer; timer.setInterval(5000); QEventLoop loop; connect(Daemon::global(), &Daemon::isRunningChanged, &loop, &QEventLoop::quit); connect(&timer, &QTimer::timeout, &loop, &QEventLoop::quit); loop.exec(); if (!Daemon::isRunning()) { qCWarning(APPER_SESSION) << "Packagekit didn't start"; qApp->quit(); return; } } qCDebug(APPER_SESSION) << "Creating Helper"; (void) new ModifyAdaptor(this); (void) new QueryAdaptor(this); - if (!QDBusConnection::sessionBus().registerService("org.freedesktop.PackageKit")) { + if (!QDBusConnection::sessionBus().registerService(QLatin1String("org.freedesktop.PackageKit"))) { qCDebug(APPER_SESSION) << "unable to register service to dbus"; return; } - if (!QDBusConnection::sessionBus().registerObject("/org/freedesktop/PackageKit", this)) { + if (!QDBusConnection::sessionBus().registerObject(QLatin1String("/org/freedesktop/PackageKit"), this)) { qCDebug(APPER_SESSION) << "unable to register object to dbus"; return; } } PkInterface::~PkInterface() { } void PkInterface::InstallCatalogs(uint xid, const QStringList &files, const QString &interaction) { qCDebug(APPER_SESSION) << xid << files << interaction; - auto task = new PkInstallCatalogs(xid, files, interaction, message()); - show(task); + show(new PkInstallCatalogs(xid, files, interaction, message())); } void PkInterface::InstallFontconfigResources(uint xid, const QStringList &resources, const QString &interaction) { qCDebug(APPER_SESSION) << xid << resources << interaction; - auto task = new PkInstallFontconfigResources(xid, resources, interaction, message()); - show(task); + show(new PkInstallFontconfigResources(xid, resources, interaction, message())); } void PkInterface::InstallGStreamerResources(uint xid, const QStringList &resources, const QString &interaction) { qCDebug(APPER_SESSION) << xid << resources << interaction; - auto task = new PkInstallGStreamerResources(xid, resources, interaction, message()); - show(task); + show(new PkInstallGStreamerResources(xid, resources, interaction, message())); } void PkInterface::InstallMimeTypes(uint xid, const QStringList &mime_types, const QString &interaction) { qCDebug(APPER_SESSION) << xid << mime_types << interaction; - auto task = new PkInstallMimeTypes(xid, mime_types, interaction, message()); - show(task); + show(new PkInstallMimeTypes(xid, mime_types, interaction, message())); } void PkInterface::InstallPackageFiles(uint xid, const QStringList &files, const QString &interaction) { qCDebug(APPER_SESSION) << xid << files << interaction; - auto task = new PkInstallPackageFiles(xid, files, interaction, message()); - show(task); + show(new PkInstallPackageFiles(xid, files, interaction, message())); } void PkInterface::InstallPackageNames(uint xid, const QStringList &packages, const QString &interaction) { qCDebug(APPER_SESSION) << xid << packages << interaction; - auto task = new PkInstallPackageNames(xid, packages, interaction, message()); - show(task); + show(new PkInstallPackageNames(xid, packages, interaction, message())); } void PkInterface::InstallProvideFiles(uint xid, const QStringList &files, const QString &interaction) { qCDebug(APPER_SESSION) << xid << files << interaction; - auto task = new PkInstallProvideFiles(xid, files, interaction, message()); - show(task); + show(new PkInstallProvideFiles(xid, files, interaction, message())); } void PkInterface::RemovePackageByFiles(uint xid, const QStringList &files, const QString &interaction) { qCDebug(APPER_SESSION) << xid << files << interaction; - auto task = new PkRemovePackageByFiles(xid, files, interaction, message()); - show(task); + show(new PkRemovePackageByFiles(xid, files, interaction, message())); } void PkInterface::InstallPrinterDrivers(uint xid, const QStringList &resources, const QString &interaction) { qCDebug(APPER_SESSION) << xid << resources << interaction; - auto task = new PkInstallPrinterDrivers(xid, resources, interaction, message()); - show(task); + show(new PkInstallPrinterDrivers(xid, resources, interaction, message())); } void PkInterface::InstallPlasmaResources(uint xid, const QStringList &resources, const QString &interaction) { qCDebug(APPER_SESSION) << xid << resources << interaction; - auto task = new PkInstallPlasmaResources(xid, resources, interaction, message()); - show(task); + show(new PkInstallPlasmaResources(xid, resources, interaction, message())); } void PkInterface::InstallResources(uint xid, const QString &type, const QStringList &resources, const QString &interaction) { - if (type == "codec") + if (type == QLatin1String("codec")) { InstallGStreamerResources(xid, resources, interaction); - else if (type == "mimetype") + } else if (type == QLatin1String("mimetype")) { InstallMimeTypes(xid, resources, interaction); - else if (type == "font") + } else if (type == QLatin1String("font")) { InstallFontconfigResources(xid, resources, interaction); - else if (type == "postscript-driver") + } else if (type == QLatin1String("postscript-driver")) { InstallPrinterDrivers(xid, resources, interaction); - else if (type == "plasma-service") + } else if (type == QLatin1String("plasma-service")) { InstallPlasmaResources(xid, resources, interaction); - else - sendErrorReply("org.freedesktop.PackageKit.Failed", "Unsupported resource type"); + } else { + sendErrorReply(QStringLiteral("org.freedesktop.PackageKit.Failed"), QStringLiteral("Unsupported resource type")); + } } //Query bool PkInterface::IsInstalled(const QString &package_name, const QString &interaction) { - auto task = new PkIsInstalled(package_name, interaction, message()); - show(task); + show(new PkIsInstalled(package_name, interaction, message())); // This is discarted return false; } bool PkInterface::SearchFile(const QString &file_name, const QString &interaction, QString &package_name) { Q_UNUSED(package_name) - auto task = new PkSearchFile(file_name, interaction, message()); - show(task); + show(new PkSearchFile(file_name, interaction, message())); // This is discarted return false; } void PkInterface::show(SessionTask *widget) { increaseRunning(); setDelayedReply(true); connect(widget, &SessionTask::finished, this, &PkInterface::decreaseRunning); if (widget->parentWId()) { // Check before showing if the widget has // a parent, otherwise it should not be modal // to not lock the application widget->setWindowModality(Qt::WindowModal); } widget->show(); // KWindowSystem::forceActiveWindow(widget->winId()); // KWindowSystem::setMainWindow(widget, widget->parentWId()); } diff --git a/PkSession/PkInterface.h b/PkSession/PkInterface.h index c496354..be1a352 100644 --- a/PkSession/PkInterface.h +++ b/PkSession/PkInterface.h @@ -1,59 +1,59 @@ /*************************************************************************** * Copyright (C) 2008-2011 by Daniel Nicoletti * * dantti12@gmail.com * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; see the file COPYING. If not, write to * * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * * Boston, MA 02110-1301, USA. * ***************************************************************************/ #ifndef PK_INTERFACE_H #define PK_INTERFACE_H #include #include "AbstractIsRunning.h" class SessionTask; class PkInterface : public AbstractIsRunning, protected QDBusContext { Q_OBJECT Q_CLASSINFO("D-Bus Interface", "org.freedesktop.PackageKit") public: explicit PkInterface(QObject *parent = 0); ~PkInterface(); public Q_SLOTS: void InstallCatalogs(uint xid, const QStringList &files, const QString &interaction); void InstallFontconfigResources(uint xid, const QStringList &resources, const QString &interaction); void InstallGStreamerResources(uint xid, const QStringList &resources, const QString &interaction); void InstallMimeTypes(uint xid, const QStringList &mime_types, const QString &interaction); void InstallPackageFiles(uint xid, const QStringList &files, const QString &interaction); void InstallPackageNames(uint xid, const QStringList &packages, const QString &interaction); - void InstallProvideFiles(uint xid, const QStringList &files, const QString &interaction); - void RemovePackageByFiles(uint xid, const QStringList &files, const QString &interaction); void InstallPrinterDrivers(uint xid, const QStringList &resources, const QString &interaction); + void InstallProvideFiles(uint xid, const QStringList &files, const QString &interaction); void InstallResources(uint xid, const QString &type, const QStringList &resources, const QString &interaction); + void RemovePackageByFiles(uint xid, const QStringList &files, const QString &interaction); //Query bool IsInstalled(const QString &package_name, const QString &interaction); bool SearchFile(const QString &file_name, const QString &interaction, QString &package_name); private: void show(SessionTask *widget); // QVariantHash parseInteraction(const QString &interaction); void InstallPlasmaResources(uint xid, const QStringList &resources, const QString &interaction); }; #endif diff --git a/PkSession/PkSession.cpp b/PkSession/PkSession.cpp index 38f8681..742c80f 100644 --- a/PkSession/PkSession.cpp +++ b/PkSession/PkSession.cpp @@ -1,98 +1,94 @@ /*************************************************************************** * Copyright (C) 2008-2011 by Daniel Nicoletti * * dantti12@gmail.com * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; see the file COPYING. If not, write to * * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * * Boston, MA 02110-1301, USA. * ***************************************************************************/ #include "PkSession.h" #include "PkInterface.h" #include #include -//#include -//#include -//#include #include #include #define MINUTE 60000 Q_DECLARE_LOGGING_CATEGORY(APPER_SESSION) using namespace PackageKit; -PkSession::PkSession(QObject* parent) - : QObject(parent) +PkSession::PkSession(QObject* parent) : QObject(parent) + , m_pkInterface(new PkInterface(this)) { - m_pkInterface = new PkInterface(this); connect(m_pkInterface, &PkInterface::close, this, &PkSession::prepareToClose); Daemon::global()->setHints(QLatin1String("locale=") + QLocale::system().name() + QLatin1String(".UTF-8")); // this enables not quitting when closing a transaction ui qApp->setQuitOnLastWindowClosed(false); // create the close timer and connect it's signal m_closeT = new QTimer(this); connect(m_closeT, &QTimer::timeout, this, &PkSession::close); prepareToClose(); } void PkSession::prepareToClose() { if (isRunning()) { qCDebug(APPER_SESSION) << "Stoping Timer"; m_closeT->stop(); } else { qCDebug(APPER_SESSION) << "Starting Timer: " << MINUTE; m_closeT->start(MINUTE); } } bool PkSession::isRunning() { if (m_pkInterface && m_pkInterface->isRunning()) { qCDebug(APPER_SESSION) << m_pkInterface; return true; } return false; } void PkSession::close() { // This will run when the timer times out, we will check // again just to be sure. if (!isRunning()) { qCDebug(APPER_SESSION) << "Closed by Timer"; qApp->quit(); } } int PkSession::newInstance() { return 0; } PkSession::~PkSession() { } diff --git a/PkSession/PkSession.h b/PkSession/PkSession.h index ed21cec..70c6ae5 100644 --- a/PkSession/PkSession.h +++ b/PkSession/PkSession.h @@ -1,46 +1,46 @@ /*************************************************************************** - * Copyright (C) 2008-2011 by Daniel Nicoletti * + * Copyright (C) 2008-2018 by Daniel Nicoletti * * dantti12@gmail.com * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; see the file COPYING. If not, write to * * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * * Boston, MA 02110-1301, USA. * ***************************************************************************/ #ifndef PKSESSION_H #define PKSESSION_H #include #include class PkInterface; class PkSession : public QObject { Q_OBJECT public: - explicit PkSession(QObject* parent = 0); + explicit PkSession(QObject* parent = nullptr); virtual ~PkSession(); int newInstance(); private Q_SLOTS: void prepareToClose(); void close(); private: bool isRunning(); QTimer *m_closeT; PkInterface *m_pkInterface; }; #endif // PKSESSION_H diff --git a/PkSession/SessionTask.cpp b/PkSession/SessionTask.cpp index b5c4ace..d7e63e3 100644 --- a/PkSession/SessionTask.cpp +++ b/PkSession/SessionTask.cpp @@ -1,659 +1,668 @@ /*************************************************************************** * Copyright (C) 2009-2011 by Daniel Nicoletti * * dantti12@gmail.com * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; see the file COPYING. If not, write to * * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * * Boston, MA 02110-1301, USA. * ***************************************************************************/ #include "SessionTask.h" #include "ui_SessionTask.h" #include "IntroDialog.h" #include "InfoWidget.h" #include "ReviewChanges.h" #include "ApplicationLauncher.h" #include #include #include #include #include #include #include #include #include #include #include //#include #include //#include #include //#include #include #include Q_DECLARE_LOGGING_CATEGORY(APPER_SESSION) using namespace PackageKit; SessionTask::SessionTask(uint xid, const QString &interaction, const QDBusMessage &message, QWidget *parent) : QDialog(parent), m_xid(xid), m_message(message), - m_reviewChanges(0), - m_pkTransaction(0), ui(new Ui::SessionTask) { ui->setupUi(this); setAttribute(Qt::WA_DeleteOnClose); m_model = new PackageModel(this); // connect(KGlobalSettings::self(), SIGNAL(kdisplayPaletteChanged()), // this, SLOT(updatePallete())); updatePallete(); setWindowIcon(QIcon::fromTheme("system-software-install")); -// setButtons(KDialog::Ok | KDialog::Cancel); -// setButtonText(KDialog::Ok, i18n("Continue")); -// setButtonIcon(KDialog::Ok, QIcon::fromTheme("go-next")); + QPushButton *okButton = ui->buttonBox->button(QDialogButtonBox::Ok); + okButton->setText(i18n("Continue")); + okButton->setIcon(QIcon::fromTheme("go-next")); enableButtonOk(false); + connect(okButton, &QPushButton::clicked, this, &SessionTask::slotContinueClicked); + + QPushButton *cancelButton = ui->buttonBox->button(QDialogButtonBox::Cancel); + connect(cancelButton, &QPushButton::clicked, this, &SessionTask::slotCancelClicked); + + Daemon::global()->setHints(QLatin1String("locale=") + QLocale::system().name() + QLatin1String(".UTF-8")); // Defaults to always m_interactions = ConfirmSearch | ConfirmDeps | ConfirmInstall | Progress | Finished | Warning; m_timeout = 0; parseInteraction(interaction); QString cmdline; uint pid; // TODO as we are running on the session it might // be useless to check the PID on the system if ((pid = getPidSession()) != UINT_MAX) { cmdline = getCmdLine(pid); } else if ((pid = getPidSystem()) != UINT_MAX) { cmdline = getCmdLine(pid); } if (!cmdline.isNull()) { setExec(cmdline); } setMinimumSize(QSize(430,280)); // KConfig config("apper"); // KConfigGroup configGroup(&config, "SessionInstaller"); // restoreDialogSize(configGroup); } SessionTask::~SessionTask() { // KConfig config("apper"); // KConfigGroup configGroup(&config, "SessionInstaller"); // saveDialogSize(configGroup); delete ui; } void SessionTask::addPackage(Transaction::Info info, const QString &packageID, const QString &summary) { m_model->addSelectedPackage(info, packageID, summary); } void SessionTask::searchFinished(PkTransaction::ExitStatus status) { if (m_pkTransaction) { // Disconnect so it can be connected to commitFinished latter disconnect(m_pkTransaction->transaction(), &PkTransaction::finished, this, &SessionTask::searchFinished); } if (status == PkTransaction::Success) { m_model->finished(); if (m_model->rowCount() == 0) { notFound(); + showCloseButton(); } else { searchSuccess(); } } else if (status == PkTransaction::Cancelled) { - // TODO PORT -// slotButtonClicked(KDialog::Cancel); + cancelClicked(); } else { searchFailed(); + showCloseButton(); } } void SessionTask::commitFinished(PkTransaction::ExitStatus status) { if (m_pkTransaction) { // Disconnect so it can be connected to something else latter disconnect(m_pkTransaction->transaction(), &PkTransaction::finished, this, &SessionTask::searchFinished); } if (status == PkTransaction::Success) { if (!m_removePackages.isEmpty()) { removePackages(); } else { commitSuccess(); + showCloseButton(); } } else if (status == PkTransaction::Cancelled) { - // TODO PORT -// slotButtonClicked(KDialog::Cancel); + cancelClicked(); } else { commitFailed(); + showCloseButton(); } } void SessionTask::updatePallete() { QPalette pal; // pal.setColor(QPalette::Window, KGlobalSettings::activeTitleColor()); // pal.setColor(QPalette::WindowText, KGlobalSettings::activeTextColor()); ui->backgroundFrame->setPalette(pal); } void SessionTask::setDialog(QDialog *dialog) { // Store the current values QWidget *widget = ui->stackedWidget->currentWidget(); if (qobject_cast(dialog)) { // TODO if there is a removal after instalation // this will break it, but we don't have // this case yet... commitSuccess(dialog); } else { // Set the new ones -// setMainWidget(dialog->mainWidget()); + setMainWidget(dialog); // setTitle(dialog->windowTitle()); // must come after -// connect(this, SIGNAL(okClicked()), -// dialog, SLOT(accept())); + connect(this, &SessionTask::continueClicked, dialog, &QDialog::accept); +// connect(this, &SessionTask::continueClicked, dia, &QDialog::accept); // connect(this, SIGNAL(okClicked()), // dialog->mainWidget(), SLOT(deleteLater())); // connect(this, SIGNAL(okClicked()), // dialog, SLOT(deleteLater())); // Make sure we see the last widget and title auto mapper = new QSignalMapper(this); mapper->setMapping(this, widget); - connect(this, SIGNAL(okClicked()), - mapper, SLOT(map())); - connect(mapper, SIGNAL(mapped(QWidget*)), - this, SLOT(setMainWidget(QWidget*))); + connect(this, &SessionTask::continueClicked, mapper, QOverload<>::of(&QSignalMapper::map)); + connect(mapper, QOverload::of(&QSignalMapper::mapped), this, &SessionTask::setMainWidget); enableButtonOk(true); } } void SessionTask::setMainWidget(QWidget *widget) { if (widget != mainWidget()) { ui->stackedWidget->addWidget(widget); ui->stackedWidget->setCurrentWidget(widget); setTitle(widget->windowTitle()); } } QWidget* SessionTask::mainWidget() { return ui->stackedWidget->currentWidget(); } void SessionTask::setInfo(const QString &title, const QString &text, const QString &details) { auto info = new InfoWidget(this); info->setWindowTitle(title); info->setDescription(text); info->setDetails(details); setMainWidget(info); // setButtons(KDialog::Close); // button(KDialog::Close)->setFocus(); if (qobject_cast(sender())) { // if we have a sender this method was caller by PkTransaction // be carefull because QSignalMapper from KDialog also calls this method sender()->disconnect(); sendErrorFinished(Failed, text); } } void SessionTask::setError(const QString &title, const QString &text, const QString &details) { auto info = new InfoWidget(this); info->setWindowTitle(title); info->setDescription(text); info->setIcon(QIcon::fromTheme("dialog-error")); info->setDetails(details); setMainWidget(info); // setButtons(KDialog::Close); // button(KDialog::Close)->setFocus(); if (qobject_cast(sender())) { // if we have a sender this method was caller by PkTransaction // be carefull because QSignalMapper from KDialog also calls this method sender()->disconnect(); sendErrorFinished(Failed, text); } } void SessionTask::setFinish(const QString &title, const QString &text, QWidget *widget) { auto info = new InfoWidget(this); info->setWindowTitle(title); info->setDescription(text); info->setIcon(QIcon::fromTheme("dialog-ok-apply")); info->addWidget(widget); setMainWidget(info); // setButtons(KDialog::Close); // button(KDialog::Close)->setFocus(); } void SessionTask::setTitle(const QString &title) { ui->titleL->setText(title); } void SessionTask::setExec(const QString &exec) { if (pathIsTrusted(exec)) { // Get from X11 the window title // KWindowInfo info = KWindowSystem::windowInfo(m_xid, NET::WMVisibleName); // parentTitle = info.visibleName(); } else { parentTitle = exec; } } bool SessionTask::pathIsTrusted(const QString &exec) { // special case the plugin helper -- it's trusted return exec == "/usr/libexec/gst-install-plugins-helper" || exec == "/usr/libexec/pk-gstreamer-install" || exec == "/usr/bin/gstreamer-codec-install" || exec == "/usr/lib/packagekit/pk-gstreamer-install" || exec == "/usr/bin/plasma-desktop" || exec == "/usr/bin/apper"; } QString SessionTask::getCmdLine(uint pid) { QFile file(QString("/proc/%1/cmdline").arg(pid)); QString line; if (file.open(QFile::ReadOnly)) { char buf[1024]; qint64 lineLength = file.readLine(buf, sizeof(buf)); if (lineLength != -1) { // the line is available in buf line = QString::fromLocal8Bit(buf); if (!line.contains("(deleted)")) { return line; } } } return QString(); } uint SessionTask::getPidSystem() { QDBusMessage msg; msg = QDBusMessage::createMethodCall("org.freedesktop.DBus", "/org/freedesktop/DBus/Bus", "org.freedesktop.DBus", QLatin1String("GetConnectionUnixProcessID")); msg << m_message.service(); QDBusMessage reply = QDBusConnection::systemBus().call(msg); if (reply.type() != QDBusMessage::ReplyMessage) { qCWarning(APPER_SESSION) << "Message did not receive a reply"; } if (reply.arguments().size() == 1) { return reply.arguments().at(0).toUInt(); } return UINT_MAX; } uint SessionTask::getPidSession() { QDBusMessage msg; msg = QDBusMessage::createMethodCall("org.freedesktop.DBus", "/org/freedesktop/DBus/Bus", "org.freedesktop.DBus", QLatin1String("GetConnectionUnixProcessID")); msg << m_message.service(); QDBusMessage reply = QDBusConnection::sessionBus().call(msg); if (reply.type() != QDBusMessage::ReplyMessage) { qCWarning(APPER_SESSION) << "Message did not receive a reply"; } if (reply.arguments().size() == 1) { return reply.arguments().at(0).toUInt(); } return UINT_MAX; } void SessionTask::search() { qCDebug(APPER_SESSION) << "virtual method called, falling back to commit()"; commit(); } void SessionTask::commit() { qCDebug(APPER_SESSION) << "virtual method called"; if (m_reviewChanges) { QStringList installPackages = m_reviewChanges->model()->selectedPackagesToInstall(); m_removePackages = m_reviewChanges->model()->selectedPackagesToRemove(); if (installPackages.isEmpty() && m_removePackages.isEmpty()) { setInfo(i18n("There are no packages to Install or Remove"), i18n("This action should not happen")); sendErrorFinished(Failed, "to install or remove due to empty lists"); } else if (!installPackages.isEmpty()) { // Install Packages auto transaction = new PkTransaction(this); setTransaction(Transaction::RoleInstallPackages, transaction); connect(transaction, &PkTransaction::finished, this, &SessionTask::commitFinished, Qt::UniqueConnection); transaction->installPackages(installPackages); } else { // Remove them removePackages(); } } } void SessionTask::removePackages() { // Remove Packages auto transaction = new PkTransaction(this); setTransaction(Transaction::RoleRemovePackages, transaction); connect(transaction, &PkTransaction::finished, this, &SessionTask::commitFinished, Qt::UniqueConnection); transaction->removePackages(m_removePackages); m_removePackages.clear(); } void SessionTask::notFound() { qCDebug(APPER_SESSION) << "virtual method called"; if (showWarning()) { setInfo(i18n("Could not find"), i18n("No packages were found that meet the request")); } sendErrorFinished(NoPackagesFound, "no package found"); } void SessionTask::searchFailed() { qCDebug(APPER_SESSION) << "virtual method called"; setInfo(i18n("Failed to find"), i18n("No packages were found that meet the request")); sendErrorFinished(Failed, "failed to search"); } void SessionTask::searchSuccess() { qCDebug(APPER_SESSION) << "virtual method called"; enableButtonOk(true); m_reviewChanges = new ReviewChanges(m_model, this); connect(m_reviewChanges, &ReviewChanges::hasSelectedPackages, this, &SessionTask::enableButtonOk); setMainWidget(m_reviewChanges); } void SessionTask::commitFailed() { qCDebug(APPER_SESSION) << "virtual method called"; // This should not be used to display stuff as the transaction should // emit error() or info() // setInfo(i18n("Failed to commit transaction"), -// PkStrings::errorMessage(m_pkTransaction->error())); +// PkStrings::errsearchFailedorMessage(m_pkTransaction->error())); sendErrorFinished(Failed, i18n("Transaction did not finish with success")); } void SessionTask::commitSuccess(QWidget *widget) { qCDebug(APPER_SESSION) << "virtual method called"; setFinish(i18n("Task completed"), i18n("All operations were committed successfully"), widget); finishTaskOk(); } -void SessionTask::slotButtonClicked(int button) +void SessionTask::showCloseButton() { - if (button == QDialogButtonBox::Ok) { -// qCDebug(APPER_SESSION) << mainWidget()->objectName(); - if (qobject_cast(mainWidget())) { - enableButtonOk(false); - search(); - } else if (qobject_cast(mainWidget())) { - enableButtonOk(false); - commit(); - } else { -// emit okClicked(); - } - } else { -// KDialog::slotButtonClicked(button); - sendErrorFinished(Cancelled, "Aborted by the user"); - } + ui->buttonBox->setStandardButtons(QDialogButtonBox::Close); + QPushButton *closeBt = ui->buttonBox->button(QDialogButtonBox::Close); + closeBt->setDefault(true); + connect(closeBt, &QPushButton::clicked, this, &SessionTask::accept); } void SessionTask::sendErrorFinished(DBusError error, const QString &msg) { QString dbusError; switch (error) { case Failed: - dbusError = "org.freedesktop.PackageKit.Failed"; + dbusError = QLatin1String("org.freedesktop.PackageKit.Failed"); break; case InternalError: - dbusError = "org.freedesktop.PackageKit.InternalError"; + dbusError = QLatin1String("org.freedesktop.PackageKit.InternalError"); break; case NoPackagesFound: - dbusError = "org.freedesktop.PackageKit.NoPackagesFound"; + dbusError = QLatin1String("org.freedesktop.PackageKit.NoPackagesFound"); break; case Forbidden: - dbusError = "org.freedesktop.PackageKit.Forbidden"; + dbusError = QLatin1String("org.freedesktop.PackageKit.Forbidden"); break; case Cancelled: - dbusError = "org.freedesktop.PackageKit.Cancelled"; + dbusError = QLatin1String("org.freedesktop.PackageKit.Cancelled"); break; } - QDBusMessage reply; - reply = m_message.createErrorReply(dbusError, msg); + QDBusMessage reply = m_message.createErrorReply(dbusError, msg); QDBusConnection::sessionBus().send(reply); } bool SessionTask::sendMessageFinished(const QDBusMessage &message) { // emit finished(); return QDBusConnection::sessionBus().send(message); } uint SessionTask::parentWId() const { return m_xid; } -void SessionTask::enableButtonOk(bool state) +void SessionTask::slotContinueClicked() +{ + if (qobject_cast(mainWidget())) { + enableButtonOk(false); + search(); + } else if (qobject_cast(mainWidget())) { + enableButtonOk(false); + commit(); + } else { +// emit okClicked(); + } +} + +void SessionTask::slotCancelClicked() { -// KDialog::enableButtonOk(state); - if (state) { + emit cancelClicked(); + sendErrorFinished(Cancelled, "Aborted by the user"); + reject(); + +} + +void SessionTask::enableButtonOk(bool enable) +{ + QPushButton *okButton = ui->buttonBox->button(QDialogButtonBox::Ok); + okButton->setEnabled(enable); + if (enable) { // When enabling the Continue button put focus on it -// button(KDialog::Ok)->setFocus(); + okButton->setFocus(); } } void SessionTask::parseInteraction(const QString &interaction) { QStringList interactions = interaction.split(','); // Enable or disable all options if (interactions.contains("always")) { m_interactions = ConfirmSearch | ConfirmDeps | ConfirmInstall | Progress | Finished | Warning; } else if (interactions.contains("never")) { m_interactions = 0; } // show custom options if (interactions.contains("show-confirm-search")) { m_interactions |= ConfirmSearch; } if (interactions.contains("show-confirm-deps")) { m_interactions |= ConfirmDeps; } if (interactions.contains("show-confirm-install")) { m_interactions |= ConfirmInstall; } if (interactions.contains("show-progress")) { m_interactions |= Progress; } if (interactions.contains("show-finished")) { m_interactions |= Finished; } if (interactions.contains("show-warning")) { m_interactions |= Warning; } // hide custom options if (interactions.contains("hide-confirm-search")) { m_interactions &= ~ConfirmSearch; } if (interactions.contains("hide-confirm-deps")) { m_interactions &= ~ConfirmDeps; } if (interactions.contains("hide-confirm-install")) { m_interactions &= ~ConfirmInstall; } if (interactions.contains("hide-progress")) { m_interactions &= ~Progress; } if (interactions.contains("hide-finished")) { m_interactions &= ~Finished; } if (interactions.contains("hide-warning")) { m_interactions &= ~Warning; } int index; QRegExp rx("^timeout=(\\d+)$"); index = interactions.indexOf(rx); if (index != -1) { if (rx.indexIn(interactions.at(index)) != -1) { m_timeout = rx.cap(1).toUInt(); } } } bool SessionTask::foundPackages() const { return m_model->rowCount(); } int SessionTask::foundPackagesSize() const { return m_model->rowCount(); } PackageModel *SessionTask::model() const { return m_model; } void SessionTask::setTransaction(Transaction::Role role, PkTransaction *t) { if (m_pkTransaction == 0) { m_pkTransaction = new PkTransactionWidget(this); m_pkTransaction->hideCancelButton(); ui->stackedWidget->addWidget(m_pkTransaction); connect(m_pkTransaction, &PkTransactionWidget::titleChanged, this, &SessionTask::setTitle); - connect(this, SIGNAL(cancelClicked()), - m_pkTransaction, SLOT(cancel())); - connect(m_pkTransaction, SIGNAL(dialog(KDialog*)), - this, SLOT(setDialog(KDialog*))); - connect(m_pkTransaction, SIGNAL(sorry(QString,QString,QString)), - this, SLOT(setInfo(QString,QString,QString))); - connect(m_pkTransaction, SIGNAL(error(QString,QString,QString)), - this, SLOT(setError(QString,QString,QString))); + connect(this, &SessionTask::cancelClicked, m_pkTransaction, &PkTransactionWidget::cancel); + connect(m_pkTransaction, &PkTransactionWidget::dialog, this, &SessionTask::setDialog); + connect(m_pkTransaction, &PkTransactionWidget::sorry, this, &SessionTask::setInfo); + connect(m_pkTransaction, &PkTransactionWidget::error, this, &SessionTask::setError); } - if (t) { m_pkTransaction->setTransaction(t, role); // setTitle(m_pkTransaction->title()); } // avoid changing the current widget if (mainWidget() != m_pkTransaction) { ui->stackedWidget->setCurrentWidget(m_pkTransaction); } } void SessionTask::finishTaskOk() { sendMessageFinished(m_message.createReply()); } SessionTask::Interactions SessionTask::interactions() const { return m_interactions; } uint SessionTask::timeout() const { return m_timeout; } bool SessionTask::showConfirmSearch() const { return m_interactions & ConfirmSearch; } bool SessionTask::showConfirmDeps() const { return m_interactions & ConfirmDeps; } bool SessionTask::showConfirmInstall() const { return m_interactions & ConfirmInstall; } bool SessionTask::showProgress() const { return m_interactions & Progress; } bool SessionTask::showFinished() const { return m_interactions & Finished; } bool SessionTask::showWarning() const { return m_interactions & Warning; } #include "SessionTask.moc" diff --git a/PkSession/SessionTask.h b/PkSession/SessionTask.h index 9643271..d69f393 100644 --- a/PkSession/SessionTask.h +++ b/PkSession/SessionTask.h @@ -1,144 +1,150 @@ /*************************************************************************** * Copyright (C) 2009-2011 by Daniel Nicoletti * * dantti12@gmail.com * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; see the file COPYING. If not, write to * * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * * Boston, MA 02110-1301, USA. * ***************************************************************************/ #ifndef SESSION_TASK_H #define SESSION_TASK_H #include #include #include #include namespace Ui { class SessionTask; } class PackageModel; class ReviewChanges; class PkTransactionWidget; class SessionTask : public QDialog { Q_OBJECT Q_ENUMS(Errors) public: SessionTask(uint xid, const QString &interaction, const QDBusMessage &message, QWidget *parent = 0); ~SessionTask(); typedef enum{ Failed, InternalError, NoPackagesFound, Forbidden, Cancelled } DBusError; enum Interaction { ConfirmSearch = 0x001, ConfirmDeps = 0x002, ConfirmInstall = 0x004, Progress = 0x010, Finished = 0x020, Warning = 0x040, Unknown = 0x100 }; Q_DECLARE_FLAGS(Interactions, Interaction) typedef struct { Transaction::Info info; QString packageID; QString summary; } IPackage; bool showConfirmSearch() const; bool showConfirmDeps() const; bool showConfirmInstall() const; bool showProgress() const; bool showFinished() const; bool showWarning() const; - virtual void slotButtonClicked(int button); - Interactions interactions() const; uint timeout() const; QWidget* mainWidget(); uint parentWId() const; + void slotContinueClicked(); + void slotCancelClicked(); + +Q_SIGNALS: + void continueClicked(); + void cancelClicked(); + public Q_SLOTS: - void enableButtonOk(bool state); + void enableButtonOk(bool enable); void setMainWidget(QWidget *widget); protected: // Virtual methods to easy subclasses virtual void search(); virtual void commit(); virtual void notFound(); virtual void searchFailed(); virtual void searchSuccess(); virtual void commitFailed(); virtual void commitSuccess(QWidget *widget = 0); + void showCloseButton(); bool foundPackages() const; int foundPackagesSize() const; PackageModel* model() const; void setTransaction(Transaction::Role role, PkTransaction *transaction = 0); void finishTaskOk(); void sendErrorFinished(DBusError error, const QString &msg); bool sendMessageFinished(const QDBusMessage &message); QString parentTitle; protected Q_SLOTS: void setTitle(const QString &title); void setInfo(const QString &title, const QString &text, const QString &details = QString()); void setError(const QString &title, const QString &text, const QString &details = QString()); void setFinish(const QString &title, const QString &text, QWidget *widget = 0); virtual void addPackage(PackageKit::Transaction::Info info, const QString &packageID, const QString &summary); virtual void searchFinished(PkTransaction::ExitStatus status); virtual void commitFinished(PkTransaction::ExitStatus status); private Q_SLOTS: void updatePallete(); void setDialog(QDialog *dialog); private: void removePackages(); void parseInteraction(const QString &interaction); uint getPidSystem(); uint getPidSession(); QString getCmdLine(uint pid); bool pathIsTrusted(const QString &exec); void setExec(const QString &exec); uint m_xid; uint m_pid; QDBusMessage m_message; Interactions m_interactions; uint m_timeout; PackageModel *m_model; QStringList m_removePackages; - ReviewChanges *m_reviewChanges; - PkTransactionWidget *m_pkTransaction; + ReviewChanges *m_reviewChanges = nullptr; + PkTransactionWidget *m_pkTransaction = nullptr; Ui::SessionTask *ui; }; Q_DECLARE_OPERATORS_FOR_FLAGS(SessionTask::Interactions) #endif diff --git a/PkSession/SessionTask.ui b/PkSession/SessionTask.ui index afbee28..7ab0552 100644 --- a/PkSession/SessionTask.ui +++ b/PkSession/SessionTask.ui @@ -1,70 +1,92 @@ SessionTask 0 0 400 300 - - 0 - QFrame::StyledPanel QFrame::Sunken 0 - + + 0 + + + 0 + + + 0 + + 0 true 0 - + + 0 + + + 0 + + + 0 + + 0 Title description true 5 + + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + diff --git a/libapper/Requirements.cpp b/libapper/Requirements.cpp index 37979e4..99c9689 100644 --- a/libapper/Requirements.cpp +++ b/libapper/Requirements.cpp @@ -1,269 +1,265 @@ /*************************************************************************** - * Copyright (C) 2008-2011 by Daniel Nicoletti * + * Copyright (C) 2008-2018 by Daniel Nicoletti * * dantti12@gmail.com * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; see the file COPYING. If not, write to * * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * * Boston, MA 02110-1301, USA. * ***************************************************************************/ #include "Requirements.h" #include "ui_Requirements.h" #include "PkIcons.h" #include "PackageModel.h" #include "ApplicationSortFilterModel.h" #include #include #include #include #include #include Requirements::Requirements(PackageModel *model, QWidget *parent) : QDialog(parent), - m_embed(false), - m_shouldShow(true), - m_untrustedButton(0), ui(new Ui::Requirements) { + ui->setupUi(this); + setAttribute(Qt::WA_DeleteOnClose); - ui->setupUi(this); - connect(ui->confirmCB, SIGNAL(toggled(bool)), this, SLOT(on_confirmCB_Toggled(bool))); + connect(ui->confirmCB, &QCheckBox::toggled, this, &Requirements::confirmCBChanged); ApplicationSortFilterModel *proxy = new ApplicationSortFilterModel(this); proxy->setSourceModel(model); ui->packageView->setModel(proxy); ui->packageView->header()->setSectionResizeMode(PackageModel::NameCol, QHeaderView::ResizeToContents); ui->packageView->header()->hideSection(PackageModel::ActionCol); ui->packageView->header()->hideSection(PackageModel::ArchCol); ui->packageView->header()->hideSection(PackageModel::CurrentVersionCol); ui->packageView->header()->hideSection(PackageModel::OriginCol); ui->packageView->header()->hideSection(PackageModel::SizeCol); - m_hideAutoConfirm = false; - setWindowTitle(i18n("Additional changes")); setWindowIcon(QIcon::fromTheme("dialog-warning")); ui->buttonBox->button(QDialogButtonBox::Ok)->setText(i18n("Continue")); // restore size setMinimumSize(QSize(600,480)); // setInitialSize(QSize(600,600)); KConfig config("apper"); KConfigGroup requirementsDialog(&config, "requirementsDialog"); // restoreGeometry(requirementsDialog.readEntry("geometry").toByteArray()); // restoreDialogSize(requirementsDialog); ui->downloadT->hide(); ui->downloadI->hide(); ui->downloadI->setPixmap(QIcon::fromTheme(QLatin1String("download")).pixmap(32, 32)); m_buttonGroup = new QButtonGroup(this); connect(m_buttonGroup, QOverload::of(&QButtonGroup::buttonClicked), this, &Requirements::actionClicked); int count = 0; if (int c = model->countInfo(Transaction::InfoRemoving)) { auto button = new QToolButton(this); button->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); button->setCheckable(true); button->setAutoRaise(true); button->setIconSize(QSize(32, 32)); button->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); button->setText(i18np("1 package to remove", "%1 packages to remove", c)); button->setIcon(PkIcons::actionIcon(Transaction::RoleRemovePackages)); m_buttonGroup->addButton(button, Transaction::InfoRemoving); ui->verticalLayout->insertWidget(count++, button); m_hideAutoConfirm = true; } if (int c = model->countInfo(Transaction::InfoDowngrading)) { auto button = new QToolButton(this); button->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); button->setCheckable(true); button->setAutoRaise(true); button->setIconSize(QSize(32, 32)); button->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); button->setText(i18np("1 package to downgrade", "%1 packages to downgrade", c)); button->setIcon(PkIcons::actionIcon(Transaction::RoleRepairSystem)); m_buttonGroup->addButton(button, Transaction::InfoDowngrading); ui->verticalLayout->insertWidget(count++, button); m_hideAutoConfirm = true; } if (int c = model->countInfo(Transaction::InfoReinstalling)) { auto button = new QToolButton(this); button->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); button->setCheckable(true); button->setAutoRaise(true); button->setIconSize(QSize(32, 32)); button->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); button->setText(i18np("1 package to reinstall", "%1 packages to reinstall", c)); button->setIcon(PkIcons::actionIcon(Transaction::RoleRemovePackages)); m_buttonGroup->addButton(button, Transaction::InfoReinstalling); ui->verticalLayout->insertWidget(count++, button); } if (int c = model->countInfo(Transaction::InfoInstalling)) { auto button = new QToolButton(this); button->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); button->setCheckable(true); button->setAutoRaise(true); button->setIconSize(QSize(32, 32)); button->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); button->setText(i18np("1 package to install", "%1 packages to install", c)); button->setIcon(PkIcons::actionIcon(Transaction::RoleInstallPackages)); m_buttonGroup->addButton(button, Transaction::InfoInstalling); ui->verticalLayout->insertWidget(count++, button); } if (int c = model->countInfo(Transaction::InfoUpdating)) { auto button = new QToolButton(this); button->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); button->setCheckable(true); button->setAutoRaise(true); button->setIconSize(QSize(32, 32)); button->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); button->setText(i18np("1 package to update", "%1 packages to update", c)); button->setIcon(PkIcons::actionIcon(Transaction::RoleUpdatePackages)); m_buttonGroup->addButton(button, Transaction::InfoUpdating); ui->verticalLayout->insertWidget(count++, button); } if (int c = model->countInfo(Transaction::InfoUntrusted)) { m_untrustedButton = new QToolButton(this); m_untrustedButton->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); m_untrustedButton->setCheckable(true); m_untrustedButton->setAutoRaise(true); m_untrustedButton->setIconSize(QSize(32, 32)); m_untrustedButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); m_untrustedButton->setText(i18np("1 untrusted package", "%1 untrusted packages", c)); m_untrustedButton->setIcon(QIcon::fromTheme("security-low")); m_untrustedButton->setVisible(false); ui->verticalLayout->insertWidget(count++, m_untrustedButton); } if (!m_buttonGroup->buttons().isEmpty()) { m_buttonGroup->buttons().first()->click(); if (m_hideAutoConfirm) { ui->confirmCB->setVisible(false); } else { // if the confirmCB is visible means that we can skip this // dialog, but only if the user previusly set so ui->confirmCB->setChecked(requirementsDialog.readEntry("autoConfirm", false)); } } else if (m_untrustedButton) { showUntrustedButton(); } else { // set this as false so the dialog is not shown m_shouldShow = false; } } Requirements::~Requirements() { KConfig config("apper"); KConfigGroup requirementsDialog(&config, "requirementsDialog"); requirementsDialog.writeEntry("geometry", saveGeometry()); delete ui; } bool Requirements::embedded() const { return m_embed; } void Requirements::setEmbedded(bool embedded) { m_embed = embedded; ui->label->setVisible(!embedded); } void Requirements::setDownloadSizeRemaining(qulonglong size) { if (size) { QString text = i18nc("how many bytes are required for download", "Need to get %1 of archives", KFormat().formatByteSize(size)); ui->downloadT->setText(text); ui->downloadT->show(); ui->downloadI->show(); } else { ui->downloadT->hide(); ui->downloadI->hide(); } } bool Requirements::trusted() const { // There are untrusted packages if the button was created... return !m_untrustedButton; } bool Requirements::shouldShow() const { return (m_shouldShow && !ui->confirmCB->isChecked()); } void Requirements::slotButtonClicked(int) { // FIXME // if (button == KDialog::Ok && // m_untrustedButton && // !m_untrustedButton->isVisible()) { // showUntrustedButton(); // } else { // KDialog::slotButtonClicked(button); // } } -void Requirements::on_confirmCB_Toggled(bool checked) +void Requirements::confirmCBChanged(bool checked) { KConfig config("apper"); KConfigGroup requirementsDialog(&config, "requirementsDialog"); if (!m_hideAutoConfirm) { requirementsDialog.writeEntry("autoConfirm", checked); } config.sync(); } void Requirements::actionClicked(int type) { auto proxy = qobject_cast(ui->packageView->model()); proxy->setInfoFilter(static_cast(type)); } void Requirements::showUntrustedButton() { // Clear the other buttons qDeleteAll(m_buttonGroup->buttons()); // Hide the auto confirm button since we will be showing this dialog anyway ui->confirmCB->setVisible(false); ui->label->setText(i18n("You are about to install unsigned packages that can compromise your system, " "as it is impossible to verify if the software came from a trusted source.")); m_untrustedButton->setVisible(true); m_buttonGroup->addButton(m_untrustedButton, Transaction::InfoUntrusted); m_untrustedButton->click(); } #include "moc_Requirements.cpp" diff --git a/libapper/Requirements.h b/libapper/Requirements.h index 9c7d86a..730644b 100644 --- a/libapper/Requirements.h +++ b/libapper/Requirements.h @@ -1,67 +1,67 @@ /*************************************************************************** * Copyright (C) 2008-2011 by Daniel Nicoletti * * dantti12@gmail.com * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; see the file COPYING. If not, write to * * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * * Boston, MA 02110-1301, USA. * ***************************************************************************/ #ifndef REQUIREMENTS_H #define REQUIREMENTS_H #include #include namespace Ui { class Requirements; } class PackageModel; class Requirements : public QDialog { Q_OBJECT Q_PROPERTY(bool embedded READ embedded WRITE setEmbedded USER true) public: explicit Requirements(PackageModel *model, QWidget *parent = 0); ~Requirements(); bool embedded() const; void setEmbedded(bool embedded); void setDownloadSizeRemaining(qulonglong size); bool trusted() const; public Q_SLOTS: bool shouldShow() const; protected Q_SLOTS: virtual void slotButtonClicked(int button); private Q_SLOTS: - void on_confirmCB_Toggled(bool checked); void actionClicked(int type); private: + void confirmCBChanged(bool checked); void showUntrustedButton(); - bool m_embed; - bool m_shouldShow; - bool m_hideAutoConfirm; - QToolButton *m_untrustedButton; + bool m_embed = false; + bool m_shouldShow = true; + bool m_hideAutoConfirm = false; + QToolButton *m_untrustedButton = nullptr; QButtonGroup *m_buttonGroup; Ui::Requirements *ui; }; #endif