r19196 by jghali - #12357: Style Manager does not manage correctly units for Line Styles
scribus-commit
scribus-commit at lists.scribus.net
Mon Jun 9 13:55:31 UTC 2014
Author: jghali
Date: Mon Jun 9 13:55:31 2014
New Revision: 19196
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=19196
Log:
#12357: Style Manager does not manage correctly units for Line Styles
Modified:
branches/Version14x/Scribus/scribus/scrspinbox.cpp
branches/Version14x/Scribus/scribus/scrspinbox.h
branches/Version14x/Scribus/scribus/smlinestyle.cpp
branches/Version14x/Scribus/scribus/smlinestylewidget.cpp
branches/Version14x/Scribus/scribus/smlinestylewidget.h
Modified: branches/Version14x/Scribus/scribus/scrspinbox.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19196&path=/branches/Version14x/Scribus/scribus/scrspinbox.cpp
==============================================================================
--- branches/Version14x/Scribus/scribus/scrspinbox.cpp (original)
+++ branches/Version14x/Scribus/scribus/scrspinbox.cpp Mon Jun 9 13:55:31 2014
@@ -51,6 +51,10 @@
{
}
+double ScrSpinBox::unitRatio() const
+{
+ return unitGetRatioFromIndex(m_unitIndex);
+}
void ScrSpinBox::setParameters( int s )
{
@@ -370,12 +374,6 @@
return retval;
}
-// void ScrSpinBox::setSingleStepM(int val)
-// {
-// QDoubleSpinBox::setSingleStep( val );
-// // currLineStep = val * Decimals;
-// }
-
void ScrSpinBox::setTabAdvance(bool enable)
{
m_tabAdvance = enable;
Modified: branches/Version14x/Scribus/scribus/scrspinbox.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19196&path=/branches/Version14x/Scribus/scribus/scrspinbox.h
==============================================================================
--- branches/Version14x/Scribus/scribus/scrspinbox.h (original)
+++ branches/Version14x/Scribus/scribus/scrspinbox.h Mon Jun 9 13:55:31 2014
@@ -37,9 +37,10 @@
void setConstants(const QMap<QString, double>* constants);
void setNewUnit(int unitIndex);
double getValue(int unitIndex=0);
- //implemented for backwards compatibility, perhaps we can remove these?
-// void setSingleStepM(int val);
void setTabAdvance(bool enable);
+
+ uint unitIndex() const { return m_unitIndex; }
+ double unitRatio() const;
public slots:
void setValues(double min, double max, int deci, double val);
Modified: branches/Version14x/Scribus/scribus/smlinestyle.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19196&path=/branches/Version14x/Scribus/scribus/smlinestyle.cpp
==============================================================================
--- branches/Version14x/Scribus/scribus/smlinestyle.cpp (original)
+++ branches/Version14x/Scribus/scribus/smlinestyle.cpp Mon Jun 9 13:55:31 2014
@@ -381,7 +381,7 @@
double oldRatio = unitRatio_;
unitRatio_ = doc_->unitRatio();
if (widget_)
- widget_->unitChange(oldRatio, unitRatio_, doc_->unitIndex());
+ widget_->unitChange(doc_->unitIndex());
}
void SMLineStyle::setupConnections()
@@ -541,11 +541,13 @@
void SMLineStyle::slotLineWidth()
{
+ double unitRatio = widget_->lineWidth->unitRatio();
+
QMap<QString, multiLine*>::iterator it;
for (it = selection_.begin(); it != selection_.end(); ++it)
{
multiLine *tmp = it.value();
- (*tmp)[currentLine_].Width = widget_->lineWidth->value();
+ (*tmp)[currentLine_].Width = widget_->lineWidth->value() / unitRatio;
}
updatePreview();
@@ -573,18 +575,18 @@
sl.Width = (*tmpLine)[currentLine_].Width;
int cc = 0;
bool fo = false;
- for (multiLine::iterator it2 = (*tmpLine).begin(); it2 != (*tmpLine).end(); ++it2)
- {
- if (sl.Width < (*it2).Width)
- {
- (*tmpLine).insert(it2, sl);
+ for (multiLine::iterator it2 = tmpLine->begin(); it2 != tmpLine->end(); ++it2)
+ {
+ if (sl.Width < it2->Width)
+ {
+ tmpLine->insert(it2, sl);
fo = true;
break;
}
cc++;
}
if (!fo)
- (*tmpLine).push_back(sl);
+ tmpLine->push_back(sl);
currentLine_ = cc;
rebuildList();
widget_->showStyle(*tmpLine, doc_->PageColors, cc);
@@ -599,37 +601,22 @@
void SMLineStyle::rebuildList()
{
+ QPixmap * pm2;
QString tmp, tmp2;
+
+ int decimals = widget_->lineWidth->decimals();
+ double unitRatio = widget_->lineWidth->unitRatio();
+ QString unitSuffix = widget_->lineWidth->suffix();
+
widget_->lineStyles->clear();
- QPixmap * pm2;
+
multiLine *tmpLine = selection_.begin().value();
- for (multiLine::iterator it = (*tmpLine).begin(); it != (*tmpLine).end(); ++it)
- {
- pm2 = getWidePixmap(calcFarbe((*it).Color, (*it).Shade));
- tmp2 = " "+tmp.setNum((*it).Width)+ tr(" pt")+" ";
- switch (static_cast<Qt::PenStyle>((*it).Dash))
- {
- case Qt::SolidLine:
- tmp2 += tr("Solid Line");
- break;
- case Qt::DashLine:
- tmp2 += tr("Dashed Line");
- break;
- case Qt::DotLine:
- tmp2 += tr("Dotted Line");
- break;
- case Qt::DashDotLine:
- tmp2 += tr("Dash Dot Line");
- break;
- case Qt::DashDotDotLine:
- tmp2 += tr("Dash Dot Dot Line");
- break;
- default:
-// tmp2 += tr("Solid Line");
- break;
- }
- tmp2 += " ";
-// widget_->lineStyles->insertItem(*pm2, tmp2);
+ for (multiLine::iterator it = tmpLine->begin(); it != tmpLine->end(); ++it)
+ {
+ pm2 = getWidePixmap(calcFarbe(it->Color, it->Shade));
+ tmp2 = " "+ tmp.setNum(it->Width * unitRatio, 'f', decimals) + unitSuffix + " ";
+ if (it->Dash < 6)
+ tmp2 += CommonStrings::translatePenStyleName(static_cast<Qt::PenStyle>(it->Dash)) + " ";
widget_->lineStyles->addItem(new QListWidgetItem(*pm2, tmp2, widget_->lineStyles));
}
}
@@ -640,16 +627,15 @@
return;
multiLine *tmpLine = selection_.begin().value();
-
- if ((*tmpLine).size() == 1)
+ if (tmpLine->size() == 1)
return;
int cc = 0;
- for (multiLine::iterator it3 = (*tmpLine).begin(); it3 != (*tmpLine).end(); ++it3)
+ for (multiLine::iterator it3 = tmpLine->begin(); it3 != tmpLine->end(); ++it3)
{
if (cc == currentLine_)
{
- (*tmpLine).erase(it3);
+ tmpLine->erase(it3);
break;
}
cc++;
@@ -676,44 +662,27 @@
if (currentLine_ < 0)
return;
-
QString tmp, tmp2;
QPixmap * pm;
+
multiLine *tmpLine = selection_.begin().value();
+ const SingleLine& singleLine = tmpLine->at(currentLine_);
+
+ int decimals = widget_->lineWidth->decimals();
+ double unitRatio = widget_->lineWidth->unitRatio();
+ QString unitSuffix = widget_->lineWidth->suffix();
- pm = getWidePixmap(calcFarbe((*tmpLine)[currentLine_].Color, (*tmpLine)[currentLine_].Shade));
- tmp2 = " "+tmp.setNum((*tmpLine)[currentLine_].Width)+ tr(" pt ");
- switch (static_cast<Qt::PenStyle>((*tmpLine)[currentLine_].Dash))
- {
- case Qt::SolidLine:
- tmp2 += tr("Solid Line");
- break;
- case Qt::DashLine:
- tmp2 += tr("Dashed Line");
- break;
- case Qt::DotLine:
- tmp2 += tr("Dotted Line");
- break;
- case Qt::DashDotLine:
- tmp2 += tr("Dash Dot Line");
- break;
- case Qt::DashDotDotLine:
- tmp2 += tr("Dash Dot Dot Line");
- break;
- default:
-// tmp2 += tr("Solid Line");
- break;
- }
- tmp2 += " ";
+ pm = getWidePixmap(calcFarbe(singleLine.Color, singleLine.Shade));
+ tmp2 = " " + tmp.setNum(singleLine.Width * unitRatio, 'f', decimals) + unitSuffix + " ";
+ if (singleLine.Dash < 6)
+ tmp2 += CommonStrings::translatePenStyleName(static_cast<Qt::PenStyle>(singleLine.Dash)) + " ";
if (widget_->lineStyles->count() == 1) // to avoid Bug in Qt-3.1.2
{
widget_->lineStyles->clear();
-// widget_->lineStyles->insertItem(*pm, tmp2);
widget_->lineStyles->addItem(new QListWidgetItem(*pm, tmp2, widget_->lineStyles));
}
else
{
-// widget_->lineStyles->changeItem(*pm, tmp2, currentLine_);
QListWidgetItem *i = widget_->lineStyles->item(currentLine_);
i->setIcon(*pm);
i->setText(tmp2);
Modified: branches/Version14x/Scribus/scribus/smlinestylewidget.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19196&path=/branches/Version14x/Scribus/scribus/smlinestylewidget.cpp
==============================================================================
--- branches/Version14x/Scribus/scribus/smlinestylewidget.cpp (original)
+++ branches/Version14x/Scribus/scribus/smlinestylewidget.cpp Mon Jun 9 13:55:31 2014
@@ -74,7 +74,7 @@
}
-void SMLineStyleWidget::unitChange(double oldRatio, double newRatio, int unitIndex)
+void SMLineStyleWidget::unitChange(int unitIndex)
{
lineWidth->setNewUnit(unitIndex);
}
@@ -103,7 +103,9 @@
if (currentStyle.count() <= i || (i < 0))
return;
- lineWidth->setValue(currentStyle[i].Width);
+ double unitRatio = lineWidth->unitRatio();
+
+ lineWidth->setValue(currentStyle[i].Width * unitRatio);
setCurrentComboItem(colorCombo, currentStyle[i].Color);
shadeBox->setValue(currentStyle[i].Shade);
@@ -146,14 +148,14 @@
QString tmp, tmp2;
lineStyles->clear();
QPixmap * pm2;
+ double unitRatio = lineWidth->unitRatio();
+ int decimals = lineWidth->decimals();
for (multiLine::iterator it = currentStyle.begin(); it != currentStyle.end(); ++it)
{
- pm2 = getWidePixmap(getColor((*it).Color, (*it).Shade));
- tmp2 = " "+tmp.setNum((*it).Width)+ lineWidth->suffix()+" ";
- if ((*it).Dash < 6)
- tmp2 += CommonStrings::translatePenStyleName(static_cast<Qt::PenStyle>((*it).Dash));
- tmp2 += " ";
- // lineStyles->insertItem( ...)
+ pm2 = getWidePixmap(getColor(it->Color, it->Shade));
+ tmp2 = " " + tmp.setNum(it->Width * unitRatio, 'f', decimals) + lineWidth->suffix() + " ";
+ if (it->Dash < 6)
+ tmp2 += CommonStrings::translatePenStyleName(static_cast<Qt::PenStyle>(it->Dash)) + " ";
lineStyles->addItem(new QListWidgetItem(*pm2, tmp2, lineStyles));
}
}
Modified: branches/Version14x/Scribus/scribus/smlinestylewidget.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19196&path=/branches/Version14x/Scribus/scribus/smlinestylewidget.h
==============================================================================
--- branches/Version14x/Scribus/scribus/smlinestylewidget.h (original)
+++ branches/Version14x/Scribus/scribus/smlinestylewidget.h Mon Jun 9 13:55:31 2014
@@ -29,7 +29,7 @@
void showStyle(const multiLine &lineStyle, ColorList &colorList, int subLine = 0);
void languageChange();
- void unitChange(double oldRatio, double newRatio, int unitIndex);
+ void unitChange(int unitIndex);
private:
LineCombo *dashCombo;
More information about the scribus-commit
mailing list