Juergen Spitzmueller wrote: > Attached is a fix for the branches color issues in qt (1. branches color > was not immediately updated, buffer reload was necessary; 2. new branches > had black background). Everything works as expected now.
*Sigh* Please try this one. I don't think a LyXName -> LColor -> LyXName cycle is necessary. Jürgen.
Index: src/frontends/controllers/ControlDocument.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/controllers/ControlDocument.C,v retrieving revision 1.41 diff -u -r1.41 ControlDocument.C --- src/frontends/controllers/ControlDocument.C 6 Oct 2003 15:42:45 -0000 1.41 +++ src/frontends/controllers/ControlDocument.C 25 Oct 2003 13:31:04 -0000 @@ -24,6 +24,8 @@ #include "language.h" #include "lyxtextclasslist.h" #include "paragraph.h" +#include "funcrequest.h" +#include "lfuns.h" #include "frontends/Alert.h" #include "frontends/LyXView.h" @@ -115,6 +117,13 @@ else lv_.buffer()->updateDocLang(newL); } +} + + +void ControlDocument::setBranchColor(string const & branch, string const & hex) +{ + string const s = branch + ' ' + hex; + lv_.dispatch(FuncRequest(LFUN_SET_COLOR, s)); } Index: src/frontends/controllers/ControlDocument.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/controllers/ControlDocument.h,v retrieving revision 1.9 diff -u -r1.9 ControlDocument.h --- src/frontends/controllers/ControlDocument.h 9 Sep 2003 11:24:22 -0000 1.9 +++ src/frontends/controllers/ControlDocument.h 25 Oct 2003 13:31:04 -0000 @@ -34,6 +34,8 @@ /// void setLanguage(); /// + void setBranchColor(std::string const & branch, std::string const & hex); + /// LyXTextClass textClass(); /// BufferParams & params(); Index: src/frontends/qt2/QDocument.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/qt2/QDocument.C,v retrieving revision 1.61 diff -u -r1.61 QDocument.C --- src/frontends/qt2/QDocument.C 23 Oct 2003 11:58:00 -0000 1.61 +++ src/frontends/qt2/QDocument.C 25 Oct 2003 13:31:06 -0000 @@ -27,6 +27,7 @@ #include "support/lstrings.h" #include "lyxtextclasslist.h" #include "floatplacement.h" +#include "LColor.h" #include <qpushbutton.h> #include <qmultilineedit.h> @@ -38,6 +39,7 @@ using lyx::support::bformat; +using lyx::support::getVectorFromString; using std::vector; using std::string; @@ -375,6 +377,26 @@ params.headsep = widgetsToLength(m->headsepLE, m->headsepUnit); params.footskip = widgetsToLength(m->footskipLE, m->footskipUnit); + + // branches + string const all_branches = params.branchlist().allBranches(); + if (!all_branches.empty()) { + std::vector<string> all = getVectorFromString(all_branches, "|"); + for (unsigned i = 0; i < all.size(); ++i) { + string const current_branch = all[i].c_str(); + string x11hexname = params.branchlist().getColor(current_branch); + // check that we have a valid color! + if (x11hexname[0] != '#') + x11hexname = lcolor.getX11Name(LColor::background); + lcolor.setColor(current_branch, x11hexname); + // display the new color + controller().setBranchColor(current_branch, x11hexname); + } + } + if (branchlist_.empty()) + branchlist_ = params.branchlist(); + params.branchlist() = branchlist_; + branchlist_.clear(); } Index: src/frontends/qt2/QDocumentDialog.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/qt2/QDocumentDialog.C,v retrieving revision 1.39 diff -u -r1.39 QDocumentDialog.C --- src/frontends/qt2/QDocumentDialog.C 23 Oct 2003 11:58:00 -0000 1.39 +++ src/frontends/qt2/QDocumentDialog.C 25 Oct 2003 13:31:07 -0000 @@ -426,7 +426,6 @@ BufferParams & params = cntrl.params(); string const all_branches = params.branchlist().allBranches(); - string const all_selected = params.branchlist().allSelected(); branchesModule->branchesLV->clear(); if (!all_branches.empty()) { std::vector<string> all = getVectorFromString(all_branches, "|"); @@ -445,6 +444,7 @@ newItem->setPixmap(2, coloritem); } } + form_->branchlist_ = params.branchlist(); form_->changed(); } @@ -514,16 +514,14 @@ sel_branch = selItem->text(0); if (sel_branch) { QColor initial; - string x11hexname = params.branchlist().getColor(fromqstr(sel_branch)); + string current_branch = fromqstr(sel_branch); + string x11hexname = params.branchlist().getColor(current_branch); if (x11hexname[0] == '#') initial.setNamedColor(toqstr(x11hexname)); QColor ncol(QColorDialog::getColor(initial)); if (ncol.isValid()){ - // FIXME: The color does not apply unless buffer restart - // XForms has this hack. What can we do? - // lyxColorHandler->getGCForeground(c); - // lyxColorHandler->updateColor(c); - params.branchlist().setColor(fromqstr(sel_branch), fromqstr(ncol.name())); + // add the color to the branchlist + params.branchlist().setColor(current_branch, fromqstr(ncol.name())); branchesModule->newBranchLE->clear(); updateBranchView(); }