colorcorrection/vectorscopegenerator.cpp
colorcorrection/waveformgenerator.cpp
razorgroupcommand.cpp
+ colorpickerwidget.cpp
+ choosecolorwidget.cpp
)
--- /dev/null
+/***************************************************************************
+ * Copyright (C) 2010 by Till Theato (root@ttill.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 *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
+ ***************************************************************************/
+
+
+#include "choosecolorwidget.h"
+#include "colorpickerwidget.h"
+
+#include <QLabel>
+#include <QHBoxLayout>
+
+#include <KColorButton>
+#include <KLocalizedString>
+
+
+ChooseColorWidget::ChooseColorWidget(QString text, QColor color, QWidget *parent) :
+ QWidget(parent)
+{
+ QHBoxLayout *layout = new QHBoxLayout(this);
+ layout->addWidget(new QLabel(text));
+ m_button = new KColorButton(color, this);
+ layout->addWidget(m_button);
+ ColorPickerWidget *picker = new ColorPickerWidget(this);
+ layout->addWidget(picker);
+
+ connect(picker, SIGNAL(colorPicked(QColor)), this, SLOT(setColor(QColor)));
+ connect(m_button, SIGNAL(clicked(bool)), this, SIGNAL(modified()));
+}
+
+QColor ChooseColorWidget::getColor()
+{
+ return m_button->color();
+}
+
+void ChooseColorWidget::setColor(QColor color)
+{
+ m_button->setColor(color);
+ emit modified();
+}
+
+#include "choosecolorwidget.moc"
--- /dev/null
+/***************************************************************************
+ * Copyright (C) 2010 by Till Theato (root@ttill.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 *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
+ ***************************************************************************/
+
+
+#ifndef CHOOSECOLORWIDGET_H
+#define CHOOSECOLORWIDGET_H
+
+#include <QtCore>
+#include <QWidget>
+
+class KColorButton;
+
+/**
+ * @class ChooseColorWidget
+ * @brief Provides options to choose a color.
+ * @author Till Theato
+ */
+
+class ChooseColorWidget : public QWidget
+{
+ Q_OBJECT
+public:
+ /** @brief Sets up the widget.
+ * @param text (optional) What the color will be used for
+ * @param color (optional) initial color */
+ ChooseColorWidget(QString text = QString(), QColor color = QColor(), QWidget* parent = 0);
+
+ /** @brief Gets the choosen color. */
+ QColor getColor();
+
+private:
+ KColorButton *m_button;
+
+private slots:
+ /** @brief Updates the different color choosing options to have all selected @param color. */
+ void setColor(QColor color);
+
+signals:
+ /** @brief Emitted whenever a different color was choosen. */
+ void modified();
+};
+
+#endif
--- /dev/null
+/***************************************************************************
+ * Copyright (C) 2010 by Till Theato (root@ttill.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 *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
+ ***************************************************************************/
+
+
+#include "colorpickerwidget.h"
+
+#include <QMouseEvent>
+#include <QPushButton>
+#include <QDesktopWidget>
+
+#include <KApplication>
+#include <KColorDialog>
+#include <KIcon>
+#include <KLocalizedString>
+
+#ifdef Q_WS_X11
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include <QX11Info>
+#include <fixx11h.h>
+
+class KCDPickerFilter: public QWidget
+{
+public:
+ KCDPickerFilter(QWidget* parent): QWidget(parent) {}
+
+ virtual bool x11Event(XEvent* event) {
+ if (event->type == ButtonRelease) {
+ QMouseEvent e(QEvent::MouseButtonRelease, QPoint(),
+ QPoint(event->xmotion.x_root, event->xmotion.y_root) , Qt::NoButton, Qt::NoButton, Qt::NoModifier);
+ QApplication::sendEvent(parentWidget(), &e);
+ return true;
+ }
+ return false;
+ }
+};
+#endif
+
+
+ColorPickerWidget::ColorPickerWidget(QWidget *parent) :
+ QWidget(parent),
+ m_filterActive(false)
+{
+#ifdef Q_WS_X11
+ m_filter = 0;
+#endif
+
+ QPushButton *button = new QPushButton(this);
+ button->setIcon(KIcon("color-picker"));
+ button->setToolTip(i18n("Pick a color on the screen"));
+ connect(button, SIGNAL(clicked()), this, SLOT(slotSetupEventFilter()));
+}
+
+ColorPickerWidget::~ColorPickerWidget()
+{
+#ifdef Q_WS_X11
+ if (m_filterActive && kapp)
+ kapp->removeX11EventFilter(m_filter);
+#endif
+}
+
+void ColorPickerWidget::mouseReleaseEvent(QMouseEvent* event)
+{
+ if (m_filterActive) {
+ closeEventFilter();
+ emit colorPicked(KColorDialog::grabColor(event->globalPos()));
+ return;
+ }
+ QWidget::mouseReleaseEvent(event);
+}
+
+void ColorPickerWidget::keyPressEvent(QKeyEvent* event)
+{
+ if (m_filterActive) {
+ if (event->key() == Qt::Key_Escape)
+ closeEventFilter();
+ event->accept();
+ return;
+ }
+ QWidget::keyPressEvent(event);
+}
+
+void ColorPickerWidget::slotSetupEventFilter()
+{
+ m_filterActive = true;
+#ifdef Q_WS_X11
+ m_filter = new KCDPickerFilter(this);
+ kapp->installX11EventFilter(m_filter);
+#endif
+ grabMouse(Qt::CrossCursor);
+ grabKeyboard();
+}
+
+void ColorPickerWidget::closeEventFilter()
+{
+ m_filterActive = false;
+#ifdef Q_WS_X11
+ kapp->removeX11EventFilter(m_filter);
+ delete m_filter;
+ m_filter = 0;
+#endif
+ releaseMouse();
+ releaseKeyboard();
+}
+
+#include "colorpickerwidget.moc"
--- /dev/null
+/***************************************************************************
+ * Copyright (C) 2010 by Till Theato (root@ttill.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 *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
+ ***************************************************************************/
+
+
+#ifndef COLORPICKERWIDGET_H
+#define COLORPICKERWIDGET_H
+
+#include <QtCore>
+#include <QWidget>
+
+#ifdef Q_WS_X11
+class KCDPickerFilter;
+#endif
+
+/**
+ * @class ColorPickerWidget
+ * @brief A widget to pick a color anywhere on the screen.
+ * @author Till Theato
+ *
+ * The code is based on the color picker in KColorDialog.
+ */
+
+class ColorPickerWidget : public QWidget
+{
+ Q_OBJECT
+
+public:
+ /** @brief Sets up the widget. */
+ ColorPickerWidget(QWidget *parent = 0);
+ /** @brief Makes sure the event filter is removed. */
+ virtual ~ColorPickerWidget();
+
+protected:
+ virtual void mouseReleaseEvent(QMouseEvent *event);
+ virtual void keyPressEvent(QKeyEvent *event);
+
+private:
+ /** @brief Closes the event filter and makes mouse and keyboard work again on other widgets/windows. */
+ void closeEventFilter();
+ bool m_filterActive;
+#ifdef Q_WS_X11
+ KCDPickerFilter *m_filter;
+#endif
+
+private slots:
+ /** @brief Sets up an event filter for picking a color. */
+ void slotSetupEventFilter();
+
+signals:
+ void colorPicked(QColor);
+};
+
+#endif
#include "profilesdialog.h"
#include "kis_curve_widget.h"
#include "kis_cubic_curve.h"
+#include "choosecolorwidget.h"
#include <KDebug>
#include <KLocale>
m_keyframeEditor->addParameter(pa);
}
} else if (type == "color") {
- Colorval *cval = new Colorval;
- cval->setupUi(toFillin);
+ if (value.startsWith('#'))
+ value = value.replace('#', "0x");
bool ok;
- if (value.startsWith('#')) value = value.replace('#', "0x");
- cval->kcolorbutton->setColor(value.toUInt(&ok, 16));
- //kDebug() << "color: " << value << ", " << value.toUInt(&ok, 16);
- cval->label->setText(paramName);
- m_valueItems[paramName] = cval;
- connect(cval->kcolorbutton, SIGNAL(clicked()) , this, SLOT(collectAllParameters()));
- m_uiItems.append(cval);
+ ChooseColorWidget *choosecolor = new ChooseColorWidget(paramName, QColor(value.toUInt(&ok, 16)), this);
+ m_vbox->addWidget(choosecolor);
+ m_valueItems[paramName] = choosecolor;
+ connect(choosecolor, SIGNAL(modified()) , this, SLOT(collectAllParameters()));
} else if (type == "position") {
int pos = value.toInt();
if (d.attribute("id") == "fadein" || d.attribute("id") == "fade_from_black") {
QCheckBox *box = ((Boolval*)m_valueItems.value(paramName))->checkBox;
setValue = box->checkState() == Qt::Checked ? "1" : "0" ;
} else if (type == "color") {
- KColorButton *color = ((Colorval*)m_valueItems.value(paramName))->kcolorbutton;
- setValue = color->color().name();
+ ChooseColorWidget *choosecolor = ((ChooseColorWidget*)m_valueItems.value(paramName));
+ setValue = choosecolor->getColor().name();
} else if (type == "complex") {
ComplexParameter *complex = ((ComplexParameter*)m_valueItems.value(paramName));
namenode.item(i) = complex->getParamDesc();