29 #include <QColorDialog>
31 #include <QToolButton>
34 #include "core/common/WLogger.h"
35 #include "core/common/WPropertyVariable.h"
36 #include "../WGuiConsts.h"
37 #include "../WQtGui.h"
38 #include "../WMainWindow.h"
40 #include "WPropertyColorWidget.h"
44 m_colorProperty( property ),
45 m_widget( &m_parameterWidgets ),
47 m_asText( &m_informationWidgets ),
48 m_infoLayout( &m_informationWidgets )
55 m_layout.setMargin( WGLOBAL_MARGIN );
56 m_layout.setSpacing( WGLOBAL_SPACING );
64 QHBoxLayout* wLayout =
new QHBoxLayout( &
m_widget );
65 wLayout->setContentsMargins( 0, 0, 0, 0 );
66 wLayout->setSpacing( 0 );
72 m_colButton->setToolButtonStyle( Qt::ToolButtonTextBesideIcon );
73 m_colButton->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Fixed ) );
76 m_colPanel->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) );
83 m_colPanel->setMinimumHeight( WMIN_WIDGET_HEIGHT );
84 m_colButton->setMinimumHeight( WMIN_WIDGET_HEIGHT );
87 setAcceptDrops(
true );
112 std::stringstream buttonColorStr;
113 buttonColorStr <<
"* { background-color: rgb("
114 << bgColor.red() <<
","
115 << bgColor.green() <<
","
116 << bgColor.blue() <<
");"
120 std::stringstream buttonColorText;
121 buttonColorText <<
"RGBA( " << bgColor.red() <<
", "
122 << bgColor.green() <<
", "
123 << bgColor.blue() <<
", "
124 << bgColor.alpha() <<
" )";
128 m_colPanel->setStyleSheet( QString().fromStdString( buttonColorStr.str() ) );
133 QPalette pal = QPalette();
135 m_asText.setAutoFillBackground(
true );
142 tmp.setRgbF( color[0],
152 return WColor( color.redF(), color.greenF(), color.blueF(), color.alphaF() );
159 #if QT_VERSION >= 0x040500
160 current = QColorDialog::getColor( current,
this, QString(
"Select Color" ), QColorDialog::ShowAlphaChannel );
162 current = QColorDialog::getColor( current,
this );
164 if( current.isValid() )
176 if(
event->mimeData()->hasColor() )
178 event->setAccepted(
true );
184 if(
event->mimeData()->hasColor() )
186 QColor color = qvariant_cast<QColor>(
event->mimeData()->colorData() );
187 if( color.isValid() )
static WMainWindow * getMainWindow()
Returns the current main window instance or NULL if not existent.
virtual void setText(const QString &text)
reimplemented function to setText