51 // ============================================================================= |
51 // ============================================================================= |
52 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
52 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
53 // ============================================================================= |
53 // ============================================================================= |
54 ConfigDialog::ConfigDialog (ForgeWindow* parent) : QDialog (parent) { |
54 ConfigDialog::ConfigDialog (ForgeWindow* parent) : QDialog (parent) { |
55 g_ConfigDialog = this; |
55 g_ConfigDialog = this; |
56 qTabs = new QTabWidget; |
56 tabs = new QTabWidget; |
57 |
57 |
58 initMainTab (); |
58 initMainTab (); |
59 initShortcutsTab (); |
59 initShortcutsTab (); |
60 initQuickColorTab (); |
60 initQuickColorTab (); |
61 initGridTab (); |
61 initGridTab (); |
62 |
62 |
63 IMPLEMENT_DIALOG_BUTTONS |
63 IMPLEMENT_DIALOG_BUTTONS |
64 |
64 |
65 QVBoxLayout* layout = new QVBoxLayout; |
65 QVBoxLayout* layout = new QVBoxLayout; |
66 layout->addWidget (qTabs); |
66 layout->addWidget (tabs); |
67 layout->addWidget (qButtons); |
67 layout->addWidget (bbx_buttons); |
68 setLayout (layout); |
68 setLayout (layout); |
69 |
69 |
70 setWindowTitle (APPNAME_DISPLAY " - Settings"); |
70 setWindowTitle (APPNAME_DISPLAY " - Settings"); |
71 setWindowIcon (QIcon ("icons/settings.png")); |
71 setWindowIcon (QIcon ("icons/settings.png")); |
72 } |
72 } |
73 |
73 |
74 // ============================================================================= |
74 // ============================================================================= |
75 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
75 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
76 // ============================================================================= |
76 // ============================================================================= |
77 void ConfigDialog::initMainTab () { |
77 void ConfigDialog::initMainTab () { |
78 qMainTab = new QWidget; |
78 mainTab = new QWidget; |
79 |
79 |
80 // ========================================================================= |
80 // ========================================================================= |
81 // LDraw path |
81 // LDraw path |
82 qLDrawPathLabel = new QLabel ("LDraw path:"); |
82 lb_LDrawPath = new QLabel ("LDraw path:"); |
83 |
83 |
84 qLDrawPath = new QLineEdit; |
84 le_LDrawPath = new QLineEdit; |
85 qLDrawPath->setText (io_ldpath.value.chars()); |
85 le_LDrawPath->setText (io_ldpath.value.chars()); |
86 |
86 |
87 qLDrawPathFindButton = new QPushButton; |
87 pb_findLDrawPath = new QPushButton; |
88 qLDrawPathFindButton->setIcon (QIcon ("icons/folder.png")); |
88 pb_findLDrawPath->setIcon (QIcon ("icons/folder.png")); |
89 connect (qLDrawPathFindButton, SIGNAL (clicked ()), |
89 connect (pb_findLDrawPath, SIGNAL (clicked ()), |
90 this, SLOT (slot_findLDrawPath ())); |
90 this, SLOT (slot_findLDrawPath ())); |
91 |
91 |
92 QHBoxLayout* qLDrawPathLayout = new QHBoxLayout; |
92 QHBoxLayout* qLDrawPathLayout = new QHBoxLayout; |
93 qLDrawPathLayout->addWidget (qLDrawPath); |
93 qLDrawPathLayout->addWidget (le_LDrawPath); |
94 qLDrawPathLayout->addWidget (qLDrawPathFindButton); |
94 qLDrawPathLayout->addWidget (pb_findLDrawPath); |
95 |
95 |
96 // ========================================================================= |
96 // ========================================================================= |
97 // Background and foreground colors |
97 // Background and foreground colors |
98 qGLBackgroundLabel = new QLabel ("Background color:"); |
98 lb_viewBg = new QLabel ("Background color:"); |
99 qGLBackgroundButton = new QPushButton; |
99 pb_viewBg = new QPushButton; |
100 setButtonBackground (qGLBackgroundButton, gl_bgcolor.value); |
100 setButtonBackground (pb_viewBg, gl_bgcolor.value); |
101 connect (qGLBackgroundButton, SIGNAL (clicked ()), |
101 connect (pb_viewBg, SIGNAL (clicked ()), |
102 this, SLOT (slot_setGLBackground ())); |
102 this, SLOT (slot_setGLBackground ())); |
103 |
103 |
104 qGLForegroundLabel = new QLabel ("Foreground color:"); |
104 lb_viewFg = new QLabel ("Foreground color:"); |
105 qGLForegroundButton = new QPushButton; |
105 pb_viewFg = new QPushButton; |
106 setButtonBackground (qGLForegroundButton, gl_maincolor.value); |
106 setButtonBackground (pb_viewFg, gl_maincolor.value); |
107 connect (qGLForegroundButton, SIGNAL (clicked ()), |
107 connect (pb_viewFg, SIGNAL (clicked ()), |
108 this, SLOT (slot_setGLForeground ())); |
108 this, SLOT (slot_setGLForeground ())); |
109 |
109 |
110 // ========================================================================= |
110 // ========================================================================= |
111 // Alpha and line thickness sliders |
111 // Alpha and line thickness sliders |
112 qGLForegroundAlphaLabel = new QLabel ("Alpha:"); |
112 lb_viewFgAlpha = new QLabel ("Alpha:"); |
113 makeSlider (qGLForegroundAlpha, 1, 10, (gl_maincolor_alpha * 10.0f)); |
113 makeSlider (sl_viewFgAlpha, 1, 10, (gl_maincolor_alpha * 10.0f)); |
114 |
114 |
115 qGLLineThicknessLabel = new QLabel ("Line thickness:"); |
115 lb_lineThickness = new QLabel ("Line thickness:"); |
116 makeSlider (qGLLineThickness, 1, 8, gl_linethickness); |
116 makeSlider (sl_lineThickness, 1, 8, gl_linethickness); |
117 |
117 |
118 // ========================================================================= |
118 // ========================================================================= |
119 // Tool bar icon size slider |
119 // Tool bar icon size slider |
120 qToolBarIconSizeLabel = new QLabel ("Toolbar icon size:"); |
120 lb_iconSize = new QLabel ("Toolbar icon size:"); |
121 makeSlider (qToolBarIconSize, 1, 5, (gui_toolbar_iconsize - 12) / 4); |
121 makeSlider (sl_iconSize, 1, 5, (gui_toolbar_iconsize - 12) / 4); |
122 |
122 |
123 // ========================================================================= |
123 // ========================================================================= |
124 // List view colorizer and BFC red/green view checkboxes |
124 // List view colorizer and BFC red/green view checkboxes |
125 qLVColorize = new QCheckBox ("Colorize polygons in list view"); |
125 cb_colorize = new QCheckBox ("Colorize polygons in list view"); |
126 INIT_CHECKBOX (qLVColorize, lv_colorize) |
126 INIT_CHECKBOX (cb_colorize, lv_colorize) |
127 |
127 |
128 qGLColorBFC = new QCheckBox ("Red/green BFC view"); |
128 cb_colorBFC = new QCheckBox ("Red/green BFC view"); |
129 INIT_CHECKBOX (qGLColorBFC, gl_colorbfc) |
129 INIT_CHECKBOX (cb_colorBFC, gl_colorbfc) |
130 |
130 |
131 qGLSelFlash = new QCheckBox ("Selection flash"); |
131 cb_selFlash = new QCheckBox ("Selection flash"); |
132 INIT_CHECKBOX (qGLSelFlash, gl_selflash) |
132 INIT_CHECKBOX (cb_selFlash, gl_selflash) |
133 |
133 |
134 QGridLayout* layout = new QGridLayout; |
134 QGridLayout* layout = new QGridLayout; |
135 layout->addWidget (qLDrawPathLabel, 0, 0); |
135 layout->addWidget (lb_LDrawPath, 0, 0); |
136 layout->addLayout (qLDrawPathLayout, 0, 1, 1, 3); |
136 layout->addLayout (qLDrawPathLayout, 0, 1, 1, 3); |
137 |
137 |
138 layout->addWidget (qGLBackgroundLabel, 1, 0); |
138 layout->addWidget (lb_viewBg, 1, 0); |
139 layout->addWidget (qGLBackgroundButton, 1, 1); |
139 layout->addWidget (pb_viewBg, 1, 1); |
140 layout->addWidget (qGLForegroundLabel, 1, 2); |
140 layout->addWidget (lb_viewFg, 1, 2); |
141 layout->addWidget (qGLForegroundButton, 1, 3); |
141 layout->addWidget (pb_viewFg, 1, 3); |
142 |
142 |
143 layout->addWidget (qGLLineThicknessLabel, 2, 0); |
143 layout->addWidget (lb_lineThickness, 2, 0); |
144 layout->addWidget (qGLLineThickness, 2, 1); |
144 layout->addWidget (sl_lineThickness, 2, 1); |
145 layout->addWidget (qGLForegroundAlphaLabel, 2, 2); |
145 layout->addWidget (lb_viewFgAlpha, 2, 2); |
146 layout->addWidget (qGLForegroundAlpha, 2, 3); |
146 layout->addWidget (sl_viewFgAlpha, 2, 3); |
147 |
147 |
148 layout->addWidget (qToolBarIconSizeLabel, 3, 0); |
148 layout->addWidget (lb_iconSize, 3, 0); |
149 layout->addWidget (qToolBarIconSize, 3, 1); |
149 layout->addWidget (sl_iconSize, 3, 1); |
150 |
150 |
151 layout->addWidget (qLVColorize, 4, 0, 1, 4); |
151 layout->addWidget (cb_colorize, 4, 0, 1, 4); |
152 layout->addWidget (qGLColorBFC, 5, 0, 1, 4); |
152 layout->addWidget (cb_colorBFC, 5, 0, 1, 4); |
153 layout->addWidget (qGLSelFlash, 6, 0, 1, 4); |
153 layout->addWidget (cb_selFlash, 6, 0, 1, 4); |
154 qMainTab->setLayout (layout); |
154 mainTab->setLayout (layout); |
155 |
155 |
156 // Add the tab to the manager |
156 // Add the tab to the manager |
157 qTabs->addTab (qMainTab, "Main settings"); |
157 tabs->addTab (mainTab, "Main settings"); |
158 } |
158 } |
159 |
159 |
160 // ============================================================================= |
160 // ============================================================================= |
161 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
161 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
162 // ============================================================================= |
162 // ============================================================================= |
163 void ConfigDialog::initShortcutsTab () { |
163 void ConfigDialog::initShortcutsTab () { |
164 QGridLayout* qLayout; |
164 QGridLayout* qLayout; |
165 |
165 |
166 qShortcutsTab = new QWidget; |
166 shortcutsTab = new QWidget; |
167 qShortcutList = new QListWidget; |
167 lw_shortcutList = new QListWidget; |
168 qLayout = new QGridLayout; |
168 qLayout = new QGridLayout; |
169 |
169 |
170 // Init table items |
170 // Init table items |
171 ulong i = 0; |
171 ulong i = 0; |
172 for (actionmeta meta : g_ActionMeta) { |
172 for (actionmeta meta : g_ActionMeta) { |
174 |
174 |
175 QListWidgetItem* qItem = new QListWidgetItem; |
175 QListWidgetItem* qItem = new QListWidgetItem; |
176 setShortcutText (qItem, meta); |
176 setShortcutText (qItem, meta); |
177 qItem->setIcon (qAct->icon ()); |
177 qItem->setIcon (qAct->icon ()); |
178 |
178 |
179 qaShortcutItems.push_back (qItem); |
179 shortcutItems.push_back (qItem); |
180 qShortcutList->insertItem (i, qItem); |
180 lw_shortcutList->insertItem (i, qItem); |
181 ++i; |
181 ++i; |
182 } |
182 } |
183 |
183 |
184 qSetShortcut = new QPushButton ("Set"); |
184 pb_setShortcut = new QPushButton ("Set"); |
185 qResetShortcut = new QPushButton ("Reset"); |
185 pb_resetShortcut = new QPushButton ("Reset"); |
186 qClearShortcut = new QPushButton ("Clear"); |
186 pb_clearShortcut = new QPushButton ("Clear"); |
187 |
187 |
188 connect (qSetShortcut, SIGNAL (clicked ()), this, SLOT (slot_setShortcut ())); |
188 connect (pb_setShortcut, SIGNAL (clicked ()), this, SLOT (slot_setShortcut ())); |
189 connect (qResetShortcut, SIGNAL (clicked ()), this, SLOT (slot_resetShortcut ())); |
189 connect (pb_resetShortcut, SIGNAL (clicked ()), this, SLOT (slot_resetShortcut ())); |
190 connect (qClearShortcut, SIGNAL (clicked ()), this, SLOT (slot_clearShortcut ())); |
190 connect (pb_clearShortcut, SIGNAL (clicked ()), this, SLOT (slot_clearShortcut ())); |
191 |
191 |
192 QVBoxLayout* qButtonLayout = new QVBoxLayout; |
192 QVBoxLayout* qButtonLayout = new QVBoxLayout; |
193 qButtonLayout->addWidget (qSetShortcut); |
193 qButtonLayout->addWidget (pb_setShortcut); |
194 qButtonLayout->addWidget (qResetShortcut); |
194 qButtonLayout->addWidget (pb_resetShortcut); |
195 qButtonLayout->addWidget (qClearShortcut); |
195 qButtonLayout->addWidget (pb_clearShortcut); |
196 qButtonLayout->addStretch (10); |
196 qButtonLayout->addStretch (10); |
197 |
197 |
198 qLayout->addWidget (qShortcutList, 0, 0); |
198 qLayout->addWidget (lw_shortcutList, 0, 0); |
199 qLayout->addLayout (qButtonLayout, 0, 1); |
199 qLayout->addLayout (qButtonLayout, 0, 1); |
200 qShortcutsTab->setLayout (qLayout); |
200 shortcutsTab->setLayout (qLayout); |
201 qTabs->addTab (qShortcutsTab, "Shortcuts"); |
201 tabs->addTab (shortcutsTab, "Shortcuts"); |
202 } |
202 } |
203 |
203 |
204 // ============================================================================= |
204 // ============================================================================= |
205 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
205 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
206 // ============================================================================= |
206 // ============================================================================= |
207 void ConfigDialog::initQuickColorTab () { |
207 void ConfigDialog::initQuickColorTab () { |
208 qQuickColorTab = new QWidget; |
208 quickColorTab = new QWidget; |
209 |
209 |
210 qAddColor = new QPushButton (getIcon ("palette"), "Add"); |
210 pb_addColor = new QPushButton (getIcon ("palette"), "Add"); |
211 qDelColor = new QPushButton (getIcon ("delete"), "Remove"); |
211 pb_delColor = new QPushButton (getIcon ("delete"), "Remove"); |
212 qChangeColor = new QPushButton (getIcon ("palette"), "Set"); |
212 pb_changeColor = new QPushButton (getIcon ("palette"), "Set"); |
213 qAddColorSeparator = new QPushButton ("Add Separator"); |
213 pb_addColorSeparator = new QPushButton ("Add Separator"); |
214 qMoveColorUp = new QPushButton (getIcon ("arrow-up"), "Move Up"); |
214 pb_moveColorUp = new QPushButton (getIcon ("arrow-up"), "Move Up"); |
215 qMoveColorDown = new QPushButton (getIcon ("arrow-down"), "Move Down"); |
215 pb_moveColorDown = new QPushButton (getIcon ("arrow-down"), "Move Down"); |
216 qClearColors = new QPushButton (getIcon ("delete-all"), "Clear"); |
216 pb_clearColors = new QPushButton (getIcon ("delete-all"), "Clear"); |
217 |
217 |
218 qQuickColorList = new QListWidget; |
218 lw_quickColors = new QListWidget; |
219 |
219 |
220 quickColorMeta = parseQuickColorMeta (); |
220 quickColorMeta = parseQuickColorMeta (); |
221 updateQuickColorList (); |
221 updateQuickColorList (); |
222 |
222 |
223 QVBoxLayout* qButtonLayout = new QVBoxLayout; |
223 QVBoxLayout* qButtonLayout = new QVBoxLayout; |
224 qButtonLayout->addWidget (qAddColor); |
224 qButtonLayout->addWidget (pb_addColor); |
225 qButtonLayout->addWidget (qDelColor); |
225 qButtonLayout->addWidget (pb_delColor); |
226 qButtonLayout->addWidget (qChangeColor); |
226 qButtonLayout->addWidget (pb_changeColor); |
227 qButtonLayout->addWidget (qAddColorSeparator); |
227 qButtonLayout->addWidget (pb_addColorSeparator); |
228 qButtonLayout->addWidget (qMoveColorUp); |
228 qButtonLayout->addWidget (pb_moveColorUp); |
229 qButtonLayout->addWidget (qMoveColorDown); |
229 qButtonLayout->addWidget (pb_moveColorDown); |
230 qButtonLayout->addWidget (qClearColors); |
230 qButtonLayout->addWidget (pb_clearColors); |
231 qButtonLayout->addStretch (1); |
231 qButtonLayout->addStretch (1); |
232 |
232 |
233 connect (qAddColor, SIGNAL (clicked ()), this, SLOT (slot_setColor ())); |
233 connect (pb_addColor, SIGNAL (clicked ()), this, SLOT (slot_setColor ())); |
234 connect (qDelColor, SIGNAL (clicked ()), this, SLOT (slot_delColor ())); |
234 connect (pb_delColor, SIGNAL (clicked ()), this, SLOT (slot_delColor ())); |
235 connect (qChangeColor, SIGNAL (clicked ()), this, SLOT (slot_setColor ())); |
235 connect (pb_changeColor, SIGNAL (clicked ()), this, SLOT (slot_setColor ())); |
236 connect (qAddColorSeparator, SIGNAL (clicked ()), this, SLOT (slot_addColorSeparator ())); |
236 connect (pb_addColorSeparator, SIGNAL (clicked ()), this, SLOT (slot_addColorSeparator ())); |
237 connect (qMoveColorUp, SIGNAL (clicked ()), this, SLOT (slot_moveColor ())); |
237 connect (pb_moveColorUp, SIGNAL (clicked ()), this, SLOT (slot_moveColor ())); |
238 connect (qMoveColorDown, SIGNAL (clicked ()), this, SLOT (slot_moveColor ())); |
238 connect (pb_moveColorDown, SIGNAL (clicked ()), this, SLOT (slot_moveColor ())); |
239 connect (qClearColors, SIGNAL (clicked ()), this, SLOT (slot_clearColors ())); |
239 connect (pb_clearColors, SIGNAL (clicked ()), this, SLOT (slot_clearColors ())); |
240 |
240 |
241 QGridLayout* qLayout = new QGridLayout; |
241 QGridLayout* qLayout = new QGridLayout; |
242 qLayout->addWidget (qQuickColorList, 0, 0); |
242 qLayout->addWidget (lw_quickColors, 0, 0); |
243 qLayout->addLayout (qButtonLayout, 0, 1); |
243 qLayout->addLayout (qButtonLayout, 0, 1); |
244 |
244 |
245 qQuickColorTab->setLayout (qLayout); |
245 quickColorTab->setLayout (qLayout); |
246 qTabs->addTab (qQuickColorTab, "Quick Colors"); |
246 tabs->addTab (quickColorTab, "Quick Colors"); |
247 } |
247 } |
248 |
248 |
249 // ============================================================================= |
249 // ============================================================================= |
250 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
250 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
251 // ============================================================================= |
251 // ============================================================================= |
265 layout->addWidget (label, 0, i++); |
265 layout->addWidget (label, 0, i++); |
266 } |
266 } |
267 |
267 |
268 for (int i = 0; i < g_NumGrids; ++i) { |
268 for (int i = 0; i < g_NumGrids; ++i) { |
269 // Icon |
269 // Icon |
270 gridIcons[i] = new QLabel; |
270 lb_gridIcons[i] = new QLabel; |
271 gridIcons[i]->setPixmap (QPixmap (format ("icons/grid-%s", str (g_GridInfo[i].name).tolower ().chars ()))); |
271 lb_gridIcons[i]->setPixmap (QPixmap (format ("icons/grid-%s", str (g_GridInfo[i].name).tolower ().chars ()))); |
272 |
272 |
273 // Text label |
273 // Text label |
274 gridLabels[i] = new QLabel (format ("%s:", g_GridInfo[i].name)); |
274 lb_gridLabels[i] = new QLabel (format ("%s:", g_GridInfo[i].name)); |
275 |
275 |
276 QHBoxLayout* labellayout = new QHBoxLayout; |
276 QHBoxLayout* labellayout = new QHBoxLayout; |
277 labellayout->addWidget (gridIcons[i]); |
277 labellayout->addWidget (lb_gridIcons[i]); |
278 labellayout->addWidget (gridLabels[i]); |
278 labellayout->addWidget (lb_gridLabels[i]); |
279 layout->addLayout (labellayout, i + 1, 0); |
279 layout->addLayout (labellayout, i + 1, 0); |
280 |
280 |
281 // Add the widgets |
281 // Add the widgets |
282 for (int j = 0; j < 4; ++j) { |
282 for (int j = 0; j < 4; ++j) { |
283 gridData[i][j] = new QDoubleSpinBox; |
283 dsb_gridData[i][j] = new QDoubleSpinBox; |
284 gridData[i][j]->setValue (g_GridInfo[i].confs[j]->value); |
284 dsb_gridData[i][j]->setValue (g_GridInfo[i].confs[j]->value); |
285 layout->addWidget (gridData[i][j], i + 1, j + 1); |
285 layout->addWidget (dsb_gridData[i][j], i + 1, j + 1); |
286 } |
286 } |
287 } |
287 } |
288 |
288 |
289 l2->addLayout (layout); |
289 l2->addLayout (layout); |
290 l2->addStretch (1); |
290 l2->addStretch (1); |
291 |
291 |
292 tab->setLayout (l2); |
292 tab->setLayout (l2); |
293 qTabs->addTab (tab, "Grids"); |
293 tabs->addTab (tab, "Grids"); |
294 } |
294 } |
295 |
295 |
296 // ============================================================================= |
296 // ============================================================================= |
297 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
297 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
298 // ============================================================================= |
298 // ============================================================================= |
299 void ConfigDialog::updateQuickColorList (quickColorMetaEntry* pSel) { |
299 void ConfigDialog::updateQuickColorList (quickColorMetaEntry* pSel) { |
300 for (QListWidgetItem* qItem : qaQuickColorItems) |
300 for (QListWidgetItem* qItem : quickColorItems) |
301 delete qItem; |
301 delete qItem; |
302 |
302 |
303 qaQuickColorItems.clear (); |
303 quickColorItems.clear (); |
304 |
304 |
305 // Init table items |
305 // Init table items |
306 for (quickColorMetaEntry& entry : quickColorMeta) { |
306 for (quickColorMetaEntry& entry : quickColorMeta) { |
307 QListWidgetItem* qItem = new QListWidgetItem; |
307 QListWidgetItem* qItem = new QListWidgetItem; |
308 |
308 |
379 |
379 |
380 // ============================================================================= |
380 // ============================================================================= |
381 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
381 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
382 // ============================================================================= |
382 // ============================================================================= |
383 void ConfigDialog::slot_delColor () { |
383 void ConfigDialog::slot_delColor () { |
384 if (qQuickColorList->selectedItems().size() == 0) |
384 if (lw_quickColors->selectedItems().size() == 0) |
385 return; |
385 return; |
386 |
386 |
387 QListWidgetItem* qItem = qQuickColorList->selectedItems ()[0]; |
387 QListWidgetItem* qItem = lw_quickColors->selectedItems ()[0]; |
388 ulong ulIdx = getItemRow (qItem, qaQuickColorItems); |
388 ulong ulIdx = getItemRow (qItem, quickColorItems); |
389 quickColorMeta.erase (quickColorMeta.begin () + ulIdx); |
389 quickColorMeta.erase (quickColorMeta.begin () + ulIdx); |
390 updateQuickColorList (); |
390 updateQuickColorList (); |
391 } |
391 } |
392 |
392 |
393 // ============================================================================= |
393 // ============================================================================= |
394 void ConfigDialog::slot_moveColor () { |
394 void ConfigDialog::slot_moveColor () { |
395 const bool bUp = (static_cast<QPushButton*> (sender()) == qMoveColorUp); |
395 const bool bUp = (static_cast<QPushButton*> (sender()) == pb_moveColorUp); |
396 |
396 |
397 if (qQuickColorList->selectedItems().size() == 0) |
397 if (lw_quickColors->selectedItems().size() == 0) |
398 return; |
398 return; |
399 |
399 |
400 QListWidgetItem* qItem = qQuickColorList->selectedItems ()[0]; |
400 QListWidgetItem* qItem = lw_quickColors->selectedItems ()[0]; |
401 ulong ulIdx = getItemRow (qItem, qaQuickColorItems); |
401 ulong ulIdx = getItemRow (qItem, quickColorItems); |
402 |
402 |
403 long lDest = bUp ? (ulIdx - 1) : (ulIdx + 1); |
403 long lDest = bUp ? (ulIdx - 1) : (ulIdx + 1); |
404 |
404 |
405 if (lDest < 0 || (ulong)lDest >= qaQuickColorItems.size ()) |
405 if (lDest < 0 || (ulong)lDest >= quickColorItems.size ()) |
406 return; // destination out of bounds |
406 return; // destination out of bounds |
407 |
407 |
408 quickColorMetaEntry tmp = quickColorMeta[lDest]; |
408 quickColorMetaEntry tmp = quickColorMeta[lDest]; |
409 quickColorMeta[lDest] = quickColorMeta[ulIdx]; |
409 quickColorMeta[lDest] = quickColorMeta[ulIdx]; |
410 quickColorMeta[ulIdx] = tmp; |
410 quickColorMeta[ulIdx] = tmp; |