1 /***************************************************************************
2  *   Copyright (C) 2007-2008 by Harm van Eersel                            *
3  *   Copyright (C) 2009 Tim Vandermeersch                                  *
4  *                                                                         *
5  *   This program is free software; you can redistribute it and/or modify  *
6  *   it under the terms of the GNU General Public License as published by  *
7  *   the Free Software Foundation; either version 2 of the License, or     *
8  *   (at your option) any later version.                                   *
9  *                                                                         *
10  *   This program is distributed in the hope that it will be useful,       *
11  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
12  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
13  *   GNU General Public License for more details.                          *
14  *                                                                         *
15  *   You should have received a copy of the GNU General Public License     *
16  *   along with this program; if not, write to the                         *
17  *   Free Software Foundation, Inc.,                                       *
18  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
19  ***************************************************************************/
20 
21 #include <QColorDialog>
22 #include "coloraction.h"
23 #include "commands.h"
24 
25 namespace Molsketch {
26 
27   struct colorAction::privateData
28   {
29     QColor color;
30   };
31 
colorAction(MolScene * parent)32   colorAction::colorAction(MolScene *parent) :
33     abstractRecursiveItemAction(parent),
34     d(new privateData)
35   {
36     setText(tr("Color...")) ;
37     setToolTip(tr("Set color")) ;
38     setWhatsThis(tr("Displays the color chooser dialog")) ;
39     QPixmap newicon(22,22);
40     newicon.fill(Qt::black);
41     d->color = QColor(Qt::black);
42     setIcon(newicon);
43     setCheckable(false);
44   }
45 
~colorAction()46   colorAction::~colorAction()
47   {
48     delete d;
49   }
50 
execute()51   void colorAction::execute()
52   {
53     QColor newColor = QColorDialog::getColor(d->color) ;
54     if (!newColor.isValid()) return ;
55 
56     d->color = newColor;
57     QPixmap newicon(22,22);
58     newicon.fill(d->color);
59     setIcon(newicon);
60 
61     ITERATEOVERITEMSMACRO("Change color", changeColor, newColor)
62   }
63 
64 }// namespace
65