mirror of
https://invent.kde.org/system/dolphin
synced 2024-07-04 17:30:55 +00:00
Show installation progress in the status bar
This commit reuses the progress reporting of the status bar for the Filelight installation progress.
This commit is contained in:
parent
6617d50dc2
commit
1b916b0aec
|
@ -71,6 +71,12 @@ DolphinStatusBar::DolphinStatusBar(QWidget *parent)
|
|||
// Initialize space information
|
||||
m_spaceInfo = new StatusBarSpaceInfo(contentsContainer);
|
||||
connect(m_spaceInfo, &StatusBarSpaceInfo::showMessage, this, &DolphinStatusBar::showMessage);
|
||||
connect(m_spaceInfo,
|
||||
&StatusBarSpaceInfo::showInstallationProgress,
|
||||
this,
|
||||
[this](const QString ¤tlyRunningTaskTitle, int installationProgressPercent) {
|
||||
showProgress(currentlyRunningTaskTitle, installationProgressPercent, CancelLoading::Disallowed);
|
||||
});
|
||||
|
||||
// Initialize progress information
|
||||
m_stopButton = new QToolButton(contentsContainer);
|
||||
|
|
|
@ -153,8 +153,8 @@ void StatusBarSpaceInfo::updateMenu()
|
|||
|
||||
vLayout->addSpacing(Dolphin::VERTICAL_SPACER_HEIGHT);
|
||||
|
||||
const QString installFilelightButtonDefaultText{i18nc("@action:button", "Install Filelight…")};
|
||||
auto installFilelightButton = new QPushButton(QIcon::fromTheme(QStringLiteral("filelight")), installFilelightButtonDefaultText, containerWidget);
|
||||
auto installFilelightButton =
|
||||
new QPushButton(QIcon::fromTheme(QStringLiteral("filelight")), i18nc("@action:button", "Install Filelight…"), containerWidget);
|
||||
installFilelightButton->setMinimumWidth(std::max(installFilelightButton->sizeHint().width(), installFilelightTitle->sizeHint().width()));
|
||||
auto buttonLayout = new QHBoxLayout{containerWidget};
|
||||
buttonLayout->addWidget(installFilelightButton, 0, Qt::AlignHCenter);
|
||||
|
@ -166,7 +166,7 @@ void StatusBarSpaceInfo::updateMenu()
|
|||
containerWidget->setFocusProxy(installFilelightButton);
|
||||
installFilelightButton->setAccessibleDescription(installFilelightBody->text());
|
||||
|
||||
connect(installFilelightButton, &QAbstractButton::clicked, this, [this, installFilelightButton, installFilelightButtonDefaultText] {
|
||||
connect(installFilelightButton, &QAbstractButton::clicked, this, [this] {
|
||||
#ifdef Q_OS_WIN
|
||||
QDesktopServices::openUrl(QUrl("https://apps.kde.org/filelight"));
|
||||
#else
|
||||
|
@ -177,8 +177,8 @@ void StatusBarSpaceInfo::updateMenu()
|
|||
return KService::serviceByDesktopName(QStringLiteral("org.kde.filelight"));
|
||||
},
|
||||
this);
|
||||
connect(packageInstaller, &KJob::result, this, [this, installFilelightButton, installFilelightButtonDefaultText](KJob *job) {
|
||||
installFilelightButton->setText(installFilelightButtonDefaultText);
|
||||
connect(packageInstaller, &KJob::result, this, [this](KJob *job) {
|
||||
Q_EMIT showInstallationProgress(QString(), 100); // Hides the progress information in the status bar.
|
||||
if (job->error()) {
|
||||
Q_EMIT showMessage(job->errorString(), KMessageWidget::Error);
|
||||
} else {
|
||||
|
@ -190,11 +190,12 @@ void StatusBarSpaceInfo::updateMenu()
|
|||
}
|
||||
}
|
||||
});
|
||||
connect(packageInstaller, &KJob::percentChanged, installFilelightButton, [installFilelightButton](KJob */* job */, long unsigned int percent) {
|
||||
if (percent > 100) {
|
||||
return; // For some reason it instantly reports 101% completion for me when it starts.
|
||||
const auto installationTaskText{i18nc("@info:status", "Installing Filelight…")};
|
||||
Q_EMIT showInstallationProgress(installationTaskText, -1);
|
||||
connect(packageInstaller, &KJob::percentChanged, this, [this, installationTaskText](KJob */* job */, long unsigned int percent) {
|
||||
if (percent < 100) { // Ignore some weird reported values.
|
||||
Q_EMIT showInstallationProgress(installationTaskText, percent);
|
||||
}
|
||||
installFilelightButton->setText(i18nc("@action:button which also shows progress %1 in percent", "Install Filelight… (%1%)", percent));
|
||||
});
|
||||
packageInstaller->start();
|
||||
#endif
|
||||
|
|
|
@ -49,6 +49,8 @@ Q_SIGNALS:
|
|||
*/
|
||||
void showMessage(const QString &message, KMessageWidget::MessageType messageType);
|
||||
|
||||
void showInstallationProgress(const QString ¤tlyRunningTaskTitle, int installationProgressPercent);
|
||||
|
||||
protected:
|
||||
void showEvent(QShowEvent *event) override;
|
||||
void hideEvent(QHideEvent *event) override;
|
||||
|
|
Loading…
Reference in New Issue
Block a user