ColorStatusBar.cc 875 Bytes
Newer Older
Dirk Wilden's avatar
Dirk Wilden committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include "ColorStatusBar.hh"

ColorStatusBar::ColorStatusBar(QWidget* parent) : QStatusBar(parent)
{
  connect (this, SIGNAL(messageChanged(const QString&)), this, SLOT(slotMessageChanged(const QString &)) );
  colored_ = false;
}

void ColorStatusBar::showMessage(const QString & message, int timeout)
{
  QStatusBar::showMessage(message, timeout);
}

void ColorStatusBar::showMessage(const QString & message, QColor _color, int timeout)
{
  QPalette pal = palette();
  pal.setColor(QPalette::Active, QPalette::WindowText, _color );
  setPalette(pal);

  colored_ = true;

  QStatusBar::showMessage(message, timeout);
}

void ColorStatusBar::slotMessageChanged(const QString & message)
{
  if ( !colored_ ){

    QPalette pal = palette();
    pal.setColor(QPalette::Active, QPalette::WindowText, QColor(Qt::black) );
    setPalette(pal);

  } else 
    colored_ = false;
}