krita

kis_gradient_chooser.cc

00001 /*
00002  *  Copyright (c) 2004 Adrian Page <adrian@pagenet.plus.com>
00003  *
00004  *  This program is free software; you can redistribute it and/or modify
00005  *  it under the terms of the GNU General Public License as published by
00006  *  the Free Software Foundation; either version 2 of the License, or
00007  *  (at your option) any later version.
00008  *
00009  *  This program is distributed in the hope that it will be useful,
00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *  GNU General Public License for more details.
00013  *
00014  *  You should have received a copy of the GNU General Public License
00015  *  along with this program; if not, write to the Free Software
00016  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00017  */
00018 #include <klocale.h>
00019 #include <qlabel.h>
00020 #include <qlayout.h>
00021 #include <qpushbutton.h>
00022 
00023 #include <kdialogbase.h>
00024 
00025 #include <koIconChooser.h>
00026 #include <kis_view.h>
00027 
00028 #include "kis_global.h"
00029 #include "kis_icon_item.h"
00030 #include "kis_gradient.h"
00031 #include "kis_autogradient.h"
00032 
00033 #include "kis_gradient_chooser.h"
00034 
00035 KisCustomGradientDialog::KisCustomGradientDialog(KisView * view, QWidget * parent, const char *name)
00036     : KDialogBase(parent, name, false, i18n("Custom Gradient"), Close)
00037 {
00038     m_page = new KisAutogradient(this, "autogradient", i18n("Custom Gradient"));
00039     setMainWidget(m_page);
00040     connect(m_page, SIGNAL(activatedResource(KisResource *)), view, SLOT(gradientActivated(KisResource*)));
00041 }
00042 
00043 KisGradientChooser::KisGradientChooser(KisView * view, QWidget *parent, const char *name) : super(parent, name)
00044 {
00045     m_lbName = new QLabel(this);
00046     
00047     m_customGradient = new QPushButton(i18n("Custom Gradient..."), this, "custom gradient button");
00048     
00049     KisCustomGradientDialog * autogradient = new KisCustomGradientDialog(view, this, "autogradient");
00050     connect(m_customGradient, SIGNAL(clicked()), autogradient, SLOT(show()));
00051     
00052     QVBoxLayout *mainLayout = new QVBoxLayout(this, 2, -1, "main layout");
00053     
00054     mainLayout->addWidget(m_lbName);
00055     mainLayout->addWidget(chooserWidget(), 10);
00056     mainLayout->addWidget(m_customGradient, 10);
00057 
00058 }
00059 
00060 KisGradientChooser::~KisGradientChooser()
00061 {
00062 }
00063 
00064 void KisGradientChooser::update(KoIconItem *item)
00065 {
00066     KisIconItem *kisItem = static_cast<KisIconItem *>(item);
00067 
00068     if (item) {
00069         KisGradient *gradient = static_cast<KisGradient *>(kisItem->resource());
00070 
00071         m_lbName->setText(gradient->name());
00072     }
00073 }
00074 
00075 
00076 #include "kis_gradient_chooser.moc"
00077 
KDE Home | KDE Accessibility Home | Description of Access Keys