Icons for templates

This commit is contained in:
Ronan Le Tiec 2020-11-20 16:24:53 +01:00
parent f9d4eac8b4
commit efac90c9bb
4 changed files with 28 additions and 18 deletions

View File

@ -14,5 +14,7 @@
<file>puzzleicon/svg/icon_scissors.svg</file>
<file>puzzleicon/svg/icon_scissors_vertical.svg</file>
<file>puzzleicon/svg/icon_scissors_horizontal.svg</file>
<file>puzzleicon/16x16/roll.png</file>
<file>puzzleicon/16x16/template.png</file>
</qresource>
</RCC>

Binary file not shown.

After

Width:  |  Height:  |  Size: 241 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 372 B

View File

@ -204,25 +204,28 @@ QString VPSheet::GetTemplateName(PaperSizeTemplate tmpl)
//---------------------------------------------------------------------------------------------------------------------
PaperSizeTemplate VPSheet::GetTemplate(QSizeF size)
{
const int max = static_cast<int>(PaperSizeTemplate::Custom);
// TODO, float comparision not safe and problems with
// inch / cm
for (int i=0; i < max; i++)
{
PaperSizeTemplate tmpl = static_cast<PaperSizeTemplate>(i);
const QSizeF tmplSize = GetTemplateSize(tmpl);
// const int max = static_cast<int>(PaperSizeTemplate::Custom);
if(size.width() == tmplSize.width())
{
if(isRollTemplate(tmpl))
{
return tmpl;
}
else if(size.height() == tmplSize.height())
{
return tmpl;
}
}
}
// for (int i=0; i < max; i++)
// {
// PaperSizeTemplate tmpl = static_cast<PaperSizeTemplate>(i);
// const QSizeF tmplSize = GetTemplateSize(tmpl);
// if(size.width() == tmplSize.width())
// {
// if(isRollTemplate(tmpl))
// {
// return tmpl;
// }
// else if(size.height() == tmplSize.height())
// {
// return tmpl;
// }
// }
// }
return PaperSizeTemplate::Custom;
}
@ -248,9 +251,14 @@ bool VPSheet::isRollTemplate(PaperSizeTemplate tmpl)
//---------------------------------------------------------------------------------------------------------------------
void VPSheet::PopulateComboBox(QVector<PaperSizeTemplate> *tmpls, QComboBox* comboBox)
{
const QIcon icoPaper("://puzzleicon/16x16/template.png");
const QIcon icoRoll("://puzzleicon/16x16/roll.png");
QIcon icon;
for (auto tmpl : *tmpls)
{
comboBox->addItem(GetTemplateName(tmpl), QVariant(static_cast<int>(tmpl)));
icon = (isRollTemplate(tmpl))? icoRoll : icoPaper;
comboBox->addItem(icon, GetTemplateName(tmpl), QVariant(static_cast<int>(tmpl)));
}
}