Skip to content

Commit

Permalink
Merge pull request #24 from tgoettlicher/fix_color
Browse files Browse the repository at this point in the history
fixed hard-coded colors
  • Loading branch information
mvidner committed Mar 10, 2014
2 parents a476f6e + b4e6867 commit 74edd5b
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
28 changes: 26 additions & 2 deletions src/QY2HelpDialog.cc
Expand Up @@ -44,11 +44,12 @@

QY2HelpDialog::QY2HelpDialog( const QString& helpText, QWidget *parent )
: QDialog( parent )
, _searchResultForeground(Qt::black)
, _searchResultBackground(Qt::yellow)
{
_ui = new Ui_QHelpDialog();
_ui->setupUi( this );
_ui->textBrowser->setText( helpText );

_ui->label->setPixmap ( QPixmap( viewmag ) );
connect( _ui->lineEdit, &pclass(_ui->lineEdit)::textEdited,
this, &pclass(this)::searchStringChanged );
Expand Down Expand Up @@ -83,7 +84,8 @@ QY2HelpDialog::~QY2HelpDialog()
void QY2HelpDialog::searchStringChanged( QString text )
{
QTextCharFormat fmt;
fmt.setBackground( Qt::yellow );
fmt.setBackground(getSearchResultBackground());
fmt.setForeground(getSearchResultForeground());
QTextDocument *d = _ui->textBrowser->document();

QTextCursor all(d);
Expand Down Expand Up @@ -112,4 +114,26 @@ void QY2HelpDialog::retranslate()
}


QColor QY2HelpDialog::getSearchResultForeground()
{
return _searchResultForeground;
}

void QY2HelpDialog::setSearchResultForeground( QColor pen )
{
_searchResultForeground = pen;
}

QColor QY2HelpDialog::getSearchResultBackground()
{
return _searchResultBackground;
}

void QY2HelpDialog::setSearchResultBackground( QColor pen )
{
_searchResultBackground = pen;
}



#include "QY2HelpDialog.moc"
9 changes: 9 additions & 0 deletions src/QY2HelpDialog.h
Expand Up @@ -28,26 +28,35 @@
#define _QY2HelpDialog_h

#include <QDialog>
#include <QColor>

class QTextCursor;
class Ui_QHelpDialog;

class QY2HelpDialog : public QDialog
{
Q_OBJECT
Q_PROPERTY(QColor searchResultForeground READ getSearchResultForeground WRITE setSearchResultForeground DESIGNABLE true)
Q_PROPERTY(QColor searchResultBackground READ getSearchResultBackground WRITE setSearchResultBackground DESIGNABLE true)

public:
QY2HelpDialog( const QString &helpText, QWidget *parent );
~QY2HelpDialog();
void setHelpText( const QString &helpText );
void retranslate();
QColor getSearchResultForeground();
QColor getSearchResultBackground();
void setSearchResultForeground( QColor pen );
void setSearchResultBackground( QColor pen );

public slots:
void searchStringChanged( QString );

private:
Ui_QHelpDialog *_ui;
QList<QTextCursor> _marks;
QColor _searchResultForeground;
QColor _searchResultBackground;


};
Expand Down

0 comments on commit 74edd5b

Please sign in to comment.