Skip to content

Commit

Permalink
Use QgsColorButtonV2 for editor widgets
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Oct 9, 2014
1 parent a5b5bd4 commit 174c2f3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
6 changes: 4 additions & 2 deletions src/gui/editorwidgets/qgscolorwidgetwrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,14 @@ QVariant QgsColorWidgetWrapper::value()

QWidget* QgsColorWidgetWrapper::createWidget( QWidget* parent )
{
return new QgsColorButton( parent );
QgsColorButtonV2* button = new QgsColorButtonV2( parent );
button->setContext( QString( "editor" ) );
return button;
}

void QgsColorWidgetWrapper::initWidget( QWidget* editor )
{
mColorButton = qobject_cast<QgsColorButton*>( editor );
mColorButton = qobject_cast<QgsColorButtonV2*>( editor );

connect( mColorButton, SIGNAL( colorChanged( QColor ) ), this, SLOT( valueChanged() ) );
}
Expand Down
6 changes: 3 additions & 3 deletions src/gui/editorwidgets/qgscolorwidgetwrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

#include "qgseditorwidgetwrapper.h"

#include "qgscolorbutton.h"
#include "qgscolorbuttonv2.h"


/**
Expand All @@ -37,14 +37,14 @@ class GUI_EXPORT QgsColorWidgetWrapper : public QgsEditorWidgetWrapper
QVariant value();

protected:
QWidget*createWidget( QWidget* parent );
QWidget* createWidget( QWidget* parent );
void initWidget( QWidget* editor );

public slots:
void setValue( const QVariant& value );

private:
QgsColorButton* mColorButton;
QgsColorButtonV2* mColorButton;
};

#endif // QGSCOLORWIDGETWRAPPER_H

3 comments on commit 174c2f3

@m-kuhn
Copy link
Member

@m-kuhn m-kuhn commented on 174c2f3 Oct 11, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Nyall, good to have this nice button also integrated here.

Was support for the old button completely removed? I.e. is it thinkable, that somebody was using a QgsColorButton in a custom .ui file and that will no longer be supported because initWidget always assumes a QgsColorButtonV2?

@nyalldawson
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@m-kuhn Well, QgsColorButton still exists, but I don't know what would happen in that use case. Given that I'm honestly clueless how these editor widgets work, should I revert this commit for 2.6?

@3nids
Copy link
Member

@3nids 3nids commented on 174c2f3 Oct 13, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only problem is that old custom UI file with QgsColorButton won't work anymore. But is it a real harm?

On the same idea, I will remove the QgsColorButton V1 from the custom widgets so people stop using it.

Please sign in to comment.