Removes ColorPickerDelegate from AzToolsFramework
Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com>
This commit is contained in:
-2
@@ -19,8 +19,6 @@ AZ_PUSH_DISABLE_WARNING(4251, "-Wunknown-warning-option")
|
||||
AZ_POP_DISABLE_WARNING
|
||||
#include <QtWidgets/QToolButton>
|
||||
|
||||
#include "../UICore/ColorPickerDelegate.hxx"
|
||||
|
||||
namespace AzToolsFramework
|
||||
{
|
||||
PropertyColorCtrl::PropertyColorCtrl(QWidget* pParent)
|
||||
|
||||
@@ -1,75 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
#include <QtCore/QAbstractItemModel>
|
||||
#include "ColorPickerDelegate.hxx"
|
||||
|
||||
#include <AzQtComponents/Components/Widgets/ColorPicker.h>
|
||||
#include <AzQtComponents/Utilities/Conversions.h>
|
||||
|
||||
namespace AzToolsFramework
|
||||
{
|
||||
ColorPickerDelegate::ColorPickerDelegate(QObject* pParent)
|
||||
: QStyledItemDelegate(pParent)
|
||||
{
|
||||
}
|
||||
|
||||
QWidget* ColorPickerDelegate::createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const
|
||||
{
|
||||
(void)index;
|
||||
(void)option;
|
||||
AzQtComponents::ColorPicker* ptrDialog = new AzQtComponents::ColorPicker(AzQtComponents::ColorPicker::Configuration::RGB,
|
||||
tr("Select Color"), parent);
|
||||
ptrDialog->setWindowFlags(Qt::Tool);
|
||||
return ptrDialog;
|
||||
}
|
||||
|
||||
void ColorPickerDelegate::setEditorData(QWidget* editor, const QModelIndex& index) const
|
||||
{
|
||||
AzQtComponents::ColorPicker* colorEditor = qobject_cast<AzQtComponents::ColorPicker*>(editor);
|
||||
|
||||
if (!editor)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
QVariant colorResult = index.data(COLOR_PICKER_ROLE);
|
||||
if (colorResult == QVariant())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const QColor pickedColor = qvariant_cast<QColor>(colorResult);
|
||||
colorEditor->setCurrentColor(AzQtComponents::fromQColor(pickedColor));
|
||||
}
|
||||
|
||||
void ColorPickerDelegate::setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const
|
||||
{
|
||||
AzQtComponents::ColorPicker* colorEditor = qobject_cast<AzQtComponents::ColorPicker*>(editor);
|
||||
|
||||
if (!editor)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const QVariant colorVariant = AzQtComponents::toQColor(colorEditor->currentColor());
|
||||
model->setData(index, colorVariant, COLOR_PICKER_ROLE);
|
||||
}
|
||||
|
||||
void ColorPickerDelegate::updateEditorGeometry(QWidget* editor, const QStyleOptionViewItem& option, const QModelIndex& index) const
|
||||
{
|
||||
(void)index;
|
||||
QRect pickerpos = option.rect;
|
||||
|
||||
pickerpos.setTopLeft(editor->parentWidget()->mapToGlobal(pickerpos.topLeft()));
|
||||
pickerpos.adjust(64, 0, 0, 0);
|
||||
editor->setGeometry(pickerpos);
|
||||
}
|
||||
|
||||
} // namespace AzToolsFramework
|
||||
|
||||
#include "UI/UICore/moc_ColorPickerDelegate.cpp"
|
||||
@@ -1,41 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef COLOR_PICKER_DELEGATE_HXX
|
||||
#define COLOR_PICKER_DELEGATE_HXX
|
||||
|
||||
#if !defined(Q_MOC_RUN)
|
||||
#include <AzCore/Memory/SystemAllocator.h>
|
||||
#include <QtWidgets/QStyledItemDelegate>
|
||||
#endif
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace AzToolsFramework
|
||||
{
|
||||
/**
|
||||
* A delegate which handles the double clicking to pop open a color picker dialog, as long as the role is COLOR_PICKER_ROLE.
|
||||
* To use it, just add a setData() and a data() function to your model which returns a QColor (or accepts one) whenever the COLOR_PICKER_ROLE is queried.
|
||||
**/
|
||||
class ColorPickerDelegate
|
||||
: public QStyledItemDelegate
|
||||
{
|
||||
Q_OBJECT;
|
||||
public:
|
||||
static const int COLOR_PICKER_ROLE = Qt::UserRole + 1;
|
||||
|
||||
AZ_CLASS_ALLOCATOR(ColorPickerDelegate, AZ::SystemAllocator, 0);
|
||||
ColorPickerDelegate(QObject* pParent);
|
||||
virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const;
|
||||
virtual void setEditorData(QWidget* editor, const QModelIndex& index) const;
|
||||
virtual void setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const;
|
||||
virtual void updateEditorGeometry(QWidget* editor, const QStyleOptionViewItem& option, const QModelIndex& index) const;
|
||||
};
|
||||
} // namespace AzToolsFramework
|
||||
|
||||
#endif //COLOR_PICKER_DELEGATE_HXX
|
||||
@@ -444,8 +444,6 @@ set(FILES
|
||||
UI/Slice/SliceRelationshipWidget.hxx
|
||||
UI/UICore/AspectRatioAwarePixmapWidget.hxx
|
||||
UI/UICore/AspectRatioAwarePixmapWidget.cpp
|
||||
UI/UICore/ColorPickerDelegate.hxx
|
||||
UI/UICore/ColorPickerDelegate.cpp
|
||||
UI/UICore/ClickableLabel.hxx
|
||||
UI/UICore/ClickableLabel.cpp
|
||||
UI/UICore/IconButton.hxx
|
||||
|
||||
Reference in New Issue
Block a user