Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:12.3
apper
0016-Show-how-much-download-is-left-and-use-QPo...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0016-Show-how-much-download-is-left-and-use-QPointers-ins.patch of Package apper
From 6cecc3dc052b60f0a2bdc4893d38b5d8a83dd464 Mon Sep 17 00:00:00 2001 From: Daniel Nicoletti <dantti12@gmail.com> Date: Fri, 18 Jan 2013 00:19:55 -0200 Subject: [PATCH 16/20] Show how much download is left and use QPointers instead of QWeakPointers for convenience --- ApperKCM/ApperKCM.cpp | 14 +++++----- libapper/PkTransaction.cpp | 65 +++++++++++++++++++++++++++------------------- libapper/PkTransaction.h | 4 --- libapper/Requirements.cpp | 22 +++++++++++++++- libapper/Requirements.h | 1 + 5 files changed, 66 insertions(+), 40 deletions(-) diff --git a/ApperKCM/ApperKCM.cpp b/ApperKCM/ApperKCM.cpp index b18caec..6189149 100644 --- a/ApperKCM/ApperKCM.cpp +++ b/ApperKCM/ApperKCM.cpp @@ -750,8 +750,7 @@ void ApperKCM::refreshCache() PkTransactionWidget *transactionW = new PkTransactionWidget(this); connect(transactionW, SIGNAL(titleChangedProgress(QString)), this, SIGNAL(caption(QString))); - PkTransaction *transaction = new PkTransaction(transactionW); - QWeakPointer<PkTransaction> pointer = transaction; + QPointer<PkTransaction> transaction = new PkTransaction(transactionW); transactionW->setTransaction(transaction, Transaction::RoleRefreshCache); ui->stackedWidget->addWidget(transactionW); @@ -768,7 +767,7 @@ void ApperKCM::refreshCache() // wait for the end of transaction if (!transaction->isFinished()) { loop.exec(); - if (pointer.isNull()) { + if (!transaction) { // Avoid crashing return; } @@ -791,8 +790,7 @@ void ApperKCM::save() } else { PkTransactionWidget *transactionW = new PkTransactionWidget(this); connect(transactionW, SIGNAL(titleChangedProgress(QString)), this, SIGNAL(caption(QString))); - PkTransaction *transaction = new PkTransaction(transactionW); - QWeakPointer<PkTransaction> pointer = transaction; + QPointer<PkTransaction> transaction = new PkTransaction(transactionW); ui->stackedWidget->addWidget(transactionW); ui->stackedWidget->setCurrentWidget(transactionW); @@ -811,7 +809,7 @@ void ApperKCM::save() // wait for the end of transaction if (!transaction->isFinished()) { loop.exec(); - if (pointer.isNull()) { + if (!transaction) { // Avoid crashing return; } @@ -826,7 +824,7 @@ void ApperKCM::save() // wait for the end of transaction if (!transaction->isFinished()) { loop.exec(); - if (pointer.isNull()) { + if (!transaction) { // Avoid crashing return; } @@ -845,7 +843,7 @@ void ApperKCM::save() // wait for the end of transaction if (!transaction->isFinished()) { loop.exec(); - if (pointer.isNull()) { + if (!transaction) { // Avoid crashing return; } diff --git a/libapper/PkTransaction.cpp b/libapper/PkTransaction.cpp index 9ab949b..1f6b4c0 100644 --- a/libapper/PkTransaction.cpp +++ b/libapper/PkTransaction.cpp @@ -55,6 +55,11 @@ class PkTransactionPrivate public: bool allowDeps; bool jobWatcher; + bool handlingActionRequired; + bool showingError; //This might replace the above + qulonglong downloadSizeRemaining; + PkTransaction::ExitStatus exitStatus; + Transaction::Status status; Transaction::TransactionFlags flags; Transaction::Role originalRole; Transaction::Error error; @@ -70,22 +75,25 @@ public: PkTransaction::PkTransaction(QObject *parent) : Transaction(parent), - m_handlingActionRequired(false), - m_showingError(false), - m_exitStatus(Success), - m_status(Transaction::StatusUnknown), d(new PkTransactionPrivate) { // for sanity we are finished till some transaction is set - d->simulateModel = 0; - d->launcher = 0; - d->originalRole = Transaction::RoleUnknown; - d->parentWindow = qobject_cast<QWidget*>(parent); + d->allowDeps = false; d->jobWatcher = false; - + d->handlingActionRequired = false; + d->showingError = false; + d->downloadSizeRemaining = 0; + d->exitStatus = Success; + d->status = Transaction::StatusUnknown; // for sanity we are trusted till an error is given and the user accepts d->flags = Transaction::TransactionFlagOnlyTrusted; + d->originalRole = Transaction::RoleUnknown; + d->error = Transaction::ErrorUnknown; + d->launcher = 0; + d->simulateModel = 0; d->progressModel = new PkTransactionProgressModel(this); + d->parentWindow = qobject_cast<QWidget*>(parent); + connect(this, SIGNAL(repoDetail(QString,QString,bool)), d->progressModel, SLOT(currentRepo(QString,QString,bool))); connect(this, SIGNAL(package(PackageKit::Transaction::Info,QString,QString)), @@ -313,7 +321,7 @@ void PkTransaction::slotErrorCode(Transaction::Error error, const QString &detai kDebug() << "errorCode: " << error << details; d->error = error; - if (m_handlingActionRequired) { + if (d->handlingActionRequired) { // We are already handling required actions // like eulaRequired() and repoSignatureRequired() return; @@ -330,7 +338,7 @@ void PkTransaction::slotErrorCode(Transaction::Error error, const QString &detai case Transaction::ErrorCannotInstallRepoUnsigned: case Transaction::ErrorCannotUpdateRepoUnsigned: { - m_handlingActionRequired = true; + d->handlingActionRequired = true; int ret = KMessageBox::warningYesNo(d->parentWindow, 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 " @@ -343,11 +351,11 @@ void PkTransaction::slotErrorCode(Transaction::Error error, const QString &detai } else { setExitStatus(Cancelled); } - m_handlingActionRequired = false; + d->handlingActionRequired = false; return; } default: - m_showingError = true; + d->showingError = true; showSorry(PkStrings::error(error), PkStrings::errorMessage(error), QString(details).replace('\n', "<br>")); // when we receive an error we are done @@ -357,12 +365,12 @@ void PkTransaction::slotErrorCode(Transaction::Error error, const QString &detai void PkTransaction::slotEulaRequired(const QString &eulaID, const QString &packageID, const QString &vendor, const QString &licenseAgreement) { - if (m_handlingActionRequired) { + if (d->handlingActionRequired) { // if its true means that we alread passed here - m_handlingActionRequired = false; + d->handlingActionRequired = false; return; } else { - m_handlingActionRequired = true; + d->handlingActionRequired = true; } LicenseAgreement *eula = new LicenseAgreement(eulaID, packageID, vendor, licenseAgreement, d->parentWindow); @@ -390,6 +398,8 @@ void PkTransaction::acceptEula() void PkTransaction::slotChanged() { + d->downloadSizeRemaining = downloadSizeRemaining(); + if (!d->jobWatcher) { return; } @@ -416,13 +426,13 @@ void PkTransaction::slotMediaChangeRequired(Transaction::MediaType type, const Q { Q_UNUSED(id) - m_handlingActionRequired = true; + d->handlingActionRequired = true; int ret = KMessageBox::questionYesNo(d->parentWindow, PkStrings::mediaMessage(type, text), i18n("A media change is required"), KStandardGuiItem::cont(), KStandardGuiItem::cancel()); - m_handlingActionRequired = false; + d->handlingActionRequired = false; // if the user clicked continue we got yes if (ret == KMessageBox::Yes) { @@ -441,12 +451,12 @@ void PkTransaction::slotRepoSignature(const QString &packageID, const QString &keyTimestamp, Transaction::SigType type) { - if (m_handlingActionRequired) { + if (d->handlingActionRequired) { // if its true means that we alread passed here - m_handlingActionRequired = false; + d->handlingActionRequired = false; return; } else { - m_handlingActionRequired = true; + d->handlingActionRequired = true; } RepoSig *repoSig = new RepoSig(packageID, repoName, keyUrl, keyUserid, keyId, keyFingerprint, keyTimestamp, type, d->parentWindow); @@ -508,6 +518,7 @@ void PkTransaction::slotFinished(Transaction::Exit status) d->newPackages = d->simulateModel->packagesWithInfo(Transaction::InfoInstalling); requires = new Requirements(d->simulateModel, d->parentWindow); + requires->setDownloadSizeRemaining(d->downloadSizeRemaining); connect(requires, SIGNAL(accepted()), this, SLOT(requeueTransaction())); connect(requires, SIGNAL(rejected()), this, SLOT(reject())); if (requires->shouldShow()) { @@ -563,19 +574,19 @@ void PkTransaction::slotFinished(Transaction::Exit status) case Transaction::ExitEulaRequired: case Transaction::ExitMediaChangeRequired: kDebug() << "finished KeyRequired or EulaRequired: " << status; - if (!m_handlingActionRequired) { + if (!d->handlingActionRequired) { kDebug() << "Not Handling Required Action"; setExitStatus(Failed); } break; case Transaction::ExitCancelled: // Avoid crash in case we are showing an error - if (!m_showingError) { + if (!d->showingError) { setExitStatus(Cancelled); } break; case Transaction::ExitFailed: - if (!m_handlingActionRequired && !m_showingError) { + if (!d->handlingActionRequired && !d->showingError) { kDebug() << "Yep, we failed."; setExitStatus(Failed); } @@ -589,7 +600,7 @@ void PkTransaction::slotFinished(Transaction::Exit status) PkTransaction::ExitStatus PkTransaction::exitStatus() const { - return m_exitStatus; + return d->exitStatus; } bool PkTransaction::isFinished() const @@ -620,8 +631,8 @@ void PkTransaction::setExitStatus(PkTransaction::ExitStatus status) d->launcher = 0; } - m_exitStatus = status; - if (!m_handlingActionRequired || !m_showingError) { + d->exitStatus = status; + if (!d->handlingActionRequired || !d->showingError) { emit finished(status); } } diff --git a/libapper/PkTransaction.h b/libapper/PkTransaction.h index 52e2b5f..c330988 100644 --- a/libapper/PkTransaction.h +++ b/libapper/PkTransaction.h @@ -107,10 +107,6 @@ private: void showError(const QString &title, const QString &description, const QString &details = QString()); void showSorry(const QString &title, const QString &description, const QString &details = QString()); - bool m_handlingActionRequired; - bool m_showingError; //This might replace the above - ExitStatus m_exitStatus; - Transaction::Status m_status; PkTransactionPrivate *d; }; diff --git a/libapper/Requirements.cpp b/libapper/Requirements.cpp index 0788b9f..7faf52c 100644 --- a/libapper/Requirements.cpp +++ b/libapper/Requirements.cpp @@ -26,6 +26,7 @@ #include "ApplicationSortFilterModel.h" #include <QToolButton> +#include <KPushButton> #include <KDebug> Requirements::Requirements(PackageModel *model, QWidget *parent) : @@ -54,7 +55,7 @@ Requirements::Requirements(PackageModel *model, QWidget *parent) : setCaption(i18n("Additional changes")); setWindowIcon(KIcon("dialog-warning")); - setButtons(KDialog::Ok | KDialog::Cancel); + setButtons(KDialog::Ok | KDialog::Cancel | KDialog::Help); setButtonText(KDialog::Ok, i18n("Continue")); // restore size setMinimumSize(QSize(600,480)); @@ -63,6 +64,10 @@ Requirements::Requirements(PackageModel *model, QWidget *parent) : KConfigGroup requirementsDialog(&config, "requirementsDialog"); restoreDialogSize(requirementsDialog); + button(KDialog::Help)->setFlat(true); + button(KDialog::Help)->setEnabled(false); + button(KDialog::Help)->setIcon(KIcon("download")); + m_buttonGroup = new QButtonGroup(this); connect(m_buttonGroup, SIGNAL(buttonClicked(int)), this, SLOT(actionClicked(int))); @@ -187,6 +192,21 @@ void Requirements::setEmbedded(bool embedded) ui->label->setVisible(!embedded); } +void Requirements::setDownloadSizeRemaining(qulonglong size) +{ + if (size) { + QString text; + text = i18nc("how many bytes are required for download", + "Need to get %1 of archives", + KGlobal::locale()->formatByteSize(size)); + button(KDialog::Help)->setText(text); + button(KDialog::Help)->setToolTip(text); + button(KDialog::Help)->show(); + } else { + button(KDialog::Help)->hide(); + } +} + bool Requirements::trusted() const { // There are untrusted packages if the button was created... diff --git a/libapper/Requirements.h b/libapper/Requirements.h index 938cf9c..1bd1e8b 100644 --- a/libapper/Requirements.h +++ b/libapper/Requirements.h @@ -40,6 +40,7 @@ public: bool embedded() const; void setEmbedded(bool embedded); + void setDownloadSizeRemaining(qulonglong size); bool trusted() const; public slots: -- 1.8.1
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor