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/statusbarmessagelabel.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/statusbarmessagelabel.cpp')
| -rw-r--r-- | src/statusbarmessagelabel.cpp | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/src/statusbarmessagelabel.cpp b/src/statusbarmessagelabel.cpp index 682aa123b..de66bebba 100644 --- a/src/statusbarmessagelabel.cpp +++ b/src/statusbarmessagelabel.cpp @@ -15,7 +15,7 @@ * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * ***************************************************************************/ #include "statusbarmessagelabel.h" @@ -106,6 +106,13 @@ void StatusBarMessageLabel::setMinimumTextHeight(int min) } } +int StatusBarMessageLabel::widthGap() const +{ + QFontMetrics fontMetrics(font()); + const int defaultGap = 10; + return fontMetrics.width(m_text) - availableTextWidth() + defaultGap; +} + void StatusBarMessageLabel::paintEvent(QPaintEvent* /* event */) { QPainter painter(this); @@ -189,13 +196,10 @@ void StatusBarMessageLabel::assureVisibleText() return; } - - int availableWidth = width() - m_pixmap.width() - pixmapGap() * 2; - QFontMetrics fontMetrics(font()); - QRect bounds(fontMetrics.boundingRect(0, 0, availableWidth, height(), - Qt::AlignVCenter | Qt::TextWordWrap, - m_text)); + const QRect bounds(fontMetrics.boundingRect(0, 0, availableTextWidth(), height(), + Qt::AlignVCenter | Qt::TextWordWrap, + m_text)); int requiredHeight = bounds.height(); if (requiredHeight < m_minTextHeight) { requiredHeight = m_minTextHeight; @@ -204,6 +208,11 @@ void StatusBarMessageLabel::assureVisibleText() updateGeometry(); } +int StatusBarMessageLabel::availableTextWidth() const +{ + return width() - m_pixmap.width() - pixmapGap() * 2; +} + QColor StatusBarMessageLabel::mixColors(const QColor& c1, const QColor& c2, int percent) const |
