]> git.lyx.org Git - features.git/commitdiff
* center RTF text vertically correctly in layout list
authorStefan Schimanski <sts@lyx.org>
Mon, 10 Mar 2008 14:44:40 +0000 (14:44 +0000)
committerStefan Schimanski <sts@lyx.org>
Mon, 10 Mar 2008 14:44:40 +0000 (14:44 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23635 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/qt4/GuiToolbar.cpp

index 9eb127c7d311d33e04b0f177403f64ab31d24794..c6f1501c1740e1513102d4cc4975156fe78877f0 100644 (file)
@@ -58,6 +58,7 @@
 #include <QStandardItem>
 #include <QStandardItemModel>
 #include <QTextDocument>
+#include <QTextFrame>
 #include <QToolBar>
 #include <QToolButton>
 #include <QVariant>
@@ -263,9 +264,10 @@ public:
                QSortFilterProxyModel const * model
                = static_cast<QSortFilterProxyModel const *>(index.model());
                QStyleOptionMenuItem opt = getStyleOption(option, index);
-
+               
                painter->eraseRect(opt.rect);
                
+               QFontMetrics fm(opt.font);
                QString text = underlineFilter(opt.text);
                opt.text = QString();
                
@@ -282,7 +284,6 @@ public:
                                paintCategoryHeader(painter, opt, 
                                        category(*index.model(), index.row()));
 
-                               QFontMetrics fm(opt.font);
                                opt.rect.setTop(opt.rect.top() + headerHeight(opt));
                                opt.menuRect = opt.rect;
                        }
@@ -306,7 +307,13 @@ public:
                QTextDocument doc;
                doc.setDefaultFont(opt.font);
                doc.setHtml(text);
-               painter->translate(opt.rect.x() + 5, opt.rect.y());
+               
+               QTextFrameFormat fmt = doc.rootFrame()->frameFormat();
+               fmt.setMargin(0);
+               doc.rootFrame()->setFrameFormat(fmt);
+               
+               painter->translate(opt.rect.x() + 5,
+                       opt.rect.y() + (opt.rect.height() - fm.height()) / 2);
                doc.documentLayout()->draw(painter, context);
                painter->restore();
        }