Vertically stack the color widget when in dock mode

This commit is contained in:
Nyall Dawson 2016-08-16 16:32:57 +10:00
parent ce133102bf
commit cd4bc8887b
5 changed files with 609 additions and 574 deletions

View File

@ -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();

View File

@ -96,7 +96,8 @@ void QgsColorButton::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 ) ) );

View File

@ -28,9 +28,9 @@
#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 )
@ -38,6 +38,18 @@ QgsCompoundColorWidget::QgsCompoundColorWidget( QWidget *parent, const QColor& c
{
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();

View File

@ -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();

File diff suppressed because it is too large Load Diff