Commit f71c438e authored by Boudewijn Rempt's avatar Boudewijn Rempt

Show the combobox for the paintop presets (not that there are any atm,

but that's the next step)

svn path=/trunk/koffice/; revision=833584
parent 4d57acbe
......@@ -114,7 +114,7 @@ KisControlFrame::KisControlFrame( KisView2 * view, const char* name )
action->setDefaultWidget( m_gradientWidget );
/**** Temporary hack to test the KoDualColorButton ***/
KoDualColorButton * dual = new KoDualColorButton(view->resourceProvider()->fgColor(), view->resourceProvider()->fgColor(), view, view);
KoDualColorButton * dual = new KoDualColorButton(view->resourceProvider()->fgColor(), view->resourceProvider()->fgColor(), view, view);
action = new KAction(i18n("&Painter's Tools"), this);
view->actionCollection()->addAction("dual", action );
action->setDefaultWidget( dual );
......@@ -135,7 +135,7 @@ KisControlFrame::KisControlFrame( KisView2 * view, const char* name )
m_patternWidget->setPopupWidget(m_patternChooserPopup);
m_gradientWidget->setPopupWidget(m_gradientChooserPopup);
m_paintopBox = new KisPaintopBox( view, view, "paintopbox" );
action = new KAction(i18n("&Painter's Tools"), this);
view->actionCollection()->addAction("paintops", action );
......
......@@ -51,7 +51,7 @@ class KXmlGuiWindow;
* Control Frame - status display with access to
* color selector, brushes, patterns, and preview
*/
class KisControlFrame : public QObject
class KisControlFrame : public QObject
{
Q_OBJECT
......
......@@ -150,6 +150,10 @@ bool allowAsChild( const QString & parentType, const QString & childType )
void KisNodeManager::getNewNodeLocation(const QString & nodeType, KisNodeSP &parent, KisNodeSP &above, KisNodeSP _activeNode)
{
qDebug() << "Type: " << nodeType;
qDebug() << "Parent: " << parent;
qDebug() << "active node: " << _activeNode;
KisNodeSP root = m_d->view->image()->root();
if (!_activeNode)
_activeNode = root->firstChild();
......@@ -195,6 +199,7 @@ void KisNodeManager::insertNode( KisNodeSP node, KisNodeSP parent, int index )
void KisNodeManager::moveNode( KisNodeSP node, KisNodeSP activeNode)
{
if(activeNode)
dbgUI << " move node " << node->name() << " toward " << activeNode->name();
else
......
......@@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include <iostream>
#include "kis_node_model.h"
#include "kis_debug.h"
......@@ -361,6 +361,7 @@ QMimeData * KisNodeModel::mimeData ( const QModelIndexList & indexes ) const
bool KisNodeModel::dropMimeData ( const QMimeData * data, Qt::DropAction action, int row, int column, const QModelIndex & parent )
{
Q_UNUSED(row);
Q_UNUSED(column);
dbgUI <<"KisNodeModel::dropMimeData" << data->formats() << " row = " << row << " column = " << column;
......
......@@ -43,7 +43,7 @@
#include <kis_painter.h>
#include <kis_paintop.h>
#include <kis_layer.h>
#include <kis_resource_server_provider.h>
#include <kis_paintop_settings.h>
#include <kis_image.h>
#include <kis_node.h>
......@@ -73,13 +73,19 @@ KisPaintopBox::KisPaintopBox (KisView2 * view, QWidget *parent, const char * nam
m_cmbPaintops->setMinimumWidth(150);
m_cmbPaintops->setToolTip(i18n("Artist's materials"));
m_cmbPaintopPresets = new KComboBox(this);
m_cmbPaintopPresets->setObjectName("KisPaintopBox::m_cmbPaintopPresets");
m_cmbPaintopPresets->setMinimumWidth(150);
m_cmbPaintopPresets->setToolTip(i18n("Brush presets"));
m_layout = new QHBoxLayout(this);
m_layout->setMargin(1);
m_layout->setSpacing(1);
m_layout->addWidget(m_cmbPaintops);
m_layout->addWidget(m_cmbPaintopPresets);
KisPresetWidget * m_presetWidget = new KisPresetWidget(this, "presetwidget");
m_presetWidget->setToolTip(i18n("Edit brush settings"));
m_presetWidget->setToolTip(i18n("Edit brush preset"));
m_presetWidget->setFixedSize( 130, 26 );
m_layout->addWidget(m_presetWidget);
......@@ -128,6 +134,19 @@ void KisPaintopBox::slotItemSelected(int index)
KisPaintOpSettingsSP settings =
paintopSettings(currentPaintop(), KoToolManager::instance()->currentInputDevice());
if(settings) settings->activate();
QList<KisPaintOpPreset*> presets;
presets.insert(0, defaultPreset(currentPaintop(), KoToolManager::instance()->currentInputDevice()).data());
foreach( KisPaintOpPreset* preset,
KisResourceServerProvider::instance()->paintOpPresetServer()->resources() )
{
if (preset->paintOp() == paintop) {
QVariant v(preset);
m_cmbPaintopPresets->addItem(preset->name(), v);
}
}
}
}
......@@ -248,6 +267,9 @@ void KisPaintopBox::setCurrentPaintop(const KoID & paintop)
KisPaintOpSettingsSP settings = paintopSettings(paintop, KoToolManager::instance()->currentInputDevice());
m_resourceProvider->slotPaintopActivated(paintop, settings);
KisPaintOpPresetSP preset = defaultPreset(paintop, KoToolManager::instance()->currentInputDevice());
m_resourceProvider->slotPaintOpPresetActivated( preset );
}
KoID KisPaintopBox::defaultPaintop(const KoInputDevice & inputDevice)
......@@ -284,5 +306,34 @@ KisPaintOpSettingsSP KisPaintopBox::paintopSettings(const KoID & paintop, const
else
return 0;
}
KisPaintOpPresetSP KisPaintopBox::defaultPreset(const KoID & paintop, const KoInputDevice & inputDevice)
{
/*
QList<KisPaintOpPresetSP> settingsArray;
InputDevicePresetsMap::iterator it = m_inputDevicePresets.find( inputDevice );
if (it == m_inputDevicePresets.end()) {
foreach (KoID paintopId, m_paintops) {
KisPaintOpPresetSP preset =
KisPaintOpRegistry::instance()->defaultPreset( paintopId, this, inputDevice, m_view->image() );
settingsArray.append( preset );
}
m_inputDevicePresets[ inputDevice ] = settingsArray;
} else {
settingsArray = (*it);
}
const int index = m_paintops.indexOf(paintop);
if (index >= 0 && index < settingsArray.count())
return settingsArray[index];
else
*/
return 0;
}
#include "kis_paintop_box.moc"
......@@ -75,16 +75,21 @@ private slots:
void slotCurrentNodeChanged(KisNodeSP node);
private:
QPixmap paintopPixmap(const KoID & paintop);
void updateOptionWidget();
const KoID & currentPaintop();
void setCurrentPaintop(const KoID & paintop);
KoID defaultPaintop(const KoInputDevice & inputDevice);
KisPaintOpSettingsSP paintopSettings(const KoID & paintop, const KoInputDevice & inputDevice);
KisPaintOpPresetSP defaultPreset(const KoID & paintop, const KoInputDevice & inputDevice);
private:
KisCanvasResourceProvider *m_resourceProvider;
QComboBox * m_cmbPaintops;
QComboBox * m_cmbPaintopPresets;
QHBoxLayout * m_layout;
QWidget * m_optionWidget;
KisPresetWidget * m_presetWidget;
......
......@@ -125,6 +125,7 @@ void KisTool::deactivate()
void KisTool::resourceChanged( int key, const QVariant & v )
{
switch ( key ) {
case ( KoCanvasResource::ForegroundColor ):
d->currentFgColor = v.value<KoColor>();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment