Reworked status bar.

This commit is contained in:
Martin Rotter 2014-01-07 08:57:10 +01:00
parent 3303167fcf
commit c210055fed
3 changed files with 29 additions and 7 deletions

View File

@ -10,6 +10,7 @@
#include "gui/iconthemefactory.h" #include "gui/iconthemefactory.h"
#include "gui/messagesview.h" #include "gui/messagesview.h"
#include "gui/feedsview.h" #include "gui/feedsview.h"
#include "gui/statusbar.h"
#include <QVBoxLayout> #include <QVBoxLayout>
#include <QSplitter> #include <QSplitter>
@ -118,7 +119,7 @@ void FeedMessageViewer::updateAllFeeds() {
} }
void FeedMessageViewer::onFeedUpdatesStarted() { void FeedMessageViewer::onFeedUpdatesStarted() {
FormMain::getInstance()->statusBar()->showProgress(0, tr("Feed update started"));
} }
void FeedMessageViewer::onFeedUpdatesProgress(FeedsModelFeed *feed, void FeedMessageViewer::onFeedUpdatesProgress(FeedsModelFeed *feed,
@ -126,13 +127,14 @@ void FeedMessageViewer::onFeedUpdatesProgress(FeedsModelFeed *feed,
int total) { int total) {
// Some feed got updated. // Some feed got updated.
m_feedsView->updateCountsOfParticularFeed(feed, true); m_feedsView->updateCountsOfParticularFeed(feed, true);
FormMain::getInstance()->statusBar()->showProgress((current * 100.0) / total,
tr("Updated feed '%1'").arg(feed->title()));
} }
void FeedMessageViewer::onFeedUpdatesFinished() { void FeedMessageViewer::onFeedUpdatesFinished() {
// Updates of some feeds finished, unlock the lock. // Updates of some feeds finished, unlock the lock.
SystemFactory::getInstance()->applicationCloseLock()->unlock(); SystemFactory::getInstance()->applicationCloseLock()->unlock();
FormMain::getInstance()->statusBar()->clearProgress();
} }
void FeedMessageViewer::createConnections() { void FeedMessageViewer::createConnections() {

View File

@ -17,22 +17,38 @@ StatusBar::StatusBar(QWidget *parent) : QStatusBar(parent) {
m_fullscreenSwitcher->setToolTip(tr("Switch application between fulscreen/normal states right from this status bar icon.")); m_fullscreenSwitcher->setToolTip(tr("Switch application between fulscreen/normal states right from this status bar icon."));
m_progressBar = new QProgressBar(this); m_progressBar = new QProgressBar(this);
m_progressBar->setTextVisible(false);
m_progressBar->setFixedWidth(100); m_progressBar->setFixedWidth(100);
m_progressBar->setVisible(false);
m_progressLabel = new QLabel(this); m_progressLabel = new QLabel(this);
m_progressLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
m_progressLabel->setText("aaa"); m_progressLabel->setText("aaa");
m_progressLabel->setVisible(false);
// Add widgets. // Add widgets.
addPermanentWidget(m_progressLabel);
addPermanentWidget(m_progressBar);
addPermanentWidget(m_fullscreenSwitcher); addPermanentWidget(m_fullscreenSwitcher);
addWidget(m_progressBar, 0);
addWidget(m_progressLabel, 1);
} }
StatusBar::~StatusBar() { StatusBar::~StatusBar() {
qDebug("Destroying StatusBar instance."); qDebug("Destroying StatusBar instance.");
} }
QToolButton *StatusBar::fullscreenSwitcher() const QToolButton *StatusBar::fullscreenSwitcher() const {
{
return m_fullscreenSwitcher; return m_fullscreenSwitcher;
} }
void StatusBar::showProgress(int progress, const QString &label) {
m_progressLabel->setVisible(true);
m_progressBar->setVisible(true);
m_progressLabel->setText(label);
m_progressBar->setValue(progress);
}
void StatusBar::clearProgress() {
m_progressLabel->setVisible(false);
m_progressBar->setVisible(false);
}

View File

@ -18,6 +18,10 @@ class StatusBar : public QStatusBar {
QToolButton *fullscreenSwitcher() const; QToolButton *fullscreenSwitcher() const;
// Progress bar operations
void showProgress(int progress, const QString &label);
void clearProgress();
private: private:
QProgressBar *m_progressBar; QProgressBar *m_progressBar;
QLabel *m_progressLabel; QLabel *m_progressLabel;