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