src/colorSelector.cc

changeset 840
d077dd19bf9a
parent 806
4240f47aa2d4
child 844
11587d419d2f
equal deleted inserted replaced
839:5f822ad61875 840:d077dd19bf9a
117 m_scene->addRect (x, y, w, w, pen, col); 117 m_scene->addRect (x, y, w, w, pen, col);
118 QGraphicsTextItem* numtext = m_scene->addText (format ("%1", i)); 118 QGraphicsTextItem* numtext = m_scene->addText (format ("%1", i));
119 numtext->setDefaultTextColor ((luma (col) < 80) ? Qt::white : Qt::black); 119 numtext->setDefaultTextColor ((luma (col) < 80) ? Qt::white : Qt::black);
120 numtext->setPos (x, y); 120 numtext->setPos (x, y);
121 121
122 if (selection() && i == selection().index()) 122 if (selection() and i == selection().index())
123 { 123 {
124 auto curspic = m_scene->addPixmap (getIcon ("colorcursor")); 124 auto curspic = m_scene->addPixmap (getIcon ("colorcursor"));
125 curspic->setPos (x, y); 125 curspic->setPos (x, y);
126 } 126 }
127 } 127 }
157 (selection().isDirect() ? "<direct color>" : selection().name()))); 157 (selection().isDirect() ? "<direct color>" : selection().name())));
158 ui->iconLabel->setPixmap (makeColorIcon (selection(), 16).pixmap (16, 16)); 158 ui->iconLabel->setPixmap (makeColorIcon (selection(), 16).pixmap (16, 16));
159 159
160 #ifdef TRANSPARENT_DIRECT_COLORS 160 #ifdef TRANSPARENT_DIRECT_COLORS
161 ui->transparentDirectColor->setEnabled (selection().isDirect()); 161 ui->transparentDirectColor->setEnabled (selection().isDirect());
162 ui->transparentDirectColor->setChecked (selection().isDirect() && selection().faceColor().alphaF() < 1.0); 162 ui->transparentDirectColor->setChecked (selection().isDirect() and selection().faceColor().alphaF() < 1.0);
163 #else 163 #else
164 ui->transparentDirectColor->setChecked (false); 164 ui->transparentDirectColor->setChecked (false);
165 ui->transparentDirectColor->setEnabled (false); 165 ui->transparentDirectColor->setEnabled (false);
166 #endif 166 #endif
167 } 167 }
172 { 172 {
173 // If this is the first resize, check if we need to scroll down to see the 173 // If this is the first resize, check if we need to scroll down to see the
174 // currently selected color. We cannot do this in the constructor because the 174 // currently selected color. We cannot do this in the constructor because the
175 // height is not set properly there. Though don't do this if we selected a 175 // height is not set properly there. Though don't do this if we selected a
176 // direct color. 176 // direct color.
177 if (m_firstResize && selection().index() >= numLDConfigColors()) 177 if (m_firstResize and selection().index() >= numLDConfigColors())
178 { 178 {
179 int visibleColors = (ui->viewport->height() / g_squareSize) * g_numColumns; 179 int visibleColors = (ui->viewport->height() / g_squareSize) * g_numColumns;
180 180
181 if (selection() && selection().index() >= visibleColors) 181 if (selection() and selection().index() >= visibleColors)
182 { 182 {
183 int y = (selection().index() / g_numColumns) * g_squareSize; 183 int y = (selection().index() / g_numColumns) * g_squareSize;
184 ui->viewport->verticalScrollBar()->setValue (y); 184 ui->viewport->verticalScrollBar()->setValue (y);
185 } 185 }
186 } 186 }
234 234
235 // ============================================================================= 235 // =============================================================================
236 // 236 //
237 void ColorSelector::transparentCheckboxClicked() 237 void ColorSelector::transparentCheckboxClicked()
238 { 238 {
239 if (selection() == null || not selection().isDirect()) 239 if (selection() == null or not selection().isDirect())
240 return; 240 return;
241 241
242 selectDirectColor (selection().faceColor()); 242 selectDirectColor (selection().faceColor());
243 } 243 }
244 244
246 // 246 //
247 bool ColorSelector::selectColor (LDColor& val, LDColor defval, QWidget* parent) 247 bool ColorSelector::selectColor (LDColor& val, LDColor defval, QWidget* parent)
248 { 248 {
249 ColorSelector dlg (defval, parent); 249 ColorSelector dlg (defval, parent);
250 250
251 if (dlg.exec() && dlg.selection() != null) 251 if (dlg.exec() and dlg.selection() != null)
252 { 252 {
253 val = dlg.selection(); 253 val = dlg.selection();
254 return true; 254 return true;
255 } 255 }
256 256

mercurial