Skip to content

Commit

Permalink
Vertically stack the color widget when in dock mode
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Aug 17, 2016
1 parent 7c4db38 commit 511b881
Show file tree
Hide file tree
Showing 5 changed files with 609 additions and 574 deletions.
10 changes: 9 additions & 1 deletion python/gui/qgscompoundcolorwidget.sip
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
3 changes: 2 additions & 1 deletion src/gui/qgscolorbuttonv2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) ) );
Expand Down
16 changes: 14 additions & 2 deletions src/gui/qgscompoundcolorwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
10 changes: 9 additions & 1 deletion src/gui/qgscompoundcolorwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
Loading

0 comments on commit 511b881

Please sign in to comment.