src/configDialog.cpp

changeset 517
2b5adb45aaa5
parent 504
6a1fa662bfc1
child 526
b29b6fc45ba9
equal deleted inserted replaced
516:d3373bc7ca3b 517:2b5adb45aaa5
133 connect (ui->findDownloadPath, SIGNAL (clicked (bool)), this, SLOT (slot_findDownloadFolder())); 133 connect (ui->findDownloadPath, SIGNAL (clicked (bool)), this, SLOT (slot_findDownloadFolder()));
134 134
135 ui->m_profileName->setText (ld_defaultname); 135 ui->m_profileName->setText (ld_defaultname);
136 ui->m_profileUsername->setText (ld_defaultuser); 136 ui->m_profileUsername->setText (ld_defaultuser);
137 ui->m_profileLicense->setCurrentIndex (ld_defaultlicense); 137 ui->m_profileLicense->setCurrentIndex (ld_defaultlicense);
138 ui->tabs->setCurrentIndex (deftab);
139 138
140 initGrids(); 139 initGrids();
141 initExtProgs(); 140 initExtProgs();
141 selectPage (deftab);
142 142
143 connect (ui->buttonBox, SIGNAL (clicked (QAbstractButton*)), 143 connect (ui->buttonBox, SIGNAL (clicked (QAbstractButton*)),
144 this, SLOT (buttonClicked (QAbstractButton*))); 144 this, SLOT (buttonClicked (QAbstractButton*)));
145
146 connect (ui->m_pages, SIGNAL (currentChanged (int)),
147 this, SLOT (selectPage (int)));
148
149 connect (ui->m_pagelist, SIGNAL (currentRowChanged (int)),
150 this, SLOT (selectPage (int)));
145 } 151 }
146 152
147 // ============================================================================= 153 // =============================================================================
148 // ----------------------------------------------------------------------------- 154 // -----------------------------------------------------------------------------
149 ConfigDialog::~ConfigDialog() 155 ConfigDialog::~ConfigDialog()
150 { delete ui; 156 { delete ui;
157 }
158
159 // =============================================================================
160 // -----------------------------------------------------------------------------
161 void ConfigDialog::selectPage (int row)
162 { ui->m_pagelist->setCurrentRow (row);
163 ui->m_pages->setCurrentIndex (row);
151 } 164 }
152 165
153 // ============================================================================= 166 // =============================================================================
154 // Adds a shortcut entry to the list of shortcuts. 167 // Adds a shortcut entry to the list of shortcuts.
155 // ----------------------------------------------------------------------------- 168 // -----------------------------------------------------------------------------
177 *ylabel = new QLabel ("Y"), 190 *ylabel = new QLabel ("Y"),
178 *zlabel = new QLabel ("Z"), 191 *zlabel = new QLabel ("Z"),
179 *anglabel = new QLabel ("Angle"); 192 *anglabel = new QLabel ("Angle");
180 short i = 1; 193 short i = 1;
181 194
182 for (QLabel * label : initlist<QLabel*> ( { xlabel, ylabel, zlabel, anglabel })) 195 for (QLabel* label : initlist<QLabel*> ({xlabel, ylabel, zlabel, anglabel}))
183 { label->setAlignment (Qt::AlignCenter); 196 { label->setAlignment (Qt::AlignCenter);
184 gridlayout->addWidget (label, 0, i++); 197 gridlayout->addWidget (label, 0, i++);
185 } 198 }
186 199
187 for (int i = 0; i < g_NumGrids; ++i) 200 for (int i = 0; i < g_NumGrids; ++i)
333 346
334 if (button == dbb->button (QDDB::Ok)) 347 if (button == dbb->button (QDDB::Ok))
335 { applySettings(); 348 { applySettings();
336 accept(); 349 accept();
337 } elif (button == dbb->button (QDDB::Apply)) 350 } elif (button == dbb->button (QDDB::Apply))
338
339 { applySettings(); 351 { applySettings();
340 } elif (button == dbb->button (QDDB::Cancel)) 352 } elif (button == dbb->button (QDDB::Cancel))
341 { reject(); 353 { reject();
342 } 354 }
343 } 355 }
350 delete item; 362 delete item;
351 363
352 quickColorItems.clear(); 364 quickColorItems.clear();
353 365
354 // Init table items 366 // Init table items
355 for (LDQuickColor & entry : quickColors) 367 for (LDQuickColor& entry : quickColors)
356 { QListWidgetItem* item = new QListWidgetItem; 368 { QListWidgetItem* item = new QListWidgetItem;
357 369
358 if (entry.isSeparator()) 370 if (entry.isSeparator())
359 { item->setText ("--------"); 371 { item->setText ("--------");
360 item->setIcon (getIcon ("empty")); 372 item->setIcon (getIcon ("empty"));
515 // Finds the given list widget item in the list of widget items given. 527 // Finds the given list widget item in the list of widget items given.
516 // ----------------------------------------------------------------------------- 528 // -----------------------------------------------------------------------------
517 int ConfigDialog::getItemRow (QListWidgetItem* item, QList<QListWidgetItem*>& haystack) 529 int ConfigDialog::getItemRow (QListWidgetItem* item, QList<QListWidgetItem*>& haystack)
518 { int i = 0; 530 { int i = 0;
519 531
520 for (QListWidgetItem * it : haystack) 532 for (QListWidgetItem* it : haystack)
521 { if (it == item) 533 { if (it == item)
522 return i; 534 return i;
523 535
524 ++i; 536 ++i;
525 } 537 }
541 // Get the list of shortcuts selected 553 // Get the list of shortcuts selected
542 // ----------------------------------------------------------------------------- 554 // -----------------------------------------------------------------------------
543 QList<ShortcutListItem*> ConfigDialog::getShortcutSelection() 555 QList<ShortcutListItem*> ConfigDialog::getShortcutSelection()
544 { QList<ShortcutListItem*> out; 556 { QList<ShortcutListItem*> out;
545 557
546 for (QListWidgetItem * entry : ui->shortcutsList->selectedItems()) 558 for (QListWidgetItem* entry : ui->shortcutsList->selectedItems())
547 out << static_cast<ShortcutListItem*> (entry); 559 out << static_cast<ShortcutListItem*> (entry);
548 560
549 return out; 561 return out;
550 } 562 }
551 563
568 // Reset a shortcut to defaults 580 // Reset a shortcut to defaults
569 // ----------------------------------------------------------------------------- 581 // -----------------------------------------------------------------------------
570 void ConfigDialog::slot_resetShortcut() 582 void ConfigDialog::slot_resetShortcut()
571 { QList<ShortcutListItem*> sel = getShortcutSelection(); 583 { QList<ShortcutListItem*> sel = getShortcutSelection();
572 584
573 for (ShortcutListItem * item : sel) 585 for (ShortcutListItem* item : sel)
574 { item->keyConfig()->reset(); 586 { item->keyConfig()->reset();
575 setShortcutText (item); 587 setShortcutText (item);
576 } 588 }
577 } 589 }
578 590
580 // Remove the shortcut of an action. 592 // Remove the shortcut of an action.
581 // ----------------------------------------------------------------------------- 593 // -----------------------------------------------------------------------------
582 void ConfigDialog::slot_clearShortcut() 594 void ConfigDialog::slot_clearShortcut()
583 { QList<ShortcutListItem*> sel = getShortcutSelection(); 595 { QList<ShortcutListItem*> sel = getShortcutSelection();
584 596
585 for (ShortcutListItem * item : sel) 597 for (ShortcutListItem* item : sel)
586 { item->keyConfig()->value = QKeySequence(); 598 { item->keyConfig()->value = QKeySequence();
587 setShortcutText (item); 599 setShortcutText (item);
588 } 600 }
589 } 601 }
590 602
592 // Set the path of an external program 604 // Set the path of an external program
593 // ----------------------------------------------------------------------------- 605 // -----------------------------------------------------------------------------
594 void ConfigDialog::slot_setExtProgPath() 606 void ConfigDialog::slot_setExtProgPath()
595 { const LDExtProgInfo* info = null; 607 { const LDExtProgInfo* info = null;
596 608
597 for (const LDExtProgInfo & it : g_LDExtProgInfo) 609 for (const LDExtProgInfo& it : g_LDExtProgInfo)
598 { if (it.setPathButton == sender()) 610 { if (it.setPathButton == sender())
599 { info = &it; 611 { info = &it;
600 break; 612 break;
601 } 613 }
602 } 614 }
632 // Gets the configuration string of the quick color toolbar 644 // Gets the configuration string of the quick color toolbar
633 // ----------------------------------------------------------------------------- 645 // -----------------------------------------------------------------------------
634 str ConfigDialog::quickColorString() 646 str ConfigDialog::quickColorString()
635 { str val; 647 { str val;
636 648
637 for (const LDQuickColor & entry : quickColors) 649 for (const LDQuickColor& entry : quickColors)
638 { if (val.length() > 0) 650 { if (val.length() > 0)
639 val += ':'; 651 val += ':';
640 652
641 if (entry.isSeparator()) 653 if (entry.isSeparator())
642 val += '|'; 654 val += '|';

mercurial