qt branches: color fixes

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7981 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jürgen Spitzmüller 2003-10-27 07:05:07 +00:00
parent afc9aaf6eb
commit 4c3beeee65
7 changed files with 49 additions and 7 deletions

View File

@ -170,6 +170,7 @@ src/insets/insettoc.C
src/insets/inseturl.C src/insets/inseturl.C
src/insets/insetwrap.C src/insets/insetwrap.C
src/insets/render_graphic.C src/insets/render_graphic.C
src/insets/render_preview.C
src/ispell.C src/ispell.C
src/kbsequence.C src/kbsequence.C
src/lengthcommon.C src/lengthcommon.C

View 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> 2003-10-13 Lars Gullik Bjønnes <larsbj@gullik.net>
* ControlCommandBuffer.C (dispatch): adjust for dispatch change * ControlCommandBuffer.C (dispatch): adjust for dispatch change

View File

@ -24,6 +24,9 @@
#include "language.h" #include "language.h"
#include "lyxtextclasslist.h" #include "lyxtextclasslist.h"
#include "paragraph.h" #include "paragraph.h"
#include "funcrequest.h"
#include "lfuns.h"
#include "LColor.h"
#include "frontends/Alert.h" #include "frontends/Alert.h"
#include "frontends/LyXView.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() void ControlDocument::classApply()
{ {
BufferParams & params = buffer()->params(); BufferParams & params = buffer()->params();

View File

@ -34,6 +34,8 @@ public:
/// ///
void setLanguage(); void setLanguage();
/// ///
void setBranchColor(std::string const & branch, std::string const & hex);
///
LyXTextClass textClass(); LyXTextClass textClass();
/// ///
BufferParams & params(); BufferParams & params();

View 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> 2003-10-23 Juergen Spitzmueller <j.spitzmueller@gmx.de>
* Dialogs.C: * Dialogs.C:

View File

@ -27,6 +27,7 @@
#include "support/lstrings.h" #include "support/lstrings.h"
#include "lyxtextclasslist.h" #include "lyxtextclasslist.h"
#include "floatplacement.h" #include "floatplacement.h"
#include "LColor.h"
#include <qpushbutton.h> #include <qpushbutton.h>
#include <qmultilineedit.h> #include <qmultilineedit.h>
@ -38,6 +39,7 @@
using lyx::support::bformat; using lyx::support::bformat;
using lyx::support::getVectorFromString;
using std::vector; using std::vector;
using std::string; using std::string;
@ -375,6 +377,25 @@ void QDocument::apply()
params.headsep = widgetsToLength(m->headsepLE, m->headsepUnit); params.headsep = widgetsToLength(m->headsepLE, m->headsepUnit);
params.footskip = widgetsToLength(m->footskipLE, m->footskipUnit); 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();
} }

View File

@ -426,7 +426,6 @@ void QDocumentDialog::updateBranchView()
BufferParams & params = cntrl.params(); BufferParams & params = cntrl.params();
string const all_branches = params.branchlist().allBranches(); string const all_branches = params.branchlist().allBranches();
string const all_selected = params.branchlist().allSelected();
branchesModule->branchesLV->clear(); branchesModule->branchesLV->clear();
if (!all_branches.empty()) { if (!all_branches.empty()) {
std::vector<string> all = getVectorFromString(all_branches, "|"); std::vector<string> all = getVectorFromString(all_branches, "|");
@ -445,6 +444,7 @@ void QDocumentDialog::updateBranchView()
newItem->setPixmap(2, coloritem); newItem->setPixmap(2, coloritem);
} }
} }
form_->branchlist_ = params.branchlist();
form_->changed(); form_->changed();
} }
@ -514,16 +514,14 @@ void QDocumentDialog::toggleBranchColor()
sel_branch = selItem->text(0); sel_branch = selItem->text(0);
if (sel_branch) { if (sel_branch) {
QColor initial; 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] == '#') if (x11hexname[0] == '#')
initial.setNamedColor(toqstr(x11hexname)); initial.setNamedColor(toqstr(x11hexname));
QColor ncol(QColorDialog::getColor(initial)); QColor ncol(QColorDialog::getColor(initial));
if (ncol.isValid()){ if (ncol.isValid()){
// FIXME: The color does not apply unless buffer restart // add the color to the branchlist
// XForms has this hack. What can we do? params.branchlist().setColor(current_branch, fromqstr(ncol.name()));
// lyxColorHandler->getGCForeground(c);
// lyxColorHandler->updateColor(c);
params.branchlist().setColor(fromqstr(sel_branch), fromqstr(ncol.name()));
branchesModule->newBranchLE->clear(); branchesModule->newBranchLE->clear();
updateBranchView(); updateBranchView();
} }