src/configDialog.cpp

changeset 498
791c831c8020
parent 493
16766ac1bbd9
child 503
bebe09014dd6
equal deleted inserted replaced
497:c51941e590b6 498:791c831c8020
103 ui->colorBFC->setChecked (gl_colorbfc); 103 ui->colorBFC->setChecked (gl_colorbfc);
104 ui->blackEdges->setChecked (gl_blackedges); 104 ui->blackEdges->setChecked (gl_blackedges);
105 ui->implicitFiles->setChecked (gui_implicitfiles); 105 ui->implicitFiles->setChecked (gui_implicitfiles);
106 ui->m_logostuds->setChecked (gl_logostuds); 106 ui->m_logostuds->setChecked (gl_logostuds);
107 107
108 ulong i = 0; 108 int i = 0;
109 #define act(N) addShortcut (key_##N, ACTION(N), i); 109 #define act(N) addShortcut (key_##N, ACTION(N), i);
110 #include "actions.h" 110 #include "actions.h"
111 111
112 ui->shortcutsList->setSortingEnabled (true); 112 ui->shortcutsList->setSortingEnabled (true);
113 ui->shortcutsList->sortItems(); 113 ui->shortcutsList->sortItems();
151 } 151 }
152 152
153 // ============================================================================= 153 // =============================================================================
154 // Adds a shortcut entry to the list of shortcuts. 154 // Adds a shortcut entry to the list of shortcuts.
155 // ----------------------------------------------------------------------------- 155 // -----------------------------------------------------------------------------
156 void ConfigDialog::addShortcut (KeySequenceConfig& cfg, QAction* act, ulong& i) 156 void ConfigDialog::addShortcut (KeySequenceConfig& cfg, QAction* act, int& i)
157 { ShortcutListItem* item = new ShortcutListItem; 157 { ShortcutListItem* item = new ShortcutListItem;
158 item->setIcon (act->icon()); 158 item->setIcon (act->icon());
159 item->setKeyConfig (&cfg); 159 item->setKeyConfig (&cfg);
160 item->setAction (act); 160 item->setAction (act);
161 setShortcutText (item); 161 setShortcutText (item);
208 ui->grids->setLayout (gridlayout); 208 ui->grids->setLayout (gridlayout);
209 } 209 }
210 210
211 // ============================================================================= 211 // =============================================================================
212 // ----------------------------------------------------------------------------- 212 // -----------------------------------------------------------------------------
213 static const struct extProgInfo 213 static const struct LDExtProgInfo
214 { const str name, iconname; 214 { const str name, iconname;
215 StringConfig* const path; 215 StringConfig* const path;
216 mutable QLineEdit* input; 216 mutable QLineEdit* input;
217 mutable QPushButton* setPathButton; 217 mutable QPushButton* setPathButton;
218 #ifndef _WIN32 218 #ifndef _WIN32
219 BoolConfig* const wine; 219 BoolConfig* const wine;
220 mutable QCheckBox* wineBox; 220 mutable QCheckBox* wineBox;
221 #endif // _WIN32 221 #endif // _WIN32
222 } g_extProgInfo[] = 222 } g_LDExtProgInfo[] =
223 { 223 {
224 #ifndef _WIN32 224 #ifndef _WIN32
225 # define EXTPROG(NAME, LOWNAME) { #NAME, #LOWNAME, &prog_##LOWNAME, null, null, &prog_##LOWNAME##_wine, null }, 225 # define EXTPROG(NAME, LOWNAME) { #NAME, #LOWNAME, &prog_##LOWNAME, null, null, &prog_##LOWNAME##_wine, null },
226 #else 226 #else
227 # define EXTPROG(NAME, LOWNAME) { #NAME, #LOWNAME, &prog_##LOWNAME, null, null }, 227 # define EXTPROG(NAME, LOWNAME) { #NAME, #LOWNAME, &prog_##LOWNAME, null, null },
238 // ============================================================================= 238 // =============================================================================
239 // Initializes the stuff in the ext programs tab 239 // Initializes the stuff in the ext programs tab
240 // ----------------------------------------------------------------------------- 240 // -----------------------------------------------------------------------------
241 void ConfigDialog::initExtProgs() 241 void ConfigDialog::initExtProgs()
242 { QGridLayout* pathsLayout = new QGridLayout; 242 { QGridLayout* pathsLayout = new QGridLayout;
243 ulong row = 0; 243 int row = 0;
244 244
245 for (const extProgInfo & info : g_extProgInfo) 245 for (const LDExtProgInfo& info : g_LDExtProgInfo)
246 { QLabel* icon = new QLabel, 246 { QLabel* icon = new QLabel,
247 *progLabel = new QLabel (info.name); 247 *progLabel = new QLabel (info.name);
248 QLineEdit* input = new QLineEdit; 248 QLineEdit* input = new QLineEdit;
249 QPushButton* setPathButton = new QPushButton; 249 QPushButton* setPathButton = new QPushButton;
250 250
305 // Apply key shortcuts 305 // Apply key shortcuts
306 #define act(N) ACTION(N)->setShortcut (key_##N); 306 #define act(N) ACTION(N)->setShortcut (key_##N);
307 #include "actions.h" 307 #include "actions.h"
308 308
309 // Ext program settings 309 // Ext program settings
310 for (const extProgInfo & info : g_extProgInfo) 310 for (const LDExtProgInfo& info : g_LDExtProgInfo)
311 { *info.path = info.input->text(); 311 { *info.path = info.input->text();
312 312
313 #ifndef _WIN32 313 #ifndef _WIN32
314 *info.wine = info.wineBox->isChecked(); 314 *info.wine = info.wineBox->isChecked();
315 #endif // _WIN32 315 #endif // _WIN32
394 { item = getSelectedQuickColor(); 394 { item = getSelectedQuickColor();
395 395
396 if (!item) 396 if (!item)
397 return; 397 return;
398 398
399 ulong i = getItemRow (item, quickColorItems); 399 int i = getItemRow (item, quickColorItems);
400 entry = &quickColors[i]; 400 entry = &quickColors[i];
401 401
402 if (entry->isSeparator() == true) 402 if (entry->isSeparator() == true)
403 return; // don't color separators 403 return; // don't color separators
404 } 404 }
413 entry->setColor (getColor (val)); 413 entry->setColor (getColor (val));
414 else 414 else
415 { LDQuickColor entry (getColor (val), null); 415 { LDQuickColor entry (getColor (val), null);
416 416
417 item = getSelectedQuickColor(); 417 item = getSelectedQuickColor();
418 ulong idx; 418 int idx = (item) ? getItemRow (item, quickColorItems) + 1 : quickColorItems.size();
419
420 if (item)
421 idx = getItemRow (item, quickColorItems) + 1;
422 else
423 idx = quickColorItems.size();
424 419
425 quickColors.insert (idx, entry); 420 quickColors.insert (idx, entry);
426 entry = quickColors[idx]; 421 entry = quickColors[idx];
427 } 422 }
428 423
452 447
453 QListWidgetItem* item = ui->quickColorList->selectedItems() [0]; 448 QListWidgetItem* item = ui->quickColorList->selectedItems() [0];
454 int idx = getItemRow (item, quickColorItems); 449 int idx = getItemRow (item, quickColorItems);
455 int dest = up ? (idx - 1) : (idx + 1); 450 int dest = up ? (idx - 1) : (idx + 1);
456 451
457 if (dest < 0 || (ulong) dest >= quickColorItems.size()) 452 if (dest < 0 || dest >= quickColorItems.size())
458 return; // destination out of bounds 453 return; // destination out of bounds
459 454
460 LDQuickColor tmp = quickColors[dest]; 455 LDQuickColor tmp = quickColors[dest];
461 quickColors[dest] = quickColors[idx]; 456 quickColors[dest] = quickColors[idx];
462 quickColors[idx] = tmp; 457 quickColors[idx] = tmp;
595 590
596 // ============================================================================= 591 // =============================================================================
597 // Set the path of an external program 592 // Set the path of an external program
598 // ----------------------------------------------------------------------------- 593 // -----------------------------------------------------------------------------
599 void ConfigDialog::slot_setExtProgPath() 594 void ConfigDialog::slot_setExtProgPath()
600 { const extProgInfo* info = null; 595 { const LDExtProgInfo* info = null;
601 596
602 for (const extProgInfo & it : g_extProgInfo) 597 for (const LDExtProgInfo & it : g_LDExtProgInfo)
603 { if (it.setPathButton == sender()) 598 { if (it.setPathButton == sender())
604 { info = &it; 599 { info = &it;
605 break; 600 break;
606 } 601 }
607 } 602 }

mercurial