r19197 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:59:14 UTC 2014
Author: jghali
Date: Mon Jun 9 13:59:14 2014
New Revision: 19197
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=19197
Log:
#12357: Style Manager does not manage correctly units for Line Styles
Modified:
trunk/Scribus/scribus/ui/scrspinbox.cpp
trunk/Scribus/scribus/ui/scrspinbox.h
trunk/Scribus/scribus/ui/smlinestyle.cpp
trunk/Scribus/scribus/ui/smlinestylewidget.cpp
trunk/Scribus/scribus/ui/smlinestylewidget.h
Modified: trunk/Scribus/scribus/ui/scrspinbox.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19197&path=/trunk/Scribus/scribus/ui/scrspinbox.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/scrspinbox.cpp (original)
+++ trunk/Scribus/scribus/ui/scrspinbox.cpp Mon Jun 9 13:59:14 2014
@@ -49,6 +49,11 @@
ScrSpinBox::~ScrSpinBox()
{
+}
+
+double ScrSpinBox::unitRatio() const
+{
+ return unitGetRatioFromIndex(m_unitIndex);
}
void ScrSpinBox::setValue(int val)
@@ -387,12 +392,6 @@
return retval;
}
-// void ScrSpinBox::setSingleStepM(int val)
-// {
-// QDoubleSpinBox::setSingleStep( val );
-// // currLineStep = val * Decimals;
-// }
-
void ScrSpinBox::setTabAdvance(bool enable)
{
m_tabAdvance = enable;
Modified: trunk/Scribus/scribus/ui/scrspinbox.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19197&path=/trunk/Scribus/scribus/ui/scrspinbox.h
==============================================================================
--- trunk/Scribus/scribus/ui/scrspinbox.h (original)
+++ trunk/Scribus/scribus/ui/scrspinbox.h Mon Jun 9 13:59:14 2014
@@ -40,9 +40,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: trunk/Scribus/scribus/ui/smlinestyle.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19197&path=/trunk/Scribus/scribus/ui/smlinestyle.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/smlinestyle.cpp (original)
+++ trunk/Scribus/scribus/ui/smlinestyle.cpp Mon Jun 9 13:59:14 2014
@@ -381,10 +381,9 @@
void SMLineStyle::unitChange()
{
- double oldRatio = m_unitRatio;
m_unitRatio = m_doc->unitRatio();
if (m_widget)
- m_widget->unitChange(oldRatio, m_unitRatio, m_doc->unitIndex());
+ m_widget->unitChange(m_doc->unitIndex());
}
void SMLineStyle::setupConnections()
@@ -544,11 +543,13 @@
void SMLineStyle::slotLineWidth()
{
+ double unitRatio = m_widget->lineWidth->unitRatio();
+
QHash<QString, multiLine*>::iterator it;
for (it = m_selection.begin(); it != m_selection.end(); ++it)
{
multiLine *tmp = it.value();
- (*tmp)[m_currentLine].Width = m_widget->lineWidth->value();
+ (*tmp)[m_currentLine].Width = m_widget->lineWidth->value() / unitRatio;
}
updatePreview();
@@ -576,18 +577,18 @@
sl.Width = (*tmpLine)[m_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);
m_currentLine = cc;
rebuildList();
m_widget->showStyle(*tmpLine, m_doc->PageColors, cc);
@@ -602,37 +603,22 @@
void SMLineStyle::rebuildList()
{
+ QPixmap * pm2;
QString tmp, tmp2;
+
+ int decimals = m_widget->lineWidth->decimals();
+ double unitRatio = m_widget->lineWidth->unitRatio();
+ QString unitSuffix = m_widget->lineWidth->suffix();
+
m_widget->lineStyles->clear();
- QPixmap * pm2;
+
multiLine *tmpLine = m_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 += " ";
-// m_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)) + " ";
m_widget->lineStyles->addItem(new QListWidgetItem(*pm2, tmp2, m_widget->lineStyles));
}
}
@@ -643,16 +629,15 @@
return;
multiLine *tmpLine = m_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 == m_currentLine)
{
- (*tmpLine).erase(it3);
+ tmpLine->erase(it3);
break;
}
cc++;
@@ -679,44 +664,27 @@
if (m_currentLine < 0)
return;
-
QString tmp, tmp2;
QPixmap * pm;
+
multiLine *tmpLine = m_selection.begin().value();
+ const SingleLine& singleLine = tmpLine->at(m_currentLine);
+
+ int decimals = m_widget->lineWidth->decimals();
+ double unitRatio = m_widget->lineWidth->unitRatio();
+ QString unitSuffix = m_widget->lineWidth->suffix();
- pm = getWidePixmap(calcFarbe((*tmpLine)[m_currentLine].Color, (*tmpLine)[m_currentLine].Shade));
- tmp2 = " "+tmp.setNum((*tmpLine)[m_currentLine].Width)+ tr(" pt ");
- switch (static_cast<Qt::PenStyle>((*tmpLine)[m_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 (m_widget->lineStyles->count() == 1) // to avoid Bug in Qt-3.1.2
{
m_widget->lineStyles->clear();
-// m_widget->lineStyles->insertItem(*pm, tmp2);
m_widget->lineStyles->addItem(new QListWidgetItem(*pm, tmp2, m_widget->lineStyles));
}
else
{
-// m_widget->lineStyles->changeItem(*pm, tmp2, m_currentLine);
QListWidgetItem *i = m_widget->lineStyles->item(m_currentLine);
i->setIcon(*pm);
i->setText(tmp2);
Modified: trunk/Scribus/scribus/ui/smlinestylewidget.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19197&path=/trunk/Scribus/scribus/ui/smlinestylewidget.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/smlinestylewidget.cpp (original)
+++ trunk/Scribus/scribus/ui/smlinestylewidget.cpp Mon Jun 9 13:59:14 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: trunk/Scribus/scribus/ui/smlinestylewidget.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19197&path=/trunk/Scribus/scribus/ui/smlinestylewidget.h
==============================================================================
--- trunk/Scribus/scribus/ui/smlinestylewidget.h (original)
+++ trunk/Scribus/scribus/ui/smlinestylewidget.h Mon Jun 9 13:59:14 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