Skip to content
Permalink
Browse files

Use some constants for search box highlighting styles

(cherry-picked from 31a9254)
  • Loading branch information
nyalldawson committed Mar 12, 2018
1 parent 5da0ff3 commit 87e8f9f6f15518736c0c31a3c29d5f613c7b4741
Showing with 37 additions and 6 deletions.
  1. +33 −2 src/gui/qgsoptionsdialoghighlightwidgetsimpl.cpp
  2. +4 −4 src/gui/qgsoptionsdialoghighlightwidgetsimpl.h
@@ -30,11 +30,24 @@

#include <functional>

const int HIGHLIGHT_BACKGROUND_RED = 255;
const int HIGHLIGHT_BACKGROUND_GREEN = 251;
const int HIGHLIGHT_BACKGROUND_BLUE = 190;
const int HIGHLIGHT_TEXT_RED = 0;
const int HIGHLIGHT_TEXT_GREEN = 0;
const int HIGHLIGHT_TEXT_BLUE = 0;

// ****************
// QLabel
QgsOptionsDialogHighlightLabel::QgsOptionsDialogHighlightLabel( QLabel *label )
: QgsOptionsDialogHighlightWidget( label )
, mLabel( label )
, mStyleSheet( QStringLiteral( /*!search!*/"QLabel { background-color: rgb(%1, %2, %3); color: rgb(%4, %5, %6 );}/*!search!*/" ).arg( HIGHLIGHT_BACKGROUND_RED )
.arg( HIGHLIGHT_BACKGROUND_GREEN )
.arg( HIGHLIGHT_BACKGROUND_BLUE )
.arg( HIGHLIGHT_TEXT_RED )
.arg( HIGHLIGHT_TEXT_GREEN )
.arg( HIGHLIGHT_TEXT_BLUE ) )
{}

bool QgsOptionsDialogHighlightLabel::searchText( const QString &text )
@@ -68,6 +81,12 @@ void QgsOptionsDialogHighlightLabel::reset()
QgsOptionsDialogHighlightCheckBox::QgsOptionsDialogHighlightCheckBox( QCheckBox *checkBox )
: QgsOptionsDialogHighlightWidget( checkBox )
, mCheckBox( checkBox )
, mStyleSheet( QStringLiteral( "/*!search!*/QCheckBox { background-color: rgb(%1, %2, %3); color: rgb( %4, %5, %6);}/*!search!*/" ).arg( HIGHLIGHT_BACKGROUND_RED )
.arg( HIGHLIGHT_BACKGROUND_GREEN )
.arg( HIGHLIGHT_BACKGROUND_BLUE )
.arg( HIGHLIGHT_TEXT_RED )
.arg( HIGHLIGHT_TEXT_GREEN )
.arg( HIGHLIGHT_TEXT_BLUE ) )
{
}

@@ -103,6 +122,12 @@ void QgsOptionsDialogHighlightCheckBox::reset()
QgsOptionsDialogHighlightButton::QgsOptionsDialogHighlightButton( QAbstractButton *button )
: QgsOptionsDialogHighlightWidget( button )
, mButton( button )
, mStyleSheet( QStringLiteral( "/*!search!*/QAbstractButton { background-color: rgb(%1, %2, %3); color: rgb(%4, %5, %6);}/*!search!*/" ).arg( HIGHLIGHT_BACKGROUND_RED )
.arg( HIGHLIGHT_BACKGROUND_GREEN )
.arg( HIGHLIGHT_BACKGROUND_BLUE )
.arg( HIGHLIGHT_TEXT_RED )
.arg( HIGHLIGHT_TEXT_GREEN )
.arg( HIGHLIGHT_TEXT_BLUE ) )
{
}

@@ -138,6 +163,12 @@ void QgsOptionsDialogHighlightButton::reset()
QgsOptionsDialogHighlightGroupBox::QgsOptionsDialogHighlightGroupBox( QGroupBox *groupBox )
: QgsOptionsDialogHighlightWidget( groupBox )
, mGroupBox( groupBox )
, mStyleSheet( QStringLiteral( "/*!search!*/QGroupBox::title { background-color: rgb(%1, %2, %3); color: rgb(%4, %5, %6);}/*!search!*/" ).arg( HIGHLIGHT_BACKGROUND_RED )
.arg( HIGHLIGHT_BACKGROUND_GREEN )
.arg( HIGHLIGHT_BACKGROUND_BLUE )
.arg( HIGHLIGHT_TEXT_RED )
.arg( HIGHLIGHT_TEXT_GREEN )
.arg( HIGHLIGHT_TEXT_BLUE ) )
{
}

@@ -209,8 +240,8 @@ bool QgsOptionsDialogHighlightTree::highlightText( const QString &text )
for ( QTreeWidgetItem *item : items )
{
mTreeInitialStyle.insert( item, qMakePair( item->background( 0 ), item->foreground( 0 ) ) );
item->setBackground( 0, QBrush( QColor( Qt::yellow ) ) );
item->setForeground( 0, QBrush( QColor( Qt::blue ) ) );
item->setBackground( 0, QBrush( QColor( HIGHLIGHT_BACKGROUND_RED, HIGHLIGHT_BACKGROUND_GREEN, HIGHLIGHT_BACKGROUND_BLUE ) ) );
item->setForeground( 0, QBrush( QColor( HIGHLIGHT_TEXT_RED, HIGHLIGHT_TEXT_GREEN, HIGHLIGHT_TEXT_BLUE ) ) );
setChildrenVisible( item, true );

QTreeWidgetItem *parent = item;
@@ -51,7 +51,7 @@ class GUI_EXPORT QgsOptionsDialogHighlightLabel : public QgsOptionsDialogHighlig
virtual bool highlightText( const QString &text ) override;
virtual void reset() override;
QPointer<QLabel> mLabel;
QString mStyleSheet = QStringLiteral( /*!search!*/"QLabel { background-color: rgb(255, 251, 190); color: black;}/*!search!*/" );
QString mStyleSheet;
};

/**
@@ -72,7 +72,7 @@ class GUI_EXPORT QgsOptionsDialogHighlightCheckBox : public QgsOptionsDialogHigh
virtual bool highlightText( const QString &text ) override;
virtual void reset() override;
QPointer<QCheckBox> mCheckBox;
QString mStyleSheet = QStringLiteral( "/*!search!*/QCheckBox { background-color: rgb(255, 251, 190); color: black;}/*!search!*/" );
QString mStyleSheet;
};

/**
@@ -93,7 +93,7 @@ class GUI_EXPORT QgsOptionsDialogHighlightButton : public QgsOptionsDialogHighli
virtual bool highlightText( const QString &text ) override;
virtual void reset() override;
QPointer<QAbstractButton> mButton;
QString mStyleSheet = QStringLiteral( "/*!search!*/QAbstractButton { background-color: rgb(255, 251, 190); color: black;}/*!search!*/" );
QString mStyleSheet;
};

/**
@@ -114,7 +114,7 @@ class GUI_EXPORT QgsOptionsDialogHighlightGroupBox : public QgsOptionsDialogHigh
virtual bool highlightText( const QString &text ) override;
virtual void reset() override;
QPointer<QGroupBox> mGroupBox;
QString mStyleSheet = QStringLiteral( "/*!search!*/QGroupBox::title { background-color: rgb(255, 251, 190); color: black;}/*!search!*/" );
QString mStyleSheet;
};

/**

0 comments on commit 87e8f9f

Please sign in to comment.
You can’t perform that action at this time.