Commit f1322a15 authored by Jan Möbius's avatar Jan Möbius
Browse files

Logger with dark theme (Thanks to Matthias Möller for the patch)

parent 40d17f03
...@@ -75,10 +75,7 @@ void ColorStatusBar::showMessage(const QString & message, QColor _color, int tim ...@@ -75,10 +75,7 @@ void ColorStatusBar::showMessage(const QString & message, QColor _color, int tim
void ColorStatusBar::slotMessageChanged(const QString & /*message*/) void ColorStatusBar::slotMessageChanged(const QString & /*message*/)
{ {
if ( !colored_ ){ if ( !colored_ ){
setPalette(QPalette{});
QPalette pal = palette();
pal.setColor(QPalette::Active, QPalette::WindowText, QColor(Qt::black) );
setPalette(pal);
} else } else
colored_ = false; colored_ = false;
......
...@@ -89,7 +89,7 @@ slotLog(Logtype _type, QString _message) { ...@@ -89,7 +89,7 @@ slotLog(Logtype _type, QString _message) {
textColor = QColor(0,160,0); textColor = QColor(0,160,0);
break; break;
case LOGOUT: case LOGOUT:
textColor = QColor(0,0,0); textColor = QPalette{}.windowText().color();
break; break;
case LOGWARN: case LOGWARN:
textColor = QColor(160,160,0); textColor = QColor(160,160,0);
......
...@@ -89,7 +89,8 @@ QtSlideWindow::QtSlideWindow(QString _name, QGraphicsItem *_parent) : ...@@ -89,7 +89,8 @@ QtSlideWindow::QtSlideWindow(QString _name, QGraphicsItem *_parent) :
dialog_(0), dialog_(0),
down_(false), down_(false),
animating_(false), animating_(false),
timer_(0) { timer_(0),
fontHeight_(QFontMetrics(QFont()).height()){
setCacheMode(QGraphicsItem::DeviceCoordinateCache); setCacheMode(QGraphicsItem::DeviceCoordinateCache);
setWindowFrameMargins(2, 15, 2, 2); setWindowFrameMargins(2, 15, 2, 2);
...@@ -178,13 +179,11 @@ void QtSlideWindow::paintWindowFrame(QPainter *_painter, const QStyleOptionGraph ...@@ -178,13 +179,11 @@ void QtSlideWindow::paintWindowFrame(QPainter *_painter, const QStyleOptionGraph
int h = geometry().height(); int h = geometry().height();
_painter->setRenderHint(QPainter::Antialiasing, true); _painter->setRenderHint(QPainter::Antialiasing, true);
_painter->setBrush(QBrush(QColor(BACKGROUND_RED, BACKGROUND_GREEN, BACKGROUND_BLUE, BACKGROUND_ALPHA))); _painter->setBrush(QPalette{}.window());
_painter->setPen(QColor(BACKGROUND_RED / 4, BACKGROUND_GREEN / 4, BACKGROUND_BLUE / 4, BACKGROUND_ALPHA)); _painter->setPen(QPalette{}.windowText().color());
_painter->drawRoundedRect(-2, -15, w + 4, h + 40, 4, 4); _painter->drawRoundedRect(-2, -4-fontHeight_, w + 4, h + 40, 4, 4);
_painter->setPen(Qt::SolidLine); _painter->drawText(2, -2-fontHeight_, w - 4, fontHeight_, Qt::AlignCenter, name_);
_painter->drawText(2, -13, w - 4, 11, Qt::AlignCenter, name_);
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
......
...@@ -153,36 +153,39 @@ class DLLEXPORT QtSlideWindow : public QGraphicsProxyWidget ...@@ -153,36 +153,39 @@ class DLLEXPORT QtSlideWindow : public QGraphicsProxyWidget
private: private:
// name /// name
QString name_; QString name_;
// child widget /// child widget
QWidget *mainWidget_; QWidget *mainWidget_;
// buttons /// buttons
QtGraphicsButton *autohideButton_; QtGraphicsButton *autohideButton_;
QtGraphicsButton *detachButton_; QtGraphicsButton *detachButton_;
// detached dialog /// detached dialog
QDialog *dialog_; QDialog *dialog_;
// Starting position (for animation) /// Starting position (for animation)
QPointF startP_; QPointF startP_;
// Ending position (for animation) /// Ending position (for animation)
QPointF endP_; QPointF endP_;
// Track if widget is at bottom position /// Track if widget is at bottom position
bool down_; bool down_;
// Animation object /// Animation object
QPropertyAnimation* animation_; QPropertyAnimation* animation_;
// Is widget animating in this moment? /// Is widget animating in this moment?
bool animating_; bool animating_;
// Wait some milliseconds before sliding widget down /// Wait some milliseconds before sliding widget down
QTimer* timer_; QTimer* timer_;
/// height of the default font
const int fontHeight_;
}; };
//============================================================================= //=============================================================================
......
...@@ -202,31 +202,31 @@ void LoggerWidget::append(const QString& _text, Logtype _type){ ...@@ -202,31 +202,31 @@ void LoggerWidget::append(const QString& _text, Logtype _type){
switch (_type) { switch (_type) {
case LOGINFO: case LOGINFO:
item->setForeground( QBrush(QColor(Qt::darkGreen)) ); item->setForeground( QBrush(QColor(Qt::darkGreen)) );
item->setBackground( QBrush(QColor(225,255,225), Qt::Dense4Pattern) ); item->setBackground( QBrush(QColor(225,255,225), Qt::SolidPattern) );
if ( infoButton_->isChecked() ) if ( infoButton_->isChecked() )
item->setHidden(false); item->setHidden(false);
break; break;
case LOGOUT: case LOGOUT:
item->setForeground( QBrush(QColor(Qt::black)) ); item->setForeground( QPalette{}.windowText() );
break; break;
case LOGWARN: case LOGWARN:
item->setForeground( QBrush(QColor(160,160,0)) ); item->setForeground( QBrush(QColor(160,160,0)) );
item->setBackground( QBrush(QColor(255,240,200),Qt::Dense4Pattern) ); item->setBackground( QBrush(QColor(255,240,200),Qt::SolidPattern) );
if ( warnButton_->isChecked() ) if ( warnButton_->isChecked() )
item->setHidden(false); item->setHidden(false);
break; break;
case LOGERR: case LOGERR:
item->setForeground( QBrush(QColor(Qt::red)) ); item->setForeground( QBrush(QColor(Qt::red)) );
item->setBackground( QBrush(QColor(255,225,225),Qt::Dense4Pattern) ); item->setBackground( QBrush(QColor(255,225,225),Qt::SolidPattern) );
if ( errorButton_->isChecked() ) if ( errorButton_->isChecked() )
item->setHidden(false); item->setHidden(false);
break; break;
case LOGSTATUS: case LOGSTATUS:
item->setForeground( QBrush(QColor(Qt::blue)) ); item->setForeground( QBrush(QColor(Qt::blue)) );
item->setBackground( QBrush(QColor(255,225,225),Qt::Dense4Pattern) ); item->setBackground( QBrush(QColor(255,225,225),Qt::SolidPattern) );
if ( errorButton_->isChecked() ) if ( errorButton_->isChecked() )
item->setHidden(false); item->setHidden(false);
......
Markdown is supported
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