From kde-commits Sun Jan 31 22:00:54 2016 From: Barth Netterfield Date: Sun, 31 Jan 2016 22:00:54 +0000 To: kde-commits Subject: [kst-plot] src: Curve appearance widgets work at any dpi. Message-Id: X-MARC-Message: https://marc.info/?l=kde-commits&m=145427767929612 Git commit 945383ea4685bf8f9c6e25a4719b54181bcd98bc by Barth Netterfield. Committed on 30/01/2016 at 23:00. Pushed by netterfield into branch 'master'. Curve appearance widgets work at any dpi. M +1 -0 src/libkstapp/mainwindow.cpp M +15 -42 src/widgets/curveappearance.cpp http://commits.kde.org/kst-plot/945383ea4685bf8f9c6e25a4719b54181bcd98bc diff --git a/src/libkstapp/mainwindow.cpp b/src/libkstapp/mainwindow.cpp index cd6094c..5c7001f 100644 --- a/src/libkstapp/mainwindow.cpp +++ b/src/libkstapp/mainwindow.cpp @@ -142,6 +142,7 @@ MainWindow::MainWindow() : qApp->installEventFilter(this); qnxToggleToolbarVisibility(); #endif + } = = diff --git a/src/widgets/curveappearance.cpp b/src/widgets/curveappearance.= cpp index 5ccd3cf..a9715d0 100644 --- a/src/widgets/curveappearance.cpp +++ b/src/widgets/curveappearance.cpp @@ -88,37 +88,23 @@ void CurveAppearance::populateSymbolCombo(QComboBox *co= mbo, QColor symbolColor) if (symbolColor =3D=3D Qt::transparent) { symbolColor =3D Qt::black; } - QStyleOptionComboBox option; - option.initFrom(combo); - option.currentIcon =3D combo->itemIcon(combo->currentIndex()); - option.currentText =3D combo->itemText(combo->currentIndex()); - option.editable =3D combo->isEditable(); - option.frame =3D combo->hasFrame(); - option.iconSize =3D combo->iconSize(); - - QRect rect =3D combo->style()->subControlRect( - QStyle::CC_ComboBox, - &option, - QStyle::SC_ComboBoxEditField, - combo ); - rect.setLeft( rect.left() + 2 ); - rect.setRight( rect.right() - 2 ); - rect.setTop( rect.top() + 2 ); - rect.setBottom( rect.bottom() - 2 ); - - combo->setIconSize(QSize(rect.width(), rect.height())); + int h =3D fontMetrics().lineSpacing(); + + combo->setIconSize(QSize(4*h, h)); = // fill the point type dialog with point types - QPixmap ppix( rect.width(), rect.height() ); + QPixmap ppix( 4*h, h ); QPainter pp( &ppix ); = int currentItem =3D combo->currentIndex(); combo->clear(); - pp.setPen(symbolColor); + QPen pen(symbolColor); + pen.setWidthF(h/12.0); + pp.setPen(pen); = for (int ptype =3D 0; ptype < KSTPOINT_MAXTYPE; ptype++) { pp.fillRect(pp.window(), QColor("white")); - CurvePointSymbol::draw(ptype, &pp, ppix.width()/2, ppix.height()/2, 3); + CurvePointSymbol::draw(ptype, &pp, ppix.width()/2, ppix.height()/2, h/= 4); combo->addItem(QIcon(ppix), QString()); } = @@ -420,35 +406,22 @@ void CurveAppearance::clearValues() { = = void CurveAppearance::populateLineStyleCombo() { + int h =3D fontMetrics().lineSpacing(); = - QStyleOptionComboBox option; - option.initFrom(_comboLineStyle); - option.currentIcon =3D _comboLineStyle->itemIcon(_comboLineStyle->curren= tIndex()); - option.currentText =3D _comboLineStyle->itemText(_comboLineStyle->curren= tIndex()); - option.editable =3D _comboLineStyle->isEditable(); - option.frame =3D _comboLineStyle->hasFrame(); - option.iconSize =3D _comboLineStyle->iconSize(); - - QRect rect =3D _comboLineStyle->style()->subControlRect( - QStyle::CC_ComboBox, - &option, - QStyle::SC_ComboBoxEditField, - _comboLineStyle ); - rect.setLeft(rect.left() + 2); - rect.setRight(rect.right() - 2); - rect.setTop(rect.top() + 2); - rect.setBottom(rect.bottom() - 2); - - _comboLineStyle->setIconSize(QSize(rect.width(), rect.height())); + _comboLineStyle->setIconSize(QSize(4*h, h)); = // fill the point type dialog with point types - QPixmap ppix(rect.width(), rect.height()); + QPixmap ppix(4*h, h); QPainter pp(&ppix); + QColor lineColor(color()); if (lineColor =3D=3D Qt::transparent) { lineColor =3D Qt::black; } + + QPen pen(lineColor, 1); + pen.setWidthF(h/12.0); = int currentItem =3D _comboLineStyle->currentIndex(); _comboLineStyle->clear();