109 m_scene->addRect (x, y, w, w, pen, col); |
109 m_scene->addRect (x, y, w, w, pen, col); |
110 QGraphicsTextItem* numtext = m_scene->addText (fmt ("%1", i)); |
110 QGraphicsTextItem* numtext = m_scene->addText (fmt ("%1", i)); |
111 numtext->setDefaultTextColor ( (luma (col) < 80) ? Qt::white : Qt::black); |
111 numtext->setDefaultTextColor ( (luma (col) < 80) ? Qt::white : Qt::black); |
112 numtext->setPos (x, y); |
112 numtext->setPos (x, y); |
113 |
113 |
114 if (sel() && i == sel()->index) |
114 if (getSelection() && i == getSelection()->index) |
115 { auto curspic = m_scene->addPixmap (getIcon ("colorcursor")); |
115 { auto curspic = m_scene->addPixmap (getIcon ("colorcursor")); |
116 curspic->setPos (x, y); |
116 curspic->setPos (x, y); |
117 } |
117 } |
118 } |
118 } |
119 } |
119 } |
131 } |
131 } |
132 |
132 |
133 // ============================================================================= |
133 // ============================================================================= |
134 // ----------------------------------------------------------------------------- |
134 // ----------------------------------------------------------------------------- |
135 void ColorSelector::drawColorInfo() |
135 void ColorSelector::drawColorInfo() |
136 { if (!sel()) |
136 { if (!getSelection()) |
137 { ui->colorLabel->setText ("---"); |
137 { ui->colorLabel->setText ("---"); |
138 return; |
138 return; |
139 } |
139 } |
140 |
140 |
141 ui->colorLabel->setText (fmt ("%1 - %2", sel()->index, sel()->name)); |
141 ui->colorLabel->setText (fmt ("%1 - %2", getSelection()->index, getSelection()->name)); |
142 } |
142 } |
143 |
143 |
144 // ============================================================================= |
144 // ============================================================================= |
145 // ----------------------------------------------------------------------------- |
145 // ----------------------------------------------------------------------------- |
146 void ColorSelector::resizeEvent (QResizeEvent* ev) |
146 void ColorSelector::resizeEvent (QResizeEvent* ev) |
148 // currently selected color. We cannot do this in the constructor because the |
148 // currently selected color. We cannot do this in the constructor because the |
149 // height is not set properly there. |
149 // height is not set properly there. |
150 if (m_firstResize) |
150 if (m_firstResize) |
151 { int visibleColors = (ui->viewport->height() / g_squareSize) * g_numColumns; |
151 { int visibleColors = (ui->viewport->height() / g_squareSize) * g_numColumns; |
152 |
152 |
153 if (sel() && sel()->index >= visibleColors) |
153 if (getSelection() && getSelection()->index >= visibleColors) |
154 { int y = (sel()->index / g_numColumns) * g_squareSize; |
154 { int y = (getSelection()->index / g_numColumns) * g_squareSize; |
155 ui->viewport->verticalScrollBar()->setValue (y); |
155 ui->viewport->verticalScrollBar()->setValue (y); |
156 } |
156 } |
157 |
157 |
158 m_firstResize = false; |
158 m_firstResize = false; |
159 } |
159 } |
184 // ============================================================================= |
184 // ============================================================================= |
185 // ----------------------------------------------------------------------------- |
185 // ----------------------------------------------------------------------------- |
186 bool ColorSelector::selectColor (int& val, int defval, QWidget* parent) |
186 bool ColorSelector::selectColor (int& val, int defval, QWidget* parent) |
187 { ColorSelector dlg (defval, parent); |
187 { ColorSelector dlg (defval, parent); |
188 |
188 |
189 if (dlg.exec() && dlg.sel() != null) |
189 if (dlg.exec() && dlg.getSelection() != null) |
190 { val = dlg.sel()->index; |
190 { val = dlg.getSelection()->index; |
191 return true; |
191 return true; |
192 } |
192 } |
193 |
193 |
194 return false; |
194 return false; |
195 } |
195 } |