Commit 3f01893f authored by Alexander Semke's avatar Alexander Semke

Better calculation of the fixed side of ThemesWidget.

parent 10590878
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
#include <KMessageBox> #include <KMessageBox>
// #include <knewstuff3/downloaddialog.h> // #include <knewstuff3/downloaddialog.h>
#include <cmath>
/*! /*!
\class ThemesWidget \class ThemesWidget
...@@ -57,7 +57,7 @@ ThemesWidget::ThemesWidget(QWidget* parent) : QListView(parent) { ...@@ -57,7 +57,7 @@ ThemesWidget::ThemesWidget(QWidget* parent) : QListView(parent) {
setDragDropMode(QListView::NoDragDrop); setDragDropMode(QListView::NoDragDrop);
//make the icon 3x3cm big and show two of them in the height //make the icon 3x3cm big and show two of them in the height
static const int themeIconSize = 3.0/2.54 * QApplication::desktop()->physicalDpiX(); static const int themeIconSize = std::ceil(3.0/2.54 * QApplication::desktop()->physicalDpiX());
setIconSize(QSize(themeIconSize, themeIconSize)); setIconSize(QSize(themeIconSize, themeIconSize));
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
...@@ -129,11 +129,12 @@ void ThemesWidget::applyClicked(const QModelIndex& index) { ...@@ -129,11 +129,12 @@ void ThemesWidget::applyClicked(const QModelIndex& index) {
void ThemesWidget::setFixedMode() { void ThemesWidget::setFixedMode() {
//resize the widget to show three items only //resize the widget to show three items only
int frameWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
QFont font; QFont font;
QFontMetrics fm(font); QFontMetrics fm(font);
static const int themeIconSize = 3.0/2.54 * QApplication::desktop()->physicalDpiX(); static const int themeIconSize = std::ceil(3.0/2.54 * QApplication::desktop()->physicalDpiX());
QSize widgetSize(themeIconSize + qApp->style()->pixelMetric(QStyle::PM_ScrollBarExtent), QSize widgetSize(themeIconSize + style()->pixelMetric(QStyle::PM_ScrollBarExtent) + frameWidth*2,
3*(themeIconSize + fm.height() + 2*spacing()) + fm.height() + spacing()); 3*(themeIconSize + fm.height() + 2* frameWidth) + fm.height() + frameWidth);
setMinimumSize(widgetSize); setMinimumSize(widgetSize);
setMaximumSize(widgetSize); setMaximumSize(widgetSize);
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment