Skip to content
Permalink
Browse files

Vertically stack the color widget when in dock mode

  • Loading branch information
nyalldawson committed Aug 17, 2016
1 parent 7c4db38 commit 511b8817a464152f6d845e32b27c42e769a9be90
@@ -14,11 +14,19 @@ class QgsCompoundColorWidget : QgsPanelWidget

public:

//! Widget layout
enum Layout
{
LayoutDefault, /*!< Use the default (rectangular) layout */
LayoutVertical, /*!< Use a narrower, vertically stacked layout */
};

/** Constructor for QgsCompoundColorWidget
* @param parent parent widget
* @param color initial color for dialog
* @param layout widget layout to use
*/
QgsCompoundColorWidget( QWidget *parent /TransferThis/ = nullptr, const QColor& color = QColor() );
QgsCompoundColorWidget( QWidget *parent /TransferThis/ = nullptr, const QColor& color = QColor(), Layout layout = LayoutDefault );

~QgsCompoundColorWidget();

@@ -96,7 +96,8 @@ void QgsColorButtonV2::showColorDialog()
{
if ( QgsPanelWidget* panel = QgsPanelWidget::findParentPanel( this ) )
{
QgsCompoundColorWidget* colorWidget = new QgsCompoundColorWidget( panel, color() );
QgsCompoundColorWidget* colorWidget = new QgsCompoundColorWidget( panel, color(), panel->dockMode() ? QgsCompoundColorWidget::LayoutVertical :
QgsCompoundColorWidget::LayoutDefault );
colorWidget->setPanelTitle( mColorDialogTitle );
colorWidget->setAllowAlpha( mAllowAlpha );
connect( colorWidget, SIGNAL( currentColorChanged( QColor ) ), this, SLOT( setValidTemporaryColor( QColor ) ) );
@@ -28,16 +28,28 @@
#include <QDesktopWidget>
#include <QMouseEvent>
#include <QInputDialog>
#include <QVBoxLayout>


QgsCompoundColorWidget::QgsCompoundColorWidget( QWidget *parent, const QColor& color )
QgsCompoundColorWidget::QgsCompoundColorWidget( QWidget *parent, const QColor& color, Layout widgetLayout )
: QgsPanelWidget( parent )
, mAllowAlpha( true )
, mLastCustomColorIndex( 0 )
, mPickingColor( false )
{
setupUi( this );

if ( widgetLayout == LayoutVertical )
{
// shuffle stuff around
QVBoxLayout* newLayout = new QVBoxLayout();
newLayout->addWidget( mTabWidget );
newLayout->addWidget( mSlidersWidget );
newLayout->addWidget( mPreviewWidget );
newLayout->addWidget( mSwatchesWidget );
delete layout();
setLayout( newLayout );
}

QSettings settings;

mSchemeList->header()->hide();
@@ -34,11 +34,19 @@ class GUI_EXPORT QgsCompoundColorWidget : public QgsPanelWidget, private Ui::Qgs

public:

//! Widget layout
enum Layout
{
LayoutDefault = 0, /*!< Use the default (rectangular) layout */
LayoutVertical, /*!< Use a narrower, vertically stacked layout */
};

/** Constructor for QgsCompoundColorWidget
* @param parent parent widget
* @param color initial color for dialog
* @param layout widget layout to use
*/
QgsCompoundColorWidget( QWidget *parent = nullptr, const QColor& color = QColor() );
QgsCompoundColorWidget( QWidget *parent = nullptr, const QColor& color = QColor(), Layout layout = LayoutDefault );

~QgsCompoundColorWidget();

0 comments on commit 511b881

Please sign in to comment.
You can’t perform that action at this time.