Warning, file /sdk/ktechlab/src/gui/itemeditor/propertyeditorcolor.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /*************************************************************************** 0002 * Copyright (C) 2003 Cedric Pasteur <cedric.pasteur@free.fr> * 0003 * Copyright (C) 2006 David Saxton <david@bluehaze.org> * 0004 * * 0005 * This program is free software; you can redistribute it and/or modify * 0006 * it under the terms of the GNU General Public License as published by * 0007 * the Free Software Foundation; either version 2 of the License, or * 0008 * (at your option) any later version. * 0009 ***************************************************************************/ 0010 0011 #include "propertyeditorcolor.h" 0012 #include "colorutils.h" 0013 #include "iteminterface.h" 0014 #include "property.h" 0015 0016 #include <KColorCombo> 0017 #include <KLocalizedString> 0018 0019 #include <QDebug> 0020 #include <QKeyEvent> 0021 #include <QLabel> 0022 #include <QString> 0023 0024 // BEGIN class PropertyEditorColor 0025 PropertyEditorColor::PropertyEditorColor(QWidget *parent, Property *property) 0026 : PropertySubEditor(parent, property) 0027 { 0028 m_pColorCombo = ColorUtils::createColorCombo(static_cast<ColorUtils::ColorScheme>(property->colorScheme()), this); 0029 m_pColorCombo->setColor(property->value().value<QColor>()); 0030 m_pColorCombo->resize(width(), height()); 0031 m_pColorCombo->show(); 0032 setWidget(m_pColorCombo); 0033 0034 connect(m_pColorCombo, &KColorCombo::activated, this, &PropertyEditorColor::valueChanged); 0035 connect(property, qOverload<const QColor &>(&Property::valueChanged), m_pColorCombo, &KColorCombo::setColor); 0036 } 0037 0038 void PropertyEditorColor::valueChanged(const QColor &color) 0039 { 0040 m_property->setValue(color); 0041 ItemInterface::self()->setProperty(m_property); 0042 } 0043 0044 bool PropertyEditorColor::eventFilter(QObject *watched, QEvent *e) 0045 { 0046 if (e->type() == QEvent::KeyPress) { 0047 QKeyEvent *ev = static_cast<QKeyEvent *>(e); 0048 if ((ev->key() == Qt::Key_Enter) | (ev->key() == Qt::Key_Space) || (ev->key() == Qt::Key_Return)) { 0049 // m_pColorCombo->animateClick(); 0050 m_pColorCombo->showPopup(); 0051 return true; 0052 } 0053 } 0054 return PropertySubEditor::eventFilter(watched, e); 0055 } 0056 // END class PropertyEditorColor 0057 0058 #include "moc_propertyeditorcolor.cpp"