diff --git a/plugins/gui/include/gui/searchbar/searchbar.h b/plugins/gui/include/gui/searchbar/searchbar.h index 84aaaa83eee..13c80f5d45b 100644 --- a/plugins/gui/include/gui/searchbar/searchbar.h +++ b/plugins/gui/include/gui/searchbar/searchbar.h @@ -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: /** @@ -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 @@ -83,10 +79,8 @@ namespace hal void setClearIcon(const QString& icon); void setClearIconStyle(const QString& style); void setColumnNames(QList 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); ///@} /** @@ -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 @@ -226,6 +221,8 @@ namespace hal QString mSearchIconStyle; QString mClearIcon; QString mClearIconStyle; + QString mOptionDialogIcon; + QString mOptionDialogIconStyle; QList mColumnNames; diff --git a/plugins/gui/resources/stylesheet/dark.qss b/plugins/gui/resources/stylesheet/dark.qss index 4cbe8ff2d47..697d6c74754 100755 --- a/plugins/gui/resources/stylesheet/dark.qss +++ b/plugins/gui/resources/stylesheet/dark.qss @@ -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 diff --git a/plugins/gui/resources/stylesheet/light.qss b/plugins/gui/resources/stylesheet/light.qss index ce3511af89b..ebb92ef4992 100755 --- a/plugins/gui/resources/stylesheet/light.qss +++ b/plugins/gui/resources/stylesheet/light.qss @@ -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 diff --git a/plugins/gui/src/python/python_editor.cpp b/plugins/gui/src/python/python_editor.cpp index 3855547042e..7953c382fac 100644 --- a/plugins/gui/src/python/python_editor.cpp +++ b/plugins/gui/src/python/python_editor.cpp @@ -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; } diff --git a/plugins/gui/src/searchbar/searchbar.cpp b/plugins/gui/src/searchbar/searchbar.cpp index 3b357a01e81..9da014e36d3 100644 --- a/plugins/gui/src/searchbar/searchbar.cpp +++ b/plugins/gui/src/searchbar/searchbar.cpp @@ -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); @@ -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); @@ -62,8 +62,6 @@ 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); @@ -71,6 +69,12 @@ namespace hal setFocusProxy(mLineEdit); } + SearchOptions Searchbar::getSearchOptions() const + { + if (!mCurrentOptions) return SearchOptions(); + return *mCurrentOptions; + } + QString Searchbar::searchIcon() const { return mSearchIcon; @@ -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; @@ -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); @@ -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); @@ -237,6 +221,7 @@ namespace hal clear(); } + /* bool Searchbar::exactMatchChecked() { return mCurrentOptions->toInt()&&1; @@ -246,6 +231,7 @@ namespace hal { return mCurrentOptions->toInt()&&2; } +*/ void Searchbar::setEmitTextWithFlags(bool emitTextWithFlags) { @@ -272,7 +258,7 @@ namespace hal bool Searchbar::filterApplied() { - return !getCurrentText().isEmpty() || exactMatchChecked() || caseSensitiveChecked(); + return !getCurrentText().isEmpty() || mCurrentOptions->isExactMatch() || mCurrentOptions->isCaseSensitive(); } void Searchbar::handleSearchOptionsDialog()