configdialog: fix size of PageSelectWidget (#83)
authortsujan <tsujan2000@gmail.com>
Mon, 25 Apr 2016 23:26:52 +0000 (03:56 +0430)
committerPaulo Lieuthier <paulolieuthier@gmail.com>
Mon, 25 Apr 2016 23:26:52 +0000 (20:26 -0300)
configdialog/lxqtpageselectwidget.cpp

index 2e02af2..1197a59 100644 (file)
@@ -30,6 +30,7 @@
 #include <QDebug>
 #include <QStyledItemDelegate>
 #include <QScrollBar>
+#include <QApplication>
 
 using namespace LXQt;
 
@@ -102,12 +103,14 @@ QSize PageSelectWidget::sizeHint() const
     int w = 0;
     for(int i=0; i< count(); ++i)
     {
-        QRect rect = fontMetrics().boundingRect(QRect(), Qt::AlignLeft | Qt::TextWordWrap, item(i)->text());
+        QRect rect = fontMetrics().boundingRect(QRect(), Qt::AlignHCenter | Qt::TextWordWrap, item(i)->text());
         w = qMax(w, rect.width());
     }
+    // consider the icon size too
+    w = qMax(w, QApplication::style()->pixelMetric(QStyle::PM_IconViewIconSize));
 
-    if (horizontalScrollBar()->isVisible())
-        w += horizontalScrollBar()->width();
+    if (verticalScrollBar()->isVisible())
+        w += QApplication::style()->pixelMetric(QStyle::PM_ScrollBarExtent);
     size.setWidth(w + frameWidth() + spacing()*2 + 10);
     return size;
 }