From 69dfb598d3d843361946d02d2715c4c7c8c8a432 Mon Sep 17 00:00:00 2001 From: blacksun Date: Wed, 20 Mar 2019 20:38:58 +0000 Subject: [PATCH] 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 --- sources/ui/dynamicelementtextmodel.cpp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/sources/ui/dynamicelementtextmodel.cpp b/sources/ui/dynamicelementtextmodel.cpp index 10cb1d4db..bb49c9fb1 100644 --- a/sources/ui/dynamicelementtextmodel.cpp +++ b/sources/ui/dynamicelementtextmodel.cpp @@ -1527,9 +1527,16 @@ QWidget *DynamicTextItemDelegate::createEditor(QWidget *parent, const QStyleOpti } case DynamicElementTextModel::font: { - QFontDialog *fd = new QFontDialog(index.data(Qt::UserRole+2).value(), parent); - fd->setObjectName("font_dialog"); - return fd; + bool ok; + QFont font = QFontDialog::getFont(&ok, index.data(Qt::UserRole+2).value(), 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(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; }