Commit ebc594cd authored by Kurt Hindenburg's avatar Kurt Hindenburg

Use a number input instead of a slider to pick text size

This replaces the text size slider by a number input w/ arrows. The
slider is awkard to change the size.  Instead of fixing the slider, the
input arrows seem a better choice.  The KIntNumInput has a slider that
could be enabled we want to enable it.

REVIEW: 105796
parent 1d8a4ae1
......@@ -450,10 +450,9 @@ void EditProfileDialog::setupAppearancePage(const Profile::Ptr profile)
_ui->fontPreviewLabel->installEventFilter(this);
_ui->fontPreviewLabel->setFont(profileFont);
setFontSliderRange(profileFont);
setFontSliderValue(profileFont);
setFontInputValue(profileFont);
connect(_ui->fontSizeSlider, SIGNAL(valueChanged(int)), this,
connect(_ui->fontSizeInput, SIGNAL(valueChanged(int)), this,
SLOT(setFontSize(int)));
connect(_ui->selectFontButton, SIGNAL(clicked()), this,
SLOT(showFontDialog()));
......@@ -577,9 +576,7 @@ bool EditProfileDialog::eventFilter(QObject* watched , QEvent* aEvent)
}
if (watched == _ui->fontPreviewLabel && aEvent->type() == QEvent::FontChange) {
const QFont& labelFont = _ui->fontPreviewLabel->font();
qreal fontSizeF = labelFont.pointSizeF();
QString fontSize = KGlobal::locale()->formatNumber(fontSizeF, fontSizeF == floor(fontSizeF) ? 0 : 1);
_ui->fontPreviewLabel->setText(i18n("%1, size %2", labelFont.family(), fontSize));
_ui->fontPreviewLabel->setText(i18n("%1", labelFont.family()));
}
return KDialog::eventFilter(watched, aEvent);
......@@ -1161,8 +1158,7 @@ void EditProfileDialog::fontSelected(const QFont& aFont)
{
QFont previewFont = aFont;
setFontSliderRange(aFont);
setFontSliderValue(aFont);
setFontInputValue(aFont);
_ui->fontPreviewLabel->setFont(previewFont);
......@@ -1199,25 +1195,16 @@ void EditProfileDialog::showFontDialog()
void EditProfileDialog::setFontSize(int pointSize)
{
QFont newFont = _ui->fontPreviewLabel->font();
newFont.setPointSizeF(pointSize / 10.0);
newFont.setPointSize(pointSize);
_ui->fontPreviewLabel->setFont(newFont);
preview(Profile::Font, newFont);
updateTempProfileProperty(Profile::Font, newFont);
}
void EditProfileDialog::setFontSliderRange(const QFont& aFont)
void EditProfileDialog::setFontInputValue(const QFont& aFont)
{
QSlider* slider = _ui->fontSizeSlider;
// Minimum on the slider is 4,
// Maximum is the greater of 2 times the current size and 14
slider->setRange(qMin(4 * 10, qRound(aFont.pointSizeF() * 10)),
qMax(14 * 10, 2 * qRound(aFont.pointSize() * 10)));
}
void EditProfileDialog::setFontSliderValue(const QFont& aFont)
{
_ui->fontSizeSlider->setValue(qRound(aFont.pointSize() * 10));
_ui->fontSizeInput->setValue(aFont.pointSize());
}
ColorSchemeViewDelegate::ColorSchemeViewDelegate(QObject* aParent)
......
......@@ -119,8 +119,7 @@ private slots:
// appearance page
void setFontSize(int pointSize);
void setFontSliderRange(const QFont&);
void setFontSliderValue(const QFont&);
void setFontInputValue(const QFont&);
void setAntialiasText(bool enable);
void setBoldIntense(bool enable);
void showFontDialog();
......
......@@ -457,32 +457,15 @@
</widget>
</item>
<item>
<widget class="QLabel" name="label_5">
<property name="text">
<string comment="@item:inrange Minimum Size">Small</string>
</property>
</widget>
</item>
<item>
<widget class="QSlider" name="fontSizeSlider">
<property name="toolTip">
<string>Adjust the font size used in this profile</string>
</property>
<widget class="KIntNumInput" name="fontSizeInput">
<property name="minimum">
<number>9</number>
<number>0</number>
</property>
<property name="maximum">
<number>20</number>
<number>999</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_6">
<property name="text">
<string comment="@item:inrange Maximum Size">Large</string>
<property name="sliderEnabled">
<bool>false</bool>
</property>
</widget>
</item>
......@@ -496,6 +479,19 @@
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
......@@ -1219,6 +1215,11 @@
<extends>QSpinBox</extends>
<header>knuminput.h</header>
</customwidget>
<customwidget>
<class>KIntNumInput</class>
<extends>QWidget</extends>
<header>knuminput.h</header>
</customwidget>
<customwidget>
<class>KMessageWidget</class>
<extends>QFrame</extends>
......
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