--- a/src/configDialog.cc Tue Jan 07 08:26:15 2014 +0200 +++ b/src/configDialog.cc Tue Jan 07 08:53:27 2014 +0200 @@ -115,7 +115,8 @@ int i = 0; for (QAction* act : g_win->findChildren<QAction*>()) - { KeySequenceConfig* cfg = g_win->shortcutForAction (act); + { + KeySequenceConfig* cfg = g_win->shortcutForAction (act); if (cfg) addShortcut (*cfg, act, i); @@ -165,13 +166,15 @@ // ============================================================================= // ----------------------------------------------------------------------------- ConfigDialog::~ConfigDialog() -{ delete ui; +{ + delete ui; } // ============================================================================= // ----------------------------------------------------------------------------- void ConfigDialog::selectPage (int row) -{ ui->m_pagelist->setCurrentRow (row); +{ + ui->m_pagelist->setCurrentRow (row); ui->m_pages->setCurrentIndex (row); } @@ -179,7 +182,8 @@ // Adds a shortcut entry to the list of shortcuts. // ----------------------------------------------------------------------------- void ConfigDialog::addShortcut (KeySequenceConfig& cfg, QAction* act, int& i) -{ ShortcutListItem* item = new ShortcutListItem; +{ + ShortcutListItem* item = new ShortcutListItem; item->setIcon (act->icon()); item->setKeyConfig (&cfg); item->setAction (act); @@ -197,7 +201,8 @@ // Initializes the table of grid stuff // ----------------------------------------------------------------------------- void ConfigDialog::initGrids() -{ QGridLayout* gridlayout = new QGridLayout; +{ + QGridLayout* gridlayout = new QGridLayout; QLabel* xlabel = new QLabel ("X"), *ylabel = new QLabel ("Y"), *zlabel = new QLabel ("Z"), @@ -205,12 +210,14 @@ int i = 1; for (QLabel* label : initlist<QLabel*> ({xlabel, ylabel, zlabel, anglabel})) - { label->setAlignment (Qt::AlignCenter); + { + label->setAlignment (Qt::AlignCenter); gridlayout->addWidget (label, 0, i++); } for (int i = 0; i < g_NumGrids; ++i) - { // Icon + { + // Icon lb_gridIcons[i] = new QLabel; lb_gridIcons[i]->setPixmap (getIcon (fmt ("grid-%1", str (g_GridInfo[i].name).toLower()))); @@ -224,7 +231,8 @@ // Add the widgets for (int j = 0; j < 4; ++j) - { dsb_gridData[i][j] = new QDoubleSpinBox; + { + dsb_gridData[i][j] = new QDoubleSpinBox; // Set the maximum angle if (j == 3) @@ -241,7 +249,8 @@ // ============================================================================= // ----------------------------------------------------------------------------- static struct LDExtProgInfo -{ const str name, +{ + const str name, iconname; str* const path; QLineEdit* input; @@ -270,11 +279,13 @@ // Initializes the stuff in the ext programs tab // ----------------------------------------------------------------------------- void ConfigDialog::initExtProgs() -{ QGridLayout* pathsLayout = new QGridLayout; +{ + QGridLayout* pathsLayout = new QGridLayout; int row = 0; for (LDExtProgInfo& info : g_LDExtProgInfo) - { QLabel* icon = new QLabel, + { + QLabel* icon = new QLabel, *progLabel = new QLabel (info.name); QLineEdit* input = new QLineEdit; QPushButton* setPathButton = new QPushButton; @@ -309,7 +320,8 @@ // Set the settings based on widget data. // ----------------------------------------------------------------------------- void ConfigDialog::applySettings() -{ // Apply configuration +{ + // Apply configuration lv_colorize = ui->colorizeObjects->isChecked(); gl_colorbfc = ui->colorBFC->isChecked(); gl_blackedges = ui->blackEdges->isChecked(); @@ -340,7 +352,8 @@ // Ext program settings for (const LDExtProgInfo& info : g_LDExtProgInfo) - { *info.path = info.input->text(); + { + *info.path = info.input->text(); #ifndef _WIN32 *info.wine = info.wineBox->isChecked(); @@ -360,16 +373,20 @@ // A dialog button was clicked // ----------------------------------------------------------------------------- void ConfigDialog::buttonClicked (QAbstractButton* button) -{ typedef QDialogButtonBox QDDB; +{ + typedef QDialogButtonBox QDDB; QDialogButtonBox* dbb = ui->buttonBox; if (button == dbb->button (QDDB::Ok)) - { applySettings(); + { + applySettings(); accept(); } elif (button == dbb->button (QDDB::Apply)) - { applySettings(); + { + applySettings(); } elif (button == dbb->button (QDDB::Cancel)) - { reject(); + { + reject(); } } @@ -377,28 +394,34 @@ // Update the list of color toolbar items in the quick color tab. // ----------------------------------------------------------------------------- void ConfigDialog::updateQuickColorList (LDQuickColor* sel) -{ for (QListWidgetItem * item : quickColorItems) +{ + for (QListWidgetItem * item : quickColorItems) delete item; quickColorItems.clear(); // Init table items for (LDQuickColor& entry : quickColors) - { QListWidgetItem* item = new QListWidgetItem; + { + QListWidgetItem* item = new QListWidgetItem; if (entry.isSeparator()) - { item->setText ("--------"); + { + item->setText ("--------"); item->setIcon (getIcon ("empty")); } else - { LDColor* col = entry.getColor(); + { + LDColor* col = entry.getColor(); if (col == null) - { item->setText ("[[unknown color]]"); + { + item->setText ("[[unknown color]]"); item->setIcon (getIcon ("error")); } else - { item->setText (col->name); + { + item->setText (col->name); item->setIcon (makeColorIcon (col, 16)); } } @@ -407,7 +430,8 @@ quickColorItems << item; if (sel && &entry == sel) - { ui->quickColorList->setCurrentItem (item); + { + ui->quickColorList->setCurrentItem (item); ui->quickColorList->scrollToItem (item); } } @@ -417,12 +441,14 @@ // Quick colors: add or edit button was clicked. // ----------------------------------------------------------------------------- void ConfigDialog::slot_setColor() -{ LDQuickColor* entry = null; +{ + LDQuickColor* entry = null; QListWidgetItem* item = null; const bool isNew = static_cast<QPushButton*> (sender()) == ui->quickColor_add; if (isNew == false) - { item = getSelectedQuickColor(); + { + item = getSelectedQuickColor(); if (!item) return; @@ -443,7 +469,8 @@ if (entry) entry->setColor (getColor (val)); else - { LDQuickColor entry (getColor (val), null); + { + LDQuickColor entry (getColor (val), null); item = getSelectedQuickColor(); int idx = (item) ? getItemRow (item, quickColorItems) + 1 : quickColorItems.size(); @@ -459,7 +486,8 @@ // Remove a quick color // ----------------------------------------------------------------------------- void ConfigDialog::slot_delColor() -{ if (ui->quickColorList->selectedItems().isEmpty()) +{ + if (ui->quickColorList->selectedItems().isEmpty()) return; QListWidgetItem* item = ui->quickColorList->selectedItems() [0]; @@ -471,7 +499,8 @@ // Move a quick color up/down // ----------------------------------------------------------------------------- void ConfigDialog::slot_moveColor() -{ const bool up = (static_cast<QPushButton*> (sender()) == ui->quickColor_moveUp); +{ + const bool up = (static_cast<QPushButton*> (sender()) == ui->quickColor_moveUp); if (ui->quickColorList->selectedItems().isEmpty()) return; @@ -494,7 +523,8 @@ // Add a separator to quick colors // ----------------------------------------------------------------------------- void ConfigDialog::slot_addColorSeparator() -{ quickColors << LDQuickColor::getSeparator(); +{ + quickColors << LDQuickColor::getSeparator(); updateQuickColorList (&quickColors[quickColors.size() - 1]); } @@ -502,7 +532,8 @@ // Clear all quick colors // ----------------------------------------------------------------------------- void ConfigDialog::slot_clearColors() -{ quickColors.clear(); +{ + quickColors.clear(); updateQuickColorList(); } @@ -510,10 +541,12 @@ // Pick a color and set the appropriate configuration option. // ----------------------------------------------------------------------------- void ConfigDialog::pickColor (str& conf, QPushButton* button) -{ QColor col = QColorDialog::getColor (QColor (conf)); +{ + QColor col = QColorDialog::getColor (QColor (conf)); if (col.isValid()) - { int r = col.red(), + { + int r = col.red(), g = col.green(), b = col.blue(); @@ -527,26 +560,30 @@ // ============================================================================= // ----------------------------------------------------------------------------- void ConfigDialog::slot_setGLBackground() -{ pickColor (gl_bgcolor, ui->backgroundColorButton); +{ + pickColor (gl_bgcolor, ui->backgroundColorButton); } // ============================================================================= // ----------------------------------------------------------------------------- void ConfigDialog::slot_setGLForeground() -{ pickColor (gl_maincolor, ui->mainColorButton); +{ + pickColor (gl_maincolor, ui->mainColorButton); } // ============================================================================= // ----------------------------------------------------------------------------- void ConfigDialog::slot_setGLSelectColor() -{ pickColor (gl_selectcolor, ui->selColorButton); +{ + pickColor (gl_selectcolor, ui->selColorButton); } // ============================================================================= // Sets background color of a given button. // ----------------------------------------------------------------------------- void ConfigDialog::setButtonBackground (QPushButton* button, str value) -{ button->setIcon (getIcon ("colorselect")); +{ + button->setIcon (getIcon ("colorselect")); button->setAutoFillBackground (true); button->setStyleSheet (fmt ("background-color: %1", value)); } @@ -555,10 +592,12 @@ // Finds the given list widget item in the list of widget items given. // ----------------------------------------------------------------------------- int ConfigDialog::getItemRow (QListWidgetItem* item, QList<QListWidgetItem*>& haystack) -{ int i = 0; +{ + int i = 0; for (QListWidgetItem* it : haystack) - { if (it == item) + { + if (it == item) return i; ++i; @@ -571,7 +610,8 @@ // Which quick color is currently selected? // ----------------------------------------------------------------------------- QListWidgetItem* ConfigDialog::getSelectedQuickColor() -{ if (ui->quickColorList->selectedItems().isEmpty()) +{ + if (ui->quickColorList->selectedItems().isEmpty()) return null; return ui->quickColorList->selectedItems() [0]; @@ -581,7 +621,8 @@ // Get the list of shortcuts selected // ----------------------------------------------------------------------------- QList<ShortcutListItem*> ConfigDialog::getShortcutSelection() -{ QList<ShortcutListItem*> out; +{ + QList<ShortcutListItem*> out; for (QListWidgetItem* entry : ui->shortcutsList->selectedItems()) out << static_cast<ShortcutListItem*> (entry); @@ -593,7 +634,8 @@ // Edit the shortcut of a given action. // ----------------------------------------------------------------------------- void ConfigDialog::slot_setShortcut() -{ QList<ShortcutListItem*> sel = getShortcutSelection(); +{ + QList<ShortcutListItem*> sel = getShortcutSelection(); if (sel.size() < 1) return; @@ -608,10 +650,12 @@ // Reset a shortcut to defaults // ----------------------------------------------------------------------------- void ConfigDialog::slot_resetShortcut() -{ QList<ShortcutListItem*> sel = getShortcutSelection(); +{ + QList<ShortcutListItem*> sel = getShortcutSelection(); for (ShortcutListItem* item : sel) - { item->getKeyConfig()->reset(); + { + item->getKeyConfig()->reset(); setShortcutText (item); } } @@ -620,10 +664,12 @@ // Remove the shortcut of an action. // ----------------------------------------------------------------------------- void ConfigDialog::slot_clearShortcut() -{ QList<ShortcutListItem*> sel = getShortcutSelection(); +{ + QList<ShortcutListItem*> sel = getShortcutSelection(); for (ShortcutListItem* item : sel) - { item->getKeyConfig()->setValue (QKeySequence()); + { + item->getKeyConfig()->setValue (QKeySequence()); setShortcutText (item); } } @@ -632,11 +678,14 @@ // Set the path of an external program // ----------------------------------------------------------------------------- void ConfigDialog::slot_setExtProgPath() -{ const LDExtProgInfo* info = null; +{ + const LDExtProgInfo* info = null; for (const LDExtProgInfo& it : g_LDExtProgInfo) - { if (it.setPathButton == sender()) - { info = ⁢ + { + if (it.setPathButton == sender()) + { + info = ⁢ break; } } @@ -654,7 +703,8 @@ // '...' button pressed for the download path // ----------------------------------------------------------------------------- void ConfigDialog::slot_findDownloadFolder() -{ str dpath = QFileDialog::getExistingDirectory(); +{ + str dpath = QFileDialog::getExistingDirectory(); ui->downloadPath->setText (dpath); } @@ -662,7 +712,8 @@ // Updates the text string for a given shortcut list item // ----------------------------------------------------------------------------- void ConfigDialog::setShortcutText (ShortcutListItem* item) -{ QAction* act = item->getAction(); +{ + QAction* act = item->getAction(); str label = act->iconText(); str keybind = item->getKeyConfig()->getValue().toString(); item->setText (fmt ("%1 (%2)", label, keybind)); @@ -672,10 +723,12 @@ // Gets the configuration string of the quick color toolbar // ----------------------------------------------------------------------------- str ConfigDialog::quickColorString() -{ str val; +{ + str val; for (const LDQuickColor& entry : quickColors) - { if (val.length() > 0) + { + if (val.length() > 0) val += ':'; if (entry.isSeparator()) @@ -696,7 +749,8 @@ // =============================================================================================== KeySequenceDialog::KeySequenceDialog (QKeySequence seq, QWidget* parent, Qt::WindowFlags f) : QDialog (parent, f), seq (seq) -{ lb_output = new QLabel; +{ + lb_output = new QLabel; IMPLEMENT_DIALOG_BUTTONS setWhatsThis (tr ("Into this dialog you can input a key sequence for use as a " @@ -714,7 +768,8 @@ // ============================================================================= // ----------------------------------------------------------------------------- bool KeySequenceDialog::staticDialog (KeySequenceConfig* cfg, QWidget* parent) -{ KeySequenceDialog dlg (cfg->getValue(), parent); +{ + KeySequenceDialog dlg (cfg->getValue(), parent); if (dlg.exec() == false) return false; @@ -726,7 +781,8 @@ // ============================================================================= // ----------------------------------------------------------------------------- void KeySequenceDialog::updateOutput() -{ str shortcut = seq.toString(); +{ + str shortcut = seq.toString(); if (seq == QKeySequence()) shortcut = "<empty>"; @@ -738,6 +794,7 @@ // ============================================================================= // ----------------------------------------------------------------------------- void KeySequenceDialog::keyPressEvent (QKeyEvent* ev) -{ seq = ev->key() + ev->modifiers(); +{ + seq = ev->key() + ev->modifiers(); updateOutput(); }