[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdelibs/kdeui/widgets
From: David Faure <faure () kde ! org>
Date: 2010-08-17 14:59:06
Message-ID: 20100817150120.F3FAFAC855 () svn ! kde ! org
[Download RAW message or body]
SVN commit 1164731 by dfaure:
Fix useless space on the right (where the clear button would be) and too early \
wrapping/squeezing when a KLineEdit is made readonly via a QLineEdit pointer
(example: combo->lineEdit()->setReadOnly(true), in \
kdepim/libkdepim/kcheckcombobox.cpp). setReadOnly is *not* virtual in QLineEdit, so \
KLineEdit has to handle becoming readonly without being told so.
Aaron, does this look ok to you? I'll backport the fix, if you agree.
CCMAIL: aseigo@kde.org
M +26 -6 klineedit.cpp
--- trunk/KDE/kdelibs/kdeui/widgets/klineedit.cpp #1164730:1164731
@@ -126,6 +126,18 @@
}
}
+ // This is called when the lineedit is readonly.
+ // Either from setReadOnly() itself, or when we realize that
+ // we became readonly and setReadOnly() wasn't called (because it's not virtual)
+ // Typical case: comboBox->lineEdit()->setReadOnly(true)
+ void adjustForReadOnly()
+ {
+ if (style && style.data()->m_overlap) {
+ style.data()->m_overlap = 0;
+ }
+ }
+
+
/**
* Checks whether we should/should not consume a key used as a shortcut.
* This makes it possible to handle shortcuts in the focused widget before any
@@ -308,11 +320,16 @@
return s;
}
+// Decides whether to show or hide the icon; called when the text changes
void KLineEdit::updateClearButtonIcon(const QString& text)
{
- if (!d->clearButton || isReadOnly()) {
+ if (!d->clearButton) {
return;
}
+ if (isReadOnly()) {
+ d->adjustForReadOnly();
+ return;
+ }
int clearButtonState = KIconLoader::DefaultState;
@@ -332,14 +349,19 @@
d->clearButton->setPixmap(SmallIcon("edit-clear-locationbar-ltr", 0, \
clearButtonState)); }
- d->clearButton->setVisible(text.length());
+ d->clearButton->setVisible(text.length() > 0);
}
+// Determine geometry of clear button. Called initially, and on resizeEvent.
void KLineEdit::updateClearButton()
{
- if (!d->clearButton || isReadOnly()) {
+ if (!d->clearButton) {
return;
}
+ if (isReadOnly()) {
+ d->adjustForReadOnly();
+ return;
+ }
const QSize geom = size();
const int frameWidth = \
style()->pixelMetric(QStyle::PM_DefaultFrameWidth,0,this); @@ -515,10 +537,8 @@
if (d->clearButton) {
d->clearButton->animateVisible(false);
- if (d->style) {
- d->style.data()->m_overlap = 0;
+ d->adjustForReadOnly();
}
- }
} else {
if (!d->squeezedText.isEmpty()) {
setText(d->squeezedText);
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic