Skip to content

Commit

Permalink
Set icon color for search options according to HAL standards
Browse files Browse the repository at this point in the history
  • Loading branch information
joern274 committed Sep 29, 2023
1 parent 4ff3e8b commit 45e0e20
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 59 deletions.
25 changes: 11 additions & 14 deletions plugins/gui/include/gui/searchbar/searchbar.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,8 @@ namespace hal
Q_PROPERTY(QString searchIconStyle READ searchIconStyle WRITE setSearchIconStyle)
Q_PROPERTY(QString clearIcon READ clearIcon WRITE setClearIcon)
Q_PROPERTY(QString clearIconStyle READ clearIconStyle WRITE setClearIconStyle)
/*Q_PROPERTY(QString caseSensitivityIcon READ caseSensitivityIcon WRITE setCaseSensitivityIcon)
Q_PROPERTY(QString caseSensitivityIconStyle READ caseSensitivityIconStyle WRITE setCaseSensitivityIconStyle)
Q_PROPERTY(QString exactMatchIcon READ exactMatchIcon WRITE setExactMatchIcon)
Q_PROPERTY(QString exactMatchIconStyle READ exactMatchIconStyle WRITE setExactMatchIconStyle)*/
Q_PROPERTY(QString optionDialogIcon READ optionDialogIcon WRITE setOptionDialogIcon)
Q_PROPERTY(QString optionDialogIconStyle READ optionDialogIconStyle WRITE setOptionDialogIconStyle)

public:
/**
Expand All @@ -70,10 +68,8 @@ namespace hal
QString searchIconStyle() const;
QString clearIcon() const;
QString clearIconStyle() const;
/*QString caseSensitivityIcon() const;
QString caseSensitivityIconStyle() const;
QString exactMatchIcon() const;
QString exactMatchIconStyle() const;*/
QString optionDialogIcon() const;
QString optionDialogIconStyle() const;
///@}

/// @name Q_PROPERTY WRITE Functions
Expand All @@ -83,10 +79,8 @@ namespace hal
void setClearIcon(const QString& icon);
void setClearIconStyle(const QString& style);
void setColumnNames(QList<QString> list);
/*void setCaseSensitivityIcon(const QString& icon);
void setCaseSensitivityIconStyle(const QString& style);
void setExactMatchIcon(const QString& icon);
void setExactMatchIconStyle(const QString& style);*/
void setOptionDialogIcon(const QString& icon);
void setOptionDialogIconStyle(const QString& style);
///@}

/**
Expand Down Expand Up @@ -138,15 +132,16 @@ namespace hal
*/
void repolish();

SearchOptions getSearchOptions() const;
/**
* @return mExactMatch->isChecked()
*/
bool exactMatchChecked();
// bool exactMatchChecked();

/**
* @return mCaseSensitive->isChecked()
*/
bool caseSensitiveChecked();
// bool caseSensitiveChecked();

/**
* A filter is applied when the searchbar contains text or (at least) one of the flags
Expand Down Expand Up @@ -226,6 +221,8 @@ namespace hal
QString mSearchIconStyle;
QString mClearIcon;
QString mClearIconStyle;
QString mOptionDialogIcon;
QString mOptionDialogIconStyle;

QList<QString> mColumnNames;

Expand Down
10 changes: 6 additions & 4 deletions plugins/gui/resources/stylesheet/dark.qss
Original file line number Diff line number Diff line change
Expand Up @@ -293,10 +293,12 @@ hal--Searchbar
border-width : 6px;
border-style : solid;
border-color : rgb(9, 11, 13);
qproperty-searchIcon : ":/icons/search";
qproperty-searchIconStyle : "all -> #E4E4E4";
qproperty-clearIcon : ":/icons/cross";
qproperty-clearIconStyle : "all -> #E4E4E4";
qproperty-searchIcon : ":/icons/search";
qproperty-searchIconStyle : "all -> #E4E4E4";
qproperty-clearIcon : ":/icons/cross";
qproperty-clearIconStyle : "all -> #E4E4E4";
qproperty-optionDialogIcon : ":/icons/settings";
qproperty-optionDialogIconStyle : "all -> #E4E4E4";
}

hal--Searchbar QLabel
Expand Down
10 changes: 6 additions & 4 deletions plugins/gui/resources/stylesheet/light.qss
Original file line number Diff line number Diff line change
Expand Up @@ -316,10 +316,12 @@ hal--Searchbar
border-width : 6px;
border-style : solid;
border-color : black;
qproperty-searchIcon : ":/icons/search";
qproperty-searchIconStyle : "all -> #000000";
qproperty-clearIcon : ":/icons/cross";
qproperty-clearIconStyle : "all -> #000000";
qproperty-searchIcon : ":/icons/search";
qproperty-searchIconStyle : "all -> #000000";
qproperty-clearIcon : ":/icons/cross";
qproperty-clearIconStyle : "all -> #000000";
qproperty-optionDialogIcon : ":/icons/settings";
qproperty-optionDialogIconStyle : "all -> #000000";
}

hal--Searchbar QLabel
Expand Down
4 changes: 2 additions & 2 deletions plugins/gui/src/python/python_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1631,9 +1631,9 @@ namespace hal
QTextDocument::FindFlags PythonEditor::getFindFlags()
{
QTextDocument::FindFlags options = QTextDocument::FindFlags();
if (mSearchbar->caseSensitiveChecked())
if (mSearchbar->getSearchOptions().isCaseSensitive())
options = options | QTextDocument::FindCaseSensitively;
if (mSearchbar->exactMatchChecked())
if (mSearchbar->getSearchOptions().isExactMatch())
options = options | QTextDocument::FindWholeWords;
return options;
}
Expand Down
56 changes: 21 additions & 35 deletions plugins/gui/src/searchbar/searchbar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace hal
{
Searchbar::Searchbar(QWidget* parent)
: QFrame(parent), mLayout(new QHBoxLayout()), mSearchIconLabel(new QLabel()), mLineEdit(new QLineEdit()), mClearIconLabel(new QLabel()), mDownButton(new QToolButton()),
mUpButton(new QToolButton()), /*mCaseSensitiveButton(new QToolButton()),*/ mSearchOptionsButton(new QToolButton()), mClearButton(new QToolButton())
mUpButton(new QToolButton()), mSearchOptionsButton(new QToolButton()), mClearButton(new QToolButton())
{
setLayout(mLayout);

Expand All @@ -38,7 +38,7 @@ namespace hal
//Placeholder icons get better ones
mDownButton->setIcon(QIcon(":/icons/arrow-down"));
mUpButton->setIcon(QIcon(":/icons/arrow-up"));
mSearchOptionsButton->setIcon(QIcon(":/icons/settings"));
mSearchOptionsButton->setIcon(gui_utility::getStyledSvgIcon(mOptionDialogIconStyle,mOptionDialogIcon));

mSearchIconLabel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::MinimumExpanding);
mLineEdit->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
Expand All @@ -62,15 +62,19 @@ namespace hal

connect(mLineEdit, &QLineEdit::textEdited, this, &Searchbar::handleTextEdited);
connect(mLineEdit, &QLineEdit::returnPressed, this, &Searchbar::handleReturnPressed);
//connect(mCaseSensitiveButton, &QToolButton::clicked, this, &Searchbar::handleTextEdited);
//connect(mSearchOptionsButton, &QToolButton::clicked, this, &Searchbar::emitTextEdited);
connect(mClearButton, &QToolButton::clicked, this, &Searchbar::handleClearClicked);

connect(mSearchOptionsButton, &QToolButton::clicked, this, &Searchbar::handleSearchOptionsDialog);

setFocusProxy(mLineEdit);
}

SearchOptions Searchbar::getSearchOptions() const
{
if (!mCurrentOptions) return SearchOptions();
return *mCurrentOptions;
}

QString Searchbar::searchIcon() const
{
return mSearchIcon;
Expand All @@ -91,26 +95,16 @@ namespace hal
return mClearIconStyle;
}

/*QString Searchbar::caseSensitivityIcon() const
QString Searchbar::optionDialogIcon() const
{
return mCaseSensitivityIcon;
return mOptionDialogIcon;
}

QString Searchbar::caseSensitivityIconStyle() const
QString Searchbar::optionDialogIconStyle() const
{
return mCaseSensitivityIconStyle;
return mOptionDialogIconStyle;
}

QString Searchbar::exactMatchIcon() const
{
return mExactMatchIcon;
}
QString Searchbar::exactMatchIconStyle() const
{
return mExactMatchIconStyle;
}*/

void Searchbar::setSearchIcon(const QString& icon)
{
mSearchIcon = icon;
Expand All @@ -136,26 +130,16 @@ namespace hal
mColumnNames = list;
}

/*void Searchbar::setCaseSensitivityIcon(const QString& icon)
{
mCaseSensitivityIcon = icon;
}
void Searchbar::setCaseSensitivityIconStyle(const QString& style)
void Searchbar::setOptionDialogIcon(const QString& icon)
{
mCaseSensitivityIconStyle = style;
mOptionDialogIcon = icon;
}

void Searchbar::setExactMatchIcon(const QString& icon)
void Searchbar::setOptionDialogIconStyle(const QString& style)
{
mExactMatchIcon = icon;
mOptionDialogIconStyle = style;
}

void Searchbar::setExactMatchIconStyle(const QString& style)
{
mExactMatchIconStyle = style;
}*/

void Searchbar::setPlaceholderText(const QString& text)
{
mLineEdit->setPlaceholderText(text);
Expand Down Expand Up @@ -191,8 +175,8 @@ namespace hal
{
QString textWithFlags;

textWithFlags.append(caseSensitiveChecked() ? "(?-i)" : "(?i)");
if (exactMatchChecked())
textWithFlags.append(mCurrentOptions->isCaseSensitive() ? "(?-i)" : "(?i)");
if (mCurrentOptions->isExactMatch())
{
textWithFlags.append("^");
textWithFlags.append(text);
Expand Down Expand Up @@ -237,6 +221,7 @@ namespace hal
clear();
}

/*
bool Searchbar::exactMatchChecked()
{
return mCurrentOptions->toInt()&&1;
Expand All @@ -246,6 +231,7 @@ namespace hal
{
return mCurrentOptions->toInt()&&2;
}
*/

void Searchbar::setEmitTextWithFlags(bool emitTextWithFlags)
{
Expand All @@ -272,7 +258,7 @@ namespace hal

bool Searchbar::filterApplied()
{
return !getCurrentText().isEmpty() || exactMatchChecked() || caseSensitiveChecked();
return !getCurrentText().isEmpty() || mCurrentOptions->isExactMatch() || mCurrentOptions->isCaseSensitive();
}

void Searchbar::handleSearchOptionsDialog()
Expand Down

0 comments on commit 45e0e20

Please sign in to comment.