mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-17 12:40:35 +01:00
DynamicElementTextModel : change the way how to display the QFontDialog use for change the font of the dynamic text.
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@5805 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -1527,9 +1527,16 @@ QWidget *DynamicTextItemDelegate::createEditor(QWidget *parent, const QStyleOpti
|
||||
}
|
||||
case DynamicElementTextModel::font:
|
||||
{
|
||||
QFontDialog *fd = new QFontDialog(index.data(Qt::UserRole+2).value<QFont>(), parent);
|
||||
fd->setObjectName("font_dialog");
|
||||
return fd;
|
||||
bool ok;
|
||||
QFont font = QFontDialog::getFont(&ok, index.data(Qt::UserRole+2).value<QFont>(), parent);
|
||||
QWidget *w = new QWidget(parent);
|
||||
if (ok)
|
||||
{
|
||||
w->setFont(font);
|
||||
w->setProperty("ok", ok);
|
||||
}
|
||||
w->setObjectName("font_dialog");
|
||||
return w;
|
||||
}
|
||||
case DynamicElementTextModel::color:
|
||||
{
|
||||
@@ -1617,17 +1624,10 @@ void DynamicTextItemDelegate::setModelData(QWidget *editor, QAbstractItemModel *
|
||||
{
|
||||
if(QStandardItem *qsi = qsim->itemFromIndex(index))
|
||||
{
|
||||
QFontDialog *fd = static_cast<QFontDialog *>(editor);
|
||||
if (fd->result() == QDialog::Accepted)
|
||||
if (editor->property("ok").toBool() == true)
|
||||
{
|
||||
//qsi->setData(fd->selectedFont().family(), Qt::EditRole);
|
||||
//qsi->setData(fd->selectedFont(), Qt::UserRole+2);
|
||||
/**For unknow reason, call selectedFont doesn't work,
|
||||
* (always return the same font, no matter what you select)
|
||||
* Instead we use curentFont
|
||||
**/
|
||||
qsi->setData(fd->currentFont().family(), Qt::EditRole);
|
||||
qsi->setData(fd->currentFont(), Qt::UserRole+2);
|
||||
qsi->setData(editor->font().family(), Qt::EditRole);
|
||||
qsi->setData(editor->font(), Qt::UserRole+2);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user