Skip to content

Commit cd4bc88

Browse files
committed
Vertically stack the color widget when in dock mode
1 parent ce13310 commit cd4bc88

5 files changed

+609
-574
lines changed

python/gui/qgscompoundcolorwidget.sip

+9-1
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,19 @@ class QgsCompoundColorWidget : QgsPanelWidget
1414

1515
public:
1616

17+
//! Widget layout
18+
enum Layout
19+
{
20+
LayoutDefault, /*!< Use the default (rectangular) layout */
21+
LayoutVertical, /*!< Use a narrower, vertically stacked layout */
22+
};
23+
1724
/** Constructor for QgsCompoundColorWidget
1825
* @param parent parent widget
1926
* @param color initial color for dialog
27+
* @param layout widget layout to use
2028
*/
21-
QgsCompoundColorWidget( QWidget *parent /TransferThis/ = nullptr, const QColor& color = QColor() );
29+
QgsCompoundColorWidget( QWidget *parent /TransferThis/ = nullptr, const QColor& color = QColor(), Layout layout = LayoutDefault );
2230

2331
~QgsCompoundColorWidget();
2432

src/gui/qgscolorbutton.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@ void QgsColorButton::showColorDialog()
9696
{
9797
if ( QgsPanelWidget* panel = QgsPanelWidget::findParentPanel( this ) )
9898
{
99-
QgsCompoundColorWidget* colorWidget = new QgsCompoundColorWidget( panel, color() );
99+
QgsCompoundColorWidget* colorWidget = new QgsCompoundColorWidget( panel, color(), panel->dockMode() ? QgsCompoundColorWidget::LayoutVertical :
100+
QgsCompoundColorWidget::LayoutDefault );
100101
colorWidget->setPanelTitle( mColorDialogTitle );
101102
colorWidget->setAllowAlpha( mAllowAlpha );
102103
connect( colorWidget, SIGNAL( currentColorChanged( QColor ) ), this, SLOT( setValidTemporaryColor( QColor ) ) );

src/gui/qgscompoundcolorwidget.cpp

+14-2
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,28 @@
2828
#include <QDesktopWidget>
2929
#include <QMouseEvent>
3030
#include <QInputDialog>
31+
#include <QVBoxLayout>
3132

32-
33-
QgsCompoundColorWidget::QgsCompoundColorWidget( QWidget *parent, const QColor& color )
33+
QgsCompoundColorWidget::QgsCompoundColorWidget( QWidget *parent, const QColor& color, Layout widgetLayout )
3434
: QgsPanelWidget( parent )
3535
, mAllowAlpha( true )
3636
, mLastCustomColorIndex( 0 )
3737
, mPickingColor( false )
3838
{
3939
setupUi( this );
4040

41+
if ( widgetLayout == LayoutVertical )
42+
{
43+
// shuffle stuff around
44+
QVBoxLayout* newLayout = new QVBoxLayout();
45+
newLayout->addWidget( mTabWidget );
46+
newLayout->addWidget( mSlidersWidget );
47+
newLayout->addWidget( mPreviewWidget );
48+
newLayout->addWidget( mSwatchesWidget );
49+
delete layout();
50+
setLayout( newLayout );
51+
}
52+
4153
QSettings settings;
4254

4355
mSchemeList->header()->hide();

src/gui/qgscompoundcolorwidget.h

+9-1
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,19 @@ class GUI_EXPORT QgsCompoundColorWidget : public QgsPanelWidget, private Ui::Qgs
3434

3535
public:
3636

37+
//! Widget layout
38+
enum Layout
39+
{
40+
LayoutDefault = 0, /*!< Use the default (rectangular) layout */
41+
LayoutVertical, /*!< Use a narrower, vertically stacked layout */
42+
};
43+
3744
/** Constructor for QgsCompoundColorWidget
3845
* @param parent parent widget
3946
* @param color initial color for dialog
47+
* @param layout widget layout to use
4048
*/
41-
QgsCompoundColorWidget( QWidget *parent = nullptr, const QColor& color = QColor() );
49+
QgsCompoundColorWidget( QWidget *parent = nullptr, const QColor& color = QColor(), Layout layout = LayoutDefault );
4250

4351
~QgsCompoundColorWidget();
4452

0 commit comments

Comments
 (0)