44 connect( mHueRadio, &QRadioButton::toggled,
this, &QgsCompoundColorWidget::mHueRadio_toggled );
45 connect( mSaturationRadio, &QRadioButton::toggled,
this, &QgsCompoundColorWidget::mSaturationRadio_toggled );
46 connect( mValueRadio, &QRadioButton::toggled,
this, &QgsCompoundColorWidget::mValueRadio_toggled );
47 connect( mRedRadio, &QRadioButton::toggled,
this, &QgsCompoundColorWidget::mRedRadio_toggled );
48 connect( mGreenRadio, &QRadioButton::toggled,
this, &QgsCompoundColorWidget::mGreenRadio_toggled );
49 connect( mBlueRadio, &QRadioButton::toggled,
this, &QgsCompoundColorWidget::mBlueRadio_toggled );
50 connect( mAddColorToSchemeButton, &QPushButton::clicked,
this, &QgsCompoundColorWidget::mAddColorToSchemeButton_clicked );
51 connect( mAddCustomColorButton, &QPushButton::clicked,
this, &QgsCompoundColorWidget::mAddCustomColorButton_clicked );
52 connect( mSampleButton, &QPushButton::clicked,
this, &QgsCompoundColorWidget::mSampleButton_clicked );
53 connect( mTabWidget, &QTabWidget::currentChanged,
this, &QgsCompoundColorWidget::mTabWidget_currentChanged );
54 connect( mActionShowInButtons, &QAction::toggled,
this, &QgsCompoundColorWidget::mActionShowInButtons_toggled );
59 QVBoxLayout *newLayout =
new QVBoxLayout();
60 newLayout->setContentsMargins( 0, 0, 0, 0 );
61 newLayout->addWidget( mTabWidget );
62 newLayout->addWidget( mSlidersWidget );
63 newLayout->addWidget( mPreviewWidget );
64 newLayout->addWidget( mSwatchesWidget );
66 setLayout( newLayout );
71 mSchemeList->header()->hide();
72 mSchemeList->setColumnWidth( 0,
static_cast< int >(
Qgis::UI_SCALE_FACTOR * fontMetrics().horizontalAdvance(
'X' ) * 6 ) );
75 refreshSchemeComboBox();
79 int activeScheme = settings.
value( QStringLiteral(
"Windows/ColorDialog/activeScheme" ), 0 ).toInt();
80 activeScheme = activeScheme >= mSchemeComboBox->count() ? 0 : activeScheme;
82 mSchemeList->setScheme( schemeList.at( activeScheme ) );
84 mSchemeComboBox->setCurrentIndex( activeScheme );
85 updateActionsForCurrentScheme();
88 connect( mSchemeList->selectionModel(), &QItemSelectionModel::selectionChanged,
this, &QgsCompoundColorWidget::listSelectionChanged );
90 mActionCopyColors->setEnabled(
false );
96 connect( mActionImportPalette, &QAction::triggered,
this, &QgsCompoundColorWidget::importPalette );
97 connect( mActionRemovePalette, &QAction::triggered,
this, &QgsCompoundColorWidget::removePalette );
98 connect( mActionNewPalette, &QAction::triggered,
this, &QgsCompoundColorWidget::newPalette );
101 QMenu *schemeMenu =
new QMenu( mSchemeToolButton );
102 schemeMenu->addAction( mActionCopyColors );
103 schemeMenu->addAction( mActionPasteColors );
104 schemeMenu->addSeparator();
105 schemeMenu->addAction( mActionImportColors );
106 schemeMenu->addAction( mActionExportColors );
107 schemeMenu->addSeparator();
108 schemeMenu->addAction( mActionNewPalette );
109 schemeMenu->addAction( mActionImportPalette );
110 schemeMenu->addAction( mActionRemovePalette );
111 schemeMenu->addAction( mActionShowInButtons );
112 mSchemeToolButton->setMenu( schemeMenu );
114 connect( mSchemeComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsCompoundColorWidget::schemeIndexChanged );
117 mOldColorLabel->hide();
120 mVerticalRamp->setInteriorMargin( 2 );
121 mVerticalRamp->setShowFrame(
true );
131 mSwatchButton1->setShowMenu(
false );
133 mSwatchButton2->setShowMenu(
false );
135 mSwatchButton3->setShowMenu(
false );
137 mSwatchButton4->setShowMenu(
false );
139 mSwatchButton5->setShowMenu(
false );
141 mSwatchButton6->setShowMenu(
false );
143 mSwatchButton7->setShowMenu(
false );
145 mSwatchButton8->setShowMenu(
false );
147 mSwatchButton9->setShowMenu(
false );
149 mSwatchButton10->setShowMenu(
false );
151 mSwatchButton11->setShowMenu(
false );
153 mSwatchButton12->setShowMenu(
false );
155 mSwatchButton13->setShowMenu(
false );
157 mSwatchButton14->setShowMenu(
false );
159 mSwatchButton15->setShowMenu(
false );
161 mSwatchButton16->setShowMenu(
false );
164 mSwatchButton1->setColor( settings.
value( QStringLiteral(
"Windows/ColorDialog/customColor1" ), QVariant( QColor() ) ).value<QColor>() );
165 mSwatchButton2->setColor( settings.
value( QStringLiteral(
"Windows/ColorDialog/customColor2" ), QVariant( QColor() ) ).value<QColor>() );
166 mSwatchButton3->setColor( settings.
value( QStringLiteral(
"Windows/ColorDialog/customColor3" ), QVariant( QColor() ) ).value<QColor>() );
167 mSwatchButton4->setColor( settings.
value( QStringLiteral(
"Windows/ColorDialog/customColor4" ), QVariant( QColor() ) ).value<QColor>() );
168 mSwatchButton5->setColor( settings.
value( QStringLiteral(
"Windows/ColorDialog/customColor5" ), QVariant( QColor() ) ).value<QColor>() );
169 mSwatchButton6->setColor( settings.
value( QStringLiteral(
"Windows/ColorDialog/customColor6" ), QVariant( QColor() ) ).value<QColor>() );
170 mSwatchButton7->setColor( settings.
value( QStringLiteral(
"Windows/ColorDialog/customColor7" ), QVariant( QColor() ) ).value<QColor>() );
171 mSwatchButton8->setColor( settings.
value( QStringLiteral(
"Windows/ColorDialog/customColor8" ), QVariant( QColor() ) ).value<QColor>() );
172 mSwatchButton9->setColor( settings.
value( QStringLiteral(
"Windows/ColorDialog/customColor9" ), QVariant( QColor() ) ).value<QColor>() );
173 mSwatchButton10->setColor( settings.
value( QStringLiteral(
"Windows/ColorDialog/customColor10" ), QVariant( QColor() ) ).value<QColor>() );
174 mSwatchButton11->setColor( settings.
value( QStringLiteral(
"Windows/ColorDialog/customColor11" ), QVariant( QColor() ) ).value<QColor>() );
175 mSwatchButton12->setColor( settings.
value( QStringLiteral(
"Windows/ColorDialog/customColor12" ), QVariant( QColor() ) ).value<QColor>() );
176 mSwatchButton13->setColor( settings.
value( QStringLiteral(
"Windows/ColorDialog/customColor13" ), QVariant( QColor() ) ).value<QColor>() );
177 mSwatchButton14->setColor( settings.
value( QStringLiteral(
"Windows/ColorDialog/customColor14" ), QVariant( QColor() ) ).value<QColor>() );
178 mSwatchButton15->setColor( settings.
value( QStringLiteral(
"Windows/ColorDialog/customColor15" ), QVariant( QColor() ) ).value<QColor>() );
179 mSwatchButton16->setColor( settings.
value( QStringLiteral(
"Windows/ColorDialog/customColor16" ), QVariant( QColor() ) ).value<QColor>() );
182 mSpinBoxRadius->setValue( settings.
value( QStringLiteral(
"Windows/ColorDialog/sampleRadius" ), 1 ).toInt() );
183 mSamplePreview->setColor( QColor() );
186 const int swatchWidth =
static_cast< int >( std::round( std::max(
Qgis::UI_SCALE_FACTOR * 1.9 * mSwatchButton1->fontMetrics().height(), 38.0 ) ) );
187 const int swatchHeight =
static_cast< int >( std::round( std::max(
Qgis::UI_SCALE_FACTOR * 1.5 * mSwatchButton1->fontMetrics().height(), 30.0 ) ) );
188 mSwatchButton1->setMinimumSize( swatchWidth, swatchHeight );
189 mSwatchButton1->setMaximumSize( swatchWidth, swatchHeight );
190 mSwatchButton2->setMinimumSize( swatchWidth, swatchHeight );
191 mSwatchButton2->setMaximumSize( swatchWidth, swatchHeight );
192 mSwatchButton3->setMinimumSize( swatchWidth, swatchHeight );
193 mSwatchButton3->setMaximumSize( swatchWidth, swatchHeight );
194 mSwatchButton4->setMinimumSize( swatchWidth, swatchHeight );
195 mSwatchButton4->setMaximumSize( swatchWidth, swatchHeight );
196 mSwatchButton5->setMinimumSize( swatchWidth, swatchHeight );
197 mSwatchButton5->setMaximumSize( swatchWidth, swatchHeight );
198 mSwatchButton6->setMinimumSize( swatchWidth, swatchHeight );
199 mSwatchButton6->setMaximumSize( swatchWidth, swatchHeight );
200 mSwatchButton7->setMinimumSize( swatchWidth, swatchHeight );
201 mSwatchButton7->setMaximumSize( swatchWidth, swatchHeight );
202 mSwatchButton8->setMinimumSize( swatchWidth, swatchHeight );
203 mSwatchButton8->setMaximumSize( swatchWidth, swatchHeight );
204 mSwatchButton9->setMinimumSize( swatchWidth, swatchHeight );
205 mSwatchButton9->setMaximumSize( swatchWidth, swatchHeight );
206 mSwatchButton10->setMinimumSize( swatchWidth, swatchHeight );
207 mSwatchButton10->setMaximumSize( swatchWidth, swatchHeight );
208 mSwatchButton11->setMinimumSize( swatchWidth, swatchHeight );
209 mSwatchButton11->setMaximumSize( swatchWidth, swatchHeight );
210 mSwatchButton12->setMinimumSize( swatchWidth, swatchHeight );
211 mSwatchButton12->setMaximumSize( swatchWidth, swatchHeight );
212 mSwatchButton13->setMinimumSize( swatchWidth, swatchHeight );
213 mSwatchButton13->setMaximumSize( swatchWidth, swatchHeight );
214 mSwatchButton14->setMinimumSize( swatchWidth, swatchHeight );
215 mSwatchButton14->setMaximumSize( swatchWidth, swatchHeight );
216 mSwatchButton15->setMinimumSize( swatchWidth, swatchHeight );
217 mSwatchButton15->setMaximumSize( swatchWidth, swatchHeight );
218 mSwatchButton16->setMinimumSize( swatchWidth, swatchHeight );
219 mSwatchButton16->setMaximumSize( swatchWidth, swatchHeight );
220 const int previewHeight =
static_cast< int >( std::round( std::max(
Qgis::UI_SCALE_FACTOR * 2.0 * mSwatchButton1->fontMetrics().height(), 40.0 ) ) );
221 mColorPreview->setMinimumSize( 0, previewHeight );
222 mPreviewWidget->setMaximumHeight( previewHeight * 2 );
223 const int swatchAddSize =
static_cast< int >( std::round( std::max(
Qgis::UI_SCALE_FACTOR * 1.4 * mSwatchButton1->fontMetrics().height(), 28.0 ) ) );
224 mAddCustomColorButton->setMinimumWidth( swatchAddSize );
225 mAddCustomColorButton->setMaximumWidth( swatchAddSize );
228 mTabWidget->setIconSize( QSize( iconSize, iconSize ) );
230 if (
color.isValid() )
236 const int activeRadio = settings.
value( QStringLiteral(
"Windows/ColorDialog/activeComponent" ), 2 ).toInt();
237 switch ( activeRadio )
240 mHueRadio->setChecked(
true );
243 mSaturationRadio->setChecked(
true );
246 mValueRadio->setChecked(
true );
249 mRedRadio->setChecked(
true );
252 mGreenRadio->setChecked(
true );
255 mBlueRadio->setChecked(
true );
258 const int currentTab = settings.
value( QStringLiteral(
"Windows/ColorDialog/activeTab" ), 0 ).toInt();
259 mTabWidget->setCurrentIndex( currentTab );