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.svg</file>
<file>puzzleicon/svg/icon_scissors_vertical.svg</file> <file>puzzleicon/svg/icon_scissors_vertical.svg</file>
<file>puzzleicon/svg/icon_scissors_horizontal.svg</file> <file>puzzleicon/svg/icon_scissors_horizontal.svg</file>
<file>puzzleicon/16x16/roll.png</file>
<file>puzzleicon/16x16/template.png</file>
</qresource> </qresource>
</RCC> </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) 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++) // const int max = static_cast<int>(PaperSizeTemplate::Custom);
{
PaperSizeTemplate tmpl = static_cast<PaperSizeTemplate>(i);
const QSizeF tmplSize = GetTemplateSize(tmpl);
if(size.width() == tmplSize.width()) // for (int i=0; i < max; i++)
{ // {
if(isRollTemplate(tmpl)) // PaperSizeTemplate tmpl = static_cast<PaperSizeTemplate>(i);
{ // const QSizeF tmplSize = GetTemplateSize(tmpl);
return tmpl;
} // if(size.width() == tmplSize.width())
else if(size.height() == tmplSize.height()) // {
{ // if(isRollTemplate(tmpl))
return tmpl; // {
} // return tmpl;
} // }
} // else if(size.height() == tmplSize.height())
// {
// return tmpl;
// }
// }
// }
return PaperSizeTemplate::Custom; return PaperSizeTemplate::Custom;
} }
@ -248,9 +251,14 @@ bool VPSheet::isRollTemplate(PaperSizeTemplate tmpl)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPSheet::PopulateComboBox(QVector<PaperSizeTemplate> *tmpls, QComboBox* comboBox) 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) 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)));
} }
} }