From 4c3beeee65bf48cd021e92a0bdf9a2522d1ae7a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Spitzm=C3=BCller?= Date: Mon, 27 Oct 2003 07:05:07 +0000 Subject: [PATCH] qt branches: color fixes git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7981 a592a061-630c-0410-9148-cb99ea01b6c8 --- po/POTFILES.in | 1 + src/frontends/controllers/ChangeLog | 4 ++++ src/frontends/controllers/ControlDocument.C | 11 +++++++++++ src/frontends/controllers/ControlDocument.h | 2 ++ src/frontends/qt2/ChangeLog | 5 +++++ src/frontends/qt2/QDocument.C | 21 +++++++++++++++++++++ src/frontends/qt2/QDocumentDialog.C | 12 +++++------- 7 files changed, 49 insertions(+), 7 deletions(-) diff --git a/po/POTFILES.in b/po/POTFILES.in index 8954f6fa14..ee9faf7add 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -170,6 +170,7 @@ src/insets/insettoc.C src/insets/inseturl.C src/insets/insetwrap.C src/insets/render_graphic.C +src/insets/render_preview.C src/ispell.C src/kbsequence.C src/lengthcommon.C diff --git a/src/frontends/controllers/ChangeLog b/src/frontends/controllers/ChangeLog index 6d4bc5ef96..381b4087c0 100644 --- a/src/frontends/controllers/ChangeLog +++ b/src/frontends/controllers/ChangeLog @@ -1,3 +1,7 @@ +2003-10-27 Juergen Spitzmueller + + * ControlDocument.[Ch]: add method setBranchColor(). + 2003-10-13 Lars Gullik Bjønnes * ControlCommandBuffer.C (dispatch): adjust for dispatch change diff --git a/src/frontends/controllers/ControlDocument.C b/src/frontends/controllers/ControlDocument.C index e705ca4485..0088f07e9f 100644 --- a/src/frontends/controllers/ControlDocument.C +++ b/src/frontends/controllers/ControlDocument.C @@ -24,6 +24,9 @@ #include "language.h" #include "lyxtextclasslist.h" #include "paragraph.h" +#include "funcrequest.h" +#include "lfuns.h" +#include "LColor.h" #include "frontends/Alert.h" #include "frontends/LyXView.h" @@ -118,6 +121,14 @@ void ControlDocument::setLanguage() } +void ControlDocument::setBranchColor(string const & branch, string const & hex) +{ + lcolor.setColor(branch, hex); + string const s = branch + ' ' + hex; + lv_.dispatch(FuncRequest(LFUN_SET_COLOR, s)); +} + + void ControlDocument::classApply() { BufferParams & params = buffer()->params(); diff --git a/src/frontends/controllers/ControlDocument.h b/src/frontends/controllers/ControlDocument.h index 3661f93294..dcd47bfe60 100644 --- a/src/frontends/controllers/ControlDocument.h +++ b/src/frontends/controllers/ControlDocument.h @@ -34,6 +34,8 @@ public: /// void setLanguage(); /// + void setBranchColor(std::string const & branch, std::string const & hex); + /// LyXTextClass textClass(); /// BufferParams & params(); diff --git a/src/frontends/qt2/ChangeLog b/src/frontends/qt2/ChangeLog index 9fe08aba1f..ab41a47477 100644 --- a/src/frontends/qt2/ChangeLog +++ b/src/frontends/qt2/ChangeLog @@ -1,3 +1,8 @@ +2003-10-27 Juergen Spitzmueller + + * QDocument.[Ch]: + * QDocumentDialog.[Ch]: Fix color setting of branches. + 2003-10-23 Juergen Spitzmueller * Dialogs.C: diff --git a/src/frontends/qt2/QDocument.C b/src/frontends/qt2/QDocument.C index bedc1f0ee3..ffae032516 100644 --- a/src/frontends/qt2/QDocument.C +++ b/src/frontends/qt2/QDocument.C @@ -27,6 +27,7 @@ #include "support/lstrings.h" #include "lyxtextclasslist.h" #include "floatplacement.h" +#include "LColor.h" #include #include @@ -38,6 +39,7 @@ using lyx::support::bformat; +using lyx::support::getVectorFromString; using std::vector; using std::string; @@ -375,6 +377,25 @@ void QDocument::apply() 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 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.empty() || x11hexname[0] != '#') + x11hexname = lcolor.getX11Name(LColor::background); + // display the new color + controller().setBranchColor(current_branch, x11hexname); + } + } + if (branchlist_.empty()) + branchlist_ = params.branchlist(); + params.branchlist() = branchlist_; + branchlist_.clear(); } diff --git a/src/frontends/qt2/QDocumentDialog.C b/src/frontends/qt2/QDocumentDialog.C index e0f0e82a96..12876572ce 100644 --- a/src/frontends/qt2/QDocumentDialog.C +++ b/src/frontends/qt2/QDocumentDialog.C @@ -426,7 +426,6 @@ void QDocumentDialog::updateBranchView() 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 all = getVectorFromString(all_branches, "|"); @@ -445,6 +444,7 @@ void QDocumentDialog::updateBranchView() newItem->setPixmap(2, coloritem); } } + form_->branchlist_ = params.branchlist(); form_->changed(); } @@ -514,16 +514,14 @@ void QDocumentDialog::toggleBranchColor() 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(); }