chalk

kis_gradient_chooser.cpp
1/*
2 * Copyright (c) 2004 Adrian Page <adrian@pagenet.plus.com>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 */
18#include <tdelocale.h>
19#include <tqlabel.h>
20#include <tqlayout.h>
21#include <tqpushbutton.h>
22
23#include <kdialogbase.h>
24
25#include <koIconChooser.h>
26#include <kis_view.h>
27
28#include "kis_global.h"
29#include "kis_icon_item.h"
30#include "kis_gradient.h"
31#include "kis_autogradient.h"
32
33#include "kis_gradient_chooser.h"
34
35KisCustomGradientDialog::KisCustomGradientDialog(KisView * view, TQWidget * parent, const char *name)
36 : KDialogBase(parent, name, false, i18n("Custom Gradient"), Close)
37{
38 m_page = new KisAutogradient(this, "autogradient", i18n("Custom Gradient"));
39 setMainWidget(m_page);
40 connect(m_page, TQ_SIGNAL(activatedResource(KisResource *)), view, TQ_SLOT(gradientActivated(KisResource*)));
41}
42
43KisGradientChooser::KisGradientChooser(KisView * view, TQWidget *parent, const char *name) : super(parent, name)
44{
45 m_lbName = new TQLabel(this);
46
47 m_customGradient = new TQPushButton(i18n("Custom Gradient..."), this, "custom gradient button");
48
49 KisCustomGradientDialog * autogradient = new KisCustomGradientDialog(view, this, "autogradient");
50 connect(m_customGradient, TQ_SIGNAL(clicked()), autogradient, TQ_SLOT(show()));
51
52 TQVBoxLayout *mainLayout = new TQVBoxLayout(this, 2, -1, "main layout");
53
54 mainLayout->addWidget(m_lbName);
55 mainLayout->addWidget(chooserWidget(), 10);
56 mainLayout->addWidget(m_customGradient, 10);
57
58}
59
60KisGradientChooser::~KisGradientChooser()
61{
62}
63
64void KisGradientChooser::update(KoIconItem *item)
65{
66 KisIconItem *kisItem = static_cast<KisIconItem *>(item);
67
68 if (item) {
69 KisGradient *gradient = static_cast<KisGradient *>(kisItem->resource());
70
71 m_lbName->setText(gradient->name());
72 }
73}
74
75
76#include "kis_gradient_chooser.moc"
77
The KisResource class provides a representation of Chalk image resources.