Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:12.3
apper
0010-Feature-show-application-status-in-window-...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0010-Feature-show-application-status-in-window-title-BUG-.patch of Package apper
From 4a5dae7bb0ae57d93acc4afd57888bd7f6695555 Mon Sep 17 00:00:00 2001 From: Daniel Nicoletti <dantti12@gmail.com> Date: Wed, 9 Jan 2013 21:18:11 -0200 Subject: [PATCH 10/14] Feature: show application status in window title BUG:300750 --- Apper/MainUi.cpp | 6 ++-- Apper/main.cpp | 6 ---- ApperKCM/ApperKCM.cpp | 46 +++++++++++++++++------------- ApperKCM/ApperKCM.h | 1 + libapper/PkTransactionWidget.cpp | 61 +++++++++++++++++++++++++++++++--------- libapper/PkTransactionWidget.h | 1 + 6 files changed, 79 insertions(+), 42 deletions(-) diff --git a/Apper/MainUi.cpp b/Apper/MainUi.cpp index 31c2092..2a91dd4 100644 --- a/Apper/MainUi.cpp +++ b/Apper/MainUi.cpp @@ -25,8 +25,8 @@ #include <KConfig> #include <KCModuleProxy> -MainUi::MainUi(QWidget *parent) - : KCMultiDialog(parent), +MainUi::MainUi(QWidget *parent) : + KCMultiDialog(parent), m_apperModule(0) { setCaption(QString()); @@ -45,6 +45,8 @@ MainUi::MainUi(QWidget *parent) KCModuleProxy *proxy = static_cast<KCModuleProxy*>(page->widget()); if (proxy) { m_apperModule = proxy->realModule(); + connect(m_apperModule, SIGNAL(caption(QString)), + this, SLOT(setCaption(QString))); } } else { kWarning() << "Could not load kcm_apper.desktop!"; diff --git a/Apper/main.cpp b/Apper/main.cpp index 580e1c3..c971680 100644 --- a/Apper/main.cpp +++ b/Apper/main.cpp @@ -125,12 +125,6 @@ int main(int argc, char **argv) return invoke("RemovePackageByFiles", args->getOptionList("remove-package-by-file")); } - if (!Apper::start()) - { - qDebug() << "Apper is already running!"; - return 0; - } - Apper app; return app.exec(); diff --git a/ApperKCM/ApperKCM.cpp b/ApperKCM/ApperKCM.cpp index 43b3475..339aee3 100644 --- a/ApperKCM/ApperKCM.cpp +++ b/ApperKCM/ApperKCM.cpp @@ -392,7 +392,7 @@ void ApperKCM::on_homeView_activated(const QModelIndex &index) } // cache the search - m_searchRole = static_cast<Transaction::Role>(index.data(CategoryModel::SearchRole).toUInt()); + m_searchRole = static_cast<Transaction::Role>(index.data(CategoryModel::SearchRole).toUInt()); kDebug() << m_searchRole << index.data(CategoryModel::CategoryRole).toString(); if (m_searchRole == Transaction::RoleResolve) { #ifdef HAVE_APPSTREAM @@ -413,6 +413,7 @@ void ApperKCM::on_homeView_activated(const QModelIndex &index) } else { m_searchGroupCategory.clear(); m_searchGroup = index.data(CategoryModel::GroupRole).value<PackageKit::Transaction::Group>(); + m_searchString = index.data().toString(); // Store the nice name to change the title } } else if (m_searchRole == Transaction::RoleGetUpdates) { setPage("updates"); @@ -503,6 +504,7 @@ void ApperKCM::setPage(const QString &page) m_settingsPage->load(); ui->titleL->clear(); ui->backTB->setEnabled(true); + emit caption(i18n("Settings")); } } else if (page == QLatin1String("updates")) { if (ui->stackedWidget->currentWidget() != m_updaterPage) { @@ -529,6 +531,7 @@ void ApperKCM::setPage(const QString &page) m_updaterPage->load(); ui->stackedWidgetBar->setCurrentIndex(BAR_UPDATE); ui->backTB->setEnabled(true); + emit caption(i18n("Updates")); } } else if (page == QLatin1String("home")) { if (ui->stackedWidget->currentWidget() == m_updaterPage || @@ -545,6 +548,7 @@ void ApperKCM::setPage(const QString &page) ui->backTB->setEnabled(true); ui->filtersTB->setEnabled(false); ui->widget->setEnabled(false); + emit caption(i18n("History")); } } @@ -589,6 +593,7 @@ void ApperKCM::on_backTB_clicked() ui->backTB->setEnabled(canGoBack); // reset the search role m_searchRole = Transaction::RoleUnknown; + emit caption(); } void ApperKCM::on_changesPB_clicked() @@ -597,6 +602,7 @@ void ApperKCM::on_changesPB_clicked() m_changesModel->addSelectedPackagesFromModel(m_browseModel); ui->stackedWidget->setCurrentWidget(ui->pageChanges); ui->backTB->setEnabled(true); + emit caption(i18n("Pending Changes")); } void ApperKCM::disconnectTransaction() @@ -623,6 +629,9 @@ void ApperKCM::disconnectTransaction() void ApperKCM::search() { ui->browseView->cleanUi(); + if (ui->stackedWidgetBar->currentIndex() != BAR_SEARCH) { + ui->stackedWidgetBar->setCurrentIndex(BAR_SEARCH); + } disconnectTransaction(); @@ -645,18 +654,24 @@ void ApperKCM::search() switch (m_searchRole) { case Transaction::RoleSearchName: m_searchTransaction->searchNames(m_searchString, m_filtersMenu->filters()); + emit caption(m_searchString); break; case Transaction::RoleSearchDetails: m_searchTransaction->searchDetails(m_searchString, m_filtersMenu->filters()); + emit caption(m_searchString); break; case Transaction::RoleSearchFile: m_searchTransaction->searchFiles(m_searchString, m_filtersMenu->filters()); + emit caption(m_searchString); break; case Transaction::RoleSearchGroup: if (m_searchGroupCategory.isEmpty()) { m_searchTransaction->searchGroup(m_searchGroup, m_filtersMenu->filters()); + // m_searchString has the group nice name + emit caption(m_searchString); } else { ui->browseView->setParentCategory(m_searchParentCategory); + emit caption(m_searchParentCategory.data().toString()); #ifndef HAVE_APPSTREAM if (m_searchGroupCategory.startsWith('@') || m_searchGroupCategory.startsWith(QLatin1String("repo:"))) { @@ -672,6 +687,7 @@ void ApperKCM::search() connect(m_searchTransaction, SIGNAL(finished(PackageKit::Transaction::Exit,uint)), ui->browseView, SLOT(enableExportInstalledPB())); m_searchTransaction->getPackages(Transaction::FilterInstalled | m_filtersMenu->filters()); + emit caption(i18n("Installed Software")); break; case Transaction::RoleResolve: #ifdef HAVE_APPSTREAM @@ -680,9 +696,11 @@ void ApperKCM::search() // WARNING the resolve might fail if the backend // has a low limit MaximumItemsToResolve m_searchTransaction->resolve(m_searchCategory, m_filtersMenu->filters()); + emit caption(m_searchParentCategory.data().toString()); } else { ui->browseView->setParentCategory(m_searchParentCategory); KMessageBox::sorry(this, i18n("Could not find an application that matched this category")); + emit caption(); disconnectTransaction(); m_searchTransaction = 0; return; @@ -691,6 +709,7 @@ void ApperKCM::search() #endif default: kWarning() << "Search type not defined yet"; + emit caption(); disconnectTransaction(); m_searchTransaction = 0; return; @@ -726,17 +745,16 @@ void ApperKCM::changed() void ApperKCM::refreshCache() { - QWidget *currentWidget = ui->stackedWidget->currentWidget(); emit changed(false); PkTransactionWidget *transactionW = new PkTransactionWidget(this); + connect(transactionW, SIGNAL(titleChangedProgress(QString)), this, SIGNAL(caption(QString))); PkTransaction *transaction = new PkTransaction(transactionW); QWeakPointer<PkTransaction> pointer = transaction; transactionW->setTransaction(transaction, Transaction::RoleRefreshCache); ui->stackedWidget->addWidget(transactionW); ui->stackedWidget->setCurrentWidget(transactionW); - int oldBar = ui->stackedWidgetBar->currentIndex(); ui->stackedWidgetBar->setCurrentIndex(BAR_TITLE); ui->backTB->setEnabled(false); connect(transactionW, SIGNAL(titleChanged(QString)), @@ -758,18 +776,9 @@ void ApperKCM::refreshCache() m_forceRefreshCache = transaction->exitStatus() == PkTransaction::Failed; } - // Finished setup old stuff - ui->backTB->setEnabled(true); - ui->stackedWidget->setCurrentWidget(currentWidget); - ui->stackedWidgetBar->setCurrentIndex(oldBar); - transactionW->deleteLater(); - transaction->deleteLater(); - if (currentWidget == m_updaterPage) { - m_updaterPage->getUpdates(); - } else { - // install then remove packages - search(); - } + // Go back to the updates page + m_updaterPage->getUpdates(); + setPage("updates"); QTimer::singleShot(0, this, SLOT(checkChanged())); } @@ -780,12 +789,12 @@ void ApperKCM::save() m_settingsPage->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; ui->stackedWidget->addWidget(transactionW); ui->stackedWidget->setCurrentWidget(transactionW); - int oldBar = ui->stackedWidgetBar->currentIndex(); ui->stackedWidgetBar->setCurrentIndex(BAR_TITLE); ui->backTB->setEnabled(false); connect(transactionW, SIGNAL(titleChanged(QString)), @@ -847,13 +856,10 @@ void ApperKCM::save() } } - // Finished setup old stuff - ui->backTB->setEnabled(true); - ui->stackedWidget->setCurrentWidget(currentWidget); - ui->stackedWidgetBar->setCurrentIndex(oldBar); transaction->deleteLater(); if (currentWidget == m_updaterPage) { m_updaterPage->getUpdates(); + setPage("updates"); } else { // install then remove packages search(); diff --git a/ApperKCM/ApperKCM.h b/ApperKCM/ApperKCM.h index 07660ec..dbe9da9 100644 --- a/ApperKCM/ApperKCM.h +++ b/ApperKCM/ApperKCM.h @@ -57,6 +57,7 @@ public: signals: void changed(bool state); + void caption(const QString &title = QString()); public slots: void load(); diff --git a/libapper/PkTransactionWidget.cpp b/libapper/PkTransactionWidget.cpp index fb88d74..252699c 100644 --- a/libapper/PkTransactionWidget.cpp +++ b/libapper/PkTransactionWidget.cpp @@ -175,23 +175,30 @@ void PkTransactionWidget::updateUi() } uint percentage = transaction->percentage(); + QString percentageString; if (percentage <= 100) { - ui->progressBar->setMaximum(100); - ui->progressBar->setValue(percentage); + if (ui->progressBar->value() != static_cast<int>(percentage)) { + ui->progressBar->setMaximum(100); + ui->progressBar->setValue(percentage); + percentageString = QString::number(percentage); + } } else if (ui->progressBar->maximum() != 0) { ui->progressBar->setMaximum(0); ui->progressBar->reset(); + percentageString = QLatin1String(""); } ui->progressBar->setRemaining(transaction->remainingTime()); // Status & Speed Transaction::Status status = transaction->status(); + uint speed = transaction->speed(); + qulonglong downloadSizeRemaining = transaction->downloadSizeRemaining(); if (m_status != status) { m_status = status; ui->currentL->setText(PkStrings::status(status, - transaction->speed(), - transaction->downloadSizeRemaining())); + speed, + downloadSizeRemaining)); KPixmapSequence sequence = KPixmapSequence(PkIcons::statusAnimation(status), KIconLoader::SizeLarge); @@ -201,25 +208,51 @@ void PkTransactionWidget::updateUi() } } else if (status == Transaction::StatusDownload) { ui->currentL->setText(PkStrings::status(status, - transaction->speed(), - transaction->downloadSizeRemaining())); + speed, + downloadSizeRemaining)); } + QString windowTitle; + QString windowTitleProgress; + KIcon windowIcon; Transaction::Role role = transaction->role(); - if (d->role != role) { - QString windowTitle; - KIcon windowIcon; - if (role == Transaction::RoleUnknown) { - windowTitle = PkStrings::status(Transaction::StatusSetup); - windowIcon = PkIcons::statusIcon(Transaction::StatusSetup); + if (role == Transaction::RoleUnknown) { + windowTitle = PkStrings::status(Transaction::StatusSetup); + if (percentageString.isEmpty()) { + windowTitleProgress = PkStrings::status(status, + speed, + downloadSizeRemaining); + } else { + QString statusText = PkStrings::status(status, + speed, + downloadSizeRemaining); + windowTitleProgress = i18n("%1 (%2%)", statusText, percentageString); + } + windowIcon = PkIcons::statusIcon(Transaction::StatusSetup); + } else { + windowTitle = PkStrings::action(role); + if (percentageString.isEmpty()) { + windowTitleProgress = PkStrings::status(status, + speed, + downloadSizeRemaining); } else { - windowTitle = PkStrings::action(role); - windowIcon = PkIcons::actionIcon(role); + QString statusText = PkStrings::status(status, + speed, + downloadSizeRemaining); + windowTitleProgress = i18n("%1 (%2%)", statusText, percentageString); } + windowIcon = PkIcons::actionIcon(role); + } + + if (d->role != role) { d->role = role; setWindowIcon(PkIcons::actionIcon(role)); setWindowTitle(windowTitle); + emit titleChanged(windowTitle); + emit titleChangedProgress(windowTitleProgress); + } else if (!percentageString.isNull()) { + emit titleChangedProgress(windowTitleProgress); } // check to see if we can cancel diff --git a/libapper/PkTransactionWidget.h b/libapper/PkTransactionWidget.h index 45d0a35..30ea044 100644 --- a/libapper/PkTransactionWidget.h +++ b/libapper/PkTransactionWidget.h @@ -54,6 +54,7 @@ public: signals: void allowCancel(bool enable); void titleChanged(const QString &title); + void titleChangedProgress(const QString &title); void dialog(KDialog *widget); void sorry(const QString &title, const QString &text, const QString &details); void error(const QString &title, const QString &text, const QString &details); -- 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