summaryrefslogtreecommitdiffstats
path: root/src/gui/widgets
diff options
context:
space:
mode:
authorAndreas Aardal Hanssen <andreas.aardal.hanssen@nokia.com>2009-10-02 06:40:17 (GMT)
committerAndreas Aardal Hanssen <andreas.aardal.hanssen@nokia.com>2009-10-02 06:40:17 (GMT)
commit17dc26e3e7a65b6eb0c0980a76c8fbe7bd37c690 (patch)
treeee9a982c144fb636ec22cdf7dd27de37725ff320 /src/gui/widgets
parentb148b182b5b48d60c2b57d8b74ad0f30272bb578 (diff)
parent7ea326d796a6d2ecb13b961c576c82a797d84706 (diff)
downloadQt-17dc26e3e7a65b6eb0c0980a76c8fbe7bd37c690.zip
Qt-17dc26e3e7a65b6eb0c0980a76c8fbe7bd37c690.tar.gz
Qt-17dc26e3e7a65b6eb0c0980a76c8fbe7bd37c690.tar.bz2
Merge commit 'qt-mainline/4.6' into kinetic-declarativeui
Conflicts: configure.exe
Diffstat (limited to 'src/gui/widgets')
-rw-r--r--src/gui/widgets/qabstractslider.cpp39
-rw-r--r--src/gui/widgets/qabstractslider_p.h1
-rw-r--r--src/gui/widgets/qcombobox.cpp10
-rw-r--r--src/gui/widgets/qcommandlinkbutton.cpp27
-rw-r--r--src/gui/widgets/qtextedit.cpp5
-rw-r--r--src/gui/widgets/qvalidator.h4
6 files changed, 46 insertions, 40 deletions
diff --git a/src/gui/widgets/qabstractslider.cpp b/src/gui/widgets/qabstractslider.cpp
index a50c105..c3289b4 100644
--- a/src/gui/widgets/qabstractslider.cpp
+++ b/src/gui/widgets/qabstractslider.cpp
@@ -215,7 +215,8 @@ QT_BEGIN_NAMESPACE
QAbstractSliderPrivate::QAbstractSliderPrivate()
: minimum(0), maximum(99), singleStep(1), pageStep(10),
- value(0), position(0), pressValue(-1), tracking(true), blocktracking(false), pressed(false),
+ value(0), position(0), pressValue(-1), offset_accumulated(0), tracking(true),
+ blocktracking(false), pressed(false),
invertedAppearance(false), invertedControls(false),
orientation(Qt::Horizontal), repeatAction(QAbstractSlider::SliderNoAction)
{
@@ -691,38 +692,30 @@ void QAbstractSlider::wheelEvent(QWheelEvent * e)
e->ignore();
if (e->orientation() != d->orientation && !rect().contains(e->pos()))
return;
- static qreal offset = 0;
- static QAbstractSlider *offset_owner = 0;
- if (offset_owner != this){
- offset_owner = this;
- offset = 0;
- }
- // On Mac/Cocoa, always scroll one step. The mouse wheel acceleration
- // is higher than on other systems, so this works well in practice.
-#ifdef QT_MAC_USE_COCOA
- int step = 1;
-#else
int step = qMin(QApplication::wheelScrollLines() * d->singleStep, d->pageStep);
-#endif
if ((e->modifiers() & Qt::ControlModifier) || (e->modifiers() & Qt::ShiftModifier))
step = d->pageStep;
- int currentOffset = qRound(qreal(e->delta()) * step / 120);
- if (currentOffset == 0)
- currentOffset = (e->delta() < 0 ? -1 : 1);
- offset += currentOffset;
- if (d->invertedControls)
- offset = -offset;
+ qreal currentOffset = qreal(e->delta()) * step / 120;
+ d->offset_accumulated += d->invertedControls ? -currentOffset : currentOffset;
- int prevValue = d->value;
- d->position = d->overflowSafeAdd(int(offset)); // value will be updated by triggerAction()
+ if (int(d->offset_accumulated) == 0) {
+ // QAbstractSlider works on integer values. So if the accumulated
+ // offset is less than +/- 1, we need to wait until we get more
+ // wheel events (this means that the wheel resolution is higher than
+ // 15 degrees, e.g. when using mac mighty mouse/trackpad):
+ return;
+ }
+ int prevValue = d->value;
+ d->position = d->overflowSafeAdd(int(d->offset_accumulated)); // value will be updated by triggerAction()
triggerAction(SliderMove);
+
if (prevValue == d->value) {
- offset = 0;
+ d->offset_accumulated = 0;
} else {
- offset -= int(offset);
+ d->offset_accumulated -= int(d->offset_accumulated);
e->accept();
}
}
diff --git a/src/gui/widgets/qabstractslider_p.h b/src/gui/widgets/qabstractslider_p.h
index 071b8df..9324d44 100644
--- a/src/gui/widgets/qabstractslider_p.h
+++ b/src/gui/widgets/qabstractslider_p.h
@@ -69,6 +69,7 @@ public:
void setSteps(int single, int page);
int minimum, maximum, singleStep, pageStep, value, position, pressValue;
+ float offset_accumulated;
uint tracking : 1;
uint blocktracking :1;
uint pressed : 1;
diff --git a/src/gui/widgets/qcombobox.cpp b/src/gui/widgets/qcombobox.cpp
index 61532b9..95ff4c1 100644
--- a/src/gui/widgets/qcombobox.cpp
+++ b/src/gui/widgets/qcombobox.cpp
@@ -403,8 +403,8 @@ QComboBoxPrivateContainer::QComboBoxPrivateContainer(QAbstractItemView *itemView
layout->setMargin(0);
#ifdef QT_SOFTKEYS_ENABLED
- selectAction = QSoftKeyManager::createKeyedAction(QSoftKeyManager::SelectSoftKey, Qt::Key_Select, itemView);
- cancelAction = QSoftKeyManager::createKeyedAction(QSoftKeyManager::CancelSoftKey, Qt::Key_Escape, itemView);
+ selectAction = QSoftKeyManager::createKeyedAction(QSoftKeyManager::SelectSoftKey, Qt::Key_Select, this);
+ cancelAction = QSoftKeyManager::createKeyedAction(QSoftKeyManager::CancelSoftKey, Qt::Key_Escape, this);
addAction(selectAction);
addAction(cancelAction);
#endif
@@ -534,6 +534,7 @@ void QComboBoxPrivateContainer::setItemView(QAbstractItemView *itemView)
this, SLOT(setCurrentIndex(QModelIndex)));
disconnect(view, SIGNAL(destroyed()),
this, SLOT(viewDestroyed()));
+
delete view;
view = 0;
}
@@ -571,11 +572,6 @@ void QComboBoxPrivateContainer::setItemView(QAbstractItemView *itemView)
this, SLOT(setCurrentIndex(QModelIndex)));
connect(view, SIGNAL(destroyed()),
this, SLOT(viewDestroyed()));
-
-#ifdef QT_SOFTKEYS_ENABLED
- selectAction->setParent(itemView);
- cancelAction->setParent(itemView);
-#endif
}
/*!
diff --git a/src/gui/widgets/qcommandlinkbutton.cpp b/src/gui/widgets/qcommandlinkbutton.cpp
index e64f687..9adf280 100644
--- a/src/gui/widgets/qcommandlinkbutton.cpp
+++ b/src/gui/widgets/qcommandlinkbutton.cpp
@@ -140,23 +140,34 @@ QFont QCommandLinkButtonPrivate::titleFont() const
Q_Q(const QCommandLinkButton);
QFont font = q->font();
if (usingVistaStyle()) {
- if (!q->testAttribute(Qt::WA_SetFont))
- font.setPointSizeF(12.0);
+ font.setPointSizeF(12.0);
} else {
font.setBold(true);
- if (!q->testAttribute(Qt::WA_SetFont))
- font.setPointSizeF(9.0);
+ font.setPointSizeF(9.0);
}
- return font;
+
+ // Note the font will be resolved against
+ // QPainters font, so we need to restore the mask
+ int resolve_mask = font.resolve_mask;
+ QFont modifiedFont = q->font().resolve(font);
+ modifiedFont.detach();
+ modifiedFont.resolve_mask = resolve_mask;
+ return modifiedFont;
}
QFont QCommandLinkButtonPrivate::descriptionFont() const
{
Q_Q(const QCommandLinkButton);
QFont font = q->font();
- if (!q->testAttribute(Qt::WA_SetFont))
- font.setPointSizeF(9.0);
- return font;
+ font.setPointSizeF(9.0);
+
+ // Note the font will be resolved against
+ // QPainters font, so we need to restore the mask
+ int resolve_mask = font.resolve_mask;
+ QFont modifiedFont = q->font().resolve(font);
+ modifiedFont.detach();
+ modifiedFont.resolve_mask = resolve_mask;
+ return modifiedFont;
}
QRect QCommandLinkButtonPrivate::titleRect() const
diff --git a/src/gui/widgets/qtextedit.cpp b/src/gui/widgets/qtextedit.cpp
index dc78fd5..3fe9bb4 100644
--- a/src/gui/widgets/qtextedit.cpp
+++ b/src/gui/widgets/qtextedit.cpp
@@ -174,8 +174,13 @@ void QTextEditPrivate::init(const QString &html)
if (!html.isEmpty())
control->setHtml(html);
+#ifdef Q_OS_MAC
+ hbar->setSingleStep(1);
+ vbar->setSingleStep(1);
+#else
hbar->setSingleStep(20);
vbar->setSingleStep(20);
+#endif
viewport->setBackgroundRole(QPalette::Base);
q->setAcceptDrops(true);
diff --git a/src/gui/widgets/qvalidator.h b/src/gui/widgets/qvalidator.h
index 268ecaa..a0d9534 100644
--- a/src/gui/widgets/qvalidator.h
+++ b/src/gui/widgets/qvalidator.h
@@ -61,7 +61,7 @@ class Q_GUI_EXPORT QValidator : public QObject
{
Q_OBJECT
public:
- explicit QValidator(QObject * parent=0);
+ explicit QValidator(QObject * parent = 0);
~QValidator();
enum State {
@@ -100,7 +100,7 @@ class Q_GUI_EXPORT QIntValidator : public QValidator
Q_PROPERTY(int top READ top WRITE setTop)
public:
- explicit QIntValidator(QObject * parent=0);
+ explicit QIntValidator(QObject * parent = 0);
QIntValidator(int bottom, int top, QObject * parent);
~QIntValidator();