Commit 2d5af8cd authored by Alexander Miller's avatar Alexander Miller Committed by Laurent Montel
Browse files

Hide progress widget when inactive



A large portion of the status bar is permanently occupied
by the progress widget, which is empty most of the time.
Hide it when unused to allow the status label to expand and
use all of the available space.

Signed-off-by: Alexander Miller's avatarAlexander Miller <alex.miller@gmx.de>
parent 1e703a72
Pipeline #171073 passed with stage
in 4 minutes and 20 seconds
......@@ -10,6 +10,7 @@
#include "akregator_part.h"
#include "akregatorconfig.h"
#include "trayicon.h"
#include <Libkdepim/ProgressManager>
#include <Libkdepim/ProgressStatusBarWidget>
#include <Libkdepim/StatusbarProgressWidget>
#include <PimCommon/BroadcastStatus>
......@@ -34,6 +35,7 @@
#include <QStatusBar>
#include <QToolBar>
#include <QToolButton>
#include <QTimer>
using namespace Akregator;
......@@ -168,7 +170,31 @@ bool MainWindow::loadPart()
void MainWindow::setupProgressWidgets()
{
auto progressStatusBarWidget = new KPIM::ProgressStatusBarWidget(statusBar(), this);
statusBar()->addPermanentWidget(progressStatusBarWidget->littleProgress(), 0);
m_statusbarProgress = progressStatusBarWidget->littleProgress();
statusBar()->addPermanentWidget(m_statusbarProgress, 0);
// The progress widget blocks a large part of the status bar, but is empty
// most of the time. Hide it when unused, allowing a longer status label.
m_hideProgressTimer = new QTimer(this);
m_hideProgressTimer->setSingleShot(true);
connect(m_hideProgressTimer, &QTimer::timeout,
m_statusbarProgress, &QWidget::hide);
connect(KPIM::ProgressManager::instance(), &KPIM::ProgressManager::progressItemAdded,
this, &MainWindow::updateStatusbarProgressVisibility);
connect(KPIM::ProgressManager::instance(), &KPIM::ProgressManager::progressItemCompleted,
this, &MainWindow::updateStatusbarProgressVisibility);
m_statusbarProgress->hide();
}
void MainWindow::updateStatusbarProgressVisibility()
{
if (KPIM::ProgressManager::instance()->isEmpty()) {
m_hideProgressTimer->start(5000);
} else {
m_hideProgressTimer->stop();
m_statusbarProgress->show();
}
}
MainWindow::~MainWindow() = default;
......
......@@ -17,6 +17,7 @@ class KSqueezedTextLabel;
class KHamburgerMenu;
class KToggleAction;
class KToggleFullScreenAction;
class QTimer;
namespace Akregator
{
class Part;
......@@ -79,6 +80,7 @@ private Q_SLOTS:
void optionsConfigureToolbars();
void applyNewToolbarConfig();
void slotOnShutdown();
void updateStatusbarProgressVisibility();
private:
void updateHamburgerMenu();
......@@ -86,6 +88,8 @@ private:
void slotFullScreen(bool t);
QPointer<Akregator::Part> m_part;
KSqueezedTextLabel *const m_statusLabel;
QWidget *m_statusbarProgress = nullptr;
QTimer *m_hideProgressTimer = nullptr;
KHamburgerMenu *mHamburgerMenu = nullptr;
KToggleAction *mShowMenuBarAction = nullptr;
KToggleFullScreenAction *mShowFullScreenAction = nullptr;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment