]> git.lyx.org Git - features.git/commitdiff
back port from trunk:
authorStephan Witt <switt@lyx.org>
Sat, 4 Jan 2014 19:37:38 +0000 (20:37 +0100)
committerStephan Witt <switt@lyx.org>
Sat, 4 Jan 2014 19:37:38 +0000 (20:37 +0100)
fix Symbols dialog box grid size in case of broken QFontMetrics::maxWidth()

src/frontends/qt4/GuiSymbols.cpp

index 95a4f623aad7b2db0a11a965f902456426f2034f..d029b213f007bc6d3e0a1a6e783134a723073121 100644 (file)
@@ -276,11 +276,15 @@ GuiSymbols::GuiSymbols(GuiView & lv)
 
        symbolsLW->setViewMode(QListView::IconMode);
        // increase the display size of the symbols a bit
-       QFont font= symbolsLW->font();
-       int size = font.pointSize() + 3;
+       QFont font = symbolsLW->font();
+       const int size = font.pointSize() + 3;
        font.setPointSize(size);
        QFontMetrics fm(font);
-       symbolsLW->setGridSize(QSize(fm.maxWidth() + 2, fm.height() + 2));
+       const int cellHeight = fm.height() + 2;
+       // FIXME: using at least cellHeight because of
+       // QFontMetrics::maxWidth() is returning 0 with Qt/Cocoa on Mac OS
+       const int cellWidth = max(cellHeight, fm.maxWidth() + 2);
+       symbolsLW->setGridSize(QSize(cellWidth, cellHeight));
        symbolsLW->setFont(font);
        symbolsLW->setModel(model_);
 }