diff options
| author | Peter Penz <[email protected]> | 2007-01-26 19:38:32 +0000 |
|---|---|---|
| committer | Peter Penz <[email protected]> | 2007-01-26 19:38:32 +0000 |
| commit | 9877bef7c56b07e715d1f7a6dddc8529387b689b (patch) | |
| tree | 5b0f47847ee43bd1af000851c040dddfe823db71 /src/dolphinstatusbar.cpp | |
| parent | dcc41b4ad4a082301a711612934233ee2c22c5d0 (diff) | |
Further optimizations for the status bar: hide the space information if the status bar text does not fit into the remaining width.
svn path=/trunk/playground/utils/dolphin/; revision=627486
Diffstat (limited to 'src/dolphinstatusbar.cpp')
| -rw-r--r-- | src/dolphinstatusbar.cpp | 44 |
1 files changed, 32 insertions, 12 deletions
diff --git a/src/dolphinstatusbar.cpp b/src/dolphinstatusbar.cpp index a112a1f64..c81a01c70 100644 --- a/src/dolphinstatusbar.cpp +++ b/src/dolphinstatusbar.cpp @@ -57,7 +57,7 @@ DolphinStatusBar::DolphinStatusBar(DolphinView* parent) : m_messageLabel->setMinimumTextHeight(size.height()); connect(parent, SIGNAL(urlChanged(const KUrl&)), - this, SLOT(updateSpaceInfo(const KUrl&))); + this, SLOT(updateSpaceInfoContent(const KUrl&))); } @@ -71,16 +71,12 @@ void DolphinStatusBar::setMessage(const QString& msg, m_messageLabel->setText(msg); m_messageLabel->setType(type); - if (type == Error) { - // assure that enough space is available for the error message and - // hide the space information and progress information - m_spaceInfo->hide(); + const int widthGap = m_messageLabel->widthGap(); + if (widthGap > 0) { m_progressBar->hide(); m_progressText->hide(); } - else if (!m_progressBar->isVisible()) { - m_spaceInfo->show(); - } + showSpaceInfo(); } DolphinStatusBar::Type DolphinStatusBar::type() const @@ -145,6 +141,12 @@ void DolphinStatusBar::setDefaultText(const QString& text) m_defaultText = text; } +void DolphinStatusBar::resizeEvent(QResizeEvent* event) +{ + QWidget::resizeEvent(event); + QTimer::singleShot(0, this, SLOT(showSpaceInfo())); +} + void DolphinStatusBar::updateProgressInfo() { const bool isErrorShown = (m_messageLabel->type() == Error); @@ -160,15 +162,33 @@ void DolphinStatusBar::updateProgressInfo() // hide the progress information and show the space information m_progressText->hide(); m_progressBar->hide(); - if (m_messageLabel->type() != Error) { - m_spaceInfo->show(); - } + showSpaceInfo(); } } -void DolphinStatusBar::updateSpaceInfo(const KUrl& url) +void DolphinStatusBar::updateSpaceInfoContent(const KUrl& url) { m_spaceInfo->setUrl(url); + showSpaceInfo(); +} + +void DolphinStatusBar::showSpaceInfo() +{ + const int widthGap = m_messageLabel->widthGap(); + const bool isProgressBarVisible = m_progressBar->isVisible(); + + if (m_spaceInfo->isVisible()) { + // The space information is shown currently. Hide it + // if the progress bar is visible or if the status bar + // text does not fit into the available width. + const QSize size(m_progressBar->sizeHint()); + if (isProgressBarVisible || (widthGap > 0)) { + m_spaceInfo->hide(); + } + } + else if (widthGap + m_spaceInfo->width() <= 0) { + m_spaceInfo->show(); + } } #include "dolphinstatusbar.moc" |
