diff --git a/libs/resourcewidgets/KisTagFilterWidget.cpp b/libs/resourcewidgets/KisTagFilterWidget.cpp index e9fd84da71..a49fcccf1b 100644 --- a/libs/resourcewidgets/KisTagFilterWidget.cpp +++ b/libs/resourcewidgets/KisTagFilterWidget.cpp @@ -1,126 +1,139 @@ /* * This file is part of the KDE project * Copyright (c) 2002 Patrick Julien * Copyright (c) 2007 Jan Hambrecht * Copyright (c) 2007 Sven Langkamp * Copyright (C) 2011 Srikanth Tiyyagura * Copyright (c) 2011 José Luis Vergara * Copyright (c) 2013 Sascha Suelzer * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #include "KisTagFilterWidget.h" #include #include #include #include #include #include #include #include #include +#include +#include +#include class KisTagFilterWidget::Private { public: QString tagSearchBarTooltip_saving_disabled; QString tagSearchBarTooltip_saving_enabled; QLineEdit* tagSearchLineEdit; QGridLayout* filterBarLayout; QCompleter* completer; QCheckBox* filterByTagCheckbox; + QString configGroup {"resources"}; + QString configName {"filterByTagChecked"}; + }; KisTagFilterWidget::KisTagFilterWidget(KisTagModel* model, QWidget* parent) : QWidget(parent) , d(new Private()) { QString searchTooltipMaintext = i18nc( "@info:tooltip", "

Enter search terms here to add resources to, or remove them from, the current tag view.

" "

To filter based on the partial, case insensitive name of a resource:
" "partialname or !partialname

" "

To include or exclude other tag sets:
" "[Tagname] or ![Tagname]

" "

For case sensitive and full name matching in-/exclusion:
" "\"ExactMatch\" or !\"ExactMatch\"

"); d->tagSearchBarTooltip_saving_disabled = searchTooltipMaintext + i18nc( "@info:tooltip", "

Filter results cannot be saved for the All Presets view. " "In this view, pressing Enter or clearing the filter box will restore all items. " "Create and/or switch to a different tag if you want to save filtered resources into named sets.

"); d->tagSearchBarTooltip_saving_enabled = searchTooltipMaintext + i18nc( "@info:tooltip", "

Pressing Enter or clicking the Save button will save the changes.

"); QGridLayout* filterBarLayout = new QGridLayout; d->tagSearchLineEdit = new QLineEdit(this); d->tagSearchLineEdit->setClearButtonEnabled(true); d->tagSearchLineEdit->setPlaceholderText(i18n("Search")); d->tagSearchLineEdit->setToolTip(d->tagSearchBarTooltip_saving_disabled); d->tagSearchLineEdit->setEnabled(true); d->completer = new QCompleter(model, this); d->completer->setCompletionRole(Qt::DisplayRole); d->completer->setCaseSensitivity(Qt::CaseInsensitive); d->tagSearchLineEdit->setCompleter(d->completer); filterBarLayout->setMargin(0); filterBarLayout->setColumnStretch(0, 1); filterBarLayout->addWidget(d->tagSearchLineEdit, 0, 0); d->filterByTagCheckbox = new QCheckBox(this); d->filterByTagCheckbox->setText(i18nc("It appears in the checkbox next to the filter box " "in resources dockers; must be short.", "filter by tag")); + KConfigGroup cfg = KSharedConfig::openConfig()->group(d->configGroup); + bool filterByTagCheckboxChecked = cfg.readEntry(d->configName, true); + d->filterByTagCheckbox->setChecked(filterByTagCheckboxChecked); + + filterBarLayout->addWidget(d->filterByTagCheckbox, 0, 1); connect(d->tagSearchLineEdit, SIGNAL(textChanged(QString)), this, SLOT(onTextChanged(QString))); connect(d->filterByTagCheckbox, SIGNAL(stateChanged(int)), this, SLOT(slotFilterByTagChanged(int))); this->setLayout(filterBarLayout); } KisTagFilterWidget::~KisTagFilterWidget() { delete d; } void KisTagFilterWidget::clear() { d->tagSearchLineEdit->clear(); } void KisTagFilterWidget::onTextChanged(const QString& lineEditText) { emit filterTextChanged(lineEditText); } void KisTagFilterWidget::slotFilterByTagChanged(int filterByTag) { emit filterByTagChanged(filterByTag == Qt::Checked); + KConfigGroup cfg = KSharedConfig::openConfig()->group(d->configGroup); + cfg.writeEntry(d->configName, filterByTag == Qt::Checked); }