Generate translated color names list. Need for property browser.

--HG--
branch : feature
This commit is contained in:
Roman Telezhynskyi 2015-02-07 14:31:10 +02:00
parent c595df7517
commit 805100ec0f
3 changed files with 50 additions and 35 deletions

View File

@ -306,42 +306,14 @@ void DialogTool::FillComboBoxLineColors(QComboBox *box) const
{
SCASSERT(box != nullptr);
const QStringList colorNames = VAbstractTool::Colors();
for (int i = 0; i < colorNames.size(); ++i)
const QMap<QString, QString> map = VAbstractTool::ColorsList();
QMap<QString, QString>::const_iterator i = map.constBegin();
while (i != map.constEnd())
{
QString name;
switch (i)
{
case 0: // ColorBlack
name = tr("black");
break;
case 1: // ColorGreen
name = tr("green");
break;
case 2: // ColorBlue
name = tr("blue");
break;
case 3: // ColorDarkRed
name = tr("dark red");
break;
case 4: // ColorDarkGreen
name = tr("dark green");
break;
case 5: // ColorDarkBlue
name = tr("dark blue");
break;
case 6: // ColorYellow
name = tr("yellow");
break;
default:
name = tr("black");
break;
}
QPixmap pix(16, 16);
pix.fill(QColor(colorNames.at(i)));
box->insertItem(i, QIcon(pix), name, QVariant(colorNames.at(i)));
pix.fill(QColor(i.key()));
box->addItem(QIcon(pix), i.value(), QVariant(i.key()));
++i;
}
}

View File

@ -231,6 +231,48 @@ const QStringList VAbstractTool::Colors()
return colors;
}
//---------------------------------------------------------------------------------------------------------------------
QMap<QString, QString> VAbstractTool::ColorsList()
{
QMap<QString, QString> map;
const QStringList colorNames = Colors();
for (int i = 0; i < colorNames.size(); ++i)
{
QString name;
switch (i)
{
case 0: // ColorBlack
name = tr("black");
break;
case 1: // ColorGreen
name = tr("green");
break;
case 2: // ColorBlue
name = tr("blue");
break;
case 3: // ColorDarkRed
name = tr("dark red");
break;
case 4: // ColorDarkGreen
name = tr("dark green");
break;
case 5: // ColorDarkBlue
name = tr("dark blue");
break;
case 6: // ColorYellow
name = tr("yellow");
break;
default:
name = tr("black");
break;
}
map.insert(colorNames.at(i), name);
}
return map;
}
//---------------------------------------------------------------------------------------------------------------------
QMap<QString, quint32> VAbstractTool::PointsList() const
{

View File

@ -109,6 +109,7 @@ public:
static QMap<QString, QIcon> LineStylesPics();
static const QStringList Colors();
static QMap<QString, QString> ColorsList();
static void AddRecord(const quint32 id, const Tool &toolType, VPattern *doc);