diff options
author | Bradley T. Hughes <bradley.hughes@nokia.com> | 2009-06-24 15:18:05 (GMT) |
---|---|---|
committer | Bradley T. Hughes <bradley.hughes@nokia.com> | 2009-06-24 15:18:05 (GMT) |
commit | 723dfce0f2af6d93d2c1b50f5e44ad3cf63e058c (patch) | |
tree | f8e1c8693aceea8f1d2fc03d9ad1555b0a441a27 /src/gui/widgets | |
parent | f90d8f3fe7e39a20b93a2ddfe0704bc48f3bd5f9 (diff) | |
parent | dab9d7c67ed2eda150c8da9e41db75f7eeeecd0d (diff) | |
download | Qt-723dfce0f2af6d93d2c1b50f5e44ad3cf63e058c.zip Qt-723dfce0f2af6d93d2c1b50f5e44ad3cf63e058c.tar.gz Qt-723dfce0f2af6d93d2c1b50f5e44ad3cf63e058c.tar.bz2 |
Merge branch 'master' of git@scm.dev.nokia.troll.no:qt/qt
Conflicts:
src/gui/kernel/qapplication_x11.cpp
Diffstat (limited to 'src/gui/widgets')
-rw-r--r-- | src/gui/widgets/qabstractspinbox.cpp | 4 | ||||
-rw-r--r-- | src/gui/widgets/qcocoamenu_mac_p.h | 17 | ||||
-rw-r--r-- | src/gui/widgets/qcombobox.cpp | 3 | ||||
-rw-r--r-- | src/gui/widgets/qdockarealayout.cpp | 65 | ||||
-rw-r--r-- | src/gui/widgets/qdockarealayout_p.h | 5 | ||||
-rw-r--r-- | src/gui/widgets/qdockwidget.cpp | 3 | ||||
-rw-r--r-- | src/gui/widgets/qlineedit.cpp | 11 | ||||
-rw-r--r-- | src/gui/widgets/qlineedit.h | 1 | ||||
-rw-r--r-- | src/gui/widgets/qlineedit_p.h | 1 | ||||
-rw-r--r-- | src/gui/widgets/qmainwindowlayout.cpp | 42 | ||||
-rw-r--r-- | src/gui/widgets/qmainwindowlayout_mac.mm | 18 | ||||
-rw-r--r-- | src/gui/widgets/qmainwindowlayout_p.h | 7 | ||||
-rw-r--r-- | src/gui/widgets/qspinbox.cpp | 6 |
13 files changed, 92 insertions, 91 deletions
diff --git a/src/gui/widgets/qabstractspinbox.cpp b/src/gui/widgets/qabstractspinbox.cpp index e7f7c78..25acd6e 100644 --- a/src/gui/widgets/qabstractspinbox.cpp +++ b/src/gui/widgets/qabstractspinbox.cpp @@ -1696,6 +1696,8 @@ void QAbstractSpinBoxPrivate::updateEdit() void QAbstractSpinBoxPrivate::setRange(const QVariant &min, const QVariant &max) { + Q_Q(QAbstractSpinBox); + clearCache(); minimum = min; maximum = (variantCompare(min, max) < 0 ? max : min); @@ -1707,6 +1709,8 @@ void QAbstractSpinBoxPrivate::setRange(const QVariant &min, const QVariant &max) } else if (value == minimum && !specialValueText.isEmpty()) { updateEdit(); } + + q->updateGeometry(); } /*! diff --git a/src/gui/widgets/qcocoamenu_mac_p.h b/src/gui/widgets/qcocoamenu_mac_p.h index cd53692..8eb6fba 100644 --- a/src/gui/widgets/qcocoamenu_mac_p.h +++ b/src/gui/widgets/qcocoamenu_mac_p.h @@ -56,16 +56,23 @@ QT_FORWARD_DECLARE_CLASS(QMenu) -@interface QT_MANGLE_NAMESPACE(QCocoaMenu) : NSMenu -{ - QMenu *qmenu; -} -- (id)initWithQMenu:(QMenu*)menu; +#if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_5 + +@protocol NSMenuDelegate <NSObject> - (void)menu:(NSMenu*)menu willHighlightItem:(NSMenuItem*)item; - (void)menuWillOpen:(NSMenu*)menu; - (void)menuWillClose:(NSMenu*)menu; - (BOOL)hasShortcut:(NSMenu *)menu forKey:(NSString *)key forModifiers:(NSUInteger)modifier whichItem:(NSMenuItem**)outItem; +@end + +#endif + +@interface QT_MANGLE_NAMESPACE(QCocoaMenu) : NSMenu <NSMenuDelegate> +{ + QMenu *qmenu; +} +- (id)initWithQMenu:(QMenu*)menu; - (BOOL)menuHasKeyEquivalent:(NSMenu *)menu forEvent:(NSEvent *)event target:(id *)target action:(SEL *)action; @end #endif diff --git a/src/gui/widgets/qcombobox.cpp b/src/gui/widgets/qcombobox.cpp index ad6f3db..1ca878d 100644 --- a/src/gui/widgets/qcombobox.cpp +++ b/src/gui/widgets/qcombobox.cpp @@ -59,6 +59,7 @@ #ifndef QT_NO_IM #include "qinputcontext.h" #endif +#include <private/qapplication_p.h> #include <private/qcombobox_p.h> #include <private/qabstractitemmodel_p.h> #include <private/qabstractscrollarea_p.h> @@ -77,8 +78,6 @@ #endif QT_BEGIN_NAMESPACE -extern QHash<QByteArray, QFont> *qt_app_fonts_hash(); - QComboBoxPrivate::QComboBoxPrivate() : QWidgetPrivate(), model(0), diff --git a/src/gui/widgets/qdockarealayout.cpp b/src/gui/widgets/qdockarealayout.cpp index 3125304..cbfa5bf 100644 --- a/src/gui/widgets/qdockarealayout.cpp +++ b/src/gui/widgets/qdockarealayout.cpp @@ -924,43 +924,41 @@ static int separatorMoveHelper(QVector<QLayoutStruct> &list, int index, int delt return delta; } -int QDockAreaLayoutInfo::separatorMove(int index, int delta, QVector<QLayoutStruct> *cache) +int QDockAreaLayoutInfo::separatorMove(int index, int delta) { #ifndef QT_NO_TABBAR Q_ASSERT(!tabbed); #endif - if (cache->isEmpty()) { - QVector<QLayoutStruct> &list = *cache; - list.resize(item_list.size()); - for (int i = 0; i < item_list.size(); ++i) { - const QDockAreaLayoutItem &item = item_list.at(i); - QLayoutStruct &ls = list[i]; - Q_ASSERT(!(item.flags & QDockAreaLayoutItem::GapItem)); - if (item.skip()) { - ls.empty = true; - } else { - ls.empty = false; - ls.pos = item.pos; - ls.size = item.size; - ls.minimumSize = pick(o, item.minimumSize()); - ls.maximumSize = pick(o, item.maximumSize()); - } + QVector<QLayoutStruct> list(item_list.size()); + for (int i = 0; i < list.size(); ++i) { + const QDockAreaLayoutItem &item = item_list.at(i); + QLayoutStruct &ls = list[i]; + Q_ASSERT(!(item.flags & QDockAreaLayoutItem::GapItem)); + if (item.skip()) { + ls.empty = true; + } else { + const int separatorSpace = item.hasFixedSize(o) ? 0 : sep; + ls.empty = false; + ls.pos = item.pos; + ls.size = item.size + separatorSpace; + ls.minimumSize = pick(o, item.minimumSize()) + separatorSpace; + ls.maximumSize = pick(o, item.maximumSize()) + separatorSpace; + } } - QVector<QLayoutStruct> list = *cache; - - delta = separatorMoveHelper(list, index, delta, sep); + //the separator space has been added to the size, so we pass 0 as a parameter + delta = separatorMoveHelper(list, index, delta, 0 /*separator*/); - for (int i = 0; i < item_list.size(); ++i) { + for (int i = 0; i < list.size(); ++i) { QDockAreaLayoutItem &item = item_list[i]; if (item.skip()) continue; QLayoutStruct &ls = list[i]; - item.size = ls.size; + const int separatorSpace = item.hasFixedSize(o) ? 0 : sep; + item.size = ls.size - separatorSpace; item.pos = ls.pos; - if (item.subinfo != 0) { item.subinfo->rect = itemRect(i); item.subinfo->fitItems(); @@ -1974,7 +1972,6 @@ bool QDockAreaLayoutInfo::restoreState(QDataStream &stream, QList<QDockWidget*> } else { int dummy; stream >> item.pos >> item.size >> dummy >> dummy; - // qDebug() << widget << item.pos << item.size; if (!testing) { widget->setFloating(false); widget->setVisible(flags & StateFlagVisible); @@ -3115,31 +3112,29 @@ QRegion QDockAreaLayout::separatorRegion() const } int QDockAreaLayout::separatorMove(QList<int> separator, const QPoint &origin, - const QPoint &dest, - QVector<QLayoutStruct> *cache) + const QPoint &dest) { int delta = 0; int index = separator.last(); + + if (separator.count() > 1) { QDockAreaLayoutInfo *info = this->info(separator); delta = pick(info->o, dest - origin); if (delta != 0) - delta = info->separatorMove(index, delta, cache); + delta = info->separatorMove(index, delta); info->apply(false); return delta; } - if (cache->isEmpty()) { - QVector<QLayoutStruct> &list = *cache; + QVector<QLayoutStruct> list; - if (index == QInternal::LeftDock || index == QInternal::RightDock) - getGrid(0, &list); - else - getGrid(&list, 0); - } + if (index == QInternal::LeftDock || index == QInternal::RightDock) + getGrid(0, &list); + else + getGrid(&list, 0); - QVector<QLayoutStruct> list = *cache; int sep_index = index == QInternal::LeftDock || index == QInternal::TopDock ? 0 : 1; Qt::Orientation o = index == QInternal::LeftDock || index == QInternal::RightDock diff --git a/src/gui/widgets/qdockarealayout_p.h b/src/gui/widgets/qdockarealayout_p.h index 137aeba..771aa52 100644 --- a/src/gui/widgets/qdockarealayout_p.h +++ b/src/gui/widgets/qdockarealayout_p.h @@ -181,7 +181,7 @@ public: void paintSeparators(QPainter *p, QWidget *widget, const QRegion &clip, const QPoint &mouse) const; QRegion separatorRegion() const; - int separatorMove(int index, int delta, QVector<QLayoutStruct> *cache); + int separatorMove(int index, int delta); QLayoutItem *itemAt(int *x, int index) const; QLayoutItem *takeAt(int *x, int index); @@ -277,8 +277,7 @@ public: void paintSeparators(QPainter *p, QWidget *widget, const QRegion &clip, const QPoint &mouse) const; QRegion separatorRegion() const; - int separatorMove(QList<int> separator, const QPoint &origin, const QPoint &dest, - QVector<QLayoutStruct> *cache); + int separatorMove(QList<int> separator, const QPoint &origin, const QPoint &dest); void updateSeparatorWidgets() const; QLayoutItem *itemAt(int *x, int index) const; diff --git a/src/gui/widgets/qdockwidget.cpp b/src/gui/widgets/qdockwidget.cpp index cf259fb..4350520 100644 --- a/src/gui/widgets/qdockwidget.cpp +++ b/src/gui/widgets/qdockwidget.cpp @@ -59,6 +59,7 @@ #include "qdockwidget_p.h" #include "qmainwindowlayout_p.h" #ifdef Q_WS_MAC +#include <private/qapplication_p.h> #include <private/qt_mac_p.h> #include <qmacstyle_mac.h> #endif @@ -67,8 +68,6 @@ QT_BEGIN_NAMESPACE extern QString qt_setWindowTitle_helperHelper(const QString&, const QWidget*); // qwidget.cpp -extern QHash<QByteArray, QFont> *qt_app_fonts_hash(); // qapplication.cpp - static inline bool hasFeature(const QDockWidgetPrivate *priv, QDockWidget::DockWidgetFeature feature) { return (priv->features & feature) == feature; } diff --git a/src/gui/widgets/qlineedit.cpp b/src/gui/widgets/qlineedit.cpp index ab2a7b7..c7f3e97 100644 --- a/src/gui/widgets/qlineedit.cpp +++ b/src/gui/widgets/qlineedit.cpp @@ -1550,10 +1550,7 @@ void QLineEditPrivate::copy(bool clipboard) const Q_Q(const QLineEdit); QString t = q->selectedText(); if (!t.isEmpty() && echoMode == QLineEdit::Normal) { - q->disconnect(QApplication::clipboard(), SIGNAL(selectionChanged()), q, 0); QApplication::clipboard()->setText(t, clipboard ? QClipboard::Clipboard : QClipboard::Selection); - q->connect(QApplication::clipboard(), SIGNAL(selectionChanged()), - q, SLOT(_q_clipboardChanged())); } } @@ -2689,11 +2686,11 @@ QMenu *QLineEdit::createStandardContextMenu() #ifndef QT_NO_CLIPBOARD action = popup->addAction(QLineEdit::tr("Cu&t") + ACCEL_KEY(QKeySequence::Cut)); - action->setEnabled(!d->readOnly && d->hasSelectedText()); + action->setEnabled(!d->readOnly && d->hasSelectedText() && d->echoMode == QLineEdit::Normal); connect(action, SIGNAL(triggered()), SLOT(cut())); action = popup->addAction(QLineEdit::tr("&Copy") + ACCEL_KEY(QKeySequence::Copy)); - action->setEnabled(d->hasSelectedText()); + action->setEnabled(d->hasSelectedText() && d->echoMode == QLineEdit::Normal); connect(action, SIGNAL(triggered()), SLOT(copy())); action = popup->addAction(QLineEdit::tr("&Paste") + ACCEL_KEY(QKeySequence::Paste)); @@ -2749,10 +2746,6 @@ void QLineEdit::changeEvent(QEvent *ev) QWidget::changeEvent(ev); } -void QLineEditPrivate::_q_clipboardChanged() -{ -} - void QLineEditPrivate::_q_handleWindowActivate() { Q_Q(QLineEdit); diff --git a/src/gui/widgets/qlineedit.h b/src/gui/widgets/qlineedit.h index bb75a19..a97dc9a 100644 --- a/src/gui/widgets/qlineedit.h +++ b/src/gui/widgets/qlineedit.h @@ -266,7 +266,6 @@ private: #endif Q_DISABLE_COPY(QLineEdit) Q_DECLARE_PRIVATE(QLineEdit) - Q_PRIVATE_SLOT(d_func(), void _q_clipboardChanged()) Q_PRIVATE_SLOT(d_func(), void _q_handleWindowActivate()) Q_PRIVATE_SLOT(d_func(), void _q_deleteSelected()) #ifndef QT_NO_COMPLETER diff --git a/src/gui/widgets/qlineedit_p.h b/src/gui/widgets/qlineedit_p.h index 3cb73d7..7a4ff26 100644 --- a/src/gui/widgets/qlineedit_p.h +++ b/src/gui/widgets/qlineedit_p.h @@ -216,7 +216,6 @@ public: void drag(); #endif - void _q_clipboardChanged(); void _q_handleWindowActivate(); void _q_deleteSelected(); bool userInput; diff --git a/src/gui/widgets/qmainwindowlayout.cpp b/src/gui/widgets/qmainwindowlayout.cpp index 10e07d3..526e7a5 100644 --- a/src/gui/widgets/qmainwindowlayout.cpp +++ b/src/gui/widgets/qmainwindowlayout.cpp @@ -1304,30 +1304,15 @@ bool QMainWindowLayout::separatorMove(const QPoint &pos) if (movingSeparator.isEmpty()) return false; movingSeparatorPos = pos; - separatorMoveTimer->start(); + separatorMoveTimer.start(0, this); return true; } -void QMainWindowLayout::doSeparatorMove() -{ - if (movingSeparator.isEmpty()) - return; - if (movingSeparatorOrigin == movingSeparatorPos) - return; - - layoutState = savedState; - layoutState.dockAreaLayout.separatorMove(movingSeparator, movingSeparatorOrigin, - movingSeparatorPos, - &separatorMoveCache); - movingSeparatorPos = movingSeparatorOrigin; -} - bool QMainWindowLayout::endSeparatorMove(const QPoint&) { bool result = !movingSeparator.isEmpty(); movingSeparator.clear(); savedState.clear(); - separatorMoveCache.clear(); return result; } @@ -1687,10 +1672,6 @@ QMainWindowLayout::QMainWindowLayout(QMainWindow *mainwindow) #ifndef QT_NO_TABBAR sep = mainwindow->style()->pixelMetric(QStyle::PM_DockWidgetSeparatorExtent, 0, mainwindow); #endif - separatorMoveTimer = new QTimer(this); - separatorMoveTimer->setSingleShot(true); - separatorMoveTimer->setInterval(0); - connect(separatorMoveTimer, SIGNAL(timeout()), this, SLOT(doSeparatorMove())); #ifndef QT_NO_TABWIDGET for (int i = 0; i < QInternal::DockCount; ++i) @@ -1982,6 +1963,27 @@ bool QMainWindowLayout::usesHIToolBar(QToolBar *toolbar) const #endif } +void QMainWindowLayout::timerEvent(QTimerEvent *e) +{ +#ifndef QT_NO_DOCKWIDGET + if (e->timerId() == separatorMoveTimer.timerId()) { + //let's move the separators + separatorMoveTimer.stop(); + if (movingSeparator.isEmpty()) + return; + if (movingSeparatorOrigin == movingSeparatorPos) + return; + + layoutState = savedState; + layoutState.dockAreaLayout.separatorMove(movingSeparator, movingSeparatorOrigin, + movingSeparatorPos); + movingSeparatorPos = movingSeparatorOrigin; + } +#endif + QLayout::timerEvent(e); +} + + QT_END_NAMESPACE #endif // QT_NO_MAINWINDOW diff --git a/src/gui/widgets/qmainwindowlayout_mac.mm b/src/gui/widgets/qmainwindowlayout_mac.mm index 03bae2f..6632be7 100644 --- a/src/gui/widgets/qmainwindowlayout_mac.mm +++ b/src/gui/widgets/qmainwindowlayout_mac.mm @@ -329,18 +329,16 @@ OSStatus QMainWindowLayout::qtmacToolbarDelegate(EventHandlerCallRef, EventRef e void QMainWindowLayout::updateHIToolBarStatus() { bool useMacToolbar = layoutState.mainWindow->unifiedTitleAndToolBarOnMac(); - if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_4) { #ifndef QT_MAC_USE_COCOA - if (useMacToolbar) { - ChangeWindowAttributes(qt_mac_window_for(layoutState.mainWindow), - kWindowUnifiedTitleAndToolbarAttribute, 0); - } else { - ChangeWindowAttributes(qt_mac_window_for(layoutState.mainWindow), - 0, kWindowUnifiedTitleAndToolbarAttribute); - } -#endif - macWindowToolbarShow(layoutState.mainWindow, useMacToolbar); + if (useMacToolbar) { + ChangeWindowAttributes(qt_mac_window_for(layoutState.mainWindow), + kWindowUnifiedTitleAndToolbarAttribute, 0); + } else { + ChangeWindowAttributes(qt_mac_window_for(layoutState.mainWindow), + 0, kWindowUnifiedTitleAndToolbarAttribute); } +#endif + macWindowToolbarShow(layoutState.mainWindow, useMacToolbar); layoutState.mainWindow->setUpdatesEnabled(false); // reduces a little bit of flicker, not all though if (!useMacToolbar) { diff --git a/src/gui/widgets/qmainwindowlayout_p.h b/src/gui/widgets/qmainwindowlayout_p.h index f5fcbda..26f8633 100644 --- a/src/gui/widgets/qmainwindowlayout_p.h +++ b/src/gui/widgets/qmainwindowlayout_p.h @@ -61,6 +61,7 @@ #include "QtGui/qtabbar.h" #include "QtCore/qvector.h" #include "QtCore/qset.h" +#include "QtCore/qbasictimer.h" #include "private/qlayoutengine_p.h" #include "qdockarealayout_p.h" @@ -165,6 +166,8 @@ public: void setDockOptions(QMainWindow::DockOptions opts); bool usesHIToolBar(QToolBar *toolbar) const; + void timerEvent(QTimerEvent *e); + // status bar QLayoutItem *statusbar; @@ -243,8 +246,7 @@ public: QList<int> movingSeparator; QPoint movingSeparatorOrigin, movingSeparatorPos; - QTimer *separatorMoveTimer; - QVector<QLayoutStruct> separatorMoveCache; + QBasicTimer separatorMoveTimer; bool startSeparatorMove(const QPoint &pos); bool separatorMove(const QPoint &pos); @@ -298,7 +300,6 @@ private slots: void animationFinished(QWidget *widget); void allAnimationsFinished(); #ifndef QT_NO_DOCKWIDGET - void doSeparatorMove(); #ifndef QT_NO_TABBAR void tabChanged(); #endif diff --git a/src/gui/widgets/qspinbox.cpp b/src/gui/widgets/qspinbox.cpp index 1c2ae0d..e069a21 100644 --- a/src/gui/widgets/qspinbox.cpp +++ b/src/gui/widgets/qspinbox.cpp @@ -284,6 +284,9 @@ void QSpinBox::setPrefix(const QString &prefix) d->prefix = prefix; d->updateEdit(); + + d->cachedSizeHint = QSize(); + updateGeometry(); } /*! @@ -318,6 +321,9 @@ void QSpinBox::setSuffix(const QString &suffix) d->suffix = suffix; d->updateEdit(); + + d->cachedSizeHint = QSize(); + updateGeometry(); } /*! |