]> git.lyx.org Git - lyx.git/blob - src/frontends/qt2/QDocumentDialog.C
Minipage is no more (long live the box inset)
[lyx.git] / src / frontends / qt2 / QDocumentDialog.C
1 /**
2  * \file QDocumentDialog.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Edwin Leuven
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13 #include "debug.h"
14 #include "qt_helpers.h"
15
16 #include "ControlDocument.h"
17 #include "QDocument.h"
18 #include "QDocumentDialog.h"
19
20 #include "panelstack.h"
21 #include "floatplacement.h"
22 #include "LColor.h"
23
24 #include "support/lstrings.h"
25 #include "bufferparams.h"
26 #include "lyxrc.h"
27
28 #include <qlabel.h>
29 #include <qmultilineedit.h>
30 #include <qlineedit.h>
31 #include <qlistview.h>
32 #include <qpushbutton.h>
33 #include <qradiobutton.h>
34 #include <qcheckbox.h>
35 #include <qslider.h>
36 #include <qpixmap.h>
37 #include <qcolor.h>
38 #include <qcolordialog.h>
39 #include "lengthcombo.h"
40
41 using lyx::support::token;
42 using lyx::support::getVectorFromString;
43
44 using std::vector;
45 using std::string;
46
47
48 QDocumentDialog::QDocumentDialog(QDocument * form)
49         : QDocumentDialogBase(0, 0, false, 0), form_(form)
50 {
51         connect(okPB, SIGNAL(clicked()),
52                 form, SLOT(slotOK()));
53         connect(applyPB, SIGNAL(clicked()),
54                 form, SLOT(slotApply()));
55         connect(closePB, SIGNAL(clicked()),
56                 form, SLOT(slotClose()));
57         connect(restorePB, SIGNAL(clicked()),
58                 form, SLOT(slotRestore()));
59
60         textLayoutModule = new TextLayoutModuleBase(this);
61         pageLayoutModule = new PageLayoutModuleBase(this);
62         marginsModule = new MarginsModuleBase(this);
63         langModule = new LanguageModuleBase(this);
64         bulletsModule = new BulletsModule(this);
65         numberingModule = new NumberingModuleBase(this);
66         biblioModule = new BiblioModuleBase(this);
67         mathsModule = new MathsModuleBase(this);
68         floatModule = new FloatPlacement(this, "floatplacement");
69         latexModule = new LaTeXModuleBase(this);
70         branchesModule = new BranchesModuleBase(this);
71         preambleModule = new PreambleModuleBase(this);
72
73         docPS->addPanel(latexModule, _("Document Class"));
74         docPS->addPanel(textLayoutModule, _("Text Layout"));
75         docPS->addPanel(pageLayoutModule, _("Page Layout"));
76         docPS->addPanel(marginsModule, _("Page Margins"));
77         docPS->addPanel(langModule, _("Language"));
78         docPS->addPanel(numberingModule, _("Numbering & TOC"));
79         docPS->addPanel(biblioModule, _("Bibliography"));
80         docPS->addPanel(mathsModule, _("Math options"));
81         docPS->addPanel(floatModule, _("Float Placement"));
82         docPS->addPanel(bulletsModule, _("Bullets"));
83         docPS->addPanel(branchesModule, _("Branches"));
84         docPS->addPanel(preambleModule, _("LaTeX Preamble"));
85         docPS->setCurrentPanel(_("Document Class"));
86
87         // preamble
88         connect(preambleModule->preambleMLE, SIGNAL(textChanged()), this, SLOT(change_adaptor()));
89         // biblio
90         connect(biblioModule->natbibCB, SIGNAL(toggled(bool)), this, SLOT(change_adaptor()));
91         connect(biblioModule->citeStyleCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
92         // language & quote
93         connect(langModule->singleQuoteRB, SIGNAL(toggled(bool)), this, SLOT(change_adaptor()));
94         connect(langModule->doubleQuoteRB, SIGNAL(toggled(bool)), this, SLOT(change_adaptor()));
95         connect(langModule->languageCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
96         connect(langModule->defaultencodingCB, SIGNAL(toggled(bool)), this, SLOT(change_adaptor()));
97         connect(langModule->encodingCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
98         connect(langModule->quoteStyleCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
99         // numbering
100         connect(numberingModule->depthSL, SIGNAL(valueChanged(int)), this, SLOT(change_adaptor()));
101         connect(numberingModule->tocSL, SIGNAL(valueChanged(int)), this, SLOT(change_adaptor()));
102         connect(numberingModule->depthSL, SIGNAL(valueChanged(int)), this, SLOT(updateNumbering()));
103         connect(numberingModule->tocSL, SIGNAL(valueChanged(int)), this, SLOT(updateNumbering()));
104         numberingModule->tocLV->setSorting(-1);
105         // maths
106         connect(mathsModule->amsCB, SIGNAL(toggled(bool)), this, SLOT(change_adaptor()));
107         connect(mathsModule->amsautoCB, SIGNAL(toggled(bool)), this, SLOT(change_adaptor()));
108         // float
109         connect(floatModule, SIGNAL(changed()), this, SLOT(change_adaptor()));
110         // latex class
111         connect(latexModule->classCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
112         connect(latexModule->optionsLE, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
113         connect(latexModule->psdriverCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
114         connect(latexModule->classCO, SIGNAL(activated(int)), this, SLOT(classChanged()));
115         // text layout
116         connect(textLayoutModule->fontsCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
117         connect(textLayoutModule->fontsizeCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
118         connect(textLayoutModule->lspacingCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
119         connect(textLayoutModule->lspacingCO, SIGNAL(activated(int)), this, SLOT(setLSpacing(int)));
120         connect(textLayoutModule->lspacingLE, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
121         connect(textLayoutModule->skipRB, SIGNAL(toggled(bool)), this, SLOT(change_adaptor()));
122         connect(textLayoutModule->indentRB, SIGNAL(toggled(bool)), this, SLOT(change_adaptor()));
123         connect(textLayoutModule->skipCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
124         connect(textLayoutModule->skipLE, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
125         connect(textLayoutModule->skipLengthCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
126         connect(textLayoutModule->skipCO, SIGNAL(activated(int)), this, SLOT(setSkip(int)));
127         connect(textLayoutModule->skipRB, SIGNAL(toggled(bool)), this, SLOT(enableSkip(bool)));
128         connect(textLayoutModule->twoColumnCB, SIGNAL(toggled(bool)), this, SLOT(change_adaptor()));
129
130         // margins
131         connect(marginsModule->marginCO, SIGNAL(activated(int)), this, SLOT(setCustomMargins(int)));
132         connect(marginsModule->marginCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
133         connect(marginsModule->topLE, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
134         connect(marginsModule->topUnit, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
135         connect(marginsModule->bottomLE, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
136         connect(marginsModule->bottomUnit, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
137         connect(marginsModule->innerLE, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
138         connect(marginsModule->innerUnit, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
139         connect(marginsModule->outerLE, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
140         connect(marginsModule->outerUnit, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
141         connect(marginsModule->headheightLE, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
142         connect(marginsModule->headheightUnit, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
143         connect(marginsModule->headsepLE, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
144         connect(marginsModule->headsepUnit, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
145         connect(marginsModule->footskipLE, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
146         connect(marginsModule->footskipUnit, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
147
148         // page layout
149         connect(pageLayoutModule->papersizeCO, SIGNAL(activated(int)), this, SLOT(setMargins(int)));
150         connect(pageLayoutModule->papersizeCO, SIGNAL(activated(int)), this, SLOT(setCustomPapersize(int)));
151         connect(pageLayoutModule->papersizeCO, SIGNAL(activated(int)), this, SLOT(setCustomPapersize(int)));
152         connect(pageLayoutModule->portraitRB, SIGNAL(toggled(bool)), this, SLOT(portraitChanged()));
153         connect(pageLayoutModule->papersizeCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
154         connect(pageLayoutModule->paperheightLE, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
155         connect(pageLayoutModule->paperwidthLE, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
156         connect(pageLayoutModule->paperwidthUnitCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
157         connect(pageLayoutModule->paperheightUnitCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
158         connect(pageLayoutModule->portraitRB, SIGNAL(toggled(bool)), this, SLOT(change_adaptor()));
159         connect(pageLayoutModule->landscapeRB, SIGNAL(toggled(bool)), this, SLOT(change_adaptor()));
160         connect(pageLayoutModule->facingPagesCB, SIGNAL(toggled(bool)), this, SLOT(change_adaptor()));
161         connect(pageLayoutModule->pagestyleCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
162
163         // bullets
164         connect(bulletsModule, SIGNAL(changed()), this, SLOT(change_adaptor()));
165
166         // branches
167         connect(branchesModule->addBranchPB, SIGNAL(pressed()), this, SLOT(addBranchPressed()));
168         connect(branchesModule->removePB, SIGNAL(pressed()), this, SLOT(deleteBranchPressed()));
169         connect(branchesModule->activatePB, SIGNAL(pressed()), this, SLOT(toggleBranchPressed()));
170         connect(branchesModule->branchesLV, SIGNAL(doubleClicked(QListViewItem *)), this,
171                 SLOT(branchDoubleClicked(QListViewItem *)));
172         connect(branchesModule->colorPB, SIGNAL(clicked()), this, SLOT(toggleBranchColor()));
173         branchesModule->branchesLV->setSorting(0);
174 }
175
176
177 QDocumentDialog::~QDocumentDialog()
178 {
179 }
180
181
182 void QDocumentDialog::showPreamble()
183 {
184         docPS->setCurrentPanel(_("LaTeX Preamble"));
185 }
186
187
188 void QDocumentDialog::saveDefaultClicked()
189 {
190         form_->saveDocDefault();
191 }
192
193
194 void QDocumentDialog::useDefaultsClicked()
195 {
196     form_->useClassDefaults();
197 }
198
199
200 void QDocumentDialog::change_adaptor()
201 {
202         form_->changed();
203 }
204
205
206 void QDocumentDialog::closeEvent(QCloseEvent * e)
207 {
208         form_->slotWMHide();
209         e->accept();
210 }
211
212
213 void QDocumentDialog::setLSpacing(int item)
214 {
215         textLayoutModule->lspacingLE->setEnabled(item == 3);
216 }
217
218
219 void QDocumentDialog::setSkip(int item)
220 {
221         bool const enable = (item == 3);
222         textLayoutModule->skipLE->setEnabled(enable);
223         textLayoutModule->skipLengthCO->setEnabled(enable);
224 }
225
226
227 void QDocumentDialog::enableSkip(bool skip)
228 {
229         textLayoutModule->skipCO->setEnabled(skip);
230         textLayoutModule->skipLE->setEnabled(skip);
231         textLayoutModule->skipLengthCO->setEnabled(skip);
232         if (skip)
233                 setSkip(textLayoutModule->skipCO->currentItem());
234 }
235
236 void QDocumentDialog::portraitChanged()
237 {
238         setMargins(pageLayoutModule->papersizeCO->currentItem());
239 }
240
241 void QDocumentDialog::setMargins(int papersize)
242 {
243         int olditem = marginsModule->marginCO->currentItem();
244         marginsModule->marginCO->clear();
245         marginsModule->marginCO->insertItem(qt_("Default"));
246         marginsModule->marginCO->insertItem(qt_("Custom"));
247         bool a4size = (papersize == 6 || papersize == 0
248                         && lyxrc.default_papersize == PAPER_A4PAPER);
249         if (a4size && pageLayoutModule->portraitRB->isChecked()) {
250                 marginsModule->marginCO->insertItem(qt_("Small margins"));
251                 marginsModule->marginCO->insertItem(qt_("Very small margins"));
252                 marginsModule->marginCO->insertItem(qt_("Very wide margins"));
253         } else if (olditem > 1) {
254                 olditem = 0;
255         }
256         marginsModule->marginCO->setCurrentItem(olditem);
257         setCustomMargins(olditem);
258 }
259
260
261 void QDocumentDialog::setCustomPapersize(int papersize)
262 {
263         bool const custom = (papersize == 1);
264
265         pageLayoutModule->paperwidthL->setEnabled(custom);
266         pageLayoutModule->paperwidthLE->setEnabled(custom);
267         pageLayoutModule->paperwidthUnitCO->setEnabled(custom);
268         pageLayoutModule->paperheightL->setEnabled(custom);
269         pageLayoutModule->paperheightLE->setEnabled(custom);
270         pageLayoutModule->paperheightLE->setFocus();
271         pageLayoutModule->paperheightUnitCO->setEnabled(custom);
272 }
273
274
275 void QDocumentDialog::setCustomMargins(int margin)
276 {
277         bool const custom = (margin == 1);
278
279         marginsModule->topL->setEnabled(custom);
280         marginsModule->topLE->setEnabled(custom);
281         marginsModule->topUnit->setEnabled(custom);
282
283         marginsModule->bottomL->setEnabled(custom);
284         marginsModule->bottomLE->setEnabled(custom);
285         marginsModule->bottomUnit->setEnabled(custom);
286
287         marginsModule->innerL->setEnabled(custom);
288         marginsModule->innerLE->setEnabled(custom);
289         marginsModule->innerUnit->setEnabled(custom);
290
291         marginsModule->outerL->setEnabled(custom);
292         marginsModule->outerLE->setEnabled(custom);
293         marginsModule->outerUnit->setEnabled(custom);
294
295         marginsModule->headheightL->setEnabled(custom);
296         marginsModule->headheightLE->setEnabled(custom);
297         marginsModule->headheightUnit->setEnabled(custom);
298
299         marginsModule->headsepL->setEnabled(custom);
300         marginsModule->headsepLE->setEnabled(custom);
301         marginsModule->headsepUnit->setEnabled(custom);
302
303         marginsModule->footskipL->setEnabled(custom);
304         marginsModule->footskipLE->setEnabled(custom);
305         marginsModule->footskipUnit->setEnabled(custom);
306 }
307
308
309 void QDocumentDialog::updateFontsize(string const & items, string const & sel)
310 {
311         textLayoutModule->fontsizeCO->clear();
312         textLayoutModule->fontsizeCO->insertItem("default");
313
314         for (int n = 0; !token(items,'|',n).empty(); ++n)
315                 textLayoutModule->fontsizeCO->
316                         insertItem(toqstr(token(items,'|',n)));
317
318         for (int n = 0; n<textLayoutModule->fontsizeCO->count(); ++n) {
319                 if (fromqstr(textLayoutModule->fontsizeCO->text(n)) == sel) {
320                         textLayoutModule->fontsizeCO->setCurrentItem(n);
321                         break;
322                 }
323         }
324 }
325
326
327 void QDocumentDialog::updatePagestyle(string const & items, string const & sel)
328 {
329         pageLayoutModule->pagestyleCO->clear();
330         pageLayoutModule->pagestyleCO->insertItem("default");
331
332         for (int n=0; !token(items,'|',n).empty(); ++n)
333                 pageLayoutModule->pagestyleCO->
334                         insertItem(toqstr(token(items,'|',n)));
335
336         for (int n = 0; n<pageLayoutModule->pagestyleCO->count(); ++n) {
337                 if (fromqstr(pageLayoutModule->pagestyleCO->text(n))==sel) {
338                         pageLayoutModule->pagestyleCO->setCurrentItem(n);
339                         break;
340                 }
341         }
342 }
343
344
345 void QDocumentDialog::classChanged()
346 {
347         ControlDocument & cntrl = form_->controller();
348         BufferParams & params = cntrl.params();
349
350         lyx::textclass_type const tc = latexModule->classCO->currentItem();
351
352         if (form_->controller().loadTextclass(tc)) {
353                 params.textclass = tc;
354
355                 if (lyxrc.auto_reset_options) {
356                         params.useClassDefaults();
357                         form_->update_contents();
358                 } else {
359                         updateFontsize(cntrl.textClass().opt_fontsize(),
360                                        params.fontsize);
361
362                         updatePagestyle(cntrl.textClass().opt_pagestyle(),
363                                         params.pagestyle);
364                 }
365         } else {
366                 latexModule->classCO->setCurrentItem(params.textclass);
367         }
368 }
369
370
371 void QDocumentDialog::updateNumbering()
372 {
373         int const depth = numberingModule->depthSL->value();
374         int const toc = numberingModule->tocSL->value();
375         QListViewItem * partitem = numberingModule->tocLV->firstChild();
376         QListViewItem * chapteritem = partitem->nextSibling();
377         QListViewItem * sectionitem = chapteritem->nextSibling();
378         QListViewItem * subsectionitem = sectionitem->nextSibling();
379         QListViewItem * subsubsectionitem = subsectionitem->nextSibling();
380         QListViewItem * paragraphitem = subsubsectionitem->nextSibling();
381         QListViewItem * subparagraphitem = paragraphitem->nextSibling();
382
383         QString const no = qt_("No");
384         QString const yes = qt_("Yes");
385
386         //numberingModule->tocLV->setUpdatesEnabled(false);
387
388         partitem->setText(1, yes);
389         chapteritem->setText(1, yes);
390         sectionitem->setText(1, yes);
391         subsectionitem->setText(1, yes);
392         subsubsectionitem->setText(1, yes);
393         paragraphitem->setText(1, yes);
394         subparagraphitem->setText(1, yes);
395         partitem->setText(2, yes);
396         chapteritem->setText(2, yes);
397         sectionitem->setText(2, yes);
398         subsectionitem->setText(2, yes);
399         subsubsectionitem->setText(2, yes);
400         paragraphitem->setText(2, yes);
401         subparagraphitem->setText(2, yes);
402
403         // numbering
404         if (depth < -1) partitem->setText(1, no);
405         if (depth < 0) chapteritem->setText(1, no);
406         if (depth < 1) sectionitem->setText(1, no);
407         if (depth < 2) subsectionitem->setText(1, no);
408         if (depth < 3) subsubsectionitem->setText(1, no);
409         if (depth < 4) paragraphitem->setText(1, no);
410         if (depth < 5) subparagraphitem->setText(1, no);
411
412         // in toc
413         if (toc < 0) chapteritem->setText(2, no);
414         if (toc < 1) sectionitem->setText(2, no);
415         if (toc < 2) subsectionitem->setText(2, no);
416         if (toc < 3) subsubsectionitem->setText(2, no);
417         if (toc < 4) paragraphitem->setText(2, no);
418         if (toc < 5) subparagraphitem->setText(2, no);
419
420         //numberingModule->tocLV->setUpdatesEnabled(true);
421         //numberingModule->tocLV->update();
422 }
423
424
425 void QDocumentDialog::updateBranchView()
426 {
427         ControlDocument & cntrl = form_->controller();
428         BufferParams & params = cntrl.params();
429
430         string const all_branches = params.branchlist().allBranches();
431         branchesModule->branchesLV->clear();
432         if (!all_branches.empty()) {
433                 std::vector<string> all = getVectorFromString(all_branches, "|");
434                 for (unsigned i = 0; i < all.size(); ++i) {
435                         QString const bname = toqstr(all[i].c_str());
436                         QString const sel =
437                                 (params.branchlist().selected(fromqstr(bname))) ? qt_("Yes") : qt_("No");
438                         QListViewItem * newItem =
439                                 new QListViewItem(branchesModule->branchesLV, bname, sel);
440                         QColor itemcolor;
441                         string x11hexname = params.branchlist().getColor(fromqstr(bname));
442                         if (x11hexname[0] == '#')
443                                 itemcolor.setNamedColor(toqstr(x11hexname));
444                         if (itemcolor.isValid()) {
445                                 QPixmap coloritem(30, 10);
446                                 coloritem.fill(itemcolor);
447                                 newItem->setPixmap(2, coloritem);
448                         }
449                 }
450         }
451         form_->branchlist_ = params.branchlist();
452         form_->changed();
453 }
454
455
456 void QDocumentDialog::addBranchPressed()
457 {
458         ControlDocument & cntrl = form_->controller();
459         BufferParams & params = cntrl.params();
460
461         QString const new_branch = branchesModule->newBranchLE->text();
462         if (!new_branch.isEmpty()) {
463                 params.branchlist().add(fromqstr(new_branch));
464                 branchesModule->newBranchLE->clear();
465                 updateBranchView();
466         }
467 }
468
469
470 void QDocumentDialog::deleteBranchPressed()
471 {
472         ControlDocument & cntrl = form_->controller();
473         BufferParams & params = cntrl.params();
474
475         QListViewItem * selItem =
476                 branchesModule->branchesLV->selectedItem();
477         QString sel_branch;
478         if (selItem != 0)
479                 sel_branch = selItem->text(0);
480         if (sel_branch) {
481                 params.branchlist().remove(fromqstr(sel_branch));
482                 branchesModule->newBranchLE->clear();
483                 updateBranchView();
484         }
485 }
486
487
488 void QDocumentDialog::toggleBranchPressed()
489 {
490         QListViewItem * selItem =
491                 branchesModule->branchesLV->selectedItem();
492         toggleBranch(selItem);
493 }
494
495
496 void QDocumentDialog::branchDoubleClicked(QListViewItem * selItem)
497 {
498         toggleBranch(selItem);
499 }
500
501
502 void QDocumentDialog::toggleBranch(QListViewItem * selItem)
503 {
504         ControlDocument & cntrl = form_->controller();
505         BufferParams & params = cntrl.params();
506
507         QString sel_branch;
508         if (selItem != 0)
509                 sel_branch = selItem->text(0);
510         if (sel_branch) {
511                 bool selected = false;
512                 if (selItem->text(1) == qt_("Yes"))
513                         selected = true;
514                 params.branchlist().setSelected(fromqstr(sel_branch), !selected);
515                 branchesModule->newBranchLE->clear();
516                 updateBranchView();
517         }
518 }
519
520
521 void QDocumentDialog::toggleBranchColor()
522 {
523         ControlDocument & cntrl = form_->controller();
524         BufferParams & params = cntrl.params();
525
526         QListViewItem * selItem =
527                 branchesModule->branchesLV->selectedItem();
528         QString sel_branch;
529         if (selItem != 0)
530                 sel_branch = selItem->text(0);
531         if (sel_branch) {
532                 QColor initial;
533                 string current_branch = fromqstr(sel_branch);
534                 string x11hexname = params.branchlist().getColor(current_branch);
535                 if (x11hexname[0] == '#')
536                         initial.setNamedColor(toqstr(x11hexname));
537                 QColor ncol(QColorDialog::getColor(initial));
538                 if (ncol.isValid()){
539                         // add the color to the branchlist
540                         params.branchlist().setColor(current_branch, fromqstr(ncol.name()));
541                         branchesModule->newBranchLE->clear();
542                         updateBranchView();
543                 }
544         }
545 }