summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustus Winter <[email protected]>2017-06-30 13:38:48 +0200
committerJustus Winter <[email protected]>2017-07-11 10:58:45 +0200
commit931613b5d1fb9b5cfdd922d436a99ad758e610bf (patch)
tree600ac0192391490df08e5764e1eca6da18bcab4a
parent09197d18207a0ecbd94f52cc26a47d913e362190 (diff)
Add and use a second set of key filters
The second set is not part of the model (i.e. it will not be displayed in Kleopatras drop down list in the default view), and will only be used for styling keys. Signed-off-by: Justus Winter <[email protected]>
-rw-r--r--src/kleo/keyfiltermanager.cpp41
1 files changed, 36 insertions, 5 deletions
diff --git a/src/kleo/keyfiltermanager.cpp b/src/kleo/keyfiltermanager.cpp
index 6b106d6..9e8582b 100644
--- a/src/kleo/keyfiltermanager.cpp
+++ b/src/kleo/keyfiltermanager.cpp
@@ -167,17 +167,25 @@ static std::vector<std::shared_ptr<KeyFilter>> defaultFilters()
return result;
}
+static std::vector<std::shared_ptr<KeyFilter>> defaultAppearanceFilters()
+{
+ std::vector<std::shared_ptr<KeyFilter> > result;
+ return result;
+}
+
class KeyFilterManager::Private
{
public:
- Private() : filters(), model(this) {}
+ Private() : filters(), appearanceFilters(), model(this) {}
void clear()
{
filters.clear();
+ appearanceFilters.clear();
model.reset();
}
std::vector<std::shared_ptr<KeyFilter>> filters;
+ std::vector<std::shared_ptr<KeyFilter>> appearanceFilters;
Model model;
};
@@ -251,6 +259,7 @@ void KeyFilterManager::reload()
d->clear();
d->filters = defaultFilters();
+ d->appearanceFilters = defaultAppearanceFilters();
KSharedConfigPtr config = KSharedConfig::openConfig(QStringLiteral("libkleopatrarc"));
const QStringList groups = config->groupList().filter(QRegularExpression(QStringLiteral("^Key Filter #\\d+$")));
@@ -339,7 +348,12 @@ static KeyFilter::FontDescription get_fontdescription(const std::vector<std::sha
QFont KeyFilterManager::font(const Key &key, const QFont &baseFont) const
{
- return get_fontdescription(d->filters, key, KeyFilter::FontDescription()).font(baseFont);
+ KeyFilter::FontDescription fd;
+
+ fd = get_fontdescription(d->appearanceFilters, key, KeyFilter::FontDescription());
+ fd = get_fontdescription(d->filters, key, fd);
+
+ return fd.font(baseFont);
}
static QColor get_color(const std::vector<std::shared_ptr<KeyFilter>> &filters, const Key &key, QColor(KeyFilter::*fun)() const)
@@ -372,17 +386,34 @@ static QString get_string(const std::vector<std::shared_ptr<KeyFilter>> &filters
QColor KeyFilterManager::bgColor(const Key &key) const
{
- return get_color(d->filters, key, &KeyFilter::bgColor);
+ QColor color;
+
+ color = get_color(d->appearanceFilters, key, &KeyFilter::bgColor);
+ if (!color.isValid()) {
+ color = get_color(d->filters, key, &KeyFilter::bgColor);
+ }
+ return color;
}
QColor KeyFilterManager::fgColor(const Key &key) const
{
- return get_color(d->filters, key, &KeyFilter::fgColor);
+ QColor color;
+
+ color = get_color(d->appearanceFilters, key, &KeyFilter::fgColor);
+ if (!color.isValid()) {
+ color = get_color(d->filters, key, &KeyFilter::fgColor);
+ }
+ return color;
}
QIcon KeyFilterManager::icon(const Key &key) const
{
- const QString icon = get_string(d->filters, key, &KeyFilter::icon);
+ QString icon;
+
+ icon = get_string(d->appearanceFilters, key, &KeyFilter::icon);
+ if (icon.isEmpty()) {
+ icon = get_string(d->filters, key, &KeyFilter::icon);
+ }
return icon.isEmpty() ? QIcon() : QIcon::fromTheme(icon);
}