]> git.lyx.org Git - features.git/commitdiff
qt branches: color fixes
authorJürgen Spitzmüller <spitz@lyx.org>
Mon, 27 Oct 2003 07:05:07 +0000 (07:05 +0000)
committerJürgen Spitzmüller <spitz@lyx.org>
Mon, 27 Oct 2003 07:05:07 +0000 (07:05 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7981 a592a061-630c-0410-9148-cb99ea01b6c8

po/POTFILES.in
src/frontends/controllers/ChangeLog
src/frontends/controllers/ControlDocument.C
src/frontends/controllers/ControlDocument.h
src/frontends/qt2/ChangeLog
src/frontends/qt2/QDocument.C
src/frontends/qt2/QDocumentDialog.C

index 8954f6fa14fcbd9e24095aac6408222f945ae586..ee9faf7addc90dd93cb78f08a066bb2a32048ffb 100644 (file)
@@ -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
index 6d4bc5ef96c6e3624e514576aeaff389951e61fe..381b4087c0cdbd044652608a9033bb93c2613b74 100644 (file)
@@ -1,3 +1,7 @@
+2003-10-27  Juergen Spitzmueller  <j.spitzmueller@gmx.de>
+
+       * ControlDocument.[Ch]: add method setBranchColor().
+
 2003-10-13  Lars Gullik Bjønnes  <larsbj@gullik.net>
 
        * ControlCommandBuffer.C (dispatch): adjust for dispatch change
index e705ca4485391b9285ceccb27262ce6e6553371b..0088f07e9f9c4437cd62ef61c827b02c5bef0038 100644 (file)
@@ -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();
index 3661f93294b4c289d684a096f9053f9c5e5706c4..dcd47bfe60840825931246f789e8497e8f724ce2 100644 (file)
@@ -34,6 +34,8 @@ public:
        ///
        void setLanguage();
        ///
+       void setBranchColor(std::string const & branch, std::string const & hex);
+       ///
        LyXTextClass textClass();
        ///
        BufferParams & params();
index 9fe08aba1fbe1d10bb21e1ce6fa25213ff05c08c..ab41a4747731cc82db81e5b13fb806b5d9d20a1a 100644 (file)
@@ -1,3 +1,8 @@
+2003-10-27  Juergen Spitzmueller  <j.spitzmueller@gmx.de>
+
+       * QDocument.[Ch]:
+       * QDocumentDialog.[Ch]: Fix color setting of branches.
+
 2003-10-23  Juergen Spitzmueller  <j.spitzmueller@gmx.de>
 
        * Dialogs.C:
index bedc1f0ee302ed5a51decb6dabf10a15da59f0a5..ffae032516d434b7969b6ef32abf249bcb292039 100644 (file)
@@ -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,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<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.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();
 }
 
 
index e0f0e82a96db5e0da45fc4d11f8de1a68f66173d..12876572cebe5b37f26c53cf58473c86e04c6dfd 100644 (file)
@@ -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<string> 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();
                }