From 06b47a52a2e462c630d720f5f0641ed07f68c6c5 Mon Sep 17 00:00:00 2001 From: Vesa Date: Thu, 3 Jul 2014 14:09:31 +0300 Subject: [PATCH] Fix styling of textFloat & whatsthis, make text floats consistent in style with tooltips Should fix #925 --- data/themes/default/style.css | 15 +++++++++++---- include/LmmsPalette.h | 6 ++++++ include/text_float.h | 8 ++++---- src/gui/LmmsPalette.cpp | 10 +++++++--- src/gui/widgets/text_float.cpp | 30 ++++++++++++++++++------------ 5 files changed, 46 insertions(+), 23 deletions(-) diff --git a/data/themes/default/style.css b/data/themes/default/style.css index 0ee1b8427..fd96384ae 100644 --- a/data/themes/default/style.css +++ b/data/themes/default/style.css @@ -7,10 +7,6 @@ QLabel, QTreeWidget, QListWidget, QGroupBox { color: #e0e0e0; } -QWhatsThat { - color: black; -} - QMdiArea { background-image: url(resources:background_artwork.png); } @@ -55,6 +51,14 @@ QToolTip { color: #4afd85; } +textFloat { + border-radius: 4px; + background: qlineargradient(spread:reflect, x1:0.5, y1:0.5, x2:0.5, y2:0, stop:0 rgba(0, 0, 0, 255), stop:1 rgba(50, 50, 50, 220)); + opacity: 175; + border: 1.0px solid rgba(0,0,0,255); + color: #4afd85; +} + QMenu { border:1px solid #747474; @@ -748,5 +752,8 @@ LmmsPalette { qproperty-brightText: #4afd85; qproperty-highlight: #202020; qproperty-highlightedText: #ffffff; + /* the next two are used for whatsthis dialogs */ + qproperty-toolTipText: #000; + qproperty-toolTipBase: #c9c9c9; } diff --git a/include/LmmsPalette.h b/include/LmmsPalette.h index 4ce41d514..8e6ef7086 100644 --- a/include/LmmsPalette.h +++ b/include/LmmsPalette.h @@ -43,6 +43,8 @@ class EXPORT LmmsPalette : public QWidget Q_PROPERTY( QColor brightText READ brightText WRITE setBrightText ) Q_PROPERTY( QColor highlight READ highlight WRITE setHighlight ) Q_PROPERTY( QColor highlightedText READ highlightedText WRITE setHighlightedText ) + Q_PROPERTY( QColor toolTipText READ toolTipText WRITE setToolTipText ) + Q_PROPERTY( QColor toolTipBase READ toolTipBase WRITE setToolTipBase ) public: LmmsPalette( QWidget * parent, QStyle * stylearg ); @@ -63,6 +65,8 @@ public: ACCESSMET( brightText, setBrightText ) ACCESSMET( highlight, setHighlight ) ACCESSMET( highlightedText, setHighlightedText ) + ACCESSMET( toolTipText, setToolTipText ) + ACCESSMET( toolTipBase, setToolTipBase ) #undef ACCESSMET @@ -79,6 +83,8 @@ private: QColor m_brightText; QColor m_highlight; QColor m_highlightedText; + QColor m_toolTipText; + QColor m_toolTipBase; }; diff --git a/include/text_float.h b/include/text_float.h index b631ca878..e7ef37092 100644 --- a/include/text_float.h +++ b/include/text_float.h @@ -23,8 +23,8 @@ */ -#ifndef _TEXT_FLOAT -#define _TEXT_FLOAT +#ifndef TEXT_FLOAT_H +#define TEXT_FLOAT_H #include #include @@ -34,6 +34,7 @@ class EXPORT textFloat : public QWidget { + Q_OBJECT public: textFloat(); virtual ~textFloat() @@ -76,7 +77,6 @@ private: QString m_text; QPixmap m_pixmap; -} ; - +}; #endif diff --git a/src/gui/LmmsPalette.cpp b/src/gui/LmmsPalette.cpp index 28e33bc0e..02c26312e 100644 --- a/src/gui/LmmsPalette.cpp +++ b/src/gui/LmmsPalette.cpp @@ -43,7 +43,9 @@ LmmsPalette::LmmsPalette( QWidget * parent, QStyle * stylearg ) : m_buttonText( 0,0,0 ), m_brightText( 74, 253, 133 ), m_highlight( 100, 100, 100 ), - m_highlightedText( 255, 255, 255 ) + m_highlightedText( 255, 255, 255 ), + m_toolTipText( 0, 0, 0 ), + m_toolTipBase( 128, 128, 128 ) { setStyle( stylearg ); stylearg->polish( this ); @@ -70,7 +72,8 @@ LmmsPalette::~LmmsPalette() ACCESSMET( brightText, setBrightText ) ACCESSMET( highlight, setHighlight ) ACCESSMET( highlightedText, setHighlightedText ) - + ACCESSMET( toolTipText, setToolTipText ) + ACCESSMET( toolTipBase, setToolTipBase ) QPalette LmmsPalette::palette() const @@ -87,7 +90,8 @@ QPalette LmmsPalette::palette() const pal.setColor( QPalette::Shadow, shadow() ); pal.setColor( QPalette::Highlight, highlight() ); pal.setColor( QPalette::HighlightedText, highlightedText() ); - + pal.setBrush( QPalette::ToolTipText, QBrush( toolTipText() ) ); + pal.setBrush( QPalette::ToolTipBase, QBrush( toolTipBase() ) ); return pal; } diff --git a/src/gui/widgets/text_float.cpp b/src/gui/widgets/text_float.cpp index 24d75043c..5068fa883 100644 --- a/src/gui/widgets/text_float.cpp +++ b/src/gui/widgets/text_float.cpp @@ -24,6 +24,7 @@ #include #include +#include #include "text_float.h" #include "gui_templates.h" @@ -41,6 +42,8 @@ textFloat::textFloat() : resize( 20, 20 ); hide(); + setAttribute( Qt::WA_TranslucentBackground, true ); + setStyle( QApplication::style() ); setFont( pointSize<8>( font() ) ); } @@ -125,35 +128,38 @@ textFloat * textFloat::displayMessage( const QString & _title, void textFloat::paintEvent( QPaintEvent * _pe ) { + QStyleOption opt; + opt.init( this ); QPainter p( this ); + p.fillRect( 0, 0, width(), height(), QColor( 0, 0, 0, 0 ) ); - p.setPen( QColor( 0, 0, 0 ) ); - - p.setBrush( QColor( 224, 224, 224 ) ); +/* p.setPen( p.pen().brush().color() ); + p.setBrush( p.background() );*/ p.setFont( pointSize<8>( p.font() ) ); + + style()->drawPrimitive( QStyle::PE_Widget, &opt, &p, this ); - p.drawRect( 0, 0, rect().right(), rect().bottom() ); +/* p.drawRect( 0, 0, rect().right(), rect().bottom() );*/ -// p.setPen( Qt::black ); - // small message? if( m_title.isEmpty() ) { - p.drawText( 2, p.fontMetrics().height()-2, m_text ); + p.drawText( opt.rect, Qt::AlignCenter, m_text ); } else { - int text_x = 2; + int text_x = opt.rect.left() + 2; + int text_y = opt.rect.top() + 12; if( m_pixmap.isNull() == false ) { - p.drawPixmap( 5, 5, m_pixmap ); + p.drawPixmap( opt.rect.topLeft() + QPoint( 5, 5 ), m_pixmap ); text_x += m_pixmap.width() + 8; } - p.drawText( text_x, 28, m_text ); + p.drawText( text_x, text_y + 16, m_text ); QFont f = p.font(); f.setBold( true ); p.setFont( f ); - p.drawText( text_x, 12, m_title ); + p.drawText( text_x, text_y, m_title ); } } @@ -194,4 +200,4 @@ void textFloat::updateSize() - +#include "moc_text_float.cxx"