[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-kimageshop
Subject: Patch: PaintOp preset usability improvements
From: Silvio Heinrich <plassy () web ! de>
Date: 2011-01-04 0:14:03
Message-ID: 4D22664B.50608 () web ! de
[Download RAW message or body]
["PaintOpPresets.patch" (text/x-diff)]
From 541017890fa8e672de1f6c7c841967b1db4bea60 Mon Sep 17 00:00:00 2001
From: Silvio Heinrich <plassy@web.de>
Date: Sat, 25 Dec 2010 17:04:16 +0100
Subject: [PATCH 1/7] Sort the paintop preset alphabetically.
---
krita/ui/widgets/kis_preset_chooser.cpp | 11 +++++++++--
1 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/krita/ui/widgets/kis_preset_chooser.cpp \
b/krita/ui/widgets/kis_preset_chooser.cpp index b13d65e..f84c922 100644
--- a/krita/ui/widgets/kis_preset_chooser.cpp
+++ b/krita/ui/widgets/kis_preset_chooser.cpp
@@ -30,6 +30,7 @@
#include <klineedit.h>
#include <kicon.h>
+#include <KoResource.h>
#include <KoResourceItemChooser.h>
#include <KoResourceModel.h>
#include <KoResourceServerAdapter.h>
@@ -100,6 +101,10 @@ void KisPresetDelegate::paint(QPainter * painter, const \
QStyleOptionViewItem & o
class KisPresetProxyAdapter : public KoResourceServerAdapter<KisPaintOpPreset>
{
+ static bool compareKoResources(const KoResource* a, const KoResource* b){
+ return a->name() < b->name();
+ }
+
public:
KisPresetProxyAdapter(KoResourceServer< KisPaintOpPreset >* resourceServer)
: KoResourceServerAdapter<KisPaintOpPreset>(resourceServer), \
m_showAll(false){} @@ -108,7 +113,7 @@ public:
virtual QList< KoResource* > resources() {
if( ! resourceServer() )
return QList<KoResource*>();
-
+
QList<KisPaintOpPreset*> serverResources = resourceServer()->resources();
QList<KoResource*> resources;
@@ -117,7 +122,9 @@ public:
resources.append( resource );
}
}
- return resources;
+
+ qSort(resources.begin(), resources.end(), \
KisPresetProxyAdapter::compareKoResources); + return resources;
}
bool filterAcceptsPreset(KisPaintOpPreset* preset) const
--
1.7.1
From d5a07666ac42351d7c5c31661f917ee13aa250e6 Mon Sep 17 00:00:00 2001
From: Silvio Heinrich <plassy@web.de>
Date: Sat, 25 Dec 2010 17:33:16 +0100
Subject: [PATCH 2/7] Removed superfluous include.
---
krita/ui/widgets/kis_preset_chooser.cpp | 1 -
1 files changed, 0 insertions(+), 1 deletions(-)
diff --git a/krita/ui/widgets/kis_preset_chooser.cpp \
b/krita/ui/widgets/kis_preset_chooser.cpp index f84c922..fc29556 100644
--- a/krita/ui/widgets/kis_preset_chooser.cpp
+++ b/krita/ui/widgets/kis_preset_chooser.cpp
@@ -30,7 +30,6 @@
#include <klineedit.h>
#include <kicon.h>
-#include <KoResource.h>
#include <KoResourceItemChooser.h>
#include <KoResourceModel.h>
#include <KoResourceServerAdapter.h>
--
1.7.1
From ebc051656c5d7d34a3fee7293f725673197ea4f1 Mon Sep 17 00:00:00 2001
From: Silvio Heinrich <plassy@web.de>
Date: Sat, 25 Dec 2010 21:50:04 +0100
Subject: [PATCH 3/7] When selecting a saved preset, the name will be loaded in the \
edit field of the PaintOpSettings popup.
---
krita/ui/kis_paintop_box.cc | 3 +++
krita/ui/widgets/kis_paintop_presets_popup.cpp | 5 +++++
krita/ui/widgets/kis_paintop_presets_popup.h | 3 ++-
3 files changed, 10 insertions(+), 1 deletions(-)
diff --git a/krita/ui/kis_paintop_box.cc b/krita/ui/kis_paintop_box.cc
index 3cb6651..a200ef0 100644
--- a/krita/ui/kis_paintop_box.cc
+++ b/krita/ui/kis_paintop_box.cc
@@ -177,6 +177,9 @@ KisPaintopBox::KisPaintopBox(KisView2 * view, QWidget *parent, \
const char * name
connect(m_resourceProvider, SIGNAL(sigNodeChanged(const KisNodeSP)),
this, SLOT(nodeChanged(const KisNodeSP)));
+
+ connect(m_presetsChooserPopup, SIGNAL(resourceSelected(KoResource*)),
+ m_presetsPopup, SLOT(resourceSelected(KoResource*)));
//Needed to connect canvas to favoriate resource manager
m_view->canvasBase()->createFavoriteResourceManager(this);
diff --git a/krita/ui/widgets/kis_paintop_presets_popup.cpp \
b/krita/ui/widgets/kis_paintop_presets_popup.cpp index 6a41049..4d71b39 100644
--- a/krita/ui/widgets/kis_paintop_presets_popup.cpp
+++ b/krita/ui/widgets/kis_paintop_presets_popup.cpp
@@ -241,5 +241,10 @@ void KisPaintOpPresetsPopup::showScratchPad()
m_d->uiWdgPaintOpPresetSettings.scratchPad->setVisible(true);
}
+void KisPaintOpPresetsPopup::resourceSelected(KoResource* resource)
+{
+ m_d->uiWdgPaintOpPresetSettings.txtPreset->setText(resource->name());
+}
+
#include "kis_paintop_presets_popup.moc"
diff --git a/krita/ui/widgets/kis_paintop_presets_popup.h \
b/krita/ui/widgets/kis_paintop_presets_popup.h index 71e00ac..49a242e 100644
--- a/krita/ui/widgets/kis_paintop_presets_popup.h
+++ b/krita/ui/widgets/kis_paintop_presets_popup.h
@@ -28,6 +28,7 @@ class QString;
class KisPaintOpPreset;
class KisPropertiesConfiguration;
class KisCanvasResourceProvider;
+class KoResource;
/**
* Popup widget for presets with built-in functionality
@@ -59,13 +60,13 @@ public:
QImage cutOutOverlay();
protected:
-
void contextMenuEvent(QContextMenuEvent *);
public slots:
void switchDetached();
void hideScratchPad();
void showScratchPad();
+ void resourceSelected(KoResource* resource);
signals:
void savePresetClicked();
--
1.7.1
From afad0392192fc1e9ee98886729b3da80264396fd Mon Sep 17 00:00:00 2001
From: Silvio Heinrich <plassy@web.de>
Date: Sun, 26 Dec 2010 01:40:31 +0100
Subject: [PATCH 4/7] Overwrite an existing PaintOp preset instead of creating a new \
one with the same name.
Additionally if a name is entered in the LineEdit field of the PaintOpPreset popup \
that exists already then the LineEdit field is highlighted and the save button text \
is changed to "Overwrite Preset"
---
krita/ui/kis_paintop_box.cc | 43 +++++++++++++++---------
krita/ui/kis_paintop_box.h | 2 +-
krita/ui/widgets/kis_paintop_presets_popup.cpp | 22 ++++++++++--
krita/ui/widgets/kis_paintop_presets_popup.h | 8 ++++
4 files changed, 55 insertions(+), 20 deletions(-)
diff --git a/krita/ui/kis_paintop_box.cc b/krita/ui/kis_paintop_box.cc
index a200ef0..4e60f69 100644
--- a/krita/ui/kis_paintop_box.cc
+++ b/krita/ui/kis_paintop_box.cc
@@ -171,15 +171,18 @@ KisPaintopBox::KisPaintopBox(KisView2 * view, QWidget *parent, \
const char * name
connect(m_presetsPopup, SIGNAL(savePresetClicked()), this, \
SLOT(slotSaveActivePreset()));
connect(m_presetsPopup, SIGNAL(defaultPresetClicked()), this, \
SLOT(slotSetupDefaultPreset())); +
+ connect(m_presetsPopup, SIGNAL(presetNameLineEditChanged(QString)),
+ this, SLOT(slotWatchPresetNameLineEdit(QString)));
connect(m_presetsChooserPopup, SIGNAL(resourceSelected(KoResource*)),
this, SLOT(resourceSelected(KoResource*)));
connect(m_resourceProvider, SIGNAL(sigNodeChanged(const KisNodeSP)),
this, SLOT(nodeChanged(const KisNodeSP)));
-
- connect(m_presetsChooserPopup, SIGNAL(resourceSelected(KoResource*)),
- m_presetsPopup, SLOT(resourceSelected(KoResource*)));
+
+ connect(m_presetsChooserPopup, SIGNAL(resourceSelected(KoResource*)),
+ m_presetsPopup, SLOT(resourceSelected(KoResource*)));
//Needed to connect canvas to favoriate resource manager
m_view->canvasBase()->createFavoriteResourceManager(this);
@@ -411,27 +414,28 @@ KisPaintOpPresetSP KisPaintopBox::activePreset(const KoID & \
paintop, const KoInp
void KisPaintopBox::slotSaveActivePreset()
{
- KisPaintOpPresetSP preset = m_resourceProvider->currentPreset();
- if (!preset)
+ KisPaintOpPresetSP curPreset = m_resourceProvider->currentPreset();
+
+ if (!curPreset)
return;
- KisPaintOpPreset* newPreset = preset->clone();
- newPreset->setImage(m_presetsPopup->cutOutOverlay());
-
+ KisPaintOpPreset* newPreset = curPreset->clone();
KoResourceServer<KisPaintOpPreset>* rServer = \
KisResourceServerProvider::instance()->paintOpPresetServer(); QString saveLocation = \
rServer->saveLocation();
-
QString name = m_presetsPopup->getPresetName();
+ QFileInfo fileInfo(saveLocation + name + newPreset->defaultFileExtension());
- QFileInfo fileInfo;
- fileInfo.setFile(saveLocation + name + newPreset->defaultFileExtension());
-
- int i = 1;
- while (fileInfo.exists()) {
- fileInfo.setFile(saveLocation + name + QString("%1").arg(i) + \
newPreset->defaultFileExtension());
- i++;
+ if (fileInfo.exists()) {
+ rServer->removeResource(rServer->getResourceByFilename(fileInfo.fileName()));
}
+
+// int i = 1;
+// while (fileInfo.exists()) {
+// fileInfo.setFile(saveLocation + name + QString("%1").arg(i) + \
newPreset->defaultFileExtension()); +// i++;
+// }
+ newPreset->setImage(m_presetsPopup->cutOutOverlay());
newPreset->setFilename(fileInfo.filePath());
newPreset->setName(name);
@@ -581,4 +585,11 @@ void KisPaintopBox::slotSaveToFavouriteBrushes()
}
}
+void KisPaintopBox::slotWatchPresetNameLineEdit(const QString& text)
+{
+ KoResourceServer<KisPaintOpPreset>* rServer = \
KisResourceServerProvider::instance()->paintOpPresetServer(); + \
m_presetsPopup->changeSavePresetButtonText(rServer->getResourceByName(text) != 0); +}
+
+
#include "kis_paintop_box.moc"
diff --git a/krita/ui/kis_paintop_box.h b/krita/ui/kis_paintop_box.h
index 85f4db2..6d17b83 100644
--- a/krita/ui/kis_paintop_box.h
+++ b/krita/ui/kis_paintop_box.h
@@ -105,7 +105,6 @@ private:
void setEnabledInternal(bool value);
private slots:
-
void updatePaintops();
void nodeChanged(const KisNodeSP node);
void eraseModeToggled(bool checked);
@@ -113,6 +112,7 @@ private slots:
void slotSetCompositeMode(const QString& compositeOp);
void slotSetPaintop(const QString& paintOpId);
void slotSaveToFavouriteBrushes();
+ void slotWatchPresetNameLineEdit(const QString& text);
private:
diff --git a/krita/ui/widgets/kis_paintop_presets_popup.cpp \
b/krita/ui/widgets/kis_paintop_presets_popup.cpp index 4d71b39..3c42640 100644
--- a/krita/ui/widgets/kis_paintop_presets_popup.cpp
+++ b/krita/ui/widgets/kis_paintop_presets_popup.cpp
@@ -112,6 +112,9 @@ KisPaintOpPresetsPopup::KisPaintOpPresetsPopup(KisCanvasResourceProvider \
* resou
connect(m_d->uiWdgPaintOpPresetSettings.bnDefaultPreset, SIGNAL(clicked()),
this, SIGNAL(defaultPresetClicked()));
+
+ connect(m_d->uiWdgPaintOpPresetSettings.txtPreset, SIGNAL(textChanged(QString)),
+ this, SIGNAL(presetNameLineEditChanged(QString)));
KisConfig cfg;
m_d->detached = !cfg.paintopPopupDetached();
@@ -161,9 +164,6 @@ void KisPaintOpPresetsPopup::setPaintOpSettingsWidget(QWidget * \
widget) }
if (widget) {
-
-
-
widget->setFont(m_d->smallFont);
m_d->settingsWidget->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, \
QSizePolicy::Fixed)); @@ -174,6 +174,22 @@ void \
KisPaintOpPresetsPopup::setPaintOpSettingsWidget(QWidget * widget) }
}
+void KisPaintOpPresetsPopup::changeSavePresetButtonText(bool change)
+{
+ QPalette palette;
+
+ if (change) {
+ palette.setColor(QPalette::Base, QColor(255,180,180));
+ m_d->uiWdgPaintOpPresetSettings.bnSave->setText("Overwrite Preset");
+ m_d->uiWdgPaintOpPresetSettings.txtPreset->setPalette(palette);
+ }
+ else {
+ m_d->uiWdgPaintOpPresetSettings.bnSave->setText("Save to Presets");
+ m_d->uiWdgPaintOpPresetSettings.txtPreset->setPalette(palette);
+ }
+}
+
+
QString KisPaintOpPresetsPopup::getPresetName() const
{
return m_d->uiWdgPaintOpPresetSettings.txtPreset->text();
diff --git a/krita/ui/widgets/kis_paintop_presets_popup.h \
b/krita/ui/widgets/kis_paintop_presets_popup.h index 49a242e..9379ba1 100644
--- a/krita/ui/widgets/kis_paintop_presets_popup.h
+++ b/krita/ui/widgets/kis_paintop_presets_popup.h
@@ -45,6 +45,12 @@ public:
~KisPaintOpPresetsPopup();
void setPaintOpSettingsWidget(QWidget * widget);
+
+ /**
+ * changes the "save to preset" button text to "override preset"
+ * and highlites the preset name lineedit
+ */
+ void changeSavePresetButtonText(bool change);
/**
* @return the name entered in the preset name lineedit
@@ -71,12 +77,14 @@ public slots:
signals:
void savePresetClicked();
void defaultPresetClicked();
+ void presetNameLineEditChanged(const QString& presetName);
private slots:
void fillScratchPadGradient();
void fillScratchPadSolid();
void fillScratchPadLayer();
void slotCheckPresetValidity();
+
private:
--
1.7.1
From f14337df9810157472ee73f07b82ef7ccc653ac7 Mon Sep 17 00:00:00 2001
From: Silvio Heinrich <plassy@web.de>
Date: Tue, 28 Dec 2010 17:49:11 +0100
Subject: [PATCH 5/7] Used i18n function for localization of hardcoded strings.
---
krita/ui/widgets/kis_paintop_presets_popup.cpp | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/krita/ui/widgets/kis_paintop_presets_popup.cpp \
b/krita/ui/widgets/kis_paintop_presets_popup.cpp index 3c42640..39b9af6 100644
--- a/krita/ui/widgets/kis_paintop_presets_popup.cpp
+++ b/krita/ui/widgets/kis_paintop_presets_popup.cpp
@@ -179,12 +179,12 @@ void KisPaintOpPresetsPopup::changeSavePresetButtonText(bool \
change) QPalette palette;
if (change) {
- palette.setColor(QPalette::Base, QColor(255,180,180));
- m_d->uiWdgPaintOpPresetSettings.bnSave->setText("Overwrite Preset");
+ palette.setColor(QPalette::Base, QColor(255,200,200));
+ m_d->uiWdgPaintOpPresetSettings.bnSave->setText(i18n("Overwrite Preset"));
m_d->uiWdgPaintOpPresetSettings.txtPreset->setPalette(palette);
}
else {
- m_d->uiWdgPaintOpPresetSettings.bnSave->setText("Save to Presets");
+ m_d->uiWdgPaintOpPresetSettings.bnSave->setText(i18n("Save to Presets"));
m_d->uiWdgPaintOpPresetSettings.txtPreset->setPalette(palette);
}
}
--
1.7.1
From 354376d992c2feefcb6e33b67e565fa07074e0d0 Mon Sep 17 00:00:00 2001
From: Silvio Heinrich <plassy@web.de>
Date: Tue, 28 Dec 2010 17:52:51 +0100
Subject: [PATCH 6/7] Highlight the preset name LineEdit field after saving a preset.
---
krita/ui/kis_paintop_box.cc | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/krita/ui/kis_paintop_box.cc b/krita/ui/kis_paintop_box.cc
index 4e60f69..90cfc8c 100644
--- a/krita/ui/kis_paintop_box.cc
+++ b/krita/ui/kis_paintop_box.cc
@@ -439,6 +439,8 @@ void KisPaintopBox::slotSaveActivePreset()
newPreset->setFilename(fileInfo.filePath());
newPreset->setName(name);
+ m_presetsPopup->changeSavePresetButtonText(true);
+
rServer->addResource(newPreset);
}
--
1.7.1
From 3860720113c8d20a887f0839485c9d53ba0cb6d5 Mon Sep 17 00:00:00 2001
From: Silvio Heinrich <plassy@web.de>
Date: Mon, 3 Jan 2011 00:49:13 +0100
Subject: [PATCH 7/7] Added copyright information for the preset chooser files.
---
krita/ui/kis_paintop_box.cc | 1 +
krita/ui/kis_paintop_box.h | 1 +
krita/ui/widgets/kis_paintop_presets_popup.cpp | 1 +
krita/ui/widgets/kis_paintop_presets_popup.h | 1 +
krita/ui/widgets/kis_preset_chooser.cpp | 1 +
krita/ui/widgets/kis_preset_chooser.h | 1 +
6 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/krita/ui/kis_paintop_box.cc b/krita/ui/kis_paintop_box.cc
index 90cfc8c..e8c1603 100644
--- a/krita/ui/kis_paintop_box.cc
+++ b/krita/ui/kis_paintop_box.cc
@@ -4,6 +4,7 @@
* Copyright (c) 2004 Boudewijn Rempt (boud@valdyas.org)
* Copyright (c) 2009 Sven Langkamp (sven.langkamp@gmail.com)
* Copyright (c) 2010 Lukáš Tvrdý <lukast.dev@gmail.com>
+ * Copyright (C) 2011 Silvio Heinrich <plassy@web.de>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/krita/ui/kis_paintop_box.h b/krita/ui/kis_paintop_box.h
index 6d17b83..618b757 100644
--- a/krita/ui/kis_paintop_box.h
+++ b/krita/ui/kis_paintop_box.h
@@ -2,6 +2,7 @@
* kis_paintop_box.h - part of KImageShop/Krayon/Krita
*
* Copyright (c) 2004-2008 Boudewijn Rempt (boud@valdyas.org)
+ * Copyright (C) 2011 Silvio Heinrich <plassy@web.de>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/krita/ui/widgets/kis_paintop_presets_popup.cpp \
b/krita/ui/widgets/kis_paintop_presets_popup.cpp index 39b9af6..9447d42 100644
--- a/krita/ui/widgets/kis_paintop_presets_popup.cpp
+++ b/krita/ui/widgets/kis_paintop_presets_popup.cpp
@@ -1,6 +1,7 @@
/* This file is part of the KDE project
* Copyright (C) 2008 Boudewijn Rempt <boud@valdyas.org>
* Copyright (C) 2010 Lukáš Tvrdý <lukast.dev@gmail.com>
+ * Copyright (C) 2011 Silvio Heinrich <plassy@web.de>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
diff --git a/krita/ui/widgets/kis_paintop_presets_popup.h \
b/krita/ui/widgets/kis_paintop_presets_popup.h index 9379ba1..8d338f4 100644
--- a/krita/ui/widgets/kis_paintop_presets_popup.h
+++ b/krita/ui/widgets/kis_paintop_presets_popup.h
@@ -1,6 +1,7 @@
/* This file is part of the KDE project
* Copyright (C) Boudewijn Rempt <boud@valdyas.org>, (C) 2008
* Copyright (C) 2010 Lukáš Tvrdý <lukast.dev@gmail.com>
+ * Copyright (C) 2011 Silvio Heinrich <plassy@web.de>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
diff --git a/krita/ui/widgets/kis_preset_chooser.cpp \
b/krita/ui/widgets/kis_preset_chooser.cpp index fc29556..9940aa4 100644
--- a/krita/ui/widgets/kis_preset_chooser.cpp
+++ b/krita/ui/widgets/kis_preset_chooser.cpp
@@ -1,6 +1,7 @@
/*
* Copyright (c) 2002 Patrick Julien <freak@codepimps.org>
* Copyright (c) 2009 Sven Langkamp <sven.langkamp@gmail.com>
+ * Copyright (C) 2011 Silvio Heinrich <plassy@web.de>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/krita/ui/widgets/kis_preset_chooser.h \
b/krita/ui/widgets/kis_preset_chooser.h index 8c383b9..88d909d 100644
--- a/krita/ui/widgets/kis_preset_chooser.h
+++ b/krita/ui/widgets/kis_preset_chooser.h
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2002 Patrick Julien <freak@codepimps.org>
+ * Copyright (C) 2011 Silvio Heinrich <plassy@web.de>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
--
1.7.1
_______________________________________________
kimageshop mailing list
kimageshop@kde.org
https://mail.kde.org/mailman/listinfo/kimageshop
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic