Issue #171: QComboBox to show Qt::PenStyle

New issue 171: QComboBox to show Qt::PenStyle. https://bitbucket.org/valentinateam/valentina/issue/171/qcombobox-to-show-qt-penstyle

Roman Telezhinskyi:

Source: QComboBox to show Qt::PenStyle.

Better show pictures that show pen styles instead names of pen styles like we do now. Pen styles hard translate and this help hide internal names from user. And also this is normal behavior for graphical application. For this moment i could find example that show how to do this.

#!c++

//![1] Begins
drawConfigBar = new QToolBar(QToolBar::tr("Draw Configuration Bar"),this);
drawConfigBar->setOrientation(Qt::Vertical);
drawConfigBar->setMovable(true);
drawConfigBar->setFloatable(true);

//![2]
QAction* newAction = NULL;
QComboBox* newComboBox = NULL;

//Pen Style
newComboBox = new QComboBox(drawConfigBar);
newComboBox->setToolTip(newComboBox->tr("Line style"));
newComboBox->setEditable(false);
newComboBox->setIconSize(QSize(80,14));
newComboBox->setMinimumWidth(80);
connect(newComboBox,SIGNAL(currentIndexChanged(int )),this,SLOT(slotLineStyleSelected(int)));

for (aaa = Qt::SolidLine; aaa < Qt::CustomDashLine; aaa++)
{
QPixmap pix(80,14);
pix.fill(Qt::white);

QBrush brush(Qt::black);
QPen pen(brush,2.5,(Qt::PenStyle)aaa);

QPainter painter(&pix);
painter.setPen(pen);
painter.drawLine(2,7,78,7);

newComboBox->addItem(QIcon(pix),"");
} 

newComboBox->setCurrentIndex((int)Qt::SolidLine - 1);

drawConfigBar->addWidget(newComboBox);

//Pen width
newComboBox = new QComboBox(drawConfigBar);
newComboBox->setToolTip(newComboBox->tr("Line width"));
newComboBox->setEditable(false);
newComboBox->setIconSize(QSize(80,14));
newComboBox->setMinimumWidth(80);
connect(newComboBox,SIGNAL(currentIndexChanged(int )),this,SLOT(slotLineThicknessSelected(int)));

for (aaa = 1; aaa < 6; aaa++)
{
QPixmap pix(80,14);
pix.fill(Qt::white);

QBrush brush(Qt::black);
QPen pen(brush,(double)aaa,Qt::SolidLine);

QPainter painter(&pix);
painter.setPen(pen);
painter.drawLine(2,7,78,7);

newComboBox->addItem(QIcon(pix),"");
}

newComboBox->setCurrentIndex(0);

drawConfigBar->addWidget(newComboBox);

We have strings that represent in xml pen styles. Need to get this strings, generate pixmaps for pen styles, set for each pixmap string and after selection pen style to get string back. See QComboBox::itemData.

Another great idea. Icons are always a good choice.On Mon, Sep 29, 2014 at 6:32 AM, Roman Telezhinskyi < issues-reply@bitbucket.org> wrote:

New issue 171: QComboBox to show Qt::PenStyle.

https://bitbucket.org/valentinateam/valentina/issue/171/qcombobox-to-show-qt-penstyle

Roman Telezhinskyi:

Source: QComboBox to show Qt::PenStyle.

Better show pictures that show pen styles instead names of pen styles like we do now. Pen styles hard translate and this help hide internal names from user. And also this is normal behavior for graphical application. For this moment i could find example that show how to do this.

#!c++

//![1] Begins
drawConfigBar = new QToolBar(QToolBar::tr("Draw Configuration Bar"),this);
drawConfigBar->setOrientation(Qt::Vertical);
drawConfigBar->setMovable(true);
drawConfigBar->setFloatable(true);

//![2]
QAction* newAction = NULL;
QComboBox* newComboBox = NULL;

//Pen Style
newComboBox = new QComboBox(drawConfigBar);
newComboBox->setToolTip(newComboBox->tr("Line style"));
newComboBox->setEditable(false);
newComboBox->setIconSize(QSize(80,14));
newComboBox->setMinimumWidth(80);
connect(newComboBox,SIGNAL(currentIndexChanged(int
)),this,SLOT(slotLineStyleSelected(int)));

for (aaa = Qt::SolidLine; aaa < Qt::CustomDashLine; aaa++)
{
QPixmap pix(80,14);
pix.fill(Qt::white);

QBrush brush(Qt::black);
QPen pen(brush,2.5,(Qt::PenStyle)aaa);

QPainter painter(&pix);
painter.setPen(pen);
painter.drawLine(2,7,78,7);

newComboBox->addItem(QIcon(pix),"");
}

newComboBox->setCurrentIndex((int)Qt::SolidLine - 1);

drawConfigBar->addWidget(newComboBox);

//Pen width
newComboBox = new QComboBox(drawConfigBar);
newComboBox->setToolTip(newComboBox->tr("Line width"));
newComboBox->setEditable(false);
newComboBox->setIconSize(QSize(80,14));
newComboBox->setMinimumWidth(80);
connect(newComboBox,SIGNAL(currentIndexChanged(int
)),this,SLOT(slotLineThicknessSelected(int)));

for (aaa = 1; aaa < 6; aaa++)
{
QPixmap pix(80,14);
pix.fill(Qt::white);

QBrush brush(Qt::black);
QPen pen(brush,(double)aaa,Qt::SolidLine);

QPainter painter(&pix);
painter.setPen(pen);
painter.drawLine(2,7,78,7);

newComboBox->addItem(QIcon(pix),"");
}

newComboBox->setCurrentIndex(0);

drawConfigBar->addWidget(newComboBox);

We have strings that represent in xml pen styles. Need to get this strings, generate pixmaps for pen styles, set for each pixmap string and after selection pen style to get string back. See QComboBox::itemData.

– You received this message because you are subscribed to the Google Groups “Valentina-project list” group. To unsubscribe from this group and stop receiving emails from it, send an email to valentina-project-list+unsubscribe@googlegroups.com. To post to this group, send email to valentina-project-list@googlegroups.com. Visit this group at http://groups.google.com/group/valentina-project-list. For more options, visit https://groups.google.com/d/optout.